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.
- package/.github/agents/copilot-instructions.md +39 -0
- package/.github/agents/speckit.analyze.agent.md +184 -0
- package/.github/agents/speckit.checklist.agent.md +294 -0
- package/.github/agents/speckit.clarify.agent.md +181 -0
- package/.github/agents/speckit.constitution.agent.md +84 -0
- package/.github/agents/speckit.implement.agent.md +135 -0
- package/.github/agents/speckit.plan.agent.md +90 -0
- package/.github/agents/speckit.specify.agent.md +258 -0
- package/.github/agents/speckit.tasks.agent.md +137 -0
- package/.github/agents/speckit.taskstoissues.agent.md +30 -0
- package/.github/copilot-instructions.md +257 -0
- package/.github/prompts/speckit.analyze.prompt.md +3 -0
- package/.github/prompts/speckit.checklist.prompt.md +3 -0
- package/.github/prompts/speckit.clarify.prompt.md +3 -0
- package/.github/prompts/speckit.constitution.prompt.md +3 -0
- package/.github/prompts/speckit.implement.prompt.md +3 -0
- package/.github/prompts/speckit.plan.prompt.md +3 -0
- package/.github/prompts/speckit.specify.prompt.md +3 -0
- package/.github/prompts/speckit.tasks.prompt.md +3 -0
- package/.github/prompts/speckit.taskstoissues.prompt.md +3 -0
- package/.github/workflows/ci.yml +38 -0
- package/.prettierrc +6 -0
- package/.specify/memory/constitution.md +181 -0
- package/.specify/scripts/bash/check-prerequisites.sh +166 -0
- package/.specify/scripts/bash/common.sh +156 -0
- package/.specify/scripts/bash/create-new-feature.sh +297 -0
- package/.specify/scripts/bash/setup-plan.sh +61 -0
- package/.specify/scripts/bash/update-agent-context.sh +810 -0
- package/.specify/templates/agent-file-template.md +28 -0
- package/.specify/templates/checklist-template.md +40 -0
- package/.specify/templates/constitution-template.md +50 -0
- package/.specify/templates/plan-template.md +113 -0
- package/.specify/templates/spec-template.md +115 -0
- package/.specify/templates/tasks-template.md +251 -0
- package/.vscode/mcp.json +42 -0
- package/.vscode/settings.json +19 -0
- package/CODE_OF_CONDUCT.md +128 -0
- package/LICENSE +21 -0
- package/README.md +213 -0
- package/dist/src/cli/developCommand.js +240 -0
- package/dist/src/cli/directCommands.js +143 -0
- package/dist/src/cli/envLoader.js +16 -0
- package/dist/src/cli/exportCommand.js +53 -0
- package/dist/src/cli/index.js +203 -0
- package/dist/src/cli/ioContext.js +109 -0
- package/dist/src/cli/preflight.js +57 -0
- package/dist/src/cli/statusCommand.js +110 -0
- package/dist/src/cli/workshopCommand.js +400 -0
- package/dist/src/develop/checkpointState.js +86 -0
- package/dist/src/develop/codeGenerator.js +319 -0
- package/dist/src/develop/dynamicScaffolder.js +226 -0
- package/dist/src/develop/githubMcpAdapter.js +122 -0
- package/dist/src/develop/index.js +15 -0
- package/dist/src/develop/mcpContextEnricher.js +195 -0
- package/dist/src/develop/pocScaffolder.js +542 -0
- package/dist/src/develop/ralphLoop.js +659 -0
- package/dist/src/develop/templateRegistry.js +364 -0
- package/dist/src/develop/testRunner.js +202 -0
- package/dist/src/logging/logger.js +58 -0
- package/dist/src/loop/conversationLoop.js +227 -0
- package/dist/src/loop/phaseSummarizer.js +87 -0
- package/dist/src/mcp/mcpManager.js +267 -0
- package/dist/src/mcp/mcpTransport.js +391 -0
- package/dist/src/mcp/retryPolicy.js +47 -0
- package/dist/src/mcp/webSearch.js +254 -0
- package/dist/src/phases/contextSummarizer.js +101 -0
- package/dist/src/phases/discoveryEnricher.js +156 -0
- package/dist/src/phases/phaseExtractors.js +222 -0
- package/dist/src/phases/phaseHandlers.js +328 -0
- package/dist/src/prompts/design.md +51 -0
- package/dist/src/prompts/develop-boundary.md +51 -0
- package/dist/src/prompts/develop.md +111 -0
- package/dist/src/prompts/discover.md +58 -0
- package/dist/src/prompts/ideate.md +56 -0
- package/dist/src/prompts/plan.md +51 -0
- package/dist/src/prompts/promptLoader.js +167 -0
- package/dist/src/prompts/promptLoader.ts +198 -0
- package/dist/src/prompts/select.md +47 -0
- package/dist/src/prompts/summarize/README.md +8 -0
- package/dist/src/prompts/summarize/design-summary.md +37 -0
- package/dist/src/prompts/summarize/develop-summary.md +25 -0
- package/dist/src/prompts/summarize/ideate-summary.md +27 -0
- package/dist/src/prompts/summarize/plan-summary.md +27 -0
- package/dist/src/prompts/summarize/select-summary.md +21 -0
- package/dist/src/prompts/system.md +28 -0
- package/dist/src/sessions/exportPaths.js +22 -0
- package/dist/src/sessions/exportWriter.js +406 -0
- package/dist/src/sessions/sessionManager.js +81 -0
- package/dist/src/sessions/sessionStore.js +65 -0
- package/dist/src/shared/activitySpinner.js +91 -0
- package/dist/src/shared/copilotClient.js +129 -0
- package/dist/src/shared/data/cards.json +1249 -0
- package/dist/src/shared/data/cardsLoader.js +51 -0
- package/dist/src/shared/errorClassifier.js +120 -0
- package/dist/src/shared/events.js +28 -0
- package/dist/src/shared/markdownRenderer.js +34 -0
- package/dist/src/shared/schemas/session.js +265 -0
- package/dist/src/shared/tableRenderer.js +20 -0
- package/dist/src/vendor/chalk.js +2 -0
- package/dist/src/vendor/cli-table3.js +3 -0
- package/dist/src/vendor/commander.js +2 -0
- package/dist/src/vendor/marked-terminal.js +3 -0
- package/dist/src/vendor/marked.js +2 -0
- package/dist/src/vendor/ora.js +2 -0
- package/dist/src/vendor/pino.js +2 -0
- package/dist/src/vendor/zod.js +2 -0
- package/dist/tests/e2e/developE2e.spec.js +126 -0
- package/dist/tests/e2e/developFailureE2e.spec.js +247 -0
- package/dist/tests/e2e/developPty.spec.js +75 -0
- package/dist/tests/e2e/discoveryWebSearchRelevance.spec.js +84 -0
- package/dist/tests/e2e/harness.spec.js +83 -0
- package/dist/tests/e2e/mcpLive.spec.js +120 -0
- package/dist/tests/e2e/newSession.e2e.spec.js +177 -0
- package/dist/tests/e2e/ralphLoopEnrichmentComparison.spec.js +62 -0
- package/dist/tests/e2e/workiqEnrichment.spec.js +56 -0
- package/dist/tests/e2e/zavaSimulation.spec.js +452 -0
- package/dist/tests/fixtures/test-fixture-project/src/add.js +3 -0
- package/dist/tests/fixtures/test-fixture-project/tests/failing.test.js +6 -0
- package/dist/tests/fixtures/test-fixture-project/tests/hanging.test.js +8 -0
- package/dist/tests/fixtures/test-fixture-project/tests/passing.test.js +10 -0
- package/dist/tests/fixtures/test-fixture-project/vitest.config.js +6 -0
- package/dist/tests/integration/autoStartConversation.spec.js +138 -0
- package/dist/tests/integration/defaultCommand.spec.js +147 -0
- package/dist/tests/integration/directCommandNonTty.spec.js +224 -0
- package/dist/tests/integration/directCommandTty.spec.js +151 -0
- package/dist/tests/integration/discoveryEnrichmentFlow.spec.js +175 -0
- package/dist/tests/integration/exportArtifacts.spec.js +202 -0
- package/dist/tests/integration/exportFallbackFlow.spec.js +99 -0
- package/dist/tests/integration/mcpDegradationFlow.spec.js +190 -0
- package/dist/tests/integration/mcpTransportFlow.spec.js +139 -0
- package/dist/tests/integration/newSessionFlow.spec.js +343 -0
- package/dist/tests/integration/pocGithubMcp.spec.js +186 -0
- package/dist/tests/integration/pocLocalFallback.spec.js +171 -0
- package/dist/tests/integration/pocScaffold.spec.js +163 -0
- package/dist/tests/integration/ralphLoopFlow.spec.js +359 -0
- package/dist/tests/integration/ralphLoopPartial.spec.js +368 -0
- package/dist/tests/integration/resumeAndBacktrack.spec.js +247 -0
- package/dist/tests/integration/spinnerLifecycle.spec.js +220 -0
- package/dist/tests/integration/summarizationFlow.spec.js +115 -0
- package/dist/tests/integration/testRunnerReal.spec.js +52 -0
- package/dist/tests/integration/webSearchAgent.spec.js +128 -0
- package/dist/tests/live/copilotSdkLive.spec.js +107 -0
- package/dist/tests/live/zavaFullWorkshop.spec.js +392 -0
- package/dist/tests/setup/loadEnv.js +3 -0
- package/dist/tests/unit/cli/developCommand.spec.js +567 -0
- package/dist/tests/unit/cli/directCommands.spec.js +279 -0
- package/dist/tests/unit/cli/envLoader.spec.js +58 -0
- package/dist/tests/unit/cli/ioContext.spec.js +119 -0
- package/dist/tests/unit/cli/preflight.spec.js +108 -0
- package/dist/tests/unit/cli/statusCommand.spec.js +111 -0
- package/dist/tests/unit/cli/workshopClientFallback.spec.js +80 -0
- package/dist/tests/unit/cli/workshopCommand.spec.js +329 -0
- package/dist/tests/unit/config/vitestEnvSetup.spec.js +13 -0
- package/dist/tests/unit/develop/checkpointState.spec.js +315 -0
- package/dist/tests/unit/develop/codeGenerator.spec.js +355 -0
- package/dist/tests/unit/develop/githubMcpAdapter.spec.js +231 -0
- package/dist/tests/unit/develop/mcpContextEnricher.spec.js +433 -0
- package/dist/tests/unit/develop/outputValidator.spec.js +119 -0
- package/dist/tests/unit/develop/pocScaffolder.spec.js +353 -0
- package/dist/tests/unit/develop/ralphLoop.spec.js +1248 -0
- package/dist/tests/unit/develop/templateRegistry.spec.js +85 -0
- package/dist/tests/unit/develop/testRunner.spec.js +249 -0
- package/dist/tests/unit/infraBicep.spec.js +92 -0
- package/dist/tests/unit/infraDeploy.spec.js +82 -0
- package/dist/tests/unit/infraTeardown.spec.js +63 -0
- package/dist/tests/unit/logging/logger.spec.js +43 -0
- package/dist/tests/unit/loop/conversationLoop.spec.js +592 -0
- package/dist/tests/unit/loop/phaseSummarizer.spec.js +141 -0
- package/dist/tests/unit/loop/streamingMarkdown.spec.js +147 -0
- package/dist/tests/unit/mcp/mcpManager.spec.js +279 -0
- package/dist/tests/unit/mcp/mcpTransport.spec.js +529 -0
- package/dist/tests/unit/mcp/retryPolicy.spec.js +218 -0
- package/dist/tests/unit/mcp/timeoutValidation.spec.js +46 -0
- package/dist/tests/unit/mcp/webSearch.spec.js +567 -0
- package/dist/tests/unit/phases/contextSummarizer.spec.js +140 -0
- package/dist/tests/unit/phases/discoveryEnricher.repeatCalls.spec.js +93 -0
- package/dist/tests/unit/phases/discoveryEnricher.spec.js +411 -0
- package/dist/tests/unit/phases/phaseExtractors.spec.js +352 -0
- package/dist/tests/unit/phases/phaseHandlers.spec.js +425 -0
- package/dist/tests/unit/prompts/promptLoader.spec.js +118 -0
- package/dist/tests/unit/schemas/pocSchemas.spec.js +412 -0
- package/dist/tests/unit/schemas/session.spec.js +257 -0
- package/dist/tests/unit/sessions/exportPaths.spec.js +31 -0
- package/dist/tests/unit/sessions/exportWriter.spec.js +655 -0
- package/dist/tests/unit/sessions/sessionManager.spec.js +151 -0
- package/dist/tests/unit/sessions/sessionStore.spec.js +116 -0
- package/dist/tests/unit/shared/activitySpinner.spec.js +175 -0
- package/dist/tests/unit/shared/cardsLoader.spec.js +76 -0
- package/dist/tests/unit/shared/copilotClient.spec.js +155 -0
- package/dist/tests/unit/shared/errorClassifier.spec.js +131 -0
- package/dist/tests/unit/shared/events.spec.js +55 -0
- package/dist/tests/unit/shared/markdownRenderer.spec.js +35 -0
- package/dist/tests/unit/shared/markdownRendererChunks.spec.js +70 -0
- package/dist/tests/unit/shared/tableRenderer.spec.js +34 -0
- package/dist/vitest.config.js +14 -0
- package/dist/vitest.live.config.js +18 -0
- package/docs/README.md +35 -0
- package/docs/architecture.md +169 -0
- package/docs/cli-usage.md +207 -0
- package/docs/environment.md +66 -0
- package/docs/export-format.md +146 -0
- package/docs/session-model.md +113 -0
- package/eslint.config.js +35 -0
- package/infra/deploy.sh +193 -0
- package/infra/gather-env.sh +211 -0
- package/infra/main.bicep +90 -0
- package/infra/main.bicepparam +18 -0
- package/infra/resources.bicep +134 -0
- package/infra/teardown.sh +114 -0
- package/package.json +63 -0
- package/specs/001-cli-workshop-rebuild/checklists/requirements.md +35 -0
- package/specs/001-cli-workshop-rebuild/contracts/cli.md +59 -0
- package/specs/001-cli-workshop-rebuild/contracts/export-summary-json.md +23 -0
- package/specs/001-cli-workshop-rebuild/contracts/session-json.md +30 -0
- package/specs/001-cli-workshop-rebuild/data-model.md +210 -0
- package/specs/001-cli-workshop-rebuild/plan.md +361 -0
- package/specs/001-cli-workshop-rebuild/quickstart.md +83 -0
- package/specs/001-cli-workshop-rebuild/research.md +116 -0
- package/specs/001-cli-workshop-rebuild/spec.md +240 -0
- package/specs/001-cli-workshop-rebuild/tasks.md +476 -0
- package/specs/002-poc-generation/contracts/poc-output.md +172 -0
- package/specs/002-poc-generation/contracts/ralph-loop.md +113 -0
- package/specs/002-poc-generation/data-model.md +172 -0
- package/specs/002-poc-generation/plan.md +109 -0
- package/specs/002-poc-generation/quickstart.md +97 -0
- package/specs/002-poc-generation/research.md +786 -0
- package/specs/002-poc-generation/spec.md +81 -0
- package/specs/002-poc-generation/tasks-fix.md +198 -0
- package/specs/002-poc-generation/tasks.md +252 -0
- package/specs/003-mcp-transport-integration/checklists/requirements.md +37 -0
- package/specs/003-mcp-transport-integration/contracts/context-enricher.md +220 -0
- package/specs/003-mcp-transport-integration/contracts/discovery-enricher.md +267 -0
- package/specs/003-mcp-transport-integration/contracts/github-adapter.md +149 -0
- package/specs/003-mcp-transport-integration/contracts/mcp-transport.md +288 -0
- package/specs/003-mcp-transport-integration/data-model.md +326 -0
- package/specs/003-mcp-transport-integration/plan.md +114 -0
- package/specs/003-mcp-transport-integration/quickstart.md +311 -0
- package/specs/003-mcp-transport-integration/research.md +395 -0
- package/specs/003-mcp-transport-integration/spec.md +234 -0
- package/specs/003-mcp-transport-integration/tasks.md +324 -0
- package/specs/003-next-spec-gaps.md +150 -0
- package/specs/004-dev-resume-hardening/checklists/requirements.md +37 -0
- package/specs/004-dev-resume-hardening/contracts/cli.md +160 -0
- package/specs/004-dev-resume-hardening/data-model.md +321 -0
- package/specs/004-dev-resume-hardening/plan.md +107 -0
- package/specs/004-dev-resume-hardening/quickstart.md +115 -0
- package/specs/004-dev-resume-hardening/research.md +142 -0
- package/specs/004-dev-resume-hardening/spec.md +221 -0
- package/specs/004-dev-resume-hardening/tasks.md +333 -0
- package/specs/005-ai-search-deploy/checklists/requirements.md +39 -0
- package/specs/005-ai-search-deploy/contracts/web-search-tool.md +241 -0
- package/specs/005-ai-search-deploy/data-model.md +130 -0
- package/specs/005-ai-search-deploy/plan.md +93 -0
- package/specs/005-ai-search-deploy/quickstart.md +96 -0
- package/specs/005-ai-search-deploy/research.md +187 -0
- package/specs/005-ai-search-deploy/spec.md +143 -0
- package/specs/005-ai-search-deploy/tasks.md +284 -0
- package/specs/006-workshop-extraction-fixes/checklists/requirements.md +61 -0
- package/specs/006-workshop-extraction-fixes/contracts/summarization-and-export.md +131 -0
- package/specs/006-workshop-extraction-fixes/data-model.md +149 -0
- package/specs/006-workshop-extraction-fixes/plan.md +123 -0
- package/specs/006-workshop-extraction-fixes/quickstart.md +101 -0
- package/specs/006-workshop-extraction-fixes/research.md +143 -0
- package/specs/006-workshop-extraction-fixes/spec.md +210 -0
- package/specs/006-workshop-extraction-fixes/tasks.md +316 -0
- package/src/cli/developCommand.ts +308 -0
- package/src/cli/directCommands.ts +195 -0
- package/src/cli/envLoader.ts +17 -0
- package/src/cli/exportCommand.ts +65 -0
- package/src/cli/index.ts +249 -0
- package/src/cli/ioContext.ts +139 -0
- package/src/cli/preflight.ts +86 -0
- package/src/cli/statusCommand.ts +118 -0
- package/src/cli/workshopCommand.ts +496 -0
- package/src/develop/checkpointState.ts +121 -0
- package/src/develop/codeGenerator.ts +402 -0
- package/src/develop/dynamicScaffolder.ts +284 -0
- package/src/develop/githubMcpAdapter.ts +199 -0
- package/src/develop/index.ts +34 -0
- package/src/develop/mcpContextEnricher.ts +279 -0
- package/src/develop/pocScaffolder.ts +646 -0
- package/src/develop/ralphLoop.ts +1044 -0
- package/src/develop/templateRegistry.ts +427 -0
- package/src/develop/testRunner.ts +276 -0
- package/src/logging/logger.ts +73 -0
- package/src/loop/conversationLoop.ts +355 -0
- package/src/loop/phaseSummarizer.ts +114 -0
- package/src/mcp/mcpManager.ts +365 -0
- package/src/mcp/mcpTransport.ts +562 -0
- package/src/mcp/retryPolicy.ts +87 -0
- package/src/mcp/webSearch.ts +388 -0
- package/src/originalPrompts/design_thinking.md +178 -0
- package/src/originalPrompts/design_thinking_persona.md +76 -0
- package/src/originalPrompts/document_generator_example.md +77 -0
- package/src/originalPrompts/document_generator_persona.md +47 -0
- package/src/originalPrompts/facilitator_persona.md +125 -0
- package/src/originalPrompts/guardrails.md +47 -0
- package/src/phases/contextSummarizer.ts +154 -0
- package/src/phases/discoveryEnricher.ts +223 -0
- package/src/phases/phaseExtractors.ts +247 -0
- package/src/phases/phaseHandlers.ts +450 -0
- package/src/prompts/design.md +51 -0
- package/src/prompts/develop-boundary.md +51 -0
- package/src/prompts/develop.md +111 -0
- package/src/prompts/discover.md +58 -0
- package/src/prompts/ideate.md +56 -0
- package/src/prompts/plan.md +51 -0
- package/src/prompts/promptLoader.ts +198 -0
- package/src/prompts/select.md +47 -0
- package/src/prompts/summarize/README.md +8 -0
- package/src/prompts/summarize/design-summary.md +37 -0
- package/src/prompts/summarize/develop-summary.md +25 -0
- package/src/prompts/summarize/ideate-summary.md +27 -0
- package/src/prompts/summarize/plan-summary.md +27 -0
- package/src/prompts/summarize/select-summary.md +21 -0
- package/src/prompts/system.md +28 -0
- package/src/sessions/exportPaths.ts +28 -0
- package/src/sessions/exportWriter.ts +490 -0
- package/src/sessions/sessionManager.ts +119 -0
- package/src/sessions/sessionStore.ts +69 -0
- package/src/shared/activitySpinner.ts +108 -0
- package/src/shared/copilotClient.ts +291 -0
- package/src/shared/data/cards.json +1249 -0
- package/src/shared/data/cardsLoader.ts +70 -0
- package/src/shared/errorClassifier.ts +160 -0
- package/src/shared/events.ts +103 -0
- package/src/shared/markdownRenderer.ts +44 -0
- package/src/shared/schemas/session.ts +346 -0
- package/src/shared/tableRenderer.ts +28 -0
- package/src/types/marked-terminal.d.ts +5 -0
- package/src/vendor/chalk.ts +2 -0
- package/src/vendor/cli-table3.ts +3 -0
- package/src/vendor/commander.ts +2 -0
- package/src/vendor/marked-terminal.ts +3 -0
- package/src/vendor/marked.ts +2 -0
- package/src/vendor/ora.ts +2 -0
- package/src/vendor/pino.ts +3 -0
- package/src/vendor/zod.ts +3 -0
- package/tests/e2e/developE2e.spec.ts +152 -0
- package/tests/e2e/developFailureE2e.spec.ts +289 -0
- package/tests/e2e/developPty.spec.ts +86 -0
- package/tests/e2e/discoveryWebSearchRelevance.spec.ts +103 -0
- package/tests/e2e/harness.spec.ts +104 -0
- package/tests/e2e/mcpLive.spec.ts +149 -0
- package/tests/e2e/newSession.e2e.spec.ts +245 -0
- package/tests/e2e/ralphLoopEnrichmentComparison.spec.ts +70 -0
- package/tests/e2e/workiqEnrichment.spec.ts +72 -0
- package/tests/e2e/zava-assessment/agent-interaction-script.md +258 -0
- package/tests/e2e/zava-assessment/company-profile.md +98 -0
- package/tests/e2e/zava-assessment/expected-results-checklist.md +454 -0
- package/tests/e2e/zavaSimulation.spec.ts +511 -0
- package/tests/fixtures/completedSession.json +141 -0
- package/tests/fixtures/test-fixture-project/package-lock.json +1585 -0
- package/tests/fixtures/test-fixture-project/package.json +12 -0
- package/tests/fixtures/test-fixture-project/src/add.ts +3 -0
- package/tests/fixtures/test-fixture-project/tests/failing.test.ts +7 -0
- package/tests/fixtures/test-fixture-project/tests/hanging.test.ts +9 -0
- package/tests/fixtures/test-fixture-project/tests/passing.test.ts +13 -0
- package/tests/fixtures/test-fixture-project/vitest.config.ts +7 -0
- package/tests/integration/autoStartConversation.spec.ts +168 -0
- package/tests/integration/defaultCommand.spec.ts +179 -0
- package/tests/integration/directCommandNonTty.spec.ts +260 -0
- package/tests/integration/directCommandTty.spec.ts +185 -0
- package/tests/integration/discoveryEnrichmentFlow.spec.ts +209 -0
- package/tests/integration/exportArtifacts.spec.ts +232 -0
- package/tests/integration/exportFallbackFlow.spec.ts +115 -0
- package/tests/integration/mcpDegradationFlow.spec.ts +231 -0
- package/tests/integration/mcpTransportFlow.spec.ts +178 -0
- package/tests/integration/newSessionFlow.spec.ts +406 -0
- package/tests/integration/pocGithubMcp.spec.ts +224 -0
- package/tests/integration/pocLocalFallback.spec.ts +205 -0
- package/tests/integration/pocScaffold.spec.ts +220 -0
- package/tests/integration/ralphLoopFlow.spec.ts +430 -0
- package/tests/integration/ralphLoopPartial.spec.ts +416 -0
- package/tests/integration/resumeAndBacktrack.spec.ts +278 -0
- package/tests/integration/spinnerLifecycle.spec.ts +270 -0
- package/tests/integration/summarizationFlow.spec.ts +135 -0
- package/tests/integration/testRunnerReal.spec.ts +63 -0
- package/tests/integration/webSearchAgent.spec.ts +155 -0
- package/tests/live/copilotSdkLive.spec.ts +149 -0
- package/tests/live/zavaFullWorkshop.spec.ts +515 -0
- package/tests/setup/loadEnv.ts +5 -0
- package/tests/unit/cli/developCommand.spec.ts +679 -0
- package/tests/unit/cli/directCommands.spec.ts +325 -0
- package/tests/unit/cli/envLoader.spec.ts +73 -0
- package/tests/unit/cli/ioContext.spec.ts +148 -0
- package/tests/unit/cli/preflight.spec.ts +125 -0
- package/tests/unit/cli/statusCommand.spec.ts +134 -0
- package/tests/unit/cli/workshopClientFallback.spec.ts +100 -0
- package/tests/unit/cli/workshopCommand.spec.ts +378 -0
- package/tests/unit/config/vitestEnvSetup.spec.ts +24 -0
- package/tests/unit/develop/checkpointState.spec.ts +378 -0
- package/tests/unit/develop/codeGenerator.spec.ts +447 -0
- package/tests/unit/develop/githubMcpAdapter.spec.ts +283 -0
- package/tests/unit/develop/mcpContextEnricher.spec.ts +564 -0
- package/tests/unit/develop/outputValidator.spec.ts +134 -0
- package/tests/unit/develop/pocScaffolder.spec.ts +451 -0
- package/tests/unit/develop/ralphLoop.spec.ts +1439 -0
- package/tests/unit/develop/templateRegistry.spec.ts +106 -0
- package/tests/unit/develop/testRunner.spec.ts +294 -0
- package/tests/unit/infraBicep.spec.ts +116 -0
- package/tests/unit/infraDeploy.spec.ts +102 -0
- package/tests/unit/infraTeardown.spec.ts +77 -0
- package/tests/unit/logging/logger.spec.ts +50 -0
- package/tests/unit/loop/conversationLoop.spec.ts +719 -0
- package/tests/unit/loop/phaseSummarizer.spec.ts +169 -0
- package/tests/unit/loop/streamingMarkdown.spec.ts +180 -0
- package/tests/unit/mcp/mcpManager.spec.ts +336 -0
- package/tests/unit/mcp/mcpTransport.spec.ts +689 -0
- package/tests/unit/mcp/retryPolicy.spec.ts +278 -0
- package/tests/unit/mcp/timeoutValidation.spec.ts +55 -0
- package/tests/unit/mcp/webSearch.spec.ts +718 -0
- package/tests/unit/phases/contextSummarizer.spec.ts +158 -0
- package/tests/unit/phases/discoveryEnricher.repeatCalls.spec.ts +125 -0
- package/tests/unit/phases/discoveryEnricher.spec.ts +512 -0
- package/tests/unit/phases/phaseExtractors.spec.ts +406 -0
- package/tests/unit/phases/phaseHandlers.spec.ts +483 -0
- package/tests/unit/prompts/promptLoader.spec.ts +144 -0
- package/tests/unit/schemas/pocSchemas.spec.ts +457 -0
- package/tests/unit/schemas/session.spec.ts +328 -0
- package/tests/unit/sessions/exportPaths.spec.ts +38 -0
- package/tests/unit/sessions/exportWriter.spec.ts +737 -0
- package/tests/unit/sessions/sessionManager.spec.ts +174 -0
- package/tests/unit/sessions/sessionStore.spec.ts +136 -0
- package/tests/unit/shared/activitySpinner.spec.ts +211 -0
- package/tests/unit/shared/cardsLoader.spec.ts +89 -0
- package/tests/unit/shared/copilotClient.spec.ts +185 -0
- package/tests/unit/shared/errorClassifier.spec.ts +152 -0
- package/tests/unit/shared/events.spec.ts +71 -0
- package/tests/unit/shared/markdownRenderer.spec.ts +42 -0
- package/tests/unit/shared/markdownRendererChunks.spec.ts +83 -0
- package/tests/unit/shared/tableRenderer.spec.ts +38 -0
- package/tsconfig.json +20 -0
- package/vitest.config.ts +15 -0
- package/vitest.live.config.ts +19 -0
|
@@ -0,0 +1,412 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* T008: Unit tests for new/extended PoC schemas (Feature 002).
|
|
3
|
+
*
|
|
4
|
+
* Tests TechStack, TestResults, TestFailure, extended PocIteration,
|
|
5
|
+
* and extended PocDevelopmentState schemas.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, it, expect } from 'vitest';
|
|
8
|
+
import { techStackSchema, testFailureSchema, testResultsSchema, pocIterationSchema, pocDevelopmentStateSchema, } from '../../../src/shared/schemas/session.js';
|
|
9
|
+
// ── TechStack ────────────────────────────────────────────────────────────────
|
|
10
|
+
describe('techStackSchema', () => {
|
|
11
|
+
it('parses a minimal valid tech stack (required fields only)', () => {
|
|
12
|
+
const result = techStackSchema.safeParse({
|
|
13
|
+
language: 'TypeScript',
|
|
14
|
+
testRunner: 'npm test',
|
|
15
|
+
runtime: 'Node.js 20',
|
|
16
|
+
});
|
|
17
|
+
expect(result.success).toBe(true);
|
|
18
|
+
if (result.success) {
|
|
19
|
+
expect(result.data.language).toBe('TypeScript');
|
|
20
|
+
expect(result.data.testRunner).toBe('npm test');
|
|
21
|
+
expect(result.data.runtime).toBe('Node.js 20');
|
|
22
|
+
expect(result.data.framework).toBeUndefined();
|
|
23
|
+
expect(result.data.buildCommand).toBeUndefined();
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
it('parses a full tech stack with optional fields', () => {
|
|
27
|
+
const result = techStackSchema.safeParse({
|
|
28
|
+
language: 'TypeScript',
|
|
29
|
+
framework: 'Express',
|
|
30
|
+
testRunner: 'npm test',
|
|
31
|
+
buildCommand: 'npm run build',
|
|
32
|
+
runtime: 'Node.js 20',
|
|
33
|
+
});
|
|
34
|
+
expect(result.success).toBe(true);
|
|
35
|
+
if (result.success) {
|
|
36
|
+
expect(result.data.framework).toBe('Express');
|
|
37
|
+
expect(result.data.buildCommand).toBe('npm run build');
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
it('rejects a tech stack missing required language', () => {
|
|
41
|
+
const result = techStackSchema.safeParse({
|
|
42
|
+
testRunner: 'npm test',
|
|
43
|
+
runtime: 'Node.js 20',
|
|
44
|
+
});
|
|
45
|
+
expect(result.success).toBe(false);
|
|
46
|
+
});
|
|
47
|
+
it('rejects a tech stack missing required testRunner', () => {
|
|
48
|
+
const result = techStackSchema.safeParse({
|
|
49
|
+
language: 'TypeScript',
|
|
50
|
+
runtime: 'Node.js 20',
|
|
51
|
+
});
|
|
52
|
+
expect(result.success).toBe(false);
|
|
53
|
+
});
|
|
54
|
+
it('rejects a tech stack missing required runtime', () => {
|
|
55
|
+
const result = techStackSchema.safeParse({
|
|
56
|
+
language: 'TypeScript',
|
|
57
|
+
testRunner: 'npm test',
|
|
58
|
+
});
|
|
59
|
+
expect(result.success).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
// ── TestFailure ──────────────────────────────────────────────────────────────
|
|
63
|
+
describe('testFailureSchema', () => {
|
|
64
|
+
it('parses a minimal test failure', () => {
|
|
65
|
+
const result = testFailureSchema.safeParse({
|
|
66
|
+
testName: 'route optimizer > should return shortest path',
|
|
67
|
+
message: 'Expected 3 but got 5',
|
|
68
|
+
});
|
|
69
|
+
expect(result.success).toBe(true);
|
|
70
|
+
});
|
|
71
|
+
it('parses a full test failure with optional fields', () => {
|
|
72
|
+
const result = testFailureSchema.safeParse({
|
|
73
|
+
testName: 'route optimizer > should return shortest path',
|
|
74
|
+
message: 'Expected 3 but got 5',
|
|
75
|
+
expected: '3',
|
|
76
|
+
actual: '5',
|
|
77
|
+
file: 'tests/optimizer.test.ts',
|
|
78
|
+
line: 42,
|
|
79
|
+
});
|
|
80
|
+
expect(result.success).toBe(true);
|
|
81
|
+
if (result.success) {
|
|
82
|
+
expect(result.data.expected).toBe('3');
|
|
83
|
+
expect(result.data.actual).toBe('5');
|
|
84
|
+
expect(result.data.file).toBe('tests/optimizer.test.ts');
|
|
85
|
+
expect(result.data.line).toBe(42);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
it('rejects a failure missing testName', () => {
|
|
89
|
+
const result = testFailureSchema.safeParse({
|
|
90
|
+
message: 'Expected 3 but got 5',
|
|
91
|
+
});
|
|
92
|
+
expect(result.success).toBe(false);
|
|
93
|
+
});
|
|
94
|
+
it('rejects a failure missing message', () => {
|
|
95
|
+
const result = testFailureSchema.safeParse({
|
|
96
|
+
testName: 'route optimizer > should return shortest path',
|
|
97
|
+
});
|
|
98
|
+
expect(result.success).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
// ── TestResults ──────────────────────────────────────────────────────────────
|
|
102
|
+
describe('testResultsSchema', () => {
|
|
103
|
+
it('parses valid test results where total = passed + failed + skipped', () => {
|
|
104
|
+
const result = testResultsSchema.safeParse({
|
|
105
|
+
passed: 3,
|
|
106
|
+
failed: 1,
|
|
107
|
+
skipped: 1,
|
|
108
|
+
total: 5,
|
|
109
|
+
durationMs: 1234,
|
|
110
|
+
failures: [{ testName: 'test A', message: 'err' }],
|
|
111
|
+
});
|
|
112
|
+
expect(result.success).toBe(true);
|
|
113
|
+
});
|
|
114
|
+
it('rejects test results where total !== passed + failed + skipped', () => {
|
|
115
|
+
const result = testResultsSchema.safeParse({
|
|
116
|
+
passed: 3,
|
|
117
|
+
failed: 1,
|
|
118
|
+
skipped: 0,
|
|
119
|
+
total: 10, // wrong
|
|
120
|
+
durationMs: 1234,
|
|
121
|
+
failures: [],
|
|
122
|
+
});
|
|
123
|
+
expect(result.success).toBe(false);
|
|
124
|
+
if (!result.success) {
|
|
125
|
+
expect(result.error.issues[0].message).toContain('total must equal');
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
it('parses results with zero failures', () => {
|
|
129
|
+
const result = testResultsSchema.safeParse({
|
|
130
|
+
passed: 5,
|
|
131
|
+
failed: 0,
|
|
132
|
+
skipped: 0,
|
|
133
|
+
total: 5,
|
|
134
|
+
durationMs: 500,
|
|
135
|
+
failures: [],
|
|
136
|
+
});
|
|
137
|
+
expect(result.success).toBe(true);
|
|
138
|
+
});
|
|
139
|
+
it('parses results with optional rawOutput', () => {
|
|
140
|
+
const result = testResultsSchema.safeParse({
|
|
141
|
+
passed: 1,
|
|
142
|
+
failed: 0,
|
|
143
|
+
skipped: 0,
|
|
144
|
+
total: 1,
|
|
145
|
+
durationMs: 100,
|
|
146
|
+
failures: [],
|
|
147
|
+
rawOutput: 'PASS tests/index.test.ts',
|
|
148
|
+
});
|
|
149
|
+
expect(result.success).toBe(true);
|
|
150
|
+
if (result.success) {
|
|
151
|
+
expect(result.data.rawOutput).toBe('PASS tests/index.test.ts');
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
it('allows rawOutput to be omitted', () => {
|
|
155
|
+
const result = testResultsSchema.safeParse({
|
|
156
|
+
passed: 1,
|
|
157
|
+
failed: 0,
|
|
158
|
+
skipped: 0,
|
|
159
|
+
total: 1,
|
|
160
|
+
durationMs: 100,
|
|
161
|
+
failures: [],
|
|
162
|
+
});
|
|
163
|
+
expect(result.success).toBe(true);
|
|
164
|
+
if (result.success) {
|
|
165
|
+
expect(result.data.rawOutput).toBeUndefined();
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
it('handles multiple test failures', () => {
|
|
169
|
+
const result = testResultsSchema.safeParse({
|
|
170
|
+
passed: 0,
|
|
171
|
+
failed: 2,
|
|
172
|
+
skipped: 0,
|
|
173
|
+
total: 2,
|
|
174
|
+
durationMs: 800,
|
|
175
|
+
failures: [
|
|
176
|
+
{ testName: 'test A', message: 'err A', file: 'tests/a.test.ts', line: 10 },
|
|
177
|
+
{ testName: 'test B', message: 'err B', expected: 'foo', actual: 'bar' },
|
|
178
|
+
],
|
|
179
|
+
});
|
|
180
|
+
expect(result.success).toBe(true);
|
|
181
|
+
if (result.success) {
|
|
182
|
+
expect(result.data.failures).toHaveLength(2);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
// ── PocIteration (extended) ─────────────────────────────────────────────────
|
|
187
|
+
describe('pocIterationSchema (extended)', () => {
|
|
188
|
+
it('parses a scaffold iteration', () => {
|
|
189
|
+
const result = pocIterationSchema.safeParse({
|
|
190
|
+
iteration: 1,
|
|
191
|
+
startedAt: '2026-01-15T10:00:00Z',
|
|
192
|
+
endedAt: '2026-01-15T10:01:00Z',
|
|
193
|
+
outcome: 'scaffold',
|
|
194
|
+
filesChanged: ['package.json', 'src/index.ts', 'tests/index.test.ts'],
|
|
195
|
+
});
|
|
196
|
+
expect(result.success).toBe(true);
|
|
197
|
+
if (result.success) {
|
|
198
|
+
expect(result.data.outcome).toBe('scaffold');
|
|
199
|
+
expect(result.data.filesChanged).toHaveLength(3);
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
it('parses a tests-passing iteration with testResults', () => {
|
|
203
|
+
const result = pocIterationSchema.safeParse({
|
|
204
|
+
iteration: 2,
|
|
205
|
+
startedAt: '2026-01-15T10:01:00Z',
|
|
206
|
+
endedAt: '2026-01-15T10:02:00Z',
|
|
207
|
+
outcome: 'tests-passing',
|
|
208
|
+
filesChanged: ['src/index.ts'],
|
|
209
|
+
testResults: {
|
|
210
|
+
passed: 3,
|
|
211
|
+
failed: 0,
|
|
212
|
+
skipped: 0,
|
|
213
|
+
total: 3,
|
|
214
|
+
durationMs: 450,
|
|
215
|
+
failures: [],
|
|
216
|
+
},
|
|
217
|
+
});
|
|
218
|
+
expect(result.success).toBe(true);
|
|
219
|
+
});
|
|
220
|
+
it('parses a tests-failing iteration with failures', () => {
|
|
221
|
+
const result = pocIterationSchema.safeParse({
|
|
222
|
+
iteration: 3,
|
|
223
|
+
startedAt: '2026-01-15T10:02:00Z',
|
|
224
|
+
outcome: 'tests-failing',
|
|
225
|
+
filesChanged: ['src/optimizer.ts'],
|
|
226
|
+
testResults: {
|
|
227
|
+
passed: 1,
|
|
228
|
+
failed: 2,
|
|
229
|
+
skipped: 0,
|
|
230
|
+
total: 3,
|
|
231
|
+
durationMs: 600,
|
|
232
|
+
failures: [{ testName: 'optimizer test', message: 'wrong output' }],
|
|
233
|
+
},
|
|
234
|
+
});
|
|
235
|
+
expect(result.success).toBe(true);
|
|
236
|
+
});
|
|
237
|
+
it('parses an error iteration with errorMessage', () => {
|
|
238
|
+
const result = pocIterationSchema.safeParse({
|
|
239
|
+
iteration: 4,
|
|
240
|
+
startedAt: '2026-01-15T10:03:00Z',
|
|
241
|
+
outcome: 'error',
|
|
242
|
+
filesChanged: [],
|
|
243
|
+
errorMessage: 'npm install failed: ENOTFOUND registry.npmjs.org',
|
|
244
|
+
});
|
|
245
|
+
expect(result.success).toBe(true);
|
|
246
|
+
if (result.success) {
|
|
247
|
+
expect(result.data.errorMessage).toContain('npm install failed');
|
|
248
|
+
}
|
|
249
|
+
});
|
|
250
|
+
it('rejects invalid outcome enum value', () => {
|
|
251
|
+
const result = pocIterationSchema.safeParse({
|
|
252
|
+
iteration: 1,
|
|
253
|
+
startedAt: '2026-01-15T10:00:00Z',
|
|
254
|
+
outcome: 'unknown-outcome',
|
|
255
|
+
filesChanged: [],
|
|
256
|
+
});
|
|
257
|
+
expect(result.success).toBe(false);
|
|
258
|
+
});
|
|
259
|
+
it('defaults outcome to scaffold when omitted', () => {
|
|
260
|
+
const result = pocIterationSchema.safeParse({
|
|
261
|
+
iteration: 1,
|
|
262
|
+
startedAt: '2026-01-15T10:00:00Z',
|
|
263
|
+
filesChanged: [],
|
|
264
|
+
});
|
|
265
|
+
expect(result.success).toBe(true);
|
|
266
|
+
if (result.success) {
|
|
267
|
+
expect(result.data.outcome).toBe('scaffold');
|
|
268
|
+
}
|
|
269
|
+
});
|
|
270
|
+
it('defaults filesChanged to empty array when omitted', () => {
|
|
271
|
+
const result = pocIterationSchema.safeParse({
|
|
272
|
+
iteration: 1,
|
|
273
|
+
startedAt: '2026-01-15T10:00:00Z',
|
|
274
|
+
outcome: 'scaffold',
|
|
275
|
+
});
|
|
276
|
+
expect(result.success).toBe(true);
|
|
277
|
+
if (result.success) {
|
|
278
|
+
expect(result.data.filesChanged).toEqual([]);
|
|
279
|
+
}
|
|
280
|
+
});
|
|
281
|
+
it('preserves optional testsRun field for backward compatibility', () => {
|
|
282
|
+
const result = pocIterationSchema.safeParse({
|
|
283
|
+
iteration: 1,
|
|
284
|
+
startedAt: '2026-01-15T10:00:00Z',
|
|
285
|
+
outcome: 'scaffold',
|
|
286
|
+
filesChanged: [],
|
|
287
|
+
testsRun: ['tests/old.spec.ts'], // legacy field
|
|
288
|
+
});
|
|
289
|
+
expect(result.success).toBe(true);
|
|
290
|
+
if (result.success) {
|
|
291
|
+
expect(result.data.testsRun).toEqual(['tests/old.spec.ts']);
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
it('parses iteration with llmPromptContext for auditability', () => {
|
|
295
|
+
const result = pocIterationSchema.safeParse({
|
|
296
|
+
iteration: 2,
|
|
297
|
+
startedAt: '2026-01-15T10:01:00Z',
|
|
298
|
+
outcome: 'tests-failing',
|
|
299
|
+
filesChanged: [],
|
|
300
|
+
llmPromptContext: 'Iteration 2 of 5, 2 failures, files: src/index.ts',
|
|
301
|
+
});
|
|
302
|
+
expect(result.success).toBe(true);
|
|
303
|
+
if (result.success) {
|
|
304
|
+
expect(result.data.llmPromptContext).toContain('Iteration 2');
|
|
305
|
+
}
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
// ── PocDevelopmentState (extended) ─────────────────────────────────────────
|
|
309
|
+
describe('pocDevelopmentStateSchema (extended)', () => {
|
|
310
|
+
it('parses a minimal poc state with repoSource=local', () => {
|
|
311
|
+
const result = pocDevelopmentStateSchema.safeParse({
|
|
312
|
+
repoSource: 'local',
|
|
313
|
+
iterations: [],
|
|
314
|
+
});
|
|
315
|
+
expect(result.success).toBe(true);
|
|
316
|
+
});
|
|
317
|
+
it('rejects a poc state with repoSource=github-mcp (always-local policy)', () => {
|
|
318
|
+
const result = pocDevelopmentStateSchema.safeParse({
|
|
319
|
+
repoSource: 'github-mcp',
|
|
320
|
+
repoUrl: 'https://github.com/acme/poc-route-optimizer',
|
|
321
|
+
iterations: [],
|
|
322
|
+
});
|
|
323
|
+
expect(result.success).toBe(false);
|
|
324
|
+
});
|
|
325
|
+
it('parses a completed poc state with all fields', () => {
|
|
326
|
+
const result = pocDevelopmentStateSchema.safeParse({
|
|
327
|
+
repoSource: 'local',
|
|
328
|
+
repoPath: './poc/fixture-session-001',
|
|
329
|
+
techStack: {
|
|
330
|
+
language: 'TypeScript',
|
|
331
|
+
testRunner: 'npm test',
|
|
332
|
+
runtime: 'Node.js 20',
|
|
333
|
+
},
|
|
334
|
+
iterations: [
|
|
335
|
+
{
|
|
336
|
+
iteration: 1,
|
|
337
|
+
startedAt: '2026-01-15T10:00:00Z',
|
|
338
|
+
outcome: 'scaffold',
|
|
339
|
+
filesChanged: ['package.json'],
|
|
340
|
+
},
|
|
341
|
+
],
|
|
342
|
+
finalStatus: 'success',
|
|
343
|
+
terminationReason: 'tests-passing',
|
|
344
|
+
totalDurationMs: 45000,
|
|
345
|
+
finalTestResults: {
|
|
346
|
+
passed: 3,
|
|
347
|
+
failed: 0,
|
|
348
|
+
skipped: 0,
|
|
349
|
+
total: 3,
|
|
350
|
+
durationMs: 400,
|
|
351
|
+
failures: [],
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
expect(result.success).toBe(true);
|
|
355
|
+
if (result.success) {
|
|
356
|
+
expect(result.data.finalStatus).toBe('success');
|
|
357
|
+
expect(result.data.terminationReason).toBe('tests-passing');
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
it('accepts finalStatus "partial" (new in Feature 002)', () => {
|
|
361
|
+
const result = pocDevelopmentStateSchema.safeParse({
|
|
362
|
+
repoSource: 'local',
|
|
363
|
+
iterations: [],
|
|
364
|
+
finalStatus: 'partial',
|
|
365
|
+
terminationReason: 'max-iterations',
|
|
366
|
+
});
|
|
367
|
+
expect(result.success).toBe(true);
|
|
368
|
+
if (result.success) {
|
|
369
|
+
expect(result.data.finalStatus).toBe('partial');
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
it('rejects invalid repoSource', () => {
|
|
373
|
+
const result = pocDevelopmentStateSchema.safeParse({
|
|
374
|
+
repoSource: 'bitbucket',
|
|
375
|
+
iterations: [],
|
|
376
|
+
});
|
|
377
|
+
expect(result.success).toBe(false);
|
|
378
|
+
});
|
|
379
|
+
it('rejects invalid terminationReason', () => {
|
|
380
|
+
const result = pocDevelopmentStateSchema.safeParse({
|
|
381
|
+
repoSource: 'local',
|
|
382
|
+
iterations: [],
|
|
383
|
+
terminationReason: 'timeout',
|
|
384
|
+
});
|
|
385
|
+
expect(result.success).toBe(false);
|
|
386
|
+
});
|
|
387
|
+
it('rejects invalid finalStatus', () => {
|
|
388
|
+
const result = pocDevelopmentStateSchema.safeParse({
|
|
389
|
+
repoSource: 'local',
|
|
390
|
+
iterations: [],
|
|
391
|
+
finalStatus: 'abandoned',
|
|
392
|
+
});
|
|
393
|
+
expect(result.success).toBe(false);
|
|
394
|
+
});
|
|
395
|
+
it('rejects missing repoSource', () => {
|
|
396
|
+
const result = pocDevelopmentStateSchema.safeParse({
|
|
397
|
+
iterations: [],
|
|
398
|
+
});
|
|
399
|
+
expect(result.success).toBe(false);
|
|
400
|
+
});
|
|
401
|
+
it('accepts all valid terminationReason values', () => {
|
|
402
|
+
const reasons = ['tests-passing', 'max-iterations', 'user-stopped', 'error'];
|
|
403
|
+
for (const reason of reasons) {
|
|
404
|
+
const result = pocDevelopmentStateSchema.safeParse({
|
|
405
|
+
repoSource: 'local',
|
|
406
|
+
iterations: [],
|
|
407
|
+
terminationReason: reason,
|
|
408
|
+
});
|
|
409
|
+
expect(result.success, `Expected ${reason} to be valid`).toBe(true);
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
});
|
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit tests for WorkshopSession Zod schemas.
|
|
3
|
+
*
|
|
4
|
+
* Validates that the session data model matches the spec in data-model.md
|
|
5
|
+
* and the contract in contracts/session-json.md.
|
|
6
|
+
*/
|
|
7
|
+
import { describe, it, expect } from 'vitest';
|
|
8
|
+
import { Phase, SessionStatus, workshopSessionSchema, } from '../../../src/shared/schemas/session.js';
|
|
9
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
10
|
+
function validSession(overrides = {}) {
|
|
11
|
+
return {
|
|
12
|
+
sessionId: 'test-001',
|
|
13
|
+
schemaVersion: '1',
|
|
14
|
+
createdAt: '2026-01-01T00:00:00Z',
|
|
15
|
+
updatedAt: '2026-01-01T00:00:00Z',
|
|
16
|
+
phase: 'Discover',
|
|
17
|
+
status: 'Active',
|
|
18
|
+
participants: [],
|
|
19
|
+
artifacts: { generatedFiles: [] },
|
|
20
|
+
...overrides,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
// ── Phase enum ───────────────────────────────────────────────────────────────
|
|
24
|
+
describe('Phase', () => {
|
|
25
|
+
it('contains all seven governed phases', () => {
|
|
26
|
+
const expected = [
|
|
27
|
+
'Discover',
|
|
28
|
+
'Ideate',
|
|
29
|
+
'Design',
|
|
30
|
+
'Select',
|
|
31
|
+
'Plan',
|
|
32
|
+
'Develop',
|
|
33
|
+
'Complete',
|
|
34
|
+
];
|
|
35
|
+
expect(Phase).toEqual(expected);
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
// ── SessionStatus enum ───────────────────────────────────────────────────────
|
|
39
|
+
describe('SessionStatus', () => {
|
|
40
|
+
it('contains Active, Paused, Completed, Errored', () => {
|
|
41
|
+
expect(SessionStatus).toEqual(['Active', 'Paused', 'Completed', 'Errored']);
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
// ── workshopSessionSchema ────────────────────────────────────────────────────
|
|
45
|
+
describe('workshopSessionSchema', () => {
|
|
46
|
+
it('parses a minimal valid session', () => {
|
|
47
|
+
const result = workshopSessionSchema.parse(validSession());
|
|
48
|
+
expect(result.sessionId).toBe('test-001');
|
|
49
|
+
expect(result.phase).toBe('Discover');
|
|
50
|
+
expect(result.status).toBe('Active');
|
|
51
|
+
});
|
|
52
|
+
it('rejects missing required field sessionId', () => {
|
|
53
|
+
const data = validSession();
|
|
54
|
+
delete data.sessionId;
|
|
55
|
+
expect(() => workshopSessionSchema.parse(data)).toThrow();
|
|
56
|
+
});
|
|
57
|
+
it('rejects invalid phase value', () => {
|
|
58
|
+
expect(() => workshopSessionSchema.parse(validSession({ phase: 'InvalidPhase' }))).toThrow();
|
|
59
|
+
});
|
|
60
|
+
it('rejects invalid status value', () => {
|
|
61
|
+
expect(() => workshopSessionSchema.parse(validSession({ status: 'Nope' }))).toThrow();
|
|
62
|
+
});
|
|
63
|
+
it('accepts optional entity fields', () => {
|
|
64
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
65
|
+
businessContext: {
|
|
66
|
+
businessDescription: 'A retail company',
|
|
67
|
+
challenges: ['inventory tracking'],
|
|
68
|
+
},
|
|
69
|
+
topic: { topicArea: 'Supply Chain' },
|
|
70
|
+
}));
|
|
71
|
+
expect(result.businessContext?.businessDescription).toBe('A retail company');
|
|
72
|
+
expect(result.topic?.topicArea).toBe('Supply Chain');
|
|
73
|
+
});
|
|
74
|
+
it('preserves unknown extra fields (forward compat)', () => {
|
|
75
|
+
const base = validSession();
|
|
76
|
+
base.futureField = 'hello';
|
|
77
|
+
const result = workshopSessionSchema.parse(base);
|
|
78
|
+
// Zod passthrough should keep the extra field
|
|
79
|
+
expect(result.futureField).toBe('hello');
|
|
80
|
+
});
|
|
81
|
+
it('handles a full session with ideas and evaluation', () => {
|
|
82
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
83
|
+
ideas: [
|
|
84
|
+
{
|
|
85
|
+
id: 'idea-1',
|
|
86
|
+
title: 'Smart Onboarding',
|
|
87
|
+
description: 'AI-guided onboarding',
|
|
88
|
+
workflowStepIds: ['step-1'],
|
|
89
|
+
},
|
|
90
|
+
],
|
|
91
|
+
evaluation: {
|
|
92
|
+
ideas: [
|
|
93
|
+
{
|
|
94
|
+
ideaId: 'idea-1',
|
|
95
|
+
feasibility: 4,
|
|
96
|
+
value: 5,
|
|
97
|
+
},
|
|
98
|
+
],
|
|
99
|
+
method: 'feasibility-value-matrix',
|
|
100
|
+
},
|
|
101
|
+
}));
|
|
102
|
+
expect(result.ideas).toHaveLength(1);
|
|
103
|
+
expect(result.evaluation?.method).toBe('feasibility-value-matrix');
|
|
104
|
+
});
|
|
105
|
+
it('validates participant roles', () => {
|
|
106
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
107
|
+
participants: [
|
|
108
|
+
{ id: 'p1', displayName: 'Alice', role: 'Facilitator' },
|
|
109
|
+
{ id: 'p2', displayName: 'Bob', role: 'Attendee' },
|
|
110
|
+
],
|
|
111
|
+
}));
|
|
112
|
+
expect(result.participants).toHaveLength(2);
|
|
113
|
+
});
|
|
114
|
+
it('rejects invalid participant role', () => {
|
|
115
|
+
expect(() => workshopSessionSchema.parse(validSession({
|
|
116
|
+
participants: [{ id: 'p1', displayName: 'Alice', role: 'Admin' }],
|
|
117
|
+
}))).toThrow();
|
|
118
|
+
});
|
|
119
|
+
it('validates ConversationTurn array in turns', () => {
|
|
120
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
121
|
+
turns: [
|
|
122
|
+
{
|
|
123
|
+
phase: 'Discover',
|
|
124
|
+
sequence: 1,
|
|
125
|
+
role: 'user',
|
|
126
|
+
content: 'We are a retail company',
|
|
127
|
+
timestamp: '2026-01-01T00:01:00Z',
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
phase: 'Discover',
|
|
131
|
+
sequence: 2,
|
|
132
|
+
role: 'assistant',
|
|
133
|
+
content: 'Got it! Tell me more about your challenges.',
|
|
134
|
+
timestamp: '2026-01-01T00:02:00Z',
|
|
135
|
+
},
|
|
136
|
+
],
|
|
137
|
+
}));
|
|
138
|
+
expect(result.turns).toHaveLength(2);
|
|
139
|
+
});
|
|
140
|
+
it('validates ArtifactIndex with generated files', () => {
|
|
141
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
142
|
+
artifacts: {
|
|
143
|
+
exportDir: './exports/test-001/',
|
|
144
|
+
generatedFiles: [
|
|
145
|
+
{
|
|
146
|
+
relativePath: 'discover.md',
|
|
147
|
+
type: 'markdown',
|
|
148
|
+
createdAt: '2026-01-01T00:05:00Z',
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
},
|
|
152
|
+
}));
|
|
153
|
+
expect(result.artifacts.generatedFiles).toHaveLength(1);
|
|
154
|
+
});
|
|
155
|
+
it('validates PocDevelopmentState', () => {
|
|
156
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
157
|
+
poc: {
|
|
158
|
+
repoSource: 'local',
|
|
159
|
+
iterations: [],
|
|
160
|
+
},
|
|
161
|
+
}));
|
|
162
|
+
expect(result.poc?.iterations).toEqual([]);
|
|
163
|
+
});
|
|
164
|
+
it('validates ImplementationPlan with milestones', () => {
|
|
165
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
166
|
+
plan: {
|
|
167
|
+
milestones: [
|
|
168
|
+
{ id: 'm1', title: 'Phase 1', items: ['Setup', 'Build'] },
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
}));
|
|
172
|
+
expect(result.plan?.milestones).toHaveLength(1);
|
|
173
|
+
});
|
|
174
|
+
it('validates BXT evaluation with classification', () => {
|
|
175
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
176
|
+
evaluation: {
|
|
177
|
+
ideas: [
|
|
178
|
+
{
|
|
179
|
+
ideaId: 'idea-1',
|
|
180
|
+
feasibility: 3,
|
|
181
|
+
value: 4,
|
|
182
|
+
risks: ['Data quality'],
|
|
183
|
+
dataNeeded: ['CRM data'],
|
|
184
|
+
humanValue: ['Time savings'],
|
|
185
|
+
kpisInfluenced: ['CSAT'],
|
|
186
|
+
},
|
|
187
|
+
],
|
|
188
|
+
method: 'feasibility-value-matrix',
|
|
189
|
+
},
|
|
190
|
+
}));
|
|
191
|
+
expect(result.evaluation?.ideas[0].risks).toContain('Data quality');
|
|
192
|
+
});
|
|
193
|
+
it('validates SelectedIdea', () => {
|
|
194
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
195
|
+
selection: {
|
|
196
|
+
ideaId: 'idea-1',
|
|
197
|
+
selectionRationale: 'Highest BXT score',
|
|
198
|
+
confirmedByUser: true,
|
|
199
|
+
confirmedAt: '2026-01-01T01:00:00Z',
|
|
200
|
+
},
|
|
201
|
+
}));
|
|
202
|
+
expect(result.selection?.confirmedByUser).toBe(true);
|
|
203
|
+
});
|
|
204
|
+
it('validates WorkflowMap with steps and edges', () => {
|
|
205
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
206
|
+
workflow: {
|
|
207
|
+
activities: [
|
|
208
|
+
{ id: 'step-1', name: 'Receive Order' },
|
|
209
|
+
{ id: 'step-2', name: 'Process Payment' },
|
|
210
|
+
],
|
|
211
|
+
edges: [{ fromStepId: 'step-1', toStepId: 'step-2' }],
|
|
212
|
+
},
|
|
213
|
+
}));
|
|
214
|
+
expect(result.workflow?.activities).toHaveLength(2);
|
|
215
|
+
expect(result.workflow?.edges).toHaveLength(1);
|
|
216
|
+
});
|
|
217
|
+
it('validates CardSelection', () => {
|
|
218
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
219
|
+
cards: {
|
|
220
|
+
selectedCards: [
|
|
221
|
+
{ id: 'extract-information', title: 'Extract Information' },
|
|
222
|
+
],
|
|
223
|
+
scores: [
|
|
224
|
+
{
|
|
225
|
+
cardId: 'extract-information',
|
|
226
|
+
dimensions: { relevance: 5, feasibility: 3 },
|
|
227
|
+
},
|
|
228
|
+
],
|
|
229
|
+
},
|
|
230
|
+
}));
|
|
231
|
+
expect(result.cards?.selectedCards).toHaveLength(1);
|
|
232
|
+
});
|
|
233
|
+
// ── T061: name field tests ─────────────────────────────────────────────────
|
|
234
|
+
it('accepts optional name field as string', () => {
|
|
235
|
+
const result = workshopSessionSchema.parse(validSession({ name: 'Logistics AI Routing' }));
|
|
236
|
+
expect(result.name).toBe('Logistics AI Routing');
|
|
237
|
+
});
|
|
238
|
+
it('omits name field gracefully when not provided', () => {
|
|
239
|
+
const result = workshopSessionSchema.parse(validSession());
|
|
240
|
+
expect(result.name).toBeUndefined();
|
|
241
|
+
});
|
|
242
|
+
it('rejects non-string name field', () => {
|
|
243
|
+
expect(() => workshopSessionSchema.parse(validSession({ name: 42 }))).toThrow();
|
|
244
|
+
});
|
|
245
|
+
it('validates ErrorRecord array', () => {
|
|
246
|
+
const result = workshopSessionSchema.parse(validSession({
|
|
247
|
+
errors: [
|
|
248
|
+
{
|
|
249
|
+
timestamp: '2026-01-01T00:10:00Z',
|
|
250
|
+
code: 'MCP_TIMEOUT',
|
|
251
|
+
message: 'WorkIQ timed out after 30s',
|
|
252
|
+
},
|
|
253
|
+
],
|
|
254
|
+
}));
|
|
255
|
+
expect(result.errors).toHaveLength(1);
|
|
256
|
+
});
|
|
257
|
+
});
|