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
|
@@ -1,268 +1,241 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* MCP
|
|
2
|
+
* MCP Tool Definitions — V3 Consolidated (14 agent + 2 admin = 16 tools)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
* description
|
|
6
|
-
* inputSchema
|
|
4
|
+
* Each tool declaration contains name, tier (agent/admin), description, and inputSchema.
|
|
5
|
+
* description is the key for Agent tool selection — use bullet list to enumerate all operations and their purposes.
|
|
6
|
+
* inputSchema is auto-generated from Zod Schema (zodToMcpSchema); parameter .describe() translates to JSON Schema description.
|
|
7
7
|
*
|
|
8
|
-
* Agent
|
|
9
|
-
* 1-7:
|
|
10
|
-
* 8
|
|
11
|
-
*
|
|
12
|
-
* 12
|
|
13
|
-
*
|
|
14
|
-
*
|
|
8
|
+
* Agent tools (14):
|
|
9
|
+
* 1-7: Query tools (health/search/knowledge/structure/graph/call_context/guard)
|
|
10
|
+
* 8: Write tool (submit_knowledge — unified pipeline, single/batch)
|
|
11
|
+
* 9: Skill management (skill)
|
|
12
|
+
* 10-12: Cold-start (bootstrap/dimension_complete/wiki)
|
|
13
|
+
* 13: Project panorama (panorama)
|
|
14
|
+
* 14: Task management (task — 5 ops: prime/create/close/fail/record_decision)
|
|
15
15
|
*
|
|
16
|
-
* Admin
|
|
17
|
-
*
|
|
16
|
+
* Admin tools (2):
|
|
17
|
+
* 15-16: enrich_candidates/knowledge_lifecycle
|
|
18
18
|
*/
|
|
19
|
-
import { BootstrapInput, CallContextInput,
|
|
19
|
+
import { BootstrapInput, CallContextInput, DimensionCompleteInput, EnrichCandidatesInput, GraphInput, GuardInput, HealthInput, KnowledgeInput, KnowledgeLifecycleInput, PanoramaInput, SearchInput, SkillInput, StructureInput, SubmitKnowledgeInput, TaskInput, WikiInput, } from '#shared/schemas/mcp-tools.js';
|
|
20
20
|
import { zodToMcpSchema } from './zodToMcpSchema.js';
|
|
21
|
-
// ─── Tier
|
|
21
|
+
// ─── Tier Definitions ────────────────────────────────────────
|
|
22
22
|
export const TIER_ORDER = { agent: 0, admin: 1 };
|
|
23
|
-
// ─── Gateway
|
|
23
|
+
// ─── Gateway Mapping (only write operations require gating) ─
|
|
24
24
|
export const TOOL_GATEWAY_MAP = {
|
|
25
|
-
// bootstrap —
|
|
25
|
+
// bootstrap — parameterless Mission Briefing (read-only analysis, no gating needed)
|
|
26
26
|
// autosnippet_bootstrap: null,
|
|
27
|
-
// dimension_complete —
|
|
27
|
+
// dimension_complete — write operation (recipe tagging + skill creation + checkpoint)
|
|
28
28
|
autosnippet_dimension_complete: { action: 'knowledge:bootstrap', resource: 'knowledge' },
|
|
29
|
-
//
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
// wiki — finalize is a write operation (meta.json)
|
|
30
|
+
autosnippet_wiki: {
|
|
31
|
+
resolver: (args) => args?.operation === 'finalize' ? { action: 'knowledge:create', resource: 'knowledge' } : null, // plan is read-only
|
|
32
|
+
},
|
|
33
|
+
// guard write operation (files mode only)
|
|
32
34
|
autosnippet_guard: {
|
|
33
35
|
resolver: (args) => args?.files && Array.isArray(args.files)
|
|
34
36
|
? { action: 'guard_rule:check_code', resource: 'guard_rules' }
|
|
35
|
-
: null, // code
|
|
37
|
+
: null, // code mode is read-only, skip Gateway
|
|
36
38
|
},
|
|
37
|
-
// skill
|
|
39
|
+
// skill write operations (create/update/delete)
|
|
38
40
|
autosnippet_skill: {
|
|
39
41
|
resolver: (args) => ({
|
|
40
42
|
create: { action: 'create:skills', resource: 'skills' },
|
|
41
43
|
update: { action: 'update:skills', resource: 'skills' },
|
|
42
44
|
delete: { action: 'delete:skills', resource: 'skills' },
|
|
43
|
-
})[args?.operation] || null, // list/load/suggest
|
|
45
|
+
})[args?.operation] || null, // list/load/suggest are read-only
|
|
44
46
|
},
|
|
45
|
-
//
|
|
47
|
+
// knowledge submission (unified pipeline)
|
|
46
48
|
autosnippet_submit_knowledge: { action: 'knowledge:create', resource: 'knowledge' },
|
|
47
|
-
|
|
48
|
-
autosnippet_save_document: { action: 'knowledge:create', resource: 'knowledge' },
|
|
49
|
-
// task 写操作(create/claim/close/fail/defer/decompose/dep_add + decision 写操作)
|
|
49
|
+
// task write operations (create/close/fail + record_decision)
|
|
50
50
|
autosnippet_task: {
|
|
51
51
|
resolver: (args) => ({
|
|
52
|
-
create: { action: 'task:create', resource: '
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
progress: { action: 'task:update', resource: 'tasks' },
|
|
58
|
-
decompose: { action: 'task:create', resource: 'tasks' },
|
|
59
|
-
dep_add: { action: 'task:update', resource: 'tasks' },
|
|
60
|
-
record_decision: { action: 'task:create', resource: 'tasks' },
|
|
61
|
-
revise_decision: { action: 'task:update', resource: 'tasks' },
|
|
62
|
-
unpin_decision: { action: 'task:update', resource: 'tasks' },
|
|
63
|
-
})[args?.operation] || null, // prime/ready/show/list/blocked/dep_tree/stats/list_decisions 只读
|
|
52
|
+
create: { action: 'task:create', resource: 'intent' },
|
|
53
|
+
close: { action: 'task:update', resource: 'intent' },
|
|
54
|
+
fail: { action: 'task:update', resource: 'intent' },
|
|
55
|
+
record_decision: { action: 'task:create', resource: 'intent' },
|
|
56
|
+
})[args?.operation] || null, // prime is read-only
|
|
64
57
|
},
|
|
65
|
-
// admin
|
|
58
|
+
// admin tools
|
|
66
59
|
autosnippet_enrich_candidates: { action: 'knowledge:update', resource: 'knowledge' },
|
|
67
60
|
autosnippet_knowledge_lifecycle: { action: 'knowledge:update', resource: 'knowledge' },
|
|
68
61
|
};
|
|
69
|
-
// ───
|
|
62
|
+
// ─── Tool Declarations ───────────────────────────────────────
|
|
70
63
|
export const TOOLS = [
|
|
71
64
|
// ══════════════════════════════════════════════════════
|
|
72
|
-
// Tier: agent — Agent
|
|
65
|
+
// Tier: agent — Core Agent Toolset (14)
|
|
73
66
|
// ══════════════════════════════════════════════════════
|
|
74
|
-
// 1.
|
|
67
|
+
// 1. Health Check
|
|
75
68
|
{
|
|
76
69
|
name: 'autosnippet_health',
|
|
77
70
|
tier: 'agent',
|
|
78
|
-
description: '
|
|
71
|
+
description: 'Check service status and knowledge base stats. Returns total (entry count) and kind/lifecycle distribution. When total=0, cold-start is needed (call autosnippet_bootstrap).',
|
|
79
72
|
inputSchema: zodToMcpSchema(HealthInput),
|
|
80
73
|
},
|
|
81
|
-
// 2.
|
|
74
|
+
// 2. Unified Search
|
|
82
75
|
{
|
|
83
76
|
name: 'autosnippet_search',
|
|
84
77
|
tier: 'agent',
|
|
85
|
-
description: '
|
|
86
|
-
'• auto
|
|
87
|
-
'• keyword —
|
|
88
|
-
'• bm25 —
|
|
89
|
-
'• semantic —
|
|
90
|
-
'• context —
|
|
91
|
-
'
|
|
78
|
+
description: 'Search the knowledge base. 5 modes:\n' +
|
|
79
|
+
'• auto (default) — automatically selects optimal strategy\n' +
|
|
80
|
+
'• keyword — exact keyword matching, best for trigger/title lookup\n' +
|
|
81
|
+
'• bm25 — full-text search, best for natural language descriptions\n' +
|
|
82
|
+
'• semantic — vector semantic search, best for fuzzy concept matching\n' +
|
|
83
|
+
'• context — combined search + context association, best for coding assistance\n' +
|
|
84
|
+
'Returns results grouped by kind (rule/pattern/fact).',
|
|
92
85
|
inputSchema: zodToMcpSchema(SearchInput),
|
|
93
86
|
},
|
|
94
|
-
// 3.
|
|
87
|
+
// 3. Knowledge Browser
|
|
95
88
|
{
|
|
96
89
|
name: 'autosnippet_knowledge',
|
|
97
90
|
tier: 'agent',
|
|
98
|
-
description: '
|
|
99
|
-
'• list —
|
|
100
|
-
'• get —
|
|
101
|
-
'• insights —
|
|
102
|
-
'• confirm_usage —
|
|
91
|
+
description: 'Knowledge entry management.\n' +
|
|
92
|
+
'• list — filter entries by kind/category/status\n' +
|
|
93
|
+
'• get — retrieve full content of a single entry (requires id)\n' +
|
|
94
|
+
'• insights — quality analysis and improvement suggestions (requires id)\n' +
|
|
95
|
+
'• confirm_usage — record that knowledge was actually adopted (requires id)',
|
|
103
96
|
inputSchema: zodToMcpSchema(KnowledgeInput),
|
|
104
97
|
},
|
|
105
|
-
// 4.
|
|
98
|
+
// 4. Project Structure
|
|
106
99
|
{
|
|
107
100
|
name: 'autosnippet_structure',
|
|
108
101
|
tier: 'agent',
|
|
109
|
-
description: '
|
|
110
|
-
'• targets —
|
|
111
|
-
'• files —
|
|
112
|
-
'• metadata —
|
|
102
|
+
description: 'Explore project structure.\n' +
|
|
103
|
+
'• targets — list build targets (modules/Targets/Packages)\n' +
|
|
104
|
+
'• files — list files for a specific Target\n' +
|
|
105
|
+
'• metadata — project metadata (language, dependencies, configuration)',
|
|
113
106
|
inputSchema: zodToMcpSchema(StructureInput),
|
|
114
107
|
},
|
|
115
|
-
// 5.
|
|
108
|
+
// 5. Knowledge Graph
|
|
116
109
|
{
|
|
117
110
|
name: 'autosnippet_graph',
|
|
118
111
|
tier: 'agent',
|
|
119
|
-
description: '
|
|
120
|
-
'• query —
|
|
121
|
-
'• impact —
|
|
122
|
-
'• path —
|
|
123
|
-
'• stats —
|
|
112
|
+
description: 'Knowledge relationship graph queries.\n' +
|
|
113
|
+
'• query — query relationships of a node\n' +
|
|
114
|
+
'• impact — analyze impact scope of modifying a knowledge entry\n' +
|
|
115
|
+
'• path — find relationship path between two knowledge nodes\n' +
|
|
116
|
+
'• stats — global graph statistics (nodes/edges/density)',
|
|
124
117
|
inputSchema: zodToMcpSchema(GraphInput),
|
|
125
118
|
},
|
|
126
|
-
// 6.
|
|
119
|
+
// 6. Call Context
|
|
127
120
|
{
|
|
128
121
|
name: 'autosnippet_call_context',
|
|
129
122
|
tier: 'agent',
|
|
130
|
-
description: '
|
|
131
|
-
'• callers —
|
|
132
|
-
'• callees —
|
|
133
|
-
'• impact —
|
|
134
|
-
'• both —
|
|
123
|
+
description: 'Query function/method call chains.\n' +
|
|
124
|
+
'• callers — who calls it (upstream call chain)\n' +
|
|
125
|
+
'• callees — what it calls (downstream dependency chain)\n' +
|
|
126
|
+
'• impact — modification impact radius (upstream + downstream + affected file count)\n' +
|
|
127
|
+
'• both — retrieve callers + callees simultaneously',
|
|
135
128
|
inputSchema: zodToMcpSchema(CallContextInput),
|
|
136
129
|
},
|
|
137
|
-
// 7. Guard
|
|
130
|
+
// 7. Guard Code Check
|
|
138
131
|
{
|
|
139
132
|
name: 'autosnippet_guard',
|
|
140
133
|
tier: 'agent',
|
|
141
|
-
description: '
|
|
142
|
-
'•
|
|
143
|
-
'• files →
|
|
144
|
-
'• code →
|
|
145
|
-
'
|
|
134
|
+
description: 'Code compliance check and Guard immune system.\n' +
|
|
135
|
+
'• no params → auto-check git diff incremental files (preferred after coding)\n' +
|
|
136
|
+
'• files → check specified file list\n' +
|
|
137
|
+
'• code → inline check code snippet\n' +
|
|
138
|
+
'• operation: "reverse_audit" → Recipe→Code reverse validation (check if knowledge is outdated)\n' +
|
|
139
|
+
'• operation: "coverage_matrix" → module-level Guard rule coverage matrix\n' +
|
|
140
|
+
'Each violation includes a fix guide (doClause + coreCode). Fix accordingly and re-check.',
|
|
146
141
|
inputSchema: zodToMcpSchema(GuardInput),
|
|
147
142
|
},
|
|
148
|
-
// 8.
|
|
143
|
+
// 8. Submit Knowledge (Unified Pipeline)
|
|
149
144
|
{
|
|
150
145
|
name: 'autosnippet_submit_knowledge',
|
|
151
146
|
tier: 'agent',
|
|
152
|
-
description: '
|
|
153
|
-
'
|
|
154
|
-
'
|
|
147
|
+
description: 'Submit knowledge entries (single/batch unified pipeline). Pass 1~N items via the items array.\n' +
|
|
148
|
+
'• All entries undergo strict validation; all V3 fields must be provided at once\n' +
|
|
149
|
+
'• Unified consolidation analysis: detects overlap with existing Recipes and batch candidates\n' +
|
|
150
|
+
'• Handle CONSOLIDATION_MERGE / CONSOLIDATION_REORGANIZE / CONSOLIDATION_INSUFFICIENT responses\n' +
|
|
151
|
+
'• Set skipConsolidation: true to skip consolidation check. content and reasoning must be objects.\n' +
|
|
152
|
+
'⚠️ Batch rule: items in the array must NOT be cross-redundant — no highly overlapping doClause/coreCode/trigger within the same batch. ' +
|
|
153
|
+
'If two entries share 80%+ content, merge into one or split into primary + extends supplementary entries.',
|
|
155
154
|
inputSchema: zodToMcpSchema(SubmitKnowledgeInput),
|
|
156
155
|
},
|
|
157
|
-
// 9.
|
|
158
|
-
{
|
|
159
|
-
name: 'autosnippet_submit_knowledge_batch',
|
|
160
|
-
tier: 'agent',
|
|
161
|
-
description: '批量提交知识条目。每条字段要求同 submit_knowledge,支持自动去重。\n' +
|
|
162
|
-
'校验更严格:不通过的条目会被拒绝(不入库),返回 rejectedSummary。\n' +
|
|
163
|
-
'适用于冷启动维度分析、模块批量扫描等场景。',
|
|
164
|
-
inputSchema: zodToMcpSchema(SubmitKnowledgeBatchInput),
|
|
165
|
-
},
|
|
166
|
-
// 10. 保存开发文档
|
|
167
|
-
{
|
|
168
|
-
name: 'autosnippet_save_document',
|
|
169
|
-
tier: 'agent',
|
|
170
|
-
description: '保存开发文档(设计文档、排查报告、ADR 等)到知识库。仅需 title + markdown,无需完整 V3 字段。',
|
|
171
|
-
inputSchema: zodToMcpSchema(SaveDocumentInput),
|
|
172
|
-
},
|
|
173
|
-
// 11. Skill 管理
|
|
156
|
+
// 9. Skill Management
|
|
174
157
|
{
|
|
175
158
|
name: 'autosnippet_skill',
|
|
176
159
|
tier: 'agent',
|
|
177
|
-
description: 'Skill
|
|
178
|
-
'• list —
|
|
179
|
-
'• load —
|
|
180
|
-
'• create —
|
|
181
|
-
'• update —
|
|
182
|
-
'• delete —
|
|
183
|
-
'• suggest —
|
|
160
|
+
description: 'Skill management.\n' +
|
|
161
|
+
'• list — list all available Skills (built-in + project-level)\n' +
|
|
162
|
+
'• load — load full Skill content for detailed guidance (requires name)\n' +
|
|
163
|
+
'• create — create project-level Skill (requires name + description + content)\n' +
|
|
164
|
+
'• update — update project-level Skill content\n' +
|
|
165
|
+
'• delete — delete project-level Skill (built-in cannot be deleted)\n' +
|
|
166
|
+
'• suggest — recommend Skills to create based on project analysis',
|
|
184
167
|
inputSchema: zodToMcpSchema(SkillInput),
|
|
185
168
|
},
|
|
186
|
-
//
|
|
169
|
+
// 10. Cold-Start Bootstrap
|
|
187
170
|
{
|
|
188
171
|
name: 'autosnippet_bootstrap',
|
|
189
172
|
tier: 'agent',
|
|
190
|
-
description: '
|
|
191
|
-
'•
|
|
192
|
-
'•
|
|
193
|
-
'•
|
|
194
|
-
'
|
|
173
|
+
description: 'Cold-start — no parameters needed. Auto-analyzes the project (AST, dependency graph, Guard audit) and returns a Mission Briefing:\n' +
|
|
174
|
+
'• Project metadata and language statistics\n' +
|
|
175
|
+
'• Dimension task list (8 dimensions × 3 Tiers)\n' +
|
|
176
|
+
'• Execution plan and submission examples\n' +
|
|
177
|
+
'After receiving the Briefing, complete all dimension analyses per the executionPlan.',
|
|
195
178
|
inputSchema: zodToMcpSchema(BootstrapInput),
|
|
196
179
|
},
|
|
197
|
-
//
|
|
180
|
+
// 11. Dimension Complete Notification
|
|
198
181
|
{
|
|
199
182
|
name: 'autosnippet_dimension_complete',
|
|
200
183
|
tier: 'agent',
|
|
201
|
-
description: '
|
|
202
|
-
'analysisText
|
|
184
|
+
description: 'Dimension analysis completion notification. Handles: Recipe linking, Skill generation (auto-synthesized from submitted candidates), Checkpoint saving, cross-dimension Hints distribution.\n' +
|
|
185
|
+
'analysisText can be brief — the system auto-synthesizes detailed content from submitted candidates for Skill generation.',
|
|
203
186
|
inputSchema: zodToMcpSchema(DimensionCompleteInput),
|
|
204
187
|
},
|
|
205
|
-
//
|
|
206
|
-
{
|
|
207
|
-
name: 'autosnippet_wiki_plan',
|
|
208
|
-
tier: 'agent',
|
|
209
|
-
description: '规划 Wiki 文档生成 — 整合项目结构与知识库,返回文档主题列表及每个主题的数据包。Agent 根据规划自行撰写文章。',
|
|
210
|
-
inputSchema: zodToMcpSchema(WikiPlanInput),
|
|
211
|
-
},
|
|
212
|
-
// 15. Wiki 完成
|
|
188
|
+
// 12. Wiki Documentation Generation
|
|
213
189
|
{
|
|
214
|
-
name: '
|
|
190
|
+
name: 'autosnippet_wiki',
|
|
215
191
|
tier: 'agent',
|
|
216
|
-
description: '
|
|
217
|
-
|
|
192
|
+
description: 'Wiki documentation generation.\n' +
|
|
193
|
+
'• plan — plan topics + data packages (integrates project structure and knowledge base; returns topic list + per-topic data package for Agent to write)\n' +
|
|
194
|
+
'• finalize — complete generation (write meta.json, dedup check, validate completeness; call after all articles are written)',
|
|
195
|
+
inputSchema: zodToMcpSchema(WikiInput),
|
|
218
196
|
},
|
|
219
|
-
//
|
|
197
|
+
// 13. Project Panorama
|
|
220
198
|
{
|
|
221
|
-
name: '
|
|
199
|
+
name: 'autosnippet_panorama',
|
|
222
200
|
tier: 'agent',
|
|
223
|
-
description: '
|
|
224
|
-
|
|
201
|
+
description: 'Project panorama queries. Auto-triggers structure scan when no data exists — no manual cold-start needed.\n' +
|
|
202
|
+
'• overview (default) — project skeleton + architecture layers + module roles + knowledge coverage\n' +
|
|
203
|
+
'• module — single module details + neighbor relationships (requires module param)\n' +
|
|
204
|
+
'• gaps — knowledge gaps (modules with code but no Recipes)\n' +
|
|
205
|
+
'• health — panorama health score (coverage + coupling + circular deps + health score)\n' +
|
|
206
|
+
'• governance_cycle — full knowledge metabolism cycle (contradiction detection + redundancy analysis + decay assessment)\n' +
|
|
207
|
+
'• decay_report — decay assessment report (5 strategy detection + decayScore)\n' +
|
|
208
|
+
'• staging_check — staging entry check + auto-publish on expiry\n' +
|
|
209
|
+
'• enhancement_suggestions — Recipe enhancement suggestions based on usage data',
|
|
210
|
+
inputSchema: zodToMcpSchema(PanoramaInput),
|
|
225
211
|
},
|
|
226
|
-
//
|
|
212
|
+
// 14. Task & Decision Management
|
|
227
213
|
{
|
|
228
214
|
name: 'autosnippet_task',
|
|
229
215
|
tier: 'agent',
|
|
230
|
-
description: '
|
|
231
|
-
'
|
|
232
|
-
'
|
|
233
|
-
'
|
|
234
|
-
'
|
|
216
|
+
description: 'Task and decision management (5 operations). Call prime first at the start of each conversation to load knowledge context.\n' +
|
|
217
|
+
'• prime — load knowledge context + initialize intent lifecycle\n' +
|
|
218
|
+
'• create — create task anchor (for non-trivial work: ≥2 files or ≥10 lines)\n' +
|
|
219
|
+
'• close — complete task + trigger Guard compliance review\n' +
|
|
220
|
+
'• fail — abandon task\n' +
|
|
221
|
+
'• record_decision — record user preference decision',
|
|
235
222
|
inputSchema: zodToMcpSchema(TaskInput),
|
|
236
223
|
},
|
|
237
224
|
// ══════════════════════════════════════════════════════
|
|
238
|
-
// Tier: admin —
|
|
225
|
+
// Tier: admin — Admin/CI Tools (+2)
|
|
239
226
|
// ══════════════════════════════════════════════════════
|
|
240
|
-
//
|
|
227
|
+
// 15. Candidate Field Diagnosis
|
|
241
228
|
{
|
|
242
229
|
name: 'autosnippet_enrich_candidates',
|
|
243
230
|
tier: 'admin',
|
|
244
|
-
description: '
|
|
231
|
+
description: 'Diagnose field completeness of candidate entries (no AI). Returns missingFields list per candidate for Agent to fill in and resubmit.',
|
|
245
232
|
inputSchema: zodToMcpSchema(EnrichCandidatesInput),
|
|
246
233
|
},
|
|
247
|
-
//
|
|
234
|
+
// 16. Knowledge Lifecycle
|
|
248
235
|
{
|
|
249
236
|
name: 'autosnippet_knowledge_lifecycle',
|
|
250
237
|
tier: 'admin',
|
|
251
|
-
description: '
|
|
238
|
+
description: 'Knowledge entry lifecycle operations. approve/fast_track → publish; reject → reject; deprecate → deprecate; reactivate → restore.',
|
|
252
239
|
inputSchema: zodToMcpSchema(KnowledgeLifecycleInput),
|
|
253
240
|
},
|
|
254
|
-
// 20. 候选预校验(调试)
|
|
255
|
-
{
|
|
256
|
-
name: 'autosnippet_validate_candidate',
|
|
257
|
-
tier: 'admin',
|
|
258
|
-
description: '独立候选校验(5 层结构化检查)。调试用,submit_knowledge 已内置校验。',
|
|
259
|
-
inputSchema: zodToMcpSchema(ValidateCandidateInput),
|
|
260
|
-
},
|
|
261
|
-
// 21. 去重检测(调试)
|
|
262
|
-
{
|
|
263
|
-
name: 'autosnippet_check_duplicate',
|
|
264
|
-
tier: 'admin',
|
|
265
|
-
description: '独立相似度检测。调试用,submit_knowledge 已内置去重。',
|
|
266
|
-
inputSchema: zodToMcpSchema(CheckDuplicateInput),
|
|
267
|
-
},
|
|
268
241
|
];
|
|
@@ -21,19 +21,23 @@ import { gatewayMiddleware } from './middleware/gatewayMiddleware.js';
|
|
|
21
21
|
import { requestLogger } from './middleware/requestLogger.js';
|
|
22
22
|
import { roleResolverMiddleware } from './middleware/roleResolver.js';
|
|
23
23
|
import aiRouter from './routes/ai.js';
|
|
24
|
+
import auditRouter from './routes/audit.js';
|
|
24
25
|
import authRouter from './routes/auth.js';
|
|
25
26
|
import candidatesRouter from './routes/candidates.js';
|
|
26
27
|
import commandsRouter from './routes/commands.js';
|
|
27
28
|
import extractRouter from './routes/extract.js';
|
|
28
29
|
import guardRouter from './routes/guard.js';
|
|
30
|
+
import guardReportRouter from './routes/guardReport.js';
|
|
29
31
|
import guardRuleRouter from './routes/guardRules.js';
|
|
30
32
|
import healthRouter from './routes/health.js';
|
|
31
33
|
import knowledgeRouter from './routes/knowledge.js';
|
|
32
34
|
import modulesRouter from './routes/modules.js';
|
|
33
35
|
import monitoringRouter from './routes/monitoring.js';
|
|
36
|
+
import panoramaRouter from './routes/panorama.js';
|
|
34
37
|
import recipesRouter from './routes/recipes.js';
|
|
35
38
|
import remoteRouter from './routes/remote.js';
|
|
36
39
|
import searchRouter from './routes/search.js';
|
|
40
|
+
import signalsRouter from './routes/signals.js';
|
|
37
41
|
import skillsRouter from './routes/skills.js';
|
|
38
42
|
import taskRouter from './routes/task.js';
|
|
39
43
|
import violationsRouter from './routes/violations.js';
|
|
@@ -223,6 +227,8 @@ export class HttpServer {
|
|
|
223
227
|
}
|
|
224
228
|
// Guard 实时检查路由(Extension DiagnosticCollection 调用)
|
|
225
229
|
this.app.use(`${apiPrefix}/guard`, guardRouter);
|
|
230
|
+
// Guard 合规报告路由
|
|
231
|
+
this.app.use(`${apiPrefix}/guard/report`, guardReportRouter);
|
|
226
232
|
// 守护规则路由
|
|
227
233
|
this.app.use(`${apiPrefix}/rules`, guardRuleRouter);
|
|
228
234
|
// TaskGraph 路由(Extension taskTool.ts 转发调用)
|
|
@@ -251,6 +257,12 @@ export class HttpServer {
|
|
|
251
257
|
this.app.use(`${apiPrefix}/wiki`, wikiRouter);
|
|
252
258
|
// Remote 路由(飞书 Bot → IDE 远程指令桥接)
|
|
253
259
|
this.app.use(`${apiPrefix}/remote`, remoteRouter);
|
|
260
|
+
// Panorama 全景路由(项目结构 + 覆盖率 + 健康度)
|
|
261
|
+
this.app.use(`${apiPrefix}/panorama`, panoramaRouter);
|
|
262
|
+
// 信号留痕 & 报告路由
|
|
263
|
+
this.app.use(`${apiPrefix}/signals`, signalsRouter);
|
|
264
|
+
// 审计日志路由
|
|
265
|
+
this.app.use(`${apiPrefix}/audit`, auditRouter);
|
|
254
266
|
// 根路径 — 返回 API 元信息(避免外部探测产生无意义 404)
|
|
255
267
|
this.app.all('/', (_req, res) => {
|
|
256
268
|
res.json({
|
|
@@ -297,6 +309,46 @@ export class HttpServer {
|
|
|
297
309
|
try {
|
|
298
310
|
this.realtimeService = initRealtimeService(this.server);
|
|
299
311
|
this.logger.info('Realtime service initialized');
|
|
312
|
+
// 桥接 EventBus / SignalBus → RealtimeService
|
|
313
|
+
try {
|
|
314
|
+
const container = getServiceContainer();
|
|
315
|
+
const rs = this.realtimeService;
|
|
316
|
+
if (typeof rs?.broadcastEvent !== 'function') {
|
|
317
|
+
throw new Error('broadcastEvent not available');
|
|
318
|
+
}
|
|
319
|
+
// EventBus → lifecycle:transition
|
|
320
|
+
const eventBus = container.services.eventBus ? container.get('eventBus') : null;
|
|
321
|
+
if (eventBus) {
|
|
322
|
+
eventBus.on('lifecycle:transition', (data) => {
|
|
323
|
+
rs.broadcastEvent('lifecycle:transition', data);
|
|
324
|
+
});
|
|
325
|
+
}
|
|
326
|
+
// SignalBridge 已将信号转发到 EventBus,HttpServer 只听 EventBus
|
|
327
|
+
if (eventBus) {
|
|
328
|
+
eventBus.on('signal:event', (signal) => {
|
|
329
|
+
rs.broadcastEvent('signal:event', signal);
|
|
330
|
+
});
|
|
331
|
+
eventBus.on('guard:updated', (signal) => {
|
|
332
|
+
rs.broadcastEvent('guard:updated', signal);
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
// 确保 SignalBridge 已初始化(触发 lazy singleton)
|
|
336
|
+
try {
|
|
337
|
+
container.get('signalBridge');
|
|
338
|
+
}
|
|
339
|
+
catch {
|
|
340
|
+
// SignalBridge 未注册时静默跳过
|
|
341
|
+
}
|
|
342
|
+
// EventBus → audit:entry
|
|
343
|
+
if (eventBus) {
|
|
344
|
+
eventBus.on('audit:entry', (data) => {
|
|
345
|
+
rs.broadcastEvent('audit:entry', data);
|
|
346
|
+
});
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
catch {
|
|
350
|
+
// EventBus/SignalBus 不可用时静默跳过
|
|
351
|
+
}
|
|
300
352
|
}
|
|
301
353
|
catch (error) {
|
|
302
354
|
this.logger.warn('Failed to initialize realtime service', {
|
|
@@ -60,8 +60,8 @@ export function validateQuery(schema) {
|
|
|
60
60
|
});
|
|
61
61
|
return;
|
|
62
62
|
}
|
|
63
|
-
//
|
|
64
|
-
req
|
|
63
|
+
// Express 5: req.query is a read-only getter, use defineProperty to override
|
|
64
|
+
Object.defineProperty(req, 'query', { value: result.data, writable: true, configurable: true });
|
|
65
65
|
next();
|
|
66
66
|
};
|
|
67
67
|
}
|
|
@@ -85,7 +85,11 @@ export function validateParams(schema) {
|
|
|
85
85
|
});
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
req
|
|
88
|
+
Object.defineProperty(req, 'params', {
|
|
89
|
+
value: result.data,
|
|
90
|
+
writable: true,
|
|
91
|
+
configurable: true,
|
|
92
|
+
});
|
|
89
93
|
next();
|
|
90
94
|
};
|
|
91
95
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Audit Log API 路由
|
|
3
|
+
*
|
|
4
|
+
* 端点:
|
|
5
|
+
* GET /api/v1/audit — 查询审计日志
|
|
6
|
+
*/
|
|
7
|
+
import express from 'express';
|
|
8
|
+
import { getServiceContainer } from '../../injection/ServiceContainer.js';
|
|
9
|
+
const router = express.Router();
|
|
10
|
+
/**
|
|
11
|
+
* GET /api/v1/audit
|
|
12
|
+
* 查询审计日志,支持按 actor/action/result/时间范围过滤
|
|
13
|
+
*
|
|
14
|
+
* Query params:
|
|
15
|
+
* actor — 操作人过滤
|
|
16
|
+
* action — 操作类型过滤
|
|
17
|
+
* result — 结果过滤 (success|failure)
|
|
18
|
+
* startDate — 起始时间戳 (毫秒)
|
|
19
|
+
* endDate — 结束时间戳 (毫秒)
|
|
20
|
+
* limit — 返回条数上限 (默认 100, 最大 500)
|
|
21
|
+
*/
|
|
22
|
+
router.get('/', async (req, res) => {
|
|
23
|
+
try {
|
|
24
|
+
const container = getServiceContainer();
|
|
25
|
+
const auditStore = container.get('auditStore');
|
|
26
|
+
if (!auditStore) {
|
|
27
|
+
res.status(503).json({
|
|
28
|
+
success: false,
|
|
29
|
+
error: { code: 'SERVICE_UNAVAILABLE', message: 'AuditStore not available' },
|
|
30
|
+
});
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
const limit = Math.min(Number(req.query.limit) || 100, 500);
|
|
34
|
+
const logs = auditStore.query({
|
|
35
|
+
actor: req.query.actor,
|
|
36
|
+
action: req.query.action,
|
|
37
|
+
result: req.query.result,
|
|
38
|
+
startDate: req.query.startDate ? Number(req.query.startDate) : undefined,
|
|
39
|
+
endDate: req.query.endDate ? Number(req.query.endDate) : undefined,
|
|
40
|
+
limit,
|
|
41
|
+
});
|
|
42
|
+
res.json({ success: true, data: { logs, total: logs.length } });
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
res.status(500).json({
|
|
46
|
+
success: false,
|
|
47
|
+
error: { code: 'AUDIT_ERROR', message: err.message },
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
export default router;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Guard Report API 路由
|
|
3
|
+
*
|
|
4
|
+
* 端点:
|
|
5
|
+
* GET /api/v1/guard/report — 项目合规性报告(ComplianceReporter + Uncertainty)
|
|
6
|
+
* GET /api/v1/guard/report/reverse — ReverseGuard 反向验证
|
|
7
|
+
* GET /api/v1/guard/report/coverage — CoverageAnalyzer 覆盖率矩阵
|
|
8
|
+
*/
|
|
9
|
+
declare const router: import("express-serve-static-core").Router;
|
|
10
|
+
export default router;
|