@dotcontext/cli 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +234 -135
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +27 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/generators/documentation/codebaseMapGenerator.d.ts +29 -46
- package/dist/generators/documentation/codebaseMapGenerator.d.ts.map +1 -1
- package/dist/generators/documentation/codebaseMapGenerator.js +148 -244
- package/dist/generators/documentation/codebaseMapGenerator.js.map +1 -1
- package/dist/generators/documentation/documentationGenerator.d.ts.map +1 -1
- package/dist/generators/documentation/documentationGenerator.js +13 -8
- package/dist/generators/documentation/documentationGenerator.js.map +1 -1
- package/dist/generators/documentation/index.d.ts +1 -1
- package/dist/generators/documentation/index.d.ts.map +1 -1
- package/dist/generators/shared/structures/documentation/architecture.d.ts.map +1 -1
- package/dist/generators/shared/structures/documentation/architecture.js +9 -9
- package/dist/generators/shared/structures/documentation/architecture.js.map +1 -1
- package/dist/generators/shared/structures/documentation/dataFlow.js +2 -2
- package/dist/generators/shared/structures/documentation/dataFlow.js.map +1 -1
- package/dist/generators/shared/structures/documentation/glossary.js +2 -2
- package/dist/generators/shared/structures/documentation/glossary.js.map +1 -1
- package/dist/generators/shared/structures/documentation/projectOverview.d.ts.map +1 -1
- package/dist/generators/shared/structures/documentation/projectOverview.js +10 -11
- package/dist/generators/shared/structures/documentation/projectOverview.js.map +1 -1
- package/dist/generators/shared/structures/skills/factory.d.ts.map +1 -1
- package/dist/generators/shared/structures/skills/factory.js +19 -15
- package/dist/generators/shared/structures/skills/factory.js.map +1 -1
- package/dist/generators/skills/skillGenerator.d.ts +2 -1
- package/dist/generators/skills/skillGenerator.d.ts.map +1 -1
- package/dist/generators/skills/skillGenerator.js +47 -6
- package/dist/generators/skills/skillGenerator.js.map +1 -1
- package/dist/generators/skills/templates/indexTemplate.d.ts.map +1 -1
- package/dist/generators/skills/templates/indexTemplate.js +22 -15
- package/dist/generators/skills/templates/indexTemplate.js.map +1 -1
- package/dist/harness/index.d.ts +11 -0
- package/dist/harness/index.d.ts.map +1 -0
- package/dist/harness/index.js +33 -0
- package/dist/harness/index.js.map +1 -0
- package/dist/index.js +365 -339
- package/dist/index.js.map +1 -1
- package/dist/mcp/bin.d.ts +19 -0
- package/dist/mcp/bin.d.ts.map +1 -0
- package/dist/mcp/bin.js +189 -0
- package/dist/mcp/bin.js.map +1 -0
- package/dist/mcp/index.d.ts +12 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +28 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/services/autoFill/autoFillService.d.ts.map +1 -1
- package/dist/services/autoFill/autoFillService.js +7 -6
- package/dist/services/autoFill/autoFillService.js.map +1 -1
- package/dist/services/cli/index.d.ts +8 -0
- package/dist/services/cli/index.d.ts.map +1 -0
- package/dist/services/cli/index.js +17 -0
- package/dist/services/cli/index.js.map +1 -0
- package/dist/services/cli/mcpInstallService.d.ts +57 -0
- package/dist/services/cli/mcpInstallService.d.ts.map +1 -0
- package/dist/services/cli/mcpInstallService.js +607 -0
- package/dist/services/cli/mcpInstallService.js.map +1 -0
- package/dist/services/cli/stateDetector.d.ts +55 -0
- package/dist/services/cli/stateDetector.d.ts.map +1 -0
- package/dist/services/cli/stateDetector.js +191 -0
- package/dist/services/cli/stateDetector.js.map +1 -0
- package/dist/services/export/contextExportService.js +3 -3
- package/dist/services/export/contextExportService.js.map +1 -1
- package/dist/services/export/exportRulesService.d.ts +1 -0
- package/dist/services/export/exportRulesService.d.ts.map +1 -1
- package/dist/services/export/exportRulesService.js +20 -8
- package/dist/services/export/exportRulesService.js.map +1 -1
- package/dist/services/export/skillExportService.d.ts.map +1 -1
- package/dist/services/export/skillExportService.js +4 -1
- package/dist/services/export/skillExportService.js.map +1 -1
- package/dist/services/harness/agentsService.d.ts +31 -0
- package/dist/services/harness/agentsService.d.ts.map +1 -0
- package/dist/services/harness/agentsService.js +135 -0
- package/dist/services/harness/agentsService.js.map +1 -0
- package/dist/services/harness/contextService.d.ts +167 -0
- package/dist/services/harness/contextService.d.ts.map +1 -0
- package/dist/services/harness/contextService.js +403 -0
- package/dist/services/harness/contextService.js.map +1 -0
- package/dist/services/harness/contextTools.d.ts +95 -0
- package/dist/services/harness/contextTools.d.ts.map +1 -0
- package/dist/services/harness/contextTools.js +990 -0
- package/dist/services/harness/contextTools.js.map +1 -0
- package/dist/services/harness/datasetService.d.ts +63 -0
- package/dist/services/harness/datasetService.d.ts.map +1 -0
- package/dist/services/harness/datasetService.js +261 -0
- package/dist/services/harness/datasetService.js.map +1 -0
- package/dist/services/harness/executionService.d.ts +74 -0
- package/dist/services/harness/executionService.d.ts.map +1 -0
- package/dist/services/harness/executionService.js +213 -0
- package/dist/services/harness/executionService.js.map +1 -0
- package/dist/services/harness/index.d.ts +21 -0
- package/dist/services/harness/index.d.ts.map +1 -0
- package/dist/services/harness/index.js +52 -0
- package/dist/services/harness/index.js.map +1 -0
- package/dist/services/harness/plansService.d.ts +45 -0
- package/dist/services/harness/plansService.d.ts.map +1 -0
- package/dist/services/harness/plansService.js +251 -0
- package/dist/services/harness/plansService.js.map +1 -0
- package/dist/services/harness/policyService.d.ts +116 -0
- package/dist/services/harness/policyService.d.ts.map +1 -0
- package/dist/services/harness/policyService.js +510 -0
- package/dist/services/harness/policyService.js.map +1 -0
- package/dist/services/harness/replayService.d.ts +63 -0
- package/dist/services/harness/replayService.d.ts.map +1 -0
- package/dist/services/harness/replayService.js +242 -0
- package/dist/services/harness/replayService.js.map +1 -0
- package/dist/services/harness/runtimeStateService.d.ts +120 -0
- package/dist/services/harness/runtimeStateService.d.ts.map +1 -0
- package/dist/services/harness/runtimeStateService.js +316 -0
- package/dist/services/harness/runtimeStateService.js.map +1 -0
- package/dist/services/harness/sensorCatalogService.d.ts +50 -0
- package/dist/services/harness/sensorCatalogService.d.ts.map +1 -0
- package/dist/services/harness/sensorCatalogService.js +308 -0
- package/dist/services/harness/sensorCatalogService.js.map +1 -0
- package/dist/services/harness/sensorsService.d.ts +64 -0
- package/dist/services/harness/sensorsService.d.ts.map +1 -0
- package/dist/services/harness/sensorsService.js +88 -0
- package/dist/services/harness/sensorsService.js.map +1 -0
- package/dist/services/harness/skillsService.d.ts +31 -0
- package/dist/services/harness/skillsService.d.ts.map +1 -0
- package/dist/services/harness/skillsService.js +296 -0
- package/dist/services/harness/skillsService.js.map +1 -0
- package/dist/services/harness/taskContractsService.d.ts +88 -0
- package/dist/services/harness/taskContractsService.d.ts.map +1 -0
- package/dist/services/harness/taskContractsService.js +210 -0
- package/dist/services/harness/taskContractsService.js.map +1 -0
- package/dist/services/harness/workflowStateService.d.ts +51 -0
- package/dist/services/harness/workflowStateService.d.ts.map +1 -0
- package/dist/services/harness/workflowStateService.js +215 -0
- package/dist/services/harness/workflowStateService.js.map +1 -0
- package/dist/services/import/agentsDetector.d.ts.map +1 -1
- package/dist/services/import/agentsDetector.js +14 -8
- package/dist/services/import/agentsDetector.js.map +1 -1
- package/dist/services/import/importAgentsService.d.ts +2 -2
- package/dist/services/import/importAgentsService.d.ts.map +1 -1
- package/dist/services/import/importAgentsService.js +8 -1
- package/dist/services/import/importAgentsService.js.map +1 -1
- package/dist/services/import/importRulesService.d.ts +2 -2
- package/dist/services/import/importRulesService.d.ts.map +1 -1
- package/dist/services/import/importRulesService.js +8 -1
- package/dist/services/import/importRulesService.js.map +1 -1
- package/dist/services/import/presets.js +2 -2
- package/dist/services/import/presets.js.map +1 -1
- package/dist/services/import/rulesDetector.d.ts.map +1 -1
- package/dist/services/import/rulesDetector.js +16 -1
- package/dist/services/import/rulesDetector.js.map +1 -1
- package/dist/services/import/types.d.ts +1 -1
- package/dist/services/import/types.d.ts.map +1 -1
- package/dist/services/mcp/actionLogger.d.ts +2 -1
- package/dist/services/mcp/actionLogger.d.ts.map +1 -1
- package/dist/services/mcp/actionLogger.js +76 -15
- package/dist/services/mcp/actionLogger.js.map +1 -1
- package/dist/services/mcp/gateway/agent.d.ts.map +1 -1
- package/dist/services/mcp/gateway/agent.js +15 -104
- package/dist/services/mcp/gateway/agent.js.map +1 -1
- package/dist/services/mcp/gateway/context.d.ts.map +1 -1
- package/dist/services/mcp/gateway/context.js +60 -172
- package/dist/services/mcp/gateway/context.js.map +1 -1
- package/dist/services/mcp/gateway/explore.js +6 -6
- package/dist/services/mcp/gateway/explore.js.map +1 -1
- package/dist/services/mcp/gateway/harness.d.ts +7 -0
- package/dist/services/mcp/gateway/harness.d.ts.map +1 -0
- package/dist/services/mcp/gateway/harness.js +337 -0
- package/dist/services/mcp/gateway/harness.js.map +1 -0
- package/dist/services/mcp/gateway/index.d.ts +3 -2
- package/dist/services/mcp/gateway/index.d.ts.map +1 -1
- package/dist/services/mcp/gateway/index.js +4 -2
- package/dist/services/mcp/gateway/index.js.map +1 -1
- package/dist/services/mcp/gateway/metrics.d.ts.map +1 -1
- package/dist/services/mcp/gateway/metrics.js +8 -8
- package/dist/services/mcp/gateway/metrics.js.map +1 -1
- package/dist/services/mcp/gateway/plan.d.ts.map +1 -1
- package/dist/services/mcp/gateway/plan.js +23 -211
- package/dist/services/mcp/gateway/plan.js.map +1 -1
- package/dist/services/mcp/gateway/shared.d.ts +1 -32
- package/dist/services/mcp/gateway/shared.d.ts.map +1 -1
- package/dist/services/mcp/gateway/shared.js +4 -30
- package/dist/services/mcp/gateway/shared.js.map +1 -1
- package/dist/services/mcp/gateway/skill.d.ts.map +1 -1
- package/dist/services/mcp/gateway/skill.js +14 -281
- package/dist/services/mcp/gateway/skill.js.map +1 -1
- package/dist/services/mcp/gateway/types.d.ts +74 -3
- package/dist/services/mcp/gateway/types.d.ts.map +1 -1
- package/dist/services/mcp/gateway/workflowAdvance.d.ts.map +1 -1
- package/dist/services/mcp/gateway/workflowAdvance.js +37 -9
- package/dist/services/mcp/gateway/workflowAdvance.js.map +1 -1
- package/dist/services/mcp/gateway/workflowInit.d.ts.map +1 -1
- package/dist/services/mcp/gateway/workflowInit.js +8 -2
- package/dist/services/mcp/gateway/workflowInit.js.map +1 -1
- package/dist/services/mcp/gateway/workflowManage.d.ts +17 -1
- package/dist/services/mcp/gateway/workflowManage.d.ts.map +1 -1
- package/dist/services/mcp/gateway/workflowManage.js +155 -10
- package/dist/services/mcp/gateway/workflowManage.js.map +1 -1
- package/dist/services/mcp/gateway/workflowStatus.d.ts.map +1 -1
- package/dist/services/mcp/gateway/workflowStatus.js +5 -3
- package/dist/services/mcp/gateway/workflowStatus.js.map +1 -1
- package/dist/services/mcp/gatewayTools.d.ts +1 -1
- package/dist/services/mcp/gatewayTools.d.ts.map +1 -1
- package/dist/services/mcp/gatewayTools.js +2 -1
- package/dist/services/mcp/gatewayTools.js.map +1 -1
- package/dist/services/mcp/index.d.ts +10 -4
- package/dist/services/mcp/index.d.ts.map +1 -1
- package/dist/services/mcp/index.js +9 -3
- package/dist/services/mcp/index.js.map +1 -1
- package/dist/services/mcp/mcpInstallService.d.ts +4 -52
- package/dist/services/mcp/mcpInstallService.d.ts.map +1 -1
- package/dist/services/mcp/mcpInstallService.js +5 -596
- package/dist/services/mcp/mcpInstallService.js.map +1 -1
- package/dist/services/mcp/mcpServer.d.ts +5 -6
- package/dist/services/mcp/mcpServer.d.ts.map +1 -1
- package/dist/services/mcp/mcpServer.js +220 -28
- package/dist/services/mcp/mcpServer.js.map +1 -1
- package/dist/services/qa/patternInferer.d.ts +2 -31
- package/dist/services/qa/patternInferer.d.ts.map +1 -1
- package/dist/services/qa/patternInferer.js +4 -353
- package/dist/services/qa/patternInferer.js.map +1 -1
- package/dist/services/qa/qaService.d.ts +6 -10
- package/dist/services/qa/qaService.d.ts.map +1 -1
- package/dist/services/qa/qaService.js +17 -53
- package/dist/services/qa/qaService.js.map +1 -1
- package/dist/services/reverseSync/importSkillsService.d.ts.map +1 -1
- package/dist/services/reverseSync/importSkillsService.js +4 -1
- package/dist/services/reverseSync/importSkillsService.js.map +1 -1
- package/dist/services/reverseSync/reverseQuickSyncService.d.ts.map +1 -1
- package/dist/services/reverseSync/reverseQuickSyncService.js +10 -6
- package/dist/services/reverseSync/reverseQuickSyncService.js.map +1 -1
- package/dist/services/reverseSync/skillsDetector.js +2 -2
- package/dist/services/reverseSync/skillsDetector.js.map +1 -1
- package/dist/services/reverseSync/toolDetector.d.ts.map +1 -1
- package/dist/services/reverseSync/toolDetector.js +3 -0
- package/dist/services/reverseSync/toolDetector.js.map +1 -1
- package/dist/services/semantic/index.d.ts +1 -0
- package/dist/services/semantic/index.d.ts.map +1 -1
- package/dist/services/semantic/index.js +3 -1
- package/dist/services/semantic/index.js.map +1 -1
- package/dist/services/semantic/semanticSnapshotService.d.ts +86 -0
- package/dist/services/semantic/semanticSnapshotService.d.ts.map +1 -0
- package/dist/services/semantic/semanticSnapshotService.js +573 -0
- package/dist/services/semantic/semanticSnapshotService.js.map +1 -0
- package/dist/services/shared/contentTypeRegistry.d.ts.map +1 -1
- package/dist/services/shared/contentTypeRegistry.js +9 -0
- package/dist/services/shared/contentTypeRegistry.js.map +1 -1
- package/dist/services/shared/contextLayout.d.ts +18 -0
- package/dist/services/shared/contextLayout.d.ts.map +1 -0
- package/dist/services/shared/contextLayout.js +139 -0
- package/dist/services/shared/contextLayout.js.map +1 -0
- package/dist/services/shared/executionContext.d.ts +38 -0
- package/dist/services/shared/executionContext.d.ts.map +1 -0
- package/dist/services/shared/executionContext.js +39 -0
- package/dist/services/shared/executionContext.js.map +1 -0
- package/dist/services/shared/index.d.ts +2 -0
- package/dist/services/shared/index.d.ts.map +1 -1
- package/dist/services/shared/index.js +11 -1
- package/dist/services/shared/index.js.map +1 -1
- package/dist/services/shared/toolRegistry.d.ts +6 -0
- package/dist/services/shared/toolRegistry.d.ts.map +1 -1
- package/dist/services/shared/toolRegistry.js +34 -20
- package/dist/services/shared/toolRegistry.js.map +1 -1
- package/dist/services/stack/scaffoldFilter.d.ts +3 -3
- package/dist/services/state/stateDetector.d.ts +4 -49
- package/dist/services/state/stateDetector.d.ts.map +1 -1
- package/dist/services/state/stateDetector.js +9 -182
- package/dist/services/state/stateDetector.js.map +1 -1
- package/dist/services/sync/index.d.ts +1 -1
- package/dist/services/sync/index.d.ts.map +1 -1
- package/dist/services/sync/index.js.map +1 -1
- package/dist/services/sync/markdownReferenceHandler.d.ts.map +1 -1
- package/dist/services/sync/markdownReferenceHandler.js +7 -2
- package/dist/services/sync/markdownReferenceHandler.js.map +1 -1
- package/dist/services/sync/presets.d.ts.map +1 -1
- package/dist/services/sync/presets.js +1 -0
- package/dist/services/sync/presets.js.map +1 -1
- package/dist/services/sync/symlinkHandler.d.ts.map +1 -1
- package/dist/services/sync/symlinkHandler.js +7 -2
- package/dist/services/sync/symlinkHandler.js.map +1 -1
- package/dist/services/sync/syncService.d.ts +2 -2
- package/dist/services/sync/syncService.d.ts.map +1 -1
- package/dist/services/sync/syncService.js +17 -3
- package/dist/services/sync/syncService.js.map +1 -1
- package/dist/services/sync/types.d.ts +9 -1
- package/dist/services/sync/types.d.ts.map +1 -1
- package/dist/services/workflow/index.d.ts +1 -1
- package/dist/services/workflow/index.d.ts.map +1 -1
- package/dist/services/workflow/index.js +2 -1
- package/dist/services/workflow/index.js.map +1 -1
- package/dist/services/workflow/workflowService.d.ts +68 -0
- package/dist/services/workflow/workflowService.d.ts.map +1 -1
- package/dist/services/workflow/workflowService.js +416 -1
- package/dist/services/workflow/workflowService.js.map +1 -1
- package/dist/utils/gitignoreManager.d.ts +8 -0
- package/dist/utils/gitignoreManager.d.ts.map +1 -1
- package/dist/utils/gitignoreManager.js +40 -0
- package/dist/utils/gitignoreManager.js.map +1 -1
- package/dist/utils/i18n.d.ts +1 -1
- package/dist/utils/i18n.js +2 -2
- package/dist/utils/i18n.js.map +1 -1
- package/dist/utils/processShutdown.d.ts +20 -0
- package/dist/utils/processShutdown.d.ts.map +1 -0
- package/dist/utils/processShutdown.js +47 -0
- package/dist/utils/processShutdown.js.map +1 -0
- package/dist/utils/prompts/index.d.ts +1 -1
- package/dist/utils/prompts/index.d.ts.map +1 -1
- package/dist/utils/prompts/index.js +1 -3
- package/dist/utils/prompts/index.js.map +1 -1
- package/dist/utils/prompts/smartDefaults.d.ts +0 -9
- package/dist/utils/prompts/smartDefaults.d.ts.map +1 -1
- package/dist/utils/prompts/smartDefaults.js +0 -23
- package/dist/utils/prompts/smartDefaults.js.map +1 -1
- package/dist/utils/prompts/types.d.ts +0 -11
- package/dist/utils/prompts/types.d.ts.map +1 -1
- package/dist/workflow/index.d.ts +1 -1
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/index.js +6 -1
- package/dist/workflow/index.js.map +1 -1
- package/dist/workflow/orchestrator.d.ts.map +1 -1
- package/dist/workflow/orchestrator.js +3 -14
- package/dist/workflow/orchestrator.js.map +1 -1
- package/dist/workflow/plans/planLinker.d.ts +13 -0
- package/dist/workflow/plans/planLinker.d.ts.map +1 -1
- package/dist/workflow/plans/planLinker.js +77 -2
- package/dist/workflow/plans/planLinker.js.map +1 -1
- package/dist/workflow/plans/types.d.ts +6 -0
- package/dist/workflow/plans/types.d.ts.map +1 -1
- package/dist/workflow/skills/frontmatter.d.ts +9 -0
- package/dist/workflow/skills/frontmatter.d.ts.map +1 -1
- package/dist/workflow/skills/frontmatter.js +16 -0
- package/dist/workflow/skills/frontmatter.js.map +1 -1
- package/dist/workflow/skills/index.d.ts +1 -1
- package/dist/workflow/skills/index.d.ts.map +1 -1
- package/dist/workflow/skills/index.js +3 -1
- package/dist/workflow/skills/index.js.map +1 -1
- package/dist/workflow/skills/skillRegistry.d.ts.map +1 -1
- package/dist/workflow/skills/skillRegistry.js +4 -1
- package/dist/workflow/skills/skillRegistry.js.map +1 -1
- package/dist/workflow/skills/skillTemplates.d.ts.map +1 -1
- package/dist/workflow/skills/skillTemplates.js +69 -30
- package/dist/workflow/skills/skillTemplates.js.map +1 -1
- package/dist/workflow/status/statusManager.d.ts +8 -3
- package/dist/workflow/status/statusManager.d.ts.map +1 -1
- package/dist/workflow/status/statusManager.js +60 -21
- package/dist/workflow/status/statusManager.js.map +1 -1
- package/dist/workflow/types.d.ts +1 -1
- package/package.json +16 -7
- package/dist/services/ai/aiSdkClient.d.ts +0 -67
- package/dist/services/ai/aiSdkClient.d.ts.map +0 -1
- package/dist/services/ai/aiSdkClient.js +0 -143
- package/dist/services/ai/aiSdkClient.js.map +0 -1
- package/dist/services/ai/index.d.ts +0 -5
- package/dist/services/ai/index.d.ts.map +0 -1
- package/dist/services/ai/index.js +0 -40
- package/dist/services/ai/index.js.map +0 -1
- package/dist/services/ai/providerFactory.d.ts +0 -35
- package/dist/services/ai/providerFactory.d.ts.map +0 -1
- package/dist/services/ai/providerFactory.js +0 -107
- package/dist/services/ai/providerFactory.js.map +0 -1
- package/dist/services/ai/schemas.d.ts +0 -557
- package/dist/services/ai/schemas.d.ts.map +0 -1
- package/dist/services/ai/schemas.js +0 -357
- package/dist/services/ai/schemas.js.map +0 -1
- package/dist/services/ai/toolRegistry.d.ts +0 -27
- package/dist/services/ai/toolRegistry.d.ts.map +0 -1
- package/dist/services/ai/toolRegistry.js +0 -151
- package/dist/services/ai/toolRegistry.js.map +0 -1
- package/dist/services/ai/tools/analyzeSymbolsTool.d.ts +0 -33
- package/dist/services/ai/tools/analyzeSymbolsTool.d.ts.map +0 -1
- package/dist/services/ai/tools/analyzeSymbolsTool.js +0 -57
- package/dist/services/ai/tools/analyzeSymbolsTool.js.map +0 -1
- package/dist/services/ai/tools/checkScaffoldingTool.d.ts +0 -18
- package/dist/services/ai/tools/checkScaffoldingTool.d.ts.map +0 -1
- package/dist/services/ai/tools/checkScaffoldingTool.js +0 -89
- package/dist/services/ai/tools/checkScaffoldingTool.js.map +0 -1
- package/dist/services/ai/tools/fillScaffoldingTool.d.ts +0 -124
- package/dist/services/ai/tools/fillScaffoldingTool.d.ts.map +0 -1
- package/dist/services/ai/tools/fillScaffoldingTool.js +0 -397
- package/dist/services/ai/tools/fillScaffoldingTool.js.map +0 -1
- package/dist/services/ai/tools/getCodebaseMapTool.d.ts +0 -17
- package/dist/services/ai/tools/getCodebaseMapTool.d.ts.map +0 -1
- package/dist/services/ai/tools/getCodebaseMapTool.js +0 -122
- package/dist/services/ai/tools/getCodebaseMapTool.js.map +0 -1
- package/dist/services/ai/tools/getFileStructureTool.d.ts +0 -29
- package/dist/services/ai/tools/getFileStructureTool.d.ts.map +0 -1
- package/dist/services/ai/tools/getFileStructureTool.js +0 -48
- package/dist/services/ai/tools/getFileStructureTool.js.map +0 -1
- package/dist/services/ai/tools/index.d.ts +0 -21
- package/dist/services/ai/tools/index.d.ts.map +0 -1
- package/dist/services/ai/tools/index.js +0 -75
- package/dist/services/ai/tools/index.js.map +0 -1
- package/dist/services/ai/tools/initializeContextTool.d.ts +0 -135
- package/dist/services/ai/tools/initializeContextTool.d.ts.map +0 -1
- package/dist/services/ai/tools/initializeContextTool.js +0 -447
- package/dist/services/ai/tools/initializeContextTool.js.map +0 -1
- package/dist/services/ai/tools/listFilesTool.d.ts +0 -18
- package/dist/services/ai/tools/listFilesTool.d.ts.map +0 -1
- package/dist/services/ai/tools/listFilesTool.js +0 -34
- package/dist/services/ai/tools/listFilesTool.js.map +0 -1
- package/dist/services/ai/tools/readFileTool.d.ts +0 -17
- package/dist/services/ai/tools/readFileTool.d.ts.map +0 -1
- package/dist/services/ai/tools/readFileTool.js +0 -63
- package/dist/services/ai/tools/readFileTool.js.map +0 -1
- package/dist/services/ai/tools/scaffoldPlanTool.d.ts +0 -41
- package/dist/services/ai/tools/scaffoldPlanTool.d.ts.map +0 -1
- package/dist/services/ai/tools/scaffoldPlanTool.js +0 -183
- package/dist/services/ai/tools/scaffoldPlanTool.js.map +0 -1
- package/dist/services/ai/tools/searchCodeTool.d.ts +0 -25
- package/dist/services/ai/tools/searchCodeTool.d.ts.map +0 -1
- package/dist/services/ai/tools/searchCodeTool.js +0 -96
- package/dist/services/ai/tools/searchCodeTool.js.map +0 -1
- package/dist/services/baseLLMClient.d.ts +0 -12
- package/dist/services/baseLLMClient.d.ts.map +0 -1
- package/dist/services/baseLLMClient.js +0 -80
- package/dist/services/baseLLMClient.js.map +0 -1
|
@@ -0,0 +1,990 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.TOOL_NAMES = exports.getCodebaseMapTool = exports.fillScaffoldingTool = exports.fillSingleFileTool = exports.listFilesToFillTool = exports.scaffoldPlanTool = exports.initializeContextTool = exports.checkScaffoldingTool = exports.searchCodeTool = exports.getFileStructureTool = exports.analyzeSymbolsTool = exports.listFilesTool = exports.readFileTool = void 0;
|
|
37
|
+
exports.getOrBuildContext = getOrBuildContext;
|
|
38
|
+
exports.cleanupSharedContext = cleanupSharedContext;
|
|
39
|
+
const fs = __importStar(require("fs-extra"));
|
|
40
|
+
const glob_1 = require("glob");
|
|
41
|
+
const path = __importStar(require("path"));
|
|
42
|
+
const treeSitterLayer_1 = require("../semantic/treeSitter/treeSitterLayer");
|
|
43
|
+
const contextBuilder_1 = require("../semantic/contextBuilder");
|
|
44
|
+
const types_1 = require("../semantic/types");
|
|
45
|
+
const fileMapper_1 = require("../../utils/fileMapper");
|
|
46
|
+
const frontMatter_1 = require("../../utils/frontMatter");
|
|
47
|
+
const scaffoldStructures_1 = require("../../generators/shared/scaffoldStructures");
|
|
48
|
+
const documentationGenerator_1 = require("../../generators/documentation/documentationGenerator");
|
|
49
|
+
const semantic_1 = require("../semantic");
|
|
50
|
+
const agentGenerator_1 = require("../../generators/agents/agentGenerator");
|
|
51
|
+
const skillGenerator_1 = require("../../generators/skills/skillGenerator");
|
|
52
|
+
const planGenerator_1 = require("../../generators/plans/planGenerator");
|
|
53
|
+
const stack_1 = require("../stack");
|
|
54
|
+
const qa_1 = require("../qa");
|
|
55
|
+
const policyService_1 = require("./policyService");
|
|
56
|
+
const sensorCatalogService_1 = require("./sensorCatalogService");
|
|
57
|
+
const shared_1 = require("../shared");
|
|
58
|
+
const skills_1 = require("../../workflow/skills");
|
|
59
|
+
const gitignoreManager_1 = require("../../utils/gitignoreManager");
|
|
60
|
+
function createInternalTool(description, execute) {
|
|
61
|
+
return { description, execute };
|
|
62
|
+
}
|
|
63
|
+
async function collectScaffoldFiles(outputDir, target = 'all') {
|
|
64
|
+
const files = [];
|
|
65
|
+
if (target === 'all' || target === 'docs') {
|
|
66
|
+
const docsDir = path.join(outputDir, 'docs');
|
|
67
|
+
if (await fs.pathExists(docsDir)) {
|
|
68
|
+
const docFiles = await (0, glob_1.glob)('**/*.md', { cwd: docsDir, nodir: true });
|
|
69
|
+
for (const file of docFiles.sort()) {
|
|
70
|
+
const filePath = path.join(docsDir, file);
|
|
71
|
+
if (!await (0, frontMatter_1.needsFill)(filePath))
|
|
72
|
+
continue;
|
|
73
|
+
files.push({
|
|
74
|
+
path: filePath,
|
|
75
|
+
relativePath: path.join('docs', file),
|
|
76
|
+
type: 'doc',
|
|
77
|
+
documentName: path.basename(file, '.md'),
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (target === 'all' || target === 'agents') {
|
|
83
|
+
const agentsDir = path.join(outputDir, 'agents');
|
|
84
|
+
if (await fs.pathExists(agentsDir)) {
|
|
85
|
+
const agentFiles = await (0, glob_1.glob)('**/*.md', { cwd: agentsDir, nodir: true });
|
|
86
|
+
for (const file of agentFiles.sort()) {
|
|
87
|
+
const filePath = path.join(agentsDir, file);
|
|
88
|
+
if (!await (0, frontMatter_1.needsFill)(filePath))
|
|
89
|
+
continue;
|
|
90
|
+
files.push({
|
|
91
|
+
path: filePath,
|
|
92
|
+
relativePath: path.join('agents', file),
|
|
93
|
+
type: 'agent',
|
|
94
|
+
documentName: path.basename(file, '.md'),
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (target === 'all' || target === 'skills') {
|
|
100
|
+
const skillsDir = path.join(outputDir, 'skills');
|
|
101
|
+
if (await fs.pathExists(skillsDir)) {
|
|
102
|
+
const skillFiles = await (0, glob_1.glob)('**/SKILL.md', { cwd: skillsDir, nodir: true });
|
|
103
|
+
for (const file of skillFiles.sort()) {
|
|
104
|
+
const skillPath = path.join(skillsDir, file);
|
|
105
|
+
if (!await (0, frontMatter_1.needsFill)(skillPath))
|
|
106
|
+
continue;
|
|
107
|
+
const segments = file.split(path.sep);
|
|
108
|
+
files.push({
|
|
109
|
+
path: skillPath,
|
|
110
|
+
relativePath: path.join('skills', file),
|
|
111
|
+
type: 'skill',
|
|
112
|
+
documentName: segments[0],
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
if (target === 'all' || target === 'plans') {
|
|
118
|
+
const plansDir = path.join(outputDir, 'plans');
|
|
119
|
+
if (await fs.pathExists(plansDir)) {
|
|
120
|
+
const planFiles = await (0, glob_1.glob)('**/*.md', { cwd: plansDir, nodir: true });
|
|
121
|
+
for (const file of planFiles.sort()) {
|
|
122
|
+
const filePath = path.join(plansDir, file);
|
|
123
|
+
if (!await (0, frontMatter_1.needsFill)(filePath))
|
|
124
|
+
continue;
|
|
125
|
+
files.push({
|
|
126
|
+
path: filePath,
|
|
127
|
+
relativePath: path.join('plans', file),
|
|
128
|
+
type: 'plan',
|
|
129
|
+
documentName: path.basename(file, '.md'),
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
if (target === 'all' || target === 'sensors') {
|
|
135
|
+
const sensorsPath = path.join(outputDir, 'harness', 'sensors.json');
|
|
136
|
+
if (await fs.pathExists(sensorsPath) && await sensorCatalogNeedsFill(sensorsPath)) {
|
|
137
|
+
files.push({
|
|
138
|
+
path: sensorsPath,
|
|
139
|
+
relativePath: path.join('harness', 'sensors.json'),
|
|
140
|
+
type: 'sensor',
|
|
141
|
+
documentName: 'sensors',
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
return files;
|
|
146
|
+
}
|
|
147
|
+
function resolveScaffoldFileInfo(outputDir, filePath) {
|
|
148
|
+
const resolvedOutputDir = path.resolve(outputDir);
|
|
149
|
+
const resolvedFilePath = path.resolve(filePath);
|
|
150
|
+
const relativePath = path.relative(resolvedOutputDir, resolvedFilePath);
|
|
151
|
+
const segments = relativePath.split(path.sep);
|
|
152
|
+
if (segments[0] === 'skills' && segments.length >= 3 && segments[2] === 'SKILL.md') {
|
|
153
|
+
return {
|
|
154
|
+
path: resolvedFilePath,
|
|
155
|
+
relativePath,
|
|
156
|
+
type: 'skill',
|
|
157
|
+
documentName: segments[1],
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
if (segments[0] === 'agents') {
|
|
161
|
+
return {
|
|
162
|
+
path: resolvedFilePath,
|
|
163
|
+
relativePath,
|
|
164
|
+
type: 'agent',
|
|
165
|
+
documentName: path.basename(resolvedFilePath, '.md'),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
if (segments[0] === 'plans') {
|
|
169
|
+
return {
|
|
170
|
+
path: resolvedFilePath,
|
|
171
|
+
relativePath,
|
|
172
|
+
type: 'plan',
|
|
173
|
+
documentName: path.basename(resolvedFilePath, '.md'),
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
if (segments[0] === 'harness' && segments[1] === 'sensors.json') {
|
|
177
|
+
return {
|
|
178
|
+
path: resolvedFilePath,
|
|
179
|
+
relativePath,
|
|
180
|
+
type: 'sensor',
|
|
181
|
+
documentName: 'sensors',
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
path: resolvedFilePath,
|
|
186
|
+
relativePath,
|
|
187
|
+
type: 'doc',
|
|
188
|
+
documentName: path.basename(resolvedFilePath, '.md'),
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function getDocFillInstructions(fileName) {
|
|
192
|
+
return `Fill ${fileName} with repository-specific documentation. Use concrete paths, conventions, and examples from this codebase instead of placeholders.`;
|
|
193
|
+
}
|
|
194
|
+
function getAgentFillInstructions(agentType) {
|
|
195
|
+
return `Fill the ${agentType} playbook with concrete responsibilities, relevant files, workflows, and quality checks used in this repository.`;
|
|
196
|
+
}
|
|
197
|
+
function getSkillFillInstructions(skillSlug) {
|
|
198
|
+
return `Fill the ${skillSlug} skill with project-specific guidance, examples, and references to real files and conventions from this repository.`;
|
|
199
|
+
}
|
|
200
|
+
function getSensorFillInstructions() {
|
|
201
|
+
return 'Review .context/harness/sensors.json and rewrite it as a project-specific sensor catalog. Keep the JSON schema valid, keep version at 1, set source to "manual", preserve stack metadata, and keep only commands that make sense for this repository.';
|
|
202
|
+
}
|
|
203
|
+
async function sensorCatalogNeedsFill(filePath) {
|
|
204
|
+
try {
|
|
205
|
+
const content = await fs.readJson(filePath);
|
|
206
|
+
return content.source !== 'manual';
|
|
207
|
+
}
|
|
208
|
+
catch {
|
|
209
|
+
return false;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
async function hasContent(dirPath) {
|
|
213
|
+
try {
|
|
214
|
+
const entries = await fs.readdir(dirPath);
|
|
215
|
+
return entries.length > 0;
|
|
216
|
+
}
|
|
217
|
+
catch {
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
async function hasSkillContent(skillsDir) {
|
|
222
|
+
try {
|
|
223
|
+
const entries = await fs.readdir(skillsDir);
|
|
224
|
+
for (const entry of entries) {
|
|
225
|
+
const skillDir = path.join(skillsDir, entry);
|
|
226
|
+
const stat = await fs.stat(skillDir).catch(() => null);
|
|
227
|
+
if (!stat?.isDirectory())
|
|
228
|
+
continue;
|
|
229
|
+
if (await fs.pathExists(path.join(skillDir, 'SKILL.md'))) {
|
|
230
|
+
return true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return false;
|
|
234
|
+
}
|
|
235
|
+
catch {
|
|
236
|
+
return false;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
async function hasHarnessRuntimeContent(harnessDir) {
|
|
240
|
+
const runtimeEntries = ['sessions', 'traces', 'artifacts', 'contracts', 'workflows', 'replays', 'datasets'];
|
|
241
|
+
for (const entry of runtimeEntries) {
|
|
242
|
+
if (await hasContent(path.join(harnessDir, entry))) {
|
|
243
|
+
return true;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
let treeSitterInstance = null;
|
|
249
|
+
function getTreeSitterLayer() {
|
|
250
|
+
if (!treeSitterInstance) {
|
|
251
|
+
treeSitterInstance = new treeSitterLayer_1.TreeSitterLayer();
|
|
252
|
+
}
|
|
253
|
+
return treeSitterInstance;
|
|
254
|
+
}
|
|
255
|
+
let sharedContextBuilder = null;
|
|
256
|
+
let cachedContext = null;
|
|
257
|
+
async function getOrBuildContext(repoPath) {
|
|
258
|
+
if (cachedContext && cachedContext.repoPath === repoPath) {
|
|
259
|
+
return cachedContext.context;
|
|
260
|
+
}
|
|
261
|
+
if (sharedContextBuilder) {
|
|
262
|
+
await sharedContextBuilder.shutdown();
|
|
263
|
+
sharedContextBuilder = null;
|
|
264
|
+
}
|
|
265
|
+
let builderOptions = {};
|
|
266
|
+
const configPath = path.join(repoPath, '.context', 'config.json');
|
|
267
|
+
if (await fs.pathExists(configPath)) {
|
|
268
|
+
try {
|
|
269
|
+
const config = await fs.readJson(configPath);
|
|
270
|
+
if (Array.isArray(config.exclude) && config.exclude.length > 0) {
|
|
271
|
+
builderOptions = {
|
|
272
|
+
exclude: [...new Set([...types_1.DEFAULT_EXCLUDE_PATTERNS, ...config.exclude])]
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
// Ignore malformed config and fall back to defaults.
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
sharedContextBuilder = new contextBuilder_1.SemanticContextBuilder(builderOptions);
|
|
281
|
+
const context = await sharedContextBuilder.buildDocumentationContext(repoPath);
|
|
282
|
+
cachedContext = { repoPath, context };
|
|
283
|
+
return context;
|
|
284
|
+
}
|
|
285
|
+
async function cleanupSharedContext() {
|
|
286
|
+
if (sharedContextBuilder) {
|
|
287
|
+
await sharedContextBuilder.shutdown();
|
|
288
|
+
sharedContextBuilder = null;
|
|
289
|
+
}
|
|
290
|
+
cachedContext = null;
|
|
291
|
+
}
|
|
292
|
+
exports.readFileTool = createInternalTool('Read the contents of a file from the filesystem', async (input) => {
|
|
293
|
+
const { filePath, encoding = 'utf-8' } = input;
|
|
294
|
+
try {
|
|
295
|
+
const content = await fs.readFile(filePath, encoding);
|
|
296
|
+
return {
|
|
297
|
+
success: true,
|
|
298
|
+
content,
|
|
299
|
+
path: filePath,
|
|
300
|
+
size: content.length
|
|
301
|
+
};
|
|
302
|
+
}
|
|
303
|
+
catch (error) {
|
|
304
|
+
return {
|
|
305
|
+
success: false,
|
|
306
|
+
error: error instanceof Error ? error.message : String(error),
|
|
307
|
+
path: filePath
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
});
|
|
311
|
+
exports.listFilesTool = createInternalTool('List files matching a glob pattern in the repository', async (input) => {
|
|
312
|
+
const { pattern, cwd, ignore } = input;
|
|
313
|
+
try {
|
|
314
|
+
const files = await (0, glob_1.glob)(pattern, {
|
|
315
|
+
cwd: cwd || process.cwd(),
|
|
316
|
+
ignore: ignore || ['node_modules/**', '.git/**', 'dist/**'],
|
|
317
|
+
absolute: false
|
|
318
|
+
});
|
|
319
|
+
return {
|
|
320
|
+
success: true,
|
|
321
|
+
files,
|
|
322
|
+
count: files.length,
|
|
323
|
+
pattern
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
return {
|
|
328
|
+
success: false,
|
|
329
|
+
error: error instanceof Error ? error.message : String(error),
|
|
330
|
+
pattern
|
|
331
|
+
};
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
exports.analyzeSymbolsTool = createInternalTool('Analyze symbols in a source file', async (input) => {
|
|
335
|
+
const { filePath, symbolTypes } = input;
|
|
336
|
+
try {
|
|
337
|
+
const treeSitter = getTreeSitterLayer();
|
|
338
|
+
const analysis = await treeSitter.analyzeFile(filePath);
|
|
339
|
+
let symbols = analysis.symbols;
|
|
340
|
+
if (symbolTypes && symbolTypes.length > 0) {
|
|
341
|
+
symbols = symbols.filter((symbol) => symbolTypes.includes(symbol.kind));
|
|
342
|
+
}
|
|
343
|
+
return {
|
|
344
|
+
success: true,
|
|
345
|
+
filePath,
|
|
346
|
+
language: analysis.language,
|
|
347
|
+
symbols: symbols.map((symbol) => ({
|
|
348
|
+
name: symbol.name,
|
|
349
|
+
kind: symbol.kind,
|
|
350
|
+
line: symbol.location.line,
|
|
351
|
+
exported: symbol.exported,
|
|
352
|
+
documentation: symbol.documentation
|
|
353
|
+
})),
|
|
354
|
+
imports: analysis.imports.map((imp) => ({
|
|
355
|
+
source: imp.source,
|
|
356
|
+
specifiers: imp.specifiers
|
|
357
|
+
})),
|
|
358
|
+
exports: analysis.exports.map((exp) => ({
|
|
359
|
+
name: exp.name,
|
|
360
|
+
isDefault: exp.isDefault
|
|
361
|
+
}))
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
catch (error) {
|
|
365
|
+
return {
|
|
366
|
+
success: false,
|
|
367
|
+
error: error instanceof Error ? error.message : String(error),
|
|
368
|
+
filePath
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
});
|
|
372
|
+
exports.getFileStructureTool = createInternalTool('Get the directory structure and file listing of a repository', async (input) => {
|
|
373
|
+
const { rootPath, maxDepth = 3, includePatterns } = input;
|
|
374
|
+
try {
|
|
375
|
+
const mapper = new fileMapper_1.FileMapper([]);
|
|
376
|
+
const structure = await mapper.mapRepository(rootPath, includePatterns || undefined);
|
|
377
|
+
const filterByDepth = (relativePath) => relativePath.split('/').length <= maxDepth;
|
|
378
|
+
return {
|
|
379
|
+
success: true,
|
|
380
|
+
rootPath: structure.rootPath,
|
|
381
|
+
totalFiles: structure.totalFiles,
|
|
382
|
+
totalSize: structure.totalSize,
|
|
383
|
+
topLevelDirs: structure.topLevelDirectoryStats.map((dir) => ({
|
|
384
|
+
name: dir.name,
|
|
385
|
+
fileCount: dir.fileCount
|
|
386
|
+
})),
|
|
387
|
+
files: structure.files
|
|
388
|
+
.filter((file) => filterByDepth(file.relativePath))
|
|
389
|
+
.slice(0, 200)
|
|
390
|
+
.map((file) => ({
|
|
391
|
+
path: file.relativePath,
|
|
392
|
+
extension: file.extension,
|
|
393
|
+
size: file.size
|
|
394
|
+
}))
|
|
395
|
+
};
|
|
396
|
+
}
|
|
397
|
+
catch (error) {
|
|
398
|
+
return {
|
|
399
|
+
success: false,
|
|
400
|
+
error: error instanceof Error ? error.message : String(error),
|
|
401
|
+
rootPath
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
exports.searchCodeTool = createInternalTool('Search for code patterns across files using regex', async (input) => {
|
|
406
|
+
const { pattern, fileGlob, maxResults = 50, cwd } = input;
|
|
407
|
+
try {
|
|
408
|
+
const files = await (0, glob_1.glob)(fileGlob || '**/*.{ts,tsx,js,jsx,py,go,rs,java}', {
|
|
409
|
+
cwd: cwd || process.cwd(),
|
|
410
|
+
ignore: ['node_modules/**', '.git/**', 'dist/**', 'build/**'],
|
|
411
|
+
absolute: true
|
|
412
|
+
});
|
|
413
|
+
const regex = new RegExp(pattern, 'gm');
|
|
414
|
+
const matches = [];
|
|
415
|
+
for (const file of files) {
|
|
416
|
+
if (matches.length >= maxResults)
|
|
417
|
+
break;
|
|
418
|
+
try {
|
|
419
|
+
const content = await fs.readFile(file, 'utf-8');
|
|
420
|
+
const lines = content.split('\n');
|
|
421
|
+
for (let index = 0; index < lines.length && matches.length < maxResults; index++) {
|
|
422
|
+
if (regex.test(lines[index])) {
|
|
423
|
+
matches.push({
|
|
424
|
+
file: path.relative(cwd || process.cwd(), file),
|
|
425
|
+
line: index + 1,
|
|
426
|
+
match: lines[index].trim().slice(0, 200),
|
|
427
|
+
context: lines.slice(Math.max(0, index - 1), index + 2).join('\n').slice(0, 500)
|
|
428
|
+
});
|
|
429
|
+
}
|
|
430
|
+
regex.lastIndex = 0;
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
catch {
|
|
434
|
+
// Skip unreadable files.
|
|
435
|
+
}
|
|
436
|
+
}
|
|
437
|
+
return {
|
|
438
|
+
success: true,
|
|
439
|
+
pattern,
|
|
440
|
+
matches,
|
|
441
|
+
totalMatches: matches.length,
|
|
442
|
+
truncated: matches.length >= maxResults
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
catch (error) {
|
|
446
|
+
return {
|
|
447
|
+
success: false,
|
|
448
|
+
error: error instanceof Error ? error.message : String(error),
|
|
449
|
+
pattern
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
exports.checkScaffoldingTool = createInternalTool('Check if .context scaffolding exists and return granular status', async (input) => {
|
|
454
|
+
if (!input.repoPath) {
|
|
455
|
+
throw new Error('repoPath is required for checkScaffolding');
|
|
456
|
+
}
|
|
457
|
+
const outputDir = path.resolve(input.repoPath, '.context');
|
|
458
|
+
try {
|
|
459
|
+
const sensorsPath = path.join(outputDir, 'harness', 'sensors.json');
|
|
460
|
+
const [initialized, docs, agents, skills, plans, workflow, harness, sensors] = await Promise.all([
|
|
461
|
+
fs.pathExists(outputDir),
|
|
462
|
+
fs.pathExists(path.join(outputDir, 'docs')).then((exists) => exists ? hasContent(path.join(outputDir, 'docs')) : false),
|
|
463
|
+
fs.pathExists(path.join(outputDir, 'agents')).then((exists) => exists ? hasContent(path.join(outputDir, 'agents')) : false),
|
|
464
|
+
fs.pathExists(path.join(outputDir, 'skills')).then((exists) => exists ? hasSkillContent(path.join(outputDir, 'skills')) : false),
|
|
465
|
+
fs.pathExists(path.join(outputDir, 'plans')).then((exists) => exists ? hasContent(path.join(outputDir, 'plans')) : false),
|
|
466
|
+
fs.pathExists(path.join(outputDir, 'workflow')).then((exists) => exists ? hasContent(path.join(outputDir, 'workflow')) : false),
|
|
467
|
+
fs.pathExists(path.join(outputDir, 'harness')).then((exists) => exists ? hasHarnessRuntimeContent(path.join(outputDir, 'harness')) : false),
|
|
468
|
+
fs.pathExists(sensorsPath)
|
|
469
|
+
]);
|
|
470
|
+
return {
|
|
471
|
+
initialized,
|
|
472
|
+
docs,
|
|
473
|
+
agents,
|
|
474
|
+
skills,
|
|
475
|
+
plans,
|
|
476
|
+
workflow,
|
|
477
|
+
harness,
|
|
478
|
+
sensors,
|
|
479
|
+
outputDir
|
|
480
|
+
};
|
|
481
|
+
}
|
|
482
|
+
catch (error) {
|
|
483
|
+
return {
|
|
484
|
+
initialized: false,
|
|
485
|
+
docs: false,
|
|
486
|
+
agents: false,
|
|
487
|
+
skills: false,
|
|
488
|
+
plans: false,
|
|
489
|
+
workflow: false,
|
|
490
|
+
harness: false,
|
|
491
|
+
sensors: false,
|
|
492
|
+
outputDir,
|
|
493
|
+
error: error instanceof Error ? error.message : String(error)
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
});
|
|
497
|
+
exports.initializeContextTool = createInternalTool('Initialize .context scaffolding and create template files', async (input) => {
|
|
498
|
+
const { repoPath, type = 'both', outputDir: customOutputDir, semantic = true, include, exclude = [], projectType: overrideProjectType, disableFiltering = false, autoFill = true, skipContentGeneration = true, generateQA = false, generateSkills = true, } = input;
|
|
499
|
+
const resolvedRepoPath = path.resolve(repoPath);
|
|
500
|
+
const outputDir = customOutputDir
|
|
501
|
+
? path.resolve(customOutputDir)
|
|
502
|
+
: path.resolve(resolvedRepoPath, '.context');
|
|
503
|
+
const scaffoldDocs = type === 'docs' || type === 'both';
|
|
504
|
+
const scaffoldAgents = type === 'agents' || type === 'both';
|
|
505
|
+
try {
|
|
506
|
+
if (!await fs.pathExists(resolvedRepoPath)) {
|
|
507
|
+
return {
|
|
508
|
+
success: false,
|
|
509
|
+
status: 'error',
|
|
510
|
+
outputDir,
|
|
511
|
+
error: `Repository path does not exist: ${resolvedRepoPath}`
|
|
512
|
+
};
|
|
513
|
+
}
|
|
514
|
+
await fs.ensureDir(outputDir);
|
|
515
|
+
const runtimeGitignorePatterns = (0, shared_1.getUntrackedContextLayoutEntries)().map((entry) => entry.path);
|
|
516
|
+
await (0, gitignoreManager_1.ensureGitignorePatterns)(resolvedRepoPath, runtimeGitignorePatterns, {
|
|
517
|
+
header: '# dotcontext runtime state'
|
|
518
|
+
});
|
|
519
|
+
if (exclude.length > 0) {
|
|
520
|
+
const configPath = path.join(outputDir, 'config.json');
|
|
521
|
+
let existingConfig = {};
|
|
522
|
+
if (await fs.pathExists(configPath)) {
|
|
523
|
+
try {
|
|
524
|
+
existingConfig = await fs.readJson(configPath);
|
|
525
|
+
}
|
|
526
|
+
catch {
|
|
527
|
+
existingConfig = {};
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
existingConfig.exclude = exclude;
|
|
531
|
+
await fs.writeJson(configPath, existingConfig, { spaces: 2 });
|
|
532
|
+
}
|
|
533
|
+
const fileMapper = new fileMapper_1.FileMapper(exclude);
|
|
534
|
+
const repoStructure = await fileMapper.mapRepository(resolvedRepoPath, include);
|
|
535
|
+
let classification;
|
|
536
|
+
let projectType = 'unknown';
|
|
537
|
+
if (!disableFiltering) {
|
|
538
|
+
const stackDetector = new stack_1.StackDetector();
|
|
539
|
+
const stackInfo = await stackDetector.detect(resolvedRepoPath);
|
|
540
|
+
if (overrideProjectType) {
|
|
541
|
+
projectType = overrideProjectType;
|
|
542
|
+
classification = {
|
|
543
|
+
primaryType: overrideProjectType,
|
|
544
|
+
secondaryTypes: [],
|
|
545
|
+
confidence: 'high',
|
|
546
|
+
reasoning: ['Project type manually specified'],
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
else {
|
|
550
|
+
classification = (0, stack_1.classifyProject)(stackInfo);
|
|
551
|
+
projectType = classification.primaryType;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
const filteredAgents = disableFiltering ? undefined : (0, stack_1.getAgentsForProjectType)(projectType);
|
|
555
|
+
const filteredDocs = disableFiltering ? undefined : (0, stack_1.getDocsForProjectType)(projectType);
|
|
556
|
+
const filteredSkills = disableFiltering ? undefined : (0, stack_1.getSkillsForProjectType)(projectType);
|
|
557
|
+
let docsGenerated = 0;
|
|
558
|
+
if (scaffoldDocs) {
|
|
559
|
+
const docGenerator = new documentationGenerator_1.DocumentationGenerator();
|
|
560
|
+
docsGenerated = await docGenerator.generateDocumentation(repoStructure, outputDir, { semantic, filteredDocs }, false);
|
|
561
|
+
}
|
|
562
|
+
let skillsGenerated = 0;
|
|
563
|
+
if (generateSkills) {
|
|
564
|
+
try {
|
|
565
|
+
const skillGenerator = new skillGenerator_1.SkillGenerator({
|
|
566
|
+
repoPath: resolvedRepoPath,
|
|
567
|
+
outputDir: path.relative(resolvedRepoPath, outputDir),
|
|
568
|
+
});
|
|
569
|
+
const skillResult = await skillGenerator.generate({
|
|
570
|
+
skills: filteredSkills,
|
|
571
|
+
force: false,
|
|
572
|
+
});
|
|
573
|
+
skillsGenerated = skillResult.generatedSkills.length;
|
|
574
|
+
}
|
|
575
|
+
catch {
|
|
576
|
+
skillsGenerated = 0;
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
let availableSkills = [];
|
|
580
|
+
if (generateSkills && skillsGenerated > 0) {
|
|
581
|
+
try {
|
|
582
|
+
const registry = (0, skills_1.createSkillRegistry)(resolvedRepoPath);
|
|
583
|
+
const discovered = await registry.discoverAll();
|
|
584
|
+
availableSkills = discovered.all.map((skill) => ({
|
|
585
|
+
slug: skill.slug,
|
|
586
|
+
name: skill.metadata.name,
|
|
587
|
+
description: skill.metadata.description,
|
|
588
|
+
phases: skill.metadata.phases || [],
|
|
589
|
+
}));
|
|
590
|
+
}
|
|
591
|
+
catch {
|
|
592
|
+
availableSkills = [];
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
let agentsGenerated = 0;
|
|
596
|
+
if (scaffoldAgents) {
|
|
597
|
+
const agentGenerator = new agentGenerator_1.AgentGenerator();
|
|
598
|
+
agentsGenerated = await agentGenerator.generateAgentPrompts(repoStructure, outputDir, { semantic, filteredAgents, availableSkills }, false);
|
|
599
|
+
}
|
|
600
|
+
let qaGenerated = 0;
|
|
601
|
+
if (generateQA) {
|
|
602
|
+
try {
|
|
603
|
+
const qaService = new qa_1.QAService();
|
|
604
|
+
const qaResult = await qaService.generateFromCodebase(resolvedRepoPath);
|
|
605
|
+
qaGenerated = qaResult.generated.length;
|
|
606
|
+
await qaService.shutdown();
|
|
607
|
+
}
|
|
608
|
+
catch {
|
|
609
|
+
qaGenerated = 0;
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
const sensorCatalogService = new sensorCatalogService_1.HarnessSensorCatalogService({
|
|
613
|
+
repoPath: resolvedRepoPath,
|
|
614
|
+
contextPath: outputDir,
|
|
615
|
+
});
|
|
616
|
+
const sensorCatalog = await sensorCatalogService.bootstrap();
|
|
617
|
+
const sensorsGenerated = sensorCatalog.sensors.length;
|
|
618
|
+
const sensorsPath = sensorCatalogService.configPath;
|
|
619
|
+
const policyService = new policyService_1.HarnessPolicyService({ repoPath: resolvedRepoPath });
|
|
620
|
+
const policyPath = path.join(outputDir, 'harness', 'policy.json');
|
|
621
|
+
let policyGenerated = false;
|
|
622
|
+
if (!await fs.pathExists(policyPath)) {
|
|
623
|
+
await policyService.savePolicy(await policyService.createBootstrapPolicy());
|
|
624
|
+
policyGenerated = true;
|
|
625
|
+
}
|
|
626
|
+
const generatedFiles = [];
|
|
627
|
+
if (scaffoldDocs) {
|
|
628
|
+
const docFiles = await collectScaffoldFiles(outputDir, 'docs');
|
|
629
|
+
for (const file of docFiles.filter((entry) => path.basename(entry.path).toLowerCase() !== 'readme.md')) {
|
|
630
|
+
generatedFiles.push({
|
|
631
|
+
path: file.path,
|
|
632
|
+
relativePath: file.relativePath,
|
|
633
|
+
type: 'doc',
|
|
634
|
+
instructions: getDocFillInstructions(path.basename(file.path))
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
if (scaffoldAgents) {
|
|
639
|
+
const agentFiles = await collectScaffoldFiles(outputDir, 'agents');
|
|
640
|
+
for (const file of agentFiles) {
|
|
641
|
+
generatedFiles.push({
|
|
642
|
+
path: file.path,
|
|
643
|
+
relativePath: file.relativePath,
|
|
644
|
+
type: 'agent',
|
|
645
|
+
instructions: getAgentFillInstructions(file.documentName)
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
if (generateSkills) {
|
|
650
|
+
const skillFiles = await collectScaffoldFiles(outputDir, 'skills');
|
|
651
|
+
for (const file of skillFiles) {
|
|
652
|
+
generatedFiles.push({
|
|
653
|
+
path: file.path,
|
|
654
|
+
relativePath: file.relativePath,
|
|
655
|
+
type: 'skill',
|
|
656
|
+
instructions: getSkillFillInstructions(file.documentName)
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
if (autoFill && await sensorCatalogNeedsFill(sensorsPath)) {
|
|
661
|
+
generatedFiles.push({
|
|
662
|
+
path: sensorsPath,
|
|
663
|
+
relativePath: path.relative(outputDir, sensorsPath),
|
|
664
|
+
type: 'sensor',
|
|
665
|
+
instructions: getSensorFillInstructions()
|
|
666
|
+
});
|
|
667
|
+
}
|
|
668
|
+
const pendingWrites = autoFill
|
|
669
|
+
? generatedFiles.map((file, index) => ({
|
|
670
|
+
order: index + 1,
|
|
671
|
+
actionType: 'WRITE_FILE',
|
|
672
|
+
filePath: file.path,
|
|
673
|
+
fileType: file.type,
|
|
674
|
+
instructions: file.instructions,
|
|
675
|
+
status: 'pending'
|
|
676
|
+
}))
|
|
677
|
+
: [];
|
|
678
|
+
const codebaseContext = autoFill && !skipContentGeneration
|
|
679
|
+
? await getOrBuildContext(resolvedRepoPath).catch(() => undefined)
|
|
680
|
+
: undefined;
|
|
681
|
+
const qaOutputDir = path.join(outputDir, 'docs', 'qa');
|
|
682
|
+
const checklist = [
|
|
683
|
+
...pendingWrites.map((item) => `[ ] Fill ${path.relative(resolvedRepoPath, item.filePath)}`),
|
|
684
|
+
sensorsGenerated > 0
|
|
685
|
+
? (await sensorCatalogNeedsFill(sensorsPath)
|
|
686
|
+
? `[ ] Customize harness sensors in ${path.relative(resolvedRepoPath, sensorsPath)}`
|
|
687
|
+
: `[x] Loaded ${sensorsGenerated} project-specific harness sensors`)
|
|
688
|
+
: '[ ] Generate harness sensors',
|
|
689
|
+
policyGenerated ? '[x] Created harness bootstrap policy' : '[x] Reused existing harness bootstrap policy',
|
|
690
|
+
qaGenerated > 0
|
|
691
|
+
? `[x] Generated ${qaGenerated} optional Q&A helper docs in ${qaOutputDir}`
|
|
692
|
+
: '[ ] Generate optional Q&A helper docs (opt-in)',
|
|
693
|
+
];
|
|
694
|
+
return {
|
|
695
|
+
success: true,
|
|
696
|
+
status: pendingWrites.length > 0 ? 'incomplete' : 'success',
|
|
697
|
+
complete: pendingWrites.length === 0,
|
|
698
|
+
instruction: pendingWrites.length > 0
|
|
699
|
+
? 'Scaffolding created. Fill each pending file with context-aware content before reporting completion.'
|
|
700
|
+
: 'Scaffolding created successfully.',
|
|
701
|
+
outputDir,
|
|
702
|
+
docsGenerated,
|
|
703
|
+
agentsGenerated,
|
|
704
|
+
skillsGenerated,
|
|
705
|
+
qaGenerated,
|
|
706
|
+
pendingWrites,
|
|
707
|
+
requiredActions: pendingWrites,
|
|
708
|
+
checklist,
|
|
709
|
+
codebaseContext,
|
|
710
|
+
classification: classification
|
|
711
|
+
? {
|
|
712
|
+
projectType: classification.primaryType,
|
|
713
|
+
confidence: classification.confidence,
|
|
714
|
+
reasoning: classification.reasoning,
|
|
715
|
+
}
|
|
716
|
+
: undefined,
|
|
717
|
+
_metadata: {
|
|
718
|
+
docsGenerated,
|
|
719
|
+
agentsGenerated,
|
|
720
|
+
skillsGenerated,
|
|
721
|
+
qaGenerated,
|
|
722
|
+
outputDir,
|
|
723
|
+
classification: classification
|
|
724
|
+
? {
|
|
725
|
+
projectType: classification.primaryType,
|
|
726
|
+
confidence: classification.confidence,
|
|
727
|
+
reasoning: classification.reasoning,
|
|
728
|
+
}
|
|
729
|
+
: undefined,
|
|
730
|
+
},
|
|
731
|
+
nextStep: pendingWrites.length > 0
|
|
732
|
+
? {
|
|
733
|
+
action: 'Call fillSingle for each pending file and then write the generated content.',
|
|
734
|
+
example: pendingWrites[0]
|
|
735
|
+
? `context({ action: "fillSingle", filePath: "${pendingWrites[0].filePath}" })`
|
|
736
|
+
: undefined
|
|
737
|
+
}
|
|
738
|
+
: undefined
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
catch (error) {
|
|
742
|
+
return {
|
|
743
|
+
success: false,
|
|
744
|
+
status: 'error',
|
|
745
|
+
complete: false,
|
|
746
|
+
outputDir,
|
|
747
|
+
error: error instanceof Error ? error.message : String(error)
|
|
748
|
+
};
|
|
749
|
+
}
|
|
750
|
+
});
|
|
751
|
+
exports.scaffoldPlanTool = createInternalTool('Create a plan template in .context/plans/', async (input) => {
|
|
752
|
+
const { planName, repoPath, outputDir: customOutputDir, title, summary, semantic = true, autoFill = true, } = input;
|
|
753
|
+
if (!repoPath) {
|
|
754
|
+
throw new Error('repoPath is required for scaffoldPlan');
|
|
755
|
+
}
|
|
756
|
+
const resolvedRepoPath = path.resolve(repoPath);
|
|
757
|
+
const outputDir = customOutputDir
|
|
758
|
+
? path.resolve(customOutputDir)
|
|
759
|
+
: path.resolve(resolvedRepoPath, '.context');
|
|
760
|
+
try {
|
|
761
|
+
const stackDetector = new stack_1.StackDetector();
|
|
762
|
+
const stackInfo = await stackDetector.detect(resolvedRepoPath);
|
|
763
|
+
const classification = (0, stack_1.classifyProject)(stackInfo);
|
|
764
|
+
const filteredAgents = (0, stack_1.getAgentsForProjectType)(classification.primaryType);
|
|
765
|
+
const filteredDocs = (0, stack_1.getDocsForProjectType)(classification.primaryType);
|
|
766
|
+
const planGenerator = new planGenerator_1.PlanGenerator();
|
|
767
|
+
const enableSemantic = autoFill && semantic;
|
|
768
|
+
const result = await planGenerator.generatePlan({
|
|
769
|
+
planName,
|
|
770
|
+
outputDir,
|
|
771
|
+
title,
|
|
772
|
+
summary,
|
|
773
|
+
force: true,
|
|
774
|
+
verbose: false,
|
|
775
|
+
semantic: enableSemantic,
|
|
776
|
+
projectPath: enableSemantic ? resolvedRepoPath : undefined,
|
|
777
|
+
selectedAgentTypes: filteredAgents,
|
|
778
|
+
selectedDocKeys: filteredDocs,
|
|
779
|
+
});
|
|
780
|
+
const planContent = await fs.readFile(result.planPath, 'utf-8');
|
|
781
|
+
return {
|
|
782
|
+
success: true,
|
|
783
|
+
status: autoFill ? 'incomplete' : 'success',
|
|
784
|
+
complete: !autoFill,
|
|
785
|
+
instruction: autoFill
|
|
786
|
+
? 'Plan scaffold created. Fill it with concrete phases, responsibilities, and acceptance criteria.'
|
|
787
|
+
: 'Plan scaffold created successfully.',
|
|
788
|
+
planPath: result.planPath,
|
|
789
|
+
planContent,
|
|
790
|
+
classification: {
|
|
791
|
+
projectType: classification.primaryType,
|
|
792
|
+
confidence: classification.confidence,
|
|
793
|
+
reasoning: classification.reasoning,
|
|
794
|
+
},
|
|
795
|
+
nextStep: autoFill
|
|
796
|
+
? {
|
|
797
|
+
action: 'Call fillSingle with the generated plan path.',
|
|
798
|
+
example: `context({ action: "fillSingle", filePath: "${result.planPath}" })`,
|
|
799
|
+
}
|
|
800
|
+
: undefined
|
|
801
|
+
};
|
|
802
|
+
}
|
|
803
|
+
catch (error) {
|
|
804
|
+
return {
|
|
805
|
+
success: false,
|
|
806
|
+
status: 'error',
|
|
807
|
+
complete: false,
|
|
808
|
+
error: error instanceof Error ? error.message : String(error)
|
|
809
|
+
};
|
|
810
|
+
}
|
|
811
|
+
});
|
|
812
|
+
exports.listFilesToFillTool = createInternalTool('List scaffold files that still need to be filled', async (input) => {
|
|
813
|
+
const { repoPath, outputDir: customOutputDir, target = 'all' } = input;
|
|
814
|
+
const resolvedRepoPath = path.resolve(repoPath);
|
|
815
|
+
const outputDir = customOutputDir
|
|
816
|
+
? path.resolve(customOutputDir)
|
|
817
|
+
: path.resolve(resolvedRepoPath, '.context');
|
|
818
|
+
try {
|
|
819
|
+
if (!await fs.pathExists(outputDir)) {
|
|
820
|
+
return {
|
|
821
|
+
success: false,
|
|
822
|
+
error: `Scaffold directory does not exist: ${outputDir}. Run context init first.`
|
|
823
|
+
};
|
|
824
|
+
}
|
|
825
|
+
const files = await collectScaffoldFiles(outputDir, target);
|
|
826
|
+
return {
|
|
827
|
+
success: true,
|
|
828
|
+
files,
|
|
829
|
+
totalCount: files.length,
|
|
830
|
+
instructions: `Found ${files.length} files to fill. Call fillSingle for each file path.`
|
|
831
|
+
};
|
|
832
|
+
}
|
|
833
|
+
catch (error) {
|
|
834
|
+
return {
|
|
835
|
+
success: false,
|
|
836
|
+
error: error instanceof Error ? error.message : String(error)
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
exports.fillSingleFileTool = createInternalTool('Build semantic context for filling a single scaffold file', async (input) => {
|
|
841
|
+
const resolvedRepoPath = path.resolve(input.repoPath);
|
|
842
|
+
const resolvedFilePath = path.resolve(input.filePath);
|
|
843
|
+
try {
|
|
844
|
+
if (!await fs.pathExists(resolvedFilePath)) {
|
|
845
|
+
return {
|
|
846
|
+
success: false,
|
|
847
|
+
error: `File does not exist: ${resolvedFilePath}`
|
|
848
|
+
};
|
|
849
|
+
}
|
|
850
|
+
const semanticContext = await getOrBuildContext(resolvedRepoPath);
|
|
851
|
+
const currentContent = await fs.readFile(resolvedFilePath, 'utf-8');
|
|
852
|
+
const fileInfo = resolveScaffoldFileInfo(path.join(resolvedRepoPath, '.context'), resolvedFilePath);
|
|
853
|
+
const structure = fileInfo.type === 'sensor'
|
|
854
|
+
? undefined
|
|
855
|
+
: (0, scaffoldStructures_1.getScaffoldStructure)(fileInfo.documentName);
|
|
856
|
+
if (fileInfo.type === 'sensor') {
|
|
857
|
+
const sensorCatalogService = new sensorCatalogService_1.HarnessSensorCatalogService({
|
|
858
|
+
repoPath: resolvedRepoPath,
|
|
859
|
+
contextPath: path.join(resolvedRepoPath, '.context'),
|
|
860
|
+
});
|
|
861
|
+
const currentCatalog = await sensorCatalogService.load();
|
|
862
|
+
return {
|
|
863
|
+
success: true,
|
|
864
|
+
filePath: resolvedFilePath,
|
|
865
|
+
fileType: fileInfo.type,
|
|
866
|
+
documentName: fileInfo.documentName,
|
|
867
|
+
semanticContext,
|
|
868
|
+
currentContent,
|
|
869
|
+
currentCatalog,
|
|
870
|
+
instructions: `Use semanticContext and currentContent to rewrite ${resolvedFilePath} as a complete JSON sensor catalog tailored to this repository. Keep version at 1, set source to "manual", preserve stack metadata, and keep only relevant sensors with real commands for this project.`
|
|
871
|
+
};
|
|
872
|
+
}
|
|
873
|
+
return {
|
|
874
|
+
success: true,
|
|
875
|
+
filePath: resolvedFilePath,
|
|
876
|
+
fileType: fileInfo.type,
|
|
877
|
+
documentName: fileInfo.documentName,
|
|
878
|
+
semanticContext,
|
|
879
|
+
scaffoldStructure: structure ? (0, scaffoldStructures_1.serializeStructureForAI)(structure) : undefined,
|
|
880
|
+
currentContent,
|
|
881
|
+
instructions: `Use semanticContext and scaffoldStructure to generate complete markdown content for ${resolvedFilePath}. Write repository-specific content without placeholders.`
|
|
882
|
+
};
|
|
883
|
+
}
|
|
884
|
+
catch (error) {
|
|
885
|
+
return {
|
|
886
|
+
success: false,
|
|
887
|
+
error: error instanceof Error ? error.message : String(error)
|
|
888
|
+
};
|
|
889
|
+
}
|
|
890
|
+
});
|
|
891
|
+
exports.fillScaffoldingTool = createInternalTool('Build semantic context for filling scaffold files', async (input) => {
|
|
892
|
+
const { repoPath, outputDir: customOutputDir, target = 'all', offset = 0, limit = 3, } = input;
|
|
893
|
+
const resolvedRepoPath = path.resolve(repoPath);
|
|
894
|
+
const outputDir = customOutputDir
|
|
895
|
+
? path.resolve(customOutputDir)
|
|
896
|
+
: path.resolve(resolvedRepoPath, '.context');
|
|
897
|
+
try {
|
|
898
|
+
if (!await fs.pathExists(resolvedRepoPath)) {
|
|
899
|
+
return {
|
|
900
|
+
success: false,
|
|
901
|
+
error: `Repository path does not exist: ${resolvedRepoPath}`
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
if (!await fs.pathExists(outputDir)) {
|
|
905
|
+
return {
|
|
906
|
+
success: false,
|
|
907
|
+
error: `Scaffold directory does not exist: ${outputDir}. Run context init first.`
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
const semanticContext = await getOrBuildContext(resolvedRepoPath);
|
|
911
|
+
const allFiles = await collectScaffoldFiles(outputDir, target);
|
|
912
|
+
const effectiveLimit = limit === 0 ? allFiles.length : limit;
|
|
913
|
+
const paginatedFiles = allFiles.slice(offset, offset + effectiveLimit);
|
|
914
|
+
const files = await Promise.all(paginatedFiles.map(async (fileInfo) => {
|
|
915
|
+
const currentContent = await fs.readFile(fileInfo.path, 'utf-8');
|
|
916
|
+
const structure = fileInfo.type === 'sensor'
|
|
917
|
+
? undefined
|
|
918
|
+
: (0, scaffoldStructures_1.getScaffoldStructure)(fileInfo.documentName);
|
|
919
|
+
return {
|
|
920
|
+
path: fileInfo.path,
|
|
921
|
+
relativePath: fileInfo.relativePath,
|
|
922
|
+
type: fileInfo.type,
|
|
923
|
+
documentName: fileInfo.documentName,
|
|
924
|
+
fillInstructions: fileInfo.type === 'sensor' ? getSensorFillInstructions() : undefined,
|
|
925
|
+
scaffoldStructure: structure ? (0, scaffoldStructures_1.serializeStructureForAI)(structure) : undefined,
|
|
926
|
+
currentContent
|
|
927
|
+
};
|
|
928
|
+
}));
|
|
929
|
+
return {
|
|
930
|
+
success: true,
|
|
931
|
+
semanticContext,
|
|
932
|
+
files,
|
|
933
|
+
totalCount: allFiles.length,
|
|
934
|
+
offset,
|
|
935
|
+
limit: effectiveLimit,
|
|
936
|
+
hasMore: offset + effectiveLimit < allFiles.length,
|
|
937
|
+
instructions: 'Generate content for each file using the shared semanticContext and each file-specific scaffoldStructure, then write the result back to the file path.'
|
|
938
|
+
};
|
|
939
|
+
}
|
|
940
|
+
catch (error) {
|
|
941
|
+
return {
|
|
942
|
+
success: false,
|
|
943
|
+
error: error instanceof Error ? error.message : String(error)
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
exports.getCodebaseMapTool = createInternalTool('Get persisted semantic snapshot data and auto-refresh it on read', async (input) => {
|
|
948
|
+
if (!input.repoPath) {
|
|
949
|
+
throw new Error('repoPath is required for getCodebaseMap');
|
|
950
|
+
}
|
|
951
|
+
const section = input.section || 'all';
|
|
952
|
+
try {
|
|
953
|
+
const snapshotService = new semantic_1.SemanticSnapshotService();
|
|
954
|
+
const result = await snapshotService.ensureFreshSection(input.repoPath, section);
|
|
955
|
+
return {
|
|
956
|
+
success: true,
|
|
957
|
+
section,
|
|
958
|
+
data: result.data,
|
|
959
|
+
mapPath: result.path,
|
|
960
|
+
source: result.source,
|
|
961
|
+
fresh: result.fresh,
|
|
962
|
+
refreshed: result.refreshed,
|
|
963
|
+
refreshReason: result.refreshReason,
|
|
964
|
+
generatedAt: result.manifest?.generatedAt ?? null,
|
|
965
|
+
schemaVersion: result.manifest?.schemaVersion ?? null,
|
|
966
|
+
};
|
|
967
|
+
}
|
|
968
|
+
catch (error) {
|
|
969
|
+
return {
|
|
970
|
+
success: false,
|
|
971
|
+
section,
|
|
972
|
+
error: error instanceof Error ? error.message : String(error)
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
});
|
|
976
|
+
exports.TOOL_NAMES = [
|
|
977
|
+
'readFile',
|
|
978
|
+
'listFiles',
|
|
979
|
+
'analyzeSymbols',
|
|
980
|
+
'getFileStructure',
|
|
981
|
+
'searchCode',
|
|
982
|
+
'checkScaffolding',
|
|
983
|
+
'initializeContext',
|
|
984
|
+
'scaffoldPlan',
|
|
985
|
+
'fillScaffolding',
|
|
986
|
+
'listFilesToFill',
|
|
987
|
+
'fillSingleFile',
|
|
988
|
+
'getCodebaseMap'
|
|
989
|
+
];
|
|
990
|
+
//# sourceMappingURL=contextTools.js.map
|