@letsrebase/verify 0.2.1 → 0.2.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/wizard.mjs +34 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@letsrebase/verify",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Work profile: build a tamper-evident, PII-redacted work profile from your coding-agent logs and send it to rebase for review.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/wizard.mjs CHANGED
@@ -20,14 +20,30 @@ function money(c) {
20
20
  return c.currency === "USD" || !c.currency ? `$${amount.toFixed(2)}` : `${amount.toFixed(2)} ${c.currency}`;
21
21
  }
22
22
 
23
- /** The spinner message for a step and what the event stream has reported so far. */
24
- export function statusLine(status, { chars = 0, tokens = null, cost = null } = {}) {
23
+ /** Seconds as the status line shows them: "42s", "1m 05s". */
24
+ function clock(ms) {
25
+ const s = Math.max(0, Math.floor(ms / 1000));
26
+ return s < 60 ? `${s}s` : `${Math.floor(s / 60)}m ${String(s % 60).padStart(2, "0")}s`;
27
+ }
28
+
29
+ /**
30
+ * The spinner message for a step and what the event stream has reported so far. Before the
31
+ * first written character the narrative says which phase it is in (waiting for the model, or
32
+ * the model reasoning when the agent streams its thoughts), so a long first token never reads
33
+ * as "0 chars"; the step's elapsed time, when given, ticks at the end.
34
+ */
35
+ export function statusLine(status, { chars = 0, thought = 0, tokens = null, cost = null, elapsed = null } = {}) {
25
36
  const parts = [];
26
- if (status.step === "narrative") parts.push("Writing the narrative", `${kilo(chars)} chars`);
27
- else parts.push("Classifying practices", `batch ${status.batch} of ${status.total}${status.retry ? " (again)" : ""}`);
37
+ if (status.step === "narrative") {
38
+ parts.push("Writing the narrative");
39
+ if (chars > 0) parts.push(`${kilo(chars)} chars`);
40
+ else if (thought > 0) parts.push(`the model is reasoning (${kilo(thought)} chars)`);
41
+ else parts.push("waiting for the model");
42
+ } else parts.push("Classifying practices", `batch ${status.batch} of ${status.total}${status.retry ? " (again)" : ""}`);
28
43
  if (tokens != null) parts.push(`${kilo(tokens)} tokens`);
29
44
  const m = cost ? money(cost) : null;
30
45
  if (m) parts.push(m);
46
+ if (elapsed != null) parts.push(clock(elapsed));
31
47
  return parts.join(" · ");
32
48
  }
33
49
 
@@ -255,15 +271,19 @@ export async function runWizard({ ui, deps, flags = {}, out, proc = process, now
255
271
  return 2;
256
272
  };
257
273
 
258
- const live = { chars: 0, tokens: null, cost: null };
274
+ const live = { chars: 0, thought: 0, tokens: null, cost: null, elapsed: null };
259
275
  let paint = () => {};
260
276
  const onEvent = (e) => {
261
277
  if (e.kind === "started") {
262
278
  runDir = e.cwd;
263
279
  pid = e.pid ?? null;
264
280
  }
265
- else if (e.kind === "turn-start") live.chars = 0;
281
+ else if (e.kind === "turn-start") {
282
+ live.chars = 0;
283
+ live.thought = 0;
284
+ }
266
285
  else if (e.kind === "agent_message_chunk" && e.content?.type === "text") live.chars += e.content.text.length;
286
+ else if (e.kind === "agent_thought_chunk" && e.content?.type === "text") live.thought += e.content.text.length;
267
287
  else if (e.kind === "usage_update") {
268
288
  if (Number.isFinite(e.used)) live.tokens = e.used;
269
289
  if (e.cost) live.cost = e.cost;
@@ -328,12 +348,17 @@ export async function runWizard({ ui, deps, flags = {}, out, proc = process, now
328
348
  spin.start(`Starting the run with ${agent.label}`);
329
349
  let status = { step: "narrative" };
330
350
  let last = -Infinity;
351
+ let stepStart = now();
331
352
  paint = () => {
332
353
  const t = now();
333
354
  if (t - last < REDRAW_MS) return;
334
355
  last = t;
356
+ live.elapsed = t - stepStart;
335
357
  spin.message(statusLine(status, live));
336
358
  };
359
+ // A first token can take a minute: the elapsed time ticks even when the agent sends nothing.
360
+ const tick = setInterval(() => paint(), 1000);
361
+ tick.unref?.();
337
362
  let result;
338
363
  try {
339
364
  sessionHandedOver = true;
@@ -350,6 +375,8 @@ export async function runWizard({ ui, deps, flags = {}, out, proc = process, now
350
375
  onStatus: (s) => {
351
376
  status = s;
352
377
  live.chars = 0;
378
+ live.thought = 0;
379
+ stepStart = now();
353
380
  last = -Infinity;
354
381
  paint();
355
382
  },
@@ -358,6 +385,7 @@ export async function runWizard({ ui, deps, flags = {}, out, proc = process, now
358
385
  spin.error(ctl.signal.aborted || e?.name === "AbortError" ? "Stopped" : `${agent.label} could not finish`);
359
386
  return await fail(e);
360
387
  } finally {
388
+ clearInterval(tick);
361
389
  // the run has closed the agent and removed what it left: nothing for the exit net to do
362
390
  proc.off("exit", onExit);
363
391
  // from here on Ctrl-C belongs to whatever comes next (the sign-in wait of submit)