overlord-cli 0.2610241050.0 → 0.2610261104.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/README.md +2 -2
  2. package/dist/connectors/AGENTS.md +22 -5
  3. package/dist/connectors/VERSION +1 -1
  4. package/dist/connectors/adapters/antigravity/conformance-manifest.yaml +1 -1
  5. package/dist/connectors/adapters/antigravity/plugin.json +1 -1
  6. package/dist/connectors/adapters/antigravity/skills/record-work.md +2 -3
  7. package/dist/connectors/adapters/claude/.claude-plugin/plugin.json +1 -1
  8. package/dist/connectors/adapters/claude/codec/claude.codec.yaml +5 -0
  9. package/dist/connectors/adapters/claude/commands/record-work.md +2 -3
  10. package/dist/connectors/adapters/claude/conformance-manifest.yaml +1 -1
  11. package/dist/connectors/adapters/claude/fixtures/normalize-post-tool-use-notebook.json +1 -0
  12. package/dist/connectors/adapters/claude/fixtures/normalize-post-tool-use-shell.json +1 -0
  13. package/dist/connectors/adapters/claude/fixtures/normalize-post-tool-use-write.json +1 -0
  14. package/dist/connectors/adapters/codex/.codex-plugin/plugin.json +2 -2
  15. package/dist/connectors/adapters/codex/CAPABILITIES.md +2 -2
  16. package/dist/connectors/adapters/codex/codec/codex.codec.yaml +10 -1
  17. package/dist/connectors/adapters/codex/conformance-manifest.yaml +2 -2
  18. package/dist/connectors/adapters/codex/fixtures/normalize-post-tool-use-failed.json +42 -0
  19. package/dist/connectors/adapters/codex/fixtures/normalize-post-tool-use-rename.json +42 -0
  20. package/dist/connectors/adapters/codex/fixtures/normalize-post-tool-use.json +6 -3
  21. package/dist/connectors/adapters/codex/harness-capabilities.yaml +2 -0
  22. package/dist/connectors/adapters/cursor/.cursor-plugin/plugin.json +1 -1
  23. package/dist/connectors/adapters/cursor/codec/cursor.codec.yaml +5 -0
  24. package/dist/connectors/adapters/cursor/commands/record-work.md +2 -3
  25. package/dist/connectors/adapters/cursor/conformance-manifest.yaml +1 -1
  26. package/dist/connectors/adapters/cursor/fixtures/normalize-post-tool-use-write.json +1 -0
  27. package/dist/connectors/adapters/cursor/rules/overlord-local.mdc +1 -1
  28. package/dist/connectors/adapters/opencode/conformance-manifest.yaml +1 -1
  29. package/dist/connectors/adapters/pi/conformance-manifest.yaml +1 -1
  30. package/dist/connectors/core/README.md +1 -1
  31. package/dist/connectors/core/overlord-mission/SKILL.md +113 -70
  32. package/dist/connectors/core/overlord-mission/reference/cli.md +53 -63
  33. package/dist/connectors/core/overlord-mission/reference/context.md +1 -1
  34. package/dist/connectors/core/overlord-mission/reference/mcp.md +3 -2
  35. package/dist/connectors/core/overlord-mission/reference/record-work.md +23 -43
  36. package/dist/connectors/core/overlord-mission/reference/shell-escaping.md +7 -5
  37. package/dist/connectors/core/scripts/capture-change-hook.sh +6 -4
  38. package/dist/connectors/core/scripts/overlord-mcp.mjs +81 -164
  39. package/dist/connectors/docs/05-connectors-and-agent-plugins.md +3 -3
  40. package/dist/connectors/docs/testing.md +5 -0
  41. package/dist/index.js +665 -236
  42. package/dist/index.js.map +4 -4
  43. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -196,12 +196,11 @@ var init_args = __esm({
196
196
  init_errors();
197
197
  MAX_INLINE_JSON_CHARS = 8192;
198
198
  INLINE_JSON_FLAG_PAIRS = [
199
- { jsonFlag: "--change-rationales-json", fileFlag: "--change-rationales-file" },
200
199
  { jsonFlag: "--payload-json", fileFlag: "--payload-file" },
201
200
  { jsonFlag: "--artifacts-json", fileFlag: "--artifacts-file" },
202
201
  { jsonFlag: "--objectives-json", fileFlag: "--objectives-file" },
203
202
  { jsonFlag: "--changes-json", fileFlag: "--changes-file" },
204
- { jsonFlag: "--changed-files-json", fileFlag: "--changed-files-file" },
203
+ { jsonFlag: "--declared-paths-json", fileFlag: "--declared-paths-file" },
205
204
  { jsonFlag: "--value-json", fileFlag: "--value-file" }
206
205
  ];
207
206
  }
@@ -906,6 +905,7 @@ var init_search = __esm({
906
905
  });
907
906
 
908
907
  // ../packages/contract/dist/index.js
908
+ var DEFERRED_WORK_LIMITS, CAPTURE_GAP_CODES, OBJECTIVE_FILE_CHANGES_LIMIT;
909
909
  var init_dist = __esm({
910
910
  "../packages/contract/dist/index.js"() {
911
911
  "use strict";
@@ -919,6 +919,20 @@ var init_dist = __esm({
919
919
  init_objective_ref();
920
920
  init_resource_paths();
921
921
  init_search();
922
+ DEFERRED_WORK_LIMITS = {
923
+ maxTitleLength: 80,
924
+ maxChangeLength: 400,
925
+ maxLocationLength: 200,
926
+ maxDoneWhenLength: 200
927
+ };
928
+ CAPTURE_GAP_CODES = [
929
+ "direct_path_unavailable",
930
+ "native_payload_unavailable",
931
+ "outcome_unavailable",
932
+ "outcome_partial",
933
+ "shell_activity_unverified"
934
+ ];
935
+ OBJECTIVE_FILE_CHANGES_LIMIT = 200;
922
936
  }
923
937
  });
924
938
 
@@ -5373,6 +5387,18 @@ var init_local_file_storage = __esm({
5373
5387
  import { createHash as createHash3, randomUUID as randomUUID2 } from "node:crypto";
5374
5388
  import { existsSync as existsSync10, realpathSync as realpathSync3, unlinkSync as unlinkSync4 } from "node:fs";
5375
5389
  import path11 from "node:path";
5390
+ function boundHealth(health) {
5391
+ let excess = health.length - MAX_HEALTH_ENTRIES;
5392
+ if (excess <= 0) return health;
5393
+ const kept = health.filter((entry) => {
5394
+ if (excess > 0 && !STICKY_HEALTH_CODES.has(entry.code)) {
5395
+ excess -= 1;
5396
+ return false;
5397
+ }
5398
+ return true;
5399
+ });
5400
+ return kept.slice(-MAX_HEALTH_ENTRIES);
5401
+ }
5376
5402
  function canonicalObjectiveId(objectiveId) {
5377
5403
  return typeof objectiveId === "string" ? objectiveId.trim() : "";
5378
5404
  }
@@ -5386,12 +5412,13 @@ function sessionKeyHash(sessionKey) {
5386
5412
  }
5387
5413
  function emptyLedger(input2) {
5388
5414
  return {
5389
- schemaVersion: 2,
5415
+ schemaVersion: LEDGER_SCHEMA_VERSION,
5390
5416
  workingDirectory: canonicalDirectory(input2.workingDirectory),
5391
5417
  objectiveId: canonicalObjectiveId(input2.objectiveId),
5392
5418
  sessionKeyHash: sessionKeyHash(input2.sessionKey),
5393
5419
  evidence: [],
5394
- health: []
5420
+ health: [],
5421
+ capture: { bindingState: "unknown" }
5395
5422
  };
5396
5423
  }
5397
5424
  function readLedger(input2) {
@@ -5402,24 +5429,95 @@ function readLedger(input2) {
5402
5429
  const raw = readBoundedUtf8File(target, MAX_LEDGER_FILE_BYTES);
5403
5430
  if (raw === null) return null;
5404
5431
  const value2 = JSON.parse(raw);
5405
- if (value2.schemaVersion !== 2 || value2.workingDirectory !== expected.workingDirectory || value2.objectiveId !== expected.objectiveId || value2.sessionKeyHash !== expected.sessionKeyHash || !Array.isArray(value2.evidence) || !Array.isArray(value2.health)) {
5432
+ if (value2.workingDirectory !== expected.workingDirectory || value2.objectiveId !== expected.objectiveId || value2.sessionKeyHash !== expected.sessionKeyHash || !Array.isArray(value2.evidence) || !Array.isArray(value2.health)) {
5406
5433
  return null;
5407
5434
  }
5435
+ const health = value2.health.filter(isStoredHealth);
5436
+ if (value2.schemaVersion === 2) {
5437
+ return upgradeSchemaV2Ledger({ expected, evidence: value2.evidence, health });
5438
+ }
5439
+ if (value2.schemaVersion !== LEDGER_SCHEMA_VERSION) return null;
5440
+ const capture = readStoredCapture(value2.capture);
5441
+ if (!capture) return null;
5408
5442
  return {
5409
5443
  ...expected,
5410
5444
  evidence: value2.evidence.filter(isStoredEvidence).slice(0, MAX_LEDGER_EVIDENCE),
5411
- health: value2.health.filter(isStoredHealth).slice(-MAX_HEALTH_ENTRIES)
5445
+ health: boundHealth(health),
5446
+ capture
5412
5447
  };
5413
5448
  } catch {
5414
5449
  return null;
5415
5450
  }
5416
5451
  }
5452
+ function upgradeSchemaV2Ledger({
5453
+ expected,
5454
+ evidence,
5455
+ health
5456
+ }) {
5457
+ const upgraded = [];
5458
+ let discardedWindowRows = 0;
5459
+ for (const value2 of evidence.slice(0, MAX_LEDGER_EVIDENCE)) {
5460
+ if (!isStoredV2Evidence(value2)) continue;
5461
+ if (value2.source !== "declared_edit") {
5462
+ discardedWindowRows += 1;
5463
+ continue;
5464
+ }
5465
+ const declared = value2.hookHealth === LEGACY_GENERATOR_DECLARATION_HEALTH;
5466
+ const hookHealth = declared ? AGENT_DECLARED_HEALTH : value2.hookHealth;
5467
+ upgraded.push({
5468
+ idempotencyKey: value2.idempotencyKey,
5469
+ filePath: value2.filePath,
5470
+ source: declared ? "agent_declared" : "declared_edit",
5471
+ observedAt: value2.observedAt,
5472
+ ...hookHealth ? { hookHealth } : {},
5473
+ ...value2.syncedAt ? { syncedAt: value2.syncedAt } : {}
5474
+ });
5475
+ }
5476
+ const ledger = { ...expected, evidence: upgraded, health: [...health] };
5477
+ if (discardedWindowRows > 0) {
5478
+ appendHealth(ledger, `${LEGACY_WINDOW_DISCARDED_HEALTH}:${discardedWindowRows}`);
5479
+ }
5480
+ ledger.health = boundHealth(ledger.health);
5481
+ return ledger;
5482
+ }
5483
+ function isStoredV2Evidence(value2) {
5484
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2) || Object.keys(value2).some((key) => !LEGACY_V2_EVIDENCE_KEYS.has(key))) {
5485
+ return false;
5486
+ }
5487
+ const entry = value2;
5488
+ return (entry.source === "declared_edit" || entry.source === "window_observed") && isStoredEvidence({
5489
+ idempotencyKey: entry.idempotencyKey,
5490
+ filePath: entry.filePath,
5491
+ source: "declared_edit",
5492
+ observedAt: entry.observedAt,
5493
+ ...entry.hookHealth !== void 0 ? { hookHealth: entry.hookHealth } : {},
5494
+ ...entry.syncedAt !== void 0 ? { syncedAt: entry.syncedAt } : {}
5495
+ });
5496
+ }
5497
+ function readStoredCapture(value2) {
5498
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2) || Object.keys(value2).some((key) => !LEDGER_CAPTURE_KEYS.has(key))) {
5499
+ return null;
5500
+ }
5501
+ const capture = value2;
5502
+ if (!CAPTURE_BINDING_STATES.includes(capture.bindingState)) return null;
5503
+ if (capture.callbackObservedAt !== void 0 && !isCanonicalUtcTimestamp(capture.callbackObservedAt)) {
5504
+ return null;
5505
+ }
5506
+ if (capture.syncedFingerprint !== void 0 && (typeof capture.syncedFingerprint !== "string" || capture.syncedFingerprint.length > 128)) {
5507
+ return null;
5508
+ }
5509
+ return {
5510
+ bindingState: capture.bindingState,
5511
+ ...capture.callbackObservedAt ? { callbackObservedAt: capture.callbackObservedAt } : {},
5512
+ ...capture.syncedFingerprint ? { syncedFingerprint: capture.syncedFingerprint } : {}
5513
+ };
5514
+ }
5417
5515
  function isStoredEvidence(value2) {
5418
5516
  if (!value2 || typeof value2 !== "object" || Array.isArray(value2) || Object.keys(value2).some((key) => !LEDGER_EVIDENCE_KEYS.has(key))) {
5419
5517
  return false;
5420
5518
  }
5421
5519
  const entry = value2;
5422
- return typeof entry.idempotencyKey === "string" && boundedOpaqueIdentifier(entry.idempotencyKey) === entry.idempotencyKey && isExactEvidencePath(entry.filePath) && ["declared_edit", "window_observed"].includes(String(entry.source)) && ["direct", "window"].includes(String(entry.quality)) && (entry.source === "declared_edit" && entry.quality === "direct" || entry.source === "window_observed" && entry.quality === "window") && typeof entry.overlap === "boolean" && isCanonicalUtcTimestamp(entry.observedAt) && (entry.toolWindowId === void 0 || typeof entry.toolWindowId === "string" && boundedOpaqueIdentifier(entry.toolWindowId) === entry.toolWindowId) && (entry.hookHealth === void 0 || typeof entry.hookHealth === "string" && boundedHealthCode(entry.hookHealth) === entry.hookHealth) && (entry.syncedAt === void 0 || isCanonicalUtcTimestamp(entry.syncedAt));
5520
+ return typeof entry.idempotencyKey === "string" && boundedOpaqueIdentifier(entry.idempotencyKey) === entry.idempotencyKey && isExactEvidencePath(entry.filePath) && (entry.source === "declared_edit" || entry.source === "agent_declared") && isCanonicalUtcTimestamp(entry.observedAt) && (entry.hookHealth === void 0 || typeof entry.hookHealth === "string" && boundedHealthCode(entry.hookHealth) === entry.hookHealth) && (entry.syncedAt === void 0 || isCanonicalUtcTimestamp(entry.syncedAt));
5423
5521
  }
5424
5522
  function isStoredHealth(value2) {
5425
5523
  if (!value2 || typeof value2 !== "object" || Array.isArray(value2) || Object.keys(value2).some((key) => !LEDGER_HEALTH_KEYS.has(key))) {
@@ -5443,7 +5541,7 @@ function mutateLedger(input2, mutation, fallback, options = {}) {
5443
5541
  const ledger = readLedger(normalized);
5444
5542
  if (!ledger) return fallback;
5445
5543
  const result = mutation(ledger);
5446
- ledger.health = ledger.health.slice(-MAX_HEALTH_ENTRIES);
5544
+ ledger.health = boundHealth(ledger.health);
5447
5545
  writeLedger(normalized, ledger);
5448
5546
  return result;
5449
5547
  });
@@ -5451,10 +5549,6 @@ function mutateLedger(input2, mutation, fallback, options = {}) {
5451
5549
  return fallback;
5452
5550
  }
5453
5551
  }
5454
- function qualityForSource(source) {
5455
- if (source === "declared_edit") return "direct";
5456
- return "window";
5457
- }
5458
5552
  function boundedHealthCode(code) {
5459
5553
  const trimmed7 = code.trim();
5460
5554
  if (!/^[a-z0-9][a-z0-9_.:-]*$/i.test(trimmed7)) return "invalid_health_code";
@@ -5611,80 +5705,148 @@ function resetChangeLedger(input2) {
5611
5705
  } catch {
5612
5706
  }
5613
5707
  }
5708
+ function appendEvidenceToLedger(ledger, input2) {
5709
+ const result = { appended: 0, accepted: [], rejected: [] };
5710
+ const now = (/* @__PURE__ */ new Date()).toISOString();
5711
+ if (input2.source !== "declared_edit" && input2.source !== "agent_declared") {
5712
+ appendHealth(ledger, "invalid_evidence_source");
5713
+ return result;
5714
+ }
5715
+ const source = input2.source;
5716
+ const hookHealth = typeof input2.hookHealth === "string" ? boundedHealthCode(input2.hookHealth) : "";
5717
+ const root = ledger.workingDirectory;
5718
+ const ignore = loadIgnoreRules(root);
5719
+ if (ignore.unavailable) {
5720
+ appendHealth(ledger, "ignore_policy_unavailable");
5721
+ for (const rawPath of input2.filePaths.slice(0, MAX_PATHS_PER_APPEND)) {
5722
+ result.rejected.push({ path: String(rawPath), reason: "ignore_policy_unavailable" });
5723
+ }
5724
+ return result;
5725
+ }
5726
+ if (input2.filePaths.length > MAX_PATHS_PER_APPEND) {
5727
+ appendHealth(ledger, "path_input_truncated");
5728
+ }
5729
+ const rejectedCounts = /* @__PURE__ */ new Map();
5730
+ const reject = (rawPath, reason) => {
5731
+ rejectedCounts.set(reason, (rejectedCounts.get(reason) ?? 0) + 1);
5732
+ result.rejected.push({ path: typeof rawPath === "string" ? rawPath : String(rawPath), reason });
5733
+ };
5734
+ let capacityReached = false;
5735
+ const seen = new Set(ledger.evidence.map((entry) => `${entry.filePath}\0${entry.source}`));
5736
+ for (const rawPath of input2.filePaths.slice(0, MAX_PATHS_PER_APPEND)) {
5737
+ if (typeof rawPath !== "string") {
5738
+ reject(rawPath, "invalid_path");
5739
+ continue;
5740
+ }
5741
+ const normalized = normalizeWorkspacePath({ root, rawPath, ignoreRules: ignore.rules });
5742
+ if ("reason" in normalized) {
5743
+ reject(rawPath, normalized.reason);
5744
+ continue;
5745
+ }
5746
+ const key = `${normalized.filePath}\0${source}`;
5747
+ if (seen.has(key)) {
5748
+ if (!result.accepted.includes(normalized.filePath)) {
5749
+ result.accepted.push(normalized.filePath);
5750
+ }
5751
+ continue;
5752
+ }
5753
+ if (ledger.evidence.length >= MAX_LEDGER_EVIDENCE) {
5754
+ capacityReached = true;
5755
+ reject(rawPath, "ledger_capacity_reached");
5756
+ continue;
5757
+ }
5758
+ ledger.evidence.push({
5759
+ idempotencyKey: randomUUID2(),
5760
+ filePath: normalized.filePath,
5761
+ source,
5762
+ observedAt: now,
5763
+ ...hookHealth ? { hookHealth } : {}
5764
+ });
5765
+ seen.add(key);
5766
+ result.accepted.push(normalized.filePath);
5767
+ result.appended += 1;
5768
+ }
5769
+ if (hookHealth) appendHealth(ledger, hookHealth);
5770
+ if (capacityReached) appendHealth(ledger, "ledger_capacity_reached");
5771
+ for (const [reason, count] of rejectedCounts) {
5772
+ if (reason !== "ledger_capacity_reached") appendHealth(ledger, `${reason}:${count}`);
5773
+ }
5774
+ return result;
5775
+ }
5614
5776
  function appendChangeEvidence(input2) {
5615
5777
  if (!Array.isArray(input2.filePaths)) return 0;
5778
+ return mutateLedger(input2, (ledger) => appendEvidenceToLedger(ledger, input2).appended, 0);
5779
+ }
5780
+ function declareChangePaths(input2) {
5781
+ const unrecorded = { accepted: [], rejected: [], recorded: false };
5782
+ if (!Array.isArray(input2.filePaths)) return unrecorded;
5616
5783
  return mutateLedger(
5617
5784
  input2,
5618
5785
  (ledger) => {
5619
- const now = (/* @__PURE__ */ new Date()).toISOString();
5620
- if (input2.source !== "declared_edit" && input2.source !== "window_observed") {
5621
- appendHealth(ledger, "invalid_evidence_source");
5622
- return 0;
5623
- }
5624
- const source = input2.source;
5625
- const expectedQuality = qualityForSource(source);
5626
- if (input2.quality !== void 0 && input2.quality !== expectedQuality) {
5627
- appendHealth(ledger, "source_quality_mismatch");
5628
- return 0;
5629
- }
5630
- const quality = input2.quality ?? expectedQuality;
5631
- const toolWindowId = boundedOpaqueIdentifier(input2.toolWindowId);
5632
- const hookHealth = typeof input2.hookHealth === "string" ? boundedHealthCode(input2.hookHealth) : "";
5633
- const root = ledger.workingDirectory;
5634
- const ignore = loadIgnoreRules(root);
5635
- if (ignore.unavailable) {
5636
- appendHealth(ledger, "ignore_policy_unavailable");
5637
- return 0;
5638
- }
5639
- if (input2.filePaths.length > MAX_PATHS_PER_APPEND) {
5640
- appendHealth(ledger, "path_input_truncated");
5641
- }
5642
- const rejected = /* @__PURE__ */ new Map();
5643
- let capacityReached = false;
5644
- const seen = new Set(ledger.evidence.map((entry) => `${entry.filePath}\0${entry.source}`));
5645
- let appended = 0;
5646
- for (const rawPath of input2.filePaths.slice(0, MAX_PATHS_PER_APPEND)) {
5647
- if (typeof rawPath !== "string") {
5648
- rejected.set("invalid_path", (rejected.get("invalid_path") ?? 0) + 1);
5649
- continue;
5650
- }
5651
- const normalized = normalizeWorkspacePath({ root, rawPath, ignoreRules: ignore.rules });
5652
- if ("reason" in normalized) {
5653
- rejected.set(normalized.reason, (rejected.get(normalized.reason) ?? 0) + 1);
5654
- continue;
5655
- }
5656
- if (seen.has(`${normalized.filePath}\0${source}`)) continue;
5657
- if (ledger.evidence.length >= MAX_LEDGER_EVIDENCE) {
5658
- capacityReached = true;
5659
- continue;
5660
- }
5661
- ledger.evidence.push({
5662
- idempotencyKey: randomUUID2(),
5663
- filePath: normalized.filePath,
5664
- source,
5665
- quality,
5666
- overlap: input2.overlap === true,
5667
- ...toolWindowId ? { toolWindowId } : {},
5668
- observedAt: now,
5669
- ...hookHealth ? { hookHealth } : {}
5670
- });
5671
- seen.add(`${normalized.filePath}\0${source}`);
5672
- appended += 1;
5786
+ const result = appendEvidenceToLedger(ledger, {
5787
+ filePaths: input2.filePaths,
5788
+ source: "agent_declared",
5789
+ hookHealth: AGENT_DECLARED_HEALTH
5790
+ });
5791
+ return { accepted: result.accepted, rejected: result.rejected, recorded: true };
5792
+ },
5793
+ unrecorded
5794
+ );
5795
+ }
5796
+ function recordChangeLedgerBinding(input2) {
5797
+ if (!CAPTURE_BINDING_STATES.includes(input2.bindingState)) return;
5798
+ mutateLedger(
5799
+ input2,
5800
+ (ledger) => {
5801
+ ledger.capture = { ...ledger.capture, bindingState: input2.bindingState };
5802
+ },
5803
+ void 0
5804
+ );
5805
+ }
5806
+ function recordChangeLedgerCallback(input2) {
5807
+ if (readLedger(input2)?.capture.callbackObservedAt) return;
5808
+ mutateLedger(
5809
+ input2,
5810
+ (ledger) => {
5811
+ if (ledger.capture.callbackObservedAt) return;
5812
+ ledger.capture = { ...ledger.capture, callbackObservedAt: (/* @__PURE__ */ new Date()).toISOString() };
5813
+ },
5814
+ void 0
5815
+ );
5816
+ }
5817
+ function changeLedgerCapturePayload(snapshot) {
5818
+ return {
5819
+ bindingState: snapshot.capture.bindingState,
5820
+ ...snapshot.capture.callbackObservedAt ? { callbackObservedAt: snapshot.capture.callbackObservedAt } : {},
5821
+ health: snapshot.health.map((entry) => ({ code: entry.code, at: entry.at }))
5822
+ };
5823
+ }
5824
+ function changeLedgerCaptureFingerprint(snapshot) {
5825
+ return createHash3("sha256").update(JSON.stringify(changeLedgerCapturePayload(snapshot))).digest("hex");
5826
+ }
5827
+ function markChangeLedgerCaptureSynced(input2) {
5828
+ mutateLedger(
5829
+ input2,
5830
+ (ledger) => {
5831
+ const current = changeLedgerCaptureFingerprint(ledger);
5832
+ if (current === input2.fingerprint) {
5833
+ ledger.capture = { ...ledger.capture, syncedFingerprint: input2.fingerprint };
5673
5834
  }
5674
- if (hookHealth) appendHealth(ledger, hookHealth);
5675
- if (capacityReached) appendHealth(ledger, "ledger_capacity_reached");
5676
- for (const [reason, count] of rejected) appendHealth(ledger, `${reason}:${count}`);
5677
- return appended;
5678
5835
  },
5679
- 0
5836
+ void 0,
5837
+ { requireExisting: true }
5680
5838
  );
5681
5839
  }
5840
+ function readChangeLedgerSnapshot(input2) {
5841
+ const objectiveId = canonicalObjectiveId(input2.objectiveId);
5842
+ const sessionKey = typeof input2.sessionKey === "string" ? input2.sessionKey.trim() : "";
5843
+ if (!objectiveId || !sessionKey) return null;
5844
+ const ledger = readLedger({ ...input2, objectiveId, sessionKey });
5845
+ return ledger ? { evidence: ledger.evidence, health: ledger.health, capture: ledger.capture } : null;
5846
+ }
5682
5847
  function recordChangeLedgerHealth(input2) {
5683
5848
  mutateLedger(input2, (ledger) => appendHealth(ledger, input2.code), void 0);
5684
5849
  }
5685
- function readChangeLedgerHealth(input2) {
5686
- return readLedger(input2)?.health ?? [];
5687
- }
5688
5850
  function readChangeLedgerEvidence(input2) {
5689
5851
  return readLedger(input2)?.evidence ?? [];
5690
5852
  }
@@ -5726,16 +5888,19 @@ function removeChangeLedger(input2) {
5726
5888
  return false;
5727
5889
  }
5728
5890
  }
5729
- var MAX_PATHS_PER_APPEND, MAX_LEDGER_EVIDENCE, MAX_HEALTH_ENTRIES, MAX_HEALTH_CODE_LENGTH, MAX_IGNORE_FILE_BYTES, MAX_IGNORE_LINES, MAX_IGNORE_RULES, MAX_IGNORE_LINE_LENGTH, MAX_LEDGER_FILE_BYTES, LEDGER_EVIDENCE_KEYS, LEDGER_HEALTH_KEYS;
5891
+ var LEDGER_SCHEMA_VERSION, MAX_PATHS_PER_APPEND, MAX_LEDGER_EVIDENCE, MAX_HEALTH_ENTRIES, STICKY_HEALTH_CODES, MAX_HEALTH_CODE_LENGTH, MAX_IGNORE_FILE_BYTES, MAX_IGNORE_LINES, MAX_IGNORE_RULES, MAX_IGNORE_LINE_LENGTH, MAX_LEDGER_FILE_BYTES, LEDGER_EVIDENCE_KEYS, LEDGER_HEALTH_KEYS, LEDGER_CAPTURE_KEYS, CAPTURE_BINDING_STATES, AGENT_DECLARED_HEALTH, LEGACY_GENERATOR_DECLARATION_HEALTH, LEGACY_WINDOW_DISCARDED_HEALTH, LEGACY_V2_EVIDENCE_KEYS;
5730
5892
  var init_change_ledger = __esm({
5731
5893
  "src/change-ledger.ts"() {
5732
5894
  "use strict";
5895
+ init_dist();
5733
5896
  init_evidence_path();
5734
5897
  init_config();
5735
5898
  init_local_file_storage();
5899
+ LEDGER_SCHEMA_VERSION = 3;
5736
5900
  MAX_PATHS_PER_APPEND = 512;
5737
5901
  MAX_LEDGER_EVIDENCE = 1e4;
5738
5902
  MAX_HEALTH_ENTRIES = 32;
5903
+ STICKY_HEALTH_CODES = new Set(CAPTURE_GAP_CODES);
5739
5904
  MAX_HEALTH_CODE_LENGTH = 160;
5740
5905
  MAX_IGNORE_FILE_BYTES = 64 * 1024;
5741
5906
  MAX_IGNORE_LINES = 512;
@@ -5746,14 +5911,22 @@ var init_change_ledger = __esm({
5746
5911
  "idempotencyKey",
5747
5912
  "filePath",
5748
5913
  "source",
5749
- "quality",
5750
- "overlap",
5751
- "toolWindowId",
5752
5914
  "observedAt",
5753
5915
  "hookHealth",
5754
5916
  "syncedAt"
5755
5917
  ]);
5756
5918
  LEDGER_HEALTH_KEYS = /* @__PURE__ */ new Set(["at", "code"]);
5919
+ LEDGER_CAPTURE_KEYS = /* @__PURE__ */ new Set(["bindingState", "callbackObservedAt", "syncedFingerprint"]);
5920
+ CAPTURE_BINDING_STATES = ["bound", "unbound", "unknown"];
5921
+ AGENT_DECLARED_HEALTH = "agent_declared";
5922
+ LEGACY_GENERATOR_DECLARATION_HEALTH = "agent_declared_generator_output";
5923
+ LEGACY_WINDOW_DISCARDED_HEALTH = "legacy_window_evidence_discarded";
5924
+ LEGACY_V2_EVIDENCE_KEYS = /* @__PURE__ */ new Set([
5925
+ ...LEDGER_EVIDENCE_KEYS,
5926
+ "quality",
5927
+ "overlap",
5928
+ "toolWindowId"
5929
+ ]);
5757
5930
  }
5758
5931
  });
5759
5932
 
@@ -6484,7 +6657,7 @@ var init_catalog_generated = __esm({
6484
6657
  "codec": "codex",
6485
6658
  "integrationShape": "callback",
6486
6659
  "capabilityTier": 1,
6487
- "descriptorDigest": "4d4908a81023cf7943ebbcb35d8477751f97d916597adc3bf3cec63bdb58dc4b",
6660
+ "descriptorDigest": "b3120edbb3f8a017801de0b9b085c42f05f1d7c335246e224cd283e874ddc542",
6488
6661
  "descriptorSchemaVersion": 1,
6489
6662
  "harness": {
6490
6663
  "name": "Codex CLI",
@@ -7262,7 +7435,7 @@ var init_catalog_generated = __esm({
7262
7435
  }
7263
7436
  }
7264
7437
  ];
7265
- HARNESS_CATALOG_DIGEST = "9b5e5074ad777fa04280b57040141eab441d4d386da054cc415f8f2166460672";
7438
+ HARNESS_CATALOG_DIGEST = "4a4d783280e116b9f7ca59bf2bbd1e19f5cd60725d08ae6eb4e064087ba3d84d";
7266
7439
  }
7267
7440
  });
7268
7441
 
@@ -9081,13 +9254,27 @@ function boundedId(value2) {
9081
9254
  const text = safeText(value2, 200).text;
9082
9255
  return text === "" ? null : text;
9083
9256
  }
9084
- function readOutcome(value2) {
9257
+ function exitCodeOutcome(code) {
9258
+ if (!Number.isSafeInteger(code))
9259
+ return void 0;
9260
+ return code === 0 ? "ok" : "error";
9261
+ }
9262
+ function readOutcome(value2, exitCodePrefix) {
9085
9263
  if (value2 === void 0 || value2 === null)
9086
9264
  return void 0;
9087
9265
  if (value2 === true)
9088
9266
  return "ok";
9089
9267
  if (value2 === false)
9090
9268
  return "error";
9269
+ if (typeof value2 === "number")
9270
+ return exitCodeOutcome(value2);
9271
+ if (typeof value2 === "string" && exitCodePrefix) {
9272
+ const firstLine = (value2.slice(0, 200).split("\n", 1)[0] ?? "").trim();
9273
+ if (!firstLine.startsWith(exitCodePrefix))
9274
+ return void 0;
9275
+ const digits = firstLine.slice(exitCodePrefix.length).trim();
9276
+ return /^-?\d{1,6}$/.test(digits) ? exitCodeOutcome(Number(digits)) : void 0;
9277
+ }
9091
9278
  if (typeof value2 === "string") {
9092
9279
  const lowered = value2.toLowerCase();
9093
9280
  if (lowered === "ok" || lowered === "success" || lowered === "completed")
@@ -9200,10 +9387,12 @@ function normalizeNativeEvent({ codec: codec2, payload, nativeEventName, nativeS
9200
9387
  }
9201
9388
  }
9202
9389
  if (rule.outcomePath) {
9203
- const outcome = readOutcome(readPath2(payload, rule.outcomePath));
9390
+ const outcome = readOutcome(readPath2(payload, rule.outcomePath), rule.outcomeExitCodePrefix);
9204
9391
  if (outcome)
9205
9392
  sealedInput.outcome = outcome;
9206
9393
  }
9394
+ if (rule.successOnly && !sealedInput.outcome)
9395
+ sealedInput.outcome = "ok";
9207
9396
  const payloadOut = sealPayload(sealedInput);
9208
9397
  const summary = summarizeEvent(kind, payloadOut);
9209
9398
  return {
@@ -9256,7 +9445,7 @@ var init_codec = __esm({
9256
9445
  init_redact();
9257
9446
  init_text();
9258
9447
  init_tool_normalize();
9259
- PATCH_HEADER = /^\*\*\* (?:Add|Update|Delete) File: (.+)$/gm;
9448
+ PATCH_HEADER = /^\*\*\* (?:(?:Add|Update|Delete) File|Move to): (.+)$/gm;
9260
9449
  MAX_PATCH_PATHS = 32;
9261
9450
  }
9262
9451
  });
@@ -9287,6 +9476,7 @@ var init_codec_registry_generated = __esm({
9287
9476
  "origin": "agent",
9288
9477
  "toolPath": "tool_name",
9289
9478
  "inputPath": "tool_input",
9479
+ "successOnly": true,
9290
9480
  "fileEditKind": "file.edited",
9291
9481
  "filePathPaths": [
9292
9482
  "file_path",
@@ -9337,6 +9527,8 @@ var init_codec_registry_generated = __esm({
9337
9527
  "inputPath": "tool_input",
9338
9528
  "callIdPath": "tool_use_id",
9339
9529
  "turnIdPath": "turn_id",
9530
+ "outcomePath": "tool_response",
9531
+ "outcomeExitCodePrefix": "Exit code: ",
9340
9532
  "fileEditKind": "file.edited",
9341
9533
  "filePathPaths": [
9342
9534
  "file_path",
@@ -9399,6 +9591,7 @@ var init_codec_registry_generated = __esm({
9399
9591
  "toolPath": "tool_name",
9400
9592
  "inputPath": "tool_input",
9401
9593
  "callIdPath": "call_id",
9594
+ "successOnly": true,
9402
9595
  "fileEditKind": "file.edited",
9403
9596
  "filePathPaths": [
9404
9597
  "file_path",
@@ -21574,6 +21767,7 @@ var init_errors2 = __esm({
21574
21767
  var init_worker_jobs = __esm({
21575
21768
  "../packages/core/dist/service/worker-jobs.js"() {
21576
21769
  "use strict";
21770
+ init_change_feed();
21577
21771
  init_util2();
21578
21772
  }
21579
21773
  });
@@ -41996,10 +42190,11 @@ var init_zod = __esm({
41996
42190
  });
41997
42191
 
41998
42192
  // ../packages/core/dist/service/delivery-report.js
41999
- var MAX_ITEMS, MAX_ALTERNATIVES, MAX_ACTION_LENGTH, MAX_DETAIL_LENGTH, humanActionCategorySchema, MAX_COMMAND_LENGTH2, MAX_LINK_LENGTH, conciseTextSchema, commandTextSchema, LINK_PATTERN, linkSchema, humanActionSchema, tradeoffSchema, MAX_WARNINGS, normalizedHumanActionSchema, normalizedTradeoffSchema, normalizedAgentReportSchema, deliveryPresentationSchema, persistedDeliveryReportSchema;
42193
+ var MAX_ITEMS, MAX_ALTERNATIVES, MAX_ACTION_LENGTH, MAX_DETAIL_LENGTH, humanActionCategorySchema, MAX_COMMAND_LENGTH2, MAX_LINK_LENGTH, conciseTextSchema, commandTextSchema, LINK_PATTERN, linkSchema, humanActionSchema, tradeoffSchema, deferredWorkFields, deferredWorkInputSchema, normalizedDeferredWorkSchema, MAX_WARNINGS, normalizedHumanActionSchema, normalizedTradeoffSchema, normalizedAgentReportSchema, deliveryPresentationSchema, persistedDeliveryReportSchema;
42000
42194
  var init_delivery_report = __esm({
42001
42195
  "../packages/core/dist/service/delivery-report.js"() {
42002
42196
  "use strict";
42197
+ init_dist();
42003
42198
  init_zod();
42004
42199
  MAX_ITEMS = 12;
42005
42200
  MAX_ALTERNATIVES = 6;
@@ -42035,6 +42230,17 @@ var init_delivery_report = __esm({
42035
42230
  rationale: conciseTextSchema,
42036
42231
  impact: conciseTextSchema.optional()
42037
42232
  });
42233
+ deferredWorkFields = {
42234
+ title: external_exports.string().trim().min(1).max(DEFERRED_WORK_LIMITS.maxTitleLength),
42235
+ change: external_exports.string().trim().min(1).max(DEFERRED_WORK_LIMITS.maxChangeLength),
42236
+ location: external_exports.string().trim().min(1).max(DEFERRED_WORK_LIMITS.maxLocationLength),
42237
+ doneWhen: external_exports.string().trim().min(1).max(DEFERRED_WORK_LIMITS.maxDoneWhenLength)
42238
+ };
42239
+ deferredWorkInputSchema = external_exports.strictObject(deferredWorkFields);
42240
+ normalizedDeferredWorkSchema = external_exports.strictObject({
42241
+ id: external_exports.string().trim().min(1).max(200),
42242
+ ...deferredWorkFields
42243
+ });
42038
42244
  MAX_WARNINGS = 12;
42039
42245
  normalizedHumanActionSchema = external_exports.strictObject({
42040
42246
  id: external_exports.string().trim().min(1).max(200),
@@ -42045,7 +42251,7 @@ var init_delivery_report = __esm({
42045
42251
  command: commandTextSchema.optional(),
42046
42252
  verify: conciseTextSchema.optional(),
42047
42253
  link: linkSchema.optional(),
42048
- source: external_exports.enum(["agent", "change_rationale", "deterministic_rule"]),
42254
+ source: external_exports.enum(["agent", "deterministic_rule"]),
42049
42255
  sourceRef: external_exports.string().trim().min(1).max(200).optional()
42050
42256
  });
42051
42257
  normalizedTradeoffSchema = external_exports.strictObject({
@@ -42054,14 +42260,14 @@ var init_delivery_report = __esm({
42054
42260
  alternativesConsidered: external_exports.array(conciseTextSchema).max(MAX_ALTERNATIVES),
42055
42261
  rationale: conciseTextSchema,
42056
42262
  impact: conciseTextSchema.optional(),
42057
- source: external_exports.enum(["agent", "change_rationale"]),
42263
+ source: external_exports.literal("agent"),
42058
42264
  sourceRef: external_exports.string().trim().min(1).max(200).optional()
42059
42265
  });
42060
42266
  normalizedAgentReportSchema = external_exports.strictObject({
42061
42267
  humanActions: external_exports.array(normalizedHumanActionSchema).max(MAX_ITEMS),
42062
42268
  tradeoffsMade: external_exports.array(normalizedTradeoffSchema).max(MAX_ITEMS),
42063
42269
  knownRisks: external_exports.array(conciseTextSchema).max(MAX_ITEMS),
42064
- deferredWork: external_exports.array(conciseTextSchema).max(MAX_ITEMS),
42270
+ deferredWork: external_exports.array(normalizedDeferredWorkSchema).max(MAX_ITEMS),
42065
42271
  assumptions: external_exports.array(conciseTextSchema).max(MAX_ITEMS)
42066
42272
  });
42067
42273
  deliveryPresentationSchema = external_exports.strictObject({
@@ -42070,7 +42276,7 @@ var init_delivery_report = __esm({
42070
42276
  humanActions: external_exports.array(normalizedHumanActionSchema).max(MAX_ITEMS),
42071
42277
  tradeoffsMade: external_exports.array(normalizedTradeoffSchema).max(MAX_ITEMS),
42072
42278
  knownRisks: external_exports.array(conciseTextSchema).max(MAX_ITEMS),
42073
- deferredWork: external_exports.array(conciseTextSchema).max(MAX_ITEMS),
42279
+ deferredWork: external_exports.array(normalizedDeferredWorkSchema).max(MAX_ITEMS),
42074
42280
  assumptions: external_exports.array(conciseTextSchema).max(MAX_ITEMS),
42075
42281
  generatedBy: external_exports.enum(["deterministic", "gemini"]),
42076
42282
  generatedAt: external_exports.string().max(64).optional(),
@@ -42123,6 +42329,7 @@ var init_requests = __esm({
42123
42329
  init_live_activity_jobs();
42124
42330
  init_util2();
42125
42331
  init_webhook_events();
42332
+ init_worker_jobs();
42126
42333
  init_window();
42127
42334
  init_credential();
42128
42335
  REMOTE_WINDOW_AWAY_SECONDS = 30 * 60;
@@ -42945,12 +43152,18 @@ function captureChangeFromPayload({
42945
43152
  });
42946
43153
  const normalized = payloadFailure ? null : normalizeForAdapter({ codec: codec2, payload: payloadForNormalize });
42947
43154
  const directPaths = normalized?.kind === "file.edited" && Array.isArray(normalized.payload.paths) ? normalized.payload.paths.filter((value2) => typeof value2 === "string") : [];
43155
+ const outcome = normalized?.payload.outcome;
42948
43156
  const confidentlyNonMutating = normalized?.kind === "tool.completed" && (normalized.payload.tool === "read" || normalized.payload.tool === "search" || normalized.payload.tool === "fetch");
42949
43157
  return withActiveObjectiveSession({
42950
43158
  workingDirectory,
42951
43159
  objectiveId,
42952
43160
  fallback: { recorded: false, reason: "no matching objective session binding" },
42953
43161
  action: (session) => {
43162
+ recordChangeLedgerCallback({
43163
+ workingDirectory,
43164
+ objectiveId: session.objectiveId,
43165
+ sessionKey: session.sessionKey
43166
+ });
42954
43167
  if (payloadFailure) {
42955
43168
  recordChangeLedgerHealth({
42956
43169
  workingDirectory,
@@ -42963,26 +43176,54 @@ function captureChangeFromPayload({
42963
43176
  if (confidentlyNonMutating) {
42964
43177
  return { recorded: false, reason: "native event is confidently non-mutating" };
42965
43178
  }
42966
- if (directPaths.length === 0) {
43179
+ if (normalized?.kind !== "file.edited") {
42967
43180
  recordChangeLedgerHealth({
42968
43181
  workingDirectory,
42969
43182
  objectiveId: session.objectiveId,
42970
43183
  sessionKey: session.sessionKey,
42971
- code: "direct_path_unavailable"
43184
+ code: normalized?.payload.tool === "shell" ? "shell_activity_unverified" : "direct_path_unavailable"
43185
+ });
43186
+ return { recorded: false, reason: "native event is not a declared file edit" };
43187
+ }
43188
+ if (outcome === "blocked") {
43189
+ return { recorded: false, reason: "native edit was blocked" };
43190
+ }
43191
+ if (outcome === "error" || outcome === "cancelled") {
43192
+ recordChangeLedgerHealth({
43193
+ workingDirectory,
43194
+ objectiveId: session.objectiveId,
43195
+ sessionKey: session.sessionKey,
43196
+ code: "outcome_partial"
42972
43197
  });
42973
43198
  return {
42974
43199
  recorded: false,
42975
- reason: normalized?.kind === "file.edited" ? "native edit contains no exact path evidence" : "native event is not a declared file edit"
43200
+ reason: `native edit ${outcome === "error" ? "failed" : "was cancelled"}`
42976
43201
  };
42977
43202
  }
43203
+ if (outcome !== "ok") {
43204
+ recordChangeLedgerHealth({
43205
+ workingDirectory,
43206
+ objectiveId: session.objectiveId,
43207
+ sessionKey: session.sessionKey,
43208
+ code: "outcome_unavailable"
43209
+ });
43210
+ return { recorded: false, reason: "native edit outcome is unavailable" };
43211
+ }
43212
+ if (directPaths.length === 0) {
43213
+ recordChangeLedgerHealth({
43214
+ workingDirectory,
43215
+ objectiveId: session.objectiveId,
43216
+ sessionKey: session.sessionKey,
43217
+ code: "direct_path_unavailable"
43218
+ });
43219
+ return { recorded: false, reason: "native edit contains no exact path evidence" };
43220
+ }
42978
43221
  const files = appendChangeEvidence({
42979
43222
  workingDirectory,
42980
43223
  objectiveId: session.objectiveId,
42981
43224
  sessionKey: session.sessionKey,
42982
43225
  filePaths: directPaths,
42983
43226
  source: "declared_edit",
42984
- quality: "direct",
42985
- overlap: false,
42986
43227
  hookHealth: "direct_path_observed"
42987
43228
  });
42988
43229
  if (files === 0) {
@@ -44370,6 +44611,107 @@ var init_launch_bootstrap = __esm({
44370
44611
  }
44371
44612
  });
44372
44613
 
44614
+ // src/local-objective-changes.ts
44615
+ function bareHealthCode(code) {
44616
+ const separator = code.indexOf(":");
44617
+ return separator === -1 ? code : code.slice(0, separator);
44618
+ }
44619
+ function buildLocalObjectiveChanges({
44620
+ objectiveId,
44621
+ snapshots,
44622
+ syncFailed
44623
+ }) {
44624
+ if (snapshots.length === 0) {
44625
+ return {
44626
+ scope: "local_objective_sessions",
44627
+ objectiveId,
44628
+ coverage: "unavailable",
44629
+ items: [],
44630
+ total: 0,
44631
+ limit: OBJECTIVE_FILE_CHANGES_LIMIT,
44632
+ truncated: false,
44633
+ sync: { synced: 0, pending: 0, failed: syncFailed },
44634
+ capture: { bindingState: "unknown", callbackObserved: false, healthCodes: [] },
44635
+ warnings: []
44636
+ };
44637
+ }
44638
+ const byPath = /* @__PURE__ */ new Map();
44639
+ for (const snapshot of snapshots) {
44640
+ for (const entry of snapshot.evidence) {
44641
+ const syncState = entry.syncedAt ? "synced" : "pending";
44642
+ const current = byPath.get(entry.filePath);
44643
+ if (!current) {
44644
+ byPath.set(entry.filePath, {
44645
+ filePath: entry.filePath,
44646
+ source: entry.source,
44647
+ observedAt: entry.observedAt,
44648
+ hookHealth: entry.hookHealth ?? null,
44649
+ syncState
44650
+ });
44651
+ continue;
44652
+ }
44653
+ const newer = entry.observedAt > current.observedAt;
44654
+ byPath.set(entry.filePath, {
44655
+ filePath: entry.filePath,
44656
+ source: current.source === "declared_edit" || entry.source === "declared_edit" ? "declared_edit" : "agent_declared",
44657
+ observedAt: newer ? entry.observedAt : current.observedAt,
44658
+ hookHealth: newer ? entry.hookHealth ?? null : current.hookHealth,
44659
+ syncState: current.syncState === "pending" || syncState === "pending" ? "pending" : "synced"
44660
+ });
44661
+ }
44662
+ }
44663
+ const rows = [...byPath.values()].sort(
44664
+ (left, right) => left.filePath < right.filePath ? -1 : left.filePath > right.filePath ? 1 : 0
44665
+ );
44666
+ const pending = rows.filter((row) => row.syncState === "pending").length;
44667
+ const warnings = /* @__PURE__ */ new Set();
44668
+ const healthCodes = /* @__PURE__ */ new Set();
44669
+ let bindingState = "bound";
44670
+ let callbackObserved = false;
44671
+ for (const snapshot of snapshots) {
44672
+ const { capture } = snapshot;
44673
+ if (BINDING_SEVERITY[capture.bindingState] > BINDING_SEVERITY[bindingState]) {
44674
+ bindingState = capture.bindingState;
44675
+ }
44676
+ if (capture.callbackObservedAt) callbackObserved = true;
44677
+ if (capture.bindingState === "unbound") warnings.add("unbound");
44678
+ else if (capture.bindingState === "unknown") warnings.add("unknown_binding");
44679
+ else if (!capture.callbackObservedAt) warnings.add("bound_no_callback");
44680
+ for (const entry of snapshot.health) {
44681
+ healthCodes.add(entry.code);
44682
+ if (CAPTURE_GAP_CODES.includes(bareHealthCode(entry.code))) {
44683
+ warnings.add("tool_activity_uncaptured");
44684
+ }
44685
+ }
44686
+ }
44687
+ if (pending > 0) warnings.add(syncFailed ? "sync_failed" : "sync_pending");
44688
+ return {
44689
+ scope: "local_objective_sessions",
44690
+ objectiveId,
44691
+ coverage: "available",
44692
+ items: rows.slice(0, OBJECTIVE_FILE_CHANGES_LIMIT),
44693
+ total: rows.length,
44694
+ limit: OBJECTIVE_FILE_CHANGES_LIMIT,
44695
+ truncated: rows.length > OBJECTIVE_FILE_CHANGES_LIMIT,
44696
+ sync: { synced: rows.length - pending, pending, failed: syncFailed },
44697
+ capture: {
44698
+ bindingState,
44699
+ callbackObserved,
44700
+ healthCodes: [...healthCodes].sort().slice(0, MAX_LOCAL_HEALTH_CODES)
44701
+ },
44702
+ warnings: [...warnings]
44703
+ };
44704
+ }
44705
+ var MAX_LOCAL_HEALTH_CODES, BINDING_SEVERITY;
44706
+ var init_local_objective_changes = __esm({
44707
+ "src/local-objective-changes.ts"() {
44708
+ "use strict";
44709
+ init_dist();
44710
+ MAX_LOCAL_HEALTH_CODES = 32;
44711
+ BINDING_SEVERITY = { bound: 0, unknown: 1, unbound: 2 };
44712
+ }
44713
+ });
44714
+
44373
44715
  // src/org-setup.ts
44374
44716
  import { readFileSync as readFileSync18 } from "node:fs";
44375
44717
  import path35 from "node:path";
@@ -44559,15 +44901,16 @@ Subcommands:
44559
44901
  create Create a draft mission without attaching
44560
44902
  prompt Create a mission and attach to it immediately
44561
44903
  record-work Record completed-from-chat work as a review mission (no attach)
44562
- update Post progress, activity events, and optional change rationales
44904
+ update Post progress and activity events; optionally declare shell/script paths
44563
44905
  heartbeat Send a liveness ping without creating a mission event
44564
44906
  ask Post a blocking question and move the mission to review
44565
44907
  deliver Finish work, send artifacts, and move the mission to review
44566
44908
  resume-follow-up Reopen a completed objective for post-delivery follow-up work
44567
44909
  hook-event Record a connector lifecycle hook (e.g. UserPromptSubmit)
44568
44910
  capture-change Local-only: append direct-path hook evidence to an objective ledger
44569
- changes Sync and inspect the attached objective's local change ledger
44570
- (source, overlap, and hook-health evidence); never arbitrate peers
44911
+ changes Local-only: sync and read this checkout's evidence for one objective
44912
+ (synced + pending paths, capture/sync warnings); never arbitrate peers
44913
+ objective-changes Read the objective's synchronized evidence across sessions and devices
44571
44914
  read-context Read shared persistent context for this mission
44572
44915
  write-context Write shared persistent context for future sessions
44573
44916
  add-artifact Create a mission artifact during a turn (no delivery required)
@@ -44671,6 +45014,10 @@ attach:
44671
45014
  --execution-request-id <id> Link this attach to a runner execution request
44672
45015
  --objective-id <id> Pin attach to this objective (UUID or coo:756.k7xm)
44673
45016
  --external-session-id <id> Native agent thread/session id for resume
45017
+ Notes:
45018
+ The CLI records the session's capture binding: bound when OVERLORD_OBJECTIVE_ID
45019
+ names the attached objective, unbound otherwise. Bound is configuration evidence
45020
+ only; it never claims the capture hook is installed or has run.
44674
45021
  Returns:
44675
45022
  Full JSON including session.sessionKey, mission, history, artifacts, sharedState,
44676
45023
  and agentInstructions with required workflow instructions and structured-field pointers.
@@ -44719,6 +45066,21 @@ list-deliveries:
44719
45066
  normalized delivery report evidence, capped at 200. total is the matching
44720
45067
  row count before that cap.
44721
45068
 
45069
+ objective-changes:
45070
+ Purpose:
45071
+ Read the synchronized changed-path evidence of exactly one objective across every
45072
+ session, resource, and device. Needs no attach and mutates nothing. It cannot see
45073
+ unsynchronized local rows; use \`changes\` for this checkout's pending evidence.
45074
+ Required:
45075
+ --objective-id <id> Display id (coo:756.k7xm) or UUID with --mission-id
45076
+ Optional:
45077
+ --mission-id <id> Required when --objective-id is a UUID
45078
+ Returns:
45079
+ ObjectiveFileChangesDto { scope: "server_objective", items, total, limit, truncated,
45080
+ capture }. items are compact rows (resourceKey, filePath, source declared_edit |
45081
+ agent_declared | null for unknown, observedAt, hookHealth) ordered by resource then
45082
+ path, capped at 200; total is the pre-cap count after the objective filter.
45083
+
44722
45084
  launch-objective:
44723
45085
  Purpose:
44724
45086
  Queue the normal execution request for one objective. This does not attach the
@@ -45080,7 +45442,7 @@ record-work:
45080
45442
  Purpose:
45081
45443
  Record work already completed in chat as a completed mission in review, in one
45082
45444
  call \u2014 no attach/deliver cycle. Creates a mission with a single completed
45083
- objective, records the file changes and their rationales, lands it in the review
45445
+ objective, records the explicitly declared changed paths, lands it in the review
45084
45446
  column, and runs the delivery through the standard Gemini summarizer so it reads
45085
45447
  like any other delivered mission. Use instead of create + attach + deliver.
45086
45448
  Required:
@@ -45091,18 +45453,16 @@ record-work:
45091
45453
  --title <text>
45092
45454
  --assigned-to <id> Workspace member to own the mission
45093
45455
  --artifacts-json / --artifacts-file <path|->
45094
- --change-rationales-json / --change-rationales-file <path|->
45095
- --changed-files-json / --changed-files-file <path|->
45456
+ --declared-paths-json / --declared-paths-file <path|->
45457
+ JSON array of repository-relative paths the work changed
45096
45458
  --payload-json / --payload-file <path|-> (single envelope; see Notes)
45097
45459
  Notes:
45098
45460
  Efficient form: stream one JSON object on stdin via \`--payload-file -\` carrying
45099
- { objective, summary, title?, changeRationales, changedFiles?, artifacts? }.
45461
+ { objective, summary, title?, declaredPaths?, artifacts? }.
45100
45462
  Explicit flags always win over fields inside --payload-json.
45101
- Change-rationale entries use the same shape documented under \`deliver\`
45102
- (filePath, label, summary, why, impact; summary is named "summary", not "rationale").
45103
- Every rationale's filePath is recorded as a changed file (shown "covered" in
45104
- review); add --changed-files-json for touched files without a rationale. The
45105
- full submission format lives in reference/record-work.md.
45463
+ Declared paths are stored as agent_declared with no resource and no VCS status;
45464
+ explain why they changed in the summary. The full submission format lives in
45465
+ reference/record-work.md.
45106
45466
 
45107
45467
  update:
45108
45468
  Purpose:
@@ -45119,13 +45479,11 @@ update:
45119
45479
  --payload-json / --payload-file <path|->
45120
45480
  --external-url <url|null>
45121
45481
  --external-session-id <id|null>
45122
- --change-rationales-json / --change-rationales-file <path|->
45482
+ --paths <a,b,c> / --paths-file <path|-> Declare shell/script outputs (see deliver)
45123
45483
  Notes:
45124
45484
  Pass --summary-file - to read the summary from stdin and avoid shell quoting issues.
45125
45485
  Inline --*-json values larger than ~8 KB are rejected; use the paired --*-file - flag.
45126
45486
  After delivery, pass --begin-follow-up-work before posting execution updates.
45127
- Change-rationale entries use the same shape documented under \`deliver\`
45128
- (filePath, label, summary, why, impact; summary is named "summary", not "rationale").
45129
45487
 
45130
45488
  heartbeat:
45131
45489
  Purpose:
@@ -45151,18 +45509,20 @@ ask:
45151
45509
 
45152
45510
  deliver:
45153
45511
  Purpose:
45154
- Conclude the session and submit the final narrative plus artifacts/change rationales.
45512
+ Conclude the session and submit the final narrative plus optional artifacts.
45155
45513
  Required:
45156
45514
  --session-key <key>
45157
45515
  --mission-id <id>
45158
45516
  --summary or --summary-file <path|->
45159
- or: --payload-json / --payload-file <path|-> with { summary, artifacts, changeRationales }
45517
+ or: --payload-json / --payload-file <path|-> with { summary, artifacts }
45160
45518
  The payload may also include deliveryReport: { schemaVersion: 1, agentReport: {
45161
45519
  humanActions, tradeoffsMade, knownRisks, deferredWork, assumptions } }. Use empty arrays
45162
45520
  when none apply. Human actions exclude Git operations and routine review/testing.
45163
45521
  Deferred work is only a recommended new objective that is not part of this mission
45164
- (for example an out-of-scope bug). Name the component or file involved and say why
45165
- the work was left. Never list work already covered by this mission's future
45522
+ (for example an out-of-scope bug). Each item is { title, change, location, doneWhen }:
45523
+ an imperative title (<=80), only the specific change needed (<=400), where to find it
45524
+ in the code (<=200), and the observable result in one sentence (<=200). String items
45525
+ are rejected with invalid_input. Never list work already covered by this mission's future
45166
45526
  objectives, leftover slices of the current objective, or human implementation
45167
45527
  follow-up (those belong in humanActions). Use an empty array when nothing qualifies.
45168
45528
  Human action shape (each item in agentReport.humanActions):
@@ -45182,58 +45542,62 @@ deliver:
45182
45542
  report those yourself when you can supply the real command and verify step.
45183
45543
  Optional:
45184
45544
  --artifacts-json / --artifacts-file <path|->
45185
- --change-rationales-json / --change-rationales-file <path|->
45545
+ --paths <a,b,c> Declare paths native capture missed (comma-separated)
45546
+ --paths-file <path|-> Same, as a JSON array of path strings (commas allowed)
45186
45547
  --verification-summary <text>
45187
45548
  --follow-up-notes <text>
45188
- Change-rationale entry shape (each item in --change-rationales-json / -file):
45189
- {
45190
- "filePath": "src/api.ts", // required repo-relative path.
45191
- "label": "Add retry", // required. short reviewer-facing title.
45192
- "summary": "Added retry.", // required. WHAT changed. The field is named "summary", NOT "rationale".
45193
- "why": "Flaky calls.", // required. WHY it changed.
45194
- "impact": "Retries 3x.", // required. behavioral impact.
45195
- "hunks": [{ "header": "@@ -10,6 +10,14 @@" }] // optional.
45196
- }
45197
- Pass an array of these. Do NOT wrap entries under a "rationale" key and do not send a
45198
- top-level "file_changes" artifact. label/summary/why/impact must be non-empty strings.
45199
45549
  Notes:
45200
- A normal delivery requires only --summary. The CLI syncs objective-bound ledger
45201
- evidence automatically before update, changes, and deliver. Optional rationales,
45202
- hook health, and path attribution cannot fail delivery. Do not continue implementation
45203
- after delivery without explicit follow-up.
45204
-
45205
- --paths <a,b,c> is optional, metadata-only evidence for outputs of a generator,
45206
- migration, or script. It is batched into this existing call, never inspects VCS,
45207
- and is not an instruction to list every changed or opened file.
45208
- Inline --*-json values larger than ~8 KB are rejected; use --change-rationales-file -
45209
- (or --payload-file -) and stream JSON on stdin. Keep --summary inline.
45210
- Run \`${primaryCommand} protocol changes --objective-id <id>\` to inspect the attached
45211
- objective ledger and retry any advisory sync. It never claims or excludes another
45212
- objective's paths.
45550
+ A normal delivery requires only --summary: explain the outcome, why, verification,
45551
+ and limitations by behavior or component. No per-file explanation exists. The CLI
45552
+ syncs objective-bound ledger evidence before update, changes, and deliver; tracking
45553
+ gaps and sync failure never fail delivery. Do not continue implementation after
45554
+ delivery without explicit follow-up.
45555
+
45556
+ Before delivering, read \`${primaryCommand} protocol changes --objective-id <id>\` once.
45557
+ Declare with --paths / --paths-file only paths you know you changed that native
45558
+ capture missed: shell/heredoc/script/generator outputs, deletes, and both rename
45559
+ endpoints. They are recorded as agent_declared in this objective's ledger, are
45560
+ normalized against this checkout (absolute paths inside it are accepted; traversal,
45561
+ out-of-checkout symlinks, ignored and Overlord-managed paths are rejected with a
45562
+ reason on stderr), and absent targets are valid. Never enumerate opened files or a
45563
+ shared-worktree diff; when unsure, describe the coverage limitation instead.
45564
+ Inline --*-json values larger than ~8 KB are rejected; use --payload-file - and
45565
+ stream JSON on stdin. Keep --summary inline.
45213
45566
 
45214
45567
  capture-change:
45215
45568
  Purpose:
45216
45569
  Normalize one raw native callback with the named connector codec and append only
45217
- declared Write/Edit paths to the exact objective/session ledger. The raw payload
45570
+ successful native edit paths to the exact objective/session ledger. The raw payload
45218
45571
  remains local and input is bounded to 1 MiB.
45219
45572
  Required:
45220
45573
  --agent <connector-key>
45221
45574
  --objective-id <id>
45222
45575
  native callback JSON on stdin
45223
45576
  Notes:
45224
- Read/search/fetch callbacks are silent. Shell, unknown, unmapped, and pathless
45225
- mutation callbacks record bounded unavailable health without claiming a path.
45577
+ Every scoped callback records callback observation; read/search/fetch callbacks
45578
+ append no evidence. A path is appended only when the codec decodes outcome ok.
45579
+ blocked appends nothing; error/cancelled record outcome_partial; unknown records
45580
+ outcome_unavailable; shell records shell_activity_unverified; other pathless or
45581
+ unmapped callbacks record direct_path_unavailable. None of these claims a path.
45226
45582
 
45227
45583
  changes:
45228
45584
  Purpose:
45229
- Sync and inspect the attached objective's local ledger. Reports whether evidence
45230
- remains unsynced, but never scans the shared worktree, claims peer paths, or drafts
45231
- rationale/skip payloads. Sync failure is advisory.
45585
+ Local-only read of this checkout's evidence for one objective. Drains every
45586
+ locally known ledger of the objective, then returns synced and pending paths
45587
+ deduplicated by path. Never scans the shared worktree, claims peer paths, or reads
45588
+ the backend's history; sync failure is advisory.
45232
45589
  Required:
45233
45590
  --objective-id <id>
45234
45591
  Optional:
45235
45592
  --mission-id <id> Required when objective id does not encode mission scope
45236
- --session-key <key> Validate one exact binding; every matching live/retry ledger drains
45593
+ --session-key <key> Must identify a local session of the objective
45594
+ Returns:
45595
+ LocalObjectiveChangesDto { scope: "local_objective_sessions", objectiveId, coverage,
45596
+ items, total, limit, truncated, sync, capture, warnings }. items are
45597
+ { filePath, source declared_edit | agent_declared, observedAt, hookHealth,
45598
+ syncState synced | pending } sorted by path and capped at 200; total counts distinct
45599
+ local paths. coverage "unavailable" means no local session matched, not "no files
45600
+ changed". This is not complete cross-device history: use objective-changes.
45237
45601
 
45238
45602
  sync-changes:
45239
45603
  Purpose:
@@ -45423,6 +45787,7 @@ var init_protocol_help = __esm({
45423
45787
  "list-deliveries",
45424
45788
  "list-organizations",
45425
45789
  "load-context",
45790
+ "objective-changes",
45426
45791
  "prompt",
45427
45792
  "read-context",
45428
45793
  "record-work",
@@ -46236,16 +46601,13 @@ function canonicalChangeEvidenceTuple(value2) {
46236
46601
  if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) return null;
46237
46602
  const record2 = value2;
46238
46603
  if (Object.keys(record2).some((key) => !SYNC_CHANGE_EVIDENCE_KEYS.has(key))) return null;
46239
- if (typeof record2.idempotencyKey !== "string" || typeof record2.filePath !== "string" || record2.source !== "declared_edit" && record2.source !== "window_observed" || record2.quality !== "direct" && record2.quality !== "window" || typeof record2.overlap !== "boolean" || typeof record2.observedAt !== "string" || record2.toolWindowId !== void 0 && typeof record2.toolWindowId !== "string" || record2.hookHealth !== void 0 && typeof record2.hookHealth !== "string") {
46604
+ if (typeof record2.idempotencyKey !== "string" || typeof record2.filePath !== "string" || record2.source !== "declared_edit" && record2.source !== "agent_declared" || typeof record2.observedAt !== "string" || record2.hookHealth !== void 0 && typeof record2.hookHealth !== "string") {
46240
46605
  return null;
46241
46606
  }
46242
46607
  return JSON.stringify([
46243
46608
  record2.idempotencyKey,
46244
46609
  record2.filePath,
46245
46610
  record2.source,
46246
- record2.quality,
46247
- record2.overlap,
46248
- record2.toolWindowId ?? null,
46249
46611
  record2.observedAt,
46250
46612
  record2.hookHealth ?? null
46251
46613
  ]);
@@ -46300,14 +46662,16 @@ async function syncObjectiveLedger({
46300
46662
  sessionKey,
46301
46663
  active
46302
46664
  }) {
46665
+ const identity = { workingDirectory, objectiveId: active.objectiveId, sessionKey };
46303
46666
  let synced = 0;
46667
+ let captureAttempted = false;
46304
46668
  while (true) {
46305
- const changes = readUnsyncedChangeEvidence({
46306
- workingDirectory,
46307
- objectiveId: active.objectiveId,
46308
- sessionKey
46309
- }).slice(0, 25);
46310
- if (changes.length === 0) return { synced };
46669
+ const changes = readUnsyncedChangeEvidence(identity).slice(0, 25);
46670
+ const snapshot = captureAttempted ? null : readChangeLedgerSnapshot(identity);
46671
+ const captureFingerprint = snapshot ? changeLedgerCaptureFingerprint(snapshot) : null;
46672
+ const sendCapture = snapshot !== null && captureFingerprint !== snapshot.capture.syncedFingerprint;
46673
+ captureAttempted = true;
46674
+ if (changes.length === 0 && !sendCapture) return { synced };
46311
46675
  try {
46312
46676
  const result = await runtime.backend.post({
46313
46677
  path: "/api/protocol/sync-changes",
@@ -46319,10 +46683,16 @@ async function syncObjectiveLedger({
46319
46683
  flags: {
46320
46684
  "--session-key": sessionKey,
46321
46685
  "--mission-id": missionId,
46322
- "--changes-json": JSON.stringify(changes)
46686
+ "--changes-json": JSON.stringify(changes),
46687
+ ...sendCapture && snapshot ? { "--capture-json": JSON.stringify(changeLedgerCapturePayload(snapshot)) } : {}
46323
46688
  }
46324
46689
  }
46325
46690
  });
46691
+ const captureStatus = asRecord5(asRecord5(result).capture).status;
46692
+ if (sendCapture && captureFingerprint && (captureStatus === "accepted" || captureStatus === "ignored")) {
46693
+ markChangeLedgerCaptureSynced({ ...identity, fingerprint: captureFingerprint });
46694
+ }
46695
+ if (changes.length === 0) return { synced };
46326
46696
  const outcomes = asRecord5(result).outcomes;
46327
46697
  const batch = new Map(
46328
46698
  changes.map((change) => [changeEvidenceIdentityKey(change), change])
@@ -46333,12 +46703,12 @@ async function syncObjectiveLedger({
46333
46703
  if (record2.status !== "accepted" && record2.status !== "ignored" || typeof record2.idempotencyKey !== "string" || typeof record2.filePath !== "string") {
46334
46704
  return [];
46335
46705
  }
46336
- const identity = {
46706
+ const identity2 = {
46337
46707
  idempotencyKey: record2.idempotencyKey,
46338
46708
  filePath: record2.filePath
46339
46709
  };
46340
- const key = changeEvidenceIdentityKey(identity);
46341
- return batch.has(key) ? [[key, identity]] : [];
46710
+ const key = changeEvidenceIdentityKey(identity2);
46711
+ return batch.has(key) ? [[key, identity2]] : [];
46342
46712
  }) : []
46343
46713
  );
46344
46714
  if (accepted.size === 0) {
@@ -46535,36 +46905,78 @@ function createdObjectiveLines(mission) {
46535
46905
  return ` Objective ${identifier}${title ? ` (${title})` : ""}: ${fields.join(", ")}`;
46536
46906
  });
46537
46907
  }
46908
+ function declaredOutputPathInputs({
46909
+ flags,
46910
+ fileInputs
46911
+ }) {
46912
+ const inline = flags["--paths"];
46913
+ const fileContent = fileInputs["--paths-file"];
46914
+ if (inline === void 0 && fileContent === void 0) return null;
46915
+ const paths = [];
46916
+ if (inline !== void 0) {
46917
+ if (typeof inline !== "string" || inline.trim() === "") {
46918
+ throw new CliError({ message: "--paths requires a comma-separated list of output paths." });
46919
+ }
46920
+ paths.push(
46921
+ ...inline.split(",").map((entry) => entry.trim()).filter(Boolean)
46922
+ );
46923
+ }
46924
+ if (fileContent !== void 0) {
46925
+ let parsed;
46926
+ try {
46927
+ parsed = JSON.parse(fileContent);
46928
+ } catch {
46929
+ throw new CliError({ message: "--paths-file must contain a JSON array of path strings." });
46930
+ }
46931
+ if (!Array.isArray(parsed) || parsed.some((entry) => typeof entry !== "string")) {
46932
+ throw new CliError({ message: "--paths-file must contain a JSON array of path strings." });
46933
+ }
46934
+ paths.push(...parsed);
46935
+ }
46936
+ if (paths.length === 0) {
46937
+ throw new CliError({ message: "--paths/--paths-file requires at least one output path." });
46938
+ }
46939
+ if (paths.length > MAX_DECLARED_OUTPUT_PATHS) {
46940
+ throw new CliError({
46941
+ message: `--paths/--paths-file accepts at most ${MAX_DECLARED_OUTPUT_PATHS} paths per call.`
46942
+ });
46943
+ }
46944
+ return paths;
46945
+ }
46538
46946
  function appendDeclaredOutputPaths({
46539
46947
  flags,
46948
+ fileInputs,
46540
46949
  active,
46541
46950
  workingDirectory
46542
46951
  }) {
46543
- const value2 = flags["--paths"];
46544
- if (value2 === void 0) return;
46952
+ const paths = declaredOutputPathInputs({ flags, fileInputs });
46545
46953
  delete flags["--paths"];
46546
- if (typeof value2 !== "string" || value2.trim() === "") {
46547
- throw new CliError({ message: "--paths requires a comma-separated list of output paths." });
46548
- }
46954
+ delete flags["--paths-file"];
46955
+ delete fileInputs["--paths-file"];
46956
+ if (paths === null) return;
46549
46957
  if (!active) {
46550
46958
  throw new CliError({
46551
- message: "--paths requires the attached objective session in this working directory."
46959
+ message: "--paths/--paths-file requires the attached objective session in this working directory."
46552
46960
  });
46553
46961
  }
46554
- const paths = value2.split(",").map((entry) => entry.trim()).filter(Boolean);
46555
- if (paths.length === 0) {
46556
- throw new CliError({ message: "--paths requires at least one output path." });
46557
- }
46558
- appendChangeEvidence({
46962
+ const result = declareChangePaths({
46559
46963
  workingDirectory,
46560
46964
  objectiveId: active.objectiveId,
46561
46965
  sessionKey: active.sessionKey,
46562
- filePaths: paths.slice(0, MAX_DECLARED_OUTPUT_PATHS),
46563
- source: "declared_edit",
46564
- quality: "direct",
46565
- overlap: false,
46566
- hookHealth: "agent_declared_generator_output"
46966
+ filePaths: paths
46567
46967
  });
46968
+ if (!result.recorded) {
46969
+ console.error("[overlord] Declared paths could not be recorded in the local change ledger.");
46970
+ return;
46971
+ }
46972
+ for (const rejected of result.rejected.slice(0, 20)) {
46973
+ console.error(
46974
+ `[overlord] Ignored declared path ${JSON.stringify(rejected.path)}: ${rejected.reason}`
46975
+ );
46976
+ }
46977
+ if (result.rejected.length > 20) {
46978
+ console.error(`[overlord] Ignored ${result.rejected.length - 20} more declared path(s).`);
46979
+ }
46568
46980
  }
46569
46981
  async function resolveProtocolFileInputs({
46570
46982
  flags,
@@ -46649,7 +47061,7 @@ Run \`${primaryCommand} protocol help\` for usage.`
46649
47061
  const suppliedRetiredFlags = retiredFlags.filter((flag) => flag in flags);
46650
47062
  if (suppliedRetiredFlags.length > 0) {
46651
47063
  throw new CliError({
46652
- message: `${suppliedRetiredFlags.join(", ")} ${suppliedRetiredFlags.length === 1 ? "was" : "were"} removed. File evidence is captured and synchronized from the objective ledger.`
47064
+ message: `${suppliedRetiredFlags.join(", ")} ${suppliedRetiredFlags.length === 1 ? "was" : "were"} removed. Explain changes in the summary; file evidence is captured in the objective ledger. Declare shell/script outputs native capture missed with --paths or --paths-file.`
46653
47065
  });
46654
47066
  }
46655
47067
  if (subcommand === "attach" && typeof flags["--execution-request-id"] !== "string" && process.env.OVERLORD_EXECUTION_REQUEST_ID) {
@@ -46716,15 +47128,26 @@ Run \`${primaryCommand} protocol help\` for usage.`
46716
47128
  message: "Mission scope is required when --objective-id is not a mission-qualified display id."
46717
47129
  });
46718
47130
  }
46719
- const sessionKey = typeof flags["--session-key"] === "string" && flags["--session-key"] || (objectiveRef ? readCachedSessionKey({ missionId, workingDirectory, objectiveId: objectiveRef }) : void 0);
46720
- const objectiveSessions = objectiveRef ? readObjectiveSessions({ workingDirectory, objectiveId: objectiveRef }) : [];
46721
- const explicitSessionKey = typeof flags["--session-key"] === "string" ? flags["--session-key"] : void 0;
46722
- const explicitSessionMatches = !explicitSessionKey || objectiveSessions.some((entry) => entry.sessionKey === explicitSessionKey);
46723
- const candidates = explicitSessionMatches ? objectiveSessions : [];
46724
- const selected = (sessionKey ? objectiveSessions.find((entry) => entry.sessionKey === sessionKey) : void 0) ?? objectiveSessions.find((entry) => !entry.deliveryPendingSync);
46725
- let synced = 0;
46726
- const warnings = [];
46727
- for (const entry of candidates) {
47131
+ const objectiveMission = missionDisplayIdFromObjectiveRef(objectiveRef);
47132
+ if (objectiveMission && missionId.includes(":") && objectiveMission !== missionId.trim()) {
47133
+ throw new CliError({
47134
+ message: `Objective ${objectiveRef} does not belong to mission ${missionId}.`
47135
+ });
47136
+ }
47137
+ const objectiveSessions = readObjectiveSessions({
47138
+ workingDirectory,
47139
+ objectiveId: objectiveRef
47140
+ }).filter(
47141
+ (entry) => !missionId.includes(":") || !entry.missionId.includes(":") || entry.missionId === missionId.trim()
47142
+ );
47143
+ const explicitSessionKey = typeof flags["--session-key"] === "string" ? flags["--session-key"].trim() : void 0;
47144
+ if (explicitSessionKey && !objectiveSessions.some((entry) => entry.sessionKey === explicitSessionKey)) {
47145
+ throw new CliError({
47146
+ message: `--session-key does not identify a local session of objective ${objectiveRef} in this working directory.`
47147
+ });
47148
+ }
47149
+ let syncFailed = false;
47150
+ for (const entry of objectiveSessions) {
46728
47151
  const result2 = await syncObjectiveLedger({
46729
47152
  runtime,
46730
47153
  workingDirectory,
@@ -46732,24 +47155,22 @@ Run \`${primaryCommand} protocol help\` for usage.`
46732
47155
  sessionKey: entry.sessionKey,
46733
47156
  active: entry
46734
47157
  });
46735
- synced += result2.synced;
46736
- if (result2.warning && !warnings.includes(result2.warning)) warnings.push(result2.warning);
47158
+ if (result2.warning) syncFailed = true;
46737
47159
  }
46738
- let unsyncedEvidence = 0;
46739
- const allHealth = candidates.flatMap((entry) => {
46740
- unsyncedEvidence += readUnsyncedChangeEvidence({
46741
- workingDirectory,
46742
- objectiveId: entry.objectiveId,
46743
- sessionKey: entry.sessionKey
46744
- }).length;
46745
- return readChangeLedgerHealth({
47160
+ const snapshots = objectiveSessions.flatMap((entry) => {
47161
+ const snapshot = readChangeLedgerSnapshot({
46746
47162
  workingDirectory,
46747
47163
  objectiveId: entry.objectiveId,
46748
47164
  sessionKey: entry.sessionKey
46749
47165
  });
47166
+ return snapshot ? [snapshot] : [];
47167
+ });
47168
+ const local = buildLocalObjectiveChanges({
47169
+ objectiveId: objectiveSessions[0]?.objectiveId ?? objectiveRef,
47170
+ snapshots,
47171
+ syncFailed
46750
47172
  });
46751
- const health = allHealth.sort((left, right) => left.at.localeCompare(right.at)).slice(-MAX_CHANGES_HEALTH_ENTRIES);
46752
- for (const entry of candidates.filter((candidate) => candidate.deliveryPendingSync)) {
47173
+ for (const entry of objectiveSessions.filter((candidate) => candidate.deliveryPendingSync)) {
46753
47174
  const stillUnsynced = readUnsyncedChangeEvidence({
46754
47175
  workingDirectory,
46755
47176
  objectiveId: entry.objectiveId,
@@ -46773,13 +47194,7 @@ Run \`${primaryCommand} protocol help\` for usage.`
46773
47194
  if (readActiveSessions(workingDirectory).length === 0) {
46774
47195
  clearActiveMissionPointer(workingDirectory);
46775
47196
  }
46776
- printJson({
46777
- objectiveId: selected?.objectiveId ?? objectiveSessions[0]?.objectiveId ?? null,
46778
- synced,
46779
- warning: candidates.length === 0 ? "no attached objective session" : warnings.length > 0 ? warnings.join("; ") : null,
46780
- unsyncedEvidence,
46781
- health
46782
- });
47197
+ printJson(local);
46783
47198
  return;
46784
47199
  }
46785
47200
  if (SESSION_KEY_SUBCOMMANDS.has(subcommand) && missionId && objectiveRef && (typeof flags["--session-key"] !== "string" || flags["--session-key"].trim() === "")) {
@@ -46825,7 +47240,7 @@ Run \`${primaryCommand} protocol help\` for usage.`
46825
47240
  const sessionKey = typeof flags["--session-key"] === "string" ? flags["--session-key"] : null;
46826
47241
  const active = sessionKey ? readActiveSessions(workingDirectory).find((entry) => entry.sessionKey === sessionKey) : void 0;
46827
47242
  lifecycleActive = active;
46828
- appendDeclaredOutputPaths({ flags, active, workingDirectory });
47243
+ appendDeclaredOutputPaths({ flags, fileInputs, active, workingDirectory });
46829
47244
  if (sessionKey && active) {
46830
47245
  await syncObjectiveLedger({ runtime, workingDirectory, missionId, sessionKey, active });
46831
47246
  }
@@ -46845,6 +47260,12 @@ Run \`${primaryCommand} protocol help\` for usage.`
46845
47260
  flags["--execution-target-id"] = preferredTargetId;
46846
47261
  }
46847
47262
  }
47263
+ const launchObjectiveEnv = process.env.OVERLORD_OBJECTIVE_ID?.trim() || void 0;
47264
+ if (subcommand === "attach") {
47265
+ delete flags["--capture-binding"];
47266
+ if (!launchObjectiveEnv) flags["--capture-binding"] = "unbound";
47267
+ else if (objectiveRef?.trim() === launchObjectiveEnv) flags["--capture-binding"] = "bound";
47268
+ }
46848
47269
  const protocolBody = {
46849
47270
  args,
46850
47271
  positional: parsed.positional,
@@ -46933,13 +47354,21 @@ Run \`${primaryCommand} protocol help\` for usage.`
46933
47354
  }
46934
47355
  if ((subcommand === "attach" || subcommand === "resume-follow-up") && attachedObjectiveId) {
46935
47356
  const objectiveIdentity = typeof attachedObjective.id === "string" && attachedObjective.id.trim() || attachedObjectiveId;
46936
- writeActiveSession({
47357
+ const bound = writeActiveSession({
46937
47358
  workingDirectory,
46938
47359
  missionId,
46939
47360
  objectiveId: objectiveIdentity,
46940
47361
  objectiveAliases: [...objectiveAliases],
46941
47362
  sessionKey: resultRecord.sessionKey
46942
47363
  });
47364
+ if (bound) {
47365
+ recordChangeLedgerBinding({
47366
+ workingDirectory,
47367
+ objectiveId: objectiveIdentity,
47368
+ sessionKey: resultRecord.sessionKey,
47369
+ bindingState: launchObjectiveEnv && (launchObjectiveEnv === objectiveIdentity || objectiveAliases.has(launchObjectiveEnv)) ? "bound" : "unbound"
47370
+ });
47371
+ }
46943
47372
  }
46944
47373
  }
46945
47374
  }
@@ -47553,20 +47982,20 @@ async function runManagementCommand({
47553
47982
  const missionId = missionRef ? missionDisplayIdFromObjectiveRef(missionRef) ?? missionRef : void 0;
47554
47983
  if (!missionId) {
47555
47984
  throw new CliError({
47556
- message: "Usage: ovld mission context|events|deliveries|artifacts|rationales <missionId> [--json]"
47985
+ message: "Usage: ovld mission context|events|deliveries|artifacts|file-changes <missionId> [--json]"
47557
47986
  });
47558
47987
  }
47559
47988
  const pathBySub = {
47560
47989
  context: `/api/missions/${encodeURIComponent(missionId)}`,
47561
47990
  events: `/api/missions/${encodeURIComponent(missionId)}/events`,
47562
47991
  artifacts: `/api/missions/${encodeURIComponent(missionId)}/artifacts`,
47563
- rationales: `/api/missions/${encodeURIComponent(missionId)}/file-changes`,
47992
+ "file-changes": `/api/missions/${encodeURIComponent(missionId)}/file-changes`,
47564
47993
  deliveries: `/api/missions/${encodeURIComponent(missionId)}/deliveries`
47565
47994
  };
47566
47995
  const path40 = sub ? pathBySub[sub] : void 0;
47567
47996
  if (!path40) {
47568
47997
  throw new CliError({
47569
- message: "Usage: ovld mission context|events|deliveries|artifacts|rationales <missionId> [--json]"
47998
+ message: "Usage: ovld mission context|events|deliveries|artifacts|file-changes <missionId> [--json]"
47570
47999
  });
47571
48000
  }
47572
48001
  const result = await runtime.backend.get(path40);
@@ -47582,27 +48011,26 @@ async function runManagementCommand({
47582
48011
  const sub = parsed.positional[0];
47583
48012
  const objectiveRef = flagValue(parsed.flags, "--objective-id");
47584
48013
  const missionId = flagValue(parsed.flags, "--mission-id") ?? missionDisplayIdFromObjectiveRef(objectiveRef);
47585
- if (!missionId) {
48014
+ if (sub !== "status" || !missionId) {
47586
48015
  throw new CliError({
47587
- message: "Usage: ovld changes status|rationales --mission-id <id> (or --objective-id <mission-display-id>.<key>)"
48016
+ message: "Usage: ovld changes status --mission-id <id> [--objective-id <id>] [--json] (or --objective-id <mission-display-id>.<key>)"
47588
48017
  });
47589
48018
  }
47590
- if (sub !== "status" && sub !== "rationales") {
47591
- throw new CliError({ message: "Usage: ovld changes status|rationales --mission-id <id>" });
47592
- }
47593
- const page = await runtime.backend.get(
47594
- `/api/missions/${encodeURIComponent(missionId)}/file-changes`
48019
+ const query = objectiveRef ? `?objectiveId=${encodeURIComponent(objectiveRef)}` : "";
48020
+ const result = await runtime.backend.get(
48021
+ `/api/missions/${encodeURIComponent(missionId)}/file-changes${query}`
47595
48022
  );
47596
- let result = missionEvidenceItems(page) ?? [];
47597
- if (objectiveRef) {
47598
- const mission = await runtime.backend.get(
47599
- `/api/missions/${encodeURIComponent(missionId)}`
48023
+ if (json2) {
48024
+ printJson(result);
48025
+ return;
48026
+ }
48027
+ for (const row of missionEvidenceItems(result) ?? []) console.log(JSON.stringify(row));
48028
+ const record2 = asRecord5(result);
48029
+ if (record2.truncated === true) {
48030
+ console.log(
48031
+ `Showing ${String(record2.limit)} of ${String(record2.total)} changed paths (truncated).`
47600
48032
  );
47601
- const objectiveId = objectiveIdForRef(mission, objectiveRef);
47602
- result = result.filter((row) => asRecord5(row).objectiveId === objectiveId);
47603
48033
  }
47604
- if (json2) printJson({ files: result, rationales: result });
47605
- else for (const row of result) console.log(JSON.stringify(row));
47606
48034
  return;
47607
48035
  }
47608
48036
  default:
@@ -48030,7 +48458,7 @@ Note: ${reinstallHint}`);
48030
48458
  message: "Usage: ovld runner service <install|start|stop|restart|status|uninstall> [--no-start] [--json]"
48031
48459
  });
48032
48460
  }
48033
- var SYNC_CHANGE_EVIDENCE_KEYS, OBJECTIVE_DISPLAY_ID_RE, PROTOCOL_FILE_FLAGS, SESSION_KEY_SUBCOMMANDS, OBJECTIVE_SCOPED_SUBCOMMANDS, READ_ONLY_MISSION_SUBCOMMANDS, RETIRED_CHANGE_TRACKING_FLAGS, MAX_CHANGES_HEALTH_ENTRIES, MAX_DECLARED_OUTPUT_PATHS, MAX_RUNNER_FAILURE_MESSAGE_LENGTH;
48461
+ var SYNC_CHANGE_EVIDENCE_KEYS, OBJECTIVE_DISPLAY_ID_RE, PROTOCOL_FILE_FLAGS, SESSION_KEY_SUBCOMMANDS, OBJECTIVE_SCOPED_SUBCOMMANDS, READ_ONLY_MISSION_SUBCOMMANDS, RETIRED_RATIONALE_FLAGS, RETIRED_CHANGED_FILES_FLAGS, RETIRED_CHANGE_TRACKING_FLAGS, MAX_DECLARED_OUTPUT_PATHS, MAX_RUNNER_FAILURE_MESSAGE_LENGTH;
48034
48462
  var init_commands = __esm({
48035
48463
  "src/commands.ts"() {
48036
48464
  "use strict";
@@ -48052,6 +48480,7 @@ var init_commands = __esm({
48052
48480
  init_launch();
48053
48481
  init_launch_bootstrap();
48054
48482
  init_launch_settings();
48483
+ init_local_objective_changes();
48055
48484
  init_native_session();
48056
48485
  init_org_setup();
48057
48486
  init_output();
@@ -48068,9 +48497,6 @@ var init_commands = __esm({
48068
48497
  "filePath",
48069
48498
  "idempotencyKey",
48070
48499
  "source",
48071
- "quality",
48072
- "overlap",
48073
- "toolWindowId",
48074
48500
  "observedAt",
48075
48501
  "hookHealth"
48076
48502
  ]);
@@ -48081,10 +48507,10 @@ var init_commands = __esm({
48081
48507
  "--options-file",
48082
48508
  "--payload-file",
48083
48509
  "--artifacts-file",
48084
- "--change-rationales-file",
48085
48510
  "--objectives-file",
48086
48511
  "--changes-file",
48087
- "--changed-files-file",
48512
+ "--declared-paths-file",
48513
+ "--paths-file",
48088
48514
  "--value-file",
48089
48515
  "--content-text-file",
48090
48516
  "--prompt-file",
@@ -48114,6 +48540,7 @@ var init_commands = __esm({
48114
48540
  "heartbeat",
48115
48541
  "hook-event",
48116
48542
  "load-context",
48543
+ "objective-changes",
48117
48544
  "read-context",
48118
48545
  "capture-change",
48119
48546
  "resume-follow-up",
@@ -48125,23 +48552,26 @@ var init_commands = __esm({
48125
48552
  ]);
48126
48553
  READ_ONLY_MISSION_SUBCOMMANDS = /* @__PURE__ */ new Set([
48127
48554
  "load-context",
48555
+ "objective-changes",
48128
48556
  "read-context",
48129
48557
  "attachment-list",
48130
48558
  "attachment-download-url"
48131
48559
  ]);
48560
+ RETIRED_RATIONALE_FLAGS = ["--change-rationales-json", "--change-rationales-file"];
48561
+ RETIRED_CHANGED_FILES_FLAGS = ["--changed-files-json", "--changed-files-file"];
48132
48562
  RETIRED_CHANGE_TRACKING_FLAGS = {
48133
- update: ["--track-changed-files", "--changed-files-json", "--changed-files-file"],
48563
+ update: ["--track-changed-files", ...RETIRED_CHANGED_FILES_FLAGS, ...RETIRED_RATIONALE_FLAGS],
48134
48564
  deliver: [
48135
- "--changed-files-json",
48136
- "--changed-files-file",
48565
+ ...RETIRED_CHANGED_FILES_FLAGS,
48566
+ ...RETIRED_RATIONALE_FLAGS,
48137
48567
  "--observed-dirty-paths-json",
48138
48568
  "--observed-dirty-paths-file",
48139
48569
  "--no-file-changes",
48140
48570
  "--skip-rationale-for-json",
48141
48571
  "--skip-rationale-for-file"
48142
- ]
48572
+ ],
48573
+ "record-work": [...RETIRED_CHANGED_FILES_FLAGS, ...RETIRED_RATIONALE_FLAGS]
48143
48574
  };
48144
- MAX_CHANGES_HEALTH_ENTRIES = 128;
48145
48575
  MAX_DECLARED_OUTPUT_PATHS = 512;
48146
48576
  MAX_RUNNER_FAILURE_MESSAGE_LENGTH = 1200;
48147
48577
  }
@@ -48378,7 +48808,7 @@ Missions:
48378
48808
  List one project's board columns (key, name, type,
48379
48809
  position, default/terminal). Statuses are defined
48380
48810
  per project, so they vary between projects.
48381
- ${primaryCommand} mission context|events|deliveries|artifacts|rationales <missionId> [--json]
48811
+ ${primaryCommand} mission context|events|deliveries|artifacts|file-changes <missionId> [--json]
48382
48812
  ${primaryCommand} requests [--mission-id <id>] [--objective-id <id>] [--json]
48383
48813
  List open and recent agent decisions
48384
48814
  ${primaryCommand} requests resolve <id> --revision <n> --decision allow|deny|ask [--text <text>]
@@ -48391,7 +48821,6 @@ Launch and runner:
48391
48821
 
48392
48822
  Changes:
48393
48823
  ${primaryCommand} changes status --mission-id <id> [--objective-id <id>] [--json]
48394
- ${primaryCommand} changes rationales --mission-id <id> [--objective-id <id>] [--json]
48395
48824
 
48396
48825
  Agents:
48397
48826
  Built-in agents (claude, codex, cursor, pi, antigravity, opencode) need an