skillmkt 0.3.6 → 0.3.8

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.
@@ -49,11 +49,29 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
49
49
  };
50
50
  const body = (req) => new Promise((r) => { let b = ''; req.on('data', (c) => b += c); req.on('end', () => r(b || '{}')); });
51
51
 
52
+ // 请求 → 用户看得懂的动作;null = 静态资源/轮询等内部流量不打扰
53
+ const action = (req, u) => {
54
+ const p = u.pathname;
55
+ if (req.method === 'GET' && (p === '/' || p === '/index.html')) return '打开了网页';
56
+ if (req.method === 'GET' && p === '/api/state') return '刷新了页面数据';
57
+ if (req.method === 'GET' && p === '/api/probe') return '点了「扫描本机模型服务」';
58
+ if (req.method === 'POST' && p === '/api/config') return '保存了设置';
59
+ if (req.method === 'POST' && p === '/api/llm-smoke') return '点了「测试连接」';
60
+ if (req.method === 'POST' && p === '/api/models') return '验证密钥 / 读取模型列表';
61
+ if (req.method === 'POST' && p === '/api/targets') return '修改了 skill 的安装位置';
62
+ return null;
63
+ };
64
+
52
65
  const server = http.createServer(async (req, res) => {
53
66
  lastActive = Date.now();
54
- const t0 = Date.now();
55
- if (!quiet) res.on('finish', () => console.log(` ${req.method} ${req.url.replace(/token=[^&\s]+/g, 'token=***')} → ${res.statusCode} ${Date.now() - t0}ms`));
56
67
  const u = new URL(req.url, 'http://x');
68
+ if (!quiet) res.on('finish', () => {
69
+ const a = req.logNote ?? action(req, u);
70
+ if (a == null) return;
71
+ const tail = res.statusCode === 401 ? '(被拒绝:链接已过期,重新打开)'
72
+ : res.statusCode >= 400 ? `(失败 ${res.statusCode})` : '';
73
+ console.log(` ${new Date().toTimeString().slice(0, 8)} ${a}${tail}`);
74
+ });
57
75
  // auth:Bearer header 或 ?token=(SSE/img 用 query,服务端不下发 cookie)
58
76
  const authed = req.headers.authorization === `Bearer ${token}` || u.searchParams.get('token') === token;
59
77
  if (u.pathname === '/api/events') { // SSE
@@ -76,6 +94,7 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
76
94
  const c = loadConflicts(ctx.hub).find((x) => x.id === b.id);
77
95
  if (!c) { res.writeHead(404); return res.end('{"error":"not found"}'); }
78
96
  if (!b.reason?.trim()) { res.writeHead(400); return res.end('{"error":"reason required"}'); }
97
+ req.logNote = `裁决了一个冲突(${{ 'keep-a': '采用方案 A', 'keep-b': '采用方案 B', merge: '合并两条', dismissed: '其实不冲突' }[b.resolution] || b.resolution})`;
79
98
  decide(ctx.hub, c, { resolution: b.resolution, custom: b.custom || null, reason: b.reason, by: 'web-ui' });
80
99
  c.status = 'resolved';
81
100
  const { writeConflict } = await import('../lib/conflicts.js');
@@ -121,6 +140,7 @@ export async function startServer(ctx, { quiet = false, port = 0 } = {}) {
121
140
  }
122
141
  if (u.pathname === '/api/targets') { // web 改投影目标
123
142
  const name = b.name, targets = b.targets || [];
143
+ req.logNote = `修改了「${name}」的安装位置`;
124
144
  const lib = readLibrary(ctx.hub);
125
145
  const s = lib.skills?.[name];
126
146
  if (!s) { res.writeHead(404); return res.end('{"error":"not found"}'); }
@@ -217,13 +217,15 @@ async function render() {
217
217
  });
218
218
  // 填完服务地址自动检测是否需要密钥:已知端点直接看 needs_key,手输地址真发 /models 探
219
219
  let keyOk = !!app.querySelector('#mkey').value.trim(); // 已保存的密钥视为已验证;改动地址/密钥后回到未验证
220
+ let keyFailed = false; // 验证真失败过→显示「密钥错误」而非「未验证」
220
221
  const markKeyNeed = (need) => {
221
222
  const has = !!app.querySelector('#mkey').value.trim();
222
223
  const hasUrl = !!app.querySelector('#murl').value.trim();
223
224
  const want = !!need && !keyOk; // 要密钥且尚未验证通过
224
225
  app.querySelector('#key-row').style.display = (need || has) ? '' : 'none';
225
226
  app.querySelector('#mkey').classList.toggle('req', want);
226
- app.querySelector('#key-hint').textContent = want ? (has ? '← 密钥未验证' : '← 需要密钥') : '';
227
+ app.querySelector('#key-hint').textContent = want
228
+ ? (keyFailed ? '← 密钥错误' : (has ? '← 待验证' : '← 需要密钥')) : '';
227
229
  app.querySelector('#model-box').style.display = (hasUrl && !want) ? '' : 'none'; // 验证通过才出现
228
230
  };
229
231
  // 拿密钥真发 /models——通过才收录模型并放出模型框;失败保持隐藏
@@ -235,20 +237,20 @@ async function render() {
235
237
  out.textContent = '验证密钥…';
236
238
  const r = await api('/models', { method: 'POST', body: JSON.stringify({ base_url: cur, api_key: key }) });
237
239
  if (r.models?.length) {
238
- keyOk = true;
240
+ keyOk = true; keyFailed = false;
239
241
  for (const m of r.models) { modelMap.set(m, cur); loadedModels.set(m, cur); }
240
242
  const ep = epsList.find((e) => e.base_url === cur);
241
243
  if (ep) { ep.needs_key = false; ep.models = r.models; }
242
244
  markKeyNeed(true); refreshOpts();
243
245
  out.textContent = `密钥有效,已加载 ${r.models.length} 个模型`;
244
246
  } else {
245
- keyOk = false; markKeyNeed(true); // 模型框保持隐藏
246
- out.textContent = r.error ? `密钥无效:${r.error}` : '密钥通了,但没读到模型';
247
+ keyOk = false; keyFailed = true; markKeyNeed(true); // 模型框保持隐藏
248
+ out.textContent = r.error ? `密钥错误:${r.error}` : '密钥通了,但没读到模型';
247
249
  }
248
250
  };
249
251
  markKeyNeed(false); // 初始:无密钥需求→藏密钥行
250
252
  app.querySelector('#murl').addEventListener('input', () => {
251
- keyOk = false;
253
+ keyOk = false; keyFailed = false;
252
254
  const cur = app.querySelector('#murl').value.trim().replace(/\/+$/, '');
253
255
  markKeyNeed(epsList.find((e) => e.base_url === cur)?.needs_key);
254
256
  refreshOpts(); renderDrop();
@@ -256,7 +258,7 @@ async function render() {
256
258
  app.querySelector('#mmodel').addEventListener('input', () => { renderDrop(); app.querySelector('#model-drop').style.display = 'block'; });
257
259
  app.querySelector('#mmodel').addEventListener('blur', () => setTimeout(() => { app.querySelector('#model-drop').style.display = 'none'; }, 120));
258
260
  app.querySelector('#mkey').addEventListener('input', () => {
259
- keyOk = false; // 密钥改动→回到未验证态,模型框收起
261
+ keyOk = false; keyFailed = false; // 密钥改动→回到未验证态,模型框收起
260
262
  const cur = app.querySelector('#murl').value.trim().replace(/\/+$/, '');
261
263
  markKeyNeed(epsList.find((e) => e.base_url === cur)?.needs_key);
262
264
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillmkt",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "type": "module",
5
5
  "description": "Local-first agent skill manager: install, audit, merge, distribute.",
6
6
  "license": "MIT",