fix: correct SOURCE_KIRO path in Kiro installer (#1025)

The script lives inside .kiro/, so SCRIPT_DIR already resolves to the .kiro directory. Appending /.kiro again produced an invalid path (.kiro/.kiro) causing the installer to find no source files to copy.
This commit is contained in:
Phạm Phú Ngọc Trai 2026-04-01 04:06:11 +07:00 committed by GitHub
parent a1cebd29f7
commit a41a07363f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,139 +1,143 @@
#!/bin/bash #!/bin/bash
# #
# ECC Kiro Installer # ECC Kiro Installer
# Installs Everything Claude Code workflows into a Kiro project. # Installs Everything Claude Code workflows into a Kiro project.
# #
# Usage: # Usage:
# ./install.sh # Install to current directory # ./install.sh # Install to current directory
# ./install.sh /path/to/dir # Install to specific directory # ./install.sh /path/to/dir # Install to specific directory
# ./install.sh ~ # Install globally to ~/.kiro/ # ./install.sh ~ # Install globally to ~/.kiro/
# #
set -euo pipefail set -euo pipefail
# When globs match nothing, expand to empty list instead of the literal pattern # When globs match nothing, expand to empty list instead of the literal pattern
shopt -s nullglob shopt -s nullglob
# Resolve the directory where this script lives (the repo root) # Resolve the directory where this script lives
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SOURCE_KIRO="$SCRIPT_DIR/.kiro"
# The script lives inside .kiro/, so SCRIPT_DIR *is* the source.
# Target directory: argument or current working directory # If invoked from the repo root (e.g., .kiro/install.sh), SCRIPT_DIR already
TARGET="${1:-.}" # points to the .kiro directory — no need to append /.kiro again.
SOURCE_KIRO="$SCRIPT_DIR"
# Expand ~ to $HOME
if [ "$TARGET" = "~" ] || [[ "$TARGET" == "~/"* ]]; then # Target directory: argument or current working directory
TARGET="${TARGET/#\~/$HOME}" TARGET="${1:-.}"
fi
# Expand ~ to $HOME
# Resolve to absolute path if [ "$TARGET" = "~" ] || [[ "$TARGET" == "~/"* ]]; then
TARGET="$(cd "$TARGET" 2>/dev/null && pwd || echo "$TARGET")" TARGET="${TARGET/#\~/$HOME}"
fi
echo "ECC Kiro Installer"
echo "==================" # Resolve to absolute path
echo "" TARGET="$(cd "$TARGET" 2>/dev/null && pwd || echo "$TARGET")"
echo "Source: $SOURCE_KIRO"
echo "Target: $TARGET/.kiro/" echo "ECC Kiro Installer"
echo "" echo "=================="
echo ""
# Subdirectories to create and populate echo "Source: $SOURCE_KIRO"
SUBDIRS="agents skills steering hooks scripts settings" echo "Target: $TARGET/.kiro/"
echo ""
# Create all required .kiro/ subdirectories
for dir in $SUBDIRS; do # Subdirectories to create and populate
mkdir -p "$TARGET/.kiro/$dir" SUBDIRS="agents skills steering hooks scripts settings"
done
# Create all required .kiro/ subdirectories
# Counters for summary for dir in $SUBDIRS; do
agents=0; skills=0; steering=0; hooks=0; scripts=0; settings=0 mkdir -p "$TARGET/.kiro/$dir"
done
# Copy agents (JSON for CLI, Markdown for IDE)
if [ -d "$SOURCE_KIRO/agents" ]; then # Counters for summary
for f in "$SOURCE_KIRO/agents"/*.json "$SOURCE_KIRO/agents"/*.md; do agents=0; skills=0; steering=0; hooks=0; scripts=0; settings=0
[ -f "$f" ] || continue
local_name=$(basename "$f") # Copy agents (JSON for CLI, Markdown for IDE)
if [ ! -f "$TARGET/.kiro/agents/$local_name" ]; then if [ -d "$SOURCE_KIRO/agents" ]; then
cp "$f" "$TARGET/.kiro/agents/" 2>/dev/null || true for f in "$SOURCE_KIRO/agents"/*.json "$SOURCE_KIRO/agents"/*.md; do
agents=$((agents + 1)) [ -f "$f" ] || continue
fi local_name=$(basename "$f")
done if [ ! -f "$TARGET/.kiro/agents/$local_name" ]; then
fi cp "$f" "$TARGET/.kiro/agents/" 2>/dev/null || true
agents=$((agents + 1))
# Copy skills (directories with SKILL.md) fi
if [ -d "$SOURCE_KIRO/skills" ]; then done
for d in "$SOURCE_KIRO/skills"/*/; do fi
[ -d "$d" ] || continue
skill_name="$(basename "$d")" # Copy skills (directories with SKILL.md)
if [ ! -d "$TARGET/.kiro/skills/$skill_name" ]; then if [ -d "$SOURCE_KIRO/skills" ]; then
mkdir -p "$TARGET/.kiro/skills/$skill_name" for d in "$SOURCE_KIRO/skills"/*/; do
cp "$d"* "$TARGET/.kiro/skills/$skill_name/" 2>/dev/null || true [ -d "$d" ] || continue
skills=$((skills + 1)) skill_name="$(basename "$d")"
fi if [ ! -d "$TARGET/.kiro/skills/$skill_name" ]; then
done mkdir -p "$TARGET/.kiro/skills/$skill_name"
fi cp "$d"* "$TARGET/.kiro/skills/$skill_name/" 2>/dev/null || true
skills=$((skills + 1))
# Copy steering files (markdown) fi
if [ -d "$SOURCE_KIRO/steering" ]; then done
for f in "$SOURCE_KIRO/steering"/*.md; do fi
local_name=$(basename "$f")
if [ ! -f "$TARGET/.kiro/steering/$local_name" ]; then # Copy steering files (markdown)
cp "$f" "$TARGET/.kiro/steering/" 2>/dev/null || true if [ -d "$SOURCE_KIRO/steering" ]; then
steering=$((steering + 1)) for f in "$SOURCE_KIRO/steering"/*.md; do
fi local_name=$(basename "$f")
done if [ ! -f "$TARGET/.kiro/steering/$local_name" ]; then
fi cp "$f" "$TARGET/.kiro/steering/" 2>/dev/null || true
steering=$((steering + 1))
# Copy hooks (.kiro.hook files and README) fi
if [ -d "$SOURCE_KIRO/hooks" ]; then done
for f in "$SOURCE_KIRO/hooks"/*.kiro.hook "$SOURCE_KIRO/hooks"/*.md; do fi
[ -f "$f" ] || continue
local_name=$(basename "$f") # Copy hooks (.kiro.hook files and README)
if [ ! -f "$TARGET/.kiro/hooks/$local_name" ]; then if [ -d "$SOURCE_KIRO/hooks" ]; then
cp "$f" "$TARGET/.kiro/hooks/" 2>/dev/null || true for f in "$SOURCE_KIRO/hooks"/*.kiro.hook "$SOURCE_KIRO/hooks"/*.md; do
hooks=$((hooks + 1)) [ -f "$f" ] || continue
fi local_name=$(basename "$f")
done if [ ! -f "$TARGET/.kiro/hooks/$local_name" ]; then
fi cp "$f" "$TARGET/.kiro/hooks/" 2>/dev/null || true
hooks=$((hooks + 1))
# Copy scripts (shell scripts) and make executable fi
if [ -d "$SOURCE_KIRO/scripts" ]; then done
for f in "$SOURCE_KIRO/scripts"/*.sh; do fi
local_name=$(basename "$f")
if [ ! -f "$TARGET/.kiro/scripts/$local_name" ]; then # Copy scripts (shell scripts) and make executable
cp "$f" "$TARGET/.kiro/scripts/" 2>/dev/null || true if [ -d "$SOURCE_KIRO/scripts" ]; then
chmod +x "$TARGET/.kiro/scripts/$local_name" 2>/dev/null || true for f in "$SOURCE_KIRO/scripts"/*.sh; do
scripts=$((scripts + 1)) local_name=$(basename "$f")
fi if [ ! -f "$TARGET/.kiro/scripts/$local_name" ]; then
done cp "$f" "$TARGET/.kiro/scripts/" 2>/dev/null || true
fi chmod +x "$TARGET/.kiro/scripts/$local_name" 2>/dev/null || true
scripts=$((scripts + 1))
# Copy settings (example files) fi
if [ -d "$SOURCE_KIRO/settings" ]; then done
for f in "$SOURCE_KIRO/settings"/*; do fi
[ -f "$f" ] || continue
local_name=$(basename "$f") # Copy settings (example files)
if [ ! -f "$TARGET/.kiro/settings/$local_name" ]; then if [ -d "$SOURCE_KIRO/settings" ]; then
cp "$f" "$TARGET/.kiro/settings/" 2>/dev/null || true for f in "$SOURCE_KIRO/settings"/*; do
settings=$((settings + 1)) [ -f "$f" ] || continue
fi local_name=$(basename "$f")
done if [ ! -f "$TARGET/.kiro/settings/$local_name" ]; then
fi cp "$f" "$TARGET/.kiro/settings/" 2>/dev/null || true
settings=$((settings + 1))
# Installation summary fi
echo "Installation complete!" done
echo "" fi
echo "Components installed:"
echo " Agents: $agents" # Installation summary
echo " Skills: $skills" echo "Installation complete!"
echo " Steering: $steering" echo ""
echo " Hooks: $hooks" echo "Components installed:"
echo " Scripts: $scripts" echo " Agents: $agents"
echo " Settings: $settings" echo " Skills: $skills"
echo "" echo " Steering: $steering"
echo "Next steps:" echo " Hooks: $hooks"
echo " 1. Open your project in Kiro" echo " Scripts: $scripts"
echo " 2. Agents: Automatic in IDE, /agent swap in CLI" echo " Settings: $settings"
echo " 3. Skills: Available via / menu in chat" echo ""
echo " 4. Steering files with 'auto' inclusion load automatically" echo "Next steps:"
echo " 5. Toggle hooks in the Agent Hooks panel" echo " 1. Open your project in Kiro"
echo " 6. Copy desired MCP servers from .kiro/settings/mcp.json.example to .kiro/settings/mcp.json" echo " 2. Agents: Automatic in IDE, /agent swap in CLI"
echo " 3. Skills: Available via / menu in chat"
echo " 4. Steering files with 'auto' inclusion load automatically"
echo " 5. Toggle hooks in the Agent Hooks panel"
echo " 6. Copy desired MCP servers from .kiro/settings/mcp.json.example to .kiro/settings/mcp.json"