-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·216 lines (174 loc) · 6.94 KB
/
install.sh
File metadata and controls
executable file
·216 lines (174 loc) · 6.94 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
#!/bin/bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
TARGET_DIR="${1:-.}"
echo "=== Specwright Installer ==="
echo "Target: $(cd "$TARGET_DIR" && pwd)"
echo ""
# --- .github/skills/ ---
echo "Installing skills..."
mkdir -p "$TARGET_DIR/.github/skills"
for skill in "$SCRIPT_DIR"/.github/skills/sw-*/; do
name=$(basename "$skill")
mkdir -p "$TARGET_DIR/.github/skills/$name"
cp "$skill/SKILL.md" "$TARGET_DIR/.github/skills/$name/SKILL.md"
done
SKILL_COUNT=$(find "$TARGET_DIR/.github/skills" -name SKILL.md 2>/dev/null | wc -l | tr -d ' ')
echo " ✓ .github/skills/ ($SKILL_COUNT skills)"
# --- .specwright/ ---
echo "Installing .specwright/..."
mkdir -p "$TARGET_DIR/.specwright/scripts"
cp "$SCRIPT_DIR/.specwright/scripts/"*.sh "$TARGET_DIR/.specwright/scripts/"
chmod +x "$TARGET_DIR/.specwright/scripts/"*.sh
echo " ✓ .specwright/scripts/"
mkdir -p "$TARGET_DIR/.specwright/templates/"{change,spike,decision}
cp "$SCRIPT_DIR/.specwright/templates/change/"* "$TARGET_DIR/.specwright/templates/change/"
cp "$SCRIPT_DIR/.specwright/templates/spike/"* "$TARGET_DIR/.specwright/templates/spike/"
cp "$SCRIPT_DIR/.specwright/templates/decision/"* "$TARGET_DIR/.specwright/templates/decision/"
cp "$SCRIPT_DIR/.specwright/templates/spec.md" "$TARGET_DIR/.specwright/templates/"
cp "$SCRIPT_DIR/.specwright/templates/COMMIT_MSG.md" "$TARGET_DIR/.specwright/templates/"
cp "$SCRIPT_DIR/.specwright/templates/PULL_REQUEST.md" "$TARGET_DIR/.specwright/templates/"
echo " ✓ .specwright/templates/"
# Hooks (source copy for reference / reinstallation)
mkdir -p "$TARGET_DIR/.specwright/hooks"
cp "$SCRIPT_DIR/.specwright/hooks/"* "$TARGET_DIR/.specwright/hooks/"
chmod +x "$TARGET_DIR/.specwright/hooks/"*
echo " ✓ .specwright/hooks/"
# --- blueprint/ ---
echo "Initialising blueprint/..."
mkdir -p "$TARGET_DIR/blueprint"/{specs,decisions,changes/{active,spikes,archive},principles}
create_if_missing() {
local file="$1" label="$2"
if [ ! -f "$file" ]; then
cat > "$file"
echo " ✓ $label (new)"
else
echo " · $label (exists, skipped)"
fi
}
create_if_missing "$TARGET_DIR/blueprint/PROJECT.md" "blueprint/PROJECT.md" << 'HEREDOC'
# [Project Name] — Project Context
## What Is This?
[2-3 sentences. What does this project do? Who is it for?]
## Current State
- [what works]
- [what's in progress]
## Tech Stack
- [language, framework, infrastructure — with versions]
## Architecture Invariants
- [rules that must NEVER be broken]
## Team & Context
- [solo dev / team size / time constraints]
## Key Entry Points
- Specs: blueprint/specs/spec.md
- Decisions: blueprint/decisions/DECISION-LOG.md
- Principles: blueprint/principles/PRINCIPLES.md
- Active work: blueprint/changes/active/
HEREDOC
create_if_missing "$TARGET_DIR/blueprint/specs/spec.md" "blueprint/specs/spec.md" << 'HEREDOC'
# System Specification
## Overview
[What does this system do, end to end?]
## Capabilities
[List capabilities with links to detailed specs]
## Cross-Cutting Concerns
- Authentication: [approach]
- Error handling: [approach]
- Logging: [approach]
## Change History
| Date | Change | Delta |
|------|--------|-------|
HEREDOC
create_if_missing "$TARGET_DIR/blueprint/decisions/DECISION-LOG.md" "blueprint/decisions/DECISION-LOG.md" << 'HEREDOC'
# Decision Log
| # | Date | Title | Status | Confidence |
|---|------|-------|--------|------------|
HEREDOC
create_if_missing "$TARGET_DIR/blueprint/principles/PRINCIPLES.md" "blueprint/principles/PRINCIPLES.md" << 'HEREDOC'
# Engineering Principles
These are the load-bearing beliefs of this project. They change rarely.
When they do change, it gets an ADR.
## P1: Tests Prove Specs
A spec without a corresponding test is an aspiration, not a requirement.
Tests are written before implementation (TDD).
## P2: Decisions Are Documented
Any architectural choice gets an ADR. "We'll remember why" is not a strategy.
## P3: Small, Reviewable Changes
Each change should be completable in a focused session.
If it can't be, break it down further.
## P4: Future-Reader Friendly
All documentation is written assuming the reader has never seen
the codebase. Avoid jargon without definition. Cross-reference liberally.
HEREDOC
create_if_missing "$TARGET_DIR/blueprint/principles/CONVENTIONS.md" "blueprint/principles/CONVENTIONS.md" << 'HEREDOC'
# Conventions
## Commits
Conventional commits: feat:, fix:, docs:, refactor:, test:
Reference ADRs when relevant: "feat: add caching (see ADR-0012)"
## Naming
- Specs: spec-[feature-name].md (kebab-case)
- ADRs: NNNN-[decision-name].md (numbered, kebab-case)
- Tests: test_[behaviour]_[expected_outcome]
- Changes: [feature-name]/ (kebab-case)
- Branches: [type]/[change-name] (e.g. feat/add-user-auth, spike/evaluate-redis)
## Code Style
[Add project-specific conventions here]
HEREDOC
create_if_missing "$TARGET_DIR/blueprint/principles/CONSTRAINTS.md" "blueprint/principles/CONSTRAINTS.md" << 'HEREDOC'
# Constraints
Hard technical limits that constrain all design decisions.
## Performance
- [e.g. API responses must be < 200ms at p99]
## Security
- [e.g. all user input must be sanitised]
## Compatibility
- [e.g. must support Node 20+]
## Infrastructure
- [e.g. single-region deployment only]
HEREDOC
# .gitignore additions
if [ -f "$TARGET_DIR/.gitignore" ]; then
if ! grep -q "specwright" "$TARGET_DIR/.gitignore" 2>/dev/null; then
echo "" >> "$TARGET_DIR/.gitignore"
echo "# Specwright scratch files" >> "$TARGET_DIR/.gitignore"
echo "blueprint/changes/active/*/scratch/" >> "$TARGET_DIR/.gitignore"
echo " ✓ .gitignore updated"
fi
fi
# --- Git hooks ---
if [ -d "$TARGET_DIR/.git" ]; then
echo "Installing git hooks..."
mkdir -p "$TARGET_DIR/.git/hooks"
for hook in "$SCRIPT_DIR/.specwright/hooks/"*; do
name=$(basename "$hook")
if [ -f "$TARGET_DIR/.git/hooks/$name" ]; then
echo " · .git/hooks/$name (exists, skipped — merge manually)"
else
cp "$hook" "$TARGET_DIR/.git/hooks/$name"
chmod +x "$TARGET_DIR/.git/hooks/$name"
echo " ✓ .git/hooks/$name"
fi
done
else
echo "Git hooks:"
echo " · No .git directory found. Run 'git init' first, then:"
echo " cp .specwright/hooks/* .git/hooks/ && chmod +x .git/hooks/*"
fi
echo ""
echo "=== Specwright installed ==="
echo ""
echo "Installed:"
echo " .github/skills/ → agent skills (slash commands)"
echo " .specwright/ → framework tooling (templates, scripts, hooks)"
echo " blueprint/ → project documentation (specs, decisions, changes)"
echo ""
echo "Next steps:"
echo " 1. Edit blueprint/PROJECT.md with your project context"
echo " 2. Edit blueprint/principles/PRINCIPLES.md with your beliefs"
echo " 3. Start working:"
echo " /sw-new-change — start a feature"
echo " /sw-new-spike — explore something"
echo " /sw-new-decision — record a decision"
echo " /sw-commit — commit and push"
echo " /sw-pr — create a PR/MR"
echo " 4. git add . && git commit -m 'chore: add specwright framework'"