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,365 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MCP Manager.
|
|
3
|
+
*
|
|
4
|
+
* Loads .vscode/mcp.json configuration, manages MCP server connections,
|
|
5
|
+
* lists available tools, classifies errors, and dispatches real MCP tool calls
|
|
6
|
+
* via the transport layer.
|
|
7
|
+
*/
|
|
8
|
+
import { readFile } from 'node:fs/promises';
|
|
9
|
+
import type { Logger } from 'pino';
|
|
10
|
+
|
|
11
|
+
import { createTransport, StdioMcpTransport } from './mcpTransport.js';
|
|
12
|
+
import type { McpTransport } from './mcpTransport.js';
|
|
13
|
+
import { withRetry } from './retryPolicy.js';
|
|
14
|
+
|
|
15
|
+
// ── Types ────────────────────────────────────────────────────────────────────
|
|
16
|
+
|
|
17
|
+
export interface StdioServerConfig {
|
|
18
|
+
name: string;
|
|
19
|
+
type: 'stdio';
|
|
20
|
+
command: string;
|
|
21
|
+
args: string[];
|
|
22
|
+
/** Environment variables for the subprocess (merged with process.env). */
|
|
23
|
+
env?: Record<string, string>;
|
|
24
|
+
/** Working directory for the subprocess. */
|
|
25
|
+
cwd?: string;
|
|
26
|
+
/** Restrict which tools are exposed from this server. */
|
|
27
|
+
tools?: string[];
|
|
28
|
+
/** Connection timeout in milliseconds. */
|
|
29
|
+
timeout?: number;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface HttpServerConfig {
|
|
33
|
+
name: string;
|
|
34
|
+
type: 'http';
|
|
35
|
+
url: string;
|
|
36
|
+
/** HTTP headers to include with each request (e.g., Authorization). */
|
|
37
|
+
headers?: Record<string, string>;
|
|
38
|
+
/** Restrict which tools are exposed from this server. */
|
|
39
|
+
tools?: string[];
|
|
40
|
+
/** Request timeout in milliseconds. */
|
|
41
|
+
timeout?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export type McpServerConfig = StdioServerConfig | HttpServerConfig;
|
|
45
|
+
|
|
46
|
+
export interface McpConfig {
|
|
47
|
+
servers: Record<string, McpServerConfig>;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ── Error classification ─────────────────────────────────────────────────────
|
|
51
|
+
|
|
52
|
+
export type McpErrorClass =
|
|
53
|
+
| 'connection-refused'
|
|
54
|
+
| 'dns-failure'
|
|
55
|
+
| 'timeout'
|
|
56
|
+
| 'auth-failure'
|
|
57
|
+
| 'unknown';
|
|
58
|
+
|
|
59
|
+
const ERROR_CODE_MAP: Record<string, McpErrorClass> = {
|
|
60
|
+
ECONNREFUSED: 'connection-refused',
|
|
61
|
+
ENOTFOUND: 'dns-failure',
|
|
62
|
+
ETIMEDOUT: 'timeout',
|
|
63
|
+
ECONNRESET: 'connection-refused',
|
|
64
|
+
ERR_TLS_CERT_ALTNAME_INVALID: 'auth-failure',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export function classifyMcpError(err: unknown): McpErrorClass {
|
|
68
|
+
if (err instanceof Error) {
|
|
69
|
+
const code = (err as NodeJS.ErrnoException).code;
|
|
70
|
+
if (code && code in ERROR_CODE_MAP) {
|
|
71
|
+
return ERROR_CODE_MAP[code];
|
|
72
|
+
}
|
|
73
|
+
// AbortError from AbortController / fetch timeouts
|
|
74
|
+
if (err instanceof DOMException && err.name === 'AbortError') {
|
|
75
|
+
return 'timeout';
|
|
76
|
+
}
|
|
77
|
+
// Message-based timeout detection
|
|
78
|
+
if (/timed?\s*out/i.test(err.message)) {
|
|
79
|
+
return 'timeout';
|
|
80
|
+
}
|
|
81
|
+
if (err.message.includes('401') || err.message.includes('403')) {
|
|
82
|
+
return 'auth-failure';
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return 'unknown';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// ── Config loader ────────────────────────────────────────────────────────────
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Load and normalize MCP configuration from a JSON file.
|
|
92
|
+
* Returns empty servers if the file doesn't exist.
|
|
93
|
+
*/
|
|
94
|
+
export async function loadMcpConfig(configPath: string): Promise<McpConfig> {
|
|
95
|
+
try {
|
|
96
|
+
const raw = await readFile(configPath, 'utf-8');
|
|
97
|
+
// Strip JSONC comments — only full-line // comments and block comments
|
|
98
|
+
// Avoid stripping // inside string values (e.g. URLs like https://)
|
|
99
|
+
const stripped = raw
|
|
100
|
+
.replace(/^\s*\/\/.*$/gm, '') // full-line // comments
|
|
101
|
+
.replace(/\/\*[\s\S]*?\*\//g, '') // block comments
|
|
102
|
+
.replace(/,(\s*[}\]])/g, '$1'); // trailing commas
|
|
103
|
+
const parsed = JSON.parse(stripped);
|
|
104
|
+
|
|
105
|
+
const servers: Record<string, McpServerConfig> = {};
|
|
106
|
+
|
|
107
|
+
if (parsed.servers && typeof parsed.servers === 'object') {
|
|
108
|
+
for (const [name, config] of Object.entries(parsed.servers)) {
|
|
109
|
+
const cfg = config as Record<string, unknown>;
|
|
110
|
+
|
|
111
|
+
if (cfg.url && typeof cfg.url === 'string') {
|
|
112
|
+
servers[name] = {
|
|
113
|
+
name,
|
|
114
|
+
type: 'http',
|
|
115
|
+
url: cfg.url,
|
|
116
|
+
...(cfg.headers && typeof cfg.headers === 'object'
|
|
117
|
+
? { headers: cfg.headers as Record<string, string> }
|
|
118
|
+
: {}),
|
|
119
|
+
...(Array.isArray(cfg.tools) ? { tools: cfg.tools as string[] } : {}),
|
|
120
|
+
...(typeof cfg.timeout === 'number' ? { timeout: cfg.timeout } : {}),
|
|
121
|
+
};
|
|
122
|
+
} else if (cfg.command && typeof cfg.command === 'string') {
|
|
123
|
+
servers[name] = {
|
|
124
|
+
name,
|
|
125
|
+
type: 'stdio',
|
|
126
|
+
command: cfg.command,
|
|
127
|
+
args: Array.isArray(cfg.args) ? cfg.args : [],
|
|
128
|
+
...(cfg.env && typeof cfg.env === 'object'
|
|
129
|
+
? { env: cfg.env as Record<string, string> }
|
|
130
|
+
: {}),
|
|
131
|
+
...(typeof cfg.cwd === 'string' ? { cwd: cfg.cwd } : {}),
|
|
132
|
+
...(Array.isArray(cfg.tools) ? { tools: cfg.tools as string[] } : {}),
|
|
133
|
+
...(typeof cfg.timeout === 'number' ? { timeout: cfg.timeout } : {}),
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return { servers };
|
|
140
|
+
} catch (err: unknown) {
|
|
141
|
+
if (err instanceof Error && 'code' in err && (err as NodeJS.ErrnoException).code === 'ENOENT') {
|
|
142
|
+
return { servers: {} };
|
|
143
|
+
}
|
|
144
|
+
// Re-throw parse or other errors
|
|
145
|
+
throw err;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
// ── SDK config bridge ────────────────────────────────────────────────────────
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* SDK-compatible MCP server config shape.
|
|
153
|
+
* Matches `MCPLocalServerConfig | MCPRemoteServerConfig` from `@github/copilot-sdk`.
|
|
154
|
+
* The `tools` field is required by the SDK (`string[]`); defaults to `['*']` (all tools).
|
|
155
|
+
*/
|
|
156
|
+
export interface SdkMcpServerConfig {
|
|
157
|
+
type?: string;
|
|
158
|
+
tools: string[];
|
|
159
|
+
timeout?: number;
|
|
160
|
+
command?: string;
|
|
161
|
+
args?: string[];
|
|
162
|
+
env?: Record<string, string>;
|
|
163
|
+
cwd?: string;
|
|
164
|
+
url?: string;
|
|
165
|
+
headers?: Record<string, string>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* Convert sofIA's `McpConfig` to the shape expected by the Copilot SDK's
|
|
170
|
+
* `SessionConfig.mcpServers` (`Record<string, MCPServerConfig>`).
|
|
171
|
+
*
|
|
172
|
+
* This bridges `.vscode/mcp.json` → SDK `createSession({ mcpServers })`.
|
|
173
|
+
* The SDK types are `MCPLocalServerConfig` and `MCPRemoteServerConfig`.
|
|
174
|
+
*/
|
|
175
|
+
export function toSdkMcpServers(config: McpConfig): Record<string, SdkMcpServerConfig> {
|
|
176
|
+
const result: Record<string, SdkMcpServerConfig> = {};
|
|
177
|
+
|
|
178
|
+
for (const [name, server] of Object.entries(config.servers)) {
|
|
179
|
+
if (server.type === 'stdio') {
|
|
180
|
+
result[name] = {
|
|
181
|
+
type: 'stdio',
|
|
182
|
+
command: server.command,
|
|
183
|
+
args: server.args,
|
|
184
|
+
tools: server.tools ?? ['*'],
|
|
185
|
+
...(server.env ? { env: server.env } : {}),
|
|
186
|
+
...(server.cwd ? { cwd: server.cwd } : {}),
|
|
187
|
+
...(server.timeout ? { timeout: server.timeout } : {}),
|
|
188
|
+
};
|
|
189
|
+
} else if (server.type === 'http') {
|
|
190
|
+
result[name] = {
|
|
191
|
+
type: 'http',
|
|
192
|
+
url: server.url,
|
|
193
|
+
tools: server.tools ?? ['*'],
|
|
194
|
+
...(server.headers ? { headers: server.headers } : {}),
|
|
195
|
+
...(server.timeout ? { timeout: server.timeout } : {}),
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return result;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// ── Default Timeouts ─────────────────────────────────────────────────────────
|
|
204
|
+
|
|
205
|
+
const DEFAULT_TIMEOUTS: Record<string, number> = {
|
|
206
|
+
github: 60_000,
|
|
207
|
+
context7: 30_000,
|
|
208
|
+
azure: 30_000,
|
|
209
|
+
workiq: 30_000,
|
|
210
|
+
'microsoftdocs/mcp': 30_000,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const FALLBACK_TIMEOUT = 30_000;
|
|
214
|
+
|
|
215
|
+
// ── McpManager ───────────────────────────────────────────────────────────────
|
|
216
|
+
|
|
217
|
+
export class McpManager {
|
|
218
|
+
private readonly config: McpConfig;
|
|
219
|
+
private readonly connectedServers = new Set<string>();
|
|
220
|
+
private readonly transports = new Map<string, McpTransport>();
|
|
221
|
+
private readonly logger?: Logger;
|
|
222
|
+
|
|
223
|
+
constructor(config: McpConfig, logger?: Logger) {
|
|
224
|
+
this.config = config;
|
|
225
|
+
this.logger = logger;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** List all configured server names. */
|
|
229
|
+
listServers(): string[] {
|
|
230
|
+
return Object.keys(this.config.servers);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** Get configuration for a specific server. */
|
|
234
|
+
getServerConfig(name: string): McpServerConfig | undefined {
|
|
235
|
+
return this.config.servers[name];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** Check if a server is currently connected (available). */
|
|
239
|
+
isAvailable(name: string): boolean {
|
|
240
|
+
return this.connectedServers.has(name);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/** Mark a server as connected. Used by the SDK integration layer. */
|
|
244
|
+
markConnected(name: string): void {
|
|
245
|
+
if (this.config.servers[name]) {
|
|
246
|
+
this.connectedServers.add(name);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** Mark a server as disconnected. */
|
|
251
|
+
markDisconnected(name: string): void {
|
|
252
|
+
this.connectedServers.delete(name);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Get all server configs as an array. */
|
|
256
|
+
getAllConfigs(): McpServerConfig[] {
|
|
257
|
+
return Object.values(this.config.servers);
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Call a tool on a named MCP server.
|
|
262
|
+
*
|
|
263
|
+
* Dispatches to the correct transport (stdio or HTTP), applies retry policy
|
|
264
|
+
* for transient errors, and normalizes the response.
|
|
265
|
+
*
|
|
266
|
+
* @param serverName The MCP server name (e.g., 'github', 'context7', 'azure')
|
|
267
|
+
* @param toolName The tool to call on that server
|
|
268
|
+
* @param args Arguments for the tool
|
|
269
|
+
* @param options Optional timeout and retry configuration
|
|
270
|
+
* @returns The tool response as a parsed object
|
|
271
|
+
*/
|
|
272
|
+
async callTool(
|
|
273
|
+
serverName: string,
|
|
274
|
+
toolName: string,
|
|
275
|
+
args: Record<string, unknown>,
|
|
276
|
+
options?: { timeoutMs?: number; retryOnTransient?: boolean },
|
|
277
|
+
): Promise<Record<string, unknown>> {
|
|
278
|
+
if (!this.isAvailable(serverName)) {
|
|
279
|
+
throw new Error(`MCP server '${serverName}' is not available`);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const serverConfig = this.config.servers[serverName];
|
|
283
|
+
if (!serverConfig) {
|
|
284
|
+
throw new Error(`Unknown MCP server: ${serverName}`);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
// Get or create transport
|
|
288
|
+
const transport = this.getOrCreateTransport(serverName, serverConfig);
|
|
289
|
+
|
|
290
|
+
// Connect stdio transports on first use
|
|
291
|
+
if (transport instanceof StdioMcpTransport && !transport.isConnected()) {
|
|
292
|
+
await transport.connect();
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const timeoutMs = options?.timeoutMs ?? DEFAULT_TIMEOUTS[serverName] ?? FALLBACK_TIMEOUT;
|
|
296
|
+
|
|
297
|
+
try {
|
|
298
|
+
let response;
|
|
299
|
+
if (options?.retryOnTransient !== false) {
|
|
300
|
+
response = await withRetry(() => transport.callTool(toolName, args, timeoutMs), {
|
|
301
|
+
serverName,
|
|
302
|
+
toolName,
|
|
303
|
+
logger: this.logger,
|
|
304
|
+
});
|
|
305
|
+
} else {
|
|
306
|
+
response = await transport.callTool(toolName, args, timeoutMs);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// Normalize content to Record<string, unknown>
|
|
310
|
+
const content = response.content;
|
|
311
|
+
if (typeof content === 'string') {
|
|
312
|
+
// Try to parse JSON string; if not JSON, wrap as { text: content }
|
|
313
|
+
try {
|
|
314
|
+
const parsed = JSON.parse(content);
|
|
315
|
+
if (typeof parsed === 'object' && parsed !== null) {
|
|
316
|
+
return parsed as Record<string, unknown>;
|
|
317
|
+
}
|
|
318
|
+
return { text: content };
|
|
319
|
+
} catch {
|
|
320
|
+
return { text: content };
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
return content;
|
|
324
|
+
} catch (err) {
|
|
325
|
+
this.markDisconnected(serverName);
|
|
326
|
+
throw err;
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/**
|
|
331
|
+
* Disconnect all cached transports and clear the registry.
|
|
332
|
+
*/
|
|
333
|
+
async disconnectAll(): Promise<void> {
|
|
334
|
+
const disconnections: Promise<void>[] = [];
|
|
335
|
+
for (const transport of this.transports.values()) {
|
|
336
|
+
disconnections.push(transport.disconnect());
|
|
337
|
+
}
|
|
338
|
+
await Promise.allSettled(disconnections);
|
|
339
|
+
this.transports.clear();
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/**
|
|
343
|
+
* Get or lazily create a transport for the given server.
|
|
344
|
+
*/
|
|
345
|
+
private getOrCreateTransport(serverName: string, config: McpServerConfig): McpTransport {
|
|
346
|
+
let transport = this.transports.get(serverName);
|
|
347
|
+
if (!transport) {
|
|
348
|
+
const logger =
|
|
349
|
+
this.logger ??
|
|
350
|
+
({
|
|
351
|
+
info: () => {},
|
|
352
|
+
warn: () => {},
|
|
353
|
+
error: () => {},
|
|
354
|
+
debug: () => {},
|
|
355
|
+
trace: () => {},
|
|
356
|
+
fatal: () => {},
|
|
357
|
+
child: () => logger,
|
|
358
|
+
level: 'silent',
|
|
359
|
+
} as unknown as Logger);
|
|
360
|
+
transport = createTransport(config, logger);
|
|
361
|
+
this.transports.set(serverName, transport);
|
|
362
|
+
}
|
|
363
|
+
return transport;
|
|
364
|
+
}
|
|
365
|
+
}
|