autosnippet 2.7.1 → 2.8.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 +7 -7
- package/bin/cli.js +21 -0
- package/bin/mcp-server.js +22 -0
- package/dashboard/dist/assets/{index-BjfUm8p9.js → index-Duc8Qk-c.js} +30 -30
- package/dashboard/dist/index.html +1 -1
- package/lib/external/mcp/McpServer.js +5 -3
- package/lib/external/mcp/handlers/skill.js +198 -0
- package/lib/external/mcp/tools.js +54 -1
- package/lib/service/automation/handlers/AlinkHandler.js +43 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ AI 编码助手生成的代码往往脱离项目上下文——不知道团队
|
|
|
37
37
|
| **Guard** | 代码审查引擎——基于知识库中的规则对代码做合规检查,支持文件 / Target / 项目三级范围 |
|
|
38
38
|
| **Skills** | 13 个 Cursor Agent 技能包——覆盖候选生成、冷启动、Guard 审计、意图路由、生命周期管理等场景 |
|
|
39
39
|
| **Bootstrap** | 冷启动引擎——自动扫描 SPM Target + AST 分析,9 维度启发式提取代码模式,AI 精炼后生成 Candidate |
|
|
40
|
-
| **ChatAgent** |
|
|
40
|
+
| **ChatAgent** | 多 Agent 协作对话系统(Analyst + Producer),支持项目感知、信心信号、组合工具链和跨对话轻量记忆 |
|
|
41
41
|
|
|
42
42
|
## 快速开始
|
|
43
43
|
|
|
@@ -82,7 +82,7 @@ asd status # 自检项目根、AI Provider、索引、Dashboard
|
|
|
82
82
|
|
|
83
83
|
### 三种使用方式
|
|
84
84
|
|
|
85
|
-
**① Cursor AI(推荐)**:自然语言驱动,Cursor 通过 13 个 Skills +
|
|
85
|
+
**① Cursor AI(推荐)**:自然语言驱动,Cursor 通过 13 个 Skills + 38 个 MCP 工具与知识库交互。
|
|
86
86
|
|
|
87
87
|
```
|
|
88
88
|
用户:「扫描 NetworkModule 这个 Target,提取最佳实践」
|
|
@@ -98,7 +98,7 @@ Cursor → autosnippet_get_targets → autosnippet_get_target_files → 逐文
|
|
|
98
98
|
|
|
99
99
|
`asd ui` 启动后访问 Web 管理后台(默认 http://127.0.0.1:3000):
|
|
100
100
|
|
|
101
|
-

|
|
102
102
|
|
|
103
103
|
**10 个功能视图**:
|
|
104
104
|
|
|
@@ -106,7 +106,7 @@ Cursor → autosnippet_get_targets → autosnippet_get_target_files → 逐文
|
|
|
106
106
|
|------|------|
|
|
107
107
|
| **Recipes** | 浏览、编辑、发布、弃用知识条目;详情抽屉支持 Markdown 编辑与关联关系管理 |
|
|
108
108
|
| **Candidates** | 审核 AI / 手动提交的候选,一键入库或批量操作,支持 AI 润色 |
|
|
109
|
-
| **AI Chat** |
|
|
109
|
+
| **AI Chat** | ChatAgent 智能对话(Analyst 分析 + Producer 生产),项目感知 + 跨对话记忆 |
|
|
110
110
|
| **SPM Explorer** | SPM Target 浏览与扫描,候选 vs Recipe 对比抽屉,头文件编辑 |
|
|
111
111
|
| **Dep Graph** | 依赖关系图可视化 |
|
|
112
112
|
| **Knowledge Graph** | Recipe 关联关系的知识图谱可视化(依赖 / 扩展 / 冲突等),AI 自动发现关系,按 category 分组 |
|
|
@@ -123,7 +123,7 @@ Cursor → autosnippet_get_targets → autosnippet_get_target_files → 逐文
|
|
|
123
123
|
|
|
124
124
|
AutoSnippet 为 Cursor 提供完整的 MCP + Skills 集成:
|
|
125
125
|
|
|
126
|
-
- **
|
|
126
|
+
- **38 个 MCP 工具**:搜索(4 种模式)、Guard 检查、候选提交 / 校验 / 查重、知识图谱查询、Bootstrap 冷启动、Skills 管理等
|
|
127
127
|
- **13 个 Agent Skills**:`autosnippet-candidates`、`autosnippet-guard`、`autosnippet-coldstart`、`autosnippet-intent` 等,引导 AI 正确使用工具
|
|
128
128
|
- **写操作 Gateway 保护**:9 个写操作经过权限 / 宪法 / 审计三重检查
|
|
129
129
|
|
|
@@ -167,7 +167,7 @@ asd install:vscode-copilot # 配置 MCP 和 Copilot 指令
|
|
|
167
167
|
|
|
168
168
|
## MCP 工具一览
|
|
169
169
|
|
|
170
|
-
|
|
170
|
+
38 个 MCP 工具按功能分组:
|
|
171
171
|
|
|
172
172
|
| 分类 | 工具 |
|
|
173
173
|
|------|------|
|
|
@@ -179,7 +179,7 @@ asd install:vscode-copilot # 配置 MCP 和 Copilot 指令
|
|
|
179
179
|
| **项目结构** | `autosnippet_get_targets`、`autosnippet_get_target_files`、`autosnippet_get_target_metadata` |
|
|
180
180
|
| **Guard** | `autosnippet_guard_check`、`autosnippet_guard_audit_files`、`autosnippet_scan_project` |
|
|
181
181
|
| **冷启动** | `autosnippet_bootstrap_knowledge`、`autosnippet_bootstrap_refine` |
|
|
182
|
-
| **Skills** | `autosnippet_list_skills`、`autosnippet_load_skill`、`autosnippet_create_skill`、`autosnippet_suggest_skills` |
|
|
182
|
+
| **Skills** | `autosnippet_list_skills`、`autosnippet_load_skill`、`autosnippet_create_skill`、`autosnippet_delete_skill`、`autosnippet_update_skill`、`autosnippet_suggest_skills` |
|
|
183
183
|
| **治理** | `autosnippet_compliance_report` |
|
|
184
184
|
|
|
185
185
|
## 配置
|
package/bin/cli.js
CHANGED
|
@@ -25,6 +25,27 @@ const __dirname = dirname(__filename);
|
|
|
25
25
|
const pkgPath = join(__dirname, '..', 'package.json');
|
|
26
26
|
const pkg = existsSync(pkgPath) ? JSON.parse(readFileSync(pkgPath, 'utf8')) : { version: '2.0.0' };
|
|
27
27
|
|
|
28
|
+
// ─── 进程级错误兜底 ────────────────────────────────────
|
|
29
|
+
process.on('uncaughtException', (error) => {
|
|
30
|
+
process.stderr.write(`[asd] Uncaught Exception: ${error.message}\n`);
|
|
31
|
+
if (error.stack) process.stderr.write(`${error.stack}\n`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
process.on('unhandledRejection', (reason) => {
|
|
36
|
+
const msg = reason instanceof Error ? reason.message : String(reason);
|
|
37
|
+
process.stderr.write(`[asd] Unhandled Rejection: ${msg}\n`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
// 优雅关闭 — 防止 SIGINT/SIGTERM 时资源泄漏
|
|
42
|
+
const handleSignal = (signal) => {
|
|
43
|
+
process.stderr.write(`[asd] Received ${signal}, exiting…\n`);
|
|
44
|
+
process.exit(0);
|
|
45
|
+
};
|
|
46
|
+
process.on('SIGTERM', () => handleSignal('SIGTERM'));
|
|
47
|
+
process.on('SIGINT', () => handleSignal('SIGINT'));
|
|
48
|
+
|
|
28
49
|
const program = new Command();
|
|
29
50
|
program
|
|
30
51
|
.name('asd')
|
package/bin/mcp-server.js
CHANGED
|
@@ -19,6 +19,28 @@
|
|
|
19
19
|
// 使用动态 import() 避免 ESM static import hoisting 导致 env 未就绪
|
|
20
20
|
process.env.ASD_MCP_MODE = '1';
|
|
21
21
|
|
|
22
|
+
// ─── 进程级错误兜底 ────────────────────────────────────
|
|
23
|
+
process.on('uncaughtException', (error) => {
|
|
24
|
+
process.stderr.write(`[MCP] Uncaught Exception: ${error.message}\n`);
|
|
25
|
+
if (error.stack) process.stderr.write(`${error.stack}\n`);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
process.on('unhandledRejection', (reason) => {
|
|
30
|
+
const msg = reason instanceof Error ? reason.message : String(reason);
|
|
31
|
+
process.stderr.write(`[MCP] Unhandled Rejection: ${msg}\n`);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
process.on('SIGTERM', () => {
|
|
36
|
+
process.stderr.write('[MCP] Received SIGTERM, shutting down…\n');
|
|
37
|
+
process.exit(0);
|
|
38
|
+
});
|
|
39
|
+
process.on('SIGINT', () => {
|
|
40
|
+
process.stderr.write('[MCP] Received SIGINT, shutting down…\n');
|
|
41
|
+
process.exit(0);
|
|
42
|
+
});
|
|
43
|
+
|
|
22
44
|
const { startMcpServer } = await import('../lib/external/mcp/McpServer.js');
|
|
23
45
|
|
|
24
46
|
startMcpServer().catch(err => {
|