@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
@@ -0,0 +1,5 @@
1
+ import{c as A}from"./chunk-FDZPRJXJ.js";import{x as _}from"./chunk-SMMOZ3H3.js";import{C as d,H as x,d as g}from"./chunk-RIQUIHYU.js";import{A as u,C as m,z as l}from"./chunk-A6VEMCRR.js";import k from"node:fs/promises";import p from"node:path";var $=["extensions","docs","examples","assets","prompts"],N=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function L(e){return $.includes(e)}function P(e,t){if(t==null)return[];let r=Array.isArray(t)?t:[t],n=[];for(let s of r){if(typeof s!="string"||s.trim().length===0)throw new u(`Package manifest field pm.${e} must contain string paths.`,l.USAGE);n.push(s.trim())}return[...new Set(n)].sort((s,i)=>s.localeCompare(i))}function w(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new u("Package manifest field pm must be an object.",l.USAGE);let t={},r=e;for(let[n,s]of Object.entries(r)){if(!L(n))continue;let i=P(n,s);i.length>0&&(t[n]=i)}return t}function a(e,t){let r=e[t];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}function y(e){if(!Array.isArray(e))return;let t=e.map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0);return t.length>0?[...new Set(t)].sort((r,n)=>r.localeCompare(n)):void 0}function v(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function O(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={docs:a(t,"docs"),npm:a(t,"npm"),repository:a(t,"repository"),report:a(t,"report")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function C(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={image:a(t,"image"),video:a(t,"video")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function M(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={display_name:a(t,"display_name")??a(t,"displayName"),category:a(t,"category"),summary:a(t,"summary"),links:O(t.links),media:C(t.media),tags:y(t.tags)};return Object.values(r).some(n=>n!==void 0)?r:void 0}async function z(e){let t=p.join(e,"package.json");if(!await m(t))return{source:"convention",resources:{}};let r;try{r=JSON.parse(await k.readFile(t,"utf8"))}catch(f){throw new u(`Failed to parse package manifest at "${t}": ${String(f)}`,l.USAGE)}if(typeof r!="object"||r===null||Array.isArray(r))throw new u(`Package manifest at "${t}" must be a JSON object.`,l.USAGE);let n=r,s=n.pm,i=s!=null,o=typeof s=="object"&&s!==null&&!Array.isArray(s)?s:{};return{source:i?"pm":"convention",package_json_path:t,package_name:typeof n.name=="string"?n.name:void 0,package_version:typeof n.version=="string"?n.version:void 0,package_private:n.private===!0,package_description:typeof n.description=="string"?n.description:void 0,package_keywords:y(n.keywords),package_homepage:typeof n.homepage=="string"?n.homepage:void 0,package_repository_url:v(n.repository),package_bugs_url:v(n.bugs),aliases:y(o.aliases),resources:w(s),catalog:M(o.catalog)}}async function b(e){if(!await m(e))return[];let t=await k.readdir(e,{withFileTypes:!0}),r=[];for(let n of t){if(!n.isDirectory())continue;let s=p.join(e,n.name);await m(p.join(s,"manifest.json"))&&r.push(s)}return r.sort((n,s)=>n.localeCompare(s))}async function Z(e){if(await m(p.join(e,"manifest.json")))return[e];let r=(await z(e)).resources.extensions??[],n=new Set;for(let s of r){if(s.includes("*")||s.startsWith("!"))throw new u(`Package extension entry "${s}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,l.USAGE);let i=p.resolve(e,s);if(!_(e,i))throw new u(`Package extension entry "${s}" resolves outside package root.`,l.USAGE);if(await m(p.join(i,"manifest.json"))){n.add(i);continue}for(let o of await b(i))n.add(o)}if(r.length===0)for(let s of N.extensions)for(let i of await b(p.join(e,s)))n.add(i);return[...n].sort((s,i)=>s.localeCompare(i))}var j=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["assurance_providers","Assurance measurement providers"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function E(e){return"#".repeat(e)}function I(e){if(!e.includes("`"))return`\`${e}\``;let t=0,r=0;for(let i of e)r=i==="`"?r+1:0,t=Math.max(t,r);let n="`".repeat(t+1),s=e.startsWith("`")||e.endsWith("`")?" ":"";return`${n}${s}${e}${s}${n}`}function D(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(I).join(", ")}`}function U(e,t,r){let n=[`${E(t)} ${e}`,""];return r.length===0?(n.push("_None._",""),n):(n.push(...r.map(s=>`- ${I(s)}`),""),n)}function R(e,t,r){return e===0&&!r?[]:[`${E(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function te(e,t={}){let r=t.headingLevel??2;if(!Number.isInteger(r)||r<1||r>6)throw new RangeError(`headingLevel must be an integer in [1, 6], received ${String(t.headingLevel)}`);let n=Math.min(r+1,6),s=t.includeEmpty===!0,i=t.title??"Extension surfaces",o=[`${E(r)} ${i}`,""];(s||e.capabilities.length>0)&&o.push(D(e.capabilities),"");for(let[c,T]of j){let S=e[c]??[];S.length===0&&!s||o.push(...U(T,n,S))}return o.push(...R(e.preflight_overrides,n,s)),!(e.preflight_overrides>0||j.some(([c])=>(e[c]?.length??0)>0))&&!s&&o.push("_This extension registers no surfaces._",""),`${o.join(`
2
+ `).trimEnd()}
3
+ `}var G=["agile","ops","research"],F={agile:[{name:"Story",description:"User-facing outcome or capability slice expressed from a stakeholder perspective.",defaultStatus:"open",folder:"stories",aliases:["user-story"]},{name:"Spike",description:"Time-boxed investigation used to reduce uncertainty before implementation.",defaultStatus:"open",folder:"spikes",aliases:["research-spike"]}],ops:[{name:"Incident",description:"Operational disruption, degradation, or support escalation with recovery tracking.",defaultStatus:"open",folder:"incidents",aliases:["outage"]},{name:"Runbook",description:"Repeatable operational procedure, diagnostic path, or response playbook.",defaultStatus:"open",folder:"runbooks",aliases:["playbook"]}],research:[{name:"Experiment",description:"Validated-learning activity with hypothesis, method, and outcome tracking.",defaultStatus:"open",folder:"experiments",aliases:["study"]},{name:"Hypothesis",description:"Testable claim or assumption that should be supported, rejected, or refined.",defaultStatus:"open",folder:"hypotheses",aliases:["assumption"]}]};function se(e){if(e===void 0)return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length===0)throw new Error("Type preset name must not be empty.");if(t==="agile"||t==="ops"||t==="research")return t;throw new Error(`Invalid type preset "${e}". Allowed: ${G.join(", ")}.`)}function ie(e){return F[e].map(t=>A(t))}var V=new Set(g),h=new Set(x.map(e=>d(e.id)).filter(e=>e.length>0));function H(e){let t=new Set;for(let r of e){let n=d(r);n.length>0&&t.add(n)}return[...t].sort((r,n)=>r.localeCompare(n))}function fe(e){let t=d(e.id);if(t.length===0)throw new Error("Status id must not be empty.");if(h.has(t))throw new Error(`Cannot add-status the built-in status "${t}". Built-in statuses are reserved: ${[...h].join(", ")}.`);let r;if(e.roles!==void 0){r=[];let o=new Set;for(let f of e.roles){let c=typeof f=="string"?f.trim().toLowerCase():"";if(c.length!==0){if(!V.has(c))throw new Error(`Invalid status role "${f}". Allowed roles: ${g.join(", ")}.`);o.has(c)||(o.add(c),r.push(c))}}if(r.length===0)throw new Error(`Status role must include at least one lifecycle role. Allowed roles: ${g.join(", ")}.`)}let n=e.aliases===void 0?void 0:H(e.aliases).filter(o=>o!==t),s=e.description?.trim(),i=typeof e.order=="number"&&Number.isFinite(e.order)?Math.trunc(e.order):void 0;return{id:t,roles:r,aliases:n,description:s&&s.length>0?s:void 0,order:i}}function J(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function K(e){let t=J(e);if(!t)return[];let r=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let s=n;typeof s.id!="string"||s.id.trim().length===0||r.push(s)}return r}function le(e){if(e==null||e.trim().length===0)return{statuses:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/statuses.json contains invalid JSON.")}return{statuses:K(t)}}function ue(e){return`${JSON.stringify({statuses:e.statuses},null,2)}
4
+ `}function pe(e,t,r){let n=e.statuses.slice(),s=n.findIndex(f=>d(f.id)===t.id),i=s>=0?n[s]:r,o={...i,id:t.id};return t.roles!==void 0&&(t.roles.length>0?o.roles=[...t.roles]:o.roles!==void 0&&delete o.roles),t.aliases!==void 0&&(t.aliases.length>0?o.aliases=[...t.aliases]:o.aliases!==void 0&&delete o.aliases),t.description!==void 0&&(o.description=t.description),t.order!==void 0&&(o.order=t.order),s>=0?n[s]=o:n.push(o),{file:{statuses:n},definition:o,replaced:i!==void 0}}function me(e,t){let r=d(t);if(r.length===0)throw new Error("Status id must not be empty.");if(h.has(r))throw new Error(`Cannot remove built-in status "${r}". Built-in statuses are reserved: ${[...h].join(", ")}.`);let n=e.statuses.slice(),s=n.findIndex(o=>d(o.id)===r);if(s<0)return{file:{statuses:n},removed:!1};let[i]=n.splice(s,1);return{file:{statuses:n},removed:!0,definition:i}}function ge(e,t){let r=[e.id,...e.aliases??[]];for(let n of r){let s=d(n);if(s.length===0)continue;let i=t.get(s);if(i!==void 0&&i!==e.id)throw new Error(`Status token "${s}" already belongs to status "${i}". Choose a different id/alias to avoid shadowing it.`)}}export{$ as a,N as b,z as c,Z as d,G as e,F as f,se as g,ie as h,h as i,fe as j,le as k,ue as l,pe as m,me as n,ge as o,te as p};
5
+ //# sourceMappingURL=chunk-46MP7IZN.js.map
@@ -0,0 +1,91 @@
1
+ import{e as zt,n as Xt,v as Gt,x as ye}from"./chunk-HL47UQZJ.js";import{$ as je,$c as me,Ab as At,Ad as He,Bd as We,Fc as jt,Lc as Lt,M as bt,Mb as Dt,N as It,Q as Ct,Rc as Q,Rd as Be,Sd as ze,Tb as K,Td as Ht,Ub as Ft,Ud as Xe,V as fe,Vb as J,Vd as Wt,X as xt,Zc as Ue,_ as Pe,_c as $t,a as ue,aa as R,dc as Mt,ec as Pt,g as gt,ha as vt,id as Ut,je as Z,la as St,le as Ge,ma as Rt,me as pe,ne as $,qe as Ye,rb as Ot,re as he,se as Bt,te as qe,we as Ve,zb as $e}from"./chunk-SMMOZ3H3.js";import{B as V,J as kt,s as Nt,t as Le}from"./chunk-3Z7MCUJM.js";import{B as Tt}from"./chunk-RIQUIHYU.js";import{A as f,B as Et,C as G,E as L,I as A,m as wt,t as j,y as Me,z as m}from"./chunk-A6VEMCRR.js";var U=new Set(wt),_e=Object.freeze({get size(){return U.size},has(e){return U.has(e)},entries(){return U.entries()},keys(){return U.keys()},values(){return U.values()},forEach(e,t){U.forEach(n=>e.call(t,n,n,_e))},[Symbol.iterator](){return U.values()}});function Yt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function qt(e){return typeof e!="string"?null:gt(e)}function Gn(e){try{return structuredClone(e)}catch{return e}}function Yn(e){let t=e.trim(),n=t.indexOf("=");if(n<=0)throw new f(`--field entries must use name=value syntax, received: ${e}`,m.USAGE);let r=t.slice(0,n).trim(),i=t.slice(n+1);return{key:r,value:i}}function qn(e,t,n){try{let r=JSON.parse(e);if(n==="array"&&Array.isArray(r)||n==="object"&&typeof r=="object"&&r!==null&&!Array.isArray(r))return r}catch{}throw new f(`--field ${t}=... must be valid JSON ${n}`,m.USAGE)}function Vn(e,t,n){if(t==="string")return n;if(t==="number"){let r=n.trim();if(r.length===0)throw new f(`--field ${e}=... must be a number`,m.USAGE);let i=Number(r);if(!Number.isFinite(i))throw new f(`--field ${e}=... must be a number`,m.USAGE);return i}if(t==="boolean"){let r=n.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes")return!0;if(r==="false"||r==="0"||r==="no")return!1;throw new f(`--field ${e}=... must be one of true|false|1|0|yes|no`,m.USAGE)}return t==="string_array"?n.split(/[\n,|]/u).map(r=>r.trim()).filter(r=>r.length>0):qn(n,e,t)}function Ke(e){let t=new Map;if(!e)return t;for(let n of e.item_fields)for(let r of n.fields){let i=Yt(r.name),o=qt(r.type);if(!i||!o)continue;let s=t.get(i);if(s&&s.type!==o)throw new f(`Extension item field "${i}" is declared with conflicting types: ${s.type}, ${o}`,m.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(i,{name:i,type:o})}return t}function Vt(e){if(_e.has(e))throw new f(`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,n)=>t.localeCompare(n)).join(", ")}.`,m.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function ge(e){return[...Ke(e).keys()].sort((t,n)=>t.localeCompare(n))}function Xi(e,t,n,r){if(!e||e.length===0)return{};let i=Ke(t),o={};for(let s of e){let{key:a,value:d}=Yn(s),c=i.get(a);if(!c)throw Kn(a,i,n,r);Vt(c.name),o[c.name]=Vn(c.name,c.type,d)}return o}function Kn(e,t,n,r){if(_e.has(e)){let s=n?.(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 f(`--field ${e} is a core item field, not an extension field`,m.USAGE,{code:"core_item_field_requires_dedicated_flag",field:e,...s})}let i=r?.(e);if(i!==void 0){let s=i.recovery?.suggested_flags?.[0];return new f(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}`,m.USAGE,{code:"project_schema_field_requires_declared_flag",field:e,changed:!1,...i})}let o=[...t.keys()].sort((s,a)=>s.localeCompare(a));return new f(`--field ${e} is not declared by an active extension item-field registration`,m.USAGE,{code:"extension_item_field_unknown",field:e,recovery:{provided_fields:[e]},nextSteps:o.length>0?[`Use one of the declared fields: ${o.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}function Jn(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(n=>typeof n=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function Qn(e,t){return!t||t.length===0?!0:t.some(n=>Object.is(n,e))}function Gi(e,t,n={}){if(t){Ke(t);for(let r of t.item_fields)for(let i of r.fields){let o=Yt(i.name);if(!o)continue;Vt(o),!(o in e)&&!n.skipDefaultFields?.has(o)&&Object.prototype.hasOwnProperty.call(i,"default")&&(e[o]=Gn(i.default));let s=e[o];if(s===void 0)continue;let a=qt(i.type);if(a&&!Jn(s,a))throw new TypeError(`Item field "${o}" must be of type ${a}`);let d=Array.isArray(i.values)?i.values:void 0;if(!Qn(s,d))throw new TypeError(`Item field "${o}" must match one of the configured allowed values`)}}}import Zn from"node:crypto";import we from"node:path";function Jt(e){let t=[],n=!1;for(let r of(e??"").toLowerCase()){let i=r.charCodeAt(0),o=i>=48&&i<=57,s=i>=97&&i<=122;if(!o&&!s){n=t.length>0;continue}n&&(t.push("-"),n=!1),t.push(r)}return t.length===0?"pm-":`${t.join("")}-`}function ee(e){let t=e.trim().toLowerCase();return t.startsWith("#")&&(t=t.slice(1)),t}function te(e,t){let n=Jt(t),r=ee(e);return r.startsWith(n)?r:`${n}${r}`}function er(e){let t=Nt(e);if(t!==void 0)return t;let n="";for(let r=0;r<e;r+=1)n+=Zn.randomInt(0,36).toString(36);return n}async function tr(e,t,n){let r=[...new Set(Object.values(n))].flatMap(i=>[we.join(e,i,`${t}.md`),we.join(e,i,`${t}.toon`)]);return r.push(we.join(e,"history",`${t}.jsonl`)),(await Promise.all(r.map(i=>G(i)))).some(Boolean)}var Kt=4,Qt=12;function nr(e){return typeof e!="number"||!Number.isFinite(e)?Kt:Math.min(Qt,Math.max(Kt,Math.trunc(e)))}async function Zi(e,t,n={}){let r=nr(n.tokenLength),i=Math.min(r+6,Qt),o=0;for(;r<=i;){for(let s=0;s<32;s+=1){let a=`${Jt(t)}${er(r)}`;if(!await(n.probeExisting===!1?G(we.join(e,"history",`${a}.jsonl`)):tr(e,a,n.typeToFolder??j)))return a;o+=1}r+=1}throw new Error(`Unable to generate unique id after ${o} attempts`)}function ne(e,t=!1){let n=e[0];if(n?.op!=="history_compact_baseline")return 0;let r=n.context?.history_compaction,i=typeof r=="object"&&r!==null&&"version_offset"in r?r.version_offset:void 0;if(typeof i=="number"&&Number.isSafeInteger(i)&&i>=0&&Number.isSafeInteger(i+e.length))return i;if(t)return null;throw new f("This compacted stream has no trustworthy version offset; numeric history addresses are unavailable.",m.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 re from"node:path";import{isUtf8 as rr}from"node:buffer";var ir=1048576,or=4194304;async function en(e,t){let n=re.dirname(e);for(;n!==re.parse(e).root;){let i=await Zt.stat(n).catch(o=>{if(L(o))return null;throw o});if(i!==null){if(!i.isDirectory())throw new f("Workflow policy storage ancestor must be a directory.",m.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Restore the policy or approval history directory before retrying."]});break}n=re.dirname(n)}let r=await Zt.open(e,"r").catch(i=>{if(L(i))return null;throw i});if(r===null)return null;try{let i=(await r.stat()).size,o=Buffer.alloc(Math.min(t,i)+1),s=0;for(;s<o.length;){let a=await r.read(o,s,o.length-s,s);if(a.bytesRead===0)break;s+=a.bytesRead}if(s===o.length||!rr(o.subarray(0,s)))throw new f("Workflow policy input exceeds its byte bound or is not valid UTF-8.",m.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Inspect the policy and approval history; reduce the declaration or use verified history compaction before retrying."]});return o.toString("utf8",0,s)}finally{await r.close()}}function sr(e){if(e===null)return{version:1,enforcement:"advise",policies:[]};let t;try{t=JSON.parse(e)}catch{throw new f("schema/policies.json must contain valid JSON.",m.CONFLICT,{code:"workflow_policy_registry_invalid",nextSteps:["Restore valid policy JSON before retrying the mutation."]})}return vt(t)}async function ar(e){return sr(await en(re.join(e,"schema","policies.json"),ir))}async function cr(e,t){let n=await en(R(e,t),or);if(n===null)return[];let r;try{if(r=n.split(/\r?\n/).filter(i=>i.trim()).map(i=>JSON.parse(i)),!me(r).ok)throw new Error("invalid chain")}catch{throw new f("Approval evidence requires a valid item history chain.",m.CONFLICT,{code:"workflow_policy_approval_history_invalid",nextSteps:[`Run pm history ${t} --verify before recording or using an approval.`]})}return r.flatMap(i=>{let o=i.context?.workflow_approval;if(i.op!=="policy_approve"||i.record_hash_version!==1||typeof i.record_hash!="string"||typeof o!="object"||o===null)return[];let s=o;return typeof s.policy_fingerprint!="string"||typeof s.content_fingerprint!="string"?[]:[{policy_fingerprint:s.policy_fingerprint,content_fingerprint:s.content_fingerprint,author:i.author}]})}async function dr(e,t,n){let r=n.before?.status!==n.after?.status&&t.policies.some(s=>s.rule.kind==="approval"&&St(s,n)),i=n.before?.id??n.after?.id,o=r&&typeof i=="string"?await cr(e,i):[];return Rt(t,{...n,approvals:o})}function lr(e,t){if(e.dryRun===!0)return!1;let n=Ht(e.pmRoot,[e.before?.metadata.id,e.after?.metadata.id],e.operation);return n===void 0?!1:(n.overrides.push(...t.map(r=>({source:"workflow_policy",policy_id:r.policy_id,rule:r.rule}))),!0)}async function Je(e){let t=await ar(e.pmRoot),n=await dr(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(n.allowed)return n;let r=n.decisions.filter(i=>!i.satisfied&&i.effect==="refuse");return lr(e,r)?n:ur(e,t,n,r)}async function ur(e,t,n,r){let i=[],o="";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:n.decisions},message:"Workflow policy refused a proposed item mutation.",lockTtlSeconds:e.settings.locks.ttl_seconds,lockWaitMs:e.settings.locks.wait_ms});i.push({path:"history/_workspace.jsonl",op:"policy_refused",record_hash:l.entry.record_hash}),o=" 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 f("Workflow policy refusal could not be recorded in workspace history.",m.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=r.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=r.length>3?` and ${r.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=bt("update",l);return h===void 0?`Supply ${l} using its declared SDK or package mutation contract, then retry.`:V(["update",p,It("update",h),`<${l}>`,"--pm-path",re.resolve(e.pmRoot)])});throw new f(`Workflow policy refused ${e.operation}: ${d}${c}.${a.length?` Missing: ${a.join(", ")}.`:""}${o}`,m.CONFLICT,{code:"workflow_policy_refused",side_effects:i,reason:s.map(l=>l.policy_id).join(","),policy_violations:s,policy_violation_count:r.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(r.slice(0,3).filter(l=>l.missing_fields.length===0).map(l=>l.remediation)),...r.length>3?[`Inspect all policies with pm schema policies before retrying ${e.operation}.`]:[]]})}import{AsyncLocalStorage as fr}from"node:async_hooks";import{channel as mr}from"node:diagnostics_channel";var Qe=new fr,Ze=mr("@unbrained/pm-cli/item-metadata-enumeration/v1");function Ee(e){Ze.publish(e)}async function bo(e){let t={enumeration_calls:0,metadata_rows:0},n=r=>{Qe.getStore()?.includes(t)&&(t.enumeration_calls+=1,t.metadata_rows+=r)};Ze.subscribe(n);try{return{result:await Qe.run([...Qe.getStore()??[],t],e),work:{...t}}}finally{Ze.unsubscribe(n)}}import H from"node:fs/promises";import nn from"node:path";import{randomUUID as pr}from"node:crypto";import{createRequire as hr}from"node:module";var yr="metadata-query-index.sqlite",ie="5",be;function oe(){return be!==void 0||(be=Ut(process.versions.node,hr(import.meta.url))),be}function tn(e,t){return Math.max(0,Math.floor(e===void 0?t:e))}function Y(e){return nn.join(e,"runtime",yr)}function _r(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 Ce(e,t,n){e.prepare("INSERT INTO metadata(key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(t,n)}function rn(e,t){let n=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(n.id,t.relativePath,JSON.stringify(n),n.status,n.type,n.priority,n.updated_at,n.created_at,n.parent??null,n.assignee??null,n.sprint??null,n.release??null),e.prepare("DELETE FROM item_metadata_keys WHERE item_id = ?").run(n.id),e.prepare("DELETE FROM item_linked_files WHERE item_id = ?").run(n.id),e.prepare("DELETE FROM item_search WHERE rowid = (SELECT rowid FROM items WHERE id = ?)").run(n.id),e.prepare("INSERT INTO item_search(rowid, id, title, description, tags) SELECT rowid, ?, ?, ?, ? FROM items WHERE id = ?").run(n.id,n.title,n.description,n.tags.join(" "),n.id);let r=e.prepare("INSERT INTO item_metadata_keys(item_id, key) VALUES (?, ?)");for(let o of Object.keys(n))r.run(n.id,o);let i=e.prepare("INSERT INTO item_linked_files(item_id, path, scope, note) VALUES (?, ?, ?, ?)");for(let o of t.linkedFiles??[])i.run(n.id,o.path,o.scope,o.note??null)}async function on(e){let t=Y(e.pmRoot),n=oe();if(!n){await H.rm(t,{force:!0});return}await H.mkdir(nn.dirname(t),{recursive:!0});let r=`${t}.${pr()}.tmp`,i;try{i=new n(r),_r(i),i.exec("BEGIN IMMEDIATE"),Ce(i,"version",ie),Ce(i,"context_fingerprint",e.contextFingerprint),Ce(i,"source_cursor",e.sourceCursor);for(let o of e.rows)rn(i,o);i.exec("COMMIT"),i.close(),i=void 0,await H.rm(t,{force:!0}),await H.rename(r,t)}catch(o){throw i?.close(),await Promise.allSettled([H.rm(r,{force:!0})]),o}}function xe(e){return Object.fromEntries(e.prepare("SELECT key, value FROM metadata").all().map(t=>[String(t.key),String(t.value)]))}async function sn(e){let t=oe();if(!t)return!1;let n=Y(e.pmRoot),r;try{await H.access(n),r=new t(n),r.exec("PRAGMA foreign_keys = ON");let i=xe(r);if(i.version!==ie||i.context_fingerprint!==e.contextFingerprint||i.source_cursor!==e.expectedSourceCursor)return r.close(),!1;r.exec("BEGIN IMMEDIATE");let o=r.prepare("DELETE FROM items WHERE relative_path = ?"),s=r.prepare("SELECT rowid FROM items WHERE relative_path = ?"),a=r.prepare("DELETE FROM item_search WHERE rowid = ?");for(let d of e.deletedRelativePaths??[]){let c=s.get(d);o.run(d),c&&a.run(c.rowid)}return e.row&&rn(r,e.row),Ce(r,"source_cursor",e.sourceCursor),r.exec("COMMIT"),r.close(),!0}catch{try{r?.exec("ROLLBACK")}catch{}return r?.close(),!1}}function Ie(e,t,n,r,i){!r||r.length===0||(e.push(`${n} ${i} (${r.map(()=>"?").join(", ")})`),t.push(...r))}function gr(e){let t=[],n=[];Ie(t,n,"status",e.statuses,"IN"),Ie(t,n,"status",e.excludeStatuses,"NOT IN"),Ie(t,n,"type",e.types,"IN"),Ie(t,n,"id",e.ids,"IN");for(let r 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 = ?)"),n.push(r);for(let[r,i]of[["parent",e.parent],["assignee",e.assignee],["sprint",e.sprint],["release",e.release]])i!==void 0&&(t.push(`${r} = ?`),n.push(i));return e.priority!==void 0&&(t.push("priority = ?"),n.push(e.priority)),{where:t.length===0?"":` WHERE ${t.join(" AND ")}`,parameters:n}}async function Oo(e){let t=oe();if(!t)return null;let n=e.query??{},{where:r,parameters:i}=gr(n),o;try{o=new t(Y(e.pmRoot),{readOnly:!0});let s=xe(o);if(s.version!==ie||s.source_cursor!==e.expectedSourceCursor)return o.close(),null;let a=o.prepare(`SELECT COUNT(*) AS count FROM items${r}`).get(...i),d=[],c="";n.limit!==void 0?(c+=" LIMIT ?",d.push(Math.max(0,Math.floor(n.limit))),n.offset!==void 0&&(c+=" OFFSET ?",d.push(Math.max(0,Math.floor(n.offset))))):n.offset!==void 0&&(c+=" LIMIT -1 OFFSET ?",d.push(Math.max(0,Math.floor(n.offset))));let u=o.prepare(`SELECT metadata_json FROM items${r}
72
+ ORDER BY ${n.terminalStatuses&&n.terminalStatuses.length>0?`CASE WHEN status IN (${n.terminalStatuses.map(()=>"?").join(", ")}) THEN 1 ELSE 0 END ASC, `:""}priority ASC, updated_at DESC, id ASC${c}`).all(...i,...n.terminalStatuses??[],...d).map(l=>{let h=JSON.parse(String(l.metadata_json));if(!h.id)throw new TypeError("Indexed metadata row has no id");return h});return o.close(),{source_cursor:s.source_cursor,total:Number(a.count),items:u}}catch{return o?.close(),null}}async function No(e){let t=oe();if(!t||e.paths.length===0)return null;let n;try{n=new t(Y(e.pmRoot),{readOnly:!0});let r=xe(n);if(r.version!==ie||r.source_cursor!==e.expectedSourceCursor)return n.close(),null;let i=e.paths.map(()=>"?").join(", "),o=e.scope===void 0?"":" AND scope = ?",s=[...e.paths,...e.scope===void 0?[]:[e.scope]],a=`path IN (${i})${o}`,d=n.prepare(`SELECT COUNT(DISTINCT item_id) AS count
73
+ FROM item_linked_files
74
+ WHERE ${a}`).get(...s),c=tn(e.limit,50),p=tn(e.offset,0),u=n.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=n.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),w=new Map(h.map(_=>[_,[]]));for(let _ of y){let E=String(_.item_id),x=w.get(E);x.push({path:String(_.path),scope:String(_.scope),..._.note===null?{}:{note:String(_.note)}}),w.set(E,x)}for(let _ of u){let E=JSON.parse(String(_.metadata_json));l.push({item:E,files:w.get(String(_.id))})}}return n.close(),{source_cursor:r.source_cursor,total:Number(d.count),matches:l}}catch{return n?.close(),null}}async function ko(e){let t=oe();if(!t)return null;let n;try{n=new t(Y(e.pmRoot),{readOnly:!0});let r=xe(n);if(r.version!==ie||r.source_cursor!==e.expectedSourceCursor)return n.close(),null;let o=n.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(s=>JSON.parse(String(s.metadata_json)));return n.close(),{source_cursor:r.source_cursor,items:o}}catch{return n?.close(),null}}async function ve(e){await H.rm(Y(e),{force:!0})}import b from"node:fs/promises";import g from"node:path";import{createHash as wr,randomUUID as un}from"node:crypto";var T=8,fn=500,Er="metadata-derived-index",br="metadata-cache.json",Ir="metadata-cache-bodies.json",Cr="metadata-cache-collections.json",xr="metadata-cache-delta.json",vr="metadata-cache-manifest.json",an=4,Sr=["comments","notes","learnings","files","tests","test_runs","docs"];function mn(){return ge(Z())}function Re(e){let t={...e},n={};for(let r of Sr)r in t&&(n[r]=t[r],delete t[r]);return{light:t,heavy:n}}function pn(e,t){return!t||Object.keys(t).length===0?e:{...e,...t}}function hn(e,t,n,r){let i=wr("sha256");i.update(`format:${e??"default"}`);let o=Object.entries(t).sort(([s],[a])=>s.localeCompare(a)).map(([s,a])=>`${s}=${a}`).join(",");return i.update(`|types:${o}`),n&&i.update(`|schema:${JSON.stringify(n)}`),r.length>0&&i.update(`|extension_fields:${r.join(",")}`),i.digest("hex").slice(0,16)}function Te(e){return g.join(e,"runtime",br)}function Oe(e){return g.join(e,"runtime",Ir)}function Ne(e){return g.join(e,"runtime",Cr)}function tt(e){return g.join(e,"runtime",xr)}function nt(e){return g.join(e,"runtime",vr)}function ke(e,t){let n=g.extname(e);return`${e.slice(0,-n.length)}.${t}${n}`}var Rr=24,S=new Map,Ae=new WeakMap;function rt(e){return Ae.get(e)??e.source_cursor}function Tr(e,t){let n=rt(e);if(!(t.base_source_cursor!==n||e.source_cursor===t.source_cursor)){Ae.set(e,n);for(let[r,i]of Object.entries(t.changes))i.entry?e.entries[r]=i.entry:delete e.entries[r];e.directory_signatures=t.directory_signatures,e.source_cursor=t.source_cursor}}function Or(e,t){if(!e)return;let n=rt(e);if(!(t.base_source_cursor!==n||e.source_cursor===t.source_cursor)){Ae.set(e,n);for(let[r,i]of Object.entries(t.changes))i.body?e.bodies[r]=i.body:delete e.bodies[r];e.source_cursor=t.source_cursor}}function Nr(e,t){if(!e)return;let n=rt(e);if(!(t.base_source_cursor!==n||e.source_cursor===t.source_cursor)){Ae.set(e,n);for(let[r,i]of Object.entries(t.changes))i.collections?e.collections[r]=i.collections:delete e.collections[r];e.source_cursor=t.source_cursor}}function kr(e,t,n,r){!e||!r||e.context_fingerprint!==r.context_fingerprint||(Tr(e,r),Or(t,r),Nr(n,r))}function et(e,t){S.size>=Rr&&!S.has(e)&&Tt(S),S.set(e,t)}async function D(e,t){let n;try{n=await b.stat(e)}catch{return S.delete(e),null}let r=S.get(e);if(r&&se(r.signature,n.mtimeMs,n.ctimeMs,n.size))return S.delete(e),S.set(e,r),r.envelope;let i;try{i=t(await b.readFile(e,"utf8"))}catch{i=null}return et(e,{signature:{mtime_ms:n.mtimeMs,ctime_ms:n.ctimeMs,size:n.size},envelope:i}),i}async function Ar(e,t,n){let r=a=>{let d=JSON.parse(a);return d.version!==T||typeof d.source_cursor!="string"||typeof d.entries!="object"||d.entries===null?null:d},i=Te(e),o=await D(i,r);if(!t||o===null||o.context_fingerprint===t)return o;let s=await D(ke(i,t),r);return s===null&&de(n,`metadata_cache_context_changed:${o.context_fingerprint}->${t}`),s}async function Dr(e,t){let n=o=>{let s=JSON.parse(o);return s.version!==T||typeof s.source_cursor!="string"||typeof s.bodies!="object"||s.bodies===null?null:s},r=Oe(e),i=await D(r,n);return t&&i?.context_fingerprint!==t?await D(ke(r,t),n):i}async function Fr(e,t){let n=o=>{let s=JSON.parse(o);return s.version!==T||typeof s.source_cursor!="string"||typeof s.collections!="object"||s.collections===null?null:s},r=Ne(e),i=await D(r,n);return t&&i?.context_fingerprint!==t?await D(ke(r,t),n):i}async function it(e){let t=tt(e),n=await D(t,r=>{let i=JSON.parse(r);return i.version!==T||typeof i.base_source_cursor!="string"||typeof i.source_cursor!="string"||typeof i.changes!="object"||i.changes===null?null:i});if(n)return{envelope:n,invalid:!1};try{return await b.stat(t),{envelope:null,invalid:!0}}catch{return{envelope:null,invalid:!1}}}async function ot(e){let t=nt(e),n=await D(t,r=>{let i=JSON.parse(r);return i.version!==T||typeof i.context_fingerprint!="string"||typeof i.source_cursor!="string"||!Number.isInteger(i.entry_count)||i.entry_count<0||typeof i.directory_signatures!="object"||i.directory_signatures===null?null:i});if(n)return n;try{await b.stat(t),await q(e)}catch{}return null}async function ae(e,t){await b.mkdir(g.dirname(e),{recursive:!0}),await A(e,JSON.stringify(t));try{let r=await b.stat(e);et(e,{signature:{mtime_ms:r.mtimeMs,ctime_ms:r.ctimeMs,size:r.size},envelope:t})}catch{S.delete(e)}let n=g.dirname(g.dirname(e));if(e===Te(n)||e===Oe(n)||e===Ne(n)){let r=ke(e,t.context_fingerprint);await A(r,JSON.stringify(t));try{let d=await b.stat(r);et(r,{signature:{mtime_ms:d.mtimeMs,ctime_ms:d.ctimeMs,size:d.size},envelope:t})}catch{S.delete(r)}let i=g.dirname(e),o=g.extname(e),s=g.basename(e,o),a=(await b.readdir(i,{withFileTypes:!0}).catch(()=>[])).filter(d=>d.isFile()&&d.name!==g.basename(e)&&d.name.startsWith(`${s}.`)&&d.name.endsWith(o)).map(d=>g.join(i,d.name));if(a.length>an){let d=(await Promise.all(a.map(async c=>{try{return{path:c,mtime:(await b.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-an)))await b.rm(c.path,{force:!0}),S.delete(c.path)}}}function Mr(e,t,n){return n?t===n&&e!==n:t==="toon"&&e!=="toon"}function yn(e,t,n){return e===void 0||Mr(e,t,n)}function de(e,t){e&&!e.includes(t)&&e.push(t)}function se(e,t,n,r){return e.mtime_ms===t&&e.ctime_ms===n&&e.size===r}async function Pr(e,t,n){let r=g.join(e,t);try{let i=await b.readdir(r);return{folder:t,dirPath:r,files:i}}catch(i){return typeof i=="object"&&i!==null&&"code"in i&&!L(i)&&de(n,`item_list_directory_read_failed:${t}`),{folder:t,dirPath:r,files:[]}}}async function jr(e,t){try{let n=await b.stat(g.join(e,t));return[t,{exists:!0,mtime_ms:n.mtimeMs,ctime_ms:n.ctimeMs,size:n.size}]}catch{return[t,{exists:!1,mtime_ms:0,ctime_ms:0,size:0}]}}async function Se(e,t){return Object.fromEntries(await Promise.all(t.map(async n=>await jr(e,n))))}function ce(e,t){return!e||Object.keys(e).length!==Object.keys(t).length?!1:Object.entries(t).every(([n,r])=>{let i=e[n];return i!==void 0&&i.exists===r.exists&&se(i,r.mtime_ms,r.ctime_ms,r.size)})}function Lr(e){return fe.some(t=>e.toLowerCase().endsWith(t))}function $r(e,t,n,r,i,o){r||(e.metadata=!0),t&&!i&&(e.body=!0),n&&!o&&(e.collections=!0)}async function Ur(e,t,n){if(n)for(let r of await he({path:e,scope:"project"}))de(t,r)}function cn(e,t,n,r){if(e)return t&&n?n.collections:r}async function Hr(e,t,n){let r=await b.stat(e),i=r.mtimeMs,o=r.ctimeMs,{size:s}=r,a=je(e);await Ur(e,n.warnings,n.dispatchReadHooks);let d=n.previousEntries[t],c=!n.forceSourceRead&&d!==void 0&&se(d,i,o,s),p=n.previousBodies[t],u=!n.forceSourceRead&&p!==void 0&&se(p,i,o,s),l=n.previousCollections[t],h=!n.forceSourceRead&&l!==void 0&&se(l,i,o,s);if(!(!c||n.includeBody&&!u||n.includeCollections&&!h))return{mtimeMs:i,ctimeMs:o,size:s,itemFormat:a,lightMetadata:d.metadata,heavyMetadata:cn(n.includeCollections,h,l,void 0),bodyLength:d.body_length,body:n.includeBody?p.body:void 0};let w=await b.readFile(e,"utf8"),_=K(w,{format:a,schema:n.schema,extensionFieldNames:n.extensionFieldNames,onWarning:x=>de(n.warnings,x)}),E=Re(_.metadata);return $r(n.state.misses,n.includeBody,n.includeCollections,c,u,h),{mtimeMs:i,ctimeMs:o,size:s,itemFormat:a,lightMetadata:c?d.metadata:E.light,heavyMetadata:cn(n.includeCollections,h,l,E.heavy),bodyLength:c?d.body_length:_.body.length,body:n.includeBody?_.body:void 0}}function Wr(e,t,n,r){n.state.newEntries[t]={mtime_ms:r.mtimeMs,ctime_ms:r.ctimeMs,size:r.size,metadata:r.lightMetadata,body_length:r.bodyLength},n.includeBody&&r.body!==void 0&&(n.state.newBodies[t]={mtime_ms:r.mtimeMs,ctime_ms:r.ctimeMs,size:r.size,body:r.body}),n.includeCollections&&r.heavyMetadata!==void 0&&(n.state.newCollections[t]={mtime_ms:r.mtimeMs,ctime_ms:r.ctimeMs,size:r.size,collections:r.heavyMetadata});let i=n.includeCollections?pn(r.lightMetadata,r.heavyMetadata):r.lightMetadata,o=n.state.documentsById.get(i.id),s={metadata:i,body:r.body,item_format:r.itemFormat,item_path:e};yn(o?.itemFormat,r.itemFormat,n.preferredFormat)&&n.state.documentsById.set(i.id,{candidate:s,itemFormat:r.itemFormat})}async function Br(e,t,n,r){try{let i=await Hr(t,n,r);Wr(t,n,r,i)}catch{de(r.warnings,`item_list_item_read_failed:${e}/${g.basename(t)}`)}}function zr(e,t){return e&&e.context_fingerprint===t?e.entries:{}}function Xr(e,t){return e&&e.context_fingerprint===t?e.bodies:{}}function Gr(e,t){return e&&e.context_fingerprint===t?e.collections:{}}function Yr(){return{newEntries:{},newBodies:{},newCollections:{},documentsById:new Map,misses:{metadata:!1,body:!1,collections:!1}}}async function qr(e,t){let n=[];for(let{folder:r,dirPath:i,files:o}of e)for(let s of o){if(!Lr(s))continue;let a=g.join(i,s),d=g.relative(t.pmRoot,a);n.push(Br(r,a,d,t)),n.length===32&&(await Promise.all(n),n.length=0)}await Promise.all(n)}async function Vr(e){if(!(!(e.state.misses.metadata||Object.keys(e.previousEntries).length!==Object.keys(e.state.newEntries).length||!ce(e.existingCache?.directory_signatures,e.directorySignatures))&&e.existingCache!==null&&e.existingCache.context_fingerprint===e.contextFingerprint))try{await ae(Te(e.pmRoot),{version:T,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,directory_signatures:e.directorySignatures,entries:e.state.newEntries}),await ae(nt(e.pmRoot),{version:T,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,entry_count:Object.keys(e.state.newEntries).length,directory_signatures:e.directorySignatures});let n=[...e.state.documentsById.values()].map(({candidate:r})=>({relativePath:g.relative(e.pmRoot,r.item_path),metadata:Re(r.metadata).light,linkedFiles:r.metadata.files??[]}));n.length>=e.minimumIndexedItems?await on({pmRoot:e.pmRoot,contextFingerprint:e.contextFingerprint,sourceCursor:e.sourceCursor,rows:n}):await ve(e.pmRoot)}catch{}}async function Kr(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 ae(Oe(e.pmRoot),{version:T,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,bodies:e.state.newBodies}).catch(()=>{})}async function Jr(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 ae(Ne(e.pmRoot),{version:T,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,collections:e.state.newCollections}).catch(()=>{})}async function st(e,t,n={}){let r=await ot(e);return n.required!==!0&&(r===null||r.entry_count<fn)?async()=>{}:Mt(e,Er,30,t,!1,!1,3e3)}async function zo(e,t){let n=await ot(e);if(n===null)return null;let r=await it(e);if(r.invalid)return await q(e),null;let i=r.envelope?.context_fingerprint===n.context_fingerprint&&r.envelope.base_source_cursor===n.source_cursor?r.envelope.source_cursor:n.source_cursor,o=r.envelope?.context_fingerprint===n.context_fingerprint&&r.envelope.base_source_cursor===n.source_cursor?r.envelope.directory_signatures:n.directory_signatures;return t&&!ce(o,await Se(e,t))?null:{source_cursor:i,entry_count:n.entry_count}}function dn(e,t){let n=g.relative(e,t);return n===""||n===".."||n.startsWith(`..${g.sep}`)||g.isAbsolute(n)?null:n}async function q(e){await Promise.all([Te(e),Oe(e),Ne(e),tt(e),nt(e)].map(async t=>{await b.rm(t,{force:!0}),S.delete(t)})),await ve(e)}async function Qr(e){if(e.mutation.document===null)return{entry:null,body:null,collections:null};let t=await b.stat(e.mutation.itemPath),n=Re(e.mutation.document.metadata),r={mtime_ms:t.mtimeMs,ctime_ms:t.ctimeMs,size:t.size};return{entry:{...r,metadata:n.light,body_length:e.mutation.document.body.length},body:{...r,body:e.mutation.document.body},collections:{...r,collections:n.heavy}}}function Zr(e,t,n){return e?.context_fingerprint===t&&e.base_source_cursor===n?structuredClone(e.changes):{}}async function at(e){let t=dn(e.pmRoot,e.itemPath),n=e.previousItemPath?dn(e.pmRoot,e.previousItemPath):void 0;if(t===null||n===null)return await q(e.pmRoot),["metadata_derived_index_path_invalidated"];try{let r=hn(e.preferredFormat,e.typeToFolder,e.schema,mn()),i=await ot(e.pmRoot);if(i===null||i.context_fingerprint!==r)return[];let o=i.source_cursor,s=await it(e.pmRoot);if(s.invalid)return await q(e.pmRoot),["metadata_derived_index_refresh_failed"];let a=Zr(s.envelope,r,o),d=s.envelope?.context_fingerprint===r&&s.envelope.base_source_cursor===o?s.envelope.source_cursor:o;n!==void 0&&(a[n]={entry:null,body:null,collections:null}),a[t]=await Qr({mutation:e});let c=un();return await ae(tt(e.pmRoot),{version:T,context_fingerprint:r,base_source_cursor:o,source_cursor:c,directory_signatures:await Se(e.pmRoot,[...new Set(Object.values(e.typeToFolder))]),changes:a}),await sn({pmRoot:e.pmRoot,contextFingerprint:r,expectedSourceCursor:d,sourceCursor:c,row:e.document===null?null:{relativePath:t,metadata:Re(e.document.metadata).light,linkedFiles:e.document.metadata.files},deletedRelativePaths:[...n===void 0?[]:[n],...e.document===null?[t]:[]]})||await ve(e.pmRoot),[]}catch{return await q(e.pmRoot).catch(()=>{}),["metadata_derived_index_refresh_failed"]}}function ei(e){return[...e.documentsById.values()].sort((t,n)=>t.candidate.metadata.id.localeCompare(n.candidate.metadata.id)).map(t=>t.candidate)}function ln(e,t,n){return e?.context_fingerprint===t&&e.source_cursor===n}function ti(e,t,n,r,i){return e.every(o=>(!t||r[o]!==void 0)&&(!n||i[o]!==void 0))}function ni(e){let t=new Map;for(let[n,r]of Object.entries(e.previousEntries)){let i=je(n);if(!i)continue;let o=e.includeCollections?pn(r.metadata,e.previousCollections[n]?.collections):r.metadata,s=t.get(o.id);yn(s?.itemFormat,i,e.preferredFormat)&&t.set(o.id,{itemFormat:i,candidate:{metadata:o,body:e.includeBody?e.previousBodies[n]?.body:void 0,item_format:i,item_path:g.join(e.pmRoot,n)}})}return[...t.values()].sort((n,r)=>n.candidate.metadata.id.localeCompare(r.candidate.metadata.id)).map(n=>n.candidate)}function ri(e){return e.forceSourceScan||qe()||e.existingCache?.context_fingerprint!==e.contextFingerprint||e.entryKeys.length<e.minimumIndexedItems||!ce(e.existingCache?.directory_signatures,e.directorySignatures)?!1:[!e.includeBody||ln(e.existingBodyCache,e.contextFingerprint,e.existingCache.source_cursor),!e.includeCollections||ln(e.existingCollectionsCache,e.contextFingerprint,e.existingCache.source_cursor)].every(Boolean)&&ti(e.entryKeys,e.includeBody,e.includeCollections,e.previousBodies,e.previousCollections)}async function De(e,t,n,r,i,o={}){let s=o.includeBody!==!1,a=o.includeCollections!==!1,d=mn(),c=hn(t,n,i,d),p=await it(e);p.invalid&&await q(e);let u=await Ar(e,c,o.cacheDiagnostics),l=s?await Dr(e,c):null,h=a?await Fr(e,c):null;kr(u,l,h,p.envelope);let y=zr(u,c),w=Xr(l,c),_=Gr(h,c),E=[...new Set(Object.values(n))],x=await Se(e,E),M=Object.keys(y),O=Math.max(1,Math.floor(o.derivedIndexMinimumItems??fn));if(ri({forceSourceScan:o.forceSourceScan===!0,contextFingerprint:c,existingCache:u,existingBodyCache:l,existingCollectionsCache:h,directorySignatures:x,entryKeys:M,minimumIndexedItems:O,includeBody:s,includeCollections:a,previousBodies:w,previousCollections:_}))return ni({pmRoot:e,preferredFormat:t,includeBody:s,includeCollections:a,previousEntries:y,previousBodies:w,previousCollections:_});let W=await Promise.all(E.map(P=>Pr(e,P,r))),v=qe(),C=Yr(),B={pmRoot:e,preferredFormat:t,warnings:r,schema:i,extensionFieldNames:d,includeBody:s,includeCollections:a,forceSourceRead:o.forceSourceScan===!0,dispatchReadHooks:v,previousEntries:y,previousBodies:w,previousCollections:_,state:C};await qr(W,B);let z=await Se(e,E),k=ce(x,z)?z:{},X=C.misses.metadata||Object.keys(y).length!==Object.keys(C.newEntries).length||!ce(u?.directory_signatures,k)||u===null?un():u.source_cursor;return await Vr({pmRoot:e,contextFingerprint:c,sourceCursor:X,existingCache:u,previousEntries:y,directorySignatures:k,state:C,minimumIndexedItems:O}),s&&await Kr({pmRoot:e,contextFingerprint:c,sourceCursor:X,existingBodyCache:l,previousBodies:w,state:C}),a&&await Jr({pmRoot:e,contextFingerprint:c,sourceCursor:X,existingCollectionsCache:h,previousCollections:_,state:C}),ei(C)}async function _n(e,t,n,r,i){return(await De(e,t,n,r,i,{includeBody:!1})).map(s=>({metadata:s.metadata,body:s.body??""}))}async function gn(e,t,n,r,i){return(await De(e,t,n,r,i,{includeBody:!1,includeCollections:!1})).map(s=>({metadata:s.metadata,body:s.body??""}))}import F from"node:fs/promises";import{statSync as ai}from"node:fs";function ii(e,t){let n=-1;return e.forEach((r,i)=>{let o=Date.parse(r.ts);if(!Number.isFinite(o))throw new f(`History for this item contains invalid timestamp at entry ${i+1}.`,m.GENERIC_FAILURE);o<=t&&(n=i)}),n}function oi(e,t){let n=e[0]?.ts??null,r=e.at(-1)?.ts??null,i={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:n,last_timestamp:r}};return r!==null&&(i.examples=[r],t!==null&&(i.examples.unshift(String(t+1),String(t+e.length)),i.valid_range.first_version=t+1,i.valid_range.last_version=t+e.length)),{guidance:i,lastTimestamp:r}}function si(e,t){let n={};if(t instanceof Error&&t.message.trim().length>0&&(n.reason=t.message.trim()),typeof t!="object"||t===null)return n;let r=t;if(typeof r.index=="number"&&Number.isInteger(r.index)&&r.index>=0&&(n.patchIndex=r.index),typeof r.operation=="object"&&r.operation!==null){let i=r.operation;Object.assign(n,Object.fromEntries(["op","path","from"].flatMap(o=>{let s=i[o];return typeof s=="string"?[[o,s]]:[]})))}if(n.patchIndex!==void 0){let i=e[n.patchIndex];i&&(n.op??=i.op,n.path??=i.path,n.from??=i.from)}return n}function En(e,t,n={}){let r=e.trim(),i=n.errorSubject??"history",o=i==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=oi(t,ne(t,!0));if(!r)throw new f(`Missing ${i} target. Use a timestamp or version number.`,m.USAGE,s);if(/^\d+$/.test(r)){let p=ne(t),u=Number(r);if(u>=1&&u<=p)throw new f(`History version ${u} was pruned by compaction.`,m.USAGE,{...s,code:"history_version_pruned"});if(!Number.isSafeInteger(u)||u<1||u>p+t.length)throw new f(`${o} version must be between ${p+1} and ${p+t.length} for this item.`,m.USAGE,s);return{kind:"version",raw:r,historyIndex:u-p-1}}let d=Date.parse(r);if(!Number.isFinite(d))throw new f(`Invalid ${i} target "${e}". Use a positive version number or ISO timestamp.`,m.USAGE,s);let c=ii(t,d);if(c<0||n.allowFutureTimestamp!==!0&&d>Date.parse(a))throw new f(i==="restore"?`No history entries exist at or before timestamp ${r}.`:`No history entry exists at timestamp ${r}.`,m.USAGE,s);return{kind:"timestamp",raw:r,historyIndex:c}}function ct(e,t,n,r){let i=Ue(e,t);if(i.ok)return i.document;let o=si(t,i.error),s=[`history_op=${r}`,o.patchIndex===void 0?null:`patch_index=${o.patchIndex}`,o.op?`op=${o.op}`:null,o.path?`path=${o.path}`:null,o.from?`from=${o.from}`:null].filter(a=>a!==null);throw new f(`Failed to apply history patch at entry ${n} (${s.join(", ")}). ${o.reason??String(i.error)}`,m.GENERIC_FAILURE)}function wn(e,t){return new f(`History entry ${e+1} lies between an unrecorded change and the record that repaired it, so its historical state cannot be reconstructed.`,m.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 bn(e,t){let n=e[0];if(n&&n.op!=="create"&&n.op!=="history_compact_baseline"){let s=Ue(Q,n.patch);if(!s.ok||typeof s.document.metadata.id!="string")throw new f("History starts without a reconstructable item baseline.",m.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 wn(t,!1);let r=e.slice(0,t+1),i=me([...r]),o=structuredClone(Q);for(let s=0;s<=t;s+=1){let a=e[s];if(!a)throw new f(`History target entry ${s+1} does not exist.`,m.USAGE);o=ct(o,a.patch,s+1,a.op)}if(!i.ok){let s=$t([...e]);throw s.ok&&s.bridged_segments?.some(a=>a.start<=t&&t<a.end)?wn(t,!0):new f(`History cannot be replayed: ${i.errors.join(", ")}.`,m.GENERIC_FAILURE,{code:"history_replay_invalid",verification_errors:i.errors,required:"Inspect the history integrity findings before attempting recovery.",nextSteps:["Run pm history <id> --verify --full."]})}return o}function Ko(e,t){if(Object.keys(e.metadata).length>0){if(typeof e.metadata.id!="string"||!Array.isArray(e.metadata.tags))throw new f("History has no complete item baseline for this target.",m.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 f(`History target ${t.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,m.USAGE)}function ci(e,t){let n=-1,r=structuredClone(Q);for(let[a,d]of e.entries()){if(r=ct(r,d.patch,a+1,d.op),r.metadata.id!==void 0&&r.metadata.id!==t)throw new f(`History belongs to item ${String(r.metadata.id)}, expected ${t}.`,m.GENERIC_FAILURE,{code:"history_replay_invalid",required:"Recover the correct history stream for this item before attempting restoration."});r.metadata.id===t&&Array.isArray(r.metadata.tags)&&(n=a)}let i=ne(e,!0),o=n<0||i===null?null:i+n+1,s=o===null?void 0:String(o);if(n>=0&&s===void 0){let a=e[n].ts;En(a,e).historyIndex===n&&(s=a)}return{version:o,target:s}}async function In(e,t,n){let r=new Set([te(t,n),ee(t)]);for(let i of r){let o=R(e,i);if(!ai(o,{throwIfNoEntry:!1})?.isFile())continue;let s=await Lt(o,i),a=-1;if(s.forEach((h,y)=>{h.op==="delete"&&(a=y)}),a<0)continue;let d=bn(s,s.length-1);if(Object.keys(d.metadata).length!==0)continue;let{version:c,target:p}=ci(s,i),u=p===void 0?["history",i,"--verify"]:["get",i,"--at",p],l=V(u);return new f(`Item ${i} was deleted at ${s[a].ts}; its history is retained.`,m.NOT_FOUND,{code:"item_deleted",required:"Read a retained materialized version, then restore it if the item should exist again.",item_id:i,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",i,p])]],recovery:{suggested_retry:l,suggested_retry_args:u}})}}import{AsyncLocalStorage as di}from"node:async_hooks";import Cn from"node:path";var xn=new di;function us(e,t){return xn.run({...e,pmRoot:Cn.resolve(e.pmRoot)},t)}function vn(e,t){let n=xn.getStore();return n?.pmRoot===Cn.resolve(e)&&n.itemId===t?{bulk_checkpoint:n.checkpointId}:void 0}import lt from"node:path";import li from"node:fs/promises";import ui from"node:path";var Sn=64;function fi(e){return[...new Set(e.filter(t=>t.trim().length>0))].sort((t,n)=>t.localeCompare(n))}function mi(e,t){return new f(`Missing history stream for ${e}. ${t} requires history streams when settings.history.missing_stream is strict_error.`,m.NOT_FOUND)}async function pi(e,t){return await Et(ui.dirname(e)),await(await li.open(e,"a")).close(),$({path:e,scope:"project",op:`${t}:history:auto_create`})}async function hi(e,t,n){let r=[];for(let i=0;i<t.length;i+=Sn){let o=t.slice(i,i+Sn),s=await Promise.all(o.map(a=>{let d;try{d=R(e,a)}catch{return!1}return G(d)}));if(o.forEach((a,d)=>{s[d]||r.push(a)}),n&&r.length>0)break}return r}async function dt(e){return yi({pmRoot:e.pmRoot,settings:e.settings,itemIds:[e.itemId],commandLabel:e.commandLabel})}async function yi(e){let t=fi(e.itemIds),n=[],r=[],i=Bt(),o=e.settings.history.missing_stream==="strict_error",s=i?t:await hi(e.pmRoot,t,o);for(let a of s.length===0?[]:t){let d=R(e.pmRoot,a);if(!await G(d)){if(o)throw mi(a,e.commandLabel);r.push(...await pi(d,e.commandLabel)),r.push(`history_stream_auto_created:${a}`),n.push(a)}}return{auto_created_ids:n,warnings:r}}import{isUtf8 as _i}from"node:buffer";async function gi(e){try{return await F.access(e),!0}catch{return!1}}function wi(e,t){e&&(e.includes(t)||e.push(t))}function ut(e){return e??ge(Z())}function Ei(e){return e==="toon"?["toon","json_markdown"]:e==="json_markdown"?["json_markdown","toon"]:["toon","json_markdown"]}async function ft(e,t,n="pm-",r,i=j){let o=t.trim(),s=o.startsWith("#")?o.slice(1):o;if(s.length===0)return null;let a=te(t,n),d=ee(t),c=[...new Set([s,a,d])].filter(l=>l.length>0),p=Object.entries(i),u=Ei(r);for(let l of c){let h=new Map;for(let[y]of p)for(let w of u){let _=Pe(e,y,l,w,i);await gi(_)&&h.set(_,h.get(_)??{id:l,type:y,itemPath:_,item_format:w})}if(h.size>1){let y=[...h.keys()].map(w=>lt.relative(e,w).split(lt.sep).join("/")).sort();throw new f(`Item ${l} has ambiguous identity across ${y.join(", ")}. Preserve both documents and inspect pm ops validate --check-storage-integrity before resolving the collision.`,m.CONFLICT,{code:"item_identity_ambiguous",item_id:l,paths:y})}for(let y of h.values())return y}return null}async function Tn(e,t={}){let n=await bi(e,t);if(n.error!==null)throw n.error;return{raw:n.raw,document:n.document}}async function bi(e,t={}){let n=await F.readFile(e.itemPath);if(!_i(n))throw new f("Item contains invalid UTF-8; preserve a binary backup before recovering it.",m.CONFLICT,{code:"item_document_encoding_invalid",item_id:e.id,item_path:e.itemPath,byte_length:n.length,empty:!1});let r=n.toString("utf8");await he({path:e.itemPath,scope:"project"});let i;try{i=K(r,{format:e.item_format,requireSupportedFormat:!0,schema:t.schema,extensionFieldNames:ut(t.extensionFieldNames),onWarning:o=>wi(t.warnings,o)})}catch(o){if(o instanceof f&&o.code==="item_format_version_unsupported")throw new f(`Item ${e.id}: ${o.message}`,o.exitCode,{...o.context,item_id:e.id,item_path:e.itemPath});if(o instanceof f&&o.code==="item_document_invalid")return{raw:r,document:null,error:new f(`Cannot read ${e.id} at ${e.itemPath}${n.length===0?" (zero-length file)":""}: ${o.message}`,o.exitCode,{...o.context,item_id:e.id,item_path:e.itemPath,byte_length:n.length,empty:n.length===0,nextSteps:[`Run pm history ${e.id} --full, then pm restore ${e.id} <version> to recover a recorded state.`]})};throw o}return{raw:r,document:i,error:null}}async function Ii(e,t,n=j,r,i){await ye(e);let o=await _n(e,t,n,r,i);return Ee(o.length),o.map(s=>s.metadata)}async function Qs(e,t,n=j,r,i){await ye(e);let o=await gn(e,t,n,r,i);return Ee(o.length),o.map(s=>s.metadata)}async function Zs(e,t,n=j,r,i,o={}){await ye(e);let s=await De(e,t,n,r,i,{includeBody:!0,forceSourceScan:o.forceSourceScan});return Ee(s.length),s.map(a=>({...a.metadata,body:a.body}))}function On(e){return{async get(t){let n=await ft(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!n)return null;let{document:r}=await Tn(n,{schema:e.settings.schema});return{item:r.metadata,body:r.body}},list:()=>Ii(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema)}}async function Ci(e,t){let n=new Set(Object.values(t)),r=[];return await Promise.all([...n].map(async i=>{try{let o=await F.readdir(lt.join(e,i));for(let s of o)for(let a of fe)if(s.toLowerCase().endsWith(a)){r.push(s.slice(0,-a.length));break}}catch{}})),r}async function xi(e,t,n,r){let i=te(t,n),o=await Ci(e,r);if(o.length===0)return[];let s=Math.max(3,Math.floor(i.length/2));return o.map(d=>({id:d,distance:ue(d,i,s)})).filter(d=>d.distance!==null).sort((d,c)=>d.distance-c.distance).slice(0,3).map(d=>d.id)}async function vi(e,t,n,r){let i=await In(e,t,n);if(i)return i;let o=await xi(e,t,n,r),s=["Confirm the active --path/PM_PATH scope, then retry with a valid id."];return o.length>0&&s.unshift(`Did you mean one of: ${o.join(", ")}?`),new f(`Item ${t} not found`,m.NOT_FOUND,{code:"item_not_found",id:t,nextSteps:s})}function Si(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 Nn(e){let t=e.typeToFolder??Ct(e.settings,Z()).type_to_folder,n=await ft(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,t);if(!n)throw await vi(e.pmRoot,e.id,e.settings.id_prefix,t);let r=await Pt(e.pmRoot,n.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"}),i=r.release;try{let o=[],{raw:s,document:a}=await Tn(n,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames,warnings:o}),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&&!Si(e.op,e.bypassAssigneeConflict)){if(l.ownership_enforcement==="strict")throw new f(`Item ${n.id} is assigned to ${c}. Use --force to override.`,m.CONFLICT);l.ownership_enforcement==="warn"&&o.push(`ownership_warning:assignee_conflict:${n.id}:${c}`)}return{typeToFolder:t,located:n,originalRaw:s,document:a,warnings:o,releaseLock:i,lease:r}}catch(o){throw await i(),o}}function kn(e){return Object.keys(e).length===0?void 0:e}async function An(e,t,n,r){return e.fence(async()=>{let i;try{i=await F.readFile(t.itemPath,"utf8")}catch(o){if(!L(o))throw o;i=null}if(i!==n)throw new f(`Item ${t.id} changed after this mutation read it; refusing to overwrite the newer revision. Nothing was written.`,m.CONFLICT,{code:"stale_revision",item_id:t.id,reason:i===null?"item_removed":"item_revision_changed",required:"Re-read the item and apply the mutation again; the newer stored revision was kept."});return r()})}function Ri(e,t,n){if(!e.handled||typeof e.result!="object"||e.result===null)return{effectiveTargetItemPath:t,effectiveSerializedAfter:n,skipItemWrite:!1};let r=e.result;return{effectiveTargetItemPath:typeof r.target_item_path=="string"&&r.target_item_path.trim().length>0?r.target_item_path:t,effectiveSerializedAfter:typeof r.contents=="string"?r.contents:n,skipItemWrite:r.skip_write===!0}}async function Dn(e){try{let t=await ft(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!t)return{document:Me};let n=K(await F.readFile(t.itemPath,"utf8"),{format:t.item_format,requireSupportedFormat:!0,schema:e.settings.schema,extensionFieldNames:ut(e.extensionFieldNames)});return n.metadata.id===e.embeddedId?{document:n}:{document:e.fallback,revision:Rn}}catch{return{document:e.fallback,revision:Rn}}}var Rn="unreadable-after-storage-override";async function Ti(e){let t=await Ve("item_store_delete",e),n=t.handled&&typeof t.result=="object"&&t.result!==null?t.result:{};return{effectiveItemPath:typeof n.item_path=="string"&&n.item_path.trim().length>0?n.item_path:e.item_path,skipDelete:n.skip_delete===!0,warnings:t.warnings}}async function Oi(e){if(!e.skipItemWrite){if(e.effectiveTargetItemPath!==e.originalItemPath){await A(e.originalItemPath,e.originalRaw),await F.rm(e.effectiveTargetItemPath,{force:!0});return}await A(e.originalItemPath,e.originalRaw)}}function Ni(e,t){Dt(e.metadata)&&t.push("deferred_fields")}async function mt(e){Ot(e.op);let t=await Nn({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:n,located:r,originalRaw:i,document:o,warnings:s,releaseLock:a,lease:d}=t;try{Be(e.pmRoot,o,r.id);let c=J(o,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),p=J(structuredClone(o),{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),u=await e.mutate(p,{storageId:r.id});if(Ni(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?.(),...vn(e.pmRoot,r.id),...Wt(e.pmRoot,[r.id,o.metadata.id])},h=Math.max($e(c.metadata),$e(p.metadata));Gt(xt(e.pmRoot),h),h>At(p.metadata)&&(p.metadata.pm_format_version=h,u.changedFields.push("pm_format_version")),p.metadata.updated_at=Le();let y=J(p,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),w=await Je({pmRoot:e.pmRoot,settings:e.settings,operation:e.op,author:e.author,before:c,after:y});await Ye({pm_root:e.pmRoot,operation:e.op,before:c,after:y,changed_fields:u.changedFields,author:e.author,sdk:On({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:n})});let _=await dt({pmRoot:e.pmRoot,settings:e.settings,itemId:r.id,commandLabel:e.op}),E="toon",x=Ft(y,{format:E,schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),M=Pe(e.pmRoot,y.metadata.type,r.id,E,n),O=R(e.pmRoot,r.id),W=await An(d,r,i,async()=>{let k=await Ve("item_store_write",{op:e.op,pm_root:e.pmRoot,item_id:r.id,source_item_path:r.itemPath,target_item_path:M,history_path:O,item_format:E,before:c,after:y,contents:x}),{effectiveTargetItemPath:N,effectiveSerializedAfter:X,skipItemWrite:P}=Ri(k,M,x),Wn=await st(e.pmRoot,e.author),_t=[];try{P||await A(N,X),!P&&N!==r.itemPath&&await F.rm(r.itemPath);let zn=He({nowIso:y.metadata.updated_at,author:e.author,op:e.op,before:c,after:y,message:e.message,context:kn({...l,...w.decisions.length===0?{}:{workflow_policies:w.decisions},...Xe(e.pmRoot,[r.id,o.metadata.id],e.op)})});try{await We(O,zn)}catch(Xn){throw await Oi({skipItemWrite:P,effectiveTargetItemPath:N,originalItemPath:r.itemPath,originalRaw:i}),Xn}P||(_t=await at({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:n,schema:e.settings.schema,itemPath:N,previousItemPath:r.itemPath,document:y}))}finally{await Wn()}let Bn=P||N!==M||X!==x;return{derivedIndexWarnings:_t,effectiveTargetItemPath:N,overrideWarnings:k.warnings,stored:Bn?await Dn({pmRoot:e.pmRoot,settings:e.settings,id:r.id,typeToFolder:n,extensionFieldNames:e.extensionFieldNames,fallback:y,embeddedId:y.metadata.id}):{document:y}}}),{derivedIndexWarnings:v,effectiveTargetItemPath:C,stored:B}=W;ze(e.pmRoot,B.document,r.id,[y.metadata.id],B.revision);let z=[...await $({path:C,scope:"project",op:e.op,item_id:y.metadata.id,item_type:y.metadata.type,before:c,after:y,changed_fields:u.changedFields}),...await $({path:O,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 Ge({id:y.metadata.id,op:e.op,item_type:y.metadata.type,previous_status:c.metadata.status,status:y.metadata.status,previous:pe(c.metadata,u.changedFields),current:pe(y.metadata,u.changedFields),changed_fields:u.changedFields}),{item:y.metadata,body:y.body,changedFields:u.changedFields,warnings:[...s,...u.warnings??[],...w.warnings,..._.warnings,...W.overrideWarnings,...v,...z]}}finally{await a()}}async function ea(e){let{historyContext:t,...n}=e;return mt({...n,resolveHistoryContext:()=>t})}async function ta(e){return mt(e)}async function na(e){return mt(e)}async function ra(e){let t=await Nn({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:"delete",author:e.author,force:e.force}),{located:n,originalRaw:r,document:i,warnings:o,releaseLock:s,lease:a}=t;try{Be(e.pmRoot,i,n.id);let d=ut(void 0),c=J(i,{schema:e.settings.schema,extensionFieldNames:d}),p=await Je({pmRoot:e.pmRoot,settings:e.settings,operation:"delete",author:e.author,before:c,after:null,dryRun:e.dryRun});await Ye({pm_root:e.pmRoot,operation:"delete",before:c,after:null,changed_fields:["deleted"],author:e.author,dry_run:e.dryRun===!0,sdk:On({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:t.typeToFolder})});let u=await dt({pmRoot:e.pmRoot,settings:e.settings,itemId:n.id,commandLabel:"delete"}),l=Le(),h=Me,y=He({nowIso:l,author:e.author,op:"delete",before:c,after:h,message:e.message,context:kn({...p.decisions.length===0?{}:{workflow_policies:p.decisions},...Xe(e.pmRoot,[n.id,i.metadata.id],"delete")})}),w=R(e.pmRoot,n.id),_=()=>Ti({op:"delete",pm_root:e.pmRoot,item_id:n.id,item_path:n.itemPath,history_path:w,before:c});if(e.dryRun===!0){let v=await _();return{item:c.metadata,changedFields:["deleted"],targetPath:v.effectiveItemPath,warnings:[...o,...p.warnings,...u.warnings,...v.warnings]}}let E=await An(a,n,r,async()=>{let{effectiveItemPath:v,skipDelete:C,warnings:B}=await _(),z=await st(e.pmRoot,e.author),k=[];try{C||await F.rm(v);try{await We(w,y)}catch(N){throw C||await A(v,r),N}C||(k=await at({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:t.typeToFolder,schema:e.settings.schema,itemPath:v,document:null}))}finally{await z()}return{derivedIndexWarnings:k,effectiveItemPath:v,overrideWarnings:B,stored:C||v!==n.itemPath?await Dn({pmRoot:e.pmRoot,settings:e.settings,id:n.id,typeToFolder:t.typeToFolder,fallback:h,embeddedId:i.metadata.id}):{document:h}}}),{derivedIndexWarnings:x,effectiveItemPath:M,stored:O}=E;ze(e.pmRoot,O.document,n.id,[i.metadata.id],O.revision);let W=[...await $({path:M,scope:"project",op:"delete",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:h,changed_fields:["deleted"]}),...await $({path:w,scope:"project",op:"delete:history",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:h,changed_fields:["deleted"]})];return Ge({id:c.metadata.id,op:"delete",item_type:c.metadata.type,previous_status:c.metadata.status,previous:pe(c.metadata,Object.keys(c.metadata)),changed_fields:["deleted"]}),{item:c.metadata,changedFields:["deleted"],warnings:[...o,...p.warnings,...u.warnings,...E.overrideWarnings,...x,...W]}}finally{await s()}}var le=Object.freeze({max_bytes:4096,max_depth:8}),Fn=160;var Mn=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u,ki=new Set(["__proto__"]),I=class extends Error{reason;path;constructor(t,n){super(t),this.reason=t,this.path=n}};function Pn(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Ai(e,t){return/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function Di(e){if(Buffer.byteLength(e,"utf8")<=Fn)return e;let t="",n=Buffer.byteLength("\u2026","utf8");for(let r of e){if(n+=Buffer.byteLength(r,"utf8"),n>Fn)break;t+=r}return`${t}\u2026`}function Fe(e,t,n){if(e.bytes+=t,!(e.bytes<=le.max_bytes))throw new I("byte_limit",n)}function jn(e,t,n){if(e.bytes+t>le.max_bytes)throw new I("byte_limit",n)}function pt(e,t,n){let r=Object.getOwnPropertyDescriptor(e,t);if(r===void 0||!("value"in r))throw new I("unsupported_value",n);return r.value}function Fi(e,t,n){if(typeof e=="number"&&!Number.isFinite(e))throw new I("non_finite_number",t);if(typeof e=="string"&&(jn(n,e.length+2,t),Mn.test(e)))throw new I("malformed_unicode",t);if(e!==null&&!["boolean","number","string"].includes(typeof e))throw new I("unsupported_value",t);return Fe(n,Buffer.byteLength(JSON.stringify(e),"utf8"),t),e}function Ln(e,t,n,r){if(typeof e!="object"||e===null)return Fi(e,t,r);if(n>=le.max_depth)throw new I("depth_limit",t);if(Array.isArray(e)){let i=pt(e,"length",t);if(typeof i!="number"||!Number.isSafeInteger(i)||i<0)throw new I("unsupported_value",t);Fe(r,i>0?i+1:2,t);let o=[];for(let s=0;s<i;s+=1){let a=`${t}[${s}]`;o.push(Ln(pt(e,String(s),a),a,n+1,r))}return o}if(!Pn(e))throw new I("unsupported_value",t);return $n(e,t,n+1,r)}function $n(e,t,n,r){let i=Object.keys(e);Fe(r,i.length>0?i.length+1:2,t);let o={};for(let s of i){jn(r,s.length+3,t);let a=Ai(t,s);if(ki.has(s))throw new I("reserved_key",a);if(Mn.test(s))throw new I("malformed_unicode",a);Fe(r,Buffer.byteLength(JSON.stringify(s),"utf8")+1,a),o[s]=Ln(pt(e,s,a),a,n,r)}return o}function Mi(e){try{if(e instanceof I)return e}catch{}return new I("unsupported_value","details")}function ht(e){let t=le.max_bytes,n={bytes:0};try{if(!Pn(e))throw new I("not_plain_object","details");return{ok:!0,details:$n(e,"details",0,n),byte_length:n.bytes}}catch(r){let i=Mi(r);return{ok:!1,omission:i.reason==="byte_limit"?{reason:"byte_limit",byte_limit:t}:{reason:i.reason,path:Di(i.path),byte_limit:t}}}}function Pi(e){return ht(e).ok}function yt(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function ma(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;if(!yt(t.requested_tokens)||t.basis!=="canonical_retry")return!1;switch(t.minimum_status){case"exact":return yt(t.minimum_feasible_tokens)&&t.feasible_tokens===t.minimum_feasible_tokens&&t.reason===void 0;case"feasible_only":return t.minimum_feasible_tokens===null&&yt(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 ji="PmCliError";function pa(e){if(!Ui(e)||e.code!=="item_already_exists"||e.exitCode!==m.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 Li(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=m.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function $i(e){if(e==null)return{};if(!Object.hasOwn(e,"details"))return e;let t=Object.getOwnPropertyDescriptor(e,"details");if(!("value"in t))throw Un("unsupported_value","details");if(t.value===void 0)return e;let n=ht(t.value);if(n.ok)return{...e,details:n.details};if(n.omission.reason==="byte_limit"){let{details:r,...i}=e;return{...i,details_omitted:n.omission}}throw Un(n.omission.reason,n.omission.path)}function Un(e,t){let n=new TypeError(`createPmCliExpectedError options.context.details must be plain JSON (${e})`);return Object.defineProperty(n,"path",{value:t,enumerable:!1}),n}function ha(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let n=new f(e,Li(t.exitCode??m.USAGE),$i(t.context));return"cause"in t&&Object.defineProperty(n,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),n}function Ui(e){try{if(!(e instanceof Error)||e.name!==ji)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 Hi(e,t){let n=e.trim().toLowerCase();if(n.length===0)return;let r=Math.floor(n.length/3);return t.map(i=>({candidate:i,distance:ue(n,i.toLowerCase(),r)??Number.POSITIVE_INFINITY})).filter(({distance:i})=>Number.isFinite(i)).sort((i,o)=>i.distance!==o.distance?i.distance-o.distance:i.candidate.localeCompare(o.candidate))[0]?.candidate}function Hn(e){return["pm",...e].map(t=>/^[A-Za-z0-9_./:@=-]+$/u.test(t)?t:JSON.stringify(t)).join(" ")}function ba(e){let t=e.command_path.trim().replaceAll(/\s+/gu," "),n=e.token.trim(),r=n.length===0?"<empty>":n,i=[...new Set(e.allowed.map(l=>l.trim()))].filter(Boolean).sort((l,h)=>l.localeCompare(h));if(t.length===0||r.length===0||i.length===0)throw new TypeError("Unknown-subcommand contracts require a path, token, and allowed set");let o=t.split(" "),s=e.trailing_args??[],a=e.display_name??`pm ${t}`,d=e.token_kind??"subcommand",c=e.retry_command?void 0:Hi(r,i),p=Hn([...o,r,...s]),u=e.retry_command??(c?Hn([...o,c,...s]):void 0);return new f(`Unknown ${a} ${d} "${r}". Allowed: ${i.join(", ")}${e.message_suffix??""}`,e.exit_code??m.USAGE,{code:"unknown_subcommand",reason:"unknown_positional_token",value:r,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:i,suggested_retry:u,fallback_candidates:e.fallback_candidates}})}export{_e as a,ge as b,Xi as c,Gi as d,ba as e,dt as f,yi as g,Jt as h,ee as i,te as j,Zi as k,ne as l,En as m,ct as n,bn as o,Ko as p,ir as q,sr as r,ar as s,cr as t,dr as u,Je as v,bo as w,us as x,Oo as y,No as z,ko as A,fn as B,Sr as C,st as D,zo as E,at as F,De as G,ft as H,Tn as I,bi as J,Ii as K,Qs as L,Zs as M,On as N,vi as O,ea as P,ta as Q,na as R,ra as S,Pi as T,ma as U,ji as V,pa as W,ha as X,Ui as Y};
91
+ //# sourceMappingURL=chunk-5LDBS6MS.js.map
@@ -0,0 +1,3 @@
1
+ var y=["commands","renderers","hooks","schema","importers","search","parser","preflight","services"],F=2,g=Object.freeze({migration:"schema",validation:"schema"}),M=Object.freeze({version:2,capabilities:[...y],legacy_aliases:{...g}}),P=["off","warn","enforce"],U=["off","warn","enforce"],Y=["none","restricted","strict"],q=["block","warn"],W=["commands.override","commands.handler","hooks.beforecommand","hooks.beforemutation","hooks.aftercommand","hooks.onwrite","hooks.onread","hooks.onindex","schema.flags","schema.itemfields","schema.itemtypes","schema.relationshipkinds","schema.migrations","schema.profiles","parser.override","preflight.override","services.override","renderers.override","importers.importer","importers.exporter","search.provider","search.vectorstore","services.assuranceprovider"],X=["output_format","error_format","help_format","lock_acquire","lock_release","history_append","item_store_write","item_store_delete","context_relevance","command_result"];function E(){return{mode:"off",trust_mode:"off",require_provenance:!1,trusted_extensions:[],default_sandbox_profile:"none",allowed_extensions:[],blocked_extensions:[],allowed_capabilities:[],blocked_capabilities:[],allowed_surfaces:[],blocked_surfaces:[],allowed_commands:[],blocked_commands:[],allowed_actions:[],blocked_actions:[],allowed_services:[],blocked_services:[],extension_overrides:[]}}var h=["goal","objective","value","impact","outcome","why_now","parent","reviewer","risk","confidence","sprint","release","blocked_by","blocked_reason","unblock_note","reporter","severity","environment","repro_steps","resolution","expected_result","actual_result"],O=["id","title","description","type","pm_format_version","source_type","type_options","status","priority","tags","created_at","updated_at","deadline","reminders","events","closed_at","completed_at","assignee","claim_principal","source_owner","author","estimated_minutes","acceptance_criteria","deferred_fields","design","external_ref","definition_of_ready","order",...h,"affected_version","fixed_version","component","regression","customer_impact","dependencies","comments","notes","learnings","files","tests","test_runs","docs","close_reason","duplicate_of","plan_mode","plan_scope","plan_harness","plan_resume_context","plan_validation","plan_decisions","plan_discoveries","plan_steps"],N=O;var x=Object.freeze([{id:"draft",roles:["draft"]},{id:"open",roles:["active","default_open"]},{id:"in_progress",aliases:["in-progress"],roles:["active"]},{id:"blocked",roles:["blocked"]},{id:"closed",roles:["terminal","terminal_done","default_close"]},{id:"canceled",aliases:["cancelled"],roles:["terminal","terminal_canceled","default_cancel"]}]),A=Object.freeze({draft_status:"draft",open_status:"open",in_progress_status:"in_progress",blocked_status:"blocked",close_status:"closed",canceled_status:"canceled"}),G=".agents/pm",z="settings.json";var I=["","epics","features","tasks","chores","issues","schema","history","search","extensions","locks"],b=["decisions","events","reminders","milestones","meetings","plans"],V=[...I,...b],$={Epic:"epics",Feature:"features",Task:"tasks",Chore:"chores",Issue:"issues",Decision:"decisions",Event:"events",Reminder:"reminders",Milestone:"milestones",Meeting:"meetings",Plan:"plans"},S={minimal:{ownership_enforcement:"none",create_mode_default:"progressive",close_validation_default:"off",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!1,duplicate_detection_mode:"off",duplicate_detection_threshold:.8,duplicate_detection_limit:3},default:{ownership_enforcement:"warn",create_mode_default:"progressive",close_validation_default:"warn",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"core",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3},strict:{ownership_enforcement:"strict",create_mode_default:"strict",close_validation_default:"strict",require_close_reason:!0,parent_reference:"strict_error",metadata_profile:"strict",force_required_for_stale_lock:!0,duplicate_detection_mode:"strict",duplicate_detection_threshold:.8,duplicate_detection_limit:3}},R=["no active blocker","ready for planned execution sequencing","work completed","work is closed"],f={blocked_reason:["no active blocker because work is closed","work is closed"],resolution:["closed with implementation evidence","closed with verification evidence","work completed and recorded","work is closed"],actual_result:["closed and recorded","work completed","work completed and recorded"]};function w(e){return e?[...e]:void 0}var Q={version:1,id_prefix:"pm-",ids:{token_length:4},author_default:"",agent_identity:{probes_enabled:!0,identity_vocabulary:{version:1,aliases:{}},harness_signals:[]},mutation_guard:{require_attributed_author:!1,secret_guard:"advise",stale_in_progress_hours:72},item_format:"toon",locks:{ttl_seconds:1800,wait_ms:3e3},checkpoints:{retention_days:14},output:{default_format:"toon"},ux:{deprecation_hints:!0},history:{missing_stream:"auto_create",compact_policy:{enabled:!1,max_entries:500,trigger:"health_warn"}},validation:{sprint_release_format:"warn",parent_reference:"warn",metadata_profile:"core",metadata_required_fields:[],lifecycle_stale_blocker_reason_patterns:[...R],lifecycle_closure_like_blocked_reason_patterns:[...f.blocked_reason],lifecycle_closure_like_resolution_patterns:[...f.resolution],lifecycle_closure_like_actual_result_patterns:[...f.actual_result],estimate_defaults_by_type:{}},governance:{preset:"minimal",...S.minimal},workflow:{definition_of_done:[]},testing:{record_results_to_items:!1,allow_untrusted_linked_tests:!1},telemetry:{enabled:!0,first_run_prompt_completed:!1,capture_level:"redacted",endpoint:"https://pm-cli.unbrained.dev/v1/events",installation_id:"",retention_days:365},agent_guidance:{prompt_completed:!1,declined:!1,declined_at:"",template_version:1,last_checked_files:[]},item_types:{definitions:[]},schema:{version:1,files:{types:"schema/types.json",statuses:"schema/statuses.json",fields:"schema/fields.json",workflows:"schema/workflows.json"},statuses:x.map(e=>({...e,aliases:w(e.aliases),roles:w(e.roles)})),fields:[],workflow:{...A},unknown_field_policy:"allow"},extensions:{enabled:[],disabled:[],policy:E()},search:{score_threshold:0,hybrid_semantic_weight:.7,max_results:50,embedding_model:"",embedding_batch_size:32,embedding_timeout_ms:3e4,scanner_max_batch_retries:3,provider:"",default_mode:"auto",mutation_refresh_policy:"semantic_configured",query_expansion:{enabled:!1,provider:""},rerank:{enabled:!1,model:"",top_k:20}},providers:{openai:{base_url:"",api_key:"",model:""},ollama:{base_url:"",model:""}},context:{default_depth:"brief",activity_limit:10,stale_threshold_days:7,next_ranking_policy:"priority_floor",sections:{hierarchy:!0,activity:!0,progress:!0,recently_created:!0,unparented:!0,blockers:!0,files:!0,workload:!0,staleness:!0,tests:!0}},vector_store:{adapter:"",collection_name:"pm_items",qdrant:{url:"",api_key:""},lancedb:{path:""}}},J={metadata:{},body:""},v={SUCCESS:0,GENERIC_FAILURE:1,USAGE:2,NOT_FOUND:3,CONFLICT:4,DEPENDENCY_FAILED:5,NO_EFFECT:6,PARTIAL_EFFECT:7},Z=Object.freeze({unknown_command:"usage",unknown_option:"usage",missing_required_option:"usage",missing_required_argument:"usage",invalid_command_usage:"usage",linked_test_value_not_quoted:"usage",invalid_argument_value:"validation",health_findings:"validation",validation_findings:"validation",close_through_update:"validation",no_update_fields:"validation",unsupported_update_option:"validation",tracker_not_initialized:"validation",item_not_found:"validation",ownership_conflict:"conflict",lock_conflict:"conflict",terminal_state_conflict:"conflict",dependency_failed:"runtime",init_gitignore_unwritable:"runtime",merge_git_config_unwritable:"runtime",command_failed:"runtime",unknown_error:"runtime"});var u=class extends Error{exitCode;code;context;constructor(t,o,s={}){super(t),this.name="PmCliError",this.exitCode=o,this.context=s,this.code=s.code}};import*as r from"node:fs/promises";import{constants as m}from"node:fs";import l from"node:path";import D from"node:crypto";var C=[10,25,50,100];async function T(e){await r.mkdir(e,{recursive:!0})}async function ae(e){try{return await r.access(e),!0}catch{return!1}}function k(e){return L(e)||c(e,"ENOTDIR")}function L(e){return c(e,"ENOENT")}async function ce(e){try{return await r.readFile(e,"utf8")}catch(t){if(k(t))return null;throw t}}async function le(e,t){let o=await r.open(e,m.O_RDONLY|m.O_NOFOLLOW|m.O_NONBLOCK);try{if(!(await o.stat()).isFile())throw t;return await o.readFile("utf8")}finally{await o.close()}}function _e(e){let t=e?.replaceAll(l.sep,"/"),o=t!==void 0&&!l.posix.isAbsolute(t)&&!l.win32.isAbsolute(t)&&!t.split("/").includes(".."),s=o?t.split("/")[0]:void 0,i={"settings.json":"settings",runtime:"runtime",schema:"schema",history:"history",transactions:"transactions"},n=s===void 0?"tracker_storage":Object.hasOwn(i,s)?i[s]:"tracker_storage",_=o&&t.length>0&&t.length<=160&&t.split("/").every(a=>a!=="."&&/^[a-zA-Z0-9_.-]+$/u.test(a)),d=_?t:`${n} (entry name redacted)`;return new u(`Transaction preview requires regular files and directories. Inspect ${d} relative to the selected tracker root.`,v.USAGE,{code:"transaction_preview_non_regular_file",preview_storage:{storage_area:n,..._?{relative_entry:t}:{},entry_redacted:!_},required:"regular files and directories within the configured tracker storage",why:"Preview does not follow linked entries or read special files.",nextSteps:[`Inspect ${d} within the selected tracker for links, directories used as files, or special files; do not follow link targets.`,"Restore the intended regular files and directories, then retry the original dry-run command."]})}async function p(e){try{await r.unlink(e)}catch{}}async function de(e,t,o={}){let s=l.dirname(e);o.createParentDirectories!==!1&&await T(s);let i=l.join(s,`.${l.basename(e)}.${process.pid}.${Date.now()}.${D.randomBytes(4).toString("hex")}.tmp`);try{await r.writeFile(i,t,o.mode===void 0?"utf8":{encoding:"utf8",mode:o.mode})}catch(n){throw await p(i),n}try{await r.rename(i,e)}catch(n){if(process.platform==="win32"&&(c(n,"EPERM")||c(n,"EBUSY"))){let _=n;for(let d of C){await new Promise(a=>setTimeout(a,d));try{await r.rename(i,e);return}catch(a){if(_=a,!c(a,"EPERM")&&!c(a,"EBUSY"))break}}throw await p(i),_}if(c(n,"EXDEV")){try{await r.copyFile(i,e)}finally{await p(i)}return}throw await p(i),n}}async function ue(e,t){let o=l.dirname(e);await T(o);let s=await r.open(e,"a");try{await s.writeFile(`${t}
2
+ `,"utf8")}finally{await s.close()}}async function pe(e){try{await r.unlink(e)}catch(t){if(!k(t))throw t}}function c(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}export{y as a,F as b,g as c,M as d,P as e,U as f,Y as g,q as h,W as i,X as j,E as k,h as l,N as m,x as n,A as o,G as p,z as q,I as r,V as s,$ as t,S as u,R as v,f as w,Q as x,J as y,v as z,u as A,T as B,ae as C,k as D,L as E,ce as F,le as G,_e as H,de as I,ue as J,pe as K};
3
+ //# sourceMappingURL=chunk-A6VEMCRR.js.map
@@ -0,0 +1,3 @@
1
+ import{execFile as d}from"node:child_process";import p from"node:path";import{promisify as g}from"node:util";import{setTimeout as _}from"node:timers/promises";var s=g(d);async function c(e,r){let t=performance.now()+5e3,o=25;for(;;)try{await s("git",["config",...r],{cwd:e,env:{...l(),LC_ALL:"C"},timeout:1e4});return}catch(n){let i=t-performance.now();if(typeof n!="object"||n===null||!("stderr"in n)||typeof n.stderr!="string"||!/could not lock config file [^\r\n]+: File exists/u.test(n.stderr)||i<=0)throw n;await _(Math.min(o,i)),o=Math.min(o*2,200)}}function I(e,r=process.platform){let t=e.endsWith(`
2
+ `)?e.slice(0,-1):e;return r==="win32"&&t.endsWith("\r")?t.slice(0,-1):t}function l(){let e={...process.env};for(let r of["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_NAMESPACE","GIT_CEILING_DIRECTORIES","GIT_DISCOVERY_ACROSS_FILESYSTEM"])delete e[r];return e}async function f(e,r){try{return(await s("git",["config","--local",...r==="core.bare"||r==="extensions.worktreeConfig"?["--type=bool"]:[],"--get",r],{cwd:e,env:l(),timeout:1e4})).stdout.trim()}catch(t){if(typeof t=="object"&&t!==null&&"code"in t&&t.code===1)return;throw t}}async function y(e){if(await f(e,"extensions.worktreeConfig")==="true")return"--worktree";let r=async i=>I((await s("git",["rev-parse","--path-format=absolute",i],{cwd:e,env:l(),timeout:1e4})).stdout),t=await r("--git-dir"),o=await r("--git-common-dir");if(t===o)return"--local";let n=p.join(o,"config.worktree");for(let i of["core.bare","core.worktree"]){let a=await f(e,i);a===void 0||i==="core.bare"&&a!=="true"||(await c(e,["--file",n,i,a]),await c(e,["--local","--unset-all",i]))}for(let i of["pm-item-toon","pm-item-markdown","pm-history","pm-relationship","pm-json"])for(let a of["name","driver"]){let m=`merge.${i}.${a}`,u=await f(e,m);u!==void 0&&await c(e,["--file",n,m,u])}return await c(e,["--local","extensions.worktreeConfig","true"]),"--worktree"}export{c as a,I as b,l as c,y as d};
3
+ //# sourceMappingURL=chunk-AIDL2ZNT.js.map