skillmkt 0.3.7 → 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"}'); }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skillmkt",
3
- "version": "0.3.7",
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",