skillmkt 0.1.3 → 0.1.5
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/commands/serve.js +22 -4
- package/client/lib/daemon.js +3 -1
- package/client/public/app.js +66 -48
- package/client/public/index.html +87 -17
- package/package.json +1 -1
package/client/commands/serve.js
CHANGED
|
@@ -6,7 +6,7 @@ import crypto from 'node:crypto';
|
|
|
6
6
|
import { daemonFile, readDaemon } from '../lib/daemon.js';
|
|
7
7
|
import { loadConflicts } from '../lib/conflicts.js';
|
|
8
8
|
import { loadDecisions, decide } from '../lib/decide.js';
|
|
9
|
-
import { readLibrary, readLock, readConfig, writeConfig, registerSkill, updateLock } from '../lib/hub.js';
|
|
9
|
+
import { readLibrary, readLock, readConfig, writeConfig, registerSkill, updateLock, ensureHub } from '../lib/hub.js';
|
|
10
10
|
import { readUpstream } from '../lib/state.js';
|
|
11
11
|
import { readYAML } from '../../pipeline/lib/util.js';
|
|
12
12
|
import { scanAll } from '../lib/scanner.js';
|
|
@@ -20,6 +20,7 @@ const MIME = { '.html': 'text/html', '.js': 'text/javascript', '.css': 'text/css
|
|
|
20
20
|
|
|
21
21
|
export async function run(ctx) {
|
|
22
22
|
const flags = ctx.flags.raw;
|
|
23
|
+
ensureHub(ctx.hub); // 未 init 也能起面板(setup 页完成初始化)
|
|
23
24
|
if (flags.stop) {
|
|
24
25
|
const d = readDaemon(ctx.hub);
|
|
25
26
|
if (d) { try { process.kill(d.pid); } catch { /* dead */ } fs.rmSync(daemonFile(ctx.hub), { force: true }); ok('daemon stopped'); }
|
|
@@ -34,7 +35,9 @@ export async function run(ctx) {
|
|
|
34
35
|
const idleMs = (ctx.config.daemon?.idle_minutes ?? 30) * 60e3;
|
|
35
36
|
|
|
36
37
|
const state = () => ({
|
|
37
|
-
hub: ctx.hub,
|
|
38
|
+
hub: ctx.hub,
|
|
39
|
+
initialized: (() => { const r = readConfig(ctx.hub)._raw; return !!(r.ui || r.llm || r.default_targets); })(),
|
|
40
|
+
library: readLibrary(ctx.hub), lock: readLock(ctx.hub),
|
|
38
41
|
upstream: readUpstream(ctx.hub), conflicts: loadConflicts(ctx.hub),
|
|
39
42
|
decisions: loadDecisions(ctx.hub), harnesses: ctx.harnesses,
|
|
40
43
|
scans: fs.existsSync(path.join(ctx.hub, 'scans')) ? fs.readdirSync(path.join(ctx.hub, 'scans')).map((f) => readYAML(path.join(ctx.hub, 'scans', f))).filter(Boolean) : [],
|
|
@@ -50,8 +53,11 @@ export async function run(ctx) {
|
|
|
50
53
|
};
|
|
51
54
|
const body = (req) => new Promise((r) => { let b = ''; req.on('data', (c) => b += c); req.on('end', () => r(b || '{}')); });
|
|
52
55
|
|
|
56
|
+
const quiet = !!flags.daemon;
|
|
53
57
|
const server = http.createServer(async (req, res) => {
|
|
54
58
|
lastActive = Date.now();
|
|
59
|
+
const t0 = Date.now();
|
|
60
|
+
if (!quiet) res.on('finish', () => console.log(` ${req.method} ${req.url} → ${res.statusCode} ${Date.now() - t0}ms`));
|
|
55
61
|
const u = new URL(req.url, 'http://x');
|
|
56
62
|
// auth:Bearer header 或 ?token=(SSE/img 用 query,服务端不下发 cookie)
|
|
57
63
|
const authed = req.headers.authorization === `Bearer ${token}` || u.searchParams.get('token') === token;
|
|
@@ -134,8 +140,20 @@ export async function run(ctx) {
|
|
|
134
140
|
fs.writeFileSync(daemonFile(ctx.hub), JSON.stringify({ pid: process.pid, port, token, started: new Date().toISOString() }));
|
|
135
141
|
const idle = setInterval(() => { if (Date.now() - lastActive > idleMs) { server.close(); process.exit(0); } }, 60e3);
|
|
136
142
|
idle.unref();
|
|
143
|
+
|
|
144
|
+
// 退出语义:SIGINT/SIGTERM/正常 close → 摘 daemon.json(前台模式主语义)
|
|
145
|
+
const shutdown = () => {
|
|
146
|
+
console.log('\nserve: shutting down…');
|
|
147
|
+
fs.rmSync(daemonFile(ctx.hub), { force: true });
|
|
148
|
+
server.close(() => process.exit(0));
|
|
149
|
+
setTimeout(() => process.exit(0), 800).unref();
|
|
150
|
+
};
|
|
151
|
+
process.on('SIGINT', shutdown);
|
|
152
|
+
process.on('SIGTERM', shutdown);
|
|
153
|
+
|
|
137
154
|
if (flags.daemon) { console.log(`daemon ready :${port}`); await new Promise(() => {}); }
|
|
138
|
-
console.log(`serve: http://127.0.0.1:${port}
|
|
139
|
-
|
|
155
|
+
console.log(`serve: http://127.0.0.1:${port}/?token=${token}`);
|
|
156
|
+
console.log(` foreground — Ctrl-C 退出(idle ${ctx.config.daemon?.idle_minutes ?? 30}m 自退;分离模式见 --daemon)`);
|
|
157
|
+
await new Promise(() => {});
|
|
140
158
|
return 0;
|
|
141
159
|
}
|
package/client/lib/daemon.js
CHANGED
|
@@ -29,7 +29,9 @@ export async function ensureDaemon(ctx) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export function openURL(d, route = '/') {
|
|
32
|
-
|
|
32
|
+
// token 必须进 ?search(location.search 可读);#fragment 只带 tab 名
|
|
33
|
+
const frag = route.includes('#') ? `#${route.split('#')[1]}` : '';
|
|
34
|
+
const url = `http://127.0.0.1:${d.port}/?token=${d.token}${frag}`;
|
|
33
35
|
try { execFileSync('open', [url]); } catch { /* linux: xdg-open */ try { execFileSync('xdg-open', [url]); } catch { /* noop */ } }
|
|
34
36
|
return url;
|
|
35
37
|
}
|
package/client/public/app.js
CHANGED
|
@@ -3,73 +3,86 @@ const T = new URLSearchParams(location.search).get('token') || '';
|
|
|
3
3
|
const api = async (p, opt) => (await fetch(`/api${p}${p.includes('?') ? '&' : '?'}token=${T}`, { headers: { authorization: `Bearer ${T}` }, ...opt })).json();
|
|
4
4
|
const el = (h) => { const d = document.createElement('div'); d.innerHTML = h; return d.firstElementChild; };
|
|
5
5
|
const esc = (s) => String(s ?? '').replace(/[&<>]/g, (c) => ({ '&': '&', '<': '<', '>': '>' }[c]));
|
|
6
|
-
let S = null, tab = 'skills';
|
|
6
|
+
let S = null, tab = location.hash.slice(1).split('?')[0] || 'skills';
|
|
7
7
|
|
|
8
8
|
async function refresh() {
|
|
9
9
|
try { S = await api('/state'); }
|
|
10
|
-
catch (e) { document.getElementById('app').innerHTML = `<p class="pill bad">/api/state
|
|
11
|
-
if (S?.error) { document.getElementById('app').innerHTML = `<p class="pill bad">${esc(S.error)}
|
|
10
|
+
catch (e) { document.getElementById('app').innerHTML = `<p class="pill bad">/api/state 请求失败:${esc(e.message)}——daemon 挂了?重跑 skillmkt serve</p>`; return; }
|
|
11
|
+
if (S?.error) { document.getElementById('app').innerHTML = `<p class="pill bad">${esc(S.error)}——URL 里的 token 已失效,重跑 skillmkt serve 拿新链接</p>`; return; }
|
|
12
|
+
if (!location.hash && !S.initialized) { tab = 'setup'; location.hash = 'setup'; } // 未初始化→setup
|
|
12
13
|
render();
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
const syncTabs = () => document.querySelectorAll('nav [data-t]').forEach((x) => x.classList.toggle('on', x.dataset.t === tab));
|
|
16
|
+
document.querySelectorAll('nav [data-t]').forEach((t) => t.onclick = () => { tab = t.dataset.t; location.hash = tab; syncTabs(); render(); });
|
|
15
17
|
const es = new EventSource(`/api/events?token=${T}`);
|
|
16
18
|
es.addEventListener('decide', () => refresh());
|
|
17
|
-
es.
|
|
18
|
-
es.
|
|
19
|
+
es.addEventListener('config', () => refresh());
|
|
20
|
+
es.addEventListener('targets', () => refresh());
|
|
21
|
+
es.onopen = () => document.getElementById('live').textContent = 'live';
|
|
22
|
+
es.onerror = () => document.getElementById('live').textContent = 'offline';
|
|
19
23
|
|
|
20
|
-
const pill = (v) =>
|
|
24
|
+
const pill = (v) => {
|
|
25
|
+
const cls = ['clean', 'installed', 'active', 'managed', 'keep-a', 'keep-b'].includes(v) ? 'ok'
|
|
26
|
+
: ['malicious', 'pending', 'missing', 'outdated'].includes(v) ? 'bad' : 'warn';
|
|
27
|
+
return `<span class="pill ${cls}">${esc(v)}</span>`;
|
|
28
|
+
};
|
|
21
29
|
|
|
22
30
|
async function render() {
|
|
23
31
|
const app = document.getElementById('app');
|
|
24
|
-
|
|
32
|
+
document.getElementById('foot').textContent = `hub: ${S.hub}`;
|
|
33
|
+
syncTabs();
|
|
34
|
+
|
|
25
35
|
if (tab === 'skills') {
|
|
26
36
|
const skills = Object.entries(S.library.skills || {});
|
|
27
|
-
app.innerHTML = `<
|
|
37
|
+
app.innerHTML = `<h2>已受管 skills(${skills.length})</h2>` + (skills.map(([n, s]) => `
|
|
28
38
|
<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')}
|
|
29
|
-
<span class="mut" style="margin-left:auto">${(s.targets || []).join('
|
|
30
|
-
<button data-tg="${esc(n)}"
|
|
31
|
-
<div class="tgbox" data-box="${esc(n)}" style="display:none;margin-top:
|
|
32
|
-
// targets 编辑:勾选 harness → POST /api/targets 重投影
|
|
39
|
+
<span class="mut" style="margin-left:auto">${(s.targets || []).join('、') || '无目标'}</span>
|
|
40
|
+
<button data-tg="${esc(n)}">编辑目标</button></div>
|
|
41
|
+
<div class="tgbox" data-box="${esc(n)}" style="display:none;margin-top:8px"></div></div>`).join('') || '<p class="mut">还没有受管 skill——skillmkt install <ref></p>');
|
|
33
42
|
app.querySelectorAll('[data-tg]').forEach((b) => b.onclick = () => {
|
|
34
43
|
const box = app.querySelector(`[data-box="${b.dataset.tg}"]`);
|
|
35
44
|
if (box.style.display === 'block') { box.style.display = 'none'; return; }
|
|
36
45
|
const s = S.library.skills[b.dataset.tg];
|
|
37
46
|
box.style.display = 'block';
|
|
38
|
-
box.innerHTML =
|
|
39
|
-
|
|
40
|
-
|
|
47
|
+
box.innerHTML = `<label class="field">投影到(勾选后立即复制过去)</label>` +
|
|
48
|
+
(S.harnesses || []).filter((x) => x.state === 'installed' && !x.detectOnly).map((x) =>
|
|
49
|
+
`<label class="row"><input type="checkbox" data-th="${esc(x.id)}" ${(s.targets || []).includes(x.id) ? 'checked' : ''}> ${esc(x.id)} <span class="mut">${esc(x.primaryDir || '')}</span></label>`).join('')
|
|
50
|
+
+ `<div class="row" style="margin-top:8px"><button class="primary tgo">应用目标</button><span class="tout mut"></span></div>`;
|
|
41
51
|
box.querySelector('.tgo').onclick = async () => {
|
|
42
52
|
const ts = [...box.querySelectorAll('[data-th]:checked')].map((x) => x.dataset.th);
|
|
43
53
|
const r = await api('/targets', { method: 'POST', body: JSON.stringify({ name: b.dataset.tg, targets: ts }) });
|
|
44
|
-
box.querySelector('.tout').textContent = r.ok ? '
|
|
54
|
+
box.querySelector('.tout').textContent = r.ok ? '已应用' : `失败:${r.error}`;
|
|
45
55
|
refresh();
|
|
46
56
|
};
|
|
47
57
|
});
|
|
48
|
-
app.innerHTML += `<
|
|
58
|
+
app.innerHTML += `<h2>harness 探测</h2>` + (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] || '')}</span></div>`).join('');
|
|
49
59
|
const up = S.upstream.skills || {};
|
|
50
|
-
if (Object.keys(up).length) app.innerHTML += `<
|
|
60
|
+
if (Object.keys(up).length) app.innerHTML += `<h2>上游状态</h2>` + Object.entries(up).map(([n, u]) => `<div class="card row"><b>${esc(n)}</b>${u.outdated ? pill('outdated') : pill('clean')}<span class="mut">${esc(String(u.ref || '').slice(0, 8))}</span></div>`).join('');
|
|
51
61
|
}
|
|
62
|
+
|
|
52
63
|
if (tab === 'conflicts') {
|
|
53
64
|
const cs = S.conflicts || [];
|
|
54
|
-
|
|
65
|
+
const pendN = cs.filter((c) => c.status === 'pending').length;
|
|
66
|
+
app.innerHTML = `<h2>冲突队列(${pendN} 待裁决)</h2>`;
|
|
55
67
|
for (const c of cs) {
|
|
56
68
|
const card = el(`<div class="card"><div class="row"><b>${esc(c.id)}</b>${pill(c.status)}<span class="mut">${esc(c.domain || '')}</span></div>
|
|
57
|
-
<div class="side a">A
|
|
58
|
-
<div class="side b">B
|
|
69
|
+
<div class="side a">A · ${esc(c.sides[0].source)}<br>${esc(c.sides[0].text)}</div>
|
|
70
|
+
<div class="side b">B · ${esc(c.sides[1].source)}<br>${esc(c.sides[1].text)}</div>
|
|
59
71
|
${c.ai_explanation ? `<p class="mut">${esc(c.ai_explanation)}</p>` : ''}
|
|
72
|
+
${c.dismiss_reason ? `<p class="mut">dismiss:${esc(c.dismiss_reason)}</p>` : ''}
|
|
60
73
|
<div class="ev-imgs"></div>
|
|
61
74
|
${c.status === 'pending' ? `<div class="row" style="margin-top:8px">
|
|
62
|
-
<button data-r="keep-a"
|
|
63
|
-
<button data-r="merge"
|
|
75
|
+
<button data-r="keep-a">保留 A</button><button data-r="keep-b">保留 B</button>
|
|
76
|
+
<button data-r="merge">合并两条…</button><button data-r="dismissed">标为误报</button></div>
|
|
64
77
|
<div class="editbox" style="display:none;margin-top:8px">
|
|
65
|
-
<
|
|
66
|
-
<
|
|
67
|
-
<div class="row" style="margin-top:
|
|
68
|
-
if (c.evidence_files) card.querySelector('.ev-imgs').innerHTML = c.evidence_files.filter((f) => f.endsWith('.png')).map((f) => `<img class="ev" src="/evidence/${c.id}/${f}?token=${T}">`).join('');
|
|
78
|
+
<label class="field">合并后的规则文本</label><textarea class="mtext"></textarea>
|
|
79
|
+
<label class="field">裁决理由(必填)</label><input type="text" class="reason">
|
|
80
|
+
<div class="row" style="margin-top:8px"><button class="primary go">提交合并</button><button class="cancel">取消</button></div></div>` : ''}</div>`);
|
|
81
|
+
if (c.evidence_files) card.querySelector('.ev-imgs').innerHTML = c.evidence_files.filter((f) => f.endsWith('.png')).map((f) => `<img class="ev" src="/evidence/${c.id}/${f}?token=${T}" alt="evidence ${esc(f)}">`).join('');
|
|
69
82
|
const post = async (resolution, custom) => {
|
|
70
83
|
let reason = card.querySelector('.reason')?.value;
|
|
71
|
-
if (!reason) reason = prompt('
|
|
72
|
-
if (!reason.trim()) return alert('
|
|
84
|
+
if (!reason) reason = prompt('裁决理由(必填):', '') || '';
|
|
85
|
+
if (!reason.trim()) return alert('裁决理由必填');
|
|
73
86
|
await api('/decide', { method: 'POST', body: JSON.stringify({ id: c.id, resolution, custom, reason }) });
|
|
74
87
|
refresh();
|
|
75
88
|
};
|
|
@@ -77,7 +90,7 @@ async function render() {
|
|
|
77
90
|
if (b.dataset.r === 'merge') {
|
|
78
91
|
const box = card.querySelector('.editbox');
|
|
79
92
|
box.style.display = 'block';
|
|
80
|
-
box.querySelector('.mtext').value = `${c.sides[0].text}\n
|
|
93
|
+
box.querySelector('.mtext').value = `${c.sides[0].text}\n${c.sides[1].text}`;
|
|
81
94
|
box.querySelector('.mtext').focus();
|
|
82
95
|
return;
|
|
83
96
|
}
|
|
@@ -87,43 +100,48 @@ async function render() {
|
|
|
87
100
|
card.querySelector('.editbox .cancel')?.addEventListener('click', () => { card.querySelector('.editbox').style.display = 'none'; });
|
|
88
101
|
app.appendChild(card);
|
|
89
102
|
}
|
|
90
|
-
if (!cs.length) app.innerHTML += '<p class="mut"
|
|
103
|
+
if (!cs.length) app.innerHTML += '<p class="mut">无冲突记录——skillmkt merge <a> <b> 生成队列</p>';
|
|
91
104
|
}
|
|
105
|
+
|
|
92
106
|
if (tab === 'review') {
|
|
93
|
-
|
|
107
|
+
const scans = S.scans || [];
|
|
108
|
+
app.innerHTML = `<h2>审核记录(${scans.length})</h2>` + (scans.map((s) => `<div class="card row"><b>${esc(s.skill || s.name || '')}</b>${pill(s.verdict)}<span class="mut">${(s.findings || []).length} findings${s.llm ? `,llm: ${esc(s.llm.verdict)}` : ''}</span></div>`).join('') || '<p class="mut">无审核记录</p>');
|
|
109
|
+
const decs = (S.decisions || []).filter((d) => d.status === 'active');
|
|
110
|
+
if (decs.length) app.innerHTML += `<h2>已生效裁决(${decs.length})</h2>` + decs.map((d) => `<div class="card"><div class="row"><b>${esc(d.id)}</b>${pill(d.resolution)}<span class="mut">by ${esc(d.decided_by)}</span></div><p class="mut">${esc(d.reason)}</p></div>`).join('');
|
|
94
111
|
}
|
|
112
|
+
|
|
95
113
|
if (tab === 'setup') {
|
|
96
114
|
const h = S.harnesses || [];
|
|
97
115
|
const cfg = await api('/config');
|
|
98
116
|
const installed = h.filter((x) => x.state === 'installed' && !x.detectOnly).map((x) => x.id);
|
|
99
117
|
const sel = new Set(cfg.default_targets?.length ? cfg.default_targets : installed);
|
|
100
|
-
app.innerHTML = `<
|
|
101
|
-
<div class="card"><
|
|
102
|
-
<div class="row"><button id="probe">探测本地端点</button><span id="probe-out" class="mut"
|
|
118
|
+
app.innerHTML = `<h2>初始化与配置</h2>
|
|
119
|
+
<div class="card"><b>LLM 端点</b><span class="mut" id="cur">${cfg.llm?.model ? `(当前:${esc(cfg.llm.model)} @ ${esc(cfg.llm.base_url)})` : '(未配置)'}</span>
|
|
120
|
+
<div class="row" style="margin-top:8px"><button id="probe">探测本地端点</button><span id="probe-out" class="mut"></span></div>
|
|
103
121
|
<div id="eps"></div>
|
|
104
|
-
<
|
|
105
|
-
<
|
|
106
|
-
<
|
|
107
|
-
<div class="row"><button id="smoke">冒烟测试</button><span id="smoke-out" class="mut"></span></div></div>
|
|
108
|
-
<div class="card"><
|
|
109
|
-
${h.map((x) => `<label class="row"
|
|
110
|
-
<div class="card"><button id="save">保存配置</button><span id="save-out" class="mut"></span></div>`;
|
|
122
|
+
<label class="field">base_url</label><input type="text" id="murl" value="${esc(cfg.llm?.base_url || '')}">
|
|
123
|
+
<label class="field">model</label><input type="text" id="mmodel" value="${esc(cfg.llm?.model || '')}">
|
|
124
|
+
<label class="field">api_key(env:VAR 引用,不存真值;留空=无 key)</label><input type="text" id="mkey" value="${esc(cfg.llm?.api_key || '')}">
|
|
125
|
+
<div class="row" style="margin-top:8px"><button id="smoke">冒烟测试</button><span id="smoke-out" class="mut"></span></div></div>
|
|
126
|
+
<div class="card"><b>默认投影目标</b><span class="mut">(新装 skill 默认投到这里)</span>
|
|
127
|
+
${h.map((x) => `<label class="row"><input type="checkbox" data-h="${esc(x.id)}" ${sel.has(x.id) ? 'checked' : ''} ${x.state !== 'installed' ? 'disabled' : ''}> ${esc(x.id)} ${pill(x.state)} <span class="mut">${esc(x.primaryDir || '')}</span></label>`).join('')}</div>
|
|
128
|
+
<div class="card"><button class="primary" id="save">保存配置</button><span id="save-out" class="mut"></span></div>`;
|
|
111
129
|
app.querySelector('#probe').onclick = async () => {
|
|
112
|
-
app.querySelector('#probe-out').textContent = '
|
|
130
|
+
app.querySelector('#probe-out').textContent = '探测中…';
|
|
113
131
|
const eps = await api('/probe');
|
|
114
|
-
app.querySelector('#eps').innerHTML = eps.flatMap((e) => e.models.slice(0, 6).map((m) => `<div class="
|
|
132
|
+
app.querySelector('#eps').innerHTML = eps.flatMap((e) => e.models.slice(0, 6).map((m) => `<div class="ep" data-b="${esc(e.base_url)}" data-m="${esc(m)}">${esc(e.name)}:${e.port} — <code>${esc(m)}</code></div>`)).join('') || '<p class="mut">未发现(8001 / 11434 / 1234 / 8000 / 8080 / 1337 / 5000)</p>';
|
|
115
133
|
app.querySelector('#probe-out').textContent = `${eps.length} 个端点`;
|
|
116
134
|
app.querySelectorAll('#eps [data-b]').forEach((d) => d.onclick = () => { app.querySelector('#murl').value = d.dataset.b; app.querySelector('#mmodel').value = d.dataset.m; });
|
|
117
135
|
};
|
|
118
136
|
app.querySelector('#smoke').onclick = async () => {
|
|
119
|
-
app.querySelector('#smoke-out').textContent = '
|
|
137
|
+
app.querySelector('#smoke-out').textContent = '调用中…';
|
|
120
138
|
const r = await api('/llm-smoke', { method: 'POST', body: JSON.stringify({ base_url: app.querySelector('#murl').value, model: app.querySelector('#mmodel').value, api_key: app.querySelector('#mkey').value }) });
|
|
121
|
-
app.querySelector('#smoke-out').textContent = r.ok ?
|
|
139
|
+
app.querySelector('#smoke-out').textContent = r.ok ? `通过:${r.reply}` : `失败:${r.error}`;
|
|
122
140
|
};
|
|
123
141
|
app.querySelector('#save').onclick = async () => {
|
|
124
142
|
const targets = [...app.querySelectorAll('[data-h]:checked')].map((x) => x.dataset.h);
|
|
125
143
|
const r = await api('/config', { method: 'POST', body: JSON.stringify({ llm: { base_url: app.querySelector('#murl').value || null, model: app.querySelector('#mmodel').value || null, api_key: app.querySelector('#mkey').value || undefined, concurrency: 2, timeout_ms: 60000 }, default_targets: targets }) });
|
|
126
|
-
app.querySelector('#save-out').textContent = r.ok ? '
|
|
144
|
+
app.querySelector('#save-out').textContent = r.ok ? ' 已写入 config.yml' : ` 失败:${r.error}`;
|
|
127
145
|
refresh();
|
|
128
146
|
};
|
|
129
147
|
}
|
package/client/public/index.html
CHANGED
|
@@ -1,21 +1,91 @@
|
|
|
1
1
|
<!doctype html>
|
|
2
|
-
<html><head><meta charset="utf-8"><
|
|
2
|
+
<html lang="zh"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1">
|
|
3
|
+
<title>skillmkt — skills 管理面板</title>
|
|
3
4
|
<style>
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
5
|
+
/* skillmkt panel — 依 skill/SKILL.md 规则:light-first、OKLCH 角色 token、单强调色、
|
|
6
|
+
无玻璃/渐变/emoji 图标、可见标签、focus-visible ring、每屏至多一个填充主按钮 */
|
|
7
|
+
:root {
|
|
8
|
+
--color-paper: oklch(0.975 0.008 95);
|
|
9
|
+
--color-surface: oklch(0.995 0.004 95);
|
|
10
|
+
--color-ink: oklch(0.24 0.02 75);
|
|
11
|
+
--color-ink-mut: oklch(0.52 0.02 75);
|
|
12
|
+
--color-line: oklch(0.88 0.01 85);
|
|
13
|
+
--color-accent: oklch(0.52 0.14 55); /* 烧橙——唯一强调色 */
|
|
14
|
+
--color-accent-ink: oklch(0.99 0.01 90);
|
|
15
|
+
--color-ok: oklch(0.52 0.11 155);
|
|
16
|
+
--color-warn: oklch(0.55 0.13 80);
|
|
17
|
+
--color-bad: oklch(0.50 0.17 28);
|
|
18
|
+
--font-body: 15px/1.6 -apple-system, "SF Pro", "PingFang SC", "Noto Sans CJK SC", sans-serif;
|
|
19
|
+
--font-display: ui-serif, Georgia, "Songti SC", serif;
|
|
20
|
+
--font-mono: ui-monospace, SFMono-Regular, Menlo, monospace;
|
|
21
|
+
--radius: 8px;
|
|
22
|
+
}
|
|
23
|
+
* { box-sizing: border-box; }
|
|
24
|
+
body { margin: 0; font: var(--font-body); background: var(--color-paper); color: var(--color-ink); }
|
|
25
|
+
|
|
26
|
+
header { display: flex; align-items: baseline; gap: 26px; padding: 18px 28px 0; border-bottom: 1px solid var(--color-line); }
|
|
27
|
+
header h1 { font: 600 22px/1 var(--font-display); margin: 0 4px 0 0; letter-spacing: -0.01em; text-wrap: balance; }
|
|
28
|
+
nav { display: flex; gap: 4px; }
|
|
29
|
+
nav button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 8px 14px 10px;
|
|
30
|
+
font: inherit; color: var(--color-ink-mut); cursor: pointer; }
|
|
31
|
+
nav button.on { color: var(--color-ink); border-bottom-color: var(--color-accent); }
|
|
32
|
+
nav button:hover { color: var(--color-ink); }
|
|
33
|
+
#live { margin-left: auto; font-size: 13px; color: var(--color-ink-mut); padding-bottom: 10px; }
|
|
34
|
+
|
|
35
|
+
main { padding: 24px 28px 60px; max-width: 1080px; }
|
|
36
|
+
h2 { font: 600 17px/1.3 var(--font-body); margin: 26px 0 10px; text-wrap: balance; }
|
|
37
|
+
h2:first-child { margin-top: 0; }
|
|
38
|
+
.mut { color: var(--color-ink-mut); }
|
|
39
|
+
code { font-family: var(--font-mono); font-size: 0.92em; }
|
|
40
|
+
|
|
41
|
+
.card { background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius);
|
|
42
|
+
padding: 14px 16px; margin-bottom: 10px; }
|
|
43
|
+
.row { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
|
|
44
|
+
.row.end { justify-content: flex-end; }
|
|
45
|
+
|
|
46
|
+
.pill { display: inline-block; padding: 1px 9px; border: 1px solid var(--color-line); border-radius: 99px;
|
|
47
|
+
font-size: 12px; line-height: 1.5; color: var(--color-ink-mut); }
|
|
48
|
+
.pill.ok { color: var(--color-ok); border-color: color-mix(in oklch, var(--color-ok) 40%, var(--color-line)); }
|
|
49
|
+
.pill.warn { color: var(--color-warn); border-color: color-mix(in oklch, var(--color-warn) 45%, var(--color-line)); }
|
|
50
|
+
.pill.bad { color: var(--color-bad); border-color: color-mix(in oklch, var(--color-bad) 45%, var(--color-line)); }
|
|
51
|
+
|
|
52
|
+
button { font: inherit; padding: 6px 14px; border: 1px solid var(--color-line); border-radius: 6px;
|
|
53
|
+
background: var(--color-surface); color: var(--color-ink); cursor: pointer; }
|
|
54
|
+
button:hover { border-color: var(--color-ink-mut); }
|
|
55
|
+
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible {
|
|
56
|
+
outline: 2px solid var(--color-accent); outline-offset: 2px; }
|
|
57
|
+
button.primary { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-accent-ink); }
|
|
58
|
+
button.primary:hover { filter: brightness(0.94); }
|
|
59
|
+
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
|
|
60
|
+
|
|
61
|
+
label.field { display: block; margin: 10px 0 2px; font-size: 13px; color: var(--color-ink-mut); }
|
|
62
|
+
input[type=text], input:not([type]), textarea, select {
|
|
63
|
+
width: 100%; font: inherit; padding: 7px 10px; border: 1px solid var(--color-line);
|
|
64
|
+
border-radius: 6px; background: var(--color-paper); color: var(--color-ink); }
|
|
65
|
+
textarea { min-height: 6rem; resize: vertical; font-family: var(--font-mono); font-size: 13px; }
|
|
66
|
+
|
|
67
|
+
.side { padding: 10px 12px; border-left: 2px solid var(--color-line); margin: 8px 0; font-size: 14px; }
|
|
68
|
+
.side.a { border-color: var(--color-accent); }
|
|
69
|
+
.side.b { border-color: var(--color-warn); }
|
|
70
|
+
img.ev { max-width: 360px; width: 100%; border: 1px solid var(--color-line); border-radius: 6px; margin: 6px 8px 0 0; }
|
|
71
|
+
|
|
72
|
+
.ep { cursor: pointer; padding: 5px 10px; border-radius: 6px; }
|
|
73
|
+
.ep:hover { background: var(--color-paper); }
|
|
74
|
+
table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
|
75
|
+
td, th { text-align: left; padding: 5px 10px; border-bottom: 1px solid var(--color-line); }
|
|
76
|
+
th { font-size: 13px; color: var(--color-ink-mut); font-weight: 500; }
|
|
77
|
+
footer { padding: 20px 28px; border-top: 1px solid var(--color-line); font-size: 13px; color: var(--color-ink-mut); }
|
|
18
78
|
</style></head><body>
|
|
19
|
-
<header
|
|
20
|
-
<
|
|
79
|
+
<header>
|
|
80
|
+
<h1>skillmkt</h1>
|
|
81
|
+
<nav>
|
|
82
|
+
<button class="on" data-t="skills">skills</button>
|
|
83
|
+
<button data-t="conflicts">conflicts</button>
|
|
84
|
+
<button data-t="review">review</button>
|
|
85
|
+
<button data-t="setup">setup</button>
|
|
86
|
+
</nav>
|
|
87
|
+
<span id="live"></span>
|
|
88
|
+
</header>
|
|
89
|
+
<main id="app"><p class="mut">载入中…</p></main>
|
|
90
|
+
<footer id="foot"></footer>
|
|
21
91
|
<script src="/app.js"></script></body></html>
|