agentdock-cli 1.1.0 → 1.4.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 +106 -4
- package/dist/package.json +2 -2
- package/dist/src/agents/registry.js +551 -0
- package/dist/src/agents/semantic.js +208 -0
- package/dist/src/cli.js +45 -1
- package/dist/src/commands/agents.js +84 -0
- package/dist/src/commands/diff.js +73 -0
- package/dist/src/commands/doctor.js +1 -0
- package/dist/src/commands/history.js +109 -0
- package/dist/src/commands/list.js +2 -1
- package/dist/src/commands/recover.js +185 -0
- package/dist/src/commands/restore.js +103 -0
- package/dist/src/commands/snapshot.js +155 -0
- package/dist/src/commands/sync.js +5 -1
- package/dist/src/constants/command-error-codes.js +4 -0
- package/dist/src/core/doctor.js +319 -6
- package/dist/src/core/installer.js +18 -15
- package/dist/src/core/list.js +6 -0
- package/dist/src/core/report.js +29 -8
- package/dist/src/core/scan-export.js +31 -30
- package/dist/src/core/scan.js +59 -34
- package/dist/src/core/snapshot-diff.js +111 -0
- package/dist/src/core/snapshot.js +535 -0
- package/dist/src/core/uninstall.js +12 -7
- package/dist/src/i18n/index.js +112 -4
- package/dist/src/scanners/semantic-scanner.js +272 -0
- package/dist/src/utils/config-format.js +168 -0
- package/package.json +2 -2
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* 语义化适配层(v1.4)。
|
|
4
|
+
*
|
|
5
|
+
* 文件级适配(snapshot / diff / restore)只关心「哪些文件」;语义化迁移还要
|
|
6
|
+
* 知道每个工具把 MCP、规则 / 指令、技能、子代理放在什么位置、用什么格式。
|
|
7
|
+
* 本文件按工具 id 声明这些语义位置,扫描器与导出器据此读写。
|
|
8
|
+
*
|
|
9
|
+
* 约定:
|
|
10
|
+
* - `mcp`:一个配置文件 + 顶层 MCP 容器键(如 `mcpServers` / `mcp` /
|
|
11
|
+
* `context_servers` / `extensions` / `amp.mcpServers`)。
|
|
12
|
+
* - `configs`:需要整文件迁移的普通配置(模型、供应商等)。
|
|
13
|
+
* - `instructions`:单文件形式的全局指令(CLAUDE.md / AGENTS.md / GEMINI.md ...)。
|
|
14
|
+
* - `ruleDirs`:规则目录,目录下的 md / mdc / txt 作为 memory 采集。
|
|
15
|
+
* - `skillDirs`:技能目录,每个子目录视为一个技能。
|
|
16
|
+
* - `agentDirs` / `agentJsonDirs`:子代理目录(md / json)。
|
|
17
|
+
* - `configDirs`:目录下的结构化配置文件(profile / 补丁)。
|
|
18
|
+
*
|
|
19
|
+
* 路径均为相对用户主目录、`/` 分隔,与注册表保持一致。
|
|
20
|
+
*/
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.AGENT_SEMANTICS = void 0;
|
|
23
|
+
exports.agentSemanticProfile = agentSemanticProfile;
|
|
24
|
+
const registry_1 = require("./registry");
|
|
25
|
+
function mcp(relPath, kind, key) {
|
|
26
|
+
return { relPath, kind, key };
|
|
27
|
+
}
|
|
28
|
+
function file(relPath, kind) {
|
|
29
|
+
return { relPath, kind };
|
|
30
|
+
}
|
|
31
|
+
function user(appName, rel) {
|
|
32
|
+
return `${(0, registry_1.vsCodeUser)(appName)}/${rel}`;
|
|
33
|
+
}
|
|
34
|
+
function gooseDir() {
|
|
35
|
+
return process.platform === 'win32'
|
|
36
|
+
? `${(0, registry_1.appDataDir)()}/Block/goose/config`
|
|
37
|
+
: '.config/goose';
|
|
38
|
+
}
|
|
39
|
+
exports.AGENT_SEMANTICS = {
|
|
40
|
+
gemini: {
|
|
41
|
+
mcp: [mcp('.gemini/settings.json', 'json', 'mcpServers')],
|
|
42
|
+
instructions: [file('.gemini/GEMINI.md', 'text')],
|
|
43
|
+
},
|
|
44
|
+
antigravity: {
|
|
45
|
+
mcp: [mcp('.gemini/config/mcp_config.json', 'json', 'mcpServers')],
|
|
46
|
+
},
|
|
47
|
+
opencode: {
|
|
48
|
+
mcp: [
|
|
49
|
+
mcp('.config/opencode/opencode.json', 'jsonc', 'mcp'),
|
|
50
|
+
mcp('.config/opencode/opencode.jsonc', 'jsonc', 'mcp'),
|
|
51
|
+
],
|
|
52
|
+
instructions: [file('.config/opencode/AGENTS.md', 'text')],
|
|
53
|
+
},
|
|
54
|
+
'grok-build': {
|
|
55
|
+
mcp: [mcp('.cursor/mcp.json', 'json', 'mcpServers')],
|
|
56
|
+
ruleDirs: ['.cursor/rules'],
|
|
57
|
+
},
|
|
58
|
+
trae: {
|
|
59
|
+
mcp: [
|
|
60
|
+
mcp(user('Trae CN', 'mcp.json'), 'json', 'mcpServers'),
|
|
61
|
+
mcp(user('Trae', 'mcp.json'), 'json', 'mcpServers'),
|
|
62
|
+
],
|
|
63
|
+
},
|
|
64
|
+
qoder: {
|
|
65
|
+
mcp: [
|
|
66
|
+
mcp(user('Qoder', 'mcp.json'), 'json', 'mcpServers'),
|
|
67
|
+
mcp(user('Qoder CN', 'mcp.json'), 'json', 'mcpServers'),
|
|
68
|
+
],
|
|
69
|
+
},
|
|
70
|
+
cline: {
|
|
71
|
+
mcp: [
|
|
72
|
+
mcp(user('Code', 'globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json'), 'json', 'mcpServers'),
|
|
73
|
+
mcp(user('Code - Insiders', 'globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json'), 'json', 'mcpServers'),
|
|
74
|
+
],
|
|
75
|
+
},
|
|
76
|
+
windsurf: {
|
|
77
|
+
mcp: [mcp('.codeium/windsurf/mcp_config.json', 'json', 'mcpServers')],
|
|
78
|
+
instructions: [file('.codeium/windsurf/memories/global_rules.md', 'text')],
|
|
79
|
+
},
|
|
80
|
+
copilot: {
|
|
81
|
+
mcp: [
|
|
82
|
+
mcp(user('Code', 'mcp.json'), 'json', 'mcpServers'),
|
|
83
|
+
mcp(user('Code - Insiders', 'mcp.json'), 'json', 'mcpServers'),
|
|
84
|
+
mcp('.copilot/mcp-config.json', 'json', 'mcpServers'),
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
'roo-code': {
|
|
88
|
+
mcp: [
|
|
89
|
+
mcp(user('Code', 'globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json'), 'json', 'mcpServers'),
|
|
90
|
+
mcp(user('Code - Insiders', 'globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json'), 'json', 'mcpServers'),
|
|
91
|
+
],
|
|
92
|
+
},
|
|
93
|
+
'kilo-code': {
|
|
94
|
+
mcp: [
|
|
95
|
+
mcp(user('Code', 'globalStorage/kilocode.kilo-code/settings/mcp_settings.json'), 'json', 'mcpServers'),
|
|
96
|
+
mcp(user('Code - Insiders', 'globalStorage/kilocode.kilo-code/settings/mcp_settings.json'), 'json', 'mcpServers'),
|
|
97
|
+
],
|
|
98
|
+
},
|
|
99
|
+
continue: {
|
|
100
|
+
mcp: [
|
|
101
|
+
mcp('.continue/config.yaml', 'yaml', 'mcpServers'),
|
|
102
|
+
mcp('.continue/config.json', 'json', 'mcpServers'),
|
|
103
|
+
],
|
|
104
|
+
configs: [file('.continue/permissions.yaml', 'yaml')],
|
|
105
|
+
ruleDirs: ['.continue/rules'],
|
|
106
|
+
},
|
|
107
|
+
goose: {
|
|
108
|
+
mcp: [mcp(`${gooseDir()}/config.yaml`, 'yaml', 'extensions')],
|
|
109
|
+
configs: [file(`${gooseDir()}/profiles.yaml`, 'yaml')],
|
|
110
|
+
},
|
|
111
|
+
qwen: {
|
|
112
|
+
mcp: [mcp('.qwen/settings.json', 'json', 'mcpServers')],
|
|
113
|
+
instructions: [file('.qwen/QWEN.md', 'text')],
|
|
114
|
+
},
|
|
115
|
+
kiro: {
|
|
116
|
+
mcp: [mcp('.kiro/settings/mcp.json', 'json', 'mcpServers')],
|
|
117
|
+
},
|
|
118
|
+
aider: {
|
|
119
|
+
configs: [
|
|
120
|
+
file('.aider.conf.yml', 'yaml'),
|
|
121
|
+
file('.aider.conf.yaml', 'yaml'),
|
|
122
|
+
],
|
|
123
|
+
},
|
|
124
|
+
zed: {
|
|
125
|
+
mcp: [
|
|
126
|
+
mcp(process.platform === 'win32' ? `${(0, registry_1.appDataDir)()}/Zed/settings.json` : '.config/zed/settings.json', 'json', 'context_servers'),
|
|
127
|
+
mcp('.config/zed/settings.json', 'json', 'context_servers'),
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
crush: {
|
|
131
|
+
mcp: [mcp('.config/crush/crush.json', 'json', 'mcp')],
|
|
132
|
+
},
|
|
133
|
+
'claude-desktop': {
|
|
134
|
+
mcp: [mcp(`${(0, registry_1.appDataDir)()}/Claude/claude_desktop_config.json`, 'json', 'mcpServers')],
|
|
135
|
+
},
|
|
136
|
+
'lm-studio': {
|
|
137
|
+
mcp: [mcp('.lmstudio/mcp.json', 'json', 'mcpServers')],
|
|
138
|
+
},
|
|
139
|
+
codebuddy: {
|
|
140
|
+
mcp: [mcp('.codebuddy/mcp.json', 'json', 'mcpServers')],
|
|
141
|
+
configs: [
|
|
142
|
+
file('.codebuddy/settings.json', 'json'),
|
|
143
|
+
file('.codebuddy/settings.local.json', 'json'),
|
|
144
|
+
],
|
|
145
|
+
instructions: [file('.codebuddy/CODEBUDDY.md', 'text')],
|
|
146
|
+
ruleDirs: ['.codebuddy/rules'],
|
|
147
|
+
skillDirs: ['.codebuddy/skills'],
|
|
148
|
+
agentDirs: ['.codebuddy/agents'],
|
|
149
|
+
},
|
|
150
|
+
kimi: {
|
|
151
|
+
mcp: [mcp('.kimi-code/mcp.json', 'json', 'mcpServers')],
|
|
152
|
+
configs: [
|
|
153
|
+
file('.kimi/config.toml', 'toml'),
|
|
154
|
+
file('.kimi/config.json', 'json'),
|
|
155
|
+
],
|
|
156
|
+
},
|
|
157
|
+
iflow: {
|
|
158
|
+
mcp: [mcp('.iflow/settings.json', 'json', 'mcpServers')],
|
|
159
|
+
instructions: [file('.iflow/IFLOW.md', 'text')],
|
|
160
|
+
},
|
|
161
|
+
junie: {
|
|
162
|
+
mcp: [mcp('.junie/mcp/mcp.json', 'json', 'mcpServers')],
|
|
163
|
+
configs: [file('.junie/config.json', 'json')],
|
|
164
|
+
},
|
|
165
|
+
'amazon-q': {
|
|
166
|
+
mcp: [mcp('.aws/amazonq/agents/default.json', 'json', 'mcpServers')],
|
|
167
|
+
agentJsonDirs: ['.aws/amazonq/cli-agents'],
|
|
168
|
+
},
|
|
169
|
+
amp: {
|
|
170
|
+
mcp: [
|
|
171
|
+
mcp(process.platform === 'win32' ? `${(0, registry_1.appDataDir)()}/amp/settings.json` : '.config/amp/settings.json', 'json', 'amp.mcpServers'),
|
|
172
|
+
mcp('.config/amp/settings.jsonc', 'jsonc', 'amp.mcpServers'),
|
|
173
|
+
],
|
|
174
|
+
},
|
|
175
|
+
'factory-droid': {
|
|
176
|
+
mcp: [mcp('.factory/mcp.json', 'json', 'mcpServers')],
|
|
177
|
+
skillDirs: ['.factory/skills'],
|
|
178
|
+
},
|
|
179
|
+
warp: {
|
|
180
|
+
mcp: [mcp('.warp/mcp.json', 'json', 'mcpServers')],
|
|
181
|
+
},
|
|
182
|
+
comate: {
|
|
183
|
+
mcp: [mcp('.comate/mcp.json', 'json', 'mcpServers')],
|
|
184
|
+
},
|
|
185
|
+
gptme: {
|
|
186
|
+
mcp: [mcp('.config/gptme/config.toml', 'toml', 'mcp')],
|
|
187
|
+
},
|
|
188
|
+
void: {
|
|
189
|
+
mcp: [mcp(user('Void', 'settings.json'), 'json', 'mcp')],
|
|
190
|
+
},
|
|
191
|
+
pearai: {
|
|
192
|
+
mcp: [mcp(user('PearAI', 'settings.json'), 'json', 'mcp')],
|
|
193
|
+
},
|
|
194
|
+
omp: {
|
|
195
|
+
mcp: [mcp('.omp/agent/config.yml', 'yaml', 'mcp')],
|
|
196
|
+
},
|
|
197
|
+
'deepseek-harness': {
|
|
198
|
+
mcp: [mcp('.dsh/settings.yaml', 'yaml', 'mcp')],
|
|
199
|
+
configDirs: ['.dsh/profiles'],
|
|
200
|
+
},
|
|
201
|
+
pi: {
|
|
202
|
+
mcp: [mcp('.pi/agent/config.json', 'json', 'mcp')],
|
|
203
|
+
configs: [file('.pi/settings.json', 'json')],
|
|
204
|
+
},
|
|
205
|
+
};
|
|
206
|
+
function agentSemanticProfile(agentId) {
|
|
207
|
+
return exports.AGENT_SEMANTICS[agentId];
|
|
208
|
+
}
|
package/dist/src/cli.js
CHANGED
|
@@ -16,6 +16,11 @@ const diff_1 = require("./commands/diff");
|
|
|
16
16
|
const config_1 = require("./commands/config");
|
|
17
17
|
const uninstall_1 = require("./commands/uninstall");
|
|
18
18
|
const sync_1 = require("./commands/sync");
|
|
19
|
+
const snapshot_1 = require("./commands/snapshot");
|
|
20
|
+
const restore_1 = require("./commands/restore");
|
|
21
|
+
const history_1 = require("./commands/history");
|
|
22
|
+
const recover_1 = require("./commands/recover");
|
|
23
|
+
const agents_1 = require("./commands/agents");
|
|
19
24
|
const pack_1 = require("./commands/pack");
|
|
20
25
|
const verify_1 = require("./commands/verify");
|
|
21
26
|
const attest_1 = require("./commands/attest");
|
|
@@ -64,6 +69,33 @@ function parseCliOptions(args) {
|
|
|
64
69
|
options.undo = true;
|
|
65
70
|
continue;
|
|
66
71
|
}
|
|
72
|
+
if (arg === '--since-last') {
|
|
73
|
+
options.sinceLast = true;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (arg === '--redact') {
|
|
77
|
+
options.redact = true;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
if (arg === '--exit-code') {
|
|
81
|
+
options.exitCode = true;
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
if (arg === '--if-changed') {
|
|
85
|
+
options.ifChanged = true;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (arg === '--baseline') {
|
|
89
|
+
const nextArg = args[index + 1];
|
|
90
|
+
if (nextArg && !nextArg.startsWith('--')) {
|
|
91
|
+
options.baseline = nextArg;
|
|
92
|
+
index += 1;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
positionals.push(arg);
|
|
96
|
+
}
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
67
99
|
if (arg === '--zip') {
|
|
68
100
|
options.zip = true;
|
|
69
101
|
continue;
|
|
@@ -144,13 +176,15 @@ function parseCliOptions(args) {
|
|
|
144
176
|
}
|
|
145
177
|
continue;
|
|
146
178
|
}
|
|
147
|
-
if (arg === '--key' || arg === '--signature') {
|
|
179
|
+
if (arg === '--key' || arg === '--signature' || arg === '--snapshot') {
|
|
148
180
|
const nextArg = args[index + 1];
|
|
149
181
|
if (nextArg && !nextArg.startsWith('--')) {
|
|
150
182
|
if (arg === '--key')
|
|
151
183
|
options.key = nextArg;
|
|
152
184
|
if (arg === '--signature')
|
|
153
185
|
options.signature = nextArg;
|
|
186
|
+
if (arg === '--snapshot')
|
|
187
|
+
options.snapshot = nextArg;
|
|
154
188
|
index += 1;
|
|
155
189
|
}
|
|
156
190
|
else {
|
|
@@ -213,6 +247,16 @@ async function runCli(args) {
|
|
|
213
247
|
return (0, uninstall_1.runUninstallCommand)(positionals[0], positionals[1], options);
|
|
214
248
|
case 'sync':
|
|
215
249
|
return (0, sync_1.runSyncCommand)(positionals[0], positionals[1], options);
|
|
250
|
+
case 'snapshot':
|
|
251
|
+
return (0, snapshot_1.runSnapshotCommand)(positionals[0], positionals[1], options);
|
|
252
|
+
case 'restore':
|
|
253
|
+
return (0, restore_1.runRestoreCommand)(options);
|
|
254
|
+
case 'history':
|
|
255
|
+
return (0, history_1.runHistoryCommand)(options);
|
|
256
|
+
case 'recover':
|
|
257
|
+
return (0, recover_1.runRecoverCommand)(options);
|
|
258
|
+
case 'agents':
|
|
259
|
+
return (0, agents_1.runAgentsCommand)(options);
|
|
216
260
|
default:
|
|
217
261
|
return {
|
|
218
262
|
exitCode: 1,
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.runAgentsCommand = runAgentsCommand;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const scan_1 = require("../core/scan");
|
|
9
|
+
const registry_1 = require("../agents/registry");
|
|
10
|
+
const fs_1 = require("../utils/fs");
|
|
11
|
+
const command_json_1 = require("../utils/command-json");
|
|
12
|
+
const command_error_codes_1 = require("../constants/command-error-codes");
|
|
13
|
+
const i18n_1 = require("../i18n");
|
|
14
|
+
/**
|
|
15
|
+
* `agentdock agents`:列出注册表支持的全部 AI 编程工具与检测结果。
|
|
16
|
+
* 用于确认「自动支持」覆盖到哪些工具,以及本机实际存在哪些配置。
|
|
17
|
+
*/
|
|
18
|
+
async function runAgentsCommand(options = {}) {
|
|
19
|
+
const root = options.root ?? (0, scan_1.defaultScanRoot)();
|
|
20
|
+
try {
|
|
21
|
+
const agents = [];
|
|
22
|
+
for (const adapter of (0, registry_1.listAgentAdapters)()) {
|
|
23
|
+
const declared = adapter.configFiles().map((file) => file.relPath);
|
|
24
|
+
const existing = [];
|
|
25
|
+
const missing = [];
|
|
26
|
+
for (const relPath of declared) {
|
|
27
|
+
const abs = node_path_1.default.join(root, ...relPath.split('/'));
|
|
28
|
+
if (await (0, fs_1.pathExists)(abs)) {
|
|
29
|
+
existing.push(relPath);
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
missing.push(relPath);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
agents.push({
|
|
36
|
+
id: adapter.id,
|
|
37
|
+
displayName: adapter.displayName,
|
|
38
|
+
aliases: adapter.aliases,
|
|
39
|
+
installed: existing.length > 0,
|
|
40
|
+
experimental: adapter.experimental === true,
|
|
41
|
+
configFiles: existing,
|
|
42
|
+
missingFiles: missing,
|
|
43
|
+
...(adapter.note ? { note: adapter.note } : {}),
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
const data = {
|
|
47
|
+
root,
|
|
48
|
+
supported: agents.length,
|
|
49
|
+
installed: agents.filter((agent) => agent.installed).length,
|
|
50
|
+
agents,
|
|
51
|
+
};
|
|
52
|
+
if (options.json === true) {
|
|
53
|
+
return { exitCode: 0, stdout: [(0, command_json_1.toJsonLine)('agents', true, data, [])], stderr: [] };
|
|
54
|
+
}
|
|
55
|
+
const lines = [(0, i18n_1.t)('agents.header', { supported: data.supported, installed: data.installed, root })];
|
|
56
|
+
for (const agent of agents) {
|
|
57
|
+
lines.push((0, i18n_1.t)('agents.item', {
|
|
58
|
+
id: agent.id,
|
|
59
|
+
name: agent.displayName,
|
|
60
|
+
status: agent.installed ? (0, i18n_1.t)('agents.installed') : (0, i18n_1.t)('agents.notInstalled'),
|
|
61
|
+
files: agent.configFiles.length,
|
|
62
|
+
}));
|
|
63
|
+
if (agent.experimental) {
|
|
64
|
+
lines.push((0, i18n_1.t)('agents.note', { note: (0, i18n_1.t)('agents.experimental') }));
|
|
65
|
+
}
|
|
66
|
+
if (agent.note) {
|
|
67
|
+
lines.push((0, i18n_1.t)('agents.note', { note: agent.note }));
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
lines.push((0, i18n_1.t)('agents.hint'));
|
|
71
|
+
return { exitCode: 0, stdout: lines, stderr: [] };
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
75
|
+
if (options.json === true) {
|
|
76
|
+
return {
|
|
77
|
+
exitCode: 1,
|
|
78
|
+
stdout: [(0, command_json_1.toJsonLine)('agents', false, { root, supported: 0, installed: 0, agents: [] }, [(0, command_json_1.toJsonError)(command_error_codes_1.COMMAND_ERROR_CODES.UNKNOWN_ERROR, message)])],
|
|
79
|
+
stderr: [],
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return { exitCode: 1, stdout: [], stderr: [message] };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
@@ -2,10 +2,83 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.runDiffCommand = runDiffCommand;
|
|
4
4
|
const installer_1 = require("../core/installer");
|
|
5
|
+
const scan_1 = require("../core/scan");
|
|
6
|
+
const snapshot_1 = require("../core/snapshot");
|
|
7
|
+
const snapshot_diff_1 = require("../core/snapshot-diff");
|
|
8
|
+
const registry_1 = require("../agents/registry");
|
|
5
9
|
const command_error_codes_1 = require("../constants/command-error-codes");
|
|
6
10
|
const command_json_1 = require("../utils/command-json");
|
|
7
11
|
const plan_render_1 = require("../utils/plan-render");
|
|
12
|
+
const i18n_1 = require("../i18n");
|
|
13
|
+
function renderSnapshotDiff(data) {
|
|
14
|
+
const lines = [(0, i18n_1.t)('diff.snapshotHeader', { from: data.from, to: data.to })];
|
|
15
|
+
if (data.changes.length === 0) {
|
|
16
|
+
lines.push(` ${(0, i18n_1.t)('diff.noChanges')}`);
|
|
17
|
+
return lines;
|
|
18
|
+
}
|
|
19
|
+
for (const change of data.changes) {
|
|
20
|
+
const symbol = change.change === 'added' ? '+' : change.change === 'removed' ? '-' : '~';
|
|
21
|
+
lines.push(` ${symbol} ${change.path}${change.note ? ` (${change.note})` : ''}`);
|
|
22
|
+
if (change.before !== undefined) {
|
|
23
|
+
lines.push(` - ${change.before}`);
|
|
24
|
+
}
|
|
25
|
+
if (change.after !== undefined) {
|
|
26
|
+
lines.push(` + ${change.after}`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
lines.push(` ${data.summary}`);
|
|
30
|
+
return lines;
|
|
31
|
+
}
|
|
32
|
+
async function runSnapshotDiff(options) {
|
|
33
|
+
const root = options.root ?? (0, scan_1.defaultScanRoot)();
|
|
34
|
+
try {
|
|
35
|
+
const agentFilter = options.agent ? (0, registry_1.normalizeAgentId)(options.agent) : undefined;
|
|
36
|
+
const snapshot = options.snapshot
|
|
37
|
+
? await (0, snapshot_1.loadSnapshot)(root, options.snapshot)
|
|
38
|
+
: await (0, snapshot_1.latestSnapshot)(root, agentFilter);
|
|
39
|
+
if (!snapshot) {
|
|
40
|
+
const message = (0, i18n_1.t)('diff.noSnapshot');
|
|
41
|
+
if (options.json === true) {
|
|
42
|
+
return {
|
|
43
|
+
exitCode: 1,
|
|
44
|
+
stdout: [(0, command_json_1.toJsonLine)('diff', false, { from: null, to: 'current' }, [(0, command_json_1.toJsonError)(command_error_codes_1.COMMAND_ERROR_CODES.SNAPSHOT_NOT_FOUND, message)])],
|
|
45
|
+
stderr: [],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return { exitCode: 1, stdout: [], stderr: [message] };
|
|
49
|
+
}
|
|
50
|
+
const before = await (0, snapshot_1.readSnapshotContents)(snapshot);
|
|
51
|
+
const after = await (0, snapshot_1.readLiveConfig)(root, snapshot.meta.agent);
|
|
52
|
+
const files = new Set([
|
|
53
|
+
...snapshot.meta.files.map((file) => file.relPath),
|
|
54
|
+
...after.keys(),
|
|
55
|
+
]);
|
|
56
|
+
const data = (0, snapshot_diff_1.buildSnapshotDiff)({ from: snapshot.meta.id, to: 'current', files: [...files], before, after });
|
|
57
|
+
const exitCode = options.exitCode === true && data.changes.length > 0 ? 1 : 0;
|
|
58
|
+
if (options.json === true) {
|
|
59
|
+
return { exitCode, stdout: [(0, command_json_1.toJsonLine)('diff', true, data, [])], stderr: [] };
|
|
60
|
+
}
|
|
61
|
+
return { exitCode, stdout: renderSnapshotDiff(data), stderr: [] };
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
65
|
+
if (options.json === true) {
|
|
66
|
+
const code = message.startsWith('SNAPSHOT_NOT_FOUND')
|
|
67
|
+
? command_error_codes_1.COMMAND_ERROR_CODES.SNAPSHOT_NOT_FOUND
|
|
68
|
+
: command_error_codes_1.COMMAND_ERROR_CODES.SNAPSHOT_FAILED;
|
|
69
|
+
return {
|
|
70
|
+
exitCode: 1,
|
|
71
|
+
stdout: [(0, command_json_1.toJsonLine)('diff', false, { from: options.snapshot ?? null, to: 'current' }, [(0, command_json_1.toJsonError)(code, message)])],
|
|
72
|
+
stderr: [],
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return { exitCode: 1, stdout: [], stderr: [message] };
|
|
76
|
+
}
|
|
77
|
+
}
|
|
8
78
|
async function runDiffCommand(packagePath, targetPath, options = {}) {
|
|
79
|
+
if (options.sinceLast === true || options.snapshot !== undefined) {
|
|
80
|
+
return runSnapshotDiff(options);
|
|
81
|
+
}
|
|
9
82
|
if (!packagePath) {
|
|
10
83
|
if (options.json === true) {
|
|
11
84
|
return {
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runHistoryCommand = runHistoryCommand;
|
|
4
|
+
const scan_1 = require("../core/scan");
|
|
5
|
+
const snapshot_1 = require("../core/snapshot");
|
|
6
|
+
const snapshot_diff_1 = require("../core/snapshot-diff");
|
|
7
|
+
const registry_1 = require("../agents/registry");
|
|
8
|
+
const command_error_codes_1 = require("../constants/command-error-codes");
|
|
9
|
+
const command_json_1 = require("../utils/command-json");
|
|
10
|
+
const i18n_1 = require("../i18n");
|
|
11
|
+
const MAX_HIGHLIGHTS = 5;
|
|
12
|
+
async function diffBetween(older, newer) {
|
|
13
|
+
const before = await (0, snapshot_1.readSnapshotContents)(older);
|
|
14
|
+
const after = await (0, snapshot_1.readSnapshotContents)(newer);
|
|
15
|
+
const files = new Set([
|
|
16
|
+
...older.meta.files.map((file) => file.relPath),
|
|
17
|
+
...newer.meta.files.map((file) => file.relPath),
|
|
18
|
+
]);
|
|
19
|
+
return (0, snapshot_diff_1.buildSnapshotDiff)({ from: older.meta.id, to: newer.meta.id, files: [...files], before, after });
|
|
20
|
+
}
|
|
21
|
+
function matchesAgent(entryAgent, agent) {
|
|
22
|
+
if (!agent || agent === 'all') {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return entryAgent === agent || entryAgent === 'all';
|
|
26
|
+
}
|
|
27
|
+
async function runHistoryCommand(options = {}) {
|
|
28
|
+
const root = options.root ?? (0, scan_1.defaultScanRoot)();
|
|
29
|
+
try {
|
|
30
|
+
const agentFilter = options.agent ? (0, registry_1.normalizeAgentId)(options.agent) : undefined;
|
|
31
|
+
const all = await (0, snapshot_1.listSnapshots)(root);
|
|
32
|
+
const filtered = all.filter((entry) => matchesAgent(entry.agent, agentFilter));
|
|
33
|
+
const dir = (0, snapshot_1.snapshotsDir)(root);
|
|
34
|
+
if (options.json === true) {
|
|
35
|
+
const entries = await buildEntries(root, filtered);
|
|
36
|
+
const data = { dir, entries };
|
|
37
|
+
return { exitCode: 0, stdout: [(0, command_json_1.toJsonLine)('history', true, data, [])], stderr: [] };
|
|
38
|
+
}
|
|
39
|
+
if (filtered.length === 0) {
|
|
40
|
+
return { exitCode: 0, stdout: [(0, i18n_1.t)('history.empty')], stderr: [] };
|
|
41
|
+
}
|
|
42
|
+
const entries = await buildEntries(root, filtered);
|
|
43
|
+
const lines = [(0, i18n_1.t)('history.header', { count: entries.length, dir })];
|
|
44
|
+
for (const entry of entries) {
|
|
45
|
+
const summary = entry.baseline
|
|
46
|
+
? (0, i18n_1.t)('history.baseline')
|
|
47
|
+
: (0, i18n_1.t)('history.changes', entry.changes);
|
|
48
|
+
lines.push((0, i18n_1.t)('history.entry', {
|
|
49
|
+
id: entry.id,
|
|
50
|
+
agent: entry.agent,
|
|
51
|
+
files: entry.files,
|
|
52
|
+
summary,
|
|
53
|
+
}));
|
|
54
|
+
for (const highlight of entry.highlights) {
|
|
55
|
+
lines.push((0, i18n_1.t)('history.highlight', { path: highlight }));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
return { exitCode: 0, stdout: lines, stderr: [] };
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
62
|
+
if (options.json === true) {
|
|
63
|
+
return {
|
|
64
|
+
exitCode: 1,
|
|
65
|
+
stdout: [(0, command_json_1.toJsonLine)('history', false, { dir: (0, snapshot_1.snapshotsDir)(root), entries: [] }, [(0, command_json_1.toJsonError)(command_error_codes_1.COMMAND_ERROR_CODES.SNAPSHOT_FAILED, message)])],
|
|
66
|
+
stderr: [],
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
return { exitCode: 1, stdout: [], stderr: [message] };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async function buildEntries(root, filtered) {
|
|
73
|
+
const entries = [];
|
|
74
|
+
for (let index = 0; index < filtered.length; index += 1) {
|
|
75
|
+
const item = filtered[index];
|
|
76
|
+
const older = filtered[index + 1];
|
|
77
|
+
if (!older) {
|
|
78
|
+
entries.push({
|
|
79
|
+
id: item.id,
|
|
80
|
+
createdAt: item.createdAt,
|
|
81
|
+
agent: item.agent,
|
|
82
|
+
files: item.files,
|
|
83
|
+
redacted: item.redacted,
|
|
84
|
+
baseline: true,
|
|
85
|
+
changes: { added: 0, removed: 0, modified: 0 },
|
|
86
|
+
highlights: [],
|
|
87
|
+
});
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
const newerSnapshot = await (0, snapshot_1.loadSnapshot)(root, item.id);
|
|
91
|
+
const olderSnapshot = await (0, snapshot_1.loadSnapshot)(root, older.id);
|
|
92
|
+
const diff = await diffBetween(olderSnapshot, newerSnapshot);
|
|
93
|
+
const changes = { added: 0, removed: 0, modified: 0 };
|
|
94
|
+
for (const change of diff.changes) {
|
|
95
|
+
changes[change.change] += 1;
|
|
96
|
+
}
|
|
97
|
+
entries.push({
|
|
98
|
+
id: item.id,
|
|
99
|
+
createdAt: item.createdAt,
|
|
100
|
+
agent: item.agent,
|
|
101
|
+
files: item.files,
|
|
102
|
+
redacted: item.redacted,
|
|
103
|
+
baseline: false,
|
|
104
|
+
changes,
|
|
105
|
+
highlights: diff.changes.slice(0, MAX_HIGHLIGHTS).map((change) => change.path),
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
return entries;
|
|
109
|
+
}
|
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.runListCommand = runListCommand;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const list_1 = require("../core/list");
|
|
9
|
+
const registry_1 = require("../agents/registry");
|
|
9
10
|
const command_error_codes_1 = require("../constants/command-error-codes");
|
|
10
11
|
const command_json_1 = require("../utils/command-json");
|
|
11
12
|
async function runListCommand(options = {}) {
|
|
@@ -28,7 +29,7 @@ async function runListCommand(options = {}) {
|
|
|
28
29
|
lines.push(`List (${report.mode}) — ${report.project.name || 'untitled'}`);
|
|
29
30
|
lines.push(report.summary);
|
|
30
31
|
for (const info of report.agents) {
|
|
31
|
-
const title = info.agent
|
|
32
|
+
const title = (0, registry_1.resolveAgentAdapter)(info.agent)?.displayName ?? info.agent;
|
|
32
33
|
lines.push(` ${title}: ${info.totals.all} 项`);
|
|
33
34
|
lines.push(` MCP: ${info.totals.mcp ? info.mcp.join(', ') : '—'}`);
|
|
34
35
|
lines.push(` Skills: ${info.totals.skills ? info.skills.join(', ') : '—'}`);
|