autosnippet 2.10.0 → 2.12.0
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 +10 -10
- package/bin/cli.js +48 -7
- package/dashboard/dist/assets/{icons-BkT3XrKf.js → icons-nJfgG6f_.js} +97 -102
- package/dashboard/dist/assets/index-BkFYJ3vq.js +121 -0
- package/dashboard/dist/assets/index-DqK6Cy2z.css +1 -0
- package/dashboard/dist/index.html +3 -3
- package/lib/cli/AiScanService.js +33 -36
- package/lib/cli/KnowledgeSyncService.js +64 -62
- package/lib/cli/UpgradeService.js +28 -0
- package/lib/domain/knowledge/KnowledgeEntry.js +55 -117
- package/lib/domain/knowledge/KnowledgeRepository.js +1 -1
- package/lib/domain/knowledge/Lifecycle.js +4 -14
- package/lib/domain/knowledge/values/Constraints.js +5 -2
- package/lib/domain/knowledge/values/Content.js +5 -22
- package/lib/domain/knowledge/values/Quality.js +3 -15
- package/lib/domain/knowledge/values/Reasoning.js +9 -8
- package/lib/domain/knowledge/values/Relations.js +16 -42
- package/lib/domain/knowledge/values/Stats.js +8 -23
- package/lib/external/ai/AiProvider.js +44 -18
- package/lib/external/mcp/handlers/bootstrap/pipeline/BootstrapSnapshot.js +541 -0
- package/lib/external/mcp/handlers/bootstrap/pipeline/EpisodicMemory.js +694 -0
- package/lib/external/mcp/handlers/bootstrap/pipeline/IncrementalBootstrap.js +220 -0
- package/lib/external/mcp/handlers/bootstrap/pipeline/ToolResultCache.js +189 -0
- package/lib/external/mcp/handlers/bootstrap/pipeline/orchestrator.js +470 -9
- package/lib/external/mcp/handlers/bootstrap.js +96 -3
- package/lib/external/mcp/handlers/browse.js +9 -10
- package/lib/external/mcp/handlers/candidate.js +4 -6
- package/lib/external/mcp/handlers/knowledge.js +74 -12
- package/lib/external/mcp/handlers/search.js +3 -3
- package/lib/external/mcp/handlers/structure.js +5 -5
- package/lib/external/mcp/tools.js +39 -32
- package/lib/http/HttpServer.js +10 -0
- package/lib/http/api-spec.js +0 -383
- package/lib/http/routes/ai.js +4 -3
- package/lib/http/routes/knowledge.js +1 -1
- package/lib/infrastructure/database/migrations/001_initial_schema.js +315 -0
- package/lib/injection/ServiceContainer.js +31 -0
- package/lib/repository/knowledge/KnowledgeRepository.impl.js +74 -109
- package/lib/service/automation/FileWatcher.js +4 -12
- package/lib/service/automation/handlers/AlinkHandler.js +2 -3
- package/lib/service/automation/handlers/CreateHandler.js +4 -5
- package/lib/service/automation/handlers/DraftHandler.js +1 -1
- package/lib/service/automation/handlers/SearchHandler.js +7 -22
- package/lib/service/candidate/SimilarityService.js +2 -2
- package/lib/service/chat/AnalystAgent.js +74 -3
- package/lib/service/chat/CandidateGuardrail.js +21 -10
- package/lib/service/chat/ChatAgent.js +205 -36
- package/lib/service/chat/EpisodicConsolidator.js +343 -0
- package/lib/service/chat/HandoffProtocol.js +1 -0
- package/lib/service/chat/ProducerAgent.js +36 -7
- package/lib/service/chat/ProjectSemanticMemory.js +865 -0
- package/lib/service/chat/ReasoningLayer.js +854 -0
- package/lib/service/chat/ReasoningTrace.js +329 -0
- package/lib/service/chat/WorkingMemory.js +316 -0
- package/lib/service/chat/tools.js +455 -125
- package/lib/service/cursor/CursorDeliveryPipeline.js +279 -0
- package/lib/service/cursor/KnowledgeCompressor.js +87 -0
- package/lib/service/cursor/RulesGenerator.js +168 -0
- package/lib/service/cursor/SkillsSyncer.js +268 -0
- package/lib/service/cursor/TokenBudget.js +58 -0
- package/lib/service/cursor/TopicClassifier.js +141 -0
- package/lib/service/guard/GuardCheckEngine.js +6 -21
- package/lib/service/guard/GuardService.js +9 -9
- package/lib/service/knowledge/CodeEntityGraph.js +787 -0
- package/lib/service/knowledge/KnowledgeFileWriter.js +28 -35
- package/lib/service/knowledge/KnowledgeService.js +144 -67
- package/lib/service/recipe/RecipeParser.js +3 -12
- package/lib/service/search/SearchEngine.js +17 -45
- package/lib/service/skills/SignalCollector.js +5 -5
- package/lib/service/spm/SpmService.js +15 -48
- package/lib/shared/RecipeReadinessChecker.js +6 -11
- package/package.json +1 -1
- package/skills/autosnippet-candidates/SKILL.md +5 -5
- package/skills/autosnippet-coldstart/SKILL.md +1 -1
- package/skills/autosnippet-create/SKILL.md +1 -1
- package/skills/autosnippet-recipes/SKILL.md +2 -2
- package/dashboard/dist/assets/index-BsB7DzW4.css +0 -1
- package/dashboard/dist/assets/index-DdmQMrJJ.js +0 -155
- package/lib/infrastructure/database/migrations/005_unified_schema_reset.js +0 -181
- package/lib/infrastructure/database/migrations/006_add_kind_column.js +0 -41
- package/lib/infrastructure/database/migrations/007_guard_violations_table.js +0 -38
- package/lib/infrastructure/database/migrations/008_add_source_file_column.js +0 -59
- package/lib/infrastructure/database/migrations/009_recipes_v2_columns.js +0 -44
- package/lib/infrastructure/database/migrations/010_create_audit_and_sessions.js +0 -58
- package/lib/infrastructure/database/migrations/011_recipe_i18n_columns.js +0 -61
- package/lib/infrastructure/database/migrations/012_add_trigger_column.js +0 -55
- package/lib/infrastructure/database/migrations/013_create_knowledge_edges.js +0 -80
- package/lib/infrastructure/database/migrations/014_add_candidate_indexes.js +0 -14
- package/lib/infrastructure/database/migrations/015_create_token_usage.js +0 -27
- package/lib/infrastructure/database/migrations/016_unified_knowledge_entries.js +0 -395
package/README.md
CHANGED
|
@@ -175,16 +175,16 @@ asd install:vscode-copilot # 配置 MCP 和 Copilot 指令
|
|
|
175
175
|
|
|
176
176
|
| 分类 | 工具 |
|
|
177
177
|
|------|------|
|
|
178
|
-
| **系统** | `health`、`
|
|
179
|
-
| **搜索** | `
|
|
180
|
-
| **Recipe 浏览** | `
|
|
181
|
-
| **候选管理** | `
|
|
182
|
-
| **知识图谱** | `
|
|
183
|
-
| **项目结构** | `
|
|
184
|
-
| **Guard** | `
|
|
185
|
-
| **冷启动** | `
|
|
186
|
-
| **Skills** | `
|
|
187
|
-
| **治理** | `
|
|
178
|
+
| **系统** | `health`、`capabilities` |
|
|
179
|
+
| **搜索** | `search`(统合入口)、`context_search`(4 层漏斗)、`keyword_search`、`semantic_search` |
|
|
180
|
+
| **Recipe 浏览** | `list_recipes`、`get_recipe`、`list_rules`、`patterns`、`list_facts`、`recipe_insights`、`confirm_usage` |
|
|
181
|
+
| **候选管理** | `validate_candidate`、`check_duplicate`、`submit_knowledge`、`submit_knowledge_batch`、`submit_knowledge_batch`、`enrich_candidates` |
|
|
182
|
+
| **知识图谱** | `graph_query`、`graph_impact`、`graph_path`、`graph_stats` |
|
|
183
|
+
| **项目结构** | `get_targets`、`get_target_files`、`get_target_metadata` |
|
|
184
|
+
| **Guard** | `guard_check`、`guard_audit_files`、`scan_project` |
|
|
185
|
+
| **冷启动** | `bootstrap_knowledge`、`bootstrap_refine` |
|
|
186
|
+
| **Skills** | `list_skills`、`load_skill`、`create_skill`、`delete_skill`、`update_skill`、`suggest_skills` |
|
|
187
|
+
| **治理** | `compliance_report` |
|
|
188
188
|
|
|
189
189
|
## 配置
|
|
190
190
|
|
package/bin/cli.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* Usage:
|
|
7
7
|
* asd setup - 初始化项目
|
|
8
|
-
* asd ais [Target] - AI 扫描 Target →
|
|
8
|
+
* asd ais [Target] - AI 扫描 Target → 直接发布 Recipes
|
|
9
9
|
* asd search <query> - 搜索知识库
|
|
10
10
|
* asd guard <file> - Guard 检查
|
|
11
11
|
* asd watch - 文件监控
|
|
@@ -78,10 +78,10 @@ program
|
|
|
78
78
|
// ─────────────────────────────────────────────────────
|
|
79
79
|
program
|
|
80
80
|
.command('ais [target]')
|
|
81
|
-
.description('AI 扫描 Target 源码 →
|
|
81
|
+
.description('AI 扫描 Target 源码 → 提取并发布 Recipes(需配置 AI Provider)')
|
|
82
82
|
.option('-d, --dir <path>', '项目目录', '.')
|
|
83
83
|
.option('-m, --max-files <n>', '最大扫描文件数', '200')
|
|
84
|
-
.option('--dry-run', '
|
|
84
|
+
.option('--dry-run', '仅预览,不发布 Recipe')
|
|
85
85
|
.option('--json', '以 JSON 格式输出')
|
|
86
86
|
.action(async (target, opts) => {
|
|
87
87
|
const projectRoot = resolve(opts.dir);
|
|
@@ -99,7 +99,7 @@ program
|
|
|
99
99
|
const scanner = new AiScanService({ container, projectRoot });
|
|
100
100
|
|
|
101
101
|
const ora = (await import('ora')).default;
|
|
102
|
-
const spinner = ora('
|
|
102
|
+
const spinner = ora('正在扫描源文件并提取 Recipe...').start();
|
|
103
103
|
|
|
104
104
|
const report = await scanner.scan(target || null, {
|
|
105
105
|
maxFiles: parseInt(opts.maxFiles, 10),
|
|
@@ -114,7 +114,7 @@ program
|
|
|
114
114
|
console.log(`\n✅ AI 扫描完成`);
|
|
115
115
|
console.log(` 扫描文件: ${report.files}`);
|
|
116
116
|
console.log(` 跳过: ${report.skipped}`);
|
|
117
|
-
console.log(`
|
|
117
|
+
console.log(` 发布 Recipe: ${report.published}`);
|
|
118
118
|
if (report.errors.length > 0) {
|
|
119
119
|
console.log(`\n⚠️ ${report.errors.length} 个错误:`);
|
|
120
120
|
for (const err of report.errors.slice(0, 10)) {
|
|
@@ -122,8 +122,8 @@ program
|
|
|
122
122
|
}
|
|
123
123
|
if (report.errors.length > 10) console.log(` ... 及其他 ${report.errors.length - 10} 个`);
|
|
124
124
|
}
|
|
125
|
-
if (!opts.dryRun && report.
|
|
126
|
-
console.log(`\n📋
|
|
125
|
+
if (!opts.dryRun && report.published > 0) {
|
|
126
|
+
console.log(`\n📋 Recipe 已发布,可通过 asd search 或 Cursor Rules 使用`);
|
|
127
127
|
}
|
|
128
128
|
}
|
|
129
129
|
|
|
@@ -490,6 +490,47 @@ program
|
|
|
490
490
|
});
|
|
491
491
|
});
|
|
492
492
|
|
|
493
|
+
// ─────────────────────────────────────────────────────
|
|
494
|
+
// cursor-rules 命令
|
|
495
|
+
// ─────────────────────────────────────────────────────
|
|
496
|
+
program
|
|
497
|
+
.command('cursor-rules')
|
|
498
|
+
.description('生成 Cursor 4 通道交付物料(Rules + Skills → .cursor/)')
|
|
499
|
+
.option('-d, --dir <path>', '项目目录', '.')
|
|
500
|
+
.option('--verbose', '详细输出')
|
|
501
|
+
.action(async (opts) => {
|
|
502
|
+
const projectRoot = resolve(opts.dir);
|
|
503
|
+
|
|
504
|
+
console.log(`\n🚀 AutoSnippet — Cursor Delivery Pipeline`);
|
|
505
|
+
console.log(` 项目: ${basename(projectRoot)}`);
|
|
506
|
+
console.log(` 路径: ${projectRoot}\n`);
|
|
507
|
+
|
|
508
|
+
const { bootstrap, container } = await initContainer({ projectRoot });
|
|
509
|
+
try {
|
|
510
|
+
const pipeline = container.get('cursorDeliveryPipeline');
|
|
511
|
+
const result = await pipeline.deliver();
|
|
512
|
+
|
|
513
|
+
console.log(`✅ Cursor 交付物料生成完成\n`);
|
|
514
|
+
console.log(` Channel A (Always-On Rules): ${result.channelA.rulesCount} 条规则 (${result.channelA.tokensUsed} tokens)`);
|
|
515
|
+
console.log(` Channel B (Smart Rules): ${result.channelB.topicCount} 个主题, ${result.channelB.patternsCount} 个模式 (${result.channelB.totalTokens} tokens)`);
|
|
516
|
+
console.log(` Channel C (Agent Skills): ${result.channelC.synced} 个 Skills 已同步`);
|
|
517
|
+
if (result.channelC.errors > 0) {
|
|
518
|
+
console.log(` ⚠️ ${result.channelC.errors} 个错误`);
|
|
519
|
+
}
|
|
520
|
+
console.log(`\n 总耗时: ${result.stats.duration}ms`);
|
|
521
|
+
|
|
522
|
+
if (opts.verbose && result.channelB.topics) {
|
|
523
|
+
console.log(`\n Channel B 主题明细:`);
|
|
524
|
+
for (const [topic, info] of Object.entries(result.channelB.topics)) {
|
|
525
|
+
console.log(` - ${topic}: ${info.patternsCount} patterns (${info.tokensUsed} tokens)`);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
console.log('');
|
|
529
|
+
} finally {
|
|
530
|
+
await bootstrap.shutdown?.();
|
|
531
|
+
}
|
|
532
|
+
});
|
|
533
|
+
|
|
493
534
|
// ─────────────────────────────────────────────────────
|
|
494
535
|
// sync 命令
|
|
495
536
|
// ─────────────────────────────────────────────────────
|