agentdock-cli 1.2.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.
@@ -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
@@ -20,6 +20,7 @@ const snapshot_1 = require("./commands/snapshot");
20
20
  const restore_1 = require("./commands/restore");
21
21
  const history_1 = require("./commands/history");
22
22
  const recover_1 = require("./commands/recover");
23
+ const agents_1 = require("./commands/agents");
23
24
  const pack_1 = require("./commands/pack");
24
25
  const verify_1 = require("./commands/verify");
25
26
  const attest_1 = require("./commands/attest");
@@ -254,6 +255,8 @@ async function runCli(args) {
254
255
  return (0, history_1.runHistoryCommand)(options);
255
256
  case 'recover':
256
257
  return (0, recover_1.runRecoverCommand)(options);
258
+ case 'agents':
259
+ return (0, agents_1.runAgentsCommand)(options);
257
260
  default:
258
261
  return {
259
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
+ }
@@ -5,6 +5,7 @@ const installer_1 = require("../core/installer");
5
5
  const scan_1 = require("../core/scan");
6
6
  const snapshot_1 = require("../core/snapshot");
7
7
  const snapshot_diff_1 = require("../core/snapshot-diff");
8
+ const registry_1 = require("../agents/registry");
8
9
  const command_error_codes_1 = require("../constants/command-error-codes");
9
10
  const command_json_1 = require("../utils/command-json");
10
11
  const plan_render_1 = require("../utils/plan-render");
@@ -31,9 +32,10 @@ function renderSnapshotDiff(data) {
31
32
  async function runSnapshotDiff(options) {
32
33
  const root = options.root ?? (0, scan_1.defaultScanRoot)();
33
34
  try {
35
+ const agentFilter = options.agent ? (0, registry_1.normalizeAgentId)(options.agent) : undefined;
34
36
  const snapshot = options.snapshot
35
37
  ? await (0, snapshot_1.loadSnapshot)(root, options.snapshot)
36
- : await (0, snapshot_1.latestSnapshot)(root);
38
+ : await (0, snapshot_1.latestSnapshot)(root, agentFilter);
37
39
  if (!snapshot) {
38
40
  const message = (0, i18n_1.t)('diff.noSnapshot');
39
41
  if (options.json === true) {
@@ -4,6 +4,7 @@ exports.runHistoryCommand = runHistoryCommand;
4
4
  const scan_1 = require("../core/scan");
5
5
  const snapshot_1 = require("../core/snapshot");
6
6
  const snapshot_diff_1 = require("../core/snapshot-diff");
7
+ const registry_1 = require("../agents/registry");
7
8
  const command_error_codes_1 = require("../constants/command-error-codes");
8
9
  const command_json_1 = require("../utils/command-json");
9
10
  const i18n_1 = require("../i18n");
@@ -26,8 +27,9 @@ function matchesAgent(entryAgent, agent) {
26
27
  async function runHistoryCommand(options = {}) {
27
28
  const root = options.root ?? (0, scan_1.defaultScanRoot)();
28
29
  try {
30
+ const agentFilter = options.agent ? (0, registry_1.normalizeAgentId)(options.agent) : undefined;
29
31
  const all = await (0, snapshot_1.listSnapshots)(root);
30
- const filtered = all.filter((entry) => matchesAgent(entry.agent, options.agent));
32
+ const filtered = all.filter((entry) => matchesAgent(entry.agent, agentFilter));
31
33
  const dir = (0, snapshot_1.snapshotsDir)(root);
32
34
  if (options.json === true) {
33
35
  const entries = await buildEntries(root, filtered);
@@ -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 === 'claude' ? 'Claude Code' : 'Codex';
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(', ') : '—'}`);
@@ -15,8 +15,12 @@ const ACTION_LABELS = {
15
15
  * 完整度评分:文件齐全度 60 + 顶层键 20 + env 10 + MCP 10,
16
16
  * 脱敏快照无法还原真实密钥,扣 20 分。
17
17
  */
18
- function scoreSnapshot(meta) {
19
- const expected = (0, snapshot_1.configFilesFor)(meta.agent);
18
+ function scoreSnapshot(meta, knownFiles) {
19
+ // `all` 快照覆盖多个工具,缺失文件应以"历史快照里出现过的文件"为参照,
20
+ // 否则会把这台机器没装的工具配置全部算成缺失,评分失真。
21
+ const expected = meta.agent === 'all'
22
+ ? [...(knownFiles ?? new Set(meta.files.map((file) => file.relPath)))]
23
+ : (0, snapshot_1.configFilesFor)(meta.agent);
20
24
  const present = new Set(meta.files.map((file) => file.relPath));
21
25
  const missingFiles = expected.filter((relPath) => !present.has(relPath));
22
26
  const fileRatio = expected.length === 0 ? 1 : (expected.length - missingFiles.length) / expected.length;
@@ -41,11 +45,12 @@ function scoreSnapshot(meta) {
41
45
  }
42
46
  async function buildCandidates(root) {
43
47
  const list = await (0, snapshot_1.listSnapshots)(root);
44
- const candidates = [];
48
+ const snapshots = [];
45
49
  for (const item of list) {
46
- const snapshot = await (0, snapshot_1.loadSnapshot)(root, item.id);
47
- candidates.push(scoreSnapshot(snapshot.meta));
50
+ snapshots.push(await (0, snapshot_1.loadSnapshot)(root, item.id));
48
51
  }
52
+ const knownFiles = new Set(snapshots.flatMap((snapshot) => (snapshot.meta.files.map((file) => file.relPath))));
53
+ const candidates = snapshots.map((snapshot) => scoreSnapshot(snapshot.meta, knownFiles));
49
54
  return candidates.sort((a, b) => b.score - a.score || b.id.localeCompare(a.id));
50
55
  }
51
56
  function renderCandidates(candidates, dir) {
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.runSnapshotCommand = runSnapshotCommand;
4
4
  const scan_1 = require("../core/scan");
5
5
  const snapshot_1 = require("../core/snapshot");
6
+ const registry_1 = require("../agents/registry");
6
7
  const command_error_codes_1 = require("../constants/command-error-codes");
7
8
  const command_json_1 = require("../utils/command-json");
8
9
  const i18n_1 = require("../i18n");
@@ -92,7 +93,7 @@ async function runSnapshotCommand(action, target, options = {}) {
92
93
  }
93
94
  return { exitCode: 0, stdout: lines, stderr: [] };
94
95
  }
95
- const agent = options.agent ?? 'all';
96
+ const agent = (0, registry_1.normalizeAgentId)(options.agent ?? 'all');
96
97
  if (options.ifChanged === true) {
97
98
  const unchanged = await (0, snapshot_1.findUnchangedSnapshot)(root, agent);
98
99
  if (unchanged) {
@@ -120,10 +120,14 @@ async function runSyncCommand(action, target, options = {}) {
120
120
  }
121
121
  const file = await loadSyncFile(options.config);
122
122
  const config = await (0, config_1.loadConfig)();
123
+ const syncAgent = options.agent ?? file.agent ?? config.agent ?? 'all';
124
+ if (syncAgent !== 'claude' && syncAgent !== 'codex' && syncAgent !== 'all') {
125
+ throw new Error(`SYNC_AGENT_UNSUPPORTED: 同步依赖语义扫描,暂只支持 claude / codex / all;${syncAgent} 可先用 snapshot push/pull 分发配置快照`);
126
+ }
123
127
  const opts = {
124
128
  target,
125
129
  root,
126
- agent: options.agent ?? file.agent ?? config.agent ?? 'all',
130
+ agent: syncAgent,
127
131
  mode: options.mode ?? file.mode ?? 'full',
128
132
  include: options.include ?? file.include ?? [],
129
133
  exclude: options.exclude ?? file.exclude ?? [],