@tangle-network/agent-eval 2.0.12 → 2.0.13

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 (99) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/dist/adapters/http.d.ts +2 -2
  3. package/dist/{agent-profile-C0FBdYa6.d.ts → agent-profile-8S2LfCvs.d.ts} +4 -4
  4. package/dist/{agent-profile-C0FBdYa6.d.ts.map → agent-profile-8S2LfCvs.d.ts.map} +1 -1
  5. package/dist/analyst/index.d.ts +36 -4
  6. package/dist/analyst/index.d.ts.map +1 -1
  7. package/dist/analyst/index.js +1 -1
  8. package/dist/app-grade/index.d.ts +2 -2
  9. package/dist/{benchmark-command-Be5O6A2v.js → benchmark-command-C7ObyGm9.js} +177 -29
  10. package/dist/benchmark-command-C7ObyGm9.js.map +1 -0
  11. package/dist/benchmarks/index.d.ts +4 -4
  12. package/dist/benchmarks/index.js +2 -2
  13. package/dist/campaign/index.d.ts +6 -6
  14. package/dist/campaign/index.js +7 -7
  15. package/dist/{campaign-CE08mvQO.js → campaign-CaO2k8Jb.js} +7 -7
  16. package/dist/{campaign-CE08mvQO.js.map → campaign-CaO2k8Jb.js.map} +1 -1
  17. package/dist/{campaign-evidence-DRvr7lZU.d.ts → campaign-evidence-DcTgo4ze.d.ts} +2 -2
  18. package/dist/{campaign-evidence-DRvr7lZU.d.ts.map → campaign-evidence-DcTgo4ze.d.ts.map} +1 -1
  19. package/dist/cli.js +616 -24
  20. package/dist/cli.js.map +1 -1
  21. package/dist/{client-DUMIaMob.d.ts → client-3sR4_h5q.d.ts} +2 -2
  22. package/dist/{client-DUMIaMob.d.ts.map → client-3sR4_h5q.d.ts.map} +1 -1
  23. package/dist/contract/index.d.ts +9 -9
  24. package/dist/contract/index.js +5 -5
  25. package/dist/{default-registry-DFRlBniE.d.ts → default-registry-CVklg2e-.d.ts} +2 -2
  26. package/dist/{default-registry-DFRlBniE.d.ts.map → default-registry-CVklg2e-.d.ts.map} +1 -1
  27. package/dist/{define-agent-eval-BHn6t-DC.js → define-agent-eval-BLHr0_IP.js} +3 -3
  28. package/dist/{define-agent-eval-BHn6t-DC.js.map → define-agent-eval-BLHr0_IP.js.map} +1 -1
  29. package/dist/{define-agent-eval-n63vmQMR.d.ts → define-agent-eval-DZ7wWMHC.d.ts} +5 -5
  30. package/dist/{define-agent-eval-n63vmQMR.d.ts.map → define-agent-eval-DZ7wWMHC.d.ts.map} +1 -1
  31. package/dist/{evaluation-VbjqORBn.d.ts → evaluation-D50Dzyce.d.ts} +2 -2
  32. package/dist/{evaluation-VbjqORBn.d.ts.map → evaluation-D50Dzyce.d.ts.map} +1 -1
  33. package/dist/evaluation.d.ts +1 -1
  34. package/dist/experiment/index.d.ts +2 -2
  35. package/dist/hosted/index.d.ts +2 -2
  36. package/dist/hosted/index.js +1 -1
  37. package/dist/{index-BEXEYURJ.d.ts → index-Bam453Y5.d.ts} +8 -8
  38. package/dist/{index-BEXEYURJ.d.ts.map → index-Bam453Y5.d.ts.map} +1 -1
  39. package/dist/{index-CbzPtg7O.d.ts → index-CYrvUGQl.d.ts} +13 -13
  40. package/dist/{index-CbzPtg7O.d.ts.map → index-CYrvUGQl.d.ts.map} +1 -1
  41. package/dist/{index-rrPT3Pw0.d.ts → index-CxciVDt0.d.ts} +2 -2
  42. package/dist/{index-rrPT3Pw0.d.ts.map → index-CxciVDt0.d.ts.map} +1 -1
  43. package/dist/{index-Dt3zWlRa.d.ts → index-D1ghgNRI.d.ts} +3 -3
  44. package/dist/{index-Dt3zWlRa.d.ts.map → index-D1ghgNRI.d.ts.map} +1 -1
  45. package/dist/index.d.ts +13 -13
  46. package/dist/index.js +4 -4
  47. package/dist/{llm-judge-CgF3ZM3R.js → llm-judge-ChGnwj4s.js} +2 -2
  48. package/dist/{llm-judge-CgF3ZM3R.js.map → llm-judge-ChGnwj4s.js.map} +1 -1
  49. package/dist/{matrix-B95YsrV7.d.ts → matrix-CAeyP9m-.d.ts} +2 -2
  50. package/dist/{matrix-B95YsrV7.d.ts.map → matrix-CAeyP9m-.d.ts.map} +1 -1
  51. package/dist/multishot/golden/index.d.ts +1 -1
  52. package/dist/multishot/index.d.ts +6 -6
  53. package/dist/multishot/index.js +2 -2
  54. package/dist/openapi.json +1 -1
  55. package/dist/{optimization-method-1xzXK-B6.js → optimization-method-D2uCSc2j.js} +4 -4
  56. package/dist/{optimization-method-1xzXK-B6.js.map → optimization-method-D2uCSc2j.js.map} +1 -1
  57. package/dist/rl.d.ts +1 -1
  58. package/dist/rollout/index.d.ts +2 -2
  59. package/dist/{run-improvement-loop-BPhkYKV2.d.ts → run-improvement-loop-C9z817z_.d.ts} +7 -7
  60. package/dist/{run-improvement-loop-BPhkYKV2.d.ts.map → run-improvement-loop-C9z817z_.d.ts.map} +1 -1
  61. package/dist/search/index.d.ts +3 -3
  62. package/dist/search/index.js +2 -2
  63. package/dist/{search-kernel-BkkDo75N.js → search-kernel-B1TEQ9pa.js} +2 -2
  64. package/dist/{search-kernel-BkkDo75N.js.map → search-kernel-B1TEQ9pa.js.map} +1 -1
  65. package/dist/{search-kernel-CDSEWa2X.d.ts → search-kernel-CZmj8gJW.d.ts} +3 -3
  66. package/dist/{search-kernel-CDSEWa2X.d.ts.map → search-kernel-CZmj8gJW.d.ts.map} +1 -1
  67. package/dist/{search-ledger-sormHFLS.js → search-ledger-EjLGVZ4X.js} +9 -5
  68. package/dist/search-ledger-EjLGVZ4X.js.map +1 -0
  69. package/dist/{search-ledger-types-BhZE848w.d.ts → search-ledger-types-D4FsvPP9.d.ts} +8 -2
  70. package/dist/search-ledger-types-D4FsvPP9.d.ts.map +1 -0
  71. package/dist/{search-shipper-BJ2Bkx2q.js → search-shipper-DtSnRfOJ.js} +2 -2
  72. package/dist/{search-shipper-BJ2Bkx2q.js.map → search-shipper-DtSnRfOJ.js.map} +1 -1
  73. package/dist/{search-summary-DMckFUNY.js → search-summary-C5fewoUi.js} +2 -2
  74. package/dist/{search-summary-DMckFUNY.js.map → search-summary-C5fewoUi.js.map} +1 -1
  75. package/dist/{self-improve-CMrPmjYE.js → self-improve-CQM7hIL_.js} +3 -3
  76. package/dist/{self-improve-CMrPmjYE.js.map → self-improve-CQM7hIL_.js.map} +1 -1
  77. package/dist/{self-improve-D0TtJz4e.d.ts → self-improve-Eo-EAWL8.d.ts} +7 -7
  78. package/dist/{self-improve-D0TtJz4e.d.ts.map → self-improve-Eo-EAWL8.d.ts.map} +1 -1
  79. package/dist/{skillopt-optimization-method-D-BPMi8J.js → skillopt-optimization-method-DQ4urRij.js} +3 -3
  80. package/dist/{skillopt-optimization-method-D-BPMi8J.js.map → skillopt-optimization-method-DQ4urRij.js.map} +1 -1
  81. package/dist/{store-tool-spans-M3WxeRrG.d.ts → store-tool-spans-BD5Z304_.d.ts} +2 -2
  82. package/dist/{store-tool-spans-M3WxeRrG.d.ts.map → store-tool-spans-BD5Z304_.d.ts.map} +1 -1
  83. package/dist/{systemone-C26IFS-a.d.ts → systemone-D7FQ7n00.d.ts} +3 -3
  84. package/dist/{systemone-C26IFS-a.d.ts.map → systemone-D7FQ7n00.d.ts.map} +1 -1
  85. package/dist/systemone.d.ts +2 -2
  86. package/dist/traces.d.ts +1 -1
  87. package/dist/{tree-BX9ykHi3.js → tree-CljLPWVm.js} +3 -3
  88. package/dist/{tree-BX9ykHi3.js.map → tree-CljLPWVm.js.map} +1 -1
  89. package/dist/{types-CBT-XcX5.d.ts → types-BtWzceBY.d.ts} +4 -2
  90. package/dist/types-BtWzceBY.d.ts.map +1 -0
  91. package/dist/{types-CYPV2dlR.d.ts → types-XxFZ2IAT.d.ts} +2 -2
  92. package/dist/{types-CYPV2dlR.d.ts.map → types-XxFZ2IAT.d.ts.map} +1 -1
  93. package/docs/search-ledger.md +1 -1
  94. package/docs/skill-eval.md +10 -3
  95. package/package.json +1 -1
  96. package/dist/benchmark-command-Be5O6A2v.js.map +0 -1
  97. package/dist/search-ledger-sormHFLS.js.map +0 -1
  98. package/dist/search-ledger-types-BhZE848w.d.ts.map +0 -1
  99. package/dist/types-CBT-XcX5.d.ts.map +0 -1
package/dist/cli.js CHANGED
@@ -1,22 +1,272 @@
1
1
  #!/usr/bin/env node
2
2
  import { c as errorMessage, s as ValidationError } from "./errors-DeEEV9Vx.js";
3
3
  import { l as costForTokenPricing } from "./cost-ledger-ni6f77QJ.js";
4
- import { i as replaySearchLedgerText } from "./search-ledger-sormHFLS.js";
5
- import { o as operatorYield, s as INSUFFICIENT_FROM } from "./search-kernel-BkkDo75N.js";
6
- import { t as renderSearchSummary } from "./search-summary-DMckFUNY.js";
7
- import { l as SEARCH_LEDGER_BATCH_MAX_BYTES, m as SearchRunKindSchema, r as shipSearchLedger, s as hostedTenantFromEnv, t as SearchShipConflictError } from "./search-shipper-BJ2Bkx2q.js";
4
+ import { i as replaySearchLedgerText } from "./search-ledger-EjLGVZ4X.js";
5
+ import { o as operatorYield, s as INSUFFICIENT_FROM } from "./search-kernel-B1TEQ9pa.js";
6
+ import { t as renderSearchSummary } from "./search-summary-C5fewoUi.js";
7
+ import { l as SEARCH_LEDGER_BATCH_MAX_BYTES, m as SearchRunKindSchema, r as shipSearchLedger, s as hostedTenantFromEnv, t as SearchShipConflictError } from "./search-shipper-DtSnRfOJ.js";
8
8
  import { n as createChatClient } from "./chat-client-TkNgQDLj.js";
9
9
  import { a as privacyHit, f as appendRolloutLines, n as runRolloutReleaseCli, r as PRIVACY_RULE_NAMES, u as gateReceiptRolloutLines } from "./hf-dataset-B0s2ZAhQ.js";
10
10
  import { i as harnessSessionRolloutLines, n as harnessSessionRefs } from "./harness-session-lines-CTh1-uOb.js";
11
- import { B as renderSkillUsageTable, L as afterInvocation, R as buildSkillUsageReport, U as readSkillFile, V as claudeCodeSkillSessions, t as runAnalystBenchmarkCommand, z as instant } from "./benchmark-command-Be5O6A2v.js";
11
+ import { B as renderSkillUsageTable, H as claudeCodeSkillSessions, L as afterInvocation, R as buildSkillUsageReport, V as codexSkillSessions, W as readSkillFile, t as runAnalystBenchmarkCommand, z as instant } from "./benchmark-command-C7ObyGm9.js";
12
12
  import { i as buildOpenApi, l as handleVersion, o as runRpcBatch, r as startServerAsync, s as runRpcOnce } from "./server-B-7vXS9T.js";
13
- import { b as editCreditText, f as landscape, g as surfaceTextEdits, l as metaSearch, m as formatLandscape, n as taskMatrix, o as skillManifold, r as formatSkillManifold, s as renderMetaSearchText, t as tree, v as front, y as editCredit } from "./tree-BX9ykHi3.js";
13
+ import { b as editCreditText, f as landscape, g as surfaceTextEdits, l as metaSearch, m as formatLandscape, n as taskMatrix, o as skillManifold, r as formatSkillManifold, s as renderMetaSearchText, t as tree, v as front, y as editCredit } from "./tree-CljLPWVm.js";
14
14
  import { a as analyzeSupervisorRun, i as renderSupervisorRunMarkdown, r as renderSupervisorRunHeadline, t as runtimeRunRolloutLines } from "./runtime-rollouts-CE0MbQPq.js";
15
15
  import { createHash } from "node:crypto";
16
16
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
17
17
  import { dirname, join, resolve } from "node:path";
18
- import { fileURLToPath } from "node:url";
18
+ import { fileURLToPath, pathToFileURL } from "node:url";
19
19
  import { appendFile, open, readFile, rm, stat } from "node:fs/promises";
20
+ // src/skill-usage/change-ledger.ts
21
+ /**
22
+ * The change ledger: one row per commit or pull request a session made, written
23
+ * by the session's own harness at the moment the call returned, and the reader
24
+ * that joins those rows to recorded sessions.
25
+ *
26
+ * A transcript names a pull request only when its output prints the URL, and
27
+ * names no commit. The ledger is the harness's own record: each row carries the
28
+ * tool call's id, so a change belongs to the typed turn whose span holds the
29
+ * call, and the session's own commits and merges are counted, not guessed from
30
+ * output text.
31
+ *
32
+ * Row format (JSON lines, `v` 1; a writer adds no other field the reader needs):
33
+ *
34
+ * | Field | Meaning |
35
+ * |---|---|
36
+ * | `at` | ISO time the call returned |
37
+ * | `harness` | the harness that wrote it, as the session reader names it (`claude-code`) |
38
+ * | `sessionId`, `agentId` | the session; inside a subagent, the subagent's id too (the id its own transcript carries) |
39
+ * | `toolUseId` | the id of the tool call that made the change; null when the harness gave none |
40
+ * | `action` | `commit`, `pr-create`, `pr-merge`, `observed`, or, from a writer that sees whole turns, `turn` and `push` |
41
+ * | `remote` | the repository as `owner/repo` (or `host/path`); null when the writer could not find it |
42
+ * | `sha`, `pr` | the commit or the pull request number; null when the call did not name it |
43
+ *
44
+ * `observed` is written once per session or subagent, at its first call. It says
45
+ * the writer was running, which is the only thing that lets "no change rows"
46
+ * mean "no change". A session with no row of any action is unknown, never none.
47
+ *
48
+ * A writer outside the harness, such as a gateway that runs the harness for a
49
+ * caller (CLI Bridge), sees turns, not tool calls, and adds fields to its rows:
50
+ *
51
+ * | Field | Meaning |
52
+ * |---|---|
53
+ * | `sessionId` | the gateway's session id |
54
+ * | `nativeSessionId` | the harness's own session id, the id its transcript carries; rows are keyed by it when present |
55
+ * | `turnId`, `runId` | the gateway's turn and run |
56
+ * | `turnStartedAt` | ISO time the turn began; with `at`, the window the change was made in |
57
+ * | `incomplete` | on a `turn` row: why that turn's change rows may not be all of its changes (a checkout shared with another running turn, an unread pull request list); null when they are |
58
+ * | `headBefore`, `head` | on a `turn` row: the working repository's HEAD when the turn began and when it ended |
59
+ * | `branch` | on a `push` row: the remote branch the turn pushed |
60
+ *
61
+ * Such a row has no `toolUseId`. The change belongs to the last tool call of the
62
+ * session record whose time lies in [`turnStartedAt`, `at`], so a record with no
63
+ * times, or none in the window, leaves the change unplaced. A `turn` row with a
64
+ * non-null `incomplete` makes the session's changes unknown, with a gap that says why.
65
+ *
66
+ * A row's `toolUseId` is the id the harness's hook saw. Where the session record
67
+ * holds the call under that id, or names it in `callAliases`, the change belongs
68
+ * to the turn that made the call. A row that matches neither makes the whole
69
+ * session unknown, with a gap that says so: the change happened, and which turn
70
+ * made it cannot be said, so no turn may be called change-free.
71
+ */
72
+ const CHANGE_LEDGER_ACTIONS = [
73
+ "observed",
74
+ "commit",
75
+ "pr-create",
76
+ "pr-merge",
77
+ "turn",
78
+ "push"
79
+ ];
80
+ const key = (harness, id) => `${harness}\u0000${id}`;
81
+ function parseRow(line) {
82
+ let value;
83
+ try {
84
+ value = JSON.parse(line);
85
+ } catch {
86
+ return null;
87
+ }
88
+ if (typeof value !== "object" || value === null) return null;
89
+ const row = value;
90
+ const text = (field) => {
91
+ const raw = row[field];
92
+ return typeof raw === "string" && raw !== "" ? raw : null;
93
+ };
94
+ const optional = (field) => {
95
+ const raw = row[field];
96
+ if (raw === null || raw === void 0) return null;
97
+ return typeof raw === "string" && raw !== "" ? raw : void 0;
98
+ };
99
+ const action = row.action;
100
+ const toolUseId = optional("toolUseId");
101
+ const agentId = optional("agentId");
102
+ const remote = optional("remote");
103
+ const sha = optional("sha");
104
+ const nativeSessionId = optional("nativeSessionId");
105
+ const turnStartedAt = optional("turnStartedAt");
106
+ const incomplete = optional("incomplete");
107
+ const pr = row.pr ?? null;
108
+ const at = text("at");
109
+ const harness = text("harness");
110
+ const sessionId = text("sessionId");
111
+ if (row.v !== 1 || at === null || harness === null || sessionId === null || !CHANGE_LEDGER_ACTIONS.includes(action) || toolUseId === void 0 || agentId === void 0 || remote === void 0 || sha === void 0 || nativeSessionId === void 0 || turnStartedAt === void 0 || incomplete === void 0 || pr !== null && !(typeof pr === "number" && Number.isInteger(pr) && pr > 0)) return null;
112
+ return {
113
+ v: 1,
114
+ at,
115
+ harness,
116
+ sessionId,
117
+ agentId,
118
+ toolUseId,
119
+ action,
120
+ remote,
121
+ sha,
122
+ pr,
123
+ nativeSessionId,
124
+ turnStartedAt,
125
+ incomplete
126
+ };
127
+ }
128
+ /** The reference the registry's outcome source names a change by: `owner/repo#123` or `owner/repo@<sha>`. */
129
+ function refOf(row) {
130
+ if (row.remote === null) return null;
131
+ if (row.action === "commit") return row.sha === null ? null : `${row.remote}@${row.sha}`;
132
+ if (row.action === "pr-create" || row.action === "pr-merge") return row.pr === null ? null : `${row.remote}#${row.pr}`;
133
+ return null;
134
+ }
135
+ /** Read ledger text. A line that is not a row is counted, not skipped silently, and no row is guessed from it. */
136
+ function parseChangeLedger(text) {
137
+ const sessions = /* @__PURE__ */ new Map();
138
+ let rows = 0;
139
+ let malformed = 0;
140
+ for (const line of text.split("\n")) {
141
+ if (line.trim() === "") continue;
142
+ const row = parseRow(line);
143
+ if (row === null) {
144
+ malformed += 1;
145
+ continue;
146
+ }
147
+ rows += 1;
148
+ const id = key(row.harness, row.agentId ?? row.nativeSessionId ?? row.sessionId);
149
+ let session = sessions.get(id);
150
+ if (session === void 0) {
151
+ session = {
152
+ observed: false,
153
+ changes: [],
154
+ unnamed: 0,
155
+ timed: [],
156
+ incomplete: /* @__PURE__ */ new Map()
157
+ };
158
+ sessions.set(id, session);
159
+ }
160
+ if (row.action === "observed" || row.action === "push") {
161
+ session.observed = true;
162
+ continue;
163
+ }
164
+ if (row.action === "turn") {
165
+ session.observed = true;
166
+ if (row.incomplete) session.incomplete.set(row.incomplete, (session.incomplete.get(row.incomplete) ?? 0) + 1);
167
+ continue;
168
+ }
169
+ session.observed = true;
170
+ const ref = refOf(row);
171
+ if (ref === null) session.unnamed += 1;
172
+ else if (row.toolUseId === null && row.turnStartedAt) session.timed.push({
173
+ ref,
174
+ from: row.turnStartedAt,
175
+ to: row.at
176
+ });
177
+ else session.changes.push({
178
+ ref,
179
+ callId: row.toolUseId ?? "",
180
+ at: row.at
181
+ });
182
+ }
183
+ return {
184
+ sessions,
185
+ rows,
186
+ malformed
187
+ };
188
+ }
189
+ /** Read one or more ledger files as one ledger. A file that cannot be read throws: a missing ledger is not an empty one. */
190
+ async function readChangeLedger(paths) {
191
+ const texts = [];
192
+ for (const path of paths) try {
193
+ texts.push(await readFile(path, "utf8"));
194
+ } catch (error) {
195
+ throw new ValidationError(`readChangeLedger: cannot read ${path}: ${errorMessage(error)}`);
196
+ }
197
+ return parseChangeLedger(texts.join("\n"));
198
+ }
199
+ /** The last tool call or skill call of the record whose time lies in [from, to]; null when there is none. */
200
+ function callInWindow(record, from, to) {
201
+ const start = Date.parse(from);
202
+ const end = Date.parse(to);
203
+ if (!Number.isFinite(start) || !Number.isFinite(end)) return null;
204
+ let found = null;
205
+ for (const event of record.events) {
206
+ if (event.kind === "model" || event.at === null) continue;
207
+ const at = Date.parse(event.at);
208
+ if (at >= start && at <= end) found = event.kind === "tool" ? event.id : event.callId;
209
+ }
210
+ return found;
211
+ }
212
+ function joinRead(read, ledger) {
213
+ if (!read.succeeded) return read;
214
+ const { value } = read;
215
+ const held = ledger.sessions.get(key(value.harness, value.sessionId));
216
+ const seen = /* @__PURE__ */ new Set();
217
+ const changes = [];
218
+ const aliases = value.callAliases ?? {};
219
+ const placeable = new Set(value.events.flatMap((event) => event.kind === "tool" ? [event.id] : event.kind === "skill" ? [event.callId] : []));
220
+ let unplaced = 0;
221
+ const timed = [];
222
+ for (const change of held?.timed ?? []) {
223
+ const callId = callInWindow(value, change.from, change.to);
224
+ if (callId === null) unplaced += 1;
225
+ else timed.push({
226
+ ref: change.ref,
227
+ callId,
228
+ at: change.to
229
+ });
230
+ }
231
+ for (const row of [
232
+ ...value.changes ?? [],
233
+ ...held?.changes ?? [],
234
+ ...timed
235
+ ]) {
236
+ const change = Object.hasOwn(aliases, row.callId) ? {
237
+ ...row,
238
+ callId: aliases[row.callId]
239
+ } : row;
240
+ if (!placeable.has(change.callId)) unplaced += 1;
241
+ const id = `${change.ref}\u0000${change.callId}`;
242
+ if (seen.has(id)) continue;
243
+ seen.add(id);
244
+ changes.push(change);
245
+ }
246
+ const gaps = [...value.gaps];
247
+ if (held !== void 0 && held.unnamed > 0) gaps.push(`${held.unnamed} changes the change ledger recorded could not be named (no repository, or no commit or pull request number)`);
248
+ if (unplaced > 0) gaps.push(`${unplaced} changes name a tool call this session record does not hold, so the turn that made them is unknown and no turn is reported as having made none`);
249
+ const { changes: _transcriptChanges, ...rest } = value;
250
+ const incomplete = [...held?.incomplete ?? []];
251
+ if (incomplete.length > 0) gaps.push(`the change ledger's writer said some turns' changes may be incomplete (${incomplete.map(([why, n]) => `${why}: ${n}`).join(", ")}), so the session's changes are unknown`);
252
+ const known = unplaced === 0 && incomplete.length === 0 && (held?.observed === true || changes.length > 0);
253
+ return {
254
+ ...read,
255
+ value: {
256
+ ...rest,
257
+ gaps,
258
+ ...known ? { changes } : {}
259
+ }
260
+ };
261
+ }
262
+ /**
263
+ * The sessions of `source` with their changes taken from the ledger as well as
264
+ * from the transcript. A session the ledger never observed keeps only the
265
+ * changes its transcript shows, and has none recorded when it shows none.
266
+ */
267
+ async function* withChangeLedger(source, ledger) {
268
+ for await (const read of source) yield joinRead(read, ledger);
269
+ }
20
270
  // src/cli-config.ts
21
271
  /**
22
272
  * Provider configuration for the `agent-eval` binary.
@@ -87,8 +337,9 @@ function nonEmpty(value) {
87
337
  }
88
338
  // src/skill-usage/command.ts
89
339
  /**
90
- * `agent-eval skill-usage <transcripts-dir>` reads a directory of Claude Code
91
- * transcripts and prints the skill-usage report.
340
+ * `agent-eval skill-usage <sessions-dir>` reads a directory of Claude Code
341
+ * transcripts (or, with `--harness codex`, Codex rollouts) and prints the
342
+ * skill-usage report.
92
343
  *
93
344
  * By default the JSON report goes to stdout and the short table to stderr, so
94
345
  * `> report.json` keeps the report while the table stays on the terminal.
@@ -105,7 +356,7 @@ const FORMATS$2 = [
105
356
  "json",
106
357
  "table"
107
358
  ];
108
- const USAGE$2 = "usage: agent-eval skill-usage <transcripts-dir> [--since <7d|36h|90m|ISO time>] [--format both|json|table] [--limit <rows>] [--pricing <rates.json>]";
359
+ const USAGE$2 = "usage: agent-eval skill-usage <sessions-dir> [--harness claude-code|codex] [--since <7d|36h|90m|ISO time>] [--format both|json|table] [--limit <rows>] [--pricing <rates.json>]";
109
360
  const PROCESS_IO$2 = {
110
361
  stdout: (text) => {
111
362
  process.stdout.write(text);
@@ -114,6 +365,17 @@ const PROCESS_IO$2 = {
114
365
  process.stderr.write(text);
115
366
  }
116
367
  };
368
+ /** The harnesses whose session stores the commands read. */
369
+ const SESSION_HARNESSES = ["claude-code", "codex"];
370
+ /** The sessions under a harness's store: Claude Code's projects directory, or Codex's sessions directory. */
371
+ function harnessSkillSessions(harness, directory, options) {
372
+ return harness === "codex" ? codexSkillSessions(directory, options) : claudeCodeSkillSessions(directory, options);
373
+ }
374
+ /** The value of `--harness`, checked. */
375
+ function parseHarness(raw) {
376
+ if (!SESSION_HARNESSES.includes(raw)) throw new Error(`--harness expects one of ${SESSION_HARNESSES.join("|")}, got ${JSON.stringify(raw)}`);
377
+ return raw;
378
+ }
117
379
  const DURATION = /^(\d+(?:\.\d+)?)([dhm])$/;
118
380
  const UNIT_MS = {
119
381
  d: 864e5,
@@ -131,6 +393,7 @@ function parseSince(raw, nowMs) {
131
393
  function parseArgs$3(argv) {
132
394
  const args = {
133
395
  directory: "",
396
+ harness: "claude-code",
134
397
  since: null,
135
398
  format: "both",
136
399
  limit: 30,
@@ -143,7 +406,8 @@ function parseArgs$3(argv) {
143
406
  };
144
407
  for (let i = 0; i < argv.length; i++) {
145
408
  const arg = argv[i];
146
- if (arg === "--since") args.since = value(arg, ++i);
409
+ if (arg === "--harness") args.harness = parseHarness(value(arg, ++i));
410
+ else if (arg === "--since") args.since = value(arg, ++i);
147
411
  else if (arg === "--format") {
148
412
  const raw = value(arg, ++i);
149
413
  if (!FORMATS$2.includes(raw)) throw new Error(`--format expects one of ${FORMATS$2.join("|")}, got ${JSON.stringify(raw)}`);
@@ -203,7 +467,7 @@ async function runSkillUsageCommand(argv, io = PROCESS_IO$2) {
203
467
  return 2;
204
468
  }
205
469
  try {
206
- const report = await buildSkillUsageReport(claudeCodeSkillSessions(resolve(args.directory), sinceMs === void 0 ? {} : { sinceMs }), {
470
+ const report = await buildSkillUsageReport(harnessSkillSessions(args.harness, resolve(args.directory), sinceMs === void 0 ? {} : { sinceMs }), {
207
471
  ...sinceMs === void 0 ? {} : { sinceMs },
208
472
  ...rates === void 0 ? {} : { pricing: (model) => rates?.get(model) },
209
473
  readSkillFile
@@ -220,6 +484,262 @@ async function runSkillUsageCommand(argv, io = PROCESS_IO$2) {
220
484
  return 1;
221
485
  }
222
486
  }
487
+ // src/intent-record/derive.ts
488
+ /**
489
+ * Intent records from recorded sessions.
490
+ *
491
+ * A session's typed turns are cut into intents. A turn that a labeler calls a
492
+ * correction or a re-ask attaches to the intent already open; any other turn
493
+ * opens a new one and closes the open one. A turn nobody labeled opens a new
494
+ * intent, and the intent it closes then cannot say how many corrections it
495
+ * drew. The span of an intent runs from its opening turn to the turn that
496
+ * closes it, or to the session's end, and its cost and procedures are those of
497
+ * the events in that span.
498
+ */
499
+ const sha256 = (text) => createHash("sha256").update(text).digest("hex");
500
+ function isCorrection(label) {
501
+ if (label === null) return null;
502
+ if (label.kind === "correction") return true;
503
+ return label.correction;
504
+ }
505
+ function cost(session, thread, options) {
506
+ const after = afterInvocation(session, thread.startEvent - 1, thread.startAt, options, {
507
+ eventIndex: thread.endEvent,
508
+ at: thread.endAt
509
+ });
510
+ return {
511
+ tokens: after.modelCalls > 0 && after.modelCallsWithoutUsage === 0 ? after.tokens.total : null,
512
+ usd: after.pricedModelCalls > 0 && after.unpricedModelCalls === 0 ? after.costUsd : null,
513
+ wallMs: after.wallMs,
514
+ modelCalls: after.modelCalls
515
+ };
516
+ }
517
+ function refsInSpan(session, from, to) {
518
+ if (session.changes === void 0) return void 0;
519
+ const position = /* @__PURE__ */ new Map();
520
+ session.events.forEach((event, index) => {
521
+ if (event.kind === "tool") position.set(event.id, index);
522
+ else if (event.kind === "skill") position.set(event.callId, index);
523
+ });
524
+ const refs = /* @__PURE__ */ new Set();
525
+ for (const change of session.changes) {
526
+ const index = position.get(change.callId);
527
+ if (index !== void 0 && index >= from && index < to) refs.add(change.ref);
528
+ }
529
+ return [...refs].sort();
530
+ }
531
+ /**
532
+ * Cut one session's typed turns into intents. Returns none when the reader
533
+ * records no typed turns, and the caller counts that session apart.
534
+ */
535
+ async function deriveSessionIntents(session, labeler, options, ignore) {
536
+ if (session.turns === void 0) return null;
537
+ const threads = [];
538
+ let open = null;
539
+ let previousText = null;
540
+ const close = (thread, by, at, event) => {
541
+ thread.closedBy = by;
542
+ thread.endAt = at;
543
+ thread.endEvent = event;
544
+ };
545
+ for (const [index, turn] of session.turns.entries()) {
546
+ if (options.sinceMs !== void 0) {
547
+ const at = instant(turn.at);
548
+ if (at === null || at < options.sinceMs) continue;
549
+ }
550
+ const context = {
551
+ harness: session.harness,
552
+ sessionId: session.sessionId,
553
+ index,
554
+ at: turn.at,
555
+ text: turn.text,
556
+ previousText
557
+ };
558
+ if (ignore?.(context) === true) continue;
559
+ const label = labeler === void 0 ? null : await labeler(context);
560
+ previousText = turn.text;
561
+ const correction = isCorrection(label);
562
+ const reask = label === null ? null : label.reask;
563
+ const attaches = open !== null && (correction === true || reask === true);
564
+ if (open !== null) {
565
+ if (correction === null) open.correctionsKnown = false;
566
+ else if (correction) open.corrections += 1;
567
+ if (reask === null) open.reasksKnown = false;
568
+ else if (reask) open.reasks += 1;
569
+ }
570
+ if (attaches && open !== null) {
571
+ open.userTurns += 1;
572
+ continue;
573
+ }
574
+ if (open !== null) close(open, "next-intent", turn.at, turn.eventIndex);
575
+ open = {
576
+ openedAtIndex: index,
577
+ startEvent: turn.eventIndex,
578
+ startAt: turn.at,
579
+ promptSha256: sha256(turn.text),
580
+ promptChars: turn.text.length,
581
+ turnId: turn.id,
582
+ label,
583
+ userTurns: 1,
584
+ corrections: 0,
585
+ reasks: 0,
586
+ correctionsKnown: true,
587
+ reasksKnown: true,
588
+ endEvent: session.events.length,
589
+ endAt: session.endedAt,
590
+ closedBy: "session-end"
591
+ };
592
+ threads.push(open);
593
+ }
594
+ return threads.map((thread) => {
595
+ return {
596
+ record: {
597
+ intentId: sha256(`${session.harness}\u0000${session.sessionId}\u0000${thread.turnId}`),
598
+ harness: session.harness,
599
+ sessionId: session.sessionId,
600
+ at: thread.startAt,
601
+ prompt: {
602
+ sha256: thread.promptSha256,
603
+ chars: thread.promptChars
604
+ },
605
+ label: thread.label === null ? null : {
606
+ source: thread.label.source,
607
+ kind: thread.label.kind,
608
+ done: thread.label.done
609
+ },
610
+ cost: cost(session, thread, options),
611
+ end: {
612
+ userTurns: thread.userTurns,
613
+ corrections: thread.correctionsKnown ? thread.corrections : null,
614
+ reasks: thread.reasksKnown ? thread.reasks : null,
615
+ closedBy: thread.closedBy
616
+ }
617
+ },
618
+ span: {
619
+ from: thread.startEvent,
620
+ to: thread.endEvent
621
+ },
622
+ window: {
623
+ from: thread.startAt,
624
+ to: thread.closedBy === "next-intent" ? thread.endAt : null
625
+ },
626
+ changeRefs: refsInSpan(session, thread.startEvent, thread.endEvent)
627
+ };
628
+ });
629
+ }
630
+ /** Whether a change reading says the change reached its done line: merged and not fixed within the window. */
631
+ function changesReachedDone(changes) {
632
+ if (changes.status !== "joined" || changes.outcomes.length === 0) return {
633
+ reachedDone: null,
634
+ abandoned: null
635
+ };
636
+ const outcomes = changes.outcomes;
637
+ const unmerged = outcomes.some((outcome) => outcome.merged === false);
638
+ const fixed = outcomes.some((outcome) => outcome.merged === true && outcome.hotfixed === true);
639
+ const clean = outcomes.every((outcome) => outcome.merged === true && outcome.hotfixed === false);
640
+ return {
641
+ reachedDone: unmerged || fixed ? false : clean ? true : null,
642
+ abandoned: unmerged ? true : outcomes.every((o) => o.merged === true) ? false : null
643
+ };
644
+ }
645
+ // src/intent-record/contract.ts
646
+ const INTENT_KINDS = [
647
+ "task",
648
+ "problem",
649
+ "project",
650
+ "information",
651
+ "correction"
652
+ ];
653
+ // src/intent-record/report.ts
654
+ const NOTES$1 = [
655
+ "Intents are cut from typed turns: a turn a labeler calls a correction or a re-ask attaches to the open intent, and any other turn, labeled or not, opens a new one. Without labels every turn is its own intent and no intent knows its corrections.",
656
+ "An intent joins the changes whose tool call lies in its span, in its own session only. Work and changes in subagents count toward the procedures that served it, by time, and not toward its cost or changes.",
657
+ "reachedDone comes from the outcome of the intent’s changes when they have one, else is true when the person moved on to another intent, else unknown. A session that ends says nothing."
658
+ ];
659
+ function joinChanges(refs, outcomes) {
660
+ if (refs === void 0) return { status: "not-recorded" };
661
+ if (refs.length === 0) return { status: "none" };
662
+ return {
663
+ status: "joined",
664
+ refs,
665
+ outcomes: refs.flatMap((ref) => {
666
+ const reading = outcomes.byRef.get(ref);
667
+ return reading === void 0 ? [] : [reading];
668
+ })
669
+ };
670
+ }
671
+ function buildIntentReport(sessions, outcomes) {
672
+ const byId = new Map(sessions.map((session) => [session.sessionId, session]));
673
+ const inherited = /* @__PURE__ */ new Map();
674
+ for (const session of sessions) for (let parent = session.parentSessionId, hops = 0; parent !== null && hops < 64; parent = byId.get(parent)?.parentSessionId ?? null, hops++) for (const draft of byId.get(parent)?.drafts ?? []) {
675
+ const from = instant(draft.window.from);
676
+ const to = instant(draft.window.to);
677
+ if (from === null) continue;
678
+ for (const invocation of session.invocations) {
679
+ const at = instant(invocation.at);
680
+ if (at === null || at < from || to !== null && at >= to) continue;
681
+ const keys = inherited.get(draft) ?? /* @__PURE__ */ new Set();
682
+ keys.add(invocation.key);
683
+ inherited.set(draft, keys);
684
+ }
685
+ }
686
+ const intents = [];
687
+ let sessionsWithTurns = 0;
688
+ let sessionsWithoutTurns = 0;
689
+ for (const session of sessions) {
690
+ if (session.drafts === null) {
691
+ sessionsWithoutTurns += 1;
692
+ continue;
693
+ }
694
+ sessionsWithTurns += 1;
695
+ for (const draft of session.drafts) {
696
+ const keys = new Set(inherited.get(draft));
697
+ for (const invocation of session.invocations) if (invocation.index >= draft.span.from && invocation.index < draft.span.to) keys.add(invocation.key);
698
+ const changes = joinChanges(draft.changeRefs, outcomes);
699
+ const fromChanges = changesReachedDone(changes);
700
+ const movedOn = draft.record.end.closedBy === "next-intent";
701
+ const evidence = fromChanges.reachedDone !== null ? "change-outcome" : movedOn ? "moved-on" : "none";
702
+ intents.push({
703
+ ...draft.record,
704
+ procedures: [...keys].sort(),
705
+ end: {
706
+ ...draft.record.end,
707
+ reachedDone: fromChanges.reachedDone ?? (movedOn ? true : null),
708
+ abandoned: fromChanges.abandoned,
709
+ evidence
710
+ },
711
+ changes
712
+ });
713
+ }
714
+ }
715
+ const kinds = [...INTENT_KINDS, null];
716
+ const share = (part, whole) => whole === 0 ? null : part / whole;
717
+ const known = (record) => record.end.reachedDone !== null;
718
+ return {
719
+ intents,
720
+ summary: {
721
+ intents: intents.length,
722
+ sessionsWithTurns,
723
+ sessionsWithoutTurns,
724
+ labeled: intents.filter((record) => record.label !== null).length,
725
+ knownEnd: intents.filter(known).length,
726
+ knownEndShare: share(intents.filter(known).length, intents.length),
727
+ byKind: kinds.map((kind) => {
728
+ const of = intents.filter((record) => (record.label?.kind ?? null) === kind);
729
+ return {
730
+ kind,
731
+ intents: of.length,
732
+ knownEnd: of.filter(known).length,
733
+ knownEndShare: share(of.filter(known).length, of.length),
734
+ knownCorrections: of.filter((record) => record.end.corrections !== null).length,
735
+ joinedToChange: of.filter((record) => record.changes.status === "joined").length,
736
+ withChangeOutcome: of.filter((record) => record.changes.status === "joined" && record.changes.outcomes.length > 0).length
737
+ };
738
+ })
739
+ },
740
+ notes: [...NOTES$1]
741
+ };
742
+ }
223
743
  /**
224
744
  * Index outcomes by change reference. An outcome judged over another window
225
745
  * keeps `merged` and `gateGreenFirstTry` and loses `hotfixed`: a 3-day and a
@@ -445,6 +965,7 @@ function addSearch(registry, search, keys, options) {
445
965
  });
446
966
  for (const cell of search.cells({ nodeId: node.nodeId })) {
447
967
  if (cell.attempts === 0) continue;
968
+ const onSeat = cell.subscriptionAttempts === cell.attempts;
448
969
  builder.executions.push({
449
970
  source: "search-cell",
450
971
  searchId: search.searchId,
@@ -455,7 +976,8 @@ function addSearch(registry, search, keys, options) {
455
976
  outcome: cell.outcome,
456
977
  score: cell.score,
457
978
  tokens: cell.tokensKnown ? cell.tokens.inputTokens + cell.tokens.outputTokens + cell.tokens.cachedTokens : null,
458
- usd: cell.costKnown ? cell.spentUsd : null,
979
+ usd: cell.costKnown && !onSeat ? cell.spentUsd : null,
980
+ costBasis: !cell.costKnown ? "unknown" : onSeat ? "subscription" : "measured",
459
981
  wallMs: cell.wallKnown ? cell.wallMs : null
460
982
  });
461
983
  }
@@ -504,6 +1026,7 @@ async function buildProcedureRegistry(input, options = {}) {
504
1026
  unreadable: 0,
505
1027
  withInvocation: 0
506
1028
  };
1029
+ const intentSessions = [];
507
1030
  const versionDigest = (event) => {
508
1031
  if (event.version !== null) return event.version.bodySha256;
509
1032
  if (event.skillFile === null || options.readSkillFile === void 0) return null;
@@ -526,6 +1049,7 @@ async function buildProcedureRegistry(input, options = {}) {
526
1049
  refs: session.changes?.map((change) => change.ref)
527
1050
  });
528
1051
  let counted = false;
1052
+ const placed = [];
529
1053
  session.events.forEach((event, position) => {
530
1054
  if (event.kind !== "skill") return;
531
1055
  if (seenCalls.has(event.callId)) return;
@@ -540,6 +1064,11 @@ async function buildProcedureRegistry(input, options = {}) {
540
1064
  const builder = registry.builder(key);
541
1065
  builder.names.add(event.skill);
542
1066
  builder.kind ??= options.kindOfSkill?.(event.skill) ?? "skill";
1067
+ placed.push({
1068
+ index: position,
1069
+ at: event.at,
1070
+ key
1071
+ });
543
1072
  const after = afterInvocation(session, position, event.at, options);
544
1073
  pending.push({
545
1074
  builderKey: key,
@@ -554,6 +1083,12 @@ async function buildProcedureRegistry(input, options = {}) {
554
1083
  });
555
1084
  });
556
1085
  if (counted) sessions.withInvocation += 1;
1086
+ if (options.intents !== void 0) intentSessions.push({
1087
+ sessionId: session.sessionId,
1088
+ parentSessionId: session.parentSessionId,
1089
+ drafts: await deriveSessionIntents(session, options.intents.labeler, options, options.intents.ignore),
1090
+ invocations: placed
1091
+ });
557
1092
  }
558
1093
  const joins = {
559
1094
  joined: 0,
@@ -590,6 +1125,7 @@ async function buildProcedureRegistry(input, options = {}) {
590
1125
  passed: 0,
591
1126
  failed: 0,
592
1127
  errored: 0,
1128
+ subscription: 0,
593
1129
  tokens: emptyMeasure(),
594
1130
  usd: emptyMeasure(),
595
1131
  wallMs: emptyMeasure()
@@ -607,7 +1143,8 @@ async function buildProcedureRegistry(input, options = {}) {
607
1143
  else if (execution.outcome === "failed") cells.failed += 1;
608
1144
  else if (execution.outcome === "errored") cells.errored += 1;
609
1145
  addMeasure(cells.tokens, execution.tokens);
610
- addMeasure(cells.usd, execution.usd);
1146
+ if (execution.costBasis === "subscription") cells.subscription += 1;
1147
+ else addMeasure(cells.usd, execution.usd);
611
1148
  addMeasure(cells.wallMs, execution.wallMs);
612
1149
  } else {
613
1150
  sessionRuns.invocations += 1;
@@ -657,6 +1194,7 @@ async function buildProcedureRegistry(input, options = {}) {
657
1194
  outcomesInWrongWindow: outcomes.otherWindow
658
1195
  },
659
1196
  versions,
1197
+ intents: options.intents === void 0 ? null : buildIntentReport(intentSessions, outcomes),
660
1198
  unreadable,
661
1199
  notes: [...NOTES]
662
1200
  };
@@ -684,6 +1222,7 @@ function renderProcedureRegistryTable(registry, limit = 30) {
684
1222
  `${registry.versions.length} procedure versions; ${registry.invocations} invocations in ${registry.sessions.read} sessions (${registry.sessions.unreadable} unreadable); ${registry.searches.read} searches`,
685
1223
  `joined to a change: ${join.joined} of ${join.invocations} invocations (${percent(join.joinedShare)}); none ${join.none}, not recorded ${join.notRecorded}`,
686
1224
  `with an outcome for a change: ${join.withOutcome} (${percent(join.withOutcomeShare)}); ${join.distinctChanges} distinct changes, ${join.outcomesSupplied} outcomes supplied (hot-fix window ${join.hotfixWindowDays} days)`,
1225
+ `cells on a subscription seat (a known basis with no dollar figure): ${registry.versions.reduce((n, v) => n + v.cells.subscription, 0)}`,
687
1226
  "",
688
1227
  "version kind names cells runs chg-joined merged y/n/? hotfix y/n/? tokens(runs) decided"
689
1228
  ];
@@ -704,13 +1243,38 @@ function renderProcedureRegistryTable(registry, limit = 30) {
704
1243
  ].join(" "));
705
1244
  }
706
1245
  if (registry.versions.length > limit) lines.push(`... ${registry.versions.length - limit} more versions in the JSON`);
1246
+ const intents = registry.intents;
1247
+ if (intents !== null) {
1248
+ const summary = intents.summary;
1249
+ lines.push("", `${summary.intents} intents in ${summary.sessionsWithTurns} sessions (${summary.sessionsWithoutTurns} record no typed turns); ${summary.labeled} labeled; known end ${summary.knownEnd} (${percent(summary.knownEndShare)})`, "kind intents known-end share corrections-known joined-to-change with-outcome");
1250
+ for (const row of summary.byKind) {
1251
+ if (row.intents === 0) continue;
1252
+ lines.push([
1253
+ (row.kind ?? "unlabeled").padEnd(12),
1254
+ String(row.intents).padStart(8),
1255
+ String(row.knownEnd).padStart(10),
1256
+ percent(row.knownEndShare).padStart(7),
1257
+ String(row.knownCorrections).padStart(18),
1258
+ String(row.joinedToChange).padStart(17),
1259
+ String(row.withChangeOutcome).padStart(13)
1260
+ ].join(" "));
1261
+ }
1262
+ for (const note of intents.notes) lines.push("", `note: ${note}`);
1263
+ }
707
1264
  for (const note of registry.notes) lines.push("", `note: ${note}`);
708
1265
  return `${lines.join("\n")}\n`;
709
1266
  }
710
1267
  // src/procedure-registry/command.ts
711
1268
  /**
712
1269
  * `agent-eval procedure-registry <sessions-dir>` prints the procedure registry
713
- * for a directory of Claude Code transcripts and any number of search ledgers.
1270
+ * for a directory of Claude Code transcripts (or, with `--harness codex`, Codex
1271
+ * rollouts) and any number of search ledgers.
1272
+ *
1273
+ * `--change-ledger <file>` (repeatable) names a change ledger, the harness's own
1274
+ * record of each commit and pull request a session made (see
1275
+ * `src/skill-usage/change-ledger.ts`). A session the ledger observed has exactly
1276
+ * the changes it lists; a session it never saw has only what its transcript
1277
+ * shows, and none recorded when the transcript shows none.
714
1278
  *
715
1279
  * `--outcomes <file>` names a JSON array of {@link ChangeOutcome}: what the
716
1280
  * caller knows of each change the sessions produced. Without it every change is
@@ -725,7 +1289,7 @@ const FORMATS$1 = [
725
1289
  "json",
726
1290
  "table"
727
1291
  ];
728
- const USAGE$1 = "usage: agent-eval procedure-registry <sessions-dir> [--ledger <search-ledger.jsonl>]... [--since <7d|36h|90m|ISO time>] [--outcomes <changes.json>] [--format both|json|table] [--limit <rows>] [--pricing <rates.json>]";
1292
+ const USAGE$1 = "usage: agent-eval procedure-registry <sessions-dir> [--harness claude-code|codex] [--ledger <search-ledger.jsonl>]... [--since <7d|36h|90m|ISO time>] [--outcomes <changes.json>] [--change-ledger <changes.jsonl>]... [--intents [<labeler.mjs>]] [--format both|json|table] [--limit <rows>] [--pricing <rates.json>]";
729
1293
  const PROCESS_IO$1 = {
730
1294
  stdout: (text) => {
731
1295
  process.stdout.write(text);
@@ -737,9 +1301,12 @@ const PROCESS_IO$1 = {
737
1301
  function parseArgs$2(argv) {
738
1302
  const args = {
739
1303
  directory: "",
1304
+ harness: "claude-code",
740
1305
  ledgers: [],
741
1306
  since: null,
742
1307
  outcomes: null,
1308
+ changeLedgers: [],
1309
+ intents: null,
743
1310
  format: "both",
744
1311
  limit: 30,
745
1312
  pricing: null
@@ -751,10 +1318,17 @@ function parseArgs$2(argv) {
751
1318
  };
752
1319
  for (let i = 0; i < argv.length; i++) {
753
1320
  const arg = argv[i];
754
- if (arg === "--ledger") args.ledgers.push(value(arg, ++i));
1321
+ if (arg === "--harness") args.harness = parseHarness(value(arg, ++i));
1322
+ else if (arg === "--ledger") args.ledgers.push(value(arg, ++i));
755
1323
  else if (arg === "--since") args.since = value(arg, ++i);
756
1324
  else if (arg === "--outcomes") args.outcomes = value(arg, ++i);
757
- else if (arg === "--pricing") args.pricing = value(arg, ++i);
1325
+ else if (arg === "--change-ledger") args.changeLedgers.push(value(arg, ++i));
1326
+ else if (arg === "--intents") {
1327
+ const next = argv[i + 1];
1328
+ const labeler = next !== void 0 && !next.startsWith("--") ? next : null;
1329
+ if (labeler !== null) i += 1;
1330
+ args.intents = { labeler };
1331
+ } else if (arg === "--pricing") args.pricing = value(arg, ++i);
758
1332
  else if (arg === "--format") {
759
1333
  const raw = value(arg, ++i);
760
1334
  if (!FORMATS$1.includes(raw)) throw new Error(`--format expects one of ${FORMATS$1.join("|")}, got ${JSON.stringify(raw)}`);
@@ -792,6 +1366,15 @@ function readOutcomes(path) {
792
1366
  };
793
1367
  });
794
1368
  }
1369
+ /** A labeler module: its default export is an {@link IntentLabeler}. It lives with the caller, where the labels and the words they read do. */
1370
+ async function loadLabeler(path) {
1371
+ const loaded = await import(pathToFileURL(resolve(path)).href);
1372
+ if (typeof loaded.default !== "function") throw new Error(`--intents ${path}: the module must export a labeler function as its default`);
1373
+ return {
1374
+ labeler: loaded.default,
1375
+ ...typeof loaded.ignore === "function" ? { ignore: loaded.ignore } : {}
1376
+ };
1377
+ }
795
1378
  async function readLedger(path) {
796
1379
  const text = await readFile(path, "utf8");
797
1380
  const first = JSON.parse(text.slice(0, Math.max(0, text.indexOf("\n"))));
@@ -817,14 +1400,20 @@ async function runProcedureRegistryCommand(argv, io = PROCESS_IO$1) {
817
1400
  return 2;
818
1401
  }
819
1402
  try {
1403
+ const labeler = args.intents?.labeler == null ? void 0 : await loadLabeler(args.intents.labeler);
1404
+ const searches = await Promise.all(args.ledgers.map((path) => readLedger(resolve(path))));
1405
+ const changeLedger = args.changeLedgers.length === 0 ? void 0 : await readChangeLedger(args.changeLedgers.map((path) => resolve(path)));
1406
+ if (changeLedger !== void 0 && changeLedger.malformed > 0) io.stderr(`change ledger: ${changeLedger.malformed} lines are not rows and were not read\n`);
1407
+ const transcripts = harnessSkillSessions(args.harness, resolve(args.directory), sinceMs === void 0 ? {} : { sinceMs });
820
1408
  const registry = await buildProcedureRegistry({
821
- searches: await Promise.all(args.ledgers.map((path) => readLedger(resolve(path)))),
822
- sessions: claudeCodeSkillSessions(resolve(args.directory), sinceMs === void 0 ? {} : { sinceMs }),
1409
+ searches,
1410
+ sessions: changeLedger === void 0 ? transcripts : withChangeLedger(transcripts, changeLedger),
823
1411
  outcomes
824
1412
  }, {
825
1413
  ...sinceMs === void 0 ? {} : { sinceMs },
826
1414
  ...rates === void 0 ? {} : { pricing: (model) => rates?.get(model) },
827
- readSkillFile
1415
+ readSkillFile,
1416
+ ...args.intents === null ? {} : { intents: { ...labeler } }
828
1417
  });
829
1418
  const table = renderProcedureRegistryTable(registry, args.limit);
830
1419
  if (args.format === "table") io.stdout(table);
@@ -1462,7 +2051,7 @@ async function runSupervisorRunCommand(argv, io = PROCESS_IO) {
1462
2051
  * agent-eval search ship <search-ledger.jsonl> --run-kind optimization|eval
1463
2052
  * agent-eval search show <search-ledger.jsonl>
1464
2053
  * agent-eval skill-usage <transcripts-dir> [--since 7d]
1465
- * agent-eval procedure-registry <sessions-dir> [--ledger <path>]... [--since 30d] [--outcomes <file>]
2054
+ * agent-eval procedure-registry <sessions-dir> [--ledger <path>]... [--since 30d] [--outcomes <file>] [--change-ledger <file>]...
1466
2055
  * agent-eval openapi [--out path] # write OpenAPI spec
1467
2056
  * agent-eval version
1468
2057
  *
@@ -1538,11 +2127,14 @@ Commands:
1538
2127
  version: invocations by agent, user and harness, sessions, and the tool
1539
2128
  calls, tool errors, tokens, wall time and cost after its first invocation.
1540
2129
  The JSON report goes to stdout and the table to stderr.
1541
- procedure-registry <sessions-dir> [--ledger <search-ledger.jsonl>]... [--since <7d|36h|90m|ISO time>] [--outcomes <changes.json>] [--format both|json|table] [--limit <rows>] [--pricing <rates.json>]
2130
+ procedure-registry <sessions-dir> [--ledger <search-ledger.jsonl>]... [--since <7d|36h|90m|ISO time>] [--outcomes <changes.json>] [--change-ledger <changes.jsonl>]... [--intents [<labeler.mjs>]] [--format both|json|table] [--limit <rows>] [--pricing <rates.json>]
1542
2131
  Join search ledgers and recorded Claude Code sessions on the version digest:
1543
2132
  per procedure version, its lineage, every execution, tokens, cost and wall
1544
2133
  time, the outcome of the changes its sessions produced, and the decisions
1545
- taken on it. The JSON registry goes to stdout and the table to stderr.
2134
+ taken on it. With --intents, also each typed turn's intent: the versions
2135
+ that served it, its cost and how it ended; the labeler module's default
2136
+ export labels turns, and without one no turn has a kind or a correction.
2137
+ The JSON registry goes to stdout and the table to stderr.
1546
2138
  version
1547
2139
  Print server + wire-protocol version JSON.
1548
2140