@dadado/agent-kit-cli 6.10.1 → 6.12.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.
Files changed (43) hide show
  1. package/dist/{add-7GH3K44T.js → add-CLRIMPN4.js} +3 -3
  2. package/dist/{chunk-52WYZFP5.js → chunk-2R4HYPQH.js} +2 -2
  3. package/dist/{chunk-26KXYR5T.js → chunk-2TKPKRHO.js} +2 -2
  4. package/dist/{chunk-CXDAT76O.js → chunk-4WHPZGF4.js} +17 -6
  5. package/dist/{chunk-6LRY2CYU.js → chunk-5RWTDCJ7.js} +5 -1
  6. package/dist/{chunk-75ELVLBY.js → chunk-5T4CHRRR.js} +1 -1
  7. package/dist/chunk-7ABY6DYH.js +89 -0
  8. package/dist/{chunk-BZI5G3OZ.js → chunk-7TEEGAED.js} +35 -5
  9. package/dist/{chunk-BSYQJ5WF.js → chunk-CRLMS2JX.js} +1 -1
  10. package/dist/{chunk-O5FKTKOW.js → chunk-DVCNJNCF.js} +3 -3
  11. package/dist/{chunk-BB22FGQ4.js → chunk-EE3LTOBZ.js} +1 -1
  12. package/dist/{chunk-LPZ2KXVE.js → chunk-FX6BIH4C.js} +1 -1
  13. package/dist/{chunk-6UKI4CAN.js → chunk-GDKTTV2A.js} +13 -2
  14. package/dist/{chunk-HIJTNHJE.js → chunk-HWYVLEET.js} +3 -3
  15. package/dist/{chunk-TZA7MT4I.js → chunk-I2SG2VPJ.js} +2 -2
  16. package/dist/{chunk-LGSNC4OI.js → chunk-IBE2EJZS.js} +1 -1
  17. package/dist/{chunk-ZF4YBL7F.js → chunk-LAYMAMPL.js} +1 -1
  18. package/dist/{chunk-GQ6Q3P7C.js → chunk-ODI2N2BN.js} +2 -2
  19. package/dist/{chunk-BIFWN6BJ.js → chunk-OKQ3SAHK.js} +1 -1
  20. package/dist/{chunk-K5OCGZWA.js → chunk-PGCRP5A6.js} +8 -8
  21. package/dist/chunk-TFKEHC2D.js +273 -0
  22. package/dist/{chunk-S7XAV6JK.js → chunk-UX6FHSO7.js} +5 -5
  23. package/dist/{chunk-TUZVOPKY.js → chunk-WAWCS5PJ.js} +75 -122
  24. package/dist/{chunk-MTLQN57O.js → chunk-WRCXRV2U.js} +114 -6
  25. package/dist/{chunk-HVH24VRL.js → chunk-XJWCL4PO.js} +1 -1
  26. package/dist/{commands-EQHK3ZEP.js → commands-DVEZOEEO.js} +5 -5
  27. package/dist/{contribute-VSVPRHQ7.js → contribute-E3COXKH4.js} +4 -4
  28. package/dist/{countdown-XYRE4GZU.js → countdown-F6EIHGDR.js} +7 -7
  29. package/dist/{diff-4P7LMQK5.js → diff-SCGNC4SF.js} +5 -5
  30. package/dist/{doctor-E6LOBJYK.js → doctor-QGO4QB7R.js} +9 -9
  31. package/dist/{engine-info-3MQML5I2.js → engine-info-MNCKB55Y.js} +2 -2
  32. package/dist/{ground-control-726LRB6Q.js → ground-control-DB5RSYAT.js} +4 -4
  33. package/dist/{hook-HJW5SXQG.js → hook-R7V4NG3C.js} +5 -5
  34. package/dist/index.js +22 -20
  35. package/dist/{init-KKVT2RW4.js → init-ONPKZS63.js} +12 -12
  36. package/dist/{install-BPZTP5KT.js → install-NHTYTVSG.js} +12 -12
  37. package/dist/queue-XI4HUFLJ.js +172 -0
  38. package/dist/{run-326EEQYY.js → run-EO5P2YZG.js} +50 -271
  39. package/dist/{run-plan-2IFO4G4Y.js → run-plan-VMW34QY6.js} +8 -7
  40. package/dist/{setup-global-BFBSR2RZ.js → setup-global-PMKGHX2S.js} +6 -6
  41. package/dist/{status-LNXVLDMP.js → status-P2I6LE6Y.js} +7 -7
  42. package/dist/{update-PX5XFCSG.js → update-K6L24JDP.js} +10 -10
  43. package/package.json +20 -13
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  REGISTRY_CLI_ARGS,
7
7
  resolveRegistryFromCli
8
- } from "./chunk-75ELVLBY.js";
8
+ } from "./chunk-5T4CHRRR.js";
9
9
  import {
10
10
  logger
11
11
  } from "./chunk-ZB43YMHW.js";
@@ -22,8 +22,8 @@ import {
22
22
  resolveProtectedGlobs,
23
23
  saveManifest,
24
24
  upsertIdList
25
- } from "./chunk-HVH24VRL.js";
26
- import "./chunk-6LRY2CYU.js";
25
+ } from "./chunk-XJWCL4PO.js";
26
+ import "./chunk-5RWTDCJ7.js";
27
27
  import {
28
28
  KIT_VERSION
29
29
  } from "./chunk-7HDQEK6T.js";
@@ -6,13 +6,13 @@ import {
6
6
  import {
7
7
  diffAgainstRegistry,
8
8
  summarizeDiff
9
- } from "./chunk-O5FKTKOW.js";
9
+ } from "./chunk-DVCNJNCF.js";
10
10
  import {
11
11
  DEFAULT_REGISTRY_URL,
12
12
  assertSafeRegistrySource,
13
13
  loadAgentKitManifest,
14
14
  resolveRegistryRoot
15
- } from "./chunk-HVH24VRL.js";
15
+ } from "./chunk-XJWCL4PO.js";
16
16
  import {
17
17
  KIT_PACKAGE_SPEC,
18
18
  KIT_VERSION
@@ -4,10 +4,10 @@ import {
4
4
  import {
5
5
  claudeRedactions,
6
6
  redactSecrets
7
- } from "./chunk-6UKI4CAN.js";
7
+ } from "./chunk-GDKTTV2A.js";
8
8
  import {
9
9
  findHitlGateInText
10
- } from "./chunk-MTLQN57O.js";
10
+ } from "./chunk-WRCXRV2U.js";
11
11
  import {
12
12
  findOnPath
13
13
  } from "./chunk-WGLPZXNU.js";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  formatHitlGateLine
3
- } from "./chunk-MTLQN57O.js";
3
+ } from "./chunk-WRCXRV2U.js";
4
4
 
5
5
  // src/plan-loop/driver-events.ts
6
6
  import { createInterface } from "readline";
7
7
  import { StringDecoder } from "string_decoder";
8
8
  var DRIVER_PROTOCOL_MAJOR = 1;
9
- var DRIVER_PROTOCOL_VERSION = "1.2.0";
9
+ var DRIVER_PROTOCOL_VERSION = "1.4.0";
10
10
  var DRIVER_EVENTS_FORMATS = ["ndjson"];
11
11
  var INBOUND_MAX_CHARS = 64 * 1024;
12
12
  var AGENT_PENDING_MAX_CHARS = 4 * 1024 * 1024;
@@ -65,14 +65,24 @@ function parseDriverInbound(line) {
65
65
  if (typeof msg.askId !== "string" || !/^[a-z0-9-]+$/.test(msg.askId)) {
66
66
  return { ok: false, error: "hitl_reply.askId must be a kebab-case string" };
67
67
  }
68
+ if (msg.source !== void 0 && msg.source !== "operator" && msg.source !== "policy") {
69
+ return { ok: false, error: 'hitl_reply.source must be "operator" or "policy"' };
70
+ }
71
+ const source = msg.source === "policy" ? { source: "policy" } : {};
68
72
  if (typeof msg.reply === "number") {
69
73
  if (!Number.isInteger(msg.reply) || msg.reply < 1) {
70
74
  return { ok: false, error: "hitl_reply.reply number must be a positive integer" };
71
75
  }
72
- return { ok: true, message: { type: "hitl_reply", askId: msg.askId, reply: msg.reply } };
76
+ return {
77
+ ok: true,
78
+ message: { type: "hitl_reply", askId: msg.askId, reply: msg.reply, ...source }
79
+ };
73
80
  }
74
81
  if (typeof msg.reply === "string" && msg.reply.trim() && !/[\r\n]/.test(msg.reply)) {
75
- return { ok: true, message: { type: "hitl_reply", askId: msg.askId, reply: msg.reply.trim() } };
82
+ return {
83
+ ok: true,
84
+ message: { type: "hitl_reply", askId: msg.askId, reply: msg.reply.trim(), ...source }
85
+ };
76
86
  }
77
87
  return { ok: false, error: "hitl_reply.reply must be a number or a one-line non-empty string" };
78
88
  }
@@ -87,7 +97,7 @@ function inboundToRawAnswer(gate, parsed) {
87
97
  detail: `reply for ${message.askId} while gate ${gate.askId} is open`
88
98
  };
89
99
  }
90
- return { kind: "line", text: String(message.reply) };
100
+ return message.source === "policy" ? { kind: "line", text: String(message.reply), source: "policy" } : { kind: "line", text: String(message.reply) };
91
101
  }
92
102
  function createDriverAnswerReader(opts) {
93
103
  const input = opts.input ?? process.stdin;
@@ -149,7 +159,8 @@ function createDriverAnswerReader(opts) {
149
159
  askId: gate.askId,
150
160
  labels: [...gate.labels],
151
161
  detection: gate.detection,
152
- line: formatHitlGateLine(gate)
162
+ line: formatHitlGateLine(gate),
163
+ usage: readOpts.usage ?? null
153
164
  });
154
165
  const line = await nextLine(readOpts.signal);
155
166
  if (line === null) return { kind: "eof" };
@@ -370,7 +370,11 @@ var KNOWN_SHIPPED_OVERLAY_HASHES = /* @__PURE__ */ new Set([
370
370
  "f95f94170f26beb4e03d4e24b22139e1aaa6bbb3d4b43d524ea9f12ed296beb4",
371
371
  "23e690d5c97eb1f739115b8977a862332fe44da3a4b0888de078cf437cf478b9",
372
372
  "f8d95774ad51e1c7cddc93be8115fa2b7ba75d45c60b71c6228b59e8a50c839d",
373
- "5b8f11be3c7f3af65ea6947cecc199f1acd5cf1fc2b2805ed3496257dd8605b5"
373
+ "5b8f11be3c7f3af65ea6947cecc199f1acd5cf1fc2b2805ed3496257dd8605b5",
374
+ "2bd11cdf44d1fd536d9a52206b79b78ecb7e0276efdf0e598d3cec5f831c35b6",
375
+ "88fa5ebe0d0fc29f8dac3de140797a85fbc8dc00e9b9c461b0e9e10bb9ef4e64",
376
+ "c746b0424dfc3a9e36c588e48526b1f14e9c2c3032397f2ba721fa7f50390230",
377
+ "9f0e1cf2e28f6949a98b7ffa0eb9c3237d8868460014f35edd9122a30fb4367c"
374
378
  ]);
375
379
 
376
380
  // src/lifecycle/paths.ts
@@ -5,7 +5,7 @@ import {
5
5
  DEFAULT_REGISTRY_REF,
6
6
  DEFAULT_REGISTRY_URL,
7
7
  resolveRegistryRoot
8
- } from "./chunk-HVH24VRL.js";
8
+ } from "./chunk-XJWCL4PO.js";
9
9
 
10
10
  // src/lifecycle/resolve-cli.ts
11
11
  async function resolveRegistryFromCli(options) {
@@ -0,0 +1,89 @@
1
+ import {
2
+ extractHandoffNamedPlans,
3
+ namedPlanCandidatePaths,
4
+ parsePlanFrontmatter
5
+ } from "./chunk-L5V3W3DY.js";
6
+ import {
7
+ HANDOFF_REL
8
+ } from "./chunk-C4Q77GGJ.js";
9
+ import {
10
+ fileExists
11
+ } from "./chunk-5B4DVO6C.js";
12
+
13
+ // src/plan-loop/plan-state.ts
14
+ import { readdir, readFile } from "fs/promises";
15
+ import path from "path";
16
+ function countPendingTodos(raw) {
17
+ return parsePlanFrontmatter(raw).todos.filter(
18
+ (t) => (t.status === "pending" || t.status === "in_progress") && t.id !== "dogfood-poc"
19
+ ).length;
20
+ }
21
+ async function findActivePlanFile(plansDir) {
22
+ if (!await fileExists(plansDir)) return null;
23
+ const files = (await readdir(plansDir)).filter((f) => f.endsWith(".plan.md")).sort();
24
+ return files[0] ? path.join(plansDir, files[0]) : null;
25
+ }
26
+ async function readPlan(planPath) {
27
+ return readFile(planPath, "utf8");
28
+ }
29
+ var QUEUE_CURSOR_RE = /^- \*\*Queue cursor:\*\*\s*(.+)$/m;
30
+ var QUEUE_STATUS_RE = /^- \*\*Queue status:\*\*\s*(.+)$/m;
31
+ var QUEUE_DONE_STATUSES = /* @__PURE__ */ new Set(["exhausted", "completed", "done"]);
32
+ function readRunQueueState(handoff) {
33
+ const queue = extractHandoffNamedPlans(handoff).runQueue;
34
+ let cursorIndex = null;
35
+ let cursorPlan = null;
36
+ const cursorRaw = QUEUE_CURSOR_RE.exec(handoff)?.[1]?.trim() ?? "";
37
+ const indexMatch = /^(\d+)\b/.exec(cursorRaw);
38
+ if (indexMatch?.[1]) cursorIndex = Number(indexMatch[1]);
39
+ const currentMatch = /current:\s*`?([^`()]+?)`?\s*\)/i.exec(cursorRaw);
40
+ if (currentMatch?.[1]) {
41
+ const base = currentMatch[1].trim().split("/").pop() ?? "";
42
+ if (/\.plan\.md$/i.test(base)) cursorPlan = base;
43
+ }
44
+ const status = QUEUE_STATUS_RE.exec(handoff)?.[1]?.trim().split(/\s+/)[0]?.replace(/[`*]/g, "");
45
+ const queueStatus = status ? status : null;
46
+ const finished = queueStatus !== null && QUEUE_DONE_STATUSES.has(queueStatus.toLowerCase());
47
+ let cursor = null;
48
+ if (cursorIndex !== null && cursorIndex >= 0 && cursorIndex < queue.length) {
49
+ cursor = cursorIndex;
50
+ } else if (cursorPlan && queue.includes(cursorPlan)) {
51
+ cursor = queue.indexOf(cursorPlan);
52
+ }
53
+ const current = cursor !== null ? queue[cursor] ?? null : cursorPlan;
54
+ return { queue, cursor, current, status: queueStatus, finished };
55
+ }
56
+ function defaultPlanStateIo() {
57
+ return {
58
+ readFile: async (file) => {
59
+ try {
60
+ return await readFile(file, "utf8");
61
+ } catch {
62
+ return null;
63
+ }
64
+ },
65
+ findActivePlan: findActivePlanFile
66
+ };
67
+ }
68
+ async function resolveActivePlanFromHandoff(root, handoff, io = defaultPlanStateIo()) {
69
+ const queue = readRunQueueState(handoff);
70
+ const base = (queue.queue.length > 0 && !queue.finished ? queue.current : null) ?? extractHandoffNamedPlans(handoff).active;
71
+ if (!base) return io.findActivePlan(path.join(root, ".cursor", "plans"));
72
+ for (const candidate of namedPlanCandidatePaths(root, base)) {
73
+ if (await io.readFile(candidate) !== null) return candidate;
74
+ }
75
+ return null;
76
+ }
77
+ async function resolveActivePlanPath(root, io = defaultPlanStateIo()) {
78
+ const handoff = await io.readFile(path.join(root, HANDOFF_REL)) ?? "";
79
+ return resolveActivePlanFromHandoff(root, handoff, io);
80
+ }
81
+
82
+ export {
83
+ countPendingTodos,
84
+ findActivePlanFile,
85
+ readPlan,
86
+ readRunQueueState,
87
+ resolveActivePlanFromHandoff,
88
+ resolveActivePlanPath
89
+ };
@@ -13,10 +13,10 @@ import {
13
13
  redactSecrets,
14
14
  resolveHitlRunOptions,
15
15
  spawnLogged
16
- } from "./chunk-6UKI4CAN.js";
16
+ } from "./chunk-GDKTTV2A.js";
17
17
  import {
18
18
  RESERVED_GATE_IDS
19
- } from "./chunk-MTLQN57O.js";
19
+ } from "./chunk-WRCXRV2U.js";
20
20
  import {
21
21
  ensureLoopLogsDir,
22
22
  runnerStatePaths
@@ -73,13 +73,42 @@ function rewriteRootArgvToRun(argv) {
73
73
  function commandMarkdownPath(root, name) {
74
74
  return path.join(root, ".cursor", "commands", `${normalizeSlashName(name)}.md`);
75
75
  }
76
- function buildDispatchPrompt(commandBody) {
77
- return [
76
+ var OPERATOR_NOTE_HEADING = "## Operator resolution note (`--note`)";
77
+ var OPERATOR_NOTE_PREAMBLE = "Operator context for this run, relayed verbatim. It is not an answer to any Ask: every gate you open still waits for a `HITL_REPLY:` line.";
78
+ function buildDispatchPrompt(commandBody, note) {
79
+ const lines = [
78
80
  "Follow the Agent Kit command below. This session is headless: use numbered-list HITL (Ask questions is Cursor-only). Before each numbered list print one line `HITL_GATE: <ask-id> | <label 1> | <label 2> | ...` (ask-id and labels from the hitl-gates skill), then wait; the operator's answer arrives as `HITL_REPLY: <ask-id> | operator reply <n> | <label>`. Never /git-prod. No CLI --force promote.",
79
81
  "",
80
82
  commandBody.trimEnd(),
81
83
  ""
82
- ].join("\n");
84
+ ];
85
+ if (note?.trim()) {
86
+ lines.push(OPERATOR_NOTE_HEADING, "", OPERATOR_NOTE_PREAMBLE, "", note.trim(), "");
87
+ }
88
+ return lines.join("\n");
89
+ }
90
+ var NOTE_SENTINEL_RE = /^[ \t>]*(HITL_GATE|HITL_REPLY):/m;
91
+ async function resolveOperatorNote(raw, root) {
92
+ let text = raw;
93
+ if (raw.startsWith("@")) {
94
+ const rel = raw.slice(1).trim();
95
+ if (!rel) return { ok: false, message: "--note @<file>: missing file path" };
96
+ const file = path.resolve(root, rel);
97
+ try {
98
+ text = await readFile(file, "utf8");
99
+ } catch {
100
+ return { ok: false, message: `--note: cannot read ${rel}` };
101
+ }
102
+ }
103
+ if (!text.trim()) return { ok: false, message: "--note is empty" };
104
+ const sentinel = NOTE_SENTINEL_RE.exec(text);
105
+ if (sentinel) {
106
+ return {
107
+ ok: false,
108
+ message: `--note may not contain a ${sentinel[1]}: line (a note is operator context, never a gate or a reply)`
109
+ };
110
+ }
111
+ return { ok: true, note: text };
83
112
  }
84
113
  function promoteBlockedMessage(name) {
85
114
  const n = normalizeSlashName(name);
@@ -216,6 +245,7 @@ export {
216
245
  classifySlash,
217
246
  rewriteRootArgvToRun,
218
247
  buildDispatchPrompt,
248
+ resolveOperatorNote,
219
249
  promoteBlockedMessage,
220
250
  unknownSlashMessage,
221
251
  readCommandFile,
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  gateExitNotePath
3
- } from "./chunk-26KXYR5T.js";
3
+ } from "./chunk-2TKPKRHO.js";
4
4
 
5
5
  // src/plan-loop/merge-detect.ts
6
6
  async function isAncestor(git, ref, baseRef) {
@@ -1,13 +1,13 @@
1
1
  import {
2
2
  managedPairs
3
- } from "./chunk-LPZ2KXVE.js";
3
+ } from "./chunk-FX6BIH4C.js";
4
4
  import {
5
5
  isProtectedPath,
6
6
  resolveProtectedGlobs
7
- } from "./chunk-HVH24VRL.js";
7
+ } from "./chunk-XJWCL4PO.js";
8
8
  import {
9
9
  resolveContained
10
- } from "./chunk-6LRY2CYU.js";
10
+ } from "./chunk-5RWTDCJ7.js";
11
11
 
12
12
  // src/lifecycle/diff.ts
13
13
  import { readFile } from "fs/promises";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  whichBinary
3
- } from "./chunk-6UKI4CAN.js";
3
+ } from "./chunk-GDKTTV2A.js";
4
4
 
5
5
  // src/plan-loop/detect.ts
6
6
  var DETECT_ORDER = ["cursor-agent", "claude"];
@@ -7,7 +7,7 @@ import {
7
7
  loadRegistry,
8
8
  packMemberFileTargets,
9
9
  skillFileTargets
10
- } from "./chunk-HVH24VRL.js";
10
+ } from "./chunk-XJWCL4PO.js";
11
11
 
12
12
  // src/lifecycle/targets.ts
13
13
  import path from "path";
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  LineSplitter,
3
3
  TurnWatcher,
4
+ UsageTally,
4
5
  askOperator,
5
6
  createTerminalAnswerReader,
6
7
  detectHitlGate,
@@ -8,7 +9,7 @@ import {
8
9
  noRelayStop,
9
10
  unansweredStop,
10
11
  userEventLine
11
- } from "./chunk-MTLQN57O.js";
12
+ } from "./chunk-WRCXRV2U.js";
12
13
  import {
13
14
  findOnPath
14
15
  } from "./chunk-WGLPZXNU.js";
@@ -314,6 +315,7 @@ var codexBackend = {
314
315
  translate
315
316
  };
316
317
  const records = [];
318
+ const usage = new UsageTally();
317
319
  let result;
318
320
  try {
319
321
  result = await spawnLogged(
@@ -323,6 +325,7 @@ var codexBackend = {
323
325
  { ...common, stdinText: prepared.prompt }
324
326
  );
325
327
  if (result.hitl) records.push(result.hitl);
328
+ if (result.usage) usage.merge(result.usage);
326
329
  for (let i = 0; result.resumeWith && i < CODEX_MAX_RESUMES; i += 1) {
327
330
  const reply = result.resumeWith;
328
331
  const thread = threadId;
@@ -342,6 +345,7 @@ var codexBackend = {
342
345
  { ...common, stdinText: reply, appendLog: true }
343
346
  );
344
347
  if (result.hitl) records.push(result.hitl);
348
+ if (result.usage) usage.merge(result.usage);
345
349
  }
346
350
  } catch (err) {
347
351
  throw new Error(`codex backend failed to start: ${redactSecrets(String(err), redact)}`);
@@ -349,6 +353,7 @@ var codexBackend = {
349
353
  return {
350
354
  exitCode: result.exitCode,
351
355
  hitl: mergeRecords(records),
356
+ usage,
352
357
  ...result.lastResult ? { lastResult: result.lastResult } : {}
353
358
  };
354
359
  }
@@ -866,7 +871,7 @@ async function runCursorAcp(opts) {
866
871
  record.replies.push(outcome.stamp);
867
872
  hitl.write(`\u2192 ${outcome.stamp.line}
868
873
  `);
869
- const n = /operator reply (\d+)/.exec(outcome.stamp.reply)?.[1];
874
+ const n = /(?:operator reply|policy pre-answer) (\d+)/.exec(outcome.stamp.reply)?.[1];
870
875
  const option = n ? q.options[Number(n) - 1] : void 0;
871
876
  if (!option) {
872
877
  hitl.write(
@@ -1404,6 +1409,7 @@ function spawnLogged(command, args, logPath, options = {}) {
1404
1409
  resolve({
1405
1410
  exitCode: code ?? 1,
1406
1411
  hitl: relay.record,
1412
+ usage: relay.usage,
1407
1413
  ...lastResult ? { lastResult } : {},
1408
1414
  ...resumeWith ? { resumeWith } : {}
1409
1415
  });
@@ -1469,8 +1475,10 @@ function createRelay(hitl, child, redactedError) {
1469
1475
  timers.push(term);
1470
1476
  };
1471
1477
  let lastResult;
1478
+ const usage = new UsageTally();
1472
1479
  const watcher = new TurnWatcher((turn) => {
1473
1480
  lastResult = turn;
1481
+ usage.note(turn.sessionId, turn.usage);
1474
1482
  const { resultText, assistantTexts } = turn;
1475
1483
  if (record.stop || closed) return;
1476
1484
  const gate = detectHitlGate(resultText, assistantTexts);
@@ -1489,6 +1497,8 @@ function createRelay(hitl, child, redactedError) {
1489
1497
  readAnswer: hitl.readAnswer,
1490
1498
  write: hitl.write,
1491
1499
  signal: abort.signal,
1500
+ // The gate's turn has already been noted above, so this is the session total so far.
1501
+ usage: usage.total(),
1492
1502
  onPromptStart: hitl.onPromptStart,
1493
1503
  onPromptEnd: hitl.onPromptEnd
1494
1504
  }).then(
@@ -1536,6 +1546,7 @@ function createRelay(hitl, child, redactedError) {
1536
1546
  startError,
1537
1547
  record,
1538
1548
  lastResult: () => lastResult,
1549
+ usage,
1539
1550
  resumeWith: () => resumeWith,
1540
1551
  feed: (text) => watcher.feed(text),
1541
1552
  finish: () => watcher.end(),
@@ -2,7 +2,7 @@ import {
2
2
  compareSemver,
3
3
  normalizeSemver,
4
4
  readLocalKitVersion
5
- } from "./chunk-52WYZFP5.js";
5
+ } from "./chunk-2R4HYPQH.js";
6
6
  import {
7
7
  L0_ARTIFACTS
8
8
  } from "./chunk-2KIOZMTV.js";
@@ -15,11 +15,11 @@ import {
15
15
  mergeStats,
16
16
  recordOutcome,
17
17
  resolveProtectedGlobs
18
- } from "./chunk-HVH24VRL.js";
18
+ } from "./chunk-XJWCL4PO.js";
19
19
  import {
20
20
  loadManagedHashLedger,
21
21
  saveManagedHashLedger
22
- } from "./chunk-6LRY2CYU.js";
22
+ } from "./chunk-5RWTDCJ7.js";
23
23
  import {
24
24
  KIT_PACKAGE_SPEC,
25
25
  KIT_VERSION
@@ -4,10 +4,10 @@ import {
4
4
  import {
5
5
  compareSemver,
6
6
  normalizeSemver
7
- } from "./chunk-52WYZFP5.js";
7
+ } from "./chunk-2R4HYPQH.js";
8
8
  import {
9
9
  MANIFEST_RELATIVE_PATH
10
- } from "./chunk-HVH24VRL.js";
10
+ } from "./chunk-XJWCL4PO.js";
11
11
  import {
12
12
  KIT_VERSION,
13
13
  pinnedCliSpec
@@ -5,7 +5,7 @@ import {
5
5
  resolveContained,
6
6
  saveManagedHashLedger,
7
7
  shouldPreserveCustomizedOverlay
8
- } from "./chunk-6LRY2CYU.js";
8
+ } from "./chunk-5RWTDCJ7.js";
9
9
  import {
10
10
  ensureDir,
11
11
  fileExists
@@ -7,7 +7,7 @@ import {
7
7
  assertRealParentContained,
8
8
  isRealWriteTargetContained,
9
9
  resolveContained
10
- } from "./chunk-6LRY2CYU.js";
10
+ } from "./chunk-5RWTDCJ7.js";
11
11
  import {
12
12
  ensureDir
13
13
  } from "./chunk-5B4DVO6C.js";
@@ -3,11 +3,11 @@ import {
3
3
  GUARD_SHELL_HOOK_MARKER,
4
4
  RESOLVE_AGENT_KIT_REL,
5
5
  SESSION_START_HOOK_MARKER
6
- } from "./chunk-ZF4YBL7F.js";
6
+ } from "./chunk-LAYMAMPL.js";
7
7
  import {
8
8
  CLAUDE_COMMANDS_DIR_REL,
9
9
  discoverInstalledCommands
10
- } from "./chunk-LGSNC4OI.js";
10
+ } from "./chunk-IBE2EJZS.js";
11
11
  import {
12
12
  findOnPath
13
13
  } from "./chunk-WGLPZXNU.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  MANIFEST_RELATIVE_PATH
3
- } from "./chunk-HVH24VRL.js";
3
+ } from "./chunk-XJWCL4PO.js";
4
4
  import {
5
5
  fileExists
6
6
  } from "./chunk-5B4DVO6C.js";
@@ -6,7 +6,7 @@ import {
6
6
  formatStaleCliRefusal,
7
7
  installL0,
8
8
  syncFromManifest
9
- } from "./chunk-HIJTNHJE.js";
9
+ } from "./chunk-HWYVLEET.js";
10
10
  import {
11
11
  SkippedSymlinkError,
12
12
  formatPersonalizationSkippedSymlinks,
@@ -15,21 +15,21 @@ import {
15
15
  import {
16
16
  REGISTRY_CLI_ARGS,
17
17
  resolveRegistryFromCli
18
- } from "./chunk-75ELVLBY.js";
18
+ } from "./chunk-5T4CHRRR.js";
19
19
  import {
20
20
  assessClaudeCommandAdapters,
21
21
  executeSafeReadinessFixes
22
- } from "./chunk-GQ6Q3P7C.js";
22
+ } from "./chunk-ODI2N2BN.js";
23
23
  import {
24
24
  writeReadinessSnapshot
25
25
  } from "./chunk-HAFRAXGV.js";
26
26
  import {
27
27
  writeClaudeSessionStartHook
28
- } from "./chunk-ZF4YBL7F.js";
28
+ } from "./chunk-LAYMAMPL.js";
29
29
  import {
30
30
  CLAUDE_HITL_FALLBACK,
31
31
  generateClaudeCommandAdapters
32
- } from "./chunk-LGSNC4OI.js";
32
+ } from "./chunk-IBE2EJZS.js";
33
33
  import {
34
34
  shouldUseWelcomeColor,
35
35
  withCliProgress
@@ -56,13 +56,13 @@ import {
56
56
  npxPinned,
57
57
  pathCliStatus,
58
58
  syncPathCliToRuntime
59
- } from "./chunk-TZA7MT4I.js";
59
+ } from "./chunk-I2SG2VPJ.js";
60
60
  import {
61
61
  assessEnvironment
62
62
  } from "./chunk-B3VR5YBQ.js";
63
63
  import {
64
64
  warnIfRunningCliBehindNpm
65
- } from "./chunk-52WYZFP5.js";
65
+ } from "./chunk-2R4HYPQH.js";
66
66
  import {
67
67
  DOMAIN_PACK_IDS,
68
68
  allPacks,
@@ -79,7 +79,7 @@ import {
79
79
  resolveProtectedGlobs,
80
80
  saveManifest,
81
81
  skillTargetDir
82
- } from "./chunk-HVH24VRL.js";
82
+ } from "./chunk-XJWCL4PO.js";
83
83
  import {
84
84
  KIT_VERSION,
85
85
  pinnedCliSpec