skillmkt 0.4.31 → 0.4.33

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.
@@ -3,6 +3,7 @@
3
3
  import { makeCtx, withState, KNOWN_FLAGS } from '../lib/ctx.js';
4
4
  import { hubExists, isInitialized } from '../lib/hub.js';
5
5
  import { L } from '../lib/i18n.js';
6
+ import { commandHelp } from '../lib/help.js';
6
7
 
7
8
  const COMMANDS = {
8
9
  init: 'init', config: 'config', doctor: 'doctor',
@@ -67,7 +68,11 @@ async function main() {
67
68
  if (!KNOWN_FLAGS.has(k)) console.error(`${L('⚠ 未知 flag,已忽略', 'warning: unknown flag ignored')}: --${kebab(k)}`);
68
69
  }
69
70
 
70
- if (ctx.flags.raw.help || ctx.flags.raw.h) { console.log(L(HELP_ZH, HELP)); process.exit(0); }
71
+ if (ctx.flags.raw.help || ctx.flags.raw.h) {
72
+ const name = cmd && COMMANDS[cmd];
73
+ console.log((name && commandHelp(name)) || L(HELP_ZH, HELP));
74
+ process.exit(0);
75
+ }
71
76
  if (ctx.flags.raw.version || ctx.flags.raw.V) {
72
77
  const pkg = (await import('../../package.json', { with: { type: 'json' } })).default;
73
78
  console.log(pkg.version);
@@ -103,11 +103,12 @@ export async function run(ctx) {
103
103
  fail(L(`判定为恶意——已隔离: ${name}(${audit.findings.length} 处发现)`, `malicious — quarantined: ${name} (${audit.findings.length} findings)`));
104
104
  return 2;
105
105
  }
106
- if (audit.verdict === 'suspicious' && ctx.config.policy !== 'permissive') {
106
+ const policy = flags.policy || ctx.config.policy;
107
+ if (audit.verdict === 'suspicious' && policy !== 'permissive') {
107
108
  warn(L(`可疑:发现 ${audit.findings.length} 处${audit.stripped.length ? `,已剔除 ${audit.stripped.length} 个文件` : ''}`, `suspicious: ${audit.findings.length} findings${audit.stripped.length ? `, stripping ${audit.stripped.length} files` : ''}`));
108
109
  audit.findings.slice(0, 5).forEach((f) => info(`${f.rule} ${f.file}:${f.line} — ${f.excerpt.slice(0, 80)}`));
109
110
  // --yes 不放大 suspicious(安全默认);strict 直接拒
110
- const proceed = ctx.config.policy === 'strict' ? false : await confirm(L(`继续安装 ${name}?`, `Install ${name} anyway?`), { defaultYes: false });
111
+ const proceed = policy === 'strict' ? false : await confirm(L(`继续安装 ${name}?`, `Install ${name} anyway?`), { defaultYes: false });
111
112
  if (!proceed) { fail(L('已取消', 'install aborted')); return 2; }
112
113
  }
113
114
 
@@ -9,16 +9,26 @@ import { loadDecisions, decide } from '../lib/decide.js';
9
9
  import { readLibrary, readLock, readConfig, writeConfig, registerSkill, updateLock, ensureHub, isInitialized } from '../lib/hub.js';
10
10
  import { readUpstream } from '../lib/state.js';
11
11
  import { readYAML } from '../../pipeline/lib/util.js';
12
- import { detectHarnesses } from '../lib/scanner.js';
12
+ import { detectHarnesses, scanAll } from '../lib/scanner.js';
13
13
  import { probeEndpoints, chat, encryptSecret, resolveKeyRef, listModels } from '../lib/llm.js';
14
14
  import { projectSkill, unproject, targetDirFor } from '../lib/project.js';
15
- import { treeHash } from '../lib/package.js';
15
+ import { readSkillDir, treeHash } from '../lib/package.js';
16
+ import { searchRemote } from '../lib/registries/skillssh.js';
17
+ import { execFile } from 'node:child_process';
16
18
  import { ok, info } from '../lib/render.js';
17
19
  import { L, detectLang } from '../lib/i18n.js';
18
20
 
19
21
  const PUB = path.join(new URL('.', import.meta.url).pathname, '../public');
22
+ const CLI = path.join(new URL('.', import.meta.url).pathname, '../bin/skillmkt.js');
20
23
  const MIME = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css', '.png': 'image/png', '.svg': 'image/svg+xml' };
21
24
 
25
+ // CLI 子进程复用——装/删/合并/升级等操作走同一套实现,不复制逻辑
26
+ // '--' 隔开 flag 与用户输入,防 -开头的 ref 被当 flag 解析
27
+ const cli = (args, timeout = 180e3) => new Promise((r) => {
28
+ execFile(process.execPath, [CLI, ...args], { timeout, env: { ...process.env, CI: '1' } },
29
+ (e, stdout, stderr) => r({ code: e ? (typeof e.code === 'number' ? e.code : 1) : 0, out: `${stdout || ''}${stderr || ''}`.trim() }));
30
+ });
31
+
22
32
  // startServer — 可复用:serve 命令与 CLI 接管共用。返回 {port, token, server, emit, shutdown}
23
33
  export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
24
34
  ensureHub(ctx.hub);
@@ -41,6 +51,13 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
41
51
  scans: fs.existsSync(path.join(ctx.hub, 'scans'))
42
52
  ? fs.readdirSync(path.join(ctx.hub, 'scans')).sort().map((f) => readYAML(path.join(ctx.hub, 'scans', f))).filter(Boolean)
43
53
  : [],
54
+ merged: (() => {
55
+ const f = path.join(ctx.hub, 'merged', 'rules.yml');
56
+ if (!fs.existsSync(f)) return null;
57
+ const y = readYAML(f) || {};
58
+ return { name: y.name, sources: y.sources || [], rules: (y.rules || []).length,
59
+ built: fs.existsSync(path.join(ctx.hub, 'merged', 'skill-out', 'SKILL.md')) };
60
+ })(),
44
61
  });
45
62
 
46
63
  const routes = {
@@ -49,6 +66,17 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
49
66
  'GET /api/decisions': () => loadDecisions(ctx.hub),
50
67
  'GET /api/config': () => readConfig(ctx.hub)._raw,
51
68
  'GET /api/probe': async () => probeEndpoints(400, { extraBases: [readConfig(ctx.hub).llm?.base_url] }),
69
+ 'GET /api/search': async (u) => { const q = u.searchParams.get('q') || ''; return q ? searchRemote(q, ctx) : { skills: [] }; },
70
+ 'GET /api/scan': () => scanAll(ctx.hub, harnesses, readLibrary(ctx.hub), null)
71
+ .filter((r) => r.state === 'external')
72
+ .map((r) => ({ name: r.name, dir: r.targetDir || '', path: r.path, where: r.where, version: r.version, description: r.description || '' })),
73
+ 'GET /api/skill': (u) => {
74
+ const n = u.searchParams.get('name') || '';
75
+ if (!n || n.includes('/') || n.includes('..')) return { error: 'bad name' };
76
+ const pkg = readSkillDir(path.join(ctx.hub, 'skills', n));
77
+ return pkg ? { ...pkg, library: readLibrary(ctx.hub).skills?.[n] || null } : { error: 'not found' };
78
+ },
79
+ 'GET /api/diff': async (u) => cli(['diff', '--', u.searchParams.get('name') || '']),
52
80
  };
53
81
  const body = (req) => new Promise((r) => { let b = ''; req.on('data', (c) => b += c); req.on('end', () => r(b || '{}')); });
54
82
 
@@ -58,6 +86,15 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
58
86
  if (req.method === 'GET' && (p === '/' || p === '/index.html')) return L('打开了网页', 'opened the page');
59
87
  if (req.method === 'POST' && p === '/api/config') return L('保存了设置', 'saved settings');
60
88
  if (req.method === 'POST' && p === '/api/targets') return L('修改了 skill 的安装位置', 'changed skill install locations');
89
+ if (req.method === 'POST' && p === '/api/install') return L('安装了 skill', 'installed a skill');
90
+ if (req.method === 'POST' && p === '/api/remove') return L('移除了 skill', 'removed a skill');
91
+ if (req.method === 'POST' && p === '/api/merge') return L('合并了 skill', 'merged skills');
92
+ if (req.method === 'POST' && p === '/api/build') return L('生成了合并产物', 'built merged skill');
93
+ if (req.method === 'POST' && p === '/api/update') return L('刷新了上游信息', 'refreshed upstream info');
94
+ if (req.method === 'POST' && p === '/api/upgrade') return L('升级了 skill', 'upgraded skills');
95
+ if (req.method === 'POST' && p === '/api/sync') return L('修复了投影', 'repaired projections');
96
+ if (req.method === 'POST' && p === '/api/audit') return L('重新审核了 skill', 're-audited a skill');
97
+ if (req.method === 'POST' && p === '/api/rollback') return L('回滚了 skill', 'rolled back a skill');
61
98
  return null;
62
99
  };
63
100
 
@@ -157,12 +194,65 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
157
194
  emit('targets', { name });
158
195
  return res.end('{"ok":true}');
159
196
  }
197
+ if (u.pathname === '/api/install') {
198
+ const args = ['install', '--yes'];
199
+ if (b.path) args.push('--path', String(b.path));
200
+ if (b.permissive) args.push('--policy', 'permissive');
201
+ args.push('--', String(b.ref || ''));
202
+ const r = await cli(args);
203
+ emit('library', {});
204
+ return res.end(JSON.stringify(r));
205
+ }
206
+ if (u.pathname === '/api/remove') {
207
+ const r = await cli(['remove', ...(b.purge ? ['--purge'] : []), '--', String(b.name || '')]);
208
+ emit('library', {});
209
+ return res.end(JSON.stringify(r));
210
+ }
211
+ if (u.pathname === '/api/merge') {
212
+ const names = (b.names || []).map(String).filter(Boolean);
213
+ const args = ['merge'];
214
+ if (b.name) args.push('--name', String(b.name));
215
+ args.push('--', ...names);
216
+ const r = await cli(args);
217
+ emit('library', {});
218
+ return res.end(JSON.stringify(r));
219
+ }
220
+ if (u.pathname === '/api/build') {
221
+ const r = await cli(['build']);
222
+ emit('library', {});
223
+ return res.end(JSON.stringify(r));
224
+ }
225
+ if (u.pathname === '/api/update') {
226
+ const r = await cli(['update'], 300e3);
227
+ emit('library', {});
228
+ return res.end(JSON.stringify(r));
229
+ }
230
+ if (u.pathname === '/api/upgrade') {
231
+ const r = await cli(['upgrade', ...(b.name ? ['--', String(b.name)] : ['--all'])], 300e3);
232
+ emit('library', {});
233
+ return res.end(JSON.stringify(r));
234
+ }
235
+ if (u.pathname === '/api/sync') {
236
+ const r = await cli(['sync']);
237
+ emit('library', {});
238
+ return res.end(JSON.stringify(r));
239
+ }
240
+ if (u.pathname === '/api/audit') {
241
+ const r = await cli(['audit', '--', String(b.name || '')]);
242
+ emit('library', {});
243
+ return res.end(JSON.stringify(r));
244
+ }
245
+ if (u.pathname === '/api/rollback') {
246
+ const r = await cli(['rollback', '--', String(b.name || '')]);
247
+ emit('library', {});
248
+ return res.end(JSON.stringify(r));
249
+ }
160
250
  } catch (e) { res.writeHead(400); return res.end(JSON.stringify({ error: e.message })); }
161
251
  res.writeHead(404); return res.end('{"error":"not found"}');
162
252
  }
163
253
  const h = routes[`${req.method} ${u.pathname}`];
164
254
  if (h) {
165
- try { return res.end(JSON.stringify(await h())); }
255
+ try { return res.end(JSON.stringify(await h(u))); }
166
256
  catch (e) { res.writeHead(500); return res.end(JSON.stringify({ error: e.message })); }
167
257
  }
168
258
  res.writeHead(404); return res.end('{"error":"not found"}');
package/client/lib/ctx.js CHANGED
@@ -4,7 +4,7 @@ import { detectHarnesses, detectProject } from './scanner.js';
4
4
  import { resolveLLM } from './llm.js';
5
5
  import { setUILang } from './i18n.js';
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
+ 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', 'policy']);
8
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', 'scan', 'evidence', 'auto']);
9
9
 
10
10
  export function parseArgv(argv) {
@@ -0,0 +1,248 @@
1
+ // help.js — 每个命令的详细帮助(usage + 说明 + flags + 例子);<cmd> -h/--help 触发
2
+ import { L } from './i18n.js';
3
+
4
+ const H = {
5
+ init: {
6
+ zh: `用法: skillmkt init
7
+ 初始化向导:探测本地 LLM 端点 → 选模型 → 勾选 skill 默认装到哪些 agent → 写 config.yml。
8
+ 裸跑 skillmkt 且未完成初始化时也会自动进这里。`,
9
+ en: `usage: skillmkt init
10
+ Setup wizard: probe local LLM endpoints → pick a model → choose default
11
+ agents → write config.yml. Bare-run on an uninitialized hub lands here too.`,
12
+ },
13
+ config: {
14
+ zh: `用法: skillmkt config [list] | get <键> | set <键> <值>
15
+ 读写 config.yml。键示例: llm.base_url / llm.model / llm.api_key / default_targets / ui.lang
16
+ 例: skillmkt config set llm.model qwen3-32b
17
+ skillmkt config set llm.api_key env:SKILLMKT_API_KEY`,
18
+ en: `usage: skillmkt config [list] | get <key> | set <key> <value>
19
+ Read/write config.yml. Keys: llm.base_url / llm.model / llm.api_key /
20
+ default_targets / ui.lang
21
+ e.g. skillmkt config set llm.model qwen3-32b
22
+ skillmkt config set llm.api_key env:SKILLMKT_API_KEY`,
23
+ },
24
+ doctor: {
25
+ zh: `用法: skillmkt doctor
26
+ 体检报告:hub 完整性、每个 agent 的 skills 目录与 skill 数、LLM 连通性、投影漂移。
27
+ 想看清 agent 探测细节就跑它。`,
28
+ en: `usage: skillmkt doctor
29
+ Health report: hub integrity, each agent's skills dir + skill count,
30
+ LLM connectivity, projection drift. The fullest agent-detection view.`,
31
+ },
32
+ search: {
33
+ zh: `用法: skillmkt search <关键词> [--local] [--json]
34
+ 默认只搜远端市场(skills.sh);--local 只查本地已装/没收编的;两个 flag 都加 = 都搜。
35
+ 例: skillmkt search commit # 远端
36
+ skillmkt search commit --local`,
37
+ en: `usage: skillmkt search <query> [--local] [--json]
38
+ Remote market search (skills.sh) by default; --local searches installed/
39
+ unmanaged skills only; both flags = both.
40
+ e.g. skillmkt search commit # remote
41
+ skillmkt search commit --local`,
42
+ },
43
+ list: {
44
+ zh: `用法: skillmkt list [--scan] [--json]
45
+ 列出所有 skill 及各自安装位置。默认不显示 agent 目录里没收编的散 skill——
46
+ --scan 主动扫一遍才列出来(行首 ◌ 标记)。`,
47
+ en: `usage: skillmkt list [--scan] [--json]
48
+ List all skills and where each is installed. Unmanaged skills sitting in
49
+ agent dirs are hidden by default — --scan lists them (marked ◌).`,
50
+ },
51
+ show: {
52
+ zh: `用法: skillmkt show <名字> [--raw|--files|--audit]
53
+ skill 详情(来源/版本/目标/审核)。--raw 打原始 SKILL.md;--files 列文件;
54
+ --audit 看审核记录。三个 flag 互斥。`,
55
+ en: `usage: skillmkt show <name> [--raw|--files|--audit]
56
+ Skill details (source/version/targets/audit). --raw prints SKILL.md;
57
+ --files lists files; --audit shows the audit record. Flags are exclusive.`,
58
+ },
59
+ install: {
60
+ zh: `用法: skillmkt install <ref|路径|owner/repo> [--target a,b] [--dry-run]
61
+ 装 skill:拉取 → 安全审核 → 落 hub → 投影到各 agent。
62
+ ref 语法:
63
+ skillmkt install owner/repo # GitHub 仓库(默认源)
64
+ skillmkt install owner/repo --path skills/foo # monorepo 子目录
65
+ skillmkt install owner/repo@v1.2.0 # 指定 tag/sha/branch
66
+ skillmkt install corp:auth-skill # 命名 registry 前缀
67
+ skillmkt install git@github.com:o/r.git # git URL
68
+ skillmkt install ./local/dir # 本地目录
69
+ skillmkt install ~/.claude/skills/x # 收编 agent 目录里没收编的
70
+ flags:
71
+ --target claude,codex 装到哪些 agent(默认 config 的 default_targets)
72
+ --scope project 装进当前仓库(不进 default_targets,随仓共享)
73
+ --to <目录> 直指路径安装(copy;--link 改 symlink)
74
+ --yes 非交互(可疑 skill 视为拒绝——安全默认)
75
+ --dry-run 只演示不落地`,
76
+ en: `usage: skillmkt install <ref|path|owner/repo> [--target a,b] [--dry-run]
77
+ Install a skill: fetch → security audit → hub → project to agents.
78
+ ref syntax:
79
+ skillmkt install owner/repo # GitHub repo (default)
80
+ skillmkt install owner/repo --path skills/foo # monorepo subdir
81
+ skillmkt install owner/repo@v1.2.0 # tag/sha/branch
82
+ skillmkt install corp:auth-skill # named registry prefix
83
+ skillmkt install git@github.com:o/r.git # git URL
84
+ skillmkt install ./local/dir # local directory
85
+ skillmkt install ~/.claude/skills/x # adopt an unmanaged skill
86
+ flags:
87
+ --target claude,codex which agents receive it (default: default_targets)
88
+ --scope project install into this repo (not default_targets)
89
+ --to <dir> install to an explicit path (copy; --link symlinks)
90
+ --yes non-interactive (suspicious skills are refused)
91
+ --dry-run preview without writing`,
92
+ },
93
+ remove: {
94
+ zh: `用法: skillmkt remove <名字> [--purge] [--scope project]
95
+ 卸 skill:删各 agent 目录里的投影 + hub 副本移进 .trash(可恢复)。
96
+ --purge 连 hub 副本一起删;--scope project 只删仓库内副本、hub 保留。
97
+ 别名: uninstall / un / rm`,
98
+ en: `usage: skillmkt remove <name> [--purge] [--scope project]
99
+ Uninstall: delete projections from agent dirs + move hub copy to .trash
100
+ (recoverable). --purge deletes the hub copy too; --scope project removes
101
+ only the repo copy and keeps the hub. Aliases: uninstall / un / rm`,
102
+ },
103
+ targets: {
104
+ zh: `用法: skillmkt targets [list] | add <id> | add --path <目录> <名字> | remove <id>
105
+ 安装位置矩阵:每个 skill 装到了哪些 agent;增删目标。
106
+ add <id> 用探测到的 agent id(claude/codex/…);--path 自定义目录。`,
107
+ en: `usage: skillmkt targets [list] | add <id> | add --path <dir> <name> | remove <id>
108
+ Install-location matrix: which agents each skill goes to; add/remove targets.
109
+ add <id> uses a detected agent id (claude/codex/…); --path takes a dir.`,
110
+ },
111
+ sync: {
112
+ zh: `用法: skillmkt sync [--dry-run]
113
+ 检查投影漂移并修复:把 hub 里的 skill 重新同步到各 agent 目录。
114
+ --dry-run 只看报告不动手(会列出新探测到的 agent)。`,
115
+ en: `usage: skillmkt sync [--dry-run]
116
+ Check projection drift and repair: re-sync hub skills into agent dirs.
117
+ --dry-run reports without writing (also lists newly detected agents).`,
118
+ },
119
+ audit: {
120
+ zh: `用法: skillmkt audit <名字|--all> [--llm] [--json]
121
+ 安全审核:scripts/密钥模式/外联指令等确定性检查;--llm 追加本地模型分析。
122
+ 结论词:干净 / 可疑 / 已剔除 / 恶意 / 已隔离。`,
123
+ en: `usage: skillmkt audit <name|--all> [--llm] [--json]
124
+ Security audit: deterministic checks for scripts/secret patterns/outbound
125
+ instructions; --llm adds local-model analysis.
126
+ Verdicts: clean / suspicious / stripped / malicious / quarantined.`,
127
+ },
128
+ update: {
129
+ zh: `用法: skillmkt update [--json]
130
+ 只刷新上游元数据(apt update 语义)——看哪些有更新用 outdated,应用用 upgrade。`,
131
+ en: `usage: skillmkt update [--json]
132
+ Refresh upstream metadata only (apt update semantics) — see what's stale
133
+ with outdated, apply with upgrade.`,
134
+ },
135
+ outdated: {
136
+ zh: `用法: skillmkt outdated [名字] [--json]
137
+ 报告可用更新:本地版 vs 上游最新。不带名字看全部。`,
138
+ en: `usage: skillmkt outdated [name] [--json]
139
+ Report available updates: local version vs upstream latest. No name = all.`,
140
+ },
141
+ upgrade: {
142
+ zh: `用法: skillmkt upgrade <名字|--all> [--dry-run]
143
+ 应用更新:拉新上游 → 重审 → 换 hub 副本(旧版进 history 可 rollback)→ 重投影。`,
144
+ en: `usage: skillmkt upgrade <name|--all> [--dry-run]
145
+ Apply updates: fetch upstream → re-audit → swap hub copy (old version kept
146
+ in history for rollback) → re-project.`,
147
+ },
148
+ download: {
149
+ zh: `用法: skillmkt download <owner/repo 或 skills.sh slug> [--path <子目录>]
150
+ 只拉取 + 审核进缓存,不安装。之后 install 同一个 ref 会直接命中缓存。`,
151
+ en: `usage: skillmkt download <owner/repo or skills.sh slug> [--path <subdir>]
152
+ Fetch + audit into cache only, no install. A later install of the same ref
153
+ hits the cache.`,
154
+ },
155
+ diff: {
156
+ zh: `用法: skillmkt diff <名字> [--semantic]
157
+ 上游对比:本地 hub 版 vs 远端最新——文件增删改的结构 diff;
158
+ --semantic 追加 LLM 语义解读(改了什么行为而不只是哪些行)。`,
159
+ en: `usage: skillmkt diff <name> [--semantic]
160
+ Upstream diff: local hub copy vs latest remote — structural file-level
161
+ changes; --semantic adds an LLM explanation of behavioral changes.`,
162
+ },
163
+ rollback: {
164
+ zh: `用法: skillmkt rollback <名字>
165
+ 回滚到升级前的版本(upgrade 会留一版历史副本;再滚更深就报错)。`,
166
+ en: `usage: skillmkt rollback <name>
167
+ Roll back to the pre-upgrade version (upgrade keeps one history copy;
168
+ deeper rollback isn't stored).`,
169
+ },
170
+ conflicts: {
171
+ zh: `用法: skillmkt conflicts [--json]
172
+ 冲突队列:merge/upgrade 检出的规则分歧,按 fingerprint 去重。
173
+ 裁决用 resolve/decide,生成用 build。`,
174
+ en: `usage: skillmkt conflicts [--json]
175
+ Conflict queue: rule disagreements found by merge/upgrade, deduped by
176
+ fingerprint. Decide via resolve/decide, generate via build.`,
177
+ },
178
+ resolve: {
179
+ zh: `用法: skillmkt resolve <冲突id>
180
+ 交互裁决单条冲突:选 A / 选 B / 编辑合并文本($EDITOR)/ 搁置。
181
+ 非交互等价物是 decide --resolution …。`,
182
+ en: `usage: skillmkt resolve <conflict-id>
183
+ Interactively resolve one conflict: keep A / keep B / edit merged text
184
+ ($EDITOR) / dismiss. Non-interactive equivalent: decide --resolution …`,
185
+ },
186
+ decide: {
187
+ zh: `用法: skillmkt decide <冲突id> --resolution keep-a|keep-b|merge|dismissed --reason "…" [--custom "文本"]
188
+ 记录冲突裁决:resolution 必填 reason(决策审计溯源);merge 需 --custom。
189
+ 例: skillmkt decide c-7f3a --resolution keep-a --reason "A 更具体"
190
+ skillmkt decide c-9b2e --resolution merge --custom "合并后的规则" --reason "两边各取一半"`,
191
+ en: `usage: skillmkt decide <conflict-id> --resolution keep-a|keep-b|merge|dismissed --reason "…" [--custom "text"]
192
+ Record a conflict decision: every resolution needs a reason (audit trail);
193
+ merge needs --custom.
194
+ e.g. skillmkt decide c-7f3a --resolution keep-a --reason "A is more specific"
195
+ skillmkt decide c-9b2e --resolution merge --custom "merged rule" --reason "best of both"`,
196
+ },
197
+ merge: {
198
+ zh: `用法: skillmkt merge <a> <b> [更多…] [--name 名字] [--auto]
199
+ 合并 ≥2 个已管理 skill:抽规则 → 去重 → 检冲突 → 写 merged/rules.yml。
200
+ 有分歧进冲突队列由人裁决(--auto 用 LLM 自动裁易裁的);
201
+ 裁决完跑 build 生成 SKILL.md。`,
202
+ en: `usage: skillmkt merge <a> <b> [more…] [--name name] [--auto]
203
+ Merge ≥2 managed skills: extract rules → dedupe → conflict-check → write
204
+ merged/rules.yml. Disagreements queue for human decision (--auto lets the
205
+ LLM arbitrate easy ones); run build afterwards for SKILL.md.`,
206
+ },
207
+ build: {
208
+ zh: `用法: skillmkt build
209
+ 用 merged/rules.yml + 已裁决的决定生成 merged/skill-out/SKILL.md。
210
+ 未决冲突的规则不会进产物。`,
211
+ en: `usage: skillmkt build
212
+ Generate merged/skill-out/SKILL.md from merged/rules.yml + active
213
+ decisions. Rules under pending conflicts never enter the output.`,
214
+ },
215
+ pack: {
216
+ zh: `用法: skillmkt pack <名字> [--out <目录>]
217
+ 打包 hub 里的 skill 为可分发的目录产物。`,
218
+ en: `usage: skillmkt pack <name> [--out <dir>]
219
+ Package a hub skill into a distributable directory.`,
220
+ },
221
+ publish: {
222
+ zh: `用法: skillmkt publish <名字> --to <registry>
223
+ 发布 skill 到已配置的 registry(先 registry add 配置)。`,
224
+ en: `usage: skillmkt publish <name> --to <registry>
225
+ Publish a skill to a configured registry (registry add first).`,
226
+ },
227
+ registry: {
228
+ zh: `用法: skillmkt registry [list] | add --type <github|rfc|clawhub|skillssh> [--url u] [--name n] [--token env:X] | remove <名字>
229
+ 管理远端 registry:市场搜索、install 解析、publish 目标都走这里注册的适配器。`,
230
+ en: `usage: skillmkt registry [list] | add --type <github|rfc|clawhub|skillssh> [--url u] [--name n] [--token env:X] | remove <name>
231
+ Manage remote registries: market search, install resolution and publish
232
+ targets all go through adapters registered here.`,
233
+ },
234
+ serve: {
235
+ zh: `用法: skillmkt serve [--port <端口>] [--daemon] [--stop]
236
+ 本地 Web 面板:市场搜索/安装/合并/冲突裁决/审核/设置全可视化,启动自动开浏览器。
237
+ --daemon 后台跑(不开浏览器);--stop 停掉后台实例。`,
238
+ en: `usage: skillmkt serve [--port <port>] [--daemon] [--stop]
239
+ Local web panel: market search / install / merge / conflict decisions /
240
+ audit / settings, opens the browser on start. --daemon runs headless in
241
+ the background (no browser); --stop kills the background instance.`,
242
+ },
243
+ };
244
+
245
+ export function commandHelp(name) {
246
+ const h = H[name];
247
+ return h ? L(h.zh, h.en) : null;
248
+ }
@@ -9,7 +9,7 @@ let saveMsg = '', saveMsgAt = 0; // 保存结果提示——要挺过保存后
9
9
  const I18N = {
10
10
  zh: {
11
11
  title: 'skillmkt — 本地 skill 管理面板', tag: '本地管理面板',
12
- nav_skills: '已安装', nav_conflicts: '冲突处理', nav_review: '安全审核', nav_setup: '设置',
12
+ nav_skills: '已安装', nav_market: '市场', nav_merge: '合并', nav_conflicts: '冲突处理', nav_review: '安全审核', nav_setup: '设置',
13
13
  live_conn: '连接中…', live_on: '已连接', live_off: '已断开',
14
14
  foot_hub: (h) => `数据目录:${h}`,
15
15
  err_conn: (e) => `连不上本地服务:${esc(e)}——服务可能已退出,重跑 <code>skillmkt serve</code>`,
@@ -73,10 +73,26 @@ const I18N = {
73
73
  step_save: '第 4 步 · 保存', save_btn: '保存设置',
74
74
  saved: (enc) => `已保存到 config.yml${enc ? ',密钥已加密' : ''}`,
75
75
  save_fail: (e) => `保存失败:${e}`,
76
+ mk_h: 'Skill 市场', mk_desc: '搜索 skills.sh 公共市场;也可以直接粘贴 owner/repo、skills.sh 条目或本地路径来安装。',
77
+ mk_ph: '搜关键词,或粘 owner/repo / 绝对路径', mk_search: '搜索', mk_direct: '按输入直接安装', mk_install: '安装',
78
+ mk_busy: '处理中…', ins_done: '完成', ins_fail: (c) => `失败(退出码 ${c})`,
79
+ sk_remove: '移除', sk_remove_sure: '再点一次确认', sk_removed: '已移除',
80
+ det_btn: '详情', det_files: (n) => `${n} 个文件`, det_diff: '上游 diff', det_rollback: '回滚上一版',
81
+ ext_h: (n) => `agent 目录里没收编的 skill(${n})`,
82
+ ext_desc: '这些已经能被对应 agent 用,但没有版本跟踪、安全审核和统一更新。收编进来集中管理。',
83
+ ext_adopt: '收编', ext_busy: '收编中…',
84
+ maint_h: '维护', upd_refresh: '刷新上游信息', upd_one: '升级', upd_all: '全部升级',
85
+ sync_btn: '检查并修复投影', op_busy: '执行中…', op_done: '完成',
86
+ mg_h: '合并 skill', mg_desc: '勾选两个以上已管理的 skill,规则会抽出来去重、查冲突——有分歧的进「冲突处理」由你裁决,最终生成一个不含未决规则的新 skill。',
87
+ mg_pick: '选择要合并的 skill(≥2)', mg_name: '新 skill 名字(可选,默认自动生成)', mg_go: '开始合并',
88
+ mg_busy: '合并中…', mg_few: '至少勾两个',
89
+ mg_state: (n, r) => `当前合并产物:${n}(${r} 条规则)`,
90
+ mg_build: '生成 SKILL.md', mg_install: '安装这个合并 skill', mg_to_conflicts: '有冲突待裁决 → 去「冲突处理」',
91
+ rv_reaudit: '重新审核',
76
92
  },
77
93
  en: {
78
94
  title: 'skillmkt — local skill manager', tag: 'local skill manager',
79
- nav_skills: 'Installed', nav_conflicts: 'Conflicts', nav_review: 'Security', nav_setup: 'Settings',
95
+ nav_skills: 'Installed', nav_market: 'Market', nav_merge: 'Merge', nav_conflicts: 'Conflicts', nav_review: 'Security', nav_setup: 'Settings',
80
96
  live_conn: 'connecting…', live_on: 'connected', live_off: 'disconnected',
81
97
  foot_hub: (h) => `Data dir: ${h}`,
82
98
  err_conn: (e) => `Cannot reach the local service: ${esc(e)} — it may have exited; run <code>skillmkt serve</code> again`,
@@ -140,6 +156,22 @@ const I18N = {
140
156
  step_save: 'Step 4 · Save', save_btn: 'Save settings',
141
157
  saved: (enc) => `Saved to config.yml${enc ? ' — key encrypted' : ''}`,
142
158
  save_fail: (e) => `Save failed: ${e}`,
159
+ mk_h: 'Skill market', mk_desc: 'Search the skills.sh public market, or paste an owner/repo, skills.sh entry, or local path to install directly.',
160
+ mk_ph: 'keywords, or paste owner/repo / absolute path', mk_search: 'Search', mk_direct: 'Install input as ref/path', mk_install: 'Install',
161
+ mk_busy: 'Working…', ins_done: 'Done', ins_fail: (c) => `Failed (exit ${c})`,
162
+ sk_remove: 'Remove', sk_remove_sure: 'Click again to confirm', sk_removed: 'Removed',
163
+ det_btn: 'Details', det_files: (n) => `${n} files`, det_diff: 'Upstream diff', det_rollback: 'Rollback a version',
164
+ ext_h: (n) => `Unmanaged skills in agent dirs (${n})`,
165
+ ext_desc: 'These already work in their agents but have no versioning, security audit, or unified updates. Adopt them to manage centrally.',
166
+ ext_adopt: 'Adopt', ext_busy: 'Adopting…',
167
+ maint_h: 'Maintenance', upd_refresh: 'Refresh upstream info', upd_one: 'Upgrade', upd_all: 'Upgrade all',
168
+ sync_btn: 'Check & repair projections', op_busy: 'Working…', op_done: 'Done',
169
+ mg_h: 'Merge skills', mg_desc: 'Check two or more managed skills — rules get extracted, deduplicated and conflict-checked. Disagreements land in "Conflicts" for you to decide; the result is a new skill with no unresolved rules.',
170
+ mg_pick: 'Skills to merge (≥2)', mg_name: 'New skill name (optional)', mg_go: 'Merge',
171
+ mg_busy: 'Merging…', mg_few: 'Pick at least two',
172
+ mg_state: (n, r) => `Current merged result: ${n} (${r} rules)`,
173
+ mg_build: 'Build SKILL.md', mg_install: 'Install this merged skill', mg_to_conflicts: 'Pending conflicts → go to "Conflicts"',
174
+ rv_reaudit: 'Re-audit',
143
175
  },
144
176
  };
145
177
  const t = (k, ...a) => { const v = (I18N[S?.lang] || I18N.zh)[k] ?? I18N.zh[k]; return typeof v === 'function' ? v(...a) : (v ?? k); };
@@ -157,6 +189,7 @@ const es = new EventSource(`/api/events?token=${T}`);
157
189
  es.addEventListener('decide', () => refresh());
158
190
  es.addEventListener('config', () => refresh());
159
191
  es.addEventListener('targets', () => refresh());
192
+ es.addEventListener('library', () => refresh());
160
193
  const live = document.getElementById('live');
161
194
  es.onopen = () => { live.classList.remove('off'); live.innerHTML = `<span class="dot"></span>${t('live_on')}`; };
162
195
  es.onerror = () => { live.classList.add('off'); live.innerHTML = `<span class="dot"></span>${t('live_off')}`; };
@@ -218,9 +251,45 @@ async function render() {
218
251
  + (skills.map(([n, s]) => `
219
252
  <div class="card"><div class="row"><b>${esc(n)}</b><span class="mut">${esc(s.version || '')}</span><span class="mut">${esc(s.source?.registry || '')}</span>${pill(s.audit || 'clean')}
220
253
  <span class="mut" style="margin-left:auto">${t('sk_at')}${(s.targets || []).map((x) => esc(x)).join(t('sep')) || t('sk_hub')}</span>
221
- <button data-tg="${esc(n)}">${t('sk_loc')}</button></div>
222
- <div class="tgbox" data-box="${esc(n)}" style="display:none;margin-top:10px"></div></div>`).join('')
254
+ <button data-tg="${esc(n)}">${t('sk_loc')}</button><button data-dt="${esc(n)}">${t('det_btn')}</button><button data-rm="${esc(n)}">${t('sk_remove')}</button></div>
255
+ <div class="tgbox" data-box="${esc(n)}" style="display:none;margin-top:10px"></div>
256
+ <div class="dtbox" data-dbox="${esc(n)}" style="display:none;margin-top:10px"></div></div>`).join('')
223
257
  || `<div class="empty">${t('sk_empty')}</div>`);
258
+ // 移除:两段式确认(第一下变确认文案,3 秒内再点才真删)
259
+ app.querySelectorAll('[data-rm]').forEach((b) => {
260
+ let armed = false, timer = null;
261
+ b.onclick = async () => {
262
+ if (!armed) { armed = true; b.textContent = t('sk_remove_sure'); b.style.borderColor = 'var(--color-bad)'; timer = setTimeout(() => { armed = false; b.textContent = t('sk_remove'); b.style.borderColor = ''; }, 3000); return; }
263
+ clearTimeout(timer); b.disabled = true; b.textContent = t('op_busy');
264
+ const r = await api('/remove', { method: 'POST', body: JSON.stringify({ name: b.dataset.rm }) });
265
+ b.textContent = r.code === 0 ? t('sk_removed') : t('ins_fail', r.code);
266
+ if (r.code === 0) refresh();
267
+ };
268
+ });
269
+ // 详情:文件清单 + 上游 diff + 回滚
270
+ app.querySelectorAll('[data-dt]').forEach((b) => b.onclick = async () => {
271
+ const box = app.querySelector(`[data-dbox="${b.dataset.dt}"]`);
272
+ if (box.style.display === 'block') { box.style.display = 'none'; return; }
273
+ const s = S.library.skills[b.dataset.dt];
274
+ const d = await api(`/skill?name=${encodeURIComponent(b.dataset.dt)}`);
275
+ box.style.display = 'block';
276
+ box.innerHTML = `<p class="mut" style="margin:4px 0">${esc(d.description || '')} · ${t('det_files', d.fileCount ?? d.files?.length ?? 0)} · ${esc(s?.source?.registry || '')} ${esc(s?.source?.ref || '')}</p>
277
+ <div class="row">${s?.source?.registry === 'github' ? `<button class="df">${t('det_diff')}</button>` : ''}<button class="rb">${t('det_rollback')}</button><span class="out mut"></span></div>
278
+ <pre class="pre mut" style="display:none;white-space:pre-wrap;font-size:13.5px;max-height:260px;overflow:auto"></pre>`;
279
+ box.querySelector('.df')?.addEventListener('click', async (e) => {
280
+ e.target.disabled = true; e.target.textContent = t('op_busy');
281
+ const r = await api(`/diff?name=${encodeURIComponent(b.dataset.dt)}`);
282
+ const pre = box.querySelector('.pre'); pre.style.display = 'block'; pre.textContent = r.out || '(no output)';
283
+ e.target.disabled = false; e.target.textContent = t('det_diff');
284
+ });
285
+ box.querySelector('.rb')?.addEventListener('click', async (e) => {
286
+ e.target.disabled = true; e.target.textContent = t('op_busy');
287
+ const r = await api('/rollback', { method: 'POST', body: JSON.stringify({ name: b.dataset.dt }) });
288
+ box.querySelector('.out').textContent = r.code === 0 ? t('op_done') : (r.out || '').slice(0, 120);
289
+ e.target.disabled = false; e.target.textContent = t('det_rollback');
290
+ if (r.code === 0) refresh();
291
+ });
292
+ });
224
293
  app.querySelectorAll('[data-tg]').forEach((b) => b.onclick = () => {
225
294
  const box = app.querySelector(`[data-box="${b.dataset.tg}"]`);
226
295
  if (box.style.display === 'block') { box.style.display = 'none'; return; }
@@ -242,9 +311,110 @@ async function render() {
242
311
  + (S.harnesses || []).map((h) => `<div class="card row"><b>${esc(h.id)}</b>${pill(h.state)}<span class="mut">${esc(h.primaryDir || h.dirs?.[0]?.path || '')}</span></div>`).join('');
243
312
  const up = S.upstream.skills || {};
244
313
  const outs = Object.entries(up).filter(([, u]) => u.outdated);
245
- if (outs.length) app.innerHTML += `<h2>${t('upd_h', outs.length)}</h2>
246
- <p class="desc">${t('upd_desc')}</p>`
247
- + outs.map(([n]) => `<div class="card row"><b>${esc(n)}</b>${pill('outdated')}</div>`).join('');
314
+ app.innerHTML += `<h2>${t('maint_h')}</h2>
315
+ <div class="card row"><button id="m-upd">${t('upd_refresh')}</button><button id="m-sync">${t('sync_btn')}</button>
316
+ ${outs.length ? `<button id="m-upg" class="primary">${t('upd_all')}(${outs.length})</button>` : ''}<span id="m-out" class="mut"></span></div>`
317
+ + (outs.length ? outs.map(([n]) => `<div class="card row"><b>${esc(n)}</b>${pill('outdated')}<button class="upg" data-n="${esc(n)}" style="margin-left:auto">${t('upd_one')}</button><span class="uout mut"></span></div>`).join('') : '');
318
+ const runOp = async (btn, path, body) => {
319
+ btn.disabled = true; const old = btn.textContent; btn.textContent = t('op_busy');
320
+ const r = await api(path, { method: 'POST', body: JSON.stringify(body || {}) });
321
+ btn.disabled = false; btn.textContent = old;
322
+ return r;
323
+ };
324
+ app.querySelector('#m-upd').onclick = async (e) => { const r = await runOp(e.target, '/update'); app.querySelector('#m-out').textContent = (r.out || '').split('\n').pop().slice(0, 100); refresh(); };
325
+ app.querySelector('#m-sync').onclick = async (e) => { const r = await runOp(e.target, '/sync'); app.querySelector('#m-out').textContent = (r.out || '').split('\n').pop().slice(0, 100); };
326
+ app.querySelector('#m-upg')?.addEventListener('click', async (e) => { await runOp(e.target, '/upgrade'); refresh(); });
327
+ app.querySelectorAll('.upg').forEach((b) => b.onclick = async (e) => {
328
+ const r = await runOp(e.target, '/upgrade', { name: b.dataset.n });
329
+ const o = b.parentElement.querySelector('.uout'); if (o) o.textContent = r.code === 0 ? t('op_done') : (r.out || '').slice(0, 100);
330
+ if (r.code === 0) refresh();
331
+ });
332
+
333
+ // 收编区:agent 目录里没收编的 skill(主动拉 /api/scan 才显示)
334
+ const ext = await api('/scan');
335
+ if (ext?.length) {
336
+ app.innerHTML += `<h2>${t('ext_h', ext.length)}</h2><p class="desc">${t('ext_desc')}</p>`
337
+ + ext.map((e) => `<div class="card row"><b>${esc(e.name)}</b><span class="mut">${esc(e.where)} · ${esc(e.dir)}</span>
338
+ <button class="adopt" data-d="${esc(e.path || '')}" style="margin-left:auto">${t('ext_adopt')}</button><span class="aout mut"></span></div>`).join('');
339
+ app.querySelectorAll('.adopt').forEach((b) => b.onclick = async (e) => {
340
+ const r = await runOp(e.target, '/install', { ref: b.dataset.d });
341
+ const o = b.parentElement.querySelector('.aout'); if (o) o.textContent = r.code === 0 ? t('op_done') : (r.out || '').split('\n').pop().slice(0, 100);
342
+ if (r.code === 0) refresh();
343
+ });
344
+ }
345
+ }
346
+
347
+ if (tab === 'market') {
348
+ app.innerHTML = `<h2>${t('mk_h')}</h2><p class="desc">${t('mk_desc')}</p>
349
+ <div class="card"><div class="frow"><input type="text" id="mk-q" placeholder="${t('mk_ph')}" style="flex:1">
350
+ <button class="primary" id="mk-go">${t('mk_search')}</button><button id="mk-dir">${t('mk_direct')}</button></div>
351
+ <div id="mk-out" class="fsub"></div></div>
352
+ <div id="mk-res"></div>`;
353
+ const q = app.querySelector('#mk-q');
354
+ const doInstall = async (ref, path, btn) => {
355
+ btn.disabled = true; const old = btn.textContent; btn.textContent = t('mk_busy');
356
+ const r = await api('/install', { method: 'POST', body: JSON.stringify({ ref, path }) });
357
+ btn.disabled = false; btn.textContent = old;
358
+ const out = btn.parentElement.querySelector('.iout') || app.querySelector('#mk-out');
359
+ out.textContent = r.code === 0 ? t('ins_done') : (r.out || '').split('\n').pop().slice(0, 120);
360
+ if (r.code === 0) refresh();
361
+ };
362
+ app.querySelector('#mk-go').onclick = async () => {
363
+ const res = app.querySelector('#mk-res');
364
+ res.innerHTML = `<p class="mut">${t('mk_busy')}</p>`;
365
+ const r = await api(`/search?q=${encodeURIComponent(q.value.trim())}`);
366
+ res.innerHTML = (r.skills || []).slice(0, 15).map((s) => {
367
+ const parts = s.slug.split('/'), ownerRepo = parts.slice(0, 2).join('/'), sub = parts.slice(2).join('/');
368
+ return `<div class="card row"><b>${esc(s.name)}</b><span class="mut">${esc(s.slug)} · ${s.installs} installs</span>
369
+ <button class="mk-i" style="margin-left:auto" data-r="${esc(ownerRepo)}" data-p="${esc(sub)}">${t('mk_install')}</button><span class="iout mut"></span></div>`;
370
+ }).join('') || `<div class="empty">${t('cf_empty')}</div>`;
371
+ res.querySelectorAll('.mk-i').forEach((b) => b.onclick = () => doInstall(b.dataset.r, b.dataset.p, b));
372
+ };
373
+ app.querySelector('#mk-dir').onclick = async () => {
374
+ const v = q.value.trim(); if (!v) return;
375
+ const r = await api('/install', { method: 'POST', body: JSON.stringify({ ref: v }) });
376
+ app.querySelector('#mk-out').textContent = r.code === 0 ? t('ins_done') : (r.out || '').split('\n').pop().slice(0, 120);
377
+ if (r.code === 0) refresh();
378
+ };
379
+ q.addEventListener('keydown', (e) => { if (e.key === 'Enter') app.querySelector('#mk-go').click(); });
380
+ }
381
+
382
+ if (tab === 'merge') {
383
+ const skills = Object.keys(S.library.skills || {});
384
+ const mg = S.merged;
385
+ const pendN = (S.conflicts || []).filter((c) => c.status === 'pending').length;
386
+ app.innerHTML = `<h2>${t('mg_h')}</h2><p class="desc">${t('mg_desc')}</p>
387
+ <div class="card"><h3>${t('mg_pick')}</h3>`
388
+ + (skills.map((n) => `<label class="check"><input type="checkbox" data-mg="${esc(n)}"> ${esc(n)}</label>`).join('')
389
+ || `<div class="empty">${t('sk_empty')}</div>`)
390
+ + `<div class="frow"><input type="text" id="mg-name" placeholder="${t('mg_name')}" style="flex:1">
391
+ <button class="primary" id="mg-go">${t('mg_go')}</button><span id="mg-out" class="mut"></span></div></div>`
392
+ + (mg ? `<div class="card"><div class="row"><b>${t('mg_state', esc(mg.name), mg.rules)}</b>
393
+ <button id="mg-build" ${mg.built ? 'disabled' : ''}>${t('mg_build')}</button>
394
+ ${mg.built ? `<button class="primary" id="mg-inst">${t('mg_install')}</button>` : ''}
395
+ <span id="mg-sout" class="mut"></span></div></div>` : '')
396
+ + (pendN ? `<div class="card row"><span class="pill warn">${pendN} pending</span><button onclick="location.hash='conflicts'">${t('mg_to_conflicts')}</button></div>` : '');
397
+ app.querySelector('#mg-go').onclick = async (e) => {
398
+ const names = [...app.querySelectorAll('[data-mg]:checked')].map((x) => x.dataset.mg);
399
+ if (names.length < 2) { app.querySelector('#mg-out').textContent = t('mg_few'); return; }
400
+ e.target.disabled = true; e.target.textContent = t('mg_busy');
401
+ const r = await api('/merge', { method: 'POST', body: JSON.stringify({ names, name: app.querySelector('#mg-name').value.trim() || undefined }) });
402
+ app.querySelector('#mg-out').textContent = (r.out || '').split('\n').pop().slice(0, 140);
403
+ e.target.disabled = false; e.target.textContent = t('mg_go');
404
+ refresh();
405
+ };
406
+ app.querySelector('#mg-build')?.addEventListener('click', async (e) => {
407
+ e.target.disabled = true; e.target.textContent = t('op_busy');
408
+ const r = await api('/build', { method: 'POST', body: '{}' });
409
+ app.querySelector('#mg-sout').textContent = (r.out || '').split('\n').pop().slice(0, 120);
410
+ refresh();
411
+ });
412
+ app.querySelector('#mg-inst')?.addEventListener('click', async (e) => {
413
+ e.target.disabled = true; e.target.textContent = t('op_busy');
414
+ const r = await api('/install', { method: 'POST', body: JSON.stringify({ ref: `${S.hub}/merged/skill-out` }) });
415
+ app.querySelector('#mg-sout').textContent = r.code === 0 ? t('ins_done') : (r.out || '').split('\n').pop().slice(0, 120);
416
+ refresh();
417
+ });
248
418
  }
249
419
 
250
420
  if (tab === 'conflicts') {
@@ -297,8 +467,16 @@ async function render() {
297
467
  const scans = S.scans || [];
298
468
  app.innerHTML = `<h2>${t('rv_h', scans.length)}</h2>
299
469
  <p class="desc">${t('rv_desc')}</p>`
300
- + (scans.map((s) => `<div class="card row"><b>${esc(s.skill || s.name || '')}</b>${pill(s.verdict)}<span class="mut">${t('findings', (s.findings || []).length)}${s.llm ? t('ai_rec', esc(CN(s.llm.verdict))) : ''}</span></div>`).join('')
470
+ + (scans.map((s) => `<div class="card row"><b>${esc(s.skill || s.name || '')}</b>${pill(s.verdict)}<span class="mut">${t('findings', (s.findings || []).length)}${s.llm ? t('ai_rec', esc(CN(s.llm.verdict))) : ''}</span>
471
+ <button class="ra" data-n="${esc(s.skill || s.name || '')}" style="margin-left:auto">${t('rv_reaudit')}</button><span class="raout mut"></span></div>`).join('')
301
472
  || `<div class="empty">${t('rv_empty')}</div>`);
473
+ app.querySelectorAll('.ra').forEach((b) => b.onclick = async () => {
474
+ b.disabled = true; const old = b.textContent; b.textContent = t('op_busy');
475
+ const r = await api('/audit', { method: 'POST', body: JSON.stringify({ name: b.dataset.n }) });
476
+ b.disabled = false; b.textContent = old;
477
+ b.parentElement.querySelector('.raout').textContent = (r.out || '').split('\n').pop().slice(0, 80);
478
+ if (r.code === 0) refresh();
479
+ });
302
480
  const decs = (S.decisions || []).filter((d) => d.status === 'active');
303
481
  if (decs.length) app.innerHTML += `<h2>${t('dec_h', decs.length)}</h2>
304
482
  <p class="desc">${t('dec_desc')}</p>`
@@ -118,6 +118,8 @@ footer { padding: 22px 32px; border-top: 1px solid var(--color-line); font-size:
118
118
  <div class="brand"><h1>awesome-skill-market</h1><span class="tag">skillmkt 本地管理面板</span></div>
119
119
  <nav>
120
120
  <button class="on" data-t="skills">已安装</button>
121
+ <button data-t="market">市场</button>
122
+ <button data-t="merge">合并</button>
121
123
  <button data-t="conflicts">冲突处理</button>
122
124
  <button data-t="review">安全审核</button>
123
125
  <button data-t="setup">设置</button>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillmkt",
3
- "version": "0.4.31",
3
+ "version": "0.4.33",
4
4
  "type": "module",
5
5
  "description": "Local-first agent skill manager: install, audit, merge, distribute.",
6
6
  "license": "MIT",