-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup
More file actions
172 lines (154 loc) · 4.89 KB
/
setup
File metadata and controls
172 lines (154 loc) · 4.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
#!/usr/bin/env bash
# kstack setup — install/uninstall/verify skills for Kiro CLI
# Usage: ./setup (install)
# ./setup remove (uninstall)
# ./setup verify (check installation)
# ./setup help (show usage)
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SKILLS_DIR="$HOME/.kiro/skills"
SKILLS=(plan-product plan-eng code-review ship qa retro)
VERSION=$(cat "$SCRIPT_DIR/VERSION" 2>/dev/null || echo "unknown")
# --- Help ---
if [[ "${1:-}" == "help" || "${1:-}" == "--help" || "${1:-}" == "-h" ]]; then
echo "kstack v${VERSION} — cognitive mode skills for Kiro CLI"
echo ""
echo "Usage:"
echo " ./setup Install skills (safe to re-run)"
echo " ./setup verify Check installation health"
echo " ./setup remove Uninstall skills (keeps repo)"
echo " ./setup help Show this message"
echo ""
echo "Supported: macOS, Linux, WSL"
echo "Requires: Kiro CLI (https://kiro.dev)"
exit 0
fi
# --- Verify ---
if [[ "${1:-}" == "verify" ]]; then
echo "Verifying kstack v${VERSION}..."
ERRORS=0
# Check kiro-cli
if command -v kiro-cli &>/dev/null; then
KIRO_VER=$(kiro-cli --version 2>/dev/null || echo "unknown")
echo " ✅ kiro-cli: $KIRO_VER"
else
echo " ❌ kiro-cli not found in PATH"
ERRORS=$((ERRORS + 1))
fi
# Check skills dir
if [[ -d "$SKILLS_DIR" ]]; then
echo " ✅ skills dir: $SKILLS_DIR"
else
echo " ❌ skills dir missing: $SKILLS_DIR"
ERRORS=$((ERRORS + 1))
fi
# Check each skill
for skill in "${SKILLS[@]}"; do
dest="$SKILLS_DIR/$skill"
if [[ -L "$dest" ]]; then
target=$(readlink -f "$dest" 2>/dev/null || readlink "$dest")
if [[ -f "$target/SKILL.md" ]]; then
echo " ✅ $skill → $target"
else
echo " ❌ $skill symlink exists but SKILL.md missing at $target"
ERRORS=$((ERRORS + 1))
fi
elif [[ -d "$dest" && -f "$dest/SKILL.md" ]]; then
echo " ⚠️ $skill is a directory (not symlink) — works but won't auto-update"
else
echo " ❌ $skill not installed"
ERRORS=$((ERRORS + 1))
fi
done
echo ""
if [[ $ERRORS -eq 0 ]]; then
echo "All checks passed. ✅"
else
echo "$ERRORS issue(s) found. Run ./setup to fix."
fi
exit $ERRORS
fi
# --- Uninstall ---
if [[ "${1:-}" == "remove" ]]; then
echo "Uninstalling kstack v${VERSION}..."
REMOVED=0
for skill in "${SKILLS[@]}"; do
dest="$SKILLS_DIR/$skill"
if [[ -L "$dest" ]]; then
rm -f "$dest"
echo " ✅ removed $skill"
REMOVED=$((REMOVED + 1))
else
echo " ⏭️ $skill not a symlink, skipping"
fi
done
echo ""
if [[ $REMOVED -eq 0 ]]; then
echo "Nothing to remove — kstack was not installed."
else
echo "kstack uninstalled ($REMOVED skills removed). Repo at $SCRIPT_DIR left intact."
echo "To fully remove: rm -rf $SCRIPT_DIR"
fi
exit 0
fi
# --- Invalid argument ---
if [[ -n "${1:-}" ]]; then
echo "Unknown command: $1"
echo "Run ./setup help for usage."
exit 1
fi
# --- Install ---
# Pre-flight: check kiro-cli
if ! command -v kiro-cli &>/dev/null; then
echo "⚠️ kiro-cli not found in PATH."
echo " Install it first: https://kiro.dev"
echo " Continuing anyway (skills will be ready when kiro-cli is installed)..."
echo ""
fi
echo "Installing kstack v${VERSION}..."
mkdir -p "$SKILLS_DIR"
INSTALLED=0
SKIPPED=0
for skill in "${SKILLS[@]}"; do
src="$SCRIPT_DIR/$skill"
dest="$SKILLS_DIR/$skill"
if [[ ! -d "$src" ]]; then
echo " ⚠️ $skill not found in repo"
continue
fi
# Already correctly linked — skip
if [[ -L "$dest" ]]; then
existing=$(readlink -f "$dest" 2>/dev/null || readlink "$dest")
expected=$(cd "$src" && pwd)
if [[ "$existing" == "$expected" ]]; then
echo " ✅ $skill (already installed)"
SKIPPED=$((SKIPPED + 1))
continue
fi
rm -f "$dest"
fi
# Handle existing non-symlink directory
if [[ -e "$dest" && ! -L "$dest" ]]; then
echo " ⚠️ $skill exists as directory, backing up to ${dest}.bak"
mv "$dest" "${dest}.bak"
fi
ln -sf "$src" "$dest"
echo " ✅ $skill"
INSTALLED=$((INSTALLED + 1))
done
echo ""
if [[ $SKIPPED -eq ${#SKILLS[@]} ]]; then
echo "kstack v${VERSION}: already installed, all ${#SKILLS[@]} skills up to date."
else
echo "kstack v${VERSION}: ${INSTALLED} installed, ${SKIPPED} already up to date."
fi
echo ""
echo "Usage — tell Kiro any of these:"
echo " • plan product — rethink the problem, find the 10-star version"
echo " • plan eng — architecture, diagrams, failure modes, test matrix"
echo " • code review — paranoid review: what blows up in prod?"
echo " • ship — sync main → test → push → PR"
echo " • qa — diff-aware testing with health score"
echo " • retro — data-driven retrospective"
echo ""
echo "Run ./setup verify to confirm everything is working."