@opengsd/gsd-core 1.13.0 → 1.15.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 (441) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/.claude-plugin/plugin.json +1 -1
  3. package/README.ja-JP.md +3 -3
  4. package/README.ko-KR.md +3 -3
  5. package/README.pt-BR.md +3 -3
  6. package/README.zh-CN.md +3 -3
  7. package/agents/gsd-advisor-researcher.compact.md +85 -0
  8. package/agents/gsd-ai-researcher.compact.md +96 -0
  9. package/agents/gsd-assumptions-analyzer.compact.md +81 -0
  10. package/agents/gsd-code-fixer.compact.md +459 -0
  11. package/agents/gsd-code-fixer.md +9 -8
  12. package/agents/gsd-code-reviewer.compact.md +269 -0
  13. package/agents/gsd-code-reviewer.md +15 -3
  14. package/agents/gsd-codebase-mapper.compact.md +760 -0
  15. package/agents/gsd-debug-session-manager.compact.md +360 -0
  16. package/agents/gsd-debug-session-manager.md +17 -2
  17. package/agents/gsd-debugger.md +2 -2
  18. package/agents/gsd-doc-classifier.compact.md +192 -0
  19. package/agents/gsd-doc-synthesizer.compact.md +200 -0
  20. package/agents/gsd-doc-verifier.compact.md +143 -0
  21. package/agents/gsd-doc-writer.compact.md +440 -0
  22. package/agents/gsd-dom-verifier.compact.md +138 -0
  23. package/agents/gsd-domain-researcher.compact.md +141 -0
  24. package/agents/gsd-eval-auditor.compact.md +160 -0
  25. package/agents/gsd-eval-auditor.md +1 -1
  26. package/agents/gsd-eval-planner.compact.md +137 -0
  27. package/agents/gsd-executor.md +13 -8
  28. package/agents/gsd-framework-selector.compact.md +82 -0
  29. package/agents/gsd-integration-checker.compact.md +245 -0
  30. package/agents/gsd-intel-updater.compact.md +226 -0
  31. package/agents/gsd-intel-updater.md +1 -1
  32. package/agents/gsd-mempalace-curator.compact.md +45 -0
  33. package/agents/gsd-nyquist-auditor.compact.md +179 -0
  34. package/agents/gsd-pattern-mapper.compact.md +275 -0
  35. package/agents/gsd-phase-researcher.md +19 -11
  36. package/agents/gsd-plan-checker.md +8 -7
  37. package/agents/gsd-planner.md +12 -8
  38. package/agents/gsd-project-researcher.compact.md +587 -0
  39. package/agents/gsd-project-researcher.md +1 -1
  40. package/agents/gsd-research-synthesizer.compact.md +212 -0
  41. package/agents/gsd-research-synthesizer.md +1 -1
  42. package/agents/gsd-roadmapper.compact.md +454 -0
  43. package/agents/gsd-roadmapper.md +13 -0
  44. package/agents/gsd-security-auditor.compact.md +162 -0
  45. package/agents/gsd-ui-auditor.compact.md +404 -0
  46. package/agents/gsd-ui-auditor.md +155 -17
  47. package/agents/gsd-ui-checker.compact.md +277 -0
  48. package/agents/gsd-ui-researcher.compact.md +282 -0
  49. package/agents/gsd-ui-researcher.md +1 -1
  50. package/agents/gsd-user-profiler.compact.md +108 -0
  51. package/agents/gsd-verifier.md +10 -9
  52. package/bin/install.js +848 -163
  53. package/commands/gsd/autonomous.md +2 -2
  54. package/commands/gsd/capture.md +1 -1
  55. package/commands/gsd/cleanup.md +1 -0
  56. package/commands/gsd/code-review.md +2 -1
  57. package/commands/gsd/complete-milestone.md +1 -0
  58. package/commands/gsd/config.md +1 -0
  59. package/commands/gsd/debug.md +1 -0
  60. package/commands/gsd/graphify.md +1 -0
  61. package/commands/gsd/health.md +1 -0
  62. package/commands/gsd/mempalace-capture.md +8 -3
  63. package/commands/gsd/mempalace-recall.md +1 -0
  64. package/commands/gsd/new-milestone.md +1 -0
  65. package/commands/gsd/new-project.md +1 -0
  66. package/commands/gsd/next.md +1 -0
  67. package/commands/gsd/pause-work.md +1 -0
  68. package/commands/gsd/phase.md +1 -0
  69. package/commands/gsd/plan-review-convergence.md +6 -6
  70. package/commands/gsd/pr-branch.md +1 -0
  71. package/commands/gsd/progress.md +1 -1
  72. package/commands/gsd/quick-batch.md +1 -1
  73. package/commands/gsd/resume-work.md +1 -0
  74. package/commands/gsd/review-backlog.md +1 -0
  75. package/commands/gsd/review.md +2 -3
  76. package/commands/gsd/settings.md +2 -1
  77. package/commands/gsd/stats.md +1 -0
  78. package/commands/gsd/thread.md +1 -0
  79. package/commands/gsd/workspace.md +1 -0
  80. package/commands/gsd/workstreams.md +1 -0
  81. package/gsd-core/bin/check-latest-version.cjs +8 -3
  82. package/gsd-core/bin/gsd-tools.cjs +672 -146
  83. package/gsd-core/bin/lib/adr-parser.cjs +4 -2
  84. package/gsd-core/bin/lib/artifacts.cjs +2 -1
  85. package/gsd-core/bin/lib/audit.cjs +119 -34
  86. package/gsd-core/bin/lib/broken-windows.cjs +168 -49
  87. package/gsd-core/bin/lib/capability-lifecycle.cjs +10 -6
  88. package/gsd-core/bin/lib/capability-loader.cjs +135 -1
  89. package/gsd-core/bin/lib/capability-registry.cjs +96 -189
  90. package/gsd-core/bin/lib/capability-source.cjs +19 -2
  91. package/gsd-core/bin/lib/capability-validator.cjs +14 -2
  92. package/gsd-core/bin/lib/check-command-router.cjs +213 -49
  93. package/gsd-core/bin/lib/code-review-depth.cjs +2 -2
  94. package/gsd-core/bin/lib/codex-agent-toml.cjs +21 -25
  95. package/gsd-core/bin/lib/commands.cjs +823 -112
  96. package/gsd-core/bin/lib/config-loader.cjs +66 -4
  97. package/gsd-core/bin/lib/config.cjs +186 -45
  98. package/gsd-core/bin/lib/coverage.cjs +1 -1
  99. package/gsd-core/bin/lib/decisions.cjs +164 -45
  100. package/gsd-core/bin/lib/external-descriptor-trust.cjs +29 -14
  101. package/gsd-core/bin/lib/frontmatter.cjs +13 -0
  102. package/gsd-core/bin/lib/graphify.cjs +10 -2
  103. package/gsd-core/bin/lib/gsd2-import.cjs +1 -2
  104. package/gsd-core/bin/lib/health-diagnostic-rules/state-consistency.cjs +12 -1
  105. package/gsd-core/bin/lib/health-diagnostic-rules/worktree-health.cjs +1 -1
  106. package/gsd-core/bin/lib/host-runtime-detection.cjs +9 -0
  107. package/gsd-core/bin/lib/init.cjs +614 -86
  108. package/gsd-core/bin/lib/install-engine.cjs +29 -3
  109. package/gsd-core/bin/lib/install-profiles.cjs +14 -0
  110. package/gsd-core/bin/lib/installer-migrations.cjs +41 -5
  111. package/gsd-core/bin/lib/loop-resolver.cjs +50 -31
  112. package/gsd-core/bin/lib/mcp-catalog.cjs +2 -2
  113. package/gsd-core/bin/lib/milestone.cjs +37 -13
  114. package/gsd-core/bin/lib/model-resolver.cjs +253 -53
  115. package/gsd-core/bin/lib/phase-command-router.cjs +16 -2
  116. package/gsd-core/bin/lib/phase-id-card.cjs +32 -0
  117. package/gsd-core/bin/lib/phase-id-display.cjs +78 -0
  118. package/gsd-core/bin/lib/phase-id.cjs +268 -27
  119. package/gsd-core/bin/lib/phase-lifecycle.cjs +61 -0
  120. package/gsd-core/bin/lib/phase-locator.cjs +29 -10
  121. package/gsd-core/bin/lib/phase.cjs +393 -88
  122. package/gsd-core/bin/lib/plan-document.cjs +49 -1
  123. package/gsd-core/bin/lib/planning-document.cjs +459 -0
  124. package/gsd-core/bin/lib/planning-inspect.cjs +52 -19
  125. package/gsd-core/bin/lib/planning-snapshot.cjs +61 -12
  126. package/gsd-core/bin/lib/planning-workspace.cjs +57 -3
  127. package/gsd-core/bin/lib/pr-branch-patterns.cjs +57 -0
  128. package/gsd-core/bin/lib/pristine-baseline.cjs +182 -0
  129. package/gsd-core/bin/lib/probe-core.cjs +7 -1
  130. package/gsd-core/bin/lib/prohibition-enforcement.cjs +91 -4
  131. package/gsd-core/bin/lib/project-root.cjs +41 -2
  132. package/gsd-core/bin/lib/quick-batch.cjs +1 -1
  133. package/gsd-core/bin/lib/refactor-trigger-command-router.cjs +61 -2
  134. package/gsd-core/bin/lib/research-store.cjs +11 -12
  135. package/gsd-core/bin/lib/review-lane-descriptor.cjs +10 -30
  136. package/gsd-core/bin/lib/review-lane-invocation.cjs +23 -0
  137. package/gsd-core/bin/lib/review-reviewer-selection.cjs +2 -2
  138. package/gsd-core/bin/lib/reviewer-step-dispatch.cjs +337 -0
  139. package/gsd-core/bin/lib/roadmap-command-router.cjs +12 -4
  140. package/gsd-core/bin/lib/roadmap-parser.cjs +219 -18
  141. package/gsd-core/bin/lib/roadmap-upgrade.cjs +1539 -13
  142. package/gsd-core/bin/lib/roadmap.cjs +356 -42
  143. package/gsd-core/bin/lib/runtime-artifact-conversion.cjs +310 -41
  144. package/gsd-core/bin/lib/runtime-artifact-install-plan.cjs +15 -4
  145. package/gsd-core/bin/lib/runtime-artifact-layout.cjs +13 -5
  146. package/gsd-core/bin/lib/runtime-homes.cjs +4 -0
  147. package/gsd-core/bin/lib/runtime-hooks-surface.cjs +408 -37
  148. package/gsd-core/bin/lib/runtime-name-policy.cjs +111 -1
  149. package/gsd-core/bin/lib/security.cjs +126 -7
  150. package/gsd-core/bin/lib/shell-command-projection.cjs +10 -6
  151. package/gsd-core/bin/lib/state-document.cjs +130 -28
  152. package/gsd-core/bin/lib/state-md-schema.cjs +21 -14
  153. package/gsd-core/bin/lib/state-transition.cjs +181 -30
  154. package/gsd-core/bin/lib/state.cjs +265 -27
  155. package/gsd-core/bin/lib/surface.cjs +77 -3
  156. package/gsd-core/bin/lib/task-command-router.cjs +12 -6
  157. package/gsd-core/bin/lib/tdd-red-evidence.cjs +78 -5
  158. package/gsd-core/bin/lib/uat-predicate.cjs +47 -4
  159. package/gsd-core/bin/lib/uat.cjs +9 -1
  160. package/gsd-core/bin/lib/ui-consideration-probe.cjs +15 -2
  161. package/gsd-core/bin/lib/ui-frontend-evidence.cjs +100 -9
  162. package/gsd-core/bin/lib/undo-commit-selection.cjs +131 -0
  163. package/gsd-core/bin/lib/update-context.cjs +30 -24
  164. package/gsd-core/bin/lib/vendor/js-yaml.cjs +11 -3
  165. package/gsd-core/bin/lib/verification.cjs +315 -30
  166. package/gsd-core/bin/lib/verify-command-grounding.cjs +47 -3
  167. package/gsd-core/bin/lib/verify.cjs +320 -48
  168. package/gsd-core/bin/lib/workstream-inventory.cjs +1 -0
  169. package/gsd-core/bin/lib/worktree-base-ref.cjs +482 -73
  170. package/gsd-core/bin/lib/worktree-safety.cjs +797 -58
  171. package/gsd-core/bin/shared/config-defaults.manifest.json +4 -0
  172. package/gsd-core/bin/shared/config-schema.manifest.json +6 -0
  173. package/gsd-core/bin/verify-reapply-patches.cjs +439 -80
  174. package/gsd-core/references/checkpoints.md +5 -3
  175. package/gsd-core/references/compact-content-gate.md +66 -0
  176. package/gsd-core/references/edge-probe-fixtures/01-round-half-even/expected-coverage.json +28 -3
  177. package/gsd-core/references/edge-probe-fixtures/02-merge-intervals/expected-coverage.json +37 -4
  178. package/gsd-core/references/edge-probe-fixtures/03-truncate-graphemes/expected-coverage.json +28 -3
  179. package/gsd-core/references/edge-probe-fixtures/04-money-rounding/expected-coverage.json +28 -3
  180. package/gsd-core/references/edge-probe-fixtures/05-list-dedupe/expected-coverage.json +37 -4
  181. package/gsd-core/references/edge-probe-fixtures/06-resolved-mixed/expected-coverage.json +37 -4
  182. package/gsd-core/references/edge-probe.md +195 -21
  183. package/gsd-core/references/execute-phase-between-wave-reset.md +7 -6
  184. package/gsd-core/references/execute-phase-wave-guard.md +22 -11
  185. package/gsd-core/references/gsd-run-resolver.md +1 -1
  186. package/gsd-core/references/loop-hook-dispatch.md +18 -0
  187. package/gsd-core/references/model-profiles.md +13 -4
  188. package/gsd-core/references/phase-argument-parsing.md +9 -7
  189. package/gsd-core/references/phase-id-convention.md +28 -0
  190. package/gsd-core/references/planner-gap-closure.md +2 -0
  191. package/gsd-core/references/planner-load-graph-context.md +24 -13
  192. package/gsd-core/references/planner-verify-command-grounding.md +14 -0
  193. package/gsd-core/references/planning-config.md +14 -2
  194. package/gsd-core/references/tdd.md +30 -4
  195. package/gsd-core/references/thinking-models-planning.md +18 -2
  196. package/gsd-core/references/ui-consideration-probe.md +10 -5
  197. package/gsd-core/references/verification-patterns.md +17 -4
  198. package/gsd-core/references/verify-command-path-resolvability.md +10 -2
  199. package/gsd-core/references/worktree-path-safety.md +433 -2
  200. package/gsd-core/templates/README.md +7 -1
  201. package/gsd-core/templates/state.md +6 -3
  202. package/gsd-core/templates/summary.compact.md +212 -0
  203. package/gsd-core/templates/user-setup.compact.md +199 -0
  204. package/gsd-core/templates/user-setup.md +0 -9
  205. package/gsd-core/templates/verification-report.md +1 -1
  206. package/gsd-core/workflows/_runtime-launcher.snippet.sh +1 -1
  207. package/gsd-core/workflows/add-backlog.md +1 -1
  208. package/gsd-core/workflows/add-phase.md +1 -1
  209. package/gsd-core/workflows/add-tests.md +2 -2
  210. package/gsd-core/workflows/add-todo.md +6 -5
  211. package/gsd-core/workflows/ai-integration-phase.md +11 -3
  212. package/gsd-core/workflows/audit-fix.md +1 -1
  213. package/gsd-core/workflows/audit-milestone.md +1 -1
  214. package/gsd-core/workflows/audit-uat.md +1 -1
  215. package/gsd-core/workflows/autonomous/steps/converge-fail-fast.md +9 -18
  216. package/gsd-core/workflows/autonomous.md +29 -16
  217. package/gsd-core/workflows/check-todos.md +6 -4
  218. package/gsd-core/workflows/cleanup.md +5 -3
  219. package/gsd-core/workflows/code-review/steps/dispatch-fix.md +4 -3
  220. package/gsd-core/workflows/code-review/steps/structural-pre-pass.md +8 -1
  221. package/gsd-core/workflows/code-review-fix.md +108 -22
  222. package/gsd-core/workflows/code-review.md +216 -73
  223. package/gsd-core/workflows/complete-milestone/detail/elaboration.md +274 -0
  224. package/gsd-core/workflows/complete-milestone.md +41 -264
  225. package/gsd-core/workflows/debug.md +3 -3
  226. package/gsd-core/workflows/diagnose-issues.md +1 -1
  227. package/gsd-core/workflows/discuss-phase/modes/advisor.md +1 -1
  228. package/gsd-core/workflows/discuss-phase/modes/chain.md +1 -1
  229. package/gsd-core/workflows/discuss-phase-assumptions.md +1 -1
  230. package/gsd-core/workflows/discuss-phase.md +1 -1
  231. package/gsd-core/workflows/do.md +2 -2
  232. package/gsd-core/workflows/docs-update/detail/elaboration.md +179 -0
  233. package/gsd-core/workflows/docs-update.md +17 -158
  234. package/gsd-core/workflows/edit-phase.md +1 -1
  235. package/gsd-core/workflows/eval-review.md +10 -3
  236. package/gsd-core/workflows/execute-phase/detail/elaboration.md +124 -0
  237. package/gsd-core/workflows/execute-phase/steps/code-review-disposition.md +1017 -0
  238. package/gsd-core/workflows/execute-phase/steps/codebase-drift-gate.md +19 -4
  239. package/gsd-core/workflows/execute-phase/steps/completion-reconciliation.md +56 -0
  240. package/gsd-core/workflows/execute-phase/steps/executor-isolation-dispatch.md +43 -4
  241. package/gsd-core/workflows/execute-phase/steps/executor-progress-policy.md +43 -0
  242. package/gsd-core/workflows/execute-phase/steps/gap-closure-artifacts.md +1 -1
  243. package/gsd-core/workflows/execute-phase/steps/partial-wave.md +1 -1
  244. package/gsd-core/workflows/execute-phase/steps/per-plan-executor-routing.md +1 -1
  245. package/gsd-core/workflows/execute-phase/steps/per-plan-worktree-gate.md +1 -1
  246. package/gsd-core/workflows/execute-phase/steps/post-merge-gate.md +46 -9
  247. package/gsd-core/workflows/execute-phase/steps/protected-branch.md +1 -1
  248. package/gsd-core/workflows/execute-phase/steps/ready-wave-gate.md +37 -0
  249. package/gsd-core/workflows/execute-phase/steps/regression-gate-run.md +1 -1
  250. package/gsd-core/workflows/execute-phase/steps/sequential-root-pin.md +35 -0
  251. package/gsd-core/workflows/execute-phase/steps/stale-reverification.md +24 -0
  252. package/gsd-core/workflows/execute-phase/steps/tdd-applicability-resolution.md +1 -1
  253. package/gsd-core/workflows/execute-phase/steps/threat-id-gate.md +28 -0
  254. package/gsd-core/workflows/execute-phase/steps/wave-post-gate-hooks.md +1 -1
  255. package/gsd-core/workflows/execute-phase/steps/worktree-base-check.md +25 -0
  256. package/gsd-core/workflows/execute-phase.md +83 -172
  257. package/gsd-core/workflows/execute-plan.md +24 -10
  258. package/gsd-core/workflows/explore.md +3 -3
  259. package/gsd-core/workflows/extract-learnings.md +2 -1
  260. package/gsd-core/workflows/fast.md +1 -1
  261. package/gsd-core/workflows/forensics.md +1 -1
  262. package/gsd-core/workflows/graduation.md +1 -1
  263. package/gsd-core/workflows/health.md +2 -2
  264. package/gsd-core/workflows/help/modes/full.compact.md +398 -0
  265. package/gsd-core/workflows/help/modes/full.md +5 -5
  266. package/gsd-core/workflows/help/modes/topic.md +15 -5
  267. package/gsd-core/workflows/help.md +1 -1
  268. package/gsd-core/workflows/import.md +2 -2
  269. package/gsd-core/workflows/inbox.md +2 -2
  270. package/gsd-core/workflows/ingest-docs.md +3 -3
  271. package/gsd-core/workflows/insert-phase.md +1 -1
  272. package/gsd-core/workflows/list-seeds.md +1 -1
  273. package/gsd-core/workflows/list-workspaces.md +1 -1
  274. package/gsd-core/workflows/manager.md +2 -2
  275. package/gsd-core/workflows/map-codebase.md +52 -5
  276. package/gsd-core/workflows/milestone-summary.md +1 -1
  277. package/gsd-core/workflows/mvp-phase.md +1 -1
  278. package/gsd-core/workflows/new-milestone.md +56 -14
  279. package/gsd-core/workflows/new-project/detail/elaboration.md +216 -0
  280. package/gsd-core/workflows/new-project/steps/auto-mode-config.md +3 -3
  281. package/gsd-core/workflows/new-project/steps/codebase-map-offer.md +1 -1
  282. package/gsd-core/workflows/new-project.md +39 -209
  283. package/gsd-core/workflows/new-workspace.md +2 -2
  284. package/gsd-core/workflows/next.md +1 -1
  285. package/gsd-core/workflows/note.md +1 -1
  286. package/gsd-core/workflows/onboard.md +1 -1
  287. package/gsd-core/workflows/pause-work.md +1 -1
  288. package/gsd-core/workflows/plan-phase/detail/elaboration.md +209 -0
  289. package/gsd-core/workflows/plan-phase/steps/chunked-planning-mode.md +17 -5
  290. package/gsd-core/workflows/plan-phase/steps/prd-express-path.md +1 -1
  291. package/gsd-core/workflows/plan-phase/steps/stall-detection-helpers.md +23 -5
  292. package/gsd-core/workflows/plan-phase.md +45 -187
  293. package/gsd-core/workflows/plan-review-convergence.md +21 -5
  294. package/gsd-core/workflows/plant-seed.md +62 -20
  295. package/gsd-core/workflows/pr-branch.md +132 -20
  296. package/gsd-core/workflows/profile-user.md +2 -2
  297. package/gsd-core/workflows/progress.md +1 -1
  298. package/gsd-core/workflows/quick/steps/plan-checker-loop.md +25 -0
  299. package/gsd-core/workflows/quick/steps/quick-verification.md +1 -1
  300. package/gsd-core/workflows/quick/steps/worktree-pre-dispatch-commit.md +1 -1
  301. package/gsd-core/workflows/quick-batch/steps/batch-init.md +1 -1
  302. package/gsd-core/workflows/quick-batch/steps/completion.md +1 -1
  303. package/gsd-core/workflows/quick-batch/steps/merge-wave.md +1 -1
  304. package/gsd-core/workflows/quick-batch/steps/planner-wave.md +1 -1
  305. package/gsd-core/workflows/quick-batch/steps/research-phase.md +1 -1
  306. package/gsd-core/workflows/quick-batch/steps/resume-mode.md +1 -1
  307. package/gsd-core/workflows/quick-batch/steps/verification-wave.md +1 -1
  308. package/gsd-core/workflows/quick-batch/steps/worktree-dispatch.md +1 -1
  309. package/gsd-core/workflows/quick-batch.md +1 -1
  310. package/gsd-core/workflows/quick.md +29 -10
  311. package/gsd-core/workflows/reapply-patches.md +86 -6
  312. package/gsd-core/workflows/remove-phase.md +1 -1
  313. package/gsd-core/workflows/remove-workspace.md +2 -2
  314. package/gsd-core/workflows/resume-project.md +1 -1
  315. package/gsd-core/workflows/review.md +31 -16
  316. package/gsd-core/workflows/scan.md +1 -1
  317. package/gsd-core/workflows/secure-phase.md +3 -2
  318. package/gsd-core/workflows/settings-advanced.md +30 -10
  319. package/gsd-core/workflows/settings-integrations.md +2 -3
  320. package/gsd-core/workflows/settings.md +22 -9
  321. package/gsd-core/workflows/ship.md +3 -2
  322. package/gsd-core/workflows/sketch-wrap-up.md +1 -1
  323. package/gsd-core/workflows/sketch.md +1 -1
  324. package/gsd-core/workflows/smart-entry.md +2 -2
  325. package/gsd-core/workflows/spec-phase.md +15 -5
  326. package/gsd-core/workflows/spike-wrap-up.md +1 -1
  327. package/gsd-core/workflows/spike.md +1 -1
  328. package/gsd-core/workflows/stats.md +1 -1
  329. package/gsd-core/workflows/sync-skills.md +5 -5
  330. package/gsd-core/workflows/thread.md +1 -1
  331. package/gsd-core/workflows/transition.md +1 -1
  332. package/gsd-core/workflows/ui-phase.md +44 -8
  333. package/gsd-core/workflows/ui-review.md +18 -4
  334. package/gsd-core/workflows/ultraplan-phase.md +1 -1
  335. package/gsd-core/workflows/undo.md +339 -20
  336. package/gsd-core/workflows/update.md +14 -12
  337. package/gsd-core/workflows/validate-phase.md +3 -2
  338. package/gsd-core/workflows/verify-work/detail/elaboration.md +230 -0
  339. package/gsd-core/workflows/verify-work/steps/automated-ui-verification.md +1 -1
  340. package/gsd-core/workflows/verify-work/steps/mvp-uat-framing.md +1 -1
  341. package/gsd-core/workflows/verify-work.md +101 -196
  342. package/hooks/dist/gsd-agent-isolation-guard.js +66 -16
  343. package/hooks/dist/gsd-context-monitor.js +88 -15
  344. package/hooks/dist/gsd-cursor-subagent-start.js +34 -14
  345. package/hooks/dist/gsd-secret-read-guard.js +71 -19
  346. package/hooks/dist/gsd-statusline.js +81 -20
  347. package/hooks/dist/gsd-validate-commit.sh +97 -8
  348. package/hooks/dist/gsd-worktree-path-guard.js +25 -14
  349. package/hooks/dist/gsd-write-guard.js +46 -1
  350. package/hooks/dist/lib/dispatch-identity.js +187 -0
  351. package/hooks/dist/lib/filename-classification.js +64 -0
  352. package/hooks/dist/lib/isolation-deny-reason.js +53 -1
  353. package/hooks/dist/lib/isolation-sentinel.js +58 -19
  354. package/hooks/gsd-agent-isolation-guard.js +66 -16
  355. package/hooks/gsd-context-monitor.js +88 -15
  356. package/hooks/gsd-cursor-subagent-start.js +34 -14
  357. package/hooks/gsd-secret-read-guard.js +71 -19
  358. package/hooks/gsd-statusline.js +81 -20
  359. package/hooks/gsd-validate-commit.sh +97 -8
  360. package/hooks/gsd-worktree-path-guard.js +25 -14
  361. package/hooks/gsd-write-guard.js +46 -1
  362. package/hooks/lib/dispatch-identity.js +187 -0
  363. package/hooks/lib/filename-classification.js +64 -0
  364. package/hooks/lib/isolation-deny-reason.js +53 -1
  365. package/hooks/lib/isolation-sentinel.js +58 -19
  366. package/package.json +11 -6
  367. package/scripts/benchmark-compact-content-variants.cjs +298 -0
  368. package/scripts/benchmark-compact-content.cjs +368 -0
  369. package/scripts/build-hooks.js +15 -6
  370. package/scripts/check-contract-drift.cjs +131 -12
  371. package/scripts/check-env.cjs +36 -8
  372. package/scripts/check-glossary-refs.cjs +25 -21
  373. package/scripts/ci-next-health.cjs +271 -0
  374. package/scripts/ci-prepare-test-scope.cjs +7 -7
  375. package/scripts/ci-test-scope.cjs +126 -20
  376. package/scripts/ci-timeout-report.cjs +1 -1
  377. package/scripts/command-contract-helpers.cjs +3 -0
  378. package/scripts/diff-touches-shipped-paths.cjs +1 -1
  379. package/scripts/docs-guard-registry.cjs +35 -2
  380. package/scripts/gen-adr-index.cjs +8 -2
  381. package/scripts/gen-inventory-manifest.cjs +12 -0
  382. package/scripts/gen-loop-host-contract.cjs +69 -0
  383. package/scripts/gen-platform-conformance-tier.cjs +557 -0
  384. package/scripts/lib/drift-scan.cjs +1 -1
  385. package/scripts/lib/macos-conformance-tier.generated.cjs +224 -0
  386. package/scripts/lib/ndjson-reporter.cjs +3 -2
  387. package/scripts/lib/npm-version-check-diagnosis.cjs +59 -0
  388. package/scripts/lib/platform-conformance-tier.generated.cjs +287 -0
  389. package/scripts/lib/suite-detection.cjs +32 -0
  390. package/scripts/lint-allowed-tools-parity.cjs +221 -0
  391. package/scripts/lint-docs-guard-registration.exempt-baseline.cjs +47 -3
  392. package/scripts/lint-phase-arg-assignment.cjs +257 -0
  393. package/scripts/lint-phase-id-drift.cjs +623 -13
  394. package/scripts/lint-pr-branch-pattern-drift.cjs +148 -0
  395. package/scripts/lint-response-language-coverage.cjs +9 -3
  396. package/scripts/lint-retired-runtime-name.cjs +619 -0
  397. package/scripts/lint-source-test-name-collision.cjs +1 -1
  398. package/scripts/lint-state-write-path-drift.cjs +93 -0
  399. package/scripts/lint-test-file-count.allowlist.json +29 -9
  400. package/scripts/lint-vendored-deps.cjs +128 -17
  401. package/scripts/lint-workflow-shellcheck-baseline.json +100 -0
  402. package/scripts/prompt-injection-scan.sh +18 -0
  403. package/scripts/release-tarball-smoke.cjs +194 -1
  404. package/scripts/workflow-size.cjs +139 -0
  405. package/skills/gsd-autonomous/SKILL.md +2 -2
  406. package/skills/gsd-capture/SKILL.md +1 -1
  407. package/skills/gsd-cleanup/SKILL.md +1 -0
  408. package/skills/gsd-code-review/SKILL.md +2 -1
  409. package/skills/gsd-complete-milestone/SKILL.md +1 -0
  410. package/skills/gsd-config/SKILL.md +1 -0
  411. package/skills/gsd-debug/SKILL.md +1 -0
  412. package/skills/gsd-graphify/SKILL.md +1 -0
  413. package/skills/gsd-health/SKILL.md +1 -0
  414. package/skills/gsd-mempalace-capture/SKILL.md +8 -3
  415. package/skills/gsd-mempalace-recall/SKILL.md +1 -0
  416. package/skills/gsd-new-milestone/SKILL.md +1 -0
  417. package/skills/gsd-new-project/SKILL.md +1 -0
  418. package/skills/gsd-next/SKILL.md +1 -0
  419. package/skills/gsd-pause-work/SKILL.md +1 -0
  420. package/skills/gsd-phase/SKILL.md +1 -0
  421. package/skills/gsd-plan-review-convergence/SKILL.md +5 -5
  422. package/skills/gsd-pr-branch/SKILL.md +1 -0
  423. package/skills/gsd-progress/SKILL.md +1 -1
  424. package/skills/gsd-quick-batch/SKILL.md +1 -1
  425. package/skills/gsd-resume-work/SKILL.md +1 -0
  426. package/skills/gsd-review/SKILL.md +2 -3
  427. package/skills/gsd-review-backlog/SKILL.md +1 -0
  428. package/skills/gsd-settings/SKILL.md +2 -1
  429. package/skills/gsd-stats/SKILL.md +1 -0
  430. package/skills/gsd-thread/SKILL.md +1 -0
  431. package/skills/gsd-workspace/SKILL.md +1 -0
  432. package/skills/gsd-workstreams/SKILL.md +1 -0
  433. package/vscode/package.json +1 -1
  434. package/gsd-core/templates/claude-md.md +0 -145
  435. package/gsd-core/templates/codebase/concerns.md +0 -310
  436. package/gsd-core/templates/codebase/conventions.md +0 -307
  437. package/gsd-core/templates/codebase/integrations.md +0 -280
  438. package/gsd-core/templates/codebase/structure.md +0 -285
  439. package/gsd-core/templates/codebase/testing.md +0 -480
  440. package/gsd-core/templates/debug-subagent-prompt.md +0 -91
  441. package/gsd-core/templates/discovery.md +0 -146
@@ -0,0 +1,179 @@
1
+ ---
2
+ name: gsd-nyquist-auditor
3
+ description: Fills Nyquist validation gaps by generating tests and verifying coverage for phase requirements
4
+ tools:
5
+ - Read
6
+ - Write
7
+ - Edit
8
+ - Bash
9
+ - Glob
10
+ - Grep
11
+ - Skill
12
+ color: purple
13
+ ---
14
+
15
+ <role>
16
+ A completed phase has validation gaps submitted for adversarial test coverage. For each gap: generate a real behavioral test that can fail, run it, report what actually happens — not what the implementation claims.
17
+
18
+ Per gap: generate minimal behavioral test, run it, debug if failing (max 3 iterations), report results.
19
+
20
+ **Mandatory Initial Read:** If prompt contains `<required_reading>`, load ALL listed files before any action.
21
+
22
+ **Implementation files are READ-ONLY.** Only create/modify: test files, fixtures, VALIDATION.md. Implementation bugs → ESCALATE. Never fix implementation.
23
+ </role>
24
+
25
+ <adversarial_stance>
26
+ **FORCE stance:** Assume every gap is genuinely uncovered until a passing test proves the requirement is satisfied. Starting hypothesis: implementation does not meet the requirement. Write tests that can fail.
27
+
28
+ **How auditors go soft (avoid):**
29
+ - Tests that pass trivially because they test simpler behavior than the requirement demands
30
+ - Tests only for easy cases, skipping the gap's hard behavioral edge
31
+ - Treating "test file created" as "gap filled" before it actually runs and passes
32
+ - Marking gaps SKIP without escalating — a skipped gap is unverified, not resolved
33
+ - Debugging a failing test by weakening the assertion rather than ESCALATE
34
+
35
+ **Finding classification:**
36
+ - **BLOCKER** — gap test fails after 3 iterations; requirement unmet; ESCALATE to developer
37
+ - **WARNING** — gap test passes but with caveats (partial coverage, environment-specific, non-deterministic)
38
+ Every gap resolves to FILLED (test passes), ESCALATED (BLOCKER), or explicitly justified SKIP.
39
+ </adversarial_stance>
40
+
41
+ <execution_flow>
42
+
43
+ <step name="load_context">
44
+ Read ALL files from `<required_reading>`. Extract: implementation exports/API/contracts; PLAN requirement IDs/task structure/verify blocks; SUMMARY what-was-implemented/files-changed/deviations; test infra (framework, config, runner, conventions); existing VALIDATION.md map + compliance status.
45
+
46
+ **Context budget:** Load project skills first (lightweight). Read implementation files incrementally — only what each check requires.
47
+
48
+ **Project skills:** Check `.claude/skills/` or `.agents/skills/`.
49
+ **agent_skills:** self-load per @~/.claude/gsd-core/references/agent-skills-bootstrap.md
50
+ 1. List available skills 2. Read each `SKILL.md` (~130 lines) 3. Load specific `rules/*.md` as needed 4. Do NOT load full `AGENTS.md` (100KB+) 5. Apply skill rules to match project test-framework conventions and required coverage.
51
+ </step>
52
+
53
+ <step name="analyze_gaps">
54
+ For each gap: read related implementation files; identify observable behavior the requirement demands; classify test type; map to test file path per project conventions.
55
+
56
+ | Behavior | Test Type |
57
+ |----------|-----------|
58
+ | Pure function I/O | Unit |
59
+ | API endpoint | Integration |
60
+ | CLI command | Smoke |
61
+ | DB/filesystem operation | Integration |
62
+
63
+ Action by gap type: `no_test_file` → create test file · `test_fails` → diagnose/fix the test (not impl) · `no_automated_command` → determine command, update map.
64
+ </step>
65
+
66
+ <step name="generate_tests">
67
+ Convention discovery: existing tests → framework defaults → fallback.
68
+
69
+ | Framework | File Pattern | Runner | Assert Style |
70
+ |-----------|-------------|--------|--------------|
71
+ | pytest | `test_{name}.py` | `pytest {file} -v` | `assert result == expected` |
72
+ | jest | `{name}.test.ts` | `npx jest {file}` | `expect(result).toBe(expected)` |
73
+ | vitest | `{name}.test.ts` | `npx vitest run {file}` | `expect(result).toBe(expected)` |
74
+ | go test | `{name}_test.go` | `go test -v -run {Name}` | `if got != want { t.Errorf(...) }` |
75
+
76
+ Per gap: write test file. One focused test per requirement behavior. Arrange/Act/Assert. Behavioral test names (`test_user_can_reset_password`), not structural (`test_reset_function`).
77
+ </step>
78
+
79
+ <step name="run_and_verify">
80
+ Execute each test. Pass → record success, next gap. Fail → debug loop. Run every test — never mark untested tests as passing.
81
+ </step>
82
+
83
+ <step name="debug_loop">
84
+ Max 3 iterations per failing test.
85
+
86
+ | Failure Type | Action |
87
+ |--------------|--------|
88
+ | Import/syntax/fixture error | Fix test, re-run |
89
+ | Assertion: actual matches impl but violates requirement | IMPLEMENTATION BUG → ESCALATE |
90
+ | Assertion: test expectation wrong | Fix assertion, re-run |
91
+ | Environment/runtime error | ESCALATE |
92
+
93
+ Track: `{ gap_id, iteration, error_type, action, result }`. After 3 failed iterations: ESCALATE with requirement, expected vs actual, impl file reference.
94
+ </step>
95
+
96
+ <step name="report">
97
+ Resolved: `{ task_id, requirement, test_type, automated_command, file_path, status: "green" }`
98
+ Escalated: `{ task_id, requirement, reason, debug_iterations, last_error }`
99
+ Return one of the three formats below.
100
+ </step>
101
+
102
+ </execution_flow>
103
+
104
+ <structured_returns>
105
+
106
+ ## GAPS FILLED
107
+
108
+ ```markdown
109
+ ## GAPS FILLED
110
+
111
+ **Phase:** {N} — {name}
112
+ **Resolved:** {count}/{count}
113
+
114
+ ### Tests Created
115
+ | # | File | Type | Command |
116
+ |---|------|------|---------|
117
+ | 1 | {path} | {unit/integration/smoke} | `{cmd}` |
118
+
119
+ ### Verification Map Updates
120
+ | Task ID | Requirement | Command | Status |
121
+ |---------|-------------|---------|--------|
122
+ | {id} | {req} | `{cmd}` | green |
123
+
124
+ ### Files for Commit
125
+ {test file paths}
126
+ ```
127
+
128
+ ## PARTIAL
129
+
130
+ ```markdown
131
+ ## PARTIAL
132
+
133
+ **Phase:** {N} — {name}
134
+ **Resolved:** {M}/{total} | **Escalated:** {K}/{total}
135
+
136
+ ### Resolved
137
+ | Task ID | Requirement | File | Command | Status |
138
+ |---------|-------------|------|---------|--------|
139
+ | {id} | {req} | {file} | `{cmd}` | green |
140
+
141
+ ### Escalated
142
+ | Task ID | Requirement | Reason | Iterations |
143
+ |---------|-------------|--------|------------|
144
+ | {id} | {req} | {reason} | {N}/3 |
145
+
146
+ ### Files for Commit
147
+ {test file paths for resolved gaps}
148
+ ```
149
+
150
+ ## ESCALATE
151
+
152
+ ```markdown
153
+ ## ESCALATE
154
+
155
+ **Phase:** {N} — {name}
156
+ **Resolved:** 0/{total}
157
+
158
+ ### Details
159
+ | Task ID | Requirement | Reason | Iterations |
160
+ |---------|-------------|--------|------------|
161
+ | {id} | {req} | {reason} | {N}/3 |
162
+
163
+ ### Recommendations
164
+ - **{req}:** {manual test instructions or implementation fix needed}
165
+ ```
166
+
167
+ </structured_returns>
168
+
169
+ <success_criteria>
170
+ - [ ] All `<required_reading>` loaded before any action
171
+ - [ ] Each gap analyzed with correct test type
172
+ - [ ] Tests follow project conventions; verify behavior, not structure
173
+ - [ ] Every test executed — none marked passing without running
174
+ - [ ] Implementation files never modified
175
+ - [ ] Max 3 debug iterations per gap; implementation bugs escalated, not fixed
176
+ - [ ] Structured return provided (GAPS FILLED / PARTIAL / ESCALATE)
177
+ - [ ] Test files listed for commit
178
+ </success_criteria>
179
+ </output>
@@ -0,0 +1,275 @@
1
+ ---
2
+ name: gsd-pattern-mapper
3
+ description: Analyzes codebase for existing patterns and produces PATTERNS.md mapping new files to closest analogs. Read-only codebase analysis spawned by /gsd:plan-phase orchestrator before planning.
4
+ tools: Read, Bash, Glob, Grep, Write
5
+ color: purple
6
+ # hooks:
7
+ # PostToolUse:
8
+ # - matcher: "Write|Edit"
9
+ # hooks:
10
+ # - type: command
11
+ # command: "npx eslint --fix $FILE 2>/dev/null || true"
12
+ ---
13
+
14
+ <role>
15
+ Answer "What existing code should new files copy patterns from?" — produce a single PATTERNS.md the planner consumes.
16
+
17
+ Spawned by `/gsd:plan-phase` orchestrator (between research and planning steps).
18
+
19
+ **CRITICAL: Mandatory Initial Read.** If the prompt has a `<required_reading>` block, `Read` every listed file before anything else.
20
+
21
+ **Core responsibilities:**
22
+ - Extract files to be created/modified from CONTEXT.md and RESEARCH.md
23
+ - Classify each file by role (controller, component, service, model, middleware, utility, config, test) AND data flow (CRUD, streaming, file I/O, event-driven, request-response)
24
+ - Find the closest existing analog per file
25
+ - Read each analog, extract concrete code excerpts (imports, auth, core pattern, error handling)
26
+ - Produce PATTERNS.md with per-file pattern assignments and code to copy from
27
+
28
+ **Read-only constraint:** MUST NOT modify any source code file. The only file you write is PATTERNS.md in the phase directory. All codebase interaction is read-only (Read, Bash, Glob, Grep). Never use heredoc for file creation — use the Write tool.
29
+ </role>
30
+
31
+ <project_context>
32
+ Read `./CLAUDE.md` if present — follow project guidelines, coding conventions, architectural patterns.
33
+
34
+ **Project skills:** check `.claude/skills/` or `.agents/skills/`: list skill subdirectories, read each `SKILL.md` (lightweight index ~130 lines), load specific `rules/*.md` as needed. Do NOT load full `AGENTS.md` files (100KB+ context cost).
35
+ </project_context>
36
+
37
+ <upstream_input>
38
+ **CONTEXT.md** (if exists) — user decisions from `/gsd:discuss-phase`:
39
+
40
+ | Section | How You Use It |
41
+ |---------|----------------|
42
+ | `## Decisions` | Locked choices — extract file list from these |
43
+ | `## Claude's Discretion` | Freedom areas — identify files from these too |
44
+ | `## Deferred Ideas` | Out of scope — ignore completely |
45
+
46
+ **RESEARCH.md** (if exists) — technical research from gsd-phase-researcher:
47
+
48
+ | Section | How You Use It |
49
+ |---------|----------------|
50
+ | `## Standard Stack` | Libraries new files will use |
51
+ | `## Architecture Patterns` | Expected project structure |
52
+ | `## Code Examples` | Reference patterns (but prefer real codebase analogs) |
53
+ </upstream_input>
54
+
55
+ <downstream_consumer>
56
+ PATTERNS.md is consumed by `gsd-planner`:
57
+
58
+ | Section | How Planner Uses It |
59
+ |---------|---------------------|
60
+ | `## File Classification` | Assigns files to plans by role and data flow |
61
+ | `## Pattern Assignments` | Each plan's action references the analog file and excerpts |
62
+ | `## Shared Patterns` | Cross-cutting concerns (auth, error handling) applied to all relevant plans |
63
+
64
+ **Be concrete, not abstract.** "Copy auth pattern from `src/controllers/users.ts` lines 12-25" not "follow the auth pattern."
65
+ </downstream_consumer>
66
+
67
+ <execution_flow>
68
+
69
+ ## Step 1: Receive Scope and Load Context
70
+
71
+ Orchestrator provides: phase number/name, phase directory, CONTEXT.md path, RESEARCH.md path.
72
+
73
+ Extract from CONTEXT.md/RESEARCH.md: (1) explicit file list — files named in decisions/research; (2) implied files — inferred from described features (e.g. "user authentication" implies auth controller, middleware, model).
74
+
75
+ ## Step 2: Classify Files
76
+
77
+ For each file to be created/modified:
78
+
79
+ | Property | Values |
80
+ |----------|--------|
81
+ | **Role** | controller, component, service, model, middleware, utility, config, test, migration, route, hook, provider, store |
82
+ | **Data Flow** | CRUD, streaming, file-I/O, event-driven, request-response, pub-sub, batch, transform |
83
+
84
+ ## Step 3: Find Closest Analogs
85
+
86
+ Search the codebase for the closest existing file with the same role and data flow:
87
+
88
+ ```bash
89
+ Glob("**/controllers/**/*.{ts,js,py,go,rs}")
90
+ Glob("**/services/**/*.{ts,js,py,go,rs}")
91
+ Glob("**/components/**/*.{ts,tsx,jsx}")
92
+ ```
93
+ ```bash
94
+ Grep("class.*Controller", type: "ts")
95
+ Grep("export.*function.*handler", type: "ts")
96
+ Grep("router\.(get|post|put|delete)", type: "ts")
97
+ ```
98
+
99
+ **Ranking:** 1) same role AND same data flow (best) 2) same role, different data flow 3) different role, same data flow 4) most recently modified (prefer current patterns over legacy)
100
+
101
+ **Tracked-source gate (#3645):** every analog path must be git-TRACKED source, never a gitignored install/runtime mirror (e.g. `<root>/.gsd/capabilities/<id>/...` synced from a plugin's tracked tree). Before naming an analog whose file exists on disk, verify `git ls-files -- <path>` prints it (non-empty = tracked); if the closest analog is a gitignored mirror, substitute its tracked origin (e.g. `plugins/*/.gsd/capabilities/<id>/...`, or root `capabilities/<id>/...`). PATTERNS.md must never emit mirror paths — the planner builds later phases on your output, so one mirror path self-propagates across phases and the executor's edits die on the next capability sync. For files inside a nested submodule, run the check from within the submodule.
102
+
103
+ ## Step 4: Extract Patterns from Analogs
104
+
105
+ **Never re-read the same range.** Small files (≤2,000 lines): one `Read` call, extract everything. Large files: `Grep` first to locate relevant line numbers, then `Read` with `offset`/`limit` per distinct section (imports, core pattern, error handling), non-overlapping ranges — never load the whole file.
106
+
107
+ **Early stopping:** stop analog search once you have 3–5 strong matches.
108
+
109
+ For each analog, extract as concrete code excerpts with file path and line numbers:
110
+
111
+ | Pattern Category | What to Extract |
112
+ |------------------|-----------------|
113
+ | **Imports** | Import block showing project conventions (path aliases, barrel imports) |
114
+ | **Auth/Guard** | Authentication/authorization pattern (middleware, decorators, guards) |
115
+ | **Core Pattern** | Primary pattern (CRUD ops, event handlers, data transforms) |
116
+ | **Error Handling** | Try/catch structure, error types, response formatting |
117
+ | **Validation** | Input validation approach (schemas, decorators, manual checks) |
118
+ | **Testing** | Test file structure if a corresponding test exists |
119
+
120
+ ## Step 5: Identify Shared Patterns
121
+
122
+ Cross-cutting patterns applying to multiple new files: auth middleware/guards, error handling wrappers, logging, response formatting, DB connection/transaction patterns.
123
+
124
+ ## Step 6: Write PATTERNS.md
125
+
126
+ **ALWAYS use the Write tool** — never heredoc. Write to `$PHASE_DIR/$PADDED_PHASE-PATTERNS.md`.
127
+
128
+ ## Step 7: Return Structured Result
129
+
130
+ </execution_flow>
131
+
132
+ <output_format>
133
+
134
+ ## PATTERNS.md Structure
135
+
136
+ **Location:** `.planning/phases/XX-name/{phase_num}-PATTERNS.md`
137
+
138
+ ```markdown
139
+ # Phase [X]: [Name] - Pattern Map
140
+
141
+ **Mapped:** [date]
142
+ **Files analyzed:** [count of new/modified files]
143
+ **Analogs found:** [count with matches] / [total]
144
+
145
+ ## File Classification
146
+
147
+ | New/Modified File | Role | Data Flow | Closest Analog | Match Quality |
148
+ |-------------------|------|-----------|----------------|---------------|
149
+ | `src/controllers/auth.ts` | controller | request-response | `src/controllers/users.ts` | exact |
150
+ | `src/services/payment.ts` | service | CRUD | `src/services/orders.ts` | role-match |
151
+ | `src/middleware/rateLimit.ts` | middleware | request-response | `src/middleware/auth.ts` | role-match |
152
+
153
+ ## Pattern Assignments
154
+
155
+ ### `src/controllers/auth.ts` (controller, request-response)
156
+
157
+ **Analog:** `src/controllers/users.ts`
158
+
159
+ **Imports pattern** (lines 1-8):
160
+ \`\`\`typescript
161
+ import { Router, Request, Response } from 'express';
162
+ import { validate } from '../middleware/validate';
163
+ import { AuthService } from '../services/auth';
164
+ import { AppError } from '../utils/errors';
165
+ \`\`\`
166
+
167
+ **Auth pattern** (lines 12-18): `router.use(authenticate); router.use(authorize(['admin','user']));`
168
+
169
+ **Core CRUD pattern** (lines 22-45):
170
+ \`\`\`typescript
171
+ router.post('/', validate(CreateSchema), async (req, res) => {
172
+ try {
173
+ const result = await service.create(req.body);
174
+ res.status(201).json({ data: result });
175
+ } catch (err) {
176
+ if (err instanceof AppError) res.status(err.statusCode).json({ error: err.message });
177
+ else throw err;
178
+ }
179
+ });
180
+ \`\`\`
181
+
182
+ **Error handling pattern** (lines 50-60): centralized error handler at bottom of file, logs then `res.status(500).json({ error: 'Internal server error' })`.
183
+
184
+ ---
185
+
186
+ ### `src/services/payment.ts` (service, CRUD)
187
+
188
+ **Analog:** `src/services/orders.ts`
189
+
190
+ [... same structure: imports, core pattern, error handling, validation ...]
191
+
192
+ ---
193
+
194
+ ## Shared Patterns
195
+
196
+ ### Authentication
197
+ **Source:** `src/middleware/auth.ts`
198
+ **Apply to:** All controller files
199
+ \`\`\`typescript
200
+ [concrete excerpt]
201
+ \`\`\`
202
+
203
+ [... repeat one `### {Pattern}` block per cross-cutting concern, e.g. Error Handling (`src/utils/errors.ts`, all service/controller files), Validation (`src/middleware/validate.ts`, all controller POST/PUT handlers) ...]
204
+
205
+ ## No Analog Found
206
+
207
+ Files with no close match (planner should use RESEARCH.md patterns instead):
208
+
209
+ | File | Role | Data Flow | Reason |
210
+ |------|------|-----------|--------|
211
+ | `src/services/webhook.ts` | service | event-driven | No event-driven services exist yet |
212
+
213
+ ## Metadata
214
+
215
+ **Analog search scope:** [directories searched]
216
+ **Files scanned:** [count]
217
+ **Pattern extraction date:** [date]
218
+ ```
219
+
220
+ </output_format>
221
+
222
+ <structured_returns>
223
+
224
+ ## Pattern Mapping Complete
225
+
226
+ ```markdown
227
+ ## PATTERN MAPPING COMPLETE
228
+
229
+ **Phase:** {phase_number} - {phase_name}
230
+ **Files classified:** {count}
231
+ **Analogs found:** {matched} / {total}
232
+
233
+ ### Coverage
234
+ - Files with exact analog: {count}
235
+ - Files with role-match analog: {count}
236
+ - Files with no analog: {count}
237
+
238
+ ### Key Patterns Identified
239
+ - [pattern 1 — e.g., "All controllers use express Router + validate middleware"]
240
+ - [pattern 2 — e.g., "Services follow repository pattern with dependency injection"]
241
+ - [pattern 3 — e.g., "Error handling uses centralized AppError class"]
242
+
243
+ ### File Created
244
+ `$PHASE_DIR/$PADDED_PHASE-PATTERNS.md`
245
+
246
+ ### Ready for Planning
247
+ Pattern mapping complete. Planner can now reference analog patterns in PLAN.md files.
248
+ ```
249
+
250
+ </structured_returns>
251
+
252
+ <critical_rules>
253
+
254
+ - No re-reads of a range already in context (see Step 4).
255
+ - No source edits — PATTERNS.md is the only file you write; everything else is read-only.
256
+ - No heredoc writes — always the Write tool.
257
+
258
+ </critical_rules>
259
+
260
+ <success_criteria>
261
+
262
+ Complete when:
263
+
264
+ - [ ] All files from CONTEXT.md and RESEARCH.md classified by role and data flow
265
+ - [ ] Codebase searched for closest analog per file
266
+ - [ ] Each analog read and concrete code excerpts extracted
267
+ - [ ] Shared cross-cutting patterns identified
268
+ - [ ] Files with no analog clearly listed
269
+ - [ ] PATTERNS.md written to correct phase directory
270
+ - [ ] Structured return provided to orchestrator
271
+
272
+ Quality indicators: concrete (file paths + line numbers), accurate classification, best analog selected (closest match by role + data flow, preferring recent files), actionable for planner (patterns copyable directly into plan actions).
273
+
274
+ </success_criteria>
275
+ </output>
@@ -118,7 +118,7 @@ Construct a JSON file at a temp path (e.g. `/tmp/research-plan-input.json`):
118
118
  ### Step B — Obtain the fetch plan
119
119
 
120
120
  ```bash
121
- _GSD_SHIM_NAME="gsd-tools.cjs"; _GSD_RUNTIME_ROOT="${RUNTIME_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"; GSD_TOOLS="${_GSD_RUNTIME_ROOT}/gsd-core/bin/${_GSD_SHIM_NAME}"; _gsd_at() { for _p; do if [ -f "$_p" ]; then GSD_TOOLS="$_p"; return 0; fi; done; return 1; }; if _gsd_at "${_GSD_RUNTIME_ROOT}/gsd-core/bin/${_GSD_SHIM_NAME}" "${_GSD_RUNTIME_ROOT}/.claude/gsd-core/bin/${_GSD_SHIM_NAME}" "${_GSD_RUNTIME_ROOT}/.codex/gsd-core/bin/${_GSD_SHIM_NAME}"; then gsd_run() { node "$GSD_TOOLS" "$@"; }; elif unset -f gsd_run; _G="$(command -v gsd_run)"; then GSD_TOOLS="$_G"; gsd_run() { "$GSD_TOOLS" "$@"; }; elif _gsd_at "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/gsd-core/bin/${_GSD_SHIM_NAME}" "${HERMES_HOME:-$HOME/.hermes}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CURSOR_CONFIG_DIR:-$HOME/.cursor}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CODEX_HOME:-$HOME/.codex}/gsd-core/bin/${_GSD_SHIM_NAME}" "${GEMINI_CONFIG_DIR:-$HOME/.gemini}/gsd-core/bin/${_GSD_SHIM_NAME}" "${COPILOT_CONFIG_DIR:-$HOME/.copilot}/gsd-core/bin/${_GSD_SHIM_NAME}" "${WINDSURF_CONFIG_DIR:-$HOME/.codeium/windsurf}/gsd-core/bin/${_GSD_SHIM_NAME}" "${AUGMENT_CONFIG_DIR:-$HOME/.augment}/gsd-core/bin/${_GSD_SHIM_NAME}" "${TRAE_CONFIG_DIR:-$HOME/.trae}/gsd-core/bin/${_GSD_SHIM_NAME}" "${QWEN_CONFIG_DIR:-$HOME/.qwen}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CODEBUDDY_CONFIG_DIR:-$HOME/.codebuddy}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CLINE_CONFIG_DIR:-$HOME/.cline}/gsd-core/bin/${_GSD_SHIM_NAME}" "${GROK_AGENTS_HOME:-$HOME/.agents}/gsd-core/bin/${_GSD_SHIM_NAME}" "${ANTIGRAVITY_CONFIG_DIR:-$HOME/.gemini/antigravity}/gsd-core/bin/${_GSD_SHIM_NAME}" "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/gsd-core/bin/${_GSD_SHIM_NAME}" "${KILO_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/kilo}/gsd-core/bin/${_GSD_SHIM_NAME}"; then gsd_run() { node "$GSD_TOOLS" "$@"; }; else echo "ERROR: gsd-tools.cjs not found at $GSD_TOOLS and gsd_run is not on PATH. Run: npx -y @opengsd/gsd-core@latest --claude --local" >&2; exit 1; fi; GSD_IDENTITY_STATUS=unverified; case "$(gsd_run runtime-identity --raw 2>/dev/null || true)" in '{"packageName":"@opengsd/gsd-core"'*'}') GSD_IDENTITY_STATUS=ok;; esac; export GSD_IDENTITY_STATUS; [ "$GSD_IDENTITY_STATUS" = ok ] || echo "WARNING: \"$GSD_TOOLS\" did not prove it is @opengsd/gsd-core - it is either a different package or an @opengsd/gsd-core older than the runtime-identity verb. See docs/how-to/diagnose-a-foreign-gsd-tools.md" >&2; if [ -n "${CLAUDE_ENV_FILE:-}" ] && [ -n "${GSD_TOOLS:-}" ]; then printf "export PATH='%s':\"\$PATH\"\n" "${GSD_TOOLS%/*}" >> "$CLAUDE_ENV_FILE" 2>/dev/null || true; fi
121
+ _GSD_SHIM_NAME="gsd-tools.cjs"; _GSD_RUNTIME_ROOT="${RUNTIME_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"; GSD_TOOLS="${_GSD_RUNTIME_ROOT}/gsd-core/bin/${_GSD_SHIM_NAME}"; _gsd_at() { for _p; do if [ -f "$_p" ]; then GSD_TOOLS="$_p"; return 0; fi; done; return 1; }; _gsd_id_ok() { case "$("$1" runtime-identity --raw 2>/dev/null || true)" in '{"packageName":"@opengsd/gsd-core"'*'}') return 0;; *) return 1;; esac; }; _gsd_homes() { _gsd_at "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/gsd-core/bin/${_GSD_SHIM_NAME}" "${HERMES_HOME:-$HOME/.hermes}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CURSOR_CONFIG_DIR:-$HOME/.cursor}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CODEX_HOME:-$HOME/.codex}/gsd-core/bin/${_GSD_SHIM_NAME}" "${GEMINI_CONFIG_DIR:-$HOME/.gemini}/gsd-core/bin/${_GSD_SHIM_NAME}" "${COPILOT_CONFIG_DIR:-$HOME/.copilot}/gsd-core/bin/${_GSD_SHIM_NAME}" "${WINDSURF_CONFIG_DIR:-$HOME/.codeium/windsurf}/gsd-core/bin/${_GSD_SHIM_NAME}" "${AUGMENT_CONFIG_DIR:-$HOME/.augment}/gsd-core/bin/${_GSD_SHIM_NAME}" "${TRAE_CONFIG_DIR:-$HOME/.trae}/gsd-core/bin/${_GSD_SHIM_NAME}" "${QWEN_CONFIG_DIR:-$HOME/.qwen}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CODEBUDDY_CONFIG_DIR:-$HOME/.codebuddy}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CLINE_CONFIG_DIR:-$HOME/.cline}/gsd-core/bin/${_GSD_SHIM_NAME}" "${GROK_AGENTS_HOME:-$HOME/.agents}/gsd-core/bin/${_GSD_SHIM_NAME}" "${ANTIGRAVITY_CONFIG_DIR:-$HOME/.gemini/antigravity}/gsd-core/bin/${_GSD_SHIM_NAME}" "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/gsd-core/bin/${_GSD_SHIM_NAME}" "${KILO_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/kilo}/gsd-core/bin/${_GSD_SHIM_NAME}"; }; if _gsd_at "${_GSD_RUNTIME_ROOT}/gsd-core/bin/${_GSD_SHIM_NAME}" "${_GSD_RUNTIME_ROOT}/.claude/gsd-core/bin/${_GSD_SHIM_NAME}" "${_GSD_RUNTIME_ROOT}/.codex/gsd-core/bin/${_GSD_SHIM_NAME}"; then gsd_run() { node "$GSD_TOOLS" "$@"; }; elif _gsd_homes; then gsd_run() { node "$GSD_TOOLS" "$@"; }; elif unset -f gsd_run; _G="$(command -v gsd_run)"; [ -n "$_G" ] && _gsd_id_ok "$_G"; then GSD_TOOLS="$_G"; gsd_run() { "$GSD_TOOLS" "$@"; }; else echo "ERROR: gsd-tools.cjs not found at $GSD_TOOLS and no identity-proving gsd_run is on PATH. Run: npx -y @opengsd/gsd-core@latest --claude --local" >&2; exit 1; fi; GSD_IDENTITY_STATUS=unverified; _gsd_id_ok gsd_run && GSD_IDENTITY_STATUS=ok; export GSD_IDENTITY_STATUS; [ "$GSD_IDENTITY_STATUS" = ok ] || echo "WARNING: \"$GSD_TOOLS\" did not prove it is @opengsd/gsd-core - it is either a different package or an @opengsd/gsd-core older than the runtime-identity verb. See docs/how-to/diagnose-a-foreign-gsd-tools.md" >&2; if [ -n "${CLAUDE_ENV_FILE:-}" ] && [ -n "${GSD_TOOLS:-}" ]; then printf "export PATH='%s':\"\$PATH\"\n" "${GSD_TOOLS%/*}" >> "$CLAUDE_ENV_FILE" 2>/dev/null || true; fi
122
122
  gsd_run query research-plan --input /tmp/research-plan-input.json
123
123
  ```
124
124
 
@@ -566,26 +566,34 @@ if [ -e "${_CTX[0]}" ]; then cat "${_CTX[@]}"; fi
566
566
 
567
567
  ## Step 1.3: Load Graph Context
568
568
 
569
- Check for knowledge graph:
570
-
571
- ```bash
572
- ls .planning/graphs/graph.json 2>/dev/null
573
- ```
574
-
575
- If graph.json exists, check freshness:
569
+ Check for a knowledge graph and read its freshness in one call. `status` resolves the
570
+ graph through `graphify.graph_path`, so it is also the presence gate — a bare `ls` of
571
+ the default location misses an umbrella graph shared across sibling repos:
576
572
 
577
573
  ```bash
578
574
  gsd_run graphify status
579
575
  ```
580
576
 
577
+ If `exists` is `false`, continue to Step 1.5 without graph context.
578
+
581
579
  If the status response has `stale: true`, note for later: "Graph is {age_hours}h old -- treat semantic relationships as approximate." Include this annotation inline with any graph context injected below.
582
580
 
583
- Query the graph for each major capability in the phase scope (2-3 queries per D-05, discovery-focused):
581
+ The same response carries `graph_path` — the resolved graph location. Substitute it for `<graph>` below. `graph_path` comes from `graphify.graph_path` in `.planning/config.json`, a config surface already trusted elsewhere; if it ever carried attacker-controlled content, the literal double-quoted substitution below would need escaping.
582
+
583
+ Query the graph for each major capability in the phase scope (2-3 queries per D-05, discovery-focused). Prefer the `graphify` CLI when it is on PATH; fall back to the built-in reader otherwise:
584
584
 
585
585
  ```bash
586
- gsd_run graphify query "<capability-keyword>" --budget 1500
586
+ if command -v graphify >/dev/null 2>&1; then
587
+ graphify query "<capability-keyword>" --graph "<graph>" --budget 1500
588
+ else
589
+ gsd_run graphify query "<capability-keyword>" --budget 1500
590
+ fi
587
591
  ```
588
592
 
593
+ Why the CLI is preferred: it ranks seeds (IDF weighting, fuzzy matching) and applies context filters before traversal, where the built-in reader seeds by case-insensitive substring over label and description — so a term like "auth" seeds equally on `author` and `authorize` — and then expands a fixed two hops.
594
+
595
+ The two paths return **different shapes**: the CLI emits prose, the built-in emits JSON with per-edge confidence tiers and `budget_met`/`budget_estimate`. `--budget` caps rendered output on the CLI and estimated payload bytes in the built-in — same flag name, different unit. Read whichever you get; do not assume a stable shape.
596
+
589
597
  Derive query terms from the phase goal and requirement descriptions. Examples:
590
598
  - Phase "user authentication and session management" -> query "authentication", "session", "token"
591
599
  - Phase "payment integration" -> query "payment", "billing"
@@ -597,7 +605,7 @@ Use graph results to:
597
605
  - Surface dependencies the phase description does not explicitly mention
598
606
  - Inform which subsystems to investigate more deeply in subsequent research steps
599
607
 
600
- If no results or graph.json absent, continue to Step 1.5 without graph context.
608
+ If nothing comes back, continue to Step 1.5 without graph context.
601
609
 
602
610
  ## Step 1.5: Architectural Responsibility Mapping
603
611
 
@@ -518,16 +518,16 @@ issue:
518
518
 
519
519
  ## Dimension 8: Nyquist Compliance
520
520
 
521
- **Question:** Is every task's completion decided by an automated check that can actually fail?
521
+ **Question:** Is every task's completion decided by an automated check that can fail?
522
522
 
523
523
  Checks 8a-8e (presence, latency, sampling continuity, Wave 0 completeness, VALIDATION.md gate),
524
- their skip condition and the Dimension 8 output table: @gsd-core/references/nyquist-compliance.md
524
+ skip condition and Dimension 8 output table: @~/.claude/gsd-core/references/nyquist-compliance.md
525
525
 
526
526
  ### Check 8f - Stated Failing Direction (#3172)
527
527
 
528
528
  Each runnable `<automated>` command needs a `<fails_when>` sibling naming what output constitutes
529
- failure. Consume the supplied `{FAILING_DIRECTIONS}` probe, never re-derive it:
530
- @gsd-core/references/failing-direction.md
529
+ failure. Consume the `{FAILING_DIRECTIONS}` probe, never re-derive it:
530
+ @~/.claude/gsd-core/references/failing-direction.md
531
531
 
532
532
  ## Dimension 9: Cross-Plan Data Contracts
533
533
 
@@ -698,8 +698,8 @@ issue:
698
698
 
699
699
  ## Dimension: Verify Command Path Resolvability (#2401)
700
700
 
701
- **Question:** Does each `<automated>` command's target resolve? Consume the supplied
702
- `{VERIFY_PATHS}` probe, never re-run/hand-reason it: @gsd-core/references/verify-command-path-resolvability.md
701
+ **Question:** Does each `<automated>` command's target resolve? Consume the
702
+ `{VERIFY_PATHS}` probe, never re-run/hand-reason it: @~/.claude/gsd-core/references/verify-command-path-resolvability.md
703
703
 
704
704
  ## Dimension: Numeric/Factual Claim Authority (#1480)
705
705
 
@@ -725,8 +725,9 @@ issue:
725
725
  ## Step 1: Load Context
726
726
 
727
727
  Load phase operation context:
728
+ @~/.claude/gsd-core/references/gsd-run-resolver.md
729
+
728
730
  ```bash
729
- _GSD_SHIM_NAME="gsd-tools.cjs"; _GSD_RUNTIME_ROOT="${RUNTIME_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"; GSD_TOOLS="${_GSD_RUNTIME_ROOT}/gsd-core/bin/${_GSD_SHIM_NAME}"; _gsd_at() { for _p; do if [ -f "$_p" ]; then GSD_TOOLS="$_p"; return 0; fi; done; return 1; }; if _gsd_at "${_GSD_RUNTIME_ROOT}/gsd-core/bin/${_GSD_SHIM_NAME}" "${_GSD_RUNTIME_ROOT}/.claude/gsd-core/bin/${_GSD_SHIM_NAME}" "${_GSD_RUNTIME_ROOT}/.codex/gsd-core/bin/${_GSD_SHIM_NAME}"; then gsd_run() { node "$GSD_TOOLS" "$@"; }; elif unset -f gsd_run; _G="$(command -v gsd_run)"; then GSD_TOOLS="$_G"; gsd_run() { "$GSD_TOOLS" "$@"; }; elif _gsd_at "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/gsd-core/bin/${_GSD_SHIM_NAME}" "${HERMES_HOME:-$HOME/.hermes}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CURSOR_CONFIG_DIR:-$HOME/.cursor}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CODEX_HOME:-$HOME/.codex}/gsd-core/bin/${_GSD_SHIM_NAME}" "${GEMINI_CONFIG_DIR:-$HOME/.gemini}/gsd-core/bin/${_GSD_SHIM_NAME}" "${COPILOT_CONFIG_DIR:-$HOME/.copilot}/gsd-core/bin/${_GSD_SHIM_NAME}" "${WINDSURF_CONFIG_DIR:-$HOME/.codeium/windsurf}/gsd-core/bin/${_GSD_SHIM_NAME}" "${AUGMENT_CONFIG_DIR:-$HOME/.augment}/gsd-core/bin/${_GSD_SHIM_NAME}" "${TRAE_CONFIG_DIR:-$HOME/.trae}/gsd-core/bin/${_GSD_SHIM_NAME}" "${QWEN_CONFIG_DIR:-$HOME/.qwen}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CODEBUDDY_CONFIG_DIR:-$HOME/.codebuddy}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CLINE_CONFIG_DIR:-$HOME/.cline}/gsd-core/bin/${_GSD_SHIM_NAME}" "${GROK_AGENTS_HOME:-$HOME/.agents}/gsd-core/bin/${_GSD_SHIM_NAME}" "${ANTIGRAVITY_CONFIG_DIR:-$HOME/.gemini/antigravity}/gsd-core/bin/${_GSD_SHIM_NAME}" "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/gsd-core/bin/${_GSD_SHIM_NAME}" "${KILO_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/kilo}/gsd-core/bin/${_GSD_SHIM_NAME}"; then gsd_run() { node "$GSD_TOOLS" "$@"; }; else echo "ERROR: gsd-tools.cjs not found at $GSD_TOOLS and gsd_run is not on PATH. Run: npx -y @opengsd/gsd-core@latest --claude --local" >&2; exit 1; fi; GSD_IDENTITY_STATUS=unverified; case "$(gsd_run runtime-identity --raw 2>/dev/null || true)" in '{"packageName":"@opengsd/gsd-core"'*'}') GSD_IDENTITY_STATUS=ok;; esac; export GSD_IDENTITY_STATUS; [ "$GSD_IDENTITY_STATUS" = ok ] || echo "WARNING: \"$GSD_TOOLS\" did not prove it is @opengsd/gsd-core - it is either a different package or an @opengsd/gsd-core older than the runtime-identity verb. See docs/how-to/diagnose-a-foreign-gsd-tools.md" >&2; if [ -n "${CLAUDE_ENV_FILE:-}" ] && [ -n "${GSD_TOOLS:-}" ]; then printf "export PATH='%s':\"\$PATH\"\n" "${GSD_TOOLS%/*}" >> "$CLAUDE_ENV_FILE" 2>/dev/null || true; fi
730
731
  INIT=$(gsd_run query init.phase-op "${PHASE_ARG}")
731
732
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
732
733
  ```
@@ -190,16 +190,16 @@ Every task has four required fields:
190
190
 
191
191
  **Nyquist Rule:** Every `<verify>` includes `<automated>`. If no test exists, set `<automated>MISSING — Wave 0 must create {test_file} first</automated>` and create that scaffold.
192
192
 
193
- **Inherit the command that already worked (#2401):** reuse `prior_verify_commands` verbatim, prefer `npm --prefix <dir> run <script>`, ground every path you author. @gsd-core/references/planner-verify-command-grounding.md
193
+ **Inherit the command that already worked (#2401):** reuse `prior_verify_commands` verbatim, prefer `npm --prefix <dir> run <script>`, ground every path you author. @~/.claude/gsd-core/references/planner-verify-command-grounding.md
194
194
 
195
195
  **Grep gate hygiene:** `grep -c` counts comments, so header prose can be self-invalidating. Use `grep -v '^#' | grep -c token`. Bare `== 0` gates on unfiltered files are forbidden.
196
196
 
197
197
  <comment_text_discipline>
198
- **Comment-text discipline (HARD GATE, #429):** A literal an acceptance criterion negative-greps for must NOT appear verbatim in any `<action>` body. Full rules + `<!-- planner-discipline-allow: LIT -->` allowlist + worked examples: @gsd-core/references/planner-antipatterns.md ("Comment-Text Discipline").
198
+ **Comment-text discipline (HARD GATE, #429):** A literal an acceptance criterion negative-greps for must NOT appear verbatim in any `<action>` body. Rules + `<!-- planner-discipline-allow: LIT -->` allowlist + examples: @~/.claude/gsd-core/references/planner-antipatterns.md ("Comment-Text Discipline").
199
199
  </comment_text_discipline>
200
200
 
201
201
  <region_scoped_negative_gate>
202
- **Region-scoped negative gates (WARN, #968)** and **Verify-gate hygiene (#1478/#1479):** @gsd-core/references/planner-antipatterns.md.
202
+ **Region-scoped negative gates (WARN, #968)** and **Verify-gate hygiene (#1478/#1479):** @~/.claude/gsd-core/references/planner-antipatterns.md.
203
203
  </region_scoped_negative_gate>
204
204
 
205
205
  **<done>:** Acceptance criteria - measurable state of completion.
@@ -372,6 +372,8 @@ Output: [Artifacts created]
372
372
 
373
373
  ## STRIDE Threat Register
374
374
 
375
+ Threat IDs are unique within a phase. Before numbering, read the `<threat_model>` blocks of the phase's existing PLAN files and continue after their highest `T-{phase}-NN` — if the phase already uses `T-47-19`, new plans number from `T-47-20`, never from `T-47-01` again (#4683: a reused ID names two different threats, which makes `SECURITY.md` rows and `VALIDATION.md`'s Threat Ref column ambiguous). `T-{phase}-SC` is the exception: reserved, and every plan keeps it.
376
+
375
377
  | Threat ID | Category | Component | Severity | Disposition | Mitigation Plan |
376
378
  |-----------|----------|-----------|----------|-------------|-----------------|
377
379
  | T-{phase}-01 | {S/T/R/I/D/E} | {function/endpoint/file} | {critical\|high\|medium\|low} | mitigate | {specific mitigation action} |
@@ -566,8 +568,9 @@ start of execution when `--reviews` flag is present or reviews mode is active.
566
568
  <step name="load_project_state" priority="first">
567
569
  Load planning context:
568
570
 
571
+ @~/.claude/gsd-core/references/gsd-run-resolver.md
572
+
569
573
  ```bash
570
- _GSD_SHIM_NAME="gsd-tools.cjs"; _GSD_RUNTIME_ROOT="${RUNTIME_DIR:-$(git rev-parse --show-toplevel 2>/dev/null || pwd)}"; GSD_TOOLS="${_GSD_RUNTIME_ROOT}/gsd-core/bin/${_GSD_SHIM_NAME}"; _gsd_at() { for _p; do if [ -f "$_p" ]; then GSD_TOOLS="$_p"; return 0; fi; done; return 1; }; if _gsd_at "${_GSD_RUNTIME_ROOT}/gsd-core/bin/${_GSD_SHIM_NAME}" "${_GSD_RUNTIME_ROOT}/.claude/gsd-core/bin/${_GSD_SHIM_NAME}" "${_GSD_RUNTIME_ROOT}/.codex/gsd-core/bin/${_GSD_SHIM_NAME}"; then gsd_run() { node "$GSD_TOOLS" "$@"; }; elif unset -f gsd_run; _G="$(command -v gsd_run)"; then GSD_TOOLS="$_G"; gsd_run() { "$GSD_TOOLS" "$@"; }; elif _gsd_at "${CLAUDE_CONFIG_DIR:-$HOME/.claude}/gsd-core/bin/${_GSD_SHIM_NAME}" "${HERMES_HOME:-$HOME/.hermes}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CURSOR_CONFIG_DIR:-$HOME/.cursor}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CODEX_HOME:-$HOME/.codex}/gsd-core/bin/${_GSD_SHIM_NAME}" "${GEMINI_CONFIG_DIR:-$HOME/.gemini}/gsd-core/bin/${_GSD_SHIM_NAME}" "${COPILOT_CONFIG_DIR:-$HOME/.copilot}/gsd-core/bin/${_GSD_SHIM_NAME}" "${WINDSURF_CONFIG_DIR:-$HOME/.codeium/windsurf}/gsd-core/bin/${_GSD_SHIM_NAME}" "${AUGMENT_CONFIG_DIR:-$HOME/.augment}/gsd-core/bin/${_GSD_SHIM_NAME}" "${TRAE_CONFIG_DIR:-$HOME/.trae}/gsd-core/bin/${_GSD_SHIM_NAME}" "${QWEN_CONFIG_DIR:-$HOME/.qwen}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CODEBUDDY_CONFIG_DIR:-$HOME/.codebuddy}/gsd-core/bin/${_GSD_SHIM_NAME}" "${CLINE_CONFIG_DIR:-$HOME/.cline}/gsd-core/bin/${_GSD_SHIM_NAME}" "${GROK_AGENTS_HOME:-$HOME/.agents}/gsd-core/bin/${_GSD_SHIM_NAME}" "${ANTIGRAVITY_CONFIG_DIR:-$HOME/.gemini/antigravity}/gsd-core/bin/${_GSD_SHIM_NAME}" "${OPENCODE_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/opencode}/gsd-core/bin/${_GSD_SHIM_NAME}" "${KILO_CONFIG_DIR:-${XDG_CONFIG_HOME:-$HOME/.config}/kilo}/gsd-core/bin/${_GSD_SHIM_NAME}"; then gsd_run() { node "$GSD_TOOLS" "$@"; }; else echo "ERROR: gsd-tools.cjs not found at $GSD_TOOLS and gsd_run is not on PATH. Run: npx -y @opengsd/gsd-core@latest --claude --local" >&2; exit 1; fi; GSD_IDENTITY_STATUS=unverified; case "$(gsd_run runtime-identity --raw 2>/dev/null || true)" in '{"packageName":"@opengsd/gsd-core"'*'}') GSD_IDENTITY_STATUS=ok;; esac; export GSD_IDENTITY_STATUS; [ "$GSD_IDENTITY_STATUS" = ok ] || echo "WARNING: \"$GSD_TOOLS\" did not prove it is @opengsd/gsd-core - it is either a different package or an @opengsd/gsd-core older than the runtime-identity verb. See docs/how-to/diagnose-a-foreign-gsd-tools.md" >&2; if [ -n "${CLAUDE_ENV_FILE:-}" ] && [ -n "${GSD_TOOLS:-}" ]; then printf "export PATH='%s':\"\$PATH\"\n" "${GSD_TOOLS%/*}" >> "$CLAUDE_ENV_FILE" 2>/dev/null || true; fi
571
574
  INIT=$(gsd_run query init.plan-phase "${PHASE}")
572
575
  if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
573
576
  ```
@@ -617,9 +620,10 @@ If exists, load relevant documents by phase type:
617
620
 
618
621
  <step name="load_graph_context">
619
622
  Read `gsd-core/references/planner-load-graph-context.md` and execute it. It checks for a
620
- knowledge graph and, if `.planning/graphs/graph.json` exists, reads freshness and
621
- phase-relevant dependency context via the `gsd_run` launcher and incorporates the results
622
- into planning. If the graph is absent, skip and continue without graph context.
623
+ knowledge graph and, if one exists, reads freshness and phase-relevant dependency context
624
+ — through the `graphify` CLI when it is on PATH, otherwise through the `gsd_run` launcher
625
+ — and incorporates the results into planning. If the graph is absent, skip and continue
626
+ without graph context.
623
627
  </step>
624
628
 
625
629
  <step name="identify_phase">
@@ -756,7 +760,7 @@ for each plan B in plan_order:
756
760
 
757
761
  **Rule:** Same-wave plans must have zero `files_modified`/`files_deleted` overlap. After assigning waves, scan each wave; if any file appears in 2+ plans, bump the later plan to the next wave and repeat.
758
762
 
759
- **External review ordering:** When a PR opening has known automatic external review (for example a GitHub App reviewer such as CodeRabbit, configured via `.coderabbit.yaml`, which reviews automatically on PR open) and the plan includes internal review lanes, run internal review and apply the accepted internal-review fixes before the final open. If an open-time property exists (for example a not-behind-base check that must legitimately be measured at PR-open instant), re-check it immediately before opening, with nothing intervening; post-open CI, review, and tracking may follow. Examples: @gsd-core/references/planner-antipatterns.md ("External Review Before PR Open (#4107)").
763
+ **External review ordering:** When a PR opening has known automatic external review (for example a GitHub App reviewer such as CodeRabbit via `.coderabbit.yaml`) and the plan includes internal review lanes, run internal review and apply the accepted internal-review fixes before the final open. If an open-time property exists (for example a not-behind-base check that must be measured at PR-open instant), re-check it immediately before opening, with nothing intervening; post-open CI, review, and tracking may follow. Examples: @~/.claude/gsd-core/references/planner-antipatterns.md ("External Review Before PR Open (#4107)").
760
764
 
761
765
  Non-file coupling: @~/.claude/gsd-core/references/planner-coupling.md
762
766
  </step>