autosnippet 3.2.18 → 3.2.20
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 +73 -104
- package/dashboard/dist/assets/{index-CKMy5LY6.js → index-DdvZE4Yd.js} +1 -1
- package/dashboard/dist/index.html +1 -1
- package/dist/bin/cli.js +45 -10
- package/dist/lib/agent/AgentEventBus.js +3 -3
- package/dist/lib/agent/AgentFactory.d.ts +3 -3
- package/dist/lib/agent/AgentFactory.js +4 -4
- package/dist/lib/agent/AgentMessage.d.ts +8 -8
- package/dist/lib/agent/AgentMessage.js +8 -8
- package/dist/lib/agent/AgentRuntime.js +2 -2
- package/dist/lib/agent/AgentState.js +4 -4
- package/dist/lib/agent/ConversationStore.d.ts +1 -1
- package/dist/lib/agent/ConversationStore.js +1 -1
- package/dist/lib/agent/PipelineStrategy.js +1 -1
- package/dist/lib/agent/context/ContextWindow.d.ts +2 -2
- package/dist/lib/agent/context/ContextWindow.js +7 -7
- package/dist/lib/agent/context/ExplorationTracker.js +9 -9
- package/dist/lib/agent/context/exploration/PlanTracker.js +2 -2
- package/dist/lib/agent/context/exploration/SignalDetector.d.ts +1 -1
- package/dist/lib/agent/context/exploration/SignalDetector.js +1 -1
- package/dist/lib/agent/core/LoopContext.d.ts +21 -21
- package/dist/lib/agent/core/LoopContext.js +21 -21
- package/dist/lib/agent/core/SystemPromptBuilder.js +4 -4
- package/dist/lib/agent/domain/EvidenceCollector.js +5 -5
- package/dist/lib/agent/memory/ActiveContext.js +1 -1
- package/dist/lib/agent/memory/MemoryRetriever.js +1 -1
- package/dist/lib/agent/memory/MemoryStore.js +2 -2
- package/dist/lib/agent/memory/SessionStore.js +3 -3
- package/dist/lib/agent/policies.d.ts +1 -1
- package/dist/lib/agent/policies.js +1 -1
- package/dist/lib/agent/strategies.d.ts +1 -1
- package/dist/lib/agent/strategies.js +4 -4
- package/dist/lib/agent/tools/_shared.d.ts +1 -1
- package/dist/lib/agent/tools/_shared.js +1 -1
- package/dist/lib/agent/tools/infrastructure.js +2 -2
- package/dist/lib/cli/SetupService.d.ts +25 -25
- package/dist/lib/cli/SetupService.js +28 -15
- package/dist/lib/cli/deploy/FileDeployer.d.ts +9 -2
- package/dist/lib/cli/deploy/FileDeployer.js +139 -46
- package/dist/lib/cli/deploy/FileManifest.d.ts +23 -39
- package/dist/lib/cli/deploy/FileManifest.js +22 -27
- package/dist/lib/core/AstAnalyzer.d.ts +2 -2
- package/dist/lib/core/AstAnalyzer.js +2 -2
- package/dist/lib/core/analysis/CallEdgeResolver.d.ts +7 -7
- package/dist/lib/core/analysis/CallEdgeResolver.js +9 -9
- package/dist/lib/core/analysis/CallGraphAnalyzer.d.ts +4 -4
- package/dist/lib/core/analysis/CallGraphAnalyzer.js +2 -2
- package/dist/lib/core/analysis/ImportPathResolver.d.ts +0 -2
- package/dist/lib/core/analysis/ImportPathResolver.js +2 -4
- package/dist/lib/core/ast/ProjectGraph.js +7 -7
- package/dist/lib/core/capability/CapabilityProbe.js +6 -14
- package/dist/lib/domain/knowledge/UnifiedValidator.js +2 -2
- package/dist/lib/domain/knowledge/values/Constraints.js +4 -4
- package/dist/lib/domain/knowledge/values/Content.js +6 -6
- package/dist/lib/domain/knowledge/values/Quality.js +5 -5
- package/dist/lib/domain/knowledge/values/Reasoning.js +5 -5
- package/dist/lib/domain/knowledge/values/Relations.js +1 -1
- package/dist/lib/domain/knowledge/values/Stats.js +6 -6
- package/dist/lib/domain/task/TaskIdGenerator.d.ts +4 -4
- package/dist/lib/domain/task/TaskIdGenerator.js +2 -2
- package/dist/lib/external/lark/LarkTransport.js +4 -4
- package/dist/lib/external/mcp/McpServer.d.ts +3 -7
- package/dist/lib/external/mcp/McpServer.js +9 -13
- package/dist/lib/external/mcp/handlers/bootstrap/ExternalSubmissionTracker.js +5 -5
- package/dist/lib/external/mcp/handlers/bootstrap/MissionBriefingBuilder.js +4 -3
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.d.ts +3 -3
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.js +3 -3
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.d.ts +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.js +1 -1
- package/dist/lib/external/mcp/handlers/bootstrap/pipeline/dimension-context.js +3 -3
- package/dist/lib/external/mcp/handlers/bootstrap/shared/dimension-sop.js +27 -14
- package/dist/lib/external/mcp/handlers/bootstrap-external.js +6 -0
- package/dist/lib/external/mcp/handlers/dimension-complete-external.js +55 -1
- package/dist/lib/external/mcp/handlers/skill.js +9 -31
- package/dist/lib/external/mcp/handlers/system.js +2 -2
- package/dist/lib/external/mcp/handlers/task.js +16 -1
- package/dist/lib/external/mcp/tools.d.ts +12 -10
- package/dist/lib/external/mcp/tools.js +97 -69
- package/dist/lib/http/utils/routeHelpers.d.ts +1 -1
- package/dist/lib/http/utils/routeHelpers.js +1 -1
- package/dist/lib/http/utils/sse-sessions.d.ts +1 -1
- package/dist/lib/http/utils/sse-sessions.js +1 -1
- package/dist/lib/infrastructure/cache/CacheService.js +1 -1
- package/dist/lib/infrastructure/vector/AsyncPersistence.js +8 -8
- package/dist/lib/infrastructure/vector/BatchEmbedder.d.ts +1 -1
- package/dist/lib/infrastructure/vector/BatchEmbedder.js +2 -2
- package/dist/lib/infrastructure/vector/HnswIndex.d.ts +4 -4
- package/dist/lib/infrastructure/vector/HnswIndex.js +5 -5
- package/dist/lib/infrastructure/vector/HnswVectorAdapter.js +8 -8
- package/dist/lib/infrastructure/vector/ScalarQuantizer.d.ts +1 -1
- package/dist/lib/infrastructure/vector/ScalarQuantizer.js +4 -4
- package/dist/lib/infrastructure/vector/VectorStore.d.ts +1 -1
- package/dist/lib/infrastructure/vector/VectorStore.js +1 -1
- package/dist/lib/injection/ServiceContainer.d.ts +1 -1
- package/dist/lib/injection/ServiceContainer.js +1 -1
- package/dist/lib/platform/NativeUi.d.ts +1 -1
- package/dist/lib/platform/NativeUi.js +1 -1
- package/dist/lib/platform/ios/spm/DependencyGraph.d.ts +1 -1
- package/dist/lib/platform/ios/spm/DependencyGraph.js +1 -1
- package/dist/lib/platform/ios/spm/PolicyEngine.d.ts +1 -1
- package/dist/lib/platform/ios/spm/PolicyEngine.js +1 -1
- package/dist/lib/platform/ios/spm/SpmDiscoverer.js +1 -1
- package/dist/lib/platform/ios/spm/SpmHelper.js +3 -3
- package/dist/lib/platform/ios/xcode/SaveEventFilter.js +2 -2
- package/dist/lib/platform/ios/xcode/XcodeIntegration.js +1 -1
- package/dist/lib/repository/base/BaseRepository.js +1 -1
- package/dist/lib/repository/task/TaskRepository.impl.d.ts +2 -2
- package/dist/lib/repository/task/TaskRepository.impl.js +1 -1
- package/dist/lib/repository/token/TokenUsageStore.js +1 -1
- package/dist/lib/service/automation/ActionPipeline.d.ts +1 -1
- package/dist/lib/service/automation/ActionPipeline.js +1 -1
- package/dist/lib/service/bootstrap/BootstrapEventEmitter.js +2 -2
- package/dist/lib/service/bootstrap/BootstrapTaskManager.d.ts +1 -1
- package/dist/lib/service/bootstrap/BootstrapTaskManager.js +2 -2
- package/dist/lib/service/bootstrap/DimensionCopyRegistry.d.ts +2 -2
- package/dist/lib/service/bootstrap/DimensionCopyRegistry.js +2 -2
- package/dist/lib/service/delivery/AgentInstructionsGenerator.d.ts +6 -15
- package/dist/lib/service/delivery/AgentInstructionsGenerator.js +53 -189
- package/dist/lib/service/delivery/CursorDeliveryPipeline.d.ts +6 -16
- package/dist/lib/service/delivery/CursorDeliveryPipeline.js +14 -19
- package/dist/lib/service/delivery/KnowledgeCompressor.d.ts +1 -1
- package/dist/lib/service/delivery/KnowledgeCompressor.js +1 -1
- package/dist/lib/service/delivery/RulesGenerator.d.ts +10 -3
- package/dist/lib/service/delivery/RulesGenerator.js +43 -3
- package/dist/lib/service/delivery/SkillsSyncer.d.ts +21 -7
- package/dist/lib/service/delivery/SkillsSyncer.js +46 -10
- package/dist/lib/service/delivery/TopicClassifier.d.ts +3 -6
- package/dist/lib/service/delivery/TopicClassifier.js +0 -3
- package/dist/lib/service/guard/ExclusionManager.d.ts +1 -1
- package/dist/lib/service/guard/ExclusionManager.js +1 -1
- package/dist/lib/service/guard/GuardCheckEngine.d.ts +3 -3
- package/dist/lib/service/guard/GuardCheckEngine.js +5 -5
- package/dist/lib/service/guard/GuardCrossFileChecks.d.ts +1 -1
- package/dist/lib/service/guard/GuardFeedbackLoop.d.ts +3 -3
- package/dist/lib/service/guard/GuardFeedbackLoop.js +3 -3
- package/dist/lib/service/guard/GuardPatternUtils.js +1 -1
- package/dist/lib/service/guard/GuardService.d.ts +1 -15
- package/dist/lib/service/guard/GuardService.js +0 -1
- package/dist/lib/service/guard/RuleLearner.d.ts +1 -1
- package/dist/lib/service/guard/RuleLearner.js +1 -1
- package/dist/lib/service/knowledge/CodeEntityGraph.d.ts +3 -3
- package/dist/lib/service/knowledge/CodeEntityGraph.js +3 -3
- package/dist/lib/service/knowledge/KnowledgeService.d.ts +0 -1
- package/dist/lib/service/knowledge/KnowledgeService.js +0 -1
- package/dist/lib/service/module/ModuleService.d.ts +1 -1
- package/dist/lib/service/module/ModuleService.js +2 -2
- package/dist/lib/service/search/HybridRetriever.d.ts +2 -2
- package/dist/lib/service/search/HybridRetriever.js +2 -2
- package/dist/lib/service/search/SearchEngine.d.ts +1 -3
- package/dist/lib/service/search/SearchEngine.js +1 -3
- package/dist/lib/service/search/contextBoost.d.ts +1 -1
- package/dist/lib/service/skills/EventAggregator.js +2 -2
- package/dist/lib/service/skills/SignalCollector.js +1 -1
- package/dist/lib/service/snippet/codecs/VSCodeCodec.js +1 -1
- package/dist/lib/service/task/TaskGraphService.d.ts +0 -3
- package/dist/lib/service/task/TaskGraphService.js +0 -3
- package/dist/lib/service/task/TaskKnowledgeBridge.d.ts +8 -27
- package/dist/lib/service/task/TaskKnowledgeBridge.js +0 -8
- package/dist/lib/service/task/TaskReadyEngine.d.ts +1 -2
- package/dist/lib/service/task/TaskReadyEngine.js +0 -1
- package/dist/lib/service/wiki/WikiRenderers.js +0 -1
- package/dist/lib/service/wiki/WikiUtils.js +2 -7
- package/dist/lib/shared/PathGuard.js +6 -6
- package/dist/lib/shared/schemas/mcp-tools.js +84 -43
- package/dist/scripts/install-vscode-copilot.js +14 -4
- package/package.json +1 -1
- package/skills/autosnippet-create/SKILL.md +131 -131
- package/skills/autosnippet-devdocs/SKILL.md +1 -2
- package/skills/autosnippet-guard/SKILL.md +20 -89
- package/skills/autosnippet-recipes/SKILL.md +35 -117
- package/skills/autosnippet-structure/SKILL.md +23 -55
- package/templates/cursor-rules/autosnippet-skills.mdc +17 -33
- package/templates/instructions/agent-static.md +24 -0
- package/templates/instructions/conventions.md +42 -0
- package/skills/autosnippet-analysis/SKILL.md +0 -169
- package/skills/autosnippet-candidates/SKILL.md +0 -367
- package/skills/autosnippet-coldstart/SKILL.md +0 -988
- package/skills/autosnippet-concepts/SKILL.md +0 -630
- package/skills/autosnippet-intent/SKILL.md +0 -55
- package/skills/autosnippet-lifecycle/SKILL.md +0 -100
- package/templates/copilot-instructions.md +0 -66
- package/templates/cursor-rules/autosnippet-conventions.mdc +0 -172
- package/templates/cursor-rules/autosnippet-workflow.mdc +0 -76
|
@@ -91,12 +91,15 @@ export declare class CursorDeliveryPipeline {
|
|
|
91
91
|
};
|
|
92
92
|
channelC: {
|
|
93
93
|
synced: number;
|
|
94
|
+
builtinSynced: number;
|
|
95
|
+
projectSynced: number;
|
|
94
96
|
skipped: number;
|
|
95
97
|
errors: number;
|
|
96
98
|
details: {
|
|
97
99
|
synced: string[];
|
|
98
100
|
skipped: string[];
|
|
99
101
|
errors: string[];
|
|
102
|
+
builtinSynced: string[];
|
|
100
103
|
};
|
|
101
104
|
};
|
|
102
105
|
channelD: {
|
|
@@ -155,18 +158,15 @@ export declare class CursorDeliveryPipeline {
|
|
|
155
158
|
}>;
|
|
156
159
|
/**
|
|
157
160
|
* 加载知识条目(active + high-confidence pending)
|
|
158
|
-
* @private
|
|
159
161
|
*/
|
|
160
162
|
_loadEntries(): Promise<KnowledgeEntryProps[]>;
|
|
161
163
|
/**
|
|
162
164
|
* 从 KnowledgeService.list() 返回值提取条目数组
|
|
163
|
-
* @private
|
|
164
165
|
*/
|
|
165
166
|
_extractItems(result: unknown): KnowledgeEntryProps[];
|
|
166
167
|
/**
|
|
167
168
|
* 按 kind 分类知识条目
|
|
168
169
|
* dev-document 类型单独分流,不进入 Channel A/B 压缩
|
|
169
|
-
* @private
|
|
170
170
|
*/
|
|
171
171
|
_classify(entries: KnowledgeEntryProps[]): {
|
|
172
172
|
rules: KnowledgeEntryProps[];
|
|
@@ -176,17 +176,14 @@ export declare class CursorDeliveryPipeline {
|
|
|
176
176
|
};
|
|
177
177
|
/**
|
|
178
178
|
* 排序 — 质量分 + 统计使用量
|
|
179
|
-
* @private
|
|
180
179
|
*/
|
|
181
180
|
_rank(entries: KnowledgeEntryProps[]): KnowledgeEntryProps[];
|
|
182
181
|
/**
|
|
183
182
|
* 计算排名分
|
|
184
|
-
* @private
|
|
185
183
|
*/
|
|
186
184
|
_rankScore(entry: KnowledgeEntryProps): number;
|
|
187
185
|
/**
|
|
188
186
|
* Channel A 生成
|
|
189
|
-
* @private
|
|
190
187
|
*/
|
|
191
188
|
_generateChannelA(rules: KnowledgeEntryProps[]): {
|
|
192
189
|
filePath: string;
|
|
@@ -201,7 +198,6 @@ export declare class CursorDeliveryPipeline {
|
|
|
201
198
|
* Channel B 生成(patterns + facts)
|
|
202
199
|
* @param patterns kind='pattern' 的知识条目
|
|
203
200
|
* @param [facts=[]] kind='fact' 的知识条目
|
|
204
|
-
* @private
|
|
205
201
|
*/
|
|
206
202
|
_generateChannelB(patterns: KnowledgeEntryProps[], facts?: KnowledgeEntryProps[]): {
|
|
207
203
|
topicCount: number;
|
|
@@ -217,7 +213,6 @@ export declare class CursorDeliveryPipeline {
|
|
|
217
213
|
/**
|
|
218
214
|
* Channel B+ — Call Graph Architecture Rules (Phase 5.2)
|
|
219
215
|
* 从调用图拓扑分析架构分层,生成 architecture smart rule
|
|
220
|
-
* @private
|
|
221
216
|
* @returns |null}
|
|
222
217
|
*/
|
|
223
218
|
_generateCallGraphArchitectureRules(): {
|
|
@@ -227,28 +222,28 @@ export declare class CursorDeliveryPipeline {
|
|
|
227
222
|
} | null;
|
|
228
223
|
/**
|
|
229
224
|
* 从文件路径中提取层级目录 (第一或第二级有意义的目录)
|
|
230
|
-
* @private
|
|
231
225
|
*/
|
|
232
226
|
_extractLayerDir(filePath: string): string | null;
|
|
233
227
|
/**
|
|
234
228
|
* Channel C 生成
|
|
235
|
-
* @private
|
|
236
229
|
*/
|
|
237
230
|
_generateChannelC(): Promise<{
|
|
238
231
|
synced: number;
|
|
232
|
+
builtinSynced: number;
|
|
233
|
+
projectSynced: number;
|
|
239
234
|
skipped: number;
|
|
240
235
|
errors: number;
|
|
241
236
|
details: {
|
|
242
237
|
synced: string[];
|
|
243
238
|
skipped: string[];
|
|
244
239
|
errors: string[];
|
|
240
|
+
builtinSynced: string[];
|
|
245
241
|
};
|
|
246
242
|
}>;
|
|
247
243
|
/**
|
|
248
244
|
* Channel D — Dev Documents 生成
|
|
249
245
|
* 将 knowledgeType='dev-document' 的条目以原始 MD 写入
|
|
250
246
|
* .cursor/skills/autosnippet-devdocs/references/ 目录
|
|
251
|
-
* @private
|
|
252
247
|
*/
|
|
253
248
|
_generateChannelD(documents: KnowledgeEntryProps[]): {
|
|
254
249
|
documentsCount: number;
|
|
@@ -258,7 +253,6 @@ export declare class CursorDeliveryPipeline {
|
|
|
258
253
|
/**
|
|
259
254
|
* Channel F — Agent Instructions 生成
|
|
260
255
|
* 生成 AGENTS.md / CLAUDE.md / .github/copilot-instructions.md
|
|
261
|
-
* @private
|
|
262
256
|
*/
|
|
263
257
|
_generateChannelF(rules: KnowledgeEntryProps[], patterns: KnowledgeEntryProps[]): {
|
|
264
258
|
filesWritten: number;
|
|
@@ -279,24 +273,20 @@ export declare class CursorDeliveryPipeline {
|
|
|
279
273
|
};
|
|
280
274
|
/**
|
|
281
275
|
* 文件名安全 slug 化
|
|
282
|
-
* @private
|
|
283
276
|
*/
|
|
284
277
|
_slugify(text: string): string;
|
|
285
278
|
/**
|
|
286
279
|
* 镜像 .cursor/ 交付物料到目标 IDE 目录(Qoder / Trae 等兼容 IDE)
|
|
287
280
|
* 只复制 autosnippet- 前缀的文件/目录,不触碰用户自定义内容
|
|
288
281
|
* @param targetDirName 目标目录名,如 '.qoder' 或 '.trae'
|
|
289
|
-
* @private
|
|
290
282
|
*/
|
|
291
283
|
_mirrorToIDE(targetDirName: string): void;
|
|
292
284
|
/**
|
|
293
285
|
* 递归复制目录
|
|
294
|
-
* @private
|
|
295
286
|
*/
|
|
296
287
|
_copyDirRecursive(src: string, dest: string): void;
|
|
297
288
|
/**
|
|
298
289
|
* 从项目路径推断项目名称
|
|
299
|
-
* @private
|
|
300
290
|
*/
|
|
301
291
|
_inferProjectName(projectRoot: string): string;
|
|
302
292
|
}
|
|
@@ -88,6 +88,12 @@ export class CursorDeliveryPipeline {
|
|
|
88
88
|
// ── Channel A: Always-On Rules ──
|
|
89
89
|
const channelA = this._generateChannelA(rules);
|
|
90
90
|
stats.channelA = channelA;
|
|
91
|
+
// ── Baseline: 零知识库时注入基础引导 ──
|
|
92
|
+
if (entries.length === 0 && channelA.rulesCount === 0) {
|
|
93
|
+
const baseline = this.rulesGenerator.writeBaselineRules();
|
|
94
|
+
stats.channelA = { rulesCount: 0, tokensUsed: baseline.tokensUsed };
|
|
95
|
+
this.logger.info?.('[CursorDelivery] Baseline rules written (zero knowledge entries)');
|
|
96
|
+
}
|
|
91
97
|
// ── Channel B: Smart Rules (by topic) + Facts ──
|
|
92
98
|
const channelB = this._generateChannelB(patterns, facts);
|
|
93
99
|
stats.channelB = channelB;
|
|
@@ -132,7 +138,6 @@ export class CursorDeliveryPipeline {
|
|
|
132
138
|
// ─── 内部方法 ───────────────────────────────────────
|
|
133
139
|
/**
|
|
134
140
|
* 加载知识条目(active + high-confidence pending)
|
|
135
|
-
* @private
|
|
136
141
|
*/
|
|
137
142
|
async _loadEntries() {
|
|
138
143
|
const allEntries = [];
|
|
@@ -164,7 +169,6 @@ export class CursorDeliveryPipeline {
|
|
|
164
169
|
}
|
|
165
170
|
/**
|
|
166
171
|
* 从 KnowledgeService.list() 返回值提取条目数组
|
|
167
|
-
* @private
|
|
168
172
|
*/
|
|
169
173
|
_extractItems(result) {
|
|
170
174
|
if (Array.isArray(result)) {
|
|
@@ -182,7 +186,6 @@ export class CursorDeliveryPipeline {
|
|
|
182
186
|
/**
|
|
183
187
|
* 按 kind 分类知识条目
|
|
184
188
|
* dev-document 类型单独分流,不进入 Channel A/B 压缩
|
|
185
|
-
* @private
|
|
186
189
|
*/
|
|
187
190
|
_classify(entries) {
|
|
188
191
|
const rules = [], patterns = [], facts = [], documents = [];
|
|
@@ -204,7 +207,6 @@ export class CursorDeliveryPipeline {
|
|
|
204
207
|
}
|
|
205
208
|
/**
|
|
206
209
|
* 排序 — 质量分 + 统计使用量
|
|
207
|
-
* @private
|
|
208
210
|
*/
|
|
209
211
|
_rank(entries) {
|
|
210
212
|
return [...entries].sort((a, b) => {
|
|
@@ -215,7 +217,6 @@ export class CursorDeliveryPipeline {
|
|
|
215
217
|
}
|
|
216
218
|
/**
|
|
217
219
|
* 计算排名分
|
|
218
|
-
* @private
|
|
219
220
|
*/
|
|
220
221
|
_rankScore(entry) {
|
|
221
222
|
const qual = entry.quality;
|
|
@@ -233,7 +234,6 @@ export class CursorDeliveryPipeline {
|
|
|
233
234
|
}
|
|
234
235
|
/**
|
|
235
236
|
* Channel A 生成
|
|
236
|
-
* @private
|
|
237
237
|
*/
|
|
238
238
|
_generateChannelA(rules) {
|
|
239
239
|
const topRules = this._rank(rules).slice(0, BUDGET.CHANNEL_A_MAX_RULES);
|
|
@@ -250,7 +250,6 @@ export class CursorDeliveryPipeline {
|
|
|
250
250
|
* Channel B 生成(patterns + facts)
|
|
251
251
|
* @param patterns kind='pattern' 的知识条目
|
|
252
252
|
* @param [facts=[]] kind='fact' 的知识条目
|
|
253
|
-
* @private
|
|
254
253
|
*/
|
|
255
254
|
_generateChannelB(patterns, facts = []) {
|
|
256
255
|
const result = { topicCount: 0, patternsCount: 0, factsCount: 0, totalTokens: 0, topics: {} };
|
|
@@ -304,7 +303,6 @@ export class CursorDeliveryPipeline {
|
|
|
304
303
|
/**
|
|
305
304
|
* Channel B+ — Call Graph Architecture Rules (Phase 5.2)
|
|
306
305
|
* 从调用图拓扑分析架构分层,生成 architecture smart rule
|
|
307
|
-
* @private
|
|
308
306
|
* @returns |null}
|
|
309
307
|
*/
|
|
310
308
|
_generateCallGraphArchitectureRules() {
|
|
@@ -435,7 +433,6 @@ export class CursorDeliveryPipeline {
|
|
|
435
433
|
}
|
|
436
434
|
/**
|
|
437
435
|
* 从文件路径中提取层级目录 (第一或第二级有意义的目录)
|
|
438
|
-
* @private
|
|
439
436
|
*/
|
|
440
437
|
_extractLayerDir(filePath) {
|
|
441
438
|
if (!filePath) {
|
|
@@ -453,15 +450,17 @@ export class CursorDeliveryPipeline {
|
|
|
453
450
|
}
|
|
454
451
|
/**
|
|
455
452
|
* Channel C 生成
|
|
456
|
-
* @private
|
|
457
453
|
*/
|
|
458
454
|
async _generateChannelC() {
|
|
459
455
|
try {
|
|
460
456
|
const syncResult = await this.skillsSyncer.sync();
|
|
461
|
-
this.logger.info?.(`[CursorDelivery] Channel C: ${syncResult.
|
|
457
|
+
this.logger.info?.(`[CursorDelivery] Channel C: ${syncResult.builtinSynced.length} builtin + ` +
|
|
458
|
+
`${syncResult.synced.length} project synced, ` +
|
|
462
459
|
`${syncResult.skipped.length} skipped, ${syncResult.errors.length} errors`);
|
|
463
460
|
return {
|
|
464
|
-
synced: syncResult.synced.length,
|
|
461
|
+
synced: syncResult.builtinSynced.length + syncResult.synced.length,
|
|
462
|
+
builtinSynced: syncResult.builtinSynced.length,
|
|
463
|
+
projectSynced: syncResult.synced.length,
|
|
465
464
|
skipped: syncResult.skipped.length,
|
|
466
465
|
errors: syncResult.errors.length,
|
|
467
466
|
details: syncResult,
|
|
@@ -471,9 +470,11 @@ export class CursorDeliveryPipeline {
|
|
|
471
470
|
this.logger.error?.(`[CursorDelivery] Channel C error: ${err.message}`);
|
|
472
471
|
return {
|
|
473
472
|
synced: 0,
|
|
473
|
+
builtinSynced: 0,
|
|
474
|
+
projectSynced: 0,
|
|
474
475
|
skipped: 0,
|
|
475
476
|
errors: 1,
|
|
476
|
-
details: { synced: [], skipped: [], errors: [err.message] },
|
|
477
|
+
details: { synced: [], skipped: [], builtinSynced: [], errors: [err.message] },
|
|
477
478
|
};
|
|
478
479
|
}
|
|
479
480
|
}
|
|
@@ -481,7 +482,6 @@ export class CursorDeliveryPipeline {
|
|
|
481
482
|
* Channel D — Dev Documents 生成
|
|
482
483
|
* 将 knowledgeType='dev-document' 的条目以原始 MD 写入
|
|
483
484
|
* .cursor/skills/autosnippet-devdocs/references/ 目录
|
|
484
|
-
* @private
|
|
485
485
|
*/
|
|
486
486
|
_generateChannelD(documents) {
|
|
487
487
|
const result = { documentsCount: 0, filesWritten: 0, filePaths: [] };
|
|
@@ -554,7 +554,6 @@ export class CursorDeliveryPipeline {
|
|
|
554
554
|
/**
|
|
555
555
|
* Channel F — Agent Instructions 生成
|
|
556
556
|
* 生成 AGENTS.md / CLAUDE.md / .github/copilot-instructions.md
|
|
557
|
-
* @private
|
|
558
557
|
*/
|
|
559
558
|
_generateChannelF(rules, patterns) {
|
|
560
559
|
try {
|
|
@@ -594,7 +593,6 @@ export class CursorDeliveryPipeline {
|
|
|
594
593
|
}
|
|
595
594
|
/**
|
|
596
595
|
* 文件名安全 slug 化
|
|
597
|
-
* @private
|
|
598
596
|
*/
|
|
599
597
|
_slugify(text) {
|
|
600
598
|
return (text
|
|
@@ -607,7 +605,6 @@ export class CursorDeliveryPipeline {
|
|
|
607
605
|
* 镜像 .cursor/ 交付物料到目标 IDE 目录(Qoder / Trae 等兼容 IDE)
|
|
608
606
|
* 只复制 autosnippet- 前缀的文件/目录,不触碰用户自定义内容
|
|
609
607
|
* @param targetDirName 目标目录名,如 '.qoder' 或 '.trae'
|
|
610
|
-
* @private
|
|
611
608
|
*/
|
|
612
609
|
_mirrorToIDE(targetDirName) {
|
|
613
610
|
try {
|
|
@@ -650,7 +647,6 @@ export class CursorDeliveryPipeline {
|
|
|
650
647
|
}
|
|
651
648
|
/**
|
|
652
649
|
* 递归复制目录
|
|
653
|
-
* @private
|
|
654
650
|
*/
|
|
655
651
|
_copyDirRecursive(src, dest) {
|
|
656
652
|
fs.mkdirSync(dest, { recursive: true });
|
|
@@ -667,7 +663,6 @@ export class CursorDeliveryPipeline {
|
|
|
667
663
|
}
|
|
668
664
|
/**
|
|
669
665
|
* 从项目路径推断项目名称
|
|
670
|
-
* @private
|
|
671
666
|
*/
|
|
672
667
|
_inferProjectName(projectRoot) {
|
|
673
668
|
return path.basename(projectRoot);
|
|
@@ -42,11 +42,18 @@ export declare class RulesGenerator {
|
|
|
42
42
|
* 保留静态模板文件(autosnippet-conventions.mdc, autosnippet-skills.mdc)
|
|
43
43
|
*/
|
|
44
44
|
cleanDynamicFiles(): void;
|
|
45
|
-
/** @private */
|
|
46
45
|
_renderChannelA(ruleLines: string[]): string;
|
|
47
|
-
/** @private */
|
|
48
46
|
_renderChannelB(topic: string, body: string, description: string): string;
|
|
49
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* Baseline Rules — 零知识库时写入基础引导文件
|
|
49
|
+
* 告知 Agent 可用的 MCP 工具和推荐工作流
|
|
50
|
+
*/
|
|
51
|
+
writeBaselineRules(): {
|
|
52
|
+
filePath: string;
|
|
53
|
+
tokensUsed: number;
|
|
54
|
+
rulesCount: number;
|
|
55
|
+
};
|
|
56
|
+
_renderBaseline(): string;
|
|
50
57
|
_ensureDir(): void;
|
|
51
58
|
}
|
|
52
59
|
export default RulesGenerator;
|
|
@@ -108,7 +108,6 @@ export class RulesGenerator {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
// ─── 渲染方法 ───────────────────────────────────────
|
|
111
|
-
/** @private */
|
|
112
111
|
_renderChannelA(ruleLines) {
|
|
113
112
|
const desc = `${this.projectName} mandatory rules — coding constraints that must never be violated. Auto-generated by AutoSnippet.`;
|
|
114
113
|
const lines = [
|
|
@@ -127,7 +126,6 @@ export class RulesGenerator {
|
|
|
127
126
|
];
|
|
128
127
|
return `${lines.join('\n')}\n`;
|
|
129
128
|
}
|
|
130
|
-
/** @private */
|
|
131
129
|
_renderChannelB(topic, body, description) {
|
|
132
130
|
const topicLabel = topic.charAt(0).toUpperCase() + topic.slice(1);
|
|
133
131
|
const lines = [
|
|
@@ -144,7 +142,49 @@ export class RulesGenerator {
|
|
|
144
142
|
];
|
|
145
143
|
return `${lines.join('\n')}\n`;
|
|
146
144
|
}
|
|
147
|
-
/**
|
|
145
|
+
/**
|
|
146
|
+
* Baseline Rules — 零知识库时写入基础引导文件
|
|
147
|
+
* 告知 Agent 可用的 MCP 工具和推荐工作流
|
|
148
|
+
*/
|
|
149
|
+
writeBaselineRules() {
|
|
150
|
+
this._ensureDir();
|
|
151
|
+
const content = this._renderBaseline();
|
|
152
|
+
const filePath = path.join(this.rulesDir, 'autosnippet-project-rules.mdc');
|
|
153
|
+
fs.writeFileSync(filePath, content, 'utf8');
|
|
154
|
+
return {
|
|
155
|
+
filePath,
|
|
156
|
+
tokensUsed: estimateTokens(content),
|
|
157
|
+
rulesCount: 0,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
_renderBaseline() {
|
|
161
|
+
const lines = [
|
|
162
|
+
'---',
|
|
163
|
+
`description: "${this.projectName} — AutoSnippet baseline guidance. Available MCP tools and recommended workflows."`,
|
|
164
|
+
'alwaysApply: true',
|
|
165
|
+
'---',
|
|
166
|
+
'',
|
|
167
|
+
`# ${this.projectName} — AutoSnippet Baseline`,
|
|
168
|
+
'',
|
|
169
|
+
'This project has AutoSnippet enabled but no knowledge entries yet.',
|
|
170
|
+
'Use the following MCP tools to build and query the knowledge base:',
|
|
171
|
+
'',
|
|
172
|
+
'## Available MCP Tools',
|
|
173
|
+
'',
|
|
174
|
+
'- `autosnippet_bootstrap` — Cold-start: analyze the project and generate initial knowledge entries',
|
|
175
|
+
'- `autosnippet_search({ query })` — Search knowledge base (BM25 + semantic)',
|
|
176
|
+
'- `autosnippet_create_recipe` — Create a new coding recipe from current context',
|
|
177
|
+
'- `autosnippet_guard` — Run compliance review on current changes',
|
|
178
|
+
'- `autosnippet_task_start` / `autosnippet_task_close` — Track coding tasks with automatic knowledge capture',
|
|
179
|
+
'',
|
|
180
|
+
'## Recommended First Steps',
|
|
181
|
+
'',
|
|
182
|
+
'1. Run `autosnippet_bootstrap` to analyze the codebase and generate initial recipes',
|
|
183
|
+
'2. Use `autosnippet_search` to query knowledge while coding',
|
|
184
|
+
'3. Run `autosnippet_guard` before committing to check compliance',
|
|
185
|
+
];
|
|
186
|
+
return `${lines.join('\n')}\n`;
|
|
187
|
+
}
|
|
148
188
|
_ensureDir() {
|
|
149
189
|
if (!fs.existsSync(this.rulesDir)) {
|
|
150
190
|
fs.mkdirSync(this.rulesDir, { recursive: true });
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SkillsSyncer — AutoSnippet Skills to .cursor/skills/ 同步器
|
|
3
3
|
*
|
|
4
|
-
* Channel C:
|
|
5
|
-
* .cursor/skills/
|
|
4
|
+
* Channel C: 将内置 Skills 和项目级 Skills 统一同步到
|
|
5
|
+
* .cursor/skills/ 目录,适配 Cursor Agent Skills 标准格式。
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* - 内置 Skills:从 AutoSnippet 包 skills/ 目录直接复制(autosnippet-create 等)
|
|
8
|
+
* - 项目级 Skills:从 AutoSnippet/skills/ 转换格式后写入(project-* → autosnippet-*)
|
|
9
|
+
* - 同时为项目级 Skill 生成 references/RECIPES.md(相关 Recipe 摘要)
|
|
8
10
|
*/
|
|
9
11
|
export declare class SkillsSyncer {
|
|
10
12
|
knowledgeService: {
|
|
@@ -36,23 +38,35 @@ export declare class SkillsSyncer {
|
|
|
36
38
|
synced: string[];
|
|
37
39
|
skipped: string[];
|
|
38
40
|
errors: string[];
|
|
41
|
+
builtinSynced: string[];
|
|
39
42
|
}>;
|
|
43
|
+
/**
|
|
44
|
+
* 同步内置 Skills:从 AutoSnippet 包 skills/ 目录直接复制到 .cursor/skills/
|
|
45
|
+
*/
|
|
46
|
+
_syncBuiltinSkills(result: {
|
|
47
|
+
builtinSynced: string[];
|
|
48
|
+
errors: string[];
|
|
49
|
+
}): void;
|
|
50
|
+
/**
|
|
51
|
+
* 同步项目级 Skills:从 AutoSnippet/skills/ 转换格式后写入 .cursor/skills/
|
|
52
|
+
*/
|
|
53
|
+
_syncProjectSkills(result: {
|
|
54
|
+
synced: string[];
|
|
55
|
+
skipped: string[];
|
|
56
|
+
errors: string[];
|
|
57
|
+
}): Promise<void>;
|
|
40
58
|
/**
|
|
41
59
|
* 转换 SKILL.md 格式 — 从 AutoSnippet 格式到 Cursor Agent Skills 标准
|
|
42
|
-
* @private
|
|
43
60
|
*/
|
|
44
61
|
_convertSkillMd(source: string, targetName: string, sourceDirName: string): string;
|
|
45
62
|
/**
|
|
46
63
|
* 生成 references/RECIPES.md
|
|
47
|
-
* @private
|
|
48
64
|
*/
|
|
49
65
|
_generateRecipes(targetSkillDir: string, sourceDirName: string): Promise<void>;
|
|
50
66
|
/**
|
|
51
67
|
* 生成使用场景列表
|
|
52
|
-
* @private
|
|
53
68
|
*/
|
|
54
69
|
_generateUseCases(sourceDirName: string): string[];
|
|
55
|
-
/** @private */
|
|
56
70
|
_capitalizeWords(str: string): string;
|
|
57
71
|
}
|
|
58
72
|
export default SkillsSyncer;
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* SkillsSyncer — AutoSnippet Skills to .cursor/skills/ 同步器
|
|
3
3
|
*
|
|
4
|
-
* Channel C:
|
|
5
|
-
* .cursor/skills/
|
|
4
|
+
* Channel C: 将内置 Skills 和项目级 Skills 统一同步到
|
|
5
|
+
* .cursor/skills/ 目录,适配 Cursor Agent Skills 标准格式。
|
|
6
6
|
*
|
|
7
|
-
*
|
|
7
|
+
* - 内置 Skills:从 AutoSnippet 包 skills/ 目录直接复制(autosnippet-create 等)
|
|
8
|
+
* - 项目级 Skills:从 AutoSnippet/skills/ 转换格式后写入(project-* → autosnippet-*)
|
|
9
|
+
* - 同时为项目级 Skill 生成 references/RECIPES.md(相关 Recipe 摘要)
|
|
8
10
|
*/
|
|
9
11
|
import fs from 'node:fs';
|
|
10
12
|
import path from 'node:path';
|
|
11
13
|
import { DEFAULT_KNOWLEDGE_BASE_DIR } from '../../shared/ProjectMarkers.js';
|
|
14
|
+
import { SKILLS_DIR as BUILTIN_SKILLS_DIR } from '../../shared/package-root.js';
|
|
12
15
|
/**
|
|
13
16
|
* 技能名称映射:AutoSnippet/skills/ → .cursor/skills/
|
|
14
17
|
* AutoSnippet/skills/ 下面是 bootstrap 动态生成的项目级 skills,
|
|
@@ -70,10 +73,48 @@ export class SkillsSyncer {
|
|
|
70
73
|
* @returns >}
|
|
71
74
|
*/
|
|
72
75
|
async sync() {
|
|
73
|
-
const result = {
|
|
76
|
+
const result = {
|
|
77
|
+
synced: [],
|
|
78
|
+
skipped: [],
|
|
79
|
+
errors: [],
|
|
80
|
+
builtinSynced: [],
|
|
81
|
+
};
|
|
82
|
+
// ── Phase 1: 同步内置 Skills ──
|
|
83
|
+
this._syncBuiltinSkills(result);
|
|
84
|
+
// ── Phase 2: 同步项目级 Skills ──
|
|
85
|
+
await this._syncProjectSkills(result);
|
|
86
|
+
return result;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 同步内置 Skills:从 AutoSnippet 包 skills/ 目录直接复制到 .cursor/skills/
|
|
90
|
+
*/
|
|
91
|
+
_syncBuiltinSkills(result) {
|
|
92
|
+
if (!fs.existsSync(BUILTIN_SKILLS_DIR)) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const builtinDirs = fs
|
|
96
|
+
.readdirSync(BUILTIN_SKILLS_DIR, { withFileTypes: true })
|
|
97
|
+
.filter((d) => d.isDirectory())
|
|
98
|
+
.map((d) => d.name);
|
|
99
|
+
for (const name of builtinDirs) {
|
|
100
|
+
try {
|
|
101
|
+
const src = path.join(BUILTIN_SKILLS_DIR, name);
|
|
102
|
+
const dest = path.join(this.targetDir, name);
|
|
103
|
+
fs.cpSync(src, dest, { recursive: true, force: true });
|
|
104
|
+
result.builtinSynced.push(name);
|
|
105
|
+
}
|
|
106
|
+
catch (err) {
|
|
107
|
+
result.errors.push(`builtin/${name}: ${err.message}`);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* 同步项目级 Skills:从 AutoSnippet/skills/ 转换格式后写入 .cursor/skills/
|
|
113
|
+
*/
|
|
114
|
+
async _syncProjectSkills(result) {
|
|
74
115
|
// 检查源目录是否存在
|
|
75
116
|
if (!fs.existsSync(this.sourceDir)) {
|
|
76
|
-
return
|
|
117
|
+
return;
|
|
77
118
|
}
|
|
78
119
|
// 扫描源目录
|
|
79
120
|
const skillDirs = fs
|
|
@@ -106,11 +147,9 @@ export class SkillsSyncer {
|
|
|
106
147
|
result.errors.push(`${dirName}: ${err.message}`);
|
|
107
148
|
}
|
|
108
149
|
}
|
|
109
|
-
return result;
|
|
110
150
|
}
|
|
111
151
|
/**
|
|
112
152
|
* 转换 SKILL.md 格式 — 从 AutoSnippet 格式到 Cursor Agent Skills 标准
|
|
113
|
-
* @private
|
|
114
153
|
*/
|
|
115
154
|
_convertSkillMd(source, targetName, sourceDirName) {
|
|
116
155
|
// 提取原始内容(去掉 frontmatter)
|
|
@@ -150,7 +189,6 @@ export class SkillsSyncer {
|
|
|
150
189
|
}
|
|
151
190
|
/**
|
|
152
191
|
* 生成 references/RECIPES.md
|
|
153
|
-
* @private
|
|
154
192
|
*/
|
|
155
193
|
async _generateRecipes(targetSkillDir, sourceDirName) {
|
|
156
194
|
const refsDir = path.join(targetSkillDir, 'references');
|
|
@@ -201,7 +239,6 @@ export class SkillsSyncer {
|
|
|
201
239
|
}
|
|
202
240
|
/**
|
|
203
241
|
* 生成使用场景列表
|
|
204
|
-
* @private
|
|
205
242
|
*/
|
|
206
243
|
_generateUseCases(sourceDirName) {
|
|
207
244
|
const casesMap = {
|
|
@@ -275,7 +312,6 @@ export class SkillsSyncer {
|
|
|
275
312
|
'- Need guidance on project-specific patterns',
|
|
276
313
|
]);
|
|
277
314
|
}
|
|
278
|
-
/** @private */
|
|
279
315
|
_capitalizeWords(str) {
|
|
280
316
|
return str.replace(/\b\w/g, (c) => c.toUpperCase());
|
|
281
317
|
}
|
|
@@ -25,15 +25,12 @@ export declare class TopicClassifier {
|
|
|
25
25
|
buildDescription(topic: string, entries: KnowledgeEntryProps[]): string;
|
|
26
26
|
/**
|
|
27
27
|
* 分类单个 entry 到主题 — 直读 AI 预计算的 topicHint
|
|
28
|
-
* @private
|
|
29
28
|
*/
|
|
30
|
-
_classifyEntry
|
|
29
|
+
private _classifyEntry;
|
|
31
30
|
/**
|
|
32
31
|
* 从 entry 提取关键词
|
|
33
|
-
* @private
|
|
34
32
|
*/
|
|
35
|
-
_extractKeywords
|
|
36
|
-
|
|
37
|
-
_topicLabel(topic: string): string;
|
|
33
|
+
private _extractKeywords;
|
|
34
|
+
private _topicLabel;
|
|
38
35
|
}
|
|
39
36
|
export default TopicClassifier;
|
|
@@ -99,14 +99,12 @@ export class TopicClassifier {
|
|
|
99
99
|
}
|
|
100
100
|
/**
|
|
101
101
|
* 分类单个 entry 到主题 — 直读 AI 预计算的 topicHint
|
|
102
|
-
* @private
|
|
103
102
|
*/
|
|
104
103
|
_classifyEntry(entry) {
|
|
105
104
|
return entry.topicHint || null; // AI 没给 → null → 归入 general
|
|
106
105
|
}
|
|
107
106
|
/**
|
|
108
107
|
* 从 entry 提取关键词
|
|
109
|
-
* @private
|
|
110
108
|
*/
|
|
111
109
|
_extractKeywords(entry) {
|
|
112
110
|
const text = `${entry.title || ''} ${entry.description || ''}`;
|
|
@@ -115,7 +113,6 @@ export class TopicClassifier {
|
|
|
115
113
|
const filtered = words.map((w) => w.toLowerCase()).filter((w) => !STOP_WORDS.has(w));
|
|
116
114
|
return [...new Set(filtered)].slice(0, 5);
|
|
117
115
|
}
|
|
118
|
-
/** @private */
|
|
119
116
|
_topicLabel(topic) {
|
|
120
117
|
const labels = {
|
|
121
118
|
networking: 'Networking',
|
|
@@ -113,7 +113,7 @@ export declare class GuardCheckEngine {
|
|
|
113
113
|
/**
|
|
114
114
|
* 注入 Enhancement Pack 外部规则(支持 RegExp 和 string pattern)
|
|
115
115
|
* 与 BUILT_IN_RULES 合并检查,自动跳过 ruleId 重复的规则
|
|
116
|
-
* @param
|
|
116
|
+
* @param rules
|
|
117
117
|
*/
|
|
118
118
|
injectExternalRules(rules: ExternalRuleInput[]): void;
|
|
119
119
|
/** EP 注入幂等标记 — 调用者可用此判断是否已完成注入,避免重复加载 EnhancementRegistry */
|
|
@@ -159,7 +159,7 @@ export declare class GuardCheckEngine {
|
|
|
159
159
|
_getAstAnalyzer(): typeof AstAnalyzerModule;
|
|
160
160
|
/**
|
|
161
161
|
* 将 Guard 命中计数回写到对应 Recipe 的 guard_hit_count
|
|
162
|
-
* @param
|
|
162
|
+
* @param violations
|
|
163
163
|
*/
|
|
164
164
|
trackGuardHits(violations: GuardViolation[]): void;
|
|
165
165
|
/**
|
|
@@ -173,7 +173,7 @@ export declare class GuardCheckEngine {
|
|
|
173
173
|
}): AuditFileResult;
|
|
174
174
|
/**
|
|
175
175
|
* 批量文件审计
|
|
176
|
-
* @param
|
|
176
|
+
* @param files
|
|
177
177
|
* @param options {scope: 'file'|'target'|'project'}
|
|
178
178
|
* @returns }
|
|
179
179
|
*/
|