skillmkt 0.4.0 → 0.4.1
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/client/bin/skillmkt.js +15 -3
- package/client/commands/audit.js +3 -2
- package/client/commands/build.js +3 -2
- package/client/commands/decide.js +2 -1
- package/client/commands/diff.js +5 -4
- package/client/commands/doctor.js +4 -3
- package/client/commands/download.js +2 -1
- package/client/commands/init.js +22 -21
- package/client/commands/install.js +5 -4
- package/client/commands/list.js +4 -3
- package/client/commands/merge.js +6 -4
- package/client/commands/outdated.js +5 -4
- package/client/commands/pack.js +2 -1
- package/client/commands/publish.js +3 -1
- package/client/commands/remove.js +4 -3
- package/client/commands/resolve.js +10 -9
- package/client/commands/rollback.js +3 -2
- package/client/commands/search.js +2 -1
- package/client/commands/serve.js +11 -13
- package/client/commands/sync.js +4 -3
- package/client/commands/targets.js +2 -1
- package/client/commands/update.js +2 -1
- package/client/commands/upgrade.js +5 -4
- package/client/lib/ctx.js +2 -0
- package/client/lib/daemon.js +3 -2
- package/client/lib/hub.js +1 -1
- package/client/lib/i18n.js +14 -0
- package/client/lib/llm.js +2 -1
- package/client/lib/project.js +3 -2
- package/client/lib/prompt.js +2 -1
- package/client/lib/registries/github.js +3 -2
- package/client/lib/registries/index.js +6 -5
- package/client/lib/registries/rfc.js +2 -1
- package/client/lib/render.js +7 -6
- package/package.json +1 -1
package/client/bin/skillmkt.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// skillmkt — local-first agent skill manager
|
|
3
3
|
import { makeCtx, withState } from '../lib/ctx.js';
|
|
4
4
|
import { hubExists } from '../lib/hub.js';
|
|
5
|
+
import { L } from '../lib/i18n.js';
|
|
5
6
|
|
|
6
7
|
const COMMANDS = {
|
|
7
8
|
init: 'init', config: 'config', doctor: 'doctor',
|
|
@@ -29,10 +30,21 @@ dist: audit pack publish registry serve
|
|
|
29
30
|
|
|
30
31
|
bare run = dashboard. docs: docs/CLI.md`;
|
|
31
32
|
|
|
33
|
+
const HELP_ZH = `skillmkt — 本地优先的 agent skill 管理器
|
|
34
|
+
|
|
35
|
+
用法: skillmkt <命令> [参数] [--json] [--hub <路径>] [--dry-run] [--ui|--cli]
|
|
36
|
+
|
|
37
|
+
核心: init config doctor search list show install remove targets sync
|
|
38
|
+
版本: update outdated upgrade download diff rollback
|
|
39
|
+
合并: conflicts resolve decide merge build
|
|
40
|
+
分发: audit pack publish registry serve
|
|
41
|
+
|
|
42
|
+
裸跑 = 仪表盘。文档: docs/CLI.md`;
|
|
43
|
+
|
|
32
44
|
async function bareRun(ctx) {
|
|
33
45
|
if (!hubExists(ctx.hub)) {
|
|
34
46
|
if (!ctx.tty) {
|
|
35
|
-
console.error("run 'skillmkt init' to get started");
|
|
47
|
+
console.error(L("请先运行 'skillmkt init' 完成初始化", "run 'skillmkt init' to get started"));
|
|
36
48
|
process.exit(1);
|
|
37
49
|
}
|
|
38
50
|
const mod = await import('../commands/init.js');
|
|
@@ -49,7 +61,7 @@ async function main() {
|
|
|
49
61
|
const [cmd, ...args] = ctx.positional;
|
|
50
62
|
ctx.args = args;
|
|
51
63
|
|
|
52
|
-
if (ctx.flags.raw.help || ctx.flags.raw.h) { console.log(HELP); process.exit(0); }
|
|
64
|
+
if (ctx.flags.raw.help || ctx.flags.raw.h) { console.log(L(HELP_ZH, HELP)); process.exit(0); }
|
|
53
65
|
if (ctx.flags.raw.version || ctx.flags.raw.V) {
|
|
54
66
|
const pkg = (await import('../../package.json', { with: { type: 'json' } })).default;
|
|
55
67
|
console.log(pkg.version);
|
|
@@ -60,7 +72,7 @@ async function main() {
|
|
|
60
72
|
|
|
61
73
|
const name = COMMANDS[cmd];
|
|
62
74
|
if (!name) {
|
|
63
|
-
console.error(
|
|
75
|
+
console.error(`${L('未知命令', 'unknown command')}: ${cmd}\n\n${L(HELP_ZH, HELP)}`);
|
|
64
76
|
process.exit(1);
|
|
65
77
|
}
|
|
66
78
|
|
package/client/commands/audit.js
CHANGED
|
@@ -5,6 +5,7 @@ import { auditDir, writeScan } from '../lib/audit.js';
|
|
|
5
5
|
import { llmAudit } from '../lib/ai.js';
|
|
6
6
|
import { walk } from '../lib/package.js';
|
|
7
7
|
import { ok, warn, fail, info } from '../lib/render.js';
|
|
8
|
+
import { L } from '../lib/i18n.js';
|
|
8
9
|
|
|
9
10
|
export async function run(ctx) {
|
|
10
11
|
const flags = ctx.flags.raw;
|
|
@@ -15,7 +16,7 @@ export async function run(ctx) {
|
|
|
15
16
|
const order = { clean: 0, suspicious: 1, stripped: 1, malicious: 2 };
|
|
16
17
|
for (const name of names) {
|
|
17
18
|
const dir = path.join(ctx.hub, 'skills', name);
|
|
18
|
-
if (!fs.existsSync(dir)) { warn(`未受管: ${name}`); continue; }
|
|
19
|
+
if (!fs.existsSync(dir)) { warn(L(`未受管: ${name}`, `not managed: ${name}`)); continue; }
|
|
19
20
|
const r = auditDir(dir, { strip: false });
|
|
20
21
|
// --llm:additive 语义审(静态结论之上,降级安全)
|
|
21
22
|
if (flags.llm && ctx.llm) {
|
|
@@ -23,7 +24,7 @@ export async function run(ctx) {
|
|
|
23
24
|
.map((p) => ({ path: path.relative(dir, p), content: fs.readFileSync(p, 'utf8') }));
|
|
24
25
|
const lr = await llmAudit(ctx.llm, { name, files }).catch(() => null);
|
|
25
26
|
if (lr) { r.llm = lr; info(` llm: ${lr.verdict}${lr.reasons?.length ? ` — ${lr.reasons.join('; ')}` : ''}`); }
|
|
26
|
-
else warn(' llm audit 不可用——保留静态结论');
|
|
27
|
+
else warn(L(' llm audit 不可用——保留静态结论', ' llm audit unavailable — keeping static verdict'));
|
|
27
28
|
}
|
|
28
29
|
writeScan(ctx.hub, name, r);
|
|
29
30
|
if (order[r.verdict] > order[worst]) worst = r.verdict;
|
package/client/commands/build.js
CHANGED
|
@@ -7,6 +7,7 @@ import { activeDecisions } from '../lib/decide.js';
|
|
|
7
7
|
import { readYAML } from '../../pipeline/lib/util.js';
|
|
8
8
|
import { ok, warn, fail, info } from '../lib/render.js';
|
|
9
9
|
import { mergedDir } from './merge.js';
|
|
10
|
+
import { L } from '../lib/i18n.js';
|
|
10
11
|
|
|
11
12
|
export function buildSkill(hub) {
|
|
12
13
|
const mPath = path.join(mergedDir(hub), 'rules.yml');
|
|
@@ -31,7 +32,7 @@ export function buildSkill(hub) {
|
|
|
31
32
|
|
|
32
33
|
export async function run(ctx) {
|
|
33
34
|
const b = buildSkill(ctx.hub);
|
|
34
|
-
if (!b) { fail('无 merged/rules.yml — 先 skillmkt merge'); return 1; }
|
|
35
|
+
if (!b) { fail(L('无 merged/rules.yml — 先 skillmkt merge', 'no merged/rules.yml — run skillmkt merge first')); return 1; }
|
|
35
36
|
const { merged, kept, customs, pending } = b;
|
|
36
37
|
// 渲染:域分组 + provenance 注释
|
|
37
38
|
const byDom = new Map();
|
|
@@ -56,6 +57,6 @@ export async function run(ctx) {
|
|
|
56
57
|
}
|
|
57
58
|
fs.mkdirSync(outDir, { recursive: true });
|
|
58
59
|
fs.writeFileSync(path.join(outDir, 'SKILL.md'), md);
|
|
59
|
-
ok(`built ${outDir}/SKILL.md — ${kept.length} rules${pending ? `,⚠ ${pending} pending
|
|
60
|
+
ok(`built ${outDir}/SKILL.md — ${kept.length} rules${pending ? L(`,⚠ ${pending} pending 双边已排除`, ` — ⚠ ${pending} pending, both sides excluded`) : ''}`);
|
|
60
61
|
return pending ? 3 : 0;
|
|
61
62
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { loadConflicts, writeConflict } from '../lib/conflicts.js';
|
|
3
3
|
import { decide } from '../lib/decide.js';
|
|
4
4
|
import { ok, fail } from '../lib/render.js';
|
|
5
|
+
import { L } from '../lib/i18n.js';
|
|
5
6
|
|
|
6
7
|
export async function run(ctx) {
|
|
7
8
|
const [id] = ctx.args;
|
|
@@ -10,7 +11,7 @@ export async function run(ctx) {
|
|
|
10
11
|
const c = loadConflicts(ctx.hub).find((x) => x.id === id);
|
|
11
12
|
if (!c) { fail(`not found: ${id}`); return 1; }
|
|
12
13
|
if (!['keep-a', 'keep-b', 'merge', 'dismissed'].includes(resolution)) { fail(`bad resolution: ${resolution}`); return 1; }
|
|
13
|
-
if (resolution === 'merge' && !custom) { fail('resolution=merge 需要 --custom 提供合并文本'); return 1; }
|
|
14
|
+
if (resolution === 'merge' && !custom) { fail(L('resolution=merge 需要 --custom 提供合并文本', 'resolution=merge needs --custom with the merged text')); return 1; }
|
|
14
15
|
decide(ctx.hub, c, { resolution, custom, reason, by: process.env.USER || 'cli' });
|
|
15
16
|
c.status = 'resolved';
|
|
16
17
|
writeConflict(ctx.hub, c);
|
package/client/commands/diff.js
CHANGED
|
@@ -7,6 +7,7 @@ import { walk, treeHash } from '../lib/package.js';
|
|
|
7
7
|
import { gitTreeHash } from '../lib/githash.js';
|
|
8
8
|
import { info, warn, fail } from '../lib/render.js';
|
|
9
9
|
import { semanticDiff } from '../lib/ai.js';
|
|
10
|
+
import { L } from '../lib/i18n.js';
|
|
10
11
|
|
|
11
12
|
function sectionsOf(dir) {
|
|
12
13
|
const f = path.join(dir, 'SKILL.md');
|
|
@@ -17,9 +18,9 @@ function sectionsOf(dir) {
|
|
|
17
18
|
export async function run(ctx) {
|
|
18
19
|
const name = ctx.args[0];
|
|
19
20
|
const s = ctx.library.skills?.[name];
|
|
20
|
-
if (!s) { fail(`未受管: ${name}`); return 1; }
|
|
21
|
+
if (!s) { fail(L(`未受管: ${name}`, `not managed: ${name}`)); return 1; }
|
|
21
22
|
const src = s.source || {};
|
|
22
|
-
if (src.registry !== 'github' || !src.ref) { fail(`${name}:
|
|
23
|
+
if (src.registry !== 'github' || !src.ref) { fail(L(`${name}: 无上游可比`, `${name}: no upstream to diff against`)); return 1; }
|
|
23
24
|
|
|
24
25
|
const [owner, repo] = src.ref.split('/');
|
|
25
26
|
const localDir = path.join(ctx.hub, 'skills', name);
|
|
@@ -44,9 +45,9 @@ export async function run(ctx) {
|
|
|
44
45
|
if (secAdded.length) info(`sections +: ${secAdded.join(' | ')}`);
|
|
45
46
|
if (secRemoved.length) info(`sections -: ${secRemoved.join(' | ')}`);
|
|
46
47
|
if (ctx.flags.raw.semantic) {
|
|
47
|
-
if (!ctx.llm) { warn('--semantic 需要 LLM(config.llm 或 OMLX_*)——以上为结构 diff'); return 0; }
|
|
48
|
+
if (!ctx.llm) { warn(L('--semantic 需要 LLM(config.llm 或 OMLX_*)——以上为结构 diff', '--semantic needs an LLM (config.llm or OMLX_*) — structural diff shown above')); return 0; }
|
|
48
49
|
const summary = await semanticDiff(ctx.llm, { name, added, removed, changed, secAdded, secRemoved }).catch(() => null);
|
|
49
|
-
info(summary ? `semantic: ${summary}` : 'semantic: LLM 不可用——结构 diff 如上');
|
|
50
|
+
info(summary ? `semantic: ${summary}` : L('semantic: LLM 不可用——结构 diff 如上', 'semantic: LLM unavailable — structural diff above'));
|
|
50
51
|
}
|
|
51
52
|
return 0;
|
|
52
53
|
}
|
|
@@ -6,6 +6,7 @@ import { hubExists } from '../lib/hub.js';
|
|
|
6
6
|
import { scanSkillDir } from '../lib/scanner.js';
|
|
7
7
|
import { readSkillDir, treeHash } from '../lib/package.js';
|
|
8
8
|
import { execFileSync } from 'node:child_process';
|
|
9
|
+
import { L } from '../lib/i18n.js';
|
|
9
10
|
|
|
10
11
|
const NODE_MIN = 22;
|
|
11
12
|
|
|
@@ -62,7 +63,7 @@ export async function run(ctx) {
|
|
|
62
63
|
const dir = h.dirs.find((d) => d.exists) ?? h.dirs[0];
|
|
63
64
|
const skills = dir?.exists ? scanSkillDir(dir.path).length : 0;
|
|
64
65
|
const note = h.detectOnly ? 'detect-only' : h.state === 'available' ? 'bin only — dir will create'
|
|
65
|
-
: h.state === 'likely' ? 'dir only — 装过?' : h.state === 'absent' ? '' : `${skills} skills`;
|
|
66
|
+
: h.state === 'likely' ? L('dir only — 装过?', 'dir only — installed?') : h.state === 'absent' ? '' : `${skills} skills`;
|
|
66
67
|
hrows.push({ id: h.id, dir: dir?.path ?? '-', state: h.state, note });
|
|
67
68
|
}
|
|
68
69
|
const hInstalled = hrows.filter((r) => r.state === 'installed').length;
|
|
@@ -89,8 +90,8 @@ export async function run(ctx) {
|
|
|
89
90
|
// llm 已配状态(不探端口——探测只在 init/config)
|
|
90
91
|
if (ctx.llm) say(true, `llm configured: ${ctx.llm.model} @ ${ctx.llm.base_url}`);
|
|
91
92
|
else {
|
|
92
|
-
say('warn', 'llm not configured — LLM features disabled (audit/conflicts/diff 降级静态)');
|
|
93
|
-
info('→ 跑 skillmkt init 一键配置');
|
|
93
|
+
say('warn', L('llm not configured — LLM features disabled (audit/conflicts/diff 降级静态)', 'llm not configured — LLM features disabled (audit/conflicts/diff fall back to static)'));
|
|
94
|
+
info(L('→ 跑 skillmkt init 一键配置', '→ run skillmkt init for one-step setup'));
|
|
94
95
|
}
|
|
95
96
|
|
|
96
97
|
// drift
|
|
@@ -6,6 +6,7 @@ import { auditDir, writeScan } from '../lib/audit.js';
|
|
|
6
6
|
import { readSkillDir, copyDir, rmDir } from '../lib/package.js';
|
|
7
7
|
import { ensureHub, cacheDir, quarantinePath } from '../lib/hub.js';
|
|
8
8
|
import { ok, warn, fail } from '../lib/render.js';
|
|
9
|
+
import { L } from '../lib/i18n.js';
|
|
9
10
|
|
|
10
11
|
export async function run(ctx) {
|
|
11
12
|
const input = ctx.args[0];
|
|
@@ -17,7 +18,7 @@ export async function run(ctx) {
|
|
|
17
18
|
? { dir: ref.absPath, provenance: { registry: 'local', adopted_from: ref.absPath }, sha: null }
|
|
18
19
|
: await fetchRef(ref, ctx);
|
|
19
20
|
const pkg = readSkillDir(got.dir);
|
|
20
|
-
if (!pkg) { fail(`不是合法 skill: ${input}`); return 1; }
|
|
21
|
+
if (!pkg) { fail(L(`不是合法 skill: ${input}`, `not a valid skill: ${input}`)); return 1; }
|
|
21
22
|
const audit = auditDir(got.dir, { strip: !ctx.flags.raw.keepScripts });
|
|
22
23
|
if (audit.verdict === 'malicious') {
|
|
23
24
|
if (!ctx.flags.dryRun) { rmDir(quarantinePath(ctx.hub, pkg.name)); copyDir(got.dir, quarantinePath(ctx.hub, pkg.name)); writeScan(ctx.hub, pkg.name, audit); }
|
package/client/commands/init.js
CHANGED
|
@@ -5,19 +5,20 @@ import { probeEndpoints, chat } from '../lib/llm.js';
|
|
|
5
5
|
import { openURL, readDaemon, pidAlive } from '../lib/daemon.js';
|
|
6
6
|
import { choose, confirm } from '../lib/prompt.js';
|
|
7
7
|
import { ok, warn, fail, info } from '../lib/render.js';
|
|
8
|
+
import { L } from '../lib/i18n.js';
|
|
8
9
|
|
|
9
10
|
export async function run(ctx) {
|
|
10
11
|
ensureHub(ctx.hub);
|
|
11
12
|
if (!ctx.tty) {
|
|
12
|
-
info('non-interactive: hub 骨架已建,LLM 配置请用 skillmkt config set llm.*');
|
|
13
|
+
info(L('non-interactive: hub 骨架已建,LLM 配置请用 skillmkt config set llm.*', 'non-interactive: hub skeleton created — configure LLM with skillmkt config set llm.*'));
|
|
13
14
|
return 0;
|
|
14
15
|
}
|
|
15
16
|
|
|
16
17
|
// 首问:初始化形态(写 ui.enabled——§3.11 自动接管与裸跑形态听它的)
|
|
17
18
|
const mode = ctx.flags.ui === 'force' ? 'web' : ctx.flags.ui === 'off' ? 'cli'
|
|
18
|
-
: (await choose('初始化方式?', [
|
|
19
|
-
{ label: 'Web 面板(推荐——探测结果、模型列表、harness 勾选可视化)', v: 'web' },
|
|
20
|
-
{ label: '终端向导(纯键盘,SSH/无浏览器环境)', v: 'cli' },
|
|
19
|
+
: (await choose(L('初始化方式?', 'Init method?'), [
|
|
20
|
+
{ label: L('Web 面板(推荐——探测结果、模型列表、harness 勾选可视化)', 'Web panel (recommended — visual probe results, model list, agent checkboxes)'), v: 'web' },
|
|
21
|
+
{ label: L('终端向导(纯键盘,SSH/无浏览器环境)', 'Terminal wizard (keyboard-only, for SSH/no-browser setups)'), v: 'cli' },
|
|
21
22
|
])).v;
|
|
22
23
|
|
|
23
24
|
const raw = readConfig(ctx.hub)._raw;
|
|
@@ -29,24 +30,24 @@ export async function run(ctx) {
|
|
|
29
30
|
try {
|
|
30
31
|
const d = readDaemon(ctx.hub);
|
|
31
32
|
if (d && pidAlive(d.pid)) {
|
|
32
|
-
ok(`Web 初始化已打开: ${openURL(d, '/#setup')}
|
|
33
|
+
ok(`Web 初始化已打开: ${openURL(d, '/#setup')}${L('(服务已在别的终端跑)', ' (server running in another terminal)')}`);
|
|
33
34
|
return 0;
|
|
34
35
|
}
|
|
35
36
|
const { startServer } = await import('./serve.js');
|
|
36
37
|
const srv = await startServer(ctx, { quiet: false });
|
|
37
38
|
const url = openURL({ port: srv.port, token: srv.token }, '/#setup');
|
|
38
|
-
ok(
|
|
39
|
-
info('setup 页内:扫描端点 → 选模型 → 勾 agent → 保存(写入 config.yml)');
|
|
40
|
-
info('服务前台运行中 — Ctrl-C 退出');
|
|
39
|
+
ok(`${L('Web 初始化已打开', 'Web init opened')}: ${url}`);
|
|
40
|
+
info(L('setup 页内:扫描端点 → 选模型 → 勾 agent → 保存(写入 config.yml)', 'in setup: scan endpoints → pick model → check agents → save (writes config.yml)'));
|
|
41
|
+
info(L('服务前台运行中 — Ctrl-C 退出', 'server running in foreground — Ctrl-C to exit'));
|
|
41
42
|
await new Promise(() => {});
|
|
42
43
|
return 0;
|
|
43
44
|
} catch (e) {
|
|
44
|
-
warn(`服务起不来(${e.message.slice(0, 60)}
|
|
45
|
+
warn(L(`服务起不来(${e.message.slice(0, 60)})——回退终端向导`, `server failed to start (${e.message.slice(0, 60)}) — falling back to terminal wizard`));
|
|
45
46
|
}
|
|
46
47
|
}
|
|
47
48
|
|
|
48
49
|
// LLM 端点探测(只在用户进入配置步骤时探测——铁律)
|
|
49
|
-
info('探测本地 LLM 服务…');
|
|
50
|
+
info(L('探测本地 LLM 服务…', 'Probing local LLM services…'));
|
|
50
51
|
const found = await probeEndpoints(400, { extraBases: [ctx.config.llm?.base_url] });
|
|
51
52
|
let base_url = null, model = null;
|
|
52
53
|
|
|
@@ -55,13 +56,13 @@ export async function run(ctx) {
|
|
|
55
56
|
...found.flatMap((f) => f.models.slice(0, 6).map((m) => ({
|
|
56
57
|
label: `${f.name}:${f.port} — ${m}`, v: { base_url: f.base_url, model: m },
|
|
57
58
|
}))),
|
|
58
|
-
{ label: '手动输入端点', v: 'manual' },
|
|
59
|
-
{ label: '跳过(确定性功能照常用)', v: 'skip' },
|
|
59
|
+
{ label: L('手动输入端点', 'Enter endpoint manually'), v: 'manual' },
|
|
60
|
+
{ label: L('跳过(确定性功能照常用)', 'Skip (deterministic features still work)'), v: 'skip' },
|
|
60
61
|
];
|
|
61
62
|
for (const f of found.filter((x) => x.needs_key)) {
|
|
62
|
-
info(`发现 ${f.name}:${f.port}(需要密钥,模型列表读不出)——选"手动输入端点"后填 ${f.base_url}`);
|
|
63
|
+
info(L(`发现 ${f.name}:${f.port}(需要密钥,模型列表读不出)——选"手动输入端点"后填 ${f.base_url}`, `found ${f.name}:${f.port} (key required, can't list models) — pick "manual" and enter ${f.base_url}`));
|
|
63
64
|
}
|
|
64
|
-
const sel = await choose('选择模型端点:', opts);
|
|
65
|
+
const sel = await choose(L('选择模型端点:', 'Choose a model endpoint:'), opts);
|
|
65
66
|
if (sel.v === 'manual') {
|
|
66
67
|
// 手动输入交给 config set 提示
|
|
67
68
|
info('→ skillmkt config set llm.base_url <url> && skillmkt config set llm.model <id>');
|
|
@@ -69,14 +70,14 @@ export async function run(ctx) {
|
|
|
69
70
|
({ base_url, model } = sel.v);
|
|
70
71
|
}
|
|
71
72
|
} else {
|
|
72
|
-
info('未发现本地 LLM 服务(已扫本机所有监听端口)');
|
|
73
|
-
info('→
|
|
73
|
+
info(L('未发现本地 LLM 服务(已扫本机所有监听端口)', 'No local LLM service found (all listening ports probed)'));
|
|
74
|
+
info('→ skillmkt config set llm.base_url http://host:port/v1');
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
// API key 环境变量引用(不存真值)
|
|
77
78
|
if (base_url) {
|
|
78
|
-
const keyEnv = await choose('API key 来源?', [
|
|
79
|
-
{ label: '无需 key(本地端点常见)', v: null },
|
|
79
|
+
const keyEnv = await choose(L('API key 来源?', 'API key source?'), [
|
|
80
|
+
{ label: L('无需 key(本地端点常见)', 'No key needed (common for local endpoints)'), v: null },
|
|
80
81
|
{ label: 'SKILLMKT_API_KEY', v: 'env:SKILLMKT_API_KEY' },
|
|
81
82
|
{ label: 'OMLX_API_KEY', v: 'env:OMLX_API_KEY' },
|
|
82
83
|
]);
|
|
@@ -88,7 +89,7 @@ export async function run(ctx) {
|
|
|
88
89
|
const reply = await chat(probe, { user: 'Reply with exactly: OK', maxTokens: 64 });
|
|
89
90
|
ok(`llm smoke: ${reply.trim().slice(0, 40) || '(empty reply)'}`);
|
|
90
91
|
} catch (e) {
|
|
91
|
-
warn(`llm smoke failed: ${e.message}
|
|
92
|
+
warn(L(`llm smoke failed: ${e.message}(配置已写入,功能将降级)`, `llm smoke failed: ${e.message} (config saved; features will degrade)`));
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
|
|
@@ -97,7 +98,7 @@ export async function run(ctx) {
|
|
|
97
98
|
raw.default_targets = [...new Set([...(raw.default_targets || []), ...installed])];
|
|
98
99
|
writeConfig(ctx.hub, raw);
|
|
99
100
|
|
|
100
|
-
ok(`init done — default_targets: ${raw.default_targets.join(', ') || '(无 installed harness,装好后 targets add)'}`);
|
|
101
|
-
info(`llm: ${model ? `${model} @ ${base_url}` : '未配置(skillmkt init 随时重跑)'}`);
|
|
101
|
+
ok(`init done — default_targets: ${raw.default_targets.join(', ') || L('(无 installed harness,装好后 targets add)', '(no installed agent — use targets add later)')}`);
|
|
102
|
+
info(`llm: ${model ? `${model} @ ${base_url}` : L('未配置(skillmkt init 随时重跑)', 'not configured (rerun skillmkt init anytime)')}`);
|
|
102
103
|
return 0;
|
|
103
104
|
}
|
|
@@ -12,6 +12,7 @@ import { primaryDir } from '../lib/scanner.js';
|
|
|
12
12
|
import { cacheLookup } from '../lib/state.js';
|
|
13
13
|
import { confirm, multiChoose } from '../lib/prompt.js';
|
|
14
14
|
import { ok, warn, fail, info } from '../lib/render.js';
|
|
15
|
+
import { L } from '../lib/i18n.js';
|
|
15
16
|
|
|
16
17
|
// 来源取证:.git remote → skills-lock.json → .market-skills.json → frontmatter
|
|
17
18
|
function recoverProvenance(dir, meta) {
|
|
@@ -87,7 +88,7 @@ export async function run(ctx) {
|
|
|
87
88
|
}
|
|
88
89
|
|
|
89
90
|
const pkg = readSkillDir(srcDir);
|
|
90
|
-
if (!pkg) { fail(`不是合法 skill(缺 SKILL.md): ${srcDir}`); return 1; }
|
|
91
|
+
if (!pkg) { fail(L(`不是合法 skill(缺 SKILL.md): ${srcDir}`, `not a valid skill (missing SKILL.md): ${srcDir}`)); return 1; }
|
|
91
92
|
const name = pkg.name;
|
|
92
93
|
|
|
93
94
|
// ② 审核闸门
|
|
@@ -105,7 +106,7 @@ export async function run(ctx) {
|
|
|
105
106
|
warn(`suspicious: ${audit.findings.length} findings${audit.stripped.length ? `, stripping ${audit.stripped.length} files` : ''}`);
|
|
106
107
|
audit.findings.slice(0, 5).forEach((f) => info(`${f.rule} ${f.file}:${f.line} — ${f.excerpt.slice(0, 80)}`));
|
|
107
108
|
// --yes 不放大 suspicious(安全默认);strict 直接拒
|
|
108
|
-
const proceed = ctx.config.policy === 'strict' ? false : await confirm(`继续安装 ${name}?`, { defaultYes: false });
|
|
109
|
+
const proceed = ctx.config.policy === 'strict' ? false : await confirm(L(`继续安装 ${name}?`, `Install ${name} anyway?`), { defaultYes: false });
|
|
109
110
|
if (!proceed) { fail('install aborted'); return 2; }
|
|
110
111
|
}
|
|
111
112
|
|
|
@@ -118,7 +119,7 @@ export async function run(ctx) {
|
|
|
118
119
|
// 与现有 hub 副本内容对比:相同则跳过 copy
|
|
119
120
|
const srcFilteredHash = (() => { const t = path.join(ctx.hub, 'cache', `__probe_${process.pid}`); rmDir(t); copyFiltered(srcDir, t, keep); const h = treeHash(t); rmDir(t); return h; })();
|
|
120
121
|
if (srcFilteredHash !== freshHash() && !flags.force) {
|
|
121
|
-
warn(`${name} 已受管且内容不同——--force 覆盖,或 upgrade
|
|
122
|
+
warn(L(`${name} 已受管且内容不同——--force 覆盖,或 upgrade 流程`, `${name} already managed with different content — --force to overwrite, or use upgrade`));
|
|
122
123
|
return 1;
|
|
123
124
|
}
|
|
124
125
|
}
|
|
@@ -144,7 +145,7 @@ export async function run(ctx) {
|
|
|
144
145
|
}
|
|
145
146
|
if (pool.length) {
|
|
146
147
|
const checked = pool.map((_, i) => i).slice(0, targets.length);
|
|
147
|
-
const idx = await multiChoose(`装到哪些位置?`, pool.map((t) => `${t.id} → ${t.dir}`), { checked });
|
|
148
|
+
const idx = await multiChoose(L(`装到哪些位置?`, `Install to which locations?`), pool.map((t) => `${t.id} → ${t.dir}`), { checked });
|
|
148
149
|
targets = idx.map((i) => pool[i]);
|
|
149
150
|
}
|
|
150
151
|
}
|
package/client/commands/list.js
CHANGED
|
@@ -3,6 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { table, out, info } from '../lib/render.js';
|
|
4
4
|
import { scanAll } from '../lib/scanner.js';
|
|
5
5
|
import { listYAML } from '../lib/yamlls.js';
|
|
6
|
+
import { L } from '../lib/i18n.js';
|
|
6
7
|
|
|
7
8
|
export async function run(ctx) {
|
|
8
9
|
const { hub, library, harnesses, project } = ctx;
|
|
@@ -35,12 +36,12 @@ export async function run(ctx) {
|
|
|
35
36
|
json: ctx.flags.json,
|
|
36
37
|
human: () => {
|
|
37
38
|
if (tableRows.length) table(tableRows, cols);
|
|
38
|
-
else info('(empty — skillmkt search / install 开始)');
|
|
39
|
+
else info(L('(empty — skillmkt search / install 开始)', '(empty — skillmkt search / install to start)'));
|
|
39
40
|
if (extRows.length) {
|
|
40
41
|
info('');
|
|
41
|
-
info('external(未收编):');
|
|
42
|
+
info(L('external(未收编):', 'external (unmanaged):'));
|
|
42
43
|
for (const e of extRows) info(` ${e.name.padEnd(30)} ${e.dir}`);
|
|
43
|
-
info(`→ skillmkt install <path>
|
|
44
|
+
info(L(`→ skillmkt install <path> 收编`, `→ skillmkt install <path> to adopt`));
|
|
44
45
|
}
|
|
45
46
|
if (ctx.project) {
|
|
46
47
|
const projRows = rows.filter((r) => r.where === 'project');
|
package/client/commands/merge.js
CHANGED
|
@@ -7,6 +7,7 @@ import { detectConflicts } from '../lib/conflicts.js';
|
|
|
7
7
|
import { autoArbitrate } from '../lib/autoarb.js';
|
|
8
8
|
import { tokens, jaccard, writeYAML } from '../../pipeline/lib/util.js';
|
|
9
9
|
import { ok, warn, fail, info } from '../lib/render.js';
|
|
10
|
+
import { L } from '../lib/i18n.js';
|
|
10
11
|
|
|
11
12
|
export const mergedDir = (hub) => path.join(hub, 'merged');
|
|
12
13
|
|
|
@@ -20,7 +21,7 @@ export async function run(ctx) {
|
|
|
20
21
|
for (const name of names) {
|
|
21
22
|
const dir = path.join(ctx.hub, 'skills', name);
|
|
22
23
|
const f = path.join(dir, 'SKILL.md');
|
|
23
|
-
if (!fs.existsSync(f)) { fail(`未受管: ${name}`); return 1; }
|
|
24
|
+
if (!fs.existsSync(f)) { fail(L(`未受管: ${name}`, `not managed: ${name}`)); return 1; }
|
|
24
25
|
let rs = null;
|
|
25
26
|
if (useLlm) {
|
|
26
27
|
try { rs = await extractRulesLLM(ctx.llm, fs.readFileSync(f, 'utf8'), name); } catch { /* 降级静态 */ }
|
|
@@ -38,12 +39,13 @@ export async function run(ctx) {
|
|
|
38
39
|
// --auto:仲裁直接吃确定项(fresh-context per conflict)
|
|
39
40
|
if (ctx.flags.raw.auto && ctx.llm && news.length) {
|
|
40
41
|
const r = await autoArbitrate(ctx.hub, ctx.llm, news, { onProgress: (c, x) => info(`${c.id}: ${x?.verdict ?? '?'}@${x?.confidence ?? '?'}`) });
|
|
41
|
-
info(`auto-arbiter: ${r.auto}
|
|
42
|
+
info(`auto-arbiter: ${r.auto} ${L('已决', 'decided')},${r.human} ${L('留人', 'left for you')}`);
|
|
42
43
|
}
|
|
43
44
|
const dir = mergedDir(ctx.hub);
|
|
44
45
|
fs.mkdirSync(dir, { recursive: true });
|
|
45
46
|
writeYAML(path.join(dir, 'rules.yml'), { name: outName, sources: names, merged_at: new Date().toISOString(), rules: dedup });
|
|
46
|
-
ok(`merged: ${dedup.length} rules(原始 ${rules.length},去重 -${rules.length - dedup.length})· 新冲突 ${news.length}
|
|
47
|
-
|
|
47
|
+
ok(L(`merged: ${dedup.length} rules(原始 ${rules.length},去重 -${rules.length - dedup.length})· 新冲突 ${news.length}`,
|
|
48
|
+
`merged: ${dedup.length} rules (${rules.length} raw, deduped -${rules.length - dedup.length}) · new conflicts ${news.length}`));
|
|
49
|
+
if (news.length) info(L(`skillmkt conflicts 查看队列;decide/resolve 裁决后 build`, `skillmkt conflicts to review; decide/resolve then build`));
|
|
48
50
|
return news.length ? 3 : 0;
|
|
49
51
|
}
|
|
@@ -4,6 +4,7 @@ import fs from 'node:fs';
|
|
|
4
4
|
import { readUpstream } from '../lib/state.js';
|
|
5
5
|
import { gitTreeHash } from '../lib/githash.js';
|
|
6
6
|
import { table, info, warn } from '../lib/render.js';
|
|
7
|
+
import { L } from '../lib/i18n.js';
|
|
7
8
|
|
|
8
9
|
export async function run(ctx) {
|
|
9
10
|
const up = readUpstream(ctx.hub);
|
|
@@ -13,13 +14,13 @@ export async function run(ctx) {
|
|
|
13
14
|
const u = up.skills?.[name];
|
|
14
15
|
const localDir = path.join(ctx.hub, 'skills', name);
|
|
15
16
|
if (!u) {
|
|
16
|
-
rows.push({ name, status: s.source?.registry === 'adopted' || s.source?.registry === 'local' ? 'n/a (无上游)' : 'never checked — run update' });
|
|
17
|
+
rows.push({ name, status: s.source?.registry === 'adopted' || s.source?.registry === 'local' ? L('n/a (无上游)', 'n/a (no upstream)') : 'never checked — run update' });
|
|
17
18
|
continue;
|
|
18
19
|
}
|
|
19
20
|
const localTree = fs.existsSync(localDir) ? gitTreeHash(localDir) : null;
|
|
20
21
|
if (localTree && u.tree_hash && localTree !== u.tree_hash) {
|
|
21
22
|
outdated++;
|
|
22
|
-
rows.push({ name, status: `upstream changed (${u.ref?.slice(0, 6)}) — upgrade
|
|
23
|
+
rows.push({ name, status: `upstream changed (${u.ref?.slice(0, 6)})${L(' — upgrade 应用', ' — run upgrade to apply')}` });
|
|
23
24
|
} else {
|
|
24
25
|
rows.push({ name, status: 'clean' });
|
|
25
26
|
}
|
|
@@ -27,8 +28,8 @@ export async function run(ctx) {
|
|
|
27
28
|
if (ctx.flags.json) { console.log(JSON.stringify({ outdated, rows })); }
|
|
28
29
|
else {
|
|
29
30
|
if (rows.length) table(rows, [{ key: 'name', title: 'skill' }, { key: 'status', title: 'status' }]);
|
|
30
|
-
if (!Object.keys(up.skills || {}).length) warn('state/upstream.yml 为空——先跑 skillmkt update');
|
|
31
|
-
else info(`last refresh: ${up.refreshed_at ?? 'unknown'}(skillmkt update
|
|
31
|
+
if (!Object.keys(up.skills || {}).length) warn(L('state/upstream.yml 为空——先跑 skillmkt update', 'state/upstream.yml is empty — run skillmkt update first'));
|
|
32
|
+
else info(`last refresh: ${up.refreshed_at ?? 'unknown'}${L('(skillmkt update 刷新)', ' (skillmkt update to refresh)')}`);
|
|
32
33
|
}
|
|
33
34
|
return outdated ? 4 : 0;
|
|
34
35
|
}
|
package/client/commands/pack.js
CHANGED
|
@@ -4,12 +4,13 @@ import path from 'node:path';
|
|
|
4
4
|
import os from 'node:os';
|
|
5
5
|
import { execFileSync } from 'node:child_process';
|
|
6
6
|
import { ok, fail, info } from '../lib/render.js';
|
|
7
|
+
import { L } from '../lib/i18n.js';
|
|
7
8
|
|
|
8
9
|
export async function run(ctx) {
|
|
9
10
|
const name = ctx.args[0];
|
|
10
11
|
if (!name) { fail('usage: skillmkt pack <name>'); return 1; }
|
|
11
12
|
const src = path.join(ctx.hub, 'skills', name);
|
|
12
|
-
if (!fs.existsSync(path.join(src, 'SKILL.md'))) { fail(`未受管: ${name}`); return 1; }
|
|
13
|
+
if (!fs.existsSync(path.join(src, 'SKILL.md'))) { fail(L(`未受管: ${name}`, `not managed: ${name}`)); return 1; }
|
|
13
14
|
const ver = ctx.library.skills?.[name]?.version || '0.0.0';
|
|
14
15
|
const out = path.resolve(`${name}-${ver}.tar.gz`);
|
|
15
16
|
const tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'skillmkt-pack-'));
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// publish <name> --to <registry> — 二期适配器;一期友好报错(clawhub POST /skills)
|
|
2
2
|
import { fail } from '../lib/render.js';
|
|
3
|
+
import { L } from '../lib/i18n.js';
|
|
3
4
|
|
|
4
5
|
export async function run(ctx) {
|
|
5
6
|
const name = ctx.args[0];
|
|
6
7
|
const to = ctx.flags.raw.to;
|
|
7
8
|
if (!name || !to) { fail('usage: skillmkt publish <name> --to <registry>'); return 1; }
|
|
8
|
-
fail(`publish: '${to}' adapter 未实现(二期:clawhub POST /api/v1/skills / 企业 registry)——当前可用 skillmkt pack ${name}
|
|
9
|
+
fail(L(`publish: '${to}' adapter 未实现(二期:clawhub POST /api/v1/skills / 企业 registry)——当前可用 skillmkt pack ${name} 出包手动分发`,
|
|
10
|
+
`publish: '${to}' adapter not implemented (phase 2: clawhub POST /api/v1/skills / enterprise registry) — for now use skillmkt pack ${name} and distribute manually`));
|
|
9
11
|
return 1;
|
|
10
12
|
}
|
|
@@ -6,13 +6,14 @@ import { unproject, targetDirFor } from '../lib/project.js';
|
|
|
6
6
|
import { confirm } from '../lib/prompt.js';
|
|
7
7
|
import { ok, warn, fail, info } from '../lib/render.js';
|
|
8
8
|
import { rmDir } from '../lib/package.js';
|
|
9
|
+
import { L } from '../lib/i18n.js';
|
|
9
10
|
|
|
10
11
|
export async function run(ctx) {
|
|
11
12
|
const name = ctx.args[0];
|
|
12
13
|
if (!name) { fail('usage: skillmkt remove <name> [--purge] [--scope project]'); return 1; }
|
|
13
14
|
const flags = ctx.flags.raw;
|
|
14
15
|
const entry = ctx.library.skills?.[name];
|
|
15
|
-
if (!entry) { fail(`未受管: ${name}`); return 1; }
|
|
16
|
+
if (!entry) { fail(L(`未受管: ${name}`, `not managed: ${name}`)); return 1; }
|
|
16
17
|
|
|
17
18
|
const projectOnly = flags.scope === 'project';
|
|
18
19
|
const targets = Object.entries(ctx.lock.skills?.[name]?.targets || {})
|
|
@@ -26,7 +27,7 @@ export async function run(ctx) {
|
|
|
26
27
|
}
|
|
27
28
|
|
|
28
29
|
if (projectOnly) {
|
|
29
|
-
info('project copy removed; hub 不动');
|
|
30
|
+
info(L('project copy removed; hub 不动', 'project copy removed; hub copy kept'));
|
|
30
31
|
return 0;
|
|
31
32
|
}
|
|
32
33
|
|
|
@@ -38,7 +39,7 @@ export async function run(ctx) {
|
|
|
38
39
|
const trash = trashPath(ctx.hub, name);
|
|
39
40
|
rmDir(trash);
|
|
40
41
|
fs.renameSync(hubDir, trash);
|
|
41
|
-
info(`→ .trash(恢复: mv 回 skills/ 或 skillmkt install <path
|
|
42
|
+
info(L(`→ .trash(恢复: mv 回 skills/ 或 skillmkt install <path>)`, `→ .trash (restore: mv back to skills/ or skillmkt install <path>)`));
|
|
42
43
|
}
|
|
43
44
|
}
|
|
44
45
|
unregisterSkill(ctx.hub, name);
|
|
@@ -10,6 +10,7 @@ import { decide } from '../lib/decide.js';
|
|
|
10
10
|
import { autoArbitrate } from '../lib/autoarb.js';
|
|
11
11
|
import { maybeHandoff } from '../lib/daemon.js';
|
|
12
12
|
import { ok, fail, info, warn } from '../lib/render.js';
|
|
13
|
+
import { L } from '../lib/i18n.js';
|
|
13
14
|
|
|
14
15
|
const edit = (seed) => {
|
|
15
16
|
const f = path.join(os.tmpdir(), `skillmkt-merge-${Date.now()}.md`);
|
|
@@ -24,9 +25,9 @@ export async function run(ctx) {
|
|
|
24
25
|
let queue = loadConflicts(ctx.hub, { pendingOnly: true });
|
|
25
26
|
// --auto:fresh-context 仲裁先吃掉确定项,剩余真价值权衡留人
|
|
26
27
|
if (ctx.flags.raw.auto) {
|
|
27
|
-
if (!ctx.llm) { fail('--auto 需要 LLM(config.llm 或 OMLX_*)'); return 1; }
|
|
28
|
+
if (!ctx.llm) { fail(L('--auto 需要 LLM(config.llm 或 OMLX_*)', '--auto needs an LLM (config.llm or OMLX_*)')); return 1; }
|
|
28
29
|
const r = await autoArbitrate(ctx.hub, ctx.llm, queue, { onProgress: (c, x) => info(`${c.id}: ${x ? `${x.verdict}@${x.confidence}` : 'parse-fail'}`) });
|
|
29
|
-
ok(`auto-arbiter: ${r.auto}
|
|
30
|
+
ok(`auto-arbiter: ${r.auto} ${L('已决', 'decided')},${r.human} ${L('留人', 'left for you')},${r.errors} ${L('错误', 'errors')}`);
|
|
30
31
|
queue = loadConflicts(ctx.hub, { pendingOnly: true });
|
|
31
32
|
if (!queue.length) return 0;
|
|
32
33
|
}
|
|
@@ -34,14 +35,14 @@ export async function run(ctx) {
|
|
|
34
35
|
if (ctx.flags.raw.evidence) {
|
|
35
36
|
const { makeEvidence, isDesignDomain } = await import('../lib/evidence.js');
|
|
36
37
|
for (const c of queue.filter((x) => isDesignDomain(x.domain))) {
|
|
37
|
-
if (!ctx.llm) { warn('--evidence 需要 LLM'); break; }
|
|
38
|
+
if (!ctx.llm) { warn(L('--evidence 需要 LLM', '--evidence needs an LLM')); break; }
|
|
38
39
|
try { await makeEvidence(ctx.llm, ctx.hub, c); info(`${c.id}: evidence ${c.evidence}`); }
|
|
39
40
|
catch (e) { warn(`${c.id}: evidence failed — ${e.message.slice(0, 60)}`); }
|
|
40
41
|
}
|
|
41
42
|
}
|
|
42
43
|
const target = ctx.args[0] ? queue.filter((c) => c.id === ctx.args[0]) : queue;
|
|
43
|
-
if (!target.length) { info('无 pending 冲突'); return 0; }
|
|
44
|
-
if (!process.stdin.isTTY || ctx.flags.raw.cli === false) { info(`${target.length} pending(非 TTY 不裁决)— skillmkt resolve 终端交互 / --ui
|
|
44
|
+
if (!target.length) { info(L('无 pending 冲突', 'no pending conflicts')); return 0; }
|
|
45
|
+
if (!process.stdin.isTTY || ctx.flags.raw.cli === false) { info(L(`${target.length} pending(非 TTY 不裁决)— skillmkt resolve 终端交互 / --ui 网页`, `${target.length} pending (not resolved without a TTY) — run skillmkt resolve interactively, or the web UI`)); return 3; }
|
|
45
46
|
|
|
46
47
|
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
47
48
|
const ask = (q) => new Promise((r) => rl.question(q, r));
|
|
@@ -51,18 +52,18 @@ export async function run(ctx) {
|
|
|
51
52
|
console.log(` A(${c.sides[0].source}): ${c.sides[0].text}`);
|
|
52
53
|
console.log(` B(${c.sides[1].source}): ${c.sides[1].text}`);
|
|
53
54
|
for (;;) {
|
|
54
|
-
const a = (await ask(' [a][b][m][e 编辑合并][d 误报][s 跳过][q] > ')).trim().toLowerCase();
|
|
55
|
+
const a = (await ask(L(' [a][b][m][e 编辑合并][d 误报][s 跳过][q] > ', ' [a][b][m][e dit merge][d ismiss][s kip][q] > '))).trim().toLowerCase();
|
|
55
56
|
if (a === 'q') { rl.close(); return resolved ? 0 : 3; }
|
|
56
57
|
if (a === 's') break;
|
|
57
58
|
const res = { a: 'keep-a', b: 'keep-b', m: 'merge', e: 'merge', d: 'dismissed' }[a];
|
|
58
59
|
if (!res) continue;
|
|
59
60
|
let custom = null;
|
|
60
61
|
if (a === 'm' || a === 'e') {
|
|
61
|
-
custom = a === 'e' ? edit(`${c.sides[0].text}\n---\n${c.sides[1].text}\n`) : (await ask(' 合并文本 > ')).trim();
|
|
62
|
-
if (!custom) { info('空文本,跳过'); break; }
|
|
62
|
+
custom = a === 'e' ? edit(`${c.sides[0].text}\n---\n${c.sides[1].text}\n`) : (await ask(L(' 合并文本 > ', ' merged text > '))).trim();
|
|
63
|
+
if (!custom) { info(L('空文本,跳过', 'empty text — skipped')); break; }
|
|
63
64
|
}
|
|
64
65
|
const reason = (await ask(' reason > ')).trim();
|
|
65
|
-
if (!reason) { info('reason 必填'); continue; }
|
|
66
|
+
if (!reason) { info(L('reason 必填', 'reason is required')); continue; }
|
|
66
67
|
decide(ctx.hub, c, { resolution: res, custom, reason, by: process.env.USER || 'cli' });
|
|
67
68
|
c.status = 'resolved';
|
|
68
69
|
writeConflict(ctx.hub, c);
|
|
@@ -7,12 +7,13 @@ import { projectSkill, targetDirFor } from '../lib/project.js';
|
|
|
7
7
|
import { updateLock } from '../lib/hub.js';
|
|
8
8
|
import { treeHash } from '../lib/package.js';
|
|
9
9
|
import { ok, fail } from '../lib/render.js';
|
|
10
|
+
import { L } from '../lib/i18n.js';
|
|
10
11
|
|
|
11
12
|
export async function run(ctx) {
|
|
12
13
|
const name = ctx.args[0];
|
|
13
14
|
const s = ctx.library.skills?.[name];
|
|
14
|
-
if (!s) { fail(`未受管: ${name}`); return 1; }
|
|
15
|
-
if (!fs.existsSync(historyDir(ctx.hub, name))) { fail(`${name}: 无历史副本(upgrade
|
|
15
|
+
if (!s) { fail(L(`未受管: ${name}`, `not managed: ${name}`)); return 1; }
|
|
16
|
+
if (!fs.existsSync(historyDir(ctx.hub, name))) { fail(L(`${name}: 无历史副本(upgrade 后才有一版深度)`, `${name}: no history copy (one version deep, only after upgrade)`)); return 1; }
|
|
16
17
|
if (!ctx.flags.dryRun) {
|
|
17
18
|
historyRestore(ctx.hub, name);
|
|
18
19
|
const dest = path.join(ctx.hub, 'skills', name);
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { scanAll } from '../lib/scanner.js';
|
|
3
3
|
import { searchRemote } from '../lib/registries/skillssh.js';
|
|
4
4
|
import { table, info, warn } from '../lib/render.js';
|
|
5
|
+
import { L } from '../lib/i18n.js';
|
|
5
6
|
|
|
6
7
|
export async function run(ctx) {
|
|
7
8
|
const query = ctx.args.join(' ').trim();
|
|
@@ -35,7 +36,7 @@ export async function run(ctx) {
|
|
|
35
36
|
if (wantRemote) {
|
|
36
37
|
info('');
|
|
37
38
|
info(`REMOTE ${remote.base || ''}`);
|
|
38
|
-
if (remoteErr) warn(`remote search failed: ${remoteErr}
|
|
39
|
+
if (remoteErr) warn(`remote search failed: ${remoteErr}${L('(本地结果可用)', ' (local results still shown)')}`);
|
|
39
40
|
else if (remote.skills.length) {
|
|
40
41
|
table(remote.skills.slice(0, 15).map((s) => ({ name: s.name, id: s.slug, installs: s.installs })),
|
|
41
42
|
[{ key: 'name', title: 'skill' }, { key: 'id', title: 'id' }, { key: 'installs', title: 'installs' }]);
|
package/client/commands/serve.js
CHANGED
|
@@ -14,6 +14,7 @@ import { probeEndpoints, chat, encryptSecret, resolveKeyRef } from '../lib/llm.j
|
|
|
14
14
|
import { projectSkill, unproject, targetDirFor } from '../lib/project.js';
|
|
15
15
|
import { treeHash } from '../lib/package.js';
|
|
16
16
|
import { ok, info } from '../lib/render.js';
|
|
17
|
+
import { L, detectLang } from '../lib/i18n.js';
|
|
17
18
|
|
|
18
19
|
const PUB = path.join(new URL('.', import.meta.url).pathname, '../public');
|
|
19
20
|
const MIME = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.png': 'image/png', '.svg': 'image/svg+xml' };
|
|
@@ -29,11 +30,7 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
|
|
|
29
30
|
const idleMs = (ctx.config.daemon?.idle_minutes ?? 30) * 60e3;
|
|
30
31
|
|
|
31
32
|
const harnesses = ctx.harnesses ?? detectHarnesses(); // bareRun/init 路径 ctx 可能没 withState
|
|
32
|
-
//
|
|
33
|
-
const detectLang = () => {
|
|
34
|
-
const l = (process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || '').toLowerCase();
|
|
35
|
-
return l.startsWith('zh') ? 'zh' : 'en';
|
|
36
|
-
};
|
|
33
|
+
// 界面默认语言跟终端 locale(SKILLMKT_LANG/LANG/LC_* 以 zh 开头→中文)
|
|
37
34
|
const state = () => ({
|
|
38
35
|
hub: ctx.hub,
|
|
39
36
|
lang: (() => readConfig(ctx.hub)._raw?.ui?.lang ?? detectLang())(),
|
|
@@ -58,9 +55,9 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
|
|
|
58
55
|
// 只记关键事件:打开网页 + 真正落盘的写操作;点击/读取/静态资源一律不打扰
|
|
59
56
|
const action = (req, u) => {
|
|
60
57
|
const p = u.pathname;
|
|
61
|
-
if (req.method === 'GET' && (p === '/' || p === '/index.html')) return '打开了网页';
|
|
62
|
-
if (req.method === 'POST' && p === '/api/config') return '保存了设置';
|
|
63
|
-
if (req.method === 'POST' && p === '/api/targets') return '修改了 skill 的安装位置';
|
|
58
|
+
if (req.method === 'GET' && (p === '/' || p === '/index.html')) return L('打开了网页', 'opened the page');
|
|
59
|
+
if (req.method === 'POST' && p === '/api/config') return L('保存了设置', 'saved settings');
|
|
60
|
+
if (req.method === 'POST' && p === '/api/targets') return L('修改了 skill 的安装位置', 'changed skill install locations');
|
|
64
61
|
return null;
|
|
65
62
|
};
|
|
66
63
|
|
|
@@ -70,8 +67,8 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
|
|
|
70
67
|
if (!quiet) res.on('finish', () => {
|
|
71
68
|
const a = req.logNote ?? action(req, u);
|
|
72
69
|
if (a == null) return;
|
|
73
|
-
const tail = res.statusCode === 401 ? '(被拒绝:链接已过期,重新打开)'
|
|
74
|
-
: res.statusCode >= 400 ? `(失败 ${res.statusCode}
|
|
70
|
+
const tail = res.statusCode === 401 ? L('(被拒绝:链接已过期,重新打开)', ' (rejected: link expired — reopen)')
|
|
71
|
+
: res.statusCode >= 400 ? L(`(失败 ${res.statusCode})`, ` (failed ${res.statusCode})`) : '';
|
|
75
72
|
console.log(` ${new Date().toTimeString().slice(0, 8)} ${a}${tail}`);
|
|
76
73
|
});
|
|
77
74
|
// auth:Bearer header 或 ?token=(SSE/img 用 query,服务端不下发 cookie)
|
|
@@ -96,7 +93,8 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
|
|
|
96
93
|
const c = loadConflicts(ctx.hub).find((x) => x.id === b.id);
|
|
97
94
|
if (!c) { res.writeHead(404); return res.end('{"error":"not found"}'); }
|
|
98
95
|
if (!b.reason?.trim()) { res.writeHead(400); return res.end('{"error":"reason required"}'); }
|
|
99
|
-
req.logNote = `裁决了一个冲突(${{ 'keep-a': '采用方案 A', 'keep-b': '采用方案 B', merge: '合并两条', dismissed: '其实不冲突' }[b.resolution] || b.resolution}
|
|
96
|
+
req.logNote = L(`裁决了一个冲突(${{ 'keep-a': '采用方案 A', 'keep-b': '采用方案 B', merge: '合并两条', dismissed: '其实不冲突' }[b.resolution] || b.resolution})`,
|
|
97
|
+
`decided a conflict (${{ 'keep-a': 'kept A', 'keep-b': 'kept B', merge: 'merged', dismissed: 'not a conflict' }[b.resolution] || b.resolution})`);
|
|
100
98
|
decide(ctx.hub, c, { resolution: b.resolution, custom: b.custom || null, reason: b.reason, by: 'web-ui' });
|
|
101
99
|
c.status = 'resolved';
|
|
102
100
|
const { writeConflict } = await import('../lib/conflicts.js');
|
|
@@ -142,7 +140,7 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
|
|
|
142
140
|
}
|
|
143
141
|
if (u.pathname === '/api/targets') { // web 改投影目标
|
|
144
142
|
const name = b.name, targets = b.targets || [];
|
|
145
|
-
req.logNote = `修改了「${name}
|
|
143
|
+
req.logNote = L(`修改了「${name}」的安装位置`, `changed install locations for "${name}"`);
|
|
146
144
|
const lib = readLibrary(ctx.hub);
|
|
147
145
|
const s = lib.skills?.[name];
|
|
148
146
|
if (!s) { res.writeHead(404); return res.end('{"error":"not found"}'); }
|
|
@@ -226,7 +224,7 @@ export async function run(ctx) {
|
|
|
226
224
|
const d = await startServer(ctx, { quiet: !!flags.daemon, port: flags.port || 0 });
|
|
227
225
|
if (flags.daemon) { console.log(`daemon ready :${d.port}`); await new Promise(() => {}); }
|
|
228
226
|
console.log(`serve: http://127.0.0.1:${d.port}/?token=${d.token}`);
|
|
229
|
-
console.log(` 前台运行 — Ctrl-C 退出(idle ${ctx.config.daemon?.idle_minutes ?? 30}m
|
|
227
|
+
console.log(L(` 前台运行 — Ctrl-C 退出(idle ${ctx.config.daemon?.idle_minutes ?? 30}m 自退)`, ` running in foreground — Ctrl-C to exit (idle ${ctx.config.daemon?.idle_minutes ?? 30}m auto-stop)`));
|
|
230
228
|
await new Promise(() => {});
|
|
231
229
|
return 0;
|
|
232
230
|
}
|
package/client/commands/sync.js
CHANGED
|
@@ -5,6 +5,7 @@ import { projectSkill, checkDrift, targetDirFor } from '../lib/project.js';
|
|
|
5
5
|
import { updateLock } from '../lib/hub.js';
|
|
6
6
|
import { confirm } from '../lib/prompt.js';
|
|
7
7
|
import { ok, warn, info } from '../lib/render.js';
|
|
8
|
+
import { L } from '../lib/i18n.js';
|
|
8
9
|
|
|
9
10
|
export async function run(ctx) {
|
|
10
11
|
const { library, lock } = ctx;
|
|
@@ -24,7 +25,7 @@ export async function run(ctx) {
|
|
|
24
25
|
const avail = ctx.harnesses.filter((h) => h.state === 'available' && !h.detectOnly
|
|
25
26
|
&& !ctx.config.default_targets.includes(h.id));
|
|
26
27
|
for (const h of avail) {
|
|
27
|
-
if (await confirm(`检测到新 harness ${h.id}(available)——纳入默认投影目标?`, { defaultYes: false })) {
|
|
28
|
+
if (await confirm(L(`检测到新 harness ${h.id}(available)——纳入默认投影目标?`, `New agent detected: ${h.id} (available) — add to default install locations?`), { defaultYes: false })) {
|
|
28
29
|
const raw = ctx.config._raw;
|
|
29
30
|
raw.default_targets = [...new Set([...(raw.default_targets || []), h.id])];
|
|
30
31
|
const { writeConfig } = await import('../lib/hub.js');
|
|
@@ -36,13 +37,13 @@ export async function run(ctx) {
|
|
|
36
37
|
let n = 0, repaired = 0;
|
|
37
38
|
for (const [name, s] of Object.entries(library.skills || {})) {
|
|
38
39
|
const src = path.join(ctx.hub, 'skills', name);
|
|
39
|
-
if (!fs.existsSync(src)) { warn(`${name}: hub
|
|
40
|
+
if (!fs.existsSync(src)) { warn(L(`${name}: hub 副本缺失`, `${name}: hub copy missing`)); continue; }
|
|
40
41
|
const lockTargets = {};
|
|
41
42
|
for (const t of s.targets || []) {
|
|
42
43
|
const dir = targetDirFor(ctx, t, name);
|
|
43
44
|
if (!dir) { warn(`${name}: unknown target ${t}`); continue; }
|
|
44
45
|
const r = projectSkill(src, name, dir, { mode: s.transport?.[t] === 'link' ? 'link' : 'copy', force: !!ctx.flags.raw.force });
|
|
45
|
-
if (r.action === 'conflict') warn(`${name} @ ${t}: ${r.detail}(手动改过的内容不覆盖——--force 强制重建,或改回后 sync
|
|
46
|
+
if (r.action === 'conflict') warn(`${name} @ ${t}: ${r.detail}${L('(手动改过的内容不覆盖——--force 强制重建,或改回后 sync)', ' (manual edits not overwritten — --force rebuilds, or revert then sync)')}`);
|
|
46
47
|
else if (r.action !== 'skipped') { repaired++; info(`${name} → ${r.action} ${r.target}`); }
|
|
47
48
|
lockTargets[t] = { hash: r.hash, projected_at: new Date().toISOString(), mode: r.mode };
|
|
48
49
|
n++;
|
|
@@ -7,6 +7,7 @@ import { updateLock } from '../lib/hub.js';
|
|
|
7
7
|
import { readSkillDir } from '../lib/package.js';
|
|
8
8
|
import { maybeHandoff } from '../lib/daemon.js';
|
|
9
9
|
import fs from 'node:fs';
|
|
10
|
+
import { L } from '../lib/i18n.js';
|
|
10
11
|
|
|
11
12
|
export async function run(ctx) {
|
|
12
13
|
const [sub, ...rest] = ctx.args;
|
|
@@ -69,7 +70,7 @@ export async function run(ctx) {
|
|
|
69
70
|
if (raw.targets?.[id]) { delete raw.targets[id]; writeConfig(ctx.hub, raw); ok(`custom target removed: ${id}`); return 0; }
|
|
70
71
|
raw.default_targets = (raw.default_targets || []).filter((t) => t !== id);
|
|
71
72
|
writeConfig(ctx.hub, raw);
|
|
72
|
-
ok(`${id} removed from default_targets(已投影副本保留——skillmkt sync
|
|
73
|
+
ok(`${id} removed from default_targets${L('(已投影副本保留——skillmkt sync 可清)', ' (projected copies kept — skillmkt sync can clean)')}`);
|
|
73
74
|
return 0;
|
|
74
75
|
}
|
|
75
76
|
|
|
@@ -5,6 +5,7 @@ import { remoteTree } from '../lib/registries/github.js';
|
|
|
5
5
|
import { setUpstream, readUpstream, writeUpstream } from '../lib/state.js';
|
|
6
6
|
import { gitTreeHash } from '../lib/githash.js';
|
|
7
7
|
import { ok, warn, info } from '../lib/render.js';
|
|
8
|
+
import { L } from '../lib/i18n.js';
|
|
8
9
|
|
|
9
10
|
export async function run(ctx) {
|
|
10
11
|
const skills = ctx.library.skills || {};
|
|
@@ -12,7 +13,7 @@ export async function run(ctx) {
|
|
|
12
13
|
let n = 0, na = 0, errs = 0;
|
|
13
14
|
for (const name of names) {
|
|
14
15
|
const s = skills[name];
|
|
15
|
-
if (!s) { warn(`未受管: ${name}`); continue; }
|
|
16
|
+
if (!s) { warn(L(`未受管: ${name}`, `not managed: ${name}`)); continue; }
|
|
16
17
|
const src = s.source || {};
|
|
17
18
|
if (src.registry !== 'github' || !src.ref) { na++; continue; } // adopted/local/rfc 无远端可查(rfc 走 registry 适配后续)
|
|
18
19
|
try {
|
|
@@ -9,6 +9,7 @@ import { projectSkill, targetDirFor } from '../lib/project.js';
|
|
|
9
9
|
import { registerSkill, updateLock } from '../lib/hub.js';
|
|
10
10
|
import { fetchMirror } from '../lib/registries/index.js';
|
|
11
11
|
import { ok, warn, fail, info } from '../lib/render.js';
|
|
12
|
+
import { L } from '../lib/i18n.js';
|
|
12
13
|
|
|
13
14
|
function copyFiltered(src, dst, keep) {
|
|
14
15
|
fs.mkdirSync(dst, { recursive: true });
|
|
@@ -31,11 +32,11 @@ export async function run(ctx) {
|
|
|
31
32
|
let upgraded = 0;
|
|
32
33
|
for (const name of names) {
|
|
33
34
|
const s = skills[name];
|
|
34
|
-
if (!s) { warn(`未受管: ${name}`); continue; }
|
|
35
|
+
if (!s) { warn(L(`未受管: ${name}`, `not managed: ${name}`)); continue; }
|
|
35
36
|
const u = up.skills?.[name];
|
|
36
|
-
if (!u?.outdated && !flags.force) { info(`${name}: clean(update
|
|
37
|
+
if (!u?.outdated && !flags.force) { info(L(`${name}: clean(update 先刷新)`, `${name}: clean (run update first to refresh)`)); continue; }
|
|
37
38
|
const src = s.source || {};
|
|
38
|
-
if (src.registry !== 'github' || !src.ref) { warn(`${name}:
|
|
39
|
+
if (src.registry !== 'github' || !src.ref) { warn(L(`${name}: 无上游可升级`, `${name}: no upstream to upgrade from`)); continue; }
|
|
39
40
|
|
|
40
41
|
const [owner, repo] = src.ref.split('/');
|
|
41
42
|
info(`${name}: fetching ${src.ref} …`);
|
|
@@ -43,7 +44,7 @@ export async function run(ctx) {
|
|
|
43
44
|
const got = await fetchSkill({ owner, repo, ref: null, path: src.path || null, mirror: fetchMirror(ctx) });
|
|
44
45
|
const pkg = readSkillDir(got.dir);
|
|
45
46
|
const audit = auditDir(got.dir, { strip: !flags.keepScripts });
|
|
46
|
-
if (audit.verdict === 'malicious') { warn(`${name}: 新版审核 malicious——保留旧版(quarantine
|
|
47
|
+
if (audit.verdict === 'malicious') { warn(L(`${name}: 新版审核 malicious——保留旧版(quarantine 不收新版)`, `${name}: new version audited malicious — keeping old version`)); continue; }
|
|
47
48
|
if (ctx.flags.dryRun) {
|
|
48
49
|
info(`[dry-run] ${name}: ${pkg?.fileCount ?? '?'} files, audit:${audit.verdict}${audit.stripped.length ? `,strip ${audit.stripped.length}` : ''}`);
|
|
49
50
|
continue;
|
package/client/lib/ctx.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { hubPath, readConfig, readLibrary, readLock, expandHome } from './hub.js';
|
|
3
3
|
import { detectHarnesses, detectProject } from './scanner.js';
|
|
4
4
|
import { resolveLLM } from './llm.js';
|
|
5
|
+
import { setUILang } from './i18n.js';
|
|
5
6
|
|
|
6
7
|
const VALUE_FLAGS = new Set(['hub', 'base-url', 'model', 'api-key-env', 'from', 'to', 'target', 'scope', 'path', 'registry', 'name', 'resolution', 'reason', 'custom', 'port', 'project', 'type', 'url', 'token', 'out', 'limit']);
|
|
7
8
|
const BOOL_FLAGS = new Set(['json', 'verbose', 'no-llm', 'dry-run', 'ui', 'cli', 'no-ui', 'yes', 'y', 'help', 'h', 'version', 'V', 'force', 'all', 'llm', 'semantic', 'raw', 'files', 'rules', 'audit-only', 'purge', 'link', 'remote', 'local', 'wait', 'stop', 'daemon', 'keep-scripts', 'report', 'check', 'once']);
|
|
@@ -44,6 +45,7 @@ export function makeCtx(argv, { wantProject = true } = {}) {
|
|
|
44
45
|
const { flags, positional } = parseArgv(argv);
|
|
45
46
|
const hub = hubPath(flags.hub);
|
|
46
47
|
const config = readConfig(hub);
|
|
48
|
+
setUILang(config.ui?.lang); // CLI 输出语言:config.ui.lang > 终端 locale
|
|
47
49
|
const cwd = process.cwd();
|
|
48
50
|
const ctx = {
|
|
49
51
|
flags,
|
package/client/lib/daemon.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import fs from 'node:fs';
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { execFileSync } from 'node:child_process';
|
|
5
|
+
import { L } from './i18n.js';
|
|
5
6
|
|
|
6
7
|
export const daemonFile = (hub) => path.join(hub, 'daemon.json');
|
|
7
8
|
export const pidAlive = (pid) => { try { process.kill(pid, 0); return true; } catch { return false; } };
|
|
@@ -26,14 +27,14 @@ export async function maybeHandoff(ctx, route = '/') {
|
|
|
26
27
|
if (ctx.config?.ui?.enabled === 'never' || ctx.config?.ui?.enabled === false) return false;
|
|
27
28
|
const d = readDaemon(ctx.hub);
|
|
28
29
|
if (d && pidAlive(d.pid)) {
|
|
29
|
-
console.log(`opened ${openURL(d, route)}(服务已在跑,Ctrl-C 那个终端的 serve
|
|
30
|
+
console.log(`opened ${openURL(d, route)}${L('(服务已在跑,Ctrl-C 那个终端的 serve 可停)', ' (server already running — the serve in that terminal can be stopped)')}`);
|
|
30
31
|
return true;
|
|
31
32
|
}
|
|
32
33
|
try {
|
|
33
34
|
const { startServer } = await import('../commands/serve.js');
|
|
34
35
|
const srv = await startServer(ctx, { quiet: false });
|
|
35
36
|
console.log(`opened ${openURL({ port: srv.port, token: srv.token }, route)}`);
|
|
36
|
-
console.log(' 服务前台运行中 — 操作日志见下方,Ctrl-C 退出');
|
|
37
|
+
console.log(L(' 服务前台运行中 — 操作日志见下方,Ctrl-C 退出', ' server running in foreground — activity log below, Ctrl-C to exit'));
|
|
37
38
|
await new Promise(() => {}); // 挂住:本进程=服务器
|
|
38
39
|
return true;
|
|
39
40
|
} catch { return false; }
|
package/client/lib/hub.js
CHANGED
|
@@ -82,7 +82,7 @@ export function readConfig(hub) {
|
|
|
82
82
|
const cfg = readYAMLFile(F(hub, 'config.yml'), {}) || {};
|
|
83
83
|
return {
|
|
84
84
|
llm: cfg.llm || null,
|
|
85
|
-
ui: { enabled: cfg.ui?.enabled ?? 'auto' },
|
|
85
|
+
ui: { enabled: cfg.ui?.enabled ?? 'auto', lang: cfg.ui?.lang },
|
|
86
86
|
policy: cfg.policy ?? 'balanced',
|
|
87
87
|
default_targets: cfg.default_targets ?? [],
|
|
88
88
|
targets: cfg.targets ?? {},
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// i18n.js — CLI 双语:config ui.lang > 终端 locale(SKILLMKT_LANG 可强制)> en
|
|
2
|
+
// 用法:L('中文', 'English')——字符串留在调用点,不建大字典
|
|
3
|
+
let override = null;
|
|
4
|
+
export const setUILang = (v) => { override = (v === 'zh' || v === 'en') ? v : null; };
|
|
5
|
+
export const detectLang = () => {
|
|
6
|
+
const l = (process.env.SKILLMKT_LANG || process.env.LC_ALL || process.env.LC_MESSAGES || process.env.LANG || '').toLowerCase();
|
|
7
|
+
return l.startsWith('zh') ? 'zh' : 'en';
|
|
8
|
+
};
|
|
9
|
+
export const lang = () => {
|
|
10
|
+
const forced = (process.env.SKILLMKT_LANG || '').toLowerCase().slice(0, 2);
|
|
11
|
+
if (forced === 'en' || forced === 'zh') return forced; // 显式强制 > config
|
|
12
|
+
return override ?? detectLang();
|
|
13
|
+
};
|
|
14
|
+
export const L = (zh, en) => (lang() === 'en' ? en : zh);
|
package/client/lib/llm.js
CHANGED
|
@@ -5,6 +5,7 @@ import path from 'node:path';
|
|
|
5
5
|
import os from 'node:os';
|
|
6
6
|
import crypto from 'node:crypto';
|
|
7
7
|
import { execFileSync } from 'node:child_process';
|
|
8
|
+
import { L } from './i18n.js';
|
|
8
9
|
|
|
9
10
|
function loadDotEnv(file) {
|
|
10
11
|
try {
|
|
@@ -138,7 +139,7 @@ async function identifyImpl(port, timeoutMs) {
|
|
|
138
139
|
};
|
|
139
140
|
if ((await get('/api/version'))?.version) return 'Ollama'; // Ollama 原生 API
|
|
140
141
|
if (await get('/api/v0/models')) return 'LM Studio API'; // 说 LM Studio 协议——也可能是 oMLX 等兼容实现
|
|
141
|
-
return 'OpenAI 兼容服务';
|
|
142
|
+
return L('OpenAI 兼容服务', 'OpenAI-compatible service');
|
|
142
143
|
}
|
|
143
144
|
|
|
144
145
|
// 仅 init/config 使用——候选端口 = 常见端口 ∪ 本机全部监听端口 ∪ env/config 已知 base_url 端口,
|
package/client/lib/project.js
CHANGED
|
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import path from 'node:path';
|
|
4
4
|
import { treeHash, copyDir, rmDir, readSkillDir } from './package.js';
|
|
5
5
|
import { primaryDir } from './scanner.js';
|
|
6
|
+
import { L } from './i18n.js';
|
|
6
7
|
|
|
7
8
|
// 投影单个 skill 到目标目录 → {target, hash, action}
|
|
8
9
|
export function projectSkill(srcDir, name, targetDir, { mode = 'copy', dryRun = false, force = false, lockEntry = null } = {}) {
|
|
@@ -65,10 +66,10 @@ export function targetDirFor(ctx, target, _name) {
|
|
|
65
66
|
// 解析目标集:--to/--target/--scope/default_targets
|
|
66
67
|
export function resolveTargets(ctx, { allowAdopted = null } = {}) {
|
|
67
68
|
const f = ctx.flags.raw;
|
|
68
|
-
if (f.to && f.target) throw new Error('--to 与 --target 互斥');
|
|
69
|
+
if (f.to && f.target) throw new Error(L('--to 与 --target 互斥', '--to and --target are mutually exclusive'));
|
|
69
70
|
if (f.to) return [{ id: `custom:${path.resolve(expandTilde(f.to))}`, dir: path.resolve(expandTilde(f.to)), mode: f.link ? 'link' : 'copy' }];
|
|
70
71
|
if (f.scope === 'project' || f.scope === 'repo') {
|
|
71
|
-
if (!ctx.project) throw new Error('--scope project 需在仓库目录内运行');
|
|
72
|
+
if (!ctx.project) throw new Error(L('--scope project 需在仓库目录内运行', '--scope project must run inside a repo directory'));
|
|
72
73
|
const out = [];
|
|
73
74
|
for (const h of ctx.harnesses) {
|
|
74
75
|
if (h.detectOnly) continue;
|
package/client/lib/prompt.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// prompt.js — TTY 确认/选择(非 TTY 一律安全默认)
|
|
2
2
|
import readline from 'node:readline';
|
|
3
|
+
import { L } from './i18n.js';
|
|
3
4
|
|
|
4
5
|
export async function confirm(question, { defaultYes = false } = {}) {
|
|
5
6
|
if (!process.stdin.isTTY) return defaultYes;
|
|
@@ -25,7 +26,7 @@ export async function choose(question, options) {
|
|
|
25
26
|
export async function multiChoose(question, options, { checked = [] } = {}) {
|
|
26
27
|
if (!process.stdin.isTTY) return checked;
|
|
27
28
|
const rl = readline.createInterface({ input: process.stdin, output: process.stderr });
|
|
28
|
-
process.stderr.write(`${question}(序号逗号分隔,回车=当前勾选,0
|
|
29
|
+
process.stderr.write(`${question}${L('(序号逗号分隔,回车=当前勾选,0=全不装)', ' (comma-separated numbers, Enter = keep checked, 0 = none)')}\n`);
|
|
29
30
|
options.forEach((o, i) => process.stderr.write(` ${checked.includes(i) ? '[x]' : '[ ]'} ${i + 1}. ${o.label || o}\n`));
|
|
30
31
|
const ans = await new Promise((res) => rl.question('> ', res));
|
|
31
32
|
rl.close();
|
|
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { execFileSync } from 'node:child_process';
|
|
6
|
+
import { L } from '../i18n.js';
|
|
6
7
|
import { treeHash, copyDir } from '../package.js';
|
|
7
8
|
|
|
8
9
|
const sh = (cmd, args) => execFileSync(cmd, args, { encoding: 'utf8', stdio: ['ignore', 'pipe', 'pipe'] }).trim();
|
|
@@ -49,7 +50,7 @@ async function fetchTarball(owner, repo, ref, { mirror = null } = {}) {
|
|
|
49
50
|
export async function fetchSkill({ owner, repo, ref = null, path: sub = null, mirror = null }) {
|
|
50
51
|
const sha = headSha(owner, repo, ref) || ref || 'HEAD';
|
|
51
52
|
const got = await fetchTarball(owner, repo, sha, { mirror });
|
|
52
|
-
if (!got) throw new Error(`fetch failed: ${owner}/${repo}@${sha}
|
|
53
|
+
if (!got) throw new Error(`fetch failed: ${owner}/${repo}@${sha}${L('(直连与镜像均不可达)', ' (direct and mirror both unreachable)')}`);
|
|
53
54
|
execFileSync('tar', ['xzf', got.tar, '-C', got.tmp]);
|
|
54
55
|
const root = fs.readdirSync(got.tmp).find((d) => d.startsWith(`${owner.replace(/\W/g, '')}`) || d.includes('-'))
|
|
55
56
|
?? fs.readdirSync(got.tmp).find((d) => fs.statSync(path.join(got.tmp, d)).isDirectory());
|
|
@@ -60,7 +61,7 @@ export async function fetchSkill({ owner, repo, ref = null, path: sub = null, mi
|
|
|
60
61
|
const cands = [sub, `skills/${sub}`, ...topDirs.map((d) => `${d}/${sub}`)];
|
|
61
62
|
const hit = cands.find((c) => fs.existsSync(path.join(dir, c, 'SKILL.md')))
|
|
62
63
|
?? cands.find((c) => fs.existsSync(path.join(dir, c)));
|
|
63
|
-
if (!hit) throw new Error(`repo 内找不到: ${sub}(试了 ${cands.slice(0, 4).join(', ')}
|
|
64
|
+
if (!hit) throw new Error(L(`repo 内找不到: ${sub}(试了 ${cands.slice(0, 4).join(', ')} …)`, `not found in repo: ${sub} (tried ${cands.slice(0, 4).join(', ')} …)`));
|
|
64
65
|
dir = path.join(dir, hit);
|
|
65
66
|
}
|
|
66
67
|
return {
|
|
@@ -2,12 +2,13 @@
|
|
|
2
2
|
import * as github from './github.js';
|
|
3
3
|
import * as skillssh from './skillssh.js';
|
|
4
4
|
import * as rfc from './rfc.js';
|
|
5
|
+
import { L } from '../i18n.js';
|
|
5
6
|
|
|
6
7
|
export const ADAPTERS = { github, skillssh, rfc, clawhub: null };
|
|
7
8
|
|
|
8
9
|
export function adapterFor(type) {
|
|
9
10
|
const a = ADAPTERS[type];
|
|
10
|
-
if (!a) throw new Error(`registry adapter 未实现: ${type}
|
|
11
|
+
if (!a) throw new Error(L(`registry adapter 未实现: ${type}(二期)`, `registry adapter not implemented: ${type} (phase 2)`));
|
|
11
12
|
return a;
|
|
12
13
|
}
|
|
13
14
|
|
|
@@ -23,15 +24,15 @@ export async function fetchRef(ref, ctx) {
|
|
|
23
24
|
}
|
|
24
25
|
if (ref.kind === 'named' && (!ref.registry || ref.registry === 'skillssh' || ref.registry === 'github')) {
|
|
25
26
|
const coord = await skillssh.resolveNamed(ref.name, ctx);
|
|
26
|
-
if (!coord) throw new Error(`skills.sh 索引未收录: ${ref.name}——可试 skillmkt install owner/repo
|
|
27
|
+
if (!coord) throw new Error(L(`skills.sh 索引未收录: ${ref.name}——可试 skillmkt install owner/repo 直指`, `not in the skills.sh index: ${ref.name} — try skillmkt install owner/repo`));
|
|
27
28
|
return github.fetchSkill({ ...coord, ref: null, mirror });
|
|
28
29
|
}
|
|
29
30
|
if (ref.registry) {
|
|
30
31
|
const reg = ctx.config.registries.find((r) => (r.name || r.type) === ref.registry);
|
|
31
|
-
if (!reg) throw new Error(`未配置 registry: ${ref.registry}`);
|
|
32
|
+
if (!reg) throw new Error(L(`未配置 registry: ${ref.registry}`, `registry not configured: ${ref.registry}`));
|
|
32
33
|
const a = adapterFor(reg.type);
|
|
33
|
-
if (!a.fetchSkill) throw new Error(`registry ${reg.type} 不支持 fetch`);
|
|
34
|
+
if (!a.fetchSkill) throw new Error(L(`registry ${reg.type} 不支持 fetch`, `registry ${reg.type} does not support fetch`));
|
|
34
35
|
return a.fetchSkill(ref, ctx, reg);
|
|
35
36
|
}
|
|
36
|
-
throw new Error(`无法解析引用: ${JSON.stringify(ref)}`);
|
|
37
|
+
throw new Error(L(`无法解析引用: ${JSON.stringify(ref)}`, `cannot resolve ref: ${JSON.stringify(ref)}`));
|
|
37
38
|
}
|
|
@@ -3,6 +3,7 @@ import fs from 'node:fs';
|
|
|
3
3
|
import os from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import crypto from 'node:crypto';
|
|
6
|
+
import { L } from '../i18n.js';
|
|
6
7
|
import { execFileSync } from 'node:child_process';
|
|
7
8
|
|
|
8
9
|
export async function fetchIndex(reg) {
|
|
@@ -23,7 +24,7 @@ export async function search(query, ctx, reg) {
|
|
|
23
24
|
export async function fetchSkill(ref, ctx, reg) {
|
|
24
25
|
const entries = await fetchIndex(reg);
|
|
25
26
|
const entry = entries.find((e) => e.name === ref.name);
|
|
26
|
-
if (!entry) throw new Error(`rfc index 无此 skill: ${ref.name}`);
|
|
27
|
+
if (!entry) throw new Error(L(`rfc index 无此 skill: ${ref.name}`, `skill not in rfc index: ${ref.name}`));
|
|
27
28
|
const res = await fetch(entry.url, { signal: AbortSignal.timeout(20000) });
|
|
28
29
|
if (!res.ok) throw new Error(`rfc fetch ${res.status}: ${entry.url}`);
|
|
29
30
|
const buf = Buffer.from(await res.arrayBuffer());
|
package/client/lib/render.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// render.js — 终端表格/卡片/仪表盘;装饰全走 stderr,--json 时 stdout 纯数据
|
|
2
|
+
import { L } from './i18n.js';
|
|
2
3
|
const err = (...a) => console.error(...a);
|
|
3
4
|
|
|
4
5
|
export function table(rows, cols) {
|
|
@@ -41,13 +42,13 @@ export function dashboard({ hub, library, scan, upstream, conflicts, llm, projec
|
|
|
41
42
|
.map((h) => `${h.id}${h.state === 'installed' ? '●' : h.state === 'available' ? '○available' : '~likely'}`);
|
|
42
43
|
if (hs.length) err(`harnesses ${hs.join(' ')}`);
|
|
43
44
|
if (project) err(`project ${project.root}`);
|
|
44
|
-
if (pending) err(`conflicts ${pending} pending —
|
|
45
|
-
if (externals) err(`external ${externals} 未收编 — install <path>
|
|
45
|
+
if (pending) err(`conflicts ${pending} pending — ${L('需要裁决', 'needs your decision')}`);
|
|
46
|
+
if (externals) err(`external ${externals} ${L('未收编 — install <path> 纳入管理', 'unmanaged — `install <path>` to adopt')}`);
|
|
46
47
|
err('');
|
|
47
48
|
const hints = [];
|
|
48
|
-
if (pending) hints.push('skillmkt conflicts --ui 裁决冲突(开面板看图)');
|
|
49
|
-
if (updates) hints.push('skillmkt outdated 看可更新项');
|
|
50
|
-
if (externals) hints.push('skillmkt list 查看 ◌external 路径');
|
|
51
|
-
hints.push('skillmkt list 安装矩阵', 'skillmkt --help 全部命令');
|
|
49
|
+
if (pending) hints.push(L('skillmkt conflicts --ui 裁决冲突(开面板看图)', 'skillmkt conflicts --ui decide conflicts (visual panel)'));
|
|
50
|
+
if (updates) hints.push(L('skillmkt outdated 看可更新项', 'skillmkt outdated view updates'));
|
|
51
|
+
if (externals) hints.push(L('skillmkt list 查看 ◌external 路径', 'skillmkt list view ◌external paths'));
|
|
52
|
+
hints.push(L('skillmkt list 安装矩阵', 'skillmkt list install matrix'), L('skillmkt --help 全部命令', 'skillmkt --help all commands'));
|
|
52
53
|
hints.slice(0, 4).forEach((h) => err(h));
|
|
53
54
|
}
|