skillmkt 0.3.16 → 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.
@@ -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,8 +30,10 @@ 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
33
+ // 界面默认语言跟终端 locale(SKILLMKT_LANG/LANG/LC_* 以 zh 开头→中文)
32
34
  const state = () => ({
33
35
  hub: ctx.hub,
36
+ lang: (() => readConfig(ctx.hub)._raw?.ui?.lang ?? detectLang())(),
34
37
  initialized: (() => { const r = readConfig(ctx.hub)._raw; return !!(r.ui || r.llm || r.default_targets); })(),
35
38
  library: readLibrary(ctx.hub), lock: readLock(ctx.hub),
36
39
  upstream: readUpstream(ctx.hub), conflicts: loadConflicts(ctx.hub),
@@ -52,9 +55,9 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
52
55
  // 只记关键事件:打开网页 + 真正落盘的写操作;点击/读取/静态资源一律不打扰
53
56
  const action = (req, u) => {
54
57
  const p = u.pathname;
55
- if (req.method === 'GET' && (p === '/' || p === '/index.html')) return '打开了网页';
56
- if (req.method === 'POST' && p === '/api/config') return '保存了设置';
57
- 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');
58
61
  return null;
59
62
  };
60
63
 
@@ -64,8 +67,8 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
64
67
  if (!quiet) res.on('finish', () => {
65
68
  const a = req.logNote ?? action(req, u);
66
69
  if (a == null) return;
67
- const tail = res.statusCode === 401 ? '(被拒绝:链接已过期,重新打开)'
68
- : 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})`) : '';
69
72
  console.log(` ${new Date().toTimeString().slice(0, 8)} ${a}${tail}`);
70
73
  });
71
74
  // auth:Bearer header 或 ?token=(SSE/img 用 query,服务端不下发 cookie)
@@ -90,7 +93,8 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
90
93
  const c = loadConflicts(ctx.hub).find((x) => x.id === b.id);
91
94
  if (!c) { res.writeHead(404); return res.end('{"error":"not found"}'); }
92
95
  if (!b.reason?.trim()) { res.writeHead(400); return res.end('{"error":"reason required"}'); }
93
- 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})`);
94
98
  decide(ctx.hub, c, { resolution: b.resolution, custom: b.custom || null, reason: b.reason, by: 'web-ui' });
95
99
  c.status = 'resolved';
96
100
  const { writeConflict } = await import('../lib/conflicts.js');
@@ -109,7 +113,7 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
109
113
  }
110
114
  raw.llm = b.llm;
111
115
  }
112
- if (b.ui !== undefined) raw.ui = b.ui;
116
+ if (b.ui !== undefined) raw.ui = { ...(raw.ui || {}), ...b.ui }; // 合并——写 lang 不抹掉 enabled
113
117
  if (b.default_targets !== undefined) raw.default_targets = b.default_targets;
114
118
  if (b.policy) raw.policy = b.policy;
115
119
  writeConfig(ctx.hub, raw);
@@ -136,7 +140,7 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
136
140
  }
137
141
  if (u.pathname === '/api/targets') { // web 改投影目标
138
142
  const name = b.name, targets = b.targets || [];
139
- req.logNote = `修改了「${name}」的安装位置`;
143
+ req.logNote = L(`修改了「${name}」的安装位置`, `changed install locations for "${name}"`);
140
144
  const lib = readLibrary(ctx.hub);
141
145
  const s = lib.skills?.[name];
142
146
  if (!s) { res.writeHead(404); return res.end('{"error":"not found"}'); }
@@ -220,7 +224,7 @@ export async function run(ctx) {
220
224
  const d = await startServer(ctx, { quiet: !!flags.daemon, port: flags.port || 0 });
221
225
  if (flags.daemon) { console.log(`daemon ready :${d.port}`); await new Promise(() => {}); }
222
226
  console.log(`serve: http://127.0.0.1:${d.port}/?token=${d.token}`);
223
- 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)`));
224
228
  await new Promise(() => {});
225
229
  return 0;
226
230
  }
@@ -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 副本缺失`); continue; }
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 先刷新)`); continue; }
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}: 无上游可升级`); continue; }
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 不收新版)`); continue; }
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,
@@ -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 端口,
@@ -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;
@@ -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=全不装)\n`);
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());
@@ -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
  }