@dadado/agent-kit-cli 6.9.0 → 6.10.1

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 (30) hide show
  1. package/dashboard/README.md +16 -0
  2. package/dashboard/art/atmospheric-purifier.webp +0 -0
  3. package/dashboard/art/rover-frozen-flats.webp +0 -0
  4. package/dashboard/art/seed-tree-crane.webp +0 -0
  5. package/dashboard/art/uplink-tower-road.webp +0 -0
  6. package/dashboard/dashboard-data.mjs +150 -8
  7. package/dashboard/dashboard.html +398 -3
  8. package/dashboard/lib/live-refresh.mjs +1 -0
  9. package/dashboard/lib/outcome-ledger.d.mts +115 -0
  10. package/dashboard/lib/outcome-ledger.mjs +595 -0
  11. package/dashboard/lib/semantic-model.d.mts +14 -0
  12. package/dashboard/lib/semantic-model.mjs +3 -0
  13. package/dashboard/serve.mjs +1 -0
  14. package/dist/{chunk-BCX5NDQC.js → chunk-GQ6Q3P7C.js} +1 -1
  15. package/dist/{chunk-67G3236R.js → chunk-K5OCGZWA.js} +2 -2
  16. package/dist/{chunk-3LLXDHIU.js → chunk-LFWPB2JR.js} +1 -0
  17. package/dist/{chunk-GO3K752H.js → chunk-SC2DBY2R.js} +2 -0
  18. package/dist/{chunk-3Z4PGEEJ.js → chunk-TUZVOPKY.js} +1 -1
  19. package/dist/{doctor-PZT7EGLQ.js → doctor-E6LOBJYK.js} +2 -2
  20. package/dist/{guard-ZZRQW3DJ.js → guard-X6FNFZ27.js} +24 -2
  21. package/dist/index.js +19 -11
  22. package/dist/{init-MGRZ7U7A.js → init-KKVT2RW4.js} +3 -3
  23. package/dist/{install-432KJISB.js → install-BPZTP5KT.js} +3 -3
  24. package/dist/{mission-control-MHQU73XC.js → mission-control-C2QV5D25.js} +1 -1
  25. package/dist/outcome-ledger-XLWHWPVQ.js +297 -0
  26. package/dist/{run-VOVR5O7S.js → run-326EEQYY.js} +2 -2
  27. package/dist/{run-plan-KWGS2SOZ.js → run-plan-2IFO4G4Y.js} +2 -2
  28. package/dist/{scan-UX4HARMJ.js → scan-BWA64R7I.js} +1 -1
  29. package/dist/{status-UDM55MHU.js → status-LNXVLDMP.js} +1 -1
  30. package/package.json +1 -1
@@ -2,7 +2,7 @@ import {
2
2
  assessHooksHealth,
3
3
  executeSafeReadinessFixes,
4
4
  refreshRepositoryProfile
5
- } from "./chunk-BCX5NDQC.js";
5
+ } from "./chunk-GQ6Q3P7C.js";
6
6
  import {
7
7
  writeReadinessSnapshot
8
8
  } from "./chunk-HAFRAXGV.js";
@@ -22,7 +22,7 @@ import {
22
22
  } from "./chunk-PNFF6OU3.js";
23
23
  import {
24
24
  runScanner
25
- } from "./chunk-GO3K752H.js";
25
+ } from "./chunk-SC2DBY2R.js";
26
26
  import "./chunk-F6C3GFKV.js";
27
27
  import {
28
28
  logger
@@ -315,6 +315,21 @@ function parsePrMergeHead(head) {
315
315
  }
316
316
  return { forge, selector, repo };
317
317
  }
318
+ var FORGE_API_CALL_RE = /(?:^|[\s'"(;|&`$])(?:[\w./-]+\/)?(?:gh|glab)\s+api(?:\s|$)/;
319
+ var FORGE_API_MERGE_RE = /\bpulls\/[^/\s'"]+\/merge\b|\/merges\b|\bmerge_requests\/[^/\s'"]+\/merge\b|\b(?:mergePullRequest|enablePullRequestAutoMerge|enqueuePullRequest|mergeBranch|mergeRequestAccept|mergeRequestSetAutoMerge)\b/;
320
+ function forgeApiMergeCall(command) {
321
+ if (!FORGE_API_MERGE_RE.test(command)) return false;
322
+ return shellSegments(command).some(
323
+ (segment) => FORGE_API_CALL_RE.test(segment) && !segmentHasAllowMainPushEnv(segment)
324
+ );
325
+ }
326
+ var PR_MERGE_CALL_RE = /(?:^|[\s'"(;|&`$!{])(?:[\w./-]+\/)?(?:gh\s+pr|glab\s+mr)\s+merge(?![\w-])/;
327
+ function unresolvedPrMergeCall(command) {
328
+ if (!PR_MERGE_CALL_RE.test(command)) return false;
329
+ return shellSegments(command).some(
330
+ (segment) => PR_MERGE_CALL_RE.test(segment) && !segmentHasAllowMainPushEnv(segment) && parsePrMergeHead(canonicalGitHead(segment)) === null
331
+ );
332
+ }
318
333
  function prMergeKey(target) {
319
334
  return `${target.forge}\0${target.repo ?? ""}\0${target.selector ?? ""}`;
320
335
  }
@@ -430,9 +445,16 @@ var SHELL_DENY_RULES = [
430
445
  {
431
446
  // Claude settings allow `gh pr merge` / `glab mr merge` so the /git-staging merge
432
447
  // skips the auto-mode classifier; this rule keeps that allowance to non-protected bases.
448
+ // A forge API merge (`gh api … pulls/<n>/merge`, a GraphQL merge mutation) has no base
449
+ // to resolve and no /git-staging use: it is denied outright, so neither the API nor
450
+ // Colony's host path (typed yes for main) can be bypassed that way. A merge behind a head
451
+ // the parser does not read (loop body, `then`, `!`, `xargs`, `bash -c`) has no target
452
+ // either: denied outright too, so an unrecognized head cannot skip the base check.
433
453
  id: "pr-merge-protected-base",
434
- description: "merging a PR/MR into main/master/prod bypasses /git-prod; an unresolved base (gh/glab could not read the PR/MR: not logged in, wrong selector, or no such PR) is denied too",
454
+ description: "merging a PR/MR into main/master/prod bypasses /git-prod; an unresolved base (gh/glab could not read the PR/MR: not logged in, wrong selector, or no such PR) is denied too, and so is any gh api / glab api merge call (REST merge endpoint or GraphQL merge mutation) and any gh pr merge / glab mr merge the guard cannot resolve to a literal target (inside a loop, if, xargs, bash -c or sh -c, or after !: run a literal `gh pr merge <n>` at the head of its own segment; text that only mentions the command is denied too)",
435
455
  test: (cmd, opts) => {
456
+ if (forgeApiMergeCall(cmd)) return true;
457
+ if (unresolvedPrMergeCall(cmd)) return true;
436
458
  const bases = opts?.prMergeBases;
437
459
  if (!bases) return false;
438
460
  return shellSegments(cmd).some((segment) => {
@@ -567,7 +589,7 @@ var guardCommand = defineCommand({
567
589
  shell: defineCommand({
568
590
  meta: {
569
591
  name: "shell",
570
- description: "Evaluate a shell command against the git-workflow / protected-branch deny-list (git checkout|restore|reset --hard|clean -fd + pushes to main/master/prod + gh pr merge / glab mr merge into main/master/prod or an unresolved base + direct git push/gh pr create|merge against the public repo). Not a general destructive-command guard: rm -rf, chmod, dd are allowed."
592
+ description: "Evaluate a shell command against the git-workflow / protected-branch deny-list (git checkout|restore|reset --hard|clean -fd + pushes to main/master/prod + gh pr merge / glab mr merge into main/master/prod or an unresolved base + any gh pr merge / glab mr merge not at the head of its own segment (loop body, if, !, xargs, bash -c / sh -c) + any gh api / glab api merge call + direct git push/gh pr create|merge against the public repo). A script file that runs a merge is out of reach. Not a general destructive-command guard: rm -rf, chmod, dd are allowed."
571
593
  },
572
594
  args: {
573
595
  json: {
package/dist/index.js CHANGED
@@ -132,7 +132,14 @@ var CLI_HELP_GROUPS = [
132
132
  {
133
133
  id: "dashboard",
134
134
  title: "DASHBOARD",
135
- commands: ["dashboard", "dashboard-broadcast", "mission-control", "monitors", "sessions"]
135
+ commands: [
136
+ "dashboard",
137
+ "dashboard-broadcast",
138
+ "mission-control",
139
+ "monitors",
140
+ "sessions",
141
+ "outcome-ledger"
142
+ ]
136
143
  },
137
144
  {
138
145
  id: "integrity",
@@ -224,13 +231,13 @@ var main = defineCommand({
224
231
  version: KIT_VERSION
225
232
  },
226
233
  subCommands: {
227
- init: () => import("./init-MGRZ7U7A.js").then((m) => m.initCommand),
228
- install: () => import("./install-432KJISB.js").then((m) => m.installCommand),
229
- scan: () => import("./scan-UX4HARMJ.js").then((m) => m.scanCommand),
234
+ init: () => import("./init-KKVT2RW4.js").then((m) => m.initCommand),
235
+ install: () => import("./install-BPZTP5KT.js").then((m) => m.installCommand),
236
+ scan: () => import("./scan-BWA64R7I.js").then((m) => m.scanCommand),
230
237
  add: () => import("./add-7GH3K44T.js").then((m) => m.addCommand),
231
- doctor: () => import("./doctor-PZT7EGLQ.js").then((m) => m.doctorCommand),
238
+ doctor: () => import("./doctor-E6LOBJYK.js").then((m) => m.doctorCommand),
232
239
  "setup-global": () => import("./setup-global-BFBSR2RZ.js").then((m) => m.setupGlobalCommand),
233
- status: () => import("./status-UDM55MHU.js").then((m) => m.statusCommand),
240
+ status: () => import("./status-LNXVLDMP.js").then((m) => m.statusCommand),
234
241
  update: () => import("./update-PX5XFCSG.js").then((m) => m.updateCommand),
235
242
  "cursor-awareness": () => import("./cursor-awareness-TN5JXD2C.js").then((m) => m.cursorAwarenessCommand),
236
243
  "public-inbound-radar": () => import("./public-inbound-radar-5U4JMBRU.js").then((m) => m.publicInboundRadarCommand),
@@ -240,18 +247,19 @@ var main = defineCommand({
240
247
  contribute: () => import("./contribute-VSVPRHQ7.js").then((m) => m.contributeCommand),
241
248
  handoff: () => import("./handoff-5AGE2D3T.js").then((m) => m.handoffCommand),
242
249
  "plan-index": () => import("./plan-index-BNLUU6T5.js").then((m) => m.planIndexCommand),
243
- run: () => import("./run-VOVR5O7S.js").then((m) => m.runCommand),
244
- "run-plan": () => import("./run-plan-KWGS2SOZ.js").then((m) => m.runPlanCommand),
245
- "run-plan-all": () => import("./run-VOVR5O7S.js").then((m) => m.runPlanAllCommand),
250
+ run: () => import("./run-326EEQYY.js").then((m) => m.runCommand),
251
+ "run-plan": () => import("./run-plan-2IFO4G4Y.js").then((m) => m.runPlanCommand),
252
+ "run-plan-all": () => import("./run-326EEQYY.js").then((m) => m.runPlanAllCommand),
246
253
  countdown: () => import("./countdown-XYRE4GZU.js").then((m) => m.countdownCommand),
247
254
  "ground-control": () => import("./ground-control-726LRB6Q.js").then((m) => m.groundControlCommand),
248
255
  dashboard: () => import("./dashboard-YNCFISNO.js").then((m) => m.dashboardCommand),
249
256
  "dashboard-broadcast": () => import("./dashboard-broadcast-NK7PU72L.js").then((m) => m.dashboardBroadcastCommand),
250
- "mission-control": () => import("./mission-control-MHQU73XC.js").then((m) => m.missionControlCommand),
257
+ "mission-control": () => import("./mission-control-C2QV5D25.js").then((m) => m.missionControlCommand),
251
258
  hook: () => import("./hook-HJW5SXQG.js").then((m) => m.hookCommand),
252
- guard: () => import("./guard-ZZRQW3DJ.js").then((m) => m.guardCommand),
259
+ guard: () => import("./guard-X6FNFZ27.js").then((m) => m.guardCommand),
253
260
  monitors: () => import("./monitors-PDXBLB3U.js").then((m) => m.monitorsCommand),
254
261
  sessions: () => import("./sessions-O7MYEMCT.js").then((m) => m.sessionsCommand),
262
+ "outcome-ledger": () => import("./outcome-ledger-XLWHWPVQ.js").then((m) => m.outcomeLedgerCommand),
255
263
  validate: () => import("./validate-V2CW7J4B.js").then((m) => m.validateCommand),
256
264
  "engine-info": () => import("./engine-info-3MQML5I2.js").then((m) => m.engineInfoCommand),
257
265
  commands: () => import("./commands-EQHK3ZEP.js").then((m) => m.commandsCommand)
@@ -2,7 +2,7 @@ import {
2
2
  nextStepAfterInstall,
3
3
  performInstall,
4
4
  printInstallEpilogue
5
- } from "./chunk-67G3236R.js";
5
+ } from "./chunk-K5OCGZWA.js";
6
6
  import {
7
7
  NON_INTERACTIVE_ROOT_ARGS
8
8
  } from "./chunk-HIJTNHJE.js";
@@ -11,7 +11,7 @@ import {
11
11
  logApplyStats
12
12
  } from "./chunk-HS7LVVLO.js";
13
13
  import "./chunk-75ELVLBY.js";
14
- import "./chunk-BCX5NDQC.js";
14
+ import "./chunk-GQ6Q3P7C.js";
15
15
  import "./chunk-HAFRAXGV.js";
16
16
  import "./chunk-ZF4YBL7F.js";
17
17
  import "./chunk-LGSNC4OI.js";
@@ -21,7 +21,7 @@ import {
21
21
  withCliProgress
22
22
  } from "./chunk-QTON2GQX.js";
23
23
  import "./chunk-PNFF6OU3.js";
24
- import "./chunk-GO3K752H.js";
24
+ import "./chunk-SC2DBY2R.js";
25
25
  import "./chunk-F6C3GFKV.js";
26
26
  import {
27
27
  logger
@@ -3,11 +3,11 @@ import {
3
3
  nextStepAfterInstall,
4
4
  performInstall,
5
5
  printInstallEpilogue
6
- } from "./chunk-67G3236R.js";
6
+ } from "./chunk-K5OCGZWA.js";
7
7
  import "./chunk-HIJTNHJE.js";
8
8
  import "./chunk-HS7LVVLO.js";
9
9
  import "./chunk-75ELVLBY.js";
10
- import "./chunk-BCX5NDQC.js";
10
+ import "./chunk-GQ6Q3P7C.js";
11
11
  import "./chunk-HAFRAXGV.js";
12
12
  import "./chunk-ZF4YBL7F.js";
13
13
  import "./chunk-LGSNC4OI.js";
@@ -15,7 +15,7 @@ import "./chunk-WGLPZXNU.js";
15
15
  import "./chunk-6RRG3WOE.js";
16
16
  import "./chunk-QTON2GQX.js";
17
17
  import "./chunk-PNFF6OU3.js";
18
- import "./chunk-GO3K752H.js";
18
+ import "./chunk-SC2DBY2R.js";
19
19
  import "./chunk-F6C3GFKV.js";
20
20
  import "./chunk-ZB43YMHW.js";
21
21
  import "./chunk-TZA7MT4I.js";
@@ -3,7 +3,7 @@ import {
3
3
  findDashboardDataScript,
4
4
  loadDashboardSnapshot,
5
5
  runMcTuiLoop
6
- } from "./chunk-3LLXDHIU.js";
6
+ } from "./chunk-LFWPB2JR.js";
7
7
  import {
8
8
  resolveDashboardSnapshotRoot
9
9
  } from "./chunk-XDCCYBCJ.js";
@@ -0,0 +1,297 @@
1
+ // src/commands/outcome-ledger.ts
2
+ import path from "path";
3
+ import { defineCommand } from "citty";
4
+
5
+ // ../../dashboard/lib/outcome-ledger.mjs
6
+ import { spawnSync } from "child_process";
7
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
8
+ import { dirname, join } from "path";
9
+ var OUTCOME_LEDGER_REL = ".cursor/context/outcome-ledger.json";
10
+ var TEST_RESULTS_REL = ".cursor/context/test-results.json";
11
+ var REPOSITORY_PROFILE_REL = ".cursor/agent-kit.config.json";
12
+ var OUTCOME_LEDGER_VERSION = 1;
13
+ var MAX_TEST_RESULTS = 200;
14
+ var MAX_RECENT_ENTRIES = 20;
15
+ var MAX_LABEL = 120;
16
+ var MAX_COMMAND_CHARS = 200;
17
+ var MAX_COMMANDS = 5;
18
+ var OUTCOME_KINDS = Object.freeze({
19
+ todo: "logic",
20
+ test: "logic",
21
+ ci: "compute",
22
+ releaseCut: "compute",
23
+ plan: "rare",
24
+ review: "rare",
25
+ releasePublished: "rare"
26
+ });
27
+ var SAFE_PART_RE = /^[A-Za-z0-9][A-Za-z0-9._+-]{0,159}$/;
28
+ var SHA_RE = /^[0-9a-f]{7,40}$/;
29
+ var ISO_RE = /^\d{4}-\d{2}-\d{2}(?:[T ][0-9:.]+(?:Z|[+-]\d{2}:?\d{2})?)?$/;
30
+ var isRecord = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
31
+ var safePart = (v) => typeof v === "string" && SAFE_PART_RE.test(v) ? v : null;
32
+ var isoOrNull = (v) => typeof v === "string" && ISO_RE.test(v.trim()) ? v.trim() : null;
33
+ function cap(text, max = MAX_LABEL) {
34
+ const s = String(text ?? "").trim();
35
+ return s.length > max ? `${s.slice(0, max - 1)}\u2026` : s;
36
+ }
37
+ function emptyOutcomeLedger() {
38
+ return { version: OUTCOME_LEDGER_VERSION, entries: {}, sources: {} };
39
+ }
40
+ function parseOutcomeLedger(raw) {
41
+ const out = emptyOutcomeLedger();
42
+ if (!isRecord(raw) || raw.version !== OUTCOME_LEDGER_VERSION || !isRecord(raw.entries)) {
43
+ return out;
44
+ }
45
+ if (isRecord(raw.sources)) {
46
+ for (const [name, stamp] of Object.entries(raw.sources)) {
47
+ if (safePart(name) && typeof stamp === "string" && stamp.length <= 64) {
48
+ out.sources[name] = stamp;
49
+ }
50
+ }
51
+ }
52
+ for (const [key, entry] of Object.entries(raw.entries)) {
53
+ if (typeof key !== "string" || key.length > 400 || !isRecord(entry)) continue;
54
+ if (typeof entry.kind !== "string" || !SAFE_PART_RE.test(entry.kind)) continue;
55
+ out.entries[key] = {
56
+ kind: entry.kind,
57
+ resource: OUTCOME_KINDS[entry.kind] ?? null,
58
+ at: isoOrNull(entry.at),
59
+ label: cap(entry.label)
60
+ };
61
+ }
62
+ return out;
63
+ }
64
+ function isFoldableOutcomeLedger(raw) {
65
+ return raw === void 0 || isRecord(raw) && raw.version === OUTCOME_LEDGER_VERSION && isRecord(raw.entries);
66
+ }
67
+ function summarizeOutcomeLedger(ledger, extras = {}) {
68
+ const parsed = parseOutcomeLedger(ledger);
69
+ const totals = { logic: 0, compute: 0, rare: 0 };
70
+ const byKind = Object.fromEntries(Object.keys(OUTCOME_KINDS).map((k) => [k, 0]));
71
+ const rows = [];
72
+ for (const [key, e] of Object.entries(parsed.entries)) {
73
+ if (!e.resource) continue;
74
+ totals[e.resource] += 1;
75
+ byKind[e.kind] += 1;
76
+ rows.push({ key, ...e });
77
+ }
78
+ rows.sort((a, b) => {
79
+ const at = a.at ?? "";
80
+ const bt = b.at ?? "";
81
+ if (at !== bt) return at < bt ? 1 : -1;
82
+ return a.key < b.key ? -1 : a.key > b.key ? 1 : 0;
83
+ });
84
+ return {
85
+ available: extras.available !== false,
86
+ reason: extras.available === false ? extras.reason ?? "unreadable" : null,
87
+ version: OUTCOME_LEDGER_VERSION,
88
+ path: OUTCOME_LEDGER_REL,
89
+ entries: rows.length,
90
+ totals,
91
+ byKind,
92
+ recent: rows.slice(0, MAX_RECENT_ENTRIES),
93
+ flow: extras.flow ?? null,
94
+ tests: extras.tests ?? { configured: false, lastRun: null }
95
+ };
96
+ }
97
+ function readJson(path2) {
98
+ try {
99
+ return JSON.parse(readFileSync(path2, "utf-8"));
100
+ } catch {
101
+ return null;
102
+ }
103
+ }
104
+ function writeIfChanged(path2, text) {
105
+ let prev = null;
106
+ if (existsSync(path2)) {
107
+ try {
108
+ prev = readFileSync(path2, "utf-8");
109
+ } catch {
110
+ prev = null;
111
+ }
112
+ }
113
+ if (prev === text) return false;
114
+ mkdirSync(dirname(path2), { recursive: true });
115
+ const tmp = `${path2}.${process.pid}.tmp`;
116
+ try {
117
+ writeFileSync(tmp, text, "utf-8");
118
+ renameSync(tmp, path2);
119
+ } finally {
120
+ rmSync(tmp, { force: true });
121
+ }
122
+ return true;
123
+ }
124
+ function readOutcomeLedger(root) {
125
+ return readOutcomeLedgerFile(root).ledger;
126
+ }
127
+ function readOutcomeLedgerFile(root) {
128
+ const path2 = join(root, OUTCOME_LEDGER_REL);
129
+ if (!existsSync(path2)) return { ledger: emptyOutcomeLedger(), foldable: true };
130
+ const raw = readJson(path2);
131
+ const foldable = raw !== null && isFoldableOutcomeLedger(raw);
132
+ return { ledger: foldable ? parseOutcomeLedger(raw) : emptyOutcomeLedger(), foldable };
133
+ }
134
+ function parseTestResults(raw) {
135
+ const runs = [];
136
+ if (isRecord(raw) && raw.version === 1 && Array.isArray(raw.runs)) {
137
+ for (const r of raw.runs) {
138
+ if (!isRecord(r) || typeof r.ok !== "boolean" || !isoOrNull(r.at)) continue;
139
+ runs.push({
140
+ at: isoOrNull(r.at),
141
+ ok: r.ok,
142
+ exitCode: Number.isInteger(r.exitCode) ? r.exitCode : null,
143
+ head: typeof r.head === "string" && SHA_RE.test(r.head) ? r.head : null,
144
+ commands: Array.isArray(r.commands) ? r.commands.filter((c) => typeof c === "string").slice(0, MAX_COMMANDS).map((c) => cap(c, MAX_COMMAND_CHARS)) : []
145
+ });
146
+ }
147
+ }
148
+ return { version: 1, runs: runs.slice(-MAX_TEST_RESULTS) };
149
+ }
150
+ function readTestResults(root) {
151
+ return parseTestResults(readJson(join(root, TEST_RESULTS_REL)));
152
+ }
153
+ function appendTestResult(root, run) {
154
+ const current = readTestResults(root);
155
+ const next = parseTestResults({ version: 1, runs: [...current.runs, run] });
156
+ writeIfChanged(join(root, TEST_RESULTS_REL), `${JSON.stringify(next, null, 2)}
157
+ `);
158
+ return next;
159
+ }
160
+ function readProfileTestCommands(root) {
161
+ const profile = readJson(join(root, REPOSITORY_PROFILE_REL));
162
+ const list = isRecord(profile) && isRecord(profile.stack) ? profile.stack.testCommands : null;
163
+ return Array.isArray(list) ? list.filter((c) => typeof c === "string" && c.trim()).slice(0, MAX_COMMANDS) : [];
164
+ }
165
+ function testCollectorStatus(root, testResults) {
166
+ const runs = testResults?.runs ?? [];
167
+ const last = runs.length > 0 ? runs[runs.length - 1] : null;
168
+ return {
169
+ configured: readProfileTestCommands(root).length > 0,
170
+ lastRun: last ? { at: last.at, ok: last.ok, head: last.head } : null
171
+ };
172
+ }
173
+ function runAndRecordTests(root, opts = {}) {
174
+ const commands = opts.commands ?? readProfileTestCommands(root);
175
+ if (commands.length === 0) return { status: "no-commands" };
176
+ const spawn = opts.spawn ?? spawnSync;
177
+ let exitCode = 0;
178
+ for (const command of commands) {
179
+ if (typeof opts.onCommand === "function") opts.onCommand(command);
180
+ const res = spawn(command, { cwd: root, shell: true, stdio: opts.stdio ?? "inherit" });
181
+ exitCode = typeof res.status === "number" ? res.status : 1;
182
+ if (exitCode !== 0) break;
183
+ }
184
+ const headRes = spawn("git", ["rev-parse", "HEAD"], { cwd: root, encoding: "utf-8" });
185
+ const head = String(headRes?.stdout ?? "").trim();
186
+ const run = {
187
+ at: (opts.now ?? /* @__PURE__ */ new Date()).toISOString(),
188
+ ok: exitCode === 0,
189
+ exitCode,
190
+ head: SHA_RE.test(head) ? head : null,
191
+ commands
192
+ };
193
+ appendTestResult(root, run);
194
+ return { status: "recorded", run };
195
+ }
196
+
197
+ // src/commands/outcome-ledger.ts
198
+ function renderOutcomeLedger(summary) {
199
+ const lines = [
200
+ `Outcome ledger (${OUTCOME_LEDGER_REL}): ${summary.entries} earned`,
201
+ ` Logic ${summary.totals.logic} \xB7 Compute ${summary.totals.compute} \xB7 Rare ${summary.totals.rare}`
202
+ ];
203
+ const kinds = Object.entries(summary.byKind).filter(([, n]) => n > 0).map(([kind, n]) => `${kind} ${n}`);
204
+ if (kinds.length > 0) lines.push(` ${kinds.join(" \xB7 ")}`);
205
+ if (!summary.tests.configured) {
206
+ lines.push(
207
+ " Tests: no stack.testCommands in .cursor/agent-kit.config.json (run `agent-kit doctor --refresh-profile` or set them)"
208
+ );
209
+ } else if (summary.tests.lastRun) {
210
+ const r = summary.tests.lastRun;
211
+ lines.push(` Tests: last run ${r.ok ? "passed" : "failed"} at ${r.at}`);
212
+ } else {
213
+ lines.push(" Tests: none recorded yet (`agent-kit outcome-ledger test`)");
214
+ }
215
+ if (summary.entries === 0) {
216
+ lines.push("Nothing earned yet. Mission Control folds the ledger on every refresh.");
217
+ }
218
+ return lines.join("\n");
219
+ }
220
+ var cwdArg = {
221
+ type: "string",
222
+ description: "Workspace folder (default: current directory)"
223
+ };
224
+ var outcomeLedgerCommand = defineCommand({
225
+ meta: {
226
+ name: "outcome-ledger",
227
+ description: "Show the verified-outcome ledger, or run the repo's test commands and record pass/fail (`test`)"
228
+ },
229
+ subCommands: {
230
+ show: defineCommand({
231
+ meta: { name: "show", description: "Print the persisted ledger totals (default)" },
232
+ args: {
233
+ json: { type: "boolean", description: "Print the summary as JSON", default: false },
234
+ cwd: cwdArg
235
+ },
236
+ run({ args }) {
237
+ const root = path.resolve(typeof args.cwd === "string" && args.cwd ? args.cwd : ".");
238
+ const summary = summarizeOutcomeLedger(readOutcomeLedger(root), {
239
+ tests: testCollectorStatus(root, readTestResults(root))
240
+ });
241
+ process.stdout.write(
242
+ args.json ? `${JSON.stringify(summary, null, 2)}
243
+ ` : `${renderOutcomeLedger(summary)}
244
+ `
245
+ );
246
+ }
247
+ }),
248
+ test: defineCommand({
249
+ meta: {
250
+ name: "test",
251
+ description: `Run stack.testCommands from the repository profile and append the outcome to ${TEST_RESULTS_REL}`
252
+ },
253
+ args: { cwd: cwdArg },
254
+ run({ args }) {
255
+ const root = path.resolve(typeof args.cwd === "string" && args.cwd ? args.cwd : ".");
256
+ if (readProfileTestCommands(root).length === 0) {
257
+ process.stderr.write(
258
+ "No stack.testCommands in .cursor/agent-kit.config.json: nothing to run, nothing recorded. Run `agent-kit doctor --refresh-profile` or set them.\n"
259
+ );
260
+ process.exitCode = 2;
261
+ return;
262
+ }
263
+ const result = runAndRecordTests(root, {
264
+ onCommand: (command) => process.stderr.write(`$ ${command}
265
+ `)
266
+ });
267
+ if (result.status !== "recorded") return;
268
+ const { run } = result;
269
+ process.stderr.write(
270
+ `Recorded: tests ${run.ok ? "passed" : `failed (exit ${run.exitCode})`}${run.head ? ` at ${run.head.slice(0, 8)}` : " (no git HEAD: earns nothing)"}
271
+ `
272
+ );
273
+ if (!run.ok) process.exitCode = run.exitCode ?? 1;
274
+ }
275
+ })
276
+ },
277
+ args: {
278
+ json: { type: "boolean", description: "Print the summary as JSON", default: false },
279
+ cwd: cwdArg
280
+ },
281
+ run({ rawArgs, args }) {
282
+ if (rawArgs.some((a) => a === "show" || a === "test")) return;
283
+ const root = path.resolve(typeof args.cwd === "string" && args.cwd ? args.cwd : ".");
284
+ const summary = summarizeOutcomeLedger(readOutcomeLedger(root), {
285
+ tests: testCollectorStatus(root, readTestResults(root))
286
+ });
287
+ process.stdout.write(
288
+ args.json ? `${JSON.stringify(summary, null, 2)}
289
+ ` : `${renderOutcomeLedger(summary)}
290
+ `
291
+ );
292
+ }
293
+ });
294
+ export {
295
+ outcomeLedgerCommand,
296
+ renderOutcomeLedger
297
+ };
@@ -3,7 +3,7 @@ import {
3
3
  runPlanLoop,
4
4
  shouldUseLiveTui,
5
5
  withLiveTui
6
- } from "./chunk-3Z4PGEEJ.js";
6
+ } from "./chunk-TUZVOPKY.js";
7
7
  import {
8
8
  DRIVER_EVENTS_FORMATS,
9
9
  DRIVER_PROTOCOL_VERSION,
@@ -27,7 +27,7 @@ import {
27
27
  classifyGateExit,
28
28
  landGateExit
29
29
  } from "./chunk-26KXYR5T.js";
30
- import "./chunk-3LLXDHIU.js";
30
+ import "./chunk-LFWPB2JR.js";
31
31
  import {
32
32
  negatedFlag
33
33
  } from "./chunk-XDCCYBCJ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runPlanLoop
3
- } from "./chunk-3Z4PGEEJ.js";
3
+ } from "./chunk-TUZVOPKY.js";
4
4
  import {
5
5
  DRIVER_EVENTS_FORMATS
6
6
  } from "./chunk-CXDAT76O.js";
@@ -11,7 +11,7 @@ import {
11
11
  import {
12
12
  LAND_ON_GATE_DESCRIPTION
13
13
  } from "./chunk-26KXYR5T.js";
14
- import "./chunk-3LLXDHIU.js";
14
+ import "./chunk-LFWPB2JR.js";
15
15
  import {
16
16
  negatedFlag
17
17
  } from "./chunk-XDCCYBCJ.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  runScanner
3
- } from "./chunk-GO3K752H.js";
3
+ } from "./chunk-SC2DBY2R.js";
4
4
  import "./chunk-F6C3GFKV.js";
5
5
  import {
6
6
  logger
@@ -7,7 +7,7 @@ import {
7
7
  } from "./chunk-PNFF6OU3.js";
8
8
  import {
9
9
  runScanner
10
- } from "./chunk-GO3K752H.js";
10
+ } from "./chunk-SC2DBY2R.js";
11
11
  import "./chunk-F6C3GFKV.js";
12
12
  import {
13
13
  logger
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dadado/agent-kit-cli",
3
- "version": "6.9.0",
3
+ "version": "6.10.1",
4
4
  "description": "Agent Kit CLI: HITL framework install and tooling for AI-assisted IDEs (rules, skills, plan/handoff, context).",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",