autosnippet 3.3.0 → 3.3.3
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 -0
- package/dist/bin/cli.js +284 -142
- 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/KnowledgeSyncService.d.ts +26 -0
- package/dist/lib/cli/KnowledgeSyncService.js +33 -1
- package/dist/lib/cli/deploy/FileManifest.d.ts +0 -21
- package/dist/lib/cli/deploy/FileManifest.js +0 -11
- 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/browse.d.ts +1 -0
- package/dist/lib/external/mcp/handlers/browse.js +2 -1
- package/dist/lib/external/mcp/handlers/consolidated.d.ts +117 -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 +239 -5
- 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 +218 -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 +18 -24
- package/dist/lib/external/mcp/tools.js +132 -159
- package/dist/lib/http/HttpServer.js +52 -0
- package/dist/lib/http/middleware/validate.js +7 -3
- package/dist/lib/http/routes/audit.d.ts +8 -0
- package/dist/lib/http/routes/audit.js +51 -0
- 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/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 +202 -504
- package/dist/lib/infrastructure/database/drizzle/schema.js +38 -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/database/migrations/005_recipe_source_refs.d.ts +9 -0
- package/dist/lib/infrastructure/database/migrations/005_recipe_source_refs.js +24 -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/infrastructure/vector/HnswVectorAdapter.js +18 -2
- package/dist/lib/injection/ServiceContainer.js +8 -0
- package/dist/lib/injection/ServiceMap.d.ts +16 -10
- 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 +1 -1
- package/dist/lib/injection/modules/AppModule.js +4 -13
- package/dist/lib/injection/modules/GuardModule.js +27 -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.d.ts +5 -0
- package/dist/lib/injection/modules/KnowledgeModule.js +131 -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/bootstrap/UiStartupTasks.d.ts +45 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.js +101 -0
- 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 +42 -0
- package/dist/lib/service/guard/GuardCheckEngine.js +465 -14
- 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/knowledge/SourceRefReconciler.d.ts +68 -0
- package/dist/lib/service/knowledge/SourceRefReconciler.js +309 -0
- 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 +125 -0
- package/dist/lib/service/panorama/PanoramaService.js +363 -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/BM25Scorer.d.ts +2 -2
- package/dist/lib/service/search/CoarseRanker.d.ts +7 -6
- package/dist/lib/service/search/CoarseRanker.js +11 -10
- package/dist/lib/service/search/FieldWeightedScorer.d.ts +81 -0
- package/dist/lib/service/search/FieldWeightedScorer.js +318 -0
- package/dist/lib/service/search/MultiSignalRanker.d.ts +3 -2
- package/dist/lib/service/search/MultiSignalRanker.js +17 -1
- package/dist/lib/service/search/SearchEngine.d.ts +9 -7
- package/dist/lib/service/search/SearchEngine.js +67 -10
- package/dist/lib/service/search/SearchTypes.d.ts +25 -3
- package/dist/lib/service/search/SearchTypes.js +6 -1
- 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 +66 -0
- package/dist/lib/service/task/IntentExtractor.js +256 -0
- package/dist/lib/service/task/PrimeSearchPipeline.d.ts +54 -0
- package/dist/lib/service/task/PrimeSearchPipeline.js +113 -0
- package/dist/lib/service/vector/VectorService.d.ts +3 -0
- package/dist/lib/service/vector/VectorService.js +38 -4
- 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/package.json +1 -1
- package/skills/autosnippet-create/SKILL.md +98 -89
- package/skills/autosnippet-devdocs/SKILL.md +55 -57
- package/templates/claude-code/hooks/autosnippet-session.sh +10 -15
- package/templates/cursor-hooks/hooks/session-start.sh +1 -1
- package/templates/guard-ci.yml +2 -2
- package/templates/instructions/agent-static.md +2 -1
- package/templates/instructions/conventions.md +5 -6
- package/templates/recipes-setup/README.md +1 -2
- package/templates/recipes-setup/_template.md +39 -39
- package/dashboard/dist/assets/icons-BofcEZ3f.js +0 -1
- package/dashboard/dist/assets/index-D0whuycy.css +0 -1
- package/dashboard/dist/assets/index-SiN1GChm.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/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/repository/task/TaskRepository.impl.d.ts +0 -171
- package/dist/lib/repository/task/TaskRepository.impl.js +0 -347
- 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
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
* Stats — 统计值对象
|
|
3
3
|
*
|
|
4
4
|
* 记录知识条目的使用统计:浏览、采用、应用、Guard 命中、搜索命中、权威分。
|
|
5
|
+
*
|
|
6
|
+
* Phase 0 扩展:新增时间戳、滑窗统计、版本号、FP 率字段。
|
|
7
|
+
* 新字段均有默认值,与旧 JSON 100% 向后兼容。
|
|
5
8
|
*/
|
|
6
9
|
type StatsCounter = 'views' | 'adoptions' | 'applications' | 'guardHits' | 'searchHits';
|
|
7
10
|
interface StatsProps {
|
|
@@ -11,6 +14,14 @@ interface StatsProps {
|
|
|
11
14
|
guardHits?: number;
|
|
12
15
|
searchHits?: number;
|
|
13
16
|
authority?: number;
|
|
17
|
+
lastHitAt?: number | null;
|
|
18
|
+
lastSearchedAt?: number | null;
|
|
19
|
+
lastGuardHitAt?: number | null;
|
|
20
|
+
hitsLast30d?: number;
|
|
21
|
+
hitsLast90d?: number;
|
|
22
|
+
searchHitsLast30d?: number;
|
|
23
|
+
version?: number;
|
|
24
|
+
ruleFalsePositiveRate?: number | null;
|
|
14
25
|
}
|
|
15
26
|
export declare class Stats {
|
|
16
27
|
adoptions: number;
|
|
@@ -19,11 +30,21 @@ export declare class Stats {
|
|
|
19
30
|
guardHits: number;
|
|
20
31
|
searchHits: number;
|
|
21
32
|
views: number;
|
|
33
|
+
lastHitAt: number | null;
|
|
34
|
+
lastSearchedAt: number | null;
|
|
35
|
+
lastGuardHitAt: number | null;
|
|
36
|
+
hitsLast30d: number;
|
|
37
|
+
hitsLast90d: number;
|
|
38
|
+
searchHitsLast30d: number;
|
|
39
|
+
version: number;
|
|
40
|
+
ruleFalsePositiveRate: number | null;
|
|
22
41
|
constructor(props?: StatsProps);
|
|
23
42
|
/** 从任意输入构造 Stats */
|
|
24
43
|
static from(input: unknown): Stats;
|
|
25
44
|
/** 增加计数 */
|
|
26
45
|
increment(counter: StatsCounter, delta?: number): Stats;
|
|
46
|
+
/** 记录一次命中,同时更新时间戳 */
|
|
47
|
+
recordHit(counter: StatsCounter, timestamp?: number): Stats;
|
|
27
48
|
/** 转换为 JSON */
|
|
28
49
|
toJSON(): {
|
|
29
50
|
views: number;
|
|
@@ -32,6 +53,14 @@ export declare class Stats {
|
|
|
32
53
|
guardHits: number;
|
|
33
54
|
searchHits: number;
|
|
34
55
|
authority: number;
|
|
56
|
+
lastHitAt: number | null;
|
|
57
|
+
lastSearchedAt: number | null;
|
|
58
|
+
lastGuardHitAt: number | null;
|
|
59
|
+
hitsLast30d: number;
|
|
60
|
+
hitsLast90d: number;
|
|
61
|
+
searchHitsLast30d: number;
|
|
62
|
+
version: number;
|
|
63
|
+
ruleFalsePositiveRate: number | null;
|
|
35
64
|
};
|
|
36
65
|
/** 从 wire format 创建 */
|
|
37
66
|
static fromJSON(data: unknown): Stats;
|
|
@@ -5,6 +5,18 @@ export class Stats {
|
|
|
5
5
|
guardHits;
|
|
6
6
|
searchHits;
|
|
7
7
|
views;
|
|
8
|
+
// Phase 0: 时间戳 —— "最后一次被使用是什么时候"
|
|
9
|
+
lastHitAt;
|
|
10
|
+
lastSearchedAt;
|
|
11
|
+
lastGuardHitAt;
|
|
12
|
+
// Phase 0: 滑窗统计 —— "最近趋势如何"
|
|
13
|
+
hitsLast30d;
|
|
14
|
+
hitsLast90d;
|
|
15
|
+
searchHitsLast30d;
|
|
16
|
+
// Phase 0: 版本 —— "这条知识更新了几次"
|
|
17
|
+
version;
|
|
18
|
+
// Phase 0: 精度 (仅 kind=rule)
|
|
19
|
+
ruleFalsePositiveRate;
|
|
8
20
|
constructor(props = {}) {
|
|
9
21
|
/** 浏览次数 */
|
|
10
22
|
this.views = props.views ?? 0;
|
|
@@ -18,6 +30,15 @@ export class Stats {
|
|
|
18
30
|
this.searchHits = props.searchHits ?? 0;
|
|
19
31
|
/** 权威分 0-5 */
|
|
20
32
|
this.authority = props.authority ?? 0;
|
|
33
|
+
// Phase 0 扩展字段(旧 JSON 无这些字段时取默认值)
|
|
34
|
+
this.lastHitAt = props.lastHitAt ?? null;
|
|
35
|
+
this.lastSearchedAt = props.lastSearchedAt ?? null;
|
|
36
|
+
this.lastGuardHitAt = props.lastGuardHitAt ?? null;
|
|
37
|
+
this.hitsLast30d = props.hitsLast30d ?? 0;
|
|
38
|
+
this.hitsLast90d = props.hitsLast90d ?? 0;
|
|
39
|
+
this.searchHitsLast30d = props.searchHitsLast30d ?? 0;
|
|
40
|
+
this.version = props.version ?? 1;
|
|
41
|
+
this.ruleFalsePositiveRate = props.ruleFalsePositiveRate ?? null;
|
|
21
42
|
}
|
|
22
43
|
/** 从任意输入构造 Stats */
|
|
23
44
|
static from(input) {
|
|
@@ -39,6 +60,18 @@ export class Stats {
|
|
|
39
60
|
this[counter] += delta;
|
|
40
61
|
return this;
|
|
41
62
|
}
|
|
63
|
+
/** 记录一次命中,同时更新时间戳 */
|
|
64
|
+
recordHit(counter, timestamp = Date.now()) {
|
|
65
|
+
this[counter] += 1;
|
|
66
|
+
this.lastHitAt = timestamp;
|
|
67
|
+
if (counter === 'searchHits') {
|
|
68
|
+
this.lastSearchedAt = timestamp;
|
|
69
|
+
}
|
|
70
|
+
if (counter === 'guardHits') {
|
|
71
|
+
this.lastGuardHitAt = timestamp;
|
|
72
|
+
}
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
42
75
|
/** 转换为 JSON */
|
|
43
76
|
toJSON() {
|
|
44
77
|
return {
|
|
@@ -48,6 +81,14 @@ export class Stats {
|
|
|
48
81
|
guardHits: this.guardHits,
|
|
49
82
|
searchHits: this.searchHits,
|
|
50
83
|
authority: this.authority,
|
|
84
|
+
lastHitAt: this.lastHitAt,
|
|
85
|
+
lastSearchedAt: this.lastSearchedAt,
|
|
86
|
+
lastGuardHitAt: this.lastGuardHitAt,
|
|
87
|
+
hitsLast30d: this.hitsLast30d,
|
|
88
|
+
hitsLast90d: this.hitsLast90d,
|
|
89
|
+
searchHitsLast30d: this.searchHitsLast30d,
|
|
90
|
+
version: this.version,
|
|
91
|
+
ruleFalsePositiveRate: this.ruleFalsePositiveRate,
|
|
51
92
|
};
|
|
52
93
|
}
|
|
53
94
|
/** 从 wire format 创建 */
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Model Context Protocol (stdio transport)
|
|
5
5
|
* 提供给 IDE AI Agent (Cursor/VSCode Copilot) 的工具集
|
|
6
6
|
*
|
|
7
|
-
* V3.
|
|
7
|
+
* V3.3 整合:39 → 16 工具(14 agent + 2 admin)
|
|
8
8
|
* 通过 ASD_MCP_TIER 环境变量控制可见工具集(agent/admin)
|
|
9
9
|
*
|
|
10
10
|
* 冷启动双路径:
|
|
11
|
-
* - 外部 Agent 路径: bootstrap (Mission Briefing) → dimension_complete × N →
|
|
11
|
+
* - 外部 Agent 路径: bootstrap (Mission Briefing) → dimension_complete × N → wiki(plan) → wiki(finalize)
|
|
12
12
|
* - 内部 Agent 路径: bootstrap.js bootstrapKnowledge() → orchestrator.js AI pipeline (Phase 5)
|
|
13
13
|
*
|
|
14
14
|
* Gateway 权限 gating: 写操作经过 Gateway 权限/宪法/审计检查(支持动态 resolver)
|
|
@@ -21,27 +21,15 @@
|
|
|
21
21
|
import { McpServer as SdkMcpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
22
22
|
import { CapabilityProbe } from '#core/capability/CapabilityProbe.js';
|
|
23
23
|
import Logger from '#infra/logging/Logger.js';
|
|
24
|
-
import type { McpContext, McpServiceContainer } from './handlers/types.js';
|
|
25
|
-
/**
|
|
26
|
-
interface DecisionEntry {
|
|
27
|
-
id: string;
|
|
28
|
-
title: string;
|
|
29
|
-
}
|
|
30
|
-
/** Decision cache structure */
|
|
31
|
-
interface DecisionCache {
|
|
32
|
-
decisions: DecisionEntry[];
|
|
33
|
-
fetchedAt: number;
|
|
34
|
-
ttl: number;
|
|
35
|
-
_pending: Promise<DecisionEntry[]> | null;
|
|
36
|
-
}
|
|
37
|
-
/** MCP session tracking */
|
|
24
|
+
import type { IntentState, McpContext, McpServiceContainer } from './handlers/types.js';
|
|
25
|
+
/** MCP session tracking (with intent lifecycle) */
|
|
38
26
|
interface McpSession {
|
|
39
27
|
id: string;
|
|
40
28
|
startedAt: number;
|
|
41
|
-
readyCalled: boolean;
|
|
42
29
|
toolCallCount: number;
|
|
43
30
|
toolsUsed: Set<string>;
|
|
44
31
|
lastActivityAt: number;
|
|
32
|
+
intent: IntentState;
|
|
45
33
|
}
|
|
46
34
|
/** McpServer constructor options */
|
|
47
35
|
interface McpServerOptions {
|
|
@@ -60,7 +48,6 @@ export declare class McpServer {
|
|
|
60
48
|
logger: ReturnType<typeof Logger.getInstance>;
|
|
61
49
|
_autoApproveMarked: boolean;
|
|
62
50
|
_capabilityProbe: CapabilityProbe | null;
|
|
63
|
-
_decisionCache: DecisionCache;
|
|
64
51
|
_lastTaskOperation: string;
|
|
65
52
|
_session: McpSession;
|
|
66
53
|
_startedAt: number;
|
|
@@ -82,30 +69,24 @@ export declare class McpServer {
|
|
|
82
69
|
_registerHandlers(): void;
|
|
83
70
|
_handleToolCall(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
84
71
|
/**
|
|
85
|
-
*
|
|
72
|
+
* Post-tool-call hook: update session stats + intent behavior tracking.
|
|
73
|
+
* Always called (non-blocking, synchronous).
|
|
86
74
|
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* - decision 写操作 (record/revise/unpin): invalidate 缓存(下次查询拉最新)
|
|
90
|
-
* - 其他工具: 注入 _activeDecisions 摘要
|
|
91
|
-
* - 首次未调 prime 的工具: 注入更强提醒
|
|
92
|
-
*
|
|
93
|
-
* @param result handler 返回的 envelope 对象
|
|
94
|
-
*/
|
|
95
|
-
_injectDecisions(toolName: string, result: unknown): Promise<unknown>;
|
|
96
|
-
/**
|
|
97
|
-
* 获取 decisions 摘要(带缓存 + 防并发)
|
|
98
|
-
* @returns >>}
|
|
75
|
+
* - Session stats: toolCallCount, toolsUsed, lastActivityAt
|
|
76
|
+
* - Intent tracking (when active): toolCalls, searchQueries, mentionedFiles, drift detection
|
|
99
77
|
*/
|
|
100
|
-
|
|
78
|
+
_trackSession(toolName: string, result: unknown): void;
|
|
101
79
|
/**
|
|
102
|
-
*
|
|
80
|
+
* Inject active decisions + intent context into tool results.
|
|
81
|
+
* Currently deferred — enable by uncommenting the call in _handleToolCall.
|
|
103
82
|
*/
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
83
|
+
_injectDecisions(toolName: string, result: unknown): Promise<unknown>;
|
|
84
|
+
private _detectDrift;
|
|
85
|
+
private _computeKeywordOverlap;
|
|
86
|
+
private _computeOverlap;
|
|
87
|
+
private _extractSearchQuery;
|
|
88
|
+
private _extractMentionedFiles;
|
|
89
|
+
private _inferModule;
|
|
109
90
|
/**
|
|
110
91
|
* 解析工具名到 handler 函数(V3 整合版)
|
|
111
92
|
*/
|
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Model Context Protocol (stdio transport)
|
|
5
5
|
* 提供给 IDE AI Agent (Cursor/VSCode Copilot) 的工具集
|
|
6
6
|
*
|
|
7
|
-
* V3.
|
|
7
|
+
* V3.3 整合:39 → 16 工具(14 agent + 2 admin)
|
|
8
8
|
* 通过 ASD_MCP_TIER 环境变量控制可见工具集(agent/admin)
|
|
9
9
|
*
|
|
10
10
|
* 冷启动双路径:
|
|
11
|
-
* - 外部 Agent 路径: bootstrap (Mission Briefing) → dimension_complete × N →
|
|
11
|
+
* - 外部 Agent 路径: bootstrap (Mission Briefing) → dimension_complete × N → wiki(plan) → wiki(finalize)
|
|
12
12
|
* - 内部 Agent 路径: bootstrap.js bootstrapKnowledge() → orchestrator.js AI pipeline (Phase 5)
|
|
13
13
|
*
|
|
14
14
|
* Gateway 权限 gating: 写操作经过 Gateway 权限/宪法/审计检查(支持动态 resolver)
|
|
@@ -26,6 +26,7 @@ import Logger from '#infra/logging/Logger.js';
|
|
|
26
26
|
import { applyPendingAutoApprove, markAutoApproveNeeded } from './autoApproveInjector.js';
|
|
27
27
|
import { envelope } from './envelope.js';
|
|
28
28
|
import { wrapHandler } from './errorHandler.js';
|
|
29
|
+
import { createIdleIntent } from './handlers/types.js';
|
|
29
30
|
import { TIER_ORDER, TOOL_GATEWAY_MAP, TOOLS } from './tools.js';
|
|
30
31
|
// ─── Handler 模块 ─────────────────────────────────────────────
|
|
31
32
|
import * as candidateHandlers from './handlers/candidate.js';
|
|
@@ -35,15 +36,15 @@ import * as systemHandlers from './handlers/system.js';
|
|
|
35
36
|
// ─── External Agent Bootstrap 新 handler ──────────────────────
|
|
36
37
|
import { bootstrapExternal } from './handlers/bootstrap-external.js';
|
|
37
38
|
import { dimensionComplete } from './handlers/dimension-complete-external.js';
|
|
39
|
+
import { panoramaHandler } from './handlers/panorama.js';
|
|
38
40
|
import { taskHandler } from './handlers/task.js';
|
|
39
|
-
import {
|
|
41
|
+
import { wikiRouter } from './handlers/wiki-external.js';
|
|
40
42
|
// ─── McpServer 类 ─────────────────────────────────────────────
|
|
41
43
|
export class McpServer {
|
|
42
44
|
container;
|
|
43
45
|
logger;
|
|
44
46
|
_autoApproveMarked;
|
|
45
47
|
_capabilityProbe;
|
|
46
|
-
_decisionCache;
|
|
47
48
|
_lastTaskOperation;
|
|
48
49
|
_session;
|
|
49
50
|
_startedAt;
|
|
@@ -58,21 +59,14 @@ export class McpServer {
|
|
|
58
59
|
this._autoApproveMarked = false;
|
|
59
60
|
this._capabilityProbe = null;
|
|
60
61
|
this._lastTaskOperation = '';
|
|
61
|
-
// ──
|
|
62
|
-
this._decisionCache = {
|
|
63
|
-
decisions: [], // [{ id, title }]
|
|
64
|
-
fetchedAt: 0, // timestamp ms
|
|
65
|
-
ttl: 60_000, // 60s TTL
|
|
66
|
-
_pending: null, // 防并发重复查询的 pending promise
|
|
67
|
-
};
|
|
68
|
-
// ── P3: Session 管理 ──
|
|
62
|
+
// ── Session 管理 (with intent lifecycle) ──
|
|
69
63
|
this._session = {
|
|
70
64
|
id: `ses-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
|
|
71
65
|
startedAt: Date.now(),
|
|
72
|
-
readyCalled: false,
|
|
73
66
|
toolCallCount: 0,
|
|
74
67
|
toolsUsed: new Set(),
|
|
75
68
|
lastActivityAt: Date.now(),
|
|
69
|
+
intent: createIdleIntent(),
|
|
76
70
|
};
|
|
77
71
|
}
|
|
78
72
|
/** 共享上下文对象,传给所有 handler */
|
|
@@ -174,8 +168,10 @@ export class McpServer {
|
|
|
174
168
|
this._lastTaskOperation = args.operation || '';
|
|
175
169
|
}
|
|
176
170
|
const result = await wrapped(ctx, args);
|
|
177
|
-
// ──
|
|
178
|
-
|
|
171
|
+
// ── Session 追踪 + 行为采集 ──
|
|
172
|
+
this._trackSession(name, result);
|
|
173
|
+
// ── [DEFERRED] Decision 注入(待 JSONL 数据验证后启用) ──
|
|
174
|
+
// await this._injectDecisions(name, result);
|
|
179
175
|
// ── 首次成功 tool call → 标记 autoApprove(one-shot) ──
|
|
180
176
|
// 用户已手动授权了至少一个工具,标记后下次 MCP 启动注入 autoApprove
|
|
181
177
|
if (!this._autoApproveMarked) {
|
|
@@ -190,135 +186,171 @@ export class McpServer {
|
|
|
190
186
|
}
|
|
191
187
|
return result;
|
|
192
188
|
}
|
|
193
|
-
// ───
|
|
189
|
+
// ─── Session tracking + behavior collection ─────────────
|
|
194
190
|
/**
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
* 策略:
|
|
198
|
-
* - prime: 刷新缓存,不额外注入(response 本身含 decisions)
|
|
199
|
-
* - decision 写操作 (record/revise/unpin): invalidate 缓存(下次查询拉最新)
|
|
200
|
-
* - 其他工具: 注入 _activeDecisions 摘要
|
|
201
|
-
* - 首次未调 prime 的工具: 注入更强提醒
|
|
191
|
+
* Post-tool-call hook: update session stats + intent behavior tracking.
|
|
192
|
+
* Always called (non-blocking, synchronous).
|
|
202
193
|
*
|
|
203
|
-
*
|
|
194
|
+
* - Session stats: toolCallCount, toolsUsed, lastActivityAt
|
|
195
|
+
* - Intent tracking (when active): toolCalls, searchQueries, mentionedFiles, drift detection
|
|
204
196
|
*/
|
|
205
|
-
|
|
206
|
-
// ──
|
|
197
|
+
_trackSession(toolName, result) {
|
|
198
|
+
// ── Session stats (always) ──
|
|
207
199
|
this._session.toolCallCount++;
|
|
208
200
|
this._session.toolsUsed.add(toolName);
|
|
209
201
|
this._session.lastActivityAt = Date.now();
|
|
210
|
-
//
|
|
202
|
+
// Task handler manages IntentState internally — skip behavior tracking
|
|
211
203
|
if (toolName === 'autosnippet_task') {
|
|
212
|
-
|
|
213
|
-
if (op === 'prime') {
|
|
214
|
-
this._session.readyCalled = true;
|
|
215
|
-
this._refreshCacheFromReady(result);
|
|
216
|
-
}
|
|
217
|
-
else if (['record_decision', 'revise_decision', 'unpin_decision'].includes(op)) {
|
|
218
|
-
this._decisionCache.fetchedAt = 0;
|
|
219
|
-
this._decisionCache._pending = null;
|
|
220
|
-
}
|
|
221
|
-
return result;
|
|
204
|
+
return;
|
|
222
205
|
}
|
|
223
|
-
//
|
|
224
|
-
const
|
|
225
|
-
if (
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
206
|
+
// ── Intent behavior tracking (active intent only) ──
|
|
207
|
+
const intent = this._session.intent;
|
|
208
|
+
if (intent.phase !== 'active') {
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
// Track tool call
|
|
212
|
+
intent.toolCalls.push({
|
|
213
|
+
tool: toolName,
|
|
214
|
+
timestamp: Date.now(),
|
|
215
|
+
args_summary: toolName,
|
|
216
|
+
});
|
|
217
|
+
// Auto-collect search queries
|
|
218
|
+
if (toolName === 'autosnippet_search') {
|
|
219
|
+
const query = this._extractSearchQuery(result);
|
|
220
|
+
if (query) {
|
|
221
|
+
intent.searchQueries.push(query);
|
|
233
222
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
223
|
+
}
|
|
224
|
+
// Auto-collect mentioned files
|
|
225
|
+
const files = this._extractMentionedFiles(toolName, result);
|
|
226
|
+
for (const f of files) {
|
|
227
|
+
if (!intent.mentionedFiles.includes(f)) {
|
|
228
|
+
intent.mentionedFiles.push(f);
|
|
229
|
+
const mod = this._inferModule(f);
|
|
230
|
+
if (mod) {
|
|
231
|
+
intent.mentionedModules.add(mod);
|
|
232
|
+
}
|
|
237
233
|
}
|
|
238
234
|
}
|
|
239
|
-
|
|
235
|
+
// Drift detection
|
|
236
|
+
this._detectDrift(toolName, intent);
|
|
240
237
|
}
|
|
238
|
+
// ─── [DEFERRED] Decision injection ───────────────────────
|
|
241
239
|
/**
|
|
242
|
-
*
|
|
243
|
-
*
|
|
240
|
+
* Inject active decisions + intent context into tool results.
|
|
241
|
+
* Currently deferred — enable by uncommenting the call in _handleToolCall.
|
|
244
242
|
*/
|
|
245
|
-
async
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
// 缓存有效(包括缓存了"空 decisions"的情况),直接返回
|
|
249
|
-
if (cache.fetchedAt > 0 && now - cache.fetchedAt < cache.ttl) {
|
|
250
|
-
return cache.decisions;
|
|
243
|
+
async _injectDecisions(toolName, result) {
|
|
244
|
+
if (toolName === 'autosnippet_task') {
|
|
245
|
+
return result;
|
|
251
246
|
}
|
|
252
|
-
|
|
253
|
-
if (
|
|
254
|
-
|
|
255
|
-
|
|
247
|
+
const intent = this._session.intent;
|
|
248
|
+
if (intent.phase !== 'active') {
|
|
249
|
+
return result;
|
|
250
|
+
}
|
|
251
|
+
if (intent.decisions.length > 0 && typeof result === 'object' && result !== null) {
|
|
252
|
+
const resultObj = result;
|
|
253
|
+
resultObj._activeDecisions = intent.decisions.map((d) => ({
|
|
254
|
+
id: d.id,
|
|
255
|
+
title: d.title,
|
|
256
|
+
}));
|
|
257
|
+
resultObj._intentContext =
|
|
258
|
+
`Active intent: "${intent.primeQuery || '(no query)'}"` +
|
|
259
|
+
(intent.taskId ? ` | Task: ${intent.taskId}` : '') +
|
|
260
|
+
` | ${intent.toolCalls.length} tool calls | ${intent.decisions.length} decision(s)`;
|
|
261
|
+
}
|
|
262
|
+
return result;
|
|
263
|
+
}
|
|
264
|
+
// ─── Drift detection helpers ───────────────────
|
|
265
|
+
_detectDrift(toolName, intent) {
|
|
266
|
+
for (const mod of intent.mentionedModules) {
|
|
267
|
+
if (intent.primeModule && mod !== intent.primeModule) {
|
|
268
|
+
const alreadyDrifted = intent.driftEvents.some((d) => d.type === 'new_module' && d.detail.includes(mod));
|
|
269
|
+
if (!alreadyDrifted) {
|
|
270
|
+
intent.driftEvents.push({
|
|
271
|
+
timestamp: Date.now(),
|
|
272
|
+
trigger: toolName,
|
|
273
|
+
type: 'new_module',
|
|
274
|
+
detail: `New module: ${mod} (prime: ${intent.primeModule})`,
|
|
275
|
+
primeOverlap: this._computeOverlap(mod, intent.primeQuery),
|
|
276
|
+
});
|
|
277
|
+
}
|
|
256
278
|
}
|
|
257
|
-
|
|
258
|
-
|
|
279
|
+
}
|
|
280
|
+
if (toolName === 'autosnippet_search' && intent.searchQueries.length > 0) {
|
|
281
|
+
const latestQuery = intent.searchQueries[intent.searchQueries.length - 1];
|
|
282
|
+
const overlap = this._computeKeywordOverlap(latestQuery, intent.primeQuery);
|
|
283
|
+
if (overlap < 0.3) {
|
|
284
|
+
intent.driftEvents.push({
|
|
285
|
+
timestamp: Date.now(),
|
|
286
|
+
trigger: toolName,
|
|
287
|
+
type: 'search_shift',
|
|
288
|
+
detail: `Search drift: "${latestQuery.slice(0, 40)}" (overlap: ${Math.round(overlap * 100)}%)`,
|
|
289
|
+
primeOverlap: overlap,
|
|
290
|
+
});
|
|
259
291
|
}
|
|
260
292
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
return result;
|
|
293
|
+
}
|
|
294
|
+
_computeKeywordOverlap(a, b) {
|
|
295
|
+
if (!a || !b) {
|
|
296
|
+
return 0;
|
|
266
297
|
}
|
|
267
|
-
|
|
268
|
-
|
|
298
|
+
const tokensA = new Set(a
|
|
299
|
+
.toLowerCase()
|
|
300
|
+
.split(/[\s,./\\|]+/)
|
|
301
|
+
.filter((t) => t.length > 1));
|
|
302
|
+
const tokensB = new Set(b
|
|
303
|
+
.toLowerCase()
|
|
304
|
+
.split(/[\s,./\\|]+/)
|
|
305
|
+
.filter((t) => t.length > 1));
|
|
306
|
+
if (tokensA.size === 0 || tokensB.size === 0) {
|
|
307
|
+
return 0;
|
|
269
308
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
async _fetchDecisionsSummary() {
|
|
275
|
-
const cache = this._decisionCache;
|
|
276
|
-
try {
|
|
277
|
-
const taskService = this.container?.get('taskGraphService');
|
|
278
|
-
if (!taskService) {
|
|
279
|
-
return cache.decisions;
|
|
309
|
+
let shared = 0;
|
|
310
|
+
for (const t of tokensA) {
|
|
311
|
+
if (tokensB.has(t)) {
|
|
312
|
+
shared++;
|
|
280
313
|
}
|
|
281
|
-
// 使用 service 公共 API(不直接访问 repo)
|
|
282
|
-
const pinned = await taskService.list({ status: 'pinned', taskType: 'decision' }, { limit: 50 });
|
|
283
|
-
cache.decisions = pinned.map((d) => ({
|
|
284
|
-
id: d.id,
|
|
285
|
-
title: d.title,
|
|
286
|
-
}));
|
|
287
|
-
cache.fetchedAt = Date.now();
|
|
288
314
|
}
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
315
|
+
return shared / Math.max(tokensA.size, tokensB.size);
|
|
316
|
+
}
|
|
317
|
+
_computeOverlap(term, query) {
|
|
318
|
+
if (!term || !query) {
|
|
319
|
+
return 0;
|
|
293
320
|
}
|
|
294
|
-
return
|
|
321
|
+
return query.toLowerCase().includes(term.toLowerCase()) ? 1 : 0;
|
|
295
322
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
const data = readyResult?.data;
|
|
303
|
-
const decisions = (data?.decisions || []);
|
|
304
|
-
this._decisionCache.decisions = decisions.map((d) => ({
|
|
305
|
-
id: d.id,
|
|
306
|
-
title: d.title,
|
|
307
|
-
}));
|
|
308
|
-
this._decisionCache.fetchedAt = Date.now();
|
|
323
|
+
_extractSearchQuery(result) {
|
|
324
|
+
if (typeof result === 'object' && result !== null) {
|
|
325
|
+
const obj = result;
|
|
326
|
+
if (typeof obj.query === 'string') {
|
|
327
|
+
return obj.query;
|
|
328
|
+
}
|
|
309
329
|
}
|
|
310
|
-
|
|
311
|
-
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
_extractMentionedFiles(_toolName, result) {
|
|
333
|
+
if (typeof result === 'object' && result !== null) {
|
|
334
|
+
const obj = result;
|
|
335
|
+
const files = obj.files || obj.mentionedFiles;
|
|
336
|
+
if (Array.isArray(files)) {
|
|
337
|
+
return files.filter((f) => typeof f === 'string');
|
|
338
|
+
}
|
|
312
339
|
}
|
|
340
|
+
return [];
|
|
341
|
+
}
|
|
342
|
+
_inferModule(filePath) {
|
|
343
|
+
const parts = filePath.replace(/\\/g, '/').split('/');
|
|
344
|
+
const meaningful = parts.slice(1, -1).filter((p) => !['src', 'lib', 'Sources'].includes(p));
|
|
345
|
+
return meaningful.slice(0, 2).join('/') || null;
|
|
313
346
|
}
|
|
314
347
|
/**
|
|
315
348
|
* 解析工具名到 handler 函数(V3 整合版)
|
|
316
349
|
*/
|
|
317
350
|
_resolveHandler(name) {
|
|
318
351
|
const HANDLER_MAP = {
|
|
319
|
-
// ── Agent 层
|
|
352
|
+
// ── Agent 层 ──
|
|
320
353
|
autosnippet_health: (ctx) => systemHandlers.health(ctx),
|
|
321
|
-
autosnippet_capabilities: () => systemHandlers.capabilities(),
|
|
322
354
|
autosnippet_search: (ctx, args) => consolidated.consolidatedSearch(ctx, args),
|
|
323
355
|
autosnippet_knowledge: (ctx, args) => consolidated.consolidatedKnowledge(ctx, args),
|
|
324
356
|
autosnippet_structure: (ctx, args) => consolidated.consolidatedStructure(ctx, args),
|
|
@@ -326,20 +358,16 @@ export class McpServer {
|
|
|
326
358
|
autosnippet_graph: (ctx, args) => consolidated.consolidatedGraph(ctx, args),
|
|
327
359
|
autosnippet_guard: (ctx, args) => consolidated.consolidatedGuard(ctx, args),
|
|
328
360
|
autosnippet_submit_knowledge: (ctx, args) => consolidated.enhancedSubmitKnowledge(ctx, args),
|
|
329
|
-
autosnippet_submit_knowledge_batch: (ctx, args) => knowledgeHandlers.submitKnowledgeBatch(ctx, args),
|
|
330
|
-
autosnippet_save_document: (ctx, args) => knowledgeHandlers.saveDocument(ctx, args),
|
|
331
361
|
autosnippet_skill: (ctx, args) => consolidated.consolidatedSkill(ctx, args),
|
|
332
362
|
autosnippet_task: (ctx, args) => taskHandler(ctx, args),
|
|
363
|
+
autosnippet_panorama: (ctx, args) => panoramaHandler(ctx, args),
|
|
333
364
|
// ── External Agent Bootstrap (v3.1) ──
|
|
334
365
|
autosnippet_bootstrap: (ctx, _args) => bootstrapExternal(ctx),
|
|
335
366
|
autosnippet_dimension_complete: (ctx, args) => dimensionComplete(ctx, args),
|
|
336
|
-
|
|
337
|
-
autosnippet_wiki_finalize: (ctx, args) => wikiFinalize(ctx, args),
|
|
367
|
+
autosnippet_wiki: (ctx, args) => wikiRouter(ctx, args),
|
|
338
368
|
// ── Admin 层 (+4) ──
|
|
339
369
|
autosnippet_enrich_candidates: (ctx, args) => candidateHandlers.enrichCandidates(ctx, args),
|
|
340
370
|
autosnippet_knowledge_lifecycle: (ctx, args) => knowledgeHandlers.knowledgeLifecycle(ctx, args),
|
|
341
|
-
autosnippet_validate_candidate: (ctx, args) => candidateHandlers.validateCandidate(ctx, args),
|
|
342
|
-
autosnippet_check_duplicate: (ctx, args) => candidateHandlers.checkDuplicate(ctx, args),
|
|
343
371
|
};
|
|
344
372
|
return HANDLER_MAP[name] ?? null;
|
|
345
373
|
}
|
|
@@ -252,6 +252,29 @@ interface MissionBriefing {
|
|
|
252
252
|
totalDimensions: number;
|
|
253
253
|
workflow: string;
|
|
254
254
|
};
|
|
255
|
+
panorama: {
|
|
256
|
+
layers: Array<{
|
|
257
|
+
level: number;
|
|
258
|
+
name: string;
|
|
259
|
+
modules: string[];
|
|
260
|
+
}>;
|
|
261
|
+
couplingHotspots: Array<{
|
|
262
|
+
module: string;
|
|
263
|
+
fanIn: number;
|
|
264
|
+
fanOut: number;
|
|
265
|
+
}>;
|
|
266
|
+
cyclicDependencies: Array<{
|
|
267
|
+
cycle: string[];
|
|
268
|
+
severity: string;
|
|
269
|
+
}>;
|
|
270
|
+
knowledgeGaps: Array<{
|
|
271
|
+
dimension: string;
|
|
272
|
+
dimensionName: string;
|
|
273
|
+
recipeCount: number;
|
|
274
|
+
status: string;
|
|
275
|
+
priority: string;
|
|
276
|
+
}>;
|
|
277
|
+
} | null;
|
|
255
278
|
session: Record<string, unknown>;
|
|
256
279
|
meta?: {
|
|
257
280
|
responseSizeKB: number;
|
|
@@ -276,6 +299,7 @@ interface MissionBriefingParams {
|
|
|
276
299
|
languageExtension?: unknown;
|
|
277
300
|
incrementalPlan?: IncrementalPlan | null;
|
|
278
301
|
languageStats?: Record<string, number> | null;
|
|
302
|
+
panoramaResult?: Record<string, unknown> | null;
|
|
279
303
|
}
|
|
280
304
|
/**
|
|
281
305
|
* 构建 Mission Briefing
|
|
@@ -293,5 +317,6 @@ interface MissionBriefingParams {
|
|
|
293
317
|
*/
|
|
294
318
|
export declare function buildMissionBriefing({ projectMeta, astData, codeEntityResult, callGraphResult, depGraphData, guardAudit, targets, activeDimensions, session, languageExtension, // §7.1: 语言扩展(反模式、Guard 规则、Agent 注意事项)
|
|
295
319
|
incrementalPlan, // §7.3: 增量 Bootstrap 评估结果
|
|
296
|
-
languageStats,
|
|
320
|
+
languageStats, // §7.4: 完整语言分布统计
|
|
321
|
+
panoramaResult, }: MissionBriefingParams): MissionBriefing;
|
|
297
322
|
export {};
|