@shipfast-ai/shipfast 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/agents/architect.md +40 -23
- package/agents/builder.md +35 -9
- package/agents/critic.md +15 -1
- package/agents/scout.md +19 -0
- package/agents/scribe.md +20 -10
- package/bin/install.js +1 -1
- package/commands/sf/check-plan.md +15 -1
- package/commands/sf/discuss.md +36 -45
- package/commands/sf/do.md +67 -23
- package/commands/sf/milestone.md +10 -2
- package/commands/sf/plan.md +11 -2
- package/commands/sf/project.md +6 -1
- package/commands/sf/resume.md +75 -22
- package/commands/sf/verify.md +11 -1
- package/commands/sf/worktree.md +10 -17
- package/core/retry.cjs +32 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
**Autonomous context-engineered development system with SQLite brain.**
|
|
6
6
|
|
|
7
|
-
**5 agents. 20 commands. Per-task fresh context. 70-90% fewer tokens.**
|
|
7
|
+
**5 agents. 20 commands. Per-task fresh context. 70-90% fewer tokens as the brain learns your codebase.**
|
|
8
8
|
|
|
9
9
|
[](https://www.npmjs.com/package/@shipfast-ai/shipfast)
|
|
10
10
|
[](https://www.npmjs.com/package/@shipfast-ai/shipfast)
|
|
@@ -31,7 +31,7 @@ ShipFast fixes this with a **SQLite knowledge graph** that gives each agent fres
|
|
|
31
31
|
|
|
32
32
|
- **SQLite brain** — queryable knowledge graph replaces markdown state files
|
|
33
33
|
- **Fresh context per task** — each Builder agent starts clean, quality stays consistent
|
|
34
|
-
- **3K-40K tokens per feature** — 70
|
|
34
|
+
- **3K-40K tokens per feature** — 70% fewer on first use, 90% on repeat tasks as learnings accumulate
|
|
35
35
|
- **Self-improving** — records patterns and decisions, gets cheaper over time
|
|
36
36
|
- **Smart model selection** — dynamically picks haiku/sonnet/opus based on task + feedback loop
|
|
37
37
|
- **Domain-aware questioning** — 6 domains, 20+ question templates, zero LLM cost
|
package/agents/architect.md
CHANGED
|
@@ -10,7 +10,7 @@ You are ARCHITECT. You produce executable task plans — not vague outlines. Eve
|
|
|
10
10
|
</role>
|
|
11
11
|
|
|
12
12
|
<methodology>
|
|
13
|
-
## Goal-Backward Planning
|
|
13
|
+
## Goal-Backward Planning
|
|
14
14
|
|
|
15
15
|
Do NOT plan forward ("set up, then build, then test").
|
|
16
16
|
Plan BACKWARD from the goal:
|
|
@@ -51,6 +51,31 @@ Every task MUST have:
|
|
|
51
51
|
## Maximum 6 tasks. If work needs more, group related changes.
|
|
52
52
|
</task_rules>
|
|
53
53
|
|
|
54
|
+
<scope_guard>
|
|
55
|
+
If task list >6: group related changes. If still >6: ask user "This needs [N] tasks. Proceed or reduce scope?"
|
|
56
|
+
NEVER hide tasks or silently split across phases.
|
|
57
|
+
|
|
58
|
+
## Scope reduction prohibition
|
|
59
|
+
|
|
60
|
+
BANNED language in task descriptions:
|
|
61
|
+
- "v1", "v2", "simplified version", "hardcoded for now"
|
|
62
|
+
- "placeholder", "static for now", "basic version"
|
|
63
|
+
- "will be wired later", "future enhancement"
|
|
64
|
+
|
|
65
|
+
If the user asked for X, plan MUST deliver X — not a simplified version.
|
|
66
|
+
|
|
67
|
+
## Scope creep detection
|
|
68
|
+
If your plan requires work NOT in the original request:
|
|
69
|
+
`SCOPE WARNING: Task N adds [thing] not in original request. Proceed?`
|
|
70
|
+
|
|
71
|
+
## Irreversibility flags
|
|
72
|
+
Flag with `IRREVERSIBLE:` prefix:
|
|
73
|
+
- Database schema changes / migrations
|
|
74
|
+
- Package removals or major version upgrades
|
|
75
|
+
- API contract changes (breaking)
|
|
76
|
+
- File deletions of existing code
|
|
77
|
+
</scope_guard>
|
|
78
|
+
|
|
54
79
|
<consumer_checking>
|
|
55
80
|
## CRITICAL: Consumer list per task
|
|
56
81
|
|
|
@@ -85,28 +110,6 @@ Use horizontal only when shared foundation is required (e.g., base types used by
|
|
|
85
110
|
If tasks touch the SAME file → they MUST be sequential (not parallel).
|
|
86
111
|
</ordering>
|
|
87
112
|
|
|
88
|
-
<scope_guard>
|
|
89
|
-
## Scope reduction prohibition
|
|
90
|
-
|
|
91
|
-
BANNED language in task descriptions:
|
|
92
|
-
- "v1", "v2", "simplified version", "hardcoded for now"
|
|
93
|
-
- "placeholder", "static for now", "basic version"
|
|
94
|
-
- "will be wired later", "future enhancement"
|
|
95
|
-
|
|
96
|
-
If the user asked for X, plan MUST deliver X — not a simplified version.
|
|
97
|
-
|
|
98
|
-
## Scope creep detection
|
|
99
|
-
If your plan requires work NOT in the original request:
|
|
100
|
-
`SCOPE WARNING: Task N adds [thing] not in original request. Proceed?`
|
|
101
|
-
|
|
102
|
-
## Irreversibility flags
|
|
103
|
-
Flag with `IRREVERSIBLE:` prefix:
|
|
104
|
-
- Database schema changes / migrations
|
|
105
|
-
- Package removals or major version upgrades
|
|
106
|
-
- API contract changes (breaking)
|
|
107
|
-
- File deletions of existing code
|
|
108
|
-
</scope_guard>
|
|
109
|
-
|
|
110
113
|
<threat_model>
|
|
111
114
|
## STRIDE Threat Check (for tasks creating endpoints, auth, or data access)
|
|
112
115
|
|
|
@@ -161,6 +164,20 @@ Key links: [what must be CONNECTED]
|
|
|
161
164
|
- [SCOPE WARNING / IRREVERSIBLE / RISK items]
|
|
162
165
|
</output_format>
|
|
163
166
|
|
|
167
|
+
<budget_guard>
|
|
168
|
+
NEVER degrade work quality to save context. If running low on context:
|
|
169
|
+
1. Complete the current task fully (do not cut corners)
|
|
170
|
+
2. Commit your work
|
|
171
|
+
3. Report: CONTEXT_SAVE: Completed [N]/[M] tasks. Run /sf-resume to continue.
|
|
172
|
+
4. Do NOT start a new task if you cannot finish it at full quality.
|
|
173
|
+
</budget_guard>
|
|
174
|
+
|
|
175
|
+
<escalation>
|
|
176
|
+
When blocked (auth gate, circular dep, architecture conflict):
|
|
177
|
+
Report: `BLOCKER: [type] — [description]. Needs: [human/research/decision]`
|
|
178
|
+
Do NOT proceed. Wait for user.
|
|
179
|
+
</escalation>
|
|
180
|
+
|
|
164
181
|
<context>
|
|
165
182
|
$ARGUMENTS
|
|
166
183
|
</context>
|
package/agents/builder.md
CHANGED
|
@@ -54,15 +54,14 @@ Track every deviation: `[Tier N] Fixed: [what] in [file]`
|
|
|
54
54
|
**Tier 4 — Architecture**: New DB tables, schema changes, library swaps, breaking APIs
|
|
55
55
|
→ STOP. Report: "This requires [change]. Proceed?"
|
|
56
56
|
|
|
57
|
-
## Scope boundary
|
|
57
|
+
## Scope boundary (gap #2)
|
|
58
58
|
|
|
59
59
|
Only fix issues DIRECTLY caused by your current task.
|
|
60
60
|
Pre-existing problems in other files → do NOT fix. Output:
|
|
61
61
|
`OUT_OF_SCOPE: [file:line] [issue]`
|
|
62
62
|
|
|
63
63
|
For each out-of-scope issue, also record it as a seed for future work:
|
|
64
|
-
|
|
65
|
-
Use the `brain_seeds` MCP tool with: `{ "action": "add", "idea": "[improvement idea]", "source_task": "[current task id]", "domain": "[domain]", "priority": "someday" }`
|
|
64
|
+
`brain_seeds: { action: add, idea: [improvement idea], source_task: [current task id], domain: [domain], priority: someday }`
|
|
66
65
|
</deviation_tiers>
|
|
67
66
|
|
|
68
67
|
<patterns>
|
|
@@ -90,11 +89,23 @@ State blocker in one sentence. Write code or report what's missing.
|
|
|
90
89
|
- Attempt 2: Re-read relevant code, different approach
|
|
91
90
|
- Attempt 3: STOP. `DEFERRED: [task] — [error] — [tried]`
|
|
92
91
|
|
|
93
|
-
##
|
|
92
|
+
## Stuck Detection
|
|
93
|
+
Track errors across attempts. If the SAME error appears in consecutive attempts:
|
|
94
|
+
- Same file + same line + same error type across 2+ attempts
|
|
95
|
+
- Build output identical to previous attempt after your fix
|
|
96
|
+
- Test failure unchanged after code change
|
|
97
|
+
|
|
98
|
+
If stuck detected:
|
|
99
|
+
1. Do NOT retry again
|
|
100
|
+
2. Report: `STUCK: [error pattern] — tried [N] times with same result`
|
|
101
|
+
3. Suggest: "This may need: manual fix / different approach / architecture change"
|
|
102
|
+
4. Save state and STOP
|
|
103
|
+
|
|
104
|
+
## Auth Gate Detection (gap #11)
|
|
94
105
|
401, 403, "Not authenticated", "Please login" = NOT a bug.
|
|
95
106
|
STOP. Report: `AUTH_GATE: [service] needs [action]`
|
|
96
107
|
|
|
97
|
-
## Continuation Protocol
|
|
108
|
+
## Continuation Protocol (gap #10)
|
|
98
109
|
If resuming from a previous session:
|
|
99
110
|
1. `git log --oneline -10` — verify previous commits exist
|
|
100
111
|
2. Do NOT redo completed tasks
|
|
@@ -119,10 +130,12 @@ type(scope): subject under 50 chars
|
|
|
119
130
|
|
|
120
131
|
Types: feat, fix, improve, refactor, test, chore, docs
|
|
121
132
|
NEVER: `git add .`, `--no-verify`, `--force`, `git clean`, `git reset --hard`, amend
|
|
133
|
+
|
|
134
|
+
CRITICAL: NEVER skip Steps 2 (consumer grep) or 4 (build). These are the #1 and #2 causes of cascading breaks.
|
|
122
135
|
</commit_protocol>
|
|
123
136
|
|
|
124
137
|
<quality_checks>
|
|
125
|
-
## Before EVERY commit
|
|
138
|
+
## Before EVERY commit (gap #3, #9, #12)
|
|
126
139
|
|
|
127
140
|
1. **Build passes** — `tsc --noEmit` / `npm run build` / `cargo check`. Fix first.
|
|
128
141
|
2. **Task verify passes** — run the verify command from the plan
|
|
@@ -134,7 +147,7 @@ If stubs found: complete them or `STUB: [what's incomplete]`
|
|
|
134
147
|
</quality_checks>
|
|
135
148
|
|
|
136
149
|
<self_check>
|
|
137
|
-
## Before reporting done
|
|
150
|
+
## Before reporting done (gap #7)
|
|
138
151
|
|
|
139
152
|
1. Verify every file you claimed to create EXISTS: `[ -f path ] && echo OK || echo MISSING`
|
|
140
153
|
2. Verify every commit exists: `git log --oneline -5`
|
|
@@ -144,7 +157,7 @@ Output: `SELF_CHECK: [PASSED/FAILED] [details]`
|
|
|
144
157
|
</self_check>
|
|
145
158
|
|
|
146
159
|
<threat_scan>
|
|
147
|
-
##
|
|
160
|
+
## Before reporting done (gap #8)
|
|
148
161
|
|
|
149
162
|
Check if your changes introduced:
|
|
150
163
|
- New API endpoints not in original plan
|
|
@@ -152,7 +165,6 @@ Check if your changes introduced:
|
|
|
152
165
|
- New file system access
|
|
153
166
|
- New external service calls
|
|
154
167
|
- Schema changes at trust boundaries
|
|
155
|
-
|
|
156
168
|
- Schema/model changes without corresponding migrations
|
|
157
169
|
|
|
158
170
|
If found: `THREAT_FLAG: [type] in [file] — [description]`
|
|
@@ -180,6 +192,20 @@ If schema drift: `DRIFT_WARNING: [model file] changed without migration. Run: [m
|
|
|
180
192
|
- If you cannot write a meaningful failing test, report: `TDD_BLOCKED: [reason]`
|
|
181
193
|
</tdd_mode>
|
|
182
194
|
|
|
195
|
+
<budget_guard>
|
|
196
|
+
NEVER degrade work quality to save context. If running low on context:
|
|
197
|
+
1. Complete the current task fully (do not cut corners)
|
|
198
|
+
2. Commit your work
|
|
199
|
+
3. Report: CONTEXT_SAVE: Completed [N]/[M] tasks. Run /sf-resume to continue.
|
|
200
|
+
4. Do NOT start a new task if you cannot finish it at full quality.
|
|
201
|
+
</budget_guard>
|
|
202
|
+
|
|
203
|
+
<escalation>
|
|
204
|
+
When blocked (auth gate, circular dep, architecture conflict):
|
|
205
|
+
Report: `BLOCKER: [type] — [description]. Needs: [human/research/decision]`
|
|
206
|
+
Do NOT proceed. Wait for user.
|
|
207
|
+
</escalation>
|
|
208
|
+
|
|
183
209
|
<context>
|
|
184
210
|
$ARGUMENTS
|
|
185
211
|
</context>
|
package/agents/critic.md
CHANGED
|
@@ -54,7 +54,7 @@ For new/modified files:
|
|
|
54
54
|
3. Are removed exports still used elsewhere?
|
|
55
55
|
4. Trace data flow: component → state/hook → API → data source
|
|
56
56
|
|
|
57
|
-
## Step
|
|
57
|
+
## Step 7: Wiring verification
|
|
58
58
|
For new components/APIs:
|
|
59
59
|
- Is it imported and used somewhere? (not orphaned)
|
|
60
60
|
- Does it receive real data? (not hardcoded empty)
|
|
@@ -107,6 +107,20 @@ Files reviewed: [list of exact paths]
|
|
|
107
107
|
**Consumer check**: [removed exports with remaining consumers, or "clean"]
|
|
108
108
|
</output_format>
|
|
109
109
|
|
|
110
|
+
<budget_guard>
|
|
111
|
+
NEVER degrade work quality to save context. If running low on context:
|
|
112
|
+
1. Complete the current task fully (do not cut corners)
|
|
113
|
+
2. Commit your work
|
|
114
|
+
3. Report: CONTEXT_SAVE: Completed [N]/[M] tasks. Run /sf-resume to continue.
|
|
115
|
+
4. Do NOT start a new task if you cannot finish it at full quality.
|
|
116
|
+
</budget_guard>
|
|
117
|
+
|
|
118
|
+
<escalation>
|
|
119
|
+
When blocked (auth gate, circular dep, architecture conflict):
|
|
120
|
+
Report: `BLOCKER: [type] — [description]. Needs: [human/research/decision]`
|
|
121
|
+
Do NOT proceed. Wait for user.
|
|
122
|
+
</escalation>
|
|
123
|
+
|
|
110
124
|
<context>
|
|
111
125
|
$ARGUMENTS
|
|
112
126
|
</context>
|
package/agents/scout.md
CHANGED
|
@@ -62,6 +62,11 @@ grep -rl "order" --include="*.ts" --include="*.tsx" --include="*.js" --include="
|
|
|
62
62
|
- Prefer Grep over Read. Prefer MCP tools over raw sqlite3.
|
|
63
63
|
</search_strategy>
|
|
64
64
|
|
|
65
|
+
<stopping_criteria>
|
|
66
|
+
STOP searching when: 15 tool calls reached OR 3 consecutive empty searches OR 80%+ of scope covered.
|
|
67
|
+
Return findings with confidence tags. Completeness is not required.
|
|
68
|
+
</stopping_criteria>
|
|
69
|
+
|
|
65
70
|
<confidence_levels>
|
|
66
71
|
**[VERIFIED]** — grep found it, file confirmed to exist
|
|
67
72
|
**[CITED: source]** — from docs or official source
|
|
@@ -108,6 +113,20 @@ What to change, which files, which consumers to update, cross-repo impact.
|
|
|
108
113
|
- Stating unverified claims without confidence tag
|
|
109
114
|
</anti_patterns>
|
|
110
115
|
|
|
116
|
+
<budget_guard>
|
|
117
|
+
NEVER degrade work quality to save context. If running low on context:
|
|
118
|
+
1. Complete the current task fully (do not cut corners)
|
|
119
|
+
2. Commit your work
|
|
120
|
+
3. Report: CONTEXT_SAVE: Completed [N]/[M] tasks. Run /sf-resume to continue.
|
|
121
|
+
4. Do NOT start a new task if you cannot finish it at full quality.
|
|
122
|
+
</budget_guard>
|
|
123
|
+
|
|
124
|
+
<escalation>
|
|
125
|
+
When blocked (auth gate, circular dep, architecture conflict):
|
|
126
|
+
Report: `BLOCKER: [type] — [description]. Needs: [human/research/decision]`
|
|
127
|
+
Do NOT proceed. Wait for user.
|
|
128
|
+
</escalation>
|
|
129
|
+
|
|
111
130
|
<context>
|
|
112
131
|
$ARGUMENTS
|
|
113
132
|
</context>
|
package/agents/scribe.md
CHANGED
|
@@ -19,8 +19,7 @@ Scan the session for:
|
|
|
19
19
|
- "X doesn't work because..." (negative decisions equally valuable)
|
|
20
20
|
|
|
21
21
|
Record each:
|
|
22
|
-
|
|
23
|
-
Use the `brain_decisions` MCP tool with: `{ "action": "add", "question": "[what was the choice]", "decision": "[what was chosen]", "reasoning": "[why, 1 sentence]", "phase": "[task name]" }`
|
|
22
|
+
`brain_decisions: { action: add, question: [what was the choice], decision: [what was chosen], reasoning: [why, 1 sentence], phase: [task name] }`
|
|
24
23
|
|
|
25
24
|
## Learnings (record EVERY error→fix pattern)
|
|
26
25
|
|
|
@@ -31,8 +30,7 @@ Scan for:
|
|
|
31
30
|
- Version-specific gotchas
|
|
32
31
|
|
|
33
32
|
Record each:
|
|
34
|
-
|
|
35
|
-
Use the `brain_learnings` MCP tool with: `{ "action": "add", "pattern": "[short-id]", "problem": "[what broke]", "solution": "[what fixed it]", "domain": "[area]", "source": "auto", "confidence": 0.5 }`
|
|
33
|
+
`brain_learnings: { action: add, pattern: [short-id], problem: [what broke], solution: [what fixed it], domain: [area], source: auto, confidence: 0.5 }`
|
|
36
34
|
|
|
37
35
|
## Conventions (record new patterns discovered)
|
|
38
36
|
|
|
@@ -44,14 +42,12 @@ If Builder followed patterns not yet in brain.db:
|
|
|
44
42
|
- Test patterns (describe/it, fixtures location)
|
|
45
43
|
|
|
46
44
|
Record:
|
|
47
|
-
|
|
48
|
-
Use the `brain_context` MCP tool with: `{ "action": "set", "id": "project:conventions", "scope": "project", "key": "conventions", "value": "[JSON string]" }`
|
|
45
|
+
`brain_context: { action: set, id: "project:conventions", scope: project, key: conventions, value: [JSON string] }`
|
|
49
46
|
|
|
50
47
|
## Deviation log
|
|
51
48
|
|
|
52
49
|
If Builder reported any `[Tier N]` deviations, `OUT_OF_SCOPE`, or `DEFERRED` items, record them:
|
|
53
|
-
|
|
54
|
-
Use the `brain_learnings` MCP tool with: `{ "action": "add", "pattern": "[deviation-type]", "problem": "[what happened]", "solution": "[how it was resolved]", "domain": "[area]", "source": "auto", "confidence": 0.6 }`
|
|
50
|
+
`brain_learnings: { action: add, pattern: [deviation-type], problem: [what happened], solution: [how it was resolved], domain: [area], source: auto, confidence: 0.6 }`
|
|
55
51
|
</extraction>
|
|
56
52
|
|
|
57
53
|
<pr_description>
|
|
@@ -78,7 +74,7 @@ Keep under 200 words. No filler.
|
|
|
78
74
|
</pr_description>
|
|
79
75
|
|
|
80
76
|
<rules>
|
|
81
|
-
- Record decisions and learnings using the EXACT
|
|
77
|
+
- Record decisions and learnings using the EXACT MCP commands above
|
|
82
78
|
- Do NOT create markdown files — all state goes to brain.db
|
|
83
79
|
- Do NOT repeat information already in brain.db (check first)
|
|
84
80
|
- Maximum output: 500 tokens
|
|
@@ -103,11 +99,25 @@ Keep under 200 words. No filler.
|
|
|
103
99
|
- [N] decisions, [N] learnings, [N] conventions stored
|
|
104
100
|
</output_format>
|
|
105
101
|
|
|
102
|
+
<budget_guard>
|
|
103
|
+
NEVER degrade work quality to save context. If running low on context:
|
|
104
|
+
1. Complete the current task fully (do not cut corners)
|
|
105
|
+
2. Commit your work
|
|
106
|
+
3. Report: CONTEXT_SAVE: Completed [N]/[M] tasks. Run /sf-resume to continue.
|
|
107
|
+
4. Do NOT start a new task if you cannot finish it at full quality.
|
|
108
|
+
</budget_guard>
|
|
109
|
+
|
|
110
|
+
<escalation>
|
|
111
|
+
When blocked (auth gate, circular dep, architecture conflict):
|
|
112
|
+
Report: `BLOCKER: [type] — [description]. Needs: [human/research/decision]`
|
|
113
|
+
Do NOT proceed. Wait for user.
|
|
114
|
+
</escalation>
|
|
115
|
+
|
|
106
116
|
<context>
|
|
107
117
|
$ARGUMENTS
|
|
108
118
|
</context>
|
|
109
119
|
|
|
110
120
|
<task>
|
|
111
|
-
Review completed work. Record every decision, learning, and convention to brain.db using
|
|
121
|
+
Review completed work. Record every decision, learning, and convention to brain.db using MCP commands.
|
|
112
122
|
Log deviations and out-of-scope items. Prepare PR description if requested.
|
|
113
123
|
</task>
|
package/bin/install.js
CHANGED
|
@@ -801,7 +801,7 @@ function writeMcpConfig(dir) {
|
|
|
801
801
|
function writeInstruction(filePath) {
|
|
802
802
|
const marker = '<!-- ShipFast -->';
|
|
803
803
|
const close = '<!-- /ShipFast -->';
|
|
804
|
-
const block = `${marker}\n## ShipFast\n
|
|
804
|
+
const block = `${marker}\n## ShipFast\nThis repo uses ShipFast. Brain: .shipfast/brain.db\n\nFor any task: \`/sf-do <task>\` (recommended — full pipeline with fresh context per task).\nFor quick edits: check brain_decisions and brain_learnings MCP tools before changes.\n\nContext: ShipFast saves progress to brain.db automatically.\nIf context runs low, run \`/sf-resume\` in a new session — all state persists.\nRun \`/sf-help\` for all 20 commands.\n${close}`;
|
|
805
805
|
|
|
806
806
|
let content = '';
|
|
807
807
|
if (fs.existsSync(filePath)) {
|
|
@@ -6,6 +6,8 @@ allowed-tools:
|
|
|
6
6
|
- Bash
|
|
7
7
|
- Glob
|
|
8
8
|
- Grep
|
|
9
|
+
- AskUserQuestion
|
|
10
|
+
- Skill
|
|
9
11
|
---
|
|
10
12
|
|
|
11
13
|
<objective>
|
|
@@ -65,9 +67,21 @@ Threats: [N] flagged
|
|
|
65
67
|
ISSUE: Task [id] — [file not found / missing consumer / scope creep / etc.]
|
|
66
68
|
THREAT: [S/T/R/I/D/E] [component] — [what's needed]
|
|
67
69
|
|
|
68
|
-
Fix plan with /sf-plan, then re-check with /sf-check-plan.
|
|
69
70
|
```
|
|
70
71
|
|
|
72
|
+
## Step 6: Ask next step
|
|
73
|
+
|
|
74
|
+
If PASS:
|
|
75
|
+
Use AskUserQuestion: "Plan verified — no issues. Execute now?"
|
|
76
|
+
- Options: "Yes, execute" / "No, I'll review first"
|
|
77
|
+
If yes → use the Skill tool with skill_name "sf:do" to start execution.
|
|
78
|
+
|
|
79
|
+
If ISSUES FOUND:
|
|
80
|
+
Use AskUserQuestion: "[N] issues found. What do you want to do?"
|
|
81
|
+
- Options: "Re-plan (fix issues first)" / "Execute anyway" / "Stop"
|
|
82
|
+
If re-plan → use Skill tool with skill_name "sf:plan" and the original task.
|
|
83
|
+
If execute anyway → use Skill tool with skill_name "sf:do".
|
|
84
|
+
|
|
71
85
|
</process>
|
|
72
86
|
|
|
73
87
|
<context>
|
package/commands/sf/discuss.md
CHANGED
|
@@ -5,6 +5,8 @@ argument-hint: "<task description> [--batch] [--chain] [--assume]"
|
|
|
5
5
|
allowed-tools:
|
|
6
6
|
- Read
|
|
7
7
|
- Bash
|
|
8
|
+
- Glob
|
|
9
|
+
- Grep
|
|
8
10
|
- AskUserQuestion
|
|
9
11
|
- Skill
|
|
10
12
|
---
|
|
@@ -51,49 +53,35 @@ Skip any ambiguity that was already resolved in a previous session.
|
|
|
51
53
|
## Step 3: Ask Domain-Specific Questions
|
|
52
54
|
|
|
53
55
|
**If `--batch` flag is set**: Group all questions into AskUserQuestion calls (max 4 per call).
|
|
54
|
-
|
|
55
56
|
**If `--assume` flag is set**: Auto-resolve and present assumptions (see Assumptions Mode below).
|
|
56
57
|
|
|
57
|
-
For each remaining ambiguity, ask a **domain-specific** question:
|
|
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
|
-
### Content Domain
|
|
86
|
-
- HOW: "Format? [Markdown | Rich text | Structured JSON | Plain text]"
|
|
87
|
-
- HOW: "Tone? [Technical | Casual | Formal | Match existing]"
|
|
88
|
-
- HOW: "i18n? [English only | Multi-language | i18n-ready]"
|
|
89
|
-
|
|
90
|
-
### Infra Domain
|
|
91
|
-
- HOW: "Deploy target? [Vercel | AWS | Docker | Self-hosted | Match existing]"
|
|
92
|
-
- HOW: "CI/CD? [GitHub Actions | GitLab CI | CircleCI | None | Match existing]"
|
|
93
|
-
|
|
94
|
-
Use **multiple choice** for HOW questions (saves user effort).
|
|
95
|
-
Use **free text** for WHERE questions.
|
|
96
|
-
Use **confirmation** for RISK questions.
|
|
58
|
+
For each remaining ambiguity, ask a **domain-specific** question using multiple choice (HOW), free text (WHERE), or confirmation (RISK):
|
|
59
|
+
|
|
60
|
+
| Domain | Type | Question |
|
|
61
|
+
|---|---|---|
|
|
62
|
+
| **UI** | HOW | Layout density? [Compact \| Comfortable \| Spacious] |
|
|
63
|
+
| UI | HOW | Interaction pattern? [Inline editing \| Modal dialogs \| Page navigation \| Drawer panels] |
|
|
64
|
+
| UI | HOW | Empty state behavior? [Placeholder \| Onboarding CTA \| Hide section] |
|
|
65
|
+
| UI | WHERE | Which page/route should this appear on? |
|
|
66
|
+
| UI | RISK | Does this affect existing UI users rely on? |
|
|
67
|
+
| **API** | HOW | Response format? [JSON REST \| GraphQL \| tRPC \| JSON-RPC] |
|
|
68
|
+
| API | HOW | Error handling? [HTTP status codes \| Always 200 \| RFC 7807] |
|
|
69
|
+
| API | HOW | Auth mechanism? [Bearer token \| API key \| Session cookie \| Public] |
|
|
70
|
+
| API | WHERE | Which endpoint prefix? (e.g., /api/v1/users) |
|
|
71
|
+
| API | RISK | Public-facing or internal API? |
|
|
72
|
+
| **Database** | HOW | ORM? [Prisma \| Drizzle \| TypeORM \| Knex \| Raw SQL \| Match existing] |
|
|
73
|
+
| Database | HOW | Migration strategy? [Auto-generate \| Manual \| Schema push] |
|
|
74
|
+
| Database | WHERE | Which table/model? |
|
|
75
|
+
| Database | RISK | Data migration needed? Existing production data? |
|
|
76
|
+
| **Auth** | HOW | Auth approach? [JWT \| Session cookies \| OAuth2 \| API keys] |
|
|
77
|
+
| Auth | HOW | Token storage? [httpOnly cookie \| localStorage \| Memory \| Secure cookie + CSRF] |
|
|
78
|
+
| Auth | HOW | Role model? [Simple roles \| RBAC \| ABAC \| No roles] |
|
|
79
|
+
| Auth | RISK | Affects existing user sessions? |
|
|
80
|
+
| **Content** | HOW | Format? [Markdown \| Rich text \| Structured JSON \| Plain text] |
|
|
81
|
+
| Content | HOW | Tone? [Technical \| Casual \| Formal \| Match existing] |
|
|
82
|
+
| Content | HOW | i18n? [English only \| Multi-language \| i18n-ready] |
|
|
83
|
+
| **Infra** | HOW | Deploy target? [Vercel \| AWS \| Docker \| Self-hosted \| Match existing] |
|
|
84
|
+
| Infra | HOW | CI/CD? [GitHub Actions \| GitLab CI \| CircleCI \| None \| Match existing] |
|
|
97
85
|
|
|
98
86
|
## Step 4: Follow-Up Depth
|
|
99
87
|
|
|
@@ -113,14 +101,14 @@ After each answer, score it:
|
|
|
113
101
|
|
|
114
102
|
Store each answer in brain.db with domain tag:
|
|
115
103
|
|
|
116
|
-
|
|
104
|
+
`brain_decisions: { action: add, question: [question], decision: [answer], reasoning: "User-provided via discussion", phase: discuss, tags: [TYPE],[domain] }`
|
|
117
105
|
|
|
118
106
|
These decisions are:
|
|
119
107
|
- Injected into all downstream agent contexts
|
|
120
108
|
- Never asked again (even across sessions)
|
|
121
109
|
- Visible via `/sf-brain decisions`
|
|
122
110
|
|
|
123
|
-
## Step 6: Report
|
|
111
|
+
## Step 6: Report + Ask Next Step
|
|
124
112
|
|
|
125
113
|
```
|
|
126
114
|
Resolved [N] ambiguities (domains: [ui, auth]):
|
|
@@ -128,10 +116,13 @@ Resolved [N] ambiguities (domains: [ui, auth]):
|
|
|
128
116
|
HOW (ui): Compact layout, modal dialogs
|
|
129
117
|
WHERE: /app/auth/login page
|
|
130
118
|
RISK: Development only — confirmed
|
|
131
|
-
|
|
132
|
-
Ready for planning. Run /sf-do to continue.
|
|
133
119
|
```
|
|
134
120
|
|
|
121
|
+
If `--chain` flag is NOT set:
|
|
122
|
+
Use AskUserQuestion: "Decisions locked. Plan and execute this task?"
|
|
123
|
+
- Options: "Yes, plan now" / "No, I'll do it later"
|
|
124
|
+
If yes → use the Skill tool with skill_name "sf:plan" and the original task description.
|
|
125
|
+
|
|
135
126
|
## Step 7: Chain Mode (when `--chain` flag is set)
|
|
136
127
|
|
|
137
128
|
After all decisions locked:
|
package/commands/sf/do.md
CHANGED
|
@@ -36,6 +36,8 @@ Extract flags from `$ARGUMENTS` before processing. Flags start with `--` and are
|
|
|
36
36
|
- `--batch` — Batch all discussion questions into 1-2 AskUserQuestion calls
|
|
37
37
|
- `--chain` — After each step, auto-run the next (discuss → plan → check → execute)
|
|
38
38
|
|
|
39
|
+
**Flag precedence** (highest wins): `--no-plan` > `--discuss` > `--cheap/--quality` > `--tdd/--research/--verify` > `--batch/--chain`
|
|
40
|
+
|
|
39
41
|
**Parse procedure:**
|
|
40
42
|
1. Extract all `--flag` tokens from the input
|
|
41
43
|
2. Remove them from the task description (remaining text = task)
|
|
@@ -122,6 +124,18 @@ Pipeline: scout → architect → builder → critic (acceleration: partial, 35%
|
|
|
122
124
|
|
|
123
125
|
If `.shipfast/brain.db` does not exist, tell user to run `shipfast init` first.
|
|
124
126
|
|
|
127
|
+
**Crash recovery**: Check for stale lock file:
|
|
128
|
+
```bash
|
|
129
|
+
[ -f .shipfast/lock ] && cat .shipfast/lock
|
|
130
|
+
```
|
|
131
|
+
If `.shipfast/lock` exists and is older than 30 minutes:
|
|
132
|
+
- Previous session was interrupted
|
|
133
|
+
- Read lock to find which task was in progress
|
|
134
|
+
- Check brain.db for task statuses: brain_tasks: { action: list }
|
|
135
|
+
- Report: "Recovered from interrupted session. [N]/[M] tasks completed. Resuming from task [N+1]."
|
|
136
|
+
- Continue with pending tasks (skip already-passed ones)
|
|
137
|
+
- Delete the stale lock file
|
|
138
|
+
|
|
125
139
|
**Store the changed files list** — use it in Step 4 (Scout) and Step 6 (Builder) for targeted context.
|
|
126
140
|
|
|
127
141
|
---
|
|
@@ -190,6 +204,11 @@ Before execution:
|
|
|
190
204
|
|
|
191
205
|
## STEP 6: EXECUTE (2-30K tokens)
|
|
192
206
|
|
|
207
|
+
**Create lock file** before starting execution:
|
|
208
|
+
```bash
|
|
209
|
+
echo '{"task":"[current_task_id]","started":'$(date +%s)'}' > .shipfast/lock
|
|
210
|
+
```
|
|
211
|
+
|
|
193
212
|
**CRITICAL RULE FOR ALL WORKFLOWS:**
|
|
194
213
|
Before removing, deleting, or modifying any function/type/selector/export/component:
|
|
195
214
|
1. `grep -r "name" --include="*.ts" --include="*.tsx" .` to find ALL consumers
|
|
@@ -207,7 +226,10 @@ Execute inline. No planning, no Scout, no Architect, no Critic.
|
|
|
207
226
|
6. Done. No SUMMARY, no verification.
|
|
208
227
|
**Redirect**: if work exceeds 3 file edits or needs research → upgrade to medium workflow.
|
|
209
228
|
|
|
229
|
+
**Trivial done**: files changed | build passes | committed | no stubs
|
|
230
|
+
|
|
210
231
|
### Medium workflow (1 Builder agent):
|
|
232
|
+
If task count > 5: auto-upgrade to complex workflow (per-task fresh agents) to prevent context filling.
|
|
211
233
|
Launch ONE Builder agent with ALL tasks batched and `model: models.builder` from Step 1.5:
|
|
212
234
|
- Agent gets: base prompt + brain context + all task descriptions
|
|
213
235
|
- If `--tdd` flag is set, prepend to Builder context: `MODE: TDD (red→green→refactor). Write failing test FIRST. See <tdd_mode> in builder prompt.`
|
|
@@ -215,11 +237,13 @@ Launch ONE Builder agent with ALL tasks batched and `model: models.builder` from
|
|
|
215
237
|
- One agent call instead of one per task = token savings
|
|
216
238
|
- If Critic is not skipped, launch Critic with `model: models.critic` after Builder completes
|
|
217
239
|
|
|
240
|
+
**Medium done**: all tasks complete | build passes | committed | critic reviewed
|
|
241
|
+
|
|
218
242
|
### Complex workflow (per-task agents, fresh context each):
|
|
219
243
|
|
|
220
244
|
**Check brain.db first** — if `/sf-plan` was run, tasks already exist:
|
|
221
245
|
|
|
222
|
-
|
|
246
|
+
`brain_tasks: { action: list, status: pending }`
|
|
223
247
|
|
|
224
248
|
If tasks found in brain.db, execute them. If not, run inline planning first.
|
|
225
249
|
|
|
@@ -246,16 +270,19 @@ For each pending task in brain.db:
|
|
|
246
270
|
2. Builder gets fresh context — no accumulated garbage from previous tasks
|
|
247
271
|
3. Builder executes: read → grep consumers → implement → build → verify → commit
|
|
248
272
|
4. After Builder completes, update task status and record model outcome:
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
Use the `brain_model_outcome` MCP tool with: `{ "agent": "builder", "model": "[model used]", "domain": "[domain]", "task_id": "[id]", "outcome": "success" }`
|
|
253
|
-
|
|
273
|
+
- `brain_tasks: { action: update, id: [id], status: passed, commit_sha: [sha] }`
|
|
274
|
+
- `brain_model_outcome: { agent: builder, model: [model used], domain: [domain], task_id: [id], outcome: success }`
|
|
254
275
|
5. If Builder fails after 3 attempts:
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
276
|
+
- `brain_tasks: { action: update, id: [id], status: failed, error: [error] }`
|
|
277
|
+
- `brain_model_outcome: { agent: builder, model: [model used], domain: [domain], task_id: [id], outcome: failure }`
|
|
278
|
+
If Builder reports STUCK (same error pattern repeated):
|
|
279
|
+
- Do NOT retry with same approach
|
|
280
|
+
- Record: brain_learnings: { action: add, pattern: stuck-[domain], problem: [repeated error], solution: null }
|
|
281
|
+
- Use AskUserQuestion: "Builder is stuck on [task]. What to do?"
|
|
282
|
+
Options: "Skip this task" / "Try different approach" / "I'll fix manually"
|
|
283
|
+
- If skip → mark task as skipped, continue to next
|
|
284
|
+
- If different approach → re-run Builder with hint: "Previous approach failed: [error]. Try a different approach."
|
|
285
|
+
- If manual → save state, STOP
|
|
259
286
|
6. Continue to next task regardless
|
|
260
287
|
|
|
261
288
|
**Wave grouping + parallel execution:**
|
|
@@ -273,11 +300,13 @@ If a wave has 2+ tasks, launch ALL Builder agents in that wave simultaneously us
|
|
|
273
300
|
- Stub detection before commit: scan for TODO/FIXME/placeholder
|
|
274
301
|
- Commit hygiene: stage specific files, never `git add .`
|
|
275
302
|
|
|
303
|
+
**Complex done**: all tasks [N/M] | build | critic | consumers clean | stubs clean | branch audit
|
|
304
|
+
|
|
276
305
|
---
|
|
277
306
|
|
|
278
307
|
## STEP 7: MANDATORY POST-EXECUTION VERIFICATION
|
|
279
308
|
|
|
280
|
-
|
|
309
|
+
STOP-GATE: Do NOT output the final report or say "Done" until ALL checks below are complete. If you skip verification, the task is FAILED regardless of whether the code works. This is not optional.
|
|
281
310
|
|
|
282
311
|
You MUST complete **ALL** of the following in order. Check each off as you go.
|
|
283
312
|
|
|
@@ -322,7 +351,7 @@ Report: `Stubs: [CLEAN/N found]`
|
|
|
322
351
|
```bash
|
|
323
352
|
CURRENT=$(git branch --show-current)
|
|
324
353
|
```
|
|
325
|
-
|
|
354
|
+
`brain_config: { action: get, key: default_branch }` — fall back to `"main"`.
|
|
326
355
|
|
|
327
356
|
If `$CURRENT` ≠ `$DEFAULT`:
|
|
328
357
|
- `git diff $DEFAULT...$CURRENT --diff-filter=D --name-only` → deleted files
|
|
@@ -352,7 +381,12 @@ If FAIL:
|
|
|
352
381
|
4. If still failing → DEFERRED
|
|
353
382
|
|
|
354
383
|
Store verification results:
|
|
355
|
-
|
|
384
|
+
`brain_context: { action: set, scope: session, key: verification, value: [JSON results] }`
|
|
385
|
+
|
|
386
|
+
**Delete lock file** after all tasks complete:
|
|
387
|
+
```bash
|
|
388
|
+
rm -f .shipfast/lock
|
|
389
|
+
```
|
|
356
390
|
|
|
357
391
|
Only AFTER 7A-7H are complete, proceed to STEP 8.
|
|
358
392
|
|
|
@@ -364,15 +398,15 @@ Only AFTER 7A-7H are complete, proceed to STEP 8.
|
|
|
364
398
|
|
|
365
399
|
If you made any architectural decisions during this task, record each one:
|
|
366
400
|
|
|
367
|
-
|
|
401
|
+
`brain_decisions: { action: add, question: [what was decided], decision: [the choice], reasoning: [why], phase: [current task] }`
|
|
368
402
|
|
|
369
403
|
If you encountered and fixed any errors, record the pattern:
|
|
370
404
|
|
|
371
|
-
|
|
405
|
+
`brain_learnings: { action: add, pattern: [short pattern name], problem: [what went wrong], solution: [what fixed it], domain: [domain], source: auto, confidence: 0.5 }`
|
|
372
406
|
|
|
373
407
|
If any improvement ideas, future features, or tech debt were surfaced during this task (including OUT_OF_SCOPE items), record them as seeds:
|
|
374
408
|
|
|
375
|
-
|
|
409
|
+
`brain_seeds: { action: add, idea: [idea], source_task: [current task], domain: [domain], priority: someday }`
|
|
376
410
|
|
|
377
411
|
**These are not optional.** If decisions were made, errors were fixed, or ideas were surfaced, you MUST record them. This is how ShipFast gets smarter over time.
|
|
378
412
|
|
|
@@ -425,13 +459,23 @@ Run /sf-resume to continue in a new session.
|
|
|
425
459
|
|
|
426
460
|
</pipeline>
|
|
427
461
|
|
|
428
|
-
<
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
462
|
+
<context_management>
|
|
463
|
+
## Context Management (ENFORCED — NEVER degrade quality)
|
|
464
|
+
|
|
465
|
+
Between tasks, assess: can you complete the next task at FULL quality?
|
|
466
|
+
If NO (context running low, responses getting long, repeated tool failures):
|
|
467
|
+
|
|
468
|
+
1. Commit any uncommitted work
|
|
469
|
+
2. Save progress: brain_context: { action: set, scope: session, key: progress, value: { completed: [task IDs], pending: [task IDs], next_task: [id] } }
|
|
470
|
+
3. Output:
|
|
471
|
+
Context save point. [N]/[M] tasks completed.
|
|
472
|
+
Progress saved to brain.db.
|
|
473
|
+
Run /sf-resume in a new session to continue with fresh context.
|
|
474
|
+
4. STOP. Do not start the next task.
|
|
475
|
+
|
|
476
|
+
NEVER: reduce quality, skip verification, use grep instead of read, or rush to finish.
|
|
477
|
+
Rule: save and resume > degrade and continue.
|
|
478
|
+
</context_management>
|
|
435
479
|
|
|
436
480
|
<context>
|
|
437
481
|
$ARGUMENTS
|
package/commands/sf/milestone.md
CHANGED
|
@@ -6,6 +6,7 @@ allowed-tools:
|
|
|
6
6
|
- Read
|
|
7
7
|
- Bash
|
|
8
8
|
- AskUserQuestion
|
|
9
|
+
- Skill
|
|
9
10
|
---
|
|
10
11
|
|
|
11
12
|
<objective>
|
|
@@ -80,9 +81,12 @@ Decisions: 8 recorded
|
|
|
80
81
|
Learnings: 12 captured
|
|
81
82
|
|
|
82
83
|
Tagged: v1.0
|
|
83
|
-
Run /sf-milestone new v2.0 to start next cycle.
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
+
Use AskUserQuestion: "Milestone complete. Start next milestone?"
|
|
87
|
+
- Options: "Yes, start new milestone" / "No, done for now"
|
|
88
|
+
If yes → use the Skill tool with skill_name "sf:milestone" and argument "new [next version]".
|
|
89
|
+
|
|
86
90
|
---
|
|
87
91
|
|
|
88
92
|
## If argument is "new <name>" — Start New Milestone
|
|
@@ -120,9 +124,13 @@ Carried forward: 2 unfinished requirements from v1
|
|
|
120
124
|
Promoted: 4 requirements from v2 backlog
|
|
121
125
|
Total v2 scope: 6 requirements
|
|
122
126
|
|
|
123
|
-
Run /sf-project to decompose into phases, or /sf-do to start working.
|
|
124
127
|
```
|
|
125
128
|
|
|
129
|
+
Use AskUserQuestion: "New milestone ready. What's next?"
|
|
130
|
+
- Options: "Decompose into phases (/sf-project)" / "Start working directly (/sf-do)" / "Stop here"
|
|
131
|
+
If decompose → use the Skill tool with skill_name "sf:project".
|
|
132
|
+
If start working → use the Skill tool with skill_name "sf:do".
|
|
133
|
+
|
|
126
134
|
</process>
|
|
127
135
|
|
|
128
136
|
<context>
|
package/commands/sf/plan.md
CHANGED
|
@@ -9,6 +9,7 @@ allowed-tools:
|
|
|
9
9
|
- Grep
|
|
10
10
|
- Agent
|
|
11
11
|
- AskUserQuestion
|
|
12
|
+
- Skill
|
|
12
13
|
---
|
|
13
14
|
|
|
14
15
|
<objective>
|
|
@@ -92,10 +93,18 @@ Tasks:
|
|
|
92
93
|
1. [description] — [files] — [size]
|
|
93
94
|
2. [description] — [files] — [size]
|
|
94
95
|
...
|
|
95
|
-
|
|
96
|
-
Run /sf-do to execute. Tasks will run with fresh context per task.
|
|
97
96
|
```
|
|
98
97
|
|
|
98
|
+
## Step 7: Ask to execute
|
|
99
|
+
|
|
100
|
+
After showing the plan, ask the user:
|
|
101
|
+
|
|
102
|
+
Use AskUserQuestion: "Plan ready with [N] tasks. Execute now?"
|
|
103
|
+
- Options: "Yes, execute" / "No, I'll review first"
|
|
104
|
+
|
|
105
|
+
If user says yes → use the Skill tool with skill_name "sf:do" to start execution.
|
|
106
|
+
If user says no → stop here. User can run `/sf-do` manually later.
|
|
107
|
+
|
|
99
108
|
</process>
|
|
100
109
|
|
|
101
110
|
<context>
|
package/commands/sf/project.md
CHANGED
|
@@ -9,6 +9,7 @@ allowed-tools:
|
|
|
9
9
|
- Grep
|
|
10
10
|
- Agent
|
|
11
11
|
- AskUserQuestion
|
|
12
|
+
- Skill
|
|
12
13
|
---
|
|
13
14
|
|
|
14
15
|
<objective>
|
|
@@ -147,9 +148,13 @@ Phase 4: [name] — [1-line description] (depends on Phase 2, 3)
|
|
|
147
148
|
|
|
148
149
|
Coverage: [M]/[M] v1 requirements mapped (100%)
|
|
149
150
|
|
|
150
|
-
Start with Phase 1? (Run /sf-do to begin)
|
|
151
151
|
```
|
|
152
152
|
|
|
153
|
+
Use AskUserQuestion: "Project decomposed into [N] phases. Start Phase 1: [name]?"
|
|
154
|
+
- Options: "Yes, start Phase 1" / "No, I'll review first"
|
|
155
|
+
|
|
156
|
+
If yes → use the Skill tool with skill_name "sf:do" and argument "Phase 1: [description]".
|
|
157
|
+
|
|
153
158
|
## Step 7: Execution
|
|
154
159
|
|
|
155
160
|
User runs `/sf-do Phase 1: [description]` for each phase.
|
package/commands/sf/resume.md
CHANGED
|
@@ -10,52 +10,105 @@ allowed-tools:
|
|
|
10
10
|
<objective>
|
|
11
11
|
Resume interrupted work from a previous session.
|
|
12
12
|
State is automatically saved to brain.db when context runs low or work is paused.
|
|
13
|
-
This command loads that state, verifies commits exist, and continues.
|
|
13
|
+
This command loads that state, verifies commits exist, and continues with fresh context per task.
|
|
14
14
|
</objective>
|
|
15
15
|
|
|
16
16
|
<process>
|
|
17
17
|
|
|
18
|
-
## Step 1: Load
|
|
18
|
+
## Step 1: Load Saved Progress
|
|
19
|
+
|
|
20
|
+
Check for lock file indicating crashed session:
|
|
21
|
+
```bash
|
|
22
|
+
[ -f .shipfast/lock ] && cat .shipfast/lock
|
|
23
|
+
```
|
|
24
|
+
If found: "Detected interrupted session. Recovering..."
|
|
25
|
+
|
|
26
|
+
Query brain.db for the latest saved session progress:
|
|
27
|
+
|
|
28
|
+
`brain_context: { action: get, scope: session, key: progress }`
|
|
19
29
|
|
|
20
|
-
Query brain.db for the latest saved session state.
|
|
21
30
|
Show the user:
|
|
22
31
|
|
|
23
32
|
```
|
|
24
33
|
Session Recovery
|
|
25
34
|
================
|
|
26
|
-
|
|
27
|
-
Stopped at: context exhaustion at 92%
|
|
35
|
+
Resuming from task [N+1]/[M].
|
|
28
36
|
|
|
29
|
-
|
|
30
|
-
task
|
|
31
|
-
task
|
|
32
|
-
|
|
37
|
+
Previously completed: [N] tasks
|
|
38
|
+
[task ID 1] — [task description] [commit sha]
|
|
39
|
+
[task ID 2] — [task description] [commit sha]
|
|
40
|
+
...
|
|
33
41
|
|
|
34
|
-
Pending:
|
|
35
|
-
task
|
|
36
|
-
|
|
42
|
+
Pending: [M-N] tasks
|
|
43
|
+
[task ID N+1] — [task description]
|
|
44
|
+
...
|
|
37
45
|
|
|
38
|
-
Decisions carried forward:
|
|
46
|
+
Decisions carried forward: [count]
|
|
47
|
+
Learnings available: [count]
|
|
39
48
|
```
|
|
40
49
|
|
|
50
|
+
Also load decisions and learnings from brain.db for context:
|
|
51
|
+
- `brain_decisions: { action: list }` — architectural decisions from prior session
|
|
52
|
+
- `brain_learnings: { action: list }` — error/fix patterns recorded
|
|
53
|
+
|
|
41
54
|
## Step 2: Verify Commits
|
|
42
55
|
|
|
43
|
-
Check that all reported commit SHAs exist in git history
|
|
44
|
-
|
|
56
|
+
Check that all reported commit SHAs for completed tasks exist in git history:
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
git log --oneline -20
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
If any completed task's commit SHA is missing, warn the user before continuing:
|
|
63
|
+
`WARN: Commit [sha] for task [id] not found in git history. Task may need to be redone.`
|
|
45
64
|
|
|
46
65
|
## Step 3: Confirm and Continue
|
|
47
66
|
|
|
48
|
-
|
|
67
|
+
Show: "Resuming from task [N+1]/[M]. Previously completed tasks will not be redone."
|
|
68
|
+
|
|
69
|
+
If no pending tasks remain:
|
|
70
|
+
`All [M] tasks were completed in the previous session. Nothing to resume.`
|
|
49
71
|
|
|
50
|
-
|
|
51
|
-
1. Inject compressed state into Builder context (~300-500 tokens)
|
|
52
|
-
2. Skip completed tasks entirely
|
|
53
|
-
3. Continue with the next pending task
|
|
54
|
-
4. All previous decisions are automatically available via brain.db
|
|
72
|
+
Otherwise proceed automatically (no confirmation prompt needed unless there are missing commits).
|
|
55
73
|
|
|
56
74
|
## Step 4: Continue Pipeline
|
|
57
75
|
|
|
58
|
-
Resume the
|
|
76
|
+
Resume execution using the **complex workflow** (per-task fresh agents) for all pending tasks:
|
|
77
|
+
|
|
78
|
+
**REQUIRED — output progress for EVERY task:**
|
|
79
|
+
|
|
80
|
+
Before each task:
|
|
81
|
+
```
|
|
82
|
+
[N/M] Building: [task description]...
|
|
83
|
+
```
|
|
84
|
+
After each task:
|
|
85
|
+
```
|
|
86
|
+
[N/M] Done: [task description] (commit: [sha])
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For each pending task:
|
|
90
|
+
1. Launch a SEPARATE sf-builder agent with ONLY that task + brain context
|
|
91
|
+
2. Builder gets fresh context — no accumulated state from previous tasks
|
|
92
|
+
3. Builder executes: read → grep consumers → implement → build → verify → commit
|
|
93
|
+
4. Update task status in brain.db: `brain_tasks: { action: update, id: [id], status: passed, commit_sha: [sha] }`
|
|
94
|
+
5. Update saved progress: `brain_context: { action: set, scope: session, key: progress, value: { completed: [...updated list], pending: [...remaining], next_task: [next id] } }`
|
|
95
|
+
6. Continue to next task
|
|
96
|
+
|
|
59
97
|
All brain.db context (decisions, learnings, conventions) carries forward automatically.
|
|
60
98
|
|
|
99
|
+
## Step 5: Complete
|
|
100
|
+
|
|
101
|
+
After all pending tasks are done, run post-execution verification (Steps 7A-7H from /sf-do):
|
|
102
|
+
- Launch Critic agent
|
|
103
|
+
- Build verification
|
|
104
|
+
- Consumer integrity check
|
|
105
|
+
- Stub scan
|
|
106
|
+
- Launch Scribe to record any new decisions/learnings
|
|
107
|
+
|
|
108
|
+
Report:
|
|
109
|
+
```
|
|
110
|
+
Resume complete. [M]/[M] tasks done.
|
|
111
|
+
Commits: [N] | Build: [PASS/FAIL] | Critic: [verdict]
|
|
112
|
+
```
|
|
113
|
+
|
|
61
114
|
</process>
|
package/commands/sf/verify.md
CHANGED
|
@@ -7,6 +7,7 @@ allowed-tools:
|
|
|
7
7
|
- Glob
|
|
8
8
|
- Grep
|
|
9
9
|
- AskUserQuestion
|
|
10
|
+
- Skill
|
|
10
11
|
---
|
|
11
12
|
|
|
12
13
|
<objective>
|
|
@@ -127,9 +128,18 @@ Failed items:
|
|
|
127
128
|
- [truth/artifact]: [what's wrong]
|
|
128
129
|
- [truth/artifact]: [what's wrong]
|
|
129
130
|
|
|
130
|
-
Fix with: /sf-do [fix description]
|
|
131
131
|
```
|
|
132
132
|
|
|
133
|
+
If verdict is FAIL:
|
|
134
|
+
Use AskUserQuestion: "Verification failed with [N] issues. Auto-fix?"
|
|
135
|
+
- Options: "Yes, auto-fix" / "No, I'll fix manually"
|
|
136
|
+
If yes → use the Skill tool with skill_name "sf:do" and the fix descriptions as argument.
|
|
137
|
+
|
|
138
|
+
If verdict is PASS:
|
|
139
|
+
Use AskUserQuestion: "Verification passed. Ship it?"
|
|
140
|
+
- Options: "Yes, create PR" / "No, not yet"
|
|
141
|
+
If yes → use the Skill tool with skill_name "sf:ship".
|
|
142
|
+
|
|
133
143
|
## Step 9: Store results
|
|
134
144
|
|
|
135
145
|
Use the `brain_context` MCP tool with: `{ "action": "set", "id": "verify:latest", "scope": "session", "key": "verification", "value": "[JSON results]" }`
|
package/commands/sf/worktree.md
CHANGED
|
@@ -25,7 +25,7 @@ can work simultaneously.
|
|
|
25
25
|
```bash
|
|
26
26
|
git worktree list
|
|
27
27
|
```
|
|
28
|
-
|
|
28
|
+
`brain_context: { action: list, scope: worktree }` — returns all worktree context entries ordered by updated_at descending.
|
|
29
29
|
Show all worktrees with path, branch, status (active/complete), and task counts.
|
|
30
30
|
|
|
31
31
|
### create <task description or name>
|
|
@@ -64,9 +64,7 @@ Branch name for this worktree?
|
|
|
64
64
|
|
|
65
65
|
**Step 3: Multi-repo check**
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
Use the `brain_config` MCP tool with: `{ "action": "get", "key": "linked_repos" }`
|
|
67
|
+
`brain_config: { action: get, key: linked_repos }`
|
|
70
68
|
|
|
71
69
|
If linked repos exist, ask which repos need this worktree (AskUserQuestion):
|
|
72
70
|
```
|
|
@@ -92,7 +90,7 @@ git -C [linked-path] worktree add [linked-path]/.shipfast/worktrees/[name] -b [b
|
|
|
92
90
|
|
|
93
91
|
**Step 5: Store metadata**
|
|
94
92
|
|
|
95
|
-
|
|
93
|
+
`brain_context: { action: set, id: "worktree:[name]", scope: worktree, key: [name], value: "{\"status\":\"active\",\"branch\":\"[branch-name]\",\"path\":\".shipfast/worktrees/[name]\",\"repos\":[\".\"],\"created\":\"[timestamp]\"}" }`
|
|
96
94
|
|
|
97
95
|
**Step 6: Report**
|
|
98
96
|
```
|
|
@@ -128,7 +126,7 @@ Note: Unlike branches, worktrees don't need `git checkout`. Just `cd` into the d
|
|
|
128
126
|
git -C .shipfast/worktrees/[name] status --short
|
|
129
127
|
git -C .shipfast/worktrees/[name] log --oneline -5
|
|
130
128
|
```
|
|
131
|
-
|
|
129
|
+
`brain_tasks: { action: list, phase_contains: [name] }` — returns tasks for this worktree ordered by created_at.
|
|
132
130
|
Show: uncommitted changes, recent commits, and pending tasks for this worktree.
|
|
133
131
|
|
|
134
132
|
### check [name]
|
|
@@ -139,9 +137,9 @@ If `[name]` is provided, check that worktree's branch. If omitted, check the cur
|
|
|
139
137
|
|
|
140
138
|
**Step 1: Resolve branches**
|
|
141
139
|
|
|
142
|
-
|
|
140
|
+
`brain_config: { action: get, key: default_branch }` — if empty, fall back to `"main"` as `$DEFAULT`.
|
|
143
141
|
|
|
144
|
-
Get worktree's branch: if `[name]` is provided,
|
|
142
|
+
Get worktree's branch: if `[name]` is provided, `brain_context: { action: get, scope: worktree, key: [name] }` and parse the `branch` field. Otherwise, run `git branch --show-current` to get `$BRANCH`.
|
|
145
143
|
|
|
146
144
|
**Step 2: Get changed files**
|
|
147
145
|
```bash
|
|
@@ -177,9 +175,7 @@ grep -rl "SYMBOL_NAME" --include="*.ts" --include="*.tsx" --include="*.js" --inc
|
|
|
177
175
|
- Found in a DIFFERENT file → **MIGRATED** (show `old_path → new_path`)
|
|
178
176
|
|
|
179
177
|
2. **Check consumers via brain.db**:
|
|
180
|
-
|
|
181
|
-
Use the `brain_search` MCP tool with: `{ "query": "consumers:SYMBOL_NAME kind:imports,calls,depends" }` — returns files that consume the given symbol.
|
|
182
|
-
|
|
178
|
+
`brain_search: { query: "consumers:SYMBOL_NAME kind:imports,calls,depends" }` — returns files that consume the given symbol.
|
|
183
179
|
- Has consumers AND not found elsewhere → **MISSING** (show consumers)
|
|
184
180
|
- Zero consumers AND not found elsewhere → **SAFELY REMOVED**
|
|
185
181
|
|
|
@@ -248,14 +244,12 @@ Warning: [N] missing items with active consumers. Merge anyway?
|
|
|
248
244
|
```
|
|
249
245
|
|
|
250
246
|
3. Get the default branch:
|
|
251
|
-
|
|
252
|
-
Use the `brain_config` MCP tool with: `{ "action": "get", "key": "default_branch" }` — if empty, fall back to `"main"` as `$DEFAULT`.
|
|
247
|
+
`brain_config: { action: get, key: default_branch }` — if empty, fall back to `"main"` as `$DEFAULT`.
|
|
253
248
|
|
|
254
249
|
4. Ask: "Merge [branch] into $DEFAULT and remove worktree? [y/n]"
|
|
255
250
|
|
|
256
251
|
5. If yes, also check multi-repo:
|
|
257
|
-
|
|
258
|
-
Use the `brain_context` MCP tool with: `{ "action": "get", "id": "worktree:[name]" }` — parse the `repos` field from the returned value.
|
|
252
|
+
`brain_context: { action: get, id: "worktree:[name]" }` — parse the `repos` field from the returned value.
|
|
259
253
|
|
|
260
254
|
For current repo:
|
|
261
255
|
```bash
|
|
@@ -274,8 +268,7 @@ git -C [linked-path] branch -d [branch-name]
|
|
|
274
268
|
```
|
|
275
269
|
|
|
276
270
|
6. Update brain.db:
|
|
277
|
-
|
|
278
|
-
Use the `brain_context` MCP tool with: `{ "action": "set", "id": "worktree:[name]", "scope": "worktree", "key": "[name]", "value": "<previous value with 'active' replaced by 'complete'>" }`
|
|
271
|
+
`brain_context: { action: set, id: "worktree:[name]", scope: worktree, key: [name], value: "<previous value with 'active' replaced by 'complete'>" }`
|
|
279
272
|
|
|
280
273
|
7. Report: `Worktree [name] merged into $DEFAULT and removed.`
|
|
281
274
|
|
package/core/retry.cjs
CHANGED
|
@@ -56,6 +56,23 @@ ${knownPattern.solution}
|
|
|
56
56
|
return parts.join('\n');
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Detect if errors across attempts indicate being stuck (same error repeating).
|
|
61
|
+
* Returns true if the last 2 errors are substantially similar.
|
|
62
|
+
*/
|
|
63
|
+
function isStuck(errors) {
|
|
64
|
+
if (errors.length < 2) return false;
|
|
65
|
+
const last = (errors[errors.length - 1] || '').toString().toLowerCase().slice(0, 200);
|
|
66
|
+
const prev = (errors[errors.length - 2] || '').toString().toLowerCase().slice(0, 200);
|
|
67
|
+
if (!last || !prev) return false;
|
|
68
|
+
// Check if 60%+ of words overlap
|
|
69
|
+
const lastWords = new Set(last.split(/\s+/));
|
|
70
|
+
const prevWords = new Set(prev.split(/\s+/));
|
|
71
|
+
let overlap = 0;
|
|
72
|
+
for (const w of lastWords) { if (prevWords.has(w)) overlap++; }
|
|
73
|
+
return overlap / Math.max(lastWords.size, prevWords.size) > 0.6;
|
|
74
|
+
}
|
|
75
|
+
|
|
59
76
|
/**
|
|
60
77
|
* Determine retry strategy based on error type.
|
|
61
78
|
*/
|
|
@@ -100,6 +117,7 @@ function classifyError(error) {
|
|
|
100
117
|
function withRetry(cwd, task, executeFn, maxAttempts = 3) {
|
|
101
118
|
let lastError = null;
|
|
102
119
|
let totalTokens = 0;
|
|
120
|
+
const errors = [];
|
|
103
121
|
|
|
104
122
|
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
105
123
|
try {
|
|
@@ -120,6 +138,17 @@ function withRetry(cwd, task, executeFn, maxAttempts = 3) {
|
|
|
120
138
|
};
|
|
121
139
|
}
|
|
122
140
|
|
|
141
|
+
// Don't retry if stuck (same error repeating)
|
|
142
|
+
if (isStuck(errors)) {
|
|
143
|
+
return {
|
|
144
|
+
success: false,
|
|
145
|
+
error: lastError,
|
|
146
|
+
stuck: true,
|
|
147
|
+
attempts,
|
|
148
|
+
tokensUsed: totalTokens
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
|
|
123
152
|
retryContext = buildRetryContext(cwd, task, lastError, attempt);
|
|
124
153
|
}
|
|
125
154
|
|
|
@@ -146,9 +175,11 @@ function withRetry(cwd, task, executeFn, maxAttempts = 3) {
|
|
|
146
175
|
}
|
|
147
176
|
|
|
148
177
|
lastError = result.error || new Error('Task failed without error details');
|
|
178
|
+
errors.push(lastError);
|
|
149
179
|
|
|
150
180
|
} catch (err) {
|
|
151
181
|
lastError = err;
|
|
182
|
+
errors.push(lastError);
|
|
152
183
|
}
|
|
153
184
|
}
|
|
154
185
|
|
|
@@ -171,5 +202,6 @@ function withRetry(cwd, task, executeFn, maxAttempts = 3) {
|
|
|
171
202
|
module.exports = {
|
|
172
203
|
buildRetryContext,
|
|
173
204
|
classifyError,
|
|
205
|
+
isStuck,
|
|
174
206
|
withRetry
|
|
175
207
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shipfast-ai/shipfast",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Autonomous context-engineered development system with SQLite brain. 5 agents, 20 commands, per-task fresh context, 70-90% fewer tokens.",
|
|
5
5
|
"bin": {
|
|
6
6
|
"shipfast": "bin/install.js"
|