golden-hoop-spell-opencode 0.1.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.
Files changed (55) hide show
  1. package/README.md +184 -0
  2. package/package.json +51 -0
  3. package/shared/SPIKE_RESULTS.md +597 -0
  4. package/shared/agents/ghs-context-haiku.md.template +124 -0
  5. package/shared/agents/ghs-plan-designer.md.template +128 -0
  6. package/shared/agents/ghs-plan-reviewer.md.template +170 -0
  7. package/shared/assets/features.json +67 -0
  8. package/shared/assets/progress.md +35 -0
  9. package/shared/ghs.default.json +7 -0
  10. package/shared/ghs.default.json.notes.md +34 -0
  11. package/shared/ghs.json.example +7 -0
  12. package/shared/opencode.json.example +11 -0
  13. package/shared/references/coding-agent.md +533 -0
  14. package/shared/references/context-snapshot-guide.md +98 -0
  15. package/shared/references/examples.md +299 -0
  16. package/shared/references/plan-designer.md +163 -0
  17. package/shared/references/plan-reviewer.md +193 -0
  18. package/shared/references/sprint-agent.md +261 -0
  19. package/src/index.ts +9 -0
  20. package/src/lib/assets.ts +31 -0
  21. package/src/lib/codegraph.ts +66 -0
  22. package/src/lib/config.ts +278 -0
  23. package/src/lib/nonce.ts +56 -0
  24. package/src/lib/parse.ts +175 -0
  25. package/src/lib/paths.ts +26 -0
  26. package/src/lib/project.ts +28 -0
  27. package/src/lib/scripts/append-progress-session.ts +178 -0
  28. package/src/lib/scripts/append-sprint.ts +121 -0
  29. package/src/lib/scripts/archive-sprint.ts +583 -0
  30. package/src/lib/scripts/init-project.ts +291 -0
  31. package/src/lib/scripts/parallel-utils.ts +380 -0
  32. package/src/lib/scripts/parse-completion-signal.ts +584 -0
  33. package/src/lib/scripts/parse-delimited-output.ts +632 -0
  34. package/src/lib/scripts/resolve-project-dir.ts +130 -0
  35. package/src/lib/scripts/status.ts +292 -0
  36. package/src/lib/scripts/update-feature-status.ts +169 -0
  37. package/src/lib/scripts/validate-structure.ts +290 -0
  38. package/src/lib/state.ts +305 -0
  39. package/src/plugin.ts +76 -0
  40. package/src/prompts/context-codegraph.ts +65 -0
  41. package/src/prompts/context-grep.ts +68 -0
  42. package/src/prompts/feature-impl.ts +78 -0
  43. package/src/prompts/plan-designer.ts +59 -0
  44. package/src/prompts/plan-reviewer.ts +61 -0
  45. package/src/prompts/sprint-planning.ts +47 -0
  46. package/src/tools/archive.ts +278 -0
  47. package/src/tools/code.ts +448 -0
  48. package/src/tools/config.ts +182 -0
  49. package/src/tools/force-archive.ts +195 -0
  50. package/src/tools/init.ts +193 -0
  51. package/src/tools/plan-finalize.ts +333 -0
  52. package/src/tools/plan-review.ts +759 -0
  53. package/src/tools/plan-start.ts +232 -0
  54. package/src/tools/sprint.ts +213 -0
  55. package/src/tools/status.ts +51 -0
@@ -0,0 +1,533 @@
1
+ # Coding Agent Reference
2
+
3
+ ## Table of Contents
4
+ 1. [Session Protocol](#session-protocol)
5
+ 2. [Implementation Process](#implementation-process)
6
+ 3. [Parallel Mode](#parallel-mode)
7
+ 4. [File Schemas](#file-schemas)
8
+ 5. [Testing Requirements](#testing-requirements)
9
+ 6. [Examples](#examples)
10
+
11
+ ## Session Protocol
12
+
13
+ ### Start of Session
14
+
15
+ **Always perform in order:**
16
+
17
+ 1. **Confirm Location**
18
+ ```bash
19
+ command python3 ${CLAUDE_PLUGIN_ROOT}/shared/scripts/resolve_project_dir.py
20
+ ```
21
+ Store the output as the absolute project directory. Use it for all reads/writes of `.ghs/features.json` and `.ghs/progress.md`.
22
+
23
+ 2. **Review Recent Work**
24
+ ```bash
25
+ git log --oneline -10
26
+ ```
27
+ Read `.ghs/progress.md` to understand previous sessions. This step is mandatory — it provides the context from prior sessions that enables continuity across context windows.
28
+
29
+ 3. **Review Feature Status**
30
+ Read `.ghs/features.json` to see:
31
+ - Current sprint status
32
+ - Completed features
33
+ - In-progress features
34
+ - Pending features
35
+ - Dependencies
36
+
37
+ 4. **Verify Project State**
38
+ Run lint and build commands (see project's AGENTS.md, or CLAUDE.md if AGENTS.md does not exist).
39
+
40
+ **⚠️ If broken, fix existing issues before starting new work.**
41
+
42
+ ### End of Session
43
+
44
+ **Always perform in this order:**
45
+
46
+ 1. Ensure no lint/build errors
47
+ 2. Commit implementation changes (before touching any `.ghs/` files):
48
+ ```bash
49
+ git add <list each modified implementation file explicitly>
50
+ git commit -m "feat(<scope>): <description>"
51
+ ```
52
+ 3. Update `.ghs/features.json` if feature complete
53
+ 4. Update `.ghs/progress.md` with session summary
54
+
55
+ ## Implementation Process
56
+
57
+ ### Step 1: Select Feature
58
+
59
+ Choose **ONE** feature per session. Prioritize:
60
+
61
+ 1. Features from current in-progress sprint
62
+ 2. High-priority pending features with completed dependencies
63
+ 3. Features that build on recent work
64
+
65
+ ### Step 2: Understand Feature
66
+
67
+ Before coding:
68
+
69
+ 1. Read acceptance criteria carefully
70
+ 2. Review technical notes
71
+ 3. Verify dependencies are satisfied
72
+ 4. Identify affected files
73
+ 5. Plan implementation approach
74
+
75
+ ### Step 3: Plan Implementation
76
+
77
+ Write a brief plan covering:
78
+ - Which files will be modified
79
+ - What patterns to follow
80
+ - What tests to write
81
+ - Potential challenges
82
+
83
+ ### Step 4: Implement Incrementally
84
+
85
+ **Key principles:**
86
+
87
+ 1. **Small Commits** - Frequent, logical commits
88
+ 2. **Test Continuously** - Verify each change
89
+ 3. **Stay Focused** - Don't scope-creep
90
+ 4. **Follow Conventions** - Match existing code style
91
+
92
+ **Commit message format:**
93
+ ```
94
+ <type>(<scope>): <description>
95
+
96
+ [optional body]
97
+
98
+ Feature: <feature-id>
99
+ ```
100
+
101
+ Types: `feat`, `fix`, `refactor`, `test`, `docs`, `chore`, `style`
102
+
103
+ ### Step 5: Verify Implementation
104
+
105
+ Check all acceptance criteria:
106
+ - [ ] Each criterion can be demonstrated
107
+ - [ ] Happy path works
108
+ - [ ] Error scenarios handled
109
+ - [ ] Edge cases considered
110
+
111
+ ## Parallel Mode
112
+
113
+ When invoked with `--parallel`, the Coding Agent switches to parallel orchestration mode. Instead of implementing one feature at a time, it analyzes the dependency graph and dispatches subagents to implement multiple features concurrently.
114
+
115
+ ### Pre-flight Checks
116
+
117
+ Perform these checks in order before starting orchestration:
118
+
119
+ 1. **Confirm Location**
120
+ ```bash
121
+ command python3 ${CLAUDE_PLUGIN_ROOT}/shared/scripts/resolve_project_dir.py
122
+ ```
123
+ Store the output as the absolute project directory.
124
+
125
+ 2. **Check for Uncompleted Sprint**
126
+ Read `.ghs/features.json` and look for a sprint with status `in_progress` or `planning` that has features with status `pending` or `blocked`.
127
+
128
+ If no uncompleted sprint exists, exit with:
129
+ ```
130
+ No uncompleted sprint found. Run /ghs:sprint first to plan a sprint.
131
+ ```
132
+
133
+ 3. **Review Recent Context** — Read `.ghs/progress.md` for recent work, blockers, and project state.
134
+
135
+ 4. **Verify Clean Working Tree**
136
+ ```bash
137
+ git status
138
+ ```
139
+ If there are uncommitted changes, exit with:
140
+ ```
141
+ Working tree has uncommitted changes. Please commit or stash before running parallel mode.
142
+ ```
143
+
144
+ ### Analysis Phase
145
+
146
+ #### Step 1: Identify Ready Features and Build Batches
147
+
148
+ Use `parallel_utils.py` to identify ready features and build conflict-free parallel batches. This script reads `.ghs/features.json`, detects dependency cycles, identifies features whose dependencies are all completed, and groups them into batches that respect file-level conflicts:
149
+
150
+ ```bash
151
+ command python3 ${CLAUDE_PLUGIN_ROOT}/shared/scripts/parallel_utils.py \
152
+ --project-dir "<PROJECT_DIR>" \
153
+ --max-parallel 5 \
154
+ --sprint-id "<SPRING_ID>"
155
+ ```
156
+
157
+ Output is JSON with the following structure:
158
+
159
+ ```json
160
+ {
161
+ "ready_features": [ /* features with all deps completed */ ],
162
+ "batches": [
163
+ [ /* batch 1: features with no file overlap */ ],
164
+ [ /* batch 2: features with no file overlap, but conflict with batch 1 */ ]
165
+ ],
166
+ "skipped": [ /* features not ready (deps unmet, wrong status, or in cycles) */ ],
167
+ "cycles": [ /* detected circular dependency chains */ ],
168
+ "cycle_feature_ids": [ /* feature IDs involved in any cycle */ ]
169
+ }
170
+ ```
171
+
172
+ Each feature in the output includes: `id`, `title`, `status`, `files_affected`, and `dependencies`.
173
+
174
+ Key batching rules (enforced by `parallel_utils.py`):
175
+ - Only `pending` features with all dependencies `completed` are considered ready
176
+ - Features involved in dependency cycles are skipped
177
+ - Features with overlapping `files_affected` are never placed in the same batch
178
+ - Maximum of 5 features per batch (configurable via `--max-parallel`)
179
+
180
+ #### Step 3: Output Execution Plan
181
+
182
+ Display the execution plan to the user:
183
+
184
+ ```
185
+ Parallel Execution Plan
186
+ ==================
187
+ Total ready features: 8
188
+ Max parallelism: 5
189
+
190
+ Batch 1 (parallel):
191
+ - s1-feat-002: Add login page (files: src/auth/login.ts)
192
+ - s1-feat-003: Add signup page (files: src/auth/signup.ts)
193
+ - s1-feat-004: Add API client (files: src/api/client.ts)
194
+
195
+ Batch 2 (parallel):
196
+ - s1-feat-005: Connect login to API (files: src/auth/login.ts, src/api/client.ts)
197
+ - s1-feat-006: Add dashboard (files: src/pages/dashboard.tsx)
198
+ ```
199
+
200
+ ### Dispatch Phase
201
+
202
+ For each feature, spawn a subagent with this prompt structure:
203
+
204
+ ```
205
+ Implement ONE feature for this project.
206
+
207
+ ## CONTEXT RESET - READ THIS FIRST
208
+ This is an isolated task. Disregard prior context, assume nothing, read files fresh, start clean.
209
+
210
+ ## Your Task
211
+ 1. Open `<PROJECT_DIR>/.ghs/features.json`, find your feature by `id == "<feature_id>"` under `sprints[].features[]`. Read its `description`/`acceptance_criteria`/`technical_notes`/`files_affected` — these are your source of truth, not the title.
212
+ 2. If the containing sprint has a `plan_ref` field, open that plan file (relative to project root) and read any sections your `technical_notes` references (e.g. "参考 plan §3.3 ..." means read §3.3). If `plan_ref` is missing or the file does not exist, log a one-line warning and proceed with `technical_notes` verbatim.
213
+ 3. Read `<PROJECT_DIR>/.ghs/progress.md` for recent project context.
214
+ 4. Implement the feature following the coding-agent.md guidelines; verify all `acceptance_criteria` are met.
215
+ 5. Run lint/build, then make a **single** commit (stage all modified implementation files with `git add`; do NOT commit `.ghs/*` files) with message: `feat(<scope>): <brief description> (Feature: <feature_id>)`.
216
+
217
+ ## Feature ID
218
+ <feature_id>
219
+
220
+ ## Critical Rules
221
+ - Do NOT modify `.ghs/` files. You may READ `features.json` but MUST NOT write.
222
+ - Focus ONLY on this feature.
223
+ - End with EXACTLY ONE signal: `FEATURE COMPLETE: <feature_id>` or `FEATURE BLOCKED: <feature_id> - <reason>`.
224
+ ```
225
+
226
+ The orchestrator MUST substitute `<PROJECT_DIR>` (from `resolve_project_dir.py`) and `<feature_id>` (from the batch feature list) into the prompt before spawning. The prompt contains NO inline feature details — the subagent reads them from `.ghs/features.json` per Task step 1. Note: the prompt does NOT contain a `<sprint_id>` placeholder — the subagent locates its feature by `id == "<feature_id>"` across `sprints[].features[]`, so the orchestrator does not need to pass `sprint_id`.
227
+
228
+ Use the Agent tool to spawn subagents:
229
+
230
+ ```json
231
+ {
232
+ "subagent_type": "general-purpose",
233
+ "description": "Implement feature <id>",
234
+ "prompt": "<full prompt from template above>",
235
+ "run_in_background": true
236
+ }
237
+ ```
238
+
239
+ For each batch:
240
+ 1. Spawn all subagents in the batch as background tasks
241
+ 2. Wait for all subagents to complete
242
+ 3. Collect results (success/failure) for each feature
243
+ 4. Proceed to verification phase
244
+
245
+ ### Verification Phase
246
+
247
+ For each background subagent that returns:
248
+
249
+ 1. **Capture raw output and save to disk** for post-mortem debugging:
250
+ ```
251
+ <PROJECT_DIR>/.ghs/parallel/<sprint_id>/<feature_id>.raw.attempt<N>
252
+ ```
253
+ `attempt<N>` starts at 1 for the first try within a feature; retries increment N.
254
+
255
+ 2. **Invoke the parser helper.**
256
+
257
+ > **You MUST copy this command verbatim, only replacing the `<placeholders>`. Do NOT grep the subagent output yourself — the helper is the single source of truth for completion-signal extraction.**
258
+
259
+ ```bash
260
+ command python3 ${CLAUDE_PLUGIN_ROOT}/shared/scripts/parse_completion_signal.py \
261
+ --feature-id <feature_id> \
262
+ --input-file <PROJECT_DIR>/.ghs/parallel/<sprint_id>/<feature_id>.raw.attempt<N> \
263
+ --min-length 50
264
+ ```
265
+
266
+ 3. **Branch on `status` (read from JSON, do not re-parse the text):**
267
+ - **`completed`**:
268
+ 1. **Run the commit/files sanity check** (前置门 — pass 才允许写 features.json):
269
+ - 从 `<PROJECT_DIR>/.ghs/features.json` 读 feature `<feature_id>` 的 `files_affected` 字段,得 `expected_files`(list)。
270
+ - **立即检查 expected_files 是否为空**:若 `expected_files == []`(features.json 中该字段缺失或为空 list),**整个 sanity check 跳过**,视为通过,日志记录 `"sanity check skipped: feature <feature_id> has no files_affected in features.json"`。此跳过分支**必须在读 git log 之前判断**,不得合并到下面的空集检查。
271
+ - 读 subagent 的 commit log(`git log --since=<dispatch_start_iso> --name-only --pretty=format:"%H %s"`,dispatch_start_iso 见下方备注),得 `actual_files`(list,去重)。
272
+ - 计算 `intersection = set(expected_files) ∩ set(actual_files)`。
273
+ - 如果 `intersection` 为空(即所有 commit 加起来一个期望文件都没碰),**不要标记 feature 完成**,触发 Format Recovery retry,appendix 中加一句:`Your commit did not touch any file listed in this feature's files_affected in features.json. Did you read features.json to find your feature's expected files?`。retry 后仍空则走 User Decision Handling。**此分支不写 features.json。**
274
+ - 如果 `intersection` 非空(或 sanity check 走 skip 分支),进入步骤 2。
275
+ 2. Update `.ghs/features.json` for `<feature_id>` with `status: "completed"`. Run lint/build to verify code quality. Verify acceptance criteria. Proceed to next feature.
276
+
277
+ **备注**:`dispatch_start_iso` 是 orchestrator 在 Dispatch Phase spawn 该 subagent 那一刻记录的 ISO 时间戳(`datetime.now(timezone.utc).isoformat()`),用于时间窗 git log 查询,覆盖 subagent 可能的多 commit。
278
+ - **`blocked`** → Update `.ghs/features.json` with `status: "blocked"` and `blocked_reason: <reason from JSON>`. Record result and proceed.
279
+ - **`unknown`** with `retry_count < MAX_RETRY (=1)` → Increment `retry_count`, re-dispatch the subagent with the original prompt plus the Format Recovery appendix. Save next raw to `<feature_id>.raw.attempt<N+1>`. Return to step 1.
280
+ - **`unknown`** with `retry_count >= MAX_RETRY` → Use AskUserQuestion per the User Decision Handling table. **Never silently hang on an unparseable response.**
281
+
282
+ 4. **Record Result**:
283
+ ```python
284
+ results = {
285
+ "feature_id": {
286
+ "status": "completed" | "blocked" | "unknown",
287
+ "reason": None | "<failure_reason>",
288
+ "strategy": "<exact_signal | case_insensitive | natural_language | none>",
289
+ "raw_file": "<path/to/feature_id>.raw.attempt<N>",
290
+ "files_changed": ["list", "of", "files"]
291
+ }
292
+ }
293
+ ```
294
+
295
+ #### Format Recovery (retry appendix)
296
+
297
+ When retrying a subagent whose previous output could not be parsed, append this block verbatim to the original prompt (replace `<feature_id>` with the actual ID):
298
+
299
+ ```
300
+ ## IMPORTANT: Previous Output Format Issue
301
+ Your previous response did not contain the required completion signal.
302
+ The dispatcher could not determine whether the feature is complete.
303
+
304
+ This time you MUST end your response with EXACTLY ONE of:
305
+ - "FEATURE COMPLETE: <feature_id>" (if successful)
306
+ - "FEATURE BLOCKED: <feature_id> - <reason>" (if blocked)
307
+
308
+ The signal line must:
309
+ 1. Be on its own line
310
+ 2. Use uppercase FEATURE
311
+ 3. Use the exact feature_id given above
312
+ 4. For BLOCKED, include a one-line reason after the dash
313
+
314
+ Do NOT use:
315
+ - "Feature Complete" (lowercase)
316
+ - "FEATURE COMPLETED" (extra D)
317
+ - "The feature is complete" (natural language)
318
+ - Chinese variants like "特性完成"
319
+ ```
320
+
321
+ #### User Decision Handling
322
+
323
+ When retry is exhausted (`retry_count >= MAX_RETRY`) and the parser still cannot determine the outcome, use AskUserQuestion with these four options:
324
+
325
+ | Option | Dispatcher behavior | File side-effects | When available |
326
+ |--------|---------------------|-------------------|----------------|
327
+ | **Retry once more** | Increment `retry_count`, re-dispatch with Format Recovery appendix | New `<feature_id>.raw.attempt<N+1>` | Always available |
328
+ | **Manually mark as completed** | Update `.ghs/features.json` with `status: "completed"`. Annotate `.ghs/progress.md` noting "manually marked after format deviation retry" | `.ghs/features.json` written; `.ghs/progress.md` annotated | Always available — but only choose this after manually verifying (commit log + file diff) |
329
+ | **Manually mark as blocked** | Update `.ghs/features.json` with `status: "blocked"` + user-supplied `blocked_reason`. Annotate `.ghs/progress.md` | `.ghs/features.json` written; `.ghs/progress.md` annotated | Always available |
330
+ | **Abort this feature, continue with others** | Leave `.ghs/features.json` for this feature at `status: "pending"`. Annotate `.ghs/progress.md`. Continue with other features in the batch | `.ghs/features.json` unchanged for this feature; `.ghs/progress.md` annotated | Always available (parallel mode only) |
331
+
332
+ The AskUserQuestion prompt must show the parser's `status`, `strategy`, and `warnings` from the most recent attempt, list the four options, and include the path to the most recent `.raw.attempt<N>` file so the user can inspect the raw subagent output before deciding.
333
+
334
+ ### State Update Phase
335
+
336
+ Subagents already committed their implementation files individually. No further git commits needed — the orchestrator only updates local tracking files.
337
+
338
+ 1. **Update .ghs/features.json** — Completed features get `status: "completed"`, blocked get `status: "blocked"` with `blocked_reason`
339
+
340
+ 2. **Write .ghs/progress.md entry** — Add parallel orchestration summary at the top of sessions section:
341
+
342
+ ```markdown
343
+ ## Parallel Orchestration - YYYY-MM-DD
344
+ **Agent**: Coding Agent (Parallel Mode)
345
+ **Sprint**: [Sprint ID]
346
+ **Max Parallelism**: [N]
347
+
348
+ ### Execution Summary
349
+ | Feature | Status | Result |
350
+ |---------|--------|--------|
351
+ | s1-feat-002 | completed | success |
352
+ | s1-feat-003 | completed | success |
353
+ | s1-feat-004 | blocked | lint errors in src/api/client.ts |
354
+
355
+ ### Statistics
356
+ - Total features: 8
357
+ - Completed: 6
358
+ - Blocked: 2
359
+ - Success rate: 75%
360
+
361
+ ### Next Steps
362
+ - Review and fix blocked features manually
363
+ - Run /ghs:code to address remaining issues
364
+ ```
365
+
366
+ ### Parallel Mode Error Handling
367
+
368
+ - **Subagent Failure**: Record failure, continue other subagents, document in .ghs/progress.md
369
+ - **Merge Conflicts**: Detect via build/lint failures, isolate conflicting features, revert if needed
370
+ - **Catastrophic Failure**: Stop orchestration, run full test suite, rollback if needed, recommend single-feature mode
371
+
372
+ ### Parallel Mode Critical Rules
373
+
374
+ 1. **Continue on Failure** — Blocked features don't stop other features
375
+ 2. **Respect File Conflicts** — Features modifying same files run sequentially
376
+ 3. **Max 5 Concurrent Subagents** — Never exceed this limit
377
+ 4. **Orchestrator Updates State** — Subagents don't modify .ghs/features.json or .ghs/progress.md
378
+ 5. **Clean State Required** — Only run parallel mode on clean working tree
379
+ 6. **Context Isolation** — Every subagent MUST receive CONTEXT RESET header
380
+
381
+ ## File Schemas
382
+
383
+ ### progress.md Structure
384
+
385
+ Add entry at **top** of sessions section:
386
+
387
+ ```markdown
388
+ ## Session N - YYYY-MM-DD
389
+ **Agent**: Coding Agent
390
+ **Sprint**: [Sprint ID]
391
+ **Feature**: [Feature ID and title]
392
+
393
+ ### Implementation
394
+ - [What was implemented]
395
+ - [Key decisions made]
396
+
397
+ ### Files Changed
398
+ - path/to/file.ts - [brief description]
399
+ - path/to/another.ts - [brief description]
400
+
401
+ ### Tests Performed
402
+ - [How the feature was verified]
403
+ - [What scenarios were tested]
404
+
405
+ ### Issues Encountered
406
+ - [Any blockers or bugs found]
407
+ - [How they were resolved]
408
+
409
+ ### Acceptance Criteria Status
410
+ - [x] Criterion 1
411
+ - [x] Criterion 2
412
+ - [ ] Criterion 3 (if incomplete, explain why)
413
+
414
+ ### Next Steps
415
+ - [Recommended next feature or follow-up]
416
+ ```
417
+
418
+ ### features.json Updates
419
+
420
+ Only update feature status field:
421
+
422
+ ```json
423
+ {
424
+ "id": "s1-feat-001",
425
+ "status": "completed" // or "in_progress"
426
+ }
427
+ ```
428
+
429
+ ### Feature Status Values
430
+
431
+ | Status | When to Use |
432
+ |--------|-------------|
433
+ | `pending` | Not started |
434
+ | `in_progress` | Currently being worked on |
435
+ | `completed` | Fully implemented and tested |
436
+ | `blocked` | Cannot proceed due to blocker (include `blocked_reason`) |
437
+
438
+ When a feature is marked `blocked`, include a `blocked_reason` field explaining why:
439
+
440
+ ```json
441
+ {
442
+ "id": "s1-feat-005",
443
+ "status": "blocked",
444
+ "blocked_reason": "Depends on s1-feat-003 which has lint errors"
445
+ }
446
+ ```
447
+
448
+ ## Testing Requirements
449
+
450
+ ### Pre-Completion Testing
451
+
452
+ Before marking feature complete:
453
+
454
+ 1. **Functional Testing**
455
+ - Test as a user would interact
456
+ - Verify all acceptance criteria
457
+ - Check happy path and errors
458
+
459
+ 2. **Cross-Platform Testing**
460
+ - Test relevant platforms for the project
461
+ - See project's AGENTS.md (or CLAUDE.md if AGENTS.md does not exist) for requirements
462
+
463
+ 3. **Technical Testing**
464
+ - Lint passes (see AGENTS.md, or CLAUDE.md if AGENTS.md does not exist, for command)
465
+ - Build succeeds (see AGENTS.md, or CLAUDE.md if AGENTS.md does not exist, for command)
466
+ - Application starts without errors
467
+ - No console errors
468
+
469
+ ### Testing Checklist
470
+
471
+ ```
472
+ ☐ Happy path works
473
+ ☐ Error handling works
474
+ ☐ Responsive on all devices (if applicable)
475
+ ☐ Theme compatibility (if applicable)
476
+ ☐ Internationalization (if applicable)
477
+ ☐ No console errors
478
+ ☐ No lint errors
479
+ ☐ Build passes
480
+ ```
481
+
482
+ ## Examples
483
+
484
+ See [examples.md](examples.md) for complete examples.
485
+
486
+ ## Quality Checklist
487
+
488
+ ### Before Marking Feature Complete
489
+
490
+ ```
491
+ ☐ All acceptance criteria met
492
+ ☐ Lint passes
493
+ ☐ Build succeeds
494
+ ☐ Manual testing completed
495
+ ☐ Code committed with descriptive message
496
+ ☐ .ghs/progress.md updated
497
+ ☐ .ghs/features.json status updated
498
+ ☐ No TODO comments left
499
+ ☐ No debug code remaining
500
+ ```
501
+
502
+ ### End of Session Checklist
503
+
504
+ ```
505
+ ☐ Feature complete (or clearly documented why not)
506
+ ☐ No lint or build errors
507
+ ☐ Code committed (before updating .ghs/ files)
508
+ ☐ .ghs/features.json updated (if feature complete)
509
+ ☐ .ghs/progress.md updated
510
+ ☐ Application in working state
511
+ ```
512
+
513
+ ## Critical Rules
514
+
515
+ 1. **One Feature Per Session** - Don't try to do too much
516
+ 2. **Always Leave Working Code** - Never leave codebase broken
517
+ 3. **Follow Acceptance Criteria** - Implement exactly what's specified
518
+ 4. **Follow Project Conventions** - See project's AGENTS.md (or CLAUDE.md if AGENTS.md does not exist) for code style
519
+ 5. **Don't Modify .ghs/features.json Lightly** - Only change feature status
520
+ 6. **Commit Frequently** - Enable rollback
521
+
522
+ ## Red Flags - Stop and Fix
523
+
524
+ **Stop immediately if you encounter:**
525
+
526
+ - Build errors
527
+ - Lint errors
528
+ - Failing tests
529
+ - Application won't start
530
+ - Previously working feature broken
531
+ - Uncommitted changes from previous session
532
+
533
+ **Fix these before proceeding with new work.**
@@ -0,0 +1,98 @@
1
+ # Context Snapshot Guide
2
+
3
+ This guide defines the format and extraction process for the project context snapshot used by ghs-plan subagents. The snapshot is a condensed summary of the project's architecture that subagents read instead of independently scanning the codebase.
4
+
5
+ ## Purpose
6
+
7
+ The snapshot serves as a **shared knowledge base** between the plan designer and plan reviewer. It is created once before any subagent work and read by all subagents across all rounds. This eliminates redundant codebase exploration and saves significant token overhead.
8
+
9
+ ## Snapshot Format
10
+
11
+ ```markdown
12
+ # Project Context Snapshot
13
+
14
+ ## 1. Technology Stack
15
+ - **Language**: <language and version>
16
+ - **Runtime/Framework**: <runtime/framework and version>
17
+ - **Key dependencies**: <list notable libraries with versions>
18
+ - **Build system**: <build tool and config>
19
+ - **Test framework**: <testing tool>
20
+
21
+ ## 2. Directory Structure
22
+
23
+ <annotated file tree with one-line descriptions for key files>
24
+
25
+ ## 3. Architecture Summary
26
+
27
+ ### Entry Point
28
+ <how the app starts, initialization flow>
29
+
30
+ ### Module Responsibilities
31
+ <one paragraph per major module describing what it does>
32
+
33
+ ### Data Model
34
+ <tables/schemas/types with field lists>
35
+
36
+ ### Key Patterns
37
+ <middleware chains, auth flow, error handling conventions, etc.>
38
+
39
+ ## 4. Relevant Code Excerpts
40
+
41
+ <function signatures, database schemas, routing setup, config sections
42
+ that are directly relevant to the requirement being planned>
43
+ ```
44
+
45
+ ## Extraction Guidelines
46
+
47
+ ### Conciseness Target
48
+
49
+ Aim for **50-70% compression** compared to reading raw source files. The snapshot should capture understanding, not reproduce code verbatim.
50
+
51
+ **Good** (summarized):
52
+ ```
53
+ ### Module Responsibilities
54
+ `src/routes/users.ts` — Express router with CRUD endpoints for users. Uses middleware
55
+ chain: auth -> validate -> handler. All handlers follow the pattern: extract params,
56
+ call service, return {data} or {error}.
57
+ ```
58
+
59
+ **Bad** (verbatim):
60
+ ```
61
+ ### Module Responsibilities
62
+ ```typescript
63
+ // full 80-line file contents pasted here
64
+ ```
65
+ ```
66
+
67
+ ### Relevance Filter
68
+
69
+ Only include code excerpts that could **possibly relate to the requirement**. For a requirement about "adding tags to posts":
70
+ - Include: post model definition, post routes, tag-related types
71
+ - Exclude: auth module, payment processing, email service
72
+
73
+ ### What to Include
74
+
75
+ 1. **Function signatures** of public APIs (not internal implementations)
76
+ 2. **Database schemas** (field names and types, not migration boilerplate)
77
+ 3. **Configuration** (environment variables, config file structure)
78
+ 4. **Routing setup** (endpoint paths and their handlers)
79
+ 5. **Type/interface definitions** relevant to the requirement
80
+
81
+ ### What NOT to Include
82
+
83
+ 1. Full file contents (use summaries instead)
84
+ 2. Import statements
85
+ 3. Boilerplate code
86
+ 4. Test files (mention their existence and framework only)
87
+ 5. Generated files (build output, lock files)
88
+
89
+ ## Extraction Process
90
+
91
+ When creating the snapshot, follow this order:
92
+
93
+ 1. **Read dependency manifest**: `package.json`, `requirements.txt`, `Cargo.toml`, etc.
94
+ 2. **Get directory structure**: `find . -type f` (exclude node_modules, .git, build dirs)
95
+ 3. **Read entry point**: `src/index.ts`, `main.py`, `src/lib.rs`, etc.
96
+ 4. **Read config files**: `.env.example`, config modules, database setup
97
+ 5. **Read requirement-relevant files**: files in directories that relate to the requirement topic
98
+ 6. **Summarize and write**: Condense findings into the snapshot format