@unbrained/pm-cli 2026.8.11 → 2026.8.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +74 -21
  3. package/dist/cli/commander-usage.js +37 -11
  4. package/dist/cli/error-guidance.d.ts +2 -0
  5. package/dist/cli/error-guidance.js +82 -19
  6. package/dist/cli/main.js +35 -19
  7. package/dist/cli/register-annotations.js +56 -3
  8. package/dist/cli/register-assurance.js +28 -17
  9. package/dist/cli/register-list-query.js +10 -7
  10. package/dist/cli/register-operations.js +16 -6
  11. package/dist/cli-bundle/bundle-manifest.json +163 -163
  12. package/dist/cli-bundle/chunks/chunk-3ZMOWAFM.js +2 -0
  13. package/dist/cli-bundle/chunks/chunk-DEDU3DG7.js +196 -0
  14. package/dist/cli-bundle/chunks/chunk-DL5M5J3V.js +13 -0
  15. package/dist/cli-bundle/chunks/chunk-F7FJYGK3.js +8 -0
  16. package/dist/cli-bundle/chunks/chunk-HIUZVCMN.js +5 -0
  17. package/dist/cli-bundle/chunks/chunk-IMGIN7R6.js +2 -0
  18. package/dist/cli-bundle/chunks/{chunk-A2SJGHSI.js → chunk-Q47C67TQ.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-WMEZHCFI.js → chunk-QGTUPEU5.js} +62 -54
  20. package/dist/cli-bundle/chunks/chunk-TF3TPKPR.js +34 -0
  21. package/dist/cli-bundle/chunks/{chunk-ZU34C3LH.js → chunk-YLBAPY22.js} +50 -50
  22. package/dist/cli-bundle/chunks/register-list-query-4HIZ7EA3.js +10 -0
  23. package/dist/cli-bundle/chunks/register-mutation-W64FZ5HN.js +20 -0
  24. package/dist/cli-bundle/chunks/register-operations-C44ET7R5.js +2 -0
  25. package/dist/cli-bundle/chunks/{register-setup-NOCOOWQY.js → register-setup-634MFRXU.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-27N23W6M.js +31 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-4H5IA6AV.js → chunk-2JP7W7GO.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-2RI2FESN.js +4 -0
  29. package/dist/cli-bundle/focused-chunks/chunk-3BNVU6LC.js +8 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-2DL3MRTD.js → chunk-3DJSGWVB.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-6MLIRBLV.js +5 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-6XYLENDV.js +155 -0
  33. package/dist/cli-bundle/focused-chunks/chunk-CP4K4WFS.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/{chunk-TL5M2PAY.js → chunk-E3AVJ655.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/chunk-EBTNSFYE.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-J5EKAIVD.js → chunk-HC2OL2H2.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-BKPIY34S.js → chunk-I75MANL7.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-IIS2FRKL.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-NFHFZH2Z.js +2 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-OGC4XSBC.js +17 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-UDAZWT25.js → chunk-OOYYKQWX.js} +4 -4
  42. package/dist/cli-bundle/focused-chunks/{chunk-23FTGO3W.js → chunk-PKPOZXLL.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/chunk-QDZUABWL.js +2 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-QQX5TDFT.js +16 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-55BIB6DV.js → chunk-TEZIXMTH.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/chunk-WEH6NSL6.js +18 -0
  47. package/dist/cli-bundle/main.js +13 -13
  48. package/dist/cli-bundle/sdk-authoring.js +1 -1
  49. package/dist/cli-bundle/sdk-contracts.js +1 -1
  50. package/dist/cli-bundle/sdk-core.js +42 -41
  51. package/dist/cli-bundle/sdk-governance.js +1 -1
  52. package/dist/cli-bundle/sdk-graph.js +1 -1
  53. package/dist/cli-bundle/sdk-merge.js +1 -1
  54. package/dist/cli-bundle/sdk-query.js +1 -1
  55. package/dist/cli-bundle/sdk-runtime.js +1 -1
  56. package/dist/cli-bundle/sdk-testing.js +1 -1
  57. package/dist/cli-bundle/sdk.js +2 -2
  58. package/dist/core/checkpoint/checkpoint-gc.js +7 -12
  59. package/dist/core/extensions/activation-summary-markdown.js +5 -4
  60. package/dist/core/extensions/activation-summary.d.ts +2 -0
  61. package/dist/core/extensions/activation-summary.js +6 -2
  62. package/dist/core/extensions/capability-usage.d.ts +1 -1
  63. package/dist/core/extensions/capability-usage.js +4 -3
  64. package/dist/core/extensions/contribution-inventory.d.ts +1 -0
  65. package/dist/core/extensions/contribution-inventory.js +6 -2
  66. package/dist/core/extensions/extension-registries.js +3 -2
  67. package/dist/core/extensions/extension-types.d.ts +83 -1
  68. package/dist/core/extensions/extension-types.js +3 -2
  69. package/dist/core/extensions/loader.d.ts +2 -8
  70. package/dist/core/extensions/loader.js +53 -144
  71. package/dist/core/extensions/registration-values.d.ts +43 -0
  72. package/dist/core/extensions/registration-values.js +210 -0
  73. package/dist/core/extensions/reserved-host-flags.js +3 -2
  74. package/dist/core/extensions/runtime-registrations.d.ts +3 -1
  75. package/dist/core/extensions/runtime-registrations.js +12 -2
  76. package/dist/core/fs/fs-utils.d.ts +2 -0
  77. package/dist/core/fs/fs-utils.js +7 -3
  78. package/dist/core/history/drift-cache.js +4 -3
  79. package/dist/core/history/drift-scan.js +16 -17
  80. package/dist/core/history/history.d.ts +8 -0
  81. package/dist/core/history/history.js +57 -7
  82. package/dist/core/history/replay.d.ts +9 -1
  83. package/dist/core/history/replay.js +48 -13
  84. package/dist/core/lock/lock-gc.js +8 -13
  85. package/dist/core/lock/lock.js +5 -4
  86. package/dist/core/output/output.d.ts +2 -0
  87. package/dist/core/output/output.js +46 -14
  88. package/dist/core/search/vector-stores.js +6 -11
  89. package/dist/core/shared/command-types.d.ts +2 -0
  90. package/dist/core/shared/command-types.js +2 -2
  91. package/dist/core/shared/errors.d.ts +5 -0
  92. package/dist/core/shared/errors.js +2 -2
  93. package/dist/core/store/item-metadata-cache.d.ts +1 -1
  94. package/dist/core/store/item-metadata-cache.js +16 -9
  95. package/dist/core/telemetry/runtime.d.ts +6 -0
  96. package/dist/core/telemetry/runtime.js +101 -30
  97. package/dist/sdk/agent/command-recovery.d.ts +2 -0
  98. package/dist/sdk/agent/command-recovery.js +10 -2
  99. package/dist/sdk/annotations.js +4 -4
  100. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  101. package/dist/sdk/cli-bootstrap.js +6 -2
  102. package/dist/sdk/cli-contracts/completeness.js +10 -3
  103. package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
  104. package/dist/sdk/cli-contracts/flag-contracts.js +9 -3
  105. package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
  106. package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
  107. package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +40 -6
  108. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +27 -3
  109. package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
  110. package/dist/sdk/cli-contracts/tool-parameter-tables.js +55 -5
  111. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  112. package/dist/sdk/cli-contracts/tool-schema.js +22 -4
  113. package/dist/sdk/cli-program.js +3 -2
  114. package/dist/sdk/comments.js +4 -3
  115. package/dist/sdk/compile-cache.js +4 -3
  116. package/dist/sdk/completion.js +16 -7
  117. package/dist/sdk/compose.d.ts +3 -1
  118. package/dist/sdk/compose.js +16 -2
  119. package/dist/sdk/context-intent-contracts.js +45 -4
  120. package/dist/sdk/context-signal-store.js +4 -3
  121. package/dist/sdk/core.d.ts +1 -0
  122. package/dist/sdk/core.js +3 -2
  123. package/dist/sdk/extension/install-runtime.js +4 -4
  124. package/dist/sdk/extension/managed-state.js +4 -3
  125. package/dist/sdk/extension-contracts.d.ts +1 -1
  126. package/dist/sdk/flag-invocation-contracts.js +5 -6
  127. package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
  128. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1597 -0
  129. package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
  130. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
  131. package/dist/sdk/generated-error-code-catalog.js +6 -3140
  132. package/dist/sdk/governance/assurance-action.d.ts +27 -3
  133. package/dist/sdk/governance/assurance-action.js +117 -31
  134. package/dist/sdk/governance/assurance-mutation-error.d.ts +14 -0
  135. package/dist/sdk/governance/assurance-mutation-error.js +58 -0
  136. package/dist/sdk/governance/assurance-presets.d.ts +54 -0
  137. package/dist/sdk/governance/assurance-presets.js +136 -0
  138. package/dist/sdk/governance/assurance-runtime.d.ts +4 -0
  139. package/dist/sdk/governance/assurance-runtime.js +118 -14
  140. package/dist/sdk/governance/assurance.d.ts +51 -6
  141. package/dist/sdk/governance/assurance.js +321 -67
  142. package/dist/sdk/governance/gc.js +5 -11
  143. package/dist/sdk/governance/health.d.ts +3 -1
  144. package/dist/sdk/governance/health.js +24 -7
  145. package/dist/sdk/governance/validate-item-reader.js +3 -3
  146. package/dist/sdk/governance/validate.d.ts +2 -0
  147. package/dist/sdk/governance/validate.js +15 -5
  148. package/dist/sdk/graph/durable-cache.d.ts +1 -1
  149. package/dist/sdk/graph/durable-cache.js +156 -29
  150. package/dist/sdk/graph/governance-contracts.d.ts +12 -0
  151. package/dist/sdk/graph/governance-contracts.js +27 -0
  152. package/dist/sdk/graph/governance.d.ts +44 -2
  153. package/dist/sdk/graph/governance.js +156 -12
  154. package/dist/sdk/guide.js +4 -4
  155. package/dist/sdk/index.d.ts +3 -2
  156. package/dist/sdk/index.js +5 -4
  157. package/dist/sdk/lifecycle/claim.js +10 -3
  158. package/dist/sdk/linked-artifacts.d.ts +2 -0
  159. package/dist/sdk/linked-artifacts.js +29 -4
  160. package/dist/sdk/merge/driver.d.ts +2 -2
  161. package/dist/sdk/merge/driver.js +3 -3
  162. package/dist/sdk/merge/install.js +5 -4
  163. package/dist/sdk/merge/receipts.d.ts +6 -4
  164. package/dist/sdk/merge/receipts.js +7 -5
  165. package/dist/sdk/merge/three-way.d.ts +2 -2
  166. package/dist/sdk/merge/three-way.js +3 -3
  167. package/dist/sdk/output-projection.d.ts +9 -1
  168. package/dist/sdk/output-projection.js +45 -9
  169. package/dist/sdk/query/activity.d.ts +49 -2
  170. package/dist/sdk/query/activity.js +185 -38
  171. package/dist/sdk/query/get.js +19 -2
  172. package/dist/sdk/read-output-contracts.d.ts +5 -1
  173. package/dist/sdk/read-output-contracts.js +17 -2
  174. package/dist/sdk/read-output-session.d.ts +2 -0
  175. package/dist/sdk/read-output-session.js +12 -5
  176. package/dist/sdk/relationship-history.js +5 -5
  177. package/dist/sdk/runtime-primitives.d.ts +3 -3
  178. package/dist/sdk/runtime-primitives.js +5 -5
  179. package/dist/sdk/runtime-stats-options.js +3 -2
  180. package/dist/sdk/runtime.js +5 -9
  181. package/dist/sdk/schema-migration.js +4 -4
  182. package/dist/sdk/stats.d.ts +36 -3
  183. package/dist/sdk/stats.js +55 -15
  184. package/dist/sdk/test/execution.d.ts +4 -0
  185. package/dist/sdk/test/execution.js +88 -23
  186. package/dist/sdk/workspace-memory.js +4 -4
  187. package/dist/sdk/workspace-snapshot.js +8 -14
  188. package/dist/sdk/workspace-transaction-gc.js +4 -9
  189. package/dist/sdk/workspace-transaction.js +4 -4
  190. package/dist/sdk/workspace.js +4 -3
  191. package/dist/types.d.ts +2 -0
  192. package/dist/types.js +2 -2
  193. package/docs/ASSURANCE.md +170 -14
  194. package/docs/COMMANDS.md +29 -8
  195. package/docs/CONFIGURATION.md +9 -0
  196. package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
  197. package/docs/EXTENSIONS.md +11 -12
  198. package/docs/MERGE_SAFETY.md +3 -1
  199. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
  200. package/docs/README.md +2 -0
  201. package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
  202. package/docs/RELATIONSHIP_GRAPH.md +15 -0
  203. package/docs/SDK.md +17 -3
  204. package/docs/SDK_AGENT_SESSION_CONTEXT.md +12 -1
  205. package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
  206. package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
  207. package/docs/TESTING.md +24 -15
  208. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
  209. package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
  210. package/marketplace.json +2 -2
  211. package/package.json +6 -6
  212. package/packages/pm-beads/package.json +1 -1
  213. package/packages/pm-calendar/package.json +1 -1
  214. package/packages/pm-command-kit/package.json +1 -1
  215. package/packages/pm-digital-twin/package.json +1 -1
  216. package/packages/pm-governance-audit/package.json +1 -1
  217. package/packages/pm-guide-shell/package.json +1 -1
  218. package/packages/pm-kanban/package.json +1 -1
  219. package/packages/pm-lifecycle-hooks/package.json +1 -1
  220. package/packages/pm-linked-test-adapters/package.json +1 -1
  221. package/packages/pm-search-advanced/package.json +1 -1
  222. package/packages/pm-templates/package.json +1 -1
  223. package/packages/pm-todos/package.json +1 -1
  224. package/packages/pm-vcs/package.json +1 -1
  225. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  226. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  227. package/sdk/public-surface.json +384 -83
  228. package/dist/cli-bundle/chunks/chunk-2OOU2AFH.js +0 -8
  229. package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +0 -33
  230. package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +0 -13
  231. package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +0 -194
  232. package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +0 -2
  233. package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +0 -2
  234. package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +0 -5
  235. package/dist/cli-bundle/chunks/register-list-query-HAUXVUPY.js +0 -10
  236. package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +0 -20
  237. package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +0 -2
  239. package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +0 -2
  240. package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +0 -16
  241. package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +0 -8
  242. package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +0 -2
  243. package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +0 -31
  244. package/dist/cli-bundle/focused-chunks/chunk-E3KCL7AY.js +0 -5
  245. package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +0 -153
  246. package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +0 -2
  247. package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +0 -18
  248. package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +0 -4
  249. package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +0 -2
  250. package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +0 -17
@@ -4,13 +4,13 @@
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]="c8668470-7e57-5dee-8e41-298e7c697b77")}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]="a1283470-00c7-5e91-8676-e1c1a667537f")}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";
11
11
  import { toItemRecord } from "../item/item-record.js";
12
12
  import { orderObject, sha256Hex, stableStringify, } from "../shared/serialization.js";
13
- import { hashDocument } from "./history.js";
13
+ import { CURRENT_HISTORY_ITEM_HASH_VERSION, SUPPORTED_HISTORY_ITEM_HASH_VERSIONS, hashDocumentForVersion, } from "./history.js";
14
14
  /** Public contract for empty replay document, shared by SDK and presentation-layer consumers. */
15
15
  export const EMPTY_REPLAY_DOCUMENT = {
16
16
  metadata: {},
@@ -21,11 +21,11 @@ export function cloneEmptyReplayDocument() {
21
21
  return structuredClone(EMPTY_REPLAY_DOCUMENT);
22
22
  }
23
23
  /** Implements replay hash for the public runtime surface of this module. */
24
- export function replayHash(document) {
24
+ export function replayHash(document, version = CURRENT_HISTORY_ITEM_HASH_VERSION) {
25
25
  if (Object.keys(document.metadata).length === 0 ||
26
26
  Array.isArray(document.metadata.tags)) {
27
27
  try {
28
- return hashDocument(replayToItemDocument(document));
28
+ return hashDocumentForVersion(replayToItemDocument(document), version);
29
29
  }
30
30
  catch {
31
31
  // Fall through when another malformed legacy field cannot be canonicalized.
@@ -124,14 +124,20 @@ export function tryApplyReplayPatch(current, patch) {
124
124
  }
125
125
  }
126
126
  /** Deterministically verify a history chain: each entry's before_hash must equal the prior replayed after_hash, the patch must strictly apply, and the recorded after_hash must equal the replayed result. */
127
- export function verifyHistoryChain(entries) {
127
+ /** Verify a chain and report the explicit or auto-detected item hash epoch. */
128
+ export function verifyHistoryChainWithVersion(entries) {
128
129
  let replay = cloneEmptyReplayDocument();
130
+ let detectedVersion;
129
131
  for (let index = 0; index < entries.length; index += 1) {
130
132
  const entry = entries[index];
131
- if (replayHash(replay) !== entry.before_hash) {
133
+ const explicitVersion = entry.item_hash_version;
134
+ if (explicitVersion !== undefined &&
135
+ !SUPPORTED_HISTORY_ITEM_HASH_VERSIONS.includes(explicitVersion)) {
132
136
  return {
133
137
  ok: false,
134
- errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`],
138
+ errors: [
139
+ `verify_failed:unsupported_item_hash_version:${String(explicitVersion)}:entry_${index + 1}`,
140
+ ],
135
141
  };
136
142
  }
137
143
  const applied = tryApplyReplayPatch(replay, entry.patch);
@@ -141,15 +147,38 @@ export function verifyHistoryChain(entries) {
141
147
  errors: [`verify_failed:patch_apply_failed:entry_${index + 1}`],
142
148
  };
143
149
  }
144
- replay = applied.document;
145
- if (replayHash(replay) !== entry.after_hash) {
150
+ const candidates = explicitVersion === undefined
151
+ ? [CURRENT_HISTORY_ITEM_HASH_VERSION, 1]
152
+ : [explicitVersion];
153
+ const beforeMatches = candidates.filter((version) => replayHash(replay, version) === entry.before_hash);
154
+ if (beforeMatches.length === 0) {
155
+ return {
156
+ ok: false,
157
+ errors: [`verify_failed:before_hash_mismatch:entry_${index + 1}`],
158
+ };
159
+ }
160
+ const version = beforeMatches.find((candidate) => replayHash(applied.document, candidate) === entry.after_hash);
161
+ if (version === undefined) {
146
162
  return {
147
163
  ok: false,
148
164
  errors: [`verify_failed:after_hash_mismatch:entry_${index + 1}`],
149
165
  };
150
166
  }
167
+ replay = applied.document;
168
+ detectedVersion = version;
151
169
  }
152
- return { ok: true, errors: [] };
170
+ return {
171
+ ok: true,
172
+ errors: [],
173
+ ...(detectedVersion === undefined
174
+ ? {}
175
+ : { item_hash_version: detectedVersion }),
176
+ };
177
+ }
178
+ /** Deterministically verify a history chain while preserving the legacy result shape. */
179
+ export function verifyHistoryChain(entries) {
180
+ const result = verifyHistoryChainWithVersion(entries);
181
+ return { ok: result.ok, errors: result.errors };
153
182
  }
154
183
  function tryApplySingleOp(document, op) {
155
184
  try {
@@ -192,6 +221,11 @@ export function lenientApplyReplayPatch(current, patch) {
192
221
  }
193
222
  /** 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. */
194
223
  export function reanchorHistoryEntries(entries) {
224
+ const unsupportedIndex = entries.findIndex((entry) => entry.item_hash_version !== undefined &&
225
+ !SUPPORTED_HISTORY_ITEM_HASH_VERSIONS.includes(entry.item_hash_version));
226
+ if (unsupportedIndex >= 0) {
227
+ throw new TypeError(`unsupported_item_hash_version:${String(entries[unsupportedIndex]?.item_hash_version)}:entry_${unsupportedIndex + 1}`);
228
+ }
195
229
  let replay = cloneEmptyReplayDocument();
196
230
  const rewritten = [];
197
231
  const details = [];
@@ -201,7 +235,7 @@ export function reanchorHistoryEntries(entries) {
201
235
  let skippedOps = 0;
202
236
  for (let index = 0; index < entries.length; index += 1) {
203
237
  const entry = entries[index];
204
- const beforeHash = replayHash(replay);
238
+ const beforeHash = replayHash(replay, CURRENT_HISTORY_ITEM_HASH_VERSION);
205
239
  const strict = tryApplyReplayPatch(replay, entry.patch);
206
240
  let next;
207
241
  let outPatch;
@@ -223,7 +257,7 @@ export function reanchorHistoryEntries(entries) {
223
257
  skippedOps += entrySkipped;
224
258
  entriesPatchRepaired += 1;
225
259
  }
226
- const afterHash = replayHash(next);
260
+ const afterHash = replayHash(next, CURRENT_HISTORY_ITEM_HASH_VERSION);
227
261
  const rehashed = beforeHash !== entry.before_hash || afterHash !== entry.after_hash;
228
262
  if (rehashed) {
229
263
  entriesRehashed += 1;
@@ -233,6 +267,7 @@ export function reanchorHistoryEntries(entries) {
233
267
  patch: outPatch,
234
268
  before_hash: beforeHash,
235
269
  after_hash: afterHash,
270
+ item_hash_version: CURRENT_HISTORY_ITEM_HASH_VERSION,
236
271
  });
237
272
  details.push({
238
273
  index: index + 1,
@@ -261,4 +296,4 @@ export function historyEntriesToRaw(entries) {
261
296
  return `${entries.map((entry) => JSON.stringify(entry)).join("\n")}\n`;
262
297
  }
263
298
  //# sourceMappingURL=replay.js.map
264
- //# debugId=c8668470-7e57-5dee-8e41-298e7c697b77
299
+ //# debugId=a1283470-00c7-5e91-8676-e1c1a667537f
@@ -9,7 +9,8 @@
9
9
  * Zero ttl means any lock older than 0 ms is stale. Negative ttl means always stale.
10
10
  */
11
11
 
12
- !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]="a026943f-1a46-526b-bfaa-435025c65c2a")}catch(e){}}();
12
+ !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]="79f9ccbd-48d1-5eb3-82ae-3dd62427041c")}catch(e){}}();
13
+ import { isFileMissingError } from "../fs/fs-utils.js";
13
14
  import fs from "node:fs/promises";
14
15
  import path from "node:path";
15
16
  function parseLock(raw) {
@@ -34,12 +35,6 @@ function parseLock(raw) {
34
35
  }
35
36
  return { id, owner, created_at, ttl_seconds };
36
37
  }
37
- function isErrno(error, code) {
38
- return (typeof error === "object" &&
39
- error !== null &&
40
- "code" in error &&
41
- error.code === code);
42
- }
43
38
  /** Pure classification of one lock file's raw content against `nowMs`. This is the single staleness/parse policy shared by `pm gc --scope locks` (which acts on it) and the `pm health` locks check (which only reports it). */
44
39
  export function classifyLockContent(file, raw, nowMs) {
45
40
  const lock = parseLock(raw);
@@ -108,7 +103,7 @@ export async function scanLockHealth(pmRoot, now) {
108
103
  dirEntries = rawDir.filter((f) => f.endsWith(".lock")).sort();
109
104
  }
110
105
  catch (error) {
111
- if (isErrno(error, "ENOENT")) {
106
+ if (isFileMissingError(error)) {
112
107
  return scan;
113
108
  }
114
109
  throw error;
@@ -119,7 +114,7 @@ export async function scanLockHealth(pmRoot, now) {
119
114
  raw = await fs.readFile(path.join(locksDir, file), "utf8");
120
115
  }
121
116
  catch (readError) {
122
- if (isErrno(readError, "ENOENT")) {
117
+ if (isFileMissingError(readError)) {
123
118
  // Disappeared between readdir and readFile — treat as a ghost; skip quietly.
124
119
  continue;
125
120
  }
@@ -159,7 +154,7 @@ export async function runLockGc(pmRoot, options) {
159
154
  dirEntries = raw.filter((f) => f.endsWith(".lock")).sort();
160
155
  }
161
156
  catch (error) {
162
- if (isErrno(error, "ENOENT")) {
157
+ if (isFileMissingError(error)) {
163
158
  return result;
164
159
  }
165
160
  throw error;
@@ -179,7 +174,7 @@ export async function runLockGc(pmRoot, options) {
179
174
  raw = await fs.readFile(absPath, "utf8");
180
175
  }
181
176
  catch (readError) {
182
- if (isErrno(readError, "ENOENT")) {
177
+ if (isFileMissingError(readError)) {
183
178
  // Disappeared between readdir and readFile — treat as a ghost; skip quietly.
184
179
  result.scanned -= 1;
185
180
  continue;
@@ -223,7 +218,7 @@ export async function runLockGc(pmRoot, options) {
223
218
  await fs.unlink(absPath);
224
219
  }
225
220
  catch (unlinkError) {
226
- if (!isErrno(unlinkError, "ENOENT")) {
221
+ if (!isFileMissingError(unlinkError)) {
227
222
  result.warnings.push(`lock_remove_failed:${file}`);
228
223
  result.retained.push(relPath);
229
224
  result.entries.push(classified.entry);
@@ -243,4 +238,4 @@ export async function runLockGc(pmRoot, options) {
243
238
  return result;
244
239
  }
245
240
  //# sourceMappingURL=lock-gc.js.map
246
- //# debugId=a026943f-1a46-526b-bfaa-435025c65c2a
241
+ //# debugId=79f9ccbd-48d1-5eb3-82ae-3dd62427041c
@@ -4,7 +4,8 @@
4
4
  * Coordinates tracker lock ownership and cleanup for Lock.
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]="c638b65d-148a-5b42-8f24-d6fa9d5ac7d3")}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]="a9ad8a9f-de6e-5bce-8685-844f1129d5fb")}catch(e){}}();
8
+ import { isFileMissingError } from "../fs/fs-utils.js";
8
9
  import fs from "node:fs/promises";
9
10
  import path from "node:path";
10
11
  import { randomUUID } from "node:crypto";
@@ -70,7 +71,7 @@ async function readLockInfo(lockPath) {
70
71
  return parseLockInfo(raw);
71
72
  }
72
73
  catch (error) {
73
- if (isErrno(error, "ENOENT")) {
74
+ if (isFileMissingError(error)) {
74
75
  return {
75
76
  info: null,
76
77
  warnings: [],
@@ -294,7 +295,7 @@ async function removeExpiredStaleCleanupGate(gatePath) {
294
295
  }
295
296
  }
296
297
  catch (error) {
297
- return isErrno(error, "ENOENT");
298
+ return isFileMissingError(error);
298
299
  }
299
300
  const owner = await readStaleCleanupGateOwner(gatePath);
300
301
  if (owner !== null &&
@@ -446,4 +447,4 @@ export async function acquireLock(pmRoot, id, ttlSeconds, owner, force = false,
446
447
  }
447
448
  }
448
449
  //# sourceMappingURL=lock.js.map
449
- //# debugId=c638b65d-148a-5b42-8f24-d6fa9d5ac7d3
450
+ //# debugId=a9ad8a9f-de6e-5bce-8685-844f1129d5fb
@@ -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
+ /** Include machine-readable row location and row-encoding metadata. */
28
+ outputRowContract?: boolean;
27
29
  /** Fallback output format used when callers do not provide an override. */
28
30
  defaultOutputFormat?: "toon" | "json";
29
31
  /** Value that configures or reports command for this contract. */
@@ -4,7 +4,7 @@
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]="b52d2756-f640-5f53-981f-05fa23fa1718")}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]="5aaf8b90-5b95-5102-9ea4-b877c696d593")}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";
@@ -12,6 +12,7 @@ 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
14
  import { resolveReadOutputEncoding } from "../../sdk/read-output-contracts.js";
15
+ import { encode as encodeToon } from "@toon-format/toon";
15
16
  const DECLARED_PROCESS_EXIT_CODES = new Set(Object.values(EXIT_CODE));
16
17
  const NATIVE_OUTPUT_MARKER = "__pm_native_output";
17
18
  let streamErrorHandlersInstalled = false;
@@ -114,6 +115,44 @@ function renderScalar(value) {
114
115
  return "null";
115
116
  return JSON.stringify(value);
116
117
  }
118
+ function isToonPrimitive(value) {
119
+ return (value === null ||
120
+ typeof value === "string" ||
121
+ typeof value === "number" ||
122
+ typeof value === "boolean");
123
+ }
124
+ function tabularObjectArray(value) {
125
+ if (value.length === 0 || !value.every(isPlainObject))
126
+ return false;
127
+ const keys = Object.keys(value[0]);
128
+ return (keys.length > 0 &&
129
+ value.every((entry) => Object.keys(entry).length === keys.length &&
130
+ keys.every((key) => Object.hasOwn(entry, key) && isToonPrimitive(entry[key]))));
131
+ }
132
+ function indentToon(encoded, depth) {
133
+ const indent = " ".repeat(depth);
134
+ return encoded
135
+ .split("\n")
136
+ .map((line) => `${indent}${line}`)
137
+ .join("\n");
138
+ }
139
+ /** Render one object field while preserving nested and tabular TOON structure. */
140
+ function renderToonObjectEntry(key, entry, depth) {
141
+ const indent = " ".repeat(depth);
142
+ if (!isPlainObject(entry) && !Array.isArray(entry)) {
143
+ return `${indent}${key}: ${renderScalar(entry)}`;
144
+ }
145
+ if (Array.isArray(entry) && entry.length === 0) {
146
+ return `${indent}${key}: []`;
147
+ }
148
+ if (Array.isArray(entry) && tabularObjectArray(entry)) {
149
+ return indentToon(encodeToon({ [key]: entry }), depth);
150
+ }
151
+ if (isPlainObject(entry) && Object.keys(entry).length === 0) {
152
+ return `${indent}${key}: {}`;
153
+ }
154
+ return `${indent}${key}:\n${renderToonValue(entry, depth + 1)}`;
155
+ }
117
156
  function compactToonValue(value) {
118
157
  if (value === null || value === undefined) {
119
158
  return undefined;
@@ -147,6 +186,9 @@ function renderToonValue(value, depth) {
147
186
  if (Array.isArray(value)) {
148
187
  if (value.length === 0)
149
188
  return "[]";
189
+ if (tabularObjectArray(value)) {
190
+ return indentToon(encodeToon(value), depth);
191
+ }
150
192
  return value
151
193
  .map((entry) => {
152
194
  if (!isPlainObject(entry) && !Array.isArray(entry)) {
@@ -167,18 +209,7 @@ function renderToonValue(value, depth) {
167
209
  if (entries.length === 0)
168
210
  return "{}";
169
211
  return entries
170
- .map(([key, entry]) => {
171
- if (!isPlainObject(entry) && !Array.isArray(entry)) {
172
- return `${indent}${key}: ${renderScalar(entry)}`;
173
- }
174
- if (Array.isArray(entry) && entry.length === 0) {
175
- return `${indent}${key}: []`;
176
- }
177
- if (isPlainObject(entry) && Object.keys(entry).length === 0) {
178
- return `${indent}${key}: {}`;
179
- }
180
- return `${indent}${key}:\n${renderToonValue(entry, depth + 1)}`;
181
- })
212
+ .map(([key, entry]) => renderToonObjectEntry(key, entry, depth))
182
213
  .join("\n");
183
214
  }
184
215
  return `${indent}${renderScalar(value)}`;
@@ -335,6 +366,7 @@ function formatEffectiveOutput(effectiveResult, nativeOutput, options) {
335
366
  ["outputBudget", options.outputBudget],
336
367
  ["outputFormat", options.outputFormat],
337
368
  ["outputSession", options.outputSession],
369
+ ["outputRowContract", options.outputRowContract],
338
370
  ].filter((entry) => entry[1] !== undefined)),
339
371
  };
340
372
  const format = resolveReadOutputEncoding(command ?? "", commandOptions) ??
@@ -424,4 +456,4 @@ export const outputTestOnly = {
424
456
  renderToonValue,
425
457
  };
426
458
  //# sourceMappingURL=output.js.map
427
- //# debugId=b52d2756-f640-5f53-981f-05fa23fa1718
459
+ //# debugId=5aaf8b90-5b95-5102-9ea4-b877c696d593
@@ -1,10 +1,10 @@
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]="7bac9506-dcad-5e52-848b-3e2631d4936c")}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]="98c8d03c-bdde-5ac4-b80d-395d885f7442")}catch(e){}}();
3
3
  import { mkdir, readFile, stat, unlink } from "node:fs/promises";
4
4
  import { basename, dirname, isAbsolute, join, resolve } from "node:path";
5
5
  import { executeSearchJsonRequest, normalizeSearchHttpTimeoutMs, resolveSearchHttpFetcher, } from "./http-client.js";
6
6
  import { isFiniteNumberArray, toErrorMessage, toNonEmptyString, trimTrailingSlashes, } from "../shared/primitives.js";
7
- import { writeFileAtomic } from "../fs/fs-utils.js";
7
+ import { isFileMissingError, writeFileAtomic } from "../fs/fs-utils.js";
8
8
  const DEFAULT_COLLECTION = "pm_items";
9
9
  const COLLECTION_SANITIZE_PATTERN = /[^a-zA-Z0-9_-]/g;
10
10
  const MAX_COLLECTION_NAME_LENGTH = 128;
@@ -200,11 +200,6 @@ function getLanceDbLocalTableKey(storePath, table) {
200
200
  function getLanceDbSnapshotPath(storePath, table) {
201
201
  return join(resolve(storePath), LANCE_DB_LOCAL_SNAPSHOT_DIR, `${table}.json`);
202
202
  }
203
- function isNodeErrorWithCode(error, code) {
204
- return (typeof error === "object" &&
205
- error !== null &&
206
- error.code === code);
207
- }
208
203
  function normalizeSnapshotRecord(entry, index, snapshotPath) {
209
204
  const id = toNonEmptyString(entry.id);
210
205
  if (!id) {
@@ -261,7 +256,7 @@ async function readLanceDbSnapshotStats(snapshotPath) {
261
256
  return { mtimeMs: stats.mtimeMs, size: stats.size };
262
257
  }
263
258
  catch (error) {
264
- if (!isNodeErrorWithCode(error, "ENOENT")) {
259
+ if (!isFileMissingError(error)) {
265
260
  throw error;
266
261
  }
267
262
  return null;
@@ -306,7 +301,7 @@ async function loadLanceDbLocalTable(storePath, table) {
306
301
  loaded = parseLanceDbSnapshot(snapshotPath, table, raw);
307
302
  }
308
303
  catch (error) {
309
- if (!isNodeErrorWithCode(error, "ENOENT")) {
304
+ if (!isFileMissingError(error)) {
310
305
  throw error;
311
306
  }
312
307
  }
@@ -331,7 +326,7 @@ async function removeSnapshotFile(snapshotPath) {
331
326
  await unlink(snapshotPath);
332
327
  }
333
328
  catch (error) {
334
- if (!isNodeErrorWithCode(error, "ENOENT")) {
329
+ if (!isFileMissingError(error)) {
335
330
  throw new Error(`LanceDB local snapshot delete failed at '${snapshotPath}': ${toErrorMessage(error)}`);
336
331
  }
337
332
  }
@@ -667,4 +662,4 @@ export async function executeVectorReset(store, knownIds = [], options = {}, vec
667
662
  return await executeVectorDelete(store, idsToDelete, options);
668
663
  }
669
664
  //# sourceMappingURL=vector-stores.js.map
670
- //# debugId=7bac9506-dcad-5e52-848b-3e2631d4936c
665
+ //# debugId=98c8d03c-bdde-5ac4-b80d-395d885f7442
@@ -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
+ /** Include the machine-readable row selector and TOON encoding contract. */
33
+ outputRowContract?: boolean;
32
34
  /** Filesystem path used for path resolution. */
33
35
  path?: string;
34
36
  /** Value that configures or reports no extensions for this contract. */
@@ -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]="ff47df0c-93db-5e20-be4e-48a2aedfeebf")}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]="044af354-3047-5fd4-ae65-458a259dedca")}catch(e){}}();
3
3
  export {};
4
4
  //# sourceMappingURL=command-types.js.map
5
- //# debugId=ff47df0c-93db-5e20-be4e-48a2aedfeebf
5
+ //# debugId=044af354-3047-5fd4-ae65-458a259dedca
@@ -11,6 +11,11 @@ export interface PmCliErrorRecoveryPayload {
11
11
  attempted_command?: string;
12
12
  /** Value that configures or reports normalized args for this contract. */
13
13
  normalized_args?: string[];
14
+ /** Positional tokens paired with their parser roles for unambiguous recovery. */
15
+ parsed_positionals?: Array<{
16
+ role: string;
17
+ value: string;
18
+ }>;
14
19
  /** Value that configures or reports provided fields for this contract. */
15
20
  provided_fields?: string[];
16
21
  /** Value that configures or reports missing for this contract. */
@@ -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]="df6f6758-f972-5bf4-aaa8-b16dd9a247f3")}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]="62fb0ba7-643f-5b33-870b-df875559610a")}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=df6f6758-f972-5bf4-aaa8-b16dd9a247f3
21
+ //# debugId=62fb0ba7-643f-5b33-870b-df875559610a
@@ -83,7 +83,7 @@ export interface ListCacheOptions {
83
83
  includeBody?: boolean;
84
84
  /** When false, heavy collection fields (comments/notes/learnings/files/tests/ test_runs/docs) are neither loaded from nor written to the separate collections cache, and are absent from the returned metadata. Light-only callers (`pm list` compact, stats, deps, activity, calendar, close) skip the large collections cache entirely. Defaults to true so any caller that does read those fields stays correct. */
85
85
  includeCollections?: boolean;
86
- /** Force canonical item enumeration and stat validation even when a fresh derived index is available. Validation, repair, migration, and equivalence tests use this correctness path. */
86
+ /** Force canonical item enumeration and authoritative file reads even when stat-matched cache tiers or a fresh derived index are available. Validation, repair, migration, and equivalence tests use this correctness path. */
87
87
  forceSourceScan?: boolean;
88
88
  /** Minimum item count required before the directory-signature derived-index fast path is used. Defaults to 500 so small workspaces preserve per-file external-edit detection; tests and specialized SDK hosts may lower it explicitly. */
89
89
  derivedIndexMinimumItems?: number;
@@ -4,7 +4,7 @@
4
4
  * Reads and writes tracker storage with format-aware helpers for the item metadata cache.
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]="8ed70856-9cba-599d-8b53-21a981af1f40")}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]="8b8c705a-8d80-576f-8642-f6f686cdbed9")}catch(e){}}();
8
8
  import fs from "node:fs/promises";
9
9
  import path from "node:path";
10
10
  import { createHash, randomUUID } from "node:crypto";
@@ -12,7 +12,7 @@ import { getActiveExtensionRegistrations, hasActiveOnReadHooks, runActiveOnReadH
12
12
  import { collectRegisteredItemFieldNames } from "../extensions/item-fields.js";
13
13
  import { parseItemDocument } from "../item/item-format.js";
14
14
  import { evictOldestMemoEntries } from "../shared/memo.js";
15
- import { writeFileAtomic } from "../fs/fs-utils.js";
15
+ import { isFileMissingError, writeFileAtomic } from "../fs/fs-utils.js";
16
16
  import { acquireLock } from "../lock/lock.js";
17
17
  import { ITEM_FILE_EXTENSIONS, getItemFormatFromPath } from "./paths.js";
18
18
  import { rebuildItemMetadataQueryIndex, removeItemMetadataQueryIndex, updateItemMetadataQueryIndex, } from "./item-metadata-query-index.js";
@@ -257,7 +257,8 @@ async function loadBodyCache(pmRoot, contextFingerprint) {
257
257
  };
258
258
  const cachePath = getBodyCachePath(pmRoot);
259
259
  const active = await loadEnvelopeMemoized(cachePath, parse);
260
- return contextFingerprint && active?.context_fingerprint !== contextFingerprint
260
+ return contextFingerprint &&
261
+ active?.context_fingerprint !== contextFingerprint
261
262
  ? await loadEnvelopeMemoized(getContextCachePath(cachePath, contextFingerprint), parse)
262
263
  : active;
263
264
  }
@@ -274,7 +275,8 @@ async function loadCollectionsCache(pmRoot, contextFingerprint) {
274
275
  };
275
276
  const cachePath = getCollectionsCachePath(pmRoot);
276
277
  const active = await loadEnvelopeMemoized(cachePath, parse);
277
- return contextFingerprint && active?.context_fingerprint !== contextFingerprint
278
+ return contextFingerprint &&
279
+ active?.context_fingerprint !== contextFingerprint
278
280
  ? await loadEnvelopeMemoized(getContextCachePath(cachePath, contextFingerprint), parse)
279
281
  : active;
280
282
  }
@@ -440,7 +442,7 @@ async function readItemDirectoryFiles(pmRoot, folder, warnings) {
440
442
  if (typeof error === "object" &&
441
443
  error !== null &&
442
444
  "code" in error &&
443
- error.code !== "ENOENT") {
445
+ !isFileMissingError(error)) {
444
446
  appendWarning(warnings, `item_list_directory_read_failed:${folder}`);
445
447
  }
446
448
  return { folder, dirPath, files: [] };
@@ -518,12 +520,16 @@ async function readCachedDocumentParts(filePath, relativePath, context) {
518
520
  const itemFormat = getItemFormatFromPath(filePath);
519
521
  await dispatchCachedDocumentReadHooks(filePath, context.warnings, context.dispatchReadHooks);
520
522
  const cachedEntry = context.previousEntries[relativePath];
521
- const metadataCached = cachedEntry !== undefined &&
523
+ const metadataCached = !context.forceSourceRead &&
524
+ cachedEntry !== undefined &&
522
525
  statMatches(cachedEntry, mtimeMs, ctimeMs, size);
523
526
  const cachedBody = context.previousBodies[relativePath];
524
- const bodyCached = cachedBody !== undefined && statMatches(cachedBody, mtimeMs, ctimeMs, size);
527
+ const bodyCached = !context.forceSourceRead &&
528
+ cachedBody !== undefined &&
529
+ statMatches(cachedBody, mtimeMs, ctimeMs, size);
525
530
  const cachedCollections = context.previousCollections[relativePath];
526
- const collectionsCached = cachedCollections !== undefined &&
531
+ const collectionsCached = !context.forceSourceRead &&
532
+ cachedCollections !== undefined &&
527
533
  statMatches(cachedCollections, mtimeMs, ctimeMs, size);
528
534
  const needRead = !metadataCached ||
529
535
  (context.includeBody && !bodyCached) ||
@@ -1028,6 +1034,7 @@ export async function listAllDocumentCandidatesCached(pmRoot, preferredFormat, t
1028
1034
  extensionFieldNames,
1029
1035
  includeBody,
1030
1036
  includeCollections,
1037
+ forceSourceRead: options.forceSourceScan === true,
1031
1038
  dispatchReadHooks,
1032
1039
  previousEntries,
1033
1040
  previousBodies,
@@ -1107,4 +1114,4 @@ export async function listAllDocumentsCachedLight(pmRoot, preferredFormat, typeT
1107
1114
  }));
1108
1115
  }
1109
1116
  //# sourceMappingURL=item-metadata-cache.js.map
1110
- //# debugId=8ed70856-9cba-599d-8b53-21a981af1f40
1117
+ //# debugId=8b8c705a-8d80-576f-8642-f6f686cdbed9
@@ -171,6 +171,10 @@ declare function sanitizeValue(value: unknown, keyHint?: string, captureLevel?:
171
171
  declare function sanitizeCommandArgs(args: string[], captureLevel?: Exclude<TelemetryCaptureLevel, "minimal">): string[];
172
172
  declare function normalizeCaptureLevel(value: string | undefined): TelemetryCaptureLevel;
173
173
  declare function parseBooleanTrueLike(value: string | undefined): boolean;
174
+ /** Resolve the background event and OTLP request timeout within the flush-lock safety envelope. */
175
+ declare function resolveTelemetryHttpTimeoutMs(): number;
176
+ /** POST a JSON payload with one total timeout that covers DNS, connection, TLS, and response completion. */
177
+ declare function postTelemetryJson(endpoint: string, headers: Record<string, string>, body: string): Promise<number>;
174
178
  declare function normalizePmVersion(value: string | undefined): string;
175
179
  declare function normalizeTelemetryErrorCode(value: string | undefined): string | undefined;
176
180
  declare function normalizeTelemetryExitCode(exitCode: number | undefined, ok: boolean): number;
@@ -335,11 +339,13 @@ export declare const _testOnly: {
335
339
  looksLikeEmailToken: typeof looksLikeEmailToken;
336
340
  otelSpansQueuePath: typeof otelSpansQueuePath;
337
341
  parseBooleanTrueLike: typeof parseBooleanTrueLike;
342
+ postTelemetryJson: typeof postTelemetryJson;
338
343
  parsePendingOtelSpanLines: typeof parsePendingOtelSpanLines;
339
344
  prunePendingOtelSpans: typeof prunePendingOtelSpans;
340
345
  reconcilePendingOtelSpansAfterFlush: typeof reconcilePendingOtelSpansAfterFlush;
341
346
  retentionCutoffMs: typeof retentionCutoffMs;
342
347
  resolveOtelTracesEndpoint: typeof resolveOtelTracesEndpoint;
348
+ resolveTelemetryHttpTimeoutMs: typeof resolveTelemetryHttpTimeoutMs;
343
349
  rewritePendingOtelSpans: typeof rewritePendingOtelSpans;
344
350
  normalizeForHash: typeof normalizeForHash;
345
351
  normalizeCaptureLevel: typeof normalizeCaptureLevel;