autosnippet 3.3.4 → 3.3.6
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/README.md +174 -83
- package/config/constitution.yaml +2 -0
- package/dashboard/dist/assets/icons-D1aVZYFW.js +1 -0
- package/dashboard/dist/assets/index-CxHOu8Hd.css +1 -0
- package/dashboard/dist/assets/index-DDdAOpYT.js +128 -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 +136 -9
- package/dist/lib/agent/AgentFactory.d.ts +0 -17
- package/dist/lib/agent/AgentFactory.js +1 -25
- 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/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/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 +1 -1
- package/dist/lib/cli/KnowledgeSyncService.d.ts +5 -1
- package/dist/lib/cli/KnowledgeSyncService.js +6 -3
- package/dist/lib/core/AstAnalyzer.d.ts +1 -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 +33 -111
- package/dist/lib/domain/knowledge/KnowledgeEntry.js +27 -6
- 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/domain/knowledge/values/Stats.d.ts +1 -1
- package/dist/lib/domain/knowledge/values/Stats.js +2 -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/orchestrator.d.ts +99 -12
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +172 -161
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/tier-scheduler.js +7 -17
- 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 +14 -10
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +39 -51
- package/dist/lib/external/mcp/handlers/bootstrap-internal.d.ts +2 -0
- package/dist/lib/external/mcp/handlers/bootstrap-internal.js +115 -82
- package/dist/lib/external/mcp/handlers/consolidated.d.ts +4 -4
- package/dist/lib/external/mcp/handlers/consolidated.js +115 -162
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +69 -1
- package/dist/lib/external/mcp/handlers/evolve-external.d.ts +54 -0
- package/dist/lib/external/mcp/handlers/evolve-external.js +226 -0
- package/dist/lib/external/mcp/handlers/knowledge.js +26 -2
- 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 +60 -3
- package/dist/lib/http/routes/knowledge.js +122 -1
- package/dist/lib/http/routes/modules.js +25 -3
- package/dist/lib/http/routes/panorama.js +16 -4
- 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.js +55 -0
- package/dist/lib/injection/ServiceMap.d.ts +8 -1
- package/dist/lib/injection/modules/InfraModule.js +4 -1
- package/dist/lib/injection/modules/KnowledgeModule.js +38 -1
- package/dist/lib/repository/evolution/ProposalRepository.d.ts +99 -0
- package/dist/lib/repository/evolution/ProposalRepository.js +255 -0
- 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 +22 -4
- package/dist/lib/service/bootstrap/UiStartupTasks.js +73 -5
- 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 +85 -0
- package/dist/lib/service/cleanup/CleanupService.js +324 -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/DecayDetector.d.ts +4 -3
- package/dist/lib/service/evolution/DecayDetector.js +97 -22
- package/dist/lib/service/evolution/KnowledgeMetabolism.d.ts +4 -2
- package/dist/lib/service/evolution/KnowledgeMetabolism.js +29 -2
- package/dist/lib/service/evolution/ProposalExecutor.d.ts +66 -0
- package/dist/lib/service/evolution/ProposalExecutor.js +424 -0
- 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/StagingManager.js +5 -3
- 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/guard/GuardCrossFileChecks.js +2 -0
- package/dist/lib/service/guard/ReverseGuard.d.ts +1 -1
- package/dist/lib/service/guard/ReverseGuard.js +32 -2
- 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 +44 -4
- package/dist/lib/service/knowledge/RecipeProductionGateway.d.ts +225 -0
- package/dist/lib/service/knowledge/RecipeProductionGateway.js +384 -0
- package/dist/lib/service/knowledge/SourceRefReconciler.d.ts +2 -0
- package/dist/lib/service/knowledge/SourceRefReconciler.js +48 -0
- package/dist/lib/service/panorama/DimensionAnalyzer.d.ts +3 -2
- package/dist/lib/service/panorama/DimensionAnalyzer.js +15 -140
- 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/shared/schemas/common.d.ts +4 -4
- package/dist/lib/shared/schemas/http-requests.d.ts +12 -1
- package/dist/lib/shared/schemas/http-requests.js +8 -0
- package/dist/lib/shared/schemas/mcp-tools.d.ts +33 -2
- package/dist/lib/shared/schemas/mcp-tools.js +42 -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 +131 -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
|
@@ -13,8 +13,7 @@
|
|
|
13
13
|
* 25. get_feedback_stats 反馈统计
|
|
14
14
|
*/
|
|
15
15
|
import { getInternalAgentRequiredFields, getSystemInjectedFields, } from '#domain/knowledge/FieldSpec.js';
|
|
16
|
-
import {
|
|
17
|
-
import { checkDimensionType, DIMENSION_DISPLAY_GROUP } from './_shared.js';
|
|
16
|
+
import { checkDimensionType, DIMENSION_DISPLAY_GROUP, stripProjectNamePrefix, } from './_shared.js';
|
|
18
17
|
// ────────────────────────────────────────────────────────────
|
|
19
18
|
// 16. submit_knowledge
|
|
20
19
|
// ────────────────────────────────────────────────────────────
|
|
@@ -71,14 +70,24 @@ export const submitCandidate = {
|
|
|
71
70
|
description: '知识维度:code-pattern / architecture / best-practice 等',
|
|
72
71
|
},
|
|
73
72
|
usageGuide: { type: 'string', description: '使用指南 Markdown(### 章节格式)' },
|
|
74
|
-
sourceFile: {
|
|
73
|
+
sourceFile: {
|
|
74
|
+
type: 'string',
|
|
75
|
+
description: 'Recipe md 文件相对路径(由系统自动设置,无需手动填写)',
|
|
76
|
+
},
|
|
77
|
+
supersedes: {
|
|
78
|
+
type: 'string',
|
|
79
|
+
description: '被替代的旧 Recipe ID。传入后将创建 supersede 提案,72h 观察窗口后自动替代。',
|
|
80
|
+
},
|
|
75
81
|
},
|
|
76
82
|
// FieldSpec 驱动: 内部 Agent 路径排除系统注入字段
|
|
77
83
|
required: getInternalAgentRequiredFields(),
|
|
78
84
|
},
|
|
79
85
|
handler: async (params, ctx) => {
|
|
80
|
-
|
|
81
|
-
|
|
86
|
+
// ── 标题正规化:剥离冗余的项目名前缀 ──
|
|
87
|
+
if (params.title) {
|
|
88
|
+
params.title = stripProjectNamePrefix(params.title, ctx.projectRoot);
|
|
89
|
+
}
|
|
90
|
+
// ── Bootstrap 维度类型校验(source-specific: 仅 bootstrap 流程) ──
|
|
82
91
|
const dimMeta = ctx._dimensionMeta;
|
|
83
92
|
if (dimMeta && ctx.source === 'system') {
|
|
84
93
|
const rejected = checkDimensionType(dimMeta, params, ctx.logger);
|
|
@@ -95,89 +104,64 @@ export const submitCandidate = {
|
|
|
95
104
|
if (!params.tags.includes('bootstrap')) {
|
|
96
105
|
params.tags.push('bootstrap');
|
|
97
106
|
}
|
|
98
|
-
// Bootstrap 模式: 将 category
|
|
99
|
-
params._category =
|
|
100
|
-
DIMENSION_DISPLAY_GROUP[dimMeta.id] || dimMeta.id;
|
|
101
|
-
// ── UnifiedValidator 统一质量验证(替代 CandidateGuardrail) ──
|
|
102
|
-
const validator = ctx._validator ||
|
|
103
|
-
new UnifiedValidator({
|
|
104
|
-
existingTitles: ctx._submittedTitles || new Set(),
|
|
105
|
-
existingFingerprints: ctx._submittedPatterns || new Set(),
|
|
106
|
-
});
|
|
107
|
-
const validResult = validator.validate(params, {
|
|
108
|
-
systemInjectedFields: getSystemInjectedFields(),
|
|
109
|
-
});
|
|
110
|
-
if (!validResult.pass) {
|
|
111
|
-
ctx.logger?.info(`[submit_knowledge] ✗ validator rejected: ${validResult.errors.join('; ')}`);
|
|
112
|
-
return {
|
|
113
|
-
status: 'rejected',
|
|
114
|
-
error: validResult.errors.join('\n'),
|
|
115
|
-
warnings: validResult.warnings,
|
|
116
|
-
hint: '请根据错误信息调整内容后重新提交。',
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
if (validResult.warnings.length > 0) {
|
|
120
|
-
ctx.logger?.debug(`[submit_knowledge] ⚠ warnings: ${validResult.warnings.join('; ')}`);
|
|
121
|
-
}
|
|
107
|
+
// Bootstrap 模式: 将 category 设为维度 ID(前端按此分组显示)
|
|
108
|
+
params._category = dimMeta.id;
|
|
122
109
|
}
|
|
123
110
|
// ── 系统自动设置 ──
|
|
124
|
-
const
|
|
111
|
+
const item = {
|
|
112
|
+
...params,
|
|
125
113
|
language: ctx._projectLanguage || '',
|
|
126
|
-
category: dimMeta
|
|
127
|
-
|
|
128
|
-
: 'general',
|
|
129
|
-
knowledgeType: dimMeta?.allowedKnowledgeTypes?.[0] || 'code-pattern',
|
|
114
|
+
category: dimMeta ? dimMeta.id : params._category || 'general',
|
|
115
|
+
knowledgeType: dimMeta?.allowedKnowledgeTypes?.[0] || params.knowledgeType || 'code-pattern',
|
|
130
116
|
source: ctx.source === 'system' ? 'bootstrap' : 'agent',
|
|
131
|
-
};
|
|
132
|
-
// ── 直传 → KnowledgeEntry ──
|
|
133
|
-
const reasoning = params.reasoning || { whyStandard: '', sources: ['agent'], confidence: 0.7 };
|
|
134
|
-
if (Array.isArray(reasoning.sources) && reasoning.sources.length === 0) {
|
|
135
|
-
reasoning.sources = ['agent'];
|
|
136
|
-
}
|
|
137
|
-
// V3 content 直透
|
|
138
|
-
const contentObj = params.content && typeof params.content === 'object'
|
|
139
|
-
? params.content
|
|
140
|
-
: { markdown: '', pattern: '' };
|
|
141
|
-
const data = {
|
|
142
|
-
...systemFields,
|
|
143
|
-
title: params.title || '',
|
|
144
|
-
description: params.description || '',
|
|
145
|
-
tags: params.tags || [],
|
|
146
|
-
trigger: params.trigger || '',
|
|
147
|
-
kind: params.kind || 'pattern',
|
|
148
|
-
topicHint: params.topicHint || '',
|
|
149
|
-
whenClause: params.whenClause || '',
|
|
150
|
-
doClause: params.doClause || '',
|
|
151
|
-
dontClause: params.dontClause || '',
|
|
152
|
-
coreCode: contentObj.pattern || '',
|
|
153
|
-
content: contentObj,
|
|
154
|
-
reasoning,
|
|
155
|
-
// V3 扩展字段直透
|
|
156
|
-
scope: params.scope || '',
|
|
157
|
-
complexity: params.complexity || '',
|
|
158
|
-
headers: params.headers || [],
|
|
159
|
-
// 注意: sourceFile 由 KnowledgeFileWriter.persist() 自动设置,
|
|
160
|
-
// 不应从 AI params/reasoning.sources 取值(那是项目源文件路径,不是知识文件路径)
|
|
161
|
-
sourceFile: '',
|
|
162
|
-
// 7.3.9 agentNotes/aiInsight 注入
|
|
163
117
|
agentNotes: dimMeta
|
|
164
118
|
? { dimensionId: dimMeta.id, outputType: dimMeta.outputType || 'candidate' }
|
|
165
119
|
: null,
|
|
166
|
-
aiInsight: reasoning.whyStandard || params.description || null,
|
|
167
120
|
};
|
|
168
121
|
if (dimMeta && ctx.source === 'system') {
|
|
169
122
|
const displayGroup = DIMENSION_DISPLAY_GROUP[dimMeta.id] || dimMeta.id;
|
|
170
|
-
|
|
123
|
+
item.tags = [...new Set([...(item.tags || []), displayGroup])];
|
|
171
124
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
125
|
+
// ── 委托 RecipeProductionGateway 统一管道 ──
|
|
126
|
+
const { RecipeProductionGateway } = await import('#service/knowledge/RecipeProductionGateway.js');
|
|
127
|
+
const gateway = new RecipeProductionGateway({
|
|
128
|
+
knowledgeService: ctx.container.get('knowledgeService'),
|
|
129
|
+
projectRoot: ctx.projectRoot,
|
|
130
|
+
logger: ctx.logger,
|
|
131
|
+
proposalRepository: ctx.container.get('proposalRepository') ?? null,
|
|
132
|
+
});
|
|
133
|
+
const gatewayResult = await gateway.create({
|
|
134
|
+
source: 'agent-tool',
|
|
135
|
+
items: [item],
|
|
136
|
+
options: {
|
|
137
|
+
skipSimilarityCheck: true,
|
|
138
|
+
skipConsolidation: true,
|
|
139
|
+
supersedes: params.supersedes,
|
|
140
|
+
existingTitles: ctx._submittedTitles,
|
|
141
|
+
existingFingerprints: ctx._submittedPatterns,
|
|
142
|
+
systemInjectedFields: dimMeta && ctx.source === 'system' ? getSystemInjectedFields() : undefined,
|
|
143
|
+
userId: 'agent',
|
|
144
|
+
},
|
|
145
|
+
});
|
|
146
|
+
// ── 映射 Gateway 结果 → 原有返回格式 ──
|
|
147
|
+
if (gatewayResult.rejected.length > 0) {
|
|
148
|
+
const rej = gatewayResult.rejected[0];
|
|
149
|
+
ctx.logger?.info(`[submit_knowledge] ✗ validator rejected: ${rej.errors.join('; ')}`);
|
|
150
|
+
return {
|
|
151
|
+
status: 'rejected',
|
|
152
|
+
error: rej.errors.join('\n'),
|
|
153
|
+
warnings: rej.warnings,
|
|
154
|
+
hint: '请根据错误信息调整内容后重新提交。',
|
|
155
|
+
};
|
|
176
156
|
}
|
|
177
|
-
|
|
178
|
-
|
|
157
|
+
if (gatewayResult.created.length > 0) {
|
|
158
|
+
const created = gatewayResult.created[0];
|
|
159
|
+
if (gatewayResult.supersedeProposal) {
|
|
160
|
+
return { ...created.raw, _supersedeProposal: gatewayResult.supersedeProposal };
|
|
161
|
+
}
|
|
162
|
+
return created.raw;
|
|
179
163
|
}
|
|
180
|
-
return
|
|
164
|
+
return { status: 'error', error: 'No items created' };
|
|
181
165
|
},
|
|
182
166
|
};
|
|
183
167
|
// ────────────────────────────────────────────────────────────
|
|
@@ -97,7 +97,7 @@ export class AiScanService {
|
|
|
97
97
|
recipe.source = 'ai-scan';
|
|
98
98
|
recipe.tags = [...new Set([...(recipe.tags || []), 'ai-scan', file.targetName])];
|
|
99
99
|
recipe.moduleName = file.targetName;
|
|
100
|
-
|
|
100
|
+
// 注意:不设置 sourceFile,由 KnowledgeFileWriter 持久化时自动设置为 md 文件路径
|
|
101
101
|
if (!recipe.aiInsight && recipe.description) {
|
|
102
102
|
recipe.aiInsight = recipe.description;
|
|
103
103
|
}
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
*/
|
|
16
16
|
import Logger from '../infrastructure/logging/Logger.js';
|
|
17
17
|
import type { ApplyReport, ReconcileReport, RepairReport } from '../service/knowledge/SourceRefReconciler.js';
|
|
18
|
+
import { SourceRefReconciler } from '../service/knowledge/SourceRefReconciler.js';
|
|
18
19
|
export interface SyncAllReport {
|
|
19
20
|
synced: number;
|
|
20
21
|
created: number;
|
|
@@ -27,11 +28,14 @@ export interface SyncAllReport {
|
|
|
27
28
|
applyReport?: ApplyReport;
|
|
28
29
|
}
|
|
29
30
|
export declare class KnowledgeSyncService {
|
|
31
|
+
#private;
|
|
30
32
|
candidatesDir: string;
|
|
31
33
|
logger: ReturnType<typeof Logger.getInstance>;
|
|
32
34
|
projectRoot: string;
|
|
33
35
|
recipesDir: string;
|
|
34
|
-
constructor(projectRoot: string
|
|
36
|
+
constructor(projectRoot: string, options?: {
|
|
37
|
+
sourceRefReconciler?: SourceRefReconciler;
|
|
38
|
+
});
|
|
35
39
|
/**
|
|
36
40
|
* 完整同步入口 — sync + reconcile + repair
|
|
37
41
|
*
|
|
@@ -25,11 +25,13 @@ export class KnowledgeSyncService {
|
|
|
25
25
|
logger;
|
|
26
26
|
projectRoot;
|
|
27
27
|
recipesDir;
|
|
28
|
-
|
|
28
|
+
#sourceRefReconciler;
|
|
29
|
+
constructor(projectRoot, options) {
|
|
29
30
|
this.projectRoot = projectRoot;
|
|
30
31
|
this.recipesDir = path.join(projectRoot, RECIPES_DIR);
|
|
31
32
|
this.candidatesDir = path.join(projectRoot, CANDIDATES_DIR);
|
|
32
33
|
this.logger = Logger.getInstance();
|
|
34
|
+
this.#sourceRefReconciler = options?.sourceRefReconciler ?? null;
|
|
33
35
|
}
|
|
34
36
|
/**
|
|
35
37
|
* 完整同步入口 — sync + reconcile + repair
|
|
@@ -46,7 +48,8 @@ export class KnowledgeSyncService {
|
|
|
46
48
|
const report = { ...syncReport };
|
|
47
49
|
// 2. 填充/验证 recipe_source_refs 桥接表
|
|
48
50
|
try {
|
|
49
|
-
const reconciler =
|
|
51
|
+
const reconciler = this.#sourceRefReconciler ??
|
|
52
|
+
new SourceRefReconciler(this.projectRoot, db);
|
|
50
53
|
report.reconcileReport = reconciler.reconcile({ force: opts.force });
|
|
51
54
|
// 3. git rename 修复
|
|
52
55
|
report.repairReport = await reconciler.repairRenames();
|
|
@@ -345,7 +348,7 @@ export class KnowledgeSyncService {
|
|
|
345
348
|
SET lifecycle = 'deprecated',
|
|
346
349
|
rejectionReason = ?,
|
|
347
350
|
updatedAt = ?
|
|
348
|
-
WHERE id = ?`).run('
|
|
351
|
+
WHERE id = ?`).run('源文件已删除(孤儿条目)', now, row.id);
|
|
349
352
|
}
|
|
350
353
|
}
|
|
351
354
|
}
|
|
@@ -262,3 +262,4 @@ declare function checkProtocolConformance(source: string, lang: string, classNam
|
|
|
262
262
|
classDeclLine: number | undefined;
|
|
263
263
|
};
|
|
264
264
|
export { analyzeFile, analyzeProject, generateContextForAgent, isAvailable, supportedLanguages, findCallExpressions, findPatternInContext, checkProtocolConformance, parseToTree, };
|
|
265
|
+
export type { ProjectAnalysisResult };
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ---
|
|
9
9
|
* 使用方式:
|
|
10
|
-
* import { DimensionCopy } from '
|
|
11
|
-
* const copy = DimensionCopy.get('
|
|
10
|
+
* import { DimensionCopy } from '#domain/dimension/DimensionCopy.js';
|
|
11
|
+
* const copy = DimensionCopy.get('design-patterns', 'python');
|
|
12
12
|
* // → { label: '设计模式与代码惯例', guide: '装饰器/描述器/上下文管理器/生成器/ABC 抽象基类/Mixin 模式' }
|
|
13
13
|
*/
|
|
14
14
|
export declare class DimensionCopy {
|
package/dist/lib/{service/bootstrap/DimensionCopyRegistry.js → domain/dimension/DimensionCopy.js}
RENAMED
|
@@ -7,10 +7,11 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ---
|
|
9
9
|
* 使用方式:
|
|
10
|
-
* import { DimensionCopy } from '
|
|
11
|
-
* const copy = DimensionCopy.get('
|
|
10
|
+
* import { DimensionCopy } from '#domain/dimension/DimensionCopy.js';
|
|
11
|
+
* const copy = DimensionCopy.get('design-patterns', 'python');
|
|
12
12
|
* // → { label: '设计模式与代码惯例', guide: '装饰器/描述器/上下文管理器/生成器/ABC 抽象基类/Mixin 模式' }
|
|
13
13
|
*/
|
|
14
|
+
import { getDimension } from './DimensionRegistry.js';
|
|
14
15
|
// ═══════════════════════════════════════════════════════════
|
|
15
16
|
// 语言族定义
|
|
16
17
|
// ═══════════════════════════════════════════════════════════
|
|
@@ -45,11 +46,7 @@ function _langFamily(lang) {
|
|
|
45
46
|
*/
|
|
46
47
|
const COPY_REGISTRY = {
|
|
47
48
|
// ── ① 代码规范 ──────────────────────────────────────
|
|
48
|
-
'
|
|
49
|
-
_default: {
|
|
50
|
-
label: '代码规范',
|
|
51
|
-
guide: '命名约定、注释风格、文件组织规范、代码格式化标准',
|
|
52
|
-
},
|
|
49
|
+
'coding-standards': {
|
|
53
50
|
apple: {
|
|
54
51
|
label: '代码规范',
|
|
55
52
|
guide: '命名约定(类名前缀/方法签名风格/API 命名)、注释风格(语言/格式/MARK 分段)、文件组织规范',
|
|
@@ -80,11 +77,7 @@ const COPY_REGISTRY = {
|
|
|
80
77
|
},
|
|
81
78
|
},
|
|
82
79
|
// ── ② 设计模式与代码惯例 ─────────────────────────────
|
|
83
|
-
'
|
|
84
|
-
_default: {
|
|
85
|
-
label: '设计模式与代码惯例',
|
|
86
|
-
guide: '单例/工厂/观察者/策略/Builder 等设计模式在项目中的使用方式',
|
|
87
|
-
},
|
|
80
|
+
'design-patterns': {
|
|
88
81
|
apple: {
|
|
89
82
|
label: '设计模式与代码惯例',
|
|
90
83
|
guide: '单例/委托/Category·Extension/工厂/Builder/观察者/Coordinator 模式、继承关系',
|
|
@@ -116,10 +109,6 @@ const COPY_REGISTRY = {
|
|
|
116
109
|
},
|
|
117
110
|
// ── ③ 架构模式 ──────────────────────────────────────
|
|
118
111
|
architecture: {
|
|
119
|
-
_default: {
|
|
120
|
-
label: '架构模式',
|
|
121
|
-
guide: '分层架构、模块职责与边界、依赖图、导入约束规则',
|
|
122
|
-
},
|
|
123
112
|
apple: {
|
|
124
113
|
label: '架构模式',
|
|
125
114
|
guide: '分层架构(MVVM/VIPER/TCA)、Package/Target 模块边界、依赖图、import 约束规则',
|
|
@@ -149,12 +138,8 @@ const COPY_REGISTRY = {
|
|
|
149
138
|
guide: '分层架构、Workspace/crate 边界、pub/pub(crate) 可见性、trait object 抽象层',
|
|
150
139
|
},
|
|
151
140
|
},
|
|
152
|
-
// ── ④
|
|
153
|
-
'
|
|
154
|
-
_default: {
|
|
155
|
-
label: '最佳实践',
|
|
156
|
-
guide: '错误处理、并发安全、资源管理、日志规范、测试模式',
|
|
157
|
-
},
|
|
141
|
+
// ── ④ 错误韧性 ──────────────────────────────────────
|
|
142
|
+
'error-resilience': {
|
|
158
143
|
apple: {
|
|
159
144
|
label: '最佳实践',
|
|
160
145
|
guide: '错误处理、并发安全(Swift Concurrency/GCD)、内存管理(ARC/weak/unowned)、日志规范、XCTest 模式',
|
|
@@ -184,12 +169,8 @@ const COPY_REGISTRY = {
|
|
|
184
169
|
guide: '错误处理(Result/? 操作符/thiserror)、并发安全(Send+Sync/Arc/Mutex)、生命周期管理、日志(tracing)、#[test] 模式',
|
|
185
170
|
},
|
|
186
171
|
},
|
|
187
|
-
// ── ⑤
|
|
188
|
-
'event-
|
|
189
|
-
_default: {
|
|
190
|
-
label: '事件与数据流',
|
|
191
|
-
guide: '事件传播机制、状态管理模式、数据流向追踪',
|
|
192
|
-
},
|
|
172
|
+
// ── ⑤ 数据与事件流 ─────────────────────────────────
|
|
173
|
+
'data-event-flow': {
|
|
193
174
|
apple: {
|
|
194
175
|
label: '事件与数据流',
|
|
195
176
|
guide: '事件传播(Delegate/Notification/Block·Closure/Target-Action)、数据状态管理(KVO/属性观察/Combine/SwiftUI State)',
|
|
@@ -219,47 +200,8 @@ const COPY_REGISTRY = {
|
|
|
219
200
|
guide: '事件传播(tokio channel/crossbeam-channel)、Stream trait、Actor 模式(Actix)、状态管理(Arc<RwLock<T>>)',
|
|
220
201
|
},
|
|
221
202
|
},
|
|
222
|
-
// ── ⑥
|
|
223
|
-
'project-profile': {
|
|
224
|
-
_default: {
|
|
225
|
-
label: '项目特征',
|
|
226
|
-
guide: '技术栈、目录结构、三方依赖枚举与用途、基础设施服务注册表',
|
|
227
|
-
},
|
|
228
|
-
apple: {
|
|
229
|
-
label: '项目特征',
|
|
230
|
-
guide: '技术栈、目录结构、三方依赖枚举与用途、Extension/Category 分类聚合、自定义基类层级与全局定义(宏/typealias/PCH)、系统事件 hook 与生命周期入口、基础设施服务注册表、Runtime 与语言互操作',
|
|
231
|
-
},
|
|
232
|
-
js: {
|
|
233
|
-
label: '项目特征',
|
|
234
|
-
guide: '技术栈(框架/构建工具/包管理器)、目录结构、三方依赖枚举与用途、monorepo 配置、环境变量与配置注入、CI/CD 管线',
|
|
235
|
-
},
|
|
236
|
-
jvm: {
|
|
237
|
-
label: '项目特征',
|
|
238
|
-
guide: '技术栈(Spring/Android/Ktor)、module 结构、三方依赖枚举与用途、构建配置(Gradle/Maven)、Profile 环境管理、基础设施服务',
|
|
239
|
-
},
|
|
240
|
-
python: {
|
|
241
|
-
label: '项目特征',
|
|
242
|
-
guide: '技术栈(Django/FastAPI/Flask)、包结构、三方依赖枚举与用途、pyproject.toml/setup.cfg 配置、虚拟环境管理',
|
|
243
|
-
},
|
|
244
|
-
go: {
|
|
245
|
-
label: '项目特征',
|
|
246
|
-
guide: '技术栈、module 结构、go.mod 依赖枚举与用途、internal 包组织、build tags、Makefile 构建',
|
|
247
|
-
},
|
|
248
|
-
dart: {
|
|
249
|
-
label: '项目特征',
|
|
250
|
-
guide: '技术栈(Flutter/Dart Server/CLI)、目录结构(lib/src 分层)、pubspec.yaml 依赖枚举与用途、平台通道(MethodChannel/FFI)、Flavors/多环境配置',
|
|
251
|
-
},
|
|
252
|
-
rust: {
|
|
253
|
-
label: '项目特征',
|
|
254
|
-
guide: '技术栈、Workspace/crate 结构、Cargo.toml 依赖枚举与用途、feature flags、#[cfg] 条件编译',
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
// ── ⑦ Agent 开发注意事项 ─────────────────────────────
|
|
203
|
+
// ── ⑥ Agent 开发注意事项 ─────────────────────────────
|
|
258
204
|
'agent-guidelines': {
|
|
259
|
-
_default: {
|
|
260
|
-
label: 'Agent 开发注意事项',
|
|
261
|
-
guide: '三大核心原则(严谨性/深度特征挖掘/完整性)、命名强制、并发安全、资源管理、已废弃 API 标记、架构约束注释、TODO/FIXME',
|
|
262
|
-
},
|
|
263
205
|
apple: {
|
|
264
206
|
label: 'Agent 开发注意事项',
|
|
265
207
|
guide: '三大核心原则(严谨性/深度特征挖掘/完整性)、命名强制、线程安全、内存约束、已废弃 API 标记、架构约束注释、TODO/FIXME',
|
|
@@ -302,11 +244,19 @@ export class DimensionCopy {
|
|
|
302
244
|
*/
|
|
303
245
|
static get(dimId, lang) {
|
|
304
246
|
const entry = COPY_REGISTRY[dimId];
|
|
305
|
-
if (
|
|
306
|
-
|
|
247
|
+
if (entry) {
|
|
248
|
+
const family = _langFamily(lang);
|
|
249
|
+
const match = entry[family] || entry[lang];
|
|
250
|
+
if (match) {
|
|
251
|
+
return match;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
// 回退到 Registry 元数据(消除 _default 双源)
|
|
255
|
+
const dim = getDimension(dimId);
|
|
256
|
+
if (dim) {
|
|
257
|
+
return { label: dim.label, guide: dim.extractionGuide };
|
|
307
258
|
}
|
|
308
|
-
|
|
309
|
-
return entry[family] || entry[lang] || entry._default || null;
|
|
259
|
+
return null;
|
|
310
260
|
}
|
|
311
261
|
/**
|
|
312
262
|
* 批量为维度数组注入语言差异化文案(单语言版本)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DimensionRegistry — 统一维度注册表 (Single Source of Truth)
|
|
3
|
+
*
|
|
4
|
+
* 25 个维度定义:
|
|
5
|
+
* Layer 1 (Universal): D1-D13 — 所有项目适用
|
|
6
|
+
* Layer 2 (Language): DL1-DL7 — 按项目语言激活
|
|
7
|
+
* Layer 3 (Framework): DF1-DF5 — 按检测到的框架激活
|
|
8
|
+
*
|
|
9
|
+
* 这是整个系统中维度定义的唯一来源。
|
|
10
|
+
* Bootstrap / Panorama / Rescan / Dashboard 均从此模块消费维度元数据。
|
|
11
|
+
*
|
|
12
|
+
* 设计文档: docs/copilot/unified-dimension-design.md §4
|
|
13
|
+
*
|
|
14
|
+
* @module domain/dimension/DimensionRegistry
|
|
15
|
+
*/
|
|
16
|
+
import type { DimensionId, UnifiedDimension } from './UnifiedDimension.js';
|
|
17
|
+
export declare const DIMENSION_REGISTRY: readonly UnifiedDimension[];
|
|
18
|
+
/**
|
|
19
|
+
* 维度 ID → 展示分组 ID 映射
|
|
20
|
+
*
|
|
21
|
+
* 展示分组:
|
|
22
|
+
* - 'architecture' — 架构与设计
|
|
23
|
+
* - 'best-practice' — 规范与实践
|
|
24
|
+
* - 'data-event-flow' — 数据与并发
|
|
25
|
+
* - 'deep-scan' — 深度扫描(语言/框架条件维度)
|
|
26
|
+
*/
|
|
27
|
+
export declare const DIMENSION_DISPLAY_GROUP: Record<string, string>;
|
|
28
|
+
/** 按 ID 获取维度 */
|
|
29
|
+
export declare function getDimension(id: string): UnifiedDimension | undefined;
|
|
30
|
+
/** 获取指定层级的所有维度 */
|
|
31
|
+
export declare function getDimensionsByLayer(layer: 'universal' | 'language' | 'framework'): readonly UnifiedDimension[];
|
|
32
|
+
/**
|
|
33
|
+
* 根据项目语言和框架过滤出活跃维度
|
|
34
|
+
*
|
|
35
|
+
* - Layer 1 (universal): 全部返回
|
|
36
|
+
* - Layer 2 (language): 仅当项目语言匹配时返回
|
|
37
|
+
* - Layer 3 (framework): 仅当项目语言+框架均匹配时返回
|
|
38
|
+
*/
|
|
39
|
+
export declare function resolveActiveDimensions(primaryLang: string, detectedFrameworks?: string[]): readonly UnifiedDimension[];
|
|
40
|
+
/**
|
|
41
|
+
* 构建 Tier 分层调度计划
|
|
42
|
+
*
|
|
43
|
+
* 基于每个维度的 tierHint 字段将活跃维度分为 3 层:
|
|
44
|
+
* - Tier 1 (tierHint=1): 基础数据层 — architecture + 语言/框架条件维度
|
|
45
|
+
* - Tier 2 (tierHint=2): 规范+设计层 — coding-standards, design-patterns
|
|
46
|
+
* - Tier 3 (tierHint=3): 实践+质量层 — 其余所有维度
|
|
47
|
+
*/
|
|
48
|
+
export declare function buildTierPlan(activeDims?: readonly UnifiedDimension[]): string[][];
|
|
49
|
+
/**
|
|
50
|
+
* 将 Recipe 分类到最匹配的维度
|
|
51
|
+
*
|
|
52
|
+
* 优先级: topicHint 精确匹配 → category 匹配 → null
|
|
53
|
+
*/
|
|
54
|
+
export declare function classifyRecipeToDimension(topicHint: string, category: string): DimensionId | null;
|