@therocketcode/gsd-core 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (568) hide show
  1. package/.claude-plugin/plugin.json +23 -0
  2. package/GEMINI.md +53 -0
  3. package/LICENSE +21 -0
  4. package/README.ja-JP.md +125 -0
  5. package/README.ko-KR.md +125 -0
  6. package/README.md +144 -0
  7. package/README.pt-BR.md +125 -0
  8. package/README.zh-CN.md +125 -0
  9. package/agents/gsd-advisor-researcher.md +108 -0
  10. package/agents/gsd-ai-researcher.md +114 -0
  11. package/agents/gsd-assumptions-analyzer.md +105 -0
  12. package/agents/gsd-code-fixer.md +668 -0
  13. package/agents/gsd-code-reviewer.md +387 -0
  14. package/agents/gsd-codebase-mapper.md +853 -0
  15. package/agents/gsd-debug-session-manager.md +314 -0
  16. package/agents/gsd-debugger.md +1452 -0
  17. package/agents/gsd-doc-classifier.md +168 -0
  18. package/agents/gsd-doc-synthesizer.md +204 -0
  19. package/agents/gsd-doc-verifier.md +217 -0
  20. package/agents/gsd-doc-writer.md +616 -0
  21. package/agents/gsd-domain-researcher.md +147 -0
  22. package/agents/gsd-eval-auditor.md +191 -0
  23. package/agents/gsd-eval-planner.md +154 -0
  24. package/agents/gsd-executor.md +785 -0
  25. package/agents/gsd-framework-selector.md +160 -0
  26. package/agents/gsd-integration-checker.md +470 -0
  27. package/agents/gsd-intel-updater.md +342 -0
  28. package/agents/gsd-nyquist-auditor.md +203 -0
  29. package/agents/gsd-pattern-mapper.md +335 -0
  30. package/agents/gsd-phase-researcher.md +867 -0
  31. package/agents/gsd-plan-checker.md +978 -0
  32. package/agents/gsd-planner.md +1204 -0
  33. package/agents/gsd-project-researcher.md +611 -0
  34. package/agents/gsd-research-synthesizer.md +259 -0
  35. package/agents/gsd-roadmapper.md +688 -0
  36. package/agents/gsd-security-auditor.md +155 -0
  37. package/agents/gsd-ui-auditor.md +495 -0
  38. package/agents/gsd-ui-checker.md +309 -0
  39. package/agents/gsd-ui-researcher.md +374 -0
  40. package/agents/gsd-user-profiler.md +171 -0
  41. package/agents/gsd-verifier.md +923 -0
  42. package/assets/gsd-logo-2000-transparent.png +0 -0
  43. package/assets/gsd-logo-2000-transparent.svg +17 -0
  44. package/assets/gsd-logo-2000.png +0 -0
  45. package/assets/gsd-logo-2000.svg +21 -0
  46. package/assets/terminal.svg +68 -0
  47. package/bin/install.js +12726 -0
  48. package/bin/lib/ui-safety-gate.cjs +107 -0
  49. package/commands/gsd/add-tests.md +42 -0
  50. package/commands/gsd/ai-integration-phase.md +37 -0
  51. package/commands/gsd/audit-fix.md +34 -0
  52. package/commands/gsd/audit-milestone.md +37 -0
  53. package/commands/gsd/audit-uat.md +24 -0
  54. package/commands/gsd/autonomous.md +48 -0
  55. package/commands/gsd/capture.md +62 -0
  56. package/commands/gsd/cleanup.md +24 -0
  57. package/commands/gsd/code-review.md +59 -0
  58. package/commands/gsd/complete-milestone.md +143 -0
  59. package/commands/gsd/config.md +56 -0
  60. package/commands/gsd/debug.md +52 -0
  61. package/commands/gsd/discover-product.md +65 -0
  62. package/commands/gsd/discuss-phase.md +77 -0
  63. package/commands/gsd/docs-update.md +49 -0
  64. package/commands/gsd/eval-review.md +33 -0
  65. package/commands/gsd/execute-phase.md +66 -0
  66. package/commands/gsd/explore.md +27 -0
  67. package/commands/gsd/extract-learnings.md +23 -0
  68. package/commands/gsd/fast.md +31 -0
  69. package/commands/gsd/forensics.md +57 -0
  70. package/commands/gsd/graphify.md +204 -0
  71. package/commands/gsd/health.md +31 -0
  72. package/commands/gsd/help.md +28 -0
  73. package/commands/gsd/import.md +45 -0
  74. package/commands/gsd/inbox.md +39 -0
  75. package/commands/gsd/ingest-docs.md +42 -0
  76. package/commands/gsd/manager.md +45 -0
  77. package/commands/gsd/map-codebase.md +83 -0
  78. package/commands/gsd/milestone-summary.md +51 -0
  79. package/commands/gsd/model-domain.md +65 -0
  80. package/commands/gsd/mvp-phase.md +45 -0
  81. package/commands/gsd/new-milestone.md +45 -0
  82. package/commands/gsd/new-project.md +47 -0
  83. package/commands/gsd/ns-context.md +23 -0
  84. package/commands/gsd/ns-ideate.md +24 -0
  85. package/commands/gsd/ns-manage.md +29 -0
  86. package/commands/gsd/ns-project.md +22 -0
  87. package/commands/gsd/ns-review.md +26 -0
  88. package/commands/gsd/ns-workflow.md +28 -0
  89. package/commands/gsd/pause-work.md +43 -0
  90. package/commands/gsd/phase.md +56 -0
  91. package/commands/gsd/plan-phase.md +64 -0
  92. package/commands/gsd/plan-review-convergence.md +59 -0
  93. package/commands/gsd/pr-branch.md +26 -0
  94. package/commands/gsd/profile-user.md +46 -0
  95. package/commands/gsd/progress.md +48 -0
  96. package/commands/gsd/quick.md +174 -0
  97. package/commands/gsd/recommend-architecture.md +64 -0
  98. package/commands/gsd/resume-work.md +30 -0
  99. package/commands/gsd/review-backlog.md +63 -0
  100. package/commands/gsd/review.md +42 -0
  101. package/commands/gsd/secure-phase.md +36 -0
  102. package/commands/gsd/settings.md +29 -0
  103. package/commands/gsd/ship.md +24 -0
  104. package/commands/gsd/sketch.md +60 -0
  105. package/commands/gsd/spec-phase.md +63 -0
  106. package/commands/gsd/spike.md +57 -0
  107. package/commands/gsd/stats.md +20 -0
  108. package/commands/gsd/surface.md +155 -0
  109. package/commands/gsd/testing-strategy.md +65 -0
  110. package/commands/gsd/thread.md +24 -0
  111. package/commands/gsd/ui-phase.md +35 -0
  112. package/commands/gsd/ui-review.md +33 -0
  113. package/commands/gsd/ultraplan-phase.md +34 -0
  114. package/commands/gsd/undo.md +35 -0
  115. package/commands/gsd/update.md +49 -0
  116. package/commands/gsd/validate-phase.md +36 -0
  117. package/commands/gsd/verify-work.md +39 -0
  118. package/commands/gsd/workspace.md +52 -0
  119. package/commands/gsd/workstreams.md +70 -0
  120. package/gemini-extension.json +6 -0
  121. package/gsd-core/bin/check-latest-version.cjs +161 -0
  122. package/gsd-core/bin/gsd-tools.cjs +1928 -0
  123. package/gsd-core/bin/lib/active-workstream-store.cjs +291 -0
  124. package/gsd-core/bin/lib/adr-parser.cjs +399 -0
  125. package/gsd-core/bin/lib/agent-command-router.cjs +68 -0
  126. package/gsd-core/bin/lib/artifacts.cjs +51 -0
  127. package/gsd-core/bin/lib/audit.cjs +743 -0
  128. package/gsd-core/bin/lib/check-command-router.cjs +343 -0
  129. package/gsd-core/bin/lib/cjs-command-router-adapter.cjs +81 -0
  130. package/gsd-core/bin/lib/cli-exit.cjs +42 -0
  131. package/gsd-core/bin/lib/clock.cjs +95 -0
  132. package/gsd-core/bin/lib/clusters.cjs +132 -0
  133. package/gsd-core/bin/lib/code-review-flags.cjs +59 -0
  134. package/gsd-core/bin/lib/command-aliases.cjs +809 -0
  135. package/gsd-core/bin/lib/command-arg-projection.cjs +55 -0
  136. package/gsd-core/bin/lib/command-routing-hub.cjs +300 -0
  137. package/gsd-core/bin/lib/commands.cjs +1203 -0
  138. package/gsd-core/bin/lib/config-schema.cjs +29 -0
  139. package/gsd-core/bin/lib/config-types.cjs +19 -0
  140. package/gsd-core/bin/lib/config.cjs +738 -0
  141. package/gsd-core/bin/lib/configuration.cjs +239 -0
  142. package/gsd-core/bin/lib/context-utilization.cjs +48 -0
  143. package/gsd-core/bin/lib/core.cjs +2051 -0
  144. package/gsd-core/bin/lib/decisions.cjs +118 -0
  145. package/gsd-core/bin/lib/docs.cjs +252 -0
  146. package/gsd-core/bin/lib/drift.cjs +364 -0
  147. package/gsd-core/bin/lib/fallow-runner.cjs +115 -0
  148. package/gsd-core/bin/lib/frontmatter.cjs +442 -0
  149. package/gsd-core/bin/lib/gap-checker.cjs +257 -0
  150. package/gsd-core/bin/lib/graphify.cjs +496 -0
  151. package/gsd-core/bin/lib/gsd2-import.cjs +456 -0
  152. package/gsd-core/bin/lib/init-command-router.cjs +62 -0
  153. package/gsd-core/bin/lib/init.cjs +1815 -0
  154. package/gsd-core/bin/lib/install-profiles.cjs +584 -0
  155. package/gsd-core/bin/lib/installer-migration-authoring.cjs +122 -0
  156. package/gsd-core/bin/lib/installer-migration-report.cjs +350 -0
  157. package/gsd-core/bin/lib/installer-migrations/000-first-time-baseline.cjs +218 -0
  158. package/gsd-core/bin/lib/installer-migrations/001-legacy-orphan-files.cjs +48 -0
  159. package/gsd-core/bin/lib/installer-migrations/002-codex-legacy-hooks-json.cjs +94 -0
  160. package/gsd-core/bin/lib/installer-migrations/003-rename-get-shit-done-to-gsd-core.cjs +108 -0
  161. package/gsd-core/bin/lib/installer-migrations.cjs +823 -0
  162. package/gsd-core/bin/lib/intel.cjs +590 -0
  163. package/gsd-core/bin/lib/learnings.cjs +270 -0
  164. package/gsd-core/bin/lib/legacy-cleanup.cjs +253 -0
  165. package/gsd-core/bin/lib/milestone.cjs +373 -0
  166. package/gsd-core/bin/lib/model-catalog.cjs +154 -0
  167. package/gsd-core/bin/lib/model-profiles.cjs +24 -0
  168. package/gsd-core/bin/lib/observability/event.cjs +51 -0
  169. package/gsd-core/bin/lib/observability/logger.cjs +146 -0
  170. package/gsd-core/bin/lib/observability/redaction.cjs +48 -0
  171. package/gsd-core/bin/lib/package-identity.cjs +35 -0
  172. package/gsd-core/bin/lib/package-legitimacy.cjs +368 -0
  173. package/gsd-core/bin/lib/phase-command-router.cjs +189 -0
  174. package/gsd-core/bin/lib/phase-lifecycle.cjs +74 -0
  175. package/gsd-core/bin/lib/phase.cjs +1307 -0
  176. package/gsd-core/bin/lib/phases-command-router.cjs +43 -0
  177. package/gsd-core/bin/lib/plan-scan.cjs +91 -0
  178. package/gsd-core/bin/lib/planning-workspace.cjs +245 -0
  179. package/gsd-core/bin/lib/profile-output.cjs +1120 -0
  180. package/gsd-core/bin/lib/profile-pipeline.cjs +517 -0
  181. package/gsd-core/bin/lib/project-root.cjs +119 -0
  182. package/gsd-core/bin/lib/prompt-budget.cjs +305 -0
  183. package/gsd-core/bin/lib/research-provider.cjs +137 -0
  184. package/gsd-core/bin/lib/research-store.cjs +167 -0
  185. package/gsd-core/bin/lib/review-reviewer-selection.cjs +121 -0
  186. package/gsd-core/bin/lib/roadmap-command-router.cjs +166 -0
  187. package/gsd-core/bin/lib/roadmap-upgrade.cjs +476 -0
  188. package/gsd-core/bin/lib/roadmap.cjs +600 -0
  189. package/gsd-core/bin/lib/runtime-artifact-layout.cjs +312 -0
  190. package/gsd-core/bin/lib/runtime-config-adapter-registry.cjs +56 -0
  191. package/gsd-core/bin/lib/runtime-homes.cjs +190 -0
  192. package/gsd-core/bin/lib/runtime-name-policy.cjs +96 -0
  193. package/gsd-core/bin/lib/runtime-slash.cjs +119 -0
  194. package/gsd-core/bin/lib/schema-detect.cjs +159 -0
  195. package/gsd-core/bin/lib/secrets.cjs +34 -0
  196. package/gsd-core/bin/lib/security.cjs +480 -0
  197. package/gsd-core/bin/lib/semver-compare.cjs +42 -0
  198. package/gsd-core/bin/lib/shell-command-projection.cjs +533 -0
  199. package/gsd-core/bin/lib/state-command-router.cjs +160 -0
  200. package/gsd-core/bin/lib/state-document.cjs +259 -0
  201. package/gsd-core/bin/lib/state.cjs +2010 -0
  202. package/gsd-core/bin/lib/surface.cjs +449 -0
  203. package/gsd-core/bin/lib/task-command-router.cjs +85 -0
  204. package/gsd-core/bin/lib/template.cjs +237 -0
  205. package/gsd-core/bin/lib/uat.cjs +297 -0
  206. package/gsd-core/bin/lib/ui-safety-gate.cjs +98 -0
  207. package/gsd-core/bin/lib/update-context.cjs +218 -0
  208. package/gsd-core/bin/lib/validate-command-router.cjs +91 -0
  209. package/gsd-core/bin/lib/validate.cjs +112 -0
  210. package/gsd-core/bin/lib/verification-command-router.cjs +31 -0
  211. package/gsd-core/bin/lib/verification.cjs +193 -0
  212. package/gsd-core/bin/lib/verify-command-router.cjs +44 -0
  213. package/gsd-core/bin/lib/verify.cjs +1451 -0
  214. package/gsd-core/bin/lib/workstream-inventory-builder.cjs +81 -0
  215. package/gsd-core/bin/lib/workstream-inventory.cjs +147 -0
  216. package/gsd-core/bin/lib/workstream-name-policy.cjs +91 -0
  217. package/gsd-core/bin/lib/workstream.cjs +380 -0
  218. package/gsd-core/bin/lib/worktree-base-ref.cjs +325 -0
  219. package/gsd-core/bin/lib/worktree-safety.cjs +943 -0
  220. package/gsd-core/bin/shared/config-defaults.manifest.json +98 -0
  221. package/gsd-core/bin/shared/config-schema.manifest.json +192 -0
  222. package/gsd-core/bin/shared/model-catalog.json +149 -0
  223. package/gsd-core/bin/shared/runtime-aliases.manifest.json +75 -0
  224. package/gsd-core/bin/verify-reapply-patches.cjs +349 -0
  225. package/gsd-core/contexts/dev.md +21 -0
  226. package/gsd-core/contexts/research.md +22 -0
  227. package/gsd-core/contexts/review.md +23 -0
  228. package/gsd-core/references/agent-contracts.md +79 -0
  229. package/gsd-core/references/ai-evals.md +156 -0
  230. package/gsd-core/references/ai-frameworks.md +186 -0
  231. package/gsd-core/references/architecture-decision.md +74 -0
  232. package/gsd-core/references/artifact-types.md +131 -0
  233. package/gsd-core/references/auth-in-tests.md +91 -0
  234. package/gsd-core/references/autonomous-smart-discuss.md +277 -0
  235. package/gsd-core/references/checkpoints.md +814 -0
  236. package/gsd-core/references/common-bug-patterns.md +114 -0
  237. package/gsd-core/references/context-budget.md +85 -0
  238. package/gsd-core/references/continuation-format.md +253 -0
  239. package/gsd-core/references/db-test-isolation.md +54 -0
  240. package/gsd-core/references/debugger-philosophy.md +76 -0
  241. package/gsd-core/references/decimal-phase-calculation.md +64 -0
  242. package/gsd-core/references/doc-conflict-engine.md +91 -0
  243. package/gsd-core/references/domain-modeling.md +80 -0
  244. package/gsd-core/references/domain-probes.md +125 -0
  245. package/gsd-core/references/e2e-tiering.md +35 -0
  246. package/gsd-core/references/execute-mvp-tdd.md +81 -0
  247. package/gsd-core/references/executor-examples.md +110 -0
  248. package/gsd-core/references/few-shot-examples/plan-checker.md +73 -0
  249. package/gsd-core/references/few-shot-examples/verifier.md +109 -0
  250. package/gsd-core/references/flaky-test-checklist.md +22 -0
  251. package/gsd-core/references/gate-prompts.md +100 -0
  252. package/gsd-core/references/gates.md +70 -0
  253. package/gsd-core/references/git-integration.md +298 -0
  254. package/gsd-core/references/git-planning-commit.md +40 -0
  255. package/gsd-core/references/ios-scaffold.md +123 -0
  256. package/gsd-core/references/mandatory-initial-read.md +2 -0
  257. package/gsd-core/references/model-profile-resolution.md +38 -0
  258. package/gsd-core/references/model-profiles.md +245 -0
  259. package/gsd-core/references/mvp-concepts.md +49 -0
  260. package/gsd-core/references/phase-argument-parsing.md +61 -0
  261. package/gsd-core/references/planner-antipatterns.md +89 -0
  262. package/gsd-core/references/planner-chunked.md +49 -0
  263. package/gsd-core/references/planner-gap-closure.md +62 -0
  264. package/gsd-core/references/planner-graphify-auto-update.md +67 -0
  265. package/gsd-core/references/planner-human-verify-mode.md +57 -0
  266. package/gsd-core/references/planner-interface-context.md +62 -0
  267. package/gsd-core/references/planner-load-graph-context.md +36 -0
  268. package/gsd-core/references/planner-mvp-mode.md +53 -0
  269. package/gsd-core/references/planner-reviews.md +39 -0
  270. package/gsd-core/references/planner-revision.md +87 -0
  271. package/gsd-core/references/planner-source-audit.md +73 -0
  272. package/gsd-core/references/planning-config.md +473 -0
  273. package/gsd-core/references/product-discovery.md +49 -0
  274. package/gsd-core/references/project-skills-discovery.md +19 -0
  275. package/gsd-core/references/questioning.md +162 -0
  276. package/gsd-core/references/realistic-test-data.md +44 -0
  277. package/gsd-core/references/research-documentation-lookup.md +29 -0
  278. package/gsd-core/references/research-philosophy.md +29 -0
  279. package/gsd-core/references/research-verification-protocol.md +27 -0
  280. package/gsd-core/references/revision-loop.md +97 -0
  281. package/gsd-core/references/scout-codebase.md +51 -0
  282. package/gsd-core/references/skeleton-template.md +48 -0
  283. package/gsd-core/references/sketch-interactivity.md +41 -0
  284. package/gsd-core/references/sketch-theme-system.md +94 -0
  285. package/gsd-core/references/sketch-tooling.md +45 -0
  286. package/gsd-core/references/sketch-variant-patterns.md +81 -0
  287. package/gsd-core/references/spidr-splitting.md +69 -0
  288. package/gsd-core/references/tdd.md +330 -0
  289. package/gsd-core/references/test-containers.md +55 -0
  290. package/gsd-core/references/test-strategy.md +75 -0
  291. package/gsd-core/references/thinking-models-debug.md +44 -0
  292. package/gsd-core/references/thinking-models-execution.md +50 -0
  293. package/gsd-core/references/thinking-models-planning.md +62 -0
  294. package/gsd-core/references/thinking-models-research.md +50 -0
  295. package/gsd-core/references/thinking-models-verification.md +55 -0
  296. package/gsd-core/references/thinking-partner.md +96 -0
  297. package/gsd-core/references/ui-brand.md +162 -0
  298. package/gsd-core/references/universal-anti-patterns.md +63 -0
  299. package/gsd-core/references/user-profiling.md +681 -0
  300. package/gsd-core/references/user-story-template.md +58 -0
  301. package/gsd-core/references/verification-overrides.md +227 -0
  302. package/gsd-core/references/verification-patterns.md +612 -0
  303. package/gsd-core/references/verify-mvp-mode.md +85 -0
  304. package/gsd-core/references/workstream-flag.md +111 -0
  305. package/gsd-core/references/worktree-branch-check.md +38 -0
  306. package/gsd-core/references/worktree-path-safety.md +67 -0
  307. package/gsd-core/templates/AI-SPEC.md +246 -0
  308. package/gsd-core/templates/DEBUG.md +169 -0
  309. package/gsd-core/templates/README.md +77 -0
  310. package/gsd-core/templates/SECURITY.md +61 -0
  311. package/gsd-core/templates/UAT.md +265 -0
  312. package/gsd-core/templates/UI-SPEC.md +100 -0
  313. package/gsd-core/templates/VALIDATION.md +76 -0
  314. package/gsd-core/templates/adr.md +58 -0
  315. package/gsd-core/templates/claude-md.md +145 -0
  316. package/gsd-core/templates/codebase/architecture.md +255 -0
  317. package/gsd-core/templates/codebase/concerns.md +310 -0
  318. package/gsd-core/templates/codebase/conventions.md +307 -0
  319. package/gsd-core/templates/codebase/integrations.md +280 -0
  320. package/gsd-core/templates/codebase/stack.md +186 -0
  321. package/gsd-core/templates/codebase/structure.md +285 -0
  322. package/gsd-core/templates/codebase/testing.md +480 -0
  323. package/gsd-core/templates/config.json +62 -0
  324. package/gsd-core/templates/context.md +352 -0
  325. package/gsd-core/templates/continue-here.md +78 -0
  326. package/gsd-core/templates/copilot-instructions.md +7 -0
  327. package/gsd-core/templates/debug-subagent-prompt.md +91 -0
  328. package/gsd-core/templates/dev-preferences.md +21 -0
  329. package/gsd-core/templates/discovery.md +146 -0
  330. package/gsd-core/templates/discussion-log.md +63 -0
  331. package/gsd-core/templates/domain-model.md +54 -0
  332. package/gsd-core/templates/milestone-archive.md +123 -0
  333. package/gsd-core/templates/milestone.md +115 -0
  334. package/gsd-core/templates/phase-prompt.md +610 -0
  335. package/gsd-core/templates/planner-subagent-prompt.md +117 -0
  336. package/gsd-core/templates/product-brief.md +55 -0
  337. package/gsd-core/templates/project.md +186 -0
  338. package/gsd-core/templates/requirements.md +231 -0
  339. package/gsd-core/templates/research-project/ARCHITECTURE.md +204 -0
  340. package/gsd-core/templates/research-project/FEATURES.md +147 -0
  341. package/gsd-core/templates/research-project/PITFALLS.md +200 -0
  342. package/gsd-core/templates/research-project/STACK.md +120 -0
  343. package/gsd-core/templates/research-project/SUMMARY.md +170 -0
  344. package/gsd-core/templates/research.md +592 -0
  345. package/gsd-core/templates/retrospective.md +54 -0
  346. package/gsd-core/templates/roadmap.md +202 -0
  347. package/gsd-core/templates/spec.md +307 -0
  348. package/gsd-core/templates/state.md +195 -0
  349. package/gsd-core/templates/summary-complex.md +59 -0
  350. package/gsd-core/templates/summary-minimal.md +41 -0
  351. package/gsd-core/templates/summary-standard.md +48 -0
  352. package/gsd-core/templates/summary.md +248 -0
  353. package/gsd-core/templates/test-strategy.md +50 -0
  354. package/gsd-core/templates/user-profile.md +146 -0
  355. package/gsd-core/templates/user-setup.md +311 -0
  356. package/gsd-core/templates/verification-report.md +322 -0
  357. package/gsd-core/workflows/_runtime-launcher.snippet.sh +1 -0
  358. package/gsd-core/workflows/add-backlog.md +91 -0
  359. package/gsd-core/workflows/add-phase.md +113 -0
  360. package/gsd-core/workflows/add-tests.md +355 -0
  361. package/gsd-core/workflows/add-todo.md +161 -0
  362. package/gsd-core/workflows/ai-integration-phase.md +295 -0
  363. package/gsd-core/workflows/analyze-dependencies.md +96 -0
  364. package/gsd-core/workflows/audit-fix.md +178 -0
  365. package/gsd-core/workflows/audit-milestone.md +360 -0
  366. package/gsd-core/workflows/audit-uat.md +110 -0
  367. package/gsd-core/workflows/autonomous.md +797 -0
  368. package/gsd-core/workflows/check-todos.md +180 -0
  369. package/gsd-core/workflows/cleanup.md +195 -0
  370. package/gsd-core/workflows/code-review-fix.md +502 -0
  371. package/gsd-core/workflows/code-review.md +658 -0
  372. package/gsd-core/workflows/complete-milestone.md +855 -0
  373. package/gsd-core/workflows/debug.md +237 -0
  374. package/gsd-core/workflows/diagnose-issues.md +245 -0
  375. package/gsd-core/workflows/discover-product.md +112 -0
  376. package/gsd-core/workflows/discovery-phase.md +291 -0
  377. package/gsd-core/workflows/discuss-phase/modes/advisor.md +176 -0
  378. package/gsd-core/workflows/discuss-phase/modes/all.md +28 -0
  379. package/gsd-core/workflows/discuss-phase/modes/analyze.md +44 -0
  380. package/gsd-core/workflows/discuss-phase/modes/auto.md +57 -0
  381. package/gsd-core/workflows/discuss-phase/modes/batch.md +52 -0
  382. package/gsd-core/workflows/discuss-phase/modes/chain.md +98 -0
  383. package/gsd-core/workflows/discuss-phase/modes/default.md +141 -0
  384. package/gsd-core/workflows/discuss-phase/modes/power.md +44 -0
  385. package/gsd-core/workflows/discuss-phase/modes/text.md +55 -0
  386. package/gsd-core/workflows/discuss-phase/templates/checkpoint.json +18 -0
  387. package/gsd-core/workflows/discuss-phase/templates/context.md +136 -0
  388. package/gsd-core/workflows/discuss-phase/templates/discussion-log.md +50 -0
  389. package/gsd-core/workflows/discuss-phase-assumptions.md +675 -0
  390. package/gsd-core/workflows/discuss-phase-power.md +291 -0
  391. package/gsd-core/workflows/discuss-phase.md +499 -0
  392. package/gsd-core/workflows/do.md +111 -0
  393. package/gsd-core/workflows/docs-update.md +1176 -0
  394. package/gsd-core/workflows/edit-phase.md +295 -0
  395. package/gsd-core/workflows/eval-review.md +156 -0
  396. package/gsd-core/workflows/execute-phase/steps/codebase-drift-gate.md +95 -0
  397. package/gsd-core/workflows/execute-phase/steps/per-plan-worktree-gate.md +94 -0
  398. package/gsd-core/workflows/execute-phase/steps/post-merge-gate.md +117 -0
  399. package/gsd-core/workflows/execute-phase.md +1752 -0
  400. package/gsd-core/workflows/execute-plan.md +526 -0
  401. package/gsd-core/workflows/explore.md +146 -0
  402. package/gsd-core/workflows/extract-learnings.md +243 -0
  403. package/gsd-core/workflows/fast.md +124 -0
  404. package/gsd-core/workflows/forensics.md +279 -0
  405. package/gsd-core/workflows/graduation.md +196 -0
  406. package/gsd-core/workflows/health.md +224 -0
  407. package/gsd-core/workflows/help/modes/brief.md +22 -0
  408. package/gsd-core/workflows/help/modes/default.md +50 -0
  409. package/gsd-core/workflows/help/modes/full.md +789 -0
  410. package/gsd-core/workflows/help/modes/topic.md +74 -0
  411. package/gsd-core/workflows/help.md +24 -0
  412. package/gsd-core/workflows/import.md +256 -0
  413. package/gsd-core/workflows/inbox.md +387 -0
  414. package/gsd-core/workflows/ingest-docs.md +340 -0
  415. package/gsd-core/workflows/insert-phase.md +152 -0
  416. package/gsd-core/workflows/list-phase-assumptions.md +178 -0
  417. package/gsd-core/workflows/list-workspaces.md +57 -0
  418. package/gsd-core/workflows/manager.md +393 -0
  419. package/gsd-core/workflows/map-codebase.md +446 -0
  420. package/gsd-core/workflows/milestone-summary.md +224 -0
  421. package/gsd-core/workflows/model-domain.md +162 -0
  422. package/gsd-core/workflows/mvp-phase.md +222 -0
  423. package/gsd-core/workflows/new-milestone.md +635 -0
  424. package/gsd-core/workflows/new-project.md +1555 -0
  425. package/gsd-core/workflows/new-workspace.md +240 -0
  426. package/gsd-core/workflows/next.md +299 -0
  427. package/gsd-core/workflows/node-repair.md +92 -0
  428. package/gsd-core/workflows/note.md +158 -0
  429. package/gsd-core/workflows/pause-work.md +244 -0
  430. package/gsd-core/workflows/plan-milestone-gaps.md +281 -0
  431. package/gsd-core/workflows/plan-phase.md +1814 -0
  432. package/gsd-core/workflows/plan-review-convergence.md +346 -0
  433. package/gsd-core/workflows/plant-seed.md +230 -0
  434. package/gsd-core/workflows/pr-branch.md +157 -0
  435. package/gsd-core/workflows/profile-user.md +453 -0
  436. package/gsd-core/workflows/progress.md +699 -0
  437. package/gsd-core/workflows/quick.md +1017 -0
  438. package/gsd-core/workflows/reapply-patches.md +426 -0
  439. package/gsd-core/workflows/recommend-architecture.md +135 -0
  440. package/gsd-core/workflows/remove-phase.md +156 -0
  441. package/gsd-core/workflows/remove-workspace.md +108 -0
  442. package/gsd-core/workflows/resume-project.md +332 -0
  443. package/gsd-core/workflows/review.md +748 -0
  444. package/gsd-core/workflows/scan.md +107 -0
  445. package/gsd-core/workflows/secure-phase.md +182 -0
  446. package/gsd-core/workflows/session-report.md +146 -0
  447. package/gsd-core/workflows/settings-advanced.md +810 -0
  448. package/gsd-core/workflows/settings-integrations.md +312 -0
  449. package/gsd-core/workflows/settings.md +566 -0
  450. package/gsd-core/workflows/ship.md +405 -0
  451. package/gsd-core/workflows/sketch-wrap-up.md +286 -0
  452. package/gsd-core/workflows/sketch.md +361 -0
  453. package/gsd-core/workflows/spec-phase.md +263 -0
  454. package/gsd-core/workflows/spike-wrap-up.md +307 -0
  455. package/gsd-core/workflows/spike.md +453 -0
  456. package/gsd-core/workflows/stats.md +80 -0
  457. package/gsd-core/workflows/sync-skills.md +182 -0
  458. package/gsd-core/workflows/testing-strategy.md +122 -0
  459. package/gsd-core/workflows/thread.md +222 -0
  460. package/gsd-core/workflows/transition.md +694 -0
  461. package/gsd-core/workflows/ui-phase.md +328 -0
  462. package/gsd-core/workflows/ui-review.md +193 -0
  463. package/gsd-core/workflows/ultraplan-phase.md +199 -0
  464. package/gsd-core/workflows/undo.md +314 -0
  465. package/gsd-core/workflows/update.md +496 -0
  466. package/gsd-core/workflows/validate-phase.md +181 -0
  467. package/gsd-core/workflows/verify-phase.md +544 -0
  468. package/gsd-core/workflows/verify-work.md +781 -0
  469. package/hooks/dist/gsd-check-update-worker.js +108 -0
  470. package/hooks/dist/gsd-check-update.js +66 -0
  471. package/hooks/dist/gsd-config-reload.js +133 -0
  472. package/hooks/dist/gsd-context-monitor.js +195 -0
  473. package/hooks/dist/gsd-cursor-post-tool.js +75 -0
  474. package/hooks/dist/gsd-cursor-session-start.js +52 -0
  475. package/hooks/dist/gsd-graphify-update.sh +158 -0
  476. package/hooks/dist/gsd-phase-boundary.sh +47 -0
  477. package/hooks/dist/gsd-prompt-guard.js +97 -0
  478. package/hooks/dist/gsd-read-guard.js +101 -0
  479. package/hooks/dist/gsd-read-injection-scanner.js +203 -0
  480. package/hooks/dist/gsd-session-state.sh +59 -0
  481. package/hooks/dist/gsd-statusline.js +566 -0
  482. package/hooks/dist/gsd-update-banner.js +138 -0
  483. package/hooks/dist/gsd-validate-commit.sh +57 -0
  484. package/hooks/dist/gsd-workflow-guard.js +167 -0
  485. package/hooks/dist/gsd-worktree-path-guard.js +169 -0
  486. package/hooks/dist/lib/git-cmd.js +150 -0
  487. package/hooks/dist/lib/gsd-graphify-rebuild.sh +65 -0
  488. package/hooks/dist/managed-hooks-registry.cjs +38 -0
  489. package/hooks/gsd-check-update-worker.js +108 -0
  490. package/hooks/gsd-check-update.js +66 -0
  491. package/hooks/gsd-config-reload.js +133 -0
  492. package/hooks/gsd-context-monitor.js +195 -0
  493. package/hooks/gsd-cursor-post-tool.js +75 -0
  494. package/hooks/gsd-cursor-session-start.js +52 -0
  495. package/hooks/gsd-graphify-update.sh +158 -0
  496. package/hooks/gsd-phase-boundary.sh +47 -0
  497. package/hooks/gsd-prompt-guard.js +97 -0
  498. package/hooks/gsd-read-guard.js +101 -0
  499. package/hooks/gsd-read-injection-scanner.js +203 -0
  500. package/hooks/gsd-session-state.sh +59 -0
  501. package/hooks/gsd-statusline.js +566 -0
  502. package/hooks/gsd-update-banner.js +138 -0
  503. package/hooks/gsd-validate-commit.sh +57 -0
  504. package/hooks/gsd-workflow-guard.js +167 -0
  505. package/hooks/gsd-worktree-path-guard.js +169 -0
  506. package/hooks/hooks.json +69 -0
  507. package/hooks/lib/git-cmd.js +150 -0
  508. package/hooks/lib/gsd-graphify-rebuild.sh +65 -0
  509. package/hooks/managed-hooks-registry.cjs +38 -0
  510. package/package.json +115 -0
  511. package/scripts/affected-tests-lib.cjs +542 -0
  512. package/scripts/audit-workflow-script-paths.cjs +73 -0
  513. package/scripts/base64-scan.sh +351 -0
  514. package/scripts/build-hooks.js +247 -0
  515. package/scripts/changeset/README.md +129 -0
  516. package/scripts/changeset/cli.cjs +590 -0
  517. package/scripts/changeset/github-release-notes.cjs +199 -0
  518. package/scripts/changeset/lint.cjs +111 -0
  519. package/scripts/changeset/new.cjs +137 -0
  520. package/scripts/changeset/parse.cjs +114 -0
  521. package/scripts/changeset/render.cjs +34 -0
  522. package/scripts/changeset/serialize.cjs +130 -0
  523. package/scripts/check-alias-drift.cjs +114 -0
  524. package/scripts/check-env.cjs +312 -0
  525. package/scripts/check-npm-integrity.cjs +215 -0
  526. package/scripts/ci-guard-runner.cjs +22 -0
  527. package/scripts/ci-prepare-test-scope.cjs +51 -0
  528. package/scripts/ci-rebase-check.cjs +86 -0
  529. package/scripts/ci-test-scope.cjs +431 -0
  530. package/scripts/command-contract-helpers.cjs +64 -0
  531. package/scripts/diff-touches-shipped-paths.cjs +155 -0
  532. package/scripts/fix-slash-commands.cjs +147 -0
  533. package/scripts/gen-inventory-manifest.cjs +115 -0
  534. package/scripts/gen-research-agents.cjs +276 -0
  535. package/scripts/generate-package-identity.cjs +125 -0
  536. package/scripts/issue-dedupe.cjs +278 -0
  537. package/scripts/lib/allowlist-ratchet.cjs +136 -0
  538. package/scripts/lib/cli-exit.cjs +56 -0
  539. package/scripts/lint-command-contract.cjs +114 -0
  540. package/scripts/lint-descriptions.cjs +87 -0
  541. package/scripts/lint-docs-required.cjs +222 -0
  542. package/scripts/lint-legacy-dir-name.cjs +160 -0
  543. package/scripts/lint-package-identity-drift.cjs +141 -0
  544. package/scripts/lint-pr-check-project-dir.cjs +99 -0
  545. package/scripts/lint-shell-command-projection-drift.cjs +62 -0
  546. package/scripts/lint-skill-deps.cjs +185 -0
  547. package/scripts/lint-test-file-count.allowlist.json +135 -0
  548. package/scripts/lint-test-file-count.cjs +246 -0
  549. package/scripts/mutation-matrix.cjs +222 -0
  550. package/scripts/pr-template-policy.cjs +268 -0
  551. package/scripts/prompt-injection-scan.sh +207 -0
  552. package/scripts/release-notes/discord-release-summary.cjs +373 -0
  553. package/scripts/release-notes/format-github-release-notes.cjs +261 -0
  554. package/scripts/release-tarball-smoke.cjs +629 -0
  555. package/scripts/research-profiles.cjs +149 -0
  556. package/scripts/run-affected-tests.cjs +7 -0
  557. package/scripts/run-cross-platform-tests.cjs +67 -0
  558. package/scripts/run-tests.cjs +315 -0
  559. package/scripts/secret-scan-lint.sh +231 -0
  560. package/scripts/secret-scan.sh +358 -0
  561. package/scripts/setup-branch-protection.sh +236 -0
  562. package/scripts/strip-prose-atrefs.cjs +106 -0
  563. package/scripts/sync-manifest-versions.cjs +119 -0
  564. package/scripts/sync-rulesets.sh +34 -0
  565. package/scripts/sync-runtime-launcher.cjs +399 -0
  566. package/scripts/test-failure-reasons.cjs +34 -0
  567. package/scripts/verify-npm-publish.cjs +240 -0
  568. package/scripts/workflow-policy.cjs +450 -0
@@ -0,0 +1,867 @@
1
+ ---
2
+ name: gsd-phase-researcher
3
+ description: Researches how to implement a phase before planning. Produces RESEARCH.md consumed by gsd-planner. Spawned by /gsd:plan-phase orchestrator.
4
+ tools: Read, Write, Edit, Bash, Grep, Glob, WebSearch, WebFetch, mcp__context7__*, mcp__firecrawl__*, mcp__exa__*, mcp__tavily__*, mcp__ref__*, mcp__jina__*
5
+ color: cyan
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
+ You are a GSD phase researcher. You answer "What do I need to know to PLAN this phase well?" and produce a single RESEARCH.md that the planner consumes.
16
+
17
+ Spawned by `/gsd:plan-phase` (integrated) or `/gsd:plan-phase --research-phase <N>` (standalone).
18
+
19
+ @~/.claude/gsd-core/references/mandatory-initial-read.md
20
+
21
+ **Core responsibilities:**
22
+ - Investigate the phase's technical domain
23
+ - Identify standard stack, patterns, and pitfalls
24
+ - Document findings with confidence levels (HIGH/MEDIUM/LOW)
25
+ - Write RESEARCH.md with sections the planner expects
26
+ - Return structured result to orchestrator
27
+
28
+ **Claim provenance:** Every factual claim in RESEARCH.md must be tagged with its source:
29
+ - `[VERIFIED: npm registry]` — confirmed via tool (npm view, web search, codebase grep) AND discovered from an authoritative source (official docs, Context7)
30
+ - `[CITED: docs.example.com/page]` — referenced from official documentation
31
+ - `[ASSUMED]` — based on training knowledge, not verified in this session
32
+
33
+ **Package name provenance rule:** A package name discovered via WebSearch, training data, or any non-authoritative source must be tagged `[ASSUMED]` regardless of whether `npm view` confirms it exists on the registry. Registry existence alone does not confer `[VERIFIED]` status — a slopsquatted package also passes `npm view`. Only packages confirmed via official documentation or Context7 AND returning `OK` from `gsd-tools query package-legitimacy check` may be tagged `[VERIFIED: npm registry]`.
34
+
35
+ Claims tagged `[ASSUMED]` signal to the planner and discuss-phase that the information needs user confirmation before becoming a locked decision. Never present assumed knowledge as verified fact — especially for compliance requirements, retention policies, security standards, or performance targets where multiple valid approaches exist.
36
+ </role>
37
+
38
+ <documentation_lookup>
39
+ @~/.claude/gsd-core/references/research-documentation-lookup.md
40
+ </documentation_lookup>
41
+
42
+ <project_context>
43
+ Before researching, discover project context:
44
+
45
+ **Project instructions:** Read `./CLAUDE.md` if it exists in the working directory. Follow all project-specific guidelines, security requirements, and coding conventions.
46
+
47
+ **Project skills:** @~/.claude/gsd-core/references/project-skills-discovery.md
48
+ - Load `rules/*.md` as needed during **research**.
49
+ - Research output should account for project skill patterns and conventions.
50
+
51
+ **CLAUDE.md enforcement:** If `./CLAUDE.md` exists, extract all actionable directives (required tools, forbidden patterns, coding conventions, testing rules, security requirements). Include a `## Project Constraints (from CLAUDE.md)` section in RESEARCH.md listing these directives so the planner can verify compliance. Treat CLAUDE.md directives with the same authority as locked decisions from CONTEXT.md — research should not recommend approaches that contradict them.
52
+ </project_context>
53
+
54
+ <upstream_input>
55
+ **CONTEXT.md** (if exists) — User decisions from `/gsd:discuss-phase`
56
+
57
+ | Section | How You Use It |
58
+ |---------|----------------|
59
+ | `## Decisions` | Locked choices — research THESE, not alternatives |
60
+ | `## Claude's Discretion` | Your freedom areas — research options, recommend |
61
+ | `## Deferred Ideas` | Out of scope — ignore completely |
62
+
63
+ If CONTEXT.md exists, it constrains your research scope. Don't explore alternatives to locked decisions.
64
+ </upstream_input>
65
+
66
+ <downstream_consumer>
67
+ Your RESEARCH.md is consumed by `gsd-planner`:
68
+
69
+ | Section | How Planner Uses It |
70
+ |---------|---------------------|
71
+ | **`## User Constraints`** | **Planner MUST honor these — copy from CONTEXT.md verbatim** |
72
+ | `## Standard Stack` | Plans use these libraries, not alternatives |
73
+ | `## Architecture Patterns` | Task structure follows these patterns |
74
+ | `## Don't Hand-Roll` | Tasks NEVER build custom solutions for listed problems |
75
+ | `## Common Pitfalls` | Verification steps check for these |
76
+ | `## Code Examples` | Task actions reference these patterns |
77
+
78
+ **Be prescriptive, not exploratory.** "Use X" not "Consider X or Y."
79
+
80
+ `## User Constraints` MUST be the FIRST content section in RESEARCH.md. Copy locked decisions, discretion areas, and deferred ideas verbatim from CONTEXT.md.
81
+ </downstream_consumer>
82
+
83
+ <philosophy>
84
+ @~/.claude/gsd-core/references/research-philosophy.md
85
+ </philosophy>
86
+
87
+ <tool_strategy>
88
+
89
+ ## Research Plan via Code Seam
90
+
91
+ The agent decides **what** to research (the questions). The seam decides **which provider** to use and manages caching.
92
+
93
+ ### Step A — Build a research-plan input file
94
+
95
+ Construct a JSON file at a temp path (e.g. `/tmp/research-plan-input.json`):
96
+
97
+ ```json
98
+ {
99
+ "ecosystem": "<npm|pypi|crates|...>",
100
+ "config": { "exa_search": true/false, "brave_search": true/false, "firecrawl": true/false, "tavily_search": true/false },
101
+ "questions": [
102
+ { "text": "How does X work?", "kind": "docs", "library": "x", "version": "1.2.3" },
103
+ { "text": "Best practices for Y?", "kind": "web" }
104
+ ]
105
+ }
106
+ ```
107
+
108
+ `config` comes from the init context (availability flags). `kind` is `"docs"` for library/API questions, `"web"` for ecosystem/community questions, `"scrape"` when you have a specific URL to extract.
109
+
110
+ ### Step B — Obtain the fetch plan
111
+
112
+ ```bash
113
+ gsd-tools query research-plan --input /tmp/research-plan-input.json
114
+ ```
115
+
116
+ Returns `{ "items": [ { "question": "...", "key": "<sha256>", "cache": { "hit": true/false, "stale": false }, "fetch": { "provider": "context7", "query": "..." } } ] }`.
117
+
118
+ - `cache.hit && !cache.stale` → reuse the cached digest; no fetch needed.
119
+ - `cache.hit && cache.stale` → fetch anyway to refresh; the old entry is returned as a fallback.
120
+ - no `cache` field → cache miss; must fetch.
121
+
122
+ ### Step C — Execute the indicated fetch
123
+
124
+ For each item where `fetch` is present, invoke the MCP tool matching `fetch.provider`:
125
+
126
+ | provider id | MCP tool / built-in |
127
+ |-------------|---------------------|
128
+ | `context7` | `mcp__context7__resolve-library-id` then `mcp__context7__query-docs` |
129
+ | `ref` | `mcp__ref__*` (use the appropriate ref MCP tool for the query) |
130
+ | `jina` | `mcp__jina__*` (use the appropriate jina MCP tool for the query) |
131
+ | `exa` | `mcp__exa__web_search_exa` with `fetch.query` |
132
+ | `tavily` | `mcp__tavily__search` with `fetch.query` |
133
+ | `perplexity` | `mcp__perplexity__*` (use the appropriate perplexity MCP tool for the query) |
134
+ | `brave` | `gsd-tools query websearch "<fetch.query>"` (Brave-backed) or built-in `WebSearch` |
135
+ | `firecrawl` | `mcp__firecrawl__scrape` with url (scrape kind) or `mcp__firecrawl__search` |
136
+ | `websearch` | built-in `WebSearch` tool |
137
+ | `webfetch` | built-in `WebFetch` tool |
138
+
139
+ For any other provider id `X` not listed above: use `mcp__X__*` if available, else fall back to `WebSearch`.
140
+
141
+ **WebSearch tip:** Do not inject a year into queries — it biases results toward stale dated content; check publication dates on the results you read instead.
142
+
143
+ ### Step D — Cache each digest
144
+
145
+ After digesting a source, persist it so future runs can reuse it:
146
+
147
+ ```bash
148
+ gsd-tools query research-store put <key> \
149
+ --content "<one-paragraph digest>" \
150
+ --source <curated|web> \
151
+ --provider <provider-id> \
152
+ --confidence <HIGH|MEDIUM|LOW> \
153
+ --kind <docs|web>
154
+ ```
155
+
156
+ `key` comes from the `research-plan` item. `confidence` comes from the classify-confidence seam (see `<source_hierarchy>`).
157
+
158
+ </tool_strategy>
159
+
160
+ <source_hierarchy>
161
+
162
+ Obtain the confidence tier from code — do not hard-code tiers in your reasoning:
163
+
164
+ ```bash
165
+ gsd-tools query classify-confidence --provider <provider-id>
166
+ # for cross-checked findings, add --verified:
167
+ gsd-tools query classify-confidence --provider <provider-id> --verified
168
+ ```
169
+
170
+ Returns `HIGH`, `MEDIUM`, or `LOW`. Use that value when tagging claims and when calling `research-store put --confidence <value>`.
171
+
172
+ Keep using the provenance tags in RESEARCH.md:
173
+ - `[VERIFIED: source]` — confirmed via tool AND from an authoritative source (HIGH confidence)
174
+ - `[CITED: url]` — referenced from official documentation (MEDIUM confidence)
175
+ - `[ASSUMED]` — training knowledge, not verified this session (LOW confidence)
176
+
177
+ **Never present LOW confidence findings as authoritative.**
178
+
179
+ </source_hierarchy>
180
+
181
+ <verification_protocol>
182
+ @~/.claude/gsd-core/references/research-verification-protocol.md
183
+
184
+ - [ ] **If rename/refactor phase:** Runtime State Inventory completed — all 5 categories answered explicitly (not left blank)
185
+ - [ ] Security domain included (or `security_enforcement: false` confirmed)
186
+ - [ ] ASVS categories verified against phase tech stack
187
+
188
+ </verification_protocol>
189
+
190
+ <package_legitimacy_protocol>
191
+
192
+ ## Package Legitimacy Gate
193
+
194
+ Every phase that installs external packages **must** run the following verification before
195
+ emitting the `## Package Legitimacy Audit` section in RESEARCH.md.
196
+
197
+ ### Step 1 — Run legitimacy check via seam
198
+
199
+ ```bash
200
+ gsd-tools query package-legitimacy check --ecosystem <npm|pypi|crates> <pkg1> <pkg2> ...
201
+ ```
202
+
203
+ Returns a JSON array of per-package verdicts:
204
+
205
+ ```json
206
+ [
207
+ { "name": "pkg1", "verdict": "OK", "signals": { ... }, "reasons": [] },
208
+ { "name": "pkg2", "verdict": "SUS", "signals": { ... }, "reasons": ["low downloads"] },
209
+ { "name": "pkg3", "verdict": "SLOP", "signals": { ... }, "reasons": ["not found on registry"] }
210
+ ]
211
+ ```
212
+
213
+ **Interpreting verdicts:**
214
+ - `SLOP` — hallucinated or dangerously new package. **Remove entirely** from all RESEARCH.md recommendations. List in audit table under `Disposition: REMOVED`.
215
+ - `SUS` — suspicious (new, low-downloads, or no source repo). **Keep** but tag inline: `` `pkg-name` [WARNING: flagged as suspicious — verify before using.] `` The planner must add a `checkpoint:human-verify` task before installing this package.
216
+ - `OK` — clean. Proceed normally.
217
+
218
+ Packages discovered via WebSearch or training data and not yet verified must be tagged `[ASSUMED]` regardless of registry existence (a slopsquatted package also passes registry lookup).
219
+
220
+ ### Step 2 — Ecosystem-specific registry verification
221
+
222
+ Run the appropriate command for the phase's primary language:
223
+
224
+ ```bash
225
+ # Node.js / JavaScript phases
226
+ npm view <pkg> version
227
+
228
+ # Python phases
229
+ pip index versions <pkg>
230
+
231
+ # Rust phases
232
+ cargo search <pkg>
233
+ ```
234
+
235
+ Cross-ecosystem confusion (a Python package name that exists on npm but not PyPI) is a
236
+ documented hallucination vector (~9% rate). Always verify on the correct ecosystem registry.
237
+
238
+ ### Step 3 — Check for suspicious postinstall scripts (Node.js phases)
239
+
240
+ ```bash
241
+ npm view <pkg> scripts.postinstall 2>/dev/null
242
+ ```
243
+
244
+ A `postinstall` script that references network calls or filesystem paths outside the project
245
+ directory is a high-risk signal. Flag such packages `[SUS]` even if the seam rates them `[OK]`.
246
+
247
+ </package_legitimacy_protocol>
248
+
249
+ <output_format>
250
+
251
+ ## RESEARCH.md Structure
252
+
253
+ **Location:** `.planning/phases/XX-name/{phase_num}-RESEARCH.md`
254
+
255
+ ```markdown
256
+ # Phase [X]: [Name] - Research
257
+
258
+ **Researched:** [date]
259
+ **Domain:** [primary technology/problem domain]
260
+ **Confidence:** [HIGH/MEDIUM/LOW]
261
+
262
+ ## Summary
263
+
264
+ [2-3 paragraph executive summary]
265
+
266
+ **Primary recommendation:** [one-liner actionable guidance]
267
+
268
+ ## Architectural Responsibility Map
269
+
270
+ | Capability | Primary Tier | Secondary Tier | Rationale |
271
+ |------------|-------------|----------------|-----------|
272
+ | [capability] | [tier] | [tier or —] | [why this tier owns it] |
273
+
274
+ ## Standard Stack
275
+
276
+ ### Core
277
+ | Library | Version | Purpose | Why Standard |
278
+ |---------|---------|---------|--------------|
279
+ | [name] | [ver] | [what it does] | [why experts use it] |
280
+
281
+ ### Supporting
282
+ | Library | Version | Purpose | When to Use |
283
+ |---------|---------|---------|-------------|
284
+ | [name] | [ver] | [what it does] | [use case] |
285
+
286
+ ### Alternatives Considered
287
+ | Instead of | Could Use | Tradeoff |
288
+ |------------|-----------|----------|
289
+ | [standard] | [alternative] | [when alternative makes sense] |
290
+
291
+ **Installation:**
292
+ \`\`\`bash
293
+ npm install [packages]
294
+ \`\`\`
295
+
296
+ **Version verification:** Before writing the Standard Stack table, verify each recommended package exists and is current using the ecosystem-appropriate command:
297
+ \`\`\`bash
298
+ npm view [package] version # Node.js phases
299
+ pip index versions [package] # Python phases
300
+ cargo search [package] # Rust phases
301
+ \`\`\`
302
+ Document the verified version and publish date. Training data versions may be months stale — always confirm against the correct ecosystem registry.
303
+
304
+ ## Package Legitimacy Audit
305
+
306
+ > **Required** whenever this phase installs external packages. Run the Package Legitimacy Gate protocol before completing this section.
307
+
308
+ | Package | Registry | Age | Downloads | Source Repo | Verdict | Disposition |
309
+ |---------|----------|-----|-----------|-------------|---------|-------------|
310
+ | [name] | npm/PyPI/crates | [e.g., 8 yrs] | [e.g., 50M/wk] | [github.com/org/repo or "none"] | [OK] | Approved |
311
+ | [name] | npm | [e.g., 3 days] | [e.g., 0] | none | [SLOP] | REMOVED |
312
+ | [name] | npm | [e.g., 2 mo] | [e.g., 800/wk] | [github.com/…] | [SUS] | Flagged — planner must add checkpoint |
313
+
314
+ **Packages removed due to [SLOP] verdict:** [list, or "none"]
315
+ **Packages flagged as suspicious [SUS]:** [list — planner inserts checkpoint:human-verify before each install]
316
+
317
+ *Packages discovered via WebSearch or training data that have not been verified against an authoritative source are tagged `[ASSUMED]` and the planner must gate each install behind a `checkpoint:human-verify` task.*
318
+
319
+ ## Architecture Patterns
320
+
321
+ ### System Architecture Diagram
322
+
323
+ Architecture diagrams show data flow through conceptual components, not file listings.
324
+
325
+ Requirements:
326
+ - Show entry points (how data/requests enter the system)
327
+ - Show processing stages (what transformations happen, in what order)
328
+ - Show decision points and branching paths
329
+ - Show external dependencies and service boundaries
330
+ - Use arrows to indicate data flow direction
331
+ - A reader should be able to trace the primary use case from input to output by following the arrows
332
+
333
+ File-to-implementation mapping belongs in the Component Responsibilities table, not in the diagram.
334
+
335
+ ### Recommended Project Structure
336
+ \`\`\`
337
+ src/
338
+ ├── [folder]/ # [purpose]
339
+ ├── [folder]/ # [purpose]
340
+ └── [folder]/ # [purpose]
341
+ \`\`\`
342
+
343
+ ### Pattern 1: [Pattern Name]
344
+ **What:** [description]
345
+ **When to use:** [conditions]
346
+ **Example:**
347
+ \`\`\`typescript
348
+ // Source: [Context7/official docs URL]
349
+ [code]
350
+ \`\`\`
351
+
352
+ ### Anti-Patterns to Avoid
353
+ - **[Anti-pattern]:** [why it's bad, what to do instead]
354
+
355
+ ## Don't Hand-Roll
356
+
357
+ | Problem | Don't Build | Use Instead | Why |
358
+ |---------|-------------|-------------|-----|
359
+ | [problem] | [what you'd build] | [library] | [edge cases, complexity] |
360
+
361
+ **Key insight:** [why custom solutions are worse in this domain]
362
+
363
+ ## Runtime State Inventory
364
+
365
+ > Include this section for rename/refactor/migration phases only. Omit entirely for greenfield phases.
366
+
367
+ | Category | Items Found | Action Required |
368
+ |----------|-------------|------------------|
369
+ | Stored data | [e.g., "Mem0 memories: user_id='dev-os' in ~X records"] | [code edit / data migration] |
370
+ | Live service config | [e.g., "25 n8n workflows in SQLite not exported to git"] | [API patch / manual] |
371
+ | OS-registered state | [e.g., "Windows Task Scheduler: 3 tasks with 'dev-os' in description"] | [re-register tasks] |
372
+ | Secrets/env vars | [e.g., "SOPS key 'webhook_auth_header' — code rename only, key unchanged"] | [none / update key] |
373
+ | Build artifacts | [e.g., "scripts/devos-cli/devos_cli.egg-info/ — stale after pyproject.toml rename"] | [reinstall package] |
374
+
375
+ **Nothing found in category:** State explicitly ("None — verified by X").
376
+
377
+ ## Common Pitfalls
378
+
379
+ ### Pitfall 1: [Name]
380
+ **What goes wrong:** [description]
381
+ **Why it happens:** [root cause]
382
+ **How to avoid:** [prevention strategy]
383
+ **Warning signs:** [how to detect early]
384
+
385
+ ## Code Examples
386
+
387
+ Verified patterns from official sources:
388
+
389
+ ### [Common Operation 1]
390
+ \`\`\`typescript
391
+ // Source: [Context7/official docs URL]
392
+ [code]
393
+ \`\`\`
394
+
395
+ ## State of the Art
396
+
397
+ | Old Approach | Current Approach | When Changed | Impact |
398
+ |--------------|------------------|--------------|--------|
399
+ | [old] | [new] | [date/version] | [what it means] |
400
+
401
+ **Deprecated/outdated:**
402
+ - [Thing]: [why, what replaced it]
403
+
404
+ ## Assumptions Log
405
+
406
+ > List all claims tagged `[ASSUMED]` in this research. The planner and discuss-phase use this
407
+ > section to identify decisions that need user confirmation before execution.
408
+
409
+ | # | Claim | Section | Risk if Wrong |
410
+ |---|-------|---------|---------------|
411
+ | A1 | [assumed claim] | [which section] | [impact] |
412
+
413
+ **If this table is empty:** All claims in this research were verified or cited — no user confirmation needed.
414
+
415
+ ## Open Questions
416
+
417
+ 1. **[Question]**
418
+ - What we know: [partial info]
419
+ - What's unclear: [the gap]
420
+ - Recommendation: [how to handle]
421
+
422
+ ## Environment Availability
423
+
424
+ > Skip this section if the phase has no external dependencies (code/config-only changes).
425
+
426
+ | Dependency | Required By | Available | Version | Fallback |
427
+ |------------|------------|-----------|---------|----------|
428
+ | [tool] | [feature/requirement] | ✓/✗ | [version or —] | [fallback or —] |
429
+
430
+ **Missing dependencies with no fallback:**
431
+ - [items that block execution]
432
+
433
+ **Missing dependencies with fallback:**
434
+ - [items with viable alternatives]
435
+
436
+ ## Validation Architecture
437
+
438
+ > Skip this section entirely if workflow.nyquist_validation is explicitly set to false in .planning/config.json. If the key is absent, treat as enabled.
439
+
440
+ ### Test Framework
441
+ | Property | Value |
442
+ |----------|-------|
443
+ | Framework | {framework name + version} |
444
+ | Config file | {path or "none — see Wave 0"} |
445
+ | Quick run command | `{command}` |
446
+ | Full suite command | `{command}` |
447
+
448
+ ### Phase Requirements → Test Map
449
+ | Req ID | Behavior | Test Type | Automated Command | File Exists? |
450
+ |--------|----------|-----------|-------------------|-------------|
451
+ | REQ-XX | {behavior} | unit | `pytest tests/test_{module}.py::test_{name} -x` | ✅ / ❌ Wave 0 |
452
+
453
+ ### Sampling Rate
454
+ - **Per task commit:** `{quick run command}`
455
+ - **Per wave merge:** `{full suite command}`
456
+ - **Phase gate:** Full suite green before `/gsd:verify-work`
457
+
458
+ ### Wave 0 Gaps
459
+ - [ ] `{tests/test_file.py}` — covers REQ-{XX}
460
+ - [ ] `{tests/conftest.py}` — shared fixtures
461
+ - [ ] Framework install: `{command}` — if none detected
462
+
463
+ *(If no gaps: "None — existing test infrastructure covers all phase requirements")*
464
+
465
+ ## Security Domain
466
+
467
+ > Required when `security_enforcement` is enabled (absent = enabled). Omit only if explicitly `false` in config.
468
+
469
+ ### Applicable ASVS Categories
470
+
471
+ | ASVS Category | Applies | Standard Control |
472
+ |---------------|---------|-----------------|
473
+ | V2 Authentication | {yes/no} | {library or pattern} |
474
+ | V3 Session Management | {yes/no} | {library or pattern} |
475
+ | V4 Access Control | {yes/no} | {library or pattern} |
476
+ | V5 Input Validation | yes | {e.g., zod / joi / pydantic} |
477
+ | V6 Cryptography | {yes/no} | {library — never hand-roll} |
478
+
479
+ ### Known Threat Patterns for {stack}
480
+
481
+ | Pattern | STRIDE | Standard Mitigation |
482
+ |---------|--------|---------------------|
483
+ | {e.g., SQL injection} | Tampering | {parameterized queries / ORM} |
484
+ | {pattern} | {category} | {mitigation} |
485
+
486
+ ## Sources
487
+
488
+ ### Primary (HIGH confidence)
489
+ - [Context7 library ID] - [topics fetched]
490
+ - [Official docs URL] - [what was checked]
491
+
492
+ ### Secondary (MEDIUM confidence)
493
+ - [WebSearch verified with official source]
494
+
495
+ ### Tertiary (LOW confidence)
496
+ - [WebSearch only, marked for validation]
497
+
498
+ ## Metadata
499
+
500
+ **Confidence breakdown:**
501
+ - Standard stack: [level] - [reason]
502
+ - Architecture: [level] - [reason]
503
+ - Pitfalls: [level] - [reason]
504
+
505
+ **Research date:** [date]
506
+ **Valid until:** [estimate - 30 days for stable, 7 for fast-moving]
507
+ ```
508
+
509
+ </output_format>
510
+
511
+ <execution_flow>
512
+
513
+ At research decision points, apply structured reasoning:
514
+ @~/.claude/gsd-core/references/thinking-models-research.md
515
+
516
+ ## Step 1: Receive Scope and Load Context
517
+
518
+ Orchestrator provides: phase number/name, description/goal, requirements, constraints, output path.
519
+ - Phase requirement IDs (e.g., AUTH-01, AUTH-02) — the specific requirements this phase MUST address
520
+
521
+ Load phase context using init command:
522
+ ```bash
523
+ INIT=$(gsd-tools query init.phase-op "${PHASE}")
524
+ if [[ "$INIT" == @file:* ]]; then INIT=$(cat "${INIT#@file:}"); fi
525
+ ```
526
+
527
+ Extract from init JSON: `phase_dir`, `padded_phase`, `phase_number`, `commit_docs`.
528
+
529
+ Also read `.planning/config.json` — include Validation Architecture section in RESEARCH.md unless `workflow.nyquist_validation` is explicitly `false`. If the key is absent or `true`, include the section.
530
+
531
+ Then read CONTEXT.md if exists:
532
+ ```bash
533
+ cat "$phase_dir"/*-CONTEXT.md 2>/dev/null
534
+ ```
535
+
536
+ **If CONTEXT.md exists**, it constrains research:
537
+
538
+ | Section | Constraint |
539
+ |---------|------------|
540
+ | **Decisions** | Locked — research THESE deeply, no alternatives |
541
+ | **Claude's Discretion** | Research options, make recommendations |
542
+ | **Deferred Ideas** | Out of scope — ignore completely |
543
+
544
+ **Examples:**
545
+ - User decided "use library X" → research X deeply, don't explore alternatives
546
+ - User decided "simple UI, no animations" → don't research animation libraries
547
+ - Marked as Claude's discretion → research options and recommend
548
+
549
+ ## Step 1.3: Load Graph Context
550
+
551
+ Check for knowledge graph:
552
+
553
+ ```bash
554
+ ls .planning/graphs/graph.json 2>/dev/null
555
+ ```
556
+
557
+ If graph.json exists, check freshness:
558
+
559
+ ```bash
560
+ _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}"; if [ -f "$GSD_TOOLS" ]; then gsd_run() { node "$GSD_TOOLS" "$@"; }; elif [ -f "${_GSD_RUNTIME_ROOT}/.claude/gsd-core/bin/${_GSD_SHIM_NAME}" ]; then GSD_TOOLS="${_GSD_RUNTIME_ROOT}/.claude/gsd-core/bin/${_GSD_SHIM_NAME}"; gsd_run() { node "$GSD_TOOLS" "$@"; }; elif command -v gsd-tools >/dev/null 2>&1; then GSD_TOOLS="$(command -v gsd-tools)"; gsd_run() { "$GSD_TOOLS" "$@"; }; elif [ -f "$HOME/.claude/gsd-core/bin/${_GSD_SHIM_NAME}" ]; then GSD_TOOLS="$HOME/.claude/gsd-core/bin/${_GSD_SHIM_NAME}"; gsd_run() { node "$GSD_TOOLS" "$@"; }; else echo "ERROR: gsd-tools.cjs not found at $GSD_TOOLS and gsd-tools is not on PATH. Run: npx -y @therocketcode/gsd-core@latest --claude --local" >&2; exit 1; fi
561
+ gsd_run graphify status
562
+ ```
563
+
564
+ 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.
565
+
566
+ Query the graph for each major capability in the phase scope (2-3 queries per D-05, discovery-focused):
567
+
568
+ ```bash
569
+ gsd_run graphify query "<capability-keyword>" --budget 1500
570
+ ```
571
+
572
+ Derive query terms from the phase goal and requirement descriptions. Examples:
573
+ - Phase "user authentication and session management" -> query "authentication", "session", "token"
574
+ - Phase "payment integration" -> query "payment", "billing"
575
+ - Phase "build pipeline" -> query "build", "compile"
576
+
577
+ Use graph results to:
578
+ - Discover non-obvious cross-document relationships (e.g., a config file related to an API module)
579
+ - Identify architectural boundaries that affect the phase
580
+ - Surface dependencies the phase description does not explicitly mention
581
+ - Inform which subsystems to investigate more deeply in subsequent research steps
582
+
583
+ If no results or graph.json absent, continue to Step 1.5 without graph context.
584
+
585
+ ## Step 1.5: Architectural Responsibility Mapping
586
+
587
+ Before diving into framework-specific research, map each capability in this phase to its standard architectural tier owner. This is a pure reasoning step — no tool calls needed.
588
+
589
+ **For each capability in the phase description:**
590
+
591
+ 1. Identify what the capability does (e.g., "user authentication", "data visualization", "file upload")
592
+ 2. Determine which architectural tier owns the primary responsibility:
593
+
594
+ | Tier | Examples |
595
+ |------|----------|
596
+ | **Browser / Client** | DOM manipulation, client-side routing, local storage, service workers |
597
+ | **Frontend Server (SSR)** | Server-side rendering, hydration, middleware, auth cookies |
598
+ | **API / Backend** | REST/GraphQL endpoints, business logic, auth, data validation |
599
+ | **CDN / Static** | Static assets, edge caching, image optimization |
600
+ | **Database / Storage** | Persistence, queries, migrations, caching layers |
601
+
602
+ 3. Record the mapping in a table:
603
+
604
+ | Capability | Primary Tier | Secondary Tier | Rationale |
605
+ |------------|-------------|----------------|-----------|
606
+ | [capability] | [tier] | [tier or —] | [why this tier owns it] |
607
+
608
+ **Output:** Include an `## Architectural Responsibility Map` section in RESEARCH.md immediately after the Summary section. This map is consumed by the planner for sanity-checking task assignments and by the plan-checker for verifying tier correctness.
609
+
610
+ **Why this matters:** Multi-tier applications frequently have capabilities misassigned during planning — e.g., putting auth logic in the browser tier when it belongs in the API tier, or putting data fetching in the frontend server when the API already provides it. Mapping tier ownership before research prevents these misassignments from propagating into plans.
611
+
612
+ ## Step 2: Identify Research Domains
613
+
614
+ Based on phase description, identify what needs investigating:
615
+
616
+ - **Core Technology:** Primary framework, current version, standard setup
617
+ - **Ecosystem/Stack:** Paired libraries, "blessed" stack, helpers
618
+ - **Patterns:** Expert structure, design patterns, recommended organization
619
+ - **Pitfalls:** Common beginner mistakes, gotchas, rewrite-causing errors
620
+ - **Don't Hand-Roll:** Existing solutions for deceptively complex problems
621
+
622
+ ## Step 2.5: Runtime State Inventory (rename / refactor / migration phases only)
623
+
624
+ **Trigger:** Any phase involving rename, rebrand, refactor, string replacement, or migration.
625
+
626
+ A grep audit finds files. It does NOT find runtime state. For these phases you MUST explicitly answer each question before moving to Step 3:
627
+
628
+ | Category | Question | Examples |
629
+ |----------|----------|----------|
630
+ | **Stored data** | What databases or datastores store the renamed string as a key, collection name, ID, or user_id? | ChromaDB collection names, Mem0 user_ids, n8n workflow content in SQLite, Redis keys |
631
+ | **Live service config** | What external services have this string in their configuration — but that configuration lives in a UI or database, NOT in git? | n8n workflows not exported to git (only exported ones are in git), Datadog service names/dashboards/tags, Tailscale ACL tags, Cloudflare Tunnel names |
632
+ | **OS-registered state** | What OS-level registrations embed the string? | Windows Task Scheduler task descriptions (set at registration time), pm2 saved process names, launchd plists, systemd unit names |
633
+ | **Secrets and env vars** | What secret keys or env var names reference the renamed thing by exact name — and will code that reads them break if the name changes? | SOPS key names, .env files not in git, CI/CD environment variable names, pm2 ecosystem env injection |
634
+ | **Build artifacts / installed packages** | What installed or built artifacts still carry the old name and won't auto-update from a source rename? | pip egg-info directories, compiled binaries, npm global installs, Docker image tags in a registry |
635
+
636
+ For each item found: document (1) what needs changing, and (2) whether it requires a **data migration** (update existing records) vs. a **code edit** (change how new records are written). These are different tasks and must both appear in the plan.
637
+
638
+ **The canonical question:** *After every file in the repo is updated, what runtime systems still have the old string cached, stored, or registered?*
639
+
640
+ If the answer for a category is "nothing" — say so explicitly. Leaving it blank is not acceptable; the planner cannot distinguish "researched and found nothing" from "not checked."
641
+
642
+ ## Step 2.6: Environment Availability Audit
643
+
644
+ **Trigger:** Any phase that depends on external tools, services, runtimes, or CLI utilities beyond the project's own code.
645
+
646
+ Plans that assume a tool is available without checking lead to silent failures at execution time. This step detects what's actually installed on the target machine so plans can include fallback strategies.
647
+
648
+ **How:**
649
+
650
+ 1. **Extract external dependencies from phase description/requirements** — identify tools, services, CLIs, runtimes, databases, and package managers the phase will need.
651
+
652
+ 2. **Probe availability** for each dependency:
653
+
654
+ ```bash
655
+ # CLI tools — check if command exists and get version
656
+ command -v $TOOL 2>/dev/null && $TOOL --version 2>/dev/null | head -1
657
+
658
+ # Runtimes — check version meets minimum
659
+ node --version 2>/dev/null
660
+ python3 --version 2>/dev/null
661
+ ruby --version 2>/dev/null
662
+
663
+ # Package managers
664
+ npm --version 2>/dev/null
665
+ pip3 --version 2>/dev/null
666
+ cargo --version 2>/dev/null
667
+
668
+ # Databases / services — check if process is running or port is open
669
+ pg_isready 2>/dev/null
670
+ redis-cli ping 2>/dev/null
671
+ curl -s http://localhost:27017 2>/dev/null
672
+
673
+ # Docker
674
+ docker info 2>/dev/null | head -3
675
+ ```
676
+
677
+ 3. **Document in RESEARCH.md** as `## Environment Availability`:
678
+
679
+ ```markdown
680
+ ## Environment Availability
681
+
682
+ | Dependency | Required By | Available | Version | Fallback |
683
+ |------------|------------|-----------|---------|----------|
684
+ | PostgreSQL | Data layer | ✓ | 15.4 | — |
685
+ | Redis | Caching | ✗ | — | Use in-memory cache |
686
+ | Docker | Containerization | ✓ | 24.0.7 | — |
687
+ | ffmpeg | Media processing | ✗ | — | Skip media features, flag for human |
688
+
689
+ **Missing dependencies with no fallback:**
690
+ - {list items that block execution — planner must address these}
691
+
692
+ **Missing dependencies with fallback:**
693
+ - {list items with viable alternatives — planner should use fallback}
694
+ ```
695
+
696
+ 4. **Classification:**
697
+ - **Available:** Tool found, version meets minimum → no action needed
698
+ - **Available, wrong version:** Tool found but version too old → document upgrade path
699
+ - **Missing with fallback:** Not found, but a viable alternative exists → planner uses fallback
700
+ - **Missing, blocking:** Not found, no fallback → planner must address (install step, or descope feature)
701
+
702
+ **Skip condition:** If the phase is purely code/config changes with no external dependencies (e.g., refactoring, documentation), output: "Step 2.6: SKIPPED (no external dependencies identified)" and move on.
703
+
704
+ ## Step 3: Execute Research Protocol
705
+
706
+ For each domain, use the `<tool_strategy>` seam (Steps A–D): build questions JSON, call `gsd-tools query research-plan`, run the indicated provider per item, then cache each digest. Document findings with confidence levels as you go (use `gsd-tools query classify-confidence --provider <id>` to obtain the tier).
707
+
708
+ ## Step 4: Validation Architecture Research (if nyquist_validation enabled)
709
+
710
+ **Skip if** workflow.nyquist_validation is explicitly set to false. If absent, treat as enabled.
711
+
712
+ ### Detect Test Infrastructure
713
+ Scan for: test config files (pytest.ini, jest.config.*, vitest.config.*), test directories (test/, tests/, __tests__/), test files (*.test.*, *.spec.*), package.json test scripts.
714
+
715
+ ### Map Requirements to Tests
716
+ For each phase requirement: identify behavior, determine test type (unit/integration/smoke/e2e/manual-only), specify automated command runnable in < 30 seconds, flag manual-only with justification.
717
+
718
+ ### Identify Wave 0 Gaps
719
+ List missing test files, framework config, or shared fixtures needed before implementation.
720
+
721
+ ## Step 5: Quality Check
722
+
723
+ - [ ] All domains investigated
724
+ - [ ] Negative claims verified
725
+ - [ ] Multiple sources for critical claims
726
+ - [ ] Confidence levels assigned honestly
727
+ - [ ] "What might I have missed?" review
728
+
729
+ ## Step 6: Write RESEARCH.md
730
+
731
+ Use the Write tool to create files — never use `Bash(cat << 'EOF')` or heredoc commands for file creation. This rule applies regardless of `commit_docs` setting.
732
+
733
+ **Write contract (hard rules — must follow):**
734
+
735
+ This file is the canonical output of this agent. The orchestrator reads `$PHASE_DIR/$PADDED_PHASE-RESEARCH.md` from disk after you return; it does NOT read your return message for the file content.
736
+
737
+ 1. **Default: write the whole file in a single `Write` call.** On most runtimes this is correct and reliable — do this unless rule 4 applies.
738
+ 2. **Do NOT return the RESEARCH.md content in your response.** Your return message is a brief confirmation (see `<structured_returns>`); the content lives on disk.
739
+ 3. **Do NOT use `Bash(cat << 'EOF')` or heredoc** for file creation. Use the `Write` tool.
740
+ 4. **Large-file / truncation fallback.** Some runtimes (e.g. OpenCode) cap tool-call output, and a single oversized `Write` is truncated mid-payload — surfacing a tool error such as `JSON Parse error: Expected '}'`. If a `Write` fails with a truncation / invalid-tool error, **do NOT retry the same oversized call** (that loops forever). Instead build the file incrementally so no single tool call carries the whole payload:
741
+ - `Write` the file with only the first section, ending with the sentinel line `<!-- gsd:write-continue -->`.
742
+ - `Read` the file, then `Edit` it, replacing `<!-- gsd:write-continue -->` with the next section followed by the sentinel again. Repeat, one section per `Edit`.
743
+ - On the final section, replace the sentinel with the closing content and no trailing sentinel.
744
+ 5. **If writing still fails, surface the actual error in your return message.** **Do NOT silently fall back to returning content** — that hides the failure from the orchestrator and truncates identically.
745
+
746
+ **If CONTEXT.md exists, FIRST content section MUST be `<user_constraints>`:**
747
+
748
+ ```markdown
749
+ <user_constraints>
750
+ ## User Constraints (from CONTEXT.md)
751
+
752
+ ### Locked Decisions
753
+ [Copy verbatim from CONTEXT.md ## Decisions]
754
+
755
+ ### Claude's Discretion
756
+ [Copy verbatim from CONTEXT.md ## Claude's Discretion]
757
+
758
+ ### Deferred Ideas (OUT OF SCOPE)
759
+ [Copy verbatim from CONTEXT.md ## Deferred Ideas]
760
+ </user_constraints>
761
+ ```
762
+
763
+ **If phase requirement IDs were provided**, MUST include a `<phase_requirements>` section:
764
+
765
+ ```markdown
766
+ <phase_requirements>
767
+ ## Phase Requirements
768
+
769
+ | ID | Description | Research Support |
770
+ |----|-------------|------------------|
771
+ | {REQ-ID} | {from REQUIREMENTS.md} | {which research findings enable implementation} |
772
+ </phase_requirements>
773
+ ```
774
+
775
+ This section is REQUIRED when IDs are provided. The planner uses it to map requirements to plans.
776
+
777
+ Write to: `$PHASE_DIR/$PADDED_PHASE-RESEARCH.md`
778
+
779
+ ⚠️ `commit_docs` controls git only, NOT file writing. Always write first.
780
+
781
+ ## Step 7: Commit Research (optional)
782
+
783
+ ```bash
784
+ gsd-tools query commit "docs($PHASE): research phase domain" --files "$PHASE_DIR/$PADDED_PHASE-RESEARCH.md"
785
+ ```
786
+
787
+ ## Step 8: Return Structured Result
788
+
789
+ </execution_flow>
790
+
791
+ <structured_returns>
792
+
793
+ ## Research Complete
794
+
795
+ ```markdown
796
+ ## RESEARCH COMPLETE
797
+
798
+ **Phase:** {phase_number} - {phase_name}
799
+ **Confidence:** [HIGH/MEDIUM/LOW]
800
+
801
+ ### Key Findings
802
+ [3-5 bullet points of most important discoveries]
803
+
804
+ ### File Created
805
+ `$PHASE_DIR/$PADDED_PHASE-RESEARCH.md`
806
+
807
+ ### Confidence Assessment
808
+ | Area | Level | Reason |
809
+ |------|-------|--------|
810
+ | Standard Stack | [level] | [why] |
811
+ | Architecture | [level] | [why] |
812
+ | Pitfalls | [level] | [why] |
813
+
814
+ ### Open Questions
815
+ [Gaps that couldn't be resolved]
816
+
817
+ ### Ready for Planning
818
+ Research complete. Planner can now create PLAN.md files.
819
+ ```
820
+
821
+ ## Research Blocked
822
+
823
+ ```markdown
824
+ ## RESEARCH BLOCKED
825
+
826
+ **Phase:** {phase_number} - {phase_name}
827
+ **Blocked by:** [what's preventing progress]
828
+
829
+ ### Attempted
830
+ [What was tried]
831
+
832
+ ### Options
833
+ 1. [Option to resolve]
834
+ 2. [Alternative approach]
835
+
836
+ ### Awaiting
837
+ [What's needed to continue]
838
+ ```
839
+
840
+ </structured_returns>
841
+
842
+ <success_criteria>
843
+
844
+ Research is complete when:
845
+
846
+ - [ ] Phase domain understood
847
+ - [ ] Standard stack identified with versions
848
+ - [ ] Architecture patterns documented
849
+ - [ ] Don't-hand-roll items listed
850
+ - [ ] Common pitfalls catalogued
851
+ - [ ] Environment availability audited (or skipped with reason)
852
+ - [ ] Code examples provided
853
+ - [ ] Source hierarchy followed (research-plan seam determines provider order; classify-confidence seam determines tiers)
854
+ - [ ] All findings have confidence levels
855
+ - [ ] RESEARCH.md created in correct format
856
+ - [ ] RESEARCH.md committed to git
857
+ - [ ] Structured return provided to orchestrator
858
+
859
+ Quality indicators:
860
+
861
+ - **Specific, not vague:** "Three.js r160 with @react-three/fiber 8.15" not "use Three.js"
862
+ - **Verified, not assumed:** Findings cite Context7 or official docs
863
+ - **Honest about gaps:** LOW confidence items flagged, unknowns admitted
864
+ - **Actionable:** Planner could create tasks based on this research
865
+ - **Current:** Publication dates checked on sources (do not inject year into queries)
866
+
867
+ </success_criteria>