sofia-cli 0.1.1

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 (435) hide show
  1. package/.github/agents/copilot-instructions.md +39 -0
  2. package/.github/agents/speckit.analyze.agent.md +184 -0
  3. package/.github/agents/speckit.checklist.agent.md +294 -0
  4. package/.github/agents/speckit.clarify.agent.md +181 -0
  5. package/.github/agents/speckit.constitution.agent.md +84 -0
  6. package/.github/agents/speckit.implement.agent.md +135 -0
  7. package/.github/agents/speckit.plan.agent.md +90 -0
  8. package/.github/agents/speckit.specify.agent.md +258 -0
  9. package/.github/agents/speckit.tasks.agent.md +137 -0
  10. package/.github/agents/speckit.taskstoissues.agent.md +30 -0
  11. package/.github/copilot-instructions.md +257 -0
  12. package/.github/prompts/speckit.analyze.prompt.md +3 -0
  13. package/.github/prompts/speckit.checklist.prompt.md +3 -0
  14. package/.github/prompts/speckit.clarify.prompt.md +3 -0
  15. package/.github/prompts/speckit.constitution.prompt.md +3 -0
  16. package/.github/prompts/speckit.implement.prompt.md +3 -0
  17. package/.github/prompts/speckit.plan.prompt.md +3 -0
  18. package/.github/prompts/speckit.specify.prompt.md +3 -0
  19. package/.github/prompts/speckit.tasks.prompt.md +3 -0
  20. package/.github/prompts/speckit.taskstoissues.prompt.md +3 -0
  21. package/.github/workflows/ci.yml +38 -0
  22. package/.prettierrc +6 -0
  23. package/.specify/memory/constitution.md +181 -0
  24. package/.specify/scripts/bash/check-prerequisites.sh +166 -0
  25. package/.specify/scripts/bash/common.sh +156 -0
  26. package/.specify/scripts/bash/create-new-feature.sh +297 -0
  27. package/.specify/scripts/bash/setup-plan.sh +61 -0
  28. package/.specify/scripts/bash/update-agent-context.sh +810 -0
  29. package/.specify/templates/agent-file-template.md +28 -0
  30. package/.specify/templates/checklist-template.md +40 -0
  31. package/.specify/templates/constitution-template.md +50 -0
  32. package/.specify/templates/plan-template.md +113 -0
  33. package/.specify/templates/spec-template.md +115 -0
  34. package/.specify/templates/tasks-template.md +251 -0
  35. package/.vscode/mcp.json +42 -0
  36. package/.vscode/settings.json +19 -0
  37. package/CODE_OF_CONDUCT.md +128 -0
  38. package/LICENSE +21 -0
  39. package/README.md +213 -0
  40. package/dist/src/cli/developCommand.js +240 -0
  41. package/dist/src/cli/directCommands.js +143 -0
  42. package/dist/src/cli/envLoader.js +16 -0
  43. package/dist/src/cli/exportCommand.js +53 -0
  44. package/dist/src/cli/index.js +203 -0
  45. package/dist/src/cli/ioContext.js +109 -0
  46. package/dist/src/cli/preflight.js +57 -0
  47. package/dist/src/cli/statusCommand.js +110 -0
  48. package/dist/src/cli/workshopCommand.js +400 -0
  49. package/dist/src/develop/checkpointState.js +86 -0
  50. package/dist/src/develop/codeGenerator.js +319 -0
  51. package/dist/src/develop/dynamicScaffolder.js +226 -0
  52. package/dist/src/develop/githubMcpAdapter.js +122 -0
  53. package/dist/src/develop/index.js +15 -0
  54. package/dist/src/develop/mcpContextEnricher.js +195 -0
  55. package/dist/src/develop/pocScaffolder.js +542 -0
  56. package/dist/src/develop/ralphLoop.js +659 -0
  57. package/dist/src/develop/templateRegistry.js +364 -0
  58. package/dist/src/develop/testRunner.js +202 -0
  59. package/dist/src/logging/logger.js +58 -0
  60. package/dist/src/loop/conversationLoop.js +227 -0
  61. package/dist/src/loop/phaseSummarizer.js +87 -0
  62. package/dist/src/mcp/mcpManager.js +267 -0
  63. package/dist/src/mcp/mcpTransport.js +391 -0
  64. package/dist/src/mcp/retryPolicy.js +47 -0
  65. package/dist/src/mcp/webSearch.js +254 -0
  66. package/dist/src/phases/contextSummarizer.js +101 -0
  67. package/dist/src/phases/discoveryEnricher.js +156 -0
  68. package/dist/src/phases/phaseExtractors.js +222 -0
  69. package/dist/src/phases/phaseHandlers.js +328 -0
  70. package/dist/src/prompts/design.md +51 -0
  71. package/dist/src/prompts/develop-boundary.md +51 -0
  72. package/dist/src/prompts/develop.md +111 -0
  73. package/dist/src/prompts/discover.md +58 -0
  74. package/dist/src/prompts/ideate.md +56 -0
  75. package/dist/src/prompts/plan.md +51 -0
  76. package/dist/src/prompts/promptLoader.js +167 -0
  77. package/dist/src/prompts/promptLoader.ts +198 -0
  78. package/dist/src/prompts/select.md +47 -0
  79. package/dist/src/prompts/summarize/README.md +8 -0
  80. package/dist/src/prompts/summarize/design-summary.md +37 -0
  81. package/dist/src/prompts/summarize/develop-summary.md +25 -0
  82. package/dist/src/prompts/summarize/ideate-summary.md +27 -0
  83. package/dist/src/prompts/summarize/plan-summary.md +27 -0
  84. package/dist/src/prompts/summarize/select-summary.md +21 -0
  85. package/dist/src/prompts/system.md +28 -0
  86. package/dist/src/sessions/exportPaths.js +22 -0
  87. package/dist/src/sessions/exportWriter.js +406 -0
  88. package/dist/src/sessions/sessionManager.js +81 -0
  89. package/dist/src/sessions/sessionStore.js +65 -0
  90. package/dist/src/shared/activitySpinner.js +91 -0
  91. package/dist/src/shared/copilotClient.js +129 -0
  92. package/dist/src/shared/data/cards.json +1249 -0
  93. package/dist/src/shared/data/cardsLoader.js +51 -0
  94. package/dist/src/shared/errorClassifier.js +120 -0
  95. package/dist/src/shared/events.js +28 -0
  96. package/dist/src/shared/markdownRenderer.js +34 -0
  97. package/dist/src/shared/schemas/session.js +265 -0
  98. package/dist/src/shared/tableRenderer.js +20 -0
  99. package/dist/src/vendor/chalk.js +2 -0
  100. package/dist/src/vendor/cli-table3.js +3 -0
  101. package/dist/src/vendor/commander.js +2 -0
  102. package/dist/src/vendor/marked-terminal.js +3 -0
  103. package/dist/src/vendor/marked.js +2 -0
  104. package/dist/src/vendor/ora.js +2 -0
  105. package/dist/src/vendor/pino.js +2 -0
  106. package/dist/src/vendor/zod.js +2 -0
  107. package/dist/tests/e2e/developE2e.spec.js +126 -0
  108. package/dist/tests/e2e/developFailureE2e.spec.js +247 -0
  109. package/dist/tests/e2e/developPty.spec.js +75 -0
  110. package/dist/tests/e2e/discoveryWebSearchRelevance.spec.js +84 -0
  111. package/dist/tests/e2e/harness.spec.js +83 -0
  112. package/dist/tests/e2e/mcpLive.spec.js +120 -0
  113. package/dist/tests/e2e/newSession.e2e.spec.js +177 -0
  114. package/dist/tests/e2e/ralphLoopEnrichmentComparison.spec.js +62 -0
  115. package/dist/tests/e2e/workiqEnrichment.spec.js +56 -0
  116. package/dist/tests/e2e/zavaSimulation.spec.js +452 -0
  117. package/dist/tests/fixtures/test-fixture-project/src/add.js +3 -0
  118. package/dist/tests/fixtures/test-fixture-project/tests/failing.test.js +6 -0
  119. package/dist/tests/fixtures/test-fixture-project/tests/hanging.test.js +8 -0
  120. package/dist/tests/fixtures/test-fixture-project/tests/passing.test.js +10 -0
  121. package/dist/tests/fixtures/test-fixture-project/vitest.config.js +6 -0
  122. package/dist/tests/integration/autoStartConversation.spec.js +138 -0
  123. package/dist/tests/integration/defaultCommand.spec.js +147 -0
  124. package/dist/tests/integration/directCommandNonTty.spec.js +224 -0
  125. package/dist/tests/integration/directCommandTty.spec.js +151 -0
  126. package/dist/tests/integration/discoveryEnrichmentFlow.spec.js +175 -0
  127. package/dist/tests/integration/exportArtifacts.spec.js +202 -0
  128. package/dist/tests/integration/exportFallbackFlow.spec.js +99 -0
  129. package/dist/tests/integration/mcpDegradationFlow.spec.js +190 -0
  130. package/dist/tests/integration/mcpTransportFlow.spec.js +139 -0
  131. package/dist/tests/integration/newSessionFlow.spec.js +343 -0
  132. package/dist/tests/integration/pocGithubMcp.spec.js +186 -0
  133. package/dist/tests/integration/pocLocalFallback.spec.js +171 -0
  134. package/dist/tests/integration/pocScaffold.spec.js +163 -0
  135. package/dist/tests/integration/ralphLoopFlow.spec.js +359 -0
  136. package/dist/tests/integration/ralphLoopPartial.spec.js +368 -0
  137. package/dist/tests/integration/resumeAndBacktrack.spec.js +247 -0
  138. package/dist/tests/integration/spinnerLifecycle.spec.js +220 -0
  139. package/dist/tests/integration/summarizationFlow.spec.js +115 -0
  140. package/dist/tests/integration/testRunnerReal.spec.js +52 -0
  141. package/dist/tests/integration/webSearchAgent.spec.js +128 -0
  142. package/dist/tests/live/copilotSdkLive.spec.js +107 -0
  143. package/dist/tests/live/zavaFullWorkshop.spec.js +392 -0
  144. package/dist/tests/setup/loadEnv.js +3 -0
  145. package/dist/tests/unit/cli/developCommand.spec.js +567 -0
  146. package/dist/tests/unit/cli/directCommands.spec.js +279 -0
  147. package/dist/tests/unit/cli/envLoader.spec.js +58 -0
  148. package/dist/tests/unit/cli/ioContext.spec.js +119 -0
  149. package/dist/tests/unit/cli/preflight.spec.js +108 -0
  150. package/dist/tests/unit/cli/statusCommand.spec.js +111 -0
  151. package/dist/tests/unit/cli/workshopClientFallback.spec.js +80 -0
  152. package/dist/tests/unit/cli/workshopCommand.spec.js +329 -0
  153. package/dist/tests/unit/config/vitestEnvSetup.spec.js +13 -0
  154. package/dist/tests/unit/develop/checkpointState.spec.js +315 -0
  155. package/dist/tests/unit/develop/codeGenerator.spec.js +355 -0
  156. package/dist/tests/unit/develop/githubMcpAdapter.spec.js +231 -0
  157. package/dist/tests/unit/develop/mcpContextEnricher.spec.js +433 -0
  158. package/dist/tests/unit/develop/outputValidator.spec.js +119 -0
  159. package/dist/tests/unit/develop/pocScaffolder.spec.js +353 -0
  160. package/dist/tests/unit/develop/ralphLoop.spec.js +1248 -0
  161. package/dist/tests/unit/develop/templateRegistry.spec.js +85 -0
  162. package/dist/tests/unit/develop/testRunner.spec.js +249 -0
  163. package/dist/tests/unit/infraBicep.spec.js +92 -0
  164. package/dist/tests/unit/infraDeploy.spec.js +82 -0
  165. package/dist/tests/unit/infraTeardown.spec.js +63 -0
  166. package/dist/tests/unit/logging/logger.spec.js +43 -0
  167. package/dist/tests/unit/loop/conversationLoop.spec.js +592 -0
  168. package/dist/tests/unit/loop/phaseSummarizer.spec.js +141 -0
  169. package/dist/tests/unit/loop/streamingMarkdown.spec.js +147 -0
  170. package/dist/tests/unit/mcp/mcpManager.spec.js +279 -0
  171. package/dist/tests/unit/mcp/mcpTransport.spec.js +529 -0
  172. package/dist/tests/unit/mcp/retryPolicy.spec.js +218 -0
  173. package/dist/tests/unit/mcp/timeoutValidation.spec.js +46 -0
  174. package/dist/tests/unit/mcp/webSearch.spec.js +567 -0
  175. package/dist/tests/unit/phases/contextSummarizer.spec.js +140 -0
  176. package/dist/tests/unit/phases/discoveryEnricher.repeatCalls.spec.js +93 -0
  177. package/dist/tests/unit/phases/discoveryEnricher.spec.js +411 -0
  178. package/dist/tests/unit/phases/phaseExtractors.spec.js +352 -0
  179. package/dist/tests/unit/phases/phaseHandlers.spec.js +425 -0
  180. package/dist/tests/unit/prompts/promptLoader.spec.js +118 -0
  181. package/dist/tests/unit/schemas/pocSchemas.spec.js +412 -0
  182. package/dist/tests/unit/schemas/session.spec.js +257 -0
  183. package/dist/tests/unit/sessions/exportPaths.spec.js +31 -0
  184. package/dist/tests/unit/sessions/exportWriter.spec.js +655 -0
  185. package/dist/tests/unit/sessions/sessionManager.spec.js +151 -0
  186. package/dist/tests/unit/sessions/sessionStore.spec.js +116 -0
  187. package/dist/tests/unit/shared/activitySpinner.spec.js +175 -0
  188. package/dist/tests/unit/shared/cardsLoader.spec.js +76 -0
  189. package/dist/tests/unit/shared/copilotClient.spec.js +155 -0
  190. package/dist/tests/unit/shared/errorClassifier.spec.js +131 -0
  191. package/dist/tests/unit/shared/events.spec.js +55 -0
  192. package/dist/tests/unit/shared/markdownRenderer.spec.js +35 -0
  193. package/dist/tests/unit/shared/markdownRendererChunks.spec.js +70 -0
  194. package/dist/tests/unit/shared/tableRenderer.spec.js +34 -0
  195. package/dist/vitest.config.js +14 -0
  196. package/dist/vitest.live.config.js +18 -0
  197. package/docs/README.md +35 -0
  198. package/docs/architecture.md +169 -0
  199. package/docs/cli-usage.md +207 -0
  200. package/docs/environment.md +66 -0
  201. package/docs/export-format.md +146 -0
  202. package/docs/session-model.md +113 -0
  203. package/eslint.config.js +35 -0
  204. package/infra/deploy.sh +193 -0
  205. package/infra/gather-env.sh +211 -0
  206. package/infra/main.bicep +90 -0
  207. package/infra/main.bicepparam +18 -0
  208. package/infra/resources.bicep +134 -0
  209. package/infra/teardown.sh +114 -0
  210. package/package.json +63 -0
  211. package/specs/001-cli-workshop-rebuild/checklists/requirements.md +35 -0
  212. package/specs/001-cli-workshop-rebuild/contracts/cli.md +59 -0
  213. package/specs/001-cli-workshop-rebuild/contracts/export-summary-json.md +23 -0
  214. package/specs/001-cli-workshop-rebuild/contracts/session-json.md +30 -0
  215. package/specs/001-cli-workshop-rebuild/data-model.md +210 -0
  216. package/specs/001-cli-workshop-rebuild/plan.md +361 -0
  217. package/specs/001-cli-workshop-rebuild/quickstart.md +83 -0
  218. package/specs/001-cli-workshop-rebuild/research.md +116 -0
  219. package/specs/001-cli-workshop-rebuild/spec.md +240 -0
  220. package/specs/001-cli-workshop-rebuild/tasks.md +476 -0
  221. package/specs/002-poc-generation/contracts/poc-output.md +172 -0
  222. package/specs/002-poc-generation/contracts/ralph-loop.md +113 -0
  223. package/specs/002-poc-generation/data-model.md +172 -0
  224. package/specs/002-poc-generation/plan.md +109 -0
  225. package/specs/002-poc-generation/quickstart.md +97 -0
  226. package/specs/002-poc-generation/research.md +786 -0
  227. package/specs/002-poc-generation/spec.md +81 -0
  228. package/specs/002-poc-generation/tasks-fix.md +198 -0
  229. package/specs/002-poc-generation/tasks.md +252 -0
  230. package/specs/003-mcp-transport-integration/checklists/requirements.md +37 -0
  231. package/specs/003-mcp-transport-integration/contracts/context-enricher.md +220 -0
  232. package/specs/003-mcp-transport-integration/contracts/discovery-enricher.md +267 -0
  233. package/specs/003-mcp-transport-integration/contracts/github-adapter.md +149 -0
  234. package/specs/003-mcp-transport-integration/contracts/mcp-transport.md +288 -0
  235. package/specs/003-mcp-transport-integration/data-model.md +326 -0
  236. package/specs/003-mcp-transport-integration/plan.md +114 -0
  237. package/specs/003-mcp-transport-integration/quickstart.md +311 -0
  238. package/specs/003-mcp-transport-integration/research.md +395 -0
  239. package/specs/003-mcp-transport-integration/spec.md +234 -0
  240. package/specs/003-mcp-transport-integration/tasks.md +324 -0
  241. package/specs/003-next-spec-gaps.md +150 -0
  242. package/specs/004-dev-resume-hardening/checklists/requirements.md +37 -0
  243. package/specs/004-dev-resume-hardening/contracts/cli.md +160 -0
  244. package/specs/004-dev-resume-hardening/data-model.md +321 -0
  245. package/specs/004-dev-resume-hardening/plan.md +107 -0
  246. package/specs/004-dev-resume-hardening/quickstart.md +115 -0
  247. package/specs/004-dev-resume-hardening/research.md +142 -0
  248. package/specs/004-dev-resume-hardening/spec.md +221 -0
  249. package/specs/004-dev-resume-hardening/tasks.md +333 -0
  250. package/specs/005-ai-search-deploy/checklists/requirements.md +39 -0
  251. package/specs/005-ai-search-deploy/contracts/web-search-tool.md +241 -0
  252. package/specs/005-ai-search-deploy/data-model.md +130 -0
  253. package/specs/005-ai-search-deploy/plan.md +93 -0
  254. package/specs/005-ai-search-deploy/quickstart.md +96 -0
  255. package/specs/005-ai-search-deploy/research.md +187 -0
  256. package/specs/005-ai-search-deploy/spec.md +143 -0
  257. package/specs/005-ai-search-deploy/tasks.md +284 -0
  258. package/specs/006-workshop-extraction-fixes/checklists/requirements.md +61 -0
  259. package/specs/006-workshop-extraction-fixes/contracts/summarization-and-export.md +131 -0
  260. package/specs/006-workshop-extraction-fixes/data-model.md +149 -0
  261. package/specs/006-workshop-extraction-fixes/plan.md +123 -0
  262. package/specs/006-workshop-extraction-fixes/quickstart.md +101 -0
  263. package/specs/006-workshop-extraction-fixes/research.md +143 -0
  264. package/specs/006-workshop-extraction-fixes/spec.md +210 -0
  265. package/specs/006-workshop-extraction-fixes/tasks.md +316 -0
  266. package/src/cli/developCommand.ts +308 -0
  267. package/src/cli/directCommands.ts +195 -0
  268. package/src/cli/envLoader.ts +17 -0
  269. package/src/cli/exportCommand.ts +65 -0
  270. package/src/cli/index.ts +249 -0
  271. package/src/cli/ioContext.ts +139 -0
  272. package/src/cli/preflight.ts +86 -0
  273. package/src/cli/statusCommand.ts +118 -0
  274. package/src/cli/workshopCommand.ts +496 -0
  275. package/src/develop/checkpointState.ts +121 -0
  276. package/src/develop/codeGenerator.ts +402 -0
  277. package/src/develop/dynamicScaffolder.ts +284 -0
  278. package/src/develop/githubMcpAdapter.ts +199 -0
  279. package/src/develop/index.ts +34 -0
  280. package/src/develop/mcpContextEnricher.ts +279 -0
  281. package/src/develop/pocScaffolder.ts +646 -0
  282. package/src/develop/ralphLoop.ts +1044 -0
  283. package/src/develop/templateRegistry.ts +427 -0
  284. package/src/develop/testRunner.ts +276 -0
  285. package/src/logging/logger.ts +73 -0
  286. package/src/loop/conversationLoop.ts +355 -0
  287. package/src/loop/phaseSummarizer.ts +114 -0
  288. package/src/mcp/mcpManager.ts +365 -0
  289. package/src/mcp/mcpTransport.ts +562 -0
  290. package/src/mcp/retryPolicy.ts +87 -0
  291. package/src/mcp/webSearch.ts +388 -0
  292. package/src/originalPrompts/design_thinking.md +178 -0
  293. package/src/originalPrompts/design_thinking_persona.md +76 -0
  294. package/src/originalPrompts/document_generator_example.md +77 -0
  295. package/src/originalPrompts/document_generator_persona.md +47 -0
  296. package/src/originalPrompts/facilitator_persona.md +125 -0
  297. package/src/originalPrompts/guardrails.md +47 -0
  298. package/src/phases/contextSummarizer.ts +154 -0
  299. package/src/phases/discoveryEnricher.ts +223 -0
  300. package/src/phases/phaseExtractors.ts +247 -0
  301. package/src/phases/phaseHandlers.ts +450 -0
  302. package/src/prompts/design.md +51 -0
  303. package/src/prompts/develop-boundary.md +51 -0
  304. package/src/prompts/develop.md +111 -0
  305. package/src/prompts/discover.md +58 -0
  306. package/src/prompts/ideate.md +56 -0
  307. package/src/prompts/plan.md +51 -0
  308. package/src/prompts/promptLoader.ts +198 -0
  309. package/src/prompts/select.md +47 -0
  310. package/src/prompts/summarize/README.md +8 -0
  311. package/src/prompts/summarize/design-summary.md +37 -0
  312. package/src/prompts/summarize/develop-summary.md +25 -0
  313. package/src/prompts/summarize/ideate-summary.md +27 -0
  314. package/src/prompts/summarize/plan-summary.md +27 -0
  315. package/src/prompts/summarize/select-summary.md +21 -0
  316. package/src/prompts/system.md +28 -0
  317. package/src/sessions/exportPaths.ts +28 -0
  318. package/src/sessions/exportWriter.ts +490 -0
  319. package/src/sessions/sessionManager.ts +119 -0
  320. package/src/sessions/sessionStore.ts +69 -0
  321. package/src/shared/activitySpinner.ts +108 -0
  322. package/src/shared/copilotClient.ts +291 -0
  323. package/src/shared/data/cards.json +1249 -0
  324. package/src/shared/data/cardsLoader.ts +70 -0
  325. package/src/shared/errorClassifier.ts +160 -0
  326. package/src/shared/events.ts +103 -0
  327. package/src/shared/markdownRenderer.ts +44 -0
  328. package/src/shared/schemas/session.ts +346 -0
  329. package/src/shared/tableRenderer.ts +28 -0
  330. package/src/types/marked-terminal.d.ts +5 -0
  331. package/src/vendor/chalk.ts +2 -0
  332. package/src/vendor/cli-table3.ts +3 -0
  333. package/src/vendor/commander.ts +2 -0
  334. package/src/vendor/marked-terminal.ts +3 -0
  335. package/src/vendor/marked.ts +2 -0
  336. package/src/vendor/ora.ts +2 -0
  337. package/src/vendor/pino.ts +3 -0
  338. package/src/vendor/zod.ts +3 -0
  339. package/tests/e2e/developE2e.spec.ts +152 -0
  340. package/tests/e2e/developFailureE2e.spec.ts +289 -0
  341. package/tests/e2e/developPty.spec.ts +86 -0
  342. package/tests/e2e/discoveryWebSearchRelevance.spec.ts +103 -0
  343. package/tests/e2e/harness.spec.ts +104 -0
  344. package/tests/e2e/mcpLive.spec.ts +149 -0
  345. package/tests/e2e/newSession.e2e.spec.ts +245 -0
  346. package/tests/e2e/ralphLoopEnrichmentComparison.spec.ts +70 -0
  347. package/tests/e2e/workiqEnrichment.spec.ts +72 -0
  348. package/tests/e2e/zava-assessment/agent-interaction-script.md +258 -0
  349. package/tests/e2e/zava-assessment/company-profile.md +98 -0
  350. package/tests/e2e/zava-assessment/expected-results-checklist.md +454 -0
  351. package/tests/e2e/zavaSimulation.spec.ts +511 -0
  352. package/tests/fixtures/completedSession.json +141 -0
  353. package/tests/fixtures/test-fixture-project/package-lock.json +1585 -0
  354. package/tests/fixtures/test-fixture-project/package.json +12 -0
  355. package/tests/fixtures/test-fixture-project/src/add.ts +3 -0
  356. package/tests/fixtures/test-fixture-project/tests/failing.test.ts +7 -0
  357. package/tests/fixtures/test-fixture-project/tests/hanging.test.ts +9 -0
  358. package/tests/fixtures/test-fixture-project/tests/passing.test.ts +13 -0
  359. package/tests/fixtures/test-fixture-project/vitest.config.ts +7 -0
  360. package/tests/integration/autoStartConversation.spec.ts +168 -0
  361. package/tests/integration/defaultCommand.spec.ts +179 -0
  362. package/tests/integration/directCommandNonTty.spec.ts +260 -0
  363. package/tests/integration/directCommandTty.spec.ts +185 -0
  364. package/tests/integration/discoveryEnrichmentFlow.spec.ts +209 -0
  365. package/tests/integration/exportArtifacts.spec.ts +232 -0
  366. package/tests/integration/exportFallbackFlow.spec.ts +115 -0
  367. package/tests/integration/mcpDegradationFlow.spec.ts +231 -0
  368. package/tests/integration/mcpTransportFlow.spec.ts +178 -0
  369. package/tests/integration/newSessionFlow.spec.ts +406 -0
  370. package/tests/integration/pocGithubMcp.spec.ts +224 -0
  371. package/tests/integration/pocLocalFallback.spec.ts +205 -0
  372. package/tests/integration/pocScaffold.spec.ts +220 -0
  373. package/tests/integration/ralphLoopFlow.spec.ts +430 -0
  374. package/tests/integration/ralphLoopPartial.spec.ts +416 -0
  375. package/tests/integration/resumeAndBacktrack.spec.ts +278 -0
  376. package/tests/integration/spinnerLifecycle.spec.ts +270 -0
  377. package/tests/integration/summarizationFlow.spec.ts +135 -0
  378. package/tests/integration/testRunnerReal.spec.ts +63 -0
  379. package/tests/integration/webSearchAgent.spec.ts +155 -0
  380. package/tests/live/copilotSdkLive.spec.ts +149 -0
  381. package/tests/live/zavaFullWorkshop.spec.ts +515 -0
  382. package/tests/setup/loadEnv.ts +5 -0
  383. package/tests/unit/cli/developCommand.spec.ts +679 -0
  384. package/tests/unit/cli/directCommands.spec.ts +325 -0
  385. package/tests/unit/cli/envLoader.spec.ts +73 -0
  386. package/tests/unit/cli/ioContext.spec.ts +148 -0
  387. package/tests/unit/cli/preflight.spec.ts +125 -0
  388. package/tests/unit/cli/statusCommand.spec.ts +134 -0
  389. package/tests/unit/cli/workshopClientFallback.spec.ts +100 -0
  390. package/tests/unit/cli/workshopCommand.spec.ts +378 -0
  391. package/tests/unit/config/vitestEnvSetup.spec.ts +24 -0
  392. package/tests/unit/develop/checkpointState.spec.ts +378 -0
  393. package/tests/unit/develop/codeGenerator.spec.ts +447 -0
  394. package/tests/unit/develop/githubMcpAdapter.spec.ts +283 -0
  395. package/tests/unit/develop/mcpContextEnricher.spec.ts +564 -0
  396. package/tests/unit/develop/outputValidator.spec.ts +134 -0
  397. package/tests/unit/develop/pocScaffolder.spec.ts +451 -0
  398. package/tests/unit/develop/ralphLoop.spec.ts +1439 -0
  399. package/tests/unit/develop/templateRegistry.spec.ts +106 -0
  400. package/tests/unit/develop/testRunner.spec.ts +294 -0
  401. package/tests/unit/infraBicep.spec.ts +116 -0
  402. package/tests/unit/infraDeploy.spec.ts +102 -0
  403. package/tests/unit/infraTeardown.spec.ts +77 -0
  404. package/tests/unit/logging/logger.spec.ts +50 -0
  405. package/tests/unit/loop/conversationLoop.spec.ts +719 -0
  406. package/tests/unit/loop/phaseSummarizer.spec.ts +169 -0
  407. package/tests/unit/loop/streamingMarkdown.spec.ts +180 -0
  408. package/tests/unit/mcp/mcpManager.spec.ts +336 -0
  409. package/tests/unit/mcp/mcpTransport.spec.ts +689 -0
  410. package/tests/unit/mcp/retryPolicy.spec.ts +278 -0
  411. package/tests/unit/mcp/timeoutValidation.spec.ts +55 -0
  412. package/tests/unit/mcp/webSearch.spec.ts +718 -0
  413. package/tests/unit/phases/contextSummarizer.spec.ts +158 -0
  414. package/tests/unit/phases/discoveryEnricher.repeatCalls.spec.ts +125 -0
  415. package/tests/unit/phases/discoveryEnricher.spec.ts +512 -0
  416. package/tests/unit/phases/phaseExtractors.spec.ts +406 -0
  417. package/tests/unit/phases/phaseHandlers.spec.ts +483 -0
  418. package/tests/unit/prompts/promptLoader.spec.ts +144 -0
  419. package/tests/unit/schemas/pocSchemas.spec.ts +457 -0
  420. package/tests/unit/schemas/session.spec.ts +328 -0
  421. package/tests/unit/sessions/exportPaths.spec.ts +38 -0
  422. package/tests/unit/sessions/exportWriter.spec.ts +737 -0
  423. package/tests/unit/sessions/sessionManager.spec.ts +174 -0
  424. package/tests/unit/sessions/sessionStore.spec.ts +136 -0
  425. package/tests/unit/shared/activitySpinner.spec.ts +211 -0
  426. package/tests/unit/shared/cardsLoader.spec.ts +89 -0
  427. package/tests/unit/shared/copilotClient.spec.ts +185 -0
  428. package/tests/unit/shared/errorClassifier.spec.ts +152 -0
  429. package/tests/unit/shared/events.spec.ts +71 -0
  430. package/tests/unit/shared/markdownRenderer.spec.ts +42 -0
  431. package/tests/unit/shared/markdownRendererChunks.spec.ts +83 -0
  432. package/tests/unit/shared/tableRenderer.spec.ts +38 -0
  433. package/tsconfig.json +20 -0
  434. package/vitest.config.ts +15 -0
  435. package/vitest.live.config.ts +19 -0
@@ -0,0 +1,324 @@
1
+ # Tasks: MCP Transport Integration
2
+
3
+ **Input**: Design documents from `/specs/003-mcp-transport-integration/`
4
+ **Prerequisites**: plan.md ✅, spec.md ✅, research.md ✅, data-model.md ✅, contracts/ ✅, quickstart.md ✅
5
+ **Branch**: `003-mcp-transport-integration`
6
+
7
+ **Tests**: Tests are REQUIRED for new behavior (Red → Green → Review). Write tests FIRST, ensure they fail, then implement.
8
+
9
+ **Organization**: Tasks are grouped by user story to enable independent implementation and testing of each story.
10
+
11
+ ## Format: `[ID] [P?] [Story] Description`
12
+
13
+ - **[P]**: Can run in parallel (different files, no dependencies on incomplete tasks)
14
+ - **[Story]**: Which user story this task belongs to (US1–US5)
15
+ - Include exact file paths in every task description
16
+
17
+ ## Already Fulfilled by Existing Code (No Tasks Created)
18
+
19
+ The following items are already implemented and do not require new tasks:
20
+
21
+ | Component | File | Status |
22
+ | -------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------- |
23
+ | Project setup | `package.json`, `tsconfig.json`, `eslint.config.js` | ✅ Complete |
24
+ | MCP config loader | `src/mcp/mcpManager.ts` (`loadMcpConfig`, `McpManager` struct) | ✅ Complete |
25
+ | Web search bridge | `src/mcp/webSearch.ts` | ✅ Complete (no changes needed) |
26
+ | GitHub adapter structure | `src/develop/githubMcpAdapter.ts` (calls `callTool()` correctly) | ✅ Complete (minor contract updates needed) |
27
+ | Context enricher structure | `src/develop/mcpContextEnricher.ts` (calls `callTool()` correctly) | ✅ Complete (minor contract updates needed) |
28
+ | Ralph Loop core | `src/develop/ralphLoop.ts` (per-iteration push reads file content correctly) | ✅ Complete (post-scaffold push is missing) |
29
+ | Adapter unit tests (basic) | `tests/unit/develop/githubMcpAdapter.spec.ts`, `mcpContextEnricher.spec.ts` | ✅ Complete (new contract cases needed) |
30
+ | Ralph Loop unit tests | `tests/unit/develop/ralphLoop.spec.ts` | ✅ Complete (post-scaffold push test missing) |
31
+ | McpManager basic tests | `tests/unit/mcp/mcpManager.spec.ts` | ✅ Complete (`callTool()` real dispatch tests missing) |
32
+ | FR-020 SDK Alignment | `specs/003-mcp-transport-integration/research.md` (Topics 7–9) | ✅ Agent architecture verified aligned; SDK hooks, `infiniteSessions`, `customAgents`, `skillDirectories` evaluated (T049–T055) |
33
+
34
+ ---
35
+
36
+ ## Phase 1: Setup (Shared Infrastructure)
37
+
38
+ **Purpose**: Verify the Feature 002 baseline before making any changes.
39
+
40
+ - [x] T001 Run `npm test` to confirm all Feature 002 tests pass before starting any work
41
+
42
+ **Checkpoint**: Baseline verified — all Feature 002 tests green before any Feature 003 code is written.
43
+
44
+ ---
45
+
46
+ ## Phase 2: Foundational (Transport Abstractions — Blocking Prerequisites)
47
+
48
+ **Purpose**: Define the transport interface and retry policy types that all User Story 1 implementation depends on. These must be created before any US1 code can be written.
49
+
50
+ **⚠️ CRITICAL**: No US1 implementation can begin until this phase is complete.
51
+
52
+ - [x] T002 Create `src/mcp/mcpTransport.ts` with the complete type foundation per `contracts/mcp-transport.md`: `McpTransport` interface, `ToolCallResponse` type, `McpTransportError` class, and empty class stubs for `StdioMcpTransport`, `HttpMcpTransport`, and `createTransport()` factory
53
+ - [x] T003 [P] Create `src/mcp/retryPolicy.ts` with `withRetry<T>()` function signature, `RetryOptions` interface, and `classifyMcpError` re-export (parallel with T002 — different file, no dependency)
54
+
55
+ **Checkpoint**: Transport abstractions defined — US1 implementation can begin.
56
+
57
+ ---
58
+
59
+ ## Phase 3: User Story 1 — MCP Tool Calls Work in Production (Priority: P1) 🎯 MVP
60
+
61
+ **Goal**: Implement the real MCP transport layer so `McpManager.callTool()` dispatches real requests to configured MCP servers, replacing the current stub that throws `"not yet wired to transport"`.
62
+
63
+ **Independent Test**: Configure a test environment with a mock MCP server implementing the JSON-RPC 2.0 protocol, run `sofia dev` on a session with a plan, and verify that real tool calls are dispatched and real responses are used.
64
+
65
+ ### Tests for User Story 1 (REQUIRED — write FIRST, verify they FAIL before implementing)
66
+
67
+ - [x] T004 [P] [US1] Create `tests/unit/mcp/mcpTransport.spec.ts` with failing tests for `HttpMcpTransport`: JSON-RPC `tools/call` framing, `Authorization: Bearer` header from `GITHUB_TOKEN`, `AbortController` timeout, HTTP 401/403 → `auth-failure` error class, HTTP 5xx → `unknown` error class, non-JSON body → `McpTransportError`
68
+ - [x] T005 [P] [US1] Add failing tests for `StdioMcpTransport` to `tests/unit/mcp/mcpTransport.spec.ts`: subprocess spawn with correct command/args, `initialize` handshake sends correct JSON-RPC request, pending request resolved on matching response id, subprocess exit rejects all pending requests with `connection-refused`, 5-second startup timeout on failed handshake
69
+ - [x] T006 [P] [US1] Create `tests/unit/mcp/retryPolicy.spec.ts` with failing tests for `withRetry()`: retries once on `connection-refused`, retries once on `timeout`, does NOT retry on `auth-failure`, does NOT retry on `unknown` error, applies ±20% jitter to initial delay, logs `warn` on retry attempt
70
+ - [x] T007 [P] [US1] Add failing tests for `McpManager.callTool()` real dispatch to `tests/unit/mcp/mcpManager.spec.ts`: returns unwrapped content from `ToolCallResponse`, throws when server not in config, dispatches to correct transport based on server config type, passes `timeoutMs` option to transport, calls `withRetry` for transient errors
71
+ - [x] T008 [P] [US1] Add new failing tests to `tests/unit/develop/githubMcpAdapter.spec.ts` per `contracts/github-adapter.md`: `createRepository` passes `{ timeoutMs: 60_000 }` as 4th arg to `callTool`, `createRepository` falls back to `response.url` then `response.clone_url` when `html_url` missing, `pushFiles` passes `{ timeoutMs: 60_000 }` as 4th arg, `pushFiles` extracts `owner` and `repo` from `repoUrl` and passes them separately (not `repoUrl`), `pushFiles` extracts `commitSha` from `response.commit.sha` as fallback
72
+ - [x] T009 [P] [US1] Add new failing tests to `tests/unit/develop/mcpContextEnricher.spec.ts` per `contracts/context-enricher.md`: `queryContext7` uses `response.id` as fallback when `response.libraryId` missing, `queryContext7` uses `response.text` as fallback content when `response.content` missing, `queryContext7` processes max 5 non-skipped dependencies, `queryAzureMcp` uses `response.text` as fallback when `response.content` missing, `queryWebSearch` tries MCP `callTool('websearch', 'search', ...)` before Azure AI Foundry bridge, `enrich` runs `queryContext7` and `queryAzureMcp` concurrently via `Promise.allSettled()`
73
+ - [x] T010 [P] [US1] Add new failing tests to `tests/unit/develop/mcpContextEnricher.spec.ts` for web search gating per `contracts/context-enricher.md`: `enrich` MUST NOT invoke `queryWebSearch()` when `stuckIterations < 2`, and MUST invoke it when `stuckIterations >= 2` (when configured and failingTests non-empty)
74
+ - [x] T011 [US1] Create `tests/integration/mcpTransportFlow.spec.ts`: spawn a minimal JSON-RPC echo server as a child process, verify `StdioMcpTransport` can connect and round-trip a `tools/call` request, verify retry fires once on first-call failure then succeeds, verify `McpManager.callTool()` dispatches through `StdioMcpTransport` for a stdio-type config
75
+ - [x] T042 [US1] Create `tests/integration/mcpDegradationFlow.spec.ts`: configure `McpManager` with servers marked unavailable (or stub transports that throw), run `GitHubMcpAdapter` + `McpContextEnricher` calls, and assert graceful degradation (no throws; adapters return `{ available: false, reason }` or fallback context) per US1 Acceptance Scenario 4 and FR-013
76
+
77
+ ### Implementation for User Story 1
78
+
79
+ - [x] T012 [US1] Implement `HttpMcpTransport` in `src/mcp/mcpTransport.ts`: `callTool()` uses native `fetch()` with `POST`, JSON-RPC `tools/call` method, `AbortController` for `timeoutMs`, `Authorization: Bearer ${process.env.GITHUB_TOKEN}` when set, parse `result.content[0].text` or `result` directly; `isConnected()` always returns `true`; `disconnect()` is a no-op (depends on T002)
80
+ - [x] T013 [US1] Implement `StdioMcpTransport` in `src/mcp/mcpTransport.ts`: `connect()` spawns subprocess via `child_process.spawn` with `stdio: ['pipe','pipe','pipe']` and `env: process.env`, sends `initialize` JSON-RPC request, waits for `initialized` notification within 5 seconds; `callTool()` writes newline-delimited JSON-RPC request to stdin, resolves on matching response id from stdout, rejects on timeout; `disconnect()` kills subprocess (depends on T012 — same file, implement sequentially)
81
+ - [x] T014 [US1] Implement `createTransport()` factory in `src/mcp/mcpTransport.ts`: returns `HttpMcpTransport` for `type: 'http'` configs and `StdioMcpTransport` for `type: 'stdio'` configs (depends on T012, T013)
82
+ - [x] T015 [US1] Implement `withRetry<T>()` in `src/mcp/retryPolicy.ts`: wraps any async function, retries once after `initialDelayMs * (0.8–1.2 jitter)` on `connection-refused`, `timeout`, or `dns-failure` error classes; does not retry on `auth-failure` or `unknown`; logs `warn` with server name, tool name, attempt number, and delay (depends on T003)
83
+ - [x] T016 [US1] Implement `McpManager.callTool()` real dispatch in `src/mcp/mcpManager.ts`: add `options?: { timeoutMs?: number; retryOnTransient?: boolean }` parameter; lazily create and cache `McpTransport` per server via `createTransport()`; call `connect()` for stdio transports on first use; wrap transport call with `withRetry()` when `retryOnTransient !== false`; unwrap `ToolCallResponse.content` (parse JSON string if string, return as-is if object); throw `Error` for unknown server names (depends on T014, T015)
84
+ - [x] T017 [US1] Implement `McpManager.disconnectAll()` in `src/mcp/mcpManager.ts`: iterate all cached transports and call `transport.disconnect()`, then clear the transport registry (depends on T016)
85
+ - [x] T018 [US1] Update `GitHubMcpAdapter.createRepository()` in `src/develop/githubMcpAdapter.ts`: add `{ timeoutMs: 60_000 }` as 4th arg to `callTool`; extend `repoUrl` extraction to try `response.html_url`, `response.url`, `response.clone_url` in order; extend `repoName` extraction to try `response.name`, `response.full_name` before falling back to `options.name`
86
+ - [x] T019 [US1] Update `GitHubMcpAdapter.pushFiles()` in `src/develop/githubMcpAdapter.ts`: add helper to extract `owner` and `repo` from `repoUrl` (parse `github.com/{owner}/{repo}` pattern); pass `owner`, `repo` separately (not `repoUrl`); add `{ timeoutMs: 60_000 }` as 4th arg; extend `commitSha` extraction to try `response.sha` then `response.commit?.sha`
87
+ - [x] T020 [US1] Update `McpContextEnricher.queryContext7()` in `src/develop/mcpContextEnricher.ts`: add `{ timeoutMs: 30_000 }` to both `callTool` calls; add `response.id` fallback when `response.libraryId` missing; add `response.text` fallback when `response.content` missing for doc text; enforce 5-dependency limit on non-skipped packages
88
+ - [x] T021 [US1] Update `McpContextEnricher.queryAzureMcp()` in `src/develop/mcpContextEnricher.ts`: add `{ timeoutMs: 30_000 }` to `callTool`; add `response.text` fallback when `response.content` missing
89
+ - [x] T022 [US1] Update `McpContextEnricher.queryWebSearch()` in `src/develop/mcpContextEnricher.ts`: add MCP-based search as primary path — `callTool('websearch', 'search', { query }, { timeoutMs: 30_000 })` when `mcpManager.isAvailable('websearch')`; retain Azure AI Foundry bridge as fallback; add `response.text` fallback for content
90
+ - [x] T023 [US1] Update `McpContextEnricher.enrich()` in `src/develop/mcpContextEnricher.ts`: run `queryContext7()` and `queryAzureMcp()` concurrently using `Promise.allSettled()`; web search (`queryWebSearch()`) runs sequentially after both complete; ensure web search is gated by `stuckIterations >= 2` per `contracts/context-enricher.md` (depends on T020–T022)
91
+
92
+ **Checkpoint**: US1 complete — `McpManager.callTool()` dispatches real tool calls; all four adapters (GitHub, Context7, Azure, WebSearch) use real transport; all unit and integration tests pass.
93
+
94
+ ---
95
+
96
+ ## Phase 4: User Story 2 — GitHub MCP Pushes Real File Content (Priority: P1)
97
+
98
+ **Goal**: Fix the Ralph Loop to push the initial scaffold files to GitHub immediately after `npm install` completes, so the remote repository always reflects the full PoC state from iteration 1 onward.
99
+
100
+ **Independent Test**: Run a Ralph Loop iteration in a test with a mock GitHub adapter; verify `pushFiles` is called after scaffold with non-empty file content read from disk for each `scaffoldResult.createdFiles` entry.
101
+
102
+ ### Tests for User Story 2 (REQUIRED — write FIRST, verify they FAIL before implementing)
103
+
104
+ - [x] T024 [US2] Add failing test to `tests/unit/develop/ralphLoop.spec.ts`: after scaffold and npm install complete, `mockGithubAdapter.pushFiles` is called once with all `scaffoldResult.createdFiles` paths and each file's actual disk content (non-empty strings); verify this push happens before the first test-run iteration begins
105
+
106
+ ### Implementation for User Story 2
107
+
108
+ - [x] T025 [US2] Add post-scaffold push to `src/develop/ralphLoop.ts`: immediately after npm install succeeds (before the iteration loop begins), if `githubAdapter?.isAvailable()` and `githubAdapter.getRepoUrl()` is set, read all `scaffoldResult.createdFiles` from disk using the existing `readFile(resolve(outputDir, f), 'utf-8')` pattern, filter out unreadable files with a `warn` log, then call `githubAdapter.pushFiles({ repoUrl, files, commitMessage: 'chore: initial scaffold', branch: 'main' })`; on pushFiles failure, log `warn` and continue (non-fatal)
109
+
110
+ **Checkpoint**: US2 complete — scaffold files are pushed to GitHub with real content immediately after `npm install`; per-iteration pushes remain correct.
111
+
112
+ ---
113
+
114
+ ## Phase 5: User Story 3 — Discovery Phase Uses Web Search (Priority: P2)
115
+
116
+ **Goal**: After the user provides company and team information in Step 1 of the discovery workshop, sofIA optionally searches the web for recent company news, competitor activity, and industry trends, storing results in the session for downstream phases.
117
+
118
+ **Independent Test**: Start a workshop session, provide company info, verify that sofIA offers to search the web, and confirm that results are stored in `session.discovery.enrichment` and persisted to the session JSON.
119
+
120
+ ### Tests for User Story 3 (REQUIRED — write FIRST, verify they FAIL before implementing)
121
+
122
+ - [x] T026 [P] [US3] Create `tests/unit/phases/discoveryEnricher.spec.ts` with failing tests for `DiscoveryEnricher.enrichFromWebSearch()`: calls `webSearchClient.search()` with queries for company news, competitor activity, and industry trends; populates `companyNews`, `competitorInfo`, `industryTrends` from results; returns gracefully with empty arrays when `webSearchClient.search()` throws; sets `sourcesUsed: ['websearch']` and `enrichedAt` timestamp
123
+ - [x] T027 [P] [US3] Add failing tests to `tests/unit/phases/discoveryEnricher.spec.ts` that the discovery phase offers enrichment per FR-014: when web search is configured + interactive, `io.prompt()` is used to ask permission before running web search; declining skips web search and stores empty enrichment
124
+ - [x] T028 [P] [US3] Add failing tests to `tests/unit/phases/discoveryEnricher.spec.ts` for session schema integration: `DiscoveryEnrichmentSchema` parses valid enrichment; validates that `enrichedAt` is ISO 8601 when present; validates `sourcesUsed` entries are lowercase; session with `discovery.enrichment` round-trips through `workshopSessionSchema.parse()`
125
+ - [x] T029 [US3] Create `tests/integration/discoveryEnrichmentFlow.spec.ts`: simulate Step 1 completion in `phaseHandlers.ts` discover handler, verify the user is offered web search enrichment (FR-014), verify `DiscoveryEnricher.enrichFromWebSearch()` is called only when consented, verify session is updated with `discovery.enrichment` containing web search data, and verify enrichment is included in the Ideate phase system prompt context
126
+
127
+ ### Implementation for User Story 3
128
+
129
+ - [x] T030 [US3] Add `DiscoveryEnrichmentSchema` and `DiscoveryEnrichment` type to `src/shared/schemas/session.ts` — exact schema per `specs/003-mcp-transport-integration/data-model.md` Entity 4; all fields optional; enforce max 10 items per array field via `.max(10)` on each array
130
+ - [x] T031 [US3] Add `DiscoveryStateSchema` to `src/shared/schemas/session.ts` with `enrichment: DiscoveryEnrichmentSchema.optional()` field, and add `discovery: DiscoveryStateSchema.optional()` to `workshopSessionSchema` (depends on T030)
131
+ - [x] T032 [US3] Create `src/phases/discoveryEnricher.ts` with `DiscoveryEnricher` class and `enrichFromWebSearch()` method: accepts `companySummary` and a `webSearchClient`; builds 3 search queries (company news, competitor activity, industry trends); calls `webSearchClient.search()` for each; populates `companyNews`, `competitorInfo`, `industryTrends` from results; sets `sourcesUsed` and `enrichedAt`; degrades gracefully on errors (depends on T030)
132
+ - [x] T033 [US3] Update `src/phases/phaseHandlers.ts` discover handler `extractResult()`: after extracting `businessContext`, if web search is configured and IO is interactive, offer web search enrichment per FR-014 (prompt default No); when consented, call `DiscoveryEnricher.enrichFromWebSearch()` and store the result in `session.discovery.enrichment`; when declined or unavailable, store empty enrichment and continue (depends on T031, T032)
133
+
134
+ **Checkpoint**: US3 complete — discovery phase offers and executes web search enrichment; results stored in `session.discovery.enrichment`; graceful degradation when web search unavailable.
135
+
136
+ ---
137
+
138
+ ## Phase 6: User Story 4 — WorkIQ Integration for Internal Context (Priority: P3)
139
+
140
+ **Goal**: After Step 1, sofIA optionally queries WorkIQ (with explicit user consent) to retrieve team collaboration patterns, expertise areas, and documentation gaps, storing them alongside web search results in the session.
141
+
142
+ **Independent Test**: With a mock WorkIQ MCP server available, verify that sofIA asks for permission before querying, stores insights in `session.discovery.enrichment.workiqInsights` when consented, and skips WorkIQ entirely when the user declines or server is unavailable.
143
+
144
+ ### Tests for User Story 4 (REQUIRED — write FIRST, verify they FAIL before implementing)
145
+
146
+ - [x] T034 [P] [US4] Add failing tests for `DiscoveryEnricher.enrichFromWorkIQ()` to `tests/unit/phases/discoveryEnricher.spec.ts`: prompts user for consent via `io` before any `callTool` call; when user consents, calls `mcpManager.callTool('workiq', 'analyze_team', ...)` and extracts `teamExpertise`, `collaborationPatterns`, `documentationGaps`; adds `'workiq'` to `sourcesUsed`; returns empty `workiqInsights` when user declines (no callTool call); returns empty `workiqInsights` gracefully when `callTool` throws
147
+ - [x] T035 [P] [US4] Add failing tests for `DiscoveryEnricher.enrich()` orchestrator to `tests/unit/phases/discoveryEnricher.spec.ts`: calls `enrichFromWorkIQ()` if WorkIQ is available; merges WorkIQ results into a `DiscoveryEnrichment` object; returns valid `DiscoveryEnrichment` with all empty fields when WorkIQ fails
148
+
149
+ ### Implementation for User Story 4
150
+
151
+ - [x] T036 [US4] Implement `DiscoveryEnricher.enrichFromWorkIQ()` in `src/phases/discoveryEnricher.ts`: display consent prompt via `io.prompt()` or `@inquirer/prompts` confirm; if declined, return empty `Partial<DiscoveryEnrichment>`; if consented and `mcpManager.isAvailable('workiq')`, call `mcpManager.callTool('workiq', 'analyze_team', { summary: companySummary, focus: ['expertise', 'collaboration', 'documentation'] }, { timeoutMs: 30_000 })`; extract `teamExpertise`, `collaborationPatterns`, `documentationGaps` from response (fallback: `response.insights` split by newline); handle auth case with a clear message; add `'workiq'` to `sourcesUsed` on success (depends on T032)
152
+ - [x] T037 [US4] Extend discovery enrichment to store WorkIQ insights in `session.discovery.enrichment.workiqInsights` when consented, and to proceed normally (no errors) when declined/unavailable per FR-016–FR-018 (wire-up lives in `phaseHandlers.ts` alongside the web-search offer)
153
+
154
+ **Checkpoint**: US4 complete — WorkIQ integration functional with permission gate; all discovery enrichment sources merged; graceful degradation confirmed.
155
+
156
+ ---
157
+
158
+ ## Phase 7: User Story 5 — Copilot SDK Agent Architecture Alignment (Priority: P2)
159
+
160
+ **Status: PARTIALLY FULFILLED** — `research.md` Topic 7 documents that the current `src/` agent definitions are already aligned with Copilot SDK v0.1.28 conventions. **However**, the SDK compliance review identified three gaps: (1) native `mcpServers` support requires wiring `.vscode/mcp.json` config through `createSession()` (Topics 1, 7); (2) SDK hooks (`onPreToolUse`/`onPostToolUse`) must be wired for CLI tool-call visibility per Constitution Principle VIII (Topic 8); (3) `infiniteSessions` should be configured for Ralph Loop sessions to prevent context window exhaustion (Topic 9).
161
+
162
+ ### Tests for SDK mcpServers wiring (REQUIRED — write FIRST)
163
+
164
+ - [x] T049 [P] [US5] Add failing tests to `tests/unit/mcp/mcpManager.spec.ts` for `toSdkMcpServers()`: verify it converts `StdioServerConfig` to `{ type: 'stdio', command, args, env?, cwd?, tools?, timeout? }` format; verify it converts `HttpServerConfig` to `{ type: 'http', url, headers?, tools?, timeout? }` format; verify it returns empty object for empty `McpConfig.servers`
165
+ - [x] T050 [P] [US5] Add failing tests to `tests/unit/shared/copilotClient.spec.ts` for `SessionOptions.mcpServers`: verify that when `mcpServers` is provided, it is forwarded to the SDK's `createSession()` call; verify that when `mcpServers` is omitted or empty, it is NOT passed to the SDK
166
+
167
+ ### Implementation for SDK mcpServers wiring
168
+
169
+ - [x] T051 [US5] Wire `loadMcpConfig()` → `toSdkMcpServers()` → `createSession({ mcpServers })` in the application entry point: load `.vscode/mcp.json` via `loadMcpConfig()`, convert via `toSdkMcpServers()`, and pass the result through `SessionOptions.mcpServers` so the Copilot SDK manages MCP server lifecycle for LLM-initiated tool calls (depends on T049, T050)
170
+
171
+ ### Tests for SDK hooks and transparency (REQUIRED — write FIRST)
172
+
173
+ - [x] T052 [P] [US5] Add failing tests to `tests/unit/shared/copilotClient.spec.ts` for SDK hooks integration: verify that `SessionOptions` accepts a `hooks` object with `onPreToolUse` and `onPostToolUse` callbacks; verify that when `hooks` is provided, it is forwarded to the SDK's `createSession()` call; verify that when `hooks` is omitted, no hooks are passed to the SDK
174
+
175
+ ### Implementation for SDK hooks, infiniteSessions, and events
176
+
177
+ - [x] T053 [US5] Wire SDK `onPreToolUse`/`onPostToolUse` hooks in `src/shared/copilotClient.ts`: add `hooks?: { onPreToolUse?: (toolName: string, toolArgs: Record<string, unknown>) => void; onPostToolUse?: (toolName: string, result: unknown, durationMs: number) => void; onErrorOccurred?: (error: Error) => void }` to `SessionOptions`; forward hooks to SDK `createSession({ hooks })` so tool-call activity (tool name, start/end, duration) is emitted to the CLI spinner via the existing activity event system in `src/shared/events.ts`; wire `onErrorOccurred` to log SDK-path errors at `warn` level (FR-021, FR-022) (depends on T052)
178
+ - [x] T054 [P] [US5] Wire `infiniteSessions` config to Ralph Loop `createSession()` calls in `src/develop/ralphLoop.ts`: pass `infiniteSessions: { backgroundCompactionThreshold: 0.7, bufferExhaustionThreshold: 0.9 }` to prevent context window exhaustion during extended multi-iteration conversations (FR-023); add unit test in `tests/unit/develop/ralphLoop.spec.ts` verifying the config is forwarded
179
+ - [x] T055 [P] [US5] Subscribe to SDK `assistant.usage` event in the conversation loop (`src/loop/conversationLoop.ts`): log token usage (input/output tokens) at `debug` level via pino logger; optionally emit cumulative usage as an activity event for the CLI spinner (FR-024); add unit test in `tests/unit/loop/conversationLoop.spec.ts` verifying event subscription
180
+
181
+ - [x] T038 Confirm no regressions from US1 and US5 changes by running `npm run test:unit` and verifying all existing `tests/unit/` specs remain green after the McpManager, copilotClient, hooks, and adapter updates
182
+
183
+ ---
184
+
185
+ ## Phase 8: Polish & Cross-Cutting Concerns
186
+
187
+ **Purpose**: Live smoke tests, linting, and typecheck pass — feature is production-ready.
188
+
189
+ - [x] T039 [P] Create `tests/e2e/mcpLive.spec.ts` with live MCP smoke tests gated behind `SOFIA_LIVE_MCP_TESTS=true`: GitHub MCP creates and deletes a test repository; Context7 resolves `express` library ID; Azure MCP returns documentation for a simple query; web search returns results for a test query — each test uses `describe.skipIf(!LIVE)` pattern per quickstart.md Section 8
190
+ - [x] T040 Validation task: satisfy SC-003-004 by running one controlled Ralph Loop scenario twice (same plan + failing tests), once with enrichment disabled and once with enrichment enabled, and compare iteration counts to green; record the comparison in test output or quickstart notes
191
+ - [x] T041 Validation task: satisfy SC-003-005 by running discovery web-search enrichment for 5 test company descriptions and confirming at least 3/5 have keyword-relevant results; record outcomes in quickstart notes
192
+ - [x] T043 [P] Live validation task: satisfy SC-003-006 by running WorkIQ enrichment in a configured environment and asserting the tool call completes within 10 seconds and persists `session.discovery.enrichment.workiqInsights` (gate behind `SOFIA_LIVE_MCP_TESTS=true`)
193
+ - [x] T044 [P] Add a timeout validation test for SC-003-007: force a short `timeoutMs` on an MCP call (HTTP and stdio) and assert a classified `timeout` error is returned/thrown and handled gracefully by adapters
194
+ - [x] T045 Run `npm run lint` and fix any `import/order` warnings introduced in Feature 003 files (blank line between external and internal import groups)
195
+ - [x] T046 Run `npm run typecheck` (`tsc --noEmit`) and fix all type errors — ensure `DiscoveryEnrichment` Zod schema types are correctly inferred and used throughout `discoveryEnricher.ts` and `phaseHandlers.ts`
196
+ - [x] T047 Run full `npm test` suite and confirm all unit, integration tests pass; e2e tests skipped in CI (not gated by `SOFIA_LIVE_MCP_TESTS=true`)
197
+ - [x] T048 Run `npm run test` with `SOFIA_LIVE_MCP_TESTS=true` in a configured environment to validate live MCP smoke tests (requires `GITHUB_TOKEN`, `AZURE_SUBSCRIPTION_ID`, and MCP servers accessible)
198
+
199
+ ---
200
+
201
+ ## Dependencies & Execution Order
202
+
203
+ ### Phase Dependencies
204
+
205
+ - **Setup (Phase 1 — T001)**: No dependencies — run immediately
206
+ - **Foundational (Phase 2 — T002–T003)**: Depends on T001 — **BLOCKS all US1 implementation**
207
+ - **US1 Tests (T004–T010)**: Depend on T002–T003 (types must exist to import); can be written before implementation (RED phase)
208
+ - **US1 Integration (T011, T042)**: Depends on T002–T003; can be written early but typically completes after US1 implementation exists
209
+ - **US1 Implementation (T012–T023)**: Depend on T002–T003; each implementation task may depend on prior transport tasks
210
+ - **US2 (T024–T025)**: Depends only on T001 — independent of US1 transport layer (different module)
211
+ - **US3 (T026–T033)**: Depends on T001 — independent of US1 and US2
212
+ - **US4 (T034–T037)**: Depends on T032 (DiscoveryEnricher class must exist from US3)
213
+ - **US5 (T049–T055, T038)**: T049–T052 tests can start after T001; T051 depends on T049, T050; T053 depends on T052; T054 and T055 are independent (can start after T001); T038 depends on US1 and US5 implementation being complete (verifies no regressions)
214
+ - **Polish (T039–T048)**: Depends on all US phases being complete
215
+
216
+ ### User Story Dependencies
217
+
218
+ - **US1 (P1)**: Depends on Phase 2 (Foundational) — no other story dependency
219
+ - **US2 (P1)**: Independent — can start immediately after T001 in parallel with US1
220
+ - **US3 (P2)**: Independent — can start after T001 in parallel with US1 and US2
221
+ - **US4 (P3)**: Depends on US3 (T032 — DiscoveryEnricher class must exist)
222
+ - **US5 (P2)**: T049–T050 tests can start after T001 (types exist in mcpManager.ts); T051 wiring depends on T049, T050; T052 test can start after T001; T053 depends on T052; T054 and T055 are independent, parallelizable after T001; T038 verification after US1 and US5 implementation
223
+
224
+ ### Within Each User Story
225
+
226
+ 1. Tests MUST be written and confirmed FAILING before implementation
227
+ 2. In US1: transport core + retry (T012–T015) before McpManager (T016–T017) before adapter/enricher updates (T018–T023)
228
+ 3. In US3: schema (T030–T031) before enricher class (T032) before phase handler wiring (T033)
229
+ 4. In US4: enricher class must exist (T032) before WorkIQ method (T036) before wiring/storage (T037)
230
+ 5. In US5: mcpServers tests (T049–T050) before wiring (T051); hooks test (T052) before hooks impl (T053); T054 and T055 are independent
231
+
232
+ ### Parallel Opportunities
233
+
234
+ **Phase 2**:
235
+
236
+ - T002 and T003 can run in parallel (different files)
237
+
238
+ **US1 Tests**:
239
+
240
+ - T004, T005, T006, T007, T008, T009, T010 can all run in parallel (different test files or additive to existing files with no conflicts)
241
+
242
+ **US2 and US1**:
243
+
244
+ - US2 (T024–T025) can be worked on in parallel with US1 (different modules: `ralphLoop.ts` vs `mcpTransport.ts`)
245
+
246
+ **US3 and US1/US2**:
247
+
248
+ - US3 (T026–T033) can be worked on in parallel with US1 and US2 (different modules: `session.ts`, `discoveryEnricher.ts`, `phaseHandlers.ts`)
249
+
250
+ **US5 Internal**:
251
+
252
+ - T049, T050, T052 (test tasks) can all run in parallel (different test files)
253
+ - T054 and T055 are independent of each other and of T051/T053 (different modules: `ralphLoop.ts`, `conversationLoop.ts`)
254
+
255
+ ---
256
+
257
+ ## Parallel Example: US1 Tests (all can run concurrently)
258
+
259
+ ```bash
260
+ # Launch all US1 test files simultaneously:
261
+ Task: "Write HttpMcpTransport tests in tests/unit/mcp/mcpTransport.spec.ts" (T004)
262
+ Task: "Write StdioMcpTransport tests in tests/unit/mcp/mcpTransport.spec.ts" (T005)
263
+ Task: "Write withRetry tests in tests/unit/mcp/retryPolicy.spec.ts" (T006)
264
+ Task: "Add McpManager.callTool() tests to tests/unit/mcp/mcpManager.spec.ts" (T007)
265
+ Task: "Add contract test cases to tests/unit/develop/githubMcpAdapter.spec.ts" (T008)
266
+ Task: "Add contract test cases to tests/unit/develop/mcpContextEnricher.spec.ts" (T009)
267
+ ```
268
+
269
+ ## Parallel Example: US1, US2, US3 (can be worked by different developers)
270
+
271
+ ```bash
272
+ # Developer A: US1 transport layer
273
+ Task: "Implement HttpMcpTransport in src/mcp/mcpTransport.ts" (T012)
274
+
275
+ # Developer B: US2 post-scaffold push (independent module)
276
+ Task: "Add post-scaffold push test to tests/unit/develop/ralphLoop.spec.ts" (T024)
277
+
278
+ # Developer C: US3 discovery enrichment schema (independent module)
279
+ Task: "Add DiscoveryEnrichmentSchema to src/shared/schemas/session.ts" (T030)
280
+ ```
281
+
282
+ ---
283
+
284
+ ## Implementation Strategy
285
+
286
+ ### MVP First (User Stories 1 + 2 Only)
287
+
288
+ 1. Complete Phase 1: Verify baseline
289
+ 2. Complete Phase 2: Transport abstractions (T002–T003)
290
+ 3. Complete US1: Transport layer + real MCP dispatch (T004–T023) and integration/degradation (T011, T042)
291
+ 4. Complete US2: Post-scaffold push fix (T024–T025)
292
+ 5. **STOP and VALIDATE**: Run `SOFIA_LIVE_MCP_TESTS=true npm test` in configured environment
293
+ 6. Deploy/demo with working GitHub adapter, Context7 enricher, Azure enricher, and web search
294
+
295
+ ### Incremental Delivery
296
+
297
+ 1. Phase 1 + Phase 2 → Foundation ready
298
+ 2. US1 → Working transport layer → Test with real MCP servers (MVP!)
299
+ 3. US2 → Scaffold push fixed → Demo complete PoC round-trip
300
+ 4. US3 → Discovery enrichment → Richer ideation phase
301
+ 5. US4 → WorkIQ integration → Internal context available
302
+ 6. US5 → SDK hooks for tool visibility, `infiniteSessions` for context management, usage tracking → CLI transparency complete
303
+ 7. Polish → Live smoke tests + CI green
304
+
305
+ ### Parallel Team Strategy
306
+
307
+ With three developers after Phase 2 completes:
308
+
309
+ - **Developer A**: US1 (transport layer — T004–T023)
310
+ - **Developer B**: US2 (post-scaffold push — T024–T025)
311
+ - **Developer C**: US3 (discovery enrichment — T026–T033)
312
+
313
+ US4 begins when US3's T032 is merged. US5 (verification) runs after US1 merges.
314
+
315
+ ---
316
+
317
+ ## Notes
318
+
319
+ - `[P]` tasks = different files, no dependencies on incomplete tasks — safe to parallelize
320
+ - Follow the "Dependencies & Execution Order" section to sequence work; task IDs are unique but may not strictly encode dependency order after updates
321
+ - Adapter unit tests (githubMcpAdapter.spec.ts, mcpContextEnricher.spec.ts) already cover basic `callTool()` integration via mocks — Tasks T008/T009 ADD new contract-specific test cases, not replace existing ones
322
+ - Live smoke tests (T039, T048) require real credentials; they are gated by `SOFIA_LIVE_MCP_TESTS=true` and are NOT run in CI
323
+ - US5 (SDK alignment) now includes SDK `mcpServers` wiring (T049–T051), hooks integration for CLI transparency (T052–T053), `infiniteSessions` for Ralph Loop context management (T054), and SDK event subscriptions (T055) — per SDK compliance review (research.md Topics 7–9)
324
+ - The `DiscoveryState` entity described in data-model.md does not exist yet in `session.ts` — T031 creates it; existing sessions remain valid because the field is `optional()`
@@ -0,0 +1,150 @@
1
+ # Next Spec: Gaps & Deferred Work from Feature 002
2
+
3
+ **Date**: 2026-02-28
4
+ **Source**: Post-implementation review of specs/002-poc-generation/
5
+ **Purpose**: Capture outstanding gaps, stubs, and deferred items that must be addressed in the next feature spec(s).
6
+
7
+ ---
8
+
9
+ ## P1 — Blocking for Production
10
+
11
+ ### GAP-001: MCP Tool Invocation Layer
12
+
13
+ `McpManager` ([src/mcp/mcpManager.ts](../src/mcp/mcpManager.ts)) tracks configuration and connection status but provides **no `callTool()` method**. Every component that needs to invoke an MCP tool (GitHub adapter, Context7 enricher, Azure enricher, web search enricher) currently simulates the call with hardcoded responses.
14
+
15
+ **Impact**: None of the MCP integrations actually work in production.
16
+
17
+ **Files affected**:
18
+
19
+ - `src/mcp/mcpManager.ts` — needs a `callTool(serverName, toolName, args)` method
20
+ - `src/develop/githubMcpAdapter.ts` — `createRepository()` and `pushFiles()` return fake data
21
+ - `src/develop/mcpContextEnricher.ts` — `queryContext7()`, `queryAzureMcp()`, `queryWebSearch()` all return hardcoded strings
22
+
23
+ **Recommendation**: Feature 003 should implement a generic `McpManager.callTool()` that connects to the configured MCP server, invokes the named tool with arguments, and returns structured results. Then update all adapters/enrichers to use it.
24
+
25
+ ### GAP-002: GitHub MCP Adapter — Real Integration
26
+
27
+ [src/develop/githubMcpAdapter.ts](../src/develop/githubMcpAdapter.ts) lines 82–88 and 111–118:
28
+
29
+ - `createRepository()` returns a fake URL (`https://github.com/poc-owner/...`) instead of calling the `create_repository` MCP tool.
30
+ - `pushFiles()` returns a random fake SHA instead of calling `create_or_update_file` MCP tools.
31
+
32
+ **Recommendation**: Wire to real GitHub MCP tools once GAP-001 is resolved. Add live integration tests gated behind an environment flag.
33
+
34
+ ### GAP-003: GitHub Adapter pushFiles Sends Empty Content
35
+
36
+ [src/develop/ralphLoop.ts](../src/develop/ralphLoop.ts) lines 459–462: when calling `pushFiles`, the file list maps written files with `content: ''` (empty string). Even once the adapter is wired to real MCP, it would push empty files.
37
+
38
+ **Fix**: Read file content from disk before pushing, or pass content through from `CodeGenerator` output.
39
+
40
+ ### GAP-004: Context7 / Azure MCP / Web Search Enrichment — Real Integration
41
+
42
+ [src/develop/mcpContextEnricher.ts](../src/develop/mcpContextEnricher.ts):
43
+
44
+ - `queryContext7()` (L127–152) returns hardcoded npmjs.com links based on dependency names instead of calling Context7 MCP
45
+ - `queryAzureMcp()` (L158–176) returns hardcoded guidance strings based on keyword detection instead of calling Azure/Microsoft Docs MCP
46
+ - `queryWebSearch()` (L183–195) returns a placeholder "no results" string instead of calling `web.search`
47
+
48
+ ### GAP-005: Web Search Enrichment & WorkIQ usage during the first phase of the discovery.
49
+
50
+ **Recommendation**: Implement real MCP tool calls via GAP-001's `callTool()`. Add graceful degradation tests with real (but optional) MCP servers.
51
+
52
+ Add a step in the first step of the discovery phase, just after the company and team information is gathered, to optionally call a web search MCP tool to gather recent news about the company, its competitors, and the industry. This information can be stored in the `DiscoveryState` and used to inform the ideation and planning phases, ensuring that the PoC is aligned with current market trends and challenges.
53
+
54
+ Use WorkIQ to analyze current internal documentation, codebase, and team expertise to identify potential areas of strength and weakness that the PoC could leverage or address. This analysis can be integrated into the discovery phase to help shape the problem statement and solution approach. Ask for permission to use it as it may require access to sensitive internal information. If permission is granted, WorkIQ can provide insights that enhance the relevance and impact of the PoC.
55
+
56
+ ### GAP-006: MCP Usage with GitHub Copilot SDK
57
+
58
+ Research how MCP is used in the GitHub Copilot SDK and ensure that our `McpManager` implementation is compatible with the expected patterns for authentication, tool invocation, and result handling. This may involve implementing specific authentication flows (e.g., OAuth) or adhering to certain request/response formats required by the Copilot SDK.
59
+
60
+ ### GAP-007: Agent definition and orchestration with GitHub Copilot SDK
61
+
62
+ Identify if the defined agents are correctly structured to work with the GitHub Copilot SDK. This includes ensuring that the agents can be invoked, that they can handle the expected input and output formats and have access to the necessary context and tools. It may also involve defining specific agent behaviors or capabilities that align with the features provided by the Copilot SDK.
63
+
64
+ ---
65
+
66
+ ## P2 — Important, Workarounds Exist
67
+
68
+ ### GAP-006: No Resume/Checkpoint for `sofia dev`
69
+
70
+ `RalphLoop.run()` always starts from scratch: scaffold → install → iterate. There is no detection of an existing PoC directory or prior `poc.iterations` state. Running `sofia dev --session X` a second time re-scaffolds everything.
71
+
72
+ The CLI recovery message at [src/cli/developCommand.ts](../src/cli/developCommand.ts) L211–213 suggests "Resume: sofia dev --session ..." but the command does not actually resume.
73
+
74
+ **Recommendation**: Detect existing PoC output and `poc.iterations` in the session. If found, skip scaffolding and resume from the last iteration number. Honor `--force` to override this.
75
+
76
+ ### GAP-007: `--force` Flag Declared but Not Implemented
77
+
78
+ `developCommand.ts` declares the `--force` option in `DevelopCommandOptions` and it's accepted by the CLI, but the flag is never read or acted upon in the command handler.
79
+
80
+ **Recommendation**: When `--force` is set, delete the existing output directory and reset `poc.iterations` before starting.
81
+
82
+ ### GAP-008: testRunner.ts at 45% Coverage
83
+
84
+ [src/develop/testRunner.ts](../src/develop/testRunner.ts) has significant untested code paths:
85
+
86
+ - `spawnTests()` method (L71–151) — child process spawning, stdout/stderr collection, timeout/SIGTERM/SIGKILL
87
+ - `extractJson()` fallback path (L220–221) — parsing JSON from mixed output
88
+ - `buildErrorResult()` private method (L256) — timeout-triggered error path
89
+
90
+ **Recommendation**: Add integration tests that spawn a real test process (e.g., a tiny Vitest project) to cover these paths. Consider extracting the spawn logic into a testable wrapper.
91
+
92
+ ### GAP-009: PoC Template Selection Not Finalized
93
+
94
+ The plan notes "v1 targets TypeScript + Vitest PoCs only (template: `node-ts-vitest`); other templates deferred." The spec's Open Items section asks to "Finalize the PoC repo technology templates and how they map from the plan's architecture notes."
95
+
96
+ Currently `PocScaffolder` always generates a Node.js/TypeScript/Vitest project regardless of what the plan's `architectureNotes` or `dependencies` specify.
97
+
98
+ **Recommendation**: Define a template registry mapping plan characteristics (language, framework) to scaffold templates. Start with Python/FastAPI as the next template.
99
+
100
+ ---
101
+
102
+ ## P3 — Nice-to-Have / Deferred
103
+
104
+ ### GAP-009: Generated Scaffold Contains Intentional TODOs
105
+
106
+ [src/develop/pocScaffolder.ts](../src/develop/pocScaffolder.ts):
107
+
108
+ - L195: generated `src/index.ts` contains `TODO: Implement the core functionality`
109
+ - L233: generated test contains `TODO: sofIA Ralph loop will refine this test`
110
+
111
+ These are intentional — the Ralph loop is expected to replace them. Not a bug, but worth noting for template quality tracking.
112
+
113
+ ### GAP-010: PTY-Based Interactive E2E Tests for `sofia dev`
114
+
115
+ The `sofia dev` command lacks PTY-based interactive E2E tests (Ctrl+C handling, spinner output, progress display). The existing E2E tests in `developE2e.spec.ts` test via function calls, not CLI subprocess interaction.
116
+
117
+ **Recommendation**: Add PTY tests similar to `newSession.e2e.spec.ts` for the dev command interactive scenarios.
118
+
119
+ ### GAP-011: Workshop Develop Phase Transition
120
+
121
+ The `workshop` command can run through Discover → Ideate → Design → Select → Plan, but transitioning from Plan into Develop within the workshop flow (rather than via `sofia dev`) is handled by a boundary prompt (`develop-boundary.md`) that only captures PoC intent. The actual Ralph loop is only triggered via the standalone `sofia dev` command.
122
+
123
+ **Recommendation**: Consider whether the workshop command should auto-invoke the Ralph loop after Plan completion, or if the two-command workflow (`workshop` then `dev`) is intentional and should be documented more prominently.
124
+
125
+ ---
126
+
127
+ ## Spec Open Items — Resolution Status
128
+
129
+ From [specs/002-poc-generation/spec.md](002-poc-generation/spec.md) "Open Items":
130
+
131
+ | # | Open Item | Status |
132
+ | --- | --------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
133
+ | 1 | Finalize the PoC repo technology templates | **Open** — only `node-ts-vitest` exists (see GAP-008) |
134
+ | 2 | Define the exact shape of `PocDevelopmentState` fields | **Resolved** — fully defined in Zod schemas |
135
+ | 3 | Confirm which parts of Ralph loop run locally vs via GitHub MCP | **Partially resolved** — architecture is correct but MCP path is simulated (see GAP-001 through GAP-004) |
136
+
137
+ ---
138
+
139
+ ## Suggested Next Feature Spec: `003-mcp-integration`
140
+
141
+ Based on the gaps above, the next feature should focus on:
142
+
143
+ 1. **Generic MCP tool invocation** — `McpManager.callTool()` with typed results, retries, timeouts
144
+ 2. **GitHub MCP real integration** — create repo, push files, with auth flow
145
+ 3. **Context7 real integration** — library documentation lookup for PoC dependencies
146
+ 4. **Azure/Microsoft Docs MCP integration** — architecture guidance for Azure-based plans
147
+ 5. **Web search integration** — research when Ralph loop iterations get stuck
148
+ 6. **Dev command resume/force** — checkpoint detection and `--force` overwrite
149
+ 7. **Additional scaffold templates** — Python/FastAPI as second template
150
+ 8. **TestRunner coverage hardening** — spawn-based integration tests
@@ -0,0 +1,37 @@
1
+ # Specification Quality Checklist: Dev Resume & Hardening
2
+
3
+ **Purpose**: Validate specification completeness and quality before proceeding to planning
4
+ **Created**: 2026-03-01
5
+ **Feature**: [specs/004-dev-resume-hardening/spec.md](../spec.md)
6
+
7
+ ## Content Quality
8
+
9
+ - [x] No implementation details (languages, frameworks, APIs)
10
+ - [x] Focused on user value and business needs
11
+ - [x] Written for non-technical stakeholders
12
+ - [x] All mandatory sections completed
13
+
14
+ ## Requirement Completeness
15
+
16
+ - [x] No [NEEDS CLARIFICATION] markers remain
17
+ - [x] Requirements are testable and unambiguous
18
+ - [x] Success criteria are measurable
19
+ - [x] Success criteria are technology-agnostic (no implementation details)
20
+ - [x] All acceptance scenarios are defined
21
+ - [x] Edge cases are identified
22
+ - [x] Scope is clearly bounded
23
+ - [x] Dependencies and assumptions identified
24
+
25
+ ## Feature Readiness
26
+
27
+ - [x] All functional requirements have clear acceptance criteria
28
+ - [x] User scenarios cover primary flows
29
+ - [x] Feature meets measurable outcomes defined in Success Criteria
30
+ - [x] No implementation details leak into specification
31
+
32
+ ## Notes
33
+
34
+ - Template names like `node-ts-vitest` and `python-pytest` are domain terms (user-facing template identifiers), not implementation details.
35
+ - References to `.sofia-metadata.json`, `node_modules/`, `package-lock.json` are user-visible artifacts that users interact with, not internal implementation.
36
+ - The spec references specific source files in the Overview for context but requirements are expressed in terms of user behavior and system capabilities.
37
+ - FR-014 mentions `TechStack` shape — this is a spec-level entity concept, not a code-level type reference.