@unbrained/pm-cli 2026.8.14 → 2026.8.16

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 (160) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +51 -11
  3. package/dist/cli/commander-usage.js +17 -4
  4. package/dist/cli/error-guidance.d.ts +7 -0
  5. package/dist/cli/error-guidance.js +65 -25
  6. package/dist/cli/main.js +3 -2
  7. package/dist/cli/register-history-author.js +16 -11
  8. package/dist/cli/register-mutation.js +4 -2
  9. package/dist/cli/register-operations.js +5 -5
  10. package/dist/cli-bundle/bundle-manifest.json +148 -148
  11. package/dist/cli-bundle/chunks/chunk-47OQEOQB.js +2 -0
  12. package/dist/cli-bundle/chunks/{chunk-XAVMOK6B.js → chunk-73UGEBRS.js} +2 -2
  13. package/dist/cli-bundle/chunks/chunk-HCIYWD6M.js +35 -0
  14. package/dist/cli-bundle/chunks/{chunk-FIW4P64F.js → chunk-I2LUWWR5.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-SBRKH6OR.js → chunk-IC5W2T34.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-TMJ7URWS.js → chunk-PANOOBIS.js} +9 -9
  17. package/dist/cli-bundle/chunks/{chunk-BFALV3YP.js → chunk-RIS565OA.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-TXMEUUUY.js → chunk-TK6N7HGM.js} +2 -2
  19. package/dist/cli-bundle/chunks/chunk-TOFG2URD.js +197 -0
  20. package/dist/cli-bundle/chunks/{chunk-G5JUB66K.js → chunk-URW4QRMI.js} +65 -59
  21. package/dist/cli-bundle/chunks/{register-list-query-T3EHHNNV.js → register-list-query-EYCXHZAG.js} +2 -2
  22. package/dist/cli-bundle/chunks/register-mutation-7YVIG54J.js +20 -0
  23. package/dist/cli-bundle/chunks/register-operations-KGDNRMCL.js +2 -0
  24. package/dist/cli-bundle/chunks/{register-setup-3YXZ444E.js → register-setup-NVXBOD5I.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-PPFGQDSI.js → chunk-4JPEBFFC.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-5NMFSX26.js +155 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-YOOI3UZX.js → chunk-6ROKKT4X.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-725JSCMP.js +2 -0
  29. package/dist/cli-bundle/focused-chunks/{chunk-XDNAW5OI.js → chunk-C7JUBRFP.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-4DQ2YERC.js → chunk-CODV5LUT.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-DQ6SMTBF.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-HAACPSUW.js +2 -0
  33. package/dist/cli-bundle/focused-chunks/{chunk-WCVE2NIG.js → chunk-J4UFYHOD.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/chunk-JX5Z344Q.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-L4RDYBIQ.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-KSEDUWVZ.js → chunk-NJ5RLEFD.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-K7RWWOAG.js → chunk-QYZERYR5.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-SSNDYZTM.js +8 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-T46KLOIB.js +50 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-KFSZ3BP6.js → chunk-TZATVC4G.js} +6 -6
  41. package/dist/cli-bundle/focused-chunks/chunk-WY3WRPVN.js +2 -0
  42. package/dist/cli-bundle/main.js +13 -13
  43. package/dist/cli-bundle/sdk-authoring.js +1 -1
  44. package/dist/cli-bundle/sdk-contracts.js +1 -1
  45. package/dist/cli-bundle/sdk-core.js +32 -35
  46. package/dist/cli-bundle/sdk-governance.js +1 -1
  47. package/dist/cli-bundle/sdk-graph.js +1 -1
  48. package/dist/cli-bundle/sdk-merge.js +32 -31
  49. package/dist/cli-bundle/sdk-query.js +1 -1
  50. package/dist/cli-bundle/sdk-runtime.js +1 -1
  51. package/dist/cli-bundle/sdk-testing.js +1 -1
  52. package/dist/cli-bundle/sdk.js +2 -2
  53. package/dist/core/diagnostics/remediation.js +7 -2
  54. package/dist/core/extensions/reserved-host-flags.js +3 -2
  55. package/dist/core/history/replay.d.ts +14 -1
  56. package/dist/core/history/replay.js +45 -8
  57. package/dist/core/history/workspace-history.js +32 -10
  58. package/dist/core/output/output.d.ts +2 -0
  59. package/dist/core/output/output.js +7 -3
  60. package/dist/core/shared/command-types.d.ts +2 -0
  61. package/dist/core/shared/command-types.js +2 -2
  62. package/dist/core/shared/errors.d.ts +14 -0
  63. package/dist/core/shared/errors.js +2 -2
  64. package/dist/core/store/item-store.js +28 -2
  65. package/dist/mcp/tool-definitions.js +9 -5
  66. package/dist/sdk/agent/refusal-reachability.d.ts +69 -0
  67. package/dist/sdk/agent/refusal-reachability.js +159 -3
  68. package/dist/sdk/author-attribution.d.ts +56 -11
  69. package/dist/sdk/author-attribution.js +174 -50
  70. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  71. package/dist/sdk/cli-bootstrap.js +7 -2
  72. package/dist/sdk/cli-contracts/completeness.js +3 -2
  73. package/dist/sdk/cli-contracts/flag-contracts.js +6 -2
  74. package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
  75. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +5 -0
  76. package/dist/sdk/cli-contracts/runtime-contracts.js +23 -7
  77. package/dist/sdk/cli-contracts/tool-parameter-tables.js +22 -5
  78. package/dist/sdk/cli-contracts/tool-schema.js +20 -5
  79. package/dist/sdk/cli-program.js +3 -2
  80. package/dist/sdk/completion.js +11 -4
  81. package/dist/sdk/core.d.ts +2 -2
  82. package/dist/sdk/core.js +3 -3
  83. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +50 -2
  84. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +74 -14
  85. package/dist/sdk/governance/assurance-action.d.ts +7 -1
  86. package/dist/sdk/governance/assurance-action.js +7 -6
  87. package/dist/sdk/governance/assurance-mutation-error.d.ts +42 -1
  88. package/dist/sdk/governance/assurance-mutation-error.js +27 -3
  89. package/dist/sdk/governance/assurance-runtime.js +12 -11
  90. package/dist/sdk/governance/assurance.d.ts +9 -0
  91. package/dist/sdk/governance/assurance.js +80 -14
  92. package/dist/sdk/governance/coverage-assurance.d.ts +24 -0
  93. package/dist/sdk/governance/coverage-assurance.js +61 -0
  94. package/dist/sdk/governance/extension-host-version.d.ts +25 -0
  95. package/dist/sdk/governance/extension-host-version.js +116 -0
  96. package/dist/sdk/governance/health.d.ts +32 -1
  97. package/dist/sdk/governance/health.js +119 -27
  98. package/dist/sdk/governance/provenance-health.d.ts +27 -0
  99. package/dist/sdk/governance/provenance-health.js +95 -3
  100. package/dist/sdk/governance/validate.js +7 -8
  101. package/dist/sdk/governance.d.ts +6 -0
  102. package/dist/sdk/governance.js +8 -2
  103. package/dist/sdk/history-repair.d.ts +13 -1
  104. package/dist/sdk/history-repair.js +62 -18
  105. package/dist/sdk/index.d.ts +2 -1
  106. package/dist/sdk/index.js +4 -3
  107. package/dist/sdk/linked-artifacts.js +16 -5
  108. package/dist/sdk/pagination.d.ts +15 -0
  109. package/dist/sdk/pagination.js +9 -5
  110. package/dist/sdk/query/context.d.ts +5 -1
  111. package/dist/sdk/query/context.js +14 -5
  112. package/dist/sdk/read-output/continuation.d.ts +11 -0
  113. package/dist/sdk/read-output/continuation.js +132 -0
  114. package/dist/sdk/read-output-budget.d.ts +1 -1
  115. package/dist/sdk/read-output-budget.js +14 -10
  116. package/dist/sdk/read-output-contracts.d.ts +66 -2
  117. package/dist/sdk/read-output-contracts.js +185 -19
  118. package/dist/sdk/read-output-rows.d.ts +2 -0
  119. package/dist/sdk/read-output-rows.js +15 -2
  120. package/dist/sdk/runtime-input.js +4 -2
  121. package/dist/sdk/runtime.d.ts +2 -5
  122. package/dist/sdk/runtime.js +3 -2
  123. package/docs/ASSURANCE.md +59 -2
  124. package/docs/COMMANDS.md +8 -2
  125. package/docs/READ_OUTPUT_CONTRACTS.md +55 -8
  126. package/docs/RELEASING.md +54 -11
  127. package/docs/SDK_CONTEXT_INTEGRITY.md +94 -4
  128. package/docs/SDK_CONTEXT_TRUTH_CONTRACTS.md +13 -5
  129. package/marketplace.json +2 -2
  130. package/package.json +3 -3
  131. package/packages/pm-beads/package.json +1 -1
  132. package/packages/pm-calendar/package.json +1 -1
  133. package/packages/pm-command-kit/package.json +1 -1
  134. package/packages/pm-digital-twin/package.json +1 -1
  135. package/packages/pm-governance-audit/package.json +1 -1
  136. package/packages/pm-guide-shell/package.json +1 -1
  137. package/packages/pm-kanban/package.json +1 -1
  138. package/packages/pm-lifecycle-hooks/package.json +1 -1
  139. package/packages/pm-linked-test-adapters/package.json +1 -1
  140. package/packages/pm-search-advanced/package.json +1 -1
  141. package/packages/pm-templates/package.json +1 -1
  142. package/packages/pm-todos/package.json +1 -1
  143. package/packages/pm-vcs/package.json +1 -1
  144. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  145. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  146. package/sdk/public-surface.json +1241 -180
  147. package/dist/cli-bundle/chunks/chunk-BBOFSVAK.js +0 -197
  148. package/dist/cli-bundle/chunks/chunk-YAMTJL6Y.js +0 -34
  149. package/dist/cli-bundle/chunks/chunk-YSVSMJ2B.js +0 -2
  150. package/dist/cli-bundle/chunks/register-mutation-E27WCLSZ.js +0 -20
  151. package/dist/cli-bundle/chunks/register-operations-4R6I7CPY.js +0 -2
  152. package/dist/cli-bundle/focused-chunks/chunk-F43TT2QQ.js +0 -8
  153. package/dist/cli-bundle/focused-chunks/chunk-KYUQGTSB.js +0 -2
  154. package/dist/cli-bundle/focused-chunks/chunk-LZ4MV3RH.js +0 -2
  155. package/dist/cli-bundle/focused-chunks/chunk-PGXJQLCT.js +0 -155
  156. package/dist/cli-bundle/focused-chunks/chunk-Q4YY3XNF.js +0 -2
  157. package/dist/cli-bundle/focused-chunks/chunk-QK753U3U.js +0 -46
  158. package/dist/cli-bundle/focused-chunks/chunk-QUMB2J27.js +0 -2
  159. package/dist/cli-bundle/focused-chunks/chunk-SM7MTG27.js +0 -2
  160. package/dist/cli-bundle/focused-chunks/chunk-ZM6TZVHC.js +0 -2
@@ -4,7 +4,7 @@
4
4
  * Implements append-only history and replay behavior for Replay.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a1283470-00c7-5e91-8676-e1c1a667537f")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0c37a722-fda7-523e-991c-f8abfb7a1495")}catch(e){}}();
8
8
  import jsonPatch from "fast-json-patch";
9
9
  import { ITEM_METADATA_KEY_ORDER } from "../shared/constants.js";
10
10
  import { canonicalDocument } from "../item/item-format.js";
@@ -219,8 +219,35 @@ export function lenientApplyReplayPatch(current, patch) {
219
219
  };
220
220
  return { document, convertedReplaceToAdd, skippedOps };
221
221
  }
222
+ /**
223
+ * Resolve the hash epoch a repair must retain.
224
+ *
225
+ * A valid stream is authoritative even when legacy entries omit the version
226
+ * field. For a broken stream, one consistent explicit epoch remains
227
+ * authoritative; fully implicit legacy streams stay on epoch 1. Only an
228
+ * irreconcilably mixed stream falls forward to the current epoch.
229
+ */
230
+ export function resolveHistoryRepairItemHashVersion(entries) {
231
+ const verified = verifyHistoryChainWithVersion(entries);
232
+ if (verified.ok && verified.item_hash_version !== undefined) {
233
+ return verified.item_hash_version;
234
+ }
235
+ const explicitVersions = [
236
+ ...new Set(entries
237
+ .map((entry) => entry.item_hash_version)
238
+ .filter((version) => version !== undefined &&
239
+ SUPPORTED_HISTORY_ITEM_HASH_VERSIONS.includes(version))),
240
+ ];
241
+ if (explicitVersions.length === 1) {
242
+ return explicitVersions[0];
243
+ }
244
+ if (explicitVersions.length === 0) {
245
+ return 1;
246
+ }
247
+ return CURRENT_HISTORY_ITEM_HASH_VERSION;
248
+ }
222
249
  /** Re-anchor a drifted history chain: replay every entry from empty, recompute the before/after hashes, and only rewrite a patch when the original op set no longer strictly applies (legacy drift). Clean entries keep their patch verbatim so the on-disk diff stays minimal. The returned chain verifies via verifyHistoryChain. */
223
- export function reanchorHistoryEntries(entries) {
250
+ export function reanchorHistoryEntries(entries, itemHashVersion = resolveHistoryRepairItemHashVersion(entries)) {
224
251
  const unsupportedIndex = entries.findIndex((entry) => entry.item_hash_version !== undefined &&
225
252
  !SUPPORTED_HISTORY_ITEM_HASH_VERSIONS.includes(entry.item_hash_version));
226
253
  if (unsupportedIndex >= 0) {
@@ -233,9 +260,11 @@ export function reanchorHistoryEntries(entries) {
233
260
  let entriesPatchRepaired = 0;
234
261
  let convertedReplaceToAdd = 0;
235
262
  let skippedOps = 0;
263
+ const explicitItemHashVersion = itemHashVersion !== 1 ||
264
+ entries.some((entry) => entry.item_hash_version !== undefined);
236
265
  for (let index = 0; index < entries.length; index += 1) {
237
266
  const entry = entries[index];
238
- const beforeHash = replayHash(replay, CURRENT_HISTORY_ITEM_HASH_VERSION);
267
+ const beforeHash = replayHash(replay, itemHashVersion);
239
268
  const strict = tryApplyReplayPatch(replay, entry.patch);
240
269
  let next;
241
270
  let outPatch;
@@ -257,18 +286,24 @@ export function reanchorHistoryEntries(entries) {
257
286
  skippedOps += entrySkipped;
258
287
  entriesPatchRepaired += 1;
259
288
  }
260
- const afterHash = replayHash(next, CURRENT_HISTORY_ITEM_HASH_VERSION);
289
+ const afterHash = replayHash(next, itemHashVersion);
261
290
  const rehashed = beforeHash !== entry.before_hash || afterHash !== entry.after_hash;
262
291
  if (rehashed) {
263
292
  entriesRehashed += 1;
264
293
  }
265
- rewritten.push({
294
+ const rewrittenEntry = {
266
295
  ...entry,
267
296
  patch: outPatch,
268
297
  before_hash: beforeHash,
269
298
  after_hash: afterHash,
270
- item_hash_version: CURRENT_HISTORY_ITEM_HASH_VERSION,
271
- });
299
+ };
300
+ if (explicitItemHashVersion) {
301
+ rewrittenEntry.item_hash_version = itemHashVersion;
302
+ }
303
+ else {
304
+ delete rewrittenEntry.item_hash_version;
305
+ }
306
+ rewritten.push(rewrittenEntry);
272
307
  details.push({
273
308
  index: index + 1,
274
309
  rehashed,
@@ -286,6 +321,8 @@ export function reanchorHistoryEntries(entries) {
286
321
  convertedReplaceToAdd,
287
322
  skippedOps,
288
323
  details,
324
+ itemHashVersion,
325
+ explicitItemHashVersion,
289
326
  };
290
327
  }
291
328
  /** Implements history entries to raw for the public runtime surface of this module. */
@@ -296,4 +333,4 @@ export function historyEntriesToRaw(entries) {
296
333
  return `${entries.map((entry) => JSON.stringify(entry)).join("\n")}\n`;
297
334
  }
298
335
  //# sourceMappingURL=replay.js.map
299
- //# debugId=a1283470-00c7-5e91-8676-e1c1a667537f
336
+ //# debugId=0c37a722-fda7-523e-991c-f8abfb7a1495
@@ -5,7 +5,7 @@
5
5
  * HistoryEntry format used by item mutations.
6
6
  */
7
7
 
8
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0f666995-78f8-5741-ae0c-0d792feea599")}catch(e){}}();
8
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="9027d972-ce29-5511-ba81-27e17d97446e")}catch(e){}}();
9
9
  import fs from "node:fs/promises";
10
10
  import path from "node:path";
11
11
  import { readFileIfExists, writeFileAtomic } from "../fs/fs-utils.js";
@@ -54,6 +54,28 @@ function workspaceDocuments(document) {
54
54
  ? document.metadata.documents
55
55
  : {};
56
56
  }
57
+ /** Refuse a workspace mutation or replay whose append-only chain is invalid. */
58
+ function throwWorkspaceHistoryVerificationFailure(errors) {
59
+ throw new PmCliError(`Workspace history verification failed: ${errors.join(", ")}`, EXIT_CODE.CONFLICT, {
60
+ code: "workspace_history_chain_invalid",
61
+ reason: "workspace_history_chain_verification_failed",
62
+ verification_errors: [...errors],
63
+ required: "Repair the _workspace history chain before reading, reconciling, restoring, or appending audited singleton state.",
64
+ why: "Continuing against an unverifiable append-only stream could hide or compound workspace state corruption.",
65
+ examples: [
66
+ "pm history _workspace --verify --json",
67
+ "pm validate --check-history-drift --fix-hints --json",
68
+ ],
69
+ nextSteps: [
70
+ "Inspect the exact verification_errors and preserve the corrupt stream as evidence.",
71
+ "Use the history-drift remediation returned by validate before retrying the refused operation.",
72
+ ],
73
+ recovery: {
74
+ recovery_mode: "compact",
75
+ next_best_command: "pm history _workspace --verify --json",
76
+ },
77
+ });
78
+ }
57
79
  /** Resolve a governed singleton path and reject paths outside the tracker root. */
58
80
  function resolveGovernedDocumentPath(pmRoot, filePath) {
59
81
  const absolutePath = path.resolve(filePath);
@@ -76,7 +98,7 @@ export async function inspectWorkspaceHistoryState(pmRoot) {
76
98
  const entries = await readHistoryEntries(getWorkspaceHistoryPath(pmRoot), WORKSPACE_HISTORY_ID);
77
99
  const verification = verifyHistoryChain(entries);
78
100
  if (!verification.ok) {
79
- throw new TypeError(`Workspace history verification failed: ${verification.errors.join(", ")}`);
101
+ throwWorkspaceHistoryVerificationFailure(verification.errors);
80
102
  }
81
103
  const documents = workspaceDocuments(entries.length === 0
82
104
  ? EMPTY_CANONICAL_DOCUMENT
@@ -123,7 +145,7 @@ async function appendWorkspaceHistoryChangeLocked(change) {
123
145
  const entries = await readHistoryEntries(historyPath, WORKSPACE_HISTORY_ID);
124
146
  const verification = verifyHistoryChain(entries);
125
147
  if (!verification.ok) {
126
- throw new TypeError(`Workspace history verification failed: ${verification.errors.join(", ")}`);
148
+ throwWorkspaceHistoryVerificationFailure(verification.errors);
127
149
  }
128
150
  const idempotentEntry = change.idempotencyKey === undefined
129
151
  ? undefined
@@ -194,7 +216,7 @@ export async function appendWorkspaceAuditEvent(options) {
194
216
  const entries = await readHistoryEntries(historyPath, WORKSPACE_HISTORY_ID);
195
217
  const verification = verifyHistoryChain(entries);
196
218
  if (!verification.ok) {
197
- throw new TypeError(`Workspace history verification failed: ${verification.errors.join(", ")}`);
219
+ throwWorkspaceHistoryVerificationFailure(verification.errors);
198
220
  }
199
221
  const beforeDocument = entries.length === 0
200
222
  ? EMPTY_CANONICAL_DOCUMENT
@@ -303,7 +325,7 @@ export async function reconcileWorkspaceJsonHistory(options) {
303
325
  const entries = await readHistoryEntries(historyPath, WORKSPACE_HISTORY_ID);
304
326
  const verification = verifyHistoryChain(entries);
305
327
  if (!verification.ok) {
306
- throw new TypeError(`Workspace history verification failed: ${verification.errors.join(", ")}`);
328
+ throwWorkspaceHistoryVerificationFailure(verification.errors);
307
329
  }
308
330
  const beforeDocument = replayWorkspaceEntries(entries);
309
331
  const priorDocuments = workspaceDocuments(beforeDocument);
@@ -349,15 +371,15 @@ export async function restoreWorkspaceJsonFromHistory(options) {
349
371
  try {
350
372
  const { documentPath, absolutePath } = resolveGovernedDocumentPath(options.pmRoot, options.filePath);
351
373
  const entries = await readHistoryEntries(getWorkspaceHistoryPath(options.pmRoot), WORKSPACE_HISTORY_ID);
374
+ const verification = verifyHistoryChain(entries);
375
+ if (!verification.ok) {
376
+ throwWorkspaceHistoryVerificationFailure(verification.errors);
377
+ }
352
378
  if (!Number.isInteger(options.targetVersion) ||
353
379
  options.targetVersion < 1 ||
354
380
  options.targetVersion > entries.length) {
355
381
  throw new TypeError(`Invalid workspace history target version: ${String(options.targetVersion)}`);
356
382
  }
357
- const verification = verifyHistoryChain(entries);
358
- if (!verification.ok) {
359
- throw new TypeError(`Workspace history verification failed: ${verification.errors.join(", ")}`);
360
- }
361
383
  const target = workspaceDocuments(replayWorkspaceEntries(entries, options.targetVersion))[documentPath];
362
384
  if (target === undefined) {
363
385
  throw new TypeError(`Workspace history version ${options.targetVersion} does not contain ${documentPath}`);
@@ -408,4 +430,4 @@ export async function restoreWorkspaceJsonFromHistory(options) {
408
430
  }
409
431
  }
410
432
  //# sourceMappingURL=workspace-history.js.map
411
- //# debugId=0f666995-78f8-5741-ae0c-0d792feea599
433
+ //# debugId=9027d972-ce29-5511-ba81-27e17d97446e
@@ -24,6 +24,8 @@ export interface OutputOptions {
24
24
  outputFormat?: "toon" | "json";
25
25
  /** Caller-carried cross-call budget and served-item state. */
26
26
  outputSession?: string;
27
+ /** Opaque budget-compaction continuation cursor. */
28
+ outputCursor?: string;
27
29
  /** Include machine-readable row location and row-encoding metadata. */
28
30
  outputRowContract?: boolean;
29
31
  /** Fallback output format used when callers do not provide an override. */
@@ -4,14 +4,14 @@
4
4
  * Formats compact human and machine output for Output.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="88eb8f29-72a2-536f-8fc9-394ed3e0e0fb")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="202cbb3e-71fe-5701-a1f5-eb515bf56561")}catch(e){}}();
8
8
  import { getActiveCommandContext, runActiveCommandOverride, runActiveRendererOverride, runActiveServiceOverrideSync, setActiveCommandResult, } from "../extensions/index.js";
9
9
  import { EXIT_CODE } from "../shared/constants.js";
10
10
  import { isHostOutputSuppressed } from "./output-control.js";
11
11
  import { projectMutationResult } from "./mutation-projection.js";
12
12
  import { attachReadOutputContracts } from "../../sdk/context-intent-contracts.js";
13
13
  import { attachOutputTokenAccounting } from "../../sdk/output-token-accounting.js";
14
- import { resolveReadOutputEncoding } from "../../sdk/read-output-contracts.js";
14
+ import { isReadOutputBudgetExceeded, resolveReadOutputEncoding, } from "../../sdk/read-output-contracts.js";
15
15
  import { encode as encodeToon } from "@toon-format/toon";
16
16
  const DECLARED_PROCESS_EXIT_CODES = new Set(Object.values(EXIT_CODE));
17
17
  const NATIVE_OUTPUT_MARKER = "__pm_native_output";
@@ -366,6 +366,7 @@ function formatEffectiveOutput(effectiveResult, nativeOutput, options) {
366
366
  ["outputBudget", options.outputBudget],
367
367
  ["outputFormat", options.outputFormat],
368
368
  ["outputSession", options.outputSession],
369
+ ["outputCursor", options.outputCursor],
369
370
  ["outputRowContract", options.outputRowContract],
370
371
  ].filter((entry) => entry[1] !== undefined)),
371
372
  };
@@ -388,6 +389,9 @@ function formatEffectiveOutput(effectiveResult, nativeOutput, options) {
388
389
  ? projectLinkedTestEvidence(outputResult, options.lean === true)
389
390
  : outputResult;
390
391
  const intentOutputResult = attachReadOutputContracts(command, resolvedCommandOptions, projectedOutputResult);
392
+ if (isReadOutputBudgetExceeded(intentOutputResult)) {
393
+ process.exitCode ||= EXIT_CODE.USAGE;
394
+ }
391
395
  const renderResolvedOutput = (value) => {
392
396
  if (format === "toon") {
393
397
  const markdownDefault = renderDefaultMarkdownResult(value);
@@ -464,4 +468,4 @@ export const outputTestOnly = {
464
468
  renderToonValue,
465
469
  };
466
470
  //# sourceMappingURL=output.js.map
467
- //# debugId=88eb8f29-72a2-536f-8fc9-394ed3e0e0fb
471
+ //# debugId=202cbb3e-71fe-5701-a1f5-eb515bf56561
@@ -29,6 +29,8 @@ export interface GlobalOptions {
29
29
  outputFormat?: "toon" | "json";
30
30
  /** Caller-carried cross-call budget and served-item state. */
31
31
  outputSession?: string;
32
+ /** Opaque budget-compaction continuation cursor. */
33
+ outputCursor?: string;
32
34
  /** Include the machine-readable row selector and TOON encoding contract. */
33
35
  outputRowContract?: boolean;
34
36
  /** Filesystem path used for path resolution. */
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="044af354-3047-5fd4-ae65-458a259dedca")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="525dce5a-3824-5c45-aa61-bd8b132bd973")}catch(e){}}();
3
3
  export {};
4
4
  //# sourceMappingURL=command-types.js.map
5
- //# debugId=044af354-3047-5fd4-ae65-458a259dedca
5
+ //# debugId=525dce5a-3824-5c45-aa61-bd8b132bd973
@@ -32,6 +32,8 @@ export interface PmCliErrorRecoveryPayload {
32
32
  candidate_commands_total?: number;
33
33
  /** Whether additional accepting command paths were omitted from this payload. */
34
34
  candidate_commands_truncated?: boolean;
35
+ /** Declared lexicon membership of an option rejected by the attempted path. */
36
+ option_scope?: "declared_on_path" | "declared_elsewhere" | "declared_nowhere";
35
37
  /** Value that configures or reports suggested retry for this contract. */
36
38
  suggested_retry?: string;
37
39
  /** Elapsed time in milliseconds for retry after. */
@@ -53,6 +55,16 @@ export interface PmCliErrorContext {
53
55
  reason?: string;
54
56
  /** Metadata field responsible for a validation failure, when known. */
55
57
  field?: string;
58
+ /** Assurance gate whose evaluation was refused, when known. */
59
+ gate_id?: string;
60
+ /** Assurance assertion whose evaluation was refused, when known. */
61
+ assertion_id?: string;
62
+ /** Assurance measurement whose source could not resolve, when known. */
63
+ measurement_id?: string;
64
+ /** Assurance measurement source kind involved in a refusal, when known. */
65
+ source_kind?: string;
66
+ /** Validate or health check selected by an assurance source, when known. */
67
+ check?: string;
56
68
  /** Serialization format involved in a parse failure. */
57
69
  format?: string;
58
70
  /** Item format version involved in a compatibility failure. */
@@ -75,6 +87,8 @@ export interface PmCliErrorContext {
75
87
  nextSteps?: string[];
76
88
  /** Exact selectors that could not be matched by a lossless removal. */
77
89
  unmatched?: string[];
90
+ /** Exact verifier findings that caused an integrity-sensitive operation to refuse. */
91
+ verification_errors?: string[];
78
92
  /** Local dependency targets that could not be resolved before mutation. */
79
93
  unresolved_targets?: string[];
80
94
  /** Available history bounds for a failed point-in-time read or restore target. */
@@ -1,6 +1,6 @@
1
1
  /** Implements the exported pm cli error runtime abstraction for core/shared/errors.ts. */
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="62fb0ba7-643f-5b33-870b-df875559610a")}catch(e){}}();
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="bf08255e-7ef4-5929-8431-2df83d98d0ba")}catch(e){}}();
4
4
  export class PmCliError extends Error {
5
5
  /** Value that configures or reports exit code for this contract. */
6
6
  exitCode;
@@ -18,4 +18,4 @@ export class PmCliError extends Error {
18
18
  }
19
19
  }
20
20
  //# sourceMappingURL=errors.js.map
21
- //# debugId=62fb0ba7-643f-5b33-870b-df875559610a
21
+ //# debugId=bf08255e-7ef4-5929-8431-2df83d98d0ba
@@ -4,7 +4,7 @@
4
4
  * Reads and writes tracker storage with format-aware helpers for Item Store.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f43e1170-e797-5a0c-b02e-d31e002ab275")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d24d61bf-7db8-5f35-8dbc-5ef93ec8220b")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import { getActiveExtensionRegistrations, projectAfterCommandItemSnapshot, recordAfterCommandAffectedItem, runActiveOnReadHooks, runActiveBeforeMutationHooks, runActiveOnWriteHooks, runActiveServiceOverride, } from "../extensions/index.js";
@@ -69,6 +69,15 @@ function trackerRootNotDirectoryError(pmRoot) {
69
69
  ],
70
70
  });
71
71
  }
72
+ function trackerRootUnreadableError(pmRoot) {
73
+ return new PmCliError(`Tracker root is not readable at ${pmRoot}.`, EXIT_CODE.GENERIC_FAILURE, {
74
+ code: "tracker_root_unreadable",
75
+ reason: "unreadable",
76
+ nextSteps: [
77
+ "Grant read and directory-search permission to the tracker root, then retry the SDK read.",
78
+ ],
79
+ });
80
+ }
72
81
  async function assertMissingMetadataRootAncestors(pmRoot) {
73
82
  const filesystemRoot = path.parse(path.resolve(pmRoot)).root;
74
83
  let ancestor = path.dirname(path.resolve(pmRoot));
@@ -114,11 +123,28 @@ async function assertItemMetadataRoot(pmRoot) {
114
123
  if (isErrno(error, "ENOTDIR")) {
115
124
  throw trackerRootNotDirectoryError(pmRoot);
116
125
  }
126
+ if (isErrno(error, "EACCES") || isErrno(error, "EPERM")) {
127
+ throw trackerRootUnreadableError(pmRoot);
128
+ }
117
129
  throw error;
118
130
  }
119
131
  if (!stats.isDirectory()) {
120
132
  throw trackerRootNotDirectoryError(pmRoot);
121
133
  }
134
+ if (process.platform !== "win32" &&
135
+ ((stats.mode & 0o444) === 0 || (stats.mode & 0o111) === 0)) {
136
+ throw trackerRootUnreadableError(pmRoot);
137
+ }
138
+ try {
139
+ const directory = await fs.opendir(pmRoot);
140
+ await directory.close();
141
+ }
142
+ catch (error) {
143
+ if (isErrno(error, "EACCES") || isErrno(error, "EPERM")) {
144
+ throw trackerRootUnreadableError(pmRoot);
145
+ }
146
+ throw error;
147
+ }
122
148
  }
123
149
  /** Implements locate item for the public runtime surface of this module. */
124
150
  export async function locateItem(pmRoot, rawId, idPrefix = "pm-", preferredFormat, typeToFolder = TYPE_TO_FOLDER) {
@@ -684,4 +710,4 @@ export async function deleteItem(params) {
684
710
  }
685
711
  }
686
712
  //# sourceMappingURL=item-store.js.map
687
- //# debugId=f43e1170-e797-5a0c-b02e-d31e002ab275
713
+ //# debugId=d24d61bf-7db8-5f35-8dbc-5ef93ec8220b
@@ -4,7 +4,7 @@
4
4
  * Defines the Tool Definitions module for pm CLI source.
5
5
  */
6
6
 
7
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cde81c26-97fa-5236-b807-e944ba4af321")}catch(e){}}();
7
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d440a41a-ae54-55fd-b939-5404a1edcdd7")}catch(e){}}();
8
8
  import { GRAPH_SUBCOMMAND_VALUES, PM_TOOL_ACTIONS, } from "../sdk/cli-contracts/enum-contracts.js";
9
9
  import { buildPmActionToolInputSchema } from "../sdk/cli-contracts/tool-schema.js";
10
10
  import { RUNTIME_STATUS_ROLE_VALUES } from "../types.js";
@@ -20,9 +20,8 @@ const READ_OUTPUT_TOOL_PROPERTIES = {
20
20
  description: "Universal read row ceiling, or unbounded to disable the shared ceiling.",
21
21
  },
22
22
  outputBudget: {
23
- type: "integer",
24
- minimum: 1,
25
- description: "Universal estimated-token ceiling for a read result.",
23
+ anyOf: [{ type: "integer", minimum: 1 }, { const: "unbounded" }],
24
+ description: "Universal estimated-token ceiling, or unbounded to return the complete read result.",
26
25
  },
27
26
  outputFormat: {
28
27
  type: "string",
@@ -32,6 +31,11 @@ const READ_OUTPUT_TOOL_PROPERTIES = {
32
31
  outputSession: {
33
32
  ...CANONICAL_OUTPUT_SESSION_TOOL_PROPERTY,
34
33
  },
34
+ outputCursor: {
35
+ type: "string",
36
+ minLength: 1,
37
+ description: "Opaque continuation cursor returned after budget compaction of a declared row collection.",
38
+ },
35
39
  };
36
40
  /** MCP transport parameters layered over every canonical action schema. */
37
41
  export const TOOL_SCHEMA_BASE = {
@@ -739,4 +743,4 @@ export function buildMcpToolContracts() {
739
743
  }).sort((left, right) => left.name.localeCompare(right.name));
740
744
  }
741
745
  //# sourceMappingURL=tool-definitions.js.map
742
- //# debugId=cde81c26-97fa-5236-b807-e944ba4af321
746
+ //# debugId=d440a41a-ae54-55fd-b939-5404a1edcdd7
@@ -36,5 +36,74 @@ export interface PmRefusalReachabilityReport {
36
36
  /** Stable, sorted conformance findings. */
37
37
  findings: PmRefusalReachabilityFinding[];
38
38
  }
39
+ /** Recovery-reference kinds emitted by structured refusal envelopes. */
40
+ export declare const PM_RECOVERY_REFERENCE_KINDS: readonly ["suggested_retry", "candidate_command", "example", "next_step", "migration_hint", "restore_with"];
41
+ /** Recovery-reference kind emitted by a refusal. */
42
+ export type PmRecoveryReferenceKind = (typeof PM_RECOVERY_REFERENCE_KINDS)[number];
43
+ /** Behavioral promise attached to a recovery reference. */
44
+ export type PmRecoveryReferenceSemantics = "recovery" | "replacement" | "behavior_preserving";
45
+ /** One derived promise that another invocation or command path is reachable. */
46
+ export interface PmRecoveryReferenceObligation {
47
+ /** Stable reference identifier derived from its emitting envelope. */
48
+ id: string;
49
+ /** Refusal probe that emitted the reference. */
50
+ probe_id: string;
51
+ /** Typed recovery vocabulary rather than prose inference. */
52
+ kind: PmRecoveryReferenceKind;
53
+ /** Whether the reference recovers, replaces, or preserves the original behavior. */
54
+ semantics: PmRecoveryReferenceSemantics;
55
+ /** Exact emitted command or recovery text. */
56
+ value: string;
57
+ }
58
+ /** Result of executing or resolving one derived recovery obligation. */
59
+ export interface PmRecoveryReferenceObservation {
60
+ /** Stable obligation identifier. */
61
+ id: string;
62
+ /** Whether the promised recovery or command path was reachable. */
63
+ reachable: boolean;
64
+ /** How the promise was discharged. */
65
+ proof: "executed" | "declared_command_path" | "linked_execution";
66
+ /** Semantics actually demonstrated by the proof. */
67
+ semantics: PmRecoveryReferenceSemantics;
68
+ }
69
+ /** Coverage totals for one emitted recovery-reference kind. */
70
+ export interface PmRecoveryReferenceKindCoverage {
71
+ /** Typed reference kind. */
72
+ kind: PmRecoveryReferenceKind;
73
+ /** Derived obligations of this kind. */
74
+ declared: number;
75
+ /** Obligations with one observation. */
76
+ observed: number;
77
+ /** Obligations proven reachable. */
78
+ passed: number;
79
+ }
80
+ /** One recovery-reference coverage failure. */
81
+ export interface PmRecoveryReferenceFinding {
82
+ /** Stable finding kind for assurance and CI. */
83
+ kind: "duplicate_obligation" | "duplicate_observation" | "missing_observation" | "unreachable_reference" | "wrong_semantics" | "undeclared_observation";
84
+ /** Obligation or observation identifier. */
85
+ reference_id: string;
86
+ /** Human-readable mismatch summary. */
87
+ detail: string;
88
+ }
89
+ /** Complete cross-kind recovery-reference coverage receipt. */
90
+ export interface PmRecoveryReferenceReport {
91
+ /** Whether every derived reference was uniquely proven reachable. */
92
+ ok: boolean;
93
+ /** Total references derived from real refusal envelopes. */
94
+ declared_reference_count: number;
95
+ /** Total reference observations supplied. */
96
+ observed_reference_count: number;
97
+ /** Reachable fraction across the declared obligation set. */
98
+ pass_fraction: number;
99
+ /** Stable coverage buckets, including zero-population kinds. */
100
+ coverage_by_kind: PmRecoveryReferenceKindCoverage[];
101
+ /** Stable, sorted conformance findings. */
102
+ findings: PmRecoveryReferenceFinding[];
103
+ }
104
+ /** Derive typed obligations from every recognized recovery field in an emitted envelope. */
105
+ export declare function derivePmRecoveryReferenceObligations(probeId: string, envelope: unknown): PmRecoveryReferenceObligation[];
39
106
  /** Compare declared refusal states with real-entrypoint observations. */
40
107
  export declare function verifyPmRefusalReachability(catalog: readonly PmErrorCodeContract[], observations: readonly PmRefusalProbeObservation[]): PmRefusalReachabilityReport;
108
+ /** Verify executable and declared-path proof for emitted recovery references. */
109
+ export declare function verifyPmRecoveryReferences(obligations: readonly PmRecoveryReferenceObligation[], observations: readonly PmRecoveryReferenceObservation[]): PmRecoveryReferenceReport;