-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbootstrap.sh
More file actions
executable file
·147 lines (121 loc) · 4.5 KB
/
bootstrap.sh
File metadata and controls
executable file
·147 lines (121 loc) · 4.5 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
#!/bin/bash
# sdd-harness bootstrap — download and init in current repo
#
# Usage:
# curl -sSL https://github.com/iMark21/sdd-harness/raw/main/bootstrap.sh | bash -s -- --stack STACK
# curl -sSL https://github.com/iMark21/sdd-harness/raw/main/bootstrap.sh | bash -s -- --stack python
set -euo pipefail
STACK="generic"
AI_SETUP=0
GITHUB_RAW="https://raw.githubusercontent.com/iMark21/sdd-harness/main"
REPO_DIR="$(pwd)"
# Parse flags
while [ $# -gt 0 ]; do
case "$1" in
--stack) STACK="${2:-}"; shift 2 ;;
--ai-setup) AI_SETUP=1; shift ;;
*) shift ;;
esac
done
printf '=== sdd-harness bootstrap ===\n'
printf 'Repository: %s\n' "$REPO_DIR"
printf 'Stack: %s\n' "$STACK"
printf '\n'
# Check if .ai already exists
if [ -d ".ai" ]; then
printf 'WARNING: .ai/ already exists\n'
printf 'To reinitialize, run: rm -rf .ai tools .cursor .github CLAUDE.md AGENTS.md GEMINI.md\n'
exit 1
fi
# Create directories
mkdir -p .ai/specs/acceptance
mkdir -p .ai/adrs
mkdir -p .ai/commands
mkdir -p .ai/agents
mkdir -p .ai/notes
mkdir -p .ai/hooks
mkdir -p tools/ci
printf '→ Downloading templates...\n'
# Download .ai files
for file in PRODUCT.md CONTEXT.md BACKLOG.md ROUTING.md README.md BOOTSTRAP.md; do
curl -fsSL "$GITHUB_RAW/templates/.ai/$file" -o ".ai/$file"
done
# Download commands
for cmd in spec.md story.md implement.md verify.md review.md release.md phase-close.md; do
curl -fsSL "$GITHUB_RAW/templates/.ai/commands/$cmd" -o ".ai/commands/$cmd"
done
# Download specs
for spec in PRD.md glossary.md; do
curl -fsSL "$GITHUB_RAW/templates/.ai/specs/$spec" -o ".ai/specs/$spec"
done
# Download ADRs
for adr in 0008-runtime-agnostic-ai-layer.md 0009-ci-stack-plugins.md; do
curl -fsSL "$GITHUB_RAW/templates/.ai/adrs/$adr" -o ".ai/adrs/$adr"
done
# Download agents
curl -fsSL "$GITHUB_RAW/templates/.ai/agents/spec-writer.md" -o ".ai/agents/spec-writer.md"
# Download notes
for note in governance-mirror.md spec-driven-development.md; do
curl -fsSL "$GITHUB_RAW/templates/.ai/notes/$note" -o ".ai/notes/$note"
done
# Download hooks
for hook in pre-commit-spec-check.sh post-edit-trace.sh install.sh config.sh; do
curl -fsSL "$GITHUB_RAW/templates/.ai/hooks/$hook" -o ".ai/hooks/$hook"
chmod +x ".ai/hooks/$hook"
done
# Download tools/ci
curl -fsSL "$GITHUB_RAW/templates/tools/ci.sh" -o "tools/ci.sh"
chmod +x "tools/ci.sh"
for plugin in common.sh swift.sh python.sh js.sh go.sh generic.sh; do
curl -fsSL "$GITHUB_RAW/templates/tools/ci/$plugin" -o "tools/ci/$plugin"
chmod +x "tools/ci/$plugin"
done
# Download bootloaders
for bootloader in CLAUDE.md AGENTS.md GEMINI.md; do
curl -fsSL "$GITHUB_RAW/templates/$bootloader" -o "$bootloader"
done
printf '→ Substituting placeholders...\n'
# Get project name and branch
PROJECT_NAME=$(basename "$(pwd)")
BRANCH=$(git symbolic-ref --short -q HEAD 2>/dev/null || echo "develop")
# Substitute placeholders
STORY_PREFIX=$(printf '%s' "$PROJECT_NAME" | tr 'a-z' 'A-Z' | tr -cd 'A-Z' | cut -c1-3)
[ -z "$STORY_PREFIX" ] && STORY_PREFIX="X"
TODAY=$(date +%Y-%m-%d)
for file in .ai/PRODUCT.md .ai/CONTEXT.md .ai/BACKLOG.md .ai/BOOTSTRAP.md .ai/specs/PRD.md .ai/specs/glossary.md; do
sed -i.bak \
-e "s/{{PROJECT_NAME}}/$PROJECT_NAME/g" \
-e "s/{{STORY_PREFIX}}/$STORY_PREFIX/g" \
-e "s/{{TODAY}}/$TODAY/g" \
-e "s/{{GIT_BRANCH}}/$BRANCH/g" \
-e "s/{{STACK}}/$STACK/g" \
"$file"
rm -f "${file}.bak"
done
printf '→ Installing hooks...\n'
cd .ai/hooks && bash install.sh && cd ../..
printf '\n=== Done ===\n'
if [ "$AI_SETUP" -eq 1 ]; then
printf '→ Downloading AI-assisted bootstrap prompt...\n'
curl -fsSL "$GITHUB_RAW/assistant-installer/PROMPT.md" -o ".ai/BOOTSTRAP-AI.md"
printf '\n=== sdd-harness ready for AI-guided bootstrap ===\n'
printf '\nOpen .ai/BOOTSTRAP-AI.md with your AI:\n'
printf ' - Claude Code\n'
printf ' - Cursor\n'
printf ' - Copilot CLI\n'
printf ' - Any AI with repo access\n'
printf '\nThe AI will:\n'
printf ' 1. Audit your repository\n'
printf ' 2. Fill PRODUCT.md (vision & goals)\n'
printf ' 3. Migrate README TODOs → BACKLOG.md\n'
printf ' 4. Initialize CONTEXT.md\n'
printf '\nThen delete .ai/BOOTSTRAP-AI.md when done.\n'
else
printf 'Next steps:\n'
printf ' 1. cat .ai/BOOTSTRAP.md (manual bootstrap)\n'
printf ' 2. bash tools/ci.sh --list (verify CI)\n'
printf ' 3. Read .ai/ROUTING.md\n'
printf '\nOr run with --ai-setup for AI-guided setup:\n'
printf ' curl -sSL ... | bash -s -- --stack %s --ai-setup\n' "$STACK"
fi
printf '\nAll files downloaded to: %s\n' "$REPO_DIR"