@double_geste/agent-standup 1.30.0 → 1.32.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/vibe.js CHANGED
@@ -74,6 +74,7 @@ function meta(dir) {
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
76
  const inProject = (id, key) => { const r = row(id); if (!r || !key) return false; if (key === PROJ) return true; const d = dirKey(meta(r.dir).cwd); return d === key || d.startsWith(key + '-'); };
77
+ 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
77
78
  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('/') : ''); };
78
79
 
79
80
  // ---- names: the title Vibe gave the session, else the first thing the person typed
@@ -113,18 +114,22 @@ function boardRow(r, now) {
113
114
  if (r.uni) { // the current format says it outright: idle, running, or blocked on an approval or a question
114
115
  const u = uniSummary(r), kind = u.status, age = now - r.mtime, live = u.live;
115
116
  const state = age >= 30 * 60e3 ? 'idle' : kind === 'blocked' ? 'blocked' : kind === 'running' ? (u.waiting ? 'waiting' : 'working') : kind === 'idle' || kind === 'failed' ? 'turn' : age < 10 * 60e3 ? 'working' : 'idle';
116
- return { proj: PROJ, id: r.id, title: title(r), mtime: r.mtime, state, tool: '', ageMs: age, subActive: state === 'idle' || state === 'turn' ? 0 : live, subTotal: u.kids, dir: dirKey(meta(r.dir).cwd), source: SOURCE };
117
+ return { proj: PROJ, id: r.id, title: title(r), mtime: r.mtime, state, tool: '', ageMs: age, subActive: state === 'idle' || state === 'turn' ? 0 : live, subTotal: u.kids, asked: u.asked || 0, dir: dirKey(meta(r.dir).cwd), source: SOURCE };
117
118
  }
118
119
  const sig = r.mtime + ':' + r.size; let t = tailCache.get(r.file);
119
120
  if (!t || t.sig !== sig) {
120
- t = { sig, turn: '' };
121
- const n = Math.min(256 * 1024, r.size), lines = readPart(r.file, r.size - n, n).split('\n').filter(Boolean); let last = null; try { last = JSON.parse(lines[lines.length - 1] || ''); } catch {}
121
+ const was = t; let alone = false; t = { sig, turn: '', asked: (was && was.asked) || 0, at: -1 };
122
+ const n = Math.min(256 * 1024, r.size), text = readPart(r.file, r.size - n, n), lines = text.split('\n').filter(Boolean); let last = null; try { last = JSON.parse(lines[lines.length - 1] || ''); } catch {}
123
+ // A message carries no time. The last thing the person typed is known by its place in the file: when that place has moved since the last look, something was typed, about when the file was last written.
124
+ // On the first look it is the time of the file when nothing was written after it, and else the start of the session.
125
+ for (let end = text.length, i; end > 0 && t.at < 0; end = i) { i = text.lastIndexOf('\n', end - 1); const l = text.slice(i + 1, end); if (!l.includes('"user"')) continue; try { const j = JSON.parse(l); if (j && j.role === 'user' && !j.injected && ((j.manual_shell && typeof j.manual_shell.command === 'string') || typed(j))) { t.at = r.size - Buffer.byteLength(text.slice(end)); alone = !text.slice(end).trim(); } } catch {} }
126
+ if (t.at >= 0 && (was ? t.at !== was.at : alone)) t.asked = r.mtime;
122
127
  if (last && typeof last === 'object') t.turn = last.role === 'assistant' && !(Array.isArray(last.tool_calls) && last.tool_calls.length) ? 'closed' : 'open'; // a plain answer closes the turn; a tool call or a tool result means the agent goes on
123
128
  if (tailCache.size > 200) tailCache.delete(tailCache.keys().next().value); tailCache.set(r.file, t);
124
129
  }
125
130
  const m = meta(r.dir), subs = m.children.map((c) => stat(path.join(r.dir, c.rel, MESSAGES))).filter(Boolean), newest = Math.max(r.mtime, ...subs.map((s) => s.mtimeMs));
126
131
  const age = now - newest, state = age >= 30 * 60e3 ? 'idle' : t.turn === 'closed' ? 'turn' : age < 10 * 60e3 ? 'working' : 'idle';
127
- return { proj: PROJ, id: r.id, title: title(r), mtime: newest, state, tool: '', ageMs: age, subActive: state === 'working' ? subs.filter((s) => now - s.mtimeMs < 240000).length : 0, subTotal: m.children.length, dir: dirKey(m.cwd), source: SOURCE };
132
+ return { proj: PROJ, id: r.id, title: title(r), mtime: newest, state, tool: '', ageMs: age, subActive: state === 'working' ? subs.filter((s) => now - s.mtimeMs < 240000).length : 0, subTotal: m.children.length, asked: t.asked || m.start || 0, dir: dirKey(m.cwd), source: SOURCE };
128
133
  }
129
134
 
130
135
  // ---- the current format: the history of a session, as Vibe would load it
@@ -223,8 +228,8 @@ function uniState(r) {
223
228
  const uniLight = new Map(); // session folder → what the lists need of a session (title, state, how many sub-agents), kept after its history has been let go
224
229
  function uniSummary(r) {
225
230
  const sig = uniSig(r), hit = uniLight.get(r.dir); if (hit && hit.sig === sig) return hit;
226
- let v = { sig, title: '', status: '', kids: 0, live: 0, waiting: false }, read = false;
227
- try { const u = uniLoad(r), st = uniState(r), se = (st.env && st.env.session) || {}; read = u.sig === sig; v = { sig, title: str(se.title).trim() || str(se.preview).replace(/\s+/g, ' ').trim().slice(0, 90), status: str(se.status && se.status.type), kids: st.kids.length, live: st.kids.filter((k) => !k.done).length, waiting: !!st.waiting }; } catch {}
231
+ let v = { sig, title: '', status: '', kids: 0, live: 0, waiting: false, asked: (hit && hit.asked) || 0 }, read = false;
232
+ try { const u = uniLoad(r), st = uniState(r), se = (st.env && st.env.session) || {}; read = u.sig === sig; v = { sig, title: str(se.title).trim() || str(se.preview).replace(/\s+/g, ' ').trim().slice(0, 90), status: str(se.status && se.status.type), kids: st.kids.length, live: st.kids.filter((k) => !k.done).length, waiting: !!st.waiting, asked: st.main.raw.reduce((m, e) => (e.kind === 'user' && e.ts > m ? e.ts : m), 0) }; } catch {} // asked: when the person last typed something there, which is what moves the live call (see currentSession in server.js)
228
233
  if (read) { if (uniLight.size > 500) uniLight.delete(uniLight.keys().next().value); uniLight.set(r.dir, v); } // not kept when the session could not be read (caught in the middle of a write): asked again next time
229
234
  return v;
230
235
  }
@@ -319,4 +324,4 @@ function parser({ toolLabel, clip, resultMax = {} }) {
319
324
  };
320
325
  return record;
321
326
  }
322
- module.exports = { PROJ, SOURCE, home, dirKey, sessions, row, fileOf, inProject, projectLabel, title, boardRow, subFiles, subCount, watch, state, parser };
327
+ module.exports = { PROJ, SOURCE, home, dirKey, sessions, row, fileOf, cwd, inProject, projectLabel, title, boardRow, subFiles, subCount, watch, state, parser };