@unbrained/pm-cli 2026.11.9 → 2026.11.11

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 (613) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/dist/cli/commander-usage.js +2 -2
  4. package/dist/cli/error-guidance.js +5 -5
  5. package/dist/cli/help-json-payload.js +1 -1
  6. package/dist/cli/main.js +4 -4
  7. package/dist/cli/public.d.ts +1 -1
  8. package/dist/cli/register-history-maintenance.js +2 -2
  9. package/dist/cli/register-setup.js +1 -1
  10. package/dist/cli/runtime/refusal-credential-redaction.js +2 -0
  11. package/dist/cli-bundle/bundle-manifest.json +1 -1
  12. package/dist/cli-bundle/chunks/{chunk-YV5ALMG2.js → chunk-4RHXGQMK.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-IGT252ES.js → chunk-5N3JMGXU.js} +2 -2
  14. package/dist/cli-bundle/chunks/{chunk-VATZTJE3.js → chunk-DIWTFDU7.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-MSJ7IHMJ.js → chunk-DV7WBAKQ.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-GZVOOHTO.js → chunk-EBAHNZJT.js} +2 -2
  17. package/dist/cli-bundle/chunks/chunk-FM375BHH.js +3 -0
  18. package/dist/cli-bundle/chunks/{chunk-O2M3TNFY.js → chunk-GOLQYO6M.js} +5 -5
  19. package/dist/cli-bundle/chunks/chunk-GZ52WAY2.js +124 -0
  20. package/dist/cli-bundle/chunks/{chunk-6V4PGJBZ.js → chunk-JESMEJTD.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-XKY4LUXN.js → chunk-JLQ7O6UV.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-YK5GAWOT.js → chunk-L3SA3354.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-GDQ2T2OR.js → chunk-NIOOJ3AG.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-GCPP37N6.js → chunk-PZI6CR24.js} +46 -46
  25. package/dist/cli-bundle/chunks/{chunk-Z3QEEOAM.js → chunk-QCTA2UFR.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-EZRLW4R6.js → chunk-SPERPX27.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-ELNWRSGZ.js → chunk-SVVFJPNW.js} +2 -2
  28. package/dist/cli-bundle/chunks/chunk-WEAF3OY4.js +3 -0
  29. package/dist/cli-bundle/chunks/{chunk-JK7O7MFO.js → chunk-WWW5WHHJ.js} +3 -3
  30. package/dist/cli-bundle/chunks/{chunk-5VRJPPUC.js → chunk-XJUYJXHZ.js} +2 -2
  31. package/dist/cli-bundle/chunks/chunk-XN2BRWDD.js +6 -0
  32. package/dist/cli-bundle/chunks/chunk-Z4YEH7VQ.js +2 -0
  33. package/dist/cli-bundle/chunks/{chunk-3BMIAI4P.js → chunk-ZJDYBXMC.js} +2 -2
  34. package/dist/cli-bundle/chunks/{chunk-G6Q4VQSI.js → chunk-ZSL6U53K.js} +2 -2
  35. package/dist/cli-bundle/chunks/{item-revision-Y5CE3EIN.js → item-revision-LNIHK36Q.js} +2 -2
  36. package/dist/cli-bundle/chunks/item-transaction-TMUYPSMR.js +2 -0
  37. package/dist/cli-bundle/chunks/{mutation-admission-TAQN2AKK.js → mutation-admission-WZY22LVH.js} +2 -2
  38. package/dist/cli-bundle/chunks/{register-list-query-XMQYFUFI.js → register-list-query-DYGPLVRL.js} +2 -2
  39. package/dist/cli-bundle/chunks/{register-mutation-OBVCFLDK.js → register-mutation-MP5JCBAJ.js} +2 -2
  40. package/dist/cli-bundle/chunks/{register-operations-CGNFZ6DR.js → register-operations-QEASK3EF.js} +2 -2
  41. package/dist/cli-bundle/chunks/{register-setup-LFB5ERXH.js → register-setup-G66U2WFV.js} +2 -2
  42. package/dist/cli-bundle/chunks/{stage-NQHF6JPC.js → stage-VIDXGF3T.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-LDMBNTOG.js → chunk-2ZS3I5ZP.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-33EK522E.js +26 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-XLSTFUXM.js → chunk-3A6XMQZJ.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-IS5FLEZW.js → chunk-3FN4ON2Z.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-UIKLNSW3.js → chunk-3SH3L3DB.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/{chunk-ALLOWZSH.js → chunk-6ICHSVEY.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/chunk-6TJXTKZD.js +44 -0
  50. package/dist/cli-bundle/focused-chunks/{chunk-AH5IST3V.js → chunk-AXPRCCYM.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/chunk-DW5S67LO.js +2 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-C3DO4ZGZ.js → chunk-GBW2EAAG.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/chunk-HIKZYZ26.js +82 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-4FWMXQN3.js → chunk-JYWVRXLD.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/chunk-M5FZTPFA.js +2 -0
  56. package/dist/cli-bundle/focused-chunks/{chunk-2SQUWQP3.js → chunk-MK7UQEE5.js} +18 -18
  57. package/dist/cli-bundle/focused-chunks/{chunk-HNFY3XLC.js → chunk-NMU3QFAU.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{chunk-QWUWNFQO.js → chunk-NP5C2TQM.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{chunk-RNZUORGI.js → chunk-NSOXVVQX.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-J7PWHKZK.js → chunk-NY65XTX7.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-Q45LDP7P.js → chunk-P6KYUJD4.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-LWMPQRJT.js → chunk-UCUESVFW.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-NZQYHPUN.js → chunk-V27M5UQH.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/chunk-VVGXPF4W.js +26 -0
  65. package/dist/cli-bundle/focused-chunks/{item-revision-M6FOLME2.js → item-revision-B3BIG66B.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/{item-transaction-H6VA5JGB.js → item-transaction-4JDWOXNB.js} +2 -2
  67. package/dist/cli-bundle/focused-chunks/{mutation-admission-PRTQWQK6.js → mutation-admission-577MXOGD.js} +2 -2
  68. package/dist/cli-bundle/focused-chunks/{stage-7T77PSJD.js → stage-EKYWEU2Y.js} +2 -2
  69. package/dist/cli-bundle/main.js +32 -32
  70. package/dist/cli-bundle/sdk-authoring.js +1 -1
  71. package/dist/cli-bundle/sdk-contracts.js +1 -1
  72. package/dist/cli-bundle/sdk-core.js +1 -1
  73. package/dist/cli-bundle/sdk-governance.js +1 -1
  74. package/dist/cli-bundle/sdk-graph.js +1 -1
  75. package/dist/cli-bundle/sdk-merge.js +57 -57
  76. package/dist/cli-bundle/sdk-query.js +1 -1
  77. package/dist/cli-bundle/sdk-runtime.js +1 -1
  78. package/dist/cli-bundle/sdk-testing.js +1 -1
  79. package/dist/cli-bundle/sdk.js +11 -11
  80. package/dist/core/checkpoint/mutation-checkpoint.d.ts +12 -20
  81. package/dist/core/config/nested-settings.d.ts +14 -45
  82. package/dist/core/config/nested-settings.js +1 -1
  83. package/dist/core/config/positional-value.d.ts +11 -14
  84. package/dist/core/config/positional-value.js +1 -1
  85. package/dist/core/extensions/activation-summary-markdown.d.ts +4 -5
  86. package/dist/core/extensions/activation-summary.d.ts +7 -15
  87. package/dist/core/extensions/capability-usage.d.ts +7 -23
  88. package/dist/core/extensions/command-hook-context.d.ts +4 -7
  89. package/dist/core/extensions/command-metadata-contract.d.ts +2 -2
  90. package/dist/core/extensions/contribution-inventory.d.ts +3 -25
  91. package/dist/core/extensions/extension-capability-aliases.d.ts +7 -10
  92. package/dist/core/extensions/extension-hook-runtime.d.ts +2 -2
  93. package/dist/core/extensions/extension-policy.d.ts +12 -47
  94. package/dist/core/extensions/extension-registries.d.ts +2 -2
  95. package/dist/core/extensions/extension-types.d.ts +332 -545
  96. package/dist/core/extensions/flag-definition-validation.d.ts +11 -13
  97. package/dist/core/extensions/flag-value-types.d.ts +11 -13
  98. package/dist/core/extensions/index.d.ts +15 -20
  99. package/dist/core/extensions/item-field-types.d.ts +5 -5
  100. package/dist/core/extensions/item-fields.d.ts +4 -7
  101. package/dist/core/extensions/loader.d.ts +5 -69
  102. package/dist/core/extensions/manifest-parser.d.ts +3 -3
  103. package/dist/core/extensions/manifest-schema.d.ts +10 -13
  104. package/dist/core/extensions/registration-contracts.d.ts +2 -4
  105. package/dist/core/extensions/registration-validation.d.ts +1 -1
  106. package/dist/core/extensions/registration-values.d.ts +5 -7
  107. package/dist/core/extensions/runtime-registrations.d.ts +6 -6
  108. package/dist/core/extensions/version-compat.d.ts +9 -10
  109. package/dist/core/fs/fs-utils.d.ts +4 -6
  110. package/dist/core/fs/host-environment-errors.d.ts +8 -10
  111. package/dist/core/governance/content-fields.d.ts +10 -14
  112. package/dist/core/governance/issue-codes.d.ts +12 -18
  113. package/dist/core/governance/metadata-coverage.d.ts +24 -34
  114. package/dist/core/history/digest.d.ts +3 -3
  115. package/dist/core/history/event-classification.d.ts +5 -5
  116. package/dist/core/history/event-index.d.ts +14 -35
  117. package/dist/core/history/history-compact-bulk.d.ts +10 -13
  118. package/dist/core/history/history-diff.d.ts +6 -11
  119. package/dist/core/history/history-rewrite.d.ts +24 -40
  120. package/dist/core/history/history-storage-stats.d.ts +9 -17
  121. package/dist/core/history/history-stream-policy.d.ts +8 -11
  122. package/dist/core/history/history.d.ts +10 -44
  123. package/dist/core/history/identity.d.ts +4 -5
  124. package/dist/core/history/operation-contract.d.ts +5 -15
  125. package/dist/core/history/projection.d.ts +10 -14
  126. package/dist/core/history/read.d.ts +6 -7
  127. package/dist/core/history/replay.d.ts +16 -37
  128. package/dist/core/history/workspace-history.d.ts +27 -60
  129. package/dist/core/io/body-file.d.ts +2 -2
  130. package/dist/core/io/bulk-ids-input.d.ts +7 -8
  131. package/dist/core/item/actionability.d.ts +16 -22
  132. package/dist/core/item/dependency-reference.d.ts +2 -2
  133. package/dist/core/item/id.d.ts +5 -9
  134. package/dist/core/item/item-format-version.d.ts +11 -13
  135. package/dist/core/item/item-format.d.ts +11 -59
  136. package/dist/core/item/item-record.d.ts +2 -2
  137. package/dist/core/item/literal-mutation-input.d.ts +2 -2
  138. package/dist/core/item/parent-reference-policy.d.ts +4 -7
  139. package/dist/core/item/parse.d.ts +10 -26
  140. package/dist/core/item/plan-lifecycle.d.ts +3 -3
  141. package/dist/core/item/priority.d.ts +2 -2
  142. package/dist/core/item/sprint-release-format.d.ts +3 -7
  143. package/dist/core/item/status-filter.d.ts +5 -7
  144. package/dist/core/item/status.d.ts +3 -4
  145. package/dist/core/item/type-registry.d.ts +17 -24
  146. package/dist/core/item/type-synonyms.d.ts +1 -1
  147. package/dist/core/lock/lock-owner.d.ts +8 -10
  148. package/dist/core/lock/lock.d.ts +19 -67
  149. package/dist/core/output/output-control.d.ts +5 -6
  150. package/dist/core/output/output.d.ts +10 -19
  151. package/dist/core/output/tabular.d.ts +2 -2
  152. package/dist/core/packages/manifest.d.ts +13 -17
  153. package/dist/core/packages/root.d.ts +3 -3
  154. package/dist/core/policy/workflow-policy-schema.d.ts +2 -310
  155. package/dist/core/policy/workflow-policy-store.d.ts +5 -14
  156. package/dist/core/policy/workflow-policy.d.ts +25 -52
  157. package/dist/core/profile/profile-describe.d.ts +8 -11
  158. package/dist/core/profile/profile-lint.d.ts +11 -13
  159. package/dist/core/profile/profile-plan.d.ts +30 -49
  160. package/dist/core/profile/profile-presets.d.ts +25 -36
  161. package/dist/core/reproducibility/context.d.ts +6 -7
  162. package/dist/core/schema/fields-file.d.ts +14 -21
  163. package/dist/core/schema/item-types-file.d.ts +16 -22
  164. package/dist/core/schema/runtime-field-filters.d.ts +2 -2
  165. package/dist/core/schema/runtime-field-values.d.ts +6 -13
  166. package/dist/core/schema/runtime-schema.d.ts +19 -31
  167. package/dist/core/schema/status-defs-file.d.ts +15 -25
  168. package/dist/core/schema/status-token.d.ts +1 -1
  169. package/dist/core/schema/type-inference.d.ts +6 -8
  170. package/dist/core/schema/type-presets.d.ts +5 -5
  171. package/dist/core/schema/type-workflows.d.ts +11 -16
  172. package/dist/core/search/background-refresh.d.ts +6 -12
  173. package/dist/core/search/bm25.d.ts +11 -19
  174. package/dist/core/search/cache.d.ts +19 -41
  175. package/dist/core/search/corpus.d.ts +16 -19
  176. package/dist/core/search/embedding-batches.d.ts +12 -17
  177. package/dist/core/search/eval-thresholds.d.ts +3 -3
  178. package/dist/core/search/eval.d.ts +16 -34
  179. package/dist/core/search/http-client.d.ts +14 -18
  180. package/dist/core/search/providers.d.ts +22 -39
  181. package/dist/core/search/relevance.d.ts +14 -19
  182. package/dist/core/search/semantic-defaults.d.ts +4 -5
  183. package/dist/core/search/vector-stores.d.ts +35 -57
  184. package/dist/core/search/vectorization-metadata.d.ts +9 -11
  185. package/dist/core/sentry/helpers.d.ts +6 -31
  186. package/dist/core/sentry/instrument.d.ts +6 -59
  187. package/dist/core/sentry/instrument.js +1 -1
  188. package/dist/core/session/session-state.d.ts +12 -32
  189. package/dist/core/shared/agent-session-context.d.ts +10 -17
  190. package/dist/core/shared/author.d.ts +48 -69
  191. package/dist/core/shared/command-line.d.ts +3 -3
  192. package/dist/core/shared/command-types.d.ts +3 -4
  193. package/dist/core/shared/constants.d.ts +14 -32
  194. package/dist/core/shared/error-details.d.ts +5 -18
  195. package/dist/core/shared/errors.d.ts +42 -83
  196. package/dist/core/shared/html-entity-decode.d.ts +1 -1
  197. package/dist/core/shared/item-metadata-contract.d.ts +2 -2
  198. package/dist/core/shared/lazy-module.d.ts +1 -1
  199. package/dist/core/shared/levenshtein.d.ts +1 -1
  200. package/dist/core/shared/numeric-parsers.d.ts +1 -1
  201. package/dist/core/shared/option-alias-visibility.d.ts +2 -2
  202. package/dist/core/shared/output-unicode.d.ts +1 -1
  203. package/dist/core/shared/primitives.d.ts +10 -10
  204. package/dist/core/shared/secret-rules.d.ts +22 -92
  205. package/dist/core/shared/secret-rules.js +4 -2
  206. package/dist/core/shared/serial-queue.d.ts +7 -9
  207. package/dist/core/shared/serialization.d.ts +1 -1
  208. package/dist/core/shared/split-comma-list.d.ts +4 -5
  209. package/dist/core/shared/text-normalization.d.ts +1 -1
  210. package/dist/core/shared/time.d.ts +6 -20
  211. package/dist/core/shared/url-credentials.d.ts +37 -0
  212. package/dist/core/shared/url-credentials.js +2 -0
  213. package/dist/core/store/item-format-migration.d.ts +4 -5
  214. package/dist/core/store/item-metadata-cache.d.ts +22 -27
  215. package/dist/core/store/item-metadata-query-index.d.ts +20 -61
  216. package/dist/core/store/item-metadata-read-work.d.ts +3 -7
  217. package/dist/core/store/item-mutation-precondition.d.ts +19 -35
  218. package/dist/core/store/item-store.d.ts +18 -141
  219. package/dist/core/store/paths.d.ts +5 -10
  220. package/dist/core/store/settings-read-cache.d.ts +7 -9
  221. package/dist/core/store/settings-sections.d.ts +15 -19
  222. package/dist/core/store/settings-validator.d.ts +27 -143
  223. package/dist/core/store/settings-validator.js +1 -1
  224. package/dist/core/store/settings.d.ts +19 -94
  225. package/dist/core/store/sqlite-runtime.d.ts +3 -3
  226. package/dist/core/store/tracker-preflight.d.ts +2 -2
  227. package/dist/core/telemetry/consent.d.ts +2 -2
  228. package/dist/core/telemetry/observability.d.ts +8 -19
  229. package/dist/core/telemetry/policy.d.ts +8 -23
  230. package/dist/core/telemetry/runtime.d.ts +44 -254
  231. package/dist/core/telemetry/runtime.js +2 -2
  232. package/dist/core/test/background-runs.d.ts +35 -79
  233. package/dist/core/test/run-selectors.d.ts +10 -12
  234. package/dist/core/validate/fix-planning.d.ts +19 -28
  235. package/dist/core/validate/missing-by-type.d.ts +3 -4
  236. package/dist/core/validate/missing-link-owners.d.ts +12 -16
  237. package/dist/core/validate/stale-file-classification.d.ts +5 -6
  238. package/dist/mcp/tool-definitions.d.ts +7 -30
  239. package/dist/sdk/actionability.d.ts +1 -1
  240. package/dist/sdk/agent/closed-domain-contracts.d.ts +4 -5
  241. package/dist/sdk/agent/command-recovery.d.ts +9 -13
  242. package/dist/sdk/agent/command-suggestions.d.ts +2 -2
  243. package/dist/sdk/agent/create-option-policy.d.ts +2 -2
  244. package/dist/sdk/agent/identity-config.d.ts +13 -18
  245. package/dist/sdk/agent/item-addressing.d.ts +4 -5
  246. package/dist/sdk/agent/linked-resource-recovery.d.ts +3 -4
  247. package/dist/sdk/agent/refusal-closure-census.d.ts +13 -25
  248. package/dist/sdk/agent/refusal-closure.d.ts +8 -11
  249. package/dist/sdk/agent/refusal-corpus-contracts.d.ts +15 -21
  250. package/dist/sdk/agent/refusal-reachability.d.ts +38 -52
  251. package/dist/sdk/agent/subcommand-recovery.d.ts +7 -15
  252. package/dist/sdk/agent/task-transcript-contracts.d.ts +12 -15
  253. package/dist/sdk/agent/tracker-preflight-contracts.d.ts +13 -17
  254. package/dist/sdk/agent-capability-contracts.d.ts +19 -32
  255. package/dist/sdk/agent-session-context.d.ts +1 -1
  256. package/dist/sdk/annotations.d.ts +32 -68
  257. package/dist/sdk/author-attribution.d.ts +22 -33
  258. package/dist/sdk/authoring.d.ts +1 -19
  259. package/dist/sdk/cli-bootstrap.d.ts +22 -59
  260. package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +31 -57
  261. package/dist/sdk/cli-contracts/command-aliases.d.ts +7 -8
  262. package/dist/sdk/cli-contracts/command-exit-contracts.d.ts +19 -65
  263. package/dist/sdk/cli-contracts/commander-mutation-options.d.ts +2 -2
  264. package/dist/sdk/cli-contracts/commander-types.d.ts +6 -11
  265. package/dist/sdk/cli-contracts/completeness.d.ts +11 -15
  266. package/dist/sdk/cli-contracts/enum-contracts.d.ts +25 -37
  267. package/dist/sdk/cli-contracts/flag-contracts.d.ts +16 -20
  268. package/dist/sdk/cli-contracts/flag-lexicon-contracts.d.ts +14 -19
  269. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +29 -47
  270. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +44 -265
  271. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +11 -564
  272. package/dist/sdk/cli-contracts/tool-schema.d.ts +18 -51
  273. package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +18 -37
  274. package/dist/sdk/cli-contracts.d.ts +1 -16
  275. package/dist/sdk/cli-program.d.ts +2 -2
  276. package/dist/sdk/command-line.d.ts +3 -4
  277. package/dist/sdk/command-line.js +1 -1
  278. package/dist/sdk/comments.d.ts +6 -10
  279. package/dist/sdk/compile-cache.d.ts +4 -5
  280. package/dist/sdk/completion/bash.d.ts +2 -2
  281. package/dist/sdk/completion/fish.d.ts +2 -2
  282. package/dist/sdk/completion/shared.d.ts +10 -77
  283. package/dist/sdk/completion/shared.js +1 -1
  284. package/dist/sdk/completion/zsh.d.ts +2 -2
  285. package/dist/sdk/completion.d.ts +2 -6
  286. package/dist/sdk/compose.d.ts +49 -74
  287. package/dist/sdk/config.d.ts +18 -94
  288. package/dist/sdk/config.js +1 -1
  289. package/dist/sdk/context/recency.d.ts +2 -2
  290. package/dist/sdk/context/semantic-session-attribution.d.ts +6 -25
  291. package/dist/sdk/context/usage-ledger.d.ts +9 -21
  292. package/dist/sdk/context-intent-contracts.d.ts +24 -35
  293. package/dist/sdk/context-intent-runtime.d.ts +7 -9
  294. package/dist/sdk/context-packing.d.ts +16 -34
  295. package/dist/sdk/context-relevance.d.ts +58 -93
  296. package/dist/sdk/context-signal-store.d.ts +29 -60
  297. package/dist/sdk/context-usage.d.ts +22 -69
  298. package/dist/sdk/contracts.d.ts +1 -24
  299. package/dist/sdk/core-governance.d.ts +1 -5
  300. package/dist/sdk/core.d.ts +1 -27
  301. package/dist/sdk/corpus-shape.d.ts +16 -28
  302. package/dist/sdk/define.d.ts +10 -14
  303. package/dist/sdk/dependencies.d.ts +32 -50
  304. package/dist/sdk/dependency-provenance.d.ts +19 -23
  305. package/dist/sdk/docs.d.ts +6 -10
  306. package/dist/sdk/duplicates.d.ts +8 -15
  307. package/dist/sdk/environment/agent-environment.d.ts +60 -101
  308. package/dist/sdk/environment/host-environment-errors.d.ts +1 -1
  309. package/dist/sdk/environment/project-runtime-compatibility.d.ts +15 -29
  310. package/dist/sdk/environment/source-context.d.ts +6 -7
  311. package/dist/sdk/environment/tracker-preflight.d.ts +1 -1
  312. package/dist/sdk/error-code-catalog.d.ts +9 -26
  313. package/dist/sdk/error-runtime.d.ts +6 -8
  314. package/dist/sdk/errors.d.ts +10 -17
  315. package/dist/sdk/eval.d.ts +11 -21
  316. package/dist/sdk/extension/command-options.d.ts +14 -26
  317. package/dist/sdk/extension/describe.d.ts +14 -19
  318. package/dist/sdk/extension/doctor.d.ts +8 -48
  319. package/dist/sdk/extension/install-plan.d.ts +12 -26
  320. package/dist/sdk/extension/install-runtime.d.ts +10 -11
  321. package/dist/sdk/extension/install-sources.d.ts +22 -104
  322. package/dist/sdk/extension/managed-state.d.ts +13 -18
  323. package/dist/sdk/extension/migrations.d.ts +22 -37
  324. package/dist/sdk/extension/output-ownership.d.ts +3 -30
  325. package/dist/sdk/extension/shared.d.ts +9 -15
  326. package/dist/sdk/extension/source-resolution.d.ts +13 -18
  327. package/dist/sdk/extension/static-inventory.d.ts +17 -21
  328. package/dist/sdk/extension/update-check.d.ts +7 -11
  329. package/dist/sdk/extension-command-context.d.ts +2 -3
  330. package/dist/sdk/extension-contracts.d.ts +11 -14
  331. package/dist/sdk/extension.d.ts +31 -192
  332. package/dist/sdk/files.d.ts +27 -68
  333. package/dist/sdk/flag-invocation-contracts.d.ts +13 -17
  334. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  335. package/dist/sdk/generated-error-code-catalog.d.ts +1 -1
  336. package/dist/sdk/governance/artifact-ledgers.d.ts +9 -16
  337. package/dist/sdk/governance/assurance-action-contracts.d.ts +1 -1
  338. package/dist/sdk/governance/assurance-action.d.ts +13 -45
  339. package/dist/sdk/governance/assurance-mutation-error.d.ts +12 -17
  340. package/dist/sdk/governance/assurance-presets.d.ts +10 -21
  341. package/dist/sdk/governance/assurance-runtime.d.ts +5 -6
  342. package/dist/sdk/governance/assurance.d.ts +97 -154
  343. package/dist/sdk/governance/boundary-fixtures.d.ts +17 -23
  344. package/dist/sdk/governance/closure-timestamps.d.ts +5 -15
  345. package/dist/sdk/governance/coverage-assurance.d.ts +5 -6
  346. package/dist/sdk/governance/defect-recurrence-coverage.d.ts +13 -23
  347. package/dist/sdk/governance/defect-recurrence-graph.d.ts +9 -13
  348. package/dist/sdk/governance/defect-recurrence.d.ts +43 -67
  349. package/dist/sdk/governance/extension-host-version.d.ts +8 -10
  350. package/dist/sdk/governance/gc.d.ts +12 -20
  351. package/dist/sdk/governance/health/projection.d.ts +8 -23
  352. package/dist/sdk/governance/health.d.ts +23 -167
  353. package/dist/sdk/governance/hierarchy-validation.d.ts +2 -18
  354. package/dist/sdk/governance/linked-file-report.d.ts +6 -10
  355. package/dist/sdk/governance/merge-receipt-history.d.ts +12 -16
  356. package/dist/sdk/governance/provenance-health.d.ts +17 -23
  357. package/dist/sdk/governance/reindex.d.ts +13 -116
  358. package/dist/sdk/governance/reliability.d.ts +13 -17
  359. package/dist/sdk/governance/stale-work.d.ts +8 -11
  360. package/dist/sdk/governance/status-role-diagnostics.d.ts +4 -6
  361. package/dist/sdk/governance/storage-integrity.d.ts +16 -23
  362. package/dist/sdk/governance/upgrade.d.ts +17 -57
  363. package/dist/sdk/governance/validate-item-reader.d.ts +3 -11
  364. package/dist/sdk/governance/validate-normalization.d.ts +2 -2
  365. package/dist/sdk/governance/validate.d.ts +29 -175
  366. package/dist/sdk/governance/workflow-completeness.d.ts +5 -17
  367. package/dist/sdk/governance/workflow-policy.d.ts +8 -16
  368. package/dist/sdk/governance/workspace-position.d.ts +12 -43
  369. package/dist/sdk/governance.d.ts +1 -39
  370. package/dist/sdk/graph/adapter.d.ts +23 -41
  371. package/dist/sdk/graph/analytics.d.ts +20 -31
  372. package/dist/sdk/graph/assembly.d.ts +24 -35
  373. package/dist/sdk/graph/cache.d.ts +13 -25
  374. package/dist/sdk/graph/cardinality-integrity.d.ts +4 -6
  375. package/dist/sdk/graph/centrality.d.ts +14 -20
  376. package/dist/sdk/graph/conformance.d.ts +12 -19
  377. package/dist/sdk/graph/deadline-scheduling.d.ts +14 -20
  378. package/dist/sdk/graph/durable-cache.d.ts +11 -14
  379. package/dist/sdk/graph/governance-contracts.d.ts +2 -2
  380. package/dist/sdk/graph/governance.d.ts +22 -36
  381. package/dist/sdk/graph/hierarchy-integrity.d.ts +18 -26
  382. package/dist/sdk/graph/index.d.ts +1 -17
  383. package/dist/sdk/graph/lifecycle-coverage.d.ts +8 -12
  384. package/dist/sdk/graph/mutation-advisory.d.ts +5 -16
  385. package/dist/sdk/graph/query-contracts.d.ts +1 -2
  386. package/dist/sdk/graph/remediation.d.ts +11 -18
  387. package/dist/sdk/graph/run.d.ts +73 -115
  388. package/dist/sdk/graph/scheduling.d.ts +8 -15
  389. package/dist/sdk/graph/traversal.d.ts +9 -15
  390. package/dist/sdk/graph/workspace-relationship-kind-registry.d.ts +2 -2
  391. package/dist/sdk/graph.d.ts +1 -12
  392. package/dist/sdk/guide-topics.d.ts +7 -10
  393. package/dist/sdk/guide.d.ts +21 -43
  394. package/dist/sdk/history/attestation-command.d.ts +7 -10
  395. package/dist/sdk/history/attestation-contract.d.ts +19 -34
  396. package/dist/sdk/history/attestation.d.ts +2 -3
  397. package/dist/sdk/history/maintenance.d.ts +17 -27
  398. package/dist/sdk/history/salvage.d.ts +5 -22
  399. package/dist/sdk/history/subject.d.ts +5 -11
  400. package/dist/sdk/history-analytics.d.ts +28 -59
  401. package/dist/sdk/history-compact.d.ts +25 -66
  402. package/dist/sdk/history-provenance.d.ts +16 -33
  403. package/dist/sdk/history-read.d.ts +9 -16
  404. package/dist/sdk/history-redact.d.ts +19 -74
  405. package/dist/sdk/history-redact.js +1 -1
  406. package/dist/sdk/history-repair.d.ts +26 -71
  407. package/dist/sdk/improvement-ledger-validation.d.ts +2 -2
  408. package/dist/sdk/improvement-ledger.d.ts +20 -39
  409. package/dist/sdk/index.d.ts +1 -268
  410. package/dist/sdk/index.js +1 -1
  411. package/dist/sdk/init-agent-guidance.d.ts +13 -68
  412. package/dist/sdk/init.d.ts +24 -94
  413. package/dist/sdk/invocation-author.d.ts +1 -1
  414. package/dist/sdk/item-children.d.ts +10 -13
  415. package/dist/sdk/item-metadata-index.d.ts +1 -2
  416. package/dist/sdk/item-schedule.d.ts +8 -9
  417. package/dist/sdk/item-transaction.d.ts +46 -90
  418. package/dist/sdk/learnings.d.ts +6 -10
  419. package/dist/sdk/lifecycle/append.d.ts +7 -9
  420. package/dist/sdk/lifecycle/claim.d.ts +26 -42
  421. package/dist/sdk/lifecycle/cli-input.d.ts +1 -1
  422. package/dist/sdk/lifecycle/close-many.d.ts +14 -65
  423. package/dist/sdk/lifecycle/close.d.ts +10 -26
  424. package/dist/sdk/lifecycle/copy.d.ts +6 -10
  425. package/dist/sdk/lifecycle/create.d.ts +15 -83
  426. package/dist/sdk/lifecycle/delete.d.ts +7 -9
  427. package/dist/sdk/lifecycle/focus.d.ts +9 -11
  428. package/dist/sdk/lifecycle/item-revision.d.ts +25 -45
  429. package/dist/sdk/lifecycle/item-revision.js +1 -1
  430. package/dist/sdk/lifecycle/lifecycle-transitions.d.ts +4 -5
  431. package/dist/sdk/lifecycle/mutation-command-options.d.ts +6 -9
  432. package/dist/sdk/lifecycle/plan-mutation-receipt.d.ts +5 -13
  433. package/dist/sdk/lifecycle/plan.d.ts +34 -74
  434. package/dist/sdk/lifecycle/reopen.d.ts +8 -14
  435. package/dist/sdk/lifecycle/restore.d.ts +9 -38
  436. package/dist/sdk/lifecycle/shared-unset-fields.d.ts +23 -614
  437. package/dist/sdk/lifecycle/start-blockers.d.ts +7 -27
  438. package/dist/sdk/lifecycle/structured-mutation-plan.d.ts +8 -16
  439. package/dist/sdk/lifecycle/task-composition.d.ts +6 -14
  440. package/dist/sdk/lifecycle/update-many.d.ts +15 -65
  441. package/dist/sdk/lifecycle/update.d.ts +21 -104
  442. package/dist/sdk/lifecycle/workflow-transition.d.ts +2 -11
  443. package/dist/sdk/lifecycle-completion.d.ts +11 -14
  444. package/dist/sdk/lifecycle-policy.d.ts +23 -32
  445. package/dist/sdk/linked-artifacts.d.ts +31 -41
  446. package/dist/sdk/mcp/apps.d.ts +12 -27
  447. package/dist/sdk/mcp/authorization.d.ts +30 -63
  448. package/dist/sdk/mcp/discovery.d.ts +23 -52
  449. package/dist/sdk/mcp/executable.d.ts +3 -10
  450. package/dist/sdk/mcp/interactions.d.ts +25 -47
  451. package/dist/sdk/mcp/protocol.d.ts +32 -64
  452. package/dist/sdk/mcp/skills.d.ts +21 -71
  453. package/dist/sdk/mcp/subscriptions.d.ts +14 -28
  454. package/dist/sdk/mcp/tasks.d.ts +21 -55
  455. package/dist/sdk/mcp/transport.d.ts +7 -15
  456. package/dist/sdk/merge/driver.d.ts +13 -37
  457. package/dist/sdk/merge/index.d.ts +1 -6
  458. package/dist/sdk/merge/install.d.ts +27 -55
  459. package/dist/sdk/merge/receipt-operation.d.ts +5 -6
  460. package/dist/sdk/merge/receipt-schema.d.ts +6 -9
  461. package/dist/sdk/merge/receipts.d.ts +29 -79
  462. package/dist/sdk/merge/reconcile.d.ts +9 -18
  463. package/dist/sdk/merge/three-way.d.ts +21 -30
  464. package/dist/sdk/merge.d.ts +1 -5
  465. package/dist/sdk/mutation-events.d.ts +21 -53
  466. package/dist/sdk/mutation-guard.d.ts +15 -135
  467. package/dist/sdk/notes.d.ts +6 -10
  468. package/dist/sdk/output/fit-envelope.d.ts +21 -28
  469. package/dist/sdk/output/list-envelope.d.ts +1 -1
  470. package/dist/sdk/output/table-rows.d.ts +8 -12
  471. package/dist/sdk/output-contracts.d.ts +11 -14
  472. package/dist/sdk/output-projection.d.ts +18 -130
  473. package/dist/sdk/output-token-accounting.d.ts +8 -15
  474. package/dist/sdk/output.d.ts +10 -15
  475. package/dist/sdk/ownership-source.d.ts +4 -5
  476. package/dist/sdk/package-import-adapters.d.ts +27 -37
  477. package/dist/sdk/package-migrations.d.ts +2 -2
  478. package/dist/sdk/package-runtime-options.d.ts +3 -3
  479. package/dist/sdk/pagination.d.ts +12 -24
  480. package/dist/sdk/profile.d.ts +25 -42
  481. package/dist/sdk/provenance.d.ts +21 -32
  482. package/dist/sdk/public-surface.json +1 -1
  483. package/dist/sdk/query/activity.d.ts +24 -77
  484. package/dist/sdk/query/aggregate.d.ts +20 -95
  485. package/dist/sdk/query/calendar.d.ts +26 -74
  486. package/dist/sdk/query/complete-list.d.ts +19 -35
  487. package/dist/sdk/query/context.d.ts +69 -240
  488. package/dist/sdk/query/declared-blockers.d.ts +2 -9
  489. package/dist/sdk/query/duplicate-candidates.d.ts +3 -5
  490. package/dist/sdk/query/get.d.ts +13 -55
  491. package/dist/sdk/query/history.d.ts +18 -29
  492. package/dist/sdk/query/item-filter-options.d.ts +7 -12
  493. package/dist/sdk/query/list-filter-shared.d.ts +4 -8
  494. package/dist/sdk/query/list.d.ts +44 -168
  495. package/dist/sdk/query/multi-value-filters.d.ts +7 -9
  496. package/dist/sdk/query/next-ranking-policy.d.ts +4 -10
  497. package/dist/sdk/query/next-ready-budget.d.ts +4 -5
  498. package/dist/sdk/query/next.d.ts +27 -86
  499. package/dist/sdk/query/parsers.d.ts +4 -6
  500. package/dist/sdk/query/projection-contracts.d.ts +12 -21
  501. package/dist/sdk/query/search/corpus.d.ts +5 -20
  502. package/dist/sdk/query/search/filters.d.ts +5 -17
  503. package/dist/sdk/query/search/input.d.ts +4 -9
  504. package/dist/sdk/query/search/lexical.d.ts +5 -9
  505. package/dist/sdk/query/search/response.d.ts +5 -22
  506. package/dist/sdk/query/search/semantic.d.ts +24 -170
  507. package/dist/sdk/query/search/types.d.ts +19 -73
  508. package/dist/sdk/query/search-contracts.d.ts +24 -34
  509. package/dist/sdk/query/search-pagination.d.ts +5 -24
  510. package/dist/sdk/query/search-rendering.d.ts +8 -32
  511. package/dist/sdk/query/search.d.ts +3 -63
  512. package/dist/sdk/query/workspace-contracts.d.ts +2 -2
  513. package/dist/sdk/query.d.ts +1 -43
  514. package/dist/sdk/read-output/continuation.d.ts +5 -6
  515. package/dist/sdk/read-output/options.d.ts +3 -8
  516. package/dist/sdk/read-output/session-result.d.ts +2 -33
  517. package/dist/sdk/read-output/tail-retention.d.ts +6 -8
  518. package/dist/sdk/read-output-budget.d.ts +14 -16
  519. package/dist/sdk/read-output-contracts.d.ts +59 -103
  520. package/dist/sdk/read-output-rows.d.ts +5 -9
  521. package/dist/sdk/read-output-session.d.ts +11 -14
  522. package/dist/sdk/relationship-analytics.d.ts +17 -37
  523. package/dist/sdk/relationship-context.d.ts +15 -33
  524. package/dist/sdk/relationship-history.d.ts +29 -50
  525. package/dist/sdk/relationship-kinds/contract.d.ts +11 -12
  526. package/dist/sdk/relationship-migration.d.ts +6 -10
  527. package/dist/sdk/relationships.d.ts +22 -34
  528. package/dist/sdk/reproducibility/process.d.ts +7 -11
  529. package/dist/sdk/runtime/context.d.ts +6 -22
  530. package/dist/sdk/runtime/schema-preview.d.ts +1 -1
  531. package/dist/sdk/runtime-input.d.ts +9 -20
  532. package/dist/sdk/runtime-primitives.d.ts +3 -82
  533. package/dist/sdk/runtime-public-contracts.d.ts +30 -50
  534. package/dist/sdk/runtime.d.ts +77 -302
  535. package/dist/sdk/scheduling-shortcuts.d.ts +8 -12
  536. package/dist/sdk/schema-migration.d.ts +18 -80
  537. package/dist/sdk/schema.d.ts +89 -192
  538. package/dist/sdk/search-refresh-worker.d.ts +1 -1
  539. package/dist/sdk/similarity-scoring.d.ts +6 -8
  540. package/dist/sdk/similarity.d.ts +33 -64
  541. package/dist/sdk/start-task-status.d.ts +2 -2
  542. package/dist/sdk/stats.d.ts +13 -48
  543. package/dist/sdk/structured-mutations.d.ts +18 -26
  544. package/dist/sdk/telemetry-flush.d.ts +1 -1
  545. package/dist/sdk/telemetry.d.ts +14 -20
  546. package/dist/sdk/templates.d.ts +14 -35
  547. package/dist/sdk/test/batch.d.ts +10 -25
  548. package/dist/sdk/test/execution.d.ts +44 -209
  549. package/dist/sdk/test/json-path.d.ts +2 -5
  550. package/dist/sdk/test/linked-command-detection.d.ts +10 -25
  551. package/dist/sdk/test/measurements.d.ts +10 -13
  552. package/dist/sdk/test/parsers.d.ts +16 -20
  553. package/dist/sdk/test/prerequisites.d.ts +2 -3
  554. package/dist/sdk/test/runs.d.ts +19 -52
  555. package/dist/sdk/test/trust.d.ts +8 -12
  556. package/dist/sdk/test/update.d.ts +9 -25
  557. package/dist/sdk/testing.d.ts +97 -206
  558. package/dist/sdk/traceability/source-traceability.d.ts +25 -56
  559. package/dist/sdk/tracker-root-discovery.d.ts +1 -1
  560. package/dist/sdk/workspace-contracts-cache.d.ts +2 -2
  561. package/dist/sdk/workspace-contracts.d.ts +8 -14
  562. package/dist/sdk/workspace-memory.d.ts +24 -42
  563. package/dist/sdk/workspace-recipe.d.ts +10 -14
  564. package/dist/sdk/workspace-snapshot.d.ts +26 -53
  565. package/dist/sdk/workspace-transaction-gc.d.ts +12 -16
  566. package/dist/sdk/workspace-transaction.d.ts +26 -40
  567. package/dist/sdk/workspace.d.ts +8 -10
  568. package/dist/types/index.d.ts +1 -1
  569. package/dist/types.d.ts +210 -353
  570. package/docs/CODEX_PLUGIN.md +2 -1
  571. package/docs/COMMANDS.md +8 -0
  572. package/docs/CONFIGURATION.md +33 -0
  573. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +28 -9
  574. package/docs/MUTATION_INTEGRITY.md +65 -0
  575. package/docs/README.md +2 -2
  576. package/docs/RELEASING.md +25 -0
  577. package/docs/SDK.md +33 -2
  578. package/docs/TESTING.md +11 -0
  579. package/marketplace.json +1 -1
  580. package/package.json +2 -1
  581. package/packages/pm-beads/package.json +1 -1
  582. package/packages/pm-calendar/package.json +1 -1
  583. package/packages/pm-command-kit/package.json +1 -1
  584. package/packages/pm-digital-twin/package.json +1 -1
  585. package/packages/pm-governance-audit/package.json +1 -1
  586. package/packages/pm-guide-shell/package.json +1 -1
  587. package/packages/pm-kanban/package.json +1 -1
  588. package/packages/pm-lifecycle-hooks/package.json +1 -1
  589. package/packages/pm-linked-test-adapters/package.json +1 -1
  590. package/packages/pm-search-advanced/package.json +1 -1
  591. package/packages/pm-templates/package.json +1 -1
  592. package/packages/pm-todos/package.json +1 -1
  593. package/packages/pm-vcs/package.json +1 -1
  594. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  595. package/plugins/pm-claude/package.json +1 -1
  596. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  597. package/plugins/pm-codex/package.json +1 -1
  598. package/plugins/pm-codex/plugin.json +1 -1
  599. package/runtime-dependencies.json +1 -1
  600. package/scripts/finalize-build.mjs +41 -4
  601. package/dist/cli-bundle/chunks/chunk-ASJZMYKM.js +0 -122
  602. package/dist/cli-bundle/chunks/chunk-BLUCQ4T4.js +0 -2
  603. package/dist/cli-bundle/chunks/chunk-JYQXIC6C.js +0 -3
  604. package/dist/cli-bundle/chunks/chunk-LVDFPGD7.js +0 -3
  605. package/dist/cli-bundle/chunks/chunk-UFIM5ZC5.js +0 -6
  606. package/dist/cli-bundle/chunks/item-transaction-XBIN4KYM.js +0 -2
  607. package/dist/cli-bundle/focused-chunks/chunk-CUGJ2DY2.js +0 -24
  608. package/dist/cli-bundle/focused-chunks/chunk-HLQOGAWG.js +0 -26
  609. package/dist/cli-bundle/focused-chunks/chunk-IB6TCE7N.js +0 -2
  610. package/dist/cli-bundle/focused-chunks/chunk-JU62TKJP.js +0 -82
  611. package/dist/cli-bundle/focused-chunks/chunk-MYBKRV5R.js +0 -2
  612. package/dist/cli-bundle/focused-chunks/chunk-NUFO3OR6.js +0 -44
  613. package/docs/CHATGPT_CODEX_PLUGIN_IMPLEMENTATION.md +0 -776
@@ -3,12 +3,9 @@
3
3
  *
4
4
  * Implements the pm history compact command surface and its agent-facing runtime behavior.
5
5
  */
6
- import { type ItemRevisionConflictRowFields } from "./lifecycle/item-revision.js";
7
- import { type HistoryCompactBulkSkipReason,type HistoryCompactScope } from "../core/history/history-compact-bulk.js";
8
- import { type BulkIdsValue } from "../core/io/bulk-ids-input.js";
9
- import type { GlobalOptions } from "../core/shared/command-types.js";
6
+ import{type ItemRevisionConflictRowFields}from "./lifecycle/item-revision.js";import{type HistoryCompactBulkSkipReason,type HistoryCompactScope}from "../core/history/history-compact-bulk.js";import{type BulkIdsValue}from "../core/io/bulk-ids-input.js";import type{GlobalOptions}from "../core/shared/command-types.js";
10
7
  /** Documents the history compact command options payload exchanged by command, SDK, and package integrations. */
11
- export interface HistoryCompactCommandOptions {
8
+ export interface HistoryCompactCommandOptions{
12
9
  /** Value that configures or reports before for this contract. */
13
10
  before?:string;
14
11
  /** Value that configures or reports dry run for this contract. */
@@ -18,11 +15,10 @@ author?:string;
18
15
  /** Human-readable explanation suitable for logs and agent-facing output. */
19
16
  message?:string;
20
17
  /** Value that configures or reports force for this contract. */
21
- force?:boolean;
22
- }
23
- type HistoryCompactBoundaryKind = "default" | "version" | "timestamp";
18
+ force?:boolean;}
19
+ type HistoryCompactBoundaryKind="default"|"version"|"timestamp";
24
20
  /** Documents the history compact result payload exchanged by command, SDK, and package integrations. */
25
- export interface HistoryCompactResult {
21
+ export interface HistoryCompactResult{
26
22
  /** Stable identifier used to reference this record across commands and storage. */
27
23
  id:string;
28
24
  /** Value that configures or reports dry run for this contract. */
@@ -30,40 +26,21 @@ dry_run:boolean;
30
26
  /** Value that configures or reports changed for this contract. */
31
27
  changed:boolean;
32
28
  /** Value that configures or reports compact boundary for this contract. */
33
- compact_boundary:{
34
- kind:HistoryCompactBoundaryKind;
35
- before:string | null;
36
- entries_compacted:number;
37
- entries_retained:number;
38
- first_retained_entry:number | null;
39
- };
29
+ compact_boundary:{kind:HistoryCompactBoundaryKind;before:string|null;entries_compacted:number;entries_retained:number;first_retained_entry:number|null;};
40
30
  /** Value that configures or reports history for this contract. */
41
- history:{
42
- path:string;
43
- entries_scanned:number;
44
- entries_after:number;
45
- baseline_entry_added:boolean;
46
- audit_entry_added:boolean;
47
- verify_ok:boolean;
48
- verify_errors:string[];
49
- };
31
+ history:{path:string;entries_scanned:number;entries_after:number;baseline_entry_added:boolean;audit_entry_added:boolean;verify_ok:boolean;verify_errors:string[];};
50
32
  /** Value that configures or reports item for this contract. */
51
- item:{
52
- exists:boolean;
53
- path:string | null;
54
- matched_chain_before:boolean | null;
55
- };
33
+ item:{exists:boolean;path:string|null;matched_chain_before:boolean|null;};
56
34
  /** Value that configures or reports warnings for this contract. */
57
35
  warnings:string[];
58
36
  /** ISO 8601 timestamp recording when generated occurred. */
59
- generated_at:string;
60
- }
37
+ generated_at:string;}
61
38
  /** Implements run history compact for the public runtime surface of this module. */
62
39
  export declare function runHistoryCompact(id:string,options:HistoryCompactCommandOptions,global:GlobalOptions):Promise<HistoryCompactResult>;
63
40
  /** Default entry floor below which a stream is treated as already compact. */
64
- export declare const HISTORY_COMPACT_BULK_DEFAULT_MIN_ENTRIES = 3;
41
+ export declare const HISTORY_COMPACT_BULK_DEFAULT_MIN_ENTRIES=3;
65
42
  /** Documents the bulk history compact command options payload exchanged by command, SDK, and package integrations. */
66
- export interface HistoryCompactBulkCommandOptions {
43
+ export interface HistoryCompactBulkCommandOptions{
67
44
  /** Value that configures or reports ids for this contract. */
68
45
  ids?:BulkIdsValue;
69
46
  /** Value that configures or reports scope for this contract. */
@@ -79,60 +56,43 @@ author?:string;
79
56
  /** Human-readable explanation suitable for logs and agent-facing output. */
80
57
  message?:string;
81
58
  /** Value that configures or reports force for this contract. */
82
- force?:boolean;
83
- }
59
+ force?:boolean;}
84
60
  /** Per-item outcome row in a bulk compaction pass. */
85
- export interface HistoryCompactBulkItemResult extends ItemRevisionConflictRowFields {
61
+ export interface HistoryCompactBulkItemResult extends ItemRevisionConflictRowFields{
86
62
  /** Stable identifier used to reference this record across commands and storage. */
87
63
  id:string;
88
64
  /** Value that configures or reports outcome for this contract. */
89
- outcome:"compacted" | "skipped" | "errored";
65
+ outcome:"compacted"|"skipped"|"errored";
90
66
  /** Value that configures or reports entries before for this contract. */
91
67
  entries_before:number;
92
68
  /** Value that configures or reports entries after for this contract. */
93
- entries_after:number | null;
69
+ entries_after:number|null;
94
70
  /** Value that configures or reports skip reason for this contract. */
95
- skip_reason:HistoryCompactBulkSkipReason | null;
71
+ skip_reason:HistoryCompactBulkSkipReason|null;
96
72
  /** Value that configures or reports changed for this contract. */
97
73
  changed:boolean;
98
74
  /** Value that configures or reports error for this contract. */
99
- error:string | null;
100
- }
75
+ error:string|null;}
101
76
  /** Documents the bulk history compact result payload exchanged by command, SDK, and package integrations. */
102
- export interface HistoryCompactBulkResult {
77
+ export interface HistoryCompactBulkResult{
103
78
  /** Value that configures or reports bulk for this contract. */
104
79
  bulk:true;
105
80
  /** Value that configures or reports dry run for this contract. */
106
81
  dry_run:boolean;
107
82
  /** Value that configures or reports mode for this contract. */
108
- mode:"ids" | "scan";
83
+ mode:"ids"|"scan";
109
84
  /** Value that configures or reports scope for this contract. */
110
- scope:HistoryCompactScope | null;
85
+ scope:HistoryCompactScope|null;
111
86
  /** Value that configures or reports criteria for this contract. */
112
- criteria:{
113
- min_entries:number;
114
- all_over:number | null;
115
- policy_threshold_applied:boolean;
116
- };
87
+ criteria:{min_entries:number;all_over:number|null;policy_threshold_applied:boolean;};
117
88
  /** Value that configures or reports totals for this contract. */
118
- totals:{
119
- streams_considered:number;
120
- selected:number;
121
- items_compacted:number;
122
- items_skipped:number;
123
- items_errored:number;
124
- };
89
+ totals:{streams_considered:number;selected:number;items_compacted:number;items_skipped:number;items_errored:number;};
125
90
  /** Value that configures or reports results for this contract. */
126
91
  results:HistoryCompactBulkItemResult[];
127
92
  /** ISO 8601 timestamp recording when generated occurred. */
128
- generated_at:string;
129
- }
93
+ generated_at:string;}
130
94
  /** Enforce the `pm history-compact` target contract shared by the CLI and MCP surfaces: exactly one selection mode — a single item `<id>`, an explicit `--ids` list, or a scan selector (`--all-over` / `--closed` / `--all-streams`). */
131
- export declare function assertHistoryCompactTarget(id:string | undefined,bulk:{
132
- ids?:string[];
133
- allOver?:number;
134
- scope?:HistoryCompactScope;
135
- }):void;
95
+ export declare function assertHistoryCompactTarget(id:string|undefined,bulk:{ids?:string[];allOver?:number;scope?:HistoryCompactScope;}):void;
136
96
  /**
137
97
  * Bulk history compaction: compact every history stream matching the requested
138
98
  * selection (explicit `--ids`, a `--scope` lifecycle filter, and/or an
@@ -145,5 +105,4 @@ scope?:HistoryCompactScope;
145
105
  * given, the policy's `max_entries` is used as the scan threshold so the
146
106
  * configured policy drives the sweep.
147
107
  */
148
- export declare function runHistoryCompactBulk(options:HistoryCompactBulkCommandOptions,global:GlobalOptions):Promise<HistoryCompactBulkResult>;
149
- export {};
108
+ export declare function runHistoryCompactBulk(options:HistoryCompactBulkCommandOptions,global:GlobalOptions):Promise<HistoryCompactBulkResult>;export{};
@@ -4,26 +4,23 @@
4
4
  * Provides patch-free immutable-history provenance projections, filtering,
5
5
  * identity interpretation, and bounded coverage summaries.
6
6
  */
7
- import { type HarnessSignalDescriptor } from "../core/shared/author.js";
8
- import type { HistoryEntry } from "../types.js";
7
+ import{type HarnessSignalDescriptor}from "../core/shared/author.js";import type{HistoryEntry}from "../types.js";
9
8
  /** Versioned, workspace-owned interpretation of legacy author spellings. */
10
- export interface AuthorIdentityVocabulary {
9
+ export interface AuthorIdentityVocabulary{
11
10
  /** Reproducible revision included in projections and summaries. */
12
11
  version:number;
13
12
  /** Exact author literals mapped to canonical harness namespaces. */
14
- aliases:Readonly<Record<string,string>>;
15
- }
13
+ aliases:Readonly<Record<string,string>>;}
16
14
  /** Read predicates shared by history, activity, events, and SDK consumers. */
17
- export interface HistoryProvenanceFilters {
15
+ export interface HistoryProvenanceFilters{
18
16
  /** Canonical recorded or vocabulary-resolved harness namespace. */
19
- harness?:string | readonly string[];
17
+ harness?:string|readonly string[];
20
18
  /** Privacy-safe invocation fingerprint. */
21
- agentInstance?:string | readonly string[];
19
+ agentInstance?:string|readonly string[];
22
20
  /** Dimension predicates expressed as exact `dimension=value` pairs. */
23
- provenance?:string | readonly string[];
24
- }
21
+ provenance?:string|readonly string[];}
25
22
  /** Patch-free identity and provenance projection for one immutable event. */
26
- export interface HistoryProvenanceRow {
23
+ export interface HistoryProvenanceRow{
27
24
  /** Optional history stream subject supplied by a collection reader. */
28
25
  item_id?:string;
29
26
  /** Optional one-based stream version supplied by a collection reader. */
@@ -39,7 +36,7 @@ author_source?:HistoryEntry["author_source"];
39
36
  /** Recorded harness or read-time alias interpretation. */
40
37
  agent_harness?:string;
41
38
  /** Whether the harness was recorded, interpreted, or remains unresolved. */
42
- harness_source:"recorded" | "vocabulary" | "unresolved";
39
+ harness_source:"recorded"|"vocabulary"|"unresolved";
43
40
  /** Vocabulary revision used for this interpretation. */
44
41
  vocabulary_version:number;
45
42
  /** Privacy-safe invocation fingerprint. */
@@ -47,10 +44,9 @@ agent_instance?:string;
47
44
  /** Every recorded extensible provenance observation, without patch payloads. */
48
45
  agent_provenance:NonNullable<HistoryEntry["agent_provenance"]>;
49
46
  /** Optional event message. */
50
- message?:string;
51
- }
47
+ message?:string;}
52
48
  /** Constant-size provenance coverage report over an inspected history set. */
53
- export interface HistoryProvenanceSummary {
49
+ export interface HistoryProvenanceSummary{
54
50
  /** Number of immutable entries inspected. */
55
51
  entries:number;
56
52
  /** Vocabulary revision used for legacy interpretation. */
@@ -62,19 +58,9 @@ resolved:number;
62
58
  /** Entries without a recorded or interpreted harness. */
63
59
  unresolved:number;
64
60
  /** Most frequent unresolved author literals, bounded to twenty rows. */
65
- unresolved_authors:Array<{
66
- author:string;
67
- entries:number;
68
- }>;
69
- };
61
+ unresolved_authors:Array<{author:string;entries:number;}>;};
70
62
  /** Availability counts for every observed or declared dimension. */
71
- dimensions:Array<{
72
- dimension:string;
73
- observed:number;
74
- unavailable:number;
75
- legacy_missing:number;
76
- }>;
77
- }
63
+ dimensions:Array<{dimension:string;observed:number;unavailable:number;legacy_missing:number;}>;}
78
64
  /** Default interpretation used when a legacy workspace has no vocabulary. */
79
65
  export declare const DEFAULT_AUTHOR_IDENTITY_VOCABULARY:AuthorIdentityVocabulary;
80
66
  /** Resolve the extensible dimension vocabulary declared by built-ins and workspace descriptors. */
@@ -82,13 +68,10 @@ export declare function resolveHistoryProvenanceDimensions(descriptors?:readonly
82
68
  /** Parse and validate exact provenance dimension predicates. */
83
69
  export declare function parseHistoryProvenanceFilters(filters:HistoryProvenanceFilters,dimensions?:readonly string[]):Map<string,Set<string>>;
84
70
  /** Project one immutable entry without its JSON Patch or document hashes. */
85
- export declare function projectHistoryProvenance(entry:HistoryEntry,vocabulary?:AuthorIdentityVocabulary,coordinates?:{
86
- itemId?:string;
87
- version?:number;
88
- }):HistoryProvenanceRow;
71
+ export declare function projectHistoryProvenance(entry:HistoryEntry,vocabulary?:AuthorIdentityVocabulary,coordinates?:{itemId?:string;version?:number;}):HistoryProvenanceRow;
89
72
  /** Test one immutable entry against shared provenance predicates. */
90
73
  export declare function historyEntryMatchesProvenance(entry:HistoryEntry,filters:HistoryProvenanceFilters,vocabulary?:AuthorIdentityVocabulary,dimensions?:readonly string[]):boolean;
91
74
  /** Compile shared provenance predicates once for efficient history scans. */
92
- export declare function compileHistoryProvenanceMatcher(filters:HistoryProvenanceFilters,vocabulary?:AuthorIdentityVocabulary,dimensions?:readonly string[]):(entry:HistoryEntry) => boolean;
75
+ export declare function compileHistoryProvenanceMatcher(filters:HistoryProvenanceFilters,vocabulary?:AuthorIdentityVocabulary,dimensions?:readonly string[]):(entry:HistoryEntry)=> boolean;
93
76
  /** Summarize identity and dimension completeness without returning event rows. */
94
- export declare function summarizeHistoryProvenance(entries:readonly HistoryEntry[],vocabulary?:AuthorIdentityVocabulary,dimensions?:readonly string[]):HistoryProvenanceSummary;
77
+ export declare function summarizeHistoryProvenance(entries:readonly HistoryEntry[],vocabulary?:AuthorIdentityVocabulary,dimensions?:readonly string[]):HistoryProvenanceSummary;
@@ -1,31 +1,26 @@
1
- import { applyHistoryPatch,ensureMaterializedHistoryTarget,extractPatchFailureContext,replayHistoryToTarget,resolveHistoryTarget,type ResolvedHistoryTarget } from "../core/history/projection.js";
2
- import { readHistoryEntries } from "../core/history/read.js";
3
- import type { HistoryEntry,ItemDocument } from "../types/index.js";
4
- export { findHistoryIdentityDiscontinuities,type HistoryIdentityDiscontinuity,} from "../core/history/identity.js";
1
+ import{applyHistoryPatch,ensureMaterializedHistoryTarget,extractPatchFailureContext,replayHistoryToTarget,resolveHistoryTarget,type ResolvedHistoryTarget}from "../core/history/projection.js";import{readHistoryEntries}from "../core/history/read.js";import type{HistoryEntry,ItemDocument}from "../types/index.js";export{findHistoryIdentityDiscontinuities,type HistoryIdentityDiscontinuity,}from "../core/history/identity.js";
5
2
  /** Workspace resolution controls accepted by {@link getItemAt}. */
6
- export interface GetItemAtOptions {
3
+ export interface GetItemAtOptions{
7
4
  /** Explicit tracker root, equivalent to the CLI global `--pm-path`. */
8
5
  pmRoot?:string;
9
6
  /** Working directory used when discovering the nearest tracker. */
10
- cwd?:string;
11
- }
7
+ cwd?:string;}
12
8
  /** Verified historical item projection returned by {@link getItemAt}. */
13
- export interface GetItemAtResult {
9
+ export interface GetItemAtResult{
14
10
  /** Reconstructed canonical item document at the selected version. */
15
11
  document:ItemDocument;
16
12
  /** Always true, preventing consumers from confusing this with current state. */
17
13
  reconstructed:true;
18
14
  /** Durable one-based version; null when a legacy checkpoint lost its mapping. */
19
- as_of_version:number | null;
15
+ as_of_version:number|null;
20
16
  /** Timestamp of the final included history entry. */
21
17
  as_of_timestamp:string;
22
18
  /** Normalized target resolution metadata shared with restore. */
23
19
  target:ResolvedHistoryTarget;
24
20
  /** Total number of entries currently available in the stream. */
25
- history_length:number;
26
- }
21
+ history_length:number;}
27
22
  /** Verification projection shared by CLI history reads and SDK consumers. */
28
- export interface HistoryVerificationResult {
23
+ export interface HistoryVerificationResult{
29
24
  /** Whether the hash chain and optional current document both verify. */
30
25
  ok:boolean;
31
26
  /** Number of entries verified. */
@@ -45,8 +40,7 @@ workspace_state_mismatches?:string[];
45
40
  /** Governed singleton paths absent from disk. */
46
41
  workspace_state_missing?:string[];
47
42
  /** Governed singleton paths unreadable as safe workspace-local JSON. */
48
- workspace_state_unreadable?:string[];
49
- }
43
+ workspace_state_unreadable?:string[];}
50
44
  /**
51
45
  * Verify a history chain and optionally compare it with a current document.
52
46
  *
@@ -59,5 +53,4 @@ export declare function verifyHistoryEntries(history:HistoryEntry[],currentDocum
59
53
  * Reconstruct one item at a one-based version or ISO timestamp without locks,
60
54
  * item writes, history writes, or derived-index mutations.
61
55
  */
62
- export declare function getItemAt(id:string,target:string,options?:GetItemAtOptions):Promise<GetItemAtResult>;
63
- export { applyHistoryPatch,ensureMaterializedHistoryTarget,extractPatchFailureContext,readHistoryEntries,replayHistoryToTarget,resolveHistoryTarget,};
56
+ export declare function getItemAt(id:string,target:string,options?:GetItemAtOptions):Promise<GetItemAtResult>;export{applyHistoryPatch,ensureMaterializedHistoryTarget,extractPatchFailureContext,readHistoryEntries,replayHistoryToTarget,resolveHistoryTarget,};
@@ -1,12 +1,10 @@
1
- export { resolveHistorySubject,type HistorySubject,} from "./history/subject.js";
2
- import { type ReplayDocument } from "../core/history/replay.js";
3
- import type { GlobalOptions } from "../core/shared/command-types.js";
1
+ export{resolveHistorySubject,type HistorySubject,}from "./history/subject.js";import{type ReplayDocument}from "../core/history/replay.js";import type{GlobalOptions}from "../core/shared/command-types.js";
4
2
  /** Documents the history redact command options payload exchanged by command, SDK, and package integrations. */
5
- export interface HistoryRedactCommandOptions {
3
+ export interface HistoryRedactCommandOptions{
6
4
  /** Value that configures or reports literal for this contract. */
7
- literal?:string[] | string;
5
+ literal?:string[]|string;
8
6
  /** Value that configures or reports regex for this contract. */
9
- regex?:string[] | string;
7
+ regex?:string[]|string;
10
8
  /** Value that configures or reports replacement for this contract. */
11
9
  replacement?:string;
12
10
  /** Value that configures or reports dry run for this contract. */
@@ -16,20 +14,12 @@ author?:string;
16
14
  /** Human-readable explanation suitable for logs and agent-facing output. */
17
15
  message?:string;
18
16
  /** Value that configures or reports force for this contract. */
19
- force?:boolean;
20
- }
21
- interface RegexRule {
22
- kind:"regex";
23
- source:string;
24
- flags:string;
25
- }
26
- interface LiteralRule {
27
- kind:"literal";
28
- value:string;
29
- }
30
- type RedactionRule = RegexRule | LiteralRule;
17
+ force?:boolean;}
18
+ interface RegexRule{kind:"regex";source:string;flags:string;}
19
+ interface LiteralRule{kind:"literal";value:string;}
20
+ type RedactionRule=RegexRule|LiteralRule;
31
21
  /** Documents the history redact result payload exchanged by command, SDK, and package integrations. */
32
- export interface HistoryRedactResult {
22
+ export interface HistoryRedactResult{
33
23
  /** Stable identifier used to reference this record across commands and storage. */
34
24
  id:string;
35
25
  /** Value that configures or reports dry run for this contract. */
@@ -45,66 +35,21 @@ regex_count:number;
45
35
  /** Total number of accepted matchers across both matcher kinds. */
46
36
  total_count:number;
47
37
  /** Whether the canonical default replacement was selected implicitly. */
48
- replacement_is_default:boolean;
49
- };
38
+ replacement_is_default:boolean;};
50
39
  /** Value that configures or reports history for this contract. */
51
- history:{
52
- path:string;
53
- entries_scanned:number;
54
- entries_changed:number;
55
- replacements:number;
56
- hash_mismatches_before:number;
57
- hash_mismatches_after:number;
58
- preexisting_hash_mismatches:number;
59
- audit_entry_added:boolean;
60
- verify_ok:boolean;
61
- verify_errors:string[];
62
- };
40
+ history:{path:string;entries_scanned:number;entries_changed:number;replacements:number;hash_mismatches_before:number;hash_mismatches_after:number;preexisting_hash_mismatches:number;audit_entry_added:boolean;verify_ok:boolean;verify_errors:string[];};
63
41
  /** Value that configures or reports item for this contract. */
64
- item:{
65
- existed_before:boolean;
66
- exists_after:boolean;
67
- path_before:string | null;
68
- path_after:string | null;
69
- changed:boolean;
70
- };
42
+ item:{existed_before:boolean;exists_after:boolean;path_before:string|null;path_after:string|null;changed:boolean;};
71
43
  /** Value that configures or reports warnings for this contract. */
72
44
  warnings:string[];
73
45
  /** ISO 8601 timestamp recording when generated occurred. */
74
- generated_at:string;
75
- }
76
- declare function normalizeStringArrayInput(value:string[] | string | undefined):string[];
77
- declare function normalizeRegexFlags(flags:string):string;
78
- declare function parseRegexRule(spec:string):RegexRule;
79
- declare function buildRedactionRules(literalInput:string[] | string | undefined,regexInput:string[] | string | undefined):RedactionRule[];
80
- declare function applyLiteralRule(value:string,literal:string,replacement:string):{
81
- value:string;
82
- replacements:number;
83
- };
84
- declare function applyRegexRule(value:string,rule:RegexRule,replacement:string):{
85
- value:string;
86
- replacements:number;
87
- };
88
- declare function redactStringValue(value:string,rules:RedactionRule[],replacement:string):{
89
- value:string;
90
- replacements:number;
91
- };
92
- declare function redactUnknownValue(value:unknown,rules:RedactionRule[],replacement:string):{
93
- value:unknown;
94
- replacements:number;
95
- };
96
- declare function hasItemMetadata(replay:ReplayDocument):boolean;
46
+ generated_at:string;}
47
+ declare function normalizeStringArrayInput(value:string[]|string|undefined):string[];declare function normalizeRegexFlags(flags:string):string;
48
+ /** Distinguish literals by their final unescaped delimiter and flag spelling, then validate without echoing sensitive matcher input. */
49
+ declare function parseRegexRule(spec:string,index?:number):RegexRule;
50
+ /** Deduplicate matchers while preserving original regex positions in validation failures, and refuse an empty matcher set. */
51
+ declare function buildRedactionRules(literalInput:string[]|string|undefined,regexInput:string[]|string|undefined):RedactionRule[];declare function applyLiteralRule(value:string,literal:string,replacement:string):{value:string;replacements:number;};declare function applyRegexRule(value:string,rule:RegexRule,replacement:string):{value:string;replacements:number;};declare function redactStringValue(value:string,rules:RedactionRule[],replacement:string):{value:string;replacements:number;};declare function redactUnknownValue(value:unknown,rules:RedactionRule[],replacement:string):{value:unknown;replacements:number;};declare function hasItemMetadata(replay:ReplayDocument):boolean;
97
52
  /** Implements run history redact for the public runtime surface of this module. */
98
53
  export declare function runHistoryRedact(id:string,options:HistoryRedactCommandOptions,global:GlobalOptions):Promise<HistoryRedactResult>;
99
54
  /** Public contract for test only, shared by SDK and presentation-layer consumers. */
100
- export declare const _testOnly:{
101
- applyLiteralRule:typeof applyLiteralRule;
102
- applyRegexRule:typeof applyRegexRule;
103
- buildRedactionRules:typeof buildRedactionRules;
104
- hasItemMetadata:typeof hasItemMetadata;
105
- normalizeRegexFlags:typeof normalizeRegexFlags;
106
- normalizeStringArrayInput:typeof normalizeStringArrayInput;
107
- parseRegexRule:typeof parseRegexRule;
108
- redactStringValue:typeof redactStringValue;
109
- redactUnknownValue:typeof redactUnknownValue;
110
- };
55
+ export declare const _testOnly:{applyLiteralRule:typeof applyLiteralRule;applyRegexRule:typeof applyRegexRule;buildRedactionRules:typeof buildRedactionRules;hasItemMetadata:typeof hasItemMetadata;normalizeRegexFlags:typeof normalizeRegexFlags;normalizeStringArrayInput:typeof normalizeStringArrayInput;parseRegexRule:typeof parseRegexRule;redactStringValue:typeof redactStringValue;redactUnknownValue:typeof redactUnknownValue;};
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ebf3254f-1fed-5972-b91a-b8ff101675f4")}catch{}})();import{resolveHistoryWorkspace,resolveHistorySubject}from"./history/subject.js";import{resolveHistorySubject as resolveHistorySubject2}from"./history/subject.js";import fs from"node:fs/promises";import{resolveHistoryHashAlgorithm}from"../core/history/digest.js";import{writeFileAtomic}from"../core/fs/fs-utils.js";import{createHistoryEntry,resealHistoryRewrite,verifyHistoryRecordHash}from"../core/history/history.js";import{invalidateHistoryDriftCacheForPath}from"../core/history/drift-cache.js";import{runHistoryMaintenance}from"./history/maintenance.js";import{EMPTY_REPLAY_DOCUMENT,historyEntriesToRaw,replayHash,replayToItemDocument}from"../core/history/replay.js";import{applyHistoryPatch}from"../core/history/projection.js";import{canonicalDocument,serializeItemDocument}from"../core/item/item-format.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{nowIso}from"../core/shared/time.js";import{runActiveOnWriteHooks}from"../core/extensions/index.js";import{acquireItemMetadataDerivedIndexLock,refreshItemMetadataDerivedIndex}from"../core/store/item-metadata-cache.js";import{getItemPath}from"../core/store/paths.js";function normalizeStringArrayInput(value){return Array.isArray(value)?value:typeof value=="string"?[value]:[]}function normalizeRegexFlags(flags){const unique=[];for(const token of flags)unique.includes(token)||unique.push(token);return unique.includes("g")||unique.push("g"),unique.join("")}function parseRegexRule(spec){const trimmed=spec.trim();if(trimmed.length===0)throw new PmCliError("history-redact --regex requires a non-empty pattern.",EXIT_CODE.USAGE);let source=trimmed,flags="g";if(trimmed.startsWith("/")&&trimmed.length>1){const slashIndex=trimmed.lastIndexOf("/");slashIndex>0&&(source=trimmed.slice(1,slashIndex),flags=normalizeRegexFlags(trimmed.slice(slashIndex+1)))}if(source.length===0)throw new PmCliError("history-redact --regex cannot use an empty pattern.",EXIT_CODE.USAGE);try{new RegExp(source,flags)}catch{throw new PmCliError("Invalid --regex value; provide a valid JavaScript regular expression.",EXIT_CODE.USAGE)}return{kind:"regex",source,flags}}function buildRedactionRules(literalInput,regexInput){const literalRules=[...new Set(normalizeStringArrayInput(literalInput).map(entry=>entry.trim()))].filter(entry=>entry.length>0).map(entry=>({kind:"literal",value:entry})),regexRules=[...new Set(normalizeStringArrayInput(regexInput).map(entry=>entry.trim()))].filter(entry=>entry.length>0).map(parseRegexRule),rules=[...literalRules,...regexRules];if(rules.length===0)throw new PmCliError("history-redact requires at least one matcher via --literal or --regex.",EXIT_CODE.USAGE,{code:"missing_required_argument",required:"Provide --literal <value> and/or --regex <pattern>.",examples:['pm history-redact pm-a1b2 --literal "[redacted_path_prefix]/private"','pm history-redact pm-a1b2 --regex "/192\\\\.168\\\\.[0-9.]+/g" --replacement "[scrubbed_ip]"']});return rules}function applyLiteralRule(value,literal,replacement){if(literal.length===0)return{value,replacements:0};let cursor=0,replacements=0;for(;cursor<=value.length;){const index=value.indexOf(literal,cursor);if(index===-1)break;replacements+=1,cursor=index+Math.max(1,literal.length)}return replacements===0?{value,replacements:0}:{value:value.split(literal).join(replacement),replacements}}function applyRegexRule(value,rule,replacement){const regex=new RegExp(rule.source,rule.flags),matches=[...value.matchAll(regex)];return matches.length===0?{value,replacements:0}:{value:value.replace(regex,replacement),replacements:matches.length}}function redactStringValue(value,rules,replacement){let next=value,replacements=0;for(const rule of rules){const result=rule.kind==="literal"?applyLiteralRule(next,rule.value,replacement):applyRegexRule(next,rule,replacement);next=result.value,replacements+=result.replacements}return{value:next,replacements}}function redactUnknownValue(value,rules,replacement){if(typeof value=="string")return redactStringValue(value,rules,replacement);if(Array.isArray(value)){let replacements=0;return{value:value.map(entry=>{const redacted=redactUnknownValue(entry,rules,replacement);return replacements+=redacted.replacements,redacted.value}),replacements}}if(typeof value=="object"&&value!==null){let replacements=0;const nextRecord={};for(const[key,entry]of Object.entries(value)){const redacted=redactUnknownValue(entry,rules,replacement);replacements+=redacted.replacements,nextRecord[key]=redacted.value}return{value:nextRecord,replacements}}return{value,replacements:0}}function redactHistoryPatch(patch,rules,replacement){let replacements=0;return{patch:patch.map(operation=>{if(!Object.prototype.hasOwnProperty.call(operation,"value"))return operation;const redactedValue=redactUnknownValue(operation.value,rules,replacement);return replacements+=redactedValue.replacements,redactedValue.replacements>0?{...operation,value:redactedValue.value}:operation}),replacements}}function inspectHistoryIntegrity(entries){let replay=structuredClone(EMPTY_REPLAY_DOCUMENT),hashMismatchesBefore=0,hashMismatchesAfter=0;for(let index=0;index<entries.length;index+=1){const entry=entries[index];replayHash(replay,void 0,resolveHistoryHashAlgorithm(entry.hash_algorithm))!==entry.before_hash&&(hashMismatchesBefore+=1),replay=applyHistoryPatch(replay,entry.patch,index+1,entry.op),replayHash(replay,void 0,resolveHistoryHashAlgorithm(entry.hash_algorithm))!==entry.after_hash&&(hashMismatchesAfter+=1)}return{hashMismatchesBefore,hashMismatchesAfter,finalDocument:replay}}function redactHistoryEntry(entry,rules,replacement){let replacements=0,changed=!1,reanchorEvidenceRedacted=!1,nextMessage=entry.message;if(typeof entry.message=="string"){const redactedMessage=redactStringValue(entry.message,rules,replacement);nextMessage=redactedMessage.value,replacements+=redactedMessage.replacements,redactedMessage.replacements>0&&(changed=!0)}const redactedPatch=redactHistoryPatch(entry.patch,rules,replacement);replacements+=redactedPatch.replacements,changed||=redactedPatch.replacements>0;const nextReanchorEvidence=entry.reanchor_evidence?.map(evidence=>{const redactedEvidencePatch=evidence.patch?redactHistoryPatch(evidence.patch,rules,replacement):{patch:void 0,replacements:0},redactedEvidenceRecord=evidence.record?redactUnknownValue(evidence.record,rules,replacement):{value:void 0,replacements:0};replacements+=redactedEvidencePatch.replacements,replacements+=redactedEvidenceRecord.replacements;const evidenceChanged=redactedEvidencePatch.replacements>0||redactedEvidenceRecord.replacements>0;if(changed||=evidenceChanged,!evidenceChanged)return evidence;reanchorEvidenceRedacted=!0;const{patch:_sensitivePatch,record:_sensitiveRecord,record_hash:_priorRecordHash,record_hash_version:_priorRecordHashVersion,...digestOnlyEvidence}=evidence;return redactedEvidencePatch.replacements>0?digestOnlyEvidence:{...digestOnlyEvidence,patch:evidence.patch}});return{entry:{...entry,message:nextMessage,patch:redactedPatch.patch,...nextReanchorEvidence?{reanchor_evidence:nextReanchorEvidence}:{}},replacements,changed,reanchorEvidenceRedacted}}function rewriteHistoryEntries(entries,rules,replacement){let replay=structuredClone(EMPTY_REPLAY_DOCUMENT),entriesChanged=0,replacements=0;const rewrittenEntries=[];for(let index=0;index<entries.length;index+=1){const original=entries[index],recordVerification=verifyHistoryRecordHash(original);if(!recordVerification.ok)throw new PmCliError(`history-redact refuses invalid immutable record ${index+1} (${recordVerification.error}).`,EXIT_CODE.GENERIC_FAILURE);const redacted=redactHistoryEntry(original,rules,replacement);replacements+=redacted.replacements,redacted.changed&&(entriesChanged+=1);const beforeHash=replayHash(replay,void 0,resolveHistoryHashAlgorithm(original.hash_algorithm));replay=applyHistoryPatch(replay,redacted.entry.patch,index+1,redacted.entry.op);const afterHash=replayHash(replay,void 0,resolveHistoryHashAlgorithm(original.hash_algorithm));rewrittenEntries.push(resealHistoryRewrite(original,{...redacted.entry,before_hash:beforeHash,after_hash:afterHash},{retainPriorRecord:redacted.changed,retainPriorRecordHash:!redacted.changed}))}return{entries:rewrittenEntries,finalDocument:replay,entriesChanged,replacements}}function hasItemMetadata(replay){return Object.keys(replay.metadata).length>0}function resolveHistoryRedactNextItem(params){if(!hasItemMetadata(params.finalDocument))return{raw:null,path:null,document:null};const canonical=canonicalDocument(replayToItemDocument(params.finalDocument),{schema:params.settings.schema});if(canonical.metadata.id!==params.subject.id)throw new PmCliError("history-redact would change the item id; narrow your patterns.",EXIT_CODE.USAGE);return{document:canonical,path:getItemPath(params.pmRoot,canonical.metadata.type,params.subject.id,"toon",params.typeToFolder),raw:serializeItemDocument(canonical,{format:"toon",schema:params.settings.schema})}}function buildHistoryRedactMessage(options,rewritten){return typeof options.message=="string"&&options.message.trim().length>0?options.message:`history-redact replaced ${rewritten.replacements} match(es) across ${rewritten.entriesChanged} entr${rewritten.entriesChanged===1?"y":"ies"}.`}function buildHistoryRedactEntries(params){const rewrittenEntries=[...params.rewritten.entries];if(params.dryRun||!params.changed)return{rewrittenEntries,auditEntryAdded:!1};const finalDocument=params.nextItemDocument??replayToItemDocument(params.rewritten.finalDocument);return rewrittenEntries.push(createHistoryEntry({nowIso:nowIso(),author:params.author,op:"history_redact",before:finalDocument,after:finalDocument,message:params.message})),{rewrittenEntries,auditEntryAdded:!0}}function createHistoryRedactTransaction(params){let derivedIndexWarnings=[];return{applyRewrite:async({historyRawUnderLock})=>{const releaseDerivedIndexLock=await acquireItemMetadataDerivedIndexLock(params.pmRoot,params.author),affectedItemPaths=new Set;params.currentItem.path&&affectedItemPaths.add(params.currentItem.path),params.nextItem.path&&affectedItemPaths.add(params.nextItem.path);const itemSnapshots=new Map;params.currentItem.path&&params.currentItem.raw!==null&&itemSnapshots.set(params.currentItem.path,params.currentItem.raw);let rethrowReleaseFailure=()=>{};try{try{params.nextItem.path&&params.nextItem.raw!==null&&params.nextItem.raw!==params.currentItem.raw&&await writeFileAtomic(params.nextItem.path,params.nextItem.raw),params.currentItem.path&&(!params.nextItem.path||params.nextItem.path!==params.currentItem.path)&&await fs.rm(params.currentItem.path,{force:!0}),await writeFileAtomic(params.subject.historyPath,historyEntriesToRaw(params.rewrittenEntries))}catch(error){try{await rollbackHistoryRedactRewrite(params.subject.historyPath,historyRawUnderLock,affectedItemPaths,itemSnapshots)}finally{await invalidateHistoryDriftCacheForPath(params.subject.historyPath)}throw error}await invalidateHistoryDriftCacheForPath(params.subject.historyPath);const itemPath=params.nextItem.path??params.currentItem.path;itemPath&&(derivedIndexWarnings=await refreshItemMetadataDerivedIndex({pmRoot:params.pmRoot,preferredFormat:params.settings.item_format,typeToFolder:params.typeRegistry.type_to_folder,schema:params.settings.schema,itemPath,...params.currentItem.path?{previousItemPath:params.currentItem.path}:{},document:params.nextItem.document}))}finally{await releaseDerivedIndexLock().catch(error=>{rethrowReleaseFailure=()=>{throw error}})}rethrowReleaseFailure()},afterWrite:async()=>[...derivedIndexWarnings,...await runHistoryRedactWriteHooks(params.subject.historyPath,[params.nextItem.path,params.currentItem.path])]}}async function rollbackHistoryRedactRewrite(historyPath,historyRawUnderLock,affectedItemPaths,itemSnapshots){historyRawUnderLock===null?await fs.rm(historyPath,{force:!0}):await writeFileAtomic(historyPath,historyRawUnderLock);for(const itemPath of affectedItemPaths){const snapshot=itemSnapshots.get(itemPath);snapshot===void 0?await fs.rm(itemPath,{force:!0}):await writeFileAtomic(itemPath,snapshot)}}async function runHistoryRedactWriteHooks(historyPath,itemHookPaths){const hookWarnings=[],uniqueItemHookPaths=new Set(itemHookPaths.filter(itemPath=>itemPath!==null));for(const itemHookPath of uniqueItemHookPaths)hookWarnings.push(...await runActiveOnWriteHooks({path:itemHookPath,scope:"project",op:"history_redact"}));return hookWarnings.push(...await runActiveOnWriteHooks({path:historyPath,scope:"project",op:"history_redact:history"})),hookWarnings}async function runHistoryRedact(id,options,global2){const{pmRoot,settings,typeRegistry}=await resolveHistoryWorkspace(global2.path),replacementInput=options.replacement??"",replacementIsDefault=replacementInput.length===0,replacement=replacementIsDefault?"[redacted]":replacementInput,rules=buildRedactionRules(options.literal,options.regex),subject=await resolveHistorySubject(pmRoot,id,settings,typeRegistry.type_to_folder);return runHistoryMaintenance({pmRoot,subject,settings,typeRegistry,operation:"history-redact",options,transform:snapshot=>buildHistoryRedactPlan({pmRoot,subject,settings,typeRegistry,options,rules,replacement,replacementIsDefault},snapshot)})}function buildHistoryRedactPlan(params,snapshot){const{pmRoot,subject,settings,typeRegistry,options,rules,replacement,replacementIsDefault}=params,historyEntries=snapshot.entries,integritySnapshot=inspectHistoryIntegrity(historyEntries),rewritten=rewriteHistoryEntries(historyEntries,rules,replacement),preexistingHashMismatches=integritySnapshot.hashMismatchesBefore+integritySnapshot.hashMismatchesAfter,dryRun=!!options.dryRun,changed=rewritten.replacements>0,warnings=[];preexistingHashMismatches>0&&warnings.push(`history_redact_preexisting_hash_mismatches:${preexistingHashMismatches}`),changed||warnings.push("history_redact_no_matches");const currentItem={raw:snapshot.loadedItem?.raw??null,path:subject.located?.itemPath??null,document:snapshot.loadedItem?.document??null},nextItem=resolveHistoryRedactNextItem({pmRoot,subject,settings,typeToFolder:typeRegistry.type_to_folder,finalDocument:rewritten.finalDocument}),itemChanged=(currentItem.path??null)!==(nextItem.path??null)||(currentItem.raw??null)!==(nextItem.raw??null),author=snapshot.author,redactionMessage=buildHistoryRedactMessage(options,rewritten),{rewrittenEntries,auditEntryAdded}=buildHistoryRedactEntries({rewritten,dryRun,changed,nextItemDocument:nextItem.document,author,message:redactionMessage});return{changed,rewrittenEntries,...createHistoryRedactTransaction({pmRoot,subject,settings,typeRegistry,currentItem,nextItem,author,rewrittenEntries}),report:({verification:historyVerify,warnings:writeWarnings})=>({id:subject.id,dry_run:dryRun,changed,patterns:{literal_count:rules.filter(rule=>rule.kind==="literal").length,regex_count:rules.filter(rule=>rule.kind==="regex").length,total_count:rules.length,replacement_is_default:replacementIsDefault},history:{path:subject.historyPath,entries_scanned:historyEntries.length,entries_changed:rewritten.entriesChanged,replacements:rewritten.replacements,hash_mismatches_before:integritySnapshot.hashMismatchesBefore,hash_mismatches_after:integritySnapshot.hashMismatchesAfter,preexisting_hash_mismatches:preexistingHashMismatches,audit_entry_added:auditEntryAdded,verify_ok:historyVerify.ok,verify_errors:historyVerify.errors},item:{existed_before:currentItem.path!==null,exists_after:nextItem.path!==null,path_before:currentItem.path,path_after:nextItem.path,changed:itemChanged},warnings:[...new Set([...warnings,...writeWarnings])].sort((left,right)=>left.localeCompare(right)),generated_at:nowIso()})}}const _testOnly={applyLiteralRule,applyRegexRule,buildRedactionRules,hasItemMetadata,normalizeRegexFlags,normalizeStringArrayInput,parseRegexRule,redactStringValue,redactUnknownValue};export{_testOnly,resolveHistorySubject2 as resolveHistorySubject,runHistoryRedact};
1
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="99336062-727a-5797-8586-117c3c106dcc")}catch{}})();import{resolveHistoryWorkspace,resolveHistorySubject}from"./history/subject.js";import{resolveHistorySubject as resolveHistorySubject2}from"./history/subject.js";import fs from"node:fs/promises";import{resolveHistoryHashAlgorithm}from"../core/history/digest.js";import{writeFileAtomic}from"../core/fs/fs-utils.js";import{createHistoryEntry,resealHistoryRewrite,verifyHistoryRecordHash}from"../core/history/history.js";import{invalidateHistoryDriftCacheForPath}from"../core/history/drift-cache.js";import{runHistoryMaintenance}from"./history/maintenance.js";import{EMPTY_REPLAY_DOCUMENT,historyEntriesToRaw,replayHash,replayToItemDocument}from"../core/history/replay.js";import{applyHistoryPatch}from"../core/history/projection.js";import{canonicalDocument,serializeItemDocument}from"../core/item/item-format.js";import{EXIT_CODE}from"../core/shared/constants.js";import{PmCliError}from"../core/shared/errors.js";import{nowIso}from"../core/shared/time.js";import{runActiveOnWriteHooks}from"../core/extensions/index.js";import{acquireItemMetadataDerivedIndexLock,refreshItemMetadataDerivedIndex}from"../core/store/item-metadata-cache.js";import{getItemPath}from"../core/store/paths.js";function normalizeStringArrayInput(value){return Array.isArray(value)?value:typeof value=="string"?[value]:[]}function normalizeRegexFlags(flags){const unique=[];for(const token of flags)unique.includes(token)||unique.push(token);return unique.includes("g")||unique.push("g"),unique.join("")}function invalidRegexRule(index,reason){return new PmCliError(`Invalid --regex value at --regex #${index}: ${reason}`,EXIT_CODE.USAGE,{code:"invalid_argument_value",field:"regex",reason:"invalid_regex",changed:!1,required:`Correct --regex #${index}: use a non-empty raw source or /pattern/flags with valid JavaScript flags.`})}function parseRegexRule(spec,index=1){const trimmed=spec.trim();if(trimmed.length===0)throw invalidRegexRule(index,"provide a non-empty pattern.");let source=trimmed,flags="g";if(trimmed.startsWith("/")&&trimmed.length>1){const slashIndex=trimmed.lastIndexOf("/");let backslashes=0;for(let index2=slashIndex-1;index2>=0&&trimmed[index2]==="\\";index2--)backslashes++;slashIndex>0&&backslashes%2===0&&/^[dgimsuvy]*$/u.test(trimmed.slice(slashIndex+1))&&(source=trimmed.slice(1,slashIndex),flags=normalizeRegexFlags(trimmed.slice(slashIndex+1)))}if(source.length===0)throw invalidRegexRule(index,"an empty pattern is not allowed.");try{new RegExp(source,flags)}catch{throw invalidRegexRule(index,"provide a valid JavaScript regular expression.")}return{kind:"regex",source,flags}}function buildRedactionRules(literalInput,regexInput){const literalRules=[...new Set(normalizeStringArrayInput(literalInput).map(entry=>entry.trim()))].filter(entry=>entry.length>0).map(entry=>({kind:"literal",value:entry})),seen=new Set,regexRules=normalizeStringArrayInput(regexInput).flatMap((entry,index)=>{const spec=entry.trim();return seen.has(spec)?[]:(seen.add(spec),[parseRegexRule(spec,index+1)])}),rules=[...literalRules,...regexRules];if(rules.length===0)throw new PmCliError("history-redact requires at least one matcher via --literal or --regex.",EXIT_CODE.USAGE,{code:"missing_required_argument",required:"Provide --literal <value> and/or --regex <pattern>.",examples:['pm history-redact pm-a1b2 --literal "[redacted_path_prefix]/private"','pm history-redact pm-a1b2 --regex "/192\\\\.168\\\\.[0-9.]+/g" --replacement "[scrubbed_ip]"']});return rules}function applyLiteralRule(value,literal,replacement){if(literal.length===0)return{value,replacements:0};let cursor=0,replacements=0;for(;cursor<=value.length;){const index=value.indexOf(literal,cursor);if(index===-1)break;replacements+=1,cursor=index+Math.max(1,literal.length)}return replacements===0?{value,replacements:0}:{value:value.split(literal).join(replacement),replacements}}function applyRegexRule(value,rule,replacement){const regex=new RegExp(rule.source,rule.flags),matches=[...value.matchAll(regex)];return matches.length===0?{value,replacements:0}:{value:value.replace(regex,replacement),replacements:matches.length}}function redactStringValue(value,rules,replacement){let next=value,replacements=0;for(const rule of rules){const result=rule.kind==="literal"?applyLiteralRule(next,rule.value,replacement):applyRegexRule(next,rule,replacement);next=result.value,replacements+=result.replacements}return{value:next,replacements}}function redactUnknownValue(value,rules,replacement){if(typeof value=="string")return redactStringValue(value,rules,replacement);if(Array.isArray(value)){let replacements=0;return{value:value.map(entry=>{const redacted=redactUnknownValue(entry,rules,replacement);return replacements+=redacted.replacements,redacted.value}),replacements}}if(typeof value=="object"&&value!==null){let replacements=0;const nextRecord={};for(const[key,entry]of Object.entries(value)){const redacted=redactUnknownValue(entry,rules,replacement);replacements+=redacted.replacements,nextRecord[key]=redacted.value}return{value:nextRecord,replacements}}return{value,replacements:0}}function redactHistoryPatch(patch,rules,replacement){let replacements=0;return{patch:patch.map(operation=>{if(!Object.prototype.hasOwnProperty.call(operation,"value"))return operation;const redactedValue=redactUnknownValue(operation.value,rules,replacement);return replacements+=redactedValue.replacements,redactedValue.replacements>0?{...operation,value:redactedValue.value}:operation}),replacements}}function inspectHistoryIntegrity(entries){let replay=structuredClone(EMPTY_REPLAY_DOCUMENT),hashMismatchesBefore=0,hashMismatchesAfter=0;for(let index=0;index<entries.length;index+=1){const entry=entries[index];replayHash(replay,void 0,resolveHistoryHashAlgorithm(entry.hash_algorithm))!==entry.before_hash&&(hashMismatchesBefore+=1),replay=applyHistoryPatch(replay,entry.patch,index+1,entry.op),replayHash(replay,void 0,resolveHistoryHashAlgorithm(entry.hash_algorithm))!==entry.after_hash&&(hashMismatchesAfter+=1)}return{hashMismatchesBefore,hashMismatchesAfter,finalDocument:replay}}function redactHistoryEntry(entry,rules,replacement){let replacements=0,changed=!1,reanchorEvidenceRedacted=!1,nextMessage=entry.message;if(typeof entry.message=="string"){const redactedMessage=redactStringValue(entry.message,rules,replacement);nextMessage=redactedMessage.value,replacements+=redactedMessage.replacements,redactedMessage.replacements>0&&(changed=!0)}const redactedPatch=redactHistoryPatch(entry.patch,rules,replacement);replacements+=redactedPatch.replacements,changed||=redactedPatch.replacements>0;const nextReanchorEvidence=entry.reanchor_evidence?.map(evidence=>{const redactedEvidencePatch=evidence.patch?redactHistoryPatch(evidence.patch,rules,replacement):{patch:void 0,replacements:0},redactedEvidenceRecord=evidence.record?redactUnknownValue(evidence.record,rules,replacement):{value:void 0,replacements:0};replacements+=redactedEvidencePatch.replacements,replacements+=redactedEvidenceRecord.replacements;const evidenceChanged=redactedEvidencePatch.replacements>0||redactedEvidenceRecord.replacements>0;if(changed||=evidenceChanged,!evidenceChanged)return evidence;reanchorEvidenceRedacted=!0;const{patch:_sensitivePatch,record:_sensitiveRecord,record_hash:_priorRecordHash,record_hash_version:_priorRecordHashVersion,...digestOnlyEvidence}=evidence;return redactedEvidencePatch.replacements>0?digestOnlyEvidence:{...digestOnlyEvidence,patch:evidence.patch}});return{entry:{...entry,message:nextMessage,patch:redactedPatch.patch,...nextReanchorEvidence?{reanchor_evidence:nextReanchorEvidence}:{}},replacements,changed,reanchorEvidenceRedacted}}function rewriteHistoryEntries(entries,rules,replacement){let replay=structuredClone(EMPTY_REPLAY_DOCUMENT),entriesChanged=0,replacements=0;const rewrittenEntries=[];for(let index=0;index<entries.length;index+=1){const original=entries[index],recordVerification=verifyHistoryRecordHash(original);if(!recordVerification.ok)throw new PmCliError(`history-redact refuses invalid immutable record ${index+1} (${recordVerification.error}).`,EXIT_CODE.GENERIC_FAILURE);const redacted=redactHistoryEntry(original,rules,replacement);replacements+=redacted.replacements,redacted.changed&&(entriesChanged+=1);const beforeHash=replayHash(replay,void 0,resolveHistoryHashAlgorithm(original.hash_algorithm));replay=applyHistoryPatch(replay,redacted.entry.patch,index+1,redacted.entry.op);const afterHash=replayHash(replay,void 0,resolveHistoryHashAlgorithm(original.hash_algorithm));rewrittenEntries.push(resealHistoryRewrite(original,{...redacted.entry,before_hash:beforeHash,after_hash:afterHash},{retainPriorRecord:redacted.changed,retainPriorRecordHash:!redacted.changed}))}return{entries:rewrittenEntries,finalDocument:replay,entriesChanged,replacements}}function hasItemMetadata(replay){return Object.keys(replay.metadata).length>0}function resolveHistoryRedactNextItem(params){if(!hasItemMetadata(params.finalDocument))return{raw:null,path:null,document:null};const canonical=canonicalDocument(replayToItemDocument(params.finalDocument),{schema:params.settings.schema});if(canonical.metadata.id!==params.subject.id)throw new PmCliError("history-redact would change the item id; narrow your patterns.",EXIT_CODE.USAGE);return{document:canonical,path:getItemPath(params.pmRoot,canonical.metadata.type,params.subject.id,"toon",params.typeToFolder),raw:serializeItemDocument(canonical,{format:"toon",schema:params.settings.schema})}}function buildHistoryRedactMessage(options,rewritten){return typeof options.message=="string"&&options.message.trim().length>0?options.message:`history-redact replaced ${rewritten.replacements} match(es) across ${rewritten.entriesChanged} entr${rewritten.entriesChanged===1?"y":"ies"}.`}function buildHistoryRedactEntries(params){const rewrittenEntries=[...params.rewritten.entries];if(params.dryRun||!params.changed)return{rewrittenEntries,auditEntryAdded:!1};const finalDocument=params.nextItemDocument??replayToItemDocument(params.rewritten.finalDocument);return rewrittenEntries.push(createHistoryEntry({nowIso:nowIso(),author:params.author,op:"history_redact",before:finalDocument,after:finalDocument,message:params.message})),{rewrittenEntries,auditEntryAdded:!0}}function createHistoryRedactTransaction(params){let derivedIndexWarnings=[];return{applyRewrite:async({historyRawUnderLock})=>{const releaseDerivedIndexLock=await acquireItemMetadataDerivedIndexLock(params.pmRoot,params.author),affectedItemPaths=new Set;params.currentItem.path&&affectedItemPaths.add(params.currentItem.path),params.nextItem.path&&affectedItemPaths.add(params.nextItem.path);const itemSnapshots=new Map;params.currentItem.path&&params.currentItem.raw!==null&&itemSnapshots.set(params.currentItem.path,params.currentItem.raw);let rethrowReleaseFailure=()=>{};try{try{params.nextItem.path&&params.nextItem.raw!==null&&params.nextItem.raw!==params.currentItem.raw&&await writeFileAtomic(params.nextItem.path,params.nextItem.raw),params.currentItem.path&&(!params.nextItem.path||params.nextItem.path!==params.currentItem.path)&&await fs.rm(params.currentItem.path,{force:!0}),await writeFileAtomic(params.subject.historyPath,historyEntriesToRaw(params.rewrittenEntries))}catch(error){try{await rollbackHistoryRedactRewrite(params.subject.historyPath,historyRawUnderLock,affectedItemPaths,itemSnapshots)}finally{await invalidateHistoryDriftCacheForPath(params.subject.historyPath)}throw error}await invalidateHistoryDriftCacheForPath(params.subject.historyPath);const itemPath=params.nextItem.path??params.currentItem.path;itemPath&&(derivedIndexWarnings=await refreshItemMetadataDerivedIndex({pmRoot:params.pmRoot,preferredFormat:params.settings.item_format,typeToFolder:params.typeRegistry.type_to_folder,schema:params.settings.schema,itemPath,...params.currentItem.path?{previousItemPath:params.currentItem.path}:{},document:params.nextItem.document}))}finally{await releaseDerivedIndexLock().catch(error=>{rethrowReleaseFailure=()=>{throw error}})}rethrowReleaseFailure()},afterWrite:async()=>[...derivedIndexWarnings,...await runHistoryRedactWriteHooks(params.subject.historyPath,[params.nextItem.path,params.currentItem.path])]}}async function rollbackHistoryRedactRewrite(historyPath,historyRawUnderLock,affectedItemPaths,itemSnapshots){historyRawUnderLock===null?await fs.rm(historyPath,{force:!0}):await writeFileAtomic(historyPath,historyRawUnderLock);for(const itemPath of affectedItemPaths){const snapshot=itemSnapshots.get(itemPath);snapshot===void 0?await fs.rm(itemPath,{force:!0}):await writeFileAtomic(itemPath,snapshot)}}async function runHistoryRedactWriteHooks(historyPath,itemHookPaths){const hookWarnings=[],uniqueItemHookPaths=new Set(itemHookPaths.filter(itemPath=>itemPath!==null));for(const itemHookPath of uniqueItemHookPaths)hookWarnings.push(...await runActiveOnWriteHooks({path:itemHookPath,scope:"project",op:"history_redact"}));return hookWarnings.push(...await runActiveOnWriteHooks({path:historyPath,scope:"project",op:"history_redact:history"})),hookWarnings}async function runHistoryRedact(id,options,global2){const{pmRoot,settings,typeRegistry}=await resolveHistoryWorkspace(global2.path),replacementInput=options.replacement??"",replacementIsDefault=replacementInput.length===0,replacement=replacementIsDefault?"[redacted]":replacementInput,rules=buildRedactionRules(options.literal,options.regex),subject=await resolveHistorySubject(pmRoot,id,settings,typeRegistry.type_to_folder);return runHistoryMaintenance({pmRoot,subject,settings,typeRegistry,operation:"history-redact",options,transform:snapshot=>buildHistoryRedactPlan({pmRoot,subject,settings,typeRegistry,options,rules,replacement,replacementIsDefault},snapshot)})}function buildHistoryRedactPlan(params,snapshot){const{pmRoot,subject,settings,typeRegistry,options,rules,replacement,replacementIsDefault}=params,historyEntries=snapshot.entries,integritySnapshot=inspectHistoryIntegrity(historyEntries),rewritten=rewriteHistoryEntries(historyEntries,rules,replacement),preexistingHashMismatches=integritySnapshot.hashMismatchesBefore+integritySnapshot.hashMismatchesAfter,dryRun=!!options.dryRun,changed=rewritten.replacements>0,warnings=[];preexistingHashMismatches>0&&warnings.push(`history_redact_preexisting_hash_mismatches:${preexistingHashMismatches}`),changed||warnings.push("history_redact_no_matches");const currentItem={raw:snapshot.loadedItem?.raw??null,path:subject.located?.itemPath??null,document:snapshot.loadedItem?.document??null},nextItem=resolveHistoryRedactNextItem({pmRoot,subject,settings,typeToFolder:typeRegistry.type_to_folder,finalDocument:rewritten.finalDocument}),itemChanged=(currentItem.path??null)!==(nextItem.path??null)||(currentItem.raw??null)!==(nextItem.raw??null),author=snapshot.author,redactionMessage=buildHistoryRedactMessage(options,rewritten),{rewrittenEntries,auditEntryAdded}=buildHistoryRedactEntries({rewritten,dryRun,changed,nextItemDocument:nextItem.document,author,message:redactionMessage});return{changed,rewrittenEntries,...createHistoryRedactTransaction({pmRoot,subject,settings,typeRegistry,currentItem,nextItem,author,rewrittenEntries}),report:({verification:historyVerify,warnings:writeWarnings})=>({id:subject.id,dry_run:dryRun,changed,patterns:{literal_count:rules.filter(rule=>rule.kind==="literal").length,regex_count:rules.filter(rule=>rule.kind==="regex").length,total_count:rules.length,replacement_is_default:replacementIsDefault},history:{path:subject.historyPath,entries_scanned:historyEntries.length,entries_changed:rewritten.entriesChanged,replacements:rewritten.replacements,hash_mismatches_before:integritySnapshot.hashMismatchesBefore,hash_mismatches_after:integritySnapshot.hashMismatchesAfter,preexisting_hash_mismatches:preexistingHashMismatches,audit_entry_added:auditEntryAdded,verify_ok:historyVerify.ok,verify_errors:historyVerify.errors},item:{existed_before:currentItem.path!==null,exists_after:nextItem.path!==null,path_before:currentItem.path,path_after:nextItem.path,changed:itemChanged},warnings:[...new Set([...warnings,...writeWarnings])].sort((left,right)=>left.localeCompare(right)),generated_at:nowIso()})}}const _testOnly={applyLiteralRule,applyRegexRule,buildRedactionRules,hasItemMetadata,normalizeRegexFlags,normalizeStringArrayInput,parseRegexRule,redactStringValue,redactUnknownValue};export{_testOnly,resolveHistorySubject2 as resolveHistorySubject,runHistoryRedact};
2
2
  //# sourceMappingURL=history-redact.js.map