@double_geste/agent-standup 1.35.0 → 1.37.0
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/codex.js +2 -1
- package/kokoro.js +3 -2
- package/package.json +1 -1
- package/public/index.html +146 -33
- package/public/locales/da.json +40 -1
- package/public/locales/de.json +44 -5
- package/public/locales/en.json +40 -1
- package/public/locales/es.json +40 -1
- package/public/locales/ja.json +40 -1
- package/public/locales/ko.json +40 -1
- package/public/locales/pt-BR.json +40 -1
- package/public/locales/zh-CN.json +40 -1
- package/public/locales/zh-TW.json +40 -1
- package/server.js +109 -35
- package/vibe.js +2 -1
|
@@ -264,6 +264,7 @@
|
|
|
264
264
|
"The shop is not open yet.": "商店尚未開放。",
|
|
265
265
|
"The shop cannot be reached. Check your connection and try again.": "無法連線到商店。請檢查網路連線後再試一次。",
|
|
266
266
|
"Hand-drawn Halloween characters, each in its own room.": "手繪萬聖節角色,每個角色都有自己的房間。",
|
|
267
|
+
"Entirely optional: the app stays free. It is a way to support the artist and the developer.": "完全自願:應用程式始終免費。這是支持畫師和開發者的一種方式。",
|
|
267
268
|
"One payment, by card, on a Stripe page. No account.": "在 Stripe 頁面以信用卡一次付清。不需要帳戶。",
|
|
268
269
|
"Buy": "購買",
|
|
269
270
|
"I already bought it": "我已購買",
|
|
@@ -305,5 +306,43 @@
|
|
|
305
306
|
"Got it": "知道了",
|
|
306
307
|
"Reset to defaults": "恢復預設設定",
|
|
307
308
|
"Your settings moved: the everyday ones are here, the rest in “All settings”.": "設定換了位置:常用的在這裡,其餘的在「全部設定」裡。",
|
|
308
|
-
"2 € minimum: you can pay more on the payment page if you like.": "最低 2 歐元:如果願意,可以在付款頁面多付一些。"
|
|
309
|
+
"2 € minimum: you can pay more on the payment page if you like.": "最低 2 歐元:如果願意,可以在付款頁面多付一些。",
|
|
310
|
+
"worked": "工作了",
|
|
311
|
+
"waiting on you for": "已等你",
|
|
312
|
+
"working for": "已工作",
|
|
313
|
+
"(one or more)": "(可複選)",
|
|
314
|
+
"(pick one)": "(單選)",
|
|
315
|
+
"Answer it in Claude Code": "請在 Claude Code 中回答",
|
|
316
|
+
"asks permission to use": "請求使用",
|
|
317
|
+
"asks to edit this file": "請求編輯此檔案",
|
|
318
|
+
"asks to open this page": "請求開啟此頁面",
|
|
319
|
+
"asks to run this command": "請求執行此命令",
|
|
320
|
+
"has a question for you": "有一個問題要問你",
|
|
321
|
+
"has several questions for you": "有幾個問題要問你",
|
|
322
|
+
"Hide until the next question": "隱藏到下一個問題",
|
|
323
|
+
"may be waiting for your go-ahead on this command": "可能在等你核准這條命令",
|
|
324
|
+
"may be waiting for your go-ahead to edit this file": "可能在等你核准編輯此檔案",
|
|
325
|
+
"proposes this plan": "提出了這個計畫",
|
|
326
|
+
"the numbers match the menu": "編號與選單一致",
|
|
327
|
+
"What the session is waiting for from you": "工作階段在等你做什麼",
|
|
328
|
+
"is waiting for your answer": "在等你的回答",
|
|
329
|
+
"A menu is open in Claude Code.": "Claude Code 中有一個開啟的選單。",
|
|
330
|
+
"Speed presets": "速度預設",
|
|
331
|
+
"pages": "頁",
|
|
332
|
+
"⭐ Rate Agent Standup": "⭐ 為 Agent Standup 評分",
|
|
333
|
+
"⭐ Star Agent Standup on GitHub": "⭐ 在 GitHub 上為 Agent Standup 加星",
|
|
334
|
+
"⭐ Star it": "⭐ 加星",
|
|
335
|
+
"Enjoying Agent Standup? A star on GitHub helps other people find it.": "喜歡 Agent Standup 嗎?在 GitHub 上加顆星能幫助更多人發現它。",
|
|
336
|
+
"Later": "以後再說",
|
|
337
|
+
"No thanks": "不用了",
|
|
338
|
+
"Model": "模型",
|
|
339
|
+
"Repeated work": "重複的工作",
|
|
340
|
+
"repeated work": "重複的工作",
|
|
341
|
+
"read again: {0}": "再次讀取:{0}",
|
|
342
|
+
"already read by {0}: {1}": "{0} 已讀過:{1}",
|
|
343
|
+
"same search again: {0}": "再次進行相同的搜尋:{0}",
|
|
344
|
+
"same search as {0}: {1}": "與 {0} 相同的搜尋:{1}",
|
|
345
|
+
"reran a failing command: {0}": "重新執行失敗的指令:{0}",
|
|
346
|
+
"☕ Buy a coffee": "☕ 請喝杯咖啡",
|
|
347
|
+
"{0} and the team are done. If the call helped you follow this long run, a coffee keeps Agent Standup going. (We only ask once.)": "{0} 和團隊已經完成。如果這次通話幫你跟上了這段長時間的工作,一杯咖啡能讓 Agent Standup 繼續下去。(我們只問這一次。)"
|
|
309
348
|
}
|
package/server.js
CHANGED
|
@@ -368,9 +368,31 @@ const readTail = (file, bytes) => { const fd = fs.openSync(file, 'r'); try { con
|
|
|
368
368
|
const readHead = (file, bytes) => { const fd = fs.openSync(file, 'r'); try { const n = Math.min(bytes, fs.fstatSync(fd).size), buf = Buffer.alloc(n); fs.readSync(fd, buf, 0, n, 0); return buf.toString('utf8'); } finally { fs.closeSync(fd); } };
|
|
369
369
|
const APPROVAL = /^(Edit|Write|MultiEdit|NotebookEdit)/, ASKS = /^(AskUserQuestion|ExitPlanMode)/, SUBTOOL = /^(Task|Agent)$/;
|
|
370
370
|
const boardCache = new Map(); // file → { sig, parsed, title }
|
|
371
|
-
let boardMemo = { at: 0, rows: [] };
|
|
371
|
+
let boardMemo = { at: 0, rows: [] }, boardForced = 0;
|
|
372
372
|
const PR_URL = /^https:\/\/github\.com\/[\w.-]+\/[\w.-]+\/pull\/\d+$/; // nothing else is given to the page as a link to open
|
|
373
373
|
const askOf = (b) => { const q = b.name === 'AskUserQuestion' && b.input && Array.isArray(b.input.questions) && b.input.questions[0] && b.input.questions[0].question; return typeof q === 'string' ? clip(q.trim(), 200) : ''; }; // the question a session stopped on, for its card
|
|
374
|
+
const callOf = (b) => { const i = b.input || {}, v = b.name === 'Bash' ? i.command : /^(Edit|Write|MultiEdit|NotebookEdit)$/.test(b.name) ? path.basename(String(i.file_path || i.notebook_path || '')) : b.name === 'WebFetch' ? i.url : ''; return typeof v === 'string' && v.trim() ? b.name + '(' + clip(v.replace(/\s+/g, ' ').trim(), 160) + ')' : ''; }; // what a call waiting for your go-ahead would do, written the way Claude Code shows it: Bash(npm test)
|
|
375
|
+
const PLAN_FILE = /[\\/]\.claude[\\/]plans[\\/][^\\/]+\.md$/, PLAN_DIR = process.env.CLAUDE_CONFIG_DIR ? path.join(process.env.CLAUDE_CONFIG_DIR, 'plans') + path.sep : '';
|
|
376
|
+
const planFile = (f) => PLAN_FILE.test(f) || (!!PLAN_DIR && f.startsWith(PLAN_DIR) && f.endsWith('.md')); // also where a CLAUDE_CONFIG_DIR set elsewhere keeps them
|
|
377
|
+
const planText = (f) => { try { const st = fs.statSync(f); if (!st.isFile() || st.size > 262144) return ''; return clip(fs.readFileSync(f, 'utf8').trim(), 1200); } catch { return ''; } };
|
|
378
|
+
const menuOf = (b) => { // what a menu waiting for you shows, from the call it waits on, word for word: the questions and their options in their order (the terminal numbers them the same way), the command, the file, the plan
|
|
379
|
+
const i = b.input || {}, t = (x, n) => (typeof x === 'string' ? clip(x.trim(), n) : '');
|
|
380
|
+
if (b.name === 'AskUserQuestion') return { kind: 'question', questions: (Array.isArray(i.questions) ? i.questions : []).slice(0, 4).map((q) => ({ q: t(q && q.question, 300), multi: !!(q && q.multiSelect), options: (q && Array.isArray(q.options) ? q.options : []).slice(0, 8).map((o) => ({ label: t(o && o.label, 80), about: t(o && o.description, 140) })).filter((o) => o.label) })).filter((q) => q.q) };
|
|
381
|
+
if (b.name === 'ExitPlanMode') return { kind: 'plan', text: t(i.plan, 1200) };
|
|
382
|
+
if (b.name === 'Bash') return { kind: 'command', cmd: t(i.command, 600), about: t(i.description, 160) };
|
|
383
|
+
if (/^(Edit|Write|MultiEdit|NotebookEdit)$/.test(b.name)) return { kind: 'edit', file: t(i.file_path || i.notebook_path, 300) };
|
|
384
|
+
if (b.name === 'WebFetch') return { kind: 'fetch', url: t(i.url, 300) };
|
|
385
|
+
return { kind: 'tool', tool: t(b.name, 80) };
|
|
386
|
+
};
|
|
387
|
+
// Claude Code also keeps <config>/sessions/<pid>.json for each open session: its status (busy, idle, or waiting while a menu waits for your answer: a permission, a question) and since when.
|
|
388
|
+
// It is the only sign of a Bash approval: in the transcript, a command waiting for your go-ahead looks just like one that runs. A file whose process has ended is left out.
|
|
389
|
+
const CC_SESSIONS = process.env.AGENT_STANDUP_CC_SESSIONS || path.join(process.env.CLAUDE_CONFIG_DIR || path.join(os.homedir(), '.claude'), 'sessions');
|
|
390
|
+
const alive = (pid) => { try { process.kill(pid, 0); return true; } catch (e) { return e.code === 'EPERM'; } };
|
|
391
|
+
function liveStatus() { // session id → { status, since }
|
|
392
|
+
const out = new Map(); let names = []; try { names = fs.readdirSync(CC_SESSIONS); } catch { return out; }
|
|
393
|
+
for (const n of names) { if (!/^\d+\.json$/.test(n)) continue; try { const s = JSON.parse(fs.readFileSync(path.join(CC_SESSIONS, n), 'utf8')); if (s && typeof s.sessionId === 'string' && /^(busy|idle|waiting)$/.test(s.status) && Number.isInteger(s.pid) && s.pid > 0 && alive(s.pid)) out.set(s.sessionId, { status: s.status === 'waiting' && s.waitingFor === 'dialog open' ? 'idle' : s.status, since: Number(s.statusUpdatedAt) || 0 }); } catch {} } /* a dialog you opened yourself (/model, /config, /mcp…) also says waiting: it is not a question for you */
|
|
394
|
+
return out;
|
|
395
|
+
}
|
|
374
396
|
// When the person last did something in a session: an order, a slash command, a "!" command, an order typed while the lead was working. It is what moves the live call (see currentSession).
|
|
375
397
|
// Not what the harness writes as a user record: the result of a tool, a reminder, the news that a background task ended, the summary of a compaction, an Esc.
|
|
376
398
|
// Nor the prompt of a task Cowork runs on a schedule (it opens with <scheduled-task …>): nobody typed it, so it does not take the call from the session you are in.
|
|
@@ -390,8 +412,8 @@ function typedBefore(file) { // the first look at a session whose last order i
|
|
|
390
412
|
function parseTail(file, st) {
|
|
391
413
|
const sig = st.mtimeMs + ':' + st.size, hit = boardCache.get(file); if (hit && hit.sig === sig) return hit;
|
|
392
414
|
const { text, cut } = readTail(file, 192 * 1024), lines = text.split('\n'); if (cut) lines.shift();
|
|
393
|
-
const pend = new Map(); let lastType = null, lastTool = false, lastStop = null, stops = false, esc = false, lastTs = 0, custom = (hit && hit.custom) || null, ai = (hit && hit.ai) || null, first = hit ? hit.first : undefined, pr = (hit && hit.pr) || null, asked = (hit && hit.asked) || 0;
|
|
394
|
-
for (const l of lines) {
|
|
415
|
+
const pend = new Map(); let lastType = null, lastTool = false, lastStop = null, stops = false, esc = false, lastTs = 0, custom = (hit && hit.custom) || null, ai = (hit && hit.ai) || null, first = hit ? hit.first : undefined, pr = (hit && hit.pr) || null, asked = (hit && hit.asked) || 0, plan = (hit && hit.plan) || null;
|
|
416
|
+
for (const l of lines) try { // one odd record costs that record, not the whole card
|
|
395
417
|
if (!l) continue; let r; try { r = JSON.parse(l); } catch { continue; }
|
|
396
418
|
const a = typedAt(r); if (a > asked) asked = a;
|
|
397
419
|
if (r.type === 'custom-title' && typeof r.customTitle === 'string') custom = r.customTitle; else if (r.type === 'ai-title' && typeof r.aiTitle === 'string') ai = r.aiTitle; // a session is renamed, or named, long after its row was first shown: the latest one read wins
|
|
@@ -399,8 +421,9 @@ function parseTail(file, st) {
|
|
|
399
421
|
const t = Date.parse(r.timestamp) || 0, bl = blocks(r);
|
|
400
422
|
if (r.type === 'assistant' || r.type === 'user') { lastType = r.type; lastTool = bl.some((b) => b.type === 'tool_use'); lastStop = (r.type === 'assistant' && r.message && r.message.stop_reason) || null; if (lastStop) stops = true; if (t) lastTs = t;
|
|
401
423
|
esc = r.type === 'user' && bl.some((b) => b.type === 'text' && /^\s*\[Request interrupted/i.test(b.text || '')); if (esc) pend.clear(); } // Esc: the turn stops there, and no call is waited for any more
|
|
402
|
-
for (const b of bl)
|
|
403
|
-
|
|
424
|
+
for (const b of bl) if (b.type === 'tool_use' && /^(Write|Edit|MultiEdit)$/.test(b.name) && b.input && planFile(String(b.input.file_path || ''))) plan = { file: String(b.input.file_path), ts: t }; // the plan, written in its own file before it is shown for approval
|
|
425
|
+
for (const b of bl) { if (b.type === 'tool_use') pend.set(b.id, { id: String(b.id || ''), name: b.name, ts: t, q: askOf(b), c: callOf(b), m: menuOf(b) }); else if (b.type === 'tool_result') pend.delete(b.tool_use_id); }
|
|
426
|
+
} catch {}
|
|
404
427
|
if (!hit && !custom) { // first look at this file: a little further back than the lines read above, and without needing whole lines
|
|
405
428
|
const big = readTail(file, 256 * 1024).text, un = (m) => { try { return m ? JSON.parse('"' + m[1] + '"') : null; } catch { return null; } };
|
|
406
429
|
custom = un([...big.matchAll(/"type":"custom-title","customTitle":"((?:[^"\\]|\\.)*)"/g)].pop()); if (!ai) ai = un([...big.matchAll(/"type":"ai-title","aiTitle":"((?:[^"\\]|\\.)*)"/g)].pop());
|
|
@@ -408,7 +431,7 @@ function parseTail(file, st) {
|
|
|
408
431
|
if (!custom && !ai && first == null) first = firstPrompt(file) || (st.size > 64 * 1024 ? '' : null); // '' = looked for and not there; a file that has just been created is looked at again
|
|
409
432
|
if (!hit && !asked && cut) asked = typedBefore(file);
|
|
410
433
|
const out = { sig, title: custom || ai || first || null, custom, ai, first, pr, lastType, lastTool, lastStop, stops, esc, lastTs, pending: [...pend.values()] }; // a title the person typed wins over the generated one, and both over the first prompt
|
|
411
|
-
out.asked = asked; boardCache.set(file, out); if (boardCache.size >
|
|
434
|
+
out.asked = asked; out.plan = plan; boardCache.set(file, out); if (boardCache.size > 3 * ROWS_MAX) boardCache.delete(boardCache.keys().next().value); return out; // more than the list can hold: a full list never pushes its own rows out, which read every row again at each scan
|
|
412
435
|
}
|
|
413
436
|
function firstPrompt(file) { // the first thing the person typed, read record by record: a pattern over the raw text ran from a user record into the assistant's first answer and took that as the title
|
|
414
437
|
const ONE = (t) => t.replace(/\s+/g, ' ').trim().slice(0, 90);
|
|
@@ -424,28 +447,42 @@ function boardRows() {
|
|
|
424
447
|
if (Date.now() - boardMemo.at < 1200) return boardMemo.rows; // several windows polling at once share one scan
|
|
425
448
|
const out = withDone(boardRows0()); boardMemo = { at: Date.now(), rows: out }; return out;
|
|
426
449
|
}
|
|
450
|
+
// How many sessions the list keeps, newest first, of each kind (Claude Code, each other tool, Cowork): `most` of them, and whatever the count, the PER_FOLDER newest of each folder, so that
|
|
451
|
+
// sessions written elsewhere never push the ones of a folder out. That is what happened with only a count: the Claude Code session of the folder the call follows left the list, and with it its
|
|
452
|
+
// tab and the call, behind 40 sessions a desktop app had just written in temporary folders (issue #9). Sessions started in a temporary folder (see tmpKey) have places of their own, TMP_ROWS at most.
|
|
453
|
+
const PER_FOLDER = 3, TMP_ROWS = 10, ROWS_MAX = 200; // ROWS_MAX: a ceiling on what the folders add, for someone with hundreds of folders (one worktree per task)
|
|
454
|
+
function capRows(list, most, folderOf) { // list: newest first
|
|
455
|
+
const real = list.filter((r) => !tmpKey(folderOf(r))), keep = new Set(real.slice(0, most)), per = new Map();
|
|
456
|
+
for (const r of real) { if (keep.size >= ROWS_MAX) break; const k = folderOf(r), n = per.get(k) || 0; if (n < PER_FOLDER) { keep.add(r); per.set(k, n + 1); } }
|
|
457
|
+
return real.filter((r) => keep.has(r)).concat(list.filter((r) => tmpKey(folderOf(r))).slice(0, TMP_ROWS));
|
|
458
|
+
}
|
|
427
459
|
function boardRows0() {
|
|
428
|
-
const now = Date.now(), rows = [];
|
|
460
|
+
const now = Date.now(), rows = [], live = liveStatus();
|
|
429
461
|
for (const m of SOURCES) for (const r of guard(() => m.sessions(), [])) if (now - r.mtime < 12 * 3600e3) rows.push({ proj: m.PROJ, id: r.id, st: { mtimeMs: r.mtime, size: r.size }, cx: r, src: m });
|
|
430
462
|
for (const proj of projects()) {
|
|
431
463
|
for (const { id, file } of transcripts(proj)) { try { const st = fs.statSync(file); if (now - st.mtimeMs < 12 * 3600e3) rows.push({ proj, id, st }); } catch {} }
|
|
432
464
|
}
|
|
433
465
|
rows.sort((a, b) => b.st.mtimeMs - a.st.mtimeMs);
|
|
434
|
-
|
|
466
|
+
const own = (r) => r.proj, folder = (r) => String(r.cx.key || r.cx.dir || ''); // a Claude Code session is listed under its folder; a Codex or Vibe one says which folder it was started in
|
|
467
|
+
return capRows(rows.filter((r) => !r.cx && r.proj !== COWORK), 40, own).concat(...SOURCES.map((m) => capRows(rows.filter((r) => r.src === m), 20, folder)), rows.filter((r) => r.proj === COWORK).slice(0, 20)).sort((a, b) => b.st.mtimeMs - a.st.mtimeMs).map(({ proj, id, st, cx, src }) => {
|
|
435
468
|
if (cx) { const r = guard(() => src.boardRow(cx, now), null); if (r && tmpKey(r.dir)) r.tmp = 1; return r; } // tmp: started in the temporary folder (see tmpKey)
|
|
436
469
|
const file = path.join(projDir(proj, id), id + '.jsonl'); let p; try { p = parseTail(file, st); } catch { p = { pending: [] }; }
|
|
437
|
-
const age = now - st.mtimeMs,
|
|
438
|
-
if (
|
|
470
|
+
const age = now - st.mtimeMs, pend = p.pending || [], w = live.get(id), lp = (w && w.status === 'waiting' && pend.find((c) => !SUBTOOL.test(c.name))) || pend[pend.length - 1]; let state = 'idle', tool = '', ageMs = age, since = 0, open = null; // lp: with a menu open and several calls waiting, Claude Code asks about the first of them
|
|
471
|
+
if (w && w.status === 'waiting' && lp) { state = 'blocked'; tool = lp.name; since = w.since || lp.ts || st.mtimeMs; ageMs = now - since; } // a menu is open in the session and a call waits on it: it needs you now, however long ago it was written
|
|
472
|
+
else if (w && w.status === 'waiting') { state = 'blocked'; since = w.since || st.mtimeMs; ageMs = now - since; const pt = p.plan && p.plan.ts > (p.asked || 0) ? planText(p.plan.file) : ''; open = { id: 'w' + since, tool: pt ? 'ExitPlanMode' : '', ...(pt ? { kind: 'plan', text: pt } : { kind: 'menu' }), sure: 1 }; } // a menu is open and the transcript has no call waiting on it: the plan to approve (Claude Code writes that call only once it is answered, the plan itself is in its file, written this turn), or a menu it does not record
|
|
473
|
+
else if (age < 30 * 60e3) {
|
|
439
474
|
if (lp) { ageMs = now - (lp.ts || st.mtimeMs); tool = lp.name;
|
|
440
|
-
state = SUBTOOL.test(lp.name) ? 'waiting' : (ASKS.test(lp.name) && ageMs > 4000) || (APPROVAL.test(lp.name) && ageMs > 15000) ? 'blocked' : 'working'; }
|
|
475
|
+
state = SUBTOOL.test(lp.name) ? 'waiting' : (ASKS.test(lp.name) && ageMs > 4000) || (APPROVAL.test(lp.name) && ageMs > 15000) ? 'blocked' : 'working'; if (state === 'blocked') since = lp.ts || st.mtimeMs; } // still a guess from how long a call has waited: a session in VS Code asks in its panel, which may not say "waiting"
|
|
441
476
|
else if (p.esc) state = 'turn'; // you stopped it (Esc): it is your turn there, not "working" for the next ten minutes
|
|
442
477
|
else if (p.lastType === 'assistant' && !p.lastTool && p.lastStop !== 'tool_use' && !(p.lastStop == null && p.stops && age < 45000)) state = 'turn'; // a line whose message goes on with a tool call is not the end of the turn: the call is written after it, a long one many seconds after.
|
|
443
478
|
// Claude Code up to 2.1.87 writes that line without saying why it stopped: in a transcript that does say it elsewhere, such a line is given 45 s for its call to come (1 in 100 takes longer than 25 s)
|
|
444
479
|
else state = age < 10 * 60e3 ? 'working' : 'idle';
|
|
480
|
+
if (state === 'turn') since = p.lastTs || st.mtimeMs;
|
|
445
481
|
}
|
|
446
482
|
let subActive = 0, subTotal = 0;
|
|
447
483
|
for (const x of subFiles(proj, id)) { subTotal++; if (now - mtimeOf(x.file) < 90e3) subActive++; }
|
|
448
|
-
|
|
484
|
+
const ran = since && p.asked && p.asked < since ? since - p.asked : 0, ask = state === 'blocked' && lp ? lp.q || lp.c : ''; // since: when it started to wait on you; ran: how long it worked, from your last order to then
|
|
485
|
+
return { proj, id, title: coworkTitle(proj, id) || p.title || id, mtime: st.mtimeMs, state, tool, ageMs, subActive, subTotal, asked: p.asked || 0, ...(since ? { since } : {}), ...(ran ? { ran } : {}), ...(p.pr ? { pr: p.pr } : {}), ...(ask ? { ask } : {}), ...(open ? { menu: open } : state === 'blocked' && lp && lp.m && !SUBTOOL.test(lp.name) ? { menu: { id: lp.id, tool: lp.name, ...lp.m, ...(w && w.status === 'waiting' ? { sure: 1 } : {}) } } : {}), ...(p.esc ? { cut: 1 } : {}), ...(tmpKey(proj) ? { tmp: 1 } : {}) }; // cut: stopped by you, which is no news to tell you
|
|
449
486
|
}).filter(Boolean);
|
|
450
487
|
}
|
|
451
488
|
// Settings live in a file, not only in the page's localStorage: the port changes between VS Code windows and reloads, and localStorage is per origin (port included).
|
|
@@ -502,6 +539,14 @@ function logError(where, e) {
|
|
|
502
539
|
fs.appendFileSync(ERRLOG, JSON.stringify({ t: new Date().toISOString(), v: VERSION, where: tidy(where, 80), msg, stack }) + '\n');
|
|
503
540
|
} catch {}
|
|
504
541
|
}
|
|
542
|
+
// Where this server runs, for ⚙ › Rate in the page: the editor (it sets AGENT_STANDUP_RATE to the review page of the store it installs from), the desktop app or the command line
|
|
543
|
+
// (a star on GitHub: they have no store). Only the desktop app and the command line ask on their own, on the third day: the extension asks in its own way (extension.js, noteUse).
|
|
544
|
+
const RATE_STORES = /^https:\/\/(marketplace\.visualstudio\.com|open-vsx\.org)\//, GITHUB_REPO = 'https://github.com/Atoll92/agent-standup';
|
|
545
|
+
function appKind() {
|
|
546
|
+
const h = String(process.env.AGENT_STANDUP_HOST || ''), rate = String(process.env.AGENT_STANDUP_RATE || '');
|
|
547
|
+
const kind = h === 'desktop app' ? 'desktop' : h === 'command line' ? 'cli' : h ? 'editor' : '';
|
|
548
|
+
return { kind, rate: kind === 'editor' && RATE_STORES.test(rate) ? rate : GITHUB_REPO };
|
|
549
|
+
}
|
|
505
550
|
function errorReport() { // what ⚙ › Report a problem shows: the app, the system and the last errors of the log
|
|
506
551
|
let errors = []; try { errors = fs.readFileSync(ERRLOG, 'utf8').split('\n').filter(Boolean).slice(-40).map((l) => { try { return JSON.parse(l); } catch { return null; } }).filter((x) => x && typeof x === 'object'); } catch {}
|
|
507
552
|
return { version: VERSION, host: String(process.env.AGENT_STANDUP_HOST || '').slice(0, 80), platform: `${process.platform} ${os.release()} ${process.arch}`, node: process.version, electron: process.versions.electron || '', file: tidy(ERRLOG, 300), errors };
|
|
@@ -515,6 +560,7 @@ process.on('uncaughtExceptionMonitor', (e, origin) => { try { if (OWN || String(
|
|
|
515
560
|
// One exception, so that the call is not left on an empty room: when the session you last typed in has finished and been quiet for STICK_MS while another one is at work, the call
|
|
516
561
|
// goes to that one. A session you went to by hand is not left that way.
|
|
517
562
|
const STICK_MS = 90000;
|
|
563
|
+
const MENU_LIVE_MS = 30 * 60e3; // a menu left open longer still needs you (board, visitor), but no longer takes the call from where you work
|
|
518
564
|
// Sessions started in the system's temporary folder: a program running Claude Code there for a moment (a test, a script, a tool that makes a folder per run), not a session someone works in.
|
|
519
565
|
// When the call looks everywhere it leaves them out, unless there is nothing else; they have no tab then and send no visitor. They stay in the Sessions view, and a window open on such a folder follows it.
|
|
520
566
|
// macOS: /var/folders/… (/private/… once resolved) and /tmp; Linux: /tmp; Windows: …\AppData\Local\Temp; and wherever TMPDIR points. A key is a folder as Claude Code names it, every other character a "-".
|
|
@@ -526,15 +572,26 @@ function sessionMtime(proj, id) {
|
|
|
526
572
|
let m = sx ? r.mtime : mtimeOf(path.join(projDir(proj, id), id + '.jsonl')); if (!m) return 0; const subs = subFilesOf(proj, id);
|
|
527
573
|
for (const x of subs) m = Math.max(m, mtimeOf(x.file)); for (const d of subs.dirs) m = Math.max(m, mtimeOf(d)); return m; // the folders too: a new file in them is activity, as when every file around the transcripts was looked at
|
|
528
574
|
}
|
|
575
|
+
// A project of Claude Code is named after its folder with every character other than a letter or digit made a dash: -Users-a-app-old may be app/old (inside app) or app-old (beside it).
|
|
576
|
+
// Which one is told by the folder its sessions were started in (the cwd of its first records), read once per project. Not found (an empty project): counted as before, by its name.
|
|
577
|
+
const projCwds = new Map(), dirKey = (d) => String(d || '').replace(/[^a-zA-Z0-9]/g, '-');
|
|
578
|
+
function projCwd(proj) {
|
|
579
|
+
if (projCwds.has(proj)) return projCwds.get(proj);
|
|
580
|
+
let cwd = ''; for (const { id } of transcripts(proj).slice(0, 3)) { try { const m = /"cwd":"((?:[^"\\]|\\.)*)"/.exec(readHead(path.join(projDir(proj, id), id + '.jsonl'), 64 * 1024)); if (m) { cwd = JSON.parse('"' + m[1] + '"'); break; } } catch {} }
|
|
581
|
+
if (cwd && dirKey(cwd) === proj) projCwds.set(proj, cwd); return cwd && dirKey(cwd) === proj ? cwd : ''; // kept once it is sure: the folder whose name is the project's
|
|
582
|
+
}
|
|
583
|
+
const inFolder = (proj, key) => { if (proj === key) return true; if (!proj.startsWith(key + '-')) return false; const cwd = projCwd(proj); if (!cwd) return true; for (let d = cwd; d;) { if (dirKey(d) === key) return true; const up = path.dirname(d); if (up === d) return false; d = up; } return false; };
|
|
529
584
|
function currentSession(projFilter, pick, stick, anyTmp) { // pick: { proj, id, since } the session you went to by hand, and the latest order there was then · stick: the session the call is in · anyTmp: sessions in the temporary folder count too (see tmpKey)
|
|
530
585
|
const safe = (x) => typeof x === 'string' && /^[\w.\-]+$/.test(x) && x !== '..', now = Date.now();
|
|
531
586
|
const there = (c) => !!c && safe(c.id) && safe(c.proj) && (sourceOf(c.proj) ? !!guard(() => sourceOf(c.proj).fileOf(c.id), null) : fs.existsSync(path.join(projDir(c.proj, c.id), c.id + '.jsonl')));
|
|
532
|
-
const inScope = (c) => (!projFilter ? anyTmp || !tmpSession(c.proj, c.id) : c.proj
|
|
533
|
-
const same = (a, b) => !!a && !!b && a.proj === b.proj && a.id === b.id
|
|
587
|
+
const inScope = (c) => (!projFilter ? anyTmp || !tmpSession(c.proj, c.id) : inFolder(c.proj, projFilter) || !!(sourceOf(c.proj) && guard(() => sourceOf(c.proj).inProject(c.id, projFilter), false))); // a Codex or Vibe session counts for a project when it was started in that folder
|
|
588
|
+
const same = (a, b) => !!a && !!b && a.proj === b.proj && a.id === b.id; let all = boardRows();
|
|
589
|
+
if (there(pick) && !all.some((r) => same(r, pick)) && now - boardForced > 5000 && sessionMtime(pick.proj, pick.id) > boardMemo.at - 1500) { boardForced = now; boardMemo.at = 0; all = boardRows(); } // boardForced: at most every 5 s, for a session written to that the list never holds (older than 12 h, past the places of its kind) // the session you went to was written after the list shared for 1.2 s was made: without it, its order read as none, and the next answer dropped your pick
|
|
590
|
+
const rows = all.filter(inScope), mine = there(pick) ? all.find((r) => same(r, pick)) : null;
|
|
534
591
|
const asked = Math.max(0, (mine && mine.asked) || 0, ...rows.map((r) => r.asked || 0)); // the latest order, in the folder the call follows or in the session you went to
|
|
535
592
|
const moved = pick && pick.pin ? Math.max(0, ...rows.filter((r) => !same(r, pick)).map((r) => r.asked || 0)) : asked; // pick.pin: a call pinned by a click on its tab (📌) is left for an order typed in another session only; what you type in it keeps it there
|
|
536
593
|
if (there(pick) && !(moved > pick.since)) return { proj: pick.proj, id: pick.id, mtime: now, asked, pick: 1 }; // no "since" on the first question after a pick: the answer gives it (asked), and the page sends it back from then on
|
|
537
|
-
const live = rows.filter((r) => /^(working|waiting
|
|
594
|
+
const live = rows.filter((r) => /^(working|waiting)$/.test(r.state) || (r.state === 'blocked' && !(now - (r.since || now) > MENU_LIVE_MS)) || r.subActive > 0 || now - r.mtime < STICK_MS), last = Math.max(0, ...live.map((r) => r.asked || 0)), top = live.filter((r) => (r.asked || 0) === last);
|
|
538
595
|
const to = top.find((r) => same(r, stick)) || top.sort((a, b) => b.mtime - a.mtime)[0]; // two sessions whose last order is not known (or of the same instant): the call stays where it is
|
|
539
596
|
if (to) return { proj: to.proj, id: to.id, mtime: to.mtime, asked };
|
|
540
597
|
if (there(stick) && inScope(stick)) return { proj: stick.proj, id: stick.id, mtime: sessionMtime(stick.proj, stick.id), asked }; // nobody is at work: the call stays where it is
|
|
@@ -542,7 +599,7 @@ function currentSession(projFilter, pick, stick, anyTmp) { // pick: { proj, id
|
|
|
542
599
|
const consider = (proj, id, m) => { if (!best || m > best.mtime) best = { proj, id, mtime: m }; };
|
|
543
600
|
for (const m of SOURCES) for (const r of guard(() => m.sessions(), [])) if (inScope({ proj: m.PROJ, id: r.id })) consider(m.PROJ, r.id, r.mtime);
|
|
544
601
|
for (const proj of projects()) {
|
|
545
|
-
if (projFilter ? proj
|
|
602
|
+
if (projFilter ? !inFolder(proj, projFilter) : !anyTmp && tmpKey(proj)) continue; // the folder itself, or a folder inside it (a Cowork session is in no folder of yours: it counts when the call looks everywhere, or at Cowork)
|
|
546
603
|
for (const { id } of transcripts(proj)) { const m = sessionMtime(proj, id); if (m) consider(proj, id, m); } // 0: a link to a transcript that is gone
|
|
547
604
|
}
|
|
548
605
|
if (!best && projFilter) return { ...currentSession('', null, stick), wide: 1 };
|
|
@@ -711,7 +768,8 @@ function buildTimeline(proj, id, files = []) {
|
|
|
711
768
|
|
|
712
769
|
// Ask the local `claude` CLI (uses the user's existing login) to map a JSON array of strings to another array. Cached.
|
|
713
770
|
const { spawn } = require('child_process');
|
|
714
|
-
const cache = new Map();
|
|
771
|
+
const cache = new Map(), CACHE_MAX = 5000; // translations and little lines, by text: the oldest go first past CACHE_MAX (an editor open for days kept every line of every session)
|
|
772
|
+
const remember = (k, v) => { cache.delete(k); cache.set(k, v); if (cache.size > CACHE_MAX) cache.delete(cache.keys().next().value); };
|
|
715
773
|
// Find a usable `claude` binary: explicit setting → PATH → usual install spots → the one bundled with the VS Code Claude Code extension.
|
|
716
774
|
let lastTrError = '', claudeCache = null;
|
|
717
775
|
const exists = (f) => { try { return fs.statSync(f).isFile(); } catch { return false; } };
|
|
@@ -736,10 +794,14 @@ function findClaude() {
|
|
|
736
794
|
const found = cands.find(exists) || bundledClaude() || null;
|
|
737
795
|
return (claudeCache = found);
|
|
738
796
|
}
|
|
797
|
+
// Through cmd.exe, Node joins the arguments with spaces and quotes none: the empty value of --tools vanished and the system prompt became one argument per word. Quoted, each stays whole
|
|
798
|
+
// (a line break or a double quote inside would end it: there are none in what is sent, and they are made harmless anyway).
|
|
799
|
+
const winArg = (a) => '"' + String(a).replace(/[\r\n]+/g, ' ').replace(/"/g, "'") + '"';
|
|
739
800
|
function spawnClaude(args, opts) {
|
|
740
801
|
const bin = findClaude(); if (!bin) { lastTrError = 'not-found'; return null; }
|
|
741
|
-
|
|
742
|
-
|
|
802
|
+
const p = process.platform === 'win32' && /\.(cmd|bat)$/i.test(bin) ? spawn('"' + bin + '"', args.map(winArg), { ...opts, shell: true, windowsHide: true }) : spawn(bin, args, { ...opts, windowsHide: true }); // npm's Windows shims need a shell, which takes the arguments as they are: each one is quoted
|
|
803
|
+
if (p.stdin) p.stdin.on('error', () => {}); // a claude that exits before reading its prompt (not signed in, an old version): EPIPE would otherwise end the whole server
|
|
804
|
+
return p;
|
|
743
805
|
}
|
|
744
806
|
let running = 0; const queue = [];
|
|
745
807
|
const pump = () => { while (running < 3 && queue.length) { running++; queue.shift()(); } };
|
|
@@ -757,7 +819,7 @@ function claudeMap(kind, instruction, texts) {
|
|
|
757
819
|
const done = (ok) => ({ texts: texts.map((t) => cache.get(kind + '|' + t) || t), ok });
|
|
758
820
|
if (!need.length) return Promise.resolve(done(true));
|
|
759
821
|
const prompt = instruction + ' Output ONLY a JSON array of strings, same length and order, no markdown.\n' + JSON.stringify(need);
|
|
760
|
-
return apiMap(prompt, need).then((arr) => { need.forEach((t, i) =>
|
|
822
|
+
return apiMap(prompt, need).then((arr) => { need.forEach((t, i) => remember(kind + '|' + t, String(arr[i]))); return done(true); }).catch(() => schedule(() => new Promise((resolve) => {
|
|
761
823
|
const p = spawnClaude(['-p', '--model', 'haiku', '--no-session-persistence', '--tools', ''], { cwd: os.tmpdir() }); if (!p) return resolve(done(false));
|
|
762
824
|
let out = ''; const timer = setTimeout(() => p.kill(), 60000);
|
|
763
825
|
p.stdout.on('data', (d) => (out += d));
|
|
@@ -767,7 +829,7 @@ function claudeMap(kind, instruction, texts) {
|
|
|
767
829
|
let ok = false;
|
|
768
830
|
try {
|
|
769
831
|
const arr = JSON.parse(out.slice(out.indexOf('['), out.lastIndexOf(']') + 1));
|
|
770
|
-
if (arr.length === need.length) { need.forEach((t, i) =>
|
|
832
|
+
if (arr.length === need.length) { need.forEach((t, i) => remember(kind + '|' + t, String(arr[i]))); ok = true; }
|
|
771
833
|
} catch {}
|
|
772
834
|
resolve(done(ok));
|
|
773
835
|
});
|
|
@@ -817,7 +879,7 @@ const pickWorker = () => trWorkers.reduce((a, b) => (a.q.length + a.busy <= b.q.
|
|
|
817
879
|
async function translateFast(texts, lang = 'fr') {
|
|
818
880
|
const need = [...new Set(texts.filter((t) => !cache.has(lang + '|' + t)))];
|
|
819
881
|
if (need.length && need.length <= 3 && !process.env.ANTHROPIC_API_KEY) { // a few lines: warm workers in parallel; many lines: one batched call
|
|
820
|
-
await Promise.all(need.map(async (t) => { const r = await pickWorker().ask(t, lang); if (r)
|
|
882
|
+
await Promise.all(need.map(async (t) => { const r = await pickWorker().ask(t, lang); if (r) remember(lang + '|' + t, r); }));
|
|
821
883
|
return { texts: texts.map((t) => cache.get(lang + '|' + t) || t), ok: texts.every((t) => cache.has(lang + '|' + t)) };
|
|
822
884
|
}
|
|
823
885
|
return claudeMap(lang, trInstr(lang), texts);
|
|
@@ -846,10 +908,11 @@ function loadVoices() { // the same list for the page, asked without waiting:
|
|
|
846
908
|
if (sayVoices) return Promise.resolve(sayVoices);
|
|
847
909
|
return sayVoicesJob || (sayVoicesJob = new Promise((resolve) => { try { execFile(VOICES_CMD[0], VOICES_CMD[1], { encoding: 'utf8', timeout: VOICES_CMD[2], windowsHide: true }, (err, out) => resolve(sayVoices || (sayVoices = parseVoices(err ? '' : String(out))))); } catch { resolve(sayVoices || (sayVoices = parseVoices(''))); } }));
|
|
848
910
|
}
|
|
849
|
-
const ttsDir = path.join(os.tmpdir(), 'agent-standup-tts-' + (process.getuid ? process.getuid() : 'user'));
|
|
911
|
+
const ttsDir = process.platform === 'linux' ? path.join(process.env.XDG_CACHE_HOME || path.join(os.homedir(), '.cache'), 'agent-standup', 'tts') : path.join(os.tmpdir(), 'agent-standup-tts-' + (process.getuid ? process.getuid() : 'user')); // Linux: /tmp is shared by every user, and a folder or file put there first by someone else would have been used (written through, or played); macOS and Windows give each user a temporary folder of their own
|
|
850
912
|
try { fs.mkdirSync(ttsDir, { recursive: true, mode: 0o700 }); } catch {}
|
|
851
913
|
const ttsJobs = new Map();
|
|
852
|
-
try { for (const f of fs.readdirSync(ttsDir)) { const p = path.join(ttsDir, f); if (Date.now() - fs.statSync(p).mtimeMs > 864e5) fs.unlinkSync(p); } } catch {} // drop cached audio older than a day
|
|
914
|
+
const ttsClean = () => { try { for (const f of fs.readdirSync(ttsDir)) { const p = path.join(ttsDir, f); if (Date.now() - fs.statSync(p).mtimeMs > 864e5) fs.unlinkSync(p); } } catch {} }; // drop cached audio older than a day
|
|
915
|
+
ttsClean(); setInterval(ttsClean, 3600e3).unref(); // also while an editor stays open for days
|
|
853
916
|
function synthesize(voice, wpm, text, out) {
|
|
854
917
|
return new Promise((resolve, reject) => {
|
|
855
918
|
let p; text = text.replace(/\[\[[^\]]*\]\]/g, ' ').replace(/\[(?=\[)/g, '[ ').replace(/\](?=\])/g, '] '); // macOS `say` obeys commands written between [[ and ]] (a 30-second silence, another voice, another speed) and this text comes from a transcript: they are taken out, and no two brackets are left side by side
|
|
@@ -1002,14 +1065,18 @@ const reveal = { // run and stat: replaced in the tests, which must not open a
|
|
|
1002
1065
|
},
|
|
1003
1066
|
run(file) { const go = (list) => { const c = list[0]; if (!c) return; try { execFile(c[0], c[1], c[2] || {}, (err) => { if (err) go(list.slice(1)); }); } catch { go(list.slice(1)); } }; go(reveal.cmds(file)); },
|
|
1004
1067
|
};
|
|
1005
|
-
|
|
1068
|
+
// Which window plays sound, in a file next to the settings: each VS Code window has its own server, and two windows with the call open both spoke.
|
|
1069
|
+
const AUDIO = path.join(path.dirname(PREFS), 'audio.json');
|
|
1070
|
+
let audioMem = { id: null, seen: 0 }, audioFile = true; // audioFile false: the file cannot be written (a read-only folder), this server keeps the owner itself as it used to
|
|
1071
|
+
const audioOwner = () => { if (!audioFile) return audioMem; try { const a = JSON.parse(fs.readFileSync(AUDIO, 'utf8')); if (a && typeof a.id === 'string') return { id: a.id, seen: Math.min(+a.seen || 0, Date.now()) }; } catch {} return { id: null, seen: 0 }; }; // min: a clock set back left a time to come, and the owner never expired
|
|
1072
|
+
const audioSave = (a) => { audioMem = a; try { fs.mkdirSync(path.dirname(AUDIO), { recursive: true }); const t = AUDIO + '.' + process.pid; fs.writeFileSync(t, JSON.stringify(a)); fs.renameSync(t, AUDIO); } catch { audioFile = false; } }; // whole or not at all: another server may read it at that moment
|
|
1006
1073
|
function start(port = PORT) {
|
|
1007
1074
|
return http.createServer((req, res) => {
|
|
1008
1075
|
let url; try { url = new URL(req.url, 'http://x'); } catch { res.writeHead(400); return res.end('bad request'); } // "GET //" is not an address: answered, where it used to stop the whole server
|
|
1009
1076
|
req.on('error', () => {}); res.on('error', () => {}); // a browser that goes away mid-request is not our problem
|
|
1010
1077
|
// Only the local machine may talk to this server: blocks other websites (cross-site requests) and DNS-rebinding attempts.
|
|
1011
1078
|
const local = (h) => /^(localhost|127\.0\.0\.1|\[::1\])(:\d+)?$/.test(h || '');
|
|
1012
|
-
let originOk = true; try { originOk = !req.headers.origin || local(new URL(req.headers.origin).host); } catch { originOk = false; }
|
|
1079
|
+
let originOk = true; try { originOk = !req.headers.origin || (local(new URL(req.headers.origin).host) && new URL(req.headers.origin).host === req.headers.host); } catch { originOk = false; } // the page's own address: another local page (a dev server on another port) is another site
|
|
1013
1080
|
if (!local(req.headers.host) || !originOk) { res.writeHead(403); return res.end('forbidden'); }
|
|
1014
1081
|
const json = (o, code = 200) => { try { res.writeHead(code, { 'content-type': 'application/json' }); res.end(JSON.stringify(o)); } catch { res.destroy(); } }; // also called from callbacks that run later, where nothing would catch an exception
|
|
1015
1082
|
const sendFile = (fp) => { const s = fs.createReadStream(fp); s.on('error', () => res.destroy()); s.pipe(res); }; // a file that vanished between the check and the read ends this answer, not the server
|
|
@@ -1033,10 +1100,11 @@ function start(port = PORT) {
|
|
|
1033
1100
|
}
|
|
1034
1101
|
if (url.pathname === '/api/audio') { // only one window at a time plays sound: the last one that claimed it (expires if that window stops answering)
|
|
1035
1102
|
const cid = url.searchParams.get('cid') || '', ok = /^[\w-]{4,40}$/.test(cid);
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
if (
|
|
1039
|
-
|
|
1103
|
+
const now = Date.now(); let a = audioOwner();
|
|
1104
|
+
if (ok && url.searchParams.get('claim')) audioSave((a = { id: cid, seen: now }));
|
|
1105
|
+
else if (ok && a.id === cid && now - a.seen > 2000) audioSave((a = { id: cid, seen: now })); // the owner says it is still there, written every 2 s at most
|
|
1106
|
+
if (a.id && now - a.seen > 6000) a = { id: null, seen: 0 };
|
|
1107
|
+
return json({ owner: a.id });
|
|
1040
1108
|
}
|
|
1041
1109
|
if (url.pathname === '/api/health') return json({ claude: findClaude(), apiKey: !!process.env.ANTHROPIC_API_KEY, trError: lastTrError, platform: process.platform });
|
|
1042
1110
|
if (url.pathname === '/api/warm') { const lang = trLang(url.searchParams.get('lang')); trWorkers.forEach((w) => { if (!w.p) w.start(lang); }); return json({ ok: true }); }
|
|
@@ -1051,7 +1119,7 @@ function start(port = PORT) {
|
|
|
1051
1119
|
.then((f) => { res.writeHead(200, { 'content-type': 'audio/wav', 'cache-control': 'max-age=86400' }); sendFile(f); })
|
|
1052
1120
|
.catch((e) => json({ error: String(e.message) }, 400));
|
|
1053
1121
|
}
|
|
1054
|
-
if (url.pathname === '/api/prefs.js') { res.writeHead(200, { 'content-type': 'application/javascript', 'cache-control': 'no-store' }); return res.end('window.SAVED_PREFS = ' + JSON.stringify(readPrefs()).replace(/</g, '\\u003c') + ';'); }
|
|
1122
|
+
if (url.pathname === '/api/prefs.js') { res.writeHead(200, { 'content-type': 'application/javascript', 'cache-control': 'no-store' }); return res.end('window.SAVED_PREFS = ' + JSON.stringify(readPrefs()).replace(/</g, '\\u003c') + '; window.AS_APP = ' + JSON.stringify(appKind()).replace(/</g, '\\u003c') + ';'); }
|
|
1055
1123
|
if (url.pathname === '/api/prefs' && req.method === 'PUT') return readBody((body) => { try { const v = JSON.parse(body); if (!v || typeof v !== 'object' || Array.isArray(v)) throw new Error('prefs must be an object'); writePrefs(v); json({ ok: true }); } catch (e) { json({ error: String(e.message || e) }, 400); } });
|
|
1056
1124
|
if (url.pathname === '/api/prefs') return json(readPrefs() || {});
|
|
1057
1125
|
if (url.pathname === '/api/done' && req.method === 'POST') return readBody((body) => { try { const v = JSON.parse(body); json({ ok: setDone(String(v.proj || ''), String(v.id || ''), v.on !== false) }); } catch (e) { logError('done', e); json({ error: String(e.message || e) }, 400); } });
|
|
@@ -1115,19 +1183,25 @@ function start(port = PORT) {
|
|
|
1115
1183
|
let f = ''; try { f = decodeURIComponent(pk ? pk[2] : url.pathname.slice('/characters/'.length)); } catch {}
|
|
1116
1184
|
const dir = pk ? packDir(pk[1]) : charactersDir(), fp = path.join(dir, f);
|
|
1117
1185
|
try { const ls = fs.lstatSync(fp); if (!CHAR_NAME.test(f) || !fp.startsWith(dir + path.sep) || !ls.isFile() || ls.size > CHAR_MAX) throw 0; } catch { res.writeHead(404); return res.end('not found'); }
|
|
1118
|
-
res.writeHead(200, { 'content-type': CHAR_TYPES[f.split('.').pop().toLowerCase()] || 'application/octet-stream', 'cache-control': 'no-cache' }); return sendFile(fp);
|
|
1186
|
+
res.writeHead(200, { 'content-type': CHAR_TYPES[f.split('.').pop().toLowerCase()] || 'application/octet-stream', 'cache-control': 'no-cache', 'x-content-type-options': 'nosniff' }); return sendFile(fp);
|
|
1119
1187
|
}
|
|
1120
1188
|
const file = path.join(PUBLIC, url.pathname === '/' ? 'index.html' : url.pathname);
|
|
1121
1189
|
let fst = null; try { fst = fs.statSync(file); } catch {}
|
|
1122
1190
|
if (!file.startsWith(PUBLIC + path.sep) || !fst || !fst.isFile()) { res.writeHead(404); return res.end('not found'); }
|
|
1123
1191
|
// The only frame of the page is the window of an artifact, served from here. Without this line a page shown there could take its own frame to another site, and send out what it holds in the address.
|
|
1124
|
-
res.writeHead(200, { 'content-type': MIME[path.extname(file)] || 'application/octet-stream', ...(path.extname(file) === '.html' ? { 'content-security-policy': "frame-src 'self'" } : {}) });
|
|
1192
|
+
res.writeHead(200, { 'content-type': MIME[path.extname(file)] || 'application/octet-stream', ...(path.extname(file) === '.html' ? { 'content-security-policy': "frame-src 'self'; object-src 'none'; base-uri 'none'; form-action 'none'" } : {}) });
|
|
1125
1193
|
res.end(fs.readFileSync(file));
|
|
1126
1194
|
} catch (e) { logError(req.method + ' ' + url.pathname, e); if (res.headersSent) return res.destroy(); json({ error: String(e.message || e) }, 500); }
|
|
1127
1195
|
}).listen(port, '127.0.0.1', function () { console.log(`Agent Standup → http://localhost:${this.address().port}`); });
|
|
1128
1196
|
}
|
|
1129
|
-
module.exports = { start, currentSession, shutdown, findClaude, bundledClaude, boardRows, sessionRows: listSessions, charactersDir, listCharacters, packsDir, installPack, logError, _reveal: reveal, _scrub: { tidy, homeRe }, _artifact: { page: artifactPage, csp: artifactCsp } };
|
|
1130
|
-
if (require.main === module) {
|
|
1197
|
+
module.exports = { _winArg: winArg, start, currentSession, shutdown, findClaude, bundledClaude, boardRows, sessionRows: listSessions, charactersDir, listCharacters, packsDir, installPack, logError, _reveal: reveal, _scrub: { tidy, homeRe }, _artifact: { page: artifactPage, csp: artifactCsp } };
|
|
1198
|
+
if (require.main === module && process.env.AGENT_STANDUP_CHILD === '1' && typeof process.send === 'function') { // started by the VS Code extension in a process of its own (see extension.js): reading a large session no longer stops the editor's extensions. Asked for by name: pm2 and others give any app a channel too
|
|
1199
|
+
const srv = start(+process.env.PORT || 0), tell = (m) => { try { process.send(m); } catch {} };
|
|
1200
|
+
srv.on('listening', () => tell({ port: srv.address().port })).on('error', (e) => { tell({ error: e.code || String(e) }); process.exit(1); });
|
|
1201
|
+
process.on('message', (m) => { if (m && m.env && typeof m.env === 'object') for (const [k, v] of Object.entries(m.env)) { if (v == null) delete process.env[k]; else process.env[k] = String(v); } }); // a setting changed in the editor (claudePath, codex, vibe…)
|
|
1202
|
+
process.on('disconnect', () => { try { shutdown(); } catch {} process.exit(0); }); // the editor window closed, or its extension host ended: this server ends with it
|
|
1203
|
+
process.on('uncaughtException', (e) => logError('crash', e)); process.on('unhandledRejection', (e) => logError('promise', e)); // written down and gone on, as in the extension host it ran in before: one odd request does not end the call
|
|
1204
|
+
} else if (require.main === module) {
|
|
1131
1205
|
start().on('error', (e) => {
|
|
1132
1206
|
console.error(e.code === 'EADDRINUSE' ? `Port ${PORT} is already in use (maybe Agent Standup is already running, e.g. inside VS Code). Try: PORT=4790 node server.js` : String(e));
|
|
1133
1207
|
process.exit(1);
|
package/vibe.js
CHANGED
|
@@ -73,7 +73,8 @@ function meta(dir) {
|
|
|
73
73
|
}
|
|
74
74
|
// The sessions a person started, newest first, each with the folder it was started in.
|
|
75
75
|
function sessions(limit = 80) { return scan().rows.slice(0, limit).map((r) => { const m = meta(r.dir); return { ...r, cwd: m.cwd, key: dirKey(m.cwd) }; }); } // meta.json is written in both formats
|
|
76
|
-
const
|
|
76
|
+
const under = (cwd, key) => { for (let d = String(cwd || ''); d;) { if (dirKey(d) === key) return true; const up = path.dirname(d); if (up === d) return false; d = up; } return false; }; // key is the folder itself or one above it: a dashed name alone cannot tell app/old (inside app) from app-old (beside it)
|
|
77
|
+
const inProject = (id, key) => { const r = row(id); if (!r || !key) return false; if (key === PROJ) return true; const c = meta(r.dir).cwd, d = dirKey(c); return d === key || (d.startsWith(key + '-') && under(c, key)); };
|
|
77
78
|
const cwd = (id) => { const r = row(id); return r ? meta(r.dir).cwd : ''; }; // the folder the session was started in: where a file it names by a relative path is
|
|
78
79
|
const projectLabel = (cwd) => { const h = os.homedir(), rel = cwd && cwd.startsWith(h + path.sep) ? cwd.slice(h.length + 1) : cwd; return 'Mistral Vibe' + (rel ? ' · ' + rel.split(path.sep).join('/') : ''); };
|
|
79
80
|
|