agentdock-cli 0.6.0 → 0.7.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 +6 -2
- package/dist/package.json +15 -9
- package/dist/src/cli.js +14 -0
- package/dist/src/commands/report.js +70 -0
- package/dist/src/constants/command-error-codes.js +1 -0
- package/dist/src/core/report-html.js +311 -0
- package/dist/src/core/report.js +243 -0
- package/dist/src/i18n/index.js +2 -2
- package/dist/src/utils/fs.js +5 -3
- package/package.json +15 -9
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# AgentDock
|
|
2
2
|
|
|
3
|
-
> 你的 AI 编码助手(Claude Code / Codex
|
|
4
|
-
>
|
|
3
|
+
> 你的 AI 编码助手(Claude Code / Codex)的**诊断 · 迁移 · 交付**工具。
|
|
4
|
+
> 一条命令体检环境,生成中文 HTML 报告与修复建议;再把 MCP Server、Skill、Agent、Plugin、Hook、记忆**原样、安全、可复现**地搬到另一台机器 —— **而且绝不把 token 一起带走。**
|
|
5
5
|
|
|
6
6
|
[](https://www.npmjs.com/package/agentdock-cli)
|
|
7
7
|
[](./LICENSE)
|
|
@@ -33,6 +33,9 @@ npx agentdock-cli --help
|
|
|
33
33
|
## 30 秒上手
|
|
34
34
|
|
|
35
35
|
```bash
|
|
36
|
+
# 0. 先体检:生成中文 HTML 报告(健康分 + 检查明细 + 修复建议 + 可分享卡片)
|
|
37
|
+
agentdock report --agent all --out ./report
|
|
38
|
+
|
|
36
39
|
# 1. 扫描当前机器的 AI 助手环境(自动隔离敏感信息)
|
|
37
40
|
agentdock scan --agent all --root ~ --out ./my-env
|
|
38
41
|
|
|
@@ -130,6 +133,7 @@ restore/
|
|
|
130
133
|
| `install` | 从包安全还原到目标机(越界校验 / 锁 / 原子写 / 幂等);`--dry-run` 只预览不落盘 | `agentdock install ./pkg ~` |
|
|
131
134
|
| `validate` | 校验 manifest 合法性 | `agentdock validate ./pkg/manifest.resolved.json` |
|
|
132
135
|
| `doctor` | 体检环境 / 包:配置健康度、可迁移性、是否泄密(每项附**修复建议**) | `agentdock doctor --agent all --root ~` |
|
|
136
|
+
| `report` | 生成可分享的环境健康报告(评分 / 清单 / 检查 / 修复建议,HTML + JSON);`--profile xinchuang` 追加信创适配启发式检查(需人工确认) | `agentdock report --agent all --out ./report` |
|
|
133
137
|
| `list` | 列出已捕获的 MCP / Skill / Agent 等定义清单 | `agentdock list --package ./pkg` |
|
|
134
138
|
| `diff` | 对比「包内容」与「目标机现状」:哪些新增 / 相同 / 变更 / 需合并 / 会冲突(不落盘) | `agentdock diff ./pkg ~` |
|
|
135
139
|
| `config` | 管理 AgentDock 自身配置(`agent` / `out` / `env` 默认值),存于 `~/.agentdock/config.json` | `agentdock config set agent codex` |
|
package/dist/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentdock-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Diagnose, migrate, and back up your AI coding assistant environment (Claude Code / Codex) — Chinese health reports, MCP servers, Skills, Agents, Plugins, Hooks, and memory, with secret isolation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
7
7
|
"codex",
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
"versioning",
|
|
13
13
|
"mcp",
|
|
14
14
|
"skills",
|
|
15
|
-
"cli"
|
|
15
|
+
"cli",
|
|
16
|
+
"report",
|
|
17
|
+
"diagnostics",
|
|
18
|
+
"health-check",
|
|
19
|
+
"audit",
|
|
20
|
+
"air-gapped"
|
|
16
21
|
],
|
|
17
22
|
"type": "commonjs",
|
|
18
23
|
"bin": {
|
|
@@ -35,17 +40,18 @@
|
|
|
35
40
|
"release:commits": "node scripts/generate-commit-groups.js"
|
|
36
41
|
},
|
|
37
42
|
"dependencies": {
|
|
38
|
-
"ajv": "^8.
|
|
43
|
+
"ajv": "^8.20.0",
|
|
39
44
|
"diff": "^8.0.4",
|
|
40
|
-
"
|
|
41
|
-
"smol-toml": "^1.
|
|
45
|
+
"picomatch": "^4.0.7",
|
|
46
|
+
"smol-toml": "^1.9.1",
|
|
42
47
|
"yaml": "^2.8.1"
|
|
43
48
|
},
|
|
44
49
|
"devDependencies": {
|
|
45
|
-
"@types/node": "^24.
|
|
46
|
-
"
|
|
50
|
+
"@types/node": "^24.19.4",
|
|
51
|
+
"@types/picomatch": "^4.0.3",
|
|
52
|
+
"tsx": "^4.23.15",
|
|
47
53
|
"typescript": "^5.9.3",
|
|
48
|
-
"vitest": "^
|
|
54
|
+
"vitest": "^4.1.12"
|
|
49
55
|
},
|
|
50
56
|
"author": "spsz831",
|
|
51
57
|
"license": "MIT",
|
package/dist/src/cli.js
CHANGED
|
@@ -6,6 +6,7 @@ const export_1 = require("./commands/export");
|
|
|
6
6
|
const install_1 = require("./commands/install");
|
|
7
7
|
const scan_1 = require("./commands/scan");
|
|
8
8
|
const doctor_1 = require("./commands/doctor");
|
|
9
|
+
const report_1 = require("./commands/report");
|
|
9
10
|
const list_1 = require("./commands/list");
|
|
10
11
|
const validate_1 = require("./commands/validate");
|
|
11
12
|
const diff_1 = require("./commands/diff");
|
|
@@ -68,6 +69,17 @@ function parseCliOptions(args) {
|
|
|
68
69
|
}
|
|
69
70
|
continue;
|
|
70
71
|
}
|
|
72
|
+
if (arg === '--profile') {
|
|
73
|
+
const nextArg = args[index + 1];
|
|
74
|
+
if (nextArg && !nextArg.startsWith('--')) {
|
|
75
|
+
options.profile = nextArg === 'xinchuang' ? 'xinchuang' : 'default';
|
|
76
|
+
index += 1;
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
positionals.push(arg);
|
|
80
|
+
}
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
71
83
|
if (arg === '--from-scan' || arg === '--env' || arg === '--package') {
|
|
72
84
|
const nextArg = args[index + 1];
|
|
73
85
|
if (nextArg && !nextArg.startsWith('--')) {
|
|
@@ -103,6 +115,8 @@ async function runCli(args) {
|
|
|
103
115
|
return (0, scan_1.runScanCommand)(options);
|
|
104
116
|
case 'doctor':
|
|
105
117
|
return (0, doctor_1.runDoctorCommand)(options);
|
|
118
|
+
case 'report':
|
|
119
|
+
return (0, report_1.runReportCommand)(options);
|
|
106
120
|
case 'list':
|
|
107
121
|
return (0, list_1.runListCommand)(options);
|
|
108
122
|
case 'diff':
|
|
@@ -0,0 +1,70 @@
|
|
|
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.runReportCommand = runReportCommand;
|
|
7
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
8
|
+
const doctor_1 = require("../core/doctor");
|
|
9
|
+
const report_1 = require("../core/report");
|
|
10
|
+
const command_error_codes_1 = require("../constants/command-error-codes");
|
|
11
|
+
const command_json_1 = require("../utils/command-json");
|
|
12
|
+
async function runReportCommand(options = {}) {
|
|
13
|
+
const agent = options.agent ?? 'all';
|
|
14
|
+
const out = options.out ? node_path_1.default.resolve(options.out) : node_path_1.default.resolve('agentdock-report');
|
|
15
|
+
const profile = options.profile ?? 'default';
|
|
16
|
+
try {
|
|
17
|
+
const report = await (0, report_1.runReport)({
|
|
18
|
+
agent,
|
|
19
|
+
root: options.root,
|
|
20
|
+
fromScan: options.fromScan,
|
|
21
|
+
package: options.package,
|
|
22
|
+
out,
|
|
23
|
+
profile,
|
|
24
|
+
});
|
|
25
|
+
if (options.json === true) {
|
|
26
|
+
return {
|
|
27
|
+
exitCode: (0, doctor_1.doctorExitCode)(report),
|
|
28
|
+
stdout: [(0, command_json_1.toJsonLine)('report', report.healthy, report, [])],
|
|
29
|
+
stderr: [],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
const lines = [
|
|
33
|
+
`Report (${report.mode})${report.agent ? ` agent=${report.agent}` : ''} — ${report.score}/100 (${report.grade})`,
|
|
34
|
+
report.summary,
|
|
35
|
+
`可迁移定义: ${report.inventory.totalEntries} 项 · 隔离机密: ${report.inventory.secretsCount} 个`,
|
|
36
|
+
...report.checks.flatMap((check) => {
|
|
37
|
+
const checkLines = [` [${check.status.toUpperCase()}] ${check.label} — ${check.detail}`];
|
|
38
|
+
if (check.remediation && check.status !== 'pass') {
|
|
39
|
+
checkLines.push(` → 建议: ${check.remediation}`);
|
|
40
|
+
}
|
|
41
|
+
return checkLines;
|
|
42
|
+
}),
|
|
43
|
+
...(report.htmlPath ? [`html: ${report.htmlPath}`, `json: ${report.jsonPath}`] : []),
|
|
44
|
+
];
|
|
45
|
+
return { exitCode: (0, doctor_1.doctorExitCode)(report), stdout: lines, stderr: [] };
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
49
|
+
if (options.json === true) {
|
|
50
|
+
const data = {
|
|
51
|
+
mode: 'live',
|
|
52
|
+
agent,
|
|
53
|
+
target: '',
|
|
54
|
+
healthy: false,
|
|
55
|
+
checks: [],
|
|
56
|
+
summary: message,
|
|
57
|
+
profile,
|
|
58
|
+
score: 0,
|
|
59
|
+
grade: 'D',
|
|
60
|
+
inventory: { agents: [], totalEntries: 0, secretsCount: 0 },
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
exitCode: 2,
|
|
64
|
+
stdout: [(0, command_json_1.toJsonLine)('report', false, data, [(0, command_json_1.toJsonError)(command_error_codes_1.COMMAND_ERROR_CODES.REPORT_FAILED, message)])],
|
|
65
|
+
stderr: [],
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
return { exitCode: 2, stdout: [], stderr: [message] };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderReportHtml = renderReportHtml;
|
|
4
|
+
function escapeHtml(value) {
|
|
5
|
+
return value
|
|
6
|
+
.replace(/&/g, '&')
|
|
7
|
+
.replace(/</g, '<')
|
|
8
|
+
.replace(/>/g, '>')
|
|
9
|
+
.replace(/"/g, '"')
|
|
10
|
+
.replace(/'/g, ''');
|
|
11
|
+
}
|
|
12
|
+
function statusLabel(status) {
|
|
13
|
+
return status === 'pass' ? 'PASS' : status === 'warn' ? 'WARN' : 'FAIL';
|
|
14
|
+
}
|
|
15
|
+
function statusColor(status) {
|
|
16
|
+
return status === 'pass' ? '#12b76a' : status === 'warn' ? '#f79009' : '#f04438';
|
|
17
|
+
}
|
|
18
|
+
function gradeClass(grade) {
|
|
19
|
+
return `grade-${grade.toLowerCase()}`;
|
|
20
|
+
}
|
|
21
|
+
function renderGauge(report) {
|
|
22
|
+
const radius = 58;
|
|
23
|
+
const circumference = 2 * Math.PI * radius;
|
|
24
|
+
const offset = circumference * (1 - report.score / 100);
|
|
25
|
+
return `
|
|
26
|
+
<div class="gauge">
|
|
27
|
+
<svg viewBox="0 0 140 140" class="gauge-svg" role="img" aria-label="环境健康度 ${report.score} 分">
|
|
28
|
+
<circle class="gauge-track" cx="70" cy="70" r="${radius}" />
|
|
29
|
+
<circle class="gauge-value ${gradeClass(report.grade)}" cx="70" cy="70" r="${radius}"
|
|
30
|
+
stroke-dasharray="${circumference.toFixed(2)}" stroke-dashoffset="${offset.toFixed(2)}" />
|
|
31
|
+
</svg>
|
|
32
|
+
<div class="gauge-center">
|
|
33
|
+
<span class="gauge-score">${report.score}</span>
|
|
34
|
+
<span class="gauge-unit">/ 100</span>
|
|
35
|
+
</div>
|
|
36
|
+
</div>`;
|
|
37
|
+
}
|
|
38
|
+
function renderInventory(report) {
|
|
39
|
+
if (report.inventory.agents.length === 0) {
|
|
40
|
+
return '<p class="muted">未捕获到可迁移定义。</p>';
|
|
41
|
+
}
|
|
42
|
+
const rows = report.inventory.agents
|
|
43
|
+
.map((item) => `
|
|
44
|
+
<tr>
|
|
45
|
+
<td><strong>${item.agent === 'claude' ? 'Claude Code' : 'Codex'}</strong></td>
|
|
46
|
+
<td>${item.mcp}</td>
|
|
47
|
+
<td>${item.skills}</td>
|
|
48
|
+
<td>${item.agents}</td>
|
|
49
|
+
<td>${item.plugins}</td>
|
|
50
|
+
<td>${item.hooks}</td>
|
|
51
|
+
<td>${item.memory}</td>
|
|
52
|
+
<td>${item.settings}</td>
|
|
53
|
+
<td><strong>${item.total}</strong></td>
|
|
54
|
+
</tr>`)
|
|
55
|
+
.join('');
|
|
56
|
+
return `
|
|
57
|
+
<table class="inventory">
|
|
58
|
+
<thead>
|
|
59
|
+
<tr>
|
|
60
|
+
<th>助手</th><th>MCP</th><th>Skill</th><th>Agent</th><th>Plugin</th>
|
|
61
|
+
<th>Hook</th><th>记忆</th><th>Settings</th><th>合计</th>
|
|
62
|
+
</tr>
|
|
63
|
+
</thead>
|
|
64
|
+
<tbody>${rows}</tbody>
|
|
65
|
+
</table>
|
|
66
|
+
<p class="inventory-total">共 <strong>${report.inventory.totalEntries}</strong> 项可迁移定义,隔离 <strong>${report.inventory.secretsCount}</strong> 个机密。</p>`;
|
|
67
|
+
}
|
|
68
|
+
function renderFinding(check, finding) {
|
|
69
|
+
const path = finding.path ? ` <code>${escapeHtml(finding.path)}</code>` : '';
|
|
70
|
+
return `<li class="finding finding--${finding.severity}"><span class="dot" style="background:${statusColor(check.status)}"></span>${escapeHtml(finding.message)}${path}</li>`;
|
|
71
|
+
}
|
|
72
|
+
function renderCheck(check) {
|
|
73
|
+
const findings = check.findings.length
|
|
74
|
+
? `<ul class="findings">${check.findings.map((finding) => renderFinding(check, finding)).join('')}</ul>`
|
|
75
|
+
: '';
|
|
76
|
+
const remediation = check.remediation && check.status !== 'pass'
|
|
77
|
+
? `<div class="remediation"><span class="remediation-label">建议</span>${escapeHtml(check.remediation)}</div>`
|
|
78
|
+
: '';
|
|
79
|
+
return `
|
|
80
|
+
<article class="check check--${check.status}">
|
|
81
|
+
<div class="check-head">
|
|
82
|
+
<span class="badge badge--${check.status}">${statusLabel(check.status)}</span>
|
|
83
|
+
<h3>${escapeHtml(check.label)}</h3>
|
|
84
|
+
</div>
|
|
85
|
+
<p class="check-detail">${escapeHtml(check.detail)}</p>
|
|
86
|
+
${findings}
|
|
87
|
+
${remediation}
|
|
88
|
+
</article>`;
|
|
89
|
+
}
|
|
90
|
+
function renderRemediation(report) {
|
|
91
|
+
const actionable = report.checks.filter((check) => check.remediation && check.status !== 'pass');
|
|
92
|
+
if (actionable.length === 0) {
|
|
93
|
+
return '<p class="muted">未发现需要处理的问题。</p>';
|
|
94
|
+
}
|
|
95
|
+
const items = actionable
|
|
96
|
+
.map((check) => `
|
|
97
|
+
<li>
|
|
98
|
+
<div class="todo-head"><span class="badge badge--${check.status}">${statusLabel(check.status)}</span> ${escapeHtml(check.label)}</div>
|
|
99
|
+
<p>${escapeHtml(check.remediation)}</p>
|
|
100
|
+
</li>`)
|
|
101
|
+
.join('');
|
|
102
|
+
return `<ol class="todo-list">${items}</ol>`;
|
|
103
|
+
}
|
|
104
|
+
function renderShareCard(report) {
|
|
105
|
+
const pass = report.checks.filter((check) => check.status === 'pass').length;
|
|
106
|
+
const warn = report.checks.filter((check) => check.status === 'warn').length;
|
|
107
|
+
const fail = report.checks.filter((check) => check.status === 'fail').length;
|
|
108
|
+
return `
|
|
109
|
+
<section class="share-card">
|
|
110
|
+
<div class="share-card-head">
|
|
111
|
+
<div>
|
|
112
|
+
<div class="share-card-kicker">可安全分享的摘要 · 已脱敏</div>
|
|
113
|
+
<div class="share-card-title">AgentDock 环境健康度</div>
|
|
114
|
+
</div>
|
|
115
|
+
<div class="share-grade ${gradeClass(report.grade)}">${report.grade}</div>
|
|
116
|
+
</div>
|
|
117
|
+
<div class="share-score">${report.score}<span> / 100</span></div>
|
|
118
|
+
<div class="share-stats">
|
|
119
|
+
<div class="share-stat"><span class="share-stat-value">${report.inventory.totalEntries}</span><span class="share-stat-label">可迁移定义</span></div>
|
|
120
|
+
<div class="share-stat"><span class="share-stat-value">${report.inventory.secretsCount}</span><span class="share-stat-label">隔离机密</span></div>
|
|
121
|
+
<div class="share-stat"><span class="share-stat-value">${pass} / ${warn} / ${fail}</span><span class="share-stat-label">通过 / 警告 / 失败</span></div>
|
|
122
|
+
</div>
|
|
123
|
+
<p class="share-card-note">仅含评分与数量,不含路径、变量名与配置内容。由 AgentDock 生成。</p>
|
|
124
|
+
</section>`;
|
|
125
|
+
}
|
|
126
|
+
const STYLES = `
|
|
127
|
+
:root {
|
|
128
|
+
color-scheme: light;
|
|
129
|
+
--bg: #f4f6fb;
|
|
130
|
+
--card: #ffffff;
|
|
131
|
+
--ink: #101828;
|
|
132
|
+
--muted: #667085;
|
|
133
|
+
--border: #e6e9f0;
|
|
134
|
+
--accent: #4f46e5;
|
|
135
|
+
--pass: #12b76a;
|
|
136
|
+
--warn: #f79009;
|
|
137
|
+
--fail: #f04438;
|
|
138
|
+
}
|
|
139
|
+
* { box-sizing: border-box; }
|
|
140
|
+
body {
|
|
141
|
+
margin: 0;
|
|
142
|
+
background: var(--bg);
|
|
143
|
+
color: var(--ink);
|
|
144
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Roboto, sans-serif;
|
|
145
|
+
line-height: 1.6;
|
|
146
|
+
}
|
|
147
|
+
.page { max-width: 980px; margin: 0 auto; padding: 40px 20px 64px; }
|
|
148
|
+
header { margin-bottom: 24px; }
|
|
149
|
+
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: .2px; }
|
|
150
|
+
.brand-mark {
|
|
151
|
+
width: 30px; height: 30px; border-radius: 9px;
|
|
152
|
+
background: linear-gradient(135deg, #6366f1, #22d3ee);
|
|
153
|
+
}
|
|
154
|
+
.meta { color: var(--muted); font-size: 13px; margin-top: 8px; word-break: break-all; }
|
|
155
|
+
.profile-note {
|
|
156
|
+
margin-top: 12px; padding: 12px 14px; border-radius: 10px;
|
|
157
|
+
background: #fffaeb; border: 1px solid #fedf89; color: #93370d; font-size: 13px;
|
|
158
|
+
}
|
|
159
|
+
.card {
|
|
160
|
+
background: var(--card); border: 1px solid var(--border); border-radius: 16px;
|
|
161
|
+
padding: 24px; margin-bottom: 20px; box-shadow: 0 1px 2px rgba(16, 24, 40, .04);
|
|
162
|
+
}
|
|
163
|
+
h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 16px; }
|
|
164
|
+
.hero { display: grid; grid-template-columns: 200px 1fr; gap: 24px; align-items: center; }
|
|
165
|
+
.gauge { position: relative; width: 180px; height: 180px; }
|
|
166
|
+
.gauge-svg { width: 180px; height: 180px; transform: rotate(-90deg); }
|
|
167
|
+
.gauge-track { fill: none; stroke: #eef1f7; stroke-width: 13; }
|
|
168
|
+
.gauge-value { fill: none; stroke: var(--accent); stroke-width: 13; stroke-linecap: round; }
|
|
169
|
+
.gauge-value.grade-a { stroke: var(--pass); }
|
|
170
|
+
.gauge-value.grade-b { stroke: #2e90fa; }
|
|
171
|
+
.gauge-value.grade-c { stroke: var(--warn); }
|
|
172
|
+
.gauge-value.grade-d { stroke: var(--fail); }
|
|
173
|
+
.gauge-center {
|
|
174
|
+
position: absolute; inset: 0; display: flex; flex-direction: column;
|
|
175
|
+
align-items: center; justify-content: center;
|
|
176
|
+
}
|
|
177
|
+
.gauge-score { font-size: 44px; font-weight: 800; line-height: 1; }
|
|
178
|
+
.gauge-unit { color: var(--muted); font-size: 13px; margin-top: 4px; }
|
|
179
|
+
.hero-grade { display: inline-flex; align-items: center; gap: 10px; font-size: 20px; font-weight: 700; }
|
|
180
|
+
.grade-chip {
|
|
181
|
+
display: inline-flex; align-items: center; justify-content: center;
|
|
182
|
+
width: 40px; height: 40px; border-radius: 12px; color: #fff; font-weight: 800;
|
|
183
|
+
}
|
|
184
|
+
.grade-chip.grade-a, .share-grade.grade-a { background: var(--pass); }
|
|
185
|
+
.grade-chip.grade-b, .share-grade.grade-b { background: #2e90fa; }
|
|
186
|
+
.grade-chip.grade-c, .share-grade.grade-c { background: var(--warn); }
|
|
187
|
+
.grade-chip.grade-d, .share-grade.grade-d { background: var(--fail); }
|
|
188
|
+
.hero-summary { color: var(--muted); margin: 10px 0 0; }
|
|
189
|
+
.stat-line { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
|
|
190
|
+
.pill {
|
|
191
|
+
border: 1px solid var(--border); border-radius: 999px; padding: 4px 11px;
|
|
192
|
+
font-size: 12px; color: var(--muted); background: #fafbff;
|
|
193
|
+
}
|
|
194
|
+
.inventory { width: 100%; border-collapse: collapse; font-size: 14px; }
|
|
195
|
+
.inventory th, .inventory td { padding: 10px 8px; text-align: right; border-bottom: 1px solid var(--border); }
|
|
196
|
+
.inventory th:first-child, .inventory td:first-child { text-align: left; }
|
|
197
|
+
.inventory th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
|
|
198
|
+
.inventory tbody tr:last-child td { border-bottom: none; }
|
|
199
|
+
.inventory-total { margin: 14px 0 0; color: var(--muted); font-size: 14px; }
|
|
200
|
+
.check { border: 1px solid var(--border); border-left: 4px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 12px; }
|
|
201
|
+
.check--pass { border-left-color: var(--pass); }
|
|
202
|
+
.check--warn { border-left-color: var(--warn); background: #fffcf5; }
|
|
203
|
+
.check--fail { border-left-color: var(--fail); background: #fff5f4; }
|
|
204
|
+
.check-head { display: flex; align-items: center; gap: 10px; }
|
|
205
|
+
.check-head h3 { margin: 0; font-size: 15px; }
|
|
206
|
+
.check-detail { margin: 8px 0 0; color: #344054; font-size: 14px; }
|
|
207
|
+
.badge {
|
|
208
|
+
display: inline-block; padding: 2px 8px; border-radius: 999px;
|
|
209
|
+
font-size: 11px; font-weight: 700; letter-spacing: .04em;
|
|
210
|
+
}
|
|
211
|
+
.badge--pass { background: #ecfdf3; color: #027a48; }
|
|
212
|
+
.badge--warn { background: #fffaeb; color: #b54708; }
|
|
213
|
+
.badge--fail { background: #fef3f2; color: #b42318; }
|
|
214
|
+
.findings { margin: 10px 0 0; padding: 0; list-style: none; }
|
|
215
|
+
.finding { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; color: #475467; margin: 4px 0; }
|
|
216
|
+
.finding .dot { width: 7px; height: 7px; border-radius: 50%; margin-top: 7px; flex: 0 0 auto; }
|
|
217
|
+
.finding code { background: #f2f4f7; border-radius: 5px; padding: 1px 5px; font-size: 12px; word-break: break-all; }
|
|
218
|
+
.remediation {
|
|
219
|
+
margin-top: 10px; padding: 10px 12px; border-radius: 9px;
|
|
220
|
+
background: #eef2ff; color: #3538cd; font-size: 13px;
|
|
221
|
+
}
|
|
222
|
+
.remediation-label { font-weight: 700; margin-right: 8px; }
|
|
223
|
+
.todo-list { margin: 0; padding-left: 20px; }
|
|
224
|
+
.todo-list li { margin-bottom: 14px; }
|
|
225
|
+
.todo-list p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
|
|
226
|
+
.todo-head { font-weight: 600; font-size: 14px; }
|
|
227
|
+
.share-card {
|
|
228
|
+
border: 1px dashed #c7d2fe; border-radius: 16px; padding: 24px;
|
|
229
|
+
background: linear-gradient(135deg, #ffffff 0%, #f5f7ff 100%);
|
|
230
|
+
}
|
|
231
|
+
.share-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
|
|
232
|
+
.share-card-kicker { font-size: 12px; color: var(--accent); font-weight: 700; letter-spacing: .04em; }
|
|
233
|
+
.share-card-title { font-size: 20px; font-weight: 700; margin-top: 4px; }
|
|
234
|
+
.share-grade {
|
|
235
|
+
width: 52px; height: 52px; border-radius: 14px; color: #fff;
|
|
236
|
+
display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800;
|
|
237
|
+
}
|
|
238
|
+
.share-score { font-size: 52px; font-weight: 800; margin: 18px 0 6px; }
|
|
239
|
+
.share-score span { font-size: 18px; color: var(--muted); font-weight: 600; }
|
|
240
|
+
.share-stats { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 10px; }
|
|
241
|
+
.share-stat { display: flex; flex-direction: column; }
|
|
242
|
+
.share-stat-value { font-size: 22px; font-weight: 700; }
|
|
243
|
+
.share-stat-label { font-size: 12px; color: var(--muted); }
|
|
244
|
+
.share-card-note { margin: 18px 0 0; font-size: 12px; color: var(--muted); }
|
|
245
|
+
.muted { color: var(--muted); font-size: 14px; }
|
|
246
|
+
@media (max-width: 640px) {
|
|
247
|
+
.hero { grid-template-columns: 1fr; justify-items: center; text-align: center; }
|
|
248
|
+
.stat-line { justify-content: center; }
|
|
249
|
+
.page { padding: 24px 14px 48px; }
|
|
250
|
+
}
|
|
251
|
+
`;
|
|
252
|
+
function renderReportHtml(report) {
|
|
253
|
+
const profileNote = report.profile === 'xinchuang'
|
|
254
|
+
? '<div class="profile-note">信创适配评估为启发式检查,结果需人工确认,不构成“已适配”结论。</div>'
|
|
255
|
+
: '';
|
|
256
|
+
const agentMeta = report.agent ? ` · agent=${escapeHtml(report.agent)}` : '';
|
|
257
|
+
const target = escapeHtml(report.target || '—');
|
|
258
|
+
const generatedAt = new Date().toLocaleString('zh-CN');
|
|
259
|
+
return `<!doctype html>
|
|
260
|
+
<html lang="zh-CN">
|
|
261
|
+
<head>
|
|
262
|
+
<meta charset="utf-8">
|
|
263
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
264
|
+
<title>AgentDock Report</title>
|
|
265
|
+
<style>${STYLES}</style>
|
|
266
|
+
</head>
|
|
267
|
+
<body>
|
|
268
|
+
<div class="page">
|
|
269
|
+
<header>
|
|
270
|
+
<div class="brand"><span class="brand-mark"></span>AgentDock Report</div>
|
|
271
|
+
<div class="meta">模式 ${escapeHtml(report.mode)}${agentMeta} · 目标 ${target} · 生成于 ${escapeHtml(generatedAt)}</div>
|
|
272
|
+
${profileNote}
|
|
273
|
+
</header>
|
|
274
|
+
|
|
275
|
+
<section class="card hero">
|
|
276
|
+
${renderGauge(report)}
|
|
277
|
+
<div>
|
|
278
|
+
<div class="hero-grade">
|
|
279
|
+
<span class="grade-chip ${gradeClass(report.grade)}">${report.grade}</span>
|
|
280
|
+
环境健康度 ${report.score} / 100
|
|
281
|
+
</div>
|
|
282
|
+
<p class="hero-summary">${escapeHtml(report.summary)}</p>
|
|
283
|
+
<div class="stat-line">
|
|
284
|
+
<span class="pill">可迁移定义 ${report.inventory.totalEntries}</span>
|
|
285
|
+
<span class="pill">隔离机密 ${report.inventory.secretsCount}</span>
|
|
286
|
+
<span class="pill">检查 ${report.checks.length} 项</span>
|
|
287
|
+
</div>
|
|
288
|
+
</div>
|
|
289
|
+
</section>
|
|
290
|
+
|
|
291
|
+
<section class="card">
|
|
292
|
+
<h2>环境清单</h2>
|
|
293
|
+
${renderInventory(report)}
|
|
294
|
+
</section>
|
|
295
|
+
|
|
296
|
+
<section class="card">
|
|
297
|
+
<h2>检查明细</h2>
|
|
298
|
+
${report.checks.map((check) => renderCheck(check)).join('')}
|
|
299
|
+
</section>
|
|
300
|
+
|
|
301
|
+
<section class="card">
|
|
302
|
+
<h2>修复建议</h2>
|
|
303
|
+
${renderRemediation(report)}
|
|
304
|
+
</section>
|
|
305
|
+
|
|
306
|
+
${renderShareCard(report)}
|
|
307
|
+
</div>
|
|
308
|
+
</body>
|
|
309
|
+
</html>
|
|
310
|
+
`;
|
|
311
|
+
}
|
|
@@ -0,0 +1,243 @@
|
|
|
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.computeReportScore = computeReportScore;
|
|
7
|
+
exports.gradeForScore = gradeForScore;
|
|
8
|
+
exports.runReport = runReport;
|
|
9
|
+
const node_os_1 = __importDefault(require("node:os"));
|
|
10
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
11
|
+
const node_path_1 = __importDefault(require("node:path"));
|
|
12
|
+
const yaml_1 = __importDefault(require("yaml"));
|
|
13
|
+
const doctor_1 = require("./doctor");
|
|
14
|
+
const report_html_1 = require("./report-html");
|
|
15
|
+
const claude_scanner_1 = require("../scanners/claude-scanner");
|
|
16
|
+
const codex_scanner_1 = require("../scanners/codex-scanner");
|
|
17
|
+
const fs_1 = require("../utils/fs");
|
|
18
|
+
// ===== inventory =====
|
|
19
|
+
function countDomain(agent, domain) {
|
|
20
|
+
const mcp = domain.mcp.length;
|
|
21
|
+
const skills = domain.skills.length;
|
|
22
|
+
const agents = domain.agents.length;
|
|
23
|
+
const plugins = domain.plugins.length;
|
|
24
|
+
const hooks = domain.hooks.length;
|
|
25
|
+
const memory = domain.memory.length;
|
|
26
|
+
const settings = domain.settings.length;
|
|
27
|
+
return {
|
|
28
|
+
agent,
|
|
29
|
+
mcp,
|
|
30
|
+
skills,
|
|
31
|
+
agents,
|
|
32
|
+
plugins,
|
|
33
|
+
hooks,
|
|
34
|
+
memory,
|
|
35
|
+
settings,
|
|
36
|
+
total: mcp + skills + agents + plugins + hooks + memory + settings,
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function makeInventory(agents, secretsCount) {
|
|
40
|
+
return {
|
|
41
|
+
agents,
|
|
42
|
+
totalEntries: agents.reduce((sum, item) => sum + item.total, 0),
|
|
43
|
+
secretsCount,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function inventoryLive(agentFilter, root) {
|
|
47
|
+
const agents = [];
|
|
48
|
+
let secretsCount = 0;
|
|
49
|
+
if (agentFilter === 'claude' || agentFilter === 'all') {
|
|
50
|
+
const scan = await (0, claude_scanner_1.scanClaude)(root);
|
|
51
|
+
agents.push(countDomain('claude', scan.domain));
|
|
52
|
+
secretsCount += scan.secrets.length;
|
|
53
|
+
}
|
|
54
|
+
if (agentFilter === 'codex' || agentFilter === 'all') {
|
|
55
|
+
const scan = await (0, codex_scanner_1.scanCodex)(root);
|
|
56
|
+
agents.push(countDomain('codex', scan.domain));
|
|
57
|
+
secretsCount += scan.secrets.length;
|
|
58
|
+
}
|
|
59
|
+
return makeInventory(agents, secretsCount);
|
|
60
|
+
}
|
|
61
|
+
function inventoryFromManifest(manifest, agentFilter) {
|
|
62
|
+
const agents = [];
|
|
63
|
+
const entries = Object.entries(manifest.agents ?? {});
|
|
64
|
+
for (const [name, domain] of entries) {
|
|
65
|
+
if (!domain) {
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
68
|
+
if (agentFilter !== 'all' && agentFilter !== name) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
agents.push(countDomain(name, domain));
|
|
72
|
+
}
|
|
73
|
+
return makeInventory(agents, manifest.secrets?.length ?? 0);
|
|
74
|
+
}
|
|
75
|
+
async function inventoryFromScan(scanPath, agentFilter) {
|
|
76
|
+
const manifestPath = node_path_1.default.resolve(scanPath);
|
|
77
|
+
if (!(await (0, fs_1.pathExists)(manifestPath))) {
|
|
78
|
+
return makeInventory([], 0);
|
|
79
|
+
}
|
|
80
|
+
const manifest = yaml_1.default.parse(await promises_1.default.readFile(manifestPath, 'utf8'));
|
|
81
|
+
return inventoryFromManifest(manifest, agentFilter);
|
|
82
|
+
}
|
|
83
|
+
async function inventoryFromPackage(pkgDir, agentFilter) {
|
|
84
|
+
const manifestPath = node_path_1.default.join(node_path_1.default.resolve(pkgDir), 'manifest.resolved.json');
|
|
85
|
+
if (!(await (0, fs_1.pathExists)(manifestPath))) {
|
|
86
|
+
return makeInventory([], 0);
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
const manifest = JSON.parse(await promises_1.default.readFile(manifestPath, 'utf8'));
|
|
90
|
+
return inventoryFromManifest(manifest, agentFilter);
|
|
91
|
+
}
|
|
92
|
+
catch {
|
|
93
|
+
return makeInventory([], 0);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
// ===== scoring =====
|
|
97
|
+
function computeReportScore(checks) {
|
|
98
|
+
let score = 100;
|
|
99
|
+
for (const check of checks) {
|
|
100
|
+
if (check.status === 'fail') {
|
|
101
|
+
score -= 20;
|
|
102
|
+
}
|
|
103
|
+
else if (check.status === 'warn') {
|
|
104
|
+
score -= 8;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return Math.max(0, Math.min(100, score));
|
|
108
|
+
}
|
|
109
|
+
function gradeForScore(score) {
|
|
110
|
+
if (score >= 90)
|
|
111
|
+
return 'A';
|
|
112
|
+
if (score >= 75)
|
|
113
|
+
return 'B';
|
|
114
|
+
if (score >= 60)
|
|
115
|
+
return 'C';
|
|
116
|
+
return 'D';
|
|
117
|
+
}
|
|
118
|
+
// ===== xinchuang heuristics =====
|
|
119
|
+
const ABSOLUTE_PATH_PATTERN = /[A-Za-z]:[\\/]|\/(?:home|Users|root|opt|usr\/local)\//g;
|
|
120
|
+
const RUNTIME_COMMAND_PATTERN = /"command"\s*:\s*"(?:npx|uvx|docker|bunx|pnpm)"|command\s*=\s*"(?:npx|uvx|docker|bunx|pnpm)"/g;
|
|
121
|
+
const EXTERNAL_ENDPOINT_PATTERN = /https?:\/\/[^\s"'`]+/g;
|
|
122
|
+
async function readConfigTexts(root) {
|
|
123
|
+
const candidates = [
|
|
124
|
+
node_path_1.default.join(root, '.claude', 'settings.json'),
|
|
125
|
+
node_path_1.default.join(root, '.claude.json'),
|
|
126
|
+
node_path_1.default.join(root, '.codex', 'config.toml'),
|
|
127
|
+
];
|
|
128
|
+
const texts = [];
|
|
129
|
+
for (const file of candidates) {
|
|
130
|
+
try {
|
|
131
|
+
texts.push({ file, text: await promises_1.default.readFile(file, 'utf8') });
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
// missing / unreadable config is already reported by the doctor checks
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return texts;
|
|
138
|
+
}
|
|
139
|
+
function collectHits(texts, pattern, sampleLimit = 3) {
|
|
140
|
+
const findings = [];
|
|
141
|
+
for (const { file, text } of texts) {
|
|
142
|
+
const matches = text.match(pattern);
|
|
143
|
+
if (!matches || matches.length === 0) {
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
const samples = [...new Set(matches)].slice(0, sampleLimit);
|
|
147
|
+
findings.push({
|
|
148
|
+
severity: 'warn',
|
|
149
|
+
message: `发现 ${matches.length} 处${samples.length ? `(示例:${samples.join(', ')})` : ''}`,
|
|
150
|
+
path: file,
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
return findings;
|
|
154
|
+
}
|
|
155
|
+
function heuristicCheck(id, label, findings, cleanDetail, remediation) {
|
|
156
|
+
const status = findings.length > 0 ? 'warn' : 'pass';
|
|
157
|
+
return {
|
|
158
|
+
id,
|
|
159
|
+
label,
|
|
160
|
+
status,
|
|
161
|
+
detail: status === 'pass' ? `${cleanDetail}(启发式检查,仍需人工确认)` : `需人工确认:发现 ${findings.length} 个可疑项`,
|
|
162
|
+
findings,
|
|
163
|
+
...(status === 'pass' ? {} : { remediation }),
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
async function xinchuangChecks(root) {
|
|
167
|
+
const texts = await readConfigTexts(root);
|
|
168
|
+
const platform = {
|
|
169
|
+
id: 'xinchuang-platform',
|
|
170
|
+
label: '信创 · 平台 / 运行时(需人工确认)',
|
|
171
|
+
status: 'warn',
|
|
172
|
+
detail: `需人工确认:当前为 ${process.platform}/${process.arch},Node ${process.version};请核对目标信创环境(如麒麟 V10 / 统信 UOS、LoongArch / 鲲鹏 ARM)的操作系统、CPU 架构与运行时版本`,
|
|
173
|
+
findings: [],
|
|
174
|
+
remediation: '信创适配无法仅凭本机静态信息判定。请在目标机上运行 `agentdock report --profile xinchuang`,人工验证 Node 运行时、依赖与 MCP 服务可用性。',
|
|
175
|
+
};
|
|
176
|
+
const pathCheck = heuristicCheck('xinchuang-paths', '信创 · 绝对路径(需人工确认)', collectHits(texts, ABSOLUTE_PATH_PATTERN), '配置中未发现平台相关的绝对路径引用', '跨机器 / 跨国产化系统时,固定路径(如 C:\\Users\\...、/home/...)通常不可用。建议改为相对路径或环境变量,并在目标机重新验证。');
|
|
177
|
+
const runtimeCheck = heuristicCheck('xinchuang-runtime', '信创 · MCP 运行时依赖(需人工确认)', collectHits(texts, RUNTIME_COMMAND_PATTERN), '配置中未发现 npx / uvx / docker 等运行时拉取命令', 'npx / uvx / docker 等运行时会在目标机联网拉取依赖;信创内网环境需提前离线安装,或改为本地可执行文件。');
|
|
178
|
+
const endpointCheck = heuristicCheck('xinchuang-endpoints', '信创 · 外网端点(需人工确认)', collectHits(texts, EXTERNAL_ENDPOINT_PATTERN), '配置中未发现外网 http(s) 端点', '外网 http(s) 端点在信创内网可能不可达,需提前确认网络策略或改用内网镜像 / 代理。');
|
|
179
|
+
return [platform, pathCheck, runtimeCheck, endpointCheck];
|
|
180
|
+
}
|
|
181
|
+
function xinchuangManualCheck(mode) {
|
|
182
|
+
return {
|
|
183
|
+
id: 'xinchuang-manual',
|
|
184
|
+
label: '信创 · 需人工确认',
|
|
185
|
+
status: 'warn',
|
|
186
|
+
detail: `需人工确认:${mode} 模式仅审计产物,不评估信创环境适配`,
|
|
187
|
+
findings: [],
|
|
188
|
+
remediation: '请在目标机上运行 `agentdock report --profile xinchuang`,人工验证运行时、依赖、绝对路径与外网端点。',
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
// ===== entry =====
|
|
192
|
+
async function runReport(options) {
|
|
193
|
+
const agent = options.agent ?? 'all';
|
|
194
|
+
const profile = options.profile ?? 'default';
|
|
195
|
+
let base;
|
|
196
|
+
let inventory;
|
|
197
|
+
let extraChecks = [];
|
|
198
|
+
if (options.fromScan) {
|
|
199
|
+
base = await (0, doctor_1.runDoctor)({ agent, fromScan: options.fromScan });
|
|
200
|
+
inventory = await inventoryFromScan(options.fromScan, agent);
|
|
201
|
+
if (profile === 'xinchuang') {
|
|
202
|
+
extraChecks = [xinchuangManualCheck('scan')];
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
else if (options.package) {
|
|
206
|
+
base = await (0, doctor_1.runDoctor)({ agent, package: options.package });
|
|
207
|
+
inventory = await inventoryFromPackage(options.package, agent);
|
|
208
|
+
if (profile === 'xinchuang') {
|
|
209
|
+
extraChecks = [xinchuangManualCheck('package')];
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
const root = options.root ?? node_os_1.default.homedir();
|
|
214
|
+
base = await (0, doctor_1.runDoctor)({ agent, root });
|
|
215
|
+
inventory = await inventoryLive(agent, root);
|
|
216
|
+
if (profile === 'xinchuang') {
|
|
217
|
+
extraChecks = await xinchuangChecks(root);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
const checks = [...base.checks, ...extraChecks];
|
|
221
|
+
const score = computeReportScore(checks);
|
|
222
|
+
const grade = gradeForScore(score);
|
|
223
|
+
const summary = profile === 'xinchuang'
|
|
224
|
+
? `${base.summary}(信创适配为启发式检查,需人工确认)`
|
|
225
|
+
: base.summary;
|
|
226
|
+
const report = {
|
|
227
|
+
...base,
|
|
228
|
+
checks,
|
|
229
|
+
summary,
|
|
230
|
+
profile,
|
|
231
|
+
score,
|
|
232
|
+
grade,
|
|
233
|
+
inventory,
|
|
234
|
+
};
|
|
235
|
+
if (options.out) {
|
|
236
|
+
await (0, fs_1.ensureDirectory)(options.out);
|
|
237
|
+
report.htmlPath = node_path_1.default.join(options.out, 'agentdock-report.html');
|
|
238
|
+
report.jsonPath = node_path_1.default.join(options.out, 'agentdock-report.json');
|
|
239
|
+
await (0, fs_1.writeJsonFile)(report.jsonPath, report);
|
|
240
|
+
await (0, fs_1.writeTextFile)(report.htmlPath, (0, report_html_1.renderReportHtml)(report));
|
|
241
|
+
}
|
|
242
|
+
return report;
|
|
243
|
+
}
|
package/dist/src/i18n/index.js
CHANGED
|
@@ -10,7 +10,7 @@ const FALLBACK = 'en';
|
|
|
10
10
|
/** User-facing strings. Machines read `--json` output, which is never localized. */
|
|
11
11
|
const DICTIONARIES = {
|
|
12
12
|
en: {
|
|
13
|
-
'cli.usage': 'Usage: agentdock <scan|export|install|validate|doctor|list|diff|config|uninstall> [path]',
|
|
13
|
+
'cli.usage': 'Usage: agentdock <scan|export|install|validate|doctor|report|list|diff|config|uninstall> [path]',
|
|
14
14
|
'install.complete': 'Install completed: {path}',
|
|
15
15
|
'uninstall.complete': 'Uninstall complete: {path}',
|
|
16
16
|
'uninstall.dryRunHeader': 'Uninstall plan (dry-run — no changes made): {path}',
|
|
@@ -31,7 +31,7 @@ const DICTIONARIES = {
|
|
|
31
31
|
'config.unsetValue': '(unset)',
|
|
32
32
|
},
|
|
33
33
|
'zh-CN': {
|
|
34
|
-
'cli.usage': '用法:agentdock <scan|export|install|validate|doctor|list|diff|config|uninstall> [path]',
|
|
34
|
+
'cli.usage': '用法:agentdock <scan|export|install|validate|doctor|report|list|diff|config|uninstall> [path]',
|
|
35
35
|
'install.complete': '安装完成:{path}',
|
|
36
36
|
'uninstall.complete': '卸载完成:{path}',
|
|
37
37
|
'uninstall.dryRunHeader': '卸载计划(dry-run — 未做任何改动):{path}',
|
package/dist/src/utils/fs.js
CHANGED
|
@@ -17,7 +17,7 @@ exports.readJsonFile = readJsonFile;
|
|
|
17
17
|
exports.writeJsonFile = writeJsonFile;
|
|
18
18
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
19
19
|
const node_path_1 = __importDefault(require("node:path"));
|
|
20
|
-
const
|
|
20
|
+
const picomatch_1 = __importDefault(require("picomatch"));
|
|
21
21
|
function resolveFrom(baseDir, targetPath) {
|
|
22
22
|
return node_path_1.default.resolve(baseDir, targetPath);
|
|
23
23
|
}
|
|
@@ -126,9 +126,11 @@ async function copyDirectoryFiltered(sourcePath, targetPath, include, exclude, f
|
|
|
126
126
|
const files = await walkDirectoryWithSymlinkPolicy(sourcePath, '', followSymlinks);
|
|
127
127
|
const includePatterns = include?.length ? include : ['**/*'];
|
|
128
128
|
const excludePatterns = exclude ?? [];
|
|
129
|
+
const includeMatchers = includePatterns.map((pattern) => (0, picomatch_1.default)(pattern, { dot: true }));
|
|
130
|
+
const excludeMatchers = excludePatterns.map((pattern) => (0, picomatch_1.default)(pattern, { dot: true }));
|
|
129
131
|
for (const file of files) {
|
|
130
|
-
const isIncluded =
|
|
131
|
-
const isExcluded =
|
|
132
|
+
const isIncluded = includeMatchers.some((matches) => matches(file.relativePath));
|
|
133
|
+
const isExcluded = excludeMatchers.some((matches) => matches(file.relativePath));
|
|
132
134
|
if (!isIncluded || isExcluded) {
|
|
133
135
|
continue;
|
|
134
136
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentdock-cli",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.7.0",
|
|
4
|
+
"description": "Diagnose, migrate, and back up your AI coding assistant environment (Claude Code / Codex) — Chinese health reports, MCP servers, Skills, Agents, Plugins, Hooks, and memory, with secret isolation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"claude-code",
|
|
7
7
|
"codex",
|
|
@@ -12,7 +12,12 @@
|
|
|
12
12
|
"versioning",
|
|
13
13
|
"mcp",
|
|
14
14
|
"skills",
|
|
15
|
-
"cli"
|
|
15
|
+
"cli",
|
|
16
|
+
"report",
|
|
17
|
+
"diagnostics",
|
|
18
|
+
"health-check",
|
|
19
|
+
"audit",
|
|
20
|
+
"air-gapped"
|
|
16
21
|
],
|
|
17
22
|
"type": "commonjs",
|
|
18
23
|
"bin": {
|
|
@@ -35,17 +40,18 @@
|
|
|
35
40
|
"release:commits": "node scripts/generate-commit-groups.js"
|
|
36
41
|
},
|
|
37
42
|
"dependencies": {
|
|
38
|
-
"ajv": "^8.
|
|
43
|
+
"ajv": "^8.20.0",
|
|
39
44
|
"diff": "^8.0.4",
|
|
40
|
-
"
|
|
41
|
-
"smol-toml": "^1.
|
|
45
|
+
"picomatch": "^4.0.7",
|
|
46
|
+
"smol-toml": "^1.9.1",
|
|
42
47
|
"yaml": "^2.8.1"
|
|
43
48
|
},
|
|
44
49
|
"devDependencies": {
|
|
45
|
-
"@types/node": "^24.
|
|
46
|
-
"
|
|
50
|
+
"@types/node": "^24.19.4",
|
|
51
|
+
"@types/picomatch": "^4.0.3",
|
|
52
|
+
"tsx": "^4.23.15",
|
|
47
53
|
"typescript": "^5.9.3",
|
|
48
|
-
"vitest": "^
|
|
54
|
+
"vitest": "^4.1.12"
|
|
49
55
|
},
|
|
50
56
|
"author": "spsz831",
|
|
51
57
|
"license": "MIT",
|