autosnippet 3.2.21 → 3.3.2
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/dashboard/dist/assets/icons-BJ2mUBi8.js +1 -0
- package/dashboard/dist/assets/index-B659K9t5.js +128 -0
- package/dashboard/dist/assets/index-NCm40PMD.css +1 -0
- package/dashboard/dist/index.html +3 -3
- package/dist/bin/cli.d.ts +1 -1
- package/dist/bin/cli.js +244 -261
- package/dist/lib/agent/context/ExplorationTracker.d.ts +2 -0
- package/dist/lib/agent/context/ExplorationTracker.js +21 -3
- package/dist/lib/agent/core/ToolExecutionPipeline.d.ts +3 -1
- package/dist/lib/agent/core/ToolExecutionPipeline.js +8 -1
- package/dist/lib/agent/forge/DynamicComposer.d.ts +58 -0
- package/dist/lib/agent/forge/DynamicComposer.js +99 -0
- package/dist/lib/agent/forge/SandboxRunner.d.ts +60 -0
- package/dist/lib/agent/forge/SandboxRunner.js +251 -0
- package/dist/lib/agent/forge/TemporaryToolRegistry.d.ts +76 -0
- package/dist/lib/agent/forge/TemporaryToolRegistry.js +154 -0
- package/dist/lib/agent/forge/ToolForge.d.ts +92 -0
- package/dist/lib/agent/forge/ToolForge.js +239 -0
- package/dist/lib/agent/forge/ToolRequirementAnalyzer.d.ts +44 -0
- package/dist/lib/agent/forge/ToolRequirementAnalyzer.js +119 -0
- package/dist/lib/agent/tools/ToolRegistry.d.ts +2 -0
- package/dist/lib/agent/tools/ToolRegistry.js +4 -0
- package/dist/lib/agent/tools/composite.js +0 -1
- package/dist/lib/agent/tools/index.d.ts +2 -50
- package/dist/lib/agent/tools/index.js +2 -3
- package/dist/lib/agent/tools/lifecycle.d.ts +1 -58
- package/dist/lib/agent/tools/lifecycle.js +2 -75
- package/dist/lib/cli/SetupService.d.ts +46 -2
- package/dist/lib/cli/SetupService.js +2 -27
- package/dist/lib/cli/deploy/FileManifest.d.ts +0 -21
- package/dist/lib/cli/deploy/FileManifest.js +0 -11
- package/dist/lib/{platform/ios/spm → core/discovery}/SpmDiscoverer.d.ts +2 -5
- package/dist/lib/{platform/ios/spm → core/discovery}/SpmDiscoverer.js +159 -44
- package/dist/lib/core/discovery/index.d.ts +1 -1
- package/dist/lib/core/discovery/index.js +2 -2
- package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +10 -0
- package/dist/lib/domain/knowledge/KnowledgeEntry.js +2 -0
- package/dist/lib/domain/knowledge/Lifecycle.d.ts +19 -2
- package/dist/lib/domain/knowledge/Lifecycle.js +32 -6
- package/dist/lib/domain/knowledge/UnifiedValidator.d.ts +1 -5
- package/dist/lib/domain/knowledge/UnifiedValidator.js +7 -44
- package/dist/lib/domain/knowledge/values/Stats.d.ts +29 -0
- package/dist/lib/domain/knowledge/values/Stats.js +41 -0
- package/dist/lib/external/mcp/McpServer.d.ts +19 -38
- package/dist/lib/external/mcp/McpServer.js +145 -117
- package/dist/lib/external/mcp/autoApproveInjector.js +0 -2
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.d.ts +26 -1
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +41 -0
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +49 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +3 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +27 -0
- package/dist/lib/external/mcp/handlers/bootstrap/skills.js +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +1 -0
- package/dist/lib/external/mcp/handlers/bootstrap-internal.js +2 -0
- package/dist/lib/external/mcp/handlers/consolidated.d.ts +116 -6
- package/dist/lib/external/mcp/handlers/consolidated.js +251 -71
- package/dist/lib/external/mcp/handlers/guard.d.ts +150 -0
- package/dist/lib/external/mcp/handlers/guard.js +245 -8
- package/dist/lib/external/mcp/handlers/knowledge.d.ts +0 -29
- package/dist/lib/external/mcp/handlers/knowledge.js +1 -76
- package/dist/lib/external/mcp/handlers/panorama.d.ts +36 -0
- package/dist/lib/external/mcp/handlers/panorama.js +156 -0
- package/dist/lib/external/mcp/handlers/system.d.ts +2 -54
- package/dist/lib/external/mcp/handlers/system.js +3 -113
- package/dist/lib/external/mcp/handlers/task.d.ts +13 -24
- package/dist/lib/external/mcp/handlers/task.js +217 -557
- package/dist/lib/external/mcp/handlers/types.d.ts +91 -8
- package/dist/lib/external/mcp/handlers/types.js +18 -1
- package/dist/lib/external/mcp/handlers/wiki-external.d.ts +18 -1
- package/dist/lib/external/mcp/handlers/wiki-external.js +16 -1
- package/dist/lib/external/mcp/tools.d.ts +14 -20
- package/dist/lib/external/mcp/tools.js +62 -91
- package/dist/lib/http/HttpServer.js +52 -6
- package/dist/lib/http/routes/{snippets.d.ts → audit.d.ts} +4 -2
- package/dist/lib/http/routes/audit.js +51 -0
- package/dist/lib/http/routes/commands.d.ts +1 -1
- package/dist/lib/http/routes/commands.js +1 -66
- package/dist/lib/http/routes/guardReport.d.ts +10 -0
- package/dist/lib/http/routes/guardReport.js +143 -0
- package/dist/lib/http/routes/knowledge.js +32 -1
- package/dist/lib/http/routes/panorama.d.ts +11 -0
- package/dist/lib/http/routes/panorama.js +322 -0
- package/dist/lib/http/routes/remote.js +0 -5
- package/dist/lib/http/routes/signals.d.ts +10 -0
- package/dist/lib/http/routes/signals.js +104 -0
- package/dist/lib/http/routes/task.d.ts +2 -3
- package/dist/lib/http/routes/task.js +17 -347
- package/dist/lib/http/routes/violations.js +1 -1
- package/dist/lib/infrastructure/audit/AuditLogger.d.ts +6 -1
- package/dist/lib/infrastructure/audit/AuditLogger.js +14 -1
- package/dist/lib/infrastructure/database/drizzle/schema.d.ts +181 -583
- package/dist/lib/infrastructure/database/drizzle/schema.js +28 -69
- package/dist/lib/infrastructure/database/migrations/004_evolution_proposals.d.ts +8 -0
- package/dist/lib/infrastructure/database/migrations/004_evolution_proposals.js +43 -0
- package/dist/lib/infrastructure/logging/Logger.d.ts +2 -0
- package/dist/lib/infrastructure/logging/Logger.js +34 -7
- package/dist/lib/infrastructure/monitoring/ErrorTracker.js +3 -1
- package/dist/lib/infrastructure/monitoring/PerformanceMonitor.d.ts +2 -2
- package/dist/lib/infrastructure/monitoring/PerformanceMonitor.js +12 -10
- package/dist/lib/infrastructure/notification/LarkNotifier.d.ts +24 -0
- package/dist/lib/infrastructure/notification/LarkNotifier.js +97 -0
- package/dist/lib/infrastructure/report/ReportStore.d.ts +45 -0
- package/dist/lib/infrastructure/report/ReportStore.js +133 -0
- package/dist/lib/infrastructure/signal/SignalAggregator.d.ts +18 -0
- package/dist/lib/infrastructure/signal/SignalAggregator.js +84 -0
- package/dist/lib/infrastructure/signal/SignalBridge.d.ts +13 -0
- package/dist/lib/infrastructure/signal/SignalBridge.js +20 -0
- package/dist/lib/infrastructure/signal/SignalBus.d.ts +63 -0
- package/dist/lib/infrastructure/signal/SignalBus.js +106 -0
- package/dist/lib/infrastructure/signal/SignalTraceWriter.d.ts +36 -0
- package/dist/lib/infrastructure/signal/SignalTraceWriter.js +130 -0
- package/dist/lib/injection/ServiceContainer.js +6 -0
- package/dist/lib/injection/ServiceMap.d.ts +16 -19
- package/dist/lib/injection/modules/AgentModule.d.ts +1 -1
- package/dist/lib/injection/modules/AgentModule.js +7 -1
- package/dist/lib/injection/modules/AppModule.d.ts +3 -4
- package/dist/lib/injection/modules/AppModule.js +7 -43
- package/dist/lib/injection/modules/GuardModule.js +59 -2
- package/dist/lib/injection/modules/InfraModule.d.ts +0 -1
- package/dist/lib/injection/modules/InfraModule.js +9 -7
- package/dist/lib/injection/modules/KnowledgeModule.js +51 -0
- package/dist/lib/injection/modules/PanoramaModule.d.ts +18 -0
- package/dist/lib/injection/modules/PanoramaModule.js +76 -0
- package/dist/lib/injection/modules/SignalModule.d.ts +10 -0
- package/dist/lib/injection/modules/SignalModule.js +84 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +1 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +6 -0
- package/dist/lib/service/bootstrap/BootstrapTaskManager.d.ts +3 -1
- package/dist/lib/service/bootstrap/BootstrapTaskManager.js +20 -1
- package/dist/lib/service/delivery/AgentInstructionsGenerator.js +4 -5
- package/dist/lib/service/delivery/CursorDeliveryPipeline.d.ts +3 -1
- package/dist/lib/service/delivery/CursorDeliveryPipeline.js +13 -10
- package/dist/lib/service/delivery/RulesGenerator.js +3 -2
- package/dist/lib/service/evolution/ConsolidationAdvisor.d.ts +114 -0
- package/dist/lib/service/evolution/ConsolidationAdvisor.js +542 -0
- package/dist/lib/service/evolution/ContradictionDetector.d.ts +54 -0
- package/dist/lib/service/evolution/ContradictionDetector.js +253 -0
- package/dist/lib/service/evolution/DecayDetector.d.ts +71 -0
- package/dist/lib/service/evolution/DecayDetector.js +244 -0
- package/dist/lib/service/evolution/EnhancementSuggester.d.ts +38 -0
- package/dist/lib/service/evolution/EnhancementSuggester.js +220 -0
- package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +82 -0
- package/dist/lib/service/evolution/KnowledgeMetabolism.js +167 -0
- package/dist/lib/service/evolution/RedundancyAnalyzer.d.ts +53 -0
- package/dist/lib/service/evolution/RedundancyAnalyzer.js +210 -0
- package/dist/lib/service/evolution/StagingManager.d.ts +57 -0
- package/dist/lib/service/evolution/StagingManager.js +201 -0
- package/dist/lib/service/guard/ComplianceReporter.d.ts +42 -2
- package/dist/lib/service/guard/ComplianceReporter.js +43 -5
- package/dist/lib/service/guard/CoverageAnalyzer.d.ts +54 -0
- package/dist/lib/service/guard/CoverageAnalyzer.js +149 -0
- package/dist/lib/service/guard/GuardCheckEngine.d.ts +55 -1
- package/dist/lib/service/guard/GuardCheckEngine.js +508 -15
- package/dist/lib/service/guard/GuardFeedbackLoop.d.ts +3 -0
- package/dist/lib/service/guard/GuardFeedbackLoop.js +9 -0
- package/dist/lib/service/guard/ReverseGuard.d.ts +73 -0
- package/dist/lib/service/guard/ReverseGuard.js +256 -0
- package/dist/lib/service/guard/RuleLearner.d.ts +12 -0
- package/dist/lib/service/guard/RuleLearner.js +38 -0
- package/dist/lib/service/guard/UncertaintyCollector.d.ts +83 -0
- package/dist/lib/service/guard/UncertaintyCollector.js +149 -0
- package/dist/lib/service/guard/ViolationsStore.d.ts +1 -0
- package/dist/lib/service/guard/ViolationsStore.js +33 -3
- package/dist/lib/service/knowledge/ConfidenceRouter.d.ts +13 -0
- package/dist/lib/service/knowledge/ConfidenceRouter.js +14 -0
- package/dist/lib/service/knowledge/KnowledgeService.js +22 -4
- package/dist/lib/service/module/ModuleService.js +3 -13
- package/dist/lib/service/panorama/CouplingAnalyzer.d.ts +27 -0
- package/dist/lib/service/panorama/CouplingAnalyzer.js +192 -0
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +28 -0
- package/dist/lib/service/panorama/DimensionAnalyzer.js +320 -0
- package/dist/lib/service/panorama/LayerInferrer.d.ts +19 -0
- package/dist/lib/service/panorama/LayerInferrer.js +182 -0
- package/dist/lib/service/panorama/ModuleDiscoverer.d.ts +24 -0
- package/dist/lib/service/panorama/ModuleDiscoverer.js +185 -0
- package/dist/lib/service/panorama/PanoramaAggregator.d.ts +29 -0
- package/dist/lib/service/panorama/PanoramaAggregator.js +228 -0
- package/dist/lib/service/panorama/PanoramaScanner.d.ts +52 -0
- package/dist/lib/service/panorama/PanoramaScanner.js +188 -0
- package/dist/lib/service/panorama/PanoramaService.d.ts +108 -0
- package/dist/lib/service/panorama/PanoramaService.js +220 -0
- package/dist/lib/service/panorama/PanoramaTypes.d.ts +134 -0
- package/dist/lib/service/panorama/PanoramaTypes.js +6 -0
- package/dist/lib/service/panorama/RoleRefiner.d.ts +48 -0
- package/dist/lib/service/panorama/RoleRefiner.js +535 -0
- package/dist/lib/service/search/MultiSignalRanker.d.ts +1 -0
- package/dist/lib/service/search/MultiSignalRanker.js +16 -0
- package/dist/lib/service/search/SearchEngine.d.ts +1 -0
- package/dist/lib/service/search/SearchEngine.js +9 -1
- package/dist/lib/service/search/SearchTypes.d.ts +2 -0
- package/dist/lib/service/signal/HitRecorder.d.ts +68 -0
- package/dist/lib/service/signal/HitRecorder.js +173 -0
- package/dist/lib/service/skills/SignalCollector.d.ts +3 -1
- package/dist/lib/service/skills/SignalCollector.js +31 -1
- package/dist/lib/service/task/IntentExtractor.d.ts +58 -0
- package/dist/lib/service/task/IntentExtractor.js +142 -0
- package/dist/lib/service/task/PrimeSearchPipeline.d.ts +54 -0
- package/dist/lib/service/task/PrimeSearchPipeline.js +98 -0
- package/dist/lib/shared/constants.d.ts +0 -15
- package/dist/lib/shared/constants.js +0 -10
- package/dist/lib/shared/schemas/config.d.ts +4 -1
- package/dist/lib/shared/schemas/config.js +8 -1
- package/dist/lib/shared/schemas/mcp-tools.d.ts +41 -96
- package/dist/lib/shared/schemas/mcp-tools.js +59 -119
- package/dist/scripts/analyze-signals.d.ts +20 -0
- package/dist/scripts/analyze-signals.js +155 -0
- package/dist/scripts/diagnose-mcp.js +1 -1
- package/dist/scripts/release.js +2 -10
- package/package.json +4 -19
- package/skills/autosnippet-devdocs/SKILL.md +11 -8
- package/templates/claude-code/hooks/autosnippet-session.sh +10 -15
- package/templates/cursor-hooks/hooks/session-start.sh +1 -1
- package/templates/instructions/agent-static.md +2 -1
- package/templates/instructions/conventions.md +5 -6
- package/templates/recipes-setup/README.md +1 -2
- package/dashboard/dist/assets/icons-C1dUryS-.js +0 -1
- package/dashboard/dist/assets/index-D0whuycy.css +0 -1
- package/dashboard/dist/assets/index-DdvZE4Yd.js +0 -128
- package/dist/lib/domain/task/Task.d.ts +0 -140
- package/dist/lib/domain/task/Task.js +0 -254
- package/dist/lib/domain/task/TaskDependency.d.ts +0 -23
- package/dist/lib/domain/task/TaskDependency.js +0 -34
- package/dist/lib/domain/task/TaskIdGenerator.d.ts +0 -40
- package/dist/lib/domain/task/TaskIdGenerator.js +0 -75
- package/dist/lib/domain/task/index.d.ts +0 -4
- package/dist/lib/domain/task/index.js +0 -4
- package/dist/lib/http/routes/snippets.js +0 -49
- package/dist/lib/infrastructure/database/migrations/002_add_tasks.d.ts +0 -11
- package/dist/lib/infrastructure/database/migrations/002_add_tasks.js +0 -86
- package/dist/lib/platform/ClipboardManager.d.ts +0 -24
- package/dist/lib/platform/ClipboardManager.js +0 -142
- package/dist/lib/platform/NativeUi.d.ts +0 -53
- package/dist/lib/platform/NativeUi.js +0 -284
- package/dist/lib/platform/ios/index.d.ts +0 -38
- package/dist/lib/platform/ios/index.js +0 -42
- package/dist/lib/platform/ios/routes/spm.d.ts +0 -9
- package/dist/lib/platform/ios/routes/spm.js +0 -371
- package/dist/lib/platform/ios/snippet/PlaceholderConverter.d.ts +0 -21
- package/dist/lib/platform/ios/snippet/PlaceholderConverter.js +0 -48
- package/dist/lib/platform/ios/snippet/XcodeCodec.d.ts +0 -23
- package/dist/lib/platform/ios/snippet/XcodeCodec.js +0 -96
- package/dist/lib/platform/ios/spm/DependencyGraph.d.ts +0 -56
- package/dist/lib/platform/ios/spm/DependencyGraph.js +0 -195
- package/dist/lib/platform/ios/spm/PackageSwiftParser.d.ts +0 -69
- package/dist/lib/platform/ios/spm/PackageSwiftParser.js +0 -231
- package/dist/lib/platform/ios/spm/PathFinder.d.ts +0 -28
- package/dist/lib/platform/ios/spm/PathFinder.js +0 -117
- package/dist/lib/platform/ios/spm/PolicyEngine.d.ts +0 -44
- package/dist/lib/platform/ios/spm/PolicyEngine.js +0 -79
- package/dist/lib/platform/ios/spm/SpmHelper.d.ts +0 -102
- package/dist/lib/platform/ios/spm/SpmHelper.js +0 -464
- package/dist/lib/platform/ios/xcode/HeaderResolver.d.ts +0 -33
- package/dist/lib/platform/ios/xcode/HeaderResolver.js +0 -90
- package/dist/lib/platform/ios/xcode/SaveEventFilter.d.ts +0 -66
- package/dist/lib/platform/ios/xcode/SaveEventFilter.js +0 -142
- package/dist/lib/platform/ios/xcode/XcodeAutomation.d.ts +0 -71
- package/dist/lib/platform/ios/xcode/XcodeAutomation.js +0 -327
- package/dist/lib/platform/ios/xcode/XcodeImportResolver.d.ts +0 -130
- package/dist/lib/platform/ios/xcode/XcodeImportResolver.js +0 -404
- package/dist/lib/platform/ios/xcode/XcodeIntegration.d.ts +0 -89
- package/dist/lib/platform/ios/xcode/XcodeIntegration.js +0 -588
- package/dist/lib/platform/ios/xcode/XcodeWriteUtils.d.ts +0 -99
- package/dist/lib/platform/ios/xcode/XcodeWriteUtils.js +0 -190
- package/dist/lib/repository/task/TaskRepository.impl.d.ts +0 -171
- package/dist/lib/repository/task/TaskRepository.impl.js +0 -347
- package/dist/lib/service/automation/ActionPipeline.d.ts +0 -34
- package/dist/lib/service/automation/ActionPipeline.js +0 -53
- package/dist/lib/service/automation/AutomationOrchestrator.d.ts +0 -86
- package/dist/lib/service/automation/AutomationOrchestrator.js +0 -57
- package/dist/lib/service/automation/ContextCollector.d.ts +0 -24
- package/dist/lib/service/automation/ContextCollector.js +0 -35
- package/dist/lib/service/automation/DirectiveDetector.d.ts +0 -51
- package/dist/lib/service/automation/DirectiveDetector.js +0 -112
- package/dist/lib/service/automation/FileWatcher.d.ts +0 -51
- package/dist/lib/service/automation/FileWatcher.js +0 -366
- package/dist/lib/service/automation/TriggerResolver.d.ts +0 -36
- package/dist/lib/service/automation/TriggerResolver.js +0 -62
- package/dist/lib/service/automation/handlers/AlinkHandler.d.ts +0 -7
- package/dist/lib/service/automation/handlers/AlinkHandler.js +0 -80
- package/dist/lib/service/automation/handlers/CreateHandler.d.ts +0 -11
- package/dist/lib/service/automation/handlers/CreateHandler.js +0 -170
- package/dist/lib/service/automation/handlers/GuardHandler.d.ts +0 -17
- package/dist/lib/service/automation/handlers/GuardHandler.js +0 -218
- package/dist/lib/service/automation/handlers/HeaderHandler.d.ts +0 -2
- package/dist/lib/service/automation/handlers/HeaderHandler.js +0 -32
- package/dist/lib/service/automation/handlers/SearchHandler.d.ts +0 -11
- package/dist/lib/service/automation/handlers/SearchHandler.js +0 -278
- package/dist/lib/service/snippet/SnippetFactory.d.ts +0 -101
- package/dist/lib/service/snippet/SnippetFactory.js +0 -145
- package/dist/lib/service/snippet/SnippetInstaller.d.ts +0 -91
- package/dist/lib/service/snippet/SnippetInstaller.js +0 -276
- package/dist/lib/service/snippet/codecs/SnippetCodec.d.ts +0 -44
- package/dist/lib/service/snippet/codecs/SnippetCodec.js +0 -35
- package/dist/lib/service/snippet/codecs/VSCodeCodec.d.ts +0 -27
- package/dist/lib/service/snippet/codecs/VSCodeCodec.js +0 -82
- package/dist/lib/service/task/TaskGraphService.d.ts +0 -222
- package/dist/lib/service/task/TaskGraphService.js +0 -597
- package/dist/lib/service/task/TaskKnowledgeBridge.d.ts +0 -95
- package/dist/lib/service/task/TaskKnowledgeBridge.js +0 -298
- package/dist/lib/service/task/TaskReadyEngine.d.ts +0 -84
- package/dist/lib/service/task/TaskReadyEngine.js +0 -115
- package/dist/scripts/build-native-ui.d.ts +0 -3
- package/dist/scripts/build-native-ui.js +0 -62
- package/dist/scripts/init-snippets.d.ts +0 -30
- package/dist/scripts/init-snippets.js +0 -298
- package/dist/scripts/install-full.d.ts +0 -7
- package/dist/scripts/install-full.js +0 -38
- package/resources/native-ui/README.md +0 -29
- package/resources/native-ui/combined-window.swift +0 -494
- package/resources/native-ui/main.swift +0 -598
- package/scripts/postinstall-safe.mjs +0 -89
package/dist/bin/cli.js
CHANGED
|
@@ -10,12 +10,12 @@
|
|
|
10
10
|
* asd search <query> - 搜索知识库
|
|
11
11
|
* asd guard <file> - Guard 检查
|
|
12
12
|
* asd guard:ci [path] - CI/CD Guard 合规检查
|
|
13
|
-
* asd watch - 文件监控
|
|
14
13
|
* asd server - 启动 API 服务
|
|
15
14
|
* asd ui - 启动 Dashboard UI
|
|
16
15
|
* asd upgrade - 升级 IDE 集成
|
|
17
16
|
* asd mirror - 镜像 .cursor/ → .qoder/ .trae/
|
|
18
17
|
* asd status - 环境状态
|
|
18
|
+
* asd health - 综合健康报告
|
|
19
19
|
*/
|
|
20
20
|
import { copyFileSync, existsSync, mkdirSync, readdirSync, readFileSync, writeFileSync, } from 'node:fs';
|
|
21
21
|
import { join, resolve } from 'node:path';
|
|
@@ -476,6 +476,8 @@ program
|
|
|
476
476
|
.option('--fail-on-error', '有 error 级违规时 exit 1', true)
|
|
477
477
|
.option('--fail-on-warning', '超过 warning 阈值时 exit 2')
|
|
478
478
|
.option('--max-warnings <n>', 'warning 阈值', '20')
|
|
479
|
+
.option('--max-uncertain <n>', 'uncertain 条目阈值 (超出时 exit 2)', '50')
|
|
480
|
+
.option('--min-coverage <n>', '最低覆盖率 (0-100,低于时 exit 3)', '0')
|
|
479
481
|
.option('--report <format>', '报告格式: json | text | markdown', 'text')
|
|
480
482
|
.option('--output <file>', '报告输出文件')
|
|
481
483
|
.option('--min-score <n>', 'Quality Gate 最低分', '70')
|
|
@@ -514,10 +516,18 @@ program
|
|
|
514
516
|
writeFileSync(opts.output, JSON.stringify(report, null, 2), 'utf8');
|
|
515
517
|
}
|
|
516
518
|
await bootstrap.shutdown();
|
|
517
|
-
// Exit code
|
|
519
|
+
// Exit code: 0=PASS, 1=FAIL(violations), 2=WARN(uncertain/warnings), 3=FAIL(coverage)
|
|
520
|
+
const maxUncertain = parseInt(opts.maxUncertain, 10);
|
|
521
|
+
const minCoverage = parseInt(opts.minCoverage, 10);
|
|
518
522
|
if (report.qualityGate.status === 'FAIL') {
|
|
519
523
|
process.exit(report.summary.errors > 0 ? 1 : 2);
|
|
520
524
|
}
|
|
525
|
+
if (minCoverage > 0 && (report.coverageScore ?? 100) < minCoverage) {
|
|
526
|
+
process.exit(3);
|
|
527
|
+
}
|
|
528
|
+
if (maxUncertain > 0 && (report.uncertainSummary?.total ?? 0) > maxUncertain) {
|
|
529
|
+
process.exit(2);
|
|
530
|
+
}
|
|
521
531
|
process.exit(0);
|
|
522
532
|
}
|
|
523
533
|
catch (err) {
|
|
@@ -605,45 +615,78 @@ program
|
|
|
605
615
|
}
|
|
606
616
|
});
|
|
607
617
|
// ─────────────────────────────────────────────────────
|
|
608
|
-
//
|
|
618
|
+
// panorama 命令
|
|
609
619
|
// ─────────────────────────────────────────────────────
|
|
610
620
|
program
|
|
611
|
-
.command('
|
|
612
|
-
.
|
|
613
|
-
.option('
|
|
614
|
-
.option('--
|
|
615
|
-
.
|
|
621
|
+
.command('panorama [path]')
|
|
622
|
+
.description('项目全景分析:架构层级、覆盖率、知识空白')
|
|
623
|
+
.option('--json', '以 JSON 格式输出')
|
|
624
|
+
.option('--gaps', '仅显示知识空白区')
|
|
625
|
+
.option('--health', '仅显示健康度评分')
|
|
626
|
+
.action(async (scanPath, opts) => {
|
|
616
627
|
try {
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
628
|
+
const projectRoot = resolve(scanPath || '.');
|
|
629
|
+
const { bootstrap, container } = await initContainer({ projectRoot });
|
|
630
|
+
const panoramaService = container.get('panoramaService');
|
|
631
|
+
if (opts.gaps) {
|
|
632
|
+
const gaps = panoramaService.getGaps();
|
|
633
|
+
if (opts.json) {
|
|
634
|
+
cli.log(JSON.stringify(gaps, null, 2));
|
|
635
|
+
}
|
|
636
|
+
else {
|
|
637
|
+
cli.log(`\n🔍 Knowledge Gaps: ${gaps.length} found\n`);
|
|
638
|
+
for (const g of gaps.slice(0, 20)) {
|
|
639
|
+
const priority = g.priority === 'high' ? '🔴' : g.priority === 'medium' ? '🟡' : '🔵';
|
|
640
|
+
cli.log(` ${priority} [${g.dimensionName}] ${g.recipeCount} recipes (${g.status}) — ${g.suggestedTopics.join(', ')}`);
|
|
641
|
+
}
|
|
642
|
+
if (gaps.length > 20) {
|
|
643
|
+
cli.log(`\n ... and ${gaps.length - 20} more gaps`);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
await bootstrap.shutdown();
|
|
647
|
+
return;
|
|
622
648
|
}
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
quiet: false,
|
|
638
|
-
exts,
|
|
639
|
-
});
|
|
640
|
-
watcher.start();
|
|
641
|
-
// 优雅退出
|
|
642
|
-
process.on('SIGINT', async () => {
|
|
643
|
-
await watcher.stop();
|
|
649
|
+
if (opts.health) {
|
|
650
|
+
const health = panoramaService.getHealth();
|
|
651
|
+
if (opts.json) {
|
|
652
|
+
cli.log(JSON.stringify(health, null, 2));
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
const icon = health.healthScore >= 80 ? '✅' : health.healthScore >= 50 ? '⚠️' : '❌';
|
|
656
|
+
cli.log(`\n${icon} Panorama Health: ${health.healthScore}/100\n`);
|
|
657
|
+
cli.log(` Dimension Coverage: ${health.healthRadar.dimensionCoverage}%`);
|
|
658
|
+
cli.log(` Avg Coupling: ${health.avgCoupling}`);
|
|
659
|
+
cli.log(` Modules: ${health.moduleCount}`);
|
|
660
|
+
cli.log(` Cycles: ${health.cycleCount}`);
|
|
661
|
+
cli.log(` Gaps: ${health.gapCount} (${health.highPriorityGaps} high-priority)`);
|
|
662
|
+
}
|
|
644
663
|
await bootstrap.shutdown();
|
|
645
|
-
|
|
646
|
-
}
|
|
664
|
+
return;
|
|
665
|
+
}
|
|
666
|
+
// 默认: 全景概览
|
|
667
|
+
const overview = panoramaService.getOverview();
|
|
668
|
+
if (opts.json) {
|
|
669
|
+
cli.log(JSON.stringify(overview, null, 2));
|
|
670
|
+
}
|
|
671
|
+
else {
|
|
672
|
+
cli.log(`\n📐 Panorama Overview\n`);
|
|
673
|
+
cli.log(` Project: ${overview.projectRoot}`);
|
|
674
|
+
cli.log(` Modules: ${overview.moduleCount}`);
|
|
675
|
+
cli.log(` Layers: ${overview.layerCount}`);
|
|
676
|
+
cli.log(` Files: ${overview.totalFiles}`);
|
|
677
|
+
cli.log(` Recipes: ${overview.totalRecipes}`);
|
|
678
|
+
cli.log(` Coverage: ${overview.overallCoverage}%`);
|
|
679
|
+
cli.log(` Cycles: ${overview.cycleCount}`);
|
|
680
|
+
cli.log(` Gaps: ${overview.gapCount}`);
|
|
681
|
+
if (overview.layers && overview.layers.length > 0) {
|
|
682
|
+
cli.log(`\n Layers:`);
|
|
683
|
+
for (const layer of overview.layers) {
|
|
684
|
+
const totalFiles = layer.modules.reduce((sum, m) => sum + m.fileCount, 0);
|
|
685
|
+
cli.log(` ${layer.name}: ${layer.modules.length} modules, ${totalFiles} files`);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
await bootstrap.shutdown();
|
|
647
690
|
}
|
|
648
691
|
catch (err) {
|
|
649
692
|
cli.error(`Error: ${err.message}`);
|
|
@@ -766,91 +809,6 @@ program
|
|
|
766
809
|
cli.warn(`⚠️ SignalCollector failed to start: ${scErr.message}`);
|
|
767
810
|
cli.debug(scErr.stack);
|
|
768
811
|
}
|
|
769
|
-
// 3. 启动文件监听器(仅 iOS/macOS 项目 — Xcode 工作流)
|
|
770
|
-
// VSCode 用户通过 AutoSnippet 扩展原生处理 as:s/as:c/as:a 指令
|
|
771
|
-
const isAppleProject = (() => {
|
|
772
|
-
try {
|
|
773
|
-
const entries = readdirSync(projectRoot, { withFileTypes: true });
|
|
774
|
-
// ── Level 1: 项目配置文件(确定性高)──
|
|
775
|
-
const hasAppleConfig = entries.some((e) => e.name === 'Package.swift' || // SPM
|
|
776
|
-
e.name === 'Podfile' || // CocoaPods
|
|
777
|
-
e.name === 'Cartfile' || // Carthage
|
|
778
|
-
e.name === 'project.yml' || // XcodeGen
|
|
779
|
-
e.name.endsWith('.xcodeproj') || // Xcode project
|
|
780
|
-
e.name.endsWith('.xcworkspace') // Xcode workspace
|
|
781
|
-
);
|
|
782
|
-
if (hasAppleConfig) {
|
|
783
|
-
return true;
|
|
784
|
-
}
|
|
785
|
-
// ── Level 2: 目录结构特征 ──
|
|
786
|
-
const hasAppleDir = entries.some((e) => e.isDirectory() &&
|
|
787
|
-
(e.name === 'Tuist' || // Tuist 项目
|
|
788
|
-
e.name === 'Pods' || // CocoaPods 产物
|
|
789
|
-
e.name === 'Carthage' || // Carthage 产物
|
|
790
|
-
e.name === 'DerivedData') // Xcode 构建产物
|
|
791
|
-
);
|
|
792
|
-
if (hasAppleDir) {
|
|
793
|
-
return true;
|
|
794
|
-
}
|
|
795
|
-
// ── Level 3: 向下扫一层(处理 monorepo 或 Sources/ 下有 .swift 的情况)──
|
|
796
|
-
const APPLE_EXTS = new Set(['.swift', '.m', '.mm', '.h']);
|
|
797
|
-
const SCAN_DIRS = ['Sources', 'Source', 'src', 'App', 'Classes', 'ios', 'iOS'];
|
|
798
|
-
for (const e of entries) {
|
|
799
|
-
// 根目录直接有 .swift/.m 文件
|
|
800
|
-
if (!e.isDirectory() && APPLE_EXTS.has(e.name.slice(e.name.lastIndexOf('.')))) {
|
|
801
|
-
return true;
|
|
802
|
-
}
|
|
803
|
-
// 常见源码目录下有 Apple 文件
|
|
804
|
-
if (e.isDirectory() && SCAN_DIRS.includes(e.name)) {
|
|
805
|
-
try {
|
|
806
|
-
const subEntries = readdirSync(join(projectRoot, e.name));
|
|
807
|
-
if (subEntries.some((f) => APPLE_EXTS.has(f.slice(f.lastIndexOf('.'))))) {
|
|
808
|
-
return true;
|
|
809
|
-
}
|
|
810
|
-
}
|
|
811
|
-
catch {
|
|
812
|
-
/* 读取失败忽略 */
|
|
813
|
-
}
|
|
814
|
-
}
|
|
815
|
-
}
|
|
816
|
-
return false;
|
|
817
|
-
}
|
|
818
|
-
catch {
|
|
819
|
-
return false;
|
|
820
|
-
}
|
|
821
|
-
})();
|
|
822
|
-
if (isAppleProject) {
|
|
823
|
-
try {
|
|
824
|
-
const Paths = await import('../lib/infrastructure/config/Paths.js');
|
|
825
|
-
const specPath = Paths.getProjectSpecPath(projectRoot);
|
|
826
|
-
const isDebugMode = process.env.ASD_DEBUG === '1';
|
|
827
|
-
// 设置 Dashboard URL 供 watcher 跳转浏览器使用
|
|
828
|
-
// 生产模式用 API 同端口,开发模式用 vite dev 5173
|
|
829
|
-
const dashDirCheck = DASHBOARD_DIR;
|
|
830
|
-
const isProductionDashboard = existsSync(join(dashDirCheck, 'dist', 'index.html')) &&
|
|
831
|
-
!existsSync(join(dashDirCheck, 'src'));
|
|
832
|
-
if (!opts.apiOnly) {
|
|
833
|
-
process.env.ASD_DASHBOARD_URL = isProductionDashboard
|
|
834
|
-
? `http://127.0.0.1:${port}`
|
|
835
|
-
: `http://localhost:5173`;
|
|
836
|
-
}
|
|
837
|
-
else {
|
|
838
|
-
process.env.ASD_DASHBOARD_URL =
|
|
839
|
-
process.env.ASD_DASHBOARD_URL || `http://${host}:${port}`;
|
|
840
|
-
}
|
|
841
|
-
const { FileWatcher } = await import('../lib/service/automation/FileWatcher.js');
|
|
842
|
-
const watcher = new FileWatcher(specPath, projectRoot, { quiet: !isDebugMode });
|
|
843
|
-
watcher.start();
|
|
844
|
-
if (isDebugMode) {
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
catch (watchErr) {
|
|
848
|
-
cli.warn(`⚠️ File watcher failed to start: ${watchErr.message}`);
|
|
849
|
-
cli.debug(watchErr.stack);
|
|
850
|
-
}
|
|
851
|
-
}
|
|
852
|
-
else if (process.env.ASD_DEBUG === '1') {
|
|
853
|
-
}
|
|
854
812
|
if (opts.apiOnly) {
|
|
855
813
|
return;
|
|
856
814
|
}
|
|
@@ -910,7 +868,8 @@ program
|
|
|
910
868
|
program
|
|
911
869
|
.command('status')
|
|
912
870
|
.description('检查环境状态')
|
|
913
|
-
.
|
|
871
|
+
.option('--json', 'JSON 格式输出')
|
|
872
|
+
.action(async (opts) => {
|
|
914
873
|
cli.log('\n AutoSnippet Environment Status');
|
|
915
874
|
cli.log(` ${'─'.repeat(40)}`);
|
|
916
875
|
// AI 配置
|
|
@@ -943,9 +902,165 @@ program
|
|
|
943
902
|
cli.log(` ❌ ${dep} (missing)`);
|
|
944
903
|
}
|
|
945
904
|
}
|
|
905
|
+
// 如果数据库存在,加载知识库统计
|
|
906
|
+
if (dbExists) {
|
|
907
|
+
try {
|
|
908
|
+
const projectRoot = resolve('.');
|
|
909
|
+
const { bootstrap, container } = await initContainer({ projectRoot });
|
|
910
|
+
const knowledgeService = container.get('knowledgeService');
|
|
911
|
+
const stats = (await knowledgeService.getStats());
|
|
912
|
+
if (stats) {
|
|
913
|
+
cli.log(' Knowledge:');
|
|
914
|
+
cli.log(` Total: ${stats.total ?? 0} Active: ${stats.active ?? 0} Staging: ${stats.staging ?? 0} Evolving: ${stats.evolving ?? 0} Decaying: ${stats.decaying ?? 0} Pending: ${stats.pending ?? 0} Deprecated: ${stats.deprecated ?? 0}`);
|
|
915
|
+
cli.log(` Rules: ${stats.rules ?? 0} Patterns: ${stats.patterns ?? 0} Facts: ${stats.facts ?? 0}`);
|
|
916
|
+
}
|
|
917
|
+
// Signal Bus 统计
|
|
918
|
+
const signalBus = container.get('signalBus');
|
|
919
|
+
if (signalBus) {
|
|
920
|
+
const bus = signalBus;
|
|
921
|
+
cli.log(' Signals:');
|
|
922
|
+
cli.log(` Emitted: ${bus.emitCount ?? 0} Listeners: ${bus.listenerCount ?? 0}`);
|
|
923
|
+
}
|
|
924
|
+
await bootstrap.shutdown();
|
|
925
|
+
}
|
|
926
|
+
catch {
|
|
927
|
+
// 降级: 无法加载容器时只展示基础状态
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
if (opts.json) {
|
|
931
|
+
// 简化 JSON 输出模式
|
|
932
|
+
const result = {
|
|
933
|
+
aiProvider: aiInfo.provider ?? 'ide-agent',
|
|
934
|
+
aiModel: aiInfo.model ?? null,
|
|
935
|
+
database: dbExists,
|
|
936
|
+
workspace: existsSync(asdDir),
|
|
937
|
+
};
|
|
938
|
+
cli.json(result);
|
|
939
|
+
}
|
|
946
940
|
cli.blank();
|
|
947
941
|
});
|
|
948
942
|
// ─────────────────────────────────────────────────────
|
|
943
|
+
// health 命令
|
|
944
|
+
// ─────────────────────────────────────────────────────
|
|
945
|
+
program
|
|
946
|
+
.command('health')
|
|
947
|
+
.description('综合健康报告:系统状态、知识生命周期、Guard 合规、信号统计')
|
|
948
|
+
.option('-d, --dir <path>', '项目目录', '.')
|
|
949
|
+
.option('--json', '以 JSON 格式输出')
|
|
950
|
+
.action(async (opts) => {
|
|
951
|
+
const projectRoot = resolve(opts.dir);
|
|
952
|
+
const { getAiConfigInfo } = await import('../lib/external/ai/AiFactory.js');
|
|
953
|
+
const aiInfo = getAiConfigInfo();
|
|
954
|
+
const aiOk = !!(aiInfo.provider && aiInfo.provider !== 'none');
|
|
955
|
+
const dbPath = join(projectRoot, '.autosnippet', 'autosnippet.db');
|
|
956
|
+
const dbExists = existsSync(dbPath);
|
|
957
|
+
let dbSizeMB = 0;
|
|
958
|
+
let dbEntries = 0;
|
|
959
|
+
let guardRuleCount = 0;
|
|
960
|
+
let knowledgeStats = {};
|
|
961
|
+
let complianceScore = 0;
|
|
962
|
+
let coverageScore = 0;
|
|
963
|
+
let confidencePct = 0;
|
|
964
|
+
let signalEmitted = 0;
|
|
965
|
+
let signalListeners = 0;
|
|
966
|
+
if (dbExists) {
|
|
967
|
+
try {
|
|
968
|
+
const { statSync } = await import('node:fs');
|
|
969
|
+
const stat = statSync(dbPath);
|
|
970
|
+
dbSizeMB = +(stat.size / (1024 * 1024)).toFixed(1);
|
|
971
|
+
}
|
|
972
|
+
catch {
|
|
973
|
+
/* stat 失败不阻塞 */
|
|
974
|
+
}
|
|
975
|
+
try {
|
|
976
|
+
const { bootstrap, container } = await initContainer({ projectRoot });
|
|
977
|
+
try {
|
|
978
|
+
const knowledgeService = container.get('knowledgeService');
|
|
979
|
+
const stats = (await knowledgeService.getStats());
|
|
980
|
+
if (stats) {
|
|
981
|
+
knowledgeStats = stats;
|
|
982
|
+
dbEntries = stats.total ?? 0;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
catch {
|
|
986
|
+
/* knowledge service 不可用 */
|
|
987
|
+
}
|
|
988
|
+
try {
|
|
989
|
+
const engine = container.get('guardCheckEngine');
|
|
990
|
+
const rules = engine.getRules();
|
|
991
|
+
guardRuleCount = rules.length;
|
|
992
|
+
}
|
|
993
|
+
catch {
|
|
994
|
+
/* guard engine 不可用 */
|
|
995
|
+
}
|
|
996
|
+
try {
|
|
997
|
+
const reporter = container.get('complianceReporter');
|
|
998
|
+
const report = await reporter.generate(projectRoot, {
|
|
999
|
+
qualityGate: { maxErrors: 0, maxWarnings: 100, minScore: 0 },
|
|
1000
|
+
maxFiles: 200,
|
|
1001
|
+
});
|
|
1002
|
+
complianceScore = report.complianceScore ?? 0;
|
|
1003
|
+
coverageScore = report.coverageScore ?? 0;
|
|
1004
|
+
confidencePct = report.confidenceScore ?? 0;
|
|
1005
|
+
}
|
|
1006
|
+
catch {
|
|
1007
|
+
/* compliance reporter 不可用 */
|
|
1008
|
+
}
|
|
1009
|
+
try {
|
|
1010
|
+
const signalBus = container.get('signalBus');
|
|
1011
|
+
signalEmitted = signalBus.emitCount ?? 0;
|
|
1012
|
+
signalListeners = signalBus.listenerCount ?? 0;
|
|
1013
|
+
}
|
|
1014
|
+
catch {
|
|
1015
|
+
/* signal bus 不可用 */
|
|
1016
|
+
}
|
|
1017
|
+
await bootstrap.shutdown();
|
|
1018
|
+
}
|
|
1019
|
+
catch {
|
|
1020
|
+
/* container init 失败,降级展示基础信息 */
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
const healthData = {
|
|
1024
|
+
system: {
|
|
1025
|
+
ai: aiOk,
|
|
1026
|
+
db: dbExists,
|
|
1027
|
+
dbSizeMB,
|
|
1028
|
+
dbEntries,
|
|
1029
|
+
guardRules: guardRuleCount,
|
|
1030
|
+
},
|
|
1031
|
+
knowledge: {
|
|
1032
|
+
active: knowledgeStats.active ?? 0,
|
|
1033
|
+
staging: knowledgeStats.staging ?? 0,
|
|
1034
|
+
evolving: knowledgeStats.evolving ?? 0,
|
|
1035
|
+
decaying: knowledgeStats.decaying ?? 0,
|
|
1036
|
+
},
|
|
1037
|
+
guard: {
|
|
1038
|
+
compliance: complianceScore,
|
|
1039
|
+
coverage: coverageScore,
|
|
1040
|
+
confidence: confidencePct,
|
|
1041
|
+
},
|
|
1042
|
+
signals: {
|
|
1043
|
+
emitted: signalEmitted,
|
|
1044
|
+
listeners: signalListeners,
|
|
1045
|
+
},
|
|
1046
|
+
};
|
|
1047
|
+
if (opts.json) {
|
|
1048
|
+
cli.json(healthData);
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
const dbStatus = dbExists ? `✅(${dbSizeMB}MB, ${dbEntries} entries)` : '❌';
|
|
1052
|
+
const aiIcon = aiOk ? '✅' : '❌';
|
|
1053
|
+
cli.log('');
|
|
1054
|
+
cli.log('AutoSnippet Health Report');
|
|
1055
|
+
cli.log('═════════════════════════');
|
|
1056
|
+
cli.log(`🔧 System: AI:${aiIcon} DB:${dbStatus} Guard:${guardRuleCount} rules`);
|
|
1057
|
+
cli.log(`📊 Knowledge: Active:${healthData.knowledge.active} Staging:${healthData.knowledge.staging} Evolving:${healthData.knowledge.evolving} Decaying:${healthData.knowledge.decaying}`);
|
|
1058
|
+
cli.log(`🛡️ Guard: Compliance:${complianceScore} Coverage:${coverageScore} Confidence:${confidencePct}%`);
|
|
1059
|
+
cli.log(`📡 Signals: emitted:${signalEmitted} listeners:${signalListeners}`);
|
|
1060
|
+
cli.blank();
|
|
1061
|
+
}
|
|
1062
|
+
});
|
|
1063
|
+
// ─────────────────────────────────────────────────────
|
|
949
1064
|
// embed 命令 — 构建/重建语义向量索引
|
|
950
1065
|
// ─────────────────────────────────────────────────────
|
|
951
1066
|
program
|
|
@@ -1103,150 +1218,18 @@ program
|
|
|
1103
1218
|
}
|
|
1104
1219
|
});
|
|
1105
1220
|
// ─────────────────────────────────────────────────────
|
|
1106
|
-
// task 命令 —
|
|
1221
|
+
// task 命令 — Task 系统已迁移到 MCP (零 DB,纯内存 + JSONL)
|
|
1222
|
+
// CLI task 子命令已废弃,通过 MCP autosnippet_task 操作
|
|
1107
1223
|
// ─────────────────────────────────────────────────────
|
|
1108
1224
|
const taskCmd = program
|
|
1109
1225
|
.command('task')
|
|
1110
|
-
.description('
|
|
1226
|
+
.description('Task 管理(已迁移到 MCP — 通过 autosnippet_task 操作)');
|
|
1111
1227
|
taskCmd
|
|
1112
1228
|
.command('list')
|
|
1113
|
-
.description('
|
|
1114
|
-
.
|
|
1115
|
-
.
|
|
1116
|
-
.
|
|
1117
|
-
.action(async (opts) => {
|
|
1118
|
-
const projectRoot = resolve(opts.dir);
|
|
1119
|
-
const { bootstrap, container } = await initContainer({ projectRoot });
|
|
1120
|
-
try {
|
|
1121
|
-
const svc = container.get('taskGraphService');
|
|
1122
|
-
const filters = {};
|
|
1123
|
-
if (opts.status) {
|
|
1124
|
-
filters.status = opts.status;
|
|
1125
|
-
}
|
|
1126
|
-
const tasks = await svc.list(filters, { limit: parseInt(opts.limit, 10) });
|
|
1127
|
-
if (tasks.length === 0) {
|
|
1128
|
-
cli.log('No tasks found.');
|
|
1129
|
-
}
|
|
1130
|
-
else {
|
|
1131
|
-
cli.log(`\n ID Status Priority Title`);
|
|
1132
|
-
cli.log(` ${'─'.repeat(70)}`);
|
|
1133
|
-
for (const t of tasks) {
|
|
1134
|
-
if (!t) {
|
|
1135
|
-
continue;
|
|
1136
|
-
}
|
|
1137
|
-
const j = t.toJSON ? t.toJSON() : t;
|
|
1138
|
-
if (!j) {
|
|
1139
|
-
continue;
|
|
1140
|
-
}
|
|
1141
|
-
const id = String(j.id || '').padEnd(16);
|
|
1142
|
-
const status = String(j.status || '').padEnd(13);
|
|
1143
|
-
const pri = String(j.priority ?? '-').padEnd(9);
|
|
1144
|
-
cli.log(` ${id} ${status} ${pri} ${j.title}`);
|
|
1145
|
-
}
|
|
1146
|
-
cli.log(`\n Total: ${tasks.length}\n`);
|
|
1147
|
-
}
|
|
1148
|
-
}
|
|
1149
|
-
finally {
|
|
1150
|
-
await bootstrap.shutdown?.();
|
|
1151
|
-
}
|
|
1152
|
-
});
|
|
1153
|
-
taskCmd
|
|
1154
|
-
.command('ready')
|
|
1155
|
-
.description('显示就绪任务(带知识上下文)')
|
|
1156
|
-
.option('-d, --dir <path>', '项目目录', '.')
|
|
1157
|
-
.option('-l, --limit <n>', '最大条数', '5')
|
|
1158
|
-
.action(async (opts) => {
|
|
1159
|
-
const projectRoot = resolve(opts.dir);
|
|
1160
|
-
const { bootstrap, container } = await initContainer({ projectRoot });
|
|
1161
|
-
try {
|
|
1162
|
-
const svc = container.get('taskGraphService');
|
|
1163
|
-
const tasks = await svc.ready({
|
|
1164
|
-
limit: parseInt(opts.limit, 10),
|
|
1165
|
-
withKnowledge: true,
|
|
1166
|
-
});
|
|
1167
|
-
if (tasks.length === 0) {
|
|
1168
|
-
cli.log('No ready tasks.');
|
|
1169
|
-
}
|
|
1170
|
-
else {
|
|
1171
|
-
for (const t of tasks) {
|
|
1172
|
-
if (!t) {
|
|
1173
|
-
continue;
|
|
1174
|
-
}
|
|
1175
|
-
const j = t.toJSON ? t.toJSON() : t;
|
|
1176
|
-
if (!j) {
|
|
1177
|
-
continue;
|
|
1178
|
-
}
|
|
1179
|
-
cli.log(`\n ▸ ${j.id} — ${j.title} (P${j.priority ?? '?'})`);
|
|
1180
|
-
const kCtx = t.knowledgeContext;
|
|
1181
|
-
if (kCtx?.relatedKnowledge?.length) {
|
|
1182
|
-
cli.log(` Knowledge: ${kCtx.relatedKnowledge.map((k) => k.title).join(', ')}`);
|
|
1183
|
-
}
|
|
1184
|
-
if (kCtx?.guardRules?.length) {
|
|
1185
|
-
cli.log(` Guard: ${kCtx.guardRules.map((r) => r.title).join(', ')}`);
|
|
1186
|
-
}
|
|
1187
|
-
}
|
|
1188
|
-
cli.blank();
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
finally {
|
|
1192
|
-
await bootstrap.shutdown?.();
|
|
1193
|
-
}
|
|
1194
|
-
});
|
|
1195
|
-
taskCmd
|
|
1196
|
-
.command('prime')
|
|
1197
|
-
.description('恢复 TaskGraph 会话上下文(等同 MCP prime 操作)')
|
|
1198
|
-
.option('-d, --dir <path>', '项目目录', '.')
|
|
1199
|
-
.action(async (opts) => {
|
|
1200
|
-
const projectRoot = resolve(opts.dir);
|
|
1201
|
-
const { bootstrap, container } = await initContainer({ projectRoot });
|
|
1202
|
-
try {
|
|
1203
|
-
const svc = container.get('taskGraphService');
|
|
1204
|
-
const result = await svc.prime({ withKnowledge: true });
|
|
1205
|
-
const inProgress = result.inProgress;
|
|
1206
|
-
const ready = result.ready;
|
|
1207
|
-
cli.log(`\n TaskGraph Prime`);
|
|
1208
|
-
cli.log(` ${'─'.repeat(40)}`);
|
|
1209
|
-
cli.log(` In Progress: ${inProgress.length}`);
|
|
1210
|
-
cli.log(` Ready: ${ready.length}`);
|
|
1211
|
-
cli.log(` Stats: ${JSON.stringify(result.stats)}`);
|
|
1212
|
-
if (inProgress.length > 0) {
|
|
1213
|
-
cli.log(`\n ▸ In Progress:`);
|
|
1214
|
-
for (const t of inProgress) {
|
|
1215
|
-
cli.log(` ${t.id} — ${t.title}`);
|
|
1216
|
-
}
|
|
1217
|
-
}
|
|
1218
|
-
if (ready.length > 0) {
|
|
1219
|
-
cli.log(`\n ▸ Ready:`);
|
|
1220
|
-
for (const t of ready) {
|
|
1221
|
-
cli.log(` ${t.id} — ${t.title}`);
|
|
1222
|
-
}
|
|
1223
|
-
}
|
|
1224
|
-
cli.blank();
|
|
1225
|
-
}
|
|
1226
|
-
finally {
|
|
1227
|
-
await bootstrap.shutdown?.();
|
|
1228
|
-
}
|
|
1229
|
-
});
|
|
1230
|
-
taskCmd
|
|
1231
|
-
.command('stats')
|
|
1232
|
-
.description('TaskGraph 统计信息')
|
|
1233
|
-
.option('-d, --dir <path>', '项目目录', '.')
|
|
1234
|
-
.action(async (opts) => {
|
|
1235
|
-
const projectRoot = resolve(opts.dir);
|
|
1236
|
-
const { bootstrap, container } = await initContainer({ projectRoot });
|
|
1237
|
-
try {
|
|
1238
|
-
const svc = container.get('taskGraphService');
|
|
1239
|
-
const stats = await svc.stats();
|
|
1240
|
-
cli.log(`\n TaskGraph Statistics`);
|
|
1241
|
-
cli.log(` ${'─'.repeat(30)}`);
|
|
1242
|
-
for (const [key, val] of Object.entries(stats)) {
|
|
1243
|
-
cli.log(` ${key.padEnd(15)} ${val}`);
|
|
1244
|
-
}
|
|
1245
|
-
cli.blank();
|
|
1246
|
-
}
|
|
1247
|
-
finally {
|
|
1248
|
-
await bootstrap.shutdown?.();
|
|
1249
|
-
}
|
|
1229
|
+
.description('[已废弃] Task 系统不再使用数据库。通过 MCP prime 操作获取上下文。')
|
|
1230
|
+
.action(() => {
|
|
1231
|
+
cli.log('\n ⚠️ Task 系统已迁移到 MCP(零 DB,纯内存 + JSONL)。');
|
|
1232
|
+
cli.log(' 使用 autosnippet_task({ operation: "prime" }) 加载上下文。\n');
|
|
1250
1233
|
});
|
|
1251
1234
|
// ─────────────────────────────────────────────────────
|
|
1252
1235
|
// mirror 命令
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
*
|
|
22
22
|
* @module ExplorationTracker
|
|
23
23
|
*/
|
|
24
|
+
import type { SignalBus } from '#infra/signal/SignalBus.js';
|
|
24
25
|
import type { ExplorationBudget, ExplorationStrategy, ExplorationTrace, PipelineType } from './exploration/ExplorationStrategies.js';
|
|
25
26
|
/** resolve() 选项 */
|
|
26
27
|
interface ResolveOptions {
|
|
@@ -34,6 +35,7 @@ interface ResolveOptions {
|
|
|
34
35
|
interface BudgetInput extends Partial<ExplorationBudget> {
|
|
35
36
|
submitToolName?: string;
|
|
36
37
|
pipelineType?: PipelineType;
|
|
38
|
+
signalBus?: SignalBus | null;
|
|
37
39
|
}
|
|
38
40
|
export declare class ExplorationTracker {
|
|
39
41
|
#private;
|
|
@@ -36,6 +36,8 @@ export class ExplorationTracker {
|
|
|
36
36
|
#phase;
|
|
37
37
|
/** 日志器 */
|
|
38
38
|
#logger;
|
|
39
|
+
/** 信号总线(可选) */
|
|
40
|
+
#signalBus;
|
|
39
41
|
// ── 子模块 ──
|
|
40
42
|
#signalDetector;
|
|
41
43
|
#nudgeGenerator;
|
|
@@ -88,6 +90,7 @@ export class ExplorationTracker {
|
|
|
88
90
|
budget.pipelineType || (strategy.name === 'analyst' ? 'analyst' : 'bootstrap');
|
|
89
91
|
this.#phase = strategy.phases[0];
|
|
90
92
|
this.#logger = Logger.getInstance();
|
|
93
|
+
this.#signalBus = budget.signalBus ?? null;
|
|
91
94
|
// 初始化子模块
|
|
92
95
|
this.#signalDetector = new SignalDetector(this.#metrics);
|
|
93
96
|
this.#nudgeGenerator = new NudgeGenerator();
|
|
@@ -147,17 +150,17 @@ export class ExplorationTracker {
|
|
|
147
150
|
shouldExit() {
|
|
148
151
|
// Scan 管线: SUMMARIZE 无消费方,直接退出
|
|
149
152
|
if (this.#isTerminalPhase() && this.#pipelineType === 'scan') {
|
|
153
|
+
this.#emitExitSignal('scan_terminal');
|
|
150
154
|
return true;
|
|
151
155
|
}
|
|
152
156
|
// 终结阶段 + 已给了 3 轮 grace → 退出
|
|
153
|
-
// 注意: phaseRounds 在 tick() 中递增 (进入终结阶段后从 1 开始计数)
|
|
154
|
-
// 3 轮 grace 允许: round 1 (首次尝试) + round 2 (空响应重试) + 安全余量
|
|
155
|
-
// 与 AgentRuntime#callLLM 的空响应 grace 机制对齐 (grace < 2 → 在 round 1 重试)
|
|
156
157
|
if (this.#isTerminalPhase() && this.#metrics.phaseRounds >= 3) {
|
|
158
|
+
this.#emitExitSignal('grace_exhausted');
|
|
157
159
|
return true;
|
|
158
160
|
}
|
|
159
161
|
// 硬上限兜底
|
|
160
162
|
if (this.#metrics.iteration >= this.#budget.maxIterations + 2) {
|
|
163
|
+
this.#emitExitSignal('hard_limit');
|
|
161
164
|
return true;
|
|
162
165
|
}
|
|
163
166
|
// 达到 maxIterations 但未在终结阶段 → 强制转入终结阶段
|
|
@@ -170,6 +173,13 @@ export class ExplorationTracker {
|
|
|
170
173
|
}
|
|
171
174
|
return false;
|
|
172
175
|
}
|
|
176
|
+
#emitExitSignal(reason) {
|
|
177
|
+
if (this.#signalBus) {
|
|
178
|
+
this.#signalBus.send('exploration', 'ExplorationTracker.exit', 0, {
|
|
179
|
+
metadata: { totalIterations: this.#metrics.iteration, reason },
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}
|
|
173
183
|
/**
|
|
174
184
|
* 获取本轮的 Nudge(每轮最多一条)
|
|
175
185
|
* @param trace 推理链
|
|
@@ -438,6 +448,14 @@ export class ExplorationTracker {
|
|
|
438
448
|
this.#metrics.roundsSinceSubmit = 0;
|
|
439
449
|
this.#justTransitioned = true;
|
|
440
450
|
this.#logger.info(`[ExplorationTracker] ${oldPhase} → ${newPhase} (iter=${this.#metrics.iteration}, submits=${this.#metrics.submitCount})`);
|
|
451
|
+
// Phase 3: 发射阶段转换信号
|
|
452
|
+
if (this.#signalBus) {
|
|
453
|
+
const terminalPhase = this.#getTerminalPhase();
|
|
454
|
+
const value = newPhase === terminalPhase ? 1.0 : 0.5;
|
|
455
|
+
this.#signalBus.send('exploration', 'ExplorationTracker.phase', value, {
|
|
456
|
+
metadata: { from: oldPhase, to: newPhase, iteration: this.#metrics.iteration },
|
|
457
|
+
});
|
|
458
|
+
}
|
|
441
459
|
}
|
|
442
460
|
#isTerminalPhase() {
|
|
443
461
|
return this.#phase === this.#getTerminalPhase();
|
|
@@ -78,7 +78,9 @@ export declare class ToolExecutionPipeline {
|
|
|
78
78
|
* 从 LoopContext.toolSchemas 中提取允许的工具名列表,
|
|
79
79
|
* 拒绝不在列表中的调用(返回 error 提示)。
|
|
80
80
|
*
|
|
81
|
-
*
|
|
81
|
+
* Forge 集成:不在白名单的工具如果已由 ToolForge 锻造(存在于 ToolRegistry),则放行。
|
|
82
|
+
*
|
|
83
|
+
* before: 如果工具不在白名单中且非锻造工具则短路返回 error
|
|
82
84
|
*/
|
|
83
85
|
export declare const allowlistGate: {
|
|
84
86
|
name: string;
|