gsd-pi 2.22.0 → 2.24.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 +25 -1
- package/dist/cli.js +74 -7
- package/dist/headless.d.ts +25 -0
- package/dist/headless.js +454 -0
- package/dist/help-text.js +47 -0
- package/dist/mcp-server.d.ts +20 -3
- package/dist/mcp-server.js +21 -1
- package/dist/models-resolver.d.ts +32 -0
- package/dist/models-resolver.js +50 -0
- package/dist/resource-loader.js +64 -9
- package/dist/resources/extensions/bg-shell/output-formatter.ts +36 -16
- package/dist/resources/extensions/bg-shell/process-manager.ts +6 -4
- package/dist/resources/extensions/bg-shell/types.ts +33 -1
- package/dist/resources/extensions/browser-tools/capture.ts +18 -16
- package/dist/resources/extensions/browser-tools/index.ts +20 -0
- package/dist/resources/extensions/browser-tools/tests/browser-tools-unit.test.cjs +25 -0
- package/dist/resources/extensions/browser-tools/tools/action-cache.ts +216 -0
- package/dist/resources/extensions/browser-tools/tools/codegen.ts +274 -0
- package/dist/resources/extensions/browser-tools/tools/device.ts +183 -0
- package/dist/resources/extensions/browser-tools/tools/extract.ts +229 -0
- package/dist/resources/extensions/browser-tools/tools/injection-detect.ts +221 -0
- package/dist/resources/extensions/browser-tools/tools/network-mock.ts +244 -0
- package/dist/resources/extensions/browser-tools/tools/pdf.ts +92 -0
- package/dist/resources/extensions/browser-tools/tools/state-persistence.ts +202 -0
- package/dist/resources/extensions/browser-tools/tools/visual-diff.ts +209 -0
- package/dist/resources/extensions/browser-tools/tools/zoom.ts +104 -0
- package/dist/resources/extensions/gsd/auto-dashboard.ts +2 -0
- package/dist/resources/extensions/gsd/auto-dispatch.ts +51 -2
- package/dist/resources/extensions/gsd/auto-prompts.ts +73 -0
- package/dist/resources/extensions/gsd/auto-recovery.ts +51 -2
- package/dist/resources/extensions/gsd/auto-worktree.ts +15 -3
- package/dist/resources/extensions/gsd/auto.ts +560 -52
- package/dist/resources/extensions/gsd/captures.ts +49 -0
- package/dist/resources/extensions/gsd/commands.ts +194 -11
- package/dist/resources/extensions/gsd/complexity.ts +1 -0
- package/dist/resources/extensions/gsd/dashboard-overlay.ts +54 -2
- package/dist/resources/extensions/gsd/diff-context.ts +73 -80
- package/dist/resources/extensions/gsd/doctor.ts +76 -12
- package/dist/resources/extensions/gsd/exit-command.ts +2 -2
- package/dist/resources/extensions/gsd/forensics.ts +95 -52
- package/dist/resources/extensions/gsd/gitignore.ts +1 -0
- package/dist/resources/extensions/gsd/guided-flow.ts +85 -5
- package/dist/resources/extensions/gsd/index.ts +34 -1
- package/dist/resources/extensions/gsd/mcp-server.ts +33 -12
- package/dist/resources/extensions/gsd/parallel-eligibility.ts +233 -0
- package/dist/resources/extensions/gsd/parallel-merge.ts +156 -0
- package/dist/resources/extensions/gsd/parallel-orchestrator.ts +496 -0
- package/dist/resources/extensions/gsd/post-unit-hooks.ts +2 -1
- package/dist/resources/extensions/gsd/preferences.ts +65 -1
- package/dist/resources/extensions/gsd/prompts/discuss-headless.md +86 -0
- package/dist/resources/extensions/gsd/prompts/execute-task.md +5 -0
- package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +104 -1
- package/dist/resources/extensions/gsd/prompts/plan-milestone.md +1 -0
- package/dist/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/dist/resources/extensions/gsd/prompts/system.md +2 -1
- package/dist/resources/extensions/gsd/prompts/validate-milestone.md +70 -0
- package/dist/resources/extensions/gsd/provider-error-pause.ts +29 -2
- package/dist/resources/extensions/gsd/roadmap-slices.ts +41 -1
- package/dist/resources/extensions/gsd/session-forensics.ts +36 -2
- package/dist/resources/extensions/gsd/session-status-io.ts +197 -0
- package/dist/resources/extensions/gsd/state.ts +72 -30
- package/dist/resources/extensions/gsd/templates/milestone-validation.md +62 -0
- package/dist/resources/extensions/gsd/tests/agent-end-provider-error.test.ts +81 -0
- package/dist/resources/extensions/gsd/tests/auto-budget-alerts.test.ts +20 -3
- package/dist/resources/extensions/gsd/tests/auto-lock-creation.test.ts +186 -0
- package/dist/resources/extensions/gsd/tests/auto-preflight.test.ts +1 -0
- package/dist/resources/extensions/gsd/tests/auto-recovery.test.ts +264 -0
- package/dist/resources/extensions/gsd/tests/auto-skip-loop.test.ts +123 -0
- package/dist/resources/extensions/gsd/tests/auto-worktree-milestone-merge.test.ts +34 -0
- package/dist/resources/extensions/gsd/tests/complete-milestone.test.ts +8 -1
- package/dist/resources/extensions/gsd/tests/derive-state-db.test.ts +9 -15
- package/dist/resources/extensions/gsd/tests/derive-state-deps.test.ts +9 -0
- package/dist/resources/extensions/gsd/tests/derive-state-draft.test.ts +8 -0
- package/dist/resources/extensions/gsd/tests/derive-state.test.ts +14 -0
- package/dist/resources/extensions/gsd/tests/doctor.test.ts +58 -0
- package/dist/resources/extensions/gsd/tests/in-flight-tool-tracking.test.ts +17 -6
- package/dist/resources/extensions/gsd/tests/integration/headless-command.ts +534 -0
- package/dist/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +8 -0
- package/dist/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +5 -5
- package/dist/resources/extensions/gsd/tests/parallel-orchestration.test.ts +656 -0
- package/dist/resources/extensions/gsd/tests/parallel-workers-multi-milestone-e2e.test.ts +354 -0
- package/dist/resources/extensions/gsd/tests/queue-reorder-e2e.test.ts +1 -0
- package/dist/resources/extensions/gsd/tests/roadmap-slices.test.ts +43 -1
- package/dist/resources/extensions/gsd/tests/triage-dispatch.test.ts +120 -0
- package/dist/resources/extensions/gsd/tests/triage-resolution.test.ts +203 -2
- package/dist/resources/extensions/gsd/tests/validate-milestone.test.ts +316 -0
- package/dist/resources/extensions/gsd/tests/visualizer-overlay.test.ts +8 -3
- package/dist/resources/extensions/gsd/tests/worker-registry.test.ts +148 -0
- package/dist/resources/extensions/gsd/triage-resolution.ts +83 -0
- package/dist/resources/extensions/gsd/types.ts +15 -1
- package/dist/resources/extensions/gsd/visualizer-overlay.ts +8 -1
- package/dist/resources/extensions/gsd/workspace-index.ts +34 -6
- package/dist/resources/extensions/subagent/index.ts +5 -0
- package/dist/resources/extensions/subagent/worker-registry.ts +99 -0
- package/dist/update-check.d.ts +9 -0
- package/dist/update-check.js +97 -0
- package/package.json +6 -1
- package/packages/pi-ai/dist/providers/anthropic.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/anthropic.js +16 -7
- package/packages/pi-ai/dist/providers/anthropic.js.map +1 -1
- package/packages/pi-ai/dist/providers/azure-openai-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/azure-openai-responses.js +12 -4
- package/packages/pi-ai/dist/providers/azure-openai-responses.js.map +1 -1
- package/packages/pi-ai/dist/providers/google-vertex.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/google-vertex.js +21 -9
- package/packages/pi-ai/dist/providers/google-vertex.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-completions.js +12 -4
- package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.d.ts.map +1 -1
- package/packages/pi-ai/dist/providers/openai-responses.js +12 -4
- package/packages/pi-ai/dist/providers/openai-responses.js.map +1 -1
- package/packages/pi-ai/src/providers/anthropic.ts +21 -8
- package/packages/pi-ai/src/providers/azure-openai-responses.ts +16 -4
- package/packages/pi-ai/src/providers/google-vertex.ts +32 -17
- package/packages/pi-ai/src/providers/openai-completions.ts +16 -4
- package/packages/pi-ai/src/providers/openai-responses.ts +16 -4
- package/packages/pi-coding-agent/dist/core/agent-session.js +1 -1
- package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js +1 -1
- package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/bash-background.test.d.ts +10 -0
- package/packages/pi-coding-agent/dist/core/tools/bash-background.test.d.ts.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/bash-background.test.js +79 -0
- package/packages/pi-coding-agent/dist/core/tools/bash-background.test.js.map +1 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts +18 -0
- package/packages/pi-coding-agent/dist/core/tools/bash.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.js +77 -1
- package/packages/pi-coding-agent/dist/core/tools/bash.js.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.js +1 -1
- package/packages/pi-coding-agent/dist/core/tools/index.js.map +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts +1 -1
- package/packages/pi-coding-agent/dist/index.d.ts.map +1 -1
- package/packages/pi-coding-agent/dist/index.js +1 -1
- package/packages/pi-coding-agent/dist/index.js.map +1 -1
- package/packages/pi-coding-agent/src/core/agent-session.ts +1 -1
- package/packages/pi-coding-agent/src/core/settings-manager.ts +2 -2
- package/packages/pi-coding-agent/src/core/tools/bash-background.test.ts +91 -0
- package/packages/pi-coding-agent/src/core/tools/bash.ts +83 -1
- package/packages/pi-coding-agent/src/core/tools/index.ts +1 -0
- package/packages/pi-coding-agent/src/index.ts +1 -0
- package/scripts/postinstall.js +7 -109
- package/src/resources/extensions/bg-shell/output-formatter.ts +36 -16
- package/src/resources/extensions/bg-shell/process-manager.ts +6 -4
- package/src/resources/extensions/bg-shell/types.ts +33 -1
- package/src/resources/extensions/browser-tools/capture.ts +18 -16
- package/src/resources/extensions/browser-tools/index.ts +20 -0
- package/src/resources/extensions/browser-tools/tests/browser-tools-unit.test.cjs +25 -0
- package/src/resources/extensions/browser-tools/tools/action-cache.ts +216 -0
- package/src/resources/extensions/browser-tools/tools/codegen.ts +274 -0
- package/src/resources/extensions/browser-tools/tools/device.ts +183 -0
- package/src/resources/extensions/browser-tools/tools/extract.ts +229 -0
- package/src/resources/extensions/browser-tools/tools/injection-detect.ts +221 -0
- package/src/resources/extensions/browser-tools/tools/network-mock.ts +244 -0
- package/src/resources/extensions/browser-tools/tools/pdf.ts +92 -0
- package/src/resources/extensions/browser-tools/tools/state-persistence.ts +202 -0
- package/src/resources/extensions/browser-tools/tools/visual-diff.ts +209 -0
- package/src/resources/extensions/browser-tools/tools/zoom.ts +104 -0
- package/src/resources/extensions/gsd/auto-dashboard.ts +2 -0
- package/src/resources/extensions/gsd/auto-dispatch.ts +51 -2
- package/src/resources/extensions/gsd/auto-prompts.ts +73 -0
- package/src/resources/extensions/gsd/auto-recovery.ts +51 -2
- package/src/resources/extensions/gsd/auto-worktree.ts +15 -3
- package/src/resources/extensions/gsd/auto.ts +560 -52
- package/src/resources/extensions/gsd/captures.ts +49 -0
- package/src/resources/extensions/gsd/commands.ts +194 -11
- package/src/resources/extensions/gsd/complexity.ts +1 -0
- package/src/resources/extensions/gsd/dashboard-overlay.ts +54 -2
- package/src/resources/extensions/gsd/diff-context.ts +73 -80
- package/src/resources/extensions/gsd/doctor.ts +76 -12
- package/src/resources/extensions/gsd/exit-command.ts +2 -2
- package/src/resources/extensions/gsd/forensics.ts +95 -52
- package/src/resources/extensions/gsd/gitignore.ts +1 -0
- package/src/resources/extensions/gsd/guided-flow.ts +85 -5
- package/src/resources/extensions/gsd/index.ts +34 -1
- package/src/resources/extensions/gsd/mcp-server.ts +33 -12
- package/src/resources/extensions/gsd/parallel-eligibility.ts +233 -0
- package/src/resources/extensions/gsd/parallel-merge.ts +156 -0
- package/src/resources/extensions/gsd/parallel-orchestrator.ts +496 -0
- package/src/resources/extensions/gsd/post-unit-hooks.ts +2 -1
- package/src/resources/extensions/gsd/preferences.ts +65 -1
- package/src/resources/extensions/gsd/prompts/discuss-headless.md +86 -0
- package/src/resources/extensions/gsd/prompts/execute-task.md +5 -0
- package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +104 -1
- package/src/resources/extensions/gsd/prompts/plan-milestone.md +1 -0
- package/src/resources/extensions/gsd/prompts/research-slice.md +1 -1
- package/src/resources/extensions/gsd/prompts/system.md +2 -1
- package/src/resources/extensions/gsd/prompts/validate-milestone.md +70 -0
- package/src/resources/extensions/gsd/provider-error-pause.ts +29 -2
- package/src/resources/extensions/gsd/roadmap-slices.ts +41 -1
- package/src/resources/extensions/gsd/session-forensics.ts +36 -2
- package/src/resources/extensions/gsd/session-status-io.ts +197 -0
- package/src/resources/extensions/gsd/state.ts +72 -30
- package/src/resources/extensions/gsd/templates/milestone-validation.md +62 -0
- package/src/resources/extensions/gsd/tests/agent-end-provider-error.test.ts +81 -0
- package/src/resources/extensions/gsd/tests/auto-budget-alerts.test.ts +20 -3
- package/src/resources/extensions/gsd/tests/auto-lock-creation.test.ts +186 -0
- package/src/resources/extensions/gsd/tests/auto-preflight.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/auto-recovery.test.ts +264 -0
- package/src/resources/extensions/gsd/tests/auto-skip-loop.test.ts +123 -0
- package/src/resources/extensions/gsd/tests/auto-worktree-milestone-merge.test.ts +34 -0
- package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +8 -1
- package/src/resources/extensions/gsd/tests/derive-state-db.test.ts +9 -15
- package/src/resources/extensions/gsd/tests/derive-state-deps.test.ts +9 -0
- package/src/resources/extensions/gsd/tests/derive-state-draft.test.ts +8 -0
- package/src/resources/extensions/gsd/tests/derive-state.test.ts +14 -0
- package/src/resources/extensions/gsd/tests/doctor.test.ts +58 -0
- package/src/resources/extensions/gsd/tests/in-flight-tool-tracking.test.ts +17 -6
- package/src/resources/extensions/gsd/tests/integration/headless-command.ts +534 -0
- package/src/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +8 -0
- package/src/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +5 -5
- package/src/resources/extensions/gsd/tests/parallel-orchestration.test.ts +656 -0
- package/src/resources/extensions/gsd/tests/parallel-workers-multi-milestone-e2e.test.ts +354 -0
- package/src/resources/extensions/gsd/tests/queue-reorder-e2e.test.ts +1 -0
- package/src/resources/extensions/gsd/tests/roadmap-slices.test.ts +43 -1
- package/src/resources/extensions/gsd/tests/triage-dispatch.test.ts +120 -0
- package/src/resources/extensions/gsd/tests/triage-resolution.test.ts +203 -2
- package/src/resources/extensions/gsd/tests/validate-milestone.test.ts +316 -0
- package/src/resources/extensions/gsd/tests/visualizer-overlay.test.ts +8 -3
- package/src/resources/extensions/gsd/tests/worker-registry.test.ts +148 -0
- package/src/resources/extensions/gsd/triage-resolution.ts +83 -0
- package/src/resources/extensions/gsd/types.ts +15 -1
- package/src/resources/extensions/gsd/visualizer-overlay.ts +8 -1
- package/src/resources/extensions/gsd/workspace-index.ts +34 -6
- package/src/resources/extensions/subagent/index.ts +5 -0
- package/src/resources/extensions/subagent/worker-registry.ts +99 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
# Headless Milestone Creation
|
|
2
|
+
|
|
3
|
+
You are creating a GSD milestone from a provided specification document. This is a **headless** (non-interactive) flow — do NOT ask the user any questions. Work entirely from the provided specification.
|
|
4
|
+
|
|
5
|
+
## Provided Specification
|
|
6
|
+
|
|
7
|
+
{{seedContext}}
|
|
8
|
+
|
|
9
|
+
## Your Task
|
|
10
|
+
|
|
11
|
+
### Step 1: Reflect
|
|
12
|
+
|
|
13
|
+
Summarize your understanding of the specification concretely:
|
|
14
|
+
- What is being built
|
|
15
|
+
- Major capabilities/features
|
|
16
|
+
- Scope estimate (how many milestones × slices)
|
|
17
|
+
- Any ambiguities or gaps you notice
|
|
18
|
+
|
|
19
|
+
### Step 2: Investigate
|
|
20
|
+
|
|
21
|
+
Scout the codebase to understand what already exists:
|
|
22
|
+
- `ls` the project root and key directories
|
|
23
|
+
- Search for relevant existing code, patterns, dependencies
|
|
24
|
+
- Check library docs if needed (`resolve_library` / `get_library_docs`)
|
|
25
|
+
|
|
26
|
+
### Step 3: Make Decisions
|
|
27
|
+
|
|
28
|
+
For any ambiguities or gaps in the specification:
|
|
29
|
+
- Make your best-guess decision based on the spec's intent, codebase patterns, and domain conventions
|
|
30
|
+
- Document each assumption clearly in the Context file
|
|
31
|
+
|
|
32
|
+
### Step 4: Assess Scope
|
|
33
|
+
|
|
34
|
+
Based on reflection + investigation:
|
|
35
|
+
- Is this a single milestone or multiple milestones?
|
|
36
|
+
- If multi-milestone: plan the full sequence with dependencies
|
|
37
|
+
|
|
38
|
+
### Step 5: Write Artifacts
|
|
39
|
+
|
|
40
|
+
**Milestone ID**: {{milestoneId}}
|
|
41
|
+
|
|
42
|
+
Use these templates exactly:
|
|
43
|
+
|
|
44
|
+
{{inlinedTemplates}}
|
|
45
|
+
|
|
46
|
+
**For single milestone**, write in this order:
|
|
47
|
+
1. `mkdir -p .gsd/milestones/{{milestoneId}}/slices`
|
|
48
|
+
2. Write `.gsd/PROJECT.md` (using Project template)
|
|
49
|
+
3. Write `.gsd/REQUIREMENTS.md` (using Requirements template)
|
|
50
|
+
4. Write `{{contextPath}}` (using Context template) — preserve the specification's exact terminology, emphasis, and specific framing. Do not paraphrase domain-specific language into generics. Document assumptions under an "Assumptions" section.
|
|
51
|
+
5. Write `{{roadmapPath}}` (using Roadmap template) — decompose into demoable vertical slices with checkboxes, risk, depends, demo sentences, proof strategy, verification classes, milestone definition of done, requirement coverage, and a boundary map. If the milestone crosses multiple runtime boundaries, include an explicit final integration slice.
|
|
52
|
+
6. Seed `.gsd/DECISIONS.md` (using Decisions template)
|
|
53
|
+
7. Update `.gsd/STATE.md`
|
|
54
|
+
8. Commit: `docs({{milestoneId}}): context, requirements, and roadmap`
|
|
55
|
+
9. Say exactly: "Milestone {{milestoneId}} ready."
|
|
56
|
+
|
|
57
|
+
**For multi-milestone**, write in this order:
|
|
58
|
+
1. Create all milestone directories: `mkdir -p .gsd/milestones/{M###}/slices` for each
|
|
59
|
+
2. Write `.gsd/PROJECT.md` — full vision across ALL milestones (using Project template)
|
|
60
|
+
3. Write `.gsd/REQUIREMENTS.md` — full capability contract (using Requirements template)
|
|
61
|
+
4. Seed `.gsd/DECISIONS.md` (using Decisions template)
|
|
62
|
+
5. Write PRIMARY `{{contextPath}}` — full context with all assumptions documented
|
|
63
|
+
6. Write PRIMARY `{{roadmapPath}}` — detailed slices for the first milestone only
|
|
64
|
+
7. For each remaining milestone, write full CONTEXT.md with `depends_on` frontmatter:
|
|
65
|
+
```yaml
|
|
66
|
+
---
|
|
67
|
+
depends_on: [M001, M002]
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
# M003: Title
|
|
71
|
+
```
|
|
72
|
+
Each context file should be rich enough that a future agent — with no memory of this conversation — can understand the intent, constraints, dependencies, what the milestone unlocks, and what "done" looks like.
|
|
73
|
+
8. Update `.gsd/STATE.md`
|
|
74
|
+
9. Commit: `docs: project plan — N milestones`
|
|
75
|
+
10. Say exactly: "Milestone {{milestoneId}} ready."
|
|
76
|
+
|
|
77
|
+
## Critical Rules
|
|
78
|
+
|
|
79
|
+
- **DO NOT ask the user any questions** — this is headless mode
|
|
80
|
+
- **Preserve the specification's terminology** — don't paraphrase domain-specific language
|
|
81
|
+
- **Document assumptions** — when you make a judgment call, note it in CONTEXT.md under "Assumptions"
|
|
82
|
+
- **Investigate before writing** — always scout the codebase first
|
|
83
|
+
- **Use depends_on frontmatter** for multi-milestone sequences (the state machine reads this field to determine execution order)
|
|
84
|
+
- **Anti-reduction rule** — if the spec describes a big vision, plan the big vision. Do not ask "what's the minimum viable version?" or reduce scope. Phase complex/risky work into later milestones — do not cut it.
|
|
85
|
+
- **Naming convention** — directories use bare IDs (`M001/`, `S01/`), files use ID-SUFFIX format (`M001-CONTEXT.md`, `M001-ROADMAP.md`)
|
|
86
|
+
- **End with "Milestone {{milestoneId}} ready."** — this triggers auto-start detection
|
|
@@ -31,6 +31,11 @@ Then:
|
|
|
31
31
|
3. Build the real thing. If the task plan says "create login endpoint", build an endpoint that actually authenticates against a real store, not one that returns a hardcoded success response. If the task plan says "create dashboard page", build a page that renders real data from the API, not a component with hardcoded props. Stubs and mocks are for tests, not for the shipped feature.
|
|
32
32
|
4. Write or update tests as part of execution — tests are verification, not an afterthought. If the slice plan defines test files in its Verification section and this is the first task, create them (they should initially fail).
|
|
33
33
|
5. When implementing non-trivial runtime behavior (async flows, API boundaries, background processes, error paths), add or preserve agent-usable observability. Skip this for simple changes where it doesn't apply.
|
|
34
|
+
|
|
35
|
+
**Background process rule:** Never use bare `command &` to run background processes. The shell's `&` operator leaves stdout/stderr attached to the parent, which causes the Bash tool to hang indefinitely waiting for those streams to close. Always redirect output before backgrounding:
|
|
36
|
+
- Correct: `command > /dev/null 2>&1 &` or `nohup command > /dev/null 2>&1 &`
|
|
37
|
+
- Example: `python -m http.server 8080 > /dev/null 2>&1 &` (NOT `python -m http.server 8080 &`)
|
|
38
|
+
- Preferred: use the `bg_shell` tool if available — it manages process lifecycle correctly without stream-inheritance issues
|
|
34
39
|
6. Verify must-haves are met by running concrete checks (tests, commands, observable behaviors)
|
|
35
40
|
7. Run the slice-level verification checks defined in the slice plan's Verification section. Track which pass. On the final task of the slice, all must pass before marking done. On intermediate tasks, partial passes are expected — note which ones pass in the summary.
|
|
36
41
|
8. If the task touches UI, browser flows, DOM behavior, or user-visible web state:
|
|
@@ -1,5 +1,108 @@
|
|
|
1
1
|
Discuss milestone {{milestoneId}} ("{{milestoneTitle}}"). Identify gray areas, ask the user about them, and write `{{milestoneId}}-CONTEXT.md` in the milestone directory with the decisions. Use the **Context** output template below. If a `GSD Skill Preferences` block is present in system context, use it to decide which skills to load and follow; do not override required artifact rules.
|
|
2
2
|
|
|
3
|
+
**Structured questions available: {{structuredQuestionsAvailable}}**
|
|
4
|
+
|
|
3
5
|
{{inlinedTemplates}}
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Interview Protocol
|
|
10
|
+
|
|
11
|
+
### Before your first question round
|
|
12
|
+
|
|
13
|
+
Do a lightweight targeted investigation so your questions are grounded in reality:
|
|
14
|
+
- Scout the codebase (`rg`, `find`, or `scout`) to understand what already exists that this milestone touches or builds on
|
|
15
|
+
- Check the roadmap context above (if present) to understand what surrounds this milestone
|
|
16
|
+
- Identify the 3–5 biggest behavioural and architectural unknowns: things where the user's answer will materially change what gets built
|
|
17
|
+
|
|
18
|
+
Do **not** go deep — just enough that your questions reflect what's actually true rather than what you assume.
|
|
19
|
+
|
|
20
|
+
### Question rounds
|
|
21
|
+
|
|
22
|
+
Ask **1–3 questions per round**. Keep each question focused on one of:
|
|
23
|
+
- **What they're building** — concrete enough to explain to a stranger
|
|
24
|
+
- **Why it needs to exist** — the problem it solves or the desire it fulfills
|
|
25
|
+
- **Who it's for** — user, team, themselves
|
|
26
|
+
- **What "done" looks like** — observable outcomes, not abstract goals
|
|
27
|
+
- **The biggest technical unknowns / risks** — what could fail, what hasn't been proven
|
|
28
|
+
- **What external systems/services this touches** — APIs, databases, third-party services
|
|
29
|
+
|
|
30
|
+
**If `{{structuredQuestionsAvailable}}` is `true`:** use `ask_user_questions` for each round. 1–3 questions per call, each as a separate question object. Keep option labels short (3–5 words). Always include a freeform "Other / let me explain" option. When the user picks that option or writes a long freeform answer, switch to plain text follow-up for that thread before resuming structured questions.
|
|
31
|
+
|
|
32
|
+
**If `{{structuredQuestionsAvailable}}` is `false`:** ask questions in plain text. Keep each round to 1–3 focused questions. Wait for answers before asking the next round.
|
|
33
|
+
|
|
34
|
+
After the user answers, investigate further if any answer opens a new unknown, then ask the next round.
|
|
35
|
+
|
|
36
|
+
### Check-in after each round
|
|
37
|
+
|
|
38
|
+
After each round of answers, ask:
|
|
39
|
+
|
|
40
|
+
> "I think I have a solid picture of this milestone. Ready to wrap up and write the context file, or is there more to cover?"
|
|
41
|
+
|
|
42
|
+
**If `{{structuredQuestionsAvailable}}` is `true`:** use `ask_user_questions` with options:
|
|
43
|
+
- "Wrap up — write the context file" *(recommended after ~2–3 rounds)*
|
|
44
|
+
- "Keep going — more to discuss"
|
|
45
|
+
|
|
46
|
+
**If `{{structuredQuestionsAvailable}}` is `false`:** ask in plain text.
|
|
47
|
+
|
|
48
|
+
If the user wants to keep going, keep asking. Stop when they say wrap up.
|
|
49
|
+
|
|
50
|
+
---
|
|
51
|
+
|
|
52
|
+
## Questioning philosophy
|
|
53
|
+
|
|
54
|
+
**Start open, follow energy.** Let the user's enthusiasm guide where you dig deeper.
|
|
55
|
+
|
|
56
|
+
**Challenge vagueness, make abstract concrete.** When the user says something abstract ("it should be smart" / "good UX"), push for specifics.
|
|
57
|
+
|
|
58
|
+
**Questions must be about the experience, not the implementation.** Never ask "what auth provider?" — ask "when someone logs in, what should that feel like?" Implementation is your job. Understanding what they want to experience is the discussion's job.
|
|
59
|
+
|
|
60
|
+
**Position-first framing.** Have opinions. "I'd lean toward X because Y — does that match your thinking?" is better than "what do you think about X vs Y?"
|
|
61
|
+
|
|
62
|
+
**Negative constraints.** Ask what would disappoint them. What they explicitly don't want. Negative constraints are sharper than positive wishes.
|
|
63
|
+
|
|
64
|
+
**Anti-patterns — never do these:**
|
|
65
|
+
- Checklist walking through predetermined topics regardless of what the user said
|
|
66
|
+
- Canned generic questions that could apply to any project
|
|
67
|
+
- Corporate speak ("What are your key success metrics?")
|
|
68
|
+
- Rapid-fire questions without acknowledging answers
|
|
69
|
+
- Asking about technical skill level
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Depth Verification
|
|
74
|
+
|
|
75
|
+
Before moving to the wrap-up gate, verify you have covered:
|
|
76
|
+
|
|
77
|
+
- [ ] What they're building — concrete enough to explain to a stranger
|
|
78
|
+
- [ ] Why it needs to exist
|
|
79
|
+
- [ ] Who it's for
|
|
80
|
+
- [ ] What "done" looks like
|
|
81
|
+
- [ ] The biggest technical unknowns / risks
|
|
82
|
+
- [ ] What external systems/services this touches
|
|
83
|
+
|
|
84
|
+
**Print a structured depth summary in chat first** — using the user's own terminology. Cover what you understood, what shaped your understanding, and any areas of remaining uncertainty.
|
|
85
|
+
|
|
86
|
+
**Then confirm:**
|
|
87
|
+
|
|
88
|
+
**If `{{structuredQuestionsAvailable}}` is `true`:** use `ask_user_questions` with:
|
|
89
|
+
- header: "Depth Check"
|
|
90
|
+
- question: "Did I capture the depth right?"
|
|
91
|
+
- options: "Yes, you got it (Recommended)", "Not quite — let me clarify"
|
|
92
|
+
- **The question ID must contain `depth_verification`** (e.g. `depth_verification_confirm`) — this enables the write-gate downstream.
|
|
93
|
+
|
|
94
|
+
**If `{{structuredQuestionsAvailable}}` is `false`:** ask in plain text: "Did I capture that correctly? Anything I missed?" Wait for confirmation before proceeding.
|
|
95
|
+
|
|
96
|
+
If they clarify, absorb the correction and re-verify.
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## Output
|
|
101
|
+
|
|
102
|
+
Once the user confirms depth:
|
|
103
|
+
|
|
104
|
+
1. Use the **Context** output template below
|
|
105
|
+
2. `mkdir -p` the milestone directory if needed
|
|
106
|
+
3. Write `{{milestoneId}}-CONTEXT.md` — preserve the user's exact terminology, emphasis, and framing. Do not paraphrase nuance into generic summaries. The context file is downstream agents' only window into this conversation.
|
|
107
|
+
4. Commit: `git add {{milestoneId}}-CONTEXT.md && git commit -m "docs({{milestoneId}}): milestone context from discuss"`
|
|
108
|
+
5. Say exactly: `"{{milestoneId}} context written."` — nothing else.
|
|
@@ -51,6 +51,7 @@ Apply these when decomposing and ordering slices:
|
|
|
51
51
|
- **Completion must imply capability.** If every slice in this roadmap were completed exactly as written, the milestone's promised outcome should actually work at the proof level claimed. Do not write slices that can all be checked off while the user-visible capability still does not exist.
|
|
52
52
|
- **Don't invent risks.** If the project is straightforward, skip the proof strategy and just ship value in smart order. Not everything has major unknowns.
|
|
53
53
|
- **Ship features, not proofs.** A completed slice should leave the product in a state where the new capability is actually usable through its real interface. A login flow slice ends with a working login page, not a middleware function. An API slice ends with endpoints that return real data from a real store, not hardcoded fixtures. A dashboard slice ends with a real dashboard rendering real data, not a component that renders mock props. If a slice can't ship the real thing yet because a dependency isn't built, it should ship with realistic stubs that are clearly marked for replacement — but the user-facing surface must be real.
|
|
54
|
+
- **Dependency format is comma-separated, never range syntax.** Write `depends:[S01,S02,S03]` — not `depends:[S01-S03]`. Range syntax is not a valid format and permanently blocks the slice.
|
|
54
55
|
- **Ambition matches the milestone.** The number and depth of slices should match the milestone's ambition. A milestone promising "core platform with auth, data model, and primary user loop" should have enough slices to actually deliver all three as working features — not two proof-of-concept slices and a note that "the rest will come in the next milestone." If the milestone's context promises an outcome, the roadmap must deliver it.
|
|
55
56
|
- **Right-size the decomposition.** Match slice count to actual complexity. If the work is small enough to build and verify in one pass, it's one slice — don't split it into three just because you can identify sub-steps. Multiple requirements can share a single slice. Conversely, don't cram genuinely independent capabilities into one slice just to keep the count low. Let the work dictate the structure.
|
|
56
57
|
|
|
@@ -46,7 +46,7 @@ Research what this slice needs. Narrate key findings and surprises as you go —
|
|
|
46
46
|
2. **Skill Discovery ({{skillDiscoveryMode}}):**{{skillDiscoveryInstructions}}
|
|
47
47
|
3. Explore relevant code for this slice's scope. For targeted exploration, use `rg`, `find`, and reads. For broad or unfamiliar subsystems, use `scout` to map the relevant area first.
|
|
48
48
|
4. Use `resolve_library` / `get_library_docs` for unfamiliar libraries — skip this for libraries already used in the codebase
|
|
49
|
-
5. Use the **Research** output template from the inlined context above — include only sections that have real content
|
|
49
|
+
5. Use the **Research** output template from the inlined context above — include only sections that have real content. The template is already inlined above; do NOT attempt to read any template file from disk (there is no `templates/SLICE-RESEARCH.md` — the correct template is already present in this prompt).
|
|
50
50
|
6. Write `{{outputPath}}`
|
|
51
51
|
|
|
52
52
|
The slice directory already exists at `{{slicePath}}/`. Do NOT mkdir — just write the file.
|
|
@@ -154,7 +154,7 @@ Templates showing the expected format for each artifact type are in:
|
|
|
154
154
|
|
|
155
155
|
**External facts:** Use `search-the-web` + `fetch_page`, or `search_and_read` for one-call extraction. Use `freshness` for recency. Never state current facts from training data without verification.
|
|
156
156
|
|
|
157
|
-
**Background processes:** Use `bg_shell` with `start` + `wait_for_ready` for servers, watchers, and daemons. Never poll with `sleep`/retry loops — `wait_for_ready` exists for this. For status checks, use `digest` (~30 tokens), not `output` (~2000 tokens). Use `highlights` (~100 tokens) when you need significant lines only. Use `output` only when actively debugging.
|
|
157
|
+
**Background processes:** Use `bg_shell` with `start` + `wait_for_ready` for servers, watchers, and daemons. Never use `bash` with `&` or `nohup` to background a process — the `bash` tool waits for stdout to close, so backgrounded children that inherit the file descriptors cause it to hang indefinitely. Never poll with `sleep`/retry loops — `wait_for_ready` exists for this. For status checks, use `digest` (~30 tokens), not `output` (~2000 tokens). Use `highlights` (~100 tokens) when you need significant lines only. Use `output` only when actively debugging.
|
|
158
158
|
|
|
159
159
|
**One-shot commands:** Use `async_bash` for builds, tests, and installs. The result is pushed to you when the command exits — no polling needed. Use `await_job` to block on a specific job.
|
|
160
160
|
|
|
@@ -169,6 +169,7 @@ Templates showing the expected format for each artifact type are in:
|
|
|
169
169
|
- Never use `cat` to read a file you might edit — `read` gives you the exact text `edit` needs.
|
|
170
170
|
- Never `grep` for a function definition when `lsp` go-to-definition is available.
|
|
171
171
|
- Never poll a server with `sleep 1 && curl` loops — use `bg_shell` `wait_for_ready`.
|
|
172
|
+
- Never use `bash` with `&` to background a process — it hangs because the child inherits stdout. Use `bg_shell` `start` instead.
|
|
172
173
|
- Never use `bg_shell` `output` for a status check — use `digest`.
|
|
173
174
|
- Never read files one-by-one to understand a subsystem — use `rg` or `scout` first.
|
|
174
175
|
- Never guess at library APIs from training data — use `get_library_docs`.
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
You are executing GSD auto-mode.
|
|
2
|
+
|
|
3
|
+
## UNIT: Validate Milestone {{milestoneId}} ("{{milestoneTitle}}")
|
|
4
|
+
|
|
5
|
+
## Working Directory
|
|
6
|
+
|
|
7
|
+
Your working directory is `{{workingDirectory}}`. All file reads, writes, and shell commands MUST operate relative to this directory. Do NOT `cd` to any other directory.
|
|
8
|
+
|
|
9
|
+
## Your Role in the Pipeline
|
|
10
|
+
|
|
11
|
+
All slices are done. Before the milestone can be completed, you must validate that the planned work was delivered as specified. Compare the roadmap's success criteria and slice definitions against the actual slice summaries and UAT results. This is a reconciliation gate — catch gaps, regressions, or missing deliverables before the milestone is sealed.
|
|
12
|
+
|
|
13
|
+
This is remediation round {{remediationRound}}. If this is round 0, this is the first validation pass. If > 0, prior validation found issues and remediation slices were added and executed — verify those remediation slices resolved the issues.
|
|
14
|
+
|
|
15
|
+
All relevant context has been preloaded below — the roadmap, all slice summaries, UAT results, requirements, decisions, and project context are inlined. Start working immediately without re-reading these files.
|
|
16
|
+
|
|
17
|
+
{{inlinedContext}}
|
|
18
|
+
|
|
19
|
+
## Validation Steps
|
|
20
|
+
|
|
21
|
+
1. For each **success criterion** in `{{roadmapPath}}`, check whether slice summaries and UAT results provide evidence that it was met. Record pass/fail per criterion.
|
|
22
|
+
2. For each **slice** in the roadmap, verify its demo/deliverable claim against its summary. Flag any slice whose summary does not substantiate its claimed output.
|
|
23
|
+
3. Check **cross-slice integration points** — do boundary map entries (produces/consumes) align with what was actually built?
|
|
24
|
+
4. Check **requirement coverage** — are all active requirements addressed by at least one slice?
|
|
25
|
+
5. Determine a verdict:
|
|
26
|
+
- `pass` — all criteria met, all slices delivered, no gaps
|
|
27
|
+
- `needs-attention` — minor gaps that do not block completion (document them)
|
|
28
|
+
- `needs-remediation` — material gaps found; add remediation slices to the roadmap
|
|
29
|
+
|
|
30
|
+
## Output
|
|
31
|
+
|
|
32
|
+
Write `{{validationPath}}` with this structure:
|
|
33
|
+
|
|
34
|
+
```markdown
|
|
35
|
+
---
|
|
36
|
+
verdict: <pass|needs-attention|needs-remediation>
|
|
37
|
+
remediation_round: {{remediationRound}}
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
# Milestone Validation: {{milestoneId}}
|
|
41
|
+
|
|
42
|
+
## Success Criteria Checklist
|
|
43
|
+
- [x] Criterion 1 — evidence: ...
|
|
44
|
+
- [ ] Criterion 2 — gap: ...
|
|
45
|
+
|
|
46
|
+
## Slice Delivery Audit
|
|
47
|
+
| Slice | Claimed | Delivered | Status |
|
|
48
|
+
|-------|---------|-----------|--------|
|
|
49
|
+
| S01 | ... | ... | pass |
|
|
50
|
+
|
|
51
|
+
## Cross-Slice Integration
|
|
52
|
+
(any boundary mismatches)
|
|
53
|
+
|
|
54
|
+
## Requirement Coverage
|
|
55
|
+
(any unaddressed requirements)
|
|
56
|
+
|
|
57
|
+
## Verdict Rationale
|
|
58
|
+
(why this verdict was chosen)
|
|
59
|
+
|
|
60
|
+
## Remediation Plan
|
|
61
|
+
(only if verdict is needs-remediation — list new slices to add to the roadmap)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
If verdict is `needs-remediation`:
|
|
65
|
+
- Add new slices to `{{roadmapPath}}` with unchecked `[ ]` status
|
|
66
|
+
- These slices will be planned and executed before validation re-runs
|
|
67
|
+
|
|
68
|
+
**You MUST write `{{validationPath}}` before finishing.**
|
|
69
|
+
|
|
70
|
+
When done, say: "Milestone {{milestoneId}} validation complete — verdict: <verdict>."
|
|
@@ -2,11 +2,38 @@ export type ProviderErrorPauseUI = {
|
|
|
2
2
|
notify(message: string, level?: "info" | "warning" | "error" | "success"): void;
|
|
3
3
|
};
|
|
4
4
|
|
|
5
|
+
/**
|
|
6
|
+
* Pause auto-mode due to a provider error.
|
|
7
|
+
*
|
|
8
|
+
* For rate-limit errors with a known reset delay, schedules an automatic
|
|
9
|
+
* resume after the delay and shows a countdown notification. For all other
|
|
10
|
+
* errors, pauses indefinitely (user must manually resume).
|
|
11
|
+
*/
|
|
5
12
|
export async function pauseAutoForProviderError(
|
|
6
13
|
ui: ProviderErrorPauseUI,
|
|
7
14
|
errorDetail: string,
|
|
8
15
|
pause: () => Promise<void>,
|
|
16
|
+
options?: {
|
|
17
|
+
isRateLimit?: boolean;
|
|
18
|
+
retryAfterMs?: number;
|
|
19
|
+
resume?: () => void;
|
|
20
|
+
},
|
|
9
21
|
): Promise<void> {
|
|
10
|
-
|
|
11
|
-
|
|
22
|
+
if (options?.isRateLimit && options.retryAfterMs && options.retryAfterMs > 0 && options.resume) {
|
|
23
|
+
const delaySec = Math.ceil(options.retryAfterMs / 1000);
|
|
24
|
+
ui.notify(
|
|
25
|
+
`Rate limited${errorDetail}. Auto-resuming in ${delaySec}s...`,
|
|
26
|
+
"warning",
|
|
27
|
+
);
|
|
28
|
+
await pause();
|
|
29
|
+
|
|
30
|
+
// Schedule auto-resume after the rate limit window
|
|
31
|
+
setTimeout(() => {
|
|
32
|
+
ui.notify("Rate limit window elapsed. Resuming auto-mode.", "info");
|
|
33
|
+
options.resume!();
|
|
34
|
+
}, options.retryAfterMs);
|
|
35
|
+
} else {
|
|
36
|
+
ui.notify(`Auto-mode paused due to provider error${errorDetail}`, "warning");
|
|
37
|
+
await pause();
|
|
38
|
+
}
|
|
12
39
|
}
|
|
@@ -1,5 +1,45 @@
|
|
|
1
1
|
import type { RoadmapSliceEntry, RiskLevel } from "./types.js";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Expand dependency shorthand into individual slice IDs.
|
|
5
|
+
*
|
|
6
|
+
* Handles two common LLM-generated patterns that the roadmap parser
|
|
7
|
+
* previously treated as single literal IDs (silently blocking slices):
|
|
8
|
+
*
|
|
9
|
+
* "S01-S04" → ["S01", "S02", "S03", "S04"] (range syntax)
|
|
10
|
+
* "S01..S04" → ["S01", "S02", "S03", "S04"] (dot-range syntax)
|
|
11
|
+
*
|
|
12
|
+
* Plain IDs ("S01", "S02") and empty strings pass through unchanged.
|
|
13
|
+
*/
|
|
14
|
+
export function expandDependencies(deps: string[]): string[] {
|
|
15
|
+
const result: string[] = [];
|
|
16
|
+
for (const dep of deps) {
|
|
17
|
+
const trimmed = dep.trim();
|
|
18
|
+
if (!trimmed) continue;
|
|
19
|
+
|
|
20
|
+
// Match range syntax: S01-S04 or S01..S04 (case-insensitive prefix)
|
|
21
|
+
const rangeMatch = trimmed.match(/^([A-Za-z]+)(\d+)(?:-|\.\.)+([A-Za-z]+)(\d+)$/);
|
|
22
|
+
if (rangeMatch) {
|
|
23
|
+
const prefixA = rangeMatch[1]!.toUpperCase();
|
|
24
|
+
const startNum = parseInt(rangeMatch[2]!, 10);
|
|
25
|
+
const prefixB = rangeMatch[3]!.toUpperCase();
|
|
26
|
+
const endNum = parseInt(rangeMatch[4]!, 10);
|
|
27
|
+
|
|
28
|
+
// Only expand when both prefixes match and range is valid
|
|
29
|
+
if (prefixA === prefixB && startNum <= endNum) {
|
|
30
|
+
const width = rangeMatch[2]!.length; // preserve zero-padding (S01 not S1)
|
|
31
|
+
for (let i = startNum; i <= endNum; i++) {
|
|
32
|
+
result.push(`${prefixA}${String(i).padStart(width, "0")}`);
|
|
33
|
+
}
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
result.push(trimmed);
|
|
39
|
+
}
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
3
43
|
function extractSlicesSection(content: string): string {
|
|
4
44
|
const headingMatch = /^## Slices\s*$/m.exec(content);
|
|
5
45
|
if (!headingMatch || headingMatch.index == null) return "";
|
|
@@ -33,7 +73,7 @@ export function parseRoadmapSlices(content: string): RoadmapSliceEntry[] {
|
|
|
33
73
|
|
|
34
74
|
const depsMatch = rest.match(/`depends:\[([^\]]*)\]`/);
|
|
35
75
|
const depends = depsMatch && depsMatch[1]!.trim()
|
|
36
|
-
? depsMatch[1]!.split(",").map(s => s.trim())
|
|
76
|
+
? expandDependencies(depsMatch[1]!.split(",").map(s => s.trim()))
|
|
37
77
|
: [];
|
|
38
78
|
|
|
39
79
|
currentSlice = { id, title, risk, depends, done, demo: "" };
|
|
@@ -22,6 +22,7 @@ import { readFileSync, readdirSync, existsSync, statSync } from "node:fs";
|
|
|
22
22
|
import { basename, join } from "node:path";
|
|
23
23
|
import { nativeParseJsonlTail } from "./native-parser-bridge.js";
|
|
24
24
|
import { nativeWorkingTreeStatus, nativeDiffStat } from "./native-git-bridge.js";
|
|
25
|
+
import { getAutoWorktreePath } from "./auto-worktree.js";
|
|
25
26
|
|
|
26
27
|
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
27
28
|
|
|
@@ -296,12 +297,45 @@ export function synthesizeCrashRecovery(
|
|
|
296
297
|
* Replaces the old shallow getLastActivityDiagnostic().
|
|
297
298
|
*/
|
|
298
299
|
export function getDeepDiagnostic(basePath: string): string | null {
|
|
299
|
-
|
|
300
|
-
|
|
300
|
+
// Try worktree activity logs first if an auto-worktree is active
|
|
301
|
+
let trace: ExecutionTrace | null = null;
|
|
302
|
+
try {
|
|
303
|
+
const mid = readActiveMilestoneId(basePath);
|
|
304
|
+
if (mid) {
|
|
305
|
+
const wtPath = getAutoWorktreePath(basePath, mid);
|
|
306
|
+
if (wtPath) {
|
|
307
|
+
const wtActivityDir = join(wtPath, ".gsd", "activity");
|
|
308
|
+
trace = readLastActivityLog(wtActivityDir);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
} catch { /* non-fatal — fall through to root */ }
|
|
312
|
+
|
|
313
|
+
// Fall back to root activity logs
|
|
314
|
+
if (!trace || trace.toolCallCount === 0) {
|
|
315
|
+
const activityDir = join(basePath, ".gsd", "activity");
|
|
316
|
+
trace = readLastActivityLog(activityDir);
|
|
317
|
+
}
|
|
318
|
+
|
|
301
319
|
if (!trace || trace.toolCallCount === 0) return null;
|
|
302
320
|
return formatTraceSummary(trace);
|
|
303
321
|
}
|
|
304
322
|
|
|
323
|
+
/**
|
|
324
|
+
* Read the active milestone ID directly from STATE.md without async deriveState().
|
|
325
|
+
* Looks for `**Active Milestone:** M001` pattern.
|
|
326
|
+
*/
|
|
327
|
+
function readActiveMilestoneId(basePath: string): string | null {
|
|
328
|
+
try {
|
|
329
|
+
const statePath = join(basePath, ".gsd", "STATE.md");
|
|
330
|
+
if (!existsSync(statePath)) return null;
|
|
331
|
+
const content = readFileSync(statePath, "utf-8");
|
|
332
|
+
const match = /\*\*Active Milestone:\*\*\s*(\S+)/i.exec(content);
|
|
333
|
+
return match?.[1] ?? null;
|
|
334
|
+
} catch {
|
|
335
|
+
return null;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
305
339
|
// ─── Formatting ───────────────────────────────────────────────────────────────
|
|
306
340
|
|
|
307
341
|
function formatRecoveryPrompt(
|