@unbrained/pm-cli 2026.11.22 → 2026.11.24

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 (912) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli/after-command-context-usage.js +1 -1
  3. package/dist/cli/argv-utils.js +1 -1
  4. package/dist/cli/bootstrap-args.js +1 -1
  5. package/dist/cli/bundle-integrity.js +2 -2
  6. package/dist/cli/command-namespaces.js +1 -1
  7. package/dist/cli/commander-usage.js +11 -11
  8. package/dist/cli/commands/annotations/comments.js +1 -1
  9. package/dist/cli/commands/annotations/docs.js +1 -1
  10. package/dist/cli/commands/annotations/files.js +1 -1
  11. package/dist/cli/commands/annotations/learnings.js +1 -1
  12. package/dist/cli/commands/annotations/notes.js +1 -1
  13. package/dist/cli/commands/extension/describe.js +1 -1
  14. package/dist/cli/commands/extension/extension.js +1 -1
  15. package/dist/cli/commands/extension/scaffold.js +1 -1
  16. package/dist/cli/commands/extension/shared.js +1 -1
  17. package/dist/cli/commands/governance/gc.js +1 -1
  18. package/dist/cli/commands/governance/health.js +1 -1
  19. package/dist/cli/commands/governance/telemetry.js +1 -1
  20. package/dist/cli/commands/governance/validate.js +1 -1
  21. package/dist/cli/commands/history/activity.js +1 -1
  22. package/dist/cli/commands/history/history-compact.js +1 -1
  23. package/dist/cli/commands/history/history-redact.js +1 -1
  24. package/dist/cli/commands/history/history-repair.js +1 -1
  25. package/dist/cli/commands/history/history.js +1 -1
  26. package/dist/cli/commands/history/restore.js +1 -1
  27. package/dist/cli/commands/lifecycle/append.js +1 -1
  28. package/dist/cli/commands/lifecycle/claim.js +1 -1
  29. package/dist/cli/commands/lifecycle/close-many.js +1 -1
  30. package/dist/cli/commands/lifecycle/close.js +1 -1
  31. package/dist/cli/commands/lifecycle/copy.js +1 -1
  32. package/dist/cli/commands/lifecycle/create.js +1 -1
  33. package/dist/cli/commands/lifecycle/delete.js +1 -1
  34. package/dist/cli/commands/lifecycle/focus.js +1 -1
  35. package/dist/cli/commands/lifecycle/plan.js +1 -1
  36. package/dist/cli/commands/lifecycle/update-many.js +1 -1
  37. package/dist/cli/commands/lifecycle/update.js +1 -1
  38. package/dist/cli/commands/query/aggregate.js +1 -1
  39. package/dist/cli/commands/query/context.js +1 -1
  40. package/dist/cli/commands/query/deps.js +1 -1
  41. package/dist/cli/commands/query/duplicates.js +1 -1
  42. package/dist/cli/commands/query/eval.js +1 -1
  43. package/dist/cli/commands/query/get.js +1 -1
  44. package/dist/cli/commands/query/graph.js +1 -1
  45. package/dist/cli/commands/query/list.js +1 -1
  46. package/dist/cli/commands/query/next.js +1 -1
  47. package/dist/cli/commands/query/search.js +1 -1
  48. package/dist/cli/commands/query/stats.js +1 -1
  49. package/dist/cli/commands/test/test-all.js +1 -1
  50. package/dist/cli/commands/test/test-runs.js +1 -1
  51. package/dist/cli/commands/test/test.js +1 -1
  52. package/dist/cli/commands/workspace/config.js +1 -1
  53. package/dist/cli/commands/workspace/contracts.js +1 -1
  54. package/dist/cli/commands/workspace/init.js +1 -1
  55. package/dist/cli/commands/workspace/merge.js +1 -1
  56. package/dist/cli/commands/workspace/profile.js +1 -1
  57. package/dist/cli/commands/workspace/schema.js +1 -1
  58. package/dist/cli/commands/workspace/upgrade.js +1 -1
  59. package/dist/cli/context-intent-invocation.js +1 -1
  60. package/dist/cli/description-stdin.js +1 -1
  61. package/dist/cli/error-guidance.js +5 -5
  62. package/dist/cli/expected-revisions.js +1 -1
  63. package/dist/cli/extension-command-help.js +6 -6
  64. package/dist/cli/extension-recovery.js +1 -1
  65. package/dist/cli/help-content.js +5 -5
  66. package/dist/cli/help-json-payload.js +7 -7
  67. package/dist/cli/invocation-profile.js +2 -2
  68. package/dist/cli/main.js +5 -5
  69. package/dist/cli/migration-gates.js +1 -1
  70. package/dist/cli/option-values.js +1 -1
  71. package/dist/cli/preflight-warnings.js +3 -3
  72. package/dist/cli/public.js +1 -1
  73. package/dist/cli/register-annotations.js +1 -1
  74. package/dist/cli/register-assurance.js +1 -1
  75. package/dist/cli/register-files-lookup.js +1 -1
  76. package/dist/cli/register-history-activity.js +1 -1
  77. package/dist/cli/register-history-author.js +1 -1
  78. package/dist/cli/register-history-maintenance.js +2 -2
  79. package/dist/cli/register-list-query.js +10 -10
  80. package/dist/cli/register-mutation-options.js +0 -1
  81. package/dist/cli/register-mutation.js +6 -6
  82. package/dist/cli/register-operations.js +1 -1
  83. package/dist/cli/register-setup.js +1 -1
  84. package/dist/cli/register-structured-mutation.js +1 -1
  85. package/dist/cli/registration-helpers.js +1 -1
  86. package/dist/cli/runtime/activation.js +1 -1
  87. package/dist/cli/runtime/annotation-option-retry.js +1 -1
  88. package/dist/cli/runtime/close-fields-retry.js +1 -1
  89. package/dist/cli/runtime/field-route-retry.js +1 -1
  90. package/dist/cli/runtime/invocation-options.js +1 -1
  91. package/dist/cli/runtime/invocation-rewrites.js +1 -1
  92. package/dist/cli/runtime/projection-retry.js +1 -1
  93. package/dist/cli/runtime/read-output-mutation-retry.js +1 -1
  94. package/dist/cli/runtime/refusal-credential-redaction.js +1 -1
  95. package/dist/cli/runtime/selection.js +1 -1
  96. package/dist/cli/runtime/telemetry-outcome.js +1 -1
  97. package/dist/cli/runtime-compatibility-boundary.js +4 -4
  98. package/dist/cli/schema/registration.js +15 -15
  99. package/dist/cli/schema-registration-helpers.js +1 -1
  100. package/dist/cli/search-refresh.js +1 -1
  101. package/dist/cli/stats-analytics-json.js +1 -1
  102. package/dist/cli/telemetry-flush.js +1 -1
  103. package/dist/cli-bundle/bundle-manifest.json +1 -1
  104. package/dist/cli-bundle/chunks/chunk-23K6DQQY.js +9 -0
  105. package/dist/cli-bundle/chunks/chunk-37UDIJ2K.js +3 -0
  106. package/dist/cli-bundle/chunks/chunk-5DUP4AZA.js +2 -0
  107. package/dist/cli-bundle/chunks/chunk-6H36ZHMI.js +2 -0
  108. package/dist/cli-bundle/chunks/chunk-7IROAPWI.js +3 -0
  109. package/dist/cli-bundle/chunks/chunk-7VRFEURZ.js +33 -0
  110. package/dist/cli-bundle/chunks/chunk-7X253M6Z.js +3 -0
  111. package/dist/cli-bundle/chunks/chunk-AA52P34H.js +3 -0
  112. package/dist/cli-bundle/chunks/chunk-AWB5KBJS.js +2 -0
  113. package/dist/cli-bundle/chunks/chunk-D6PDUKUG.js +9 -0
  114. package/dist/cli-bundle/chunks/chunk-DQDRA3SW.js +2 -0
  115. package/dist/cli-bundle/chunks/chunk-FXJYZBWV.js +113 -0
  116. package/dist/cli-bundle/chunks/chunk-HNKK2UG6.js +8 -0
  117. package/dist/cli-bundle/chunks/chunk-HZZLSBIJ.js +2 -0
  118. package/dist/cli-bundle/chunks/chunk-I2OJ5B4A.js +2 -0
  119. package/dist/cli-bundle/chunks/chunk-I3BFCKZR.js +2 -0
  120. package/dist/cli-bundle/chunks/chunk-MXUSC5RS.js +31 -0
  121. package/dist/cli-bundle/chunks/chunk-PLIUU37C.js +3 -0
  122. package/dist/cli-bundle/chunks/chunk-PQUBVRV5.js +2 -0
  123. package/dist/cli-bundle/chunks/chunk-PW7U7WCE.js +3 -0
  124. package/dist/cli-bundle/chunks/chunk-PZA7QECY.js +1 -0
  125. package/dist/cli-bundle/chunks/chunk-SLFRSZK6.js +1 -0
  126. package/dist/cli-bundle/chunks/chunk-SSALO4DB.js +2 -0
  127. package/dist/cli-bundle/chunks/chunk-STOOTHZZ.js +2 -0
  128. package/dist/cli-bundle/chunks/chunk-TKRY22SO.js +2 -0
  129. package/dist/cli-bundle/chunks/{chunk-B76TFRO2.js → chunk-TVIJ2VCU.js} +93 -93
  130. package/dist/cli-bundle/chunks/chunk-VJSGUXGU.js +3 -0
  131. package/dist/cli-bundle/chunks/chunk-WWTPNIC2.js +6 -0
  132. package/dist/cli-bundle/chunks/chunk-XFADNMGD.js +2 -0
  133. package/dist/cli-bundle/chunks/chunk-YOPTAIBD.js +125 -0
  134. package/dist/cli-bundle/chunks/chunk-YW2HBHRO.js +70 -0
  135. package/dist/cli-bundle/chunks/chunk-YYT3MIRF.js +3 -0
  136. package/dist/cli-bundle/chunks/chunk-Z7MFVRDV.js +2 -0
  137. package/dist/cli-bundle/chunks/chunk-ZOX4SWRL.js +8 -0
  138. package/dist/cli-bundle/chunks/chunk-ZYCOM4MS.js +9 -0
  139. package/dist/cli-bundle/chunks/context-budget-recovery-M5RFUEFG.js +2 -0
  140. package/dist/cli-bundle/chunks/field-option-collisions-W66HSWMK.js +2 -0
  141. package/dist/cli-bundle/chunks/indexed-receipt-blobs-BPYKN5Q7.js +4 -0
  142. package/dist/cli-bundle/{focused-chunks/item-revision-2O6MLPEX.js → chunks/item-revision-D3LSBNIR.js} +2 -2
  143. package/dist/cli-bundle/chunks/item-transaction-M6NTBYH3.js +2 -0
  144. package/dist/cli-bundle/chunks/mutation-actor-OKL3CQVX.js +2 -0
  145. package/dist/cli-bundle/chunks/mutation-admission-EKPEOZMF.js +2 -0
  146. package/dist/cli-bundle/chunks/{register-list-query-RR5KACJ3.js → register-list-query-3LBV6CS2.js} +11 -11
  147. package/dist/cli-bundle/chunks/register-mutation-72AGTMNE.js +21 -0
  148. package/dist/cli-bundle/chunks/register-operations-XERFG2SH.js +2 -0
  149. package/dist/cli-bundle/chunks/register-setup-W22L34Z4.js +2 -0
  150. package/dist/cli-bundle/chunks/runtime-schema-JP2KBHBY.js +2 -0
  151. package/dist/cli-bundle/chunks/settlement-hook-6MR32OOC.js +7 -0
  152. package/dist/cli-bundle/chunks/stage-T2LKWN7C.js +2 -0
  153. package/dist/cli-bundle/focused-chunks/chunk-24VRBNKE.js +26 -0
  154. package/dist/cli-bundle/focused-chunks/chunk-3ELVASVA.js +2 -0
  155. package/dist/cli-bundle/focused-chunks/chunk-3GT4A3ZN.js +44 -0
  156. package/dist/cli-bundle/focused-chunks/chunk-3OCDKITJ.js +3 -0
  157. package/dist/cli-bundle/focused-chunks/chunk-3Z7MCUJM.js +3 -0
  158. package/dist/cli-bundle/focused-chunks/chunk-46MP7IZN.js +5 -0
  159. package/dist/cli-bundle/focused-chunks/chunk-5LDBS6MS.js +91 -0
  160. package/dist/cli-bundle/focused-chunks/chunk-A6VEMCRR.js +3 -0
  161. package/dist/cli-bundle/focused-chunks/chunk-AIDL2ZNT.js +3 -0
  162. package/dist/cli-bundle/focused-chunks/chunk-B6BNHKUW.js +78 -0
  163. package/dist/cli-bundle/focused-chunks/chunk-BKPUUW5O.js +1 -0
  164. package/dist/cli-bundle/focused-chunks/chunk-BWOVFE5B.js +2 -0
  165. package/dist/cli-bundle/focused-chunks/chunk-C7WHWI7K.js +3 -0
  166. package/dist/cli-bundle/focused-chunks/chunk-EUQGZPGO.js +2 -0
  167. package/dist/cli-bundle/focused-chunks/chunk-FDZPRJXJ.js +27 -0
  168. package/dist/cli-bundle/focused-chunks/chunk-GXP7Q4XM.js +2 -0
  169. package/dist/cli-bundle/focused-chunks/chunk-HL47UQZJ.js +8 -0
  170. package/dist/cli-bundle/focused-chunks/chunk-IIP6LZ5E.js +2 -0
  171. package/dist/cli-bundle/focused-chunks/chunk-K53OIT5J.js +2 -0
  172. package/dist/cli-bundle/focused-chunks/chunk-LMFIAQ2V.js +2 -0
  173. package/dist/cli-bundle/focused-chunks/chunk-LMU7DDOA.js +2 -0
  174. package/dist/cli-bundle/focused-chunks/chunk-OZOCEB2Q.js +8 -0
  175. package/dist/cli-bundle/focused-chunks/chunk-Q2HY44LV.js +13 -0
  176. package/dist/cli-bundle/focused-chunks/chunk-REFMQY47.js +2 -0
  177. package/dist/cli-bundle/focused-chunks/chunk-RIE3SJSE.js +9 -0
  178. package/dist/cli-bundle/focused-chunks/chunk-RIQUIHYU.js +3 -0
  179. package/dist/cli-bundle/focused-chunks/chunk-RLO2HCZT.js +2 -0
  180. package/dist/cli-bundle/focused-chunks/chunk-SMMOZ3H3.js +100 -0
  181. package/dist/cli-bundle/focused-chunks/chunk-UVTUX54T.js +2 -0
  182. package/dist/cli-bundle/focused-chunks/chunk-X6CXWWNB.js +2 -0
  183. package/dist/cli-bundle/focused-chunks/chunk-XDBHD4CY.js +8 -0
  184. package/dist/cli-bundle/focused-chunks/chunk-YD66IRSL.js +2 -0
  185. package/dist/cli-bundle/focused-chunks/chunk-Z7W2RQIB.js +2 -0
  186. package/dist/cli-bundle/focused-chunks/context-budget-recovery-CSJV3TY3.js +2 -0
  187. package/dist/cli-bundle/focused-chunks/field-option-collisions-UODPSV6W.js +2 -0
  188. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-EGEJMG3G.js +4 -0
  189. package/dist/cli-bundle/focused-chunks/item-revision-QH7RNBX4.js +2 -0
  190. package/dist/cli-bundle/focused-chunks/item-transaction-ZO72OINF.js +2 -0
  191. package/dist/cli-bundle/focused-chunks/mutation-actor-PHVLKG4I.js +2 -0
  192. package/dist/cli-bundle/focused-chunks/mutation-admission-ZSG5OECH.js +2 -0
  193. package/dist/cli-bundle/focused-chunks/runtime-schema-6RQMIDTN.js +2 -0
  194. package/dist/cli-bundle/focused-chunks/settlement-hook-FMLGKG7J.js +7 -0
  195. package/dist/cli-bundle/focused-chunks/stage-AQMKRVX4.js +2 -0
  196. package/dist/cli-bundle/main.js +27 -27
  197. package/dist/cli-bundle/sdk-authoring.js +1 -1
  198. package/dist/cli-bundle/sdk-contracts.js +5 -5
  199. package/dist/cli-bundle/sdk-core.js +1 -1
  200. package/dist/cli-bundle/sdk-governance.js +1 -1
  201. package/dist/cli-bundle/sdk-graph.js +1 -1
  202. package/dist/cli-bundle/sdk-merge.js +66 -66
  203. package/dist/cli-bundle/sdk-query.js +1 -1
  204. package/dist/cli-bundle/sdk-runtime.js +1 -1
  205. package/dist/cli-bundle/sdk-testing.js +1 -1
  206. package/dist/cli-bundle/sdk.js +13 -13
  207. package/dist/cli.js +1 -1
  208. package/dist/core/checkpoint/checkpoint-gc.js +1 -1
  209. package/dist/core/checkpoint/mutation-checkpoint.js +2 -2
  210. package/dist/core/checkpoint/mutation-context.js +1 -1
  211. package/dist/core/config/nested-settings.js +1 -1
  212. package/dist/core/config/positional-value.js +1 -1
  213. package/dist/core/diagnostics/remediation.js +1 -1
  214. package/dist/core/extensions/activation-summary-markdown.js +2 -2
  215. package/dist/core/extensions/activation-summary.js +1 -1
  216. package/dist/core/extensions/activation-transaction.js +1 -1
  217. package/dist/core/extensions/capability-usage.js +1 -1
  218. package/dist/core/extensions/command-hook-context.js +1 -1
  219. package/dist/core/extensions/command-metadata-contract.js +1 -1
  220. package/dist/core/extensions/command-visibility-tier.js +1 -1
  221. package/dist/core/extensions/contribution-inventory.js +1 -1
  222. package/dist/core/extensions/exporter-output-contract.js +1 -1
  223. package/dist/core/extensions/extension-candidate.js +1 -1
  224. package/dist/core/extensions/extension-capability-aliases.js +1 -1
  225. package/dist/core/extensions/extension-hook-runtime.js +1 -1
  226. package/dist/core/extensions/extension-policy.js +1 -1
  227. package/dist/core/extensions/extension-registries.js +1 -1
  228. package/dist/core/extensions/extension-runtime-helpers.js +1 -1
  229. package/dist/core/extensions/extension-types.js +1 -1
  230. package/dist/core/extensions/flag-definition-validation.js +1 -1
  231. package/dist/core/extensions/flag-value-types.js +1 -1
  232. package/dist/core/extensions/index.js +1 -1
  233. package/dist/core/extensions/item-field-types.js +1 -1
  234. package/dist/core/extensions/item-fields.js +1 -1
  235. package/dist/core/extensions/loader.js +1 -1
  236. package/dist/core/extensions/manifest-parser.js +1 -1
  237. package/dist/core/extensions/manifest-schema.js +1 -1
  238. package/dist/core/extensions/module-graph-snapshot.js +1 -1
  239. package/dist/core/extensions/mutation-actor-snapshot.js +1 -1
  240. package/dist/core/extensions/mutation-actor.js +1 -1
  241. package/dist/core/extensions/preflight-ownership.js +1 -1
  242. package/dist/core/extensions/read-output-contract.js +1 -1
  243. package/dist/core/extensions/registration-contracts.js +1 -1
  244. package/dist/core/extensions/registration-validation.js +1 -1
  245. package/dist/core/extensions/registration-values.js +1 -1
  246. package/dist/core/extensions/reserved-host-flags.js +1 -1
  247. package/dist/core/extensions/runtime-registrations.js +1 -1
  248. package/dist/core/extensions/service-ownership.js +1 -1
  249. package/dist/core/extensions/version-compat.js +1 -1
  250. package/dist/core/extensions/version-diagnostics.js +1 -1
  251. package/dist/core/fs/atomic-create.js +1 -1
  252. package/dist/core/fs/file-glob.js +1 -1
  253. package/dist/core/fs/fs-utils.js +2 -2
  254. package/dist/core/fs/host-environment-errors.js +1 -1
  255. package/dist/core/fs/index.js +1 -1
  256. package/dist/core/fs/path-utils.js +1 -1
  257. package/dist/core/governance/content-fields.js +1 -1
  258. package/dist/core/governance/issue-codes.js +1 -1
  259. package/dist/core/governance/metadata-coverage.js +1 -1
  260. package/dist/core/history/bridge.js +1 -1
  261. package/dist/core/history/digest.js +1 -1
  262. package/dist/core/history/drift-cache.js +3 -3
  263. package/dist/core/history/drift-scan.js +1 -1
  264. package/dist/core/history/event-classification.js +1 -1
  265. package/dist/core/history/event-index.js +11 -11
  266. package/dist/core/history/history-compact-bulk.js +1 -1
  267. package/dist/core/history/history-diff.js +1 -1
  268. package/dist/core/history/history-rewrite.js +1 -1
  269. package/dist/core/history/history-storage-stats.js +1 -1
  270. package/dist/core/history/history-stream-policy.js +1 -1
  271. package/dist/core/history/history.js +2 -2
  272. package/dist/core/history/identity.js +1 -1
  273. package/dist/core/history/index.js +1 -1
  274. package/dist/core/history/operation-contract.js +1 -1
  275. package/dist/core/history/projection.js +1 -1
  276. package/dist/core/history/read.js +1 -1
  277. package/dist/core/history/replay.js +2 -2
  278. package/dist/core/history/stream-summary.js +2 -2
  279. package/dist/core/history/tombstone.js +1 -1
  280. package/dist/core/history/version-address.js +1 -1
  281. package/dist/core/history/workspace-history.js +2 -2
  282. package/dist/core/io/body-file.js +1 -1
  283. package/dist/core/io/bulk-ids-input.js +2 -2
  284. package/dist/core/item/actionability.js +1 -1
  285. package/dist/core/item/deferred-fields.js +1 -1
  286. package/dist/core/item/dependency-reference.js +1 -1
  287. package/dist/core/item/id.js +1 -1
  288. package/dist/core/item/index.js +1 -1
  289. package/dist/core/item/item-format-version.js +1 -1
  290. package/dist/core/item/item-format.js +7 -7
  291. package/dist/core/item/item-record.js +1 -1
  292. package/dist/core/item/item-type-definition.js +1 -1
  293. package/dist/core/item/literal-mutation-input.js +1 -1
  294. package/dist/core/item/parent-reference-policy.js +1 -1
  295. package/dist/core/item/parse.js +8 -8
  296. package/dist/core/item/plan-lifecycle.js +1 -1
  297. package/dist/core/item/priority.js +1 -1
  298. package/dist/core/item/sprint-release-format.js +1 -1
  299. package/dist/core/item/status-filter.js +1 -1
  300. package/dist/core/item/status.js +1 -1
  301. package/dist/core/item/toon-decode.js +1 -1
  302. package/dist/core/item/type-registry.js +1 -1
  303. package/dist/core/item/type-synonyms.js +1 -1
  304. package/dist/core/lock/index.js +1 -1
  305. package/dist/core/lock/lock-confinement.js +1 -1
  306. package/dist/core/lock/lock-gc.js +1 -1
  307. package/dist/core/lock/lock-owner.js +1 -1
  308. package/dist/core/lock/lock.js +4 -4
  309. package/dist/core/output/linked-test-projection.js +5 -5
  310. package/dist/core/output/mutation-projection.js +1 -1
  311. package/dist/core/output/output-control.js +1 -1
  312. package/dist/core/output/output.js +19 -19
  313. package/dist/core/output/query-summary.js +1 -1
  314. package/dist/core/output/tabular.js +3 -3
  315. package/dist/core/packages/manifest.js +1 -1
  316. package/dist/core/packages/root.js +1 -1
  317. package/dist/core/policy/workflow-policy-schema.js +1 -1
  318. package/dist/core/policy/workflow-policy-store.js +1 -1
  319. package/dist/core/policy/workflow-policy.js +1 -1
  320. package/dist/core/profile/profile-describe.js +1 -1
  321. package/dist/core/profile/profile-lint.d.ts +1 -1
  322. package/dist/core/profile/profile-lint.js +1 -1
  323. package/dist/core/profile/profile-plan.js +1 -1
  324. package/dist/core/profile/profile-presets.js +4 -4
  325. package/dist/core/reproducibility/context.js +1 -1
  326. package/dist/core/schema/fields-file.js +2 -2
  327. package/dist/core/schema/item-types-file.js +2 -2
  328. package/dist/core/schema/runtime-field-filters.js +1 -1
  329. package/dist/core/schema/runtime-field-values.js +1 -1
  330. package/dist/core/schema/runtime-schema.d.ts +2 -0
  331. package/dist/core/schema/runtime-schema.js +2 -2
  332. package/dist/core/schema/status-defs-file.js +2 -2
  333. package/dist/core/schema/status-token.js +1 -1
  334. package/dist/core/schema/type-inference.js +1 -1
  335. package/dist/core/schema/type-presets.js +1 -1
  336. package/dist/core/schema/type-workflows.js +1 -1
  337. package/dist/core/search/background-refresh.js +2 -2
  338. package/dist/core/search/bm25.js +1 -1
  339. package/dist/core/search/cache.js +2 -2
  340. package/dist/core/search/corpus.js +1 -1
  341. package/dist/core/search/embedding-batches.js +1 -1
  342. package/dist/core/search/eval-thresholds.js +1 -1
  343. package/dist/core/search/eval.js +1 -1
  344. package/dist/core/search/http-client.js +1 -1
  345. package/dist/core/search/providers.js +1 -1
  346. package/dist/core/search/relevance.js +1 -1
  347. package/dist/core/search/semantic-defaults.js +1 -1
  348. package/dist/core/search/staleness.js +1 -1
  349. package/dist/core/search/vector-stores.js +2 -2
  350. package/dist/core/search/vectorization-metadata.js +1 -1
  351. package/dist/core/sentry/helpers.js +1 -1
  352. package/dist/core/sentry/instrument.js +1 -1
  353. package/dist/core/sentry/sensitive-assignments.js +1 -1
  354. package/dist/core/session/session-state.js +1 -1
  355. package/dist/core/shared/agent-session-context.js +1 -1
  356. package/dist/core/shared/author.js +5 -5
  357. package/dist/core/shared/command-line.js +1 -1
  358. package/dist/core/shared/command-types.js +0 -1
  359. package/dist/core/shared/conflict-markers.js +1 -1
  360. package/dist/core/shared/constants.js +1 -1
  361. package/dist/core/shared/error-details.js +1 -1
  362. package/dist/core/shared/errors.js +1 -1
  363. package/dist/core/shared/html-entity-decode.js +1 -1
  364. package/dist/core/shared/index.js +1 -1
  365. package/dist/core/shared/item-metadata-contract.js +1 -1
  366. package/dist/core/shared/lazy-module.js +1 -1
  367. package/dist/core/shared/levenshtein.js +1 -1
  368. package/dist/core/shared/memo.js +1 -1
  369. package/dist/core/shared/numeric-parsers.js +1 -1
  370. package/dist/core/shared/option-alias-visibility.js +1 -1
  371. package/dist/core/shared/output-unicode.js +1 -1
  372. package/dist/core/shared/primitives.js +1 -1
  373. package/dist/core/shared/process-tree.js +2 -2
  374. package/dist/core/shared/secret-rules.js +5 -5
  375. package/dist/core/shared/serial-queue.js +1 -1
  376. package/dist/core/shared/serialization.js +1 -1
  377. package/dist/core/shared/split-comma-list.js +1 -1
  378. package/dist/core/shared/text-normalization.js +1 -1
  379. package/dist/core/shared/time.js +2 -2
  380. package/dist/core/shared/url-credentials.js +1 -1
  381. package/dist/core/store/index.js +1 -1
  382. package/dist/core/store/item-format-migration.js +1 -1
  383. package/dist/core/store/item-metadata-cache.js +1 -1
  384. package/dist/core/store/item-metadata-query-index.js +11 -11
  385. package/dist/core/store/item-metadata-read-work.js +1 -1
  386. package/dist/core/store/item-mutation-precondition.js +1 -1
  387. package/dist/core/store/item-store.js +1 -1
  388. package/dist/core/store/paths.js +1 -1
  389. package/dist/core/store/settings-concurrency.js +1 -1
  390. package/dist/core/store/settings-read-cache.js +1 -1
  391. package/dist/core/store/settings-sections.js +2 -2
  392. package/dist/core/store/settings-validator.js +1 -1
  393. package/dist/core/store/settings.d.ts +3 -1
  394. package/dist/core/store/settings.js +6 -6
  395. package/dist/core/store/sqlite-runtime.js +1 -1
  396. package/dist/core/store/tracker-preflight.js +1 -1
  397. package/dist/core/store/transaction-coordinator-scope.js +1 -1
  398. package/dist/core/telemetry/consent.js +3 -3
  399. package/dist/core/telemetry/observability.js +1 -1
  400. package/dist/core/telemetry/policy.js +1 -1
  401. package/dist/core/telemetry/read-sampling.js +2 -2
  402. package/dist/core/telemetry/runtime.js +9 -9
  403. package/dist/core/test/background-runs.js +4 -4
  404. package/dist/core/test/item-test-run-tracking.js +1 -1
  405. package/dist/core/test/run-selectors.js +1 -1
  406. package/dist/core/validate/estimate-defaults.js +1 -1
  407. package/dist/core/validate/fix-planning.js +1 -1
  408. package/dist/core/validate/linked-artifact-reference.js +1 -1
  409. package/dist/core/validate/missing-by-type.js +1 -1
  410. package/dist/core/validate/missing-link-owners.js +1 -1
  411. package/dist/core/validate/stale-file-classification.js +1 -1
  412. package/dist/mcp/http-server.js +5 -5
  413. package/dist/mcp/legacy-adapter.js +1 -1
  414. package/dist/mcp/runtime-capabilities.js +1 -1
  415. package/dist/mcp/server.js +4 -4
  416. package/dist/mcp/tool-definitions.js +1 -1
  417. package/dist/sdk/actionability.js +1 -1
  418. package/dist/sdk/agent/closed-domain-contracts.js +1 -1
  419. package/dist/sdk/agent/command-recovery.js +1 -1
  420. package/dist/sdk/agent/command-suggestions.js +1 -1
  421. package/dist/sdk/agent/create-option-policy.js +1 -1
  422. package/dist/sdk/agent/identity-config.js +1 -1
  423. package/dist/sdk/agent/item-addressing.js +1 -1
  424. package/dist/sdk/agent/linked-resource-recovery.js +1 -1
  425. package/dist/sdk/agent/refusal-closure-census.js +2 -2
  426. package/dist/sdk/agent/refusal-corpus-contracts.js +1 -1
  427. package/dist/sdk/agent/subcommand-recovery.js +1 -1
  428. package/dist/sdk/agent-capability-contracts.js +3 -3
  429. package/dist/sdk/agent-session-context.js +1 -1
  430. package/dist/sdk/annotations.js +1 -1
  431. package/dist/sdk/author-attribution.js +1 -1
  432. package/dist/sdk/cli-bootstrap.js +1 -1
  433. package/dist/sdk/cli-contracts/agent-output-contracts.js +5 -5
  434. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
  435. package/dist/sdk/cli-contracts/command-aliases.js +1 -1
  436. package/dist/sdk/cli-contracts/command-exit-contracts.js +1 -1
  437. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  438. package/dist/sdk/cli-contracts/commander-types.js +1 -1
  439. package/dist/sdk/cli-contracts/completeness.js +1 -1
  440. package/dist/sdk/cli-contracts/enum-contracts.js +1 -1
  441. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  442. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +2 -2
  443. package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
  444. package/dist/sdk/cli-contracts/registration-helpers.js +7 -7
  445. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  446. package/dist/sdk/cli-contracts/schemas/assurance-definition.js +1 -1
  447. package/dist/sdk/cli-contracts/string-lists.js +1 -1
  448. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  449. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  450. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  451. package/dist/sdk/cli-contracts/typed-action-inputs.js +0 -1
  452. package/dist/sdk/cli-contracts.js +1 -1
  453. package/dist/sdk/cli-program.js +1 -1
  454. package/dist/sdk/command-line.js +1 -1
  455. package/dist/sdk/comments.js +1 -1
  456. package/dist/sdk/compile-cache.js +1 -1
  457. package/dist/sdk/completion/bash.js +2 -2
  458. package/dist/sdk/completion/fish.js +72 -72
  459. package/dist/sdk/completion/shared.js +1 -1
  460. package/dist/sdk/completion/zsh.js +75 -75
  461. package/dist/sdk/completion.js +1 -1
  462. package/dist/sdk/config.js +1 -1
  463. package/dist/sdk/context/recency.js +1 -1
  464. package/dist/sdk/context/semantic-session-attribution.js +1 -1
  465. package/dist/sdk/context/usage-egress.js +1 -1
  466. package/dist/sdk/context/usage-ledger.js +6 -6
  467. package/dist/sdk/context-intent-contracts.js +1 -1
  468. package/dist/sdk/context-intent-runtime.js +1 -1
  469. package/dist/sdk/context-packing.js +1 -1
  470. package/dist/sdk/context-relevance.js +1 -1
  471. package/dist/sdk/context-signal-store.js +2 -2
  472. package/dist/sdk/context-usage.js +1 -1
  473. package/dist/sdk/dependencies/context-budget-recovery.js +1 -1
  474. package/dist/sdk/dependencies.js +1 -1
  475. package/dist/sdk/dependency-flag-validation.js +1 -1
  476. package/dist/sdk/dependency-provenance.js +1 -1
  477. package/dist/sdk/docs.js +1 -1
  478. package/dist/sdk/duplicates.js +1 -1
  479. package/dist/sdk/environment/host-environment-errors.js +1 -1
  480. package/dist/sdk/environment/project-runtime-compatibility.js +2 -2
  481. package/dist/sdk/environment/source-context.js +1 -1
  482. package/dist/sdk/environment/tracker-preflight.js +1 -1
  483. package/dist/sdk/error-code-catalog.js +1 -1
  484. package/dist/sdk/error-runtime.js +1 -1
  485. package/dist/sdk/errors.js +1 -1
  486. package/dist/sdk/eval.js +1 -1
  487. package/dist/sdk/extension/author-manifest.js +1 -1
  488. package/dist/sdk/extension/bundled-catalog.js +1 -1
  489. package/dist/sdk/extension/command-options.d.ts +26 -1
  490. package/dist/sdk/extension/command-options.js +1 -1
  491. package/dist/sdk/extension/concurrency.js +1 -1
  492. package/dist/sdk/extension/copy-scope.js +1 -1
  493. package/dist/sdk/extension/custom-field-collisions.js +1 -1
  494. package/dist/sdk/extension/describe.js +3 -3
  495. package/dist/sdk/extension/doctor.js +1 -1
  496. package/dist/sdk/extension/install-plan.js +1 -1
  497. package/dist/sdk/extension/install-receipts.js +1 -1
  498. package/dist/sdk/extension/install-runtime.js +3 -3
  499. package/dist/sdk/extension/install-snapshot.js +1 -1
  500. package/dist/sdk/extension/install-sources.js +5 -5
  501. package/dist/sdk/extension/managed-state.js +2 -2
  502. package/dist/sdk/extension/managed-update-status.js +1 -1
  503. package/dist/sdk/extension/migrations.js +2 -2
  504. package/dist/sdk/extension/native-command-options.js +1 -1
  505. package/dist/sdk/extension/output-ownership.js +1 -1
  506. package/dist/sdk/extension/runtime-summary.js +1 -1
  507. package/dist/sdk/extension/scaffold.js +11 -11
  508. package/dist/sdk/extension/shared.js +1 -1
  509. package/dist/sdk/extension/source-resolution.js +1 -1
  510. package/dist/sdk/extension/static-inventory.js +1 -1
  511. package/dist/sdk/extension/update-check.js +1 -1
  512. package/dist/sdk/extension-command-context.js +2 -2
  513. package/dist/sdk/extension-contracts.js +1 -1
  514. package/dist/sdk/extension.js +1 -1
  515. package/dist/sdk/files.js +1 -1
  516. package/dist/sdk/flag-invocation-contracts.js +1 -1
  517. package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
  518. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  519. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  520. package/dist/sdk/generated-error-code-catalog.js +1 -1
  521. package/dist/sdk/governance/assurance-action-contracts.js +0 -1
  522. package/dist/sdk/governance/assurance-action.js +1 -1
  523. package/dist/sdk/governance/assurance-limits.js +1 -1
  524. package/dist/sdk/governance/assurance-mutation-error.js +1 -1
  525. package/dist/sdk/governance/assurance-presets.js +1 -1
  526. package/dist/sdk/governance/assurance-runtime.js +1 -1
  527. package/dist/sdk/governance/assurance.js +4 -4
  528. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  529. package/dist/sdk/governance/closure-timestamps.js +1 -1
  530. package/dist/sdk/governance/defect-recurrence-coverage.js +1 -1
  531. package/dist/sdk/governance/defect-recurrence-graph.js +1 -1
  532. package/dist/sdk/governance/defect-recurrence-signals.js +1 -1
  533. package/dist/sdk/governance/defect-recurrence.js +2 -2
  534. package/dist/sdk/governance/extension-host-version.js +1 -1
  535. package/dist/sdk/governance/gc.js +1 -1
  536. package/dist/sdk/governance/health/history-drift-remedies.js +1 -1
  537. package/dist/sdk/governance/health/projection.js +1 -1
  538. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  539. package/dist/sdk/governance/health.js +2 -2
  540. package/dist/sdk/governance/hierarchy-validation.js +1 -1
  541. package/dist/sdk/governance/in-progress-work-health.js +1 -1
  542. package/dist/sdk/governance/lifecycle-dependency-cycles.js +1 -1
  543. package/dist/sdk/governance/linked-file-report.js +1 -1
  544. package/dist/sdk/governance/merge-receipt-history.js +1 -1
  545. package/dist/sdk/governance/provenance-health.js +4 -4
  546. package/dist/sdk/governance/reindex.js +5 -5
  547. package/dist/sdk/governance/stale-work.js +1 -1
  548. package/dist/sdk/governance/status-role-diagnostics.js +1 -1
  549. package/dist/sdk/governance/storage-integrity.js +1 -1
  550. package/dist/sdk/governance/tracked-runtime-cache.js +1 -1
  551. package/dist/sdk/governance/upgrade.js +2 -2
  552. package/dist/sdk/governance/validate-deferred-fields.js +1 -1
  553. package/dist/sdk/governance/validate-history-drift.js +1 -1
  554. package/dist/sdk/governance/validate-item-reader.js +1 -1
  555. package/dist/sdk/governance/validate-normalization.js +1 -1
  556. package/dist/sdk/governance/validate.js +1 -1
  557. package/dist/sdk/governance/workflow-completeness.js +1 -1
  558. package/dist/sdk/governance/workflow-policy.js +3 -3
  559. package/dist/sdk/governance/workspace-position.js +2 -2
  560. package/dist/sdk/graph/analytics.js +1 -1
  561. package/dist/sdk/graph/assembly.js +1 -1
  562. package/dist/sdk/graph/cache.js +1 -1
  563. package/dist/sdk/graph/cardinality-integrity.js +1 -1
  564. package/dist/sdk/graph/centrality.js +1 -1
  565. package/dist/sdk/graph/deadline-scheduling.js +1 -1
  566. package/dist/sdk/graph/durable-cache.js +1 -1
  567. package/dist/sdk/graph/governance-contracts.js +1 -1
  568. package/dist/sdk/graph/governance.js +1 -1
  569. package/dist/sdk/graph/hierarchy-integrity.js +1 -1
  570. package/dist/sdk/graph/lifecycle-coverage.js +1 -1
  571. package/dist/sdk/graph/mutation-advisory.js +1 -1
  572. package/dist/sdk/graph/query-contracts.js +1 -1
  573. package/dist/sdk/graph/remediation.js +1 -1
  574. package/dist/sdk/graph/run.js +1 -1
  575. package/dist/sdk/graph/scheduling.js +1 -1
  576. package/dist/sdk/graph/traversal.js +1 -1
  577. package/dist/sdk/graph/workspace-relationship-kind-registry.js +1 -1
  578. package/dist/sdk/guide-topics.js +1 -1
  579. package/dist/sdk/guide.js +7 -7
  580. package/dist/sdk/history/append-only-repair.js +4 -4
  581. package/dist/sdk/history/attestation-command.js +2 -2
  582. package/dist/sdk/history/attestation-contract.js +1 -1
  583. package/dist/sdk/history/attestation-scan.js +1 -1
  584. package/dist/sdk/history/attestation.js +1 -1
  585. package/dist/sdk/history/maintenance.js +1 -1
  586. package/dist/sdk/history/reanchor-refusal.js +1 -1
  587. package/dist/sdk/history/reseed.js +1 -1
  588. package/dist/sdk/history/salvage.js +5 -5
  589. package/dist/sdk/history/subject.js +1 -1
  590. package/dist/sdk/history-analytics.js +1 -1
  591. package/dist/sdk/history-compact.js +1 -1
  592. package/dist/sdk/history-mcp.js +1 -1
  593. package/dist/sdk/history-provenance.js +1 -1
  594. package/dist/sdk/history-read.js +1 -1
  595. package/dist/sdk/history-redact.js +1 -1
  596. package/dist/sdk/history-repair.js +1 -1
  597. package/dist/sdk/improvement-ledger-validation.js +1 -1
  598. package/dist/sdk/improvement-ledger.js +2 -2
  599. package/dist/sdk/index.d.ts +1 -1
  600. package/dist/sdk/init-agent-guidance.js +10 -10
  601. package/dist/sdk/init.js +14 -14
  602. package/dist/sdk/invocation-author.js +1 -1
  603. package/dist/sdk/item-children.js +1 -1
  604. package/dist/sdk/item-metadata-index.js +1 -1
  605. package/dist/sdk/item-schedule.js +1 -1
  606. package/dist/sdk/item-transaction.js +1 -1
  607. package/dist/sdk/learnings.js +1 -1
  608. package/dist/sdk/lifecycle/append.js +3 -3
  609. package/dist/sdk/lifecycle/checkpoint-rollback.js +1 -1
  610. package/dist/sdk/lifecycle/claim.js +1 -1
  611. package/dist/sdk/lifecycle/cli-input.js +1 -1
  612. package/dist/sdk/lifecycle/close-many.js +1 -1
  613. package/dist/sdk/lifecycle/close.js +1 -1
  614. package/dist/sdk/lifecycle/copy.js +1 -1
  615. package/dist/sdk/lifecycle/core-field-recovery.js +1 -1
  616. package/dist/sdk/lifecycle/core-item-fields.js +1 -1
  617. package/dist/sdk/lifecycle/create-deferrals.js +1 -1
  618. package/dist/sdk/lifecycle/create.js +1 -1
  619. package/dist/sdk/lifecycle/delete.js +1 -1
  620. package/dist/sdk/lifecycle/dependency-removal.js +1 -1
  621. package/dist/sdk/lifecycle/event-validation-messages.js +1 -1
  622. package/dist/sdk/lifecycle/focus.js +1 -1
  623. package/dist/sdk/lifecycle/hierarchy-mutation-lock.js +1 -1
  624. package/dist/sdk/lifecycle/item-revision.js +1 -1
  625. package/dist/sdk/lifecycle/legacy-none-tokens.js +1 -1
  626. package/dist/sdk/lifecycle/lifecycle-transitions.js +1 -1
  627. package/dist/sdk/lifecycle/mcp-actions.js +1 -1
  628. package/dist/sdk/lifecycle/metadata-normalizers.js +1 -1
  629. package/dist/sdk/lifecycle/mutation-command-options.js +0 -1
  630. package/dist/sdk/lifecycle/mutation-facet-contracts.js +1 -1
  631. package/dist/sdk/lifecycle/mutation-option-validation.js +1 -1
  632. package/dist/sdk/lifecycle/plan-mutation-receipt.js +1 -1
  633. package/dist/sdk/lifecycle/plan.js +1 -1
  634. package/dist/sdk/lifecycle/recurrence-parsers.js +1 -1
  635. package/dist/sdk/lifecycle/release-handoff.js +1 -1
  636. package/dist/sdk/lifecycle/reopen.js +1 -1
  637. package/dist/sdk/lifecycle/repeatable-metadata-parsers.js +2 -2
  638. package/dist/sdk/lifecycle/repeated-terminal-state.js +1 -1
  639. package/dist/sdk/lifecycle/restore.js +1 -1
  640. package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
  641. package/dist/sdk/lifecycle/start-blockers.js +1 -1
  642. package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
  643. package/dist/sdk/lifecycle/task-composition.js +1 -1
  644. package/dist/sdk/lifecycle/update-many.js +1 -1
  645. package/dist/sdk/lifecycle/update.js +2 -2
  646. package/dist/sdk/lifecycle/workflow-transition.js +1 -1
  647. package/dist/sdk/lifecycle-completion.js +1 -1
  648. package/dist/sdk/lifecycle-policy.js +1 -1
  649. package/dist/sdk/linked-artifacts.js +2 -2
  650. package/dist/sdk/mcp/apps.js +5 -5
  651. package/dist/sdk/mcp/authorization.js +1 -1
  652. package/dist/sdk/mcp/discovery.js +1 -1
  653. package/dist/sdk/mcp/executable.js +4 -4
  654. package/dist/sdk/mcp/interactions.js +1 -1
  655. package/dist/sdk/mcp/protocol.js +1 -1
  656. package/dist/sdk/mcp/skills.js +3 -3
  657. package/dist/sdk/mcp/subscriptions.js +1 -1
  658. package/dist/sdk/mcp/tasks.js +2 -2
  659. package/dist/sdk/mcp/transport.js +1 -1
  660. package/dist/sdk/merge/abandoned-receipts.js +1 -1
  661. package/dist/sdk/merge/driver.js +7 -7
  662. package/dist/sdk/merge/history-scalar-rebase.js +1 -1
  663. package/dist/sdk/merge/ignored-artifacts.js +1 -1
  664. package/dist/sdk/merge/index.js +1 -1
  665. package/dist/sdk/merge/indexed-receipt-blobs.js +2 -2
  666. package/dist/sdk/merge/install.js +6 -6
  667. package/dist/sdk/merge/receipt-file-boundary.js +1 -1
  668. package/dist/sdk/merge/receipt-operation.js +1 -1
  669. package/dist/sdk/merge/receipt-schema.js +1 -1
  670. package/dist/sdk/merge/receipts.js +4 -4
  671. package/dist/sdk/merge/reconcile.js +1 -1
  672. package/dist/sdk/merge/settlement-hook.js +4 -4
  673. package/dist/sdk/merge/stage.js +1 -1
  674. package/dist/sdk/merge/three-way.js +9 -9
  675. package/dist/sdk/merge/worktree-config.js +2 -2
  676. package/dist/sdk/merge.js +1 -1
  677. package/dist/sdk/mutation-events.js +1 -1
  678. package/dist/sdk/mutation-guard.js +1 -1
  679. package/dist/sdk/notes.js +1 -1
  680. package/dist/sdk/output/fit-envelope.js +1 -1
  681. package/dist/sdk/output/list-envelope.js +1 -1
  682. package/dist/sdk/output/table-rows.js +1 -1
  683. package/dist/sdk/output-contracts.js +1 -1
  684. package/dist/sdk/output-projection.js +1 -1
  685. package/dist/sdk/output-token-accounting.js +1 -1
  686. package/dist/sdk/output.js +2 -2
  687. package/dist/sdk/ownership-source.js +1 -1
  688. package/dist/sdk/package-import-adapters.js +1 -1
  689. package/dist/sdk/package-migrations.js +1 -1
  690. package/dist/sdk/package-runtime-options.js +1 -1
  691. package/dist/sdk/pagination.js +1 -1
  692. package/dist/sdk/profile.js +5 -5
  693. package/dist/sdk/provenance.js +1 -1
  694. package/dist/sdk/public-surface.json +1 -1
  695. package/dist/sdk/query/activity.js +1 -1
  696. package/dist/sdk/query/aggregate.js +1 -1
  697. package/dist/sdk/query/calendar.js +4 -4
  698. package/dist/sdk/query/complete-list.js +1 -1
  699. package/dist/sdk/query/context.js +2 -2
  700. package/dist/sdk/query/declared-blockers.js +1 -1
  701. package/dist/sdk/query/duplicate-candidates.js +1 -1
  702. package/dist/sdk/query/get-facet-roots.js +1 -1
  703. package/dist/sdk/query/get.js +1 -1
  704. package/dist/sdk/query/history.js +1 -1
  705. package/dist/sdk/query/item-filter-options.js +0 -1
  706. package/dist/sdk/query/light-metadata.js +1 -1
  707. package/dist/sdk/query/list-filter-shared.js +1 -1
  708. package/dist/sdk/query/list.js +1 -1
  709. package/dist/sdk/query/multi-value-filters.js +1 -1
  710. package/dist/sdk/query/next-ranking-policy.js +1 -1
  711. package/dist/sdk/query/next-ready-budget.js +1 -1
  712. package/dist/sdk/query/next.js +2 -2
  713. package/dist/sdk/query/parsers.js +1 -1
  714. package/dist/sdk/query/projection-contracts.js +1 -1
  715. package/dist/sdk/query/search/corpus.js +2 -2
  716. package/dist/sdk/query/search/filters.js +1 -1
  717. package/dist/sdk/query/search/input.js +1 -1
  718. package/dist/sdk/query/search/lexical.js +1 -1
  719. package/dist/sdk/query/search/response.js +1 -1
  720. package/dist/sdk/query/search/semantic.js +3 -3
  721. package/dist/sdk/query/search/types.js +0 -1
  722. package/dist/sdk/query/search-contracts.js +1 -1
  723. package/dist/sdk/query/search-pagination.js +1 -1
  724. package/dist/sdk/query/search-rendering.js +1 -1
  725. package/dist/sdk/query/search.js +1 -1
  726. package/dist/sdk/query/window-pagination.js +1 -1
  727. package/dist/sdk/query/workspace-contracts.js +1 -1
  728. package/dist/sdk/read-output/continuation.js +1 -1
  729. package/dist/sdk/read-output/extension.js +1 -1
  730. package/dist/sdk/read-output/options.js +1 -1
  731. package/dist/sdk/read-output/positional-rows.js +1 -1
  732. package/dist/sdk/read-output/provenance.js +1 -1
  733. package/dist/sdk/read-output/session-result.js +0 -1
  734. package/dist/sdk/read-output/surfaces.js +1 -1
  735. package/dist/sdk/read-output/tail-retention.js +1 -1
  736. package/dist/sdk/read-output-budget.js +1 -1
  737. package/dist/sdk/read-output-contracts.d.ts +11 -0
  738. package/dist/sdk/read-output-contracts.js +1 -1
  739. package/dist/sdk/read-output-rows.js +1 -1
  740. package/dist/sdk/read-output-session.js +1 -1
  741. package/dist/sdk/relationship-analytics.js +1 -1
  742. package/dist/sdk/relationship-context.js +1 -1
  743. package/dist/sdk/relationship-history.js +6 -6
  744. package/dist/sdk/relationship-kinds/contract.js +1 -1
  745. package/dist/sdk/relationships.js +1 -1
  746. package/dist/sdk/reproducibility/process.js +1 -1
  747. package/dist/sdk/runtime/actions.js +1 -1
  748. package/dist/sdk/runtime/context.js +1 -1
  749. package/dist/sdk/runtime/mutation-admission.js +1 -1
  750. package/dist/sdk/runtime/mutation-value-validation.js +1 -1
  751. package/dist/sdk/runtime/schema-preview.js +1 -1
  752. package/dist/sdk/runtime/schema.js +1 -1
  753. package/dist/sdk/runtime-action-aliases.js +1 -1
  754. package/dist/sdk/runtime-extended-actions.js +1 -1
  755. package/dist/sdk/runtime-input.d.ts +2 -0
  756. package/dist/sdk/runtime-input.js +1 -1
  757. package/dist/sdk/runtime-primitives.js +1 -1
  758. package/dist/sdk/runtime-public-contracts.js +0 -1
  759. package/dist/sdk/runtime-stats-options.js +1 -1
  760. package/dist/sdk/runtime.d.ts +5 -3
  761. package/dist/sdk/runtime.js +1 -1
  762. package/dist/sdk/scheduling-shortcuts.js +1 -1
  763. package/dist/sdk/schema/field-flag-spelling.d.ts +22 -0
  764. package/dist/sdk/schema/field-flag-spelling.js +2 -0
  765. package/dist/sdk/schema/field-option-collisions.js +2 -0
  766. package/dist/sdk/schema-migration.js +4 -4
  767. package/dist/sdk/schema.js +7 -7
  768. package/dist/sdk/search-refresh-worker.js +1 -1
  769. package/dist/sdk/similarity-scoring.js +1 -1
  770. package/dist/sdk/similarity.js +1 -1
  771. package/dist/sdk/start-task-status.js +1 -1
  772. package/dist/sdk/stats.js +1 -1
  773. package/dist/sdk/structured-mutations.js +1 -1
  774. package/dist/sdk/telemetry-flush.js +1 -1
  775. package/dist/sdk/telemetry.js +4 -4
  776. package/dist/sdk/templates.js +3 -3
  777. package/dist/sdk/test/batch.js +2 -2
  778. package/dist/sdk/test/command-args.js +1 -1
  779. package/dist/sdk/test/command-resolution.js +2 -2
  780. package/dist/sdk/test/entry.js +2 -2
  781. package/dist/sdk/test/execution-receipts.js +2 -2
  782. package/dist/sdk/test/execution.js +5 -5
  783. package/dist/sdk/test/json-path.js +1 -1
  784. package/dist/sdk/test/linked-command-detection.js +1 -1
  785. package/dist/sdk/test/measurements.js +1 -1
  786. package/dist/sdk/test/parsers.js +1 -1
  787. package/dist/sdk/test/prerequisites.js +1 -1
  788. package/dist/sdk/test/receipt-index-snapshot.js +1 -1
  789. package/dist/sdk/test/run-phases.js +1 -1
  790. package/dist/sdk/test/runs.js +1 -1
  791. package/dist/sdk/test/trust.js +2 -2
  792. package/dist/sdk/test/update.js +1 -1
  793. package/dist/sdk/test/workspace-snapshot.js +1 -1
  794. package/dist/sdk/traceability/runtime-files-lookup.js +1 -1
  795. package/dist/sdk/traceability/source-traceability.js +2 -2
  796. package/dist/sdk/tracker-root-discovery.js +1 -1
  797. package/dist/sdk/transactions/item-finalization.js +1 -1
  798. package/dist/sdk/workspace-contracts-cache.js +1 -1
  799. package/dist/sdk/workspace-contracts.js +1 -1
  800. package/dist/sdk/workspace-memory.js +2 -2
  801. package/dist/sdk/workspace-snapshot.js +5 -5
  802. package/dist/sdk/workspace-transaction-gc.js +1 -1
  803. package/dist/sdk/workspace-transaction.js +2 -2
  804. package/dist/sdk/workspace.js +6 -6
  805. package/dist/types/index.js +1 -1
  806. package/dist/types.js +1 -1
  807. package/docs/COMMANDS.md +1 -1
  808. package/docs/EXTENSIONS.md +2 -2
  809. package/docs/READ_OUTPUT_CONTRACTS.md +2 -0
  810. package/docs/SDK.md +94 -5
  811. package/docs/SDK_AUDITED_MUTATIONS.md +11 -0
  812. package/marketplace.json +1 -1
  813. package/package.json +2 -1
  814. package/packages/pm-beads/package.json +1 -1
  815. package/packages/pm-calendar/package.json +1 -1
  816. package/packages/pm-command-kit/package.json +1 -1
  817. package/packages/pm-digital-twin/package.json +1 -1
  818. package/packages/pm-governance-audit/package.json +1 -1
  819. package/packages/pm-guide-shell/package.json +1 -1
  820. package/packages/pm-kanban/package.json +1 -1
  821. package/packages/pm-lifecycle-hooks/package.json +1 -1
  822. package/packages/pm-linked-test-adapters/package.json +1 -1
  823. package/packages/pm-search-advanced/package.json +1 -1
  824. package/packages/pm-templates/package.json +1 -1
  825. package/packages/pm-todos/package.json +1 -1
  826. package/packages/pm-vcs/package.json +1 -1
  827. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  828. package/plugins/pm-claude/package.json +1 -1
  829. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  830. package/plugins/pm-codex/package.json +1 -1
  831. package/plugins/pm-codex/plugin.json +1 -1
  832. package/runtime-dependencies.json +1 -1
  833. package/scripts/finalize-build.mjs +63 -24
  834. package/scripts/prepare-build-cache.mjs +28 -1
  835. package/dist/cli-bundle/chunks/chunk-3W47ZZ5T.js +0 -9
  836. package/dist/cli-bundle/chunks/chunk-4TB5D6HL.js +0 -125
  837. package/dist/cli-bundle/chunks/chunk-5ZMVLWE3.js +0 -2
  838. package/dist/cli-bundle/chunks/chunk-6BBDEIKC.js +0 -33
  839. package/dist/cli-bundle/chunks/chunk-AR4NP5HI.js +0 -3
  840. package/dist/cli-bundle/chunks/chunk-B4PPFOPY.js +0 -3
  841. package/dist/cli-bundle/chunks/chunk-CAR2L5NW.js +0 -8
  842. package/dist/cli-bundle/chunks/chunk-DEZPZOQ7.js +0 -2
  843. package/dist/cli-bundle/chunks/chunk-EIGUKEV6.js +0 -2
  844. package/dist/cli-bundle/chunks/chunk-GTPCAJMZ.js +0 -8
  845. package/dist/cli-bundle/chunks/chunk-GYP24M7W.js +0 -2
  846. package/dist/cli-bundle/chunks/chunk-HC2OPETM.js +0 -2
  847. package/dist/cli-bundle/chunks/chunk-HKUV74K3.js +0 -2
  848. package/dist/cli-bundle/chunks/chunk-HXHYDO2R.js +0 -115
  849. package/dist/cli-bundle/chunks/chunk-IB7UB5TE.js +0 -2
  850. package/dist/cli-bundle/chunks/chunk-J2LABXBL.js +0 -2
  851. package/dist/cli-bundle/chunks/chunk-J52BEBSS.js +0 -2
  852. package/dist/cli-bundle/chunks/chunk-KQIZ34SF.js +0 -3
  853. package/dist/cli-bundle/chunks/chunk-LQBWLNZJ.js +0 -3
  854. package/dist/cli-bundle/chunks/chunk-OJTMGDON.js +0 -31
  855. package/dist/cli-bundle/chunks/chunk-SPPHDVZE.js +0 -2
  856. package/dist/cli-bundle/chunks/chunk-TC6XLIYO.js +0 -2
  857. package/dist/cli-bundle/chunks/chunk-U7EL3AYA.js +0 -3
  858. package/dist/cli-bundle/chunks/chunk-VQFWW4EF.js +0 -6
  859. package/dist/cli-bundle/chunks/chunk-X6MIWTTT.js +0 -2
  860. package/dist/cli-bundle/chunks/chunk-XC5Q2ZV7.js +0 -2
  861. package/dist/cli-bundle/chunks/chunk-XFHPKXAE.js +0 -71
  862. package/dist/cli-bundle/chunks/chunk-YHVLVSEZ.js +0 -9
  863. package/dist/cli-bundle/chunks/chunk-YMUSRWV4.js +0 -9
  864. package/dist/cli-bundle/chunks/chunk-YR2KEBHP.js +0 -2
  865. package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +0 -2
  866. package/dist/cli-bundle/chunks/indexed-receipt-blobs-ITTXIN4K.js +0 -4
  867. package/dist/cli-bundle/chunks/item-revision-4QBMZXKX.js +0 -2
  868. package/dist/cli-bundle/chunks/item-transaction-QY3PUHEI.js +0 -2
  869. package/dist/cli-bundle/chunks/mutation-actor-FWLYWJ37.js +0 -2
  870. package/dist/cli-bundle/chunks/mutation-admission-7ZDCK3G2.js +0 -2
  871. package/dist/cli-bundle/chunks/register-mutation-57AJQWFV.js +0 -21
  872. package/dist/cli-bundle/chunks/register-operations-RKWST7CU.js +0 -2
  873. package/dist/cli-bundle/chunks/register-setup-CMI23PC5.js +0 -2
  874. package/dist/cli-bundle/chunks/settlement-hook-BXN5LEQD.js +0 -7
  875. package/dist/cli-bundle/chunks/stage-4KDVXC5Z.js +0 -2
  876. package/dist/cli-bundle/focused-chunks/chunk-2ZD7275J.js +0 -2
  877. package/dist/cli-bundle/focused-chunks/chunk-324AHXJO.js +0 -2
  878. package/dist/cli-bundle/focused-chunks/chunk-3IRCYJI5.js +0 -3
  879. package/dist/cli-bundle/focused-chunks/chunk-3V53UBHN.js +0 -9
  880. package/dist/cli-bundle/focused-chunks/chunk-3XSWH6QC.js +0 -91
  881. package/dist/cli-bundle/focused-chunks/chunk-4JZITIJB.js +0 -2
  882. package/dist/cli-bundle/focused-chunks/chunk-4KTFKSS3.js +0 -2
  883. package/dist/cli-bundle/focused-chunks/chunk-5C5TK3ET.js +0 -78
  884. package/dist/cli-bundle/focused-chunks/chunk-AKJYOZZP.js +0 -2
  885. package/dist/cli-bundle/focused-chunks/chunk-BRZV7BFV.js +0 -8
  886. package/dist/cli-bundle/focused-chunks/chunk-C3O6JJPO.js +0 -2
  887. package/dist/cli-bundle/focused-chunks/chunk-CR7CGEB2.js +0 -3
  888. package/dist/cli-bundle/focused-chunks/chunk-EGN2HFRU.js +0 -2
  889. package/dist/cli-bundle/focused-chunks/chunk-GHQVM6K6.js +0 -2
  890. package/dist/cli-bundle/focused-chunks/chunk-HDEKFSOK.js +0 -2
  891. package/dist/cli-bundle/focused-chunks/chunk-I5LGPUWH.js +0 -2
  892. package/dist/cli-bundle/focused-chunks/chunk-IWOXAUDU.js +0 -2
  893. package/dist/cli-bundle/focused-chunks/chunk-ML3JHCC6.js +0 -6
  894. package/dist/cli-bundle/focused-chunks/chunk-OPGOOP25.js +0 -2
  895. package/dist/cli-bundle/focused-chunks/chunk-RE7ZWT7D.js +0 -27
  896. package/dist/cli-bundle/focused-chunks/chunk-RKQNVYGF.js +0 -3
  897. package/dist/cli-bundle/focused-chunks/chunk-RQ252B6V.js +0 -8
  898. package/dist/cli-bundle/focused-chunks/chunk-SVOOGGAK.js +0 -2
  899. package/dist/cli-bundle/focused-chunks/chunk-URGHTTT3.js +0 -8
  900. package/dist/cli-bundle/focused-chunks/chunk-USPYKWQG.js +0 -13
  901. package/dist/cli-bundle/focused-chunks/chunk-UWS3FC4D.js +0 -102
  902. package/dist/cli-bundle/focused-chunks/chunk-UXQGFGAT.js +0 -44
  903. package/dist/cli-bundle/focused-chunks/chunk-WZWXGDYY.js +0 -26
  904. package/dist/cli-bundle/focused-chunks/chunk-YKSLZPLT.js +0 -2
  905. package/dist/cli-bundle/focused-chunks/chunk-ZWJTY4ID.js +0 -2
  906. package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +0 -2
  907. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-AF4U3F3D.js +0 -4
  908. package/dist/cli-bundle/focused-chunks/item-transaction-GLACUTPL.js +0 -2
  909. package/dist/cli-bundle/focused-chunks/mutation-actor-TCYDPUGG.js +0 -2
  910. package/dist/cli-bundle/focused-chunks/mutation-admission-LY73EJWM.js +0 -2
  911. package/dist/cli-bundle/focused-chunks/settlement-hook-ARYCZQY4.js +0 -7
  912. package/dist/cli-bundle/focused-chunks/stage-DQ7RQQ52.js +0 -2
@@ -1,91 +0,0 @@
1
- import{e as zt,n as Xt,v as Gt,x as he}from"./chunk-BRZV7BFV.js";import{$f as pe,Af as Be,Ba as Me,Bd as q,Bf as Ht,Ca as Pe,Cd as Ft,Cf as ze,Da as R,Dd as K,Df as Wt,Ec as Dt,Fc as je,H as gt,He as $e,Ie as $t,Je as fe,Nc as V,Nd as Mt,Oa as Tt,Od as Pt,Sa as St,Se as Ut,Ta as xt,Tf as Q,Vc as kt,Vf as Xe,Wf as ye,Xf as L,_f as Ge,a as ue,ag as Bt,bc as Rt,bg as Ye,eg as Ve,hd as Le,id as Nt,if as Ue,jf as He,na as Et,ne as jt,oa as vt,ra as It,te as Lt,ud as At,wa as me,ya as Ct,yc as Ot,ze as J,zf as We}from"./chunk-UWS3FC4D.js";import{A as m,B as bt,C as z,E as j,I as N,m as wt,t as P,y as Fe,z as f}from"./chunk-3IRCYJI5.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4e02447f-3fb0-5f7c-9512-be2b348fd082")}catch{}})();var $=new Set(wt),_e=Object.freeze({get size(){return $.size},has(e){return $.has(e)},entries(){return $.entries()},keys(){return $.keys()},values(){return $.values()},forEach(e,t){$.forEach(i=>e.call(t,i,i,_e))},[Symbol.iterator](){return $.values()}});function Yt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Vt(e){return typeof e!="string"?null:gt(e)}function Xi(e){try{return structuredClone(e)}catch{return e}}function Gi(e){let t=e.trim(),i=t.indexOf("=");if(i<=0)throw new m(`--field entries must use name=value syntax, received: ${e}`,f.USAGE);let o=t.slice(0,i).trim(),r=t.slice(i+1);return{key:o,value:r}}function Yi(e,t,i){try{let o=JSON.parse(e);if(i==="array"&&Array.isArray(o)||i==="object"&&typeof o=="object"&&o!==null&&!Array.isArray(o))return o}catch{}throw new m(`--field ${t}=... must be valid JSON ${i}`,f.USAGE)}function Vi(e,t,i){if(t==="string")return i;if(t==="number"){let o=i.trim();if(o.length===0)throw new m(`--field ${e}=... must be a number`,f.USAGE);let r=Number(o);if(!Number.isFinite(r))throw new m(`--field ${e}=... must be a number`,f.USAGE);return r}if(t==="boolean"){let o=i.trim().toLowerCase();if(o==="true"||o==="1"||o==="yes")return!0;if(o==="false"||o==="0"||o==="no")return!1;throw new m(`--field ${e}=... must be one of true|false|1|0|yes|no`,f.USAGE)}return t==="string_array"?i.split(/[\n,|]/u).map(o=>o.trim()).filter(o=>o.length>0):Yi(i,e,t)}function qe(e){let t=new Map;if(!e)return t;for(let i of e.item_fields)for(let o of i.fields){let r=Yt(o.name),n=Vt(o.type);if(!r||!n)continue;let s=t.get(r);if(s&&s.type!==n)throw new m(`Extension item field "${r}" is declared with conflicting types: ${s.type}, ${n}`,f.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(r,{name:r,type:n})}return t}function qt(e){if(_e.has(e))throw new m(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[..._e].sort((t,i)=>t.localeCompare(i)).join(", ")}.`,f.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function ge(e){return[...qe(e).keys()].sort((t,i)=>t.localeCompare(i))}function Xr(e,t,i,o){if(!e||e.length===0)return{};let r=qe(t),n={};for(let s of e){let{key:a,value:d}=Gi(s),c=r.get(a);if(!c)throw qi(a,r,i,o);qt(c.name),n[c.name]=Vi(c.name,c.type,d)}return n}function qi(e,t,i,o){if(_e.has(e)){let s=i?.(e)??{recovery:{provided_fields:[e]},nextSteps:["Core metadata has no generic --field mutation path. Use the owning lifecycle, evidence, or importer API; inspect pm update <id> --help for declared mutation flags."]};return new m(`--field ${e} is a core item field, not an extension field`,f.USAGE,{code:"core_item_field_requires_dedicated_flag",field:e,...s})}let r=o?.(e);if(r!==void 0){let s=r.recovery?.suggested_flags?.[0];return new m(s===void 0?`--field ${e} is a project-schema field, not an extension field`:`--field ${e} is a project-schema field; set it with its declared flag ${s}`,f.USAGE,{code:"project_schema_field_requires_declared_flag",field:e,changed:!1,...r})}let n=[...t.keys()].sort((s,a)=>s.localeCompare(a));return new m(`--field ${e} is not declared by an active extension item-field registration`,f.USAGE,{code:"extension_item_field_unknown",field:e,recovery:{provided_fields:[e]},nextSteps:n.length>0?[`Use one of the declared fields: ${n.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}function Ki(e,t){return t==="string"?typeof e=="string":t==="number"?typeof e=="number"&&Number.isFinite(e):t==="boolean"?typeof e=="boolean":t==="array"?Array.isArray(e):t==="string_array"?Array.isArray(e)&&e.every(i=>typeof i=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ji(e,t){return!t||t.length===0?!0:t.some(i=>Object.is(i,e))}function Gr(e,t,i={}){if(t){qe(t);for(let o of t.item_fields)for(let r of o.fields){let n=Yt(r.name);if(!n)continue;qt(n),!(n in e)&&!i.skipDefaultFields?.has(n)&&Object.prototype.hasOwnProperty.call(r,"default")&&(e[n]=Xi(r.default));let s=e[n];if(s===void 0)continue;let a=Vt(r.type);if(a&&!Ki(s,a))throw new TypeError(`Item field "${n}" must be of type ${a}`);let d=Array.isArray(r.values)?r.values:void 0;if(!Ji(s,d))throw new TypeError(`Item field "${n}" must match one of the configured allowed values`)}}}import Qi from"node:crypto";import we from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="664124e5-715d-5f86-ae69-89f203db76c3")}catch{}})();function Jt(e){let t=[],i=!1;for(let o of(e??"").toLowerCase()){let r=o.charCodeAt(0),n=r>=48&&r<=57,s=r>=97&&r<=122;if(!n&&!s){i=t.length>0;continue}i&&(t.push("-"),i=!1),t.push(o)}return t.length===0?"pm-":`${t.join("")}-`}function Z(e){let t=e.trim().toLowerCase();return t.startsWith("#")&&(t=t.slice(1)),t}function ee(e,t){let i=Jt(t),o=Z(e);return o.startsWith(i)?o:`${i}${o}`}function Zi(e){let t=Dt(e);if(t!==void 0)return t;let i="";for(let o=0;o<e;o+=1)i+=Qi.randomInt(0,36).toString(36);return i}async function eo(e,t,i){let o=[...new Set(Object.values(i))].flatMap(r=>[we.join(e,r,`${t}.md`),we.join(e,r,`${t}.toon`)]);return o.push(we.join(e,"history",`${t}.jsonl`)),(await Promise.all(o.map(r=>z(r)))).some(Boolean)}var Kt=4,Qt=12;function to(e){return typeof e!="number"||!Number.isFinite(e)?Kt:Math.min(Qt,Math.max(Kt,Math.trunc(e)))}async function Zr(e,t,i={}){let o=to(i.tokenLength),r=Math.min(o+6,Qt),n=0;for(;o<=r;){for(let s=0;s<32;s+=1){let a=`${Jt(t)}${Zi(o)}`;if(!await(i.probeExisting===!1?z(we.join(e,"history",`${a}.jsonl`)):eo(e,a,i.typeToFolder??P)))return a;n+=1}o+=1}throw new Error(`Unable to generate unique id after ${n} attempts`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5db05e2f-4742-526b-b1c8-b97ff302b40e")}catch{}})();function te(e,t=!1){let i=e[0];if(i?.op!=="history_compact_baseline")return 0;let o=i.context?.history_compaction,r=typeof o=="object"&&o!==null&&"version_offset"in o?o.version_offset:void 0;if(typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&Number.isSafeInteger(r+e.length))return r;if(t)return null;throw new m("This compacted stream has no trustworthy version offset; numeric history addresses are unavailable.",f.USAGE,{code:"history_version_mapping_unavailable",required:"Use a retained timestamp or recover the pre-compaction stream from version control.",nextSteps:["Run pm history <id> --full to inspect the retained timestamps and checkpoint evidence."]})}import Zt from"node:fs/promises";import ie from"node:path";import{isUtf8 as io}from"node:buffer";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9fa43d4b-3e4e-5d96-a256-0ce743f52372")}catch{}})();var oo=1048576,ro=4194304;async function ei(e,t){let i=ie.dirname(e);for(;i!==ie.parse(e).root;){let r=await Zt.stat(i).catch(n=>{if(j(n))return null;throw n});if(r!==null){if(!r.isDirectory())throw new m("Workflow policy storage ancestor must be a directory.",f.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Restore the policy or approval history directory before retrying."]});break}i=ie.dirname(i)}let o=await Zt.open(e,"r").catch(r=>{if(j(r))return null;throw r});if(o===null)return null;try{let r=(await o.stat()).size,n=Buffer.alloc(Math.min(t,r)+1),s=0;for(;s<n.length;){let a=await o.read(n,s,n.length-s,s);if(a.bytesRead===0)break;s+=a.bytesRead}if(s===n.length||!io(n.subarray(0,s)))throw new m("Workflow policy input exceeds its byte bound or is not valid UTF-8.",f.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Inspect the policy and approval history; reduce the declaration or use verified history compaction before retrying."]});return n.toString("utf8",0,s)}finally{await o.close()}}function no(e){if(e===null)return{version:1,enforcement:"advise",policies:[]};let t;try{t=JSON.parse(e)}catch{throw new m("schema/policies.json must contain valid JSON.",f.CONFLICT,{code:"workflow_policy_registry_invalid",nextSteps:["Restore valid policy JSON before retrying the mutation."]})}return Tt(t)}async function so(e){return no(await ei(ie.join(e,"schema","policies.json"),oo))}async function ao(e,t){let i=await ei(R(e,t),ro);if(i===null)return[];let o;try{if(o=i.split(/\r?\n/).filter(r=>r.trim()).map(r=>JSON.parse(r)),!fe(o).ok)throw new Error("invalid chain")}catch{throw new m("Approval evidence requires a valid item history chain.",f.CONFLICT,{code:"workflow_policy_approval_history_invalid",nextSteps:[`Run pm history ${t} --verify before recording or using an approval.`]})}return o.flatMap(r=>{let n=r.context?.workflow_approval;if(r.op!=="policy_approve"||r.record_hash_version!==1||typeof r.record_hash!="string"||typeof n!="object"||n===null)return[];let s=n;return typeof s.policy_fingerprint!="string"||typeof s.content_fingerprint!="string"?[]:[{policy_fingerprint:s.policy_fingerprint,content_fingerprint:s.content_fingerprint,author:r.author}]})}async function co(e,t,i){let o=i.before?.status!==i.after?.status&&t.policies.some(s=>s.rule.kind==="approval"&&St(s,i)),r=i.before?.id??i.after?.id,n=o&&typeof r=="string"?await ao(e,r):[];return xt(t,{...i,approvals:n})}function lo(e,t){if(e.dryRun===!0)return!1;let i=Ht(e.pmRoot,[e.before?.metadata.id,e.after?.metadata.id],e.operation);return i===void 0?!1:(i.overrides.push(...t.map(o=>({source:"workflow_policy",policy_id:o.policy_id,rule:o.rule}))),!0)}async function Ke(e){let t=await so(e.pmRoot),i=await co(e.pmRoot,t,{operation:e.operation,author:e.author,before:e.before?{...e.before.metadata,body:e.before.body}:null,after:e.after?{...e.after.metadata,body:e.after.body}:null});if(i.allowed)return i;let o=i.decisions.filter(r=>!r.satisfied&&r.effect==="refuse");return lo(e,o)?i:uo(e,t,i,o)}async function uo(e,t,i,o){let r=[],n="";if(!e.dryRun)try{let l=await zt({pmRoot:e.pmRoot,op:"policy_refused",author:e.author,context:{item_id:e.after?.metadata.id??e.before?.metadata.id,operation:e.operation,workflow_policies:i.decisions},message:"Workflow policy refused a proposed item mutation.",lockTtlSeconds:e.settings.locks.ttl_seconds,lockWaitMs:e.settings.locks.wait_ms});r.push({path:"history/_workspace.jsonl",op:"policy_refused",record_hash:l.entry.record_hash}),n=" Audit appended to tracker-relative history/_workspace.jsonl; retain it with the workspace changes. Each refused attempt records its own audit event."}catch(l){let h=new m("Workflow policy refusal could not be recorded in workspace history.",f.CONFLICT,{code:"workflow_policy_audit_failed",nextSteps:["Resolve workspace-history lock or storage failures, then retry the refused mutation; no item changes were written."]});throw h.cause=l,h}let s=o.slice(0,3).map(l=>({policy_id:l.policy_id,rule:l.rule,description:t.policies.find(h=>h.id===l.policy_id).description,missing_fields:l.missing_fields})),a=[...new Set(s.flatMap(l=>l.missing_fields))],d=s.map(l=>`${l.policy_id} (${l.rule})`).join(", "),c=o.length>3?` and ${o.length-3} more`:"",p=e.after?.metadata.id??e.before.metadata.id,u=a.map(l=>{if(e.before===null)return`Supply ${l} in the original ${e.operation} request, then retry; the item was not created.`;let h=Et("update",l);return h===void 0?`Supply ${l} using its declared SDK or package mutation contract, then retry.`:V(["update",p,vt("update",h),`<${l}>`,"--pm-path",ie.resolve(e.pmRoot)])});throw new m(`Workflow policy refused ${e.operation}: ${d}${c}.${a.length?` Missing: ${a.join(", ")}.`:""}${n}`,f.CONFLICT,{code:"workflow_policy_refused",side_effects:r,reason:s.map(l=>l.policy_id).join(","),policy_violations:s,policy_violation_count:o.length,required:a.length?`Supply missing fields: ${a.join(", ")}, then retry the refused mutation.`:"Satisfy the declared workflow policy before retrying.",why:s.map(l=>l.description).filter(Boolean).join(" ")||void 0,recovery:{missing_required_fields:a},nextSteps:[...u,...new Set(o.slice(0,3).filter(l=>l.missing_fields.length===0).map(l=>l.remediation)),...o.length>3?[`Inspect all policies with pm schema policies before retrying ${e.operation}.`]:[]]})}import{AsyncLocalStorage as mo}from"node:async_hooks";import{channel as fo}from"node:diagnostics_channel";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b2b2d49a-bb8c-54d7-89d2-1dbe76879129")}catch{}})();var Je=new mo,Qe=fo("@unbrained/pm-cli/item-metadata-enumeration/v1");function be(e){Qe.publish(e)}async function En(e){let t={enumeration_calls:0,metadata_rows:0},i=o=>{Je.getStore()?.includes(t)&&(t.enumeration_calls+=1,t.metadata_rows+=o)};Qe.subscribe(i);try{return{result:await Je.run([...Je.getStore()??[],t],e),work:{...t}}}finally{Qe.unsubscribe(i)}}import U from"node:fs/promises";import ii from"node:path";import{randomUUID as yo}from"node:crypto";import{createRequire as po}from"node:module";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="84a3dae8-69b6-589d-a8ec-11f77c1d103a")}catch{}})();var ho="metadata-query-index.sqlite",oe="5",Ze;function re(){return Ze!==void 0||(Ze=Ut(process.versions.node,po(import.meta.url))),Ze}function ti(e,t){return Math.max(0,Math.floor(e===void 0?t:e))}function X(e){return ii.join(e,"runtime",ho)}function _o(e){e.exec(`
2
- PRAGMA foreign_keys = ON;
3
- PRAGMA journal_mode = OFF;
4
- PRAGMA synchronous = OFF;
5
- CREATE TABLE metadata (
6
- key TEXT PRIMARY KEY,
7
- value TEXT NOT NULL
8
- ) STRICT;
9
- CREATE TABLE items (
10
- id TEXT PRIMARY KEY,
11
- relative_path TEXT NOT NULL UNIQUE,
12
- metadata_json TEXT NOT NULL,
13
- status TEXT NOT NULL,
14
- type TEXT NOT NULL,
15
- priority INTEGER NOT NULL,
16
- updated_at TEXT NOT NULL,
17
- created_at TEXT NOT NULL,
18
- parent TEXT,
19
- assignee TEXT,
20
- sprint TEXT,
21
- release TEXT
22
- ) STRICT;
23
- CREATE INDEX items_default_order
24
- ON items(priority, updated_at DESC, id);
25
- CREATE INDEX items_status_default_order
26
- ON items(status, priority, updated_at DESC, id);
27
- CREATE INDEX items_type_default_order
28
- ON items(type, priority, updated_at DESC, id);
29
- CREATE INDEX items_parent_default_order
30
- ON items(parent, priority, updated_at DESC, id);
31
- CREATE TABLE item_metadata_keys (
32
- item_id TEXT NOT NULL,
33
- key TEXT NOT NULL,
34
- PRIMARY KEY(item_id, key),
35
- FOREIGN KEY(item_id) REFERENCES items(id) ON DELETE CASCADE
36
- ) STRICT;
37
- CREATE INDEX item_metadata_keys_key_item
38
- ON item_metadata_keys(key, item_id);
39
- CREATE TABLE item_linked_files (
40
- item_id TEXT NOT NULL,
41
- path TEXT NOT NULL,
42
- scope TEXT NOT NULL,
43
- note TEXT,
44
- PRIMARY KEY(item_id, path, scope),
45
- FOREIGN KEY(item_id) REFERENCES items(id) ON DELETE CASCADE
46
- ) STRICT;
47
- CREATE INDEX item_linked_files_path_scope_item
48
- ON item_linked_files(path, scope, item_id);
49
- CREATE VIRTUAL TABLE item_search USING fts5(
50
- id UNINDEXED,
51
- title,
52
- description,
53
- tags,
54
- tokenize = 'unicode61'
55
- );
56
- `)}function ve(e,t,i){e.prepare("INSERT INTO metadata(key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(t,i)}function oi(e,t){let i=t.metadata;e.prepare(`INSERT INTO items(
57
- id, relative_path, metadata_json, status, type, priority,
58
- updated_at, created_at, parent, assignee, sprint, release
59
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
60
- ON CONFLICT(id) DO UPDATE SET
61
- relative_path = excluded.relative_path,
62
- metadata_json = excluded.metadata_json,
63
- status = excluded.status,
64
- type = excluded.type,
65
- priority = excluded.priority,
66
- updated_at = excluded.updated_at,
67
- created_at = excluded.created_at,
68
- parent = excluded.parent,
69
- assignee = excluded.assignee,
70
- sprint = excluded.sprint,
71
- release = excluded.release`).run(i.id,t.relativePath,JSON.stringify(i),i.status,i.type,i.priority,i.updated_at,i.created_at,i.parent??null,i.assignee??null,i.sprint??null,i.release??null),e.prepare("DELETE FROM item_metadata_keys WHERE item_id = ?").run(i.id),e.prepare("DELETE FROM item_linked_files WHERE item_id = ?").run(i.id),e.prepare("DELETE FROM item_search WHERE rowid = (SELECT rowid FROM items WHERE id = ?)").run(i.id),e.prepare("INSERT INTO item_search(rowid, id, title, description, tags) SELECT rowid, ?, ?, ?, ? FROM items WHERE id = ?").run(i.id,i.title,i.description,i.tags.join(" "),i.id);let o=e.prepare("INSERT INTO item_metadata_keys(item_id, key) VALUES (?, ?)");for(let n of Object.keys(i))o.run(i.id,n);let r=e.prepare("INSERT INTO item_linked_files(item_id, path, scope, note) VALUES (?, ?, ?, ?)");for(let n of t.linkedFiles??[])r.run(i.id,n.path,n.scope,n.note??null)}async function ri(e){let t=X(e.pmRoot),i=re();if(!i){await U.rm(t,{force:!0});return}await U.mkdir(ii.dirname(t),{recursive:!0});let o=`${t}.${yo()}.tmp`,r;try{r=new i(o),_o(r),r.exec("BEGIN IMMEDIATE"),ve(r,"version",oe),ve(r,"context_fingerprint",e.contextFingerprint),ve(r,"source_cursor",e.sourceCursor);for(let n of e.rows)oi(r,n);r.exec("COMMIT"),r.close(),r=void 0,await U.rm(t,{force:!0}),await U.rename(o,t)}catch(n){throw r?.close(),await Promise.allSettled([U.rm(o,{force:!0})]),n}}function Ie(e){return Object.fromEntries(e.prepare("SELECT key, value FROM metadata").all().map(t=>[String(t.key),String(t.value)]))}async function ni(e){let t=re();if(!t)return!1;let i=X(e.pmRoot),o;try{await U.access(i),o=new t(i),o.exec("PRAGMA foreign_keys = ON");let r=Ie(o);if(r.version!==oe||r.context_fingerprint!==e.contextFingerprint||r.source_cursor!==e.expectedSourceCursor)return o.close(),!1;o.exec("BEGIN IMMEDIATE");let n=o.prepare("DELETE FROM items WHERE relative_path = ?"),s=o.prepare("SELECT rowid FROM items WHERE relative_path = ?"),a=o.prepare("DELETE FROM item_search WHERE rowid = ?");for(let d of e.deletedRelativePaths??[]){let c=s.get(d);n.run(d),c&&a.run(c.rowid)}return e.row&&oi(o,e.row),ve(o,"source_cursor",e.sourceCursor),o.exec("COMMIT"),o.close(),!0}catch{try{o?.exec("ROLLBACK")}catch{}return o?.close(),!1}}function Ee(e,t,i,o,r){!o||o.length===0||(e.push(`${i} ${r} (${o.map(()=>"?").join(", ")})`),t.push(...o))}function go(e){let t=[],i=[];Ee(t,i,"status",e.statuses,"IN"),Ee(t,i,"status",e.excludeStatuses,"NOT IN"),Ee(t,i,"type",e.types,"IN"),Ee(t,i,"id",e.ids,"IN");for(let o of e.metadataKeys??[])t.push("EXISTS (SELECT 1 FROM item_metadata_keys AS indexed_key WHERE indexed_key.item_id = items.id AND indexed_key.key = ?)"),i.push(o);for(let[o,r]of[["parent",e.parent],["assignee",e.assignee],["sprint",e.sprint],["release",e.release]])r!==void 0&&(t.push(`${o} = ?`),i.push(r));return e.priority!==void 0&&(t.push("priority = ?"),i.push(e.priority)),{where:t.length===0?"":` WHERE ${t.join(" AND ")}`,parameters:i}}async function On(e){let t=re();if(!t)return null;let i=e.query??{},{where:o,parameters:r}=go(i),n;try{n=new t(X(e.pmRoot),{readOnly:!0});let s=Ie(n);if(s.version!==oe||s.source_cursor!==e.expectedSourceCursor)return n.close(),null;let a=n.prepare(`SELECT COUNT(*) AS count FROM items${o}`).get(...r),d=[],c="";i.limit!==void 0?(c+=" LIMIT ?",d.push(Math.max(0,Math.floor(i.limit))),i.offset!==void 0&&(c+=" OFFSET ?",d.push(Math.max(0,Math.floor(i.offset))))):i.offset!==void 0&&(c+=" LIMIT -1 OFFSET ?",d.push(Math.max(0,Math.floor(i.offset))));let p=n.prepare(`SELECT metadata_json FROM items${o}
72
- ORDER BY ${i.terminalStatuses&&i.terminalStatuses.length>0?`CASE WHEN status IN (${i.terminalStatuses.map(()=>"?").join(", ")}) THEN 1 ELSE 0 END ASC, `:""}priority ASC, updated_at DESC, id ASC${c}`).all(...r,...i.terminalStatuses??[],...d).map(u=>{let l=JSON.parse(String(u.metadata_json));if(!l.id)throw new TypeError("Indexed metadata row has no id");return l});return n.close(),{source_cursor:s.source_cursor,total:Number(a.count),items:p}}catch{return n?.close(),null}}async function Dn(e){let t=re();if(!t||e.paths.length===0)return null;let i;try{i=new t(X(e.pmRoot),{readOnly:!0});let o=Ie(i);if(o.version!==oe||o.source_cursor!==e.expectedSourceCursor)return i.close(),null;let r=e.paths.map(()=>"?").join(", "),n=e.scope===void 0?"":" AND scope = ?",s=[...e.paths,...e.scope===void 0?[]:[e.scope]],a=`path IN (${r})${n}`,d=i.prepare(`SELECT COUNT(DISTINCT item_id) AS count
73
- FROM item_linked_files
74
- WHERE ${a}`).get(...s),c=ti(e.limit,50),p=ti(e.offset,0),u=i.prepare(`SELECT items.id, items.metadata_json
75
- FROM items
76
- WHERE EXISTS (
77
- SELECT 1 FROM item_linked_files
78
- WHERE item_linked_files.item_id = items.id AND ${a}
79
- )
80
- ORDER BY items.priority ASC, items.updated_at DESC, items.id ASC
81
- LIMIT ? OFFSET ?`).all(...s,c,p),l=[];if(u.length>0){let h=u.map(_=>String(_.id)),y=i.prepare(`SELECT item_id, path, scope, note
82
- FROM item_linked_files
83
- WHERE item_id IN (${h.map(()=>"?").join(", ")})
84
- AND ${a}
85
- ORDER BY path ASC, scope ASC`).all(...h,...s),g=new Map(h.map(_=>[_,[]]));for(let _ of y){let b=String(_.item_id),x=g.get(b);x.push({path:String(_.path),scope:String(_.scope),..._.note===null?{}:{note:String(_.note)}}),g.set(b,x)}for(let _ of u){let b=JSON.parse(String(_.metadata_json));l.push({item:b,files:g.get(String(_.id))})}}return i.close(),{source_cursor:o.source_cursor,total:Number(d.count),matches:l}}catch{return i?.close(),null}}async function kn(e){let t=re();if(!t)return null;let i;try{i=new t(X(e.pmRoot),{readOnly:!0});let o=Ie(i);if(o.version!==oe||o.source_cursor!==e.expectedSourceCursor)return i.close(),null;let r=i.prepare(`SELECT items.metadata_json
86
- FROM item_search
87
- JOIN items ON items.id = item_search.id
88
- WHERE item_search MATCH ?
89
- ORDER BY bm25(item_search), items.priority, items.updated_at DESC, items.id
90
- LIMIT ?`).all(e.query,Math.max(0,Math.floor(e.limit))).map(n=>JSON.parse(String(n.metadata_json)));return i.close(),{source_cursor:o.source_cursor,items:r}}catch{return i?.close(),null}}async function Ce(e){await U.rm(X(e),{force:!0})}import E from"node:fs/promises";import w from"node:path";import{createHash as wo,randomUUID as li}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="846c1c5d-8a5c-56ee-832a-bfc780283e70")}catch{}})();var O=8,ui=500,bo="metadata-derived-index",Eo="metadata-cache.json",vo="metadata-cache-bodies.json",Io="metadata-cache-collections.json",Co="metadata-cache-delta.json",To="metadata-cache-manifest.json",si=4,So=["comments","notes","learnings","files","tests","test_runs","docs"];function mi(){return ge(Q())}function Se(e){let t={...e},i={};for(let o of So)o in t&&(i[o]=t[o],delete t[o]);return{light:t,heavy:i}}function fi(e,t){return!t||Object.keys(t).length===0?e:{...e,...t}}function yi(e,t,i,o){let r=wo("sha256");r.update(`format:${e??"default"}`);let n=Object.entries(t).sort(([s],[a])=>s.localeCompare(a)).map(([s,a])=>`${s}=${a}`).join(",");return r.update(`|types:${n}`),i&&r.update(`|schema:${JSON.stringify(i)}`),o.length>0&&r.update(`|extension_fields:${o.join(",")}`),r.digest("hex").slice(0,16)}function xe(e){return w.join(e,"runtime",Eo)}function Re(e){return w.join(e,"runtime",vo)}function Oe(e){return w.join(e,"runtime",Io)}function tt(e){return w.join(e,"runtime",Co)}function it(e){return w.join(e,"runtime",To)}function De(e,t){let i=w.extname(e);return`${e.slice(0,-i.length)}.${t}${i}`}var xo=24,S=new Map,ke=new WeakMap;function ot(e){return ke.get(e)??e.source_cursor}function Ro(e,t){let i=ot(e);if(!(t.base_source_cursor!==i||e.source_cursor===t.source_cursor)){ke.set(e,i);for(let[o,r]of Object.entries(t.changes))r.entry?e.entries[o]=r.entry:delete e.entries[o];e.directory_signatures=t.directory_signatures,e.source_cursor=t.source_cursor}}function Oo(e,t){if(!e)return;let i=ot(e);if(!(t.base_source_cursor!==i||e.source_cursor===t.source_cursor)){ke.set(e,i);for(let[o,r]of Object.entries(t.changes))r.body?e.bodies[o]=r.body:delete e.bodies[o];e.source_cursor=t.source_cursor}}function Do(e,t){if(!e)return;let i=ot(e);if(!(t.base_source_cursor!==i||e.source_cursor===t.source_cursor)){ke.set(e,i);for(let[o,r]of Object.entries(t.changes))r.collections?e.collections[o]=r.collections:delete e.collections[o];e.source_cursor=t.source_cursor}}function ko(e,t,i,o){!e||!o||e.context_fingerprint!==o.context_fingerprint||(Ro(e,o),Oo(t,o),Do(i,o))}function et(e,t){S.size>=xo&&!S.has(e)&&Rt(S),S.set(e,t)}async function A(e,t){let i;try{i=await E.stat(e)}catch{return S.delete(e),null}let o=S.get(e);if(o&&ne(o.signature,i.mtimeMs,i.ctimeMs,i.size))return S.delete(e),S.set(e,o),o.envelope;let r;try{r=t(await E.readFile(e,"utf8"))}catch{r=null}return et(e,{signature:{mtime_ms:i.mtimeMs,ctime_ms:i.ctimeMs,size:i.size},envelope:r}),r}async function No(e,t,i){let o=a=>{let d=JSON.parse(a);return d.version!==O||typeof d.source_cursor!="string"||typeof d.entries!="object"||d.entries===null?null:d},r=xe(e),n=await A(r,o);if(!t||n===null||n.context_fingerprint===t)return n;let s=await A(De(r,t),o);return s===null&&ce(i,`metadata_cache_context_changed:${n.context_fingerprint}->${t}`),s}async function Ao(e,t){let i=n=>{let s=JSON.parse(n);return s.version!==O||typeof s.source_cursor!="string"||typeof s.bodies!="object"||s.bodies===null?null:s},o=Re(e),r=await A(o,i);return t&&r?.context_fingerprint!==t?await A(De(o,t),i):r}async function Fo(e,t){let i=n=>{let s=JSON.parse(n);return s.version!==O||typeof s.source_cursor!="string"||typeof s.collections!="object"||s.collections===null?null:s},o=Oe(e),r=await A(o,i);return t&&r?.context_fingerprint!==t?await A(De(o,t),i):r}async function rt(e){let t=tt(e),i=await A(t,o=>{let r=JSON.parse(o);return r.version!==O||typeof r.base_source_cursor!="string"||typeof r.source_cursor!="string"||typeof r.changes!="object"||r.changes===null?null:r});if(i)return{envelope:i,invalid:!1};try{return await E.stat(t),{envelope:null,invalid:!0}}catch{return{envelope:null,invalid:!1}}}async function nt(e){let t=it(e),i=await A(t,o=>{let r=JSON.parse(o);return r.version!==O||typeof r.context_fingerprint!="string"||typeof r.source_cursor!="string"||!Number.isInteger(r.entry_count)||r.entry_count<0||typeof r.directory_signatures!="object"||r.directory_signatures===null?null:r});if(i)return i;try{await E.stat(t),await G(e)}catch{}return null}async function se(e,t){await E.mkdir(w.dirname(e),{recursive:!0}),await N(e,JSON.stringify(t));try{let o=await E.stat(e);et(e,{signature:{mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size},envelope:t})}catch{S.delete(e)}let i=w.dirname(w.dirname(e));if(e===xe(i)||e===Re(i)||e===Oe(i)){let o=De(e,t.context_fingerprint);await N(o,JSON.stringify(t));try{let d=await E.stat(o);et(o,{signature:{mtime_ms:d.mtimeMs,ctime_ms:d.ctimeMs,size:d.size},envelope:t})}catch{S.delete(o)}let r=w.dirname(e),n=w.extname(e),s=w.basename(e,n),a=(await E.readdir(r,{withFileTypes:!0}).catch(()=>[])).filter(d=>d.isFile()&&d.name!==w.basename(e)&&d.name.startsWith(`${s}.`)&&d.name.endsWith(n)).map(d=>w.join(r,d.name));if(a.length>si){let d=(await Promise.all(a.map(async c=>{try{return{path:c,mtime:(await E.stat(c)).mtimeMs}}catch{return null}}))).filter(c=>c!==null);for(let c of d.sort((p,u)=>p.mtime-u.mtime).slice(0,Math.max(0,d.length-si)))await E.rm(c.path,{force:!0}),S.delete(c.path)}}}function Mo(e,t,i){return i?t===i&&e!==i:t==="toon"&&e!=="toon"}function pi(e,t,i){return e===void 0||Mo(e,t,i)}function ce(e,t){e&&!e.includes(t)&&e.push(t)}function ne(e,t,i,o){return e.mtime_ms===t&&e.ctime_ms===i&&e.size===o}async function Po(e,t,i){let o=w.join(e,t);try{let r=await E.readdir(o);return{folder:t,dirPath:o,files:r}}catch(r){return typeof r=="object"&&r!==null&&"code"in r&&!j(r)&&ce(i,`item_list_directory_read_failed:${t}`),{folder:t,dirPath:o,files:[]}}}async function jo(e,t){try{let i=await E.stat(w.join(e,t));return[t,{exists:!0,mtime_ms:i.mtimeMs,ctime_ms:i.ctimeMs,size:i.size}]}catch{return[t,{exists:!1,mtime_ms:0,ctime_ms:0,size:0}]}}async function Te(e,t){return Object.fromEntries(await Promise.all(t.map(async i=>await jo(e,i))))}function ae(e,t){return!e||Object.keys(e).length!==Object.keys(t).length?!1:Object.entries(t).every(([i,o])=>{let r=e[i];return r!==void 0&&r.exists===o.exists&&ne(r,o.mtime_ms,o.ctime_ms,o.size)})}function Lo(e){return me.some(t=>e.toLowerCase().endsWith(t))}function $o(e,t,i,o,r,n){o||(e.metadata=!0),t&&!r&&(e.body=!0),i&&!n&&(e.collections=!0)}async function Uo(e,t,i){if(i)for(let o of await pe({path:e,scope:"project"}))ce(t,o)}function ai(e,t,i,o){if(e)return t&&i?i.collections:o}async function Ho(e,t,i){let o=await E.stat(e),r=o.mtimeMs,n=o.ctimeMs,{size:s}=o,a=Pe(e);await Uo(e,i.warnings,i.dispatchReadHooks);let d=i.previousEntries[t],c=!i.forceSourceRead&&d!==void 0&&ne(d,r,n,s),p=i.previousBodies[t],u=!i.forceSourceRead&&p!==void 0&&ne(p,r,n,s),l=i.previousCollections[t],h=!i.forceSourceRead&&l!==void 0&&ne(l,r,n,s);if(!(!c||i.includeBody&&!u||i.includeCollections&&!h))return{mtimeMs:r,ctimeMs:n,size:s,itemFormat:a,lightMetadata:d.metadata,heavyMetadata:ai(i.includeCollections,h,l,void 0),bodyLength:d.body_length,body:i.includeBody?p.body:void 0};let y=await E.readFile(e,"utf8"),g=q(y,{format:a,schema:i.schema,extensionFieldNames:i.extensionFieldNames,onWarning:b=>ce(i.warnings,b)}),_=Se(g.metadata);return $o(i.state.misses,i.includeBody,i.includeCollections,c,u,h),{mtimeMs:r,ctimeMs:n,size:s,itemFormat:a,lightMetadata:c?d.metadata:_.light,heavyMetadata:ai(i.includeCollections,h,l,_.heavy),bodyLength:c?d.body_length:g.body.length,body:i.includeBody?g.body:void 0}}function Wo(e,t,i,o){i.state.newEntries[t]={mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size,metadata:o.lightMetadata,body_length:o.bodyLength},i.includeBody&&o.body!==void 0&&(i.state.newBodies[t]={mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size,body:o.body}),i.includeCollections&&o.heavyMetadata!==void 0&&(i.state.newCollections[t]={mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size,collections:o.heavyMetadata});let r=i.includeCollections?fi(o.lightMetadata,o.heavyMetadata):o.lightMetadata,n=i.state.documentsById.get(r.id),s={metadata:r,body:o.body,item_format:o.itemFormat,item_path:e};pi(n?.itemFormat,o.itemFormat,i.preferredFormat)&&i.state.documentsById.set(r.id,{candidate:s,itemFormat:o.itemFormat})}async function Bo(e,t,i,o){try{let r=await Ho(t,i,o);Wo(t,i,o,r)}catch{ce(o.warnings,`item_list_item_read_failed:${e}/${w.basename(t)}`)}}function zo(e,t){return e&&e.context_fingerprint===t?e.entries:{}}function Xo(e,t){return e&&e.context_fingerprint===t?e.bodies:{}}function Go(e,t){return e&&e.context_fingerprint===t?e.collections:{}}function Yo(){return{newEntries:{},newBodies:{},newCollections:{},documentsById:new Map,misses:{metadata:!1,body:!1,collections:!1}}}async function Vo(e,t){let i=[];for(let{folder:o,dirPath:r,files:n}of e)for(let s of n){if(!Lo(s))continue;let a=w.join(r,s),d=w.relative(t.pmRoot,a);i.push(Bo(o,a,d,t)),i.length===32&&(await Promise.all(i),i.length=0)}await Promise.all(i)}async function qo(e){if(!(!(e.state.misses.metadata||Object.keys(e.previousEntries).length!==Object.keys(e.state.newEntries).length||!ae(e.existingCache?.directory_signatures,e.directorySignatures))&&e.existingCache!==null&&e.existingCache.context_fingerprint===e.contextFingerprint))try{await se(xe(e.pmRoot),{version:O,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,directory_signatures:e.directorySignatures,entries:e.state.newEntries}),await se(it(e.pmRoot),{version:O,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,entry_count:Object.keys(e.state.newEntries).length,directory_signatures:e.directorySignatures});let t=[...e.state.documentsById.values()].map(({candidate:i})=>({relativePath:w.relative(e.pmRoot,i.item_path),metadata:Se(i.metadata).light,linkedFiles:i.metadata.files??[]}));t.length>=e.minimumIndexedItems?await ri({pmRoot:e.pmRoot,contextFingerprint:e.contextFingerprint,sourceCursor:e.sourceCursor,rows:t}):await Ce(e.pmRoot)}catch{}}async function Ko(e){!(e.state.misses.body||Object.keys(e.previousBodies).length!==Object.keys(e.state.newBodies).length)&&e.existingBodyCache!==null&&e.existingBodyCache.context_fingerprint===e.contextFingerprint||await se(Re(e.pmRoot),{version:O,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,bodies:e.state.newBodies}).catch(()=>{})}async function Jo(e){!(e.state.misses.collections||Object.keys(e.previousCollections).length!==Object.keys(e.state.newCollections).length)&&e.existingCollectionsCache!==null&&e.existingCollectionsCache.context_fingerprint===e.contextFingerprint||await se(Oe(e.pmRoot),{version:O,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,collections:e.state.newCollections}).catch(()=>{})}async function st(e,t,i={}){let o=await nt(e);return i.required!==!0&&(o===null||o.entry_count<ui)?async()=>{}:Mt(e,bo,30,t,!1,!1,3e3)}async function zn(e,t){let i=await nt(e);if(i===null)return null;let o=await rt(e);if(o.invalid)return await G(e),null;let r=o.envelope?.context_fingerprint===i.context_fingerprint&&o.envelope.base_source_cursor===i.source_cursor?o.envelope.source_cursor:i.source_cursor,n=o.envelope?.context_fingerprint===i.context_fingerprint&&o.envelope.base_source_cursor===i.source_cursor?o.envelope.directory_signatures:i.directory_signatures;return t&&!ae(n,await Te(e,t))?null:{source_cursor:r,entry_count:i.entry_count}}function ci(e,t){let i=w.relative(e,t);return i===""||i===".."||i.startsWith(`..${w.sep}`)||w.isAbsolute(i)?null:i}async function G(e){await Promise.all([xe(e),Re(e),Oe(e),tt(e),it(e)].map(async t=>{await E.rm(t,{force:!0}),S.delete(t)})),await Ce(e)}async function Qo(e){if(e.mutation.document===null)return{entry:null,body:null,collections:null};let t=await E.stat(e.mutation.itemPath),i=Se(e.mutation.document.metadata),o={mtime_ms:t.mtimeMs,ctime_ms:t.ctimeMs,size:t.size};return{entry:{...o,metadata:i.light,body_length:e.mutation.document.body.length},body:{...o,body:e.mutation.document.body},collections:{...o,collections:i.heavy}}}function Zo(e,t,i){return e?.context_fingerprint===t&&e.base_source_cursor===i?structuredClone(e.changes):{}}async function at(e){let t=ci(e.pmRoot,e.itemPath),i=e.previousItemPath?ci(e.pmRoot,e.previousItemPath):void 0;if(t===null||i===null)return await G(e.pmRoot),["metadata_derived_index_path_invalidated"];try{let o=yi(e.preferredFormat,e.typeToFolder,e.schema,mi()),r=await nt(e.pmRoot);if(r===null||r.context_fingerprint!==o)return[];let n=r.source_cursor,s=await rt(e.pmRoot);if(s.invalid)return await G(e.pmRoot),["metadata_derived_index_refresh_failed"];let a=Zo(s.envelope,o,n),d=s.envelope?.context_fingerprint===o&&s.envelope.base_source_cursor===n?s.envelope.source_cursor:n;i!==void 0&&(a[i]={entry:null,body:null,collections:null}),a[t]=await Qo({mutation:e});let c=li();return await se(tt(e.pmRoot),{version:O,context_fingerprint:o,base_source_cursor:n,source_cursor:c,directory_signatures:await Te(e.pmRoot,[...new Set(Object.values(e.typeToFolder))]),changes:a}),await ni({pmRoot:e.pmRoot,contextFingerprint:o,expectedSourceCursor:d,sourceCursor:c,row:e.document===null?null:{relativePath:t,metadata:Se(e.document.metadata).light,linkedFiles:e.document.metadata.files},deletedRelativePaths:[...i===void 0?[]:[i],...e.document===null?[t]:[]]})||await Ce(e.pmRoot),[]}catch{return await G(e.pmRoot).catch(()=>{}),["metadata_derived_index_refresh_failed"]}}function er(e){return[...e.documentsById.values()].sort((t,i)=>t.candidate.metadata.id.localeCompare(i.candidate.metadata.id)).map(t=>t.candidate)}function di(e,t,i){return e?.context_fingerprint===t&&e.source_cursor===i}function tr(e,t,i,o,r){return e.every(n=>(!t||o[n]!==void 0)&&(!i||r[n]!==void 0))}function ir(e){let t=new Map;for(let[i,o]of Object.entries(e.previousEntries)){let r=Pe(i);if(!r)continue;let n=e.includeCollections?fi(o.metadata,e.previousCollections[i]?.collections):o.metadata,s=t.get(n.id);pi(s?.itemFormat,r,e.preferredFormat)&&t.set(n.id,{itemFormat:r,candidate:{metadata:n,body:e.includeBody?e.previousBodies[i]?.body:void 0,item_format:r,item_path:w.join(e.pmRoot,i)}})}return[...t.values()].sort((i,o)=>i.candidate.metadata.id.localeCompare(o.candidate.metadata.id)).map(i=>i.candidate)}function or(e){return e.forceSourceScan||Ye()||e.existingCache?.context_fingerprint!==e.contextFingerprint||e.entryKeys.length<e.minimumIndexedItems||!ae(e.existingCache?.directory_signatures,e.directorySignatures)?!1:[!e.includeBody||di(e.existingBodyCache,e.contextFingerprint,e.existingCache.source_cursor),!e.includeCollections||di(e.existingCollectionsCache,e.contextFingerprint,e.existingCache.source_cursor)].every(Boolean)&&tr(e.entryKeys,e.includeBody,e.includeCollections,e.previousBodies,e.previousCollections)}async function Ne(e,t,i,o,r,n={}){let s=n.includeBody!==!1,a=n.includeCollections!==!1,d=mi(),c=yi(t,i,r,d),p=await rt(e);p.invalid&&await G(e);let u=await No(e,c,n.cacheDiagnostics),l=s?await Ao(e,c):null,h=a?await Fo(e,c):null;ko(u,l,h,p.envelope);let y=zo(u,c),g=Xo(l,c),_=Go(h,c),b=[...new Set(Object.values(i))],x=await Te(e,b),M=Object.keys(y),D=Math.max(1,Math.floor(n.derivedIndexMinimumItems??ui));if(or({forceSourceScan:n.forceSourceScan===!0,contextFingerprint:c,existingCache:u,existingBodyCache:l,existingCollectionsCache:h,directorySignatures:x,entryKeys:M,minimumIndexedItems:D,includeBody:s,includeCollections:a,previousBodies:g,previousCollections:_}))return ir({pmRoot:e,preferredFormat:t,includeBody:s,includeCollections:a,previousEntries:y,previousBodies:g,previousCollections:_});let H=await Promise.all(b.map(le=>Po(e,le,o))),C=Ye(),I=Yo(),W={pmRoot:e,preferredFormat:t,warnings:o,schema:r,extensionFieldNames:d,includeBody:s,includeCollections:a,forceSourceRead:n.forceSourceScan===!0,dispatchReadHooks:C,previousEntries:y,previousBodies:g,previousCollections:_,state:I};await Vo(H,W);let B=await Te(e,b),k=ae(x,B)?B:{},T=I.misses.metadata||Object.keys(y).length!==Object.keys(I.newEntries).length||!ae(u?.directory_signatures,k)||u===null?li():u.source_cursor;return await qo({pmRoot:e,contextFingerprint:c,sourceCursor:T,existingCache:u,previousEntries:y,directorySignatures:k,state:I,minimumIndexedItems:D}),s&&await Ko({pmRoot:e,contextFingerprint:c,sourceCursor:T,existingBodyCache:l,previousBodies:g,state:I}),a&&await Jo({pmRoot:e,contextFingerprint:c,sourceCursor:T,existingCollectionsCache:h,previousCollections:_,state:I}),er(I)}async function hi(e,t,i,o,r){return(await Ne(e,t,i,o,r,{includeBody:!1})).map(n=>({metadata:n.metadata,body:n.body??""}))}async function _i(e,t,i,o,r){return(await Ne(e,t,i,o,r,{includeBody:!1,includeCollections:!1})).map(n=>({metadata:n.metadata,body:n.body??""}))}import F from"node:fs/promises";import{statSync as ar}from"node:fs";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="cd7d3a47-d37a-55f4-aa60-4fc3ea08d528")}catch{}})();function rr(e,t){let i=-1;return e.forEach((o,r)=>{let n=Date.parse(o.ts);if(!Number.isFinite(n))throw new m(`History for this item contains invalid timestamp at entry ${r+1}.`,f.GENERIC_FAILURE);n<=t&&(i=r)}),i}function nr(e,t){let i=e[0]?.ts??null,o=e.at(-1)?.ts??null,r={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:i,last_timestamp:o}};return o!==null&&(r.examples=[o],t!==null&&(r.examples.unshift(String(t+1),String(t+e.length)),r.valid_range.first_version=t+1,r.valid_range.last_version=t+e.length)),{guidance:r,lastTimestamp:o}}function sr(e,t){let i={};if(t instanceof Error&&t.message.trim().length>0&&(i.reason=t.message.trim()),typeof t!="object"||t===null)return i;let o=t;if(typeof o.index=="number"&&Number.isInteger(o.index)&&o.index>=0&&(i.patchIndex=o.index),typeof o.operation=="object"&&o.operation!==null){let r=o.operation;Object.assign(i,Object.fromEntries(["op","path","from"].flatMap(n=>{let s=r[n];return typeof s=="string"?[[n,s]]:[]})))}if(i.patchIndex!==void 0){let r=e[i.patchIndex];r&&(i.op??=r.op,i.path??=r.path,i.from??=r.from)}return i}function wi(e,t,i={}){let o=e.trim(),r=i.errorSubject??"history",n=r==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=nr(t,te(t,!0));if(!o)throw new m(`Missing ${r} target. Use a timestamp or version number.`,f.USAGE,s);if(/^\d+$/.test(o)){let p=te(t),u=Number(o);if(u>=1&&u<=p)throw new m(`History version ${u} was pruned by compaction.`,f.USAGE,{...s,code:"history_version_pruned"});if(!Number.isSafeInteger(u)||u<1||u>p+t.length)throw new m(`${n} version must be between ${p+1} and ${p+t.length} for this item.`,f.USAGE,s);return{kind:"version",raw:o,historyIndex:u-p-1}}let d=Date.parse(o);if(!Number.isFinite(d))throw new m(`Invalid ${r} target "${e}". Use a positive version number or ISO timestamp.`,f.USAGE,s);let c=rr(t,d);if(c<0||i.allowFutureTimestamp!==!0&&d>Date.parse(a))throw new m(r==="restore"?`No history entries exist at or before timestamp ${o}.`:`No history entry exists at timestamp ${o}.`,f.USAGE,s);return{kind:"timestamp",raw:o,historyIndex:c}}function ct(e,t,i,o){let r=$e(e,t);if(r.ok)return r.document;let n=sr(t,r.error),s=[`history_op=${o}`,n.patchIndex===void 0?null:`patch_index=${n.patchIndex}`,n.op?`op=${n.op}`:null,n.path?`path=${n.path}`:null,n.from?`from=${n.from}`:null].filter(a=>a!==null);throw new m(`Failed to apply history patch at entry ${i} (${s.join(", ")}). ${n.reason??String(r.error)}`,f.GENERIC_FAILURE)}function gi(e,t){return new m(`History entry ${e+1} lies between an unrecorded change and the record that repaired it, so its historical state cannot be reconstructed.`,f.USAGE,{code:"history_version_unreconstructable",required:t?"Choose a version before the bridged break or from its bridge onward.":"Choose a version whose record is not marked replay_inexact.",nextSteps:[t?"Run pm history <id> --full to find the bridge record and the versions around it.":"Run pm history <id> --full and pick a version whose record has no replay_inexact marker."]})}function bi(e,t){let i=e[0];if(i&&i.op!=="create"&&i.op!=="history_compact_baseline"){let s=$e(J,i.patch);if(!s.ok||typeof s.document.metadata.id!="string")throw new m("History starts without a reconstructable item baseline.",f.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the missing baseline."]})}if(e[t]?.replay_inexact===!0)throw gi(t,!1);let o=e.slice(0,t+1),r=fe([...o]),n=structuredClone(J);for(let s=0;s<=t;s+=1){let a=e[s];if(!a)throw new m(`History target entry ${s+1} does not exist.`,f.USAGE);n=ct(n,a.patch,s+1,a.op)}if(!r.ok){let s=$t([...e]);throw s.ok&&s.bridged_segments?.some(a=>a.start<=t&&t<a.end)?gi(t,!0):new m(`History cannot be replayed: ${r.errors.join(", ")}.`,f.GENERIC_FAILURE,{code:"history_replay_invalid",verification_errors:r.errors,required:"Inspect the history integrity findings before attempting recovery.",nextSteps:["Run pm history <id> --verify --full."]})}return n}function Kn(e,t){if(Object.keys(e.metadata).length>0){if(typeof e.metadata.id!="string"||!Array.isArray(e.metadata.tags))throw new m("History has no complete item baseline for this target.",f.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the first recorded state."]});return e}throw new m(`History target ${t.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,f.USAGE)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="be69f1e8-4543-5cf5-abb0-9d38ca1d0cc6")}catch{}})();function cr(e,t){let i=-1,o=structuredClone(J);for(let[a,d]of e.entries()){if(o=ct(o,d.patch,a+1,d.op),o.metadata.id!==void 0&&o.metadata.id!==t)throw new m(`History belongs to item ${String(o.metadata.id)}, expected ${t}.`,f.GENERIC_FAILURE,{code:"history_replay_invalid",required:"Recover the correct history stream for this item before attempting restoration."});o.metadata.id===t&&Array.isArray(o.metadata.tags)&&(i=a)}let r=te(e,!0),n=i<0||r===null?null:r+i+1,s=n===null?void 0:String(n);if(i>=0&&s===void 0){let a=e[i].ts;wi(a,e).historyIndex===i&&(s=a)}return{version:n,target:s}}async function Ei(e,t,i){let o=new Set([ee(t,i),Z(t)]);for(let r of o){let n=R(e,r);if(!ar(n,{throwIfNoEntry:!1})?.isFile())continue;let s=await Lt(n,r),a=-1;if(s.forEach((h,y)=>{h.op==="delete"&&(a=y)}),a<0)continue;let d=bi(s,s.length-1);if(Object.keys(d.metadata).length!==0)continue;let{version:c,target:p}=cr(s,r),u=p===void 0?["history",r,"--verify"]:["get",r,"--at",p],l=V(u);return new m(`Item ${r} was deleted at ${s[a].ts}; its history is retained.`,f.NOT_FOUND,{code:"item_deleted",required:"Read a retained materialized version, then restore it if the item should exist again.",item_id:r,tombstone:{deleted:!0,deleted_at:s[a].ts,recoverable:p!==void 0,last_materialized_version:c},nextSteps:[l,...p===void 0?["Recover the pre-compaction history from version control."]:[V(["restore",r,p])]],recovery:{suggested_retry:l,suggested_retry_args:u}})}}import{AsyncLocalStorage as dr}from"node:async_hooks";import vi from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c343ed33-0135-5d3a-94a4-67314b295168")}catch{}})();var Ii=new dr;function us(e,t){return Ii.run({...e,pmRoot:vi.resolve(e.pmRoot)},t)}function Ci(e,t){let i=Ii.getStore();return i?.pmRoot===vi.resolve(e)&&i.itemId===t?{bulk_checkpoint:i.checkpointId}:void 0}import lt from"node:path";import lr from"node:fs/promises";import ur from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2e67dcb3-0d34-5884-8b79-5e98458f8c57")}catch{}})();var Ti=64;function mr(e){return[...new Set(e.filter(t=>t.trim().length>0))].sort((t,i)=>t.localeCompare(i))}function fr(e,t){return new m(`Missing history stream for ${e}. ${t} requires history streams when settings.history.missing_stream is strict_error.`,f.NOT_FOUND)}async function yr(e,t){return await bt(ur.dirname(e)),await(await lr.open(e,"a")).close(),L({path:e,scope:"project",op:`${t}:history:auto_create`})}async function pr(e,t,i){let o=[];for(let r=0;r<t.length;r+=Ti){let n=t.slice(r,r+Ti),s=await Promise.all(n.map(a=>{let d;try{d=R(e,a)}catch{return!1}return z(d)}));if(n.forEach((a,d)=>{s[d]||o.push(a)}),i&&o.length>0)break}return o}async function dt(e){return hr({pmRoot:e.pmRoot,settings:e.settings,itemIds:[e.itemId],commandLabel:e.commandLabel})}async function hr(e){let t=mr(e.itemIds),i=[],o=[],r=Bt(),n=e.settings.history.missing_stream==="strict_error",s=r?t:await pr(e.pmRoot,t,n);for(let a of s.length===0?[]:t){let d=R(e.pmRoot,a);if(!await z(d)){if(n)throw fr(a,e.commandLabel);o.push(...await yr(d,e.commandLabel)),o.push(`history_stream_auto_created:${a}`),i.push(a)}}return{auto_created_ids:i,warnings:o}}import{isUtf8 as _r}from"node:buffer";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2fda779c-a87f-517c-b71a-626c4fef98e5")}catch{}})();async function gr(e){try{return await F.access(e),!0}catch{return!1}}function wr(e,t){e&&(e.includes(t)||e.push(t))}function ut(e){return e??ge(Q())}function br(e){return e==="toon"?["toon","json_markdown"]:e==="json_markdown"?["json_markdown","toon"]:["toon","json_markdown"]}async function mt(e,t,i="pm-",o,r=P){let n=t.trim(),s=n.startsWith("#")?n.slice(1):n;if(s.length===0)return null;let a=ee(t,i),d=Z(t),c=[...new Set([s,a,d])].filter(l=>l.length>0),p=Object.entries(r),u=br(o);for(let l of c){let h=new Map;for(let[y]of p)for(let g of u){let _=Me(e,y,l,g,r);await gr(_)&&h.set(_,h.get(_)??{id:l,type:y,itemPath:_,item_format:g})}if(h.size>1){let y=[...h.keys()].map(g=>lt.relative(e,g).split(lt.sep).join("/")).sort();throw new m(`Item ${l} has ambiguous identity across ${y.join(", ")}. Preserve both documents and inspect pm ops validate --check-storage-integrity before resolving the collision.`,f.CONFLICT,{code:"item_identity_ambiguous",item_id:l,paths:y})}for(let y of h.values())return y}return null}async function xi(e,t={}){let i=await Er(e,t);if(i.error!==null)throw i.error;return{raw:i.raw,document:i.document}}async function Er(e,t={}){let i=await F.readFile(e.itemPath);if(!_r(i))throw new m("Item contains invalid UTF-8; preserve a binary backup before recovering it.",f.CONFLICT,{code:"item_document_encoding_invalid",item_id:e.id,item_path:e.itemPath,byte_length:i.length,empty:!1});let o=i.toString("utf8");await pe({path:e.itemPath,scope:"project"});let r;try{r=q(o,{format:e.item_format,requireSupportedFormat:!0,schema:t.schema,extensionFieldNames:ut(t.extensionFieldNames),onWarning:n=>wr(t.warnings,n)})}catch(n){if(n instanceof m&&n.code==="item_format_version_unsupported")throw new m(`Item ${e.id}: ${n.message}`,n.exitCode,{...n.context,item_id:e.id,item_path:e.itemPath});if(n instanceof m&&n.code==="item_document_invalid")return{raw:o,document:null,error:new m(`Cannot read ${e.id} at ${e.itemPath}${i.length===0?" (zero-length file)":""}: ${n.message}`,n.exitCode,{...n.context,item_id:e.id,item_path:e.itemPath,byte_length:i.length,empty:i.length===0,nextSteps:[`Run pm history ${e.id} --full, then pm restore ${e.id} <version> to recover a recorded state.`]})};throw n}return{raw:o,document:r,error:null}}async function vr(e,t,i=P,o,r){await he(e);let n=await hi(e,t,i,o,r);return be(n.length),n.map(s=>s.metadata)}async function Qs(e,t,i=P,o,r){await he(e);let n=await _i(e,t,i,o,r);return be(n.length),n.map(s=>s.metadata)}async function Zs(e,t,i=P,o,r,n={}){await he(e);let s=await Ne(e,t,i,o,r,{includeBody:!0,forceSourceScan:n.forceSourceScan});return be(s.length),s.map(a=>({...a.metadata,body:a.body}))}function Ri(e){return{async get(t){let i=await mt(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!i)return null;let{document:o}=await xi(i,{schema:e.settings.schema});return{item:o.metadata,body:o.body}},list:()=>vr(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema)}}async function Ir(e,t){let i=new Set(Object.values(t)),o=[];return await Promise.all([...i].map(async r=>{try{let n=await F.readdir(lt.join(e,r));for(let s of n)for(let a of me)if(s.toLowerCase().endsWith(a)){o.push(s.slice(0,-a.length));break}}catch{}})),o}async function Cr(e,t,i,o){let r=ee(t,i),n=await Ir(e,o);if(n.length===0)return[];let s=Math.max(3,Math.floor(r.length/2));return n.map(a=>({id:a,distance:ue(a,r,s)})).filter(a=>a.distance!==null).sort((a,d)=>a.distance-d.distance).slice(0,3).map(a=>a.id)}async function Tr(e,t,i,o){let r=await Ei(e,t,i);if(r)return r;let n=await Cr(e,t,i,o),s=["Confirm the active --path/PM_PATH scope, then retry with a valid id."];return n.length>0&&s.unshift(`Did you mean one of: ${n.join(", ")}?`),new m(`Item ${t} not found`,f.NOT_FOUND,{code:"item_not_found",id:t,nextSteps:s})}function Sr(e,t){return e==="claim"||t===!0&&(e==="comment_add"||e==="comment_edit"||e==="comment_delete"||e==="note_add"||e==="learning_add"||e==="release"||e==="update"||e==="update_ownership_bypass"||e==="update_audit")}async function Oi(e){let t=e.typeToFolder??It(e.settings,Q()).type_to_folder,i=await mt(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,t);if(!i)throw await Tr(e.pmRoot,e.id,e.settings.id_prefix,t);let o=await Pt(e.pmRoot,i.id,e.settings.locks.ttl_seconds,e.author,!!e.force,e.settings.governance.force_required_for_stale_lock,e.settings.locks.wait_ms,{waitPolicy:"progress"}),r=o.release;try{let n=[],{raw:s,document:a}=await xi(i,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames,warnings:n}),d=a.metadata.assignee?.trim(),c=kt(d),p=a.metadata.claim_principal?.trim()||d,u=jt(e.author),l=Xt(e.settings);if(c&&p!==u&&!e.force&&!Sr(e.op,e.bypassAssigneeConflict)){if(l.ownership_enforcement==="strict")throw new m(`Item ${i.id} is assigned to ${c}. Use --force to override.`,f.CONFLICT);l.ownership_enforcement==="warn"&&n.push(`ownership_warning:assignee_conflict:${i.id}:${c}`)}return{typeToFolder:t,located:i,originalRaw:s,document:a,warnings:n,releaseLock:r,lease:o}}catch(n){throw await r(),n}}function Di(e){return Object.keys(e).length===0?void 0:e}async function ki(e,t,i,o){return e.fence(async()=>{let r;try{r=await F.readFile(t.itemPath,"utf8")}catch(n){if(!j(n))throw n;r=null}if(r!==i)throw new m(`Item ${t.id} changed after this mutation read it; refusing to overwrite the newer revision. Nothing was written.`,f.CONFLICT,{code:"stale_revision",item_id:t.id,reason:r===null?"item_removed":"item_revision_changed",required:"Re-read the item and apply the mutation again; the newer stored revision was kept."});return o()})}function xr(e,t,i){if(!e.handled||typeof e.result!="object"||e.result===null)return{effectiveTargetItemPath:t,effectiveSerializedAfter:i,skipItemWrite:!1};let o=e.result;return{effectiveTargetItemPath:typeof o.target_item_path=="string"&&o.target_item_path.trim().length>0?o.target_item_path:t,effectiveSerializedAfter:typeof o.contents=="string"?o.contents:i,skipItemWrite:o.skip_write===!0}}async function Ni(e){try{let t=await mt(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!t)return{document:Fe};let i=q(await F.readFile(t.itemPath,"utf8"),{format:t.item_format,requireSupportedFormat:!0,schema:e.settings.schema,extensionFieldNames:ut(e.extensionFieldNames)});return i.metadata.id===e.embeddedId?{document:i}:{document:e.fallback,revision:Si}}catch{return{document:e.fallback,revision:Si}}}var Si="unreadable-after-storage-override";async function Rr(e){let t=await Ve("item_store_delete",e),i=t.handled&&typeof t.result=="object"&&t.result!==null?t.result:{};return{effectiveItemPath:typeof i.item_path=="string"&&i.item_path.trim().length>0?i.item_path:e.item_path,skipDelete:i.skip_delete===!0,warnings:t.warnings}}async function Or(e){if(!e.skipItemWrite){if(e.effectiveTargetItemPath!==e.originalItemPath){await N(e.originalItemPath,e.originalRaw),await F.rm(e.effectiveTargetItemPath,{force:!0});return}await N(e.originalItemPath,e.originalRaw)}}function Dr(e,t){At(e.metadata)&&t.push("deferred_fields")}async function ft(e){Ot(e.op);let t=await Oi({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:e.op,author:e.author,force:e.force,bypassAssigneeConflict:e.bypassAssigneeConflict,extensionFieldNames:e.extensionFieldNames,typeToFolder:e.typeToFolder}),{typeToFolder:i,located:o,originalRaw:r,document:n,warnings:s,releaseLock:a,lease:d}=t;try{We(e.pmRoot,n,o.id);let c=K(n,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),p=K(structuredClone(n),{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),u=await e.mutate(p,{storageId:o.id});if(Dr(p,u.changedFields),e.skipNoop===!0&&u.changedFields.length===0)return{item:c.metadata,body:c.body,changedFields:[],warnings:[...s,...u.warnings??[]]};let l={...e.resolveHistoryContext?.(),...Ci(e.pmRoot,o.id),...Wt(e.pmRoot,[o.id,n.metadata.id])},h=Math.max(Le(c.metadata),Le(p.metadata));Gt(Ct(e.pmRoot),h),h>Nt(p.metadata)&&(p.metadata.pm_format_version=h,u.changedFields.push("pm_format_version")),p.metadata.updated_at=je();let y=K(p,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),g=await Ke({pmRoot:e.pmRoot,settings:e.settings,operation:e.op,author:e.author,before:c,after:y});await Ge({pm_root:e.pmRoot,operation:e.op,before:c,after:y,changed_fields:u.changedFields,author:e.author,sdk:Ri({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:i})});let _=await dt({pmRoot:e.pmRoot,settings:e.settings,itemId:o.id,commandLabel:e.op}),b="toon",x=Ft(y,{format:b,schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),M=Me(e.pmRoot,y.metadata.type,o.id,b,i),D=R(e.pmRoot,o.id),H=await ki(d,o,r,async()=>{let k=await Ve("item_store_write",{op:e.op,pm_root:e.pmRoot,item_id:o.id,source_item_path:o.itemPath,target_item_path:M,history_path:D,item_format:b,before:c,after:y,contents:x}),{effectiveTargetItemPath:T,effectiveSerializedAfter:le,skipItemWrite:Y}=xr(k,M,x),Hi=await st(e.pmRoot,e.author),_t=[];try{Y||await N(T,le),!Y&&T!==o.itemPath&&await F.rm(o.itemPath);let Bi=Ue({nowIso:y.metadata.updated_at,author:e.author,op:e.op,before:c,after:y,message:e.message,context:Di({...l,...g.decisions.length===0?{}:{workflow_policies:g.decisions},...ze(e.pmRoot,[o.id,n.metadata.id],e.op)})});try{await He(D,Bi)}catch(zi){throw await Or({skipItemWrite:Y,effectiveTargetItemPath:T,originalItemPath:o.itemPath,originalRaw:r}),zi}Y||(_t=await at({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:i,schema:e.settings.schema,itemPath:T,previousItemPath:o.itemPath,document:y}))}finally{await Hi()}let Wi=Y||T!==M||le!==x;return{derivedIndexWarnings:_t,effectiveTargetItemPath:T,overrideWarnings:k.warnings,stored:Wi?await Ni({pmRoot:e.pmRoot,settings:e.settings,id:o.id,typeToFolder:i,extensionFieldNames:e.extensionFieldNames,fallback:y,embeddedId:y.metadata.id}):{document:y}}}),{derivedIndexWarnings:C,effectiveTargetItemPath:I,stored:W}=H;Be(e.pmRoot,W.document,o.id,[y.metadata.id],W.revision);let B=[...await L({path:I,scope:"project",op:e.op,item_id:y.metadata.id,item_type:y.metadata.type,before:c,after:y,changed_fields:u.changedFields}),...await L({path:D,scope:"project",op:`${e.op}:history`,item_id:y.metadata.id,item_type:y.metadata.type,before:c,after:y,changed_fields:u.changedFields})];return Xe({id:y.metadata.id,op:e.op,item_type:y.metadata.type,previous_status:c.metadata.status,status:y.metadata.status,previous:ye(c.metadata,u.changedFields),current:ye(y.metadata,u.changedFields),changed_fields:u.changedFields}),{item:y.metadata,body:y.body,changedFields:u.changedFields,warnings:[...s,...u.warnings??[],...g.warnings,..._.warnings,...H.overrideWarnings,...C,...B]}}finally{await a()}}async function ea(e){let{historyContext:t,...i}=e;return ft({...i,resolveHistoryContext:()=>t})}async function ta(e){return ft(e)}async function ia(e){return ft(e)}async function oa(e){let t=await Oi({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:"delete",author:e.author,force:e.force}),{located:i,originalRaw:o,document:r,warnings:n,releaseLock:s,lease:a}=t;try{We(e.pmRoot,r,i.id);let d=ut(void 0),c=K(r,{schema:e.settings.schema,extensionFieldNames:d}),p=await Ke({pmRoot:e.pmRoot,settings:e.settings,operation:"delete",author:e.author,before:c,after:null,dryRun:e.dryRun});await Ge({pm_root:e.pmRoot,operation:"delete",before:c,after:null,changed_fields:["deleted"],author:e.author,dry_run:e.dryRun===!0,sdk:Ri({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:t.typeToFolder})});let u=await dt({pmRoot:e.pmRoot,settings:e.settings,itemId:i.id,commandLabel:"delete"}),l=je(),h=Fe,y=Ue({nowIso:l,author:e.author,op:"delete",before:c,after:h,message:e.message,context:Di({...p.decisions.length===0?{}:{workflow_policies:p.decisions},...ze(e.pmRoot,[i.id,r.metadata.id],"delete")})}),g=R(e.pmRoot,i.id),_=()=>Rr({op:"delete",pm_root:e.pmRoot,item_id:i.id,item_path:i.itemPath,history_path:g,before:c});if(e.dryRun===!0){let C=await _();return{item:c.metadata,changedFields:["deleted"],targetPath:C.effectiveItemPath,warnings:[...n,...p.warnings,...u.warnings,...C.warnings]}}let b=await ki(a,i,o,async()=>{let{effectiveItemPath:C,skipDelete:I,warnings:W}=await _(),B=await st(e.pmRoot,e.author),k=[];try{I||await F.rm(C);try{await He(g,y)}catch(T){throw I||await N(C,o),T}I||(k=await at({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:t.typeToFolder,schema:e.settings.schema,itemPath:C,document:null}))}finally{await B()}return{derivedIndexWarnings:k,effectiveItemPath:C,overrideWarnings:W,stored:I||C!==i.itemPath?await Ni({pmRoot:e.pmRoot,settings:e.settings,id:i.id,typeToFolder:t.typeToFolder,fallback:h,embeddedId:r.metadata.id}):{document:h}}}),{derivedIndexWarnings:x,effectiveItemPath:M,stored:D}=b;Be(e.pmRoot,D.document,i.id,[r.metadata.id],D.revision);let H=[...await L({path:M,scope:"project",op:"delete",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:h,changed_fields:["deleted"]}),...await L({path:g,scope:"project",op:"delete:history",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:h,changed_fields:["deleted"]})];return Xe({id:c.metadata.id,op:"delete",item_type:c.metadata.type,previous_status:c.metadata.status,previous:ye(c.metadata,Object.keys(c.metadata)),changed_fields:["deleted"]}),{item:c.metadata,changedFields:["deleted"],warnings:[...n,...p.warnings,...u.warnings,...b.overrideWarnings,...x,...H]}}finally{await s()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a483f454-e261-5232-bae0-da3cdb8c0518")}catch{}})();var de=Object.freeze({max_bytes:4096,max_depth:8}),Ai=160;var Fi=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u,kr=new Set(["__proto__"]),v=class extends Error{reason;path;constructor(t,i){super(t),this.reason=t,this.path=i}};function Mi(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Nr(e,t){return/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function Ar(e){if(Buffer.byteLength(e,"utf8")<=Ai)return e;let t="",i=Buffer.byteLength("\u2026","utf8");for(let o of e){if(i+=Buffer.byteLength(o,"utf8"),i>Ai)break;t+=o}return`${t}\u2026`}function Ae(e,t,i){if(e.bytes+=t,!(e.bytes<=de.max_bytes))throw new v("byte_limit",i)}function Pi(e,t,i){if(e.bytes+t>de.max_bytes)throw new v("byte_limit",i)}function yt(e,t,i){let o=Object.getOwnPropertyDescriptor(e,t);if(o===void 0||!("value"in o))throw new v("unsupported_value",i);return o.value}function Fr(e,t,i){if(typeof e=="number"&&!Number.isFinite(e))throw new v("non_finite_number",t);if(typeof e=="string"&&(Pi(i,e.length+2,t),Fi.test(e)))throw new v("malformed_unicode",t);if(e!==null&&!["boolean","number","string"].includes(typeof e))throw new v("unsupported_value",t);return Ae(i,Buffer.byteLength(JSON.stringify(e),"utf8"),t),e}function ji(e,t,i,o){if(typeof e!="object"||e===null)return Fr(e,t,o);if(i>=de.max_depth)throw new v("depth_limit",t);if(Array.isArray(e)){let r=yt(e,"length",t);if(typeof r!="number"||!Number.isSafeInteger(r)||r<0)throw new v("unsupported_value",t);Ae(o,r>0?r+1:2,t);let n=[];for(let s=0;s<r;s+=1){let a=`${t}[${s}]`;n.push(ji(yt(e,String(s),a),a,i+1,o))}return n}if(!Mi(e))throw new v("unsupported_value",t);return Li(e,t,i+1,o)}function Li(e,t,i,o){let r=Object.keys(e);Ae(o,r.length>0?r.length+1:2,t);let n={};for(let s of r){Pi(o,s.length+3,t);let a=Nr(t,s);if(kr.has(s))throw new v("reserved_key",a);if(Fi.test(s))throw new v("malformed_unicode",a);Ae(o,Buffer.byteLength(JSON.stringify(s),"utf8")+1,a),n[s]=ji(yt(e,s,a),a,i,o)}return n}function Mr(e){try{if(e instanceof v)return e}catch{}return new v("unsupported_value","details")}function pt(e){let t=de.max_bytes,i={bytes:0};try{if(!Mi(e))throw new v("not_plain_object","details");return{ok:!0,details:Li(e,"details",0,i),byte_length:i.bytes}}catch(o){let r=Mr(o);return{ok:!1,omission:r.reason==="byte_limit"?{reason:"byte_limit",byte_limit:t}:{reason:r.reason,path:Ar(r.path),byte_limit:t}}}}function Pr(e){return pt(e).ok}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e82bc812-181f-57ab-a29a-61703e8bec1b")}catch{}})();function ht(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function ya(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;if(!ht(t.requested_tokens)||t.basis!=="canonical_retry")return!1;switch(t.minimum_status){case"exact":return ht(t.minimum_feasible_tokens)&&t.feasible_tokens===t.minimum_feasible_tokens&&t.reason===void 0;case"feasible_only":return t.minimum_feasible_tokens===null&&ht(t.feasible_tokens)&&t.reason===void 0;case"unavailable":return t.minimum_feasible_tokens===null&&t.feasible_tokens===null&&["query_cost_limit","search_limit","output_constraints"].includes(t.reason);default:return!1}}var jr="PmCliError";function pa(e){if(!Ur(e)||e.code!=="item_already_exists"||e.exitCode!==f.CONFLICT)return!1;let t=e.context;return typeof t=="object"&&t!==null&&t.code==="item_already_exists"&&typeof t.id=="string"&&t.id.trim().length>0&&typeof t.path=="string"&&t.path.trim().length>0}function Lr(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=f.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function $r(e){if(e==null)return{};if(!Object.hasOwn(e,"details"))return e;let t=Object.getOwnPropertyDescriptor(e,"details");if(!("value"in t))throw $i("unsupported_value","details");if(t.value===void 0)return e;let i=pt(t.value);if(i.ok)return{...e,details:i.details};if(i.omission.reason==="byte_limit"){let{details:o,...r}=e;return{...r,details_omitted:i.omission}}throw $i(i.omission.reason,i.omission.path)}function $i(e,t){let i=new TypeError(`createPmCliExpectedError options.context.details must be plain JSON (${e})`);return Object.defineProperty(i,"path",{value:t,enumerable:!1}),i}function ha(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let i=new m(e,Lr(t.exitCode??f.USAGE),$r(t.context));return"cause"in t&&Object.defineProperty(i,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),i}function Ur(e){try{if(!(e instanceof Error)||e.name!==jr)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)&&typeof t.context=="object"&&t.context!==null&&!Array.isArray(t.context)}catch{return!1}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e23f9ca6-9fa6-566b-9bfb-7cbe6d449a59")}catch{}})();function Hr(e,t){let i=e.trim().toLowerCase();if(i.length===0)return;let o=Math.floor(i.length/3);return t.map(r=>({candidate:r,distance:ue(i,r.toLowerCase(),o)??Number.POSITIVE_INFINITY})).filter(({distance:r})=>Number.isFinite(r)).sort((r,n)=>r.distance!==n.distance?r.distance-n.distance:r.candidate.localeCompare(n.candidate))[0]?.candidate}function Ui(e){return["pm",...e].map(t=>/^[A-Za-z0-9_./:@=-]+$/u.test(t)?t:JSON.stringify(t)).join(" ")}function Ea(e){let t=e.command_path.trim().replaceAll(/\s+/gu," "),i=e.token.trim(),o=i.length===0?"<empty>":i,r=[...new Set(e.allowed.map(l=>l.trim()))].filter(Boolean).sort((l,h)=>l.localeCompare(h));if(t.length===0||o.length===0||r.length===0)throw new TypeError("Unknown-subcommand contracts require a path, token, and allowed set");let n=t.split(" "),s=e.trailing_args??[],a=e.display_name??`pm ${t}`,d=e.token_kind??"subcommand",c=e.retry_command?void 0:Hr(o,r),p=Ui([...n,o,...s]),u=e.retry_command??(c?Ui([...n,c,...s]):void 0);return new m(`Unknown ${a} ${d} "${o}". Allowed: ${r.join(", ")}${e.message_suffix??""}`,e.exit_code??f.USAGE,{code:"unknown_subcommand",reason:"unknown_positional_token",value:o,examples:[...u?[u]:[],...e.examples??[],`pm ${t} --help`],nextSteps:u?[`Retry with the suggested command: ${u}`]:["Choose one value from recovery.allowed_values."],recovery:{attempted_command:p,allowed_values:r,suggested_retry:u,fallback_candidates:e.fallback_candidates}})}export{_e as a,ge as b,Xr as c,Gr as d,Ea as e,dt as f,hr as g,Jt as h,Z as i,ee as j,Zr as k,te as l,wi as m,ct as n,bi as o,Kn as p,oo as q,no as r,so as s,ao as t,co as u,Ke as v,En as w,us as x,On as y,Dn as z,kn as A,ui as B,So as C,st as D,zn as E,at as F,Ne as G,mt as H,xi as I,Er as J,vr as K,Qs as L,Zs as M,Ri as N,Tr as O,ea as P,ta as Q,ia as R,oa as S,Pr as T,ya as U,jr as V,pa as W,ha as X,Ur as Y};
91
- //# sourceMappingURL=chunk-3XSWH6QC.js.map
@@ -1,2 +0,0 @@
1
- import{a as h,b as B}from"./chunk-C3O6JJPO.js";import{V as k,la as O,nd as p,od as m,ta as A}from"./chunk-UWS3FC4D.js";(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]="a319e7d9-e248-573b-bf1f-35217ce49fd0")}catch{}})();function w(e,n){return(n===void 0?void 0:A(e,n))?.execution_role??O[e.trim().toLowerCase()]??"agent"}var E="blocked_by",L="blocks",G=Object.freeze([E,L]),v="no-active-blocker";function r(e){return e.trim().toLowerCase()}function y(e,n){return n?`external:${e}`:`local:${r(e)}`}function I(e){let n=new Map,t=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(t.length>0&&r(t)!==v){let o=h(t);n.set(y(t,o),o?t:r(t))}for(let o of e.dependencies??[]){let c=typeof o.id=="string"?o.id.trim():"";if(k(o.kind)===E&&c.length>0&&r(c)!==v){let s=h(c)||B(o.source_kind);n.set(y(c,s),s?c:r(c))}}return[...n.values()].sort((o,c)=>o.localeCompare(c))}function _(e){let n=new Map;for(let t of e){let o=r(t.id);o.length!==0&&n.set(o,new Set(I(t)))}for(let t of e){let o=r(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=k(c.kind)===L&&typeof c.id=="string"?r(c.id):"";if(s.length===0||s===v)continue;let l=n.get(s)??new Set;l.add(o),n.set(s,l)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function M(e,n){let t=r(e.id);return t.length>0?_(n).get(t)??I(e):I(e)}function D(e,n,t,o){let c=e,s=typeof c.id=="string"?o?.get(r(c.id))??M(c,[...n.values()]):I(e),l=new Set((e.dependencies??[]).filter(d=>k(d.kind)===E&&B(d.source_kind)&&typeof d.id=="string"&&d.id.trim().length>0).map(d=>y(d.id.trim(),!0)));return s.map(d=>{if(h(d)||l.has(y(d,!0)))return{id:d,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let i=n.get(r(d));return i?{id:d,title:i.title,status:i.status,resolved:m(i.status,t)}:{id:d,title:null,status:null,resolved:!1}})}function R(e,n,t){return D(e,n,t)}function U(e,n){let t=new Map(e.map(l=>[r(l.id),l])),o=_(e),c=new Set([...z(n),...n.blocked_statuses]),s=new Set;for(let l of e){let d=p(l.status,n);c.has(d)&&(n.blocked_statuses.has(d)||D(l,t,n,o).some(i=>!i.resolved))&&s.add(r(l.id))}return s}function W(e,n,t={},o){let c=[...e.ready,...e.decisions,...e.gates];t.includeContainers===!0&&c.push(...e.containers.filter(l=>l.open_blockers.length===0&&!n.blocked_statuses.has(p(l.item.status,n))));let s={ready:[],decisions:[],gates:[]};for(let l of c){let d=w(l.item.type,o);d==="human"&&t.includeDecisions!==!0?s.decisions.push(l):d==="gate"&&t.includeGates!==!0?s.gates.push(l):s.ready.push(l)}return s}function z(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function $(e,n,t){let o=[r(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let l of n.get(s)??[]){if(!m(l.status,t))return!0;o.push(r(l.id))}}}return!1}function j(e){let n=new Map,t=new Map,o=new Map,c=_(e);for(let s of e){n.set(r(s.id),s);let l=typeof s.parent=="string"?s.parent.trim():"";if(l.length>0){let d=r(l),i=t.get(d)??[];i.push(s),t.set(d,i)}for(let d of c.get(r(s.id))){let i=r(d),b=o.get(i)??[];b.push(s.id),o.set(i,b)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function V(e,n,t,o){let{itemsById:c,childrenByParent:s,blockedByReverse:l,blockerIdsByItem:d}=j(n),i=new Set([...z(t),...t.blocked_statuses]),b=new Set(n.filter(a=>!m(a.status,t)).map(a=>r(a.id))),S=[],C=[],g=[],N=[],x=[],T=0;for(let a of e){if(!i.has(p(a.status,t)))continue;T+=1;let K=D(a,c,t,d).filter(u=>!u.resolved),Y=(l.get(r(a.id))??[]).filter(u=>b.has(r(u))).sort((u,F)=>u.localeCompare(F)),f={item:a,open_blockers:K,unblocks:Y};if($(a.id,s,t)){g.push(f);continue}let P=t.blocked_statuses.has(p(a.status,t));if(K.length===0&&!P){let u=w(a.type,o);u==="human"?N.push(f):u==="gate"?x.push(f):S.push(f)}else C.push(f)}return{ready:S,blocked:C,containers:g,decisions:N,gates:x,active_count:T,container_count:g.length}}(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]="ae1c56b3-148d-502d-9450-e807fdfab4da")}catch{}})();export{w as a,G as b,I as c,_ as d,M as e,R as f,U as g,W as h,V as i};
2
- //# sourceMappingURL=chunk-4JZITIJB.js.map
@@ -1,2 +0,0 @@
1
- import{b as ze}from"./chunk-OPGOOP25.js";import{nb as q,ob as V,pb as W,qb as X,ra as Le,sa as Ae,va as Re,wa as ke}from"./chunk-RE7ZWT7D.js";import{F as me,b as j,c as B,f as ue}from"./chunk-ZWJTY4ID.js";import{d as Be,e as Ge,h as $e}from"./chunk-HDEKFSOK.js";import{g as je}from"./chunk-4JZITIJB.js";import{A as H,C as Ne,E as R,K as Ue,L as k,M as Pe,b as ce,l as De,m as Ke,o as xe,p as Oe,y as z}from"./chunk-3XSWH6QC.js";import{s as S,y as O}from"./chunk-BRZV7BFV.js";import{Cc as pe,Ee as we,Fc as ye,Ie as Se,Jc as L,Kc as ge,Lc as G,Nc as _e,Tf as A,bg as Ee,ca as h,ff as ve,gf as Ie,hf as Fe,hh as Te,ih as Ce,jh as $,mc as M,md as he,nh as Me,oc as fe,od as E,ra as v,sa as x,te as be,xa as w}from"./chunk-UWS3FC4D.js";import{A as f,z as m}from"./chunk-3IRCYJI5.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="738a98bc-eaf0-578d-88e3-1c5f83c8894b")}catch{}})();function N(e,t="--limit"){if(e===void 0)return;let r=String(e).trim(),i=r.length===0?Number.NaN:Number(r);if(!Number.isInteger(i)||i<0)throw new f(`${t} must be a non-negative integer`,m.USAGE);return i}function He(e,t="--priority"){if(e===void 0)return;let r=String(e).trim(),i=r.length===0?Number.NaN:Number(r);if(!Number.isInteger(i)||i<0||i>4)throw new f(`${t} filter must be 0..4`,m.USAGE);return i}function ti(e,t,r="--type"){if(e===void 0)return;let i=x(e,t);if(!i)throw new f(`${r} filter must be one of ${t.types.join("|")}`,m.USAGE);return i}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="75ecca0c-fac8-5a9b-9043-c65731daad4a")}catch{}})();function Y(e,t){if(e===void 0)return;let r=[],i="";for(let o=0;o<e.length;o+=1){let a=e[o];if(a==="\\"){let l=e[o+1];if(l===","||l==="\\"){i+=l,o+=1;continue}i+=a;continue}if(a===","){r.push(i),i="";continue}i+=a}r.push(i);let n=r.map(o=>o.trim());if(n.some(o=>o.length===0))throw new f(`${t.label} requires at least one non-empty value`,m.USAGE);let s=n.map(o=>t.normalize?.(o)??o);return[...new Set(s)]}function D(e,t){let r=Y(e,t);return r===void 0?void 0:new Set(r)}function qe(e,t,r="--type"){let i=Y(e,{label:r});if(i===void 0)return;let n=i.map(s=>{let o=x(s,t);if(!o)throw new f(`${r} filter token "${s}" must be one of ${t.types.join("|")}`,m.USAGE);return o});return new Set(n)}function Ve(e,t="--priority"){let r=Y(e,{label:t});if(r!==void 0)return new Set(r.map(i=>He(i,t)))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f9d73d74-7c4e-5ea9-b34c-c984b4c15ab3")}catch{}})();function We(e,t){let r=e.trim().toLowerCase();return t.alias_to_id.get(r)??r}function Je(e){return{isTerminal(t){return e.terminal_statuses.has(We(t,e))},classify(t){let r=We(t,e);return e.terminal_canceled_statuses.has(r)?"canceled":e.terminal_statuses.has(r)?"closed":e.blocked_statuses.has(r)?"blocked":e.draft_statuses.has(r)?"draft":r===e.open_status?"open":e.active_statuses.has(r)?"in_progress":"other"}}}function Q(e){return h(e.acceptance_criteria)===void 0}function J(e){return!Number.isFinite(e.estimated_minutes)}function Ze(e,t){return t.isTerminal(e.status)?h(e.resolution)===void 0:!1}function qt(e){return h(e.reviewer)===void 0}function Vt(e){return h(e.risk)===void 0}function Wt(e){return typeof e.confidence=="number"?!Number.isFinite(e.confidence):h(e.confidence)===void 0}function Xt(e){return h(e.sprint)===void 0}function Yt(e){return h(e.release)===void 0}function Z(e){return!!(e.acMissing||e.estimatesMissing||e.resolutionMissing||e.reviewerMissing||e.riskMissing||e.confidenceMissing||e.sprintMissing||e.releaseMissing||e.metadataMissing)}function Qt(e,t,r){return[[t.acMissing,Q(e)],[t.estimatesMissing,J(e)],[t.resolutionMissing,Ze(e,r)],[t.reviewerMissing,qt(e)],[t.riskMissing,Vt(e)],[t.confidenceMissing,Wt(e)],[t.sprintMissing,Xt(e)],[t.releaseMissing,Yt(e)]].every(([i,n])=>i!==!0||n)}function Jt(e,t){return Q(e)||J(e)||Ze(e,t)}function et(e,t,r){return Z(t)?!(!Qt(e,t,r)||t.metadataMissing&&!Jt(e,r)):!0}var ee=["acceptance_criteria","estimated_minutes","resolution","tags","parent"];function Zt(e,t){switch(t){case"acceptance_criteria":return!Q(e);case"estimated_minutes":return!J(e);case"resolution":return h(e.resolution)!==void 0;case"tags":return Array.isArray(e.tags)&&e.tags.length>0;default:return h(e.parent)!==void 0}}function er(e,t,r){return t==="resolution"?r.isTerminal(e.status):!0}function tr(e,t){return t===0?100:Math.round(e/t*1e3)/10}function Xe(){let e={};for(let t of ee)e[t]={present:0,applicable:0,percent:100};return e}function Ye(e,t,r){for(let i of ee){if(!er(t,i,r))continue;let n=e[i];n.applicable+=1,Zt(t,i)&&(n.present+=1)}}function Qe(e){for(let t of ee){let r=e[t];r.percent=tr(r.present,r.applicable)}}function di(e,t){let r=Xe(),i={};for(let n of e){Ye(r,n,t);let s=i[n.type]??(i[n.type]=Xe());Ye(s,n,t)}Qe(r);for(let n of Object.values(i))Qe(n);return{overall:r,by_type:i}}var rr={assignee:"(unassigned)",priority:"(no priority)",tag:"(untagged)",parent:"(unparented)",type:"(untyped)",status:"(no status)"};function ir(e){return rr[e]}function nr(){return{open:0,in_progress:0,blocked:0,draft:0,closed:0,canceled:0,other:0}}function sr(e,t,r){switch(t){case"assignee":return[h(e.assignee)??null];case"parent":return[h(e.parent)??null];case"type":return[h(e.type)??null];case"status":return[h(e.status)??null];case"priority":return[typeof e.priority=="number"?`P${e.priority}`:null];default:{let i=r.tagPrefix?.trim(),n=(Array.isArray(e.tags)?e.tags:[]).filter(s=>typeof s=="string"&&s.length>0&&(!i||s.startsWith(i)));return n.length>0?n:[null]}}}function ci(e,t,r,i={}){let n=new Map,s=0;for(let a of e){s+=1;let l=r.classify(a.status);for(let d of sr(a,t,i)){let c=d??"\0empty",u=n.get(c);u||(u={label:d??ir(t),key:d,buckets:nr(),total:0},n.set(c,u)),u.buckets[l]+=1,u.total+=1}}let o=[...n.values()].sort((a,l)=>l.total!==a.total?l.total-a.total:a.key===null?1:l.key===null?-1:a.label.localeCompare(l.label));return{dimension:t,rows:o,total_items:s}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="67f9184e-08b6-5f21-9f92-e60974adbf1e")}catch{}})();var T=["notes","learnings","files","docs","tests","comments","deps","body","linked_command"];function I(e){return Array.isArray(e)&&e.length>0}function or(e){return typeof e=="string"&&e.trim().length>0}function ar(e){return Array.isArray(e)?e.some(t=>{if(typeof t!="object"||t===null)return!1;let r=t.command;return typeof r=="string"&&r.trim().length>0}):!1}function rt(e,t){switch(t){case"notes":return I(e.notes);case"learnings":return I(e.learnings);case"files":return I(e.files);case"docs":return I(e.docs);case"tests":return I(e.tests);case"comments":return I(e.comments);case"deps":return I(e.dependencies);case"body":return or(e.body);case"linked_command":return ar(e.tests)}}function it(e){return T.some(t=>e[t]!==void 0)}function nt(e,t){for(let r of T){let i=t[r];if(i===void 0)continue;let n=rt(e,r);if(i==="present"&&!n||i==="absent"&&n)return!1}return!0}function st(e){return T.some(t=>t!=="body"&&e[t]!==void 0)}function ot(e){return e.body!==void 0}function tt(e,t){return t===0?100:Math.round(e/t*1e3)/10}function lr(){let e={};for(let t of T)e[t]={present:0,total:0,percent:100};return e}function mi(e){let t=lr(),r=e.length;for(let o of e)for(let a of T)rt(o,a)&&(t[a].present+=1);for(let o of T)t[o].total=r,t[o].percent=tt(t[o].present,r);let i=t.body,n=r-i.present,s={present:n,total:r,percent:tt(n,r)};return{total_items:r,fields:t,body_populated:i,empty_body:s}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9a6eb9fd-03f3-562d-b3d5-08d6bb55ef8f")}catch{}})();var mt=e=>({acMissing:e.filterAcMissing===!0,estimatesMissing:e.filterEstimatesMissing===!0,resolutionMissing:e.filterResolutionMissing===!0,metadataMissing:e.filterMetadataMissing===!0,reviewerMissing:e.filterReviewerMissing===!0,riskMissing:e.filterRiskMissing===!0,confidenceMissing:e.filterConfidenceMissing===!0,sprintMissing:e.filterSprintMissing===!0,releaseMissing:e.filterReleaseMissing===!0}),at=[{field:"notes",presentKey:"hasNotes",absentKey:"noNotes",presentFlag:"--has-notes",absentFlag:"--no-notes"},{field:"learnings",presentKey:"hasLearnings",absentKey:"noLearnings",presentFlag:"--has-learnings",absentFlag:"--no-learnings"},{field:"files",presentKey:"hasFiles",absentKey:"noFiles",presentFlag:"--has-files",absentFlag:"--no-files"},{field:"docs",presentKey:"hasDocs",absentKey:"noDocs",presentFlag:"--has-docs",absentFlag:"--no-docs"},{field:"tests",presentKey:"hasTests",absentKey:"noTests",presentFlag:"--has-tests",absentFlag:"--no-tests"},{field:"comments",presentKey:"hasComments",absentKey:"noComments",presentFlag:"--has-comments",absentFlag:"--no-comments"},{field:"deps",presentKey:"hasDeps",absentKey:"noDeps",presentFlag:"--has-deps",absentFlag:"--no-deps"},{field:"body",presentKey:"hasBody",absentKey:"emptyBody",presentFlag:"--has-body",absentFlag:"--empty-body"},{field:"linked_command",presentKey:"hasLinkedCommand",absentKey:"noLinkedCommand",presentFlag:"--has-linked-command",absentFlag:"--no-linked-command"}],re=e=>{let t=at.find(r=>e[r.presentKey]===!0&&e[r.absentKey]===!0);if(t)throw new f(`Cannot combine ${t.presentFlag} with ${t.absentFlag} for the same field.`,m.USAGE);return Object.fromEntries(at.flatMap(r=>e[r.presentKey]===!0?[[r.field,"present"]]:e[r.absentKey]===!0?[[r.field,"absent"]]:[]))},lt=["priority","deadline","updated_at","created_at","title","parent"],dt=["asc","desc"],ft=new Set(Ne);function dr(e,t,r){let i=e.filter(o=>o.startsWith("item_list_item_read_failed:")).length,n=e.filter(o=>o.startsWith("item_list_directory_read_failed:")).length,s={status:t?"unchecked":i+n>0?"partial":"complete",unreadable_item_count:i,unreadable_directory_count:n};if(r&&s.status==="partial")throw new f(`List source is incomplete: ${i} item document(s) and ${n} item directory/directories could not be read.`,m.GENERIC_FAILURE,{code:"list_source_incomplete",why:"Strict list reads fail closed so agents and SDK consumers never treat an omitted item as a complete workspace.",nextSteps:["Run pm validate --check-storage-integrity to locate unreadable tracker artifacts.","Repair the reported files or align the installed decoder version, then retry."]});return s}function cr(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&Object.keys(e).length>0}var ur=[{key:"hasNotes",summaryKey:"has_notes"},{key:"hasLearnings",summaryKey:"has_learnings"},{key:"hasFiles",summaryKey:"has_files"},{key:"hasDocs",summaryKey:"has_docs"},{key:"hasTests",summaryKey:"has_tests"},{key:"hasComments",summaryKey:"has_comments"},{key:"hasDeps",summaryKey:"has_deps"},{key:"hasBody",summaryKey:"has_body"},{key:"hasLinkedCommand",summaryKey:"has_linked_command"},{key:"noNotes",summaryKey:"no_notes"},{key:"noLearnings",summaryKey:"no_learnings"},{key:"noFiles",summaryKey:"no_files"},{key:"noDocs",summaryKey:"no_docs"},{key:"noTests",summaryKey:"no_tests"},{key:"noComments",summaryKey:"no_comments"},{key:"noDeps",summaryKey:"no_deps"},{key:"emptyBody",summaryKey:"empty_body"},{key:"noLinkedCommand",summaryKey:"no_linked_command"}],mr=[{key:"filterReviewerMissing",summaryKey:"filter_reviewer_missing"},{key:"filterRiskMissing",summaryKey:"filter_risk_missing"},{key:"filterConfidenceMissing",summaryKey:"filter_confidence_missing"},{key:"filterSprintMissing",summaryKey:"filter_sprint_missing"},{key:"filterReleaseMissing",summaryKey:"filter_release_missing"}];function pt(e,t){for(let r of ur)t[r.key]===!0&&(e[r.summaryKey]=!0)}function yt(e,t){for(let r of mr)t[r.key]===!0&&(e[r.summaryKey]=!0)}function fr(e,t,r){for(let i of r){let n=t[i.optionKey];n!==void 0&&(e[i.summaryKey]=i.normalize?i.normalize(n):n)}}function gt(e){let t={};return pt(t,e),t}function _t(e){let t={};return yt(t,e),t}var pr=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"}],yr=[{optionKey:"type",summaryKey:"type"},{optionKey:"tag",summaryKey:"tag"},{optionKey:"priority",summaryKey:"priority"},{optionKey:"deadlineBefore",summaryKey:"deadline_before"},{optionKey:"deadlineAfter",summaryKey:"deadline_after"},{optionKey:"updatedAfter",summaryKey:"updated_after"},{optionKey:"updatedBefore",summaryKey:"updated_before"},{optionKey:"createdAfter",summaryKey:"created_after"},{optionKey:"createdBefore",summaryKey:"created_before"},{optionKey:"ids",summaryKey:"ids"},{optionKey:"assignee",summaryKey:"assignee"},{optionKey:"assigneeFilter",summaryKey:"assignee_filter"},{optionKey:"parent",summaryKey:"parent"},{optionKey:"sprint",summaryKey:"sprint"},{optionKey:"release",summaryKey:"release"},{optionKey:"limit",summaryKey:"limit"},{optionKey:"offset",summaryKey:"offset"},{optionKey:"includeBody",summaryKey:"include_body"},{optionKey:"compact",summaryKey:"compact"},{optionKey:"fields",summaryKey:"fields"}],gr=[{key:"filterAcMissing",summaryKey:"filter_ac_missing"},{key:"filterEstimatesMissing",summaryKey:"filter_estimates_missing"},{key:"filterResolutionMissing",summaryKey:"filter_resolution_missing"},{key:"filterMetadataMissing",summaryKey:"filter_metadata_missing"}],_r="-7d";function ht(e){let{filtersStatus:t,options:r,treeEnabled:i,treeDepth:n,sortField:s,sortOrder:o,runtimeFieldFilters:a}=e,l={};return t!==null&&(l.status=t),r.dependencyBlocked===!0&&(l.blocked_semantics="status_or_dependency"),fr(l,r,pr),wt(l,r),r.filterAcMissing===!0&&(l.filter_ac_missing=!0),r.filterEstimatesMissing===!0&&(l.filter_estimates_missing=!0),r.filterResolutionMissing===!0&&(l.filter_resolution_missing=!0),r.filterMetadataMissing===!0&&(l.filter_metadata_missing=!0),yt(l,r),pt(l,r),r.limit!==void 0&&(l.limit=r.limit),r.offset!==void 0&&(l.offset=r.offset),r.includeBody===!0&&(l.include_body=!0),r.fields!==void 0&&(l.fields=r.fields),i&&(l.tree=!0,n!==void 0&&(l.tree_depth=n)),s!==void 0&&(l.sort=s,l.order=o),cr(a)&&(l.runtime_filters=a),l}function ie(e,t,r){let i=E(e.status,r),n=E(t.status,r);if(i!==n)return i?1:-1;let s=e.priority-t.priority;if(s!==0)return s;let o=L(t.updated_at,e.updated_at);return o!==0?o:(e.id??"").localeCompare(t.id??"")}function hr(e,t){return[...e].sort((r,i)=>ie(r,i,t))}function ct(e,t){if(e!==void 0)return G(e,new Date,t)}function K(e,t){if(e==null)return;let r=String(e).trim();if(r.length!==0)return G(r,new Date,t)}function bt(e){let t=e.updatedAfter!=null&&String(e.updatedAfter).trim().length>0;if([e.today===!0,e.recent===!0,t].filter(r=>r).length>1)throw new f("Choose only one updated_at window: --today, --recent, or --updated-after.",m.USAGE);if(e.today===!0){let r=new Date;return r.setHours(0,0,0,0),r.toISOString()}return e.recent===!0?K(_r,"recent"):K(e.updatedAfter,"updated-after")}function wt(e,t){t.today===!0&&(e.today=!0),t.recent===!0&&(e.recent=!0)}function St(e){if(e==null)return;let t=String(e).trim();if(t.length===0)throw new f("--ids requires at least one non-empty item ID",m.USAGE);let r=t.split(",").map(i=>i.trim()).filter(i=>i.length>0);if(r.length===0)throw new f("--ids requires at least one non-empty item ID",m.USAGE);return new Set(r)}function ne(e){if(e===void 0)return;let t=String(e).trim(),r=t.length===0?Number.NaN:Number(t);if(!Number.isInteger(r)||r<0)throw new f("Offset filter must be a non-negative integer",m.USAGE);return r}function vt(e){if(e===void 0)return;let t=e.split(",").map(r=>r.trim()).filter(r=>r.length>0);if(t.length===0)throw new f("List --fields requires a comma-separated list of field names",m.USAGE);return[...new Set(t)]}function It(e,t=e.projectionCommand??"list"){let r=e.compact===!0,i=e.brief===!0,n=e.full===!0,s=vt(e.fields);if(Number(r)+Number(i)+Number(n)+ +(s!==void 0)>1)throw new f("List projection options are mutually exclusive. Use one of --compact, --brief, --full, or --fields.",m.USAGE,{code:"projection_options_mutually_exclusive",recovery:{suggested_retry:`pm ${t} --brief`,suggested_retry_args:[t,"--brief"]}});if(n)return{mode:"full",fields:[]};if(i){let o=se(e.sort);return{mode:"brief",fields:[...new Set([...B,o??"priority"])]}}return r?{mode:"compact",fields:[...j]}:s?{mode:"fields",fields:[...new Set(s.map(o=>F(o)))]}:{mode:"full",fields:[]}}function F(e){return e.startsWith("item.")?e.slice(5):e}function br(e,t,r){if(e.mode!=="fields")return;let i=ue(t),n=new Set(i),s=e.fields.filter(o=>!n.has(F(o)));if(s.length>0){let o=[r,"--fields",e.fields.filter(a=>!s.includes(a)).join(",")||"id,title,status"];throw new f(`Unknown list --fields value(s): ${s.join(", ")}`,m.USAGE,{code:"unknown_field_projection",required:"Choose fields from recovery.allowed_values; each field also accepts an item. prefix.",examples:["pm list --status open --fields id,title,status","pm list --fields id,title,parent,priority --limit 10","pm list --all --fields id,title,body --limit 5"],recovery:{allowed_values:i,suggested_retry:_e(o),suggested_retry_args:o}})}}var wr=new Map([["updated","updated_at"],["update","updated_at"],["modified","updated_at"],["created","created_at"],["create","created_at"]]);function se(e){if(e===void 0)return;let t=e.trim().toLowerCase(),r=wr.get(t);if(r)return r;if(!lt.includes(t))throw new f(`Sort field must be one of ${lt.join("|")} (aliases: updated->updated_at, created->created_at)`,m.USAGE);return t}function Ft(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!dt.includes(t))throw new f(`Sort order must be one of ${dt.join("|")}`,m.USAGE);return t}function Sr(e){return N(e,"--tree-depth")}function Et(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(!t)throw new f("Assignee filter must be one of assigned|unassigned",m.USAGE);if(t!=="assigned"&&t!=="unassigned")throw new f(`Invalid assignee filter "${e}". Allowed: assigned|unassigned`,m.USAGE);return t}function ut(e,t){return Ae(e,t,{strict:!0})}function Tt(e){return D(e,{label:"--tag",normalize:t=>t.toLowerCase()})}function vr(e,t,r){let i=Tt(t);if(i===void 0)return;let n=new Set(e.flatMap(o=>o.tags.map(a=>a.trim().toLowerCase()))),s=[...i].filter(o=>!n.has(o));s.length>0&&r.push(`unknown_tags:${s.join(",")}`)}function Ir(e,t){if(e&&[...e].some(r=>r.toLowerCase()==="none"||r.toLowerCase()==="null"))throw new f('--assignee no longer accepts "none" or "null". Use --assignee-filter unassigned.',m.USAGE);if(e!==void 0&&t==="unassigned")throw new f("Cannot combine --assignee with --assignee-filter unassigned",m.USAGE)}function Fr(e,t,r,i){let n=D(t.assignee,{label:"--assignee"}),s=Et(t.assigneeFilter);Ir(n,s);let o=mt(t),a=re(t);return{idsFilter:St(t.ids),statusSet:e&&e.length>0?new Set(e):void 0,excludeTerminal:t.excludeTerminal===!0,typeFilter:qe(t.type,r),tagFilters:Tt(t.tag),priorityFilter:Ve(t.priority),deadlineBefore:ct(t.deadlineBefore,"deadline-before"),deadlineAfter:ct(t.deadlineAfter,"deadline-after"),updatedAfter:bt(t),updatedBefore:K(t.updatedBefore,"updated-before"),createdAfter:K(t.createdAfter,"created-after"),createdBefore:K(t.createdBefore,"created-before"),assigneeFilter:n,assigneeModeFilter:s,parentFilter:t.parent?.trim(),treeEnabled:t.tree===!0,sprintFilter:D(t.sprint,{label:"--sprint"}),releaseFilter:D(t.release,{label:"--release"}),missingMetadataFilters:o,missingMetadataActive:Z(o),lifecycleClassifier:Je(i),contentFieldFilters:a,contentFiltersActive:it(a)}}function Er(e,t,r){return t.idsFilter&&!t.idsFilter.has(e.id)||t.statusSet&&!t.statusSet.has(e.status)||t.excludeTerminal&&E(e.status,r)||t.typeFilter&&!t.typeFilter.has(e.type)||t.tagFilters&&![...t.tagFilters].some(i=>(e.tags??[]).some(n=>n.trim().toLowerCase()===i))?!1:t.priorityFilter===void 0||t.priorityFilter.has(e.priority)}function Tr(e,t){return ge(e,t)}function Cr(e,t){return t.assigneeModeFilter==="assigned"&&!e.assignee||t.assigneeModeFilter==="unassigned"&&e.assignee?!1:t.assigneeFilter===void 0||e.assignee!==void 0&&t.assigneeFilter.has(e.assignee)}function Mr(e,t,r){let i=e.parent?.trim().toLowerCase(),n=[...new Set([...r?.get(e.id.trim().toLowerCase())??[],...i?[i]:[]])];return t.parentFilter!==void 0&&!t.treeEnabled&&!n.includes(t.parentFilter.trim().toLowerCase())||t.sprintFilter!==void 0&&(e.sprint===void 0||!t.sprintFilter.has(e.sprint))?!1:t.releaseFilter===void 0||e.release!==void 0&&t.releaseFilter.has(e.release)}function Lr(e,t,r,i,n){return!(!Er(e,t,r)||!Tr(e,t)||!Cr(e,t)||!Mr(e,t,n)||t.missingMetadataActive&&!et(e,t.missingMetadataFilters,t.lifecycleClassifier)||t.contentFiltersActive&&!nt(e,t.contentFieldFilters)||!ke(e,i))}function Ct(e,t,r,i,n,s,o){let a=Fr(t,r,i,n);return e.filter(l=>Lr(l,a,n,s,o))}function C(e){if(typeof e!="string")return;let t=e.trim();return t.length>0?t:void 0}function te(e,t,r,i){let n=e,s=typeof n.title=="string"?n.title:"",o=i??C(typeof n.parent=="string"?n.parent:void 0)??null;return{...e,tree_depth:t,tree_parent:o,tree_children:r,tree_title:`${" ".repeat(t)}${s}`}}function Ar(e,t){let r=new Map,i=new Map;for(let n of e){let s=n.id.trim().toLowerCase();r.set(s,n);let o=t?t.parents_by_child.get(s)??[]:[C(n.parent)?.toLowerCase()].filter(a=>a!==void 0);for(let a of o){let l=i.get(a)??[];l.push(n),i.set(a,l)}}return{byId:r,childrenByParent:i}}function Rr(e,t,r,i,n){return t?[...i.get(t.toLowerCase())??[]]:e.filter(s=>(n?n.parents_by_child.get(s.id.trim().toLowerCase())??[]:[C(s.parent)?.toLowerCase()].filter(o=>o!==void 0)).every(o=>!r.has(o)))}function Mt(e,t,r,i,n=e){let{byId:s,childrenByParent:o}=Ar(e,i),a=Rr(e,t,s,o,i),l=[],d=new Set,c=new Map(n.map(p=>[p.id.trim().toLowerCase(),p.id.trim()])),u=[...a].reverse().map(p=>({node:p,depth:0,parentId:t===void 0?void 0:c.get(t.trim().toLowerCase())??t.trim()}));for(;u.length>0;){let{node:p,depth:y,parentId:g}=u.pop(),_=p.id.trim().toLowerCase();if(d.has(_))continue;d.add(_);let b=o.get(_)??[];if(l.push(te(p,y,b.length,g)),!(r!==void 0&&y>=r))for(let P of[...b].reverse())u.push({node:P,depth:y+1,parentId:c.get(_)})}if(t===void 0&&r===void 0)for(let p of e){let y=p.id.trim().toLowerCase();d.has(y)||(d.add(y),l.push(te(p,0,o.get(y)?.length??0)))}return l}function Lt(e,t){return e===t?0:e===null?1:t===null?-1:e.localeCompare(t)}function At(e,t){return e===t?0:e===null?1:t===null?-1:L(e,t)}function Rt(e,t,r){switch(r){case"priority":return e.priority-t.priority;case"deadline":return At(e.deadline??null,t.deadline??null);case"updated_at":return L(e.updated_at,t.updated_at);case"created_at":return L(e.created_at,t.created_at);case"title":return(e.title??"").localeCompare(t.title??"");case"parent":return Lt(e.parent??null,t.parent??null);default:return 0}}function kt(e,t,r,i){return t?[...e].sort((n,s)=>{let o=Rt(n,s,t);if(o!==0)return r==="desc"?-o:o;let a=ie(n,s,i);return r==="desc"?-a:a}):hr(e,i)}function Dt(e,t,r=!1){let i=F(t.trim());if(i.length===0)return null;let n=e;return r&&i==="title"&&typeof n.tree_title=="string"?n.tree_title:Object.prototype.hasOwnProperty.call(n,i)?n[i]??null:null}function oe(e,t,r=!1){return t.mode==="full"?e:e.map(i=>{let n={};for(let s of t.fields)n[s]=Dt(i,s,r);return n})}function Kt(e){let t=[];for(let r of e)t.push(r.metadata_key);return[...t,...ce(A())]}function xt(e,t){let r=N(e.limit);if(r!==void 0)return r;if(e.noTruncate!==!0)return t>=1e4?20:void 0}function kr(e,t,r){return t.after===void 0?ne(t.offset)??0:Me(e,t.after,r,i=>i.id)}function Ot(e,t,r){return{...e!==void 0?{applied_limit:e}:{},has_more:t,truncated:t,next_cursor:r??null}}async function Dr(e,t){let r=w(process.cwd(),t.path);await O(r);let i=await S(r),n=M(i.schema),s=fe(i.schema),o=e.projectionCommand??"list",a=It(e,o);return br(a,Kt(s.definitions),o),{pmRoot:r,settings:i,statusRegistry:n,runtimeFieldFilters:Re(e,s,"list"),typeRegistry:v(i,A()),projection:a}}async function Kr(e,t,r){let i=t.projection.fields.some(l=>F(l)==="body"),n=t.projection.mode==="full"||t.projection.fields.some(l=>ft.has(F(l))),s=re(e),o=st(s),a=ot(s);return e.includeBody||i||a?await Pe(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,r,t.settings.schema):n||o?await Ue(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,r,t.settings.schema):await k(t.pmRoot,t.settings.item_format,t.typeRegistry.type_to_folder,r,t.settings.schema)}function xr(e){let t=se(e.sort),r=Ft(e.order)??"asc",i=e.tree===!0;if(!i&&e.treeDepth!==void 0)throw new f("List --tree-depth requires --tree",m.USAGE);if(!t&&e.order!==void 0)throw new f("List --order requires --sort",m.USAGE);return{sortField:t,sortOrder:r,treeEnabled:i,treeDepth:i?Sr(e.treeDepth):void 0,parentRoot:i?C(e.parent):void 0}}function Or(e,t,r){let i=ut(t.status,r),n;t.lifecycleBucket==="in_progress"?n=[r.in_progress_status]:t.lifecycleBucket==="open"&&(n=[...r.active_statuses].filter(d=>d!==r.in_progress_status).sort((d,c)=>d.localeCompare(c)));let s=i??n??ut(e,r),o=Le(t.status),a=i||o?{...t,excludeTerminal:!1}:t,l="all";return o?l="all":i!==void 0?l=i.length===1?i[0]:i:t.lifecycleBucket!==void 0?l=t.lifecycleBucket:s!==void 0?l=s.length===1?s[0]:s:a.excludeTerminal===!0&&(l=null),{resolvedStatus:s,explicitAllStatuses:o,effectiveOptions:a,filtersStatus:l}}function Nr(e,t,r,i,n){if(t.after!==void 0&&t.offset!==void 0)throw new f("List --after cannot be combined with --offset.",m.USAGE);let s=xt(t,e.length),o=kr(e,t,n),a=s===void 0?e.slice(o):e.slice(o,o+s),l=oe(a,r,i),d=e.length,c=a.length>0&&o+a.length<d,u=c&&a.length>0?$(n,a[a.length-1].id,o+a.length-1):void 0;return{projected:l,totalMatched:d,pageExtras:Ot(s,c,u)}}function Nt(e,t,r,i){return Ce("list",{pmRoot:i,status:e,options:Te(t,me),sort:r.sortField??"default",order:r.sortOrder,tree:r.treeEnabled,tree_depth:r.treeDepth??null})}async function Ur(e){let{options:t,runtime:r,statusSelection:i,ordering:n}=e,s=new Set(["status","limit","offset","compact","brief","full","fields","format","stream","includeBody","excludeTerminal","dependencyBlocked","lifecycleBucket","noTruncate","projectionCommand","truncate","notes","learnings","files","docs","tests","comments","deps","linkedCommand"]),o=[r.projection.mode==="full",r.projection.fields.some(y=>{let g=F(y);return g==="body"||ft.has(g)})].includes(!0);if([t.limit===void 0,t.after!==void 0,t.noTruncate===!0,t.includeBody===!0,t.dependencyBlocked===!0,t.strictRead===!0,n.treeEnabled,n.sortField!==void 0,o,Ee(),Object.keys(r.runtimeFieldFilters).length>0,Object.entries(t).some(([y,g])=>g!==void 0&&!s.has(y))].includes(!0))return null;let a=await R(r.pmRoot,[...new Set(Object.values(r.typeRegistry.type_to_folder))]);if(!a)return null;let l=N(t.limit),d=ne(t.offset)??0,c=await z({pmRoot:r.pmRoot,expectedSourceCursor:a.source_cursor,query:{statuses:i.resolvedStatus,excludeStatuses:i.resolvedStatus===void 0&&i.effectiveOptions.excludeTerminal===!0?[...r.statusRegistry.terminal_statuses]:void 0,terminalStatuses:[...r.statusRegistry.terminal_statuses],limit:l,offset:d}});if(!c)return null;let u=c.items.length>0&&d+c.items.length<c.total,p=u?$(Nt(i.filtersStatus,t,n,r.pmRoot),c.items.at(-1).id,d+c.items.length-1):void 0;return{projected:oe(c.items,r.projection,!1),totalMatched:c.total,pageExtras:Ot(l,u,p)}}function Pr(e){let{filtersStatus:t,options:r,noTruncate:i,treeEnabled:n,treeDepth:s,sortField:o,sortOrder:a,runtimeFieldFilters:l}=e,d={};t!==null&&(d.status=t),r.dependencyBlocked===!0&&(d.blocked_semantics="status_or_dependency");let c=r;for(let u of yr){let p=c[u.optionKey];p!=null&&(d[u.summaryKey]=p)}for(let u of gr)c[u.key]===!0&&(d[u.summaryKey]=!0);return Object.assign(d,_t(r),gt(r)),wt(d,r),i&&(d.no_truncate=!0),r.strictRead===!0&&(d.strict_read=!0),n&&(d.tree=!0,s!==void 0&&(d.tree_depth=s)),o!==void 0&&(d.sort=o,d.order=a),d.runtime_filters=l,d}async function qi(e,t,r){let i=await Dr(t,r),n=[],s=xr(t),o=Or(e,t,i.statusRegistry),a=t.noTruncate===!0,l=await Ur({options:t,runtime:i,statusSelection:o,ordering:s}),d=l;if(!d){let g=await Kr(t,i,n),_=s.treeEnabled||C(t.parent)!==void 0?$e(Ge(g,Be())):void 0;vr(g,t.tag,n);let b=Ct(g,o.resolvedStatus,o.effectiveOptions,i.typeRegistry,i.statusRegistry,i.runtimeFieldFilters,_?.parents_by_child),P=t.dependencyBlocked===!0?(()=>{let zt=je(g,i.statusRegistry);return b.filter(Ht=>zt.has(Ht.id.trim().toLowerCase()))})():b,de=kt(P,s.sortField,s.sortOrder,i.statusRegistry),$t=s.treeEnabled?Mt(de,s.parentRoot,s.treeDepth,_,g):de;d=Nr($t,t,i.projection,s.treeEnabled,Nt(o.filtersStatus,t,s,i.pmRoot))}let c=ye(),u=[...new Set(n)].sort((g,_)=>g.localeCompare(_)),p=dr(u,l!==null,t.strictRead===!0),y=i.projection.mode==="full"?null:[...i.projection.fields];if(i.projection.mode==="compact"&&t.compact===!0){let g=ht({filtersStatus:o.filtersStatus,options:t,treeEnabled:s.treeEnabled,treeDepth:s.treeDepth,sortField:s.sortField,sortOrder:s.sortOrder,runtimeFieldFilters:i.runtimeFieldFilters});return{items:d.projected,count:d.projected.length,total:d.totalMatched,...d.pageExtras,completeness:p,filters:g,projection:{mode:"compact",fields:y},...u.length>0?{warnings:u}:{}}}return{items:d.projected,count:d.projected.length,total:d.totalMatched,...d.pageExtras,completeness:p,filters:Pr({filtersStatus:o.filtersStatus,options:t,noTruncate:a,treeEnabled:s.treeEnabled,treeDepth:s.treeDepth,sortField:s.sortField,sortOrder:s.sortOrder,runtimeFieldFilters:i.runtimeFieldFilters}),projection:{mode:i.projection.mode,fields:y},sorting:{sort:s.sortField??"default",order:s.sortField?s.sortOrder:"asc",...s.sortField===void 0&&!s.treeEnabled?{effective_keys:[["status_registry:nonterminal_before_terminal","asc"],["priority","asc"],["updated_at","desc"],["id","asc"]]}:{}},now:c,...u.length>0?{warnings:u}:{}}}var Vi={applyFilters:Ct,buildCompactListFilterSummary:ht,buildContentFilterEcho:gt,buildGovernanceMissingFilterEcho:_t,resolveContentFieldFilters:re,resolveMissingMetadataFilters:mt,compareBySortField:Rt,compareDefaultSort:ie,compareNullableString:Lt,compareNullableTimestamp:At,normalizeProjectionField:F,parseAssigneeFilter:Et,parseFieldSelectors:vt,parseIdsFilter:St,parseOffset:ne,parseProjectionConfig:It,resolveListUpdatedAfter:bt,resolveListPageLimit:xt,parseSortField:se,parseSortOrder:Ft,orderItemsAsTree:Mt,projectListItems:oe,readListFieldValue:Dt,runtimeMetadataKeysForProjection:Kt,sortItems:kt,trimNonEmpty:C,withTreeMetadata:te};(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="eb2e6046-156c-56ee-a03a-ecaa1cccfb45")}catch{}})();function pn(e,t){let r=Se(e),i=e.length>0?e[e.length-1].after_hash:Fe(),n=t===void 0||r.item_hash_version===void 0?void 0:Ie(t,r.item_hash_version,pe(e.at(-1)?.hash_algorithm)),s=t===void 0?void 0:n===void 0?ve(t):n[Math.max(0,n.indexOf(i))],o=s===void 0?void 0:s===i,a=[...r.errors];return o===!1&&a.push("verify_failed:current_item_hash_mismatch"),{ok:a.length===0,entries:e.length,errors:a,latest_after_hash:e.length>0?e[e.length-1].after_hash:void 0,current_item_hash:s,current_matches_latest:o}}async function yn(e,t,r={}){let i=w(r.cwd??process.cwd(),r.pmRoot);await O(i);let n=await S(i),s=v(n,A()),o=await ze(i,e,n,s.type_to_folder),a=await be(o.historyPath,o.id);if(a.length===0)throw new f(`No history exists for ${o.id}; point-in-time reads are unavailable.`,m.NOT_FOUND);let l=Ke(t,a),d=Oe(xe(a,l.historyIndex),l),c=we(d,{schema:n.schema});if(c.metadata.id!==o.id)throw new f(`History target resolved to item ${c.metadata.id}, expected ${o.id}.`,m.GENERIC_FAILURE);let u=a[l.historyIndex],p=De(a,!0);return{document:c,reconstructed:!0,as_of_version:p===null?null:p+l.historyIndex+1,as_of_timestamp:u.ts,target:l,history_length:a.length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e524f0ad-faad-5d89-b8f5-1283979919ad")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="67d97df8-6551-52ed-9307-8b573a087831")}catch{}})();var U=1e6;function ae(e,t=U,r=.8,i=!1){let n=new Set,s=(c,u)=>{if(n.add(`${c}:${u}`),n.size>t)throw new f(`Duplicate sweep exceeded ${t} candidate pairs; narrow it with statuses or since.`,m.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the duplicate query or increase its similarity threshold. No partial result was returned."})};if(i||r===0){for(let c=0;c<e.length;c+=1)for(let u=0;u<c;u+=1)s(u,c);return n}let o=new Map;for(let{prepared:c}of e)for(let u of c.tokens)o.set(u,(o.get(u)??0)+1);let a=new Map,l=new Map,d=new Map;for(let[c,{prepared:u}]of e.entries()){let p=[...u.tokens].sort((_,b)=>o.get(_)-o.get(b)||_.localeCompare(b)),y=p.length-Math.ceil(r*p.length-1e-12)+1,g=[{index:a,keys:[u.normalized],lengthFilter:!1},{index:l,keys:r<=.99?u.issueCodes:[],lengthFilter:!1},{index:d,keys:p.length===0?[""]:p.slice(0,y),lengthFilter:!0}];for(let _ of g)jr(e,c,_,r,s)}return n}function jr(e,t,r,i,n){let s=e[t].prepared.tokens.length;for(let o of r.keys){let a=r.index.get(o)??[];for(let l of a){let d=e[l].prepared.tokens.length;r.lengthFilter&&Math.min(d,s)/Math.max(d,s)+1e-12<i||n(l,t)}a.push(t),r.index.set(o,a)}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a5f450bd-8970-5b1b-8250-b76b7818e6e1")}catch{}})();var Br=3,Ut=20,Gr=.8,$r=100,Pt=1e3;function Gn(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`,`likely_duplicate_recovery:${e.recovery.action}:${e.recovery.item_id}`]}async function zr(e,t){let r=e.items[0],i=w(t.cwd??process.cwd(),t.pmRoot),n=M((await S(i)).schema);return E(r.status,n)?{action:"reopen",item_id:r.id,command:`pm item reopen ${r.id} "<recurrence reason>"`,args:["item","reopen",r.id,"<recurrence reason>"]}:{action:"reuse",item_id:r.id,command:`pm get ${r.id} --full`,args:["get",r.id,"--full"]}}function le(e){let t=e.limit??Br,r=e.threshold??Gr;if(!Number.isSafeInteger(t)||t<0||t>Ut)throw new f(`Similarity limit must be an integer from 0 to ${Ut}.`,m.USAGE);if(!Number.isFinite(r)||r<0||r>1)throw new f("Similarity threshold must be a number from 0 to 1.",m.USAGE);return{limit:t,threshold:r}}function jt(e){let t=e.limit??$r;if(!Number.isSafeInteger(t)||t<0||t>Pt)throw new f(`Duplicate cluster limit must be an integer from 0 to ${Pt}.`,m.USAGE);let r=e.since===void 0?void 0:new Date(e.since);if(r&&Number.isNaN(r.getTime()))throw new f("Duplicate cluster --since must be a valid ISO timestamp.",m.USAGE);return{limit:t,since:r}}async function Hr(e,t){let r=w(e.cwd??process.cwd(),e.pmRoot),i=await S(r),n=v(i),s=e.statuses?.map(u=>u.trim().toLowerCase()).filter(Boolean);if(e.statuses!==void 0&&s?.length===0)throw new f("Duplicate cluster statuses must include at least one lifecycle status or all.",m.USAGE);let o=M(i.schema),a=s?.map(u=>{if(u==="all")return u;let p=he(u,o);if(!p)throw new f(`Unknown duplicate-cluster status "${u}". Allowed: all, ${o.definitions.map(y=>y.id).join(", ")}.`,m.USAGE);return p}),l=a?.includes("all")===!0;if(l&&a?.some(u=>u!=="all"))throw new f('The "all" status cannot be combined with other statuses.',m.USAGE);let d=l?void 0:a,c=d?new Set(d):void 0;return{items:(await k(r,i.item_format,n.type_to_folder,void 0,i.schema)).filter(u=>(!c||c.has(u.status))&&(!t||new Date(u.created_at).getTime()>=t.getTime())),statuses:d}}var $n={buildDuplicateClusters:Gt,collectDuplicateCandidatePairs:ae,createDuplicateUnionFind:Bt};function Bt(e){let t=Array.from({length:e},(r,i)=>i);return{parent:t,findRoot:r=>{let i=r;for(;t[i]!==i;)i=t[i];for(;t[r]!==r;){let n=t[r];t[r]=i,r=n}return i}}}function qr(e,t,r,i){let n=[];for(let s of t){let[o,a]=s.split(":").map(u=>Number.parseInt(u,10)),l=X(e[o].prepared,e[a].prepared);if(l.score<r)continue;let d=i.findRoot(o),c=i.findRoot(a);d!==c&&(i.parent[c]=d),n.push({left_id:e[o].item.id,right_id:e[a].item.id,...l})}return n}function Gt(e,t,r,i){let n=new Map;for(let a of e.keys()){let l=r.findRoot(a),d=n.get(l)??[];d.push(a),n.set(l,d)}let s=new Map(e.map(({item:a},l)=>[a.id,r.findRoot(l)])),o=new Map;for(let a of t){let l=s.get(a.left_id),d=o.get(l)??[];d.push(a),o.set(l,d)}return[...n.values()].filter(a=>a.length>1).map(a=>{let l=(o.get(r.findRoot(a[0]))??[]).sort((d,c)=>c.score-d.score||d.left_id.localeCompare(c.left_id)||d.right_id.localeCompare(c.right_id));return{id:e[a[0]].item.id,items:a.map(d=>{let c=e[d].item;return{id:c.id,title:c.title,status:c.status,type:c.type}}),matches:l,max_score:l[0]?.score??0}}).sort((a,l)=>l.max_score-a.max_score||a.id.localeCompare(l.id)).slice(0,i)}function Vr(e,t,r,i,n){return t.filter(s=>!r.has(s.id)).map(s=>({id:s.id,title:s.title,status:s.status,type:s.type,...W(e,s.title)})).filter(s=>s.score>=i).sort((s,o)=>o.score-s.score||s.id.localeCompare(o.id)).slice(0,n)}async function Wr(e,t={}){let r=e.title.trim();if(r.length===0)throw new f("Similarity candidate title must not be empty.",m.USAGE);let{limit:i,threshold:n}=le(t),s=w(t.cwd??process.cwd(),t.pmRoot),o=await S(s),a=v(o),l=await R(s,Object.values(a.type_to_folder)),d=q(r),c=l&&d.length>0?await H({pmRoot:s,expectedSourceCursor:l.source_cursor,query:d.map(y=>`"${y.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(i*10,50)}):null,u=c===null?await k(s,o.item_format,a.type_to_folder,void 0,o.schema):c.items,p=Vr(r,u,new Set(e.excludeIds??[]),n,i);return{items:p,count:p.length,threshold:n,source:c?"persistent_index":"metadata_fallback"}}function Xr(e,t={}){let{threshold:r}=le({...t,limit:void 0}),{limit:i}=jt(t),n=new Set;for(let c of e){if(!c.id.trim()||n.has(c.id))throw new f("Duplicate analysis requires unique non-empty item ids.",m.USAGE);n.add(c.id)}let s=[...e].sort((c,u)=>c.id.localeCompare(u.id)).map(c=>({item:c,prepared:V(c.title)})),o=ae(s,U,r,t.exhaustive===!0),a=Bt(s.length),l=qr(s,o,r,a),d=Gt(s,l,a,i);return{clusters:d,count:d.length,threshold:r,cost:{item_count:s.length,algorithm:t.exhaustive===!0||r===0?"exhaustive":"prefix_exact",possible_pairs:s.length*(s.length-1)/2,pair_limit:U,recall_guarantee:"exact",candidate_pairs:o.size,scored_pairs:o.size}}}async function zn(e={}){le({...e,limit:void 0});let{since:t}=jt(e),{items:r,statuses:i}=await Hr(e,t);return{...Xr(r,e),source:"metadata_scan",filters:{statuses:i??null,since:e.since??null}}}async function Hn(e,t){if(t.mode==="off")return;let r=await Wr(e,t);if(r.count===0)return;let i=await zr(r,t),n=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!n){let s=r.items.map(a=>`${a.id} (${a.status}): ${a.title}`).join("; "),o=i.action==="reopen"?"Reopen the canonical item":"Reuse the canonical item";throw new f(`Likely duplicate item(s) found: ${s}. ${o} or pass --allow-duplicate with explicit intent.`,m.CONFLICT,{code:"likely_duplicate",required:`${o}, or explicitly acknowledge the duplicate with --allow-duplicate.`,recovery:{suggested_flags:["--allow-duplicate"],suggested_retry:i.command,suggested_retry_args:i.args}})}return{mode:t.mode,bypassed:n,result:r,recovery:i}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f091d0c3-f2a7-5d76-8656-4aebe82e9798")}catch{}})();function Vn(e,t){let r=t??{};return e.filter(i=>r[i.id]!==i.updated_at).map(i=>i.id).sort((i,n)=>i.localeCompare(n))}export{N as a,He as b,ti as c,Y as d,D as e,qe as f,Ve as g,Je as h,Z as i,et as j,di as k,ci as l,it as m,nt as n,mi as o,mt as p,re as q,lt as r,dt as s,fr as t,gt as u,_t as v,qi as w,Vi as x,pn as y,yn as z,Gn as A,$n as B,Wr as C,Xr as D,zn as E,Hn as F,Vn as G};
2
- //# sourceMappingURL=chunk-4KTFKSS3.js.map