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
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* insight-evolver.ts — Evolution Agent 领域函数
|
|
3
|
+
*
|
|
4
|
+
* Evolution Agent 是管线中的专职进化角色:
|
|
5
|
+
* - 接收当前维度的**全部**现有 Recipe(不仅是衰退的)
|
|
6
|
+
* - 使用工具读取真实代码,验证每个 Recipe 的真实性
|
|
7
|
+
* - 通过**附加提案**(Proposal)驱动状态变更,不创建新 Recipe
|
|
8
|
+
* - 三种决策: propose_evolution / confirm_deprecation / skip_evolution
|
|
9
|
+
*
|
|
10
|
+
* 被 PipelineStrategy 的 evolution preset 引用。
|
|
11
|
+
* 按维度隔离:每个维度的 Evolve Stage 只处理属于该维度的 Recipe。
|
|
12
|
+
*
|
|
13
|
+
* @module insight-evolver
|
|
14
|
+
*/
|
|
15
|
+
/** 静态审计 hint(可选)— 来自 RecipeRelevanceAuditor */
|
|
16
|
+
export interface AuditHint {
|
|
17
|
+
relevanceScore: number;
|
|
18
|
+
verdict: string;
|
|
19
|
+
evidence: {
|
|
20
|
+
triggerStillMatches: boolean;
|
|
21
|
+
symbolsAlive: number;
|
|
22
|
+
depsIntact: boolean;
|
|
23
|
+
codeFilesExist: number;
|
|
24
|
+
};
|
|
25
|
+
decayReasons: string[];
|
|
26
|
+
}
|
|
27
|
+
/** 现有 Recipe(含可选的 audit hint) */
|
|
28
|
+
export interface ExistingRecipeForEvolution {
|
|
29
|
+
id: string;
|
|
30
|
+
title: string;
|
|
31
|
+
trigger: string;
|
|
32
|
+
content?: {
|
|
33
|
+
markdown?: string;
|
|
34
|
+
rationale?: string;
|
|
35
|
+
coreCode?: string;
|
|
36
|
+
};
|
|
37
|
+
sourceRefs?: string[];
|
|
38
|
+
/** 静态审计 hint — 仅供参考,Agent 应通过读代码自行验证 */
|
|
39
|
+
auditHint?: AuditHint | null;
|
|
40
|
+
}
|
|
41
|
+
/** Evolution Agent 上下文 */
|
|
42
|
+
export interface EvolutionContext {
|
|
43
|
+
/** 当前维度的全部现有 Recipe(healthy + decaying),按维度过滤后注入 */
|
|
44
|
+
existingRecipes: ExistingRecipeForEvolution[];
|
|
45
|
+
dimensionId: string;
|
|
46
|
+
dimensionLabel: string;
|
|
47
|
+
projectOverview: {
|
|
48
|
+
primaryLang: string;
|
|
49
|
+
fileCount: number;
|
|
50
|
+
modules: string[];
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export declare const EVOLVER_SYSTEM_PROMPT = "\u4F60\u662F AutoSnippet \u7684 **Evolution Agent**\uFF0C\u4E13\u804C\u9A8C\u8BC1\u9879\u76EE\u4E2D\u73B0\u6709\u77E5\u8BC6\u6761\u76EE\uFF08Recipe\uFF09\u7684\u771F\u5B9E\u6027\u4E0E\u65F6\u6548\u6027\u3002\n\n## \u6838\u5FC3\u804C\u8D23\n\n\u4F60\u901A\u8FC7\u9605\u8BFB\u9879\u76EE\u771F\u5B9E\u4EE3\u7801\u6765\u9A8C\u8BC1\u6BCF\u6761 Recipe \u662F\u5426\u4ECD\u7136\u53CD\u6620\u5F53\u524D\u9879\u76EE\u5B9E\u8DF5\u3002\n\u4F60\u7684\u5DE5\u4F5C\u7ED3\u679C\u4EE5**\u63D0\u6848\uFF08Proposal\uFF09**\u65B9\u5F0F\u9644\u52A0\u5230\u73B0\u6709 Recipe \u4E0A\uFF0C\u63A8\u52A8\u77E5\u8BC6\u5E93\u7684\u6E10\u8FDB\u5F0F\u6F14\u5316\u3002\n\u4F60**\u4E0D\u521B\u5EFA\u65B0 Recipe**\u2014\u2014\u90A3\u662F\u540E\u7EED Produce \u9636\u6BB5\u7684\u804C\u8D23\u3002\n\n## \u9A8C\u8BC1\u6D41\u7A0B\n\n\u5BF9\u6BCF\u4E2A Recipe \u6309\u4EE5\u4E0B\u6B65\u9AA4\u9A8C\u8BC1:\n1. \u9605\u8BFB Recipe \u7684\u6838\u5FC3\u4EE3\u7801\u7247\u6BB5\u548C\u6E90\u6587\u4EF6\u5F15\u7528\uFF0C\u7406\u89E3\u5176\u63CF\u8FF0\u7684\u6A21\u5F0F\n2. \u4F7F\u7528 `read_project_file` \u8BFB\u53D6\u6E90\u6587\u4EF6\uFF0C\u9A8C\u8BC1\u4EE3\u7801\u662F\u5426\u5B58\u5728\u4E14\u4E0E Recipe \u63CF\u8FF0\u5339\u914D\n3. \u5982\u679C\u6E90\u6587\u4EF6\u4E0D\u5B58\u5728\u6216\u4EE3\u7801\u4E0D\u5339\u914D\uFF0C\u4F7F\u7528 `search_project_code` \u641C\u7D22\u8BE5\u6A21\u5F0F\u662F\u5426\u5DF2\u8FC1\u79FB\u5230\u5176\u4ED6\u4F4D\u7F6E\n4. \u57FA\u4E8E\u771F\u5B9E\u4EE3\u7801\u7684\u9A8C\u8BC1\u7ED3\u679C\u505A\u51FA\u51B3\u7B56\n\n## \u51B3\u7B56\u89C4\u5219\n\n\u6309\u4EE5\u4E0B\u51B3\u7B56\u6811\u5224\u65AD\uFF08\u4F18\u5148\u7EA7\u4ECE\u4E0A\u5230\u4E0B\uFF09:\n\n| \u9A8C\u8BC1\u7ED3\u679C | \u51B3\u7B56 | \u5DE5\u5177 |\n|---------|------|------|\n| \u6E90\u6587\u4EF6\u5B58\u5728 + \u4EE3\u7801\u5339\u914D Recipe \u63CF\u8FF0 | **\u8DF3\u8FC7**: \u4ECD\u7136\u6709\u6548 | `skip_evolution` |\n| \u6E90\u6587\u4EF6\u5B58\u5728 + \u4EE3\u7801\u5DF2\u53D8\u5316\uFF08\u63A5\u53E3\u6539\u53D8/\u91CD\u6784\uFF09 | **\u8FDB\u5316\u63D0\u6848**: \u9644\u52A0\u53D8\u66F4\u8BC1\u636E | `propose_evolution` |\n| \u6E90\u6587\u4EF6\u4E0D\u5B58\u5728 + \u6A21\u5F0F\u5DF2\u8FC1\u79FB\u5230\u65B0\u4F4D\u7F6E | **\u8FDB\u5316\u63D0\u6848**: \u9644\u52A0\u8FC1\u79FB\u8BC1\u636E | `propose_evolution` |\n| \u6E90\u6587\u4EF6\u4E0D\u5B58\u5728 + \u5B8C\u5168\u65E0\u66FF\u4EE3 | **\u786E\u8BA4\u5E9F\u5F03**: \u77E5\u8BC6\u5DF2\u5931\u6548 | `confirm_deprecation` |\n| \u4FE1\u606F\u4E0D\u8DB3\u4EE5\u505A\u51FA\u5224\u65AD | **\u8DF3\u8FC7**: \u4EA4\u7ED9\u65F6\u9650\u673A\u5236 | `skip_evolution` |\n\n## \u5DE5\u5177\u8BF4\u660E\n\n- `propose_evolution` \u2014 \u4E3A Recipe \u9644\u52A0\u8FDB\u5316\u63D0\u6848\uFF0C\u5305\u542B\u4EE3\u7801\u9A8C\u8BC1\u8BC1\u636E\u548C\u5EFA\u8BAE\u53D8\u66F4\u3002\u63D0\u6848\u8FDB\u5165\u89C2\u5BDF\u7A97\u53E3\uFF08enhance: 48h, correction: 24h\uFF09\uFF0C\u4E0D\u76F4\u63A5\u4FEE\u6539 Recipe\n- `confirm_deprecation` \u2014 \u786E\u8BA4 Recipe \u5DF2\u8FC7\u65F6\uFF0C\u7ACB\u5373\u6807\u8BB0\u4E3A deprecated\uFF08\u8DF3\u8FC7\u89C2\u5BDF\u7A97\u53E3\uFF09\n- `skip_evolution` \u2014 \u663E\u5F0F\u8DF3\u8FC7\uFF0Creason \u4E2D\u8BF4\u660E\u662F\"\u9A8C\u8BC1\u6709\u6548\"\u8FD8\u662F\"\u4FE1\u606F\u4E0D\u8DB3\"\n\n## \u91CD\u8981\u7EA6\u675F\n\n- \u6BCF\u4E2A Recipe \u5FC5\u987B\u6709\u4E00\u4E2A\u660E\u786E\u51B3\u7B56\uFF0C\u4E0D\u8981\u9057\u6F0F\u4EFB\u4F55\u4E00\u4E2A\n- `propose_evolution` \u7684 evidence \u5B57\u6BB5\u5FC5\u987B\u5305\u542B\u4F60\u8BFB\u5230\u7684\u771F\u5B9E\u4EE3\u7801\uFF0C\u4E0D\u8981\u7F16\u9020\n- `propose_evolution` \u7684 type \u533A\u5206: enhance\uFF08\u6A21\u5F0F\u8FC1\u79FB/\u529F\u80FD\u6269\u5C55\uFF09vs correction\uFF08\u63CF\u8FF0\u9519\u8BEF/\u63A5\u53E3\u53D8\u66F4\uFF09\n- \u90E8\u5206 Recipe \u9644\u5E26\u7CFB\u7EDF\u9884\u68C0\u63D0\u793A\uFF08auditHint\uFF09\uFF0C\u4EC5\u4F9B\u53C2\u8003\u2014\u2014\u4F60\u5FC5\u987B\u4EE5\u5B9E\u9645\u8BFB\u5230\u7684\u4EE3\u7801\u4E3A\u51C6\n- \u5373\u4F7F\u9884\u68C0\u63D0\u793A\u8BF4\"healthy\"\uFF0C\u4F60\u8BFB\u4EE3\u7801\u540E\u53D1\u73B0\u4E0D\u5339\u914D\u4E5F\u8981\u63D0\u4EA4\u63D0\u6848";
|
|
54
|
+
export declare const EVOLVER_TOOLS: string[];
|
|
55
|
+
export declare const EVOLVER_BUDGET: {
|
|
56
|
+
maxIterations: number;
|
|
57
|
+
searchBudget: number;
|
|
58
|
+
searchBudgetGrace: number;
|
|
59
|
+
maxSubmits: number;
|
|
60
|
+
softSubmitLimit: number;
|
|
61
|
+
idleRoundsToExit: number;
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* 构建 Evolution Agent 的用户 Prompt
|
|
65
|
+
*
|
|
66
|
+
* 按维度打包全部现有 Recipe 清单 + 可选 audit hint + 项目概览,
|
|
67
|
+
* 让 Agent 通过提案机制对每个 Recipe 做出进化/废弃/跳过决策。
|
|
68
|
+
*/
|
|
69
|
+
export declare function buildEvolverPrompt(_phaseInput: unknown, _phaseResults: unknown, strategyContext: EvolutionContext): string;
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* insight-evolver.ts — Evolution Agent 领域函数
|
|
3
|
+
*
|
|
4
|
+
* Evolution Agent 是管线中的专职进化角色:
|
|
5
|
+
* - 接收当前维度的**全部**现有 Recipe(不仅是衰退的)
|
|
6
|
+
* - 使用工具读取真实代码,验证每个 Recipe 的真实性
|
|
7
|
+
* - 通过**附加提案**(Proposal)驱动状态变更,不创建新 Recipe
|
|
8
|
+
* - 三种决策: propose_evolution / confirm_deprecation / skip_evolution
|
|
9
|
+
*
|
|
10
|
+
* 被 PipelineStrategy 的 evolution preset 引用。
|
|
11
|
+
* 按维度隔离:每个维度的 Evolve Stage 只处理属于该维度的 Recipe。
|
|
12
|
+
*
|
|
13
|
+
* @module insight-evolver
|
|
14
|
+
*/
|
|
15
|
+
// ──────────────────────────────────────────────────────────────────
|
|
16
|
+
// System Prompt
|
|
17
|
+
// ──────────────────────────────────────────────────────────────────
|
|
18
|
+
export const EVOLVER_SYSTEM_PROMPT = `你是 AutoSnippet 的 **Evolution Agent**,专职验证项目中现有知识条目(Recipe)的真实性与时效性。
|
|
19
|
+
|
|
20
|
+
## 核心职责
|
|
21
|
+
|
|
22
|
+
你通过阅读项目真实代码来验证每条 Recipe 是否仍然反映当前项目实践。
|
|
23
|
+
你的工作结果以**提案(Proposal)**方式附加到现有 Recipe 上,推动知识库的渐进式演化。
|
|
24
|
+
你**不创建新 Recipe**——那是后续 Produce 阶段的职责。
|
|
25
|
+
|
|
26
|
+
## 验证流程
|
|
27
|
+
|
|
28
|
+
对每个 Recipe 按以下步骤验证:
|
|
29
|
+
1. 阅读 Recipe 的核心代码片段和源文件引用,理解其描述的模式
|
|
30
|
+
2. 使用 \`read_project_file\` 读取源文件,验证代码是否存在且与 Recipe 描述匹配
|
|
31
|
+
3. 如果源文件不存在或代码不匹配,使用 \`search_project_code\` 搜索该模式是否已迁移到其他位置
|
|
32
|
+
4. 基于真实代码的验证结果做出决策
|
|
33
|
+
|
|
34
|
+
## 决策规则
|
|
35
|
+
|
|
36
|
+
按以下决策树判断(优先级从上到下):
|
|
37
|
+
|
|
38
|
+
| 验证结果 | 决策 | 工具 |
|
|
39
|
+
|---------|------|------|
|
|
40
|
+
| 源文件存在 + 代码匹配 Recipe 描述 | **跳过**: 仍然有效 | \`skip_evolution\` |
|
|
41
|
+
| 源文件存在 + 代码已变化(接口改变/重构) | **进化提案**: 附加变更证据 | \`propose_evolution\` |
|
|
42
|
+
| 源文件不存在 + 模式已迁移到新位置 | **进化提案**: 附加迁移证据 | \`propose_evolution\` |
|
|
43
|
+
| 源文件不存在 + 完全无替代 | **确认废弃**: 知识已失效 | \`confirm_deprecation\` |
|
|
44
|
+
| 信息不足以做出判断 | **跳过**: 交给时限机制 | \`skip_evolution\` |
|
|
45
|
+
|
|
46
|
+
## 工具说明
|
|
47
|
+
|
|
48
|
+
- \`propose_evolution\` — 为 Recipe 附加进化提案,包含代码验证证据和建议变更。提案进入观察窗口(enhance: 48h, correction: 24h),不直接修改 Recipe
|
|
49
|
+
- \`confirm_deprecation\` — 确认 Recipe 已过时,立即标记为 deprecated(跳过观察窗口)
|
|
50
|
+
- \`skip_evolution\` — 显式跳过,reason 中说明是"验证有效"还是"信息不足"
|
|
51
|
+
|
|
52
|
+
## 重要约束
|
|
53
|
+
|
|
54
|
+
- 每个 Recipe 必须有一个明确决策,不要遗漏任何一个
|
|
55
|
+
- \`propose_evolution\` 的 evidence 字段必须包含你读到的真实代码,不要编造
|
|
56
|
+
- \`propose_evolution\` 的 type 区分: enhance(模式迁移/功能扩展)vs correction(描述错误/接口变更)
|
|
57
|
+
- 部分 Recipe 附带系统预检提示(auditHint),仅供参考——你必须以实际读到的代码为准
|
|
58
|
+
- 即使预检提示说"healthy",你读代码后发现不匹配也要提交提案`;
|
|
59
|
+
// ──────────────────────────────────────────────────────────────────
|
|
60
|
+
// 工具白名单
|
|
61
|
+
// ──────────────────────────────────────────────────────────────────
|
|
62
|
+
export const EVOLVER_TOOLS = [
|
|
63
|
+
'read_project_file',
|
|
64
|
+
'search_project_code',
|
|
65
|
+
'propose_evolution',
|
|
66
|
+
'confirm_deprecation',
|
|
67
|
+
'skip_evolution',
|
|
68
|
+
];
|
|
69
|
+
// ──────────────────────────────────────────────────────────────────
|
|
70
|
+
// 预算
|
|
71
|
+
// ──────────────────────────────────────────────────────────────────
|
|
72
|
+
export const EVOLVER_BUDGET = {
|
|
73
|
+
maxIterations: 20,
|
|
74
|
+
searchBudget: 10,
|
|
75
|
+
searchBudgetGrace: 4,
|
|
76
|
+
maxSubmits: 8,
|
|
77
|
+
softSubmitLimit: 8,
|
|
78
|
+
idleRoundsToExit: 2,
|
|
79
|
+
};
|
|
80
|
+
// ──────────────────────────────────────────────────────────────────
|
|
81
|
+
// Prompt 构建
|
|
82
|
+
// ──────────────────────────────────────────────────────────────────
|
|
83
|
+
/**
|
|
84
|
+
* 构建 Evolution Agent 的用户 Prompt
|
|
85
|
+
*
|
|
86
|
+
* 按维度打包全部现有 Recipe 清单 + 可选 audit hint + 项目概览,
|
|
87
|
+
* 让 Agent 通过提案机制对每个 Recipe 做出进化/废弃/跳过决策。
|
|
88
|
+
*/
|
|
89
|
+
export function buildEvolverPrompt(_phaseInput, _phaseResults, strategyContext) {
|
|
90
|
+
const { existingRecipes, dimensionId, dimensionLabel, projectOverview } = strategyContext;
|
|
91
|
+
const parts = [];
|
|
92
|
+
// §1 任务概述
|
|
93
|
+
parts.push(`# 验证任务: ${dimensionLabel} [${dimensionId}]`);
|
|
94
|
+
parts.push(`你需要验证 **${existingRecipes.length}** 个现有 Recipe 的真实性。`);
|
|
95
|
+
parts.push(`项目概况: ${projectOverview.primaryLang} 语言,${projectOverview.fileCount} 个文件。`);
|
|
96
|
+
if (projectOverview.modules.length > 0) {
|
|
97
|
+
parts.push(`主要模块: ${projectOverview.modules.slice(0, 10).join(', ')}`);
|
|
98
|
+
}
|
|
99
|
+
// §2 现有 Recipe 清单
|
|
100
|
+
parts.push('# 现有 Recipe 清单');
|
|
101
|
+
parts.push('以下是需要你验证的全部 Recipe。对每一个,你需要读取源文件、验证代码、然后做出决策。');
|
|
102
|
+
for (let i = 0; i < existingRecipes.length; i++) {
|
|
103
|
+
const recipe = existingRecipes[i];
|
|
104
|
+
const lines = [];
|
|
105
|
+
lines.push(`## [${i + 1}/${existingRecipes.length}] ${recipe.title}`);
|
|
106
|
+
lines.push(`- **ID**: \`${recipe.id}\``);
|
|
107
|
+
lines.push(`- **Trigger**: \`${recipe.trigger}\``);
|
|
108
|
+
// 源文件引用 — 验证的起点
|
|
109
|
+
if (recipe.sourceRefs && recipe.sourceRefs.length > 0) {
|
|
110
|
+
lines.push(`- **源文件引用** (请用 \`read_project_file\` 读取验证):`);
|
|
111
|
+
for (const ref of recipe.sourceRefs.slice(0, 5)) {
|
|
112
|
+
lines.push(` - \`${ref}\``);
|
|
113
|
+
}
|
|
114
|
+
if (recipe.sourceRefs.length > 5) {
|
|
115
|
+
lines.push(` - ... 及其他 ${recipe.sourceRefs.length - 5} 个文件`);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
lines.push('- **源文件引用**: 无(需要用 `search_project_code` 搜索相关代码)');
|
|
120
|
+
}
|
|
121
|
+
// Recipe 声称的核心代码(缩略)
|
|
122
|
+
if (recipe.content?.coreCode) {
|
|
123
|
+
const truncated = recipe.content.coreCode.length > 400
|
|
124
|
+
? `${recipe.content.coreCode.slice(0, 400)}...`
|
|
125
|
+
: recipe.content.coreCode;
|
|
126
|
+
lines.push(`- **Recipe 声称的核心代码** (需验证是否与实际一致):`);
|
|
127
|
+
lines.push(`\`\`\`\n${truncated}\n\`\`\``);
|
|
128
|
+
}
|
|
129
|
+
// Recipe 的设计原理
|
|
130
|
+
if (recipe.content?.rationale) {
|
|
131
|
+
const rationale = recipe.content.rationale.length > 200
|
|
132
|
+
? `${recipe.content.rationale.slice(0, 200)}...`
|
|
133
|
+
: recipe.content.rationale;
|
|
134
|
+
lines.push(`- **设计原理**: ${rationale}`);
|
|
135
|
+
}
|
|
136
|
+
// 静态审计 hint(可选)
|
|
137
|
+
if (recipe.auditHint) {
|
|
138
|
+
lines.push('- **系统预检提示** ⚠️ 仅供参考,以你读到的代码为准:');
|
|
139
|
+
lines.push(` - 评分: ${recipe.auditHint.relevanceScore}/100 → ${recipe.auditHint.verdict}`);
|
|
140
|
+
const ev = recipe.auditHint.evidence;
|
|
141
|
+
const checks = [
|
|
142
|
+
`Trigger: ${ev.triggerStillMatches ? '✅' : '❌'}`,
|
|
143
|
+
`符号: ${(ev.symbolsAlive * 100).toFixed(0)}%`,
|
|
144
|
+
`依赖: ${ev.depsIntact ? '✅' : '❌'}`,
|
|
145
|
+
`代码文件: ${(ev.codeFilesExist * 100).toFixed(0)}%`,
|
|
146
|
+
];
|
|
147
|
+
lines.push(` - ${checks.join(' | ')}`);
|
|
148
|
+
if (recipe.auditHint.decayReasons.length > 0) {
|
|
149
|
+
lines.push(` - 预检原因: ${recipe.auditHint.decayReasons.join('; ')}`);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
parts.push(lines.join('\n'));
|
|
153
|
+
}
|
|
154
|
+
// §3 验证工作流
|
|
155
|
+
parts.push('# 验证工作流');
|
|
156
|
+
parts.push('对每个 Recipe 按以下步骤执行:');
|
|
157
|
+
parts.push('');
|
|
158
|
+
parts.push('**步骤 1 — 读取源文件**');
|
|
159
|
+
parts.push('- 使用 `read_project_file` 读取 sourceRefs 中列出的文件');
|
|
160
|
+
parts.push('- 如果没有 sourceRefs,跳到步骤 2');
|
|
161
|
+
parts.push('');
|
|
162
|
+
parts.push('**步骤 2 — 搜索验证**(仅在源文件缺失或代码不匹配时)');
|
|
163
|
+
parts.push('- 使用 `search_project_code` 搜索 Recipe 中的类名、函数名、关键模式');
|
|
164
|
+
parts.push('- 确认该模式是否迁移到了新位置或已被完全移除');
|
|
165
|
+
parts.push('');
|
|
166
|
+
parts.push('**步骤 3 — 做出决策**');
|
|
167
|
+
parts.push('- 基于步骤 1-2 的验证结果,调用对应的决策工具');
|
|
168
|
+
// §4 决策指令
|
|
169
|
+
parts.push('# 决策指令');
|
|
170
|
+
parts.push('对上述每个 Recipe 做出以下三种决策之一:');
|
|
171
|
+
parts.push('');
|
|
172
|
+
parts.push('### 1. 🔄 附加进化提案 — 代码已变但知识仍有价值');
|
|
173
|
+
parts.push('调用 `propose_evolution`:');
|
|
174
|
+
parts.push('```json');
|
|
175
|
+
parts.push('{');
|
|
176
|
+
parts.push(' "recipeId": "recipe-xxx",');
|
|
177
|
+
parts.push(' "type": "enhance", // enhance=模式迁移/功能扩展, correction=描述错误/接口变更');
|
|
178
|
+
parts.push(' "description": "说明发生了什么变化",');
|
|
179
|
+
parts.push(' "evidence": {');
|
|
180
|
+
parts.push(' "sourceStatus": "modified", // exists|moved|modified|deleted');
|
|
181
|
+
parts.push(' "currentCode": "你读到的实际代码片段",');
|
|
182
|
+
parts.push(' "newLocation": "新路径(仅 moved 时)",');
|
|
183
|
+
parts.push(' "suggestedChanges": "{结构化 JSON — 见下方格式}"');
|
|
184
|
+
parts.push(' },');
|
|
185
|
+
parts.push(' "confidence": 0.85');
|
|
186
|
+
parts.push('}');
|
|
187
|
+
parts.push('```');
|
|
188
|
+
parts.push('');
|
|
189
|
+
parts.push('#### suggestedChanges 格式(重要!)');
|
|
190
|
+
parts.push('suggestedChanges 必须是一个 JSON 字符串,格式如下:');
|
|
191
|
+
parts.push('```json');
|
|
192
|
+
parts.push('{');
|
|
193
|
+
parts.push(' "patchVersion": 1,');
|
|
194
|
+
parts.push(' "changes": [');
|
|
195
|
+
parts.push(' {');
|
|
196
|
+
parts.push(' "field": "coreCode",');
|
|
197
|
+
parts.push(' "action": "replace",');
|
|
198
|
+
parts.push(' "newValue": "更新后的代码片段"');
|
|
199
|
+
parts.push(' },');
|
|
200
|
+
parts.push(' {');
|
|
201
|
+
parts.push(' "field": "content.markdown",');
|
|
202
|
+
parts.push(' "action": "replace-section",');
|
|
203
|
+
parts.push(' "section": "### 使用指南",');
|
|
204
|
+
parts.push(' "newContent": "### 使用指南\\n更新后的内容"');
|
|
205
|
+
parts.push(' }');
|
|
206
|
+
parts.push(' ],');
|
|
207
|
+
parts.push(' "reasoning": "源代码变更原因说明"');
|
|
208
|
+
parts.push('}');
|
|
209
|
+
parts.push('```');
|
|
210
|
+
parts.push('');
|
|
211
|
+
parts.push('可修改的字段: `coreCode`, `doClause`, `dontClause`, `whenClause`, `content.markdown`, `content.rationale`, `sourceRefs`, `headers`');
|
|
212
|
+
parts.push('操作类型: `replace`=全量替换, `replace-section`=替换 Markdown section, `append`=追加');
|
|
213
|
+
parts.push('');
|
|
214
|
+
parts.push('### 2. ⛔ 确认废弃 — 知识确实过时,无法挽救');
|
|
215
|
+
parts.push('调用 `confirm_deprecation`:');
|
|
216
|
+
parts.push('```json');
|
|
217
|
+
parts.push('{ "recipeId": "recipe-xxx", "reason": "具体废弃原因" }');
|
|
218
|
+
parts.push('```');
|
|
219
|
+
parts.push('');
|
|
220
|
+
parts.push('### 3. ⏭️ 跳过 — 仍然有效 或 信息不足');
|
|
221
|
+
parts.push('调用 `skip_evolution`:');
|
|
222
|
+
parts.push('```json');
|
|
223
|
+
parts.push('{ "recipeId": "recipe-xxx", "reason": "验证有效: 代码与描述完全匹配" }');
|
|
224
|
+
parts.push('```');
|
|
225
|
+
parts.push('或:');
|
|
226
|
+
parts.push('```json');
|
|
227
|
+
parts.push('{ "recipeId": "recipe-xxx", "reason": "信息不足: 无法确认源文件位置" }');
|
|
228
|
+
parts.push('```');
|
|
229
|
+
return parts.join('\n\n');
|
|
230
|
+
}
|
|
@@ -190,4 +190,46 @@ export declare function insightGateEvaluator(source: unknown, phaseResults: Reco
|
|
|
190
190
|
};
|
|
191
191
|
};
|
|
192
192
|
};
|
|
193
|
+
/** Tool call record for evolution gate */
|
|
194
|
+
interface EvolutionToolCallRecord {
|
|
195
|
+
tool?: string;
|
|
196
|
+
name?: string;
|
|
197
|
+
args?: Record<string, unknown>;
|
|
198
|
+
result?: unknown;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Evolution Gate 评估器 — 面向 PipelineStrategy gate.evaluator
|
|
202
|
+
*
|
|
203
|
+
* 检查 Evolution Agent 是否对所有现有 Recipe 做出了决策:
|
|
204
|
+
* - evolved (submit_knowledge with supersedes)
|
|
205
|
+
* - deprecated (confirm_deprecation)
|
|
206
|
+
* - skipped (skip_evolution)
|
|
207
|
+
*
|
|
208
|
+
* 如果还有未处理的 Recipe,返回 retry 要求补充决策。
|
|
209
|
+
*
|
|
210
|
+
* 兼容旧字段: 优先读 existingRecipes,回退 decayedRecipes。
|
|
211
|
+
*/
|
|
212
|
+
export declare function evolutionGateEvaluator(source: {
|
|
213
|
+
toolCalls?: EvolutionToolCallRecord[];
|
|
214
|
+
} | null | undefined, _phaseResults: unknown, strategyContext?: {
|
|
215
|
+
existingRecipes?: Array<{
|
|
216
|
+
id: string;
|
|
217
|
+
}>;
|
|
218
|
+
decayedRecipes?: Array<{
|
|
219
|
+
id: string;
|
|
220
|
+
}>;
|
|
221
|
+
}): {
|
|
222
|
+
action: string;
|
|
223
|
+
reason: string;
|
|
224
|
+
artifact?: undefined;
|
|
225
|
+
} | {
|
|
226
|
+
action: string;
|
|
227
|
+
artifact: {
|
|
228
|
+
evolved: number;
|
|
229
|
+
deprecated: number;
|
|
230
|
+
skipped: number;
|
|
231
|
+
totalRecipes: number;
|
|
232
|
+
};
|
|
233
|
+
reason?: undefined;
|
|
234
|
+
};
|
|
193
235
|
export {};
|
|
@@ -382,6 +382,47 @@ export function insightGateEvaluator(source, phaseResults, strategyContext = {})
|
|
|
382
382
|
artifact,
|
|
383
383
|
};
|
|
384
384
|
}
|
|
385
|
+
/**
|
|
386
|
+
* Evolution Gate 评估器 — 面向 PipelineStrategy gate.evaluator
|
|
387
|
+
*
|
|
388
|
+
* 检查 Evolution Agent 是否对所有现有 Recipe 做出了决策:
|
|
389
|
+
* - evolved (submit_knowledge with supersedes)
|
|
390
|
+
* - deprecated (confirm_deprecation)
|
|
391
|
+
* - skipped (skip_evolution)
|
|
392
|
+
*
|
|
393
|
+
* 如果还有未处理的 Recipe,返回 retry 要求补充决策。
|
|
394
|
+
*
|
|
395
|
+
* 兼容旧字段: 优先读 existingRecipes,回退 decayedRecipes。
|
|
396
|
+
*/
|
|
397
|
+
export function evolutionGateEvaluator(source, _phaseResults, strategyContext = {}) {
|
|
398
|
+
const totalRecipes = (strategyContext.existingRecipes ?? strategyContext.decayedRecipes ?? [])
|
|
399
|
+
.length;
|
|
400
|
+
const toolCalls = source?.toolCalls || [];
|
|
401
|
+
// 统计各决策数
|
|
402
|
+
const evolved = toolCalls.filter((tc) => {
|
|
403
|
+
const tool = tc.tool || tc.name;
|
|
404
|
+
return tool === 'submit_knowledge' && tc.args?.supersedes;
|
|
405
|
+
}).length;
|
|
406
|
+
const deprecated = toolCalls.filter((tc) => {
|
|
407
|
+
const tool = tc.tool || tc.name;
|
|
408
|
+
return tool === 'confirm_deprecation';
|
|
409
|
+
}).length;
|
|
410
|
+
const skipped = toolCalls.filter((tc) => {
|
|
411
|
+
const tool = tc.tool || tc.name;
|
|
412
|
+
return tool === 'skip_evolution';
|
|
413
|
+
}).length;
|
|
414
|
+
const processed = evolved + deprecated + skipped;
|
|
415
|
+
if (totalRecipes > 0 && processed < totalRecipes) {
|
|
416
|
+
return {
|
|
417
|
+
action: 'retry',
|
|
418
|
+
reason: `只处理了 ${processed}/${totalRecipes} 个 Recipe,还有 ${totalRecipes - processed} 个未决策`,
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
return {
|
|
422
|
+
action: 'pass',
|
|
423
|
+
artifact: { evolved, deprecated, skipped, totalRecipes },
|
|
424
|
+
};
|
|
425
|
+
}
|
|
385
426
|
// ──────────────────────────────────────────────────────────────────
|
|
386
427
|
// 类型定义 (JSDoc)
|
|
387
428
|
// ──────────────────────────────────────────────────────────────────
|
|
@@ -62,7 +62,7 @@ interface GateStrategyContext {
|
|
|
62
62
|
submitToolNames?: string[];
|
|
63
63
|
[key: string]: unknown;
|
|
64
64
|
}
|
|
65
|
-
export declare const PRODUCER_SYSTEM_PROMPT = "\u4F60\u662F\u77E5\u8BC6\u7BA1\u7406\u4E13\u5BB6\u3002\u4F60\u4F1A\u6536\u5230\u4E00\u6BB5\u4EE3\u7801\u5206\u6790\u6587\u672C\uFF0C\u9700\u8981\u5C06\u5176\u4E2D\u7684\u77E5\u8BC6\u70B9\u8F6C\u5316\u4E3A\u7ED3\u6784\u5316\u7684\u77E5\u8BC6\u5019\u9009\u3002\n\n\u6838\u5FC3\u539F\u5219: \u5206\u6790\u6587\u672C\u5DF2\u7ECF\u5305\u542B\u4E86\u6240\u6709\u53D1\u73B0\uFF0C\u4F60\u7684\u552F\u4E00\u5DE5\u4F5C\u662F\u5C06\u5B83\u4EEC\u683C\u5F0F\u5316\u4E3A submit_knowledge \u8C03\u7528\u3002\n\n\u6BCF\u4E2A\u5019\u9009\u5FC5\u987B:\n1. \u6709\u6E05\u6670\u7684\u6807\u9898 (\u63CF\u8FF0\u77E5\u8BC6\u70B9\u7684\u6838\u5FC3\uFF0C\u4F7F\u7528\u9879\u76EE\u771F\u5B9E\u7C7B\u540D)\n2. \u6709\u9879\u76EE\u7279\u5199\u98CE\u683C\u7684\u6B63\u6587 (content.markdown \u5B57\u6BB5\uFF0C\u7ED3\u5408\u4EE3\u7801\u5C55\u793A)\n3. \u6807\u6CE8\u76F8\u5173\u6587\u4EF6\u8DEF\u5F84\n4. \u9009\u62E9\u6B63\u786E\u7684 kind (rule/pattern/fact)\n5. \u63D0\u4F9B\u5B8C\u6574\u7684 Cursor \u4EA4\u4ED8\u5B57\u6BB5 (trigger, doClause, whenClause \u7B49)\n\n\u5DE5\u4F5C\u6D41\u7A0B:\n1. \u9605\u8BFB\u5206\u6790\u6587\u672C\uFF0C\u8BC6\u522B\u6BCF\u4E2A\u72EC\u7ACB\u7684\u77E5\u8BC6\u70B9/\u53D1\u73B0\n2. \u7528 read_project_file \u6279\u91CF\u83B7\u53D6\u5173\u952E\u4EE3\u7801\u7247\u6BB5:\n read_project_file({ filePaths: [\"FileA.
|
|
65
|
+
export declare const PRODUCER_SYSTEM_PROMPT = "\u4F60\u662F\u77E5\u8BC6\u7BA1\u7406\u4E13\u5BB6\u3002\u4F60\u4F1A\u6536\u5230\u4E00\u6BB5\u4EE3\u7801\u5206\u6790\u6587\u672C\uFF0C\u9700\u8981\u5C06\u5176\u4E2D\u7684\u77E5\u8BC6\u70B9\u8F6C\u5316\u4E3A\u7ED3\u6784\u5316\u7684\u77E5\u8BC6\u5019\u9009\u3002\n\n\u6838\u5FC3\u539F\u5219: \u5206\u6790\u6587\u672C\u5DF2\u7ECF\u5305\u542B\u4E86\u6240\u6709\u53D1\u73B0\uFF0C\u4F60\u7684\u552F\u4E00\u5DE5\u4F5C\u662F\u5C06\u5B83\u4EEC\u683C\u5F0F\u5316\u4E3A submit_knowledge \u8C03\u7528\u3002\n\n\u6BCF\u4E2A\u5019\u9009\u5FC5\u987B:\n1. \u6709\u6E05\u6670\u7684\u6807\u9898 (\u63CF\u8FF0\u77E5\u8BC6\u70B9\u7684\u6838\u5FC3\uFF0C\u4F7F\u7528\u9879\u76EE\u771F\u5B9E\u7C7B\u540D\uFF0C\u4E0D\u4EE5\u9879\u76EE\u540D\u5F00\u5934)\n2. \u6709\u9879\u76EE\u7279\u5199\u98CE\u683C\u7684\u6B63\u6587 (content.markdown \u5B57\u6BB5\uFF0C\u7ED3\u5408\u4EE3\u7801\u5C55\u793A)\n3. \u6807\u6CE8\u76F8\u5173\u6587\u4EF6\u7684\u5B8C\u6574\u76F8\u5BF9\u8DEF\u5F84 + \u884C\u53F7\uFF08\u4ECE\u9879\u76EE\u6839\u76EE\u5F55\u5F00\u59CB\uFF0C\u5982 Packages/AOXNetworkKit/Sources/.../NetworkClient.swift:42\uFF09\n4. \u9009\u62E9\u6B63\u786E\u7684 kind (rule/pattern/fact)\n5. \u63D0\u4F9B\u5B8C\u6574\u7684 Cursor \u4EA4\u4ED8\u5B57\u6BB5 (trigger, doClause, whenClause \u7B49)\n6. \u6807\u6CE8\u6240\u5C5E\u6A21\u5757/\u5305\u540D\uFF08\u5982\u300C\u6240\u5C5E\u6A21\u5757: AOXNetworkKit\u300D\uFF09\uFF0C\u7279\u522B\u662F\u6765\u81EA\u672C\u5730\u5B50\u5305\u7684\u77E5\u8BC6\n\n\u5DE5\u4F5C\u6D41\u7A0B:\n1. \u9605\u8BFB\u5206\u6790\u6587\u672C\uFF0C\u8BC6\u522B\u6BCF\u4E2A\u72EC\u7ACB\u7684\u77E5\u8BC6\u70B9/\u53D1\u73B0\n2. \u7528 read_project_file \u6279\u91CF\u83B7\u53D6\u5173\u952E\u4EE3\u7801\u7247\u6BB5:\n read_project_file({ filePaths: [\"Full/Path/To/FileA.swift\", \"Full/Path/To/FileB.swift\"], maxLines: 80 })\n3. \u7ACB\u523B\u8C03\u7528 submit_knowledge \u63D0\u4EA4\n4. \u91CD\u590D\u76F4\u5230\u5206\u6790\u4E2D\u7684\u6240\u6709\u77E5\u8BC6\u70B9\u90FD\u5DF2\u63D0\u4EA4\n\n\u5173\u952E\u89C4\u5219:\n- \u5206\u6790\u4E2D\u7684\u6BCF\u4E2A\u8981\u70B9/\u6BB5\u843D\u90FD\u5E94\u8F6C\u5316\u4E3A\u81F3\u5C11\u4E00\u4E2A\u5019\u9009\n- read_project_file \u652F\u6301 filePaths \u6570\u7EC4\u6279\u91CF\u8BFB\u53D6\u591A\u4E2A\u6587\u4EF6\uFF0C\u4E00\u6B21\u8C03\u7528\u5B8C\u6210\n- read_project_file \u65F6\u8BFB\u53D6\u8DB3\u591F\u591A\u7684\u884C\u6570\uFF08startLine + maxLines \u81F3\u5C11 30 \u884C\uFF09\n- reasoning.sources \u5FC5\u987B\u662F\u975E\u7A7A\u6570\u7EC4\uFF0C\u586B\u5199\u6587\u4EF6\u7684\u5B8C\u6574\u76F8\u5BF9\u8DEF\u5F84\u5982 [\"Packages/AOXNetworkKit/Sources/AOXNetworkKit/Client/NetworkClient.swift\"]\uFF08\u7981\u6B62\u53EA\u5199\u6587\u4EF6\u540D\uFF09\n- content.markdown \u4E2D\u7684\u6765\u6E90\u6807\u6CE8\u5FC5\u987B\u4F7F\u7528\u5B8C\u6574\u76F8\u5BF9\u8DEF\u5F84+\u884C\u53F7: (\u6765\u6E90: Full/Path/FileName.ext:\u884C\u53F7)\n- \u5982\u679C\u5206\u6790\u63D0\u5230\u4E86 3 \u4E2A\u6A21\u5F0F\uFF0C\u5C31\u5E94\u8BE5\u63D0\u4EA4 3 \u4E2A\u5019\u9009\uFF0C\u4E0D\u8981\u5408\u5E76\n- \u7981\u6B62: \u4E0D\u8981\u641C\u7D22\u65B0\u6587\u4EF6\u3001\u4E0D\u8981\u505A\u989D\u5916\u5206\u6790\uFF0C\u4E13\u6CE8\u4E8E\u683C\u5F0F\u5316\u548C\u63D0\u4EA4\n- \u3010\u8DE8\u7EF4\u5EA6\u53BB\u91CD\u3011\u6BCF\u6761\u5019\u9009\u5FC5\u987B\u805A\u7126\u5F53\u524D\u7EF4\u5EA6\u72EC\u6709\u7684\u89C6\u89D2\uFF0C\u4E0D\u5F97\u5C06\u540C\u4E00\u77E5\u8BC6\u70B9\u6362\u4E2A\u8BF4\u6CD5\u91CD\u590D\u63D0\u4EA4\u3002\u76F8\u540C\u7684\u7C7B/\u6A21\u5F0F\u53EA\u5728\u6700\u76F8\u5173\u7684\u7EF4\u5EA6\u51FA\u73B0\u4E00\u6B21\uFF0C\u5B81\u53EF\u5C11\u63D0\u4EA4\u4E5F\u4E0D\u8981\u5145\u6570\n\n\u5BB9\u9519\u89C4\u5219:\n- \u5982\u679C read_project_file \u8FD4\u56DE\"\u6587\u4EF6\u4E0D\u5B58\u5728\"\u6216\u9519\u8BEF\uFF0C\u4E0D\u8981\u91CD\u8BD5\u540C\u4E00\u6587\u4EF6\u7684\u5176\u4ED6\u8DEF\u5F84\u53D8\u4F53\n- \u6587\u4EF6\u8BFB\u53D6\u5931\u8D25\u65F6\uFF0C\u76F4\u63A5\u4F7F\u7528\u5206\u6790\u6587\u672C\u4E2D\u5DF2\u6709\u7684\u4EE3\u7801\u548C\u63CF\u8FF0\u6765\u63D0\u4EA4\u5019\u9009\n- \u6C38\u8FDC\u4E0D\u8981\u56E0\u4E3A\u6587\u4EF6\u8BFB\u53D6\u5931\u8D25\u800C\u8DF3\u8FC7\u77E5\u8BC6\u70B9 \u2014 \u5206\u6790\u6587\u672C\u5DF2\u7ECF\u5305\u542B\u8DB3\u591F\u4FE1\u606F\n- \u5148\u63D0\u4EA4\u5019\u9009\uFF0C\u518D\u8003\u8651\u662F\u5426\u9700\u8981\u8BFB\u53D6\u66F4\u591A\u4EE3\u7801\uFF08\u63D0\u4EA4\u4F18\u5148\u4E8E\u9A8C\u8BC1\uFF09";
|
|
66
66
|
export declare const PRODUCER_TOOLS: string[];
|
|
67
67
|
export declare const PRODUCER_BUDGET: {
|
|
68
68
|
maxIterations: number;
|
|
@@ -79,6 +79,29 @@ export declare const PRODUCER_BUDGET: {
|
|
|
79
79
|
* @param projectInfo { name }
|
|
80
80
|
*/
|
|
81
81
|
export declare function buildProducerPrompt(analysisReport: AnalysisReportLike, dimConfig: DimConfig, projectInfo: ProjectInfo): string;
|
|
82
|
+
/** Panorama context for Producer */
|
|
83
|
+
interface ProducerPanoramaContext {
|
|
84
|
+
moduleRole: string | null;
|
|
85
|
+
moduleLayer: number | null;
|
|
86
|
+
knownGaps: string[];
|
|
87
|
+
layerContext: string | null;
|
|
88
|
+
}
|
|
89
|
+
/** Rescan context for Producer — gap info + existing recipe titles */
|
|
90
|
+
interface ProducerRescanContext {
|
|
91
|
+
existingRecipes: Array<{
|
|
92
|
+
title: string;
|
|
93
|
+
trigger: string;
|
|
94
|
+
}>;
|
|
95
|
+
decayingRecipes?: Array<{
|
|
96
|
+
id?: string;
|
|
97
|
+
title: string;
|
|
98
|
+
trigger: string;
|
|
99
|
+
decayReason?: string;
|
|
100
|
+
}>;
|
|
101
|
+
occupiedTriggers: string[];
|
|
102
|
+
gap: number;
|
|
103
|
+
existing: number;
|
|
104
|
+
}
|
|
82
105
|
/**
|
|
83
106
|
* 构建 Producer Prompt v2 — 用于 AnalysisArtifact
|
|
84
107
|
*
|
|
@@ -86,8 +109,10 @@ export declare function buildProducerPrompt(analysisReport: AnalysisReportLike,
|
|
|
86
109
|
* - §3 结构化发现 (findings)
|
|
87
110
|
* - §4 代码证据 (evidenceMap → code context)
|
|
88
111
|
* - §5 负空间信号
|
|
112
|
+
* - §9 (可选) Rescan 模式约束
|
|
113
|
+
* - §M1 (可选) 全景上下文
|
|
89
114
|
*/
|
|
90
|
-
export declare function buildProducerPromptV2(artifact: AnalysisArtifactLike, dimConfig: DimConfig, projectInfo: ProjectInfo): string;
|
|
115
|
+
export declare function buildProducerPromptV2(artifact: AnalysisArtifactLike, dimConfig: DimConfig, projectInfo: ProjectInfo, rescanContext?: ProducerRescanContext | null, panorama?: ProducerPanoramaContext | null): string;
|
|
91
116
|
/**
|
|
92
117
|
* 从 evidenceMap 构建代码上下文段
|
|
93
118
|
*
|
|
@@ -23,16 +23,17 @@ export const PRODUCER_SYSTEM_PROMPT = `你是知识管理专家。你会收到
|
|
|
23
23
|
核心原则: 分析文本已经包含了所有发现,你的唯一工作是将它们格式化为 submit_knowledge 调用。
|
|
24
24
|
|
|
25
25
|
每个候选必须:
|
|
26
|
-
1. 有清晰的标题 (
|
|
26
|
+
1. 有清晰的标题 (描述知识点的核心,使用项目真实类名,不以项目名开头)
|
|
27
27
|
2. 有项目特写风格的正文 (content.markdown 字段,结合代码展示)
|
|
28
|
-
3.
|
|
28
|
+
3. 标注相关文件的完整相对路径 + 行号(从项目根目录开始,如 Packages/AOXNetworkKit/Sources/.../NetworkClient.swift:42)
|
|
29
29
|
4. 选择正确的 kind (rule/pattern/fact)
|
|
30
30
|
5. 提供完整的 Cursor 交付字段 (trigger, doClause, whenClause 等)
|
|
31
|
+
6. 标注所属模块/包名(如「所属模块: AOXNetworkKit」),特别是来自本地子包的知识
|
|
31
32
|
|
|
32
33
|
工作流程:
|
|
33
34
|
1. 阅读分析文本,识别每个独立的知识点/发现
|
|
34
35
|
2. 用 read_project_file 批量获取关键代码片段:
|
|
35
|
-
read_project_file({ filePaths: ["FileA.
|
|
36
|
+
read_project_file({ filePaths: ["Full/Path/To/FileA.swift", "Full/Path/To/FileB.swift"], maxLines: 80 })
|
|
36
37
|
3. 立刻调用 submit_knowledge 提交
|
|
37
38
|
4. 重复直到分析中的所有知识点都已提交
|
|
38
39
|
|
|
@@ -40,9 +41,11 @@ export const PRODUCER_SYSTEM_PROMPT = `你是知识管理专家。你会收到
|
|
|
40
41
|
- 分析中的每个要点/段落都应转化为至少一个候选
|
|
41
42
|
- read_project_file 支持 filePaths 数组批量读取多个文件,一次调用完成
|
|
42
43
|
- read_project_file 时读取足够多的行数(startLine + maxLines 至少 30 行)
|
|
43
|
-
- reasoning.sources
|
|
44
|
+
- reasoning.sources 必须是非空数组,填写文件的完整相对路径如 ["Packages/AOXNetworkKit/Sources/AOXNetworkKit/Client/NetworkClient.swift"](禁止只写文件名)
|
|
45
|
+
- content.markdown 中的来源标注必须使用完整相对路径+行号: (来源: Full/Path/FileName.ext:行号)
|
|
44
46
|
- 如果分析提到了 3 个模式,就应该提交 3 个候选,不要合并
|
|
45
47
|
- 禁止: 不要搜索新文件、不要做额外分析,专注于格式化和提交
|
|
48
|
+
- 【跨维度去重】每条候选必须聚焦当前维度独有的视角,不得将同一知识点换个说法重复提交。相同的类/模式只在最相关的维度出现一次,宁可少提交也不要充数
|
|
46
49
|
|
|
47
50
|
容错规则:
|
|
48
51
|
- 如果 read_project_file 返回"文件不存在"或错误,不要重试同一文件的其他路径变体
|
|
@@ -99,8 +102,10 @@ export function buildProducerPrompt(analysisReport, dimConfig, projectInfo) {
|
|
|
99
102
|
* - §3 结构化发现 (findings)
|
|
100
103
|
* - §4 代码证据 (evidenceMap → code context)
|
|
101
104
|
* - §5 负空间信号
|
|
105
|
+
* - §9 (可选) Rescan 模式约束
|
|
106
|
+
* - §M1 (可选) 全景上下文
|
|
102
107
|
*/
|
|
103
|
-
export function buildProducerPromptV2(artifact, dimConfig, projectInfo) {
|
|
108
|
+
export function buildProducerPromptV2(artifact, dimConfig, projectInfo, rescanContext, panorama) {
|
|
104
109
|
const parts = [];
|
|
105
110
|
parts.push(`将以下对 ${projectInfo.name} 项目 "${dimConfig.label}" 维度的分析,转化为知识候选:`);
|
|
106
111
|
parts.push(`---\n${artifact.analysisText}\n---`);
|
|
@@ -144,6 +149,56 @@ export function buildProducerPromptV2(artifact, dimConfig, projectInfo) {
|
|
|
144
149
|
// §8 写作指南 + 提交要求
|
|
145
150
|
parts.push(STYLE_GUIDE);
|
|
146
151
|
parts.push(SUBMIT_REQUIREMENTS);
|
|
152
|
+
// §M1 全景上下文 — 帮助 Producer 理解模块定位
|
|
153
|
+
if (panorama) {
|
|
154
|
+
const pLines = [];
|
|
155
|
+
if (panorama.moduleRole) {
|
|
156
|
+
pLines.push(`模块角色: ${panorama.moduleRole}${panorama.moduleLayer !== null ? ` (L${panorama.moduleLayer})` : ''}`);
|
|
157
|
+
}
|
|
158
|
+
if (panorama.layerContext) {
|
|
159
|
+
pLines.push(`架构层级: ${panorama.layerContext}`);
|
|
160
|
+
}
|
|
161
|
+
if (panorama.knownGaps.length > 0) {
|
|
162
|
+
pLines.push(`知识空白区: ${panorama.knownGaps.join(', ')} — 优先为这些方向创建候选。`);
|
|
163
|
+
}
|
|
164
|
+
if (pLines.length > 0) {
|
|
165
|
+
parts.push(`## 🏗️ 项目全景\n${pLines.join('\n')}`);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
// §9a Rescan 模式约束 — 限制提交数量,避免重复
|
|
169
|
+
if (rescanContext && rescanContext.gap > 0) {
|
|
170
|
+
const lines = [
|
|
171
|
+
'## ⚠️ 增量扫描模式 — 补齐约束',
|
|
172
|
+
`本维度已有 ${rescanContext.existing} 个有效知识,需补齐 **${rescanContext.gap}** 个。`,
|
|
173
|
+
`**提交上限: ${rescanContext.gap} 个候选**。达到目标后立即停止,不要多提交。`,
|
|
174
|
+
];
|
|
175
|
+
if (rescanContext.occupiedTriggers.length > 0) {
|
|
176
|
+
lines.push(`已占用的 trigger: ${rescanContext.occupiedTriggers.slice(0, 15).join(', ')}`);
|
|
177
|
+
lines.push('禁止使用上述已占用的 trigger,必须为新模式创建新 trigger。');
|
|
178
|
+
}
|
|
179
|
+
if (rescanContext.existingRecipes.length > 0) {
|
|
180
|
+
lines.push('已有知识标题 (禁止重复):');
|
|
181
|
+
for (const r of rescanContext.existingRecipes.slice(0, 8)) {
|
|
182
|
+
lines.push(`- "${r.title}"`);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
parts.push(lines.join('\n'));
|
|
186
|
+
}
|
|
187
|
+
// §9b 衰退 Recipe — 可用 supersedes 替换
|
|
188
|
+
if (rescanContext?.decayingRecipes && rescanContext.decayingRecipes.length > 0) {
|
|
189
|
+
const dLines = [
|
|
190
|
+
'## 🔄 可替换的衰退知识',
|
|
191
|
+
'以下 Recipe 正在衰退,如果 Analyst 发现了更新版本的模式,',
|
|
192
|
+
'你可以用 `supersedes` 参数提交替代版本:',
|
|
193
|
+
];
|
|
194
|
+
for (const r of rescanContext.decayingRecipes.slice(0, 5)) {
|
|
195
|
+
dLines.push(`- [${r.id || '?'}] "${r.title}" — ${r.decayReason || '衰退中'}`);
|
|
196
|
+
dLines.push(` → 替换方式: submit_knowledge({ ...newRecipe, supersedes: "${r.id || ''}" })`);
|
|
197
|
+
}
|
|
198
|
+
dLines.push('注意: supersedes 提交会创建观察窗口(72h),不是立即替换。');
|
|
199
|
+
dLines.push('替换的新 Recipe 必须基于当前代码,不要复制旧 Recipe 内容。');
|
|
200
|
+
parts.push(dLines.join('\n'));
|
|
201
|
+
}
|
|
147
202
|
return parts.join('\n\n');
|
|
148
203
|
}
|
|
149
204
|
// ──────────────────────────────────────────────────────────────────
|
|
@@ -30,32 +30,35 @@ export const SCAN_TASK_CONFIGS = {
|
|
|
30
30
|
核心原则: 分析文本已经包含了所有发现,你的唯一工作是将它们格式化为 collect_scan_recipe 调用。
|
|
31
31
|
|
|
32
32
|
每个候选必须:
|
|
33
|
-
1. 有清晰的标题 (
|
|
33
|
+
1. 有清晰的标题 (描述知识点的核心,使用项目真实类名,不以项目名开头)
|
|
34
34
|
2. 有项目特写风格的正文 (content.markdown 字段,结合代码展示)
|
|
35
|
-
3.
|
|
35
|
+
3. 标注相关文件的完整相对路径 + 行号 (reasoning.sources,如 ["Packages/ModuleName/Sources/.../FileName.swift"])
|
|
36
36
|
4. 选择正确的 kind (rule/pattern/fact)
|
|
37
37
|
5. 提供完整的 Cursor 交付字段 (trigger, doClause, whenClause 等)
|
|
38
|
+
6. 标注所属模块/包名(特别是来自本地子包的知识)
|
|
38
39
|
|
|
39
40
|
## 「项目特写」写作要求(content.markdown)
|
|
40
41
|
content.markdown 字段必须是「项目特写」:
|
|
41
42
|
1. **项目选择了什么** — 采用了哪种写法/模式/约定
|
|
42
43
|
2. **为什么这样选** — 统计分布、占比、历史决策
|
|
43
44
|
3. **项目禁止什么** — 反模式、已废弃写法
|
|
44
|
-
4. **新代码怎么写** — 可直接复制使用的代码模板 + 来源标注 (来源: FileName.ext:行号)
|
|
45
|
+
4. **新代码怎么写** — 可直接复制使用的代码模板 + 来源标注 (来源: Full/Relative/Path/FileName.ext:行号)
|
|
45
46
|
|
|
46
47
|
## 工作流程
|
|
47
48
|
1. 阅读分析文本,识别每个独立的知识点/发现
|
|
48
49
|
2. 用 read_project_file 批量获取关键代码片段:
|
|
49
|
-
read_project_file({ filePaths: ["FileA.
|
|
50
|
+
read_project_file({ filePaths: ["Full/Path/To/FileA.swift", "Full/Path/To/FileB.swift"], maxLines: 80 })
|
|
50
51
|
3. 立刻调用 collect_scan_recipe 提交
|
|
51
52
|
4. 重复直到分析中的所有知识点都已提交
|
|
52
53
|
|
|
53
54
|
## 关键规则
|
|
54
55
|
- 分析中的每个要点/段落都应转化为至少一个候选
|
|
55
56
|
- read_project_file 支持 filePaths 数组批量读取多个文件,一次调用完成
|
|
56
|
-
- reasoning.sources
|
|
57
|
+
- reasoning.sources 必须是非空数组,填写文件的完整相对路径(从项目根目录开始),禁止只写文件名
|
|
58
|
+
- content.markdown 中的来源标注必须使用完整相对路径: (来源: Full/Path/FileName.ext:行号)
|
|
57
59
|
- 如果分析提到了 3 个模式,就应该提交 3 个候选,不要合并
|
|
58
60
|
- 禁止: 不要搜索新文件、不要做额外分析,专注于格式化和提交
|
|
61
|
+
- 【跨维度去重】每条候选必须聚焦当前维度独有的视角,不得将同一知识点换个说法重复提交到不同维度。宁可少提交也不要充数
|
|
59
62
|
|
|
60
63
|
容错规则:
|
|
61
64
|
- 如果 read_project_file 返回"文件不存在"或错误,不要重试同一文件的其他路径变体
|
|
@@ -71,7 +74,7 @@ content.markdown 字段必须是「项目特写」:
|
|
|
71
74
|
核心原则: 分析文本已经包含了所有发现,你的唯一工作是将它们格式化为 collect_scan_recipe 调用。
|
|
72
75
|
|
|
73
76
|
这是单文件/代码片段的深度分析,提交一个(或少量)高质量的知识候选:
|
|
74
|
-
1.
|
|
77
|
+
1. 清晰的标题(描述代码的核心功能,使用项目真实类名,不以项目名开头)
|
|
75
78
|
2. 完整的技术文档正文(content.markdown 字段,≥200 字符)
|
|
76
79
|
3. 实用的使用指南(usageGuide 字段,含示例)
|
|
77
80
|
4. 准确的分类(category)和标签(tags)
|
|
@@ -206,7 +209,7 @@ export function buildScanPipelineStages({ task, producePrompt, analyzeCaps, prod
|
|
|
206
209
|
2. content.markdown 字段 ≥ 200 字符,含代码块 (\`\`\`)
|
|
207
210
|
3. content.rationale 必填 — 设计原理说明
|
|
208
211
|
4. reasoning.sources 必须是非空数组
|
|
209
|
-
5.
|
|
212
|
+
5. 标题使用项目真实类名,不以项目名开头
|
|
210
213
|
6. 必填: trigger (@kebab-case)、kind (rule/pattern/fact)、doClause (英文祈使句)`;
|
|
211
214
|
},
|
|
212
215
|
skipOnDegrade: true,
|