gsd-pi 2.10.12 → 2.12.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 (504) hide show
  1. package/dist/bundled-extension-paths.d.ts +2 -0
  2. package/dist/bundled-extension-paths.js +10 -0
  3. package/dist/loader.js +45 -28
  4. package/dist/onboarding.js +100 -0
  5. package/dist/resource-loader.js +12 -3
  6. package/dist/resources/GSD-WORKFLOW.md +661 -0
  7. package/dist/resources/agents/researcher.md +29 -0
  8. package/dist/resources/agents/scout.md +56 -0
  9. package/dist/resources/agents/worker.md +31 -0
  10. package/dist/resources/extensions/ask-user-questions.ts +289 -0
  11. package/dist/resources/extensions/async-jobs/async-bash-tool.ts +211 -0
  12. package/dist/resources/extensions/async-jobs/await-tool.ts +101 -0
  13. package/dist/resources/extensions/async-jobs/cancel-job-tool.ts +34 -0
  14. package/dist/resources/extensions/async-jobs/index.ts +133 -0
  15. package/dist/resources/extensions/async-jobs/job-manager.ts +211 -0
  16. package/dist/resources/extensions/bg-shell/index.ts +3179 -0
  17. package/dist/resources/extensions/browser-tools/BROWSER-TOOLS-V2-PROPOSAL.md +1277 -0
  18. package/dist/resources/extensions/browser-tools/capture.ts +165 -0
  19. package/dist/resources/extensions/browser-tools/core.d.ts +205 -0
  20. package/dist/resources/extensions/browser-tools/core.js +1057 -0
  21. package/dist/resources/extensions/browser-tools/evaluate-helpers.ts +184 -0
  22. package/dist/resources/extensions/browser-tools/index.ts +51 -0
  23. package/dist/resources/extensions/browser-tools/lifecycle.ts +270 -0
  24. package/dist/resources/extensions/browser-tools/package.json +24 -0
  25. package/dist/resources/extensions/browser-tools/refs.ts +264 -0
  26. package/dist/resources/extensions/browser-tools/settle.ts +197 -0
  27. package/dist/resources/extensions/browser-tools/state.ts +408 -0
  28. package/dist/resources/extensions/browser-tools/tests/browser-tools-integration.test.mjs +652 -0
  29. package/dist/resources/extensions/browser-tools/tests/browser-tools-unit.test.cjs +614 -0
  30. package/dist/resources/extensions/browser-tools/tools/assertions.ts +342 -0
  31. package/dist/resources/extensions/browser-tools/tools/forms.ts +801 -0
  32. package/dist/resources/extensions/browser-tools/tools/inspection.ts +492 -0
  33. package/dist/resources/extensions/browser-tools/tools/intent.ts +614 -0
  34. package/dist/resources/extensions/browser-tools/tools/interaction.ts +865 -0
  35. package/dist/resources/extensions/browser-tools/tools/navigation.ts +232 -0
  36. package/dist/resources/extensions/browser-tools/tools/pages.ts +303 -0
  37. package/dist/resources/extensions/browser-tools/tools/refs.ts +541 -0
  38. package/dist/resources/extensions/browser-tools/tools/screenshot.ts +83 -0
  39. package/dist/resources/extensions/browser-tools/tools/session.ts +400 -0
  40. package/dist/resources/extensions/browser-tools/tools/wait.ts +247 -0
  41. package/dist/resources/extensions/browser-tools/utils.ts +660 -0
  42. package/dist/resources/extensions/context7/index.ts +428 -0
  43. package/dist/resources/extensions/context7/package.json +11 -0
  44. package/dist/resources/extensions/get-secrets-from-user.ts +625 -0
  45. package/dist/resources/extensions/google-search/index.ts +336 -0
  46. package/dist/resources/extensions/google-search/package.json +9 -0
  47. package/dist/resources/extensions/gsd/activity-log.ts +116 -0
  48. package/dist/resources/extensions/gsd/auto.ts +3732 -0
  49. package/dist/resources/extensions/gsd/commands.ts +544 -0
  50. package/dist/resources/extensions/gsd/crash-recovery.ts +105 -0
  51. package/dist/resources/extensions/gsd/dashboard-overlay.ts +564 -0
  52. package/dist/resources/extensions/gsd/dispatch-guard.ts +78 -0
  53. package/dist/resources/extensions/gsd/docs/preferences-reference.md +278 -0
  54. package/dist/resources/extensions/gsd/doctor.ts +766 -0
  55. package/dist/resources/extensions/gsd/exit-command.ts +18 -0
  56. package/dist/resources/extensions/gsd/files.ts +857 -0
  57. package/dist/resources/extensions/gsd/git-service.ts +904 -0
  58. package/dist/resources/extensions/gsd/gitignore.ts +200 -0
  59. package/dist/resources/extensions/gsd/guided-flow.ts +1054 -0
  60. package/dist/resources/extensions/gsd/index.ts +735 -0
  61. package/dist/resources/extensions/gsd/metrics.ts +374 -0
  62. package/dist/resources/extensions/gsd/migrate/command.ts +218 -0
  63. package/dist/resources/extensions/gsd/migrate/index.ts +42 -0
  64. package/dist/resources/extensions/gsd/migrate/parser.ts +323 -0
  65. package/dist/resources/extensions/gsd/migrate/parsers.ts +624 -0
  66. package/dist/resources/extensions/gsd/migrate/preview.ts +48 -0
  67. package/dist/resources/extensions/gsd/migrate/transformer.ts +346 -0
  68. package/dist/resources/extensions/gsd/migrate/types.ts +370 -0
  69. package/dist/resources/extensions/gsd/migrate/validator.ts +55 -0
  70. package/dist/resources/extensions/gsd/migrate/writer.ts +539 -0
  71. package/dist/resources/extensions/gsd/native-git-bridge.ts +181 -0
  72. package/dist/resources/extensions/gsd/native-parser-bridge.ts +135 -0
  73. package/dist/resources/extensions/gsd/observability-validator.ts +408 -0
  74. package/dist/resources/extensions/gsd/package.json +11 -0
  75. package/dist/resources/extensions/gsd/paths.ts +339 -0
  76. package/dist/resources/extensions/gsd/post-unit-hooks.ts +449 -0
  77. package/dist/resources/extensions/gsd/preferences.ts +988 -0
  78. package/dist/resources/extensions/gsd/prompt-loader.ts +92 -0
  79. package/dist/resources/extensions/gsd/prompts/complete-milestone.md +25 -0
  80. package/dist/resources/extensions/gsd/prompts/complete-slice.md +27 -0
  81. package/dist/resources/extensions/gsd/prompts/discuss.md +237 -0
  82. package/dist/resources/extensions/gsd/prompts/doctor-heal.md +29 -0
  83. package/dist/resources/extensions/gsd/prompts/execute-task.md +63 -0
  84. package/dist/resources/extensions/gsd/prompts/guided-complete-slice.md +3 -0
  85. package/dist/resources/extensions/gsd/prompts/guided-discuss-milestone.md +5 -0
  86. package/dist/resources/extensions/gsd/prompts/guided-discuss-slice.md +61 -0
  87. package/dist/resources/extensions/gsd/prompts/guided-execute-task.md +3 -0
  88. package/dist/resources/extensions/gsd/prompts/guided-plan-milestone.md +29 -0
  89. package/dist/resources/extensions/gsd/prompts/guided-plan-slice.md +3 -0
  90. package/dist/resources/extensions/gsd/prompts/guided-research-slice.md +13 -0
  91. package/dist/resources/extensions/gsd/prompts/guided-resume-task.md +1 -0
  92. package/dist/resources/extensions/gsd/prompts/plan-milestone.md +78 -0
  93. package/dist/resources/extensions/gsd/prompts/plan-slice.md +55 -0
  94. package/dist/resources/extensions/gsd/prompts/queue.md +100 -0
  95. package/dist/resources/extensions/gsd/prompts/reassess-roadmap.md +48 -0
  96. package/dist/resources/extensions/gsd/prompts/replan-slice.md +39 -0
  97. package/dist/resources/extensions/gsd/prompts/research-milestone.md +37 -0
  98. package/dist/resources/extensions/gsd/prompts/research-slice.md +28 -0
  99. package/dist/resources/extensions/gsd/prompts/review-migration.md +66 -0
  100. package/dist/resources/extensions/gsd/prompts/run-uat.md +109 -0
  101. package/dist/resources/extensions/gsd/prompts/system.md +190 -0
  102. package/dist/resources/extensions/gsd/prompts/worktree-merge.md +123 -0
  103. package/dist/resources/extensions/gsd/roadmap-slices.ts +50 -0
  104. package/dist/resources/extensions/gsd/session-forensics.ts +500 -0
  105. package/dist/resources/extensions/gsd/skill-discovery.ts +137 -0
  106. package/dist/resources/extensions/gsd/state.ts +569 -0
  107. package/dist/resources/extensions/gsd/templates/context.md +76 -0
  108. package/dist/resources/extensions/gsd/templates/decisions.md +8 -0
  109. package/dist/resources/extensions/gsd/templates/milestone-summary.md +73 -0
  110. package/dist/resources/extensions/gsd/templates/plan.md +131 -0
  111. package/dist/resources/extensions/gsd/templates/preferences.md +23 -0
  112. package/dist/resources/extensions/gsd/templates/project.md +31 -0
  113. package/dist/resources/extensions/gsd/templates/reassessment.md +28 -0
  114. package/dist/resources/extensions/gsd/templates/requirements.md +81 -0
  115. package/dist/resources/extensions/gsd/templates/research.md +46 -0
  116. package/dist/resources/extensions/gsd/templates/roadmap.md +118 -0
  117. package/dist/resources/extensions/gsd/templates/secrets-manifest.md +22 -0
  118. package/dist/resources/extensions/gsd/templates/slice-context.md +58 -0
  119. package/dist/resources/extensions/gsd/templates/slice-summary.md +99 -0
  120. package/dist/resources/extensions/gsd/templates/state.md +19 -0
  121. package/dist/resources/extensions/gsd/templates/task-plan.md +52 -0
  122. package/dist/resources/extensions/gsd/templates/task-summary.md +57 -0
  123. package/dist/resources/extensions/gsd/templates/uat.md +54 -0
  124. package/dist/resources/extensions/gsd/tests/activity-log-prune.test.ts +297 -0
  125. package/dist/resources/extensions/gsd/tests/activity-log-save.test.ts +127 -0
  126. package/dist/resources/extensions/gsd/tests/auto-draft-pause.test.ts +109 -0
  127. package/dist/resources/extensions/gsd/tests/auto-preflight.test.ts +45 -0
  128. package/dist/resources/extensions/gsd/tests/auto-secrets-gate.test.ts +196 -0
  129. package/dist/resources/extensions/gsd/tests/auto-supervisor.test.mjs +53 -0
  130. package/dist/resources/extensions/gsd/tests/collect-from-manifest.test.ts +469 -0
  131. package/dist/resources/extensions/gsd/tests/complete-milestone.test.ts +200 -0
  132. package/dist/resources/extensions/gsd/tests/cost-projection.test.ts +134 -0
  133. package/dist/resources/extensions/gsd/tests/derive-state-deps.test.ts +312 -0
  134. package/dist/resources/extensions/gsd/tests/derive-state-draft.test.ts +299 -0
  135. package/dist/resources/extensions/gsd/tests/derive-state.test.ts +660 -0
  136. package/dist/resources/extensions/gsd/tests/discuss-prompt.test.ts +27 -0
  137. package/dist/resources/extensions/gsd/tests/dispatch-guard.test.ts +91 -0
  138. package/dist/resources/extensions/gsd/tests/doctor-fixlevel.test.ts +170 -0
  139. package/dist/resources/extensions/gsd/tests/doctor.test.ts +594 -0
  140. package/dist/resources/extensions/gsd/tests/draft-promotion.test.ts +169 -0
  141. package/dist/resources/extensions/gsd/tests/exit-command.test.ts +50 -0
  142. package/dist/resources/extensions/gsd/tests/git-service.test.ts +1788 -0
  143. package/dist/resources/extensions/gsd/tests/idle-recovery.test.ts +577 -0
  144. package/dist/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +580 -0
  145. package/dist/resources/extensions/gsd/tests/manifest-status.test.ts +283 -0
  146. package/dist/resources/extensions/gsd/tests/metrics-io.test.ts +176 -0
  147. package/dist/resources/extensions/gsd/tests/metrics.test.ts +188 -0
  148. package/dist/resources/extensions/gsd/tests/migrate-command.test.ts +369 -0
  149. package/dist/resources/extensions/gsd/tests/migrate-parser.test.ts +757 -0
  150. package/dist/resources/extensions/gsd/tests/migrate-transformer.test.ts +635 -0
  151. package/dist/resources/extensions/gsd/tests/migrate-validator-parsers.test.ts +414 -0
  152. package/dist/resources/extensions/gsd/tests/migrate-writer-integration.test.ts +297 -0
  153. package/dist/resources/extensions/gsd/tests/migrate-writer.test.ts +398 -0
  154. package/dist/resources/extensions/gsd/tests/must-have-parser.test.ts +291 -0
  155. package/dist/resources/extensions/gsd/tests/network-error-fallback.test.ts +54 -0
  156. package/dist/resources/extensions/gsd/tests/next-milestone-id.test.ts +66 -0
  157. package/dist/resources/extensions/gsd/tests/orphaned-branch.test.ts +353 -0
  158. package/dist/resources/extensions/gsd/tests/parsers.test.ts +1664 -0
  159. package/dist/resources/extensions/gsd/tests/plan-milestone.test.ts +133 -0
  160. package/dist/resources/extensions/gsd/tests/plan-quality-validator.test.ts +363 -0
  161. package/dist/resources/extensions/gsd/tests/post-unit-hooks.test.ts +297 -0
  162. package/dist/resources/extensions/gsd/tests/preferences-hooks.test.ts +226 -0
  163. package/dist/resources/extensions/gsd/tests/queue-draft-detection.test.ts +126 -0
  164. package/dist/resources/extensions/gsd/tests/reassess-prompt.test.ts +142 -0
  165. package/dist/resources/extensions/gsd/tests/regex-hardening.test.ts +281 -0
  166. package/dist/resources/extensions/gsd/tests/remote-questions.test.ts +155 -0
  167. package/dist/resources/extensions/gsd/tests/remote-status.test.ts +99 -0
  168. package/dist/resources/extensions/gsd/tests/replan-slice.test.ts +493 -0
  169. package/dist/resources/extensions/gsd/tests/requirements.test.ts +106 -0
  170. package/dist/resources/extensions/gsd/tests/resolve-ts-hooks.mjs +35 -0
  171. package/dist/resources/extensions/gsd/tests/resolve-ts.mjs +11 -0
  172. package/dist/resources/extensions/gsd/tests/roadmap-slices.test.ts +41 -0
  173. package/dist/resources/extensions/gsd/tests/run-uat.test.ts +316 -0
  174. package/dist/resources/extensions/gsd/tests/secure-env-collect.test.ts +185 -0
  175. package/dist/resources/extensions/gsd/tests/smart-entry-draft.test.ts +123 -0
  176. package/dist/resources/extensions/gsd/tests/test-helpers.ts +61 -0
  177. package/dist/resources/extensions/gsd/tests/unique-milestone-ids.test.ts +219 -0
  178. package/dist/resources/extensions/gsd/tests/unit-runtime.test.ts +234 -0
  179. package/dist/resources/extensions/gsd/tests/workspace-index.test.ts +75 -0
  180. package/dist/resources/extensions/gsd/tests/worktree-integration.test.ts +234 -0
  181. package/dist/resources/extensions/gsd/tests/worktree-manager.test.ts +141 -0
  182. package/dist/resources/extensions/gsd/tests/worktree.test.ts +597 -0
  183. package/dist/resources/extensions/gsd/tests/write-gate.test.ts +122 -0
  184. package/dist/resources/extensions/gsd/types.ts +296 -0
  185. package/dist/resources/extensions/gsd/unit-runtime.ts +184 -0
  186. package/dist/resources/extensions/gsd/workspace-index.ts +189 -0
  187. package/dist/resources/extensions/gsd/worktree-command.ts +845 -0
  188. package/dist/resources/extensions/gsd/worktree-manager.ts +459 -0
  189. package/dist/resources/extensions/gsd/{worktree.js → worktree.ts} +92 -61
  190. package/dist/resources/extensions/mac-tools/index.ts +852 -0
  191. package/dist/resources/extensions/mac-tools/swift-cli/Package.swift +22 -0
  192. package/dist/resources/extensions/mac-tools/swift-cli/Sources/main.swift +1318 -0
  193. package/dist/resources/extensions/mcporter/index.ts +429 -0
  194. package/dist/resources/extensions/remote-questions/config.ts +81 -0
  195. package/dist/resources/extensions/remote-questions/discord-adapter.ts +128 -0
  196. package/dist/resources/extensions/remote-questions/format.ts +163 -0
  197. package/dist/resources/extensions/remote-questions/manager.ts +192 -0
  198. package/dist/resources/extensions/remote-questions/remote-command.ts +361 -0
  199. package/dist/resources/extensions/remote-questions/slack-adapter.ts +92 -0
  200. package/dist/resources/extensions/remote-questions/status.ts +31 -0
  201. package/dist/resources/extensions/remote-questions/store.ts +77 -0
  202. package/dist/resources/extensions/remote-questions/types.ts +75 -0
  203. package/dist/resources/extensions/search-the-web/cache.ts +78 -0
  204. package/dist/resources/extensions/search-the-web/command-search-provider.ts +99 -0
  205. package/dist/resources/extensions/search-the-web/format.ts +258 -0
  206. package/dist/resources/extensions/search-the-web/http.ts +238 -0
  207. package/dist/resources/extensions/search-the-web/index.ts +65 -0
  208. package/dist/resources/extensions/search-the-web/native-search.ts +165 -0
  209. package/dist/resources/extensions/search-the-web/provider.ts +136 -0
  210. package/dist/resources/extensions/search-the-web/tavily.ts +116 -0
  211. package/dist/resources/extensions/search-the-web/tool-fetch-page.ts +581 -0
  212. package/dist/resources/extensions/search-the-web/tool-llm-context.ts +620 -0
  213. package/dist/resources/extensions/search-the-web/tool-search.ts +635 -0
  214. package/dist/resources/extensions/search-the-web/url-utils.ts +91 -0
  215. package/dist/resources/extensions/shared/bundled-extension-paths.ts +11 -0
  216. package/dist/resources/extensions/shared/confirm-ui.ts +126 -0
  217. package/dist/resources/extensions/shared/interview-ui.ts +613 -0
  218. package/dist/resources/extensions/shared/next-action-ui.ts +197 -0
  219. package/dist/resources/extensions/shared/progress-widget.ts +282 -0
  220. package/dist/resources/extensions/shared/terminal.ts +23 -0
  221. package/dist/resources/extensions/shared/thinking-widget.ts +107 -0
  222. package/dist/resources/extensions/shared/ui.ts +400 -0
  223. package/dist/resources/extensions/shared/wizard-ui.ts +551 -0
  224. package/dist/resources/extensions/slash-commands/audit.ts +88 -0
  225. package/dist/resources/extensions/slash-commands/clear.ts +10 -0
  226. package/dist/resources/extensions/slash-commands/create-extension.ts +297 -0
  227. package/dist/resources/extensions/slash-commands/create-slash-command.ts +234 -0
  228. package/dist/resources/extensions/slash-commands/index.ts +12 -0
  229. package/dist/resources/extensions/subagent/agents.ts +126 -0
  230. package/dist/resources/extensions/subagent/index.ts +1072 -0
  231. package/dist/resources/extensions/subagent/isolation.ts +498 -0
  232. package/dist/resources/extensions/ttsr/index.ts +163 -0
  233. package/dist/resources/extensions/ttsr/rule-loader.ts +121 -0
  234. package/dist/resources/extensions/ttsr/ttsr-interrupt.md +6 -0
  235. package/dist/resources/extensions/ttsr/ttsr-manager.ts +430 -0
  236. package/dist/resources/extensions/universal-config/discovery.ts +78 -0
  237. package/dist/resources/extensions/universal-config/format.ts +160 -0
  238. package/dist/resources/extensions/universal-config/index.ts +118 -0
  239. package/dist/resources/extensions/universal-config/package.json +11 -0
  240. package/dist/resources/extensions/universal-config/scanners.ts +579 -0
  241. package/dist/resources/extensions/universal-config/tests/discovery.test.ts +111 -0
  242. package/dist/resources/extensions/universal-config/tests/format.test.ts +111 -0
  243. package/dist/resources/extensions/universal-config/tests/scanners.test.ts +438 -0
  244. package/dist/resources/extensions/universal-config/tools.ts +60 -0
  245. package/dist/resources/extensions/universal-config/types.ts +116 -0
  246. package/dist/resources/extensions/voice/index.ts +271 -0
  247. package/dist/resources/extensions/voice/speech-recognizer.py +504 -0
  248. package/dist/resources/extensions/voice/speech-recognizer.swift +154 -0
  249. package/dist/resources/skills/debug-like-expert/SKILL.md +231 -0
  250. package/dist/resources/skills/debug-like-expert/references/debugging-mindset.md +253 -0
  251. package/dist/resources/skills/debug-like-expert/references/hypothesis-testing.md +373 -0
  252. package/dist/resources/skills/debug-like-expert/references/investigation-techniques.md +337 -0
  253. package/dist/resources/skills/debug-like-expert/references/verification-patterns.md +425 -0
  254. package/dist/resources/skills/debug-like-expert/references/when-to-research.md +361 -0
  255. package/dist/resources/skills/frontend-design/SKILL.md +45 -0
  256. package/dist/resources/skills/github-workflows/SKILL.md +92 -0
  257. package/dist/resources/skills/github-workflows/references/gh/SKILL.md +255 -0
  258. package/dist/resources/skills/github-workflows/references/gh/references/issue-stories.md +204 -0
  259. package/dist/resources/skills/github-workflows/references/gh/references/labels.md +170 -0
  260. package/dist/resources/skills/github-workflows/references/gh/references/milestones.md +158 -0
  261. package/dist/resources/skills/github-workflows/references/gh/references/projects-v2.md +177 -0
  262. package/dist/resources/skills/github-workflows/references/gh/scripts/experiment_cleanup.py +191 -0
  263. package/dist/resources/skills/github-workflows/references/gh/scripts/github_project_setup.py +799 -0
  264. package/dist/resources/skills/github-workflows/references/gh/tests/__init__.py +0 -0
  265. package/dist/resources/skills/github-workflows/references/gh/tests/test_github_project_setup.py +608 -0
  266. package/dist/resources/skills/swiftui/SKILL.md +208 -0
  267. package/dist/resources/skills/swiftui/references/animations.md +921 -0
  268. package/dist/resources/skills/swiftui/references/architecture.md +1561 -0
  269. package/dist/resources/skills/swiftui/references/layout-system.md +1186 -0
  270. package/dist/resources/skills/swiftui/references/navigation.md +1492 -0
  271. package/dist/resources/skills/swiftui/references/networking-async.md +214 -0
  272. package/dist/resources/skills/swiftui/references/performance.md +1706 -0
  273. package/dist/resources/skills/swiftui/references/platform-integration.md +204 -0
  274. package/dist/resources/skills/swiftui/references/state-management.md +1443 -0
  275. package/dist/resources/skills/swiftui/references/swiftdata.md +297 -0
  276. package/dist/resources/skills/swiftui/references/testing-debugging.md +247 -0
  277. package/dist/resources/skills/swiftui/references/uikit-appkit-interop.md +218 -0
  278. package/dist/resources/skills/swiftui/workflows/add-feature.md +191 -0
  279. package/dist/resources/skills/swiftui/workflows/build-new-app.md +311 -0
  280. package/dist/resources/skills/swiftui/workflows/debug-swiftui.md +192 -0
  281. package/dist/resources/skills/swiftui/workflows/optimize-performance.md +197 -0
  282. package/dist/resources/skills/swiftui/workflows/ship-app.md +203 -0
  283. package/dist/resources/skills/swiftui/workflows/write-tests.md +235 -0
  284. package/dist/wizard.js +1 -0
  285. package/package.json +8 -6
  286. package/packages/native/dist/fd/index.d.ts +1 -0
  287. package/packages/native/dist/fd/index.js +1 -0
  288. package/packages/native/dist/grep/index.d.ts +2 -1
  289. package/packages/native/dist/grep/index.js +1 -0
  290. package/packages/native/src/__tests__/fd.test.mjs +35 -0
  291. package/packages/native/src/__tests__/grep.test.mjs +26 -9
  292. package/packages/native/src/fd/index.ts +1 -0
  293. package/packages/native/src/grep/index.ts +3 -2
  294. package/packages/pi-agent-core/dist/agent-loop.d.ts.map +1 -1
  295. package/packages/pi-agent-core/dist/agent-loop.js +169 -55
  296. package/packages/pi-agent-core/dist/agent-loop.js.map +1 -1
  297. package/packages/pi-agent-core/dist/agent.d.ts +13 -1
  298. package/packages/pi-agent-core/dist/agent.d.ts.map +1 -1
  299. package/packages/pi-agent-core/dist/agent.js +16 -0
  300. package/packages/pi-agent-core/dist/agent.js.map +1 -1
  301. package/packages/pi-agent-core/dist/types.d.ts +91 -1
  302. package/packages/pi-agent-core/dist/types.d.ts.map +1 -1
  303. package/packages/pi-agent-core/dist/types.js.map +1 -1
  304. package/packages/pi-agent-core/src/agent-loop.ts +273 -63
  305. package/packages/pi-agent-core/src/agent.ts +24 -0
  306. package/packages/pi-agent-core/src/types.ts +98 -0
  307. package/packages/pi-ai/dist/env-api-keys.js +2 -0
  308. package/packages/pi-ai/dist/env-api-keys.js.map +1 -1
  309. package/packages/pi-ai/dist/models.generated.d.ts +314 -0
  310. package/packages/pi-ai/dist/models.generated.d.ts.map +1 -1
  311. package/packages/pi-ai/dist/models.generated.js +236 -0
  312. package/packages/pi-ai/dist/models.generated.js.map +1 -1
  313. package/packages/pi-ai/dist/providers/google-gemini-cli.d.ts.map +1 -1
  314. package/packages/pi-ai/dist/providers/google-gemini-cli.js +6 -0
  315. package/packages/pi-ai/dist/providers/google-gemini-cli.js.map +1 -1
  316. package/packages/pi-ai/dist/providers/openai-completions.d.ts.map +1 -1
  317. package/packages/pi-ai/dist/providers/openai-completions.js +2 -0
  318. package/packages/pi-ai/dist/providers/openai-completions.js.map +1 -1
  319. package/packages/pi-ai/dist/types.d.ts +1 -1
  320. package/packages/pi-ai/dist/types.d.ts.map +1 -1
  321. package/packages/pi-ai/dist/types.js.map +1 -1
  322. package/packages/pi-ai/src/env-api-keys.ts +2 -0
  323. package/packages/pi-ai/src/models.generated.ts +236 -0
  324. package/packages/pi-ai/src/providers/google-gemini-cli.ts +8 -0
  325. package/packages/pi-ai/src/providers/openai-completions.ts +3 -0
  326. package/packages/pi-ai/src/types.ts +2 -1
  327. package/packages/pi-coding-agent/dist/cli/args.d.ts.map +1 -1
  328. package/packages/pi-coding-agent/dist/cli/args.js +1 -0
  329. package/packages/pi-coding-agent/dist/cli/args.js.map +1 -1
  330. package/packages/pi-coding-agent/dist/core/agent-session.d.ts +26 -0
  331. package/packages/pi-coding-agent/dist/core/agent-session.d.ts.map +1 -1
  332. package/packages/pi-coding-agent/dist/core/agent-session.js +137 -22
  333. package/packages/pi-coding-agent/dist/core/agent-session.js.map +1 -1
  334. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts +20 -0
  335. package/packages/pi-coding-agent/dist/core/auth-storage.d.ts.map +1 -1
  336. package/packages/pi-coding-agent/dist/core/auth-storage.js +43 -0
  337. package/packages/pi-coding-agent/dist/core/auth-storage.js.map +1 -1
  338. package/packages/pi-coding-agent/dist/core/fallback-resolver.d.ts +51 -0
  339. package/packages/pi-coding-agent/dist/core/fallback-resolver.d.ts.map +1 -0
  340. package/packages/pi-coding-agent/dist/core/fallback-resolver.js +119 -0
  341. package/packages/pi-coding-agent/dist/core/fallback-resolver.js.map +1 -0
  342. package/packages/pi-coding-agent/dist/core/fallback-resolver.test.d.ts +2 -0
  343. package/packages/pi-coding-agent/dist/core/fallback-resolver.test.d.ts.map +1 -0
  344. package/packages/pi-coding-agent/dist/core/fallback-resolver.test.js +183 -0
  345. package/packages/pi-coding-agent/dist/core/fallback-resolver.test.js.map +1 -0
  346. package/packages/pi-coding-agent/dist/core/index.d.ts +1 -0
  347. package/packages/pi-coding-agent/dist/core/index.d.ts.map +1 -1
  348. package/packages/pi-coding-agent/dist/core/index.js +1 -0
  349. package/packages/pi-coding-agent/dist/core/index.js.map +1 -1
  350. package/packages/pi-coding-agent/dist/core/model-resolver.d.ts.map +1 -1
  351. package/packages/pi-coding-agent/dist/core/model-resolver.js +1 -0
  352. package/packages/pi-coding-agent/dist/core/model-resolver.js.map +1 -1
  353. package/packages/pi-coding-agent/dist/core/session-manager.d.ts +12 -1
  354. package/packages/pi-coding-agent/dist/core/session-manager.d.ts.map +1 -1
  355. package/packages/pi-coding-agent/dist/core/session-manager.js +37 -1
  356. package/packages/pi-coding-agent/dist/core/session-manager.js.map +1 -1
  357. package/packages/pi-coding-agent/dist/core/session-manager.test.d.ts +2 -0
  358. package/packages/pi-coding-agent/dist/core/session-manager.test.d.ts.map +1 -0
  359. package/packages/pi-coding-agent/dist/core/session-manager.test.js +61 -0
  360. package/packages/pi-coding-agent/dist/core/session-manager.test.js.map +1 -0
  361. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts +20 -0
  362. package/packages/pi-coding-agent/dist/core/settings-manager.d.ts.map +1 -1
  363. package/packages/pi-coding-agent/dist/core/settings-manager.js +47 -0
  364. package/packages/pi-coding-agent/dist/core/settings-manager.js.map +1 -1
  365. package/packages/pi-coding-agent/dist/core/tools/find.d.ts.map +1 -1
  366. package/packages/pi-coding-agent/dist/core/tools/find.js +1 -0
  367. package/packages/pi-coding-agent/dist/core/tools/find.js.map +1 -1
  368. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.d.ts.map +1 -1
  369. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js +6 -15
  370. package/packages/pi-coding-agent/dist/modes/interactive/components/footer.js.map +1 -1
  371. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts +18 -1
  372. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.d.ts.map +1 -1
  373. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js +46 -4
  374. package/packages/pi-coding-agent/dist/modes/interactive/components/login-dialog.js.map +1 -1
  375. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  376. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +25 -2
  377. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  378. package/packages/pi-coding-agent/src/cli/args.ts +1 -0
  379. package/packages/pi-coding-agent/src/core/agent-session.ts +167 -22
  380. package/packages/pi-coding-agent/src/core/auth-storage.ts +45 -0
  381. package/packages/pi-coding-agent/src/core/fallback-resolver.test.ts +229 -0
  382. package/packages/pi-coding-agent/src/core/fallback-resolver.ts +165 -0
  383. package/packages/pi-coding-agent/src/core/index.ts +1 -0
  384. package/packages/pi-coding-agent/src/core/model-resolver.ts +1 -0
  385. package/packages/pi-coding-agent/src/core/session-manager.test.ts +65 -0
  386. package/packages/pi-coding-agent/src/core/session-manager.ts +51 -1
  387. package/packages/pi-coding-agent/src/core/settings-manager.ts +66 -0
  388. package/packages/pi-coding-agent/src/core/tools/find.ts +1 -0
  389. package/packages/pi-coding-agent/src/modes/interactive/components/footer.ts +6 -16
  390. package/packages/pi-coding-agent/src/modes/interactive/components/login-dialog.ts +49 -4
  391. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +28 -2
  392. package/packages/pi-tui/dist/autocomplete.d.ts.map +1 -1
  393. package/packages/pi-tui/dist/autocomplete.js +3 -4
  394. package/packages/pi-tui/dist/autocomplete.js.map +1 -1
  395. package/packages/pi-tui/dist/components/editor.d.ts +7 -0
  396. package/packages/pi-tui/dist/components/editor.d.ts.map +1 -1
  397. package/packages/pi-tui/dist/components/editor.js +57 -50
  398. package/packages/pi-tui/dist/components/editor.js.map +1 -1
  399. package/packages/pi-tui/src/autocomplete.ts +3 -5
  400. package/packages/pi-tui/src/components/editor.ts +70 -49
  401. package/pkg/dist/core/export-html/ansi-to-html.d.ts +22 -0
  402. package/pkg/dist/core/export-html/ansi-to-html.d.ts.map +1 -0
  403. package/pkg/dist/core/export-html/ansi-to-html.js +249 -0
  404. package/pkg/dist/core/export-html/ansi-to-html.js.map +1 -0
  405. package/pkg/dist/core/export-html/index.d.ts +37 -0
  406. package/pkg/dist/core/export-html/index.d.ts.map +1 -0
  407. package/pkg/dist/core/export-html/index.js +223 -0
  408. package/pkg/dist/core/export-html/index.js.map +1 -0
  409. package/pkg/dist/core/export-html/template.css +971 -0
  410. package/pkg/dist/core/export-html/template.html +54 -0
  411. package/pkg/dist/core/export-html/template.js +1583 -0
  412. package/pkg/dist/core/export-html/tool-renderer.d.ts +38 -0
  413. package/pkg/dist/core/export-html/tool-renderer.d.ts.map +1 -0
  414. package/pkg/dist/core/export-html/tool-renderer.js +70 -0
  415. package/pkg/dist/core/export-html/tool-renderer.js.map +1 -0
  416. package/pkg/dist/core/export-html/vendor/highlight.min.js +1213 -0
  417. package/pkg/dist/core/export-html/vendor/marked.min.js +6 -0
  418. package/scripts/postinstall.js +30 -17
  419. package/src/resources/extensions/bg-shell/index.ts +51 -7
  420. package/src/resources/extensions/gsd/activity-log.ts +61 -14
  421. package/src/resources/extensions/gsd/auto.ts +288 -19
  422. package/src/resources/extensions/gsd/commands.ts +9 -3
  423. package/src/resources/extensions/gsd/dashboard-overlay.ts +55 -12
  424. package/src/resources/extensions/gsd/docs/preferences-reference.md +25 -0
  425. package/src/resources/extensions/gsd/doctor.ts +60 -3
  426. package/src/resources/extensions/gsd/files.ts +45 -1
  427. package/src/resources/extensions/gsd/git-service.ts +46 -41
  428. package/src/resources/extensions/gsd/guided-flow.ts +81 -9
  429. package/src/resources/extensions/gsd/index.ts +62 -1
  430. package/src/resources/extensions/gsd/native-git-bridge.ts +181 -0
  431. package/src/resources/extensions/gsd/paths.ts +35 -4
  432. package/src/resources/extensions/gsd/post-unit-hooks.ts +449 -0
  433. package/src/resources/extensions/gsd/preferences.ts +232 -1
  434. package/src/resources/extensions/gsd/prompt-loader.ts +45 -3
  435. package/src/resources/extensions/gsd/prompts/complete-milestone.md +1 -1
  436. package/src/resources/extensions/gsd/prompts/complete-slice.md +1 -3
  437. package/src/resources/extensions/gsd/prompts/discuss.md +10 -8
  438. package/src/resources/extensions/gsd/prompts/execute-task.md +4 -2
  439. package/src/resources/extensions/gsd/prompts/guided-complete-slice.md +3 -1
  440. package/src/resources/extensions/gsd/prompts/guided-discuss-milestone.md +3 -1
  441. package/src/resources/extensions/gsd/prompts/guided-discuss-slice.md +3 -1
  442. package/src/resources/extensions/gsd/prompts/guided-execute-task.md +3 -1
  443. package/src/resources/extensions/gsd/prompts/guided-plan-milestone.md +4 -2
  444. package/src/resources/extensions/gsd/prompts/guided-plan-slice.md +3 -1
  445. package/src/resources/extensions/gsd/prompts/guided-research-slice.md +3 -1
  446. package/src/resources/extensions/gsd/prompts/plan-milestone.md +9 -12
  447. package/src/resources/extensions/gsd/prompts/plan-slice.md +1 -3
  448. package/src/resources/extensions/gsd/prompts/queue.md +3 -1
  449. package/src/resources/extensions/gsd/prompts/research-milestone.md +1 -1
  450. package/src/resources/extensions/gsd/prompts/research-slice.md +1 -1
  451. package/src/resources/extensions/gsd/state.ts +130 -18
  452. package/src/resources/extensions/gsd/templates/context.md +1 -1
  453. package/src/resources/extensions/gsd/templates/state.md +3 -3
  454. package/src/resources/extensions/gsd/tests/activity-log-save.test.ts +127 -0
  455. package/src/resources/extensions/gsd/tests/complete-milestone.test.ts +5 -1
  456. package/src/resources/extensions/gsd/tests/doctor.test.ts +115 -1
  457. package/src/resources/extensions/gsd/tests/draft-promotion.test.ts +6 -2
  458. package/src/resources/extensions/gsd/tests/git-service.test.ts +35 -35
  459. package/src/resources/extensions/gsd/tests/idle-recovery.test.ts +8 -8
  460. package/src/resources/extensions/gsd/tests/integration-mixed-milestones.test.ts +4 -1
  461. package/src/resources/extensions/gsd/tests/network-error-fallback.test.ts +54 -0
  462. package/src/resources/extensions/gsd/tests/orphaned-branch.test.ts +5 -5
  463. package/src/resources/extensions/gsd/tests/post-unit-hooks.test.ts +297 -0
  464. package/src/resources/extensions/gsd/tests/preferences-hooks.test.ts +226 -0
  465. package/src/resources/extensions/gsd/tests/regex-hardening.test.ts +12 -0
  466. package/src/resources/extensions/gsd/tests/unit-runtime.test.ts +6 -0
  467. package/src/resources/extensions/gsd/tests/worktree-integration.test.ts +4 -4
  468. package/src/resources/extensions/gsd/tests/worktree-manager.test.ts +4 -4
  469. package/src/resources/extensions/gsd/tests/worktree.test.ts +19 -19
  470. package/src/resources/extensions/gsd/types.ts +109 -0
  471. package/src/resources/extensions/gsd/worktree-manager.ts +72 -13
  472. package/src/resources/extensions/gsd/worktree.ts +5 -4
  473. package/src/resources/extensions/search-the-web/command-search-provider.ts +8 -4
  474. package/src/resources/extensions/search-the-web/native-search.ts +32 -23
  475. package/src/resources/extensions/search-the-web/provider.ts +19 -2
  476. package/src/resources/extensions/search-the-web/tool-fetch-page.ts +62 -0
  477. package/src/resources/extensions/search-the-web/tool-llm-context.ts +62 -3
  478. package/src/resources/extensions/search-the-web/tool-search.ts +62 -3
  479. package/src/resources/extensions/shared/bundled-extension-paths.ts +11 -0
  480. package/src/resources/extensions/subagent/index.ts +2 -1
  481. package/src/resources/skills/github-workflows/SKILL.md +5 -0
  482. package/dist/resources/extensions/gsd/git-service.d.ts +0 -225
  483. package/dist/resources/extensions/gsd/git-service.js +0 -756
  484. package/dist/resources/extensions/gsd/preferences.d.ts +0 -122
  485. package/dist/resources/extensions/gsd/preferences.js +0 -616
  486. package/dist/resources/extensions/gsd/worktree.d.ts +0 -106
  487. package/dist/resources/extensions/remote-questions/config.d.ts +0 -14
  488. package/dist/resources/extensions/remote-questions/config.js +0 -68
  489. package/dist/resources/extensions/remote-questions/discord-adapter.d.ts +0 -17
  490. package/dist/resources/extensions/remote-questions/discord-adapter.js +0 -118
  491. package/dist/resources/extensions/remote-questions/format.d.ts +0 -38
  492. package/dist/resources/extensions/remote-questions/format.js +0 -119
  493. package/dist/resources/extensions/remote-questions/manager.d.ts +0 -23
  494. package/dist/resources/extensions/remote-questions/manager.js +0 -161
  495. package/dist/resources/extensions/remote-questions/remote-command.d.ts +0 -6
  496. package/dist/resources/extensions/remote-questions/remote-command.js +0 -358
  497. package/dist/resources/extensions/remote-questions/slack-adapter.d.ts +0 -15
  498. package/dist/resources/extensions/remote-questions/slack-adapter.js +0 -82
  499. package/dist/resources/extensions/remote-questions/status.d.ts +0 -9
  500. package/dist/resources/extensions/remote-questions/status.js +0 -25
  501. package/dist/resources/extensions/remote-questions/store.d.ts +0 -11
  502. package/dist/resources/extensions/remote-questions/store.js +0 -66
  503. package/dist/resources/extensions/remote-questions/types.d.ts +0 -68
  504. package/dist/resources/extensions/remote-questions/types.js +0 -4
@@ -0,0 +1,1664 @@
1
+ import { parseRoadmap, parsePlan, parseSummary, parseContinue, parseRequirementCounts, parseSecretsManifest, formatSecretsManifest } from '../files.ts';
2
+ import { createTestContext } from './test-helpers.ts';
3
+
4
+ const { assertEq, assertTrue, report } = createTestContext();
5
+ // ═══════════════════════════════════════════════════════════════════════════
6
+ // parseRoadmap tests
7
+ // ═══════════════════════════════════════════════════════════════════════════
8
+
9
+ console.log('\n=== parseRoadmap: full roadmap ===');
10
+ {
11
+ const content = `# M001: GSD Extension — Hierarchical Planning
12
+
13
+ **Vision:** Build a structured planning system for coding agents.
14
+
15
+ **Success Criteria:**
16
+ - All parsers have test coverage
17
+ - Round-trip formatting preserves data
18
+ - State derivation works correctly
19
+
20
+ ---
21
+
22
+ ## Slices
23
+
24
+ - [x] **S01: Types + File I/O** \`risk:low\` \`depends:[]\`
25
+ > After this: All types defined and parsers work.
26
+
27
+ - [ ] **S02: State Derivation** \`risk:medium\` \`depends:[S01]\`
28
+ > After this: Dashboard shows real-time state.
29
+
30
+ - [ ] **S03: Auto Mode** \`risk:high\` \`depends:[S01, S02]\`
31
+ > After this: Agent can execute tasks automatically.
32
+
33
+ ---
34
+
35
+ ## Boundary Map
36
+
37
+ ### S01 → S02
38
+ \`\`\`
39
+ Produces:
40
+ types.ts — all type definitions
41
+ files.ts — parser and formatter functions
42
+
43
+ Consumes from S02:
44
+ nothing
45
+ \`\`\`
46
+
47
+ ### S02 → S03
48
+ \`\`\`
49
+ Produces:
50
+ state.ts — deriveState function
51
+
52
+ Consumes from S03:
53
+ auto-mode entry points
54
+ \`\`\`
55
+ `;
56
+
57
+ const r = parseRoadmap(content);
58
+
59
+ assertEq(r.title, 'M001: GSD Extension — Hierarchical Planning', 'roadmap title');
60
+ assertEq(r.vision, 'Build a structured planning system for coding agents.', 'roadmap vision');
61
+ assertEq(r.successCriteria.length, 3, 'success criteria count');
62
+ assertEq(r.successCriteria[0], 'All parsers have test coverage', 'first success criterion');
63
+ assertEq(r.successCriteria[2], 'State derivation works correctly', 'third success criterion');
64
+
65
+ // Slices
66
+ assertEq(r.slices.length, 3, 'slice count');
67
+
68
+ assertEq(r.slices[0].id, 'S01', 'S01 id');
69
+ assertEq(r.slices[0].title, 'Types + File I/O', 'S01 title');
70
+ assertEq(r.slices[0].risk, 'low', 'S01 risk');
71
+ assertEq(r.slices[0].depends, [], 'S01 depends');
72
+ assertEq(r.slices[0].done, true, 'S01 done');
73
+ assertEq(r.slices[0].demo, 'All types defined and parsers work.', 'S01 demo');
74
+
75
+ assertEq(r.slices[1].id, 'S02', 'S02 id');
76
+ assertEq(r.slices[1].title, 'State Derivation', 'S02 title');
77
+ assertEq(r.slices[1].risk, 'medium', 'S02 risk');
78
+ assertEq(r.slices[1].depends, ['S01'], 'S02 depends');
79
+ assertEq(r.slices[1].done, false, 'S02 done');
80
+
81
+ assertEq(r.slices[2].id, 'S03', 'S03 id');
82
+ assertEq(r.slices[2].risk, 'high', 'S03 risk');
83
+ assertEq(r.slices[2].depends, ['S01', 'S02'], 'S03 depends');
84
+ assertEq(r.slices[2].done, false, 'S03 done');
85
+
86
+ // Boundary map
87
+ assertEq(r.boundaryMap.length, 2, 'boundary map entry count');
88
+ assertEq(r.boundaryMap[0].fromSlice, 'S01', 'bm[0] from');
89
+ assertEq(r.boundaryMap[0].toSlice, 'S02', 'bm[0] to');
90
+ assertTrue(r.boundaryMap[0].produces.includes('types.ts'), 'bm[0] produces mentions types.ts');
91
+ assertEq(r.boundaryMap[1].fromSlice, 'S02', 'bm[1] from');
92
+ assertEq(r.boundaryMap[1].toSlice, 'S03', 'bm[1] to');
93
+ }
94
+
95
+ console.log('\n=== parseRoadmap: empty slices section ===');
96
+ {
97
+ const content = `# M002: Empty Milestone
98
+
99
+ **Vision:** Nothing yet.
100
+
101
+ ## Slices
102
+
103
+ ## Boundary Map
104
+ `;
105
+
106
+ const r = parseRoadmap(content);
107
+ assertEq(r.title, 'M002: Empty Milestone', 'title with empty slices');
108
+ assertEq(r.slices.length, 0, 'no slices parsed');
109
+ assertEq(r.boundaryMap.length, 0, 'no boundary map entries');
110
+ }
111
+
112
+ console.log('\n=== parseRoadmap: malformed checkbox lines ===');
113
+ {
114
+ // Lines that don't match the expected bold pattern should be skipped
115
+ const content = `# M003: Malformed
116
+
117
+ **Vision:** Test malformed lines.
118
+
119
+ ## Slices
120
+
121
+ - [ ] S01: Missing bold markers \`risk:low\` \`depends:[]\`
122
+ - [x] **S02: Valid Slice** \`risk:medium\` \`depends:[]\`
123
+ > After this: Works.
124
+ - [ ] Not a checkbox at all
125
+ Some random text
126
+ - [x] **S03: Another Valid** \`risk:high\` \`depends:[S02]\`
127
+ > After this: Also works.
128
+ `;
129
+
130
+ const r = parseRoadmap(content);
131
+ // Only S02 and S03 should be parsed (malformed lines without bold markers are skipped)
132
+ assertEq(r.slices.length, 2, 'only valid slices parsed from malformed input');
133
+ assertEq(r.slices[0].id, 'S02', 'first valid slice is S02');
134
+ assertEq(r.slices[0].done, true, 'S02 done');
135
+ assertEq(r.slices[1].id, 'S03', 'second valid slice is S03');
136
+ assertEq(r.slices[1].depends, ['S02'], 'S03 depends on S02');
137
+ }
138
+
139
+ console.log('\n=== parseRoadmap: lowercase vs uppercase X for done ===');
140
+ {
141
+ const content = `# M004: Case Test
142
+
143
+ **Vision:** Test X case sensitivity.
144
+
145
+ ## Slices
146
+
147
+ - [x] **S01: Lowercase x** \`risk:low\` \`depends:[]\`
148
+ > After this: done.
149
+
150
+ - [X] **S02: Uppercase X** \`risk:low\` \`depends:[]\`
151
+ > After this: also done.
152
+
153
+ - [ ] **S03: Not Done** \`risk:low\` \`depends:[]\`
154
+ > After this: not yet.
155
+ `;
156
+
157
+ const r = parseRoadmap(content);
158
+ assertEq(r.slices.length, 3, 'all three slices parsed');
159
+ assertEq(r.slices[0].done, true, 'lowercase x is done');
160
+ assertEq(r.slices[1].done, true, 'uppercase X is done');
161
+ assertEq(r.slices[2].done, false, 'space is not done');
162
+ }
163
+
164
+ console.log('\n=== parseRoadmap: missing boundary map ===');
165
+ {
166
+ const content = `# M005: No Boundary Map
167
+
168
+ **Vision:** A roadmap without a boundary map section.
169
+
170
+ **Success Criteria:**
171
+ - One criterion
172
+
173
+ ---
174
+
175
+ ## Slices
176
+
177
+ - [ ] **S01: Only Slice** \`risk:low\` \`depends:[]\`
178
+ > After this: Done.
179
+ `;
180
+
181
+ const r = parseRoadmap(content);
182
+ assertEq(r.title, 'M005: No Boundary Map', 'title');
183
+ assertEq(r.slices.length, 1, 'one slice');
184
+ assertEq(r.boundaryMap.length, 0, 'empty boundary map when section missing');
185
+ assertEq(r.successCriteria.length, 1, 'one success criterion');
186
+ }
187
+
188
+ console.log('\n=== parseRoadmap: no sections at all ===');
189
+ {
190
+ const content = `# M006: Bare Minimum
191
+
192
+ Just a title and nothing else.
193
+ `;
194
+
195
+ const r = parseRoadmap(content);
196
+ assertEq(r.title, 'M006: Bare Minimum', 'title from bare roadmap');
197
+ assertEq(r.vision, '', 'empty vision');
198
+ assertEq(r.successCriteria.length, 0, 'no success criteria');
199
+ assertEq(r.slices.length, 0, 'no slices');
200
+ assertEq(r.boundaryMap.length, 0, 'no boundary map');
201
+ }
202
+
203
+ console.log('\n=== parseRoadmap: slice with no demo blockquote ===');
204
+ {
205
+ const content = `# M007: No Demo
206
+
207
+ **Vision:** Testing slices without demo lines.
208
+
209
+ ## Slices
210
+
211
+ - [ ] **S01: No Demo Here** \`risk:medium\` \`depends:[]\`
212
+ - [ ] **S02: Also No Demo** \`risk:low\` \`depends:[S01]\`
213
+ `;
214
+
215
+ const r = parseRoadmap(content);
216
+ assertEq(r.slices.length, 2, 'two slices without demos');
217
+ assertEq(r.slices[0].demo, '', 'S01 demo empty');
218
+ assertEq(r.slices[1].demo, '', 'S02 demo empty');
219
+ }
220
+
221
+ console.log('\n=== parseRoadmap: missing risk defaults to low ===');
222
+ {
223
+ const content = `# M008: Default Risk
224
+
225
+ **Vision:** Test default risk.
226
+
227
+ ## Slices
228
+
229
+ - [ ] **S01: No Risk Tag** \`depends:[]\`
230
+ > After this: done.
231
+ `;
232
+
233
+ const r = parseRoadmap(content);
234
+ assertEq(r.slices.length, 1, 'one slice');
235
+ assertEq(r.slices[0].risk, 'low', 'default risk is low');
236
+ }
237
+
238
+ // ═══════════════════════════════════════════════════════════════════════════
239
+ // parsePlan tests
240
+ // ═══════════════════════════════════════════════════════════════════════════
241
+
242
+ console.log('\n=== parsePlan: full plan ===');
243
+ {
244
+ const content = `# S01: Parser Test Suite
245
+
246
+ **Goal:** All 5 parsers have test coverage with edge cases.
247
+ **Demo:** \`node --test tests/parsers.test.ts\` passes with zero failures.
248
+
249
+ ## Must-Haves
250
+
251
+ - parseRoadmap tests cover happy path and edge cases
252
+ - parsePlan tests cover happy path and edge cases
253
+ - All existing tests still pass
254
+
255
+ ## Tasks
256
+
257
+ - [ ] **T01: Test parseRoadmap and parsePlan** \`est:45m\`
258
+ Create tests/parsers.test.ts with comprehensive tests for the two most complex parsers.
259
+
260
+ - [x] **T02: Test parseSummary and parseContinue** \`est:35m\`
261
+ Extend tests/parsers.test.ts with tests for the remaining parsers.
262
+
263
+ ## Files Likely Touched
264
+
265
+ - \`tests/parsers.test.ts\` — new test file
266
+ - \`types.ts\` — add observability_surfaces
267
+ - \`files.ts\` — update parseSummary
268
+ `;
269
+
270
+ const p = parsePlan(content);
271
+
272
+ assertEq(p.id, 'S01', 'plan id');
273
+ assertEq(p.title, 'Parser Test Suite', 'plan title');
274
+ assertEq(p.goal, 'All 5 parsers have test coverage with edge cases.', 'plan goal');
275
+ assertEq(p.demo, '`node --test tests/parsers.test.ts` passes with zero failures.', 'plan demo');
276
+
277
+ // Must-haves
278
+ assertEq(p.mustHaves.length, 3, 'must-have count');
279
+ assertEq(p.mustHaves[0], 'parseRoadmap tests cover happy path and edge cases', 'first must-have');
280
+
281
+ // Tasks
282
+ assertEq(p.tasks.length, 2, 'task count');
283
+
284
+ assertEq(p.tasks[0].id, 'T01', 'T01 id');
285
+ assertEq(p.tasks[0].title, 'Test parseRoadmap and parsePlan', 'T01 title');
286
+ assertEq(p.tasks[0].done, false, 'T01 not done');
287
+ assertTrue(p.tasks[0].description.includes('comprehensive tests'), 'T01 description content');
288
+
289
+ assertEq(p.tasks[1].id, 'T02', 'T02 id');
290
+ assertEq(p.tasks[1].title, 'Test parseSummary and parseContinue', 'T02 title');
291
+ assertEq(p.tasks[1].done, true, 'T02 done');
292
+
293
+ // Files likely touched
294
+ assertEq(p.filesLikelyTouched.length, 3, 'files likely touched count');
295
+ assertTrue(p.filesLikelyTouched[0].includes('tests/parsers.test.ts'), 'first file');
296
+ }
297
+
298
+ console.log('\n=== parsePlan: multi-line task description concatenation ===');
299
+ {
300
+ const content = `# S02: Multi-line Test
301
+
302
+ **Goal:** Test multi-line descriptions.
303
+ **Demo:** Descriptions are concatenated.
304
+
305
+ ## Must-Haves
306
+
307
+ - Multi-line works
308
+
309
+ ## Tasks
310
+
311
+ - [ ] **T01: Multi-line Task** \`est:30m\`
312
+ First line of description.
313
+ Second line of description.
314
+ Third line of description.
315
+
316
+ - [ ] **T02: Single Line** \`est:10m\`
317
+ Just one line.
318
+
319
+ ## Files Likely Touched
320
+
321
+ - \`foo.ts\`
322
+ `;
323
+
324
+ const p = parsePlan(content);
325
+
326
+ assertEq(p.tasks.length, 2, 'two tasks');
327
+ // Multi-line descriptions should be concatenated with spaces
328
+ assertTrue(p.tasks[0].description.includes('First line'), 'T01 desc has first line');
329
+ assertTrue(p.tasks[0].description.includes('Second line'), 'T01 desc has second line');
330
+ assertTrue(p.tasks[0].description.includes('Third line'), 'T01 desc has third line');
331
+ // Verify concatenation with space separator
332
+ assertTrue(p.tasks[0].description.includes('description. Second'), 'lines joined with space');
333
+
334
+ assertEq(p.tasks[1].description, 'Just one line.', 'T02 single-line desc');
335
+ }
336
+
337
+ console.log('\n=== parsePlan: task with missing estimate ===');
338
+ {
339
+ const content = `# S03: No Estimate
340
+
341
+ **Goal:** Handle tasks without estimates.
342
+ **Demo:** Parser doesn't crash.
343
+
344
+ ## Tasks
345
+
346
+ - [ ] **T01: No Estimate Task**
347
+ A task without an estimate backtick.
348
+
349
+ - [ ] **T02: Has Estimate** \`est:20m\`
350
+ This one has an estimate.
351
+ `;
352
+
353
+ const p = parsePlan(content);
354
+
355
+ assertEq(p.tasks.length, 2, 'two tasks parsed');
356
+ assertEq(p.tasks[0].id, 'T01', 'T01 id');
357
+ assertEq(p.tasks[0].title, 'No Estimate Task', 'T01 title without estimate');
358
+ assertEq(p.tasks[0].done, false, 'T01 not done');
359
+ // The estimate backtick text appears in description if present, but parser doesn't crash without it
360
+ assertEq(p.tasks[1].id, 'T02', 'T02 id');
361
+ }
362
+
363
+ console.log('\n=== parsePlan: empty tasks section ===');
364
+ {
365
+ const content = `# S04: Empty Tasks
366
+
367
+ **Goal:** No tasks yet.
368
+ **Demo:** Nothing.
369
+
370
+ ## Must-Haves
371
+
372
+ - Something
373
+
374
+ ## Tasks
375
+
376
+ ## Files Likely Touched
377
+
378
+ - \`nothing.ts\`
379
+ `;
380
+
381
+ const p = parsePlan(content);
382
+
383
+ assertEq(p.id, 'S04', 'plan id with empty tasks');
384
+ assertEq(p.tasks.length, 0, 'no tasks');
385
+ assertEq(p.mustHaves.length, 1, 'one must-have');
386
+ assertEq(p.filesLikelyTouched.length, 1, 'one file');
387
+ }
388
+
389
+ console.log('\n=== parsePlan: no H1 ===');
390
+ {
391
+ const content = `**Goal:** A plan without a heading.
392
+ **Demo:** Still parses.
393
+
394
+ ## Tasks
395
+
396
+ - [ ] **T01: Orphan Task** \`est:5m\`
397
+ A task in a headingless plan.
398
+ `;
399
+
400
+ const p = parsePlan(content);
401
+
402
+ assertEq(p.id, '', 'empty id without H1');
403
+ assertEq(p.title, '', 'empty title without H1');
404
+ assertEq(p.goal, 'A plan without a heading.', 'goal still parsed');
405
+ assertEq(p.tasks.length, 1, 'task still parsed');
406
+ assertEq(p.tasks[0].id, 'T01', 'task id');
407
+ }
408
+
409
+ console.log('\n=== parsePlan: task estimate backtick in description ===');
410
+ {
411
+ // The `est:45m` text appears after the bold closing but before the description lines
412
+ // It should end up as part of the description or be ignored gracefully
413
+ const content = `# S05: Estimate Handling
414
+
415
+ **Goal:** Test estimate text handling.
416
+ **Demo:** Works.
417
+
418
+ ## Tasks
419
+
420
+ - [ ] **T01: With Estimate** \`est:45m\`
421
+ Main description here.
422
+ `;
423
+
424
+ const p = parsePlan(content);
425
+ assertEq(p.tasks.length, 1, 'one task');
426
+ assertEq(p.tasks[0].id, 'T01', 'task id');
427
+ assertEq(p.tasks[0].title, 'With Estimate', 'title excludes estimate');
428
+ // The `est:45m` backtick text after ** is not part of the title or description
429
+ // It's on the same line after the regex match captures, so it's in the remainder
430
+ // The description should be the continuation lines
431
+ assertTrue(p.tasks[0].description.includes('Main description'), 'description from continuation line');
432
+ }
433
+
434
+ console.log('\n=== parsePlan: uppercase X for done ===');
435
+ {
436
+ const content = `# S06: Case Test
437
+
438
+ **Goal:** Test case.
439
+ **Demo:** Works.
440
+
441
+ ## Tasks
442
+
443
+ - [X] **T01: Uppercase Done** \`est:5m\`
444
+ Done with uppercase X.
445
+
446
+ - [x] **T02: Lowercase Done** \`est:5m\`
447
+ Done with lowercase x.
448
+ `;
449
+
450
+ const p = parsePlan(content);
451
+ assertEq(p.tasks[0].done, true, 'uppercase X is done');
452
+ assertEq(p.tasks[1].done, true, 'lowercase x is done');
453
+ }
454
+
455
+ console.log('\n=== parsePlan: no Must-Haves section ===');
456
+ {
457
+ const content = `# S07: No Must-Haves
458
+
459
+ **Goal:** Test missing must-haves.
460
+ **Demo:** Parser handles it.
461
+
462
+ ## Tasks
463
+
464
+ - [ ] **T01: Only Task** \`est:10m\`
465
+ The only task.
466
+ `;
467
+
468
+ const p = parsePlan(content);
469
+ assertEq(p.mustHaves.length, 0, 'empty must-haves');
470
+ assertEq(p.tasks.length, 1, 'task still parsed');
471
+ }
472
+
473
+ console.log('\n=== parsePlan: no Files Likely Touched section ===');
474
+ {
475
+ const content = `# S08: No Files
476
+
477
+ **Goal:** Test missing files section.
478
+ **Demo:** Parser handles it.
479
+
480
+ ## Tasks
481
+
482
+ - [ ] **T01: Task** \`est:10m\`
483
+ Description.
484
+ `;
485
+
486
+ const p = parsePlan(content);
487
+ assertEq(p.filesLikelyTouched.length, 0, 'empty files likely touched');
488
+ }
489
+
490
+ console.log('\n=== parsePlan: old-format task entries (no sublines) ===');
491
+ {
492
+ const content = `# S09: Old Format
493
+
494
+ **Goal:** Test old-format compatibility.
495
+ **Demo:** Parser handles entries without sublines.
496
+
497
+ ## Tasks
498
+
499
+ - [ ] **T01: Classic Task** \`est:10m\`
500
+ Just a plain description with no labeled sublines.
501
+ `;
502
+
503
+ const p = parsePlan(content);
504
+ assertEq(p.tasks.length, 1, 'one task parsed');
505
+ assertEq(p.tasks[0].id, 'T01', 'task id');
506
+ assertEq(p.tasks[0].title, 'Classic Task', 'task title');
507
+ assertEq(p.tasks[0].done, false, 'task not done');
508
+ assertEq(p.tasks[0].files, undefined, 'files is undefined for old-format entry');
509
+ assertEq(p.tasks[0].verify, undefined, 'verify is undefined for old-format entry');
510
+ }
511
+
512
+ console.log('\n=== parsePlan: new-format task entries with Files and Verify sublines ===');
513
+ {
514
+ const content = `# S10: New Format
515
+
516
+ **Goal:** Test new-format subline extraction.
517
+ **Demo:** Parser extracts Files and Verify correctly.
518
+
519
+ ## Tasks
520
+
521
+ - [ ] **T01: Modern Task** \`est:15m\`
522
+ - Why: because we need typed plan entries
523
+ - Files: \`types.ts\`, \`files.ts\`
524
+ - Verify: run the test suite
525
+ `;
526
+
527
+ const p = parsePlan(content);
528
+ assertEq(p.tasks.length, 1, 'one task parsed');
529
+ assertEq(p.tasks[0].id, 'T01', 'task id');
530
+ assertTrue(Array.isArray(p.tasks[0].files), 'files is an array');
531
+ assertEq(p.tasks[0].files!.length, 2, 'files array has two entries');
532
+ assertEq(p.tasks[0].files![0], 'types.ts', 'first file is types.ts');
533
+ assertEq(p.tasks[0].files![1], 'files.ts', 'second file is files.ts');
534
+ assertEq(p.tasks[0].verify, 'run the test suite', 'verify string extracted correctly');
535
+ assertTrue(p.tasks[0].description.includes('Why: because we need typed plan entries'), 'Why line accumulates into description');
536
+ }
537
+
538
+ // ═══════════════════════════════════════════════════════════════════════════
539
+ // parseSummary tests
540
+ // ═══════════════════════════════════════════════════════════════════════════
541
+
542
+ console.log('\n=== parseSummary: full summary with all frontmatter fields ===');
543
+ {
544
+ const content = `---
545
+ id: T01
546
+ parent: S01
547
+ milestone: M001
548
+ provides:
549
+ - parseRoadmap test coverage
550
+ - parsePlan test coverage
551
+ requires:
552
+ - slice: S00
553
+ provides: type definitions
554
+ - slice: S02
555
+ provides: state derivation
556
+ affects:
557
+ - auto-mode dispatch
558
+ key_files:
559
+ - tests/parsers.test.ts
560
+ - files.ts
561
+ key_decisions:
562
+ - Use manual assert pattern
563
+ patterns_established:
564
+ - parsers.test.ts is the canonical test location
565
+ drill_down_paths:
566
+ - tests/parsers.test.ts for assertion details
567
+ observability_surfaces:
568
+ - test pass/fail output from node --test
569
+ - exit code 1 on failure
570
+ duration: 23min
571
+ verification_result: pass
572
+ retries: 0
573
+ completed_at: 2025-03-10T08:00:00Z
574
+ ---
575
+
576
+ # T01: Test parseRoadmap and parsePlan
577
+
578
+ **Created parsers.test.ts with 98 assertions across 16 test groups.**
579
+
580
+ ## What Happened
581
+
582
+ Added comprehensive tests for parseRoadmap and parsePlan.
583
+
584
+ ## Deviations
585
+
586
+ None.
587
+
588
+ ## Files Created/Modified
589
+
590
+ - \`tests/parsers.test.ts\` — new test file with 98 assertions
591
+ - \`types.ts\` — added observability_surfaces field
592
+ - \`files.ts\` — updated parseSummary extraction
593
+ `;
594
+
595
+ const s = parseSummary(content);
596
+
597
+ // Frontmatter fields
598
+ assertEq(s.frontmatter.id, 'T01', 'summary id');
599
+ assertEq(s.frontmatter.parent, 'S01', 'summary parent');
600
+ assertEq(s.frontmatter.milestone, 'M001', 'summary milestone');
601
+ assertEq(s.frontmatter.provides.length, 2, 'provides count');
602
+ assertEq(s.frontmatter.provides[0], 'parseRoadmap test coverage', 'first provides');
603
+ assertEq(s.frontmatter.provides[1], 'parsePlan test coverage', 'second provides');
604
+
605
+ // requires (nested objects)
606
+ assertEq(s.frontmatter.requires.length, 2, 'requires count');
607
+ assertEq(s.frontmatter.requires[0].slice, 'S00', 'first requires slice');
608
+ assertEq(s.frontmatter.requires[0].provides, 'type definitions', 'first requires provides');
609
+ assertEq(s.frontmatter.requires[1].slice, 'S02', 'second requires slice');
610
+ assertEq(s.frontmatter.requires[1].provides, 'state derivation', 'second requires provides');
611
+
612
+ assertEq(s.frontmatter.affects.length, 1, 'affects count');
613
+ assertEq(s.frontmatter.affects[0], 'auto-mode dispatch', 'affects value');
614
+ assertEq(s.frontmatter.key_files.length, 2, 'key_files count');
615
+ assertEq(s.frontmatter.key_decisions.length, 1, 'key_decisions count');
616
+ assertEq(s.frontmatter.patterns_established.length, 1, 'patterns_established count');
617
+ assertEq(s.frontmatter.drill_down_paths.length, 1, 'drill_down_paths count');
618
+
619
+ // observability_surfaces extraction
620
+ assertEq(s.frontmatter.observability_surfaces.length, 2, 'observability_surfaces count');
621
+ assertEq(s.frontmatter.observability_surfaces[0], 'test pass/fail output from node --test', 'first observability surface');
622
+ assertEq(s.frontmatter.observability_surfaces[1], 'exit code 1 on failure', 'second observability surface');
623
+
624
+ assertEq(s.frontmatter.duration, '23min', 'duration');
625
+ assertEq(s.frontmatter.verification_result, 'pass', 'verification_result');
626
+ assertEq(s.frontmatter.completed_at, '2025-03-10T08:00:00Z', 'completed_at');
627
+
628
+ // Body fields
629
+ assertEq(s.title, 'T01: Test parseRoadmap and parsePlan', 'summary title');
630
+ assertEq(s.oneLiner, 'Created parsers.test.ts with 98 assertions across 16 test groups.', 'one-liner');
631
+ assertTrue(s.whatHappened.includes('comprehensive tests'), 'whatHappened content');
632
+ assertEq(s.deviations, 'None.', 'deviations');
633
+
634
+ // Files modified
635
+ assertEq(s.filesModified.length, 3, 'filesModified count');
636
+ assertEq(s.filesModified[0].path, 'tests/parsers.test.ts', 'first file path');
637
+ assertTrue(s.filesModified[0].description.includes('98 assertions'), 'first file description');
638
+ assertEq(s.filesModified[1].path, 'types.ts', 'second file path');
639
+ assertEq(s.filesModified[2].path, 'files.ts', 'third file path');
640
+ }
641
+
642
+ console.log('\n=== parseSummary: one-liner extraction (bold-wrapped line after H1) ===');
643
+ {
644
+ const content = `# S01: Parser Test Suite
645
+
646
+ **All 5 parsers have test coverage with edge cases.**
647
+
648
+ ## What Happened
649
+
650
+ Things happened.
651
+ `;
652
+
653
+ const s = parseSummary(content);
654
+ assertEq(s.title, 'S01: Parser Test Suite', 'title');
655
+ assertEq(s.oneLiner, 'All 5 parsers have test coverage with edge cases.', 'bold one-liner');
656
+ }
657
+
658
+ console.log('\n=== parseSummary: non-bold paragraph after H1 (empty one-liner) ===');
659
+ {
660
+ const content = `# T02: Some Task
661
+
662
+ This is just a regular paragraph, not bold.
663
+
664
+ ## What Happened
665
+
666
+ Did stuff.
667
+ `;
668
+
669
+ const s = parseSummary(content);
670
+ assertEq(s.title, 'T02: Some Task', 'title');
671
+ assertEq(s.oneLiner, '', 'non-bold line results in empty one-liner');
672
+ }
673
+
674
+ console.log('\n=== parseSummary: files-modified parsing (backtick path — description format) ===');
675
+ {
676
+ const content = `# T03: File Changes
677
+
678
+ **One-liner.**
679
+
680
+ ## Files Created/Modified
681
+
682
+ - \`src/index.ts\` — main entry point
683
+ - \`src/utils.ts\` — utility functions
684
+ - \`README.md\` — updated docs
685
+ `;
686
+
687
+ const s = parseSummary(content);
688
+ assertEq(s.filesModified.length, 3, 'three files');
689
+ assertEq(s.filesModified[0].path, 'src/index.ts', 'first path');
690
+ assertEq(s.filesModified[0].description, 'main entry point', 'first description');
691
+ assertEq(s.filesModified[1].path, 'src/utils.ts', 'second path');
692
+ assertEq(s.filesModified[2].path, 'README.md', 'third path');
693
+ }
694
+
695
+ console.log('\n=== parseSummary: missing frontmatter (safe defaults) ===');
696
+ {
697
+ const content = `# T04: No Frontmatter
698
+
699
+ **Did something.**
700
+
701
+ ## What Happened
702
+
703
+ No frontmatter at all.
704
+ `;
705
+
706
+ const s = parseSummary(content);
707
+ assertEq(s.frontmatter.id, '', 'default id empty');
708
+ assertEq(s.frontmatter.parent, '', 'default parent empty');
709
+ assertEq(s.frontmatter.milestone, '', 'default milestone empty');
710
+ assertEq(s.frontmatter.provides.length, 0, 'default provides empty');
711
+ assertEq(s.frontmatter.requires.length, 0, 'default requires empty');
712
+ assertEq(s.frontmatter.affects.length, 0, 'default affects empty');
713
+ assertEq(s.frontmatter.key_files.length, 0, 'default key_files empty');
714
+ assertEq(s.frontmatter.key_decisions.length, 0, 'default key_decisions empty');
715
+ assertEq(s.frontmatter.patterns_established.length, 0, 'default patterns_established empty');
716
+ assertEq(s.frontmatter.drill_down_paths.length, 0, 'default drill_down_paths empty');
717
+ assertEq(s.frontmatter.observability_surfaces.length, 0, 'default observability_surfaces empty');
718
+ assertEq(s.frontmatter.duration, '', 'default duration empty');
719
+ assertEq(s.frontmatter.verification_result, 'untested', 'default verification_result');
720
+ assertEq(s.frontmatter.completed_at, '', 'default completed_at empty');
721
+ assertEq(s.title, 'T04: No Frontmatter', 'title still parsed');
722
+ assertEq(s.oneLiner, 'Did something.', 'one-liner still parsed');
723
+ }
724
+
725
+ console.log('\n=== parseSummary: empty body ===');
726
+ {
727
+ const content = `---
728
+ id: T05
729
+ parent: S01
730
+ milestone: M001
731
+ ---
732
+ `;
733
+
734
+ const s = parseSummary(content);
735
+ assertEq(s.frontmatter.id, 'T05', 'id from frontmatter');
736
+ assertEq(s.title, '', 'empty title');
737
+ assertEq(s.oneLiner, '', 'empty one-liner');
738
+ assertEq(s.whatHappened, '', 'empty whatHappened');
739
+ assertEq(s.deviations, '', 'empty deviations');
740
+ assertEq(s.filesModified.length, 0, 'no files modified');
741
+ }
742
+
743
+ console.log('\n=== parseSummary: summary with requires array (nested objects) ===');
744
+ {
745
+ const content = `---
746
+ id: T06
747
+ parent: S02
748
+ milestone: M001
749
+ requires:
750
+ - slice: S01
751
+ provides: parser functions
752
+ - slice: S00
753
+ provides: core types
754
+ - slice: S03
755
+ provides: state engine
756
+ provides: []
757
+ affects: []
758
+ key_files: []
759
+ key_decisions: []
760
+ patterns_established: []
761
+ drill_down_paths: []
762
+ observability_surfaces: []
763
+ duration: 10min
764
+ verification_result: pass
765
+ retries: 1
766
+ completed_at: 2025-03-10T09:00:00Z
767
+ ---
768
+
769
+ # T06: Nested Requires
770
+
771
+ **Test nested requires parsing.**
772
+
773
+ ## What Happened
774
+
775
+ Tested.
776
+ `;
777
+
778
+ const s = parseSummary(content);
779
+ assertEq(s.frontmatter.requires.length, 3, 'three requires entries');
780
+ assertEq(s.frontmatter.requires[0].slice, 'S01', 'first requires slice');
781
+ assertEq(s.frontmatter.requires[0].provides, 'parser functions', 'first requires provides');
782
+ assertEq(s.frontmatter.requires[1].slice, 'S00', 'second requires slice');
783
+ assertEq(s.frontmatter.requires[2].slice, 'S03', 'third requires slice');
784
+ assertEq(s.frontmatter.requires[2].provides, 'state engine', 'third requires provides');
785
+ }
786
+
787
+ // ═══════════════════════════════════════════════════════════════════════════
788
+ // parseContinue tests
789
+ // ═══════════════════════════════════════════════════════════════════════════
790
+
791
+ console.log('\n=== parseContinue: full continue file with all frontmatter fields ===');
792
+ {
793
+ const content = `---
794
+ milestone: M001
795
+ slice: S01
796
+ task: T02
797
+ step: 3
798
+ total_steps: 5
799
+ status: in_progress
800
+ saved_at: 2025-03-10T08:30:00Z
801
+ ---
802
+
803
+ ## Completed Work
804
+
805
+ Steps 1-3 are done. Created test file and wrote assertions.
806
+
807
+ ## Remaining Work
808
+
809
+ Steps 4-5: run tests and check regressions.
810
+
811
+ ## Decisions Made
812
+
813
+ Used manual assert pattern instead of node:assert.
814
+
815
+ ## Context
816
+
817
+ Working in the gsd-s01 worktree. All imports use .ts extensions.
818
+
819
+ ## Next Action
820
+
821
+ Run the full test suite with node --test.
822
+ `;
823
+
824
+ const c = parseContinue(content);
825
+
826
+ // Frontmatter
827
+ assertEq(c.frontmatter.milestone, 'M001', 'continue milestone');
828
+ assertEq(c.frontmatter.slice, 'S01', 'continue slice');
829
+ assertEq(c.frontmatter.task, 'T02', 'continue task');
830
+ assertEq(c.frontmatter.step, 3, 'continue step');
831
+ assertEq(c.frontmatter.totalSteps, 5, 'continue totalSteps');
832
+ assertEq(c.frontmatter.status, 'in_progress', 'continue status');
833
+ assertEq(c.frontmatter.savedAt, '2025-03-10T08:30:00Z', 'continue savedAt');
834
+
835
+ // Body sections
836
+ assertTrue(c.completedWork.includes('Steps 1-3 are done'), 'completedWork content');
837
+ assertTrue(c.remainingWork.includes('Steps 4-5'), 'remainingWork content');
838
+ assertTrue(c.decisions.includes('manual assert pattern'), 'decisions content');
839
+ assertTrue(c.context.includes('gsd-s01 worktree'), 'context content');
840
+ assertTrue(c.nextAction.includes('node --test'), 'nextAction content');
841
+ }
842
+
843
+ console.log('\n=== parseContinue: string step/totalSteps parsed as integers ===');
844
+ {
845
+ const content = `---
846
+ milestone: M002
847
+ slice: S03
848
+ task: T01
849
+ step: 7
850
+ total_steps: 12
851
+ status: in_progress
852
+ saved_at: 2025-03-10T10:00:00Z
853
+ ---
854
+
855
+ ## Completed Work
856
+
857
+ Some work.
858
+
859
+ ## Remaining Work
860
+
861
+ More work.
862
+
863
+ ## Decisions Made
864
+
865
+ None.
866
+
867
+ ## Context
868
+
869
+ None.
870
+
871
+ ## Next Action
872
+
873
+ Continue.
874
+ `;
875
+
876
+ const c = parseContinue(content);
877
+ assertEq(c.frontmatter.step, 7, 'step parsed as integer 7');
878
+ assertEq(c.frontmatter.totalSteps, 12, 'totalSteps parsed as integer 12');
879
+ assertEq(typeof c.frontmatter.step, 'number', 'step is number type');
880
+ assertEq(typeof c.frontmatter.totalSteps, 'number', 'totalSteps is number type');
881
+ }
882
+
883
+ console.log('\n=== parseContinue: NaN step values (non-numeric strings) ===');
884
+ {
885
+ const content = `---
886
+ milestone: M001
887
+ slice: S01
888
+ task: T01
889
+ step: abc
890
+ total_steps: xyz
891
+ status: in_progress
892
+ saved_at: 2025-03-10T10:00:00Z
893
+ ---
894
+
895
+ ## Completed Work
896
+
897
+ Work.
898
+
899
+ ## Remaining Work
900
+
901
+ Work.
902
+
903
+ ## Decisions Made
904
+
905
+ None.
906
+
907
+ ## Context
908
+
909
+ None.
910
+
911
+ ## Next Action
912
+
913
+ Do things.
914
+ `;
915
+
916
+ const c = parseContinue(content);
917
+ // parseInt("abc") returns NaN; the parser || 0 fallback should give 0
918
+ // Actually, looking at parser: typeof fm.step === 'string' ? parseInt(fm.step) : ...
919
+ // parseInt("abc") = NaN, and NaN || 0 doesn't work because NaN is falsy only in boolean context
920
+ // But the parser uses: typeof fm.step === 'string' ? parseInt(fm.step) : (fm.step as number) || 0
921
+ // parseInt returns NaN which is a number, not 0 — let's verify
922
+ const stepIsNaN = Number.isNaN(c.frontmatter.step);
923
+ const totalIsNaN = Number.isNaN(c.frontmatter.totalSteps);
924
+ // The parser does parseInt which returns NaN for non-numeric strings
925
+ // There's no || 0 fallback on the parseInt path, so NaN is expected
926
+ assertTrue(stepIsNaN, 'NaN step when non-numeric string');
927
+ assertTrue(totalIsNaN, 'NaN totalSteps when non-numeric string');
928
+ }
929
+
930
+ console.log('\n=== parseContinue: all three status variants ===');
931
+ {
932
+ for (const status of ['in_progress', 'interrupted', 'compacted'] as const) {
933
+ const content = `---
934
+ milestone: M001
935
+ slice: S01
936
+ task: T01
937
+ step: 1
938
+ total_steps: 3
939
+ status: ${status}
940
+ saved_at: 2025-03-10T10:00:00Z
941
+ ---
942
+
943
+ ## Completed Work
944
+
945
+ Work.
946
+ `;
947
+
948
+ const c = parseContinue(content);
949
+ assertEq(c.frontmatter.status, status, `status variant: ${status}`);
950
+ }
951
+ }
952
+
953
+ console.log('\n=== parseContinue: missing frontmatter ===');
954
+ {
955
+ const content = `## Completed Work
956
+
957
+ Some work done.
958
+
959
+ ## Remaining Work
960
+
961
+ More to do.
962
+
963
+ ## Decisions Made
964
+
965
+ A decision.
966
+
967
+ ## Context
968
+
969
+ Some context.
970
+
971
+ ## Next Action
972
+
973
+ Next thing.
974
+ `;
975
+
976
+ const c = parseContinue(content);
977
+ assertEq(c.frontmatter.milestone, '', 'default milestone empty');
978
+ assertEq(c.frontmatter.slice, '', 'default slice empty');
979
+ assertEq(c.frontmatter.task, '', 'default task empty');
980
+ assertEq(c.frontmatter.step, 0, 'default step 0');
981
+ assertEq(c.frontmatter.totalSteps, 0, 'default totalSteps 0');
982
+ assertEq(c.frontmatter.status, 'in_progress', 'default status in_progress');
983
+ assertEq(c.frontmatter.savedAt, '', 'default savedAt empty');
984
+
985
+ // Body sections still parse
986
+ assertTrue(c.completedWork.includes('Some work done'), 'completedWork without frontmatter');
987
+ assertTrue(c.remainingWork.includes('More to do'), 'remainingWork without frontmatter');
988
+ assertTrue(c.decisions.includes('A decision'), 'decisions without frontmatter');
989
+ assertTrue(c.context.includes('Some context'), 'context without frontmatter');
990
+ assertTrue(c.nextAction.includes('Next thing'), 'nextAction without frontmatter');
991
+ }
992
+
993
+ console.log('\n=== parseContinue: body section extraction ===');
994
+ {
995
+ const content = `---
996
+ milestone: M001
997
+ slice: S01
998
+ task: T03
999
+ step: 2
1000
+ total_steps: 4
1001
+ status: interrupted
1002
+ saved_at: 2025-03-10T11:00:00Z
1003
+ ---
1004
+
1005
+ ## Completed Work
1006
+
1007
+ First paragraph of completed work.
1008
+ Second paragraph continuing the explanation.
1009
+
1010
+ ## Remaining Work
1011
+
1012
+ Need to finish step 3 and step 4.
1013
+
1014
+ ## Decisions Made
1015
+
1016
+ Decided to use approach A over approach B because of performance.
1017
+
1018
+ ## Context
1019
+
1020
+ Running in worktree. Node 22 required. TypeScript strict mode.
1021
+
1022
+ ## Next Action
1023
+
1024
+ Pick up at step 3: run the integration tests.
1025
+ `;
1026
+
1027
+ const c = parseContinue(content);
1028
+ assertTrue(c.completedWork.includes('First paragraph'), 'completedWork first paragraph');
1029
+ assertTrue(c.completedWork.includes('Second paragraph'), 'completedWork second paragraph');
1030
+ assertTrue(c.remainingWork.includes('step 3 and step 4'), 'remainingWork detail');
1031
+ assertTrue(c.decisions.includes('approach A over approach B'), 'decisions detail');
1032
+ assertTrue(c.context.includes('Node 22 required'), 'context detail');
1033
+ assertTrue(c.nextAction.includes('step 3: run the integration tests'), 'nextAction detail');
1034
+ }
1035
+
1036
+ console.log('\n=== parseContinue: total_steps vs totalSteps key support ===');
1037
+ {
1038
+ // Test total_steps (snake_case) — the primary format
1039
+ const content1 = `---
1040
+ milestone: M001
1041
+ slice: S01
1042
+ task: T01
1043
+ step: 2
1044
+ total_steps: 8
1045
+ status: in_progress
1046
+ saved_at: 2025-03-10T12:00:00Z
1047
+ ---
1048
+
1049
+ ## Completed Work
1050
+
1051
+ Work.
1052
+ `;
1053
+
1054
+ const c1 = parseContinue(content1);
1055
+ assertEq(c1.frontmatter.totalSteps, 8, 'total_steps snake_case works');
1056
+
1057
+ // Test totalSteps (camelCase) — the fallback
1058
+ const content2 = `---
1059
+ milestone: M001
1060
+ slice: S01
1061
+ task: T01
1062
+ step: 2
1063
+ totalSteps: 6
1064
+ status: in_progress
1065
+ saved_at: 2025-03-10T12:00:00Z
1066
+ ---
1067
+
1068
+ ## Completed Work
1069
+
1070
+ Work.
1071
+ `;
1072
+
1073
+ const c2 = parseContinue(content2);
1074
+ assertEq(c2.frontmatter.totalSteps, 6, 'totalSteps camelCase works');
1075
+ }
1076
+
1077
+ // ═══════════════════════════════════════════════════════════════════════════
1078
+ // parseRequirementCounts tests
1079
+ // ═══════════════════════════════════════════════════════════════════════════
1080
+
1081
+ console.log('\n=== parseRequirementCounts: full requirements file ===');
1082
+ {
1083
+ const content = `# Requirements
1084
+
1085
+ ## Active
1086
+
1087
+ ### R001 — User authentication
1088
+ - Status: active
1089
+
1090
+ ### R002 — Dashboard rendering
1091
+ - Status: blocked
1092
+
1093
+ ### R003 — API rate limiting
1094
+ - Status: active
1095
+
1096
+ ## Validated
1097
+
1098
+ ### R010 — Parser test coverage
1099
+ - Status: validated
1100
+
1101
+ ### R011 — Type system
1102
+ - Status: validated
1103
+
1104
+ ## Deferred
1105
+
1106
+ ### R020 — Admin panel
1107
+ - Status: deferred
1108
+
1109
+ ## Out of Scope
1110
+
1111
+ ### R030 — Mobile app
1112
+ - Status: out-of-scope
1113
+
1114
+ ### R031 — Desktop app
1115
+ - Status: out-of-scope
1116
+ `;
1117
+
1118
+ const counts = parseRequirementCounts(content);
1119
+ assertEq(counts.active, 3, 'active count');
1120
+ assertEq(counts.validated, 2, 'validated count');
1121
+ assertEq(counts.deferred, 1, 'deferred count');
1122
+ assertEq(counts.outOfScope, 2, 'outOfScope count');
1123
+ assertEq(counts.blocked, 1, 'blocked count');
1124
+ assertEq(counts.total, 8, 'total is sum of active+validated+deferred+outOfScope');
1125
+ }
1126
+
1127
+ console.log('\n=== parseRequirementCounts: null input returns all zeros ===');
1128
+ {
1129
+ const counts = parseRequirementCounts(null);
1130
+ assertEq(counts.active, 0, 'null active');
1131
+ assertEq(counts.validated, 0, 'null validated');
1132
+ assertEq(counts.deferred, 0, 'null deferred');
1133
+ assertEq(counts.outOfScope, 0, 'null outOfScope');
1134
+ assertEq(counts.blocked, 0, 'null blocked');
1135
+ assertEq(counts.total, 0, 'null total');
1136
+ }
1137
+
1138
+ console.log('\n=== parseRequirementCounts: empty sections return zero counts ===');
1139
+ {
1140
+ const content = `# Requirements
1141
+
1142
+ ## Active
1143
+
1144
+ ## Validated
1145
+
1146
+ ## Deferred
1147
+
1148
+ ## Out of Scope
1149
+ `;
1150
+
1151
+ const counts = parseRequirementCounts(content);
1152
+ assertEq(counts.active, 0, 'empty active');
1153
+ assertEq(counts.validated, 0, 'empty validated');
1154
+ assertEq(counts.deferred, 0, 'empty deferred');
1155
+ assertEq(counts.outOfScope, 0, 'empty outOfScope');
1156
+ assertEq(counts.blocked, 0, 'empty blocked');
1157
+ assertEq(counts.total, 0, 'empty total');
1158
+ }
1159
+
1160
+ console.log('\n=== parseRequirementCounts: blocked status counting ===');
1161
+ {
1162
+ const content = `# Requirements
1163
+
1164
+ ## Active
1165
+
1166
+ ### R001 — Blocked thing
1167
+ - Status: blocked
1168
+
1169
+ ### R002 — Another blocked thing
1170
+ - Status: blocked
1171
+
1172
+ ### R003 — Active thing
1173
+ - Status: active
1174
+
1175
+ ## Validated
1176
+
1177
+ ## Deferred
1178
+
1179
+ ### R020 — Blocked deferred
1180
+ - Status: blocked
1181
+
1182
+ ## Out of Scope
1183
+ `;
1184
+
1185
+ const counts = parseRequirementCounts(content);
1186
+ assertEq(counts.active, 3, 'active includes blocked items in Active section');
1187
+ assertEq(counts.blocked, 3, 'blocked counts all blocked statuses across sections');
1188
+ assertEq(counts.deferred, 1, 'deferred section count');
1189
+ }
1190
+
1191
+ console.log('\n=== parseRequirementCounts: total is sum of all section counts ===');
1192
+ {
1193
+ const content = `# Requirements
1194
+
1195
+ ## Active
1196
+
1197
+ ### R001 — One
1198
+ - Status: active
1199
+
1200
+ ## Validated
1201
+
1202
+ ### R010 — Two
1203
+ - Status: validated
1204
+
1205
+ ### R011 — Three
1206
+ - Status: validated
1207
+
1208
+ ## Deferred
1209
+
1210
+ ### R020 — Four
1211
+ - Status: deferred
1212
+
1213
+ ### R021 — Five
1214
+ - Status: deferred
1215
+
1216
+ ### R022 — Six
1217
+ - Status: deferred
1218
+
1219
+ ## Out of Scope
1220
+
1221
+ ### R030 — Seven
1222
+ - Status: out-of-scope
1223
+ `;
1224
+
1225
+ const counts = parseRequirementCounts(content);
1226
+ assertEq(counts.active, 1, 'one active');
1227
+ assertEq(counts.validated, 2, 'two validated');
1228
+ assertEq(counts.deferred, 3, 'three deferred');
1229
+ assertEq(counts.outOfScope, 1, 'one outOfScope');
1230
+ assertEq(counts.total, 7, 'total = 1 + 2 + 3 + 1');
1231
+ assertEq(counts.total, counts.active + counts.validated + counts.deferred + counts.outOfScope, 'total is exact sum');
1232
+ }
1233
+
1234
+ // ═══════════════════════════════════════════════════════════════════════════
1235
+ // parseSecretsManifest / formatSecretsManifest tests
1236
+ // ═══════════════════════════════════════════════════════════════════════════
1237
+
1238
+ console.log('\n=== parseSecretsManifest: full manifest with 3 keys ===');
1239
+ {
1240
+ const content = `# Secrets Manifest
1241
+
1242
+ **Milestone:** M003
1243
+ **Generated:** 2025-06-15T10:00:00Z
1244
+
1245
+ ### OPENAI_API_KEY
1246
+
1247
+ **Service:** OpenAI
1248
+ **Dashboard:** https://platform.openai.com/api-keys
1249
+ **Format hint:** starts with sk-
1250
+ **Status:** pending
1251
+ **Destination:** dotenv
1252
+
1253
+ 1. Go to https://platform.openai.com/api-keys
1254
+ 2. Click "Create new secret key"
1255
+ 3. Copy the key immediately — it won't be shown again
1256
+
1257
+ ### STRIPE_SECRET_KEY
1258
+
1259
+ **Service:** Stripe
1260
+ **Dashboard:** https://dashboard.stripe.com/apikeys
1261
+ **Format hint:** starts with sk_test_ or sk_live_
1262
+ **Status:** collected
1263
+ **Destination:** dotenv
1264
+
1265
+ 1. Go to https://dashboard.stripe.com/apikeys
1266
+ 2. Reveal the secret key
1267
+ 3. Copy it
1268
+
1269
+ ### SUPABASE_URL
1270
+
1271
+ **Service:** Supabase
1272
+ **Dashboard:** https://app.supabase.com/project/settings/api
1273
+ **Format hint:** https://<project-ref>.supabase.co
1274
+ **Status:** skipped
1275
+ **Destination:** vercel
1276
+
1277
+ 1. Go to project settings in Supabase
1278
+ 2. Copy the URL from the API section
1279
+ `;
1280
+
1281
+ const m = parseSecretsManifest(content);
1282
+
1283
+ assertEq(m.milestone, 'M003', 'manifest milestone');
1284
+ assertEq(m.generatedAt, '2025-06-15T10:00:00Z', 'manifest generatedAt');
1285
+ assertEq(m.entries.length, 3, 'three entries');
1286
+
1287
+ // First entry
1288
+ assertEq(m.entries[0].key, 'OPENAI_API_KEY', 'entry 0 key');
1289
+ assertEq(m.entries[0].service, 'OpenAI', 'entry 0 service');
1290
+ assertEq(m.entries[0].dashboardUrl, 'https://platform.openai.com/api-keys', 'entry 0 dashboardUrl');
1291
+ assertEq(m.entries[0].formatHint, 'starts with sk-', 'entry 0 formatHint');
1292
+ assertEq(m.entries[0].status, 'pending', 'entry 0 status');
1293
+ assertEq(m.entries[0].destination, 'dotenv', 'entry 0 destination');
1294
+ assertEq(m.entries[0].guidance.length, 3, 'entry 0 guidance count');
1295
+ assertEq(m.entries[0].guidance[0], 'Go to https://platform.openai.com/api-keys', 'entry 0 guidance[0]');
1296
+ assertEq(m.entries[0].guidance[2], 'Copy the key immediately — it won\'t be shown again', 'entry 0 guidance[2]');
1297
+
1298
+ // Second entry
1299
+ assertEq(m.entries[1].key, 'STRIPE_SECRET_KEY', 'entry 1 key');
1300
+ assertEq(m.entries[1].service, 'Stripe', 'entry 1 service');
1301
+ assertEq(m.entries[1].status, 'collected', 'entry 1 status');
1302
+ assertEq(m.entries[1].formatHint, 'starts with sk_test_ or sk_live_', 'entry 1 formatHint');
1303
+ assertEq(m.entries[1].guidance.length, 3, 'entry 1 guidance count');
1304
+
1305
+ // Third entry
1306
+ assertEq(m.entries[2].key, 'SUPABASE_URL', 'entry 2 key');
1307
+ assertEq(m.entries[2].status, 'skipped', 'entry 2 status');
1308
+ assertEq(m.entries[2].destination, 'vercel', 'entry 2 destination');
1309
+ assertEq(m.entries[2].guidance.length, 2, 'entry 2 guidance count');
1310
+ }
1311
+
1312
+ console.log('\n=== parseSecretsManifest: single-key manifest ===');
1313
+ {
1314
+ const content = `# Secrets Manifest
1315
+
1316
+ **Milestone:** M001
1317
+ **Generated:** 2025-06-15T12:00:00Z
1318
+
1319
+ ### DATABASE_URL
1320
+
1321
+ **Service:** PostgreSQL
1322
+ **Dashboard:** https://console.neon.tech
1323
+ **Format hint:** postgresql://...
1324
+ **Status:** pending
1325
+ **Destination:** dotenv
1326
+
1327
+ 1. Create a database on Neon
1328
+ 2. Copy the connection string
1329
+ `;
1330
+
1331
+ const m = parseSecretsManifest(content);
1332
+ assertEq(m.milestone, 'M001', 'single-key milestone');
1333
+ assertEq(m.entries.length, 1, 'single entry');
1334
+ assertEq(m.entries[0].key, 'DATABASE_URL', 'single entry key');
1335
+ assertEq(m.entries[0].service, 'PostgreSQL', 'single entry service');
1336
+ assertEq(m.entries[0].guidance.length, 2, 'single entry guidance count');
1337
+ }
1338
+
1339
+ console.log('\n=== parseSecretsManifest: empty/no-secrets manifest ===');
1340
+ {
1341
+ const content = `# Secrets Manifest
1342
+
1343
+ **Milestone:** M002
1344
+ **Generated:** 2025-06-15T14:00:00Z
1345
+ `;
1346
+
1347
+ const m = parseSecretsManifest(content);
1348
+ assertEq(m.milestone, 'M002', 'empty manifest milestone');
1349
+ assertEq(m.generatedAt, '2025-06-15T14:00:00Z', 'empty manifest generatedAt');
1350
+ assertEq(m.entries.length, 0, 'no entries in empty manifest');
1351
+ }
1352
+
1353
+ console.log('\n=== parseSecretsManifest: missing optional fields default correctly ===');
1354
+ {
1355
+ const content = `# Secrets Manifest
1356
+
1357
+ **Milestone:** M004
1358
+ **Generated:** 2025-06-15T16:00:00Z
1359
+
1360
+ ### SOME_API_KEY
1361
+
1362
+ **Service:** SomeService
1363
+
1364
+ 1. Get the key from the dashboard
1365
+ `;
1366
+
1367
+ const m = parseSecretsManifest(content);
1368
+ assertEq(m.entries.length, 1, 'one entry with missing fields');
1369
+ assertEq(m.entries[0].key, 'SOME_API_KEY', 'key parsed');
1370
+ assertEq(m.entries[0].service, 'SomeService', 'service parsed');
1371
+ assertEq(m.entries[0].dashboardUrl, '', 'missing dashboardUrl defaults to empty string');
1372
+ assertEq(m.entries[0].formatHint, '', 'missing formatHint defaults to empty string');
1373
+ assertEq(m.entries[0].status, 'pending', 'missing status defaults to pending');
1374
+ assertEq(m.entries[0].destination, 'dotenv', 'missing destination defaults to dotenv');
1375
+ assertEq(m.entries[0].guidance.length, 1, 'guidance still parsed');
1376
+ }
1377
+
1378
+ console.log('\n=== parseSecretsManifest: all three status values parse ===');
1379
+ {
1380
+ for (const status of ['pending', 'collected', 'skipped'] as const) {
1381
+ const content = `# Secrets Manifest
1382
+
1383
+ **Milestone:** M005
1384
+ **Generated:** 2025-06-15T18:00:00Z
1385
+
1386
+ ### TEST_KEY
1387
+
1388
+ **Service:** TestService
1389
+ **Status:** ${status}
1390
+
1391
+ 1. Do something
1392
+ `;
1393
+
1394
+ const m = parseSecretsManifest(content);
1395
+ assertEq(m.entries[0].status, status, `status variant: ${status}`);
1396
+ }
1397
+ }
1398
+
1399
+ console.log('\n=== parseSecretsManifest: invalid status defaults to pending ===');
1400
+ {
1401
+ const content = `# Secrets Manifest
1402
+
1403
+ **Milestone:** M006
1404
+ **Generated:** 2025-06-15T20:00:00Z
1405
+
1406
+ ### BAD_STATUS_KEY
1407
+
1408
+ **Service:** TestService
1409
+ **Status:** invalid_value
1410
+
1411
+ 1. Some step
1412
+ `;
1413
+
1414
+ const m = parseSecretsManifest(content);
1415
+ assertEq(m.entries[0].status, 'pending', 'invalid status defaults to pending');
1416
+ }
1417
+
1418
+ console.log('\n=== parseSecretsManifest + formatSecretsManifest: round-trip ===');
1419
+ {
1420
+ const original = `# Secrets Manifest
1421
+
1422
+ **Milestone:** M007
1423
+ **Generated:** 2025-06-16T10:00:00Z
1424
+
1425
+ ### OPENAI_API_KEY
1426
+
1427
+ **Service:** OpenAI
1428
+ **Dashboard:** https://platform.openai.com/api-keys
1429
+ **Format hint:** starts with sk-
1430
+ **Status:** pending
1431
+ **Destination:** dotenv
1432
+
1433
+ 1. Go to the API keys page
1434
+ 2. Create a new key
1435
+ 3. Copy it
1436
+
1437
+ ### REDIS_URL
1438
+
1439
+ **Service:** Upstash
1440
+ **Dashboard:** https://console.upstash.com
1441
+ **Format hint:** redis://...
1442
+ **Status:** collected
1443
+ **Destination:** vercel
1444
+
1445
+ 1. Open Upstash console
1446
+ 2. Copy the Redis URL
1447
+ `;
1448
+
1449
+ const parsed1 = parseSecretsManifest(original);
1450
+ const formatted = formatSecretsManifest(parsed1);
1451
+ const parsed2 = parseSecretsManifest(formatted);
1452
+
1453
+ // Verify semantic equality after round-trip
1454
+ assertEq(parsed2.milestone, parsed1.milestone, 'round-trip milestone');
1455
+ assertEq(parsed2.generatedAt, parsed1.generatedAt, 'round-trip generatedAt');
1456
+ assertEq(parsed2.entries.length, parsed1.entries.length, 'round-trip entry count');
1457
+
1458
+ for (let i = 0; i < parsed1.entries.length; i++) {
1459
+ const e1 = parsed1.entries[i];
1460
+ const e2 = parsed2.entries[i];
1461
+ assertEq(e2.key, e1.key, `round-trip entry ${i} key`);
1462
+ assertEq(e2.service, e1.service, `round-trip entry ${i} service`);
1463
+ assertEq(e2.dashboardUrl, e1.dashboardUrl, `round-trip entry ${i} dashboardUrl`);
1464
+ assertEq(e2.formatHint, e1.formatHint, `round-trip entry ${i} formatHint`);
1465
+ assertEq(e2.status, e1.status, `round-trip entry ${i} status`);
1466
+ assertEq(e2.destination, e1.destination, `round-trip entry ${i} destination`);
1467
+ assertEq(e2.guidance.length, e1.guidance.length, `round-trip entry ${i} guidance length`);
1468
+ for (let j = 0; j < e1.guidance.length; j++) {
1469
+ assertEq(e2.guidance[j], e1.guidance[j], `round-trip entry ${i} guidance[${j}]`);
1470
+ }
1471
+ }
1472
+ }
1473
+
1474
+ // ═══════════════════════════════════════════════════════════════════════════
1475
+ // LLM-style round-trip tests — realistic manifest variations
1476
+ // ═══════════════════════════════════════════════════════════════════════════
1477
+
1478
+ console.log('\n=== LLM round-trip: extra whitespace ===');
1479
+ {
1480
+ // LLMs often produce inconsistent indentation and trailing spaces
1481
+ const messy = `# Secrets Manifest
1482
+
1483
+ **Milestone:** M010
1484
+ **Generated:** 2025-07-01T12:00:00Z
1485
+
1486
+ ### OPENAI_API_KEY
1487
+
1488
+ **Service:** OpenAI
1489
+ **Dashboard:** https://platform.openai.com/api-keys
1490
+ **Format hint:** starts with sk-
1491
+ **Status:** pending
1492
+ **Destination:** dotenv
1493
+
1494
+ 1. Go to the API keys page
1495
+ 2. Create a new key
1496
+
1497
+ ### REDIS_URL
1498
+
1499
+ **Service:** Upstash
1500
+ **Status:** collected
1501
+ **Destination:** vercel
1502
+
1503
+ 1. Open console
1504
+ `;
1505
+
1506
+ const parsed1 = parseSecretsManifest(messy);
1507
+ const formatted = formatSecretsManifest(parsed1);
1508
+ const parsed2 = parseSecretsManifest(formatted);
1509
+
1510
+ assertEq(parsed2.milestone, parsed1.milestone, 'whitespace round-trip milestone');
1511
+ assertEq(parsed2.generatedAt, parsed1.generatedAt, 'whitespace round-trip generatedAt');
1512
+ assertEq(parsed2.entries.length, parsed1.entries.length, 'whitespace round-trip entry count');
1513
+ assertEq(parsed2.entries.length, 2, 'whitespace: two entries parsed');
1514
+
1515
+ for (let i = 0; i < parsed1.entries.length; i++) {
1516
+ const e1 = parsed1.entries[i];
1517
+ const e2 = parsed2.entries[i];
1518
+ assertEq(e2.key, e1.key, `whitespace round-trip entry ${i} key`);
1519
+ assertEq(e2.service, e1.service, `whitespace round-trip entry ${i} service`);
1520
+ assertEq(e2.dashboardUrl, e1.dashboardUrl, `whitespace round-trip entry ${i} dashboardUrl`);
1521
+ assertEq(e2.formatHint, e1.formatHint, `whitespace round-trip entry ${i} formatHint`);
1522
+ assertEq(e2.status, e1.status, `whitespace round-trip entry ${i} status`);
1523
+ assertEq(e2.destination, e1.destination, `whitespace round-trip entry ${i} destination`);
1524
+ assertEq(e2.guidance.length, e1.guidance.length, `whitespace round-trip entry ${i} guidance length`);
1525
+ for (let j = 0; j < e1.guidance.length; j++) {
1526
+ assertEq(e2.guidance[j], e1.guidance[j], `whitespace round-trip entry ${i} guidance[${j}]`);
1527
+ }
1528
+ }
1529
+
1530
+ // Verify the parser correctly stripped trailing whitespace
1531
+ assertEq(parsed1.milestone, 'M010', 'whitespace: milestone trimmed');
1532
+ assertEq(parsed1.entries[0].key, 'OPENAI_API_KEY', 'whitespace: key trimmed');
1533
+ assertEq(parsed1.entries[0].service, 'OpenAI', 'whitespace: service trimmed');
1534
+ }
1535
+
1536
+ console.log('\n=== LLM round-trip: missing optional fields ===');
1537
+ {
1538
+ // LLMs may omit Dashboard and Format hint lines entirely
1539
+ const minimal = `# Secrets Manifest
1540
+
1541
+ **Milestone:** M011
1542
+ **Generated:** 2025-07-02T08:00:00Z
1543
+
1544
+ ### DATABASE_URL
1545
+
1546
+ **Service:** Neon
1547
+ **Status:** pending
1548
+ **Destination:** dotenv
1549
+
1550
+ 1. Create a Neon project
1551
+ 2. Copy connection string
1552
+
1553
+ ### WEBHOOK_SECRET
1554
+
1555
+ **Service:** Stripe
1556
+ **Status:** collected
1557
+ **Destination:** dotenv
1558
+
1559
+ 1. Go to webhooks
1560
+ `;
1561
+
1562
+ const parsed1 = parseSecretsManifest(minimal);
1563
+
1564
+ // Verify missing optional fields get defaults
1565
+ assertEq(parsed1.entries[0].dashboardUrl, '', 'missing-optional: no dashboard → empty string');
1566
+ assertEq(parsed1.entries[0].formatHint, '', 'missing-optional: no format hint → empty string');
1567
+ assertEq(parsed1.entries[1].dashboardUrl, '', 'missing-optional: entry 2 no dashboard → empty string');
1568
+ assertEq(parsed1.entries[1].formatHint, '', 'missing-optional: entry 2 no format hint → empty string');
1569
+
1570
+ // Round-trip: formatter omits empty optional fields, re-parse preserves defaults
1571
+ const formatted = formatSecretsManifest(parsed1);
1572
+ const parsed2 = parseSecretsManifest(formatted);
1573
+
1574
+ assertEq(parsed2.entries.length, parsed1.entries.length, 'missing-optional round-trip entry count');
1575
+
1576
+ for (let i = 0; i < parsed1.entries.length; i++) {
1577
+ const e1 = parsed1.entries[i];
1578
+ const e2 = parsed2.entries[i];
1579
+ assertEq(e2.key, e1.key, `missing-optional round-trip entry ${i} key`);
1580
+ assertEq(e2.service, e1.service, `missing-optional round-trip entry ${i} service`);
1581
+ assertEq(e2.dashboardUrl, e1.dashboardUrl, `missing-optional round-trip entry ${i} dashboardUrl`);
1582
+ assertEq(e2.formatHint, e1.formatHint, `missing-optional round-trip entry ${i} formatHint`);
1583
+ assertEq(e2.status, e1.status, `missing-optional round-trip entry ${i} status`);
1584
+ assertEq(e2.destination, e1.destination, `missing-optional round-trip entry ${i} destination`);
1585
+ assertEq(e2.guidance.length, e1.guidance.length, `missing-optional round-trip entry ${i} guidance length`);
1586
+ }
1587
+ }
1588
+
1589
+ console.log('\n=== LLM round-trip: extra blank lines ===');
1590
+ {
1591
+ // LLMs sometimes insert excessive blank lines between sections
1592
+ const blanky = `# Secrets Manifest
1593
+
1594
+
1595
+ **Milestone:** M012
1596
+ **Generated:** 2025-07-03T14:00:00Z
1597
+
1598
+
1599
+
1600
+ ### API_KEY_ONE
1601
+
1602
+
1603
+ **Service:** ServiceOne
1604
+ **Dashboard:** https://one.example.com
1605
+
1606
+
1607
+ **Format hint:** key_...
1608
+ **Status:** pending
1609
+ **Destination:** dotenv
1610
+
1611
+
1612
+
1613
+ 1. Go to settings
1614
+
1615
+
1616
+ 2. Generate key
1617
+
1618
+
1619
+
1620
+ ### API_KEY_TWO
1621
+
1622
+
1623
+
1624
+ **Service:** ServiceTwo
1625
+ **Status:** skipped
1626
+ **Destination:** dotenv
1627
+
1628
+
1629
+ 1. Not needed
1630
+ `;
1631
+
1632
+ const parsed1 = parseSecretsManifest(blanky);
1633
+
1634
+ assertEq(parsed1.entries.length, 2, 'blank-lines: two entries parsed');
1635
+ assertEq(parsed1.milestone, 'M012', 'blank-lines: milestone parsed');
1636
+ assertEq(parsed1.entries[0].key, 'API_KEY_ONE', 'blank-lines: first key');
1637
+ assertEq(parsed1.entries[0].guidance.length, 2, 'blank-lines: first entry guidance count');
1638
+ assertEq(parsed1.entries[1].key, 'API_KEY_TWO', 'blank-lines: second key');
1639
+ assertEq(parsed1.entries[1].status, 'skipped', 'blank-lines: second entry status');
1640
+
1641
+ // Round-trip produces clean output
1642
+ const formatted = formatSecretsManifest(parsed1);
1643
+ const parsed2 = parseSecretsManifest(formatted);
1644
+
1645
+ assertEq(parsed2.entries.length, parsed1.entries.length, 'blank-lines round-trip entry count');
1646
+
1647
+ for (let i = 0; i < parsed1.entries.length; i++) {
1648
+ const e1 = parsed1.entries[i];
1649
+ const e2 = parsed2.entries[i];
1650
+ assertEq(e2.key, e1.key, `blank-lines round-trip entry ${i} key`);
1651
+ assertEq(e2.service, e1.service, `blank-lines round-trip entry ${i} service`);
1652
+ assertEq(e2.dashboardUrl, e1.dashboardUrl, `blank-lines round-trip entry ${i} dashboardUrl`);
1653
+ assertEq(e2.formatHint, e1.formatHint, `blank-lines round-trip entry ${i} formatHint`);
1654
+ assertEq(e2.status, e1.status, `blank-lines round-trip entry ${i} status`);
1655
+ assertEq(e2.destination, e1.destination, `blank-lines round-trip entry ${i} destination`);
1656
+ assertEq(e2.guidance.length, e1.guidance.length, `blank-lines round-trip entry ${i} guidance length`);
1657
+ }
1658
+
1659
+ // Verify the formatted output is cleaner (fewer consecutive blank lines)
1660
+ const consecutiveBlanks = formatted.match(/\n{4,}/g);
1661
+ assertTrue(consecutiveBlanks === null, 'blank-lines: formatted output has no 4+ consecutive newlines');
1662
+ }
1663
+
1664
+ report();