autosnippet 3.3.5 → 3.3.7
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-FHns2ypa.js +1 -0
- package/dashboard/dist/assets/index-BRJv5Y3r.js +135 -0
- package/dashboard/dist/assets/index-DzoB7kxK.css +1 -0
- package/dashboard/dist/index.html +3 -3
- package/dist/bin/api-server.js +1 -0
- package/dist/bin/cli.d.ts +1 -0
- package/dist/bin/cli.js +137 -9
- package/dist/lib/agent/AgentFactory.d.ts +0 -17
- package/dist/lib/agent/AgentFactory.js +1 -25
- package/dist/lib/agent/AgentRuntime.d.ts +2 -2
- package/dist/lib/agent/AgentRuntime.js +26 -18
- package/dist/lib/agent/capabilities.d.ts +11 -0
- package/dist/lib/agent/capabilities.js +29 -5
- package/dist/lib/agent/context/ExplorationTracker.js +10 -1
- package/dist/lib/agent/context/exploration/ExplorationStrategies.d.ts +2 -0
- package/dist/lib/agent/context/exploration/ExplorationStrategies.js +2 -2
- package/dist/lib/agent/domain/ChatAgentTasks.js +4 -0
- package/dist/lib/agent/domain/insight-analyst.d.ts +47 -3
- package/dist/lib/agent/domain/insight-analyst.js +111 -11
- package/dist/lib/agent/domain/insight-evolver.d.ts +69 -0
- package/dist/lib/agent/domain/insight-evolver.js +230 -0
- package/dist/lib/agent/domain/insight-gate.d.ts +42 -0
- package/dist/lib/agent/domain/insight-gate.js +41 -0
- package/dist/lib/agent/domain/insight-producer.d.ts +27 -2
- package/dist/lib/agent/domain/insight-producer.js +60 -5
- package/dist/lib/agent/domain/scan-prompts.js +10 -7
- package/dist/lib/agent/forced-summary.js +7 -2
- package/dist/lib/agent/memory/ActiveContext.d.ts +2 -28
- package/dist/lib/agent/memory/MemoryCoordinator.d.ts +2 -2
- package/dist/lib/agent/memory/SessionStore.d.ts +6 -12
- package/dist/lib/agent/memory/SessionStore.js +9 -15
- package/dist/lib/agent/memory/memory-flush-contract.d.ts +49 -0
- package/dist/lib/agent/memory/memory-flush-contract.js +16 -0
- package/dist/lib/agent/memory/session-store-schema.d.ts +20 -0
- package/dist/lib/agent/memory/session-store-schema.js +41 -0
- package/dist/lib/agent/presets.d.ts +89 -1
- package/dist/lib/agent/presets.js +53 -5
- package/dist/lib/agent/tools/_shared.d.ts +7 -15
- package/dist/lib/agent/tools/_shared.js +20 -21
- package/dist/lib/agent/tools/composite.d.ts +25 -22
- package/dist/lib/agent/tools/composite.js +108 -109
- package/dist/lib/agent/tools/evolution-tools.d.ts +145 -0
- package/dist/lib/agent/tools/evolution-tools.js +161 -0
- package/dist/lib/agent/tools/index.d.ts +163 -92
- package/dist/lib/agent/tools/index.js +9 -1
- package/dist/lib/agent/tools/lifecycle.d.ts +7 -1
- package/dist/lib/agent/tools/lifecycle.js +59 -75
- package/dist/lib/cli/AiScanService.js +5 -5
- package/dist/lib/cli/KnowledgeSyncService.js +1 -1
- package/dist/lib/core/AstAnalyzer.d.ts +1 -0
- package/dist/lib/core/discovery/ConfigWatcher.d.ts +64 -0
- package/dist/lib/core/discovery/ConfigWatcher.js +336 -0
- package/dist/lib/core/discovery/CustomConfigDiscoverer.d.ts +30 -0
- package/dist/lib/core/discovery/CustomConfigDiscoverer.js +1305 -0
- package/dist/lib/core/discovery/DiscovererPreference.d.ts +44 -0
- package/dist/lib/core/discovery/DiscovererPreference.js +141 -0
- package/dist/lib/core/discovery/DiscovererRegistry.d.ts +10 -1
- package/dist/lib/core/discovery/DiscovererRegistry.js +42 -2
- package/dist/lib/core/discovery/ProjectDiscoverer.d.ts +19 -0
- package/dist/lib/core/discovery/index.d.ts +2 -0
- package/dist/lib/core/discovery/index.js +4 -0
- package/dist/lib/core/discovery/parsers/CMakeParser.d.ts +32 -0
- package/dist/lib/core/discovery/parsers/CMakeParser.js +148 -0
- package/dist/lib/core/discovery/parsers/GradleDslParser.d.ts +43 -0
- package/dist/lib/core/discovery/parsers/GradleDslParser.js +171 -0
- package/dist/lib/core/discovery/parsers/JsonConfigParser.d.ts +45 -0
- package/dist/lib/core/discovery/parsers/JsonConfigParser.js +122 -0
- package/dist/lib/core/discovery/parsers/RubyDslParser.d.ts +49 -0
- package/dist/lib/core/discovery/parsers/RubyDslParser.js +282 -0
- package/dist/lib/core/discovery/parsers/StarlarkParser.d.ts +33 -0
- package/dist/lib/core/discovery/parsers/StarlarkParser.js +229 -0
- package/dist/lib/core/discovery/parsers/YamlConfigParser.d.ts +37 -0
- package/dist/lib/core/discovery/parsers/YamlConfigParser.js +212 -0
- package/dist/lib/{service/bootstrap/DimensionCopyRegistry.d.ts → domain/dimension/DimensionCopy.d.ts} +2 -2
- package/dist/lib/{service/bootstrap/DimensionCopyRegistry.js → domain/dimension/DimensionCopy.js} +22 -72
- package/dist/lib/domain/dimension/DimensionRegistry.d.ts +54 -0
- package/dist/lib/domain/dimension/DimensionRegistry.js +620 -0
- package/dist/lib/domain/dimension/DimensionSop.d.ts +55 -0
- package/dist/lib/domain/dimension/DimensionSop.js +1604 -0
- package/dist/lib/domain/dimension/UnifiedDimension.d.ts +61 -0
- package/dist/lib/domain/dimension/UnifiedDimension.js +53 -0
- package/dist/lib/domain/dimension/index.d.ts +10 -0
- package/dist/lib/domain/dimension/index.js +9 -0
- package/dist/lib/domain/knowledge/FieldSpec.d.ts +1 -1
- package/dist/lib/domain/knowledge/FieldSpec.js +29 -16
- package/dist/lib/domain/knowledge/KnowledgeEntry.d.ts +40 -112
- package/dist/lib/domain/knowledge/KnowledgeEntry.js +44 -9
- package/dist/lib/domain/knowledge/KnowledgeRepository.d.ts +1 -0
- package/dist/lib/domain/knowledge/KnowledgeRepository.js +3 -0
- package/dist/lib/domain/knowledge/Lifecycle.js +1 -1
- package/dist/lib/domain/knowledge/StyleGuide.d.ts +1 -1
- package/dist/lib/domain/knowledge/StyleGuide.js +1 -1
- package/dist/lib/domain/knowledge/UnifiedValidator.js +15 -0
- package/dist/lib/external/ai/AiProvider.d.ts +12 -0
- package/dist/lib/external/ai/AiProvider.js +24 -0
- package/dist/lib/external/ai/AiProviderManager.d.ts +101 -0
- package/dist/lib/external/ai/AiProviderManager.js +193 -0
- package/dist/lib/external/ai/providers/ClaudeProvider.js +11 -0
- package/dist/lib/external/ai/providers/GoogleGeminiProvider.js +18 -0
- package/dist/lib/external/ai/providers/MockProvider.d.ts +21 -3
- package/dist/lib/external/ai/providers/MockProvider.js +290 -14
- package/dist/lib/external/ai/providers/OpenAiProvider.js +16 -0
- package/dist/lib/external/lark/LarkTransport.d.ts +5 -1
- package/dist/lib/external/lark/LarkTransport.js +10 -2
- package/dist/lib/external/mcp/McpServer.js +4 -0
- package/dist/lib/external/mcp/handlers/TargetClassifier.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.d.ts +8 -16
- package/dist/lib/external/mcp/handlers/bootstrap/BootstrapSession.js +10 -10
- package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.d.ts +7 -0
- package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +20 -0
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.d.ts +52 -132
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +204 -17
- package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.d.ts +11 -75
- package/dist/lib/external/mcp/handlers/bootstrap/base-dimensions.js +40 -191
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.d.ts +13 -78
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-configs.js +30 -52
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.d.ts +0 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/mock-pipeline.d.ts +20 -0
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/mock-pipeline.js +432 -0
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.d.ts +99 -12
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +188 -169
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/tier-scheduler.js +7 -17
- package/dist/lib/external/mcp/handlers/bootstrap/refine.js +8 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.d.ts +46 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/async-fill-helpers.js +58 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.d.ts +25 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/audit-helpers.js +47 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.d.ts +50 -12
- package/dist/lib/external/mcp/handlers/bootstrap/shared/bootstrap-phases.js +30 -10
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-text.js +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.d.ts +24 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/handler-types.js +14 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.d.ts +14 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/panorama-utils.js +48 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.d.ts +21 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/session-helpers.js +45 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/skill-generator.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.d.ts +27 -0
- package/dist/lib/external/mcp/handlers/bootstrap/shared/target-file-map.js +44 -0
- package/dist/lib/external/mcp/handlers/bootstrap-external.d.ts +23 -10
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +41 -51
- package/dist/lib/external/mcp/handlers/bootstrap-internal.d.ts +2 -0
- package/dist/lib/external/mcp/handlers/bootstrap-internal.js +117 -82
- package/dist/lib/external/mcp/handlers/consolidated.d.ts +4 -4
- package/dist/lib/external/mcp/handlers/consolidated.js +108 -332
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +71 -2
- package/dist/lib/external/mcp/handlers/evolve-external.d.ts +54 -0
- package/dist/lib/external/mcp/handlers/evolve-external.js +229 -0
- package/dist/lib/external/mcp/handlers/knowledge.js +30 -5
- package/dist/lib/external/mcp/handlers/rescan-external.d.ts +76 -0
- package/dist/lib/external/mcp/handlers/rescan-external.js +335 -0
- package/dist/lib/external/mcp/handlers/rescan-internal.d.ts +120 -0
- package/dist/lib/external/mcp/handlers/rescan-internal.js +359 -0
- package/dist/lib/external/mcp/handlers/search.d.ts +6 -5
- package/dist/lib/external/mcp/handlers/search.js +6 -5
- package/dist/lib/external/mcp/handlers/types.d.ts +2 -1
- package/dist/lib/external/mcp/handlers/wiki-external.js +2 -2
- package/dist/lib/external/mcp/tools.d.ts +8 -18
- package/dist/lib/external/mcp/tools.js +58 -2
- package/dist/lib/http/routes/ai.js +111 -30
- package/dist/lib/http/routes/candidates.js +11 -4
- package/dist/lib/http/routes/commands.js +10 -1
- package/dist/lib/http/routes/health.js +11 -0
- package/dist/lib/http/routes/knowledge.js +122 -1
- package/dist/lib/http/routes/modules.js +52 -3
- package/dist/lib/http/routes/panorama.js +16 -4
- package/dist/lib/http/routes/recipes.js +7 -0
- package/dist/lib/http/utils/routeHelpers.js +2 -1
- package/dist/lib/infrastructure/cache/CacheCoordinator.d.ts +41 -0
- package/dist/lib/infrastructure/cache/CacheCoordinator.js +105 -0
- package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.d.ts +7 -0
- package/dist/lib/infrastructure/database/migrations/006_lifecycle_transition_events.js +28 -0
- package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +1 -1
- package/dist/lib/injection/ServiceContainer.d.ts +6 -5
- package/dist/lib/injection/ServiceContainer.js +64 -25
- package/dist/lib/injection/ServiceMap.d.ts +10 -1
- package/dist/lib/injection/modules/AiModule.d.ts +6 -9
- package/dist/lib/injection/modules/AiModule.js +82 -39
- package/dist/lib/injection/modules/KnowledgeModule.js +15 -1
- package/dist/lib/injection/modules/PanoramaModule.js +1 -1
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.d.ts +4 -0
- package/dist/lib/repository/knowledge/KnowledgeRepository.impl.js +16 -1
- package/dist/lib/service/bootstrap/BootstrapEventEmitter.d.ts +3 -2
- package/dist/lib/service/bootstrap/BootstrapEventEmitter.js +1 -1
- package/dist/lib/service/bootstrap/DeliveryVerifier.d.ts +51 -0
- package/dist/lib/service/bootstrap/DeliveryVerifier.js +163 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.d.ts +5 -0
- package/dist/lib/service/bootstrap/UiStartupTasks.js +20 -0
- package/dist/lib/service/bootstrap/bootstrap-event-types.d.ts +54 -0
- package/dist/lib/service/bootstrap/bootstrap-event-types.js +10 -0
- package/dist/lib/service/cleanup/CleanupService.d.ts +132 -0
- package/dist/lib/service/cleanup/CleanupService.js +571 -0
- package/dist/lib/service/delivery/AgentInstructionsGenerator.js +39 -43
- package/dist/lib/service/delivery/FileProtection.d.ts +20 -0
- package/dist/lib/service/delivery/FileProtection.js +54 -0
- package/dist/lib/service/delivery/SkillsSyncer.js +16 -21
- package/dist/lib/service/evolution/ContentPatcher.d.ts +44 -0
- package/dist/lib/service/evolution/ContentPatcher.js +310 -0
- package/dist/lib/service/evolution/ProposalExecutor.d.ts +4 -0
- package/dist/lib/service/evolution/ProposalExecutor.js +77 -13
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.d.ts +64 -0
- package/dist/lib/service/evolution/RecipeLifecycleSupervisor.js +458 -0
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.d.ts +89 -0
- package/dist/lib/service/evolution/RecipeRelevanceAuditor.js +492 -0
- package/dist/lib/service/evolution/createSupersedeProposal.d.ts +44 -0
- package/dist/lib/service/evolution/createSupersedeProposal.js +81 -0
- package/dist/lib/service/guard/ComplianceReporter.d.ts +4 -0
- package/dist/lib/service/guard/ComplianceReporter.js +51 -0
- package/dist/lib/service/guard/GuardCheckEngine.js +5 -4
- package/dist/lib/service/knowledge/CodeEntityGraph.d.ts +6 -0
- package/dist/lib/service/knowledge/CodeEntityGraph.js +16 -0
- package/dist/lib/service/knowledge/ConfidenceRouter.js +1 -1
- package/dist/lib/service/knowledge/KnowledgeService.d.ts +11 -1
- package/dist/lib/service/knowledge/KnowledgeService.js +67 -14
- package/dist/lib/service/knowledge/RecipeProductionGateway.d.ts +225 -0
- package/dist/lib/service/knowledge/RecipeProductionGateway.js +384 -0
- package/dist/lib/service/module/ModuleService.js +10 -19
- package/dist/lib/service/panorama/CouplingAnalyzer.d.ts +10 -1
- package/dist/lib/service/panorama/CouplingAnalyzer.js +44 -2
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +4 -3
- package/dist/lib/service/panorama/DimensionAnalyzer.js +40 -151
- package/dist/lib/service/panorama/LayerInferrer.d.ts +16 -1
- package/dist/lib/service/panorama/LayerInferrer.js +118 -1
- package/dist/lib/service/panorama/ModuleDiscoverer.d.ts +9 -0
- package/dist/lib/service/panorama/ModuleDiscoverer.js +58 -2
- package/dist/lib/service/panorama/PanoramaAggregator.d.ts +6 -2
- package/dist/lib/service/panorama/PanoramaAggregator.js +84 -6
- package/dist/lib/service/panorama/PanoramaScanner.js +28 -0
- package/dist/lib/service/panorama/PanoramaService.js +10 -5
- package/dist/lib/service/panorama/PanoramaTypes.d.ts +38 -0
- package/dist/lib/service/panorama/RoleRefiner.d.ts +2 -0
- package/dist/lib/service/panorama/RoleRefiner.js +41 -0
- package/dist/lib/service/panorama/TechStackProfiler.d.ts +13 -0
- package/dist/lib/service/panorama/TechStackProfiler.js +191 -0
- package/dist/lib/service/search/BM25Scorer.d.ts +2 -2
- package/dist/lib/service/search/SearchEngine.d.ts +11 -10
- package/dist/lib/service/search/SearchEngine.js +38 -36
- package/dist/lib/service/search/SearchTypes.d.ts +14 -8
- package/dist/lib/service/search/SearchTypes.js +1 -1
- package/dist/lib/service/search/tokenizer.d.ts +1 -1
- package/dist/lib/service/search/tokenizer.js +2 -2
- package/dist/lib/service/skills/SignalCollector.d.ts +1 -0
- package/dist/lib/service/skills/SignalCollector.js +6 -5
- package/dist/lib/service/vector/ContextualEnricher.d.ts +1 -0
- package/dist/lib/service/vector/ContextualEnricher.js +4 -0
- package/dist/lib/shared/LanguageService.js +3 -0
- package/dist/lib/shared/developer-identity.d.ts +18 -0
- package/dist/lib/shared/developer-identity.js +62 -0
- package/dist/lib/shared/schemas/common.d.ts +4 -4
- package/dist/lib/shared/schemas/http-requests.d.ts +20 -18
- package/dist/lib/shared/schemas/http-requests.js +17 -6
- package/dist/lib/shared/schemas/mcp-tools.d.ts +32 -2
- package/dist/lib/shared/schemas/mcp-tools.js +38 -0
- package/dist/lib/types/evolution.d.ts +135 -0
- package/dist/lib/types/evolution.js +6 -0
- package/dist/lib/types/graph-shared.d.ts +25 -0
- package/dist/lib/types/graph-shared.js +7 -0
- package/dist/lib/types/knowledge-wire.d.ts +132 -0
- package/dist/lib/types/knowledge-wire.js +7 -0
- package/dist/lib/types/project-snapshot-builder.d.ts +19 -0
- package/dist/lib/types/project-snapshot-builder.js +189 -0
- package/dist/lib/types/project-snapshot.d.ts +399 -0
- package/dist/lib/types/project-snapshot.js +17 -0
- package/dist/lib/types/search-wire.d.ts +46 -0
- package/dist/lib/types/search-wire.js +7 -0
- package/dist/lib/types/snapshot-views.d.ts +58 -0
- package/dist/lib/types/snapshot-views.js +103 -0
- package/package.json +1 -1
- package/skills/autosnippet-recipes/SKILL.md +1 -1
- package/templates/instructions/agent-static.md +2 -0
- package/templates/instructions/conventions.md +3 -1
- package/templates/recipes-setup/README.md +2 -2
- package/dashboard/dist/assets/icons-BJ2mUBi8.js +0 -1
- package/dashboard/dist/assets/index-B659K9t5.js +0 -128
- package/dashboard/dist/assets/index-NCm40PMD.css +0 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.d.ts +0 -169
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/noAiFallback.js +0 -727
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.d.ts +0 -370
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +0 -821
|
@@ -47,6 +47,8 @@ export interface SubmitWithCheckParams {
|
|
|
47
47
|
sourceFile?: string;
|
|
48
48
|
threshold?: number;
|
|
49
49
|
knowledgeType?: string;
|
|
50
|
+
/** 被替代的旧 Recipe ID(进化架构入口) */
|
|
51
|
+
supersedes?: string;
|
|
50
52
|
[key: string]: unknown;
|
|
51
53
|
}
|
|
52
54
|
export interface PlanTaskParams {
|
|
@@ -188,13 +190,14 @@ export declare const submitWithCheck: {
|
|
|
188
190
|
type: string;
|
|
189
191
|
description: string;
|
|
190
192
|
};
|
|
193
|
+
supersedes: {
|
|
194
|
+
type: string;
|
|
195
|
+
description: string;
|
|
196
|
+
};
|
|
191
197
|
};
|
|
192
198
|
required: string[];
|
|
193
199
|
};
|
|
194
200
|
handler: (params: SubmitWithCheckParams, ctx: ToolHandlerContext) => Promise<{
|
|
195
|
-
status: string;
|
|
196
|
-
reason: string;
|
|
197
|
-
} | {
|
|
198
201
|
submitted: boolean;
|
|
199
202
|
status: string;
|
|
200
203
|
reason: string;
|
|
@@ -204,10 +207,19 @@ export declare const submitWithCheck: {
|
|
|
204
207
|
confidence: string;
|
|
205
208
|
hint: string;
|
|
206
209
|
};
|
|
210
|
+
error?: undefined;
|
|
211
|
+
similar?: undefined;
|
|
212
|
+
highestSimilarity?: undefined;
|
|
213
|
+
} | {
|
|
214
|
+
submitted: boolean;
|
|
215
|
+
reason: string;
|
|
216
|
+
error: string;
|
|
217
|
+
status?: undefined;
|
|
218
|
+
errors?: undefined;
|
|
219
|
+
warnings?: undefined;
|
|
220
|
+
_meta?: undefined;
|
|
207
221
|
similar?: undefined;
|
|
208
222
|
highestSimilarity?: undefined;
|
|
209
|
-
entry?: undefined;
|
|
210
|
-
error?: undefined;
|
|
211
223
|
} | {
|
|
212
224
|
submitted: boolean;
|
|
213
225
|
reason: string;
|
|
@@ -224,37 +236,28 @@ export declare const submitWithCheck: {
|
|
|
224
236
|
status?: undefined;
|
|
225
237
|
errors?: undefined;
|
|
226
238
|
warnings?: undefined;
|
|
227
|
-
entry?: undefined;
|
|
228
239
|
error?: undefined;
|
|
229
240
|
} | {
|
|
241
|
+
_meta: {
|
|
242
|
+
confidence: string;
|
|
243
|
+
hint: string;
|
|
244
|
+
};
|
|
245
|
+
_supersedeProposal?: {
|
|
246
|
+
proposalId: string;
|
|
247
|
+
} | undefined;
|
|
230
248
|
submitted: boolean;
|
|
231
|
-
entry:
|
|
249
|
+
entry: unknown;
|
|
232
250
|
similar: {
|
|
233
251
|
file: string;
|
|
234
252
|
title: string;
|
|
235
253
|
similarity: number;
|
|
236
254
|
}[];
|
|
237
|
-
_meta: {
|
|
238
|
-
confidence: string;
|
|
239
|
-
hint: string;
|
|
240
|
-
};
|
|
241
255
|
status?: undefined;
|
|
242
256
|
reason?: undefined;
|
|
243
257
|
errors?: undefined;
|
|
244
258
|
warnings?: undefined;
|
|
245
|
-
highestSimilarity?: undefined;
|
|
246
259
|
error?: undefined;
|
|
247
|
-
} | {
|
|
248
|
-
submitted: boolean;
|
|
249
|
-
reason: string;
|
|
250
|
-
error: string;
|
|
251
|
-
status?: undefined;
|
|
252
|
-
errors?: undefined;
|
|
253
|
-
warnings?: undefined;
|
|
254
|
-
_meta?: undefined;
|
|
255
|
-
similar?: undefined;
|
|
256
260
|
highestSimilarity?: undefined;
|
|
257
|
-
entry?: undefined;
|
|
258
261
|
}>;
|
|
259
262
|
};
|
|
260
263
|
/**
|
|
@@ -9,9 +9,8 @@
|
|
|
9
9
|
* ── review_my_output 元工具: 自我质量审查
|
|
10
10
|
*/
|
|
11
11
|
import { getInternalAgentRequiredFields, getSystemInjectedFields, } from '#domain/knowledge/FieldSpec.js';
|
|
12
|
-
import { UnifiedValidator } from '#domain/knowledge/UnifiedValidator.js';
|
|
13
12
|
import { findSimilarRecipes } from '#service/candidate/SimilarityService.js';
|
|
14
|
-
import { checkDimensionType, DIMENSION_DISPLAY_GROUP, } from './_shared.js';
|
|
13
|
+
import { checkDimensionType, DIMENSION_DISPLAY_GROUP, stripProjectNamePrefix, } from './_shared.js';
|
|
15
14
|
// ────────────────────────────────────────────────────────────
|
|
16
15
|
// 34. analyze_code — 组合工具 (Guard + Recipe 搜索)
|
|
17
16
|
// ────────────────────────────────────────────────────────────
|
|
@@ -182,13 +181,24 @@ export const submitWithCheck = {
|
|
|
182
181
|
enum: ['basic', 'intermediate', 'advanced'],
|
|
183
182
|
description: '复杂度',
|
|
184
183
|
},
|
|
185
|
-
sourceFile: {
|
|
184
|
+
sourceFile: {
|
|
185
|
+
type: 'string',
|
|
186
|
+
description: 'Recipe md 文件相对路径(由系统自动设置,无需手动填写)',
|
|
187
|
+
},
|
|
186
188
|
threshold: { type: 'number', description: '相似度阈值,默认 0.7' },
|
|
189
|
+
supersedes: {
|
|
190
|
+
type: 'string',
|
|
191
|
+
description: '被替代的旧 Recipe ID。传入后将创建 supersede 提案,72h 观察窗口后自动替代。',
|
|
192
|
+
},
|
|
187
193
|
},
|
|
188
194
|
required: getInternalAgentRequiredFields(),
|
|
189
195
|
},
|
|
190
196
|
handler: async (params, ctx) => {
|
|
191
197
|
const projectRoot = ctx.projectRoot;
|
|
198
|
+
// ── 标题正规化:剥离冗余的项目名前缀 ──
|
|
199
|
+
if (params.title) {
|
|
200
|
+
params.title = stripProjectNamePrefix(params.title, projectRoot);
|
|
201
|
+
}
|
|
192
202
|
// ── Bootstrap 维度类型校验 ──
|
|
193
203
|
const dimMeta = ctx._dimensionMeta;
|
|
194
204
|
if (dimMeta && ctx.source === 'system') {
|
|
@@ -206,122 +216,111 @@ export const submitWithCheck = {
|
|
|
206
216
|
params.tags.push('bootstrap');
|
|
207
217
|
}
|
|
208
218
|
}
|
|
209
|
-
//
|
|
219
|
+
// ── 系统自动设置 ──
|
|
220
|
+
const item = {
|
|
221
|
+
...params,
|
|
222
|
+
language: ctx._projectLanguage || '',
|
|
223
|
+
category: dimMeta ? dimMeta.id : 'general',
|
|
224
|
+
knowledgeType: dimMeta?.allowedKnowledgeTypes?.[0] || params.knowledgeType || 'code-pattern',
|
|
225
|
+
source: ctx.source === 'system' ? 'bootstrap' : 'agent',
|
|
226
|
+
agentNotes: dimMeta
|
|
227
|
+
? { dimensionId: dimMeta.id, outputType: dimMeta.outputType || 'candidate' }
|
|
228
|
+
: null,
|
|
229
|
+
};
|
|
210
230
|
if (dimMeta && ctx.source === 'system') {
|
|
211
|
-
const
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
const
|
|
217
|
-
|
|
231
|
+
const displayGroup = DIMENSION_DISPLAY_GROUP[dimMeta.id] || dimMeta.id;
|
|
232
|
+
item.tags = [...new Set([...(item.tags || []), displayGroup])];
|
|
233
|
+
}
|
|
234
|
+
// ── 委托 RecipeProductionGateway 统一管道(含查重) ──
|
|
235
|
+
try {
|
|
236
|
+
const { RecipeProductionGateway } = await import('#service/knowledge/RecipeProductionGateway.js');
|
|
237
|
+
const gateway = new RecipeProductionGateway({
|
|
238
|
+
knowledgeService: ctx.container.get('knowledgeService'),
|
|
239
|
+
projectRoot,
|
|
240
|
+
logger: ctx.logger,
|
|
241
|
+
proposalRepository: ctx.container.get('proposalRepository') ?? null,
|
|
242
|
+
findSimilarRecipes,
|
|
218
243
|
});
|
|
219
|
-
|
|
220
|
-
|
|
244
|
+
const gatewayResult = await gateway.create({
|
|
245
|
+
source: 'agent-tool',
|
|
246
|
+
items: [item],
|
|
247
|
+
options: {
|
|
248
|
+
skipSimilarityCheck: false,
|
|
249
|
+
skipConsolidation: true,
|
|
250
|
+
similarityThreshold: params.threshold || 0.7,
|
|
251
|
+
supersedes: params.supersedes,
|
|
252
|
+
existingTitles: ctx._submittedTitles,
|
|
253
|
+
existingFingerprints: ctx._submittedPatterns,
|
|
254
|
+
systemInjectedFields: getSystemInjectedFields(),
|
|
255
|
+
userId: 'agent',
|
|
256
|
+
},
|
|
257
|
+
});
|
|
258
|
+
// ── 映射 Gateway 结果 → 原有返回格式 ──
|
|
259
|
+
// 验证拒绝
|
|
260
|
+
if (gatewayResult.rejected.length > 0 && gatewayResult.created.length === 0) {
|
|
261
|
+
const rej = gatewayResult.rejected[0];
|
|
262
|
+
if (rej.reason === 'validation_failed') {
|
|
263
|
+
return {
|
|
264
|
+
submitted: false,
|
|
265
|
+
status: 'rejected',
|
|
266
|
+
reason: 'validation_failed',
|
|
267
|
+
errors: rej.errors,
|
|
268
|
+
warnings: rej.warnings,
|
|
269
|
+
_meta: {
|
|
270
|
+
confidence: 'high',
|
|
271
|
+
hint: '请根据错误信息调整内容后重新提交。',
|
|
272
|
+
},
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
return { submitted: false, reason: 'submit_error', error: rej.errors.join('\n') };
|
|
276
|
+
}
|
|
277
|
+
// 重复阻止
|
|
278
|
+
if (gatewayResult.duplicates.length > 0) {
|
|
279
|
+
const dup = gatewayResult.duplicates[0];
|
|
221
280
|
return {
|
|
222
281
|
submitted: false,
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
warnings: validResult.warnings,
|
|
282
|
+
reason: 'duplicate_blocked',
|
|
283
|
+
similar: dup.similarTo,
|
|
284
|
+
highestSimilarity: dup.similarTo[0]?.similarity || 0,
|
|
227
285
|
_meta: {
|
|
228
286
|
confidence: 'high',
|
|
229
|
-
hint:
|
|
287
|
+
hint: `发现高度相似 Recipe(相似度 ${((dup.similarTo[0]?.similarity || 0) * 100).toFixed(0)}%),已阻止提交。`,
|
|
230
288
|
},
|
|
231
289
|
};
|
|
232
290
|
}
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
confidence: 0.7,
|
|
265
|
-
};
|
|
266
|
-
const systemFields = {
|
|
267
|
-
language: ctx._projectLanguage || '',
|
|
268
|
-
category: dimMeta
|
|
269
|
-
? DIMENSION_DISPLAY_GROUP[dimMeta.id] || dimMeta.id
|
|
270
|
-
: 'general',
|
|
271
|
-
knowledgeType: dimMeta?.allowedKnowledgeTypes?.[0] || 'code-pattern',
|
|
272
|
-
source: ctx.source === 'system' ? 'bootstrap' : 'agent',
|
|
273
|
-
};
|
|
274
|
-
const data = {
|
|
275
|
-
...systemFields,
|
|
276
|
-
title: params.title || '',
|
|
277
|
-
description: params.description || '',
|
|
278
|
-
tags: params.tags || [],
|
|
279
|
-
trigger: params.trigger || '',
|
|
280
|
-
kind: params.kind || 'pattern',
|
|
281
|
-
topicHint: params.topicHint || '',
|
|
282
|
-
whenClause: params.whenClause || '',
|
|
283
|
-
doClause: params.doClause || '',
|
|
284
|
-
dontClause: params.dontClause || '',
|
|
285
|
-
coreCode: contentObj2.pattern || '',
|
|
286
|
-
content: contentObj2,
|
|
287
|
-
reasoning,
|
|
288
|
-
// V3 扩展字段直透(与 submit_knowledge 对齐)
|
|
289
|
-
headers: params.headers || [],
|
|
290
|
-
usageGuide: params.usageGuide || '',
|
|
291
|
-
scope: params.scope || '',
|
|
292
|
-
complexity: params.complexity || '',
|
|
293
|
-
// 注意: sourceFile 由 KnowledgeFileWriter.persist() 自动设置,
|
|
294
|
-
// 不应从 AI params/reasoning.sources 取值(那是项目源文件路径,不是知识文件路径)
|
|
295
|
-
sourceFile: '',
|
|
296
|
-
// agentNotes / aiInsight(与 submit_knowledge 对齐)
|
|
297
|
-
agentNotes: dimMeta
|
|
298
|
-
? { dimensionId: dimMeta.id, outputType: dimMeta.outputType || 'candidate' }
|
|
299
|
-
: null,
|
|
300
|
-
aiInsight: reasoning.whyStandard || params.description || null,
|
|
301
|
-
};
|
|
302
|
-
if (dimMeta && ctx.source === 'system') {
|
|
303
|
-
const displayGroup = DIMENSION_DISPLAY_GROUP[dimMeta.id] || dimMeta.id;
|
|
304
|
-
data.tags = [...new Set([...(data.tags || []), displayGroup])];
|
|
305
|
-
}
|
|
306
|
-
const created = await knowledgeService.create(data, { userId: 'agent' });
|
|
307
|
-
// QualityScorer 自动评分(与 submit_knowledge 对齐)
|
|
308
|
-
try {
|
|
309
|
-
await knowledgeService.updateQuality(created.id, { userId: 'agent' });
|
|
310
|
-
}
|
|
311
|
-
catch {
|
|
312
|
-
/* best effort */
|
|
291
|
+
// 成功创建
|
|
292
|
+
if (gatewayResult.created.length > 0) {
|
|
293
|
+
const created = gatewayResult.created[0];
|
|
294
|
+
const raw = created.raw;
|
|
295
|
+
const entry = typeof raw.toJSON === 'function'
|
|
296
|
+
? raw.toJSON()
|
|
297
|
+
: raw;
|
|
298
|
+
// 获取低相似度匹配(如有)
|
|
299
|
+
const contentObj2 = params.content && typeof params.content === 'object'
|
|
300
|
+
? params.content
|
|
301
|
+
: { markdown: '', pattern: '' };
|
|
302
|
+
const cand = {
|
|
303
|
+
title: params.title || '',
|
|
304
|
+
summary: params.description || '',
|
|
305
|
+
code: contentObj2.markdown || contentObj2.pattern || '',
|
|
306
|
+
};
|
|
307
|
+
const similar = findSimilarRecipes(projectRoot, cand, { threshold: 0.5, topK: 5 });
|
|
308
|
+
return {
|
|
309
|
+
submitted: true,
|
|
310
|
+
entry,
|
|
311
|
+
similar: similar.length > 0 ? similar : [],
|
|
312
|
+
...(gatewayResult.supersedeProposal
|
|
313
|
+
? { _supersedeProposal: gatewayResult.supersedeProposal }
|
|
314
|
+
: {}),
|
|
315
|
+
_meta: {
|
|
316
|
+
confidence: 'high',
|
|
317
|
+
hint: similar.length > 0
|
|
318
|
+
? `已提交,但有 ${similar.length} 个低相似度匹配。`
|
|
319
|
+
: '已提交,无重复风险。',
|
|
320
|
+
},
|
|
321
|
+
};
|
|
313
322
|
}
|
|
314
|
-
return {
|
|
315
|
-
submitted: true,
|
|
316
|
-
entry: typeof created.toJSON === 'function' ? created.toJSON() : created,
|
|
317
|
-
similar: similar.length > 0 ? similar : [],
|
|
318
|
-
_meta: {
|
|
319
|
-
confidence: 'high',
|
|
320
|
-
hint: similar.length > 0
|
|
321
|
-
? `已提交,但有 ${similar.length} 个低相似度匹配。`
|
|
322
|
-
: '已提交,无重复风险。',
|
|
323
|
-
},
|
|
324
|
-
};
|
|
323
|
+
return { submitted: false, reason: 'submit_error', error: 'No items created' };
|
|
325
324
|
}
|
|
326
325
|
catch (err) {
|
|
327
326
|
return { submitted: false, reason: 'submit_error', error: err.message };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* evolution-tools.ts — Evolution Agent 专用工具
|
|
3
|
+
*
|
|
4
|
+
* 三个提案驱动的决策工具,供 Evolution Agent 在 rescan 时对现有 Recipe 做出明确决策:
|
|
5
|
+
* - propose_evolution: 附加进化提案(代码已变但知识仍有价值)
|
|
6
|
+
* - confirm_deprecation: 确认 Recipe 应被废弃(加速 deprecate 流程)
|
|
7
|
+
* - skip_evolution: 显式跳过进化决策(仍然有效或信息不足)
|
|
8
|
+
*
|
|
9
|
+
* @module agent/tools/evolution-tools
|
|
10
|
+
*/
|
|
11
|
+
import type { ToolHandlerContext } from './_shared.js';
|
|
12
|
+
export interface ProposeEvolutionParams {
|
|
13
|
+
recipeId: string;
|
|
14
|
+
type: 'enhance' | 'correction';
|
|
15
|
+
description: string;
|
|
16
|
+
evidence: {
|
|
17
|
+
sourceStatus: 'exists' | 'moved' | 'modified' | 'deleted';
|
|
18
|
+
currentCode?: string;
|
|
19
|
+
newLocation?: string;
|
|
20
|
+
suggestedChanges: string;
|
|
21
|
+
};
|
|
22
|
+
confidence: number;
|
|
23
|
+
}
|
|
24
|
+
interface ConfirmDeprecationParams {
|
|
25
|
+
recipeId: string;
|
|
26
|
+
reason: string;
|
|
27
|
+
}
|
|
28
|
+
interface SkipEvolutionParams {
|
|
29
|
+
recipeId: string;
|
|
30
|
+
reason: string;
|
|
31
|
+
}
|
|
32
|
+
export declare const proposeEvolution: {
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
parameters: {
|
|
36
|
+
type: string;
|
|
37
|
+
properties: {
|
|
38
|
+
recipeId: {
|
|
39
|
+
type: string;
|
|
40
|
+
description: string;
|
|
41
|
+
};
|
|
42
|
+
type: {
|
|
43
|
+
type: string;
|
|
44
|
+
enum: string[];
|
|
45
|
+
description: string;
|
|
46
|
+
};
|
|
47
|
+
description: {
|
|
48
|
+
type: string;
|
|
49
|
+
description: string;
|
|
50
|
+
};
|
|
51
|
+
evidence: {
|
|
52
|
+
type: string;
|
|
53
|
+
description: string;
|
|
54
|
+
properties: {
|
|
55
|
+
sourceStatus: {
|
|
56
|
+
type: string;
|
|
57
|
+
enum: string[];
|
|
58
|
+
description: string;
|
|
59
|
+
};
|
|
60
|
+
currentCode: {
|
|
61
|
+
type: string;
|
|
62
|
+
description: string;
|
|
63
|
+
};
|
|
64
|
+
newLocation: {
|
|
65
|
+
type: string;
|
|
66
|
+
description: string;
|
|
67
|
+
};
|
|
68
|
+
suggestedChanges: {
|
|
69
|
+
type: string;
|
|
70
|
+
description: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
required: string[];
|
|
74
|
+
};
|
|
75
|
+
confidence: {
|
|
76
|
+
type: string;
|
|
77
|
+
description: string;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
required: string[];
|
|
81
|
+
};
|
|
82
|
+
handler: (params: ProposeEvolutionParams, ctx: ToolHandlerContext) => Promise<{
|
|
83
|
+
status: "error";
|
|
84
|
+
message: string;
|
|
85
|
+
recipeId: string;
|
|
86
|
+
proposalId?: undefined;
|
|
87
|
+
type?: undefined;
|
|
88
|
+
expiresAt?: undefined;
|
|
89
|
+
} | {
|
|
90
|
+
status: "proposed";
|
|
91
|
+
proposalId: string;
|
|
92
|
+
recipeId: string;
|
|
93
|
+
type: "enhance" | "correction";
|
|
94
|
+
expiresAt: number;
|
|
95
|
+
message?: undefined;
|
|
96
|
+
}>;
|
|
97
|
+
};
|
|
98
|
+
export declare const confirmDeprecation: {
|
|
99
|
+
name: string;
|
|
100
|
+
description: string;
|
|
101
|
+
parameters: {
|
|
102
|
+
type: string;
|
|
103
|
+
properties: {
|
|
104
|
+
recipeId: {
|
|
105
|
+
type: string;
|
|
106
|
+
description: string;
|
|
107
|
+
};
|
|
108
|
+
reason: {
|
|
109
|
+
type: string;
|
|
110
|
+
description: string;
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
required: string[];
|
|
114
|
+
};
|
|
115
|
+
handler: (params: ConfirmDeprecationParams, ctx: ToolHandlerContext) => Promise<{
|
|
116
|
+
status: string;
|
|
117
|
+
recipeId: string;
|
|
118
|
+
reason: string;
|
|
119
|
+
result: unknown;
|
|
120
|
+
}>;
|
|
121
|
+
};
|
|
122
|
+
export declare const skipEvolution: {
|
|
123
|
+
name: string;
|
|
124
|
+
description: string;
|
|
125
|
+
parameters: {
|
|
126
|
+
type: string;
|
|
127
|
+
properties: {
|
|
128
|
+
recipeId: {
|
|
129
|
+
type: string;
|
|
130
|
+
description: string;
|
|
131
|
+
};
|
|
132
|
+
reason: {
|
|
133
|
+
type: string;
|
|
134
|
+
description: string;
|
|
135
|
+
};
|
|
136
|
+
};
|
|
137
|
+
required: string[];
|
|
138
|
+
};
|
|
139
|
+
handler: (params: SkipEvolutionParams, _ctx: ToolHandlerContext) => Promise<{
|
|
140
|
+
status: string;
|
|
141
|
+
recipeId: string;
|
|
142
|
+
reason: string;
|
|
143
|
+
}>;
|
|
144
|
+
};
|
|
145
|
+
export {};
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* evolution-tools.ts — Evolution Agent 专用工具
|
|
3
|
+
*
|
|
4
|
+
* 三个提案驱动的决策工具,供 Evolution Agent 在 rescan 时对现有 Recipe 做出明确决策:
|
|
5
|
+
* - propose_evolution: 附加进化提案(代码已变但知识仍有价值)
|
|
6
|
+
* - confirm_deprecation: 确认 Recipe 应被废弃(加速 deprecate 流程)
|
|
7
|
+
* - skip_evolution: 显式跳过进化决策(仍然有效或信息不足)
|
|
8
|
+
*
|
|
9
|
+
* @module agent/tools/evolution-tools
|
|
10
|
+
*/
|
|
11
|
+
// ──────────────────────────────────────────────────────────
|
|
12
|
+
// propose_evolution — 为现有 Recipe 附加进化提案
|
|
13
|
+
// ──────────────────────────────────────────────────────────
|
|
14
|
+
export const proposeEvolution = {
|
|
15
|
+
name: 'propose_evolution',
|
|
16
|
+
description: '为现有 Recipe 附加进化提案(代码已变化但知识仍有价值时使用,不创建新 Recipe)',
|
|
17
|
+
parameters: {
|
|
18
|
+
type: 'object',
|
|
19
|
+
properties: {
|
|
20
|
+
recipeId: { type: 'string', description: '目标 Recipe ID' },
|
|
21
|
+
type: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
enum: ['enhance', 'correction'],
|
|
24
|
+
description: '提案类型: enhance=增强补充(代码迁移/扩展), correction=纠正错误(代码变更导致描述不准确)',
|
|
25
|
+
},
|
|
26
|
+
description: {
|
|
27
|
+
type: 'string',
|
|
28
|
+
description: '描述发生了什么变化、为什么需要更新(人类可读)',
|
|
29
|
+
},
|
|
30
|
+
evidence: {
|
|
31
|
+
type: 'object',
|
|
32
|
+
description: '代码验证证据',
|
|
33
|
+
properties: {
|
|
34
|
+
sourceStatus: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
enum: ['exists', 'moved', 'modified', 'deleted'],
|
|
37
|
+
description: '源文件状态: exists=存在但内容变化, moved=迁移到新位置, modified=签名/结构变化, deleted=已删除但有替代',
|
|
38
|
+
},
|
|
39
|
+
currentCode: {
|
|
40
|
+
type: 'string',
|
|
41
|
+
description: '当前实际代码片段(验证时读到的)',
|
|
42
|
+
},
|
|
43
|
+
newLocation: {
|
|
44
|
+
type: 'string',
|
|
45
|
+
description: '新文件路径(仅 moved 时填写)',
|
|
46
|
+
},
|
|
47
|
+
suggestedChanges: {
|
|
48
|
+
type: 'string',
|
|
49
|
+
description: '建议对 Recipe 做出的具体更新',
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
required: ['sourceStatus', 'suggestedChanges'],
|
|
53
|
+
},
|
|
54
|
+
confidence: {
|
|
55
|
+
type: 'number',
|
|
56
|
+
description: '置信度 0.0-1.0(基于代码验证的确定程度)',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ['recipeId', 'type', 'description', 'evidence', 'confidence'],
|
|
60
|
+
},
|
|
61
|
+
handler: async (params, ctx) => {
|
|
62
|
+
const { recipeId, type, description, evidence, confidence } = params;
|
|
63
|
+
// 通过 ProposalRepository 创建提案
|
|
64
|
+
const proposalRepo = ctx.container.get('proposalRepository');
|
|
65
|
+
if (!proposalRepo) {
|
|
66
|
+
return {
|
|
67
|
+
status: 'error',
|
|
68
|
+
message: 'ProposalRepository not available',
|
|
69
|
+
recipeId,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
const proposal = proposalRepo.create({
|
|
73
|
+
type,
|
|
74
|
+
targetRecipeId: recipeId,
|
|
75
|
+
relatedRecipeIds: [],
|
|
76
|
+
confidence: Math.max(0, Math.min(1, confidence)),
|
|
77
|
+
source: 'decay-scan',
|
|
78
|
+
description,
|
|
79
|
+
evidence: [
|
|
80
|
+
{
|
|
81
|
+
sourceStatus: evidence.sourceStatus,
|
|
82
|
+
currentCode: evidence.currentCode,
|
|
83
|
+
newLocation: evidence.newLocation,
|
|
84
|
+
suggestedChanges: evidence.suggestedChanges,
|
|
85
|
+
verifiedBy: 'evolution-agent',
|
|
86
|
+
verifiedAt: Date.now(),
|
|
87
|
+
},
|
|
88
|
+
],
|
|
89
|
+
});
|
|
90
|
+
if (!proposal) {
|
|
91
|
+
return {
|
|
92
|
+
status: 'error',
|
|
93
|
+
message: 'Failed to create proposal (target recipe may not exist or duplicate proposal)',
|
|
94
|
+
recipeId,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return {
|
|
98
|
+
status: 'proposed',
|
|
99
|
+
proposalId: proposal.id,
|
|
100
|
+
recipeId,
|
|
101
|
+
type,
|
|
102
|
+
expiresAt: proposal.expiresAt,
|
|
103
|
+
};
|
|
104
|
+
},
|
|
105
|
+
};
|
|
106
|
+
// ──────────────────────────────────────────────────────────
|
|
107
|
+
// confirm_deprecation — 确认 Recipe 应被废弃
|
|
108
|
+
// ──────────────────────────────────────────────────────────
|
|
109
|
+
export const confirmDeprecation = {
|
|
110
|
+
name: 'confirm_deprecation',
|
|
111
|
+
description: '确认一个衰退 Recipe 应被废弃(加速废弃流程,跳过观察窗口)',
|
|
112
|
+
parameters: {
|
|
113
|
+
type: 'object',
|
|
114
|
+
properties: {
|
|
115
|
+
recipeId: { type: 'string', description: '要废弃的 Recipe ID' },
|
|
116
|
+
reason: { type: 'string', description: '废弃原因(人类可读)' },
|
|
117
|
+
},
|
|
118
|
+
required: ['recipeId', 'reason'],
|
|
119
|
+
},
|
|
120
|
+
handler: async (params, ctx) => {
|
|
121
|
+
const { recipeId, reason } = params;
|
|
122
|
+
// 1. 通过 knowledgeService 将 lifecycle 转为 deprecated
|
|
123
|
+
const knowledgeService = ctx.container.get('knowledgeService');
|
|
124
|
+
const result = knowledgeService.deprecate(recipeId, reason, { userId: 'evolution-agent' });
|
|
125
|
+
// 2. 尝试解决关联的 deprecate proposal(status → executed)
|
|
126
|
+
try {
|
|
127
|
+
const proposalRepo = ctx.container.get('proposalRepository');
|
|
128
|
+
if (proposalRepo) {
|
|
129
|
+
const existing = proposalRepo.findByTarget(recipeId);
|
|
130
|
+
for (const p of existing) {
|
|
131
|
+
if (p.type === 'deprecate') {
|
|
132
|
+
proposalRepo.markExecuted(p.id, `Evolution Agent confirmed deprecation: ${reason}`, 'evolution-agent');
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// ProposalRepository 不可用时静默失败
|
|
139
|
+
}
|
|
140
|
+
return { status: 'deprecated', recipeId, reason, result };
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
// ──────────────────────────────────────────────────────────
|
|
144
|
+
// skip_evolution — 显式跳过进化决策
|
|
145
|
+
// ──────────────────────────────────────────────────────────
|
|
146
|
+
export const skipEvolution = {
|
|
147
|
+
name: 'skip_evolution',
|
|
148
|
+
description: '显式跳过一个 Recipe 的进化决策(信息不足或不紧急,交给时限机制处理)',
|
|
149
|
+
parameters: {
|
|
150
|
+
type: 'object',
|
|
151
|
+
properties: {
|
|
152
|
+
recipeId: { type: 'string', description: '跳过的 Recipe ID' },
|
|
153
|
+
reason: { type: 'string', description: '跳过原因' },
|
|
154
|
+
},
|
|
155
|
+
required: ['recipeId', 'reason'],
|
|
156
|
+
},
|
|
157
|
+
handler: async (params, _ctx) => {
|
|
158
|
+
// 不修改 proposal 状态,仅记录决策
|
|
159
|
+
return { status: 'skipped', recipeId: params.recipeId, reason: params.reason };
|
|
160
|
+
},
|
|
161
|
+
};
|