@unbrained/pm-cli 2026.11.7 → 2026.11.9

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 (259) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +84 -48
  3. package/dist/cli/extension-command-help.js +4 -3
  4. package/dist/cli/help-json-payload.js +1 -1
  5. package/dist/cli/main.js +1 -1
  6. package/dist/cli/register-annotations.js +1 -1
  7. package/dist/cli/register-list-query.js +5 -5
  8. package/dist/cli/runtime/annotation-option-retry.js +2 -0
  9. package/dist/cli/runtime/invocation-options.js +1 -1
  10. package/dist/cli/runtime/projection-retry.js +1 -1
  11. package/dist/cli/runtime/read-output-mutation-retry.js +2 -0
  12. package/dist/cli-bundle/bundle-manifest.json +1 -1
  13. package/dist/cli-bundle/chunks/chunk-3BMIAI4P.js +8 -0
  14. package/dist/cli-bundle/chunks/chunk-5VRJPPUC.js +2 -0
  15. package/dist/cli-bundle/chunks/{chunk-WXVMPLBY.js → chunk-6V4PGJBZ.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-F3B2ULHB.js → chunk-ASJZMYKM.js} +33 -33
  17. package/dist/cli-bundle/chunks/chunk-BLUCQ4T4.js +2 -0
  18. package/dist/cli-bundle/chunks/chunk-ELNWRSGZ.js +9 -0
  19. package/dist/cli-bundle/chunks/{chunk-RFI4O6NU.js → chunk-EZRLW4R6.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-OJZG7Y6S.js → chunk-G6Q4VQSI.js} +2 -2
  21. package/dist/cli-bundle/chunks/chunk-GCPP37N6.js +116 -0
  22. package/dist/cli-bundle/chunks/{chunk-OIBSKKCO.js → chunk-GDQ2T2OR.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-KPAVZILX.js → chunk-GZVOOHTO.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-3DI6CEF3.js → chunk-IGT252ES.js} +2 -2
  25. package/dist/cli-bundle/chunks/chunk-JK7O7MFO.js +31 -0
  26. package/dist/cli-bundle/chunks/{chunk-MQOZNGPS.js → chunk-JYQXIC6C.js} +2 -2
  27. package/dist/cli-bundle/chunks/{chunk-XSEDESNW.js → chunk-LVDFPGD7.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-QG6FLDM4.js → chunk-MSJ7IHMJ.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-BQ5O3CBF.js → chunk-O2M3TNFY.js} +69 -65
  30. package/dist/cli-bundle/chunks/chunk-UFIM5ZC5.js +6 -0
  31. package/dist/cli-bundle/chunks/chunk-VATZTJE3.js +2 -0
  32. package/dist/cli-bundle/chunks/{chunk-WS2N4TQW.js → chunk-XKY4LUXN.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-VM6OGNQC.js → chunk-YK5GAWOT.js} +2 -2
  34. package/dist/cli-bundle/chunks/{chunk-TGQPCNAD.js → chunk-YV5ALMG2.js} +2 -2
  35. package/dist/cli-bundle/chunks/{chunk-ETHAZC3F.js → chunk-Z3QEEOAM.js} +2 -2
  36. package/dist/cli-bundle/chunks/item-revision-Y5CE3EIN.js +2 -0
  37. package/dist/cli-bundle/chunks/item-transaction-XBIN4KYM.js +2 -0
  38. package/dist/cli-bundle/chunks/{mutation-admission-LUXUKISJ.js → mutation-admission-TAQN2AKK.js} +2 -2
  39. package/dist/cli-bundle/chunks/register-list-query-XMQYFUFI.js +11 -0
  40. package/dist/cli-bundle/chunks/register-mutation-OBVCFLDK.js +20 -0
  41. package/dist/cli-bundle/chunks/{register-operations-AHDWE2G3.js → register-operations-CGNFZ6DR.js} +2 -2
  42. package/dist/cli-bundle/chunks/{register-setup-7BGG3CI3.js → register-setup-LFB5ERXH.js} +2 -2
  43. package/dist/cli-bundle/chunks/{stage-S5BYWLGY.js → stage-NQHF6JPC.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-2SQUWQP3.js +26 -0
  45. package/dist/cli-bundle/focused-chunks/chunk-4FWMXQN3.js +12 -0
  46. package/dist/cli-bundle/focused-chunks/chunk-AH5IST3V.js +2 -0
  47. package/dist/cli-bundle/focused-chunks/{chunk-4EXRRSDS.js → chunk-ALLOWZSH.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/{chunk-IYJRFJHT.js → chunk-C3DO4ZGZ.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/chunk-CUGJ2DY2.js +24 -0
  50. package/dist/cli-bundle/focused-chunks/chunk-HLQOGAWG.js +26 -0
  51. package/dist/cli-bundle/focused-chunks/chunk-HNFY3XLC.js +2 -0
  52. package/dist/cli-bundle/focused-chunks/chunk-IB6TCE7N.js +2 -0
  53. package/dist/cli-bundle/focused-chunks/{chunk-LW4TN5ZM.js → chunk-IS5FLEZW.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/chunk-J7PWHKZK.js +91 -0
  55. package/dist/cli-bundle/focused-chunks/chunk-JU62TKJP.js +82 -0
  56. package/dist/cli-bundle/focused-chunks/chunk-LDMBNTOG.js +2 -0
  57. package/dist/cli-bundle/focused-chunks/chunk-LWMPQRJT.js +2 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-MYBKRV5R.js +2 -0
  59. package/dist/cli-bundle/focused-chunks/chunk-NUFO3OR6.js +44 -0
  60. package/dist/cli-bundle/focused-chunks/chunk-NZQYHPUN.js +3 -0
  61. package/dist/cli-bundle/focused-chunks/{chunk-JRJOFMI7.js → chunk-Q45LDP7P.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/chunk-QWUWNFQO.js +2 -0
  63. package/dist/cli-bundle/focused-chunks/chunk-RNZUORGI.js +2 -0
  64. package/dist/cli-bundle/focused-chunks/{chunk-G2VIY6XA.js → chunk-UIKLNSW3.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-BIDF4KO7.js → chunk-XLSTFUXM.js} +8 -8
  66. package/dist/cli-bundle/focused-chunks/item-revision-M6FOLME2.js +2 -0
  67. package/dist/cli-bundle/focused-chunks/item-transaction-H6VA5JGB.js +2 -0
  68. package/dist/cli-bundle/focused-chunks/mutation-admission-PRTQWQK6.js +2 -0
  69. package/dist/cli-bundle/focused-chunks/stage-7T77PSJD.js +2 -0
  70. package/dist/cli-bundle/main.js +32 -31
  71. package/dist/cli-bundle/sdk-authoring.js +1 -1
  72. package/dist/cli-bundle/sdk-contracts.js +4 -4
  73. package/dist/cli-bundle/sdk-core.js +1 -1
  74. package/dist/cli-bundle/sdk-governance.js +1 -1
  75. package/dist/cli-bundle/sdk-graph.js +1 -1
  76. package/dist/cli-bundle/sdk-merge.js +57 -57
  77. package/dist/cli-bundle/sdk-query.js +1 -1
  78. package/dist/cli-bundle/sdk-runtime.js +1 -1
  79. package/dist/cli-bundle/sdk-testing.js +1 -1
  80. package/dist/cli-bundle/sdk.js +12 -12
  81. package/dist/core/extensions/flag-definition-validation.js +1 -1
  82. package/dist/core/extensions/reserved-host-flags.js +1 -1
  83. package/dist/core/history/history-stream-policy.d.ts +12 -3
  84. package/dist/core/history/history-stream-policy.js +1 -1
  85. package/dist/core/history/projection.d.ts +7 -2
  86. package/dist/core/history/projection.js +1 -1
  87. package/dist/core/item/item-format.d.ts +13 -1
  88. package/dist/core/item/item-format.js +2 -2
  89. package/dist/core/lock/lock.d.ts +1 -1
  90. package/dist/core/lock/lock.js +1 -1
  91. package/dist/core/output/output.d.ts +17 -1
  92. package/dist/core/output/output.js +7 -7
  93. package/dist/core/search/corpus.js +1 -1
  94. package/dist/core/search/providers.d.ts +3 -2
  95. package/dist/core/search/providers.js +1 -1
  96. package/dist/core/search/vector-stores.d.ts +3 -2
  97. package/dist/core/search/vector-stores.js +1 -1
  98. package/dist/core/sentry/instrument.d.ts +2 -1
  99. package/dist/core/sentry/instrument.js +1 -1
  100. package/dist/mcp/tool-definitions.js +1 -1
  101. package/dist/sdk/annotations.d.ts +44 -1
  102. package/dist/sdk/annotations.js +1 -1
  103. package/dist/sdk/authoring.d.ts +6 -0
  104. package/dist/sdk/authoring.js +1 -1
  105. package/dist/sdk/cli-contracts/flag-contracts.d.ts +15 -0
  106. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  107. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  108. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +6 -0
  109. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  110. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  111. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  112. package/dist/sdk/command-line.d.ts +2 -1
  113. package/dist/sdk/command-line.js +1 -1
  114. package/dist/sdk/comments.d.ts +4 -2
  115. package/dist/sdk/comments.js +1 -1
  116. package/dist/sdk/completion/bash.js +1 -1
  117. package/dist/sdk/completion/fish.js +2 -1
  118. package/dist/sdk/completion/zsh.js +4 -1
  119. package/dist/sdk/context-intent-contracts.d.ts +5 -1
  120. package/dist/sdk/context-intent-contracts.js +1 -1
  121. package/dist/sdk/contracts.d.ts +3 -0
  122. package/dist/sdk/contracts.js +1 -1
  123. package/dist/sdk/core.d.ts +14 -0
  124. package/dist/sdk/core.js +1 -1
  125. package/dist/sdk/corpus-shape.d.ts +2 -2
  126. package/dist/sdk/corpus-shape.js +1 -1
  127. package/dist/sdk/define.d.ts +14 -8
  128. package/dist/sdk/define.js +1 -1
  129. package/dist/sdk/extension/command-options.d.ts +123 -0
  130. package/dist/sdk/extension/command-options.js +2 -0
  131. package/dist/sdk/extension-contracts.d.ts +1 -2
  132. package/dist/sdk/extension-contracts.js +1 -1
  133. package/dist/sdk/generated/error-code-catalog-rows.js +1 -1
  134. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  135. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  136. package/dist/sdk/governance.d.ts +8 -0
  137. package/dist/sdk/governance.js +1 -1
  138. package/dist/sdk/graph.d.ts +5 -0
  139. package/dist/sdk/graph.js +1 -1
  140. package/dist/sdk/index.d.ts +61 -1
  141. package/dist/sdk/index.js +1 -1
  142. package/dist/sdk/learnings.d.ts +4 -2
  143. package/dist/sdk/learnings.js +1 -1
  144. package/dist/sdk/lifecycle/item-revision.d.ts +6 -0
  145. package/dist/sdk/lifecycle/item-revision.js +1 -1
  146. package/dist/sdk/lifecycle/restore.d.ts +1 -1
  147. package/dist/sdk/merge.d.ts +3 -0
  148. package/dist/sdk/merge.js +1 -1
  149. package/dist/sdk/notes.d.ts +4 -2
  150. package/dist/sdk/notes.js +1 -1
  151. package/dist/sdk/public-surface.json +1 -1
  152. package/dist/sdk/query/get-facet-roots.js +2 -0
  153. package/dist/sdk/query/get.js +1 -1
  154. package/dist/sdk/query/list.d.ts +5 -1
  155. package/dist/sdk/query/list.js +1 -1
  156. package/dist/sdk/query/search/semantic.d.ts +11 -3
  157. package/dist/sdk/query/search/semantic.js +1 -1
  158. package/dist/sdk/query/search-rendering.d.ts +9 -3
  159. package/dist/sdk/query/search-rendering.js +1 -1
  160. package/dist/sdk/query.d.ts +11 -0
  161. package/dist/sdk/query.js +1 -1
  162. package/dist/sdk/read-output/continuation.d.ts +8 -0
  163. package/dist/sdk/read-output/continuation.js +1 -1
  164. package/dist/sdk/read-output/options.d.ts +1 -1
  165. package/dist/sdk/read-output/options.js +1 -1
  166. package/dist/sdk/read-output/positional-rows.js +2 -0
  167. package/dist/sdk/read-output/surfaces.js +1 -1
  168. package/dist/sdk/read-output/tail-retention.d.ts +34 -0
  169. package/dist/sdk/read-output/tail-retention.js +2 -0
  170. package/dist/sdk/read-output-budget.d.ts +14 -2
  171. package/dist/sdk/read-output-budget.js +1 -1
  172. package/dist/sdk/read-output-contracts.d.ts +24 -4
  173. package/dist/sdk/read-output-contracts.js +1 -1
  174. package/dist/sdk/read-output-rows.d.ts +7 -3
  175. package/dist/sdk/read-output-rows.js +1 -1
  176. package/dist/sdk/runtime/actions.js +1 -1
  177. package/dist/sdk/runtime-input.js +1 -1
  178. package/dist/sdk/runtime.d.ts +26 -3
  179. package/dist/sdk/runtime.js +1 -1
  180. package/dist/sdk/test/execution.d.ts +29 -2
  181. package/dist/sdk/test/execution.js +1 -1
  182. package/dist/sdk/testing.d.ts +14 -1
  183. package/dist/sdk/testing.js +1 -1
  184. package/dist/sdk/traceability/source-traceability.d.ts +4 -1
  185. package/dist/sdk/traceability/source-traceability.js +1 -1
  186. package/dist/sdk/workspace-recipe.d.ts +2 -2
  187. package/dist/sdk/workspace-recipe.js +1 -1
  188. package/docs/AGENT_OUTPUT_ENCODINGS.md +16 -0
  189. package/docs/ARCHITECTURE.md +2 -1
  190. package/docs/COMMANDS.md +4 -1
  191. package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +1 -1
  192. package/docs/EXTENSIONS.md +1 -1
  193. package/docs/MCP_OPTION_CONFORMANCE.md +13 -0
  194. package/docs/README.md +2 -2
  195. package/docs/READ_OUTPUT_CONTRACTS.md +99 -0
  196. package/docs/RELEASING.md +27 -5
  197. package/docs/SDK.md +100 -2
  198. package/docs/SDK_CONTEXT_INTEGRITY.md +2 -0
  199. package/docs/agent-task-token-baseline.json +1 -1
  200. package/docs/generated/FLAG_LEXICON_BUDGETS.md +6 -6
  201. package/marketplace.json +1 -1
  202. package/package.json +3 -1
  203. package/packages/pm-beads/package.json +1 -1
  204. package/packages/pm-calendar/package.json +1 -1
  205. package/packages/pm-command-kit/package.json +1 -1
  206. package/packages/pm-digital-twin/package.json +1 -1
  207. package/packages/pm-governance-audit/package.json +1 -1
  208. package/packages/pm-guide-shell/package.json +1 -1
  209. package/packages/pm-kanban/package.json +1 -1
  210. package/packages/pm-lifecycle-hooks/package.json +1 -1
  211. package/packages/pm-linked-test-adapters/package.json +1 -1
  212. package/packages/pm-search-advanced/package.json +1 -1
  213. package/packages/pm-templates/package.json +1 -1
  214. package/packages/pm-todos/package.json +1 -1
  215. package/packages/pm-vcs/package.json +1 -1
  216. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  217. package/plugins/pm-claude/package.json +1 -1
  218. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  219. package/plugins/pm-codex/package.json +1 -1
  220. package/plugins/pm-codex/plugin.json +1 -1
  221. package/runtime-dependencies.json +1 -1
  222. package/dist/cli/extension-command-options.js +0 -2
  223. package/dist/cli-bundle/chunks/chunk-4PPWVIIT.js +0 -2
  224. package/dist/cli-bundle/chunks/chunk-5KHLV7JU.js +0 -116
  225. package/dist/cli-bundle/chunks/chunk-COKKWMSC.js +0 -8
  226. package/dist/cli-bundle/chunks/chunk-D53G3NOE.js +0 -6
  227. package/dist/cli-bundle/chunks/chunk-JZWFZH2K.js +0 -2
  228. package/dist/cli-bundle/chunks/chunk-O6TIOKCM.js +0 -9
  229. package/dist/cli-bundle/chunks/chunk-WYIDX67P.js +0 -31
  230. package/dist/cli-bundle/chunks/item-revision-SPEKTFBB.js +0 -2
  231. package/dist/cli-bundle/chunks/item-transaction-BT55TQXE.js +0 -2
  232. package/dist/cli-bundle/chunks/register-list-query-DU4W7VJU.js +0 -11
  233. package/dist/cli-bundle/chunks/register-mutation-IC2C53QK.js +0 -20
  234. package/dist/cli-bundle/focused-chunks/chunk-4LDOL6U7.js +0 -26
  235. package/dist/cli-bundle/focused-chunks/chunk-4PW5XWVI.js +0 -2
  236. package/dist/cli-bundle/focused-chunks/chunk-A46YSPRF.js +0 -2
  237. package/dist/cli-bundle/focused-chunks/chunk-AI2PYNFI.js +0 -2
  238. package/dist/cli-bundle/focused-chunks/chunk-AJ2I377F.js +0 -44
  239. package/dist/cli-bundle/focused-chunks/chunk-CWFNQQZE.js +0 -3
  240. package/dist/cli-bundle/focused-chunks/chunk-D3U7FOZR.js +0 -2
  241. package/dist/cli-bundle/focused-chunks/chunk-GFF6BITP.js +0 -2
  242. package/dist/cli-bundle/focused-chunks/chunk-IIBWXNW3.js +0 -3
  243. package/dist/cli-bundle/focused-chunks/chunk-J5N42SKC.js +0 -3
  244. package/dist/cli-bundle/focused-chunks/chunk-KL33JMPC.js +0 -2
  245. package/dist/cli-bundle/focused-chunks/chunk-LH4C7BLB.js +0 -2
  246. package/dist/cli-bundle/focused-chunks/chunk-LTQEYE2L.js +0 -81
  247. package/dist/cli-bundle/focused-chunks/chunk-LTTMERPN.js +0 -12
  248. package/dist/cli-bundle/focused-chunks/chunk-MESFDQ3H.js +0 -26
  249. package/dist/cli-bundle/focused-chunks/chunk-MWTBAI3V.js +0 -2
  250. package/dist/cli-bundle/focused-chunks/chunk-TWULNB3N.js +0 -2
  251. package/dist/cli-bundle/focused-chunks/chunk-XAC6NP7U.js +0 -2
  252. package/dist/cli-bundle/focused-chunks/chunk-XG3TBYQK.js +0 -23
  253. package/dist/cli-bundle/focused-chunks/chunk-XMZAFKVP.js +0 -91
  254. package/dist/cli-bundle/focused-chunks/item-revision-ELI6NGMY.js +0 -2
  255. package/dist/cli-bundle/focused-chunks/item-transaction-GUGAUY77.js +0 -2
  256. package/dist/cli-bundle/focused-chunks/mutation-admission-54FI37AA.js +0 -2
  257. package/dist/cli-bundle/focused-chunks/stage-OHDJ43T2.js +0 -2
  258. package/docs/ECOSYSTEM_PLANNING_REVIEW.md +0 -274
  259. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +0 -472
@@ -0,0 +1,2 @@
1
+ import{$a as m,Za as b,ab as f,bb as k,lb as u}from"./chunk-2SQUWQP3.js";import{z as a}from"./chunk-G6ERMFJ5.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7c95b311-b408-50f7-87e8-2c2fa2323092")}catch{}})();var D=[{exit_code:a.SUCCESS,outcome:"effect",success:!0,meaning:"The requested operation completed with its intended effect."},{exit_code:a.GENERIC_FAILURE,outcome:"internal_failure",success:!1,meaning:"An unexpected runtime or internal failure prevented completion."},{exit_code:a.USAGE,outcome:"refused_input",success:!1,meaning:"The invocation was refused because its input or composition was invalid."},{exit_code:a.NOT_FOUND,outcome:"refused_tracker_state",success:!1,meaning:"The requested tracker, item, or resource was not present."},{exit_code:a.CONFLICT,outcome:"conflict",success:!1,meaning:"Current state or concurrency prevented the requested effect."},{exit_code:a.DEPENDENCY_FAILED,outcome:"dependency_failed",success:!1,meaning:"A required dependency operation failed."},{exit_code:a.NO_EFFECT,outcome:"no_effect",success:!0,meaning:"The request was valid and completed, but matched nothing to change."},{exit_code:a.PARTIAL_EFFECT,outcome:"partial_effect",success:!0,meaning:"The request completed and changed some, but not all, selected targets."}],h=[a.SUCCESS,a.GENERIC_FAILURE,a.USAGE,a.NOT_FOUND,a.CONFLICT,a.DEPENDENCY_FAILED],P=new Set(["close-many","update-many"]),w=u.map(e=>({command:e,exit_codes:P.has(e)?[...h,a.NO_EFFECT,a.PARTIAL_EFFECT]:[...h]})),v=new Map(w.map(e=>[e.command,e])),R=[a.SUCCESS,a.NO_EFFECT,a.PARTIAL_EFFECT];function Ee(e){return R.includes(e)}function Te(e){return D.some(t=>t.exit_code===e)}function Ae(e){let t=e.trim().toLowerCase().split(/\s+/u).filter(Boolean).join(" ");return v.get(t)??v.get(t.split(" ")[0])}function Oe(e,t=u,s=w){let o=new Map(s.map(c=>[c.command,c])),i=t.filter(c=>!o.has(c)),r=e.filter(c=>{let n=o.get(c.command)??o.get(c.command.split(" ")[0]);return n===void 0||!n.exit_codes.includes(c.exit_code)}),d=new Set(e.map(c=>c.exit_code)),_=[...new Set(s.flatMap(c=>c.exit_codes))].filter(c=>!d.has(c)).sort((c,n)=>c-n);return{ok:i.length===0&&r.length===0&&_.length===0,missing_commands:i,undeclared_observations:r,unreachable_exit_codes:_}}function Se(e){return e.applied===0&&e.failed>0?{outcome:"dependency_failed",exit_code:a.DEPENDENCY_FAILED}:e.applied===0?{outcome:"no_effect",exit_code:a.NO_EFFECT}:e.skipped>0||e.failed>0||e.unmatched>0?{outcome:"partial_effect",exit_code:a.PARTIAL_EFFECT}:{outcome:"effect",exit_code:a.SUCCESS}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="7df4fe91-e8a4-540f-8737-c67f2efa460e")}catch{}})();var x=[{exit_code:1,class:"generic_failure"},{exit_code:2,class:"usage"},{exit_code:3,class:"not_found"},{exit_code:4,class:"conflict"},{exit_code:5,class:"dependency_failed"}],L=new Map(x.map(e=>[e.exit_code,e.class]));function g(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].sort()}function q(e){if(!e)return[];let t=new Set,s=new Set;return e.map(o=>{let i=o.state.trim(),r=o.probe_id.trim(),d=g(o.entrypoints);if(!/^[a-z][a-z0-9_]*$/.test(i)||!/^[a-z][a-z0-9-]*$/.test(r)||d.length===0||t.has(i)||s.has(r))throw new TypeError("Invalid pm refusal state contract");return t.add(i),s.add(r),{state:i,probe_id:r,entrypoints:d,expected_exit_class:o.expected_exit_class}}).sort((o,i)=>o.state.localeCompare(i.state))}function F(e,t,s,o,i){return![[1,2,3,4,5].includes(e.exit_code),e.meaning.trim().length>0,e.recovery.trim().length>0,t.length>0,s.length>0,/^[a-z][a-z0-9_]*$/.test(o),i.every(r=>/^[a-z][a-z0-9_]*$/.test(r)),L.get(e.exit_code)===e.class].includes(!1)}function j(e,t){let s=e,o=new Set;for(;s.canonical_code!==s.code;){if(o.has(s.code))throw new TypeError(`Alias cycle in pm error code catalog: ${e.code}`);o.add(s.code);let i=t.get(s.canonical_code);if(!i)throw new TypeError(`Invalid pm error code contract: ${e.code}`);s=i}return s}function $(e){let t=new Map(e.map(s=>[s.code,s]));for(let s of e){let o=j(s,t);if(o.exit_code!==s.exit_code||o.class!==s.class)throw new TypeError(`Alias transport mismatch for pm error code: ${s.code}`);let i=e.filter(r=>r.code!==o.code&&r.canonical_code===o.code).map(r=>r.code).sort();if(s.code===o.code?JSON.stringify(s.aliases)!==JSON.stringify(i):s.aliases.length>0)throw new TypeError(`Invalid pm error code contract: ${s.code}`)}}function E(e){let t=new Set,s=e.map(o=>{let i=o.code.trim();if(!/^[a-z][a-z0-9_]*$/.test(i))throw new TypeError(`Invalid pm error code: ${JSON.stringify(o.code)}`);if(t.has(i))throw new TypeError(`Duplicate pm error code: ${i}`);t.add(i);let r=g(o.sources),d=g(o.emitting_commands),_=(o.canonical_code??i).trim(),c=g(o.aliases??[]),n=q(o.owned_states);if(!F(o,r,d,_,c))throw new TypeError(`Invalid pm error code contract: ${i}`);if(n.some(l=>l.expected_exit_class!==o.class))throw new TypeError(`Invalid pm refusal state exit class: ${i}`);return Object.freeze({...o,code:i,meaning:o.meaning.trim(),recovery:o.recovery.trim(),sources:r,emitting_commands:d,canonical_code:_,aliases:c,owned_states:n})});return $(s),Object.freeze(s.sort((o,i)=>o.code.localeCompare(i.code)))}function Ne(e,t){let s=C(e,t);return C(s.canonical_code??s.code,t)}function C(e,t){let s=e.trim(),o=t.find(i=>i.code===s);if(!o)throw new TypeError(`Unknown pm error code "${s}"`);return o}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0b0d726a-0fd5-5196-bee1-d34c433c0016")}catch{}})();var z="Inspect the structured error guidance, then retry the suggested command when one is present.",U=new Map(x.map(e=>[e.exit_code,e.class]));function T(e){return e.map(t=>{let s=`${t.code.replaceAll("_"," ")} condition.`,o={code:t.code,meaning:`${s.charAt(0).toUpperCase()}${s.slice(1)}`,stability:t.stable?"stable":"provisional",exit_code:t.exit_code,class:U.get(t.exit_code),recovery:z,sources:t.sources,emitting_commands:t.emitting_commands??["*"],canonical_code:t.canonical_code??t.code,aliases:t.aliases??[]};return t.owned_states&&(o.owned_states=t.owned_states),o})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="785ecacc-6f06-5d01-90c7-d29d23f796bf")}catch{}})();var A=[{code:"acceptance_criteria_mutation_conflict",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_remove_unmatched",exit_code:3,sources:["sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts"],emitting_commands:["update","update-many"]},{code:"acceptance_criteria_semicolon_forbidden",exit_code:2,stable:!0,sources:["core/item/parse.ts"]},{code:"accepted_rejected_value",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"alias_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"alias_target_missing",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"already_claimed_by",exit_code:4,stable:!0,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"ambiguous_option_combination",exit_code:2,stable:!0,sources:["sdk/lifecycle/claim.ts","sdk/lifecycle/plan.ts"],emitting_commands:["claim","plan"]},{code:"annotation_alias_conflict",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"annotation_entry_mismatch",exit_code:4,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_invalid",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_expectation_without_target",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_flag_like_value",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_if_absent_without_append",exit_code:2,sources:["sdk/annotations.ts"]},{code:"annotation_message_without_text",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"annotation_text_source_conflict",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"annotation_transposed_subcommand",exit_code:2,sources:["cli/register-annotations.ts"]},{code:"append_empty_body",exit_code:2,stable:!0,sources:["sdk/lifecycle/append.ts"],emitting_commands:["append"]},{code:"assurance_registry_invalid",exit_code:1,sources:["sdk/governance/assurance.ts"]},{code:"bare_comma_entry_ambiguous",exit_code:2,sources:["core/item/parse.ts"]},{code:"blocker_identity_read_failed",exit_code:1,sources:["sdk/query/declared-blockers.ts"]},{code:"body_file_conflicts_with_body",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_missing_path",exit_code:2,stable:!0,sources:["core/io/body-file.ts"]},{code:"body_file_unreadable",exit_code:3,stable:!0,sources:["core/io/body-file.ts"]},{code:"budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"bulk_create_route",exit_code:2,sources:["cli/register-mutation.ts"]},{code:"bulk_ids_input_empty",exit_code:2,sources:["core/io/bulk-ids-input.ts","sdk/history-compact.ts","sdk/history-mcp.ts"],owned_states:[{state:"bulk_ids_stdin_contains_no_nonempty_ids",probe_id:"bulk-ids-stdin-empty",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_missing_path",exit_code:2,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_token_omits_its_path",probe_id:"bulk-ids-file-path-missing",entrypoints:["update-many"],expected_exit_class:"usage"}]},{code:"bulk_ids_input_unreadable",exit_code:3,sources:["core/io/bulk-ids-input.ts"],owned_states:[{state:"bulk_ids_file_path_cannot_be_read",probe_id:"bulk-ids-file-unreadable",entrypoints:["update-many"],expected_exit_class:"not_found"}]},{code:"bundle_integrity_torn_install",exit_code:1,stable:!0,sources:["cli/bundle-integrity.ts"]},{code:"capability_undeclared",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"capability_unused",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"child_projection_item_bound_exceeded",exit_code:1,stable:!0,sources:["sdk/item-children.ts"]},{code:"close_reason_required",exit_code:2,stable:!0,sources:["sdk/lifecycle-policy.ts","sdk/lifecycle/close-many.ts"],emitting_commands:["*","close-many"]},{code:"close_through_update",exit_code:1,stable:!0,sources:["core/telemetry/observability.ts"]},{code:"close_validation_missing_fields",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"collected_zero_items",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"collection_transposed_subcommand",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"command_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"command_namespace",exit_code:2,stable:!0,sources:["sdk/cli-contracts/runtime-contracts.ts"]},{code:"command_override_conflict",exit_code:4,stable:!0,sources:["sdk/compose.ts"]},{code:"config_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"config_key_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"config_value_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"conflicting_lifecycle_owner",exit_code:2,stable:!0,sources:["cli/register-operations.ts"]},{code:"context_evaluation_read_incomplete",exit_code:2,sources:["sdk/context-relevance.ts"]},{code:"context_signal_store_invalid",exit_code:2,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_stale",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_signal_store_write_failed",exit_code:1,sources:["sdk/context-signal-store.ts"]},{code:"context_takes_no_item_argument",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"core_item_field_requires_dedicated_flag",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"create_positional_type_without_title",exit_code:2,stable:!0,sources:["cli/register-mutation.ts"]},{code:"dependency_cardinality_created",exit_code:2,sources:["sdk/graph/cardinality-integrity.ts"]},{code:"dependency_edge_not_allowed",exit_code:2,stable:!0,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_flag_value_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_remove_no_match",exit_code:3,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"dependency_target_not_found",exit_code:3,sources:["sdk/dependency-flag-validation.ts"]},{code:"dependency_temporal_order_invalid",exit_code:2,sources:["sdk/dependency-flag-validation.ts"]},{code:"duplicate_canonical_flag",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"duplicate_command",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"duplicate_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"duplicate_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"duplicate_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"duplicate_probe",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"duplicate_sweep_cost_limit",exit_code:4,stable:!0,sources:["sdk/query/duplicate-candidates.ts"],emitting_commands:["duplicate-candidates"]},{code:"duplicate_target_circular",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_is_duplicate",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_missing",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"duplicate_target_self",exit_code:2,stable:!0,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{code:"empty_corpus",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"empty_surface",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"event_cursor_query_mismatch",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"event_history_integrity_failed",exit_code:1,sources:["core/history/event-index.ts"]},{code:"event_index_unavailable",exit_code:1,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"exit_code_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"expect_hash_background_unsupported",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invalid",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_invocation_rewritten",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_requires_mutation",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expect_hash_target_required",exit_code:2,sources:["sdk/lifecycle/item-revision.ts"]},{code:"expected_revision_duplicate",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"expected_revision_scope_conflict",exit_code:2,sources:["core/store/item-mutation-precondition.ts"]},{code:"extension_command_activation_failed",exit_code:1,stable:!0,sources:["cli/commander-usage.ts"]},{code:"extension_dependency_name_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_spec_invalid",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_dependency_version_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"extension_flag_value_invalid",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_install_incomplete_source_scan",exit_code:2,sources:["sdk/extension/install-plan.ts"]},{code:"extension_install_rollback_failed",exit_code:1,sources:["sdk/extension/install-snapshot.ts"]},{code:"extension_install_soft_failed",exit_code:1,stable:!0,sources:["cli/register-setup.ts"]},{code:"extension_install_source_contains_destination",exit_code:2,stable:!0,sources:["sdk/extension/install-runtime.ts"]},{code:"extension_item_field_reserved",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_type_conflict",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_item_field_unknown",exit_code:2,stable:!0,sources:["core/extensions/item-fields.ts"]},{code:"extension_mutation_guard_failed",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_decision",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_invalid_denial",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_mutation_guard_timed_out",exit_code:4,stable:!0,sources:["core/extensions/extension-hook-runtime.ts"]},{code:"extension_option_spelling_conflict",exit_code:2,sources:["sdk/extension/command-options.ts"]},{code:"extension_read_output_invalid",exit_code:2,sources:["sdk/read-output/extension.ts"]},{code:"extension_update_health_partial_coverage",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"extensions_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"field_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"field_mcp_input_collision",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"github_source_entry_unbuilt",exit_code:2,stable:!0,sources:["sdk/extension/shared.ts"]},{code:"hierarchy_cardinality_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_cycle_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"hierarchy_parent_divergence_created",exit_code:4,sources:["sdk/graph/hierarchy-integrity.ts"]},{code:"history_author_acknowledge_plan_conflict",exit_code:4,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_plan_fingerprint_required",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_preview_limit_invalid",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_required_values_missing",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_conflict",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_selector_required",exit_code:2,stable:!0,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_not_actionable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_author_acknowledge_target_unreadable",exit_code:2,sources:["sdk/author-attribution.ts"]},{code:"history_baseline_unavailable",exit_code:1,sources:["core/history/projection.ts"]},{code:"history_drift_chain_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_chain_mismatches"]},{code:"history_drift_hash_mismatch",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_hash_mismatches"]},{code:"history_drift_merge_receipt",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"history_drift_missing_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_missing_streams"]},{code:"history_drift_unreadable_stream",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_unreadable_streams"]},{code:"history_drift_version_skew",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_drift_version_skews"]},{code:"history_json_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/history/read.ts"],canonical_code:"merge_conflict_markers_detected"},{code:"history_replay_invalid",exit_code:1,sources:["core/history/projection.ts","core/history/tombstone.ts"]},{code:"history_salvage_refused",exit_code:4,sources:["sdk/history/salvage.ts"]},{code:"history_stream_over_compact_threshold",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"history_target_out_of_range",exit_code:1,stable:!0,sources:["core/history/projection.ts"]},{code:"history_timestamp_invalid",exit_code:1,sources:["core/history/event-index.ts","core/history/history.ts"]},{code:"history_union_rebase_conflict",exit_code:4,sources:["sdk/merge/history-scalar-rebase.ts"]},{code:"history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_history_unknown_author_events"]},{code:"history_version_mapping_unavailable",exit_code:2,sources:["core/history/version-address.ts"]},{code:"history_version_pruned",exit_code:2,sources:["core/history/projection.ts"]},{code:"host_environment_capacity_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_operation_invalid",exit_code:2,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_permission_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"host_environment_resource_fault",exit_code:1,sources:["core/fs/host-environment-errors.ts"]},{code:"improvement_metric_contract_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"improvement_observation_conflict",exit_code:4,sources:["sdk/improvement-ledger.ts"]},{code:"incomplete_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"inconsistent_concept_kind",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"init_existing_settings_requires_force",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_gitignore_unwritable",exit_code:1,stable:!0,sources:["sdk/workspace.ts"]},{code:"init_id_prefix_conflict",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"init_id_prefix_path_like",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"integrity_history_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_history_conflict_markers"]},{code:"integrity_history_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_history_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_ahead_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_ahead_items"]},{code:"integrity_item_conflict_marker",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_outdated_format_version",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_format_version_outdated_items"]},{code:"integrity_item_parse_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"integrity_item_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"invalid_argument_value",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/item/priority.ts","core/telemetry/observability.ts","sdk/config.ts","sdk/context-intent-contracts.ts","sdk/dependencies.ts","sdk/governance/assurance-mutation-error.ts","sdk/lifecycle/create.ts","sdk/lifecycle/task-composition.ts","sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts","sdk/query/next.ts","sdk/runtime-input.ts","sdk/runtime/mutation-admission.ts","sdk/runtime/mutation-value-validation.ts","sdk/runtime/schema-preview.ts","sdk/workspace.ts"],emitting_commands:["*","create","next","task-composition","update","update-many"]},{code:"invalid_command_usage",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"invalid_event_cursor",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_cursor_mode",exit_code:2,sources:["cli/register-list-query.ts","sdk/mutation-events.ts","sdk/runtime-extended-actions.ts"]},{code:"invalid_event_follow_interval",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_limit",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_event_since",exit_code:2,stable:!0,sources:["sdk/mutation-events.ts"]},{code:"invalid_history_analytics_limit",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_minimum_sample",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_history_analytics_since",exit_code:2,sources:["sdk/history-analytics.ts"]},{code:"invalid_improvement_ledger",exit_code:1,sources:["sdk/improvement-ledger-validation.ts"]},{code:"invalid_improvement_metric",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_limit",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_improvement_observation_timestamp",exit_code:2,sources:["sdk/improvement-ledger.ts"]},{code:"invalid_provenance_predicate",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"invalid_query_cursor",exit_code:2,stable:!0,sources:["sdk/pagination.ts","sdk/query/window-pagination.ts"]},{code:"invalid_read_output_session",exit_code:2,sources:["sdk/read-output-session.ts"]},{code:"invalid_reproducible_process_environment",exit_code:2,sources:["sdk/reproducibility/process.ts"]},{code:"invalid_workspace_snapshot_target",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"item_already_active",exit_code:4,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"item_already_exists",exit_code:4,stable:!0,sources:["sdk/lifecycle/create.ts"],emitting_commands:["create"]},{code:"item_deleted",exit_code:3,sources:["core/history/tombstone.ts"]},{code:"item_document_encoding_invalid",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_document_invalid",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_document_roundtrip_failed",exit_code:1,stable:!0,sources:["core/item/item-format.ts"]},{code:"item_format_version_unsupported",exit_code:4,sources:["core/item/item-format.ts"]},{code:"item_id_collision",exit_code:4,stable:!0,sources:["sdk/lifecycle/copy.ts"],emitting_commands:["copy"]},{code:"item_identity_ambiguous",exit_code:4,sources:["core/store/item-store.ts"]},{code:"item_identity_conflict",exit_code:4,sources:["sdk/governance/validate-history-drift.ts","sdk/lifecycle/item-revision.ts","sdk/merge/three-way.ts","sdk/query/declared-blockers.ts"]},{code:"item_identity_reserved",exit_code:4,sources:["core/history/history.ts"]},{code:"item_not_found",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/item-store.ts","core/telemetry/observability.ts","sdk/governance/validate-history-drift.ts"]},{code:"item_revision_conflict",exit_code:4,sources:["core/store/item-mutation-precondition.ts"]},{code:"likely_duplicate",exit_code:4,stable:!0,sources:["sdk/similarity.ts"]},{code:"linked_artifact_mutation_conflict",exit_code:2,sources:["sdk/linked-artifacts.ts"]},{code:"linked_resource_positional_value",exit_code:2,sources:["cli/error-guidance.ts"]},{code:"linked_test_command_immutable",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_command_not_executable",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_context_invalid",exit_code:2,sources:["sdk/test/entry.ts"]},{code:"linked_test_patch_fields_unsupported",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_remove_no_match",exit_code:3,sources:["sdk/test/execution.ts"]},{code:"linked_test_update_ambiguous",exit_code:2,sources:["sdk/test/update.ts"]},{code:"linked_test_update_no_match",exit_code:3,sources:["sdk/test/update.ts"]},{code:"linked_test_value_not_quoted",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"list_source_incomplete",exit_code:1,stable:!0,sources:["sdk/query/list.ts"],emitting_commands:["list"]},{code:"local_package_archive_unsafe",exit_code:2,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"local_source_not_found_bare_name",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"lock_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/lock/lock.ts","core/telemetry/observability.ts"]},{code:"lock_lost",exit_code:4,sources:["core/lock/lock.ts"]},{code:"lock_path_unsafe",exit_code:4,sources:["core/lock/lock-confinement.ts"]},{code:"locks_stale_count",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"locks_unreadable",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"malformed_plan_step_evidence",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"managed_state_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"managed_state_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_capabilities_absent",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"manifest_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"manifest_unknown_key",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_declares_an_unknown_top_level_key",probe_id:"author-manifest-unknown-key",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"manifest_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"mcp_annotation_file_unavailable",exit_code:2,sources:["sdk/runtime-input.ts"]},{code:"mcp_stdin_unavailable",exit_code:2,sources:["sdk/annotations.ts"]},{code:"mcp_task_not_found_or_not_authorized",exit_code:3,sources:["sdk/mcp/tasks.ts"]},{code:"merge_artifacts_ignored",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_bun_launcher_unavailable",exit_code:5,sources:["sdk/merge/install.ts"]},{code:"merge_conflict_markers_detected",exit_code:1,stable:!0,sources:["core/item/item-format.ts"],aliases:["history_merge_conflict_markers_detected"]},{code:"merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_driver_configuration_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_git_config_unwritable",exit_code:5,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_receipt_evidence_invalid",exit_code:4,sources:["core/diagnostics/remediation.ts","sdk/merge/reconcile.ts"]},{code:"merge_receipt_history_reference_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_receipt_not_portable",exit_code:4,sources:["sdk/merge/receipts.ts"]},{code:"merge_receipts_pending",exit_code:1,sources:["core/diagnostics/remediation.ts"]}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="853917f6-6746-52c8-a2ce-df083ecbe6a6")}catch{}})();var O=[{code:"merge_reconcile_receipt_evidence_untrusted",exit_code:4,sources:["sdk/history-repair.ts"]},{code:"merge_root_not_found",exit_code:3,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_settlement_hook_conflict",exit_code:4,sources:["sdk/merge/settlement-hook.ts"]},{code:"merge_settlement_review_required",exit_code:4,sources:["sdk/merge/ignored-artifacts.ts","sdk/merge/reconcile.ts","sdk/merge/stage.ts"]},{code:"missing_allowed_values",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"missing_cli_flag",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_directory",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"missing_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_lifecycle_target",exit_code:2,stable:!0,sources:["sdk/extension.ts"]},{code:"missing_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"missing_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"missing_parameter_alias",exit_code:1,sources:["sdk/cli-contracts/tool-option-contracts.ts"]},{code:"missing_positive_execution_receipt",exit_code:1,sources:["sdk/test/execution.ts"]},{code:"missing_probe",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"missing_required_argument",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/main.ts","cli/register-mutation.ts","cli/schema/registration.ts","core/telemetry/observability.ts","sdk/governance/assurance-action.ts","sdk/history-redact.ts","sdk/invocation-author.ts","sdk/lifecycle/claim.ts"],emitting_commands:["*","claim"]},{code:"missing_required_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/context-intent-contracts.ts","sdk/lifecycle/create.ts","sdk/lifecycle/plan.ts"],emitting_commands:["*","create","plan"]},{code:"missing_suggested_retry",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"missing_suggested_retry_args",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"module_import_failed",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"multi_target_github_install_ambiguous",exit_code:2,stable:!0,sources:["cli/register-setup.ts"]},{code:"mutation_author_required",exit_code:2,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"mutation_document_unreadable",exit_code:2,sources:["cli/register-structured-mutation.ts"]},{code:"mutation_option_value_invalid",exit_code:2,sources:["sdk/lifecycle/mutation-option-validation.ts"],emitting_commands:["item mutate"]},{code:"mutation_secret_guard_blocked",exit_code:4,stable:!0,sources:["sdk/mutation-guard.ts"]},{code:"no_matching_tests",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_projects_matched_filters",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_test_files_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_tests_found",exit_code:1,stable:!0,sources:["sdk/test/execution-receipts.ts"]},{code:"no_update_fields",exit_code:1,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts"]},{code:"no_version_bounds_declared",exit_code:1,sources:["core/extensions/manifest-schema.ts"],owned_states:[{state:"author_workspace_manifest_omits_canonical_pm_version_bounds",probe_id:"author-manifest-version-bounds-missing",entrypoints:["health"],expected_exit_class:"generic_failure"}]},{code:"non_refusal_exit",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"npm_pack_json_shape_unsupported",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_missing",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_archive_unsafe",exit_code:1,sources:["sdk/extension/install-sources.ts"]},{code:"npm_package_not_found",exit_code:3,stable:!0,sources:["sdk/extension/install-sources.ts"]},{code:"ownership_conflict",exit_code:4,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/annotations.ts"]},{code:"ownership_dependency_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"ownership_metadata_bypass_restricted_options",exit_code:1,stable:!0,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"package_spec_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"package_upgrade_modes_mutually_exclusive",exit_code:2,sources:["sdk/governance/upgrade.ts"]},{code:"positional_shape_budget_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"positional_signature_mismatch",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"profile_name_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_name_not_normalized",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_summary_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"profile_title_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"project_runtime_history_epoch_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_item_format_incompatible",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_mutation",exit_code:4,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_runtime_stale_read",exit_code:1,sources:["sdk/environment/project-runtime-compatibility.ts"]},{code:"project_schema_field_requires_declared_flag",exit_code:2,sources:["core/extensions/item-fields.ts"]},{code:"projection_options_mutually_exclusive",exit_code:2,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"provenance_value_domain_invalid",exit_code:2,sources:["core/diagnostics/remediation.ts"]},{code:"read_output_cursor_command_mismatch",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_invalid",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_cursor_stale",exit_code:2,sources:["sdk/read-output/continuation.ts"]},{code:"read_output_mutation_conflict",exit_code:2,sources:["sdk/read-output-contracts.ts"]},{code:"recovery_kind_mismatch",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"redundant_edge",exit_code:1,stable:!0,sources:["sdk/graph/remediation.ts"]},{code:"refusal_allowed_values_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_error_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_exit_code_mismatch",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_mutated_state",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_probe_missing",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"refusal_recovery_failed",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"reindex_already_running",exit_code:4,stable:!0,sources:["sdk/governance/reindex.ts"]},{code:"removed_canonical_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"removed_compatibility_spelling",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"reopen_reason_required",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reopen_receipt_missing",exit_code:1,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"reopen_target_status_invalid",exit_code:2,sources:["sdk/lifecycle/reopen.ts"],emitting_commands:["item reopen"]},{code:"reported_zero_passes",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reported_zero_tests",exit_code:1,sources:["sdk/test/execution-receipts.ts"]},{code:"reserved_item_field",exit_code:1,stable:!0,sources:["sdk/compose.ts"]},{code:"retry_failed",exit_code:1,sources:["sdk/agent/refusal-closure.ts","sdk/agent/tracker-preflight-contracts.ts"]},{code:"schema_migration_input_required",exit_code:2,stable:!0,sources:["cli/migration-gates.ts"]},{code:"semantic_spelling_collision",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"settings_invalid",exit_code:2,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_read_fs_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_invalid_schema",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_read_merge_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"settings_section_document_malformed",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_document_missing",exit_code:3,sources:["core/store/settings-sections.ts"]},{code:"settings_section_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_name_invalid",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_reserved",exit_code:2,sources:["core/store/settings-sections.ts"]},{code:"settings_section_revision_conflict",exit_code:4,sources:["core/store/settings-sections.ts"]},{code:"settings_unreadable",exit_code:1,sources:["sdk/extension/static-inventory.ts"]},{code:"settings_write_assigned_path_invalid",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_json",exit_code:2,sources:["core/store/settings.ts"]},{code:"settings_write_invalid_existing_schema",exit_code:2,sources:["core/store/settings.ts"]},{code:"stale_budget",exit_code:1,sources:["sdk/cli-contracts/flag-lexicon-contracts.ts"]},{code:"stale_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_observed_signature",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_revision",exit_code:4,sources:["core/store/item-store.ts"]},{code:"start_blocked_by_open_dependency",exit_code:4,sources:["sdk/lifecycle/start-blockers.ts"],emitting_commands:["claim","start-task","update"]},{code:"status_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"status_lifecycle_role_required",exit_code:2,sources:["sdk/schema.ts"]},{code:"stdin_json_invalid",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"stdin_json_persisted_annotation_changed",exit_code:2,sources:["sdk/lifecycle/update.ts"],emitting_commands:["update"]},{code:"stdin_json_unknown_key",exit_code:2,stable:!0,sources:["sdk/structured-mutations.ts"]},{code:"structured_event_immutable",exit_code:2,stable:!0,sources:["sdk/annotations.ts"]},{code:"structured_event_input_conflict",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_empty",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_json_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"structured_event_since_invalid",exit_code:2,stable:!0,sources:["sdk/notes.ts"]},{code:"suggested_retry_args_mismatch",exit_code:1,sources:["sdk/agent/refusal-closure.ts"]},{code:"telemetry_endpoint_probe_failed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_endpoint_probe_http_status",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_otel_export_failing",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_high_retries",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_invalid_rows",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_queue_pending",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_schema_version_behind",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"telemetry_state_invalid_json",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"template_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"terminal_plan_mutation",exit_code:4,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"terminal_state_conflict",exit_code:4,stable:!0,sources:["core/telemetry/observability.ts","sdk/lifecycle/claim.ts"],emitting_commands:["*","claim"]},{code:"test_measure_requires_execution",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"test_measure_requires_run",exit_code:2,sources:["sdk/test/prerequisites.ts"]},{code:"text_unpaired_surrogate",exit_code:2,sources:["core/item/item-format.ts","core/shared/output-unicode.ts"]},{code:"tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],aliases:["validate_storage_tracked_runtime_cache_files"]},{code:"tracker_not_initialized",exit_code:3,stable:!0,sources:["cli/error-guidance.ts","core/store/tracker-preflight.ts","core/telemetry/observability.ts"],owned_states:[{state:"selected_tracker_root_exists_without_settings",probe_id:"tracker-root-settings-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_missing",exit_code:3,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_does_not_exist",probe_id:"tracker-root-missing",entrypoints:["list"],expected_exit_class:"not_found"}]},{code:"tracker_root_not_directory",exit_code:2,stable:!0,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_a_regular_file",probe_id:"tracker-root-not-directory",entrypoints:["list"],expected_exit_class:"usage"}]},{code:"tracker_root_unreadable",exit_code:1,sources:["core/store/tracker-preflight.ts"],owned_states:[{state:"selected_tracker_root_is_not_readable",probe_id:"tracker-root-unreadable",entrypoints:["list"],expected_exit_class:"generic_failure"}]},{code:"transaction_abandoned",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_committed",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_create_compensated",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_journal_invalid",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_partial_mutation",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_plan_mismatch",exit_code:4,sources:["sdk/workspace-transaction.ts"]},{code:"transaction_preview_external_schema",exit_code:2,sources:["sdk/item-transaction.ts"]},{code:"transaction_preview_non_regular_file",exit_code:2,sources:["core/fs/fs-utils.ts"]},{code:"transaction_preview_snapshot_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"transaction_recovery_plan_missing",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"type_duplicate",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"type_invalid",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"undeclared_observation",exit_code:1,sources:["sdk/flag-invocation-contracts.ts"]},{code:"unexpected_refusal_probe",exit_code:1,sources:["sdk/agent/refusal-corpus-contracts.ts"]},{code:"unknown_command",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","core/telemetry/observability.ts","sdk/cli-contracts/runtime-contracts.ts"]},{code:"unknown_context_intent",exit_code:2,stable:!0,sources:["sdk/context-intent-contracts.ts"]},{code:"unknown_error",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"unknown_field",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_field_projection",exit_code:2,stable:!0,sources:["sdk/query/get.ts","sdk/query/list.ts","sdk/query/search-contracts.ts"],emitting_commands:["get","list","search"]},{code:"unknown_item_type",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_lifecycle_action",exit_code:2,stable:!0,sources:["sdk/agent/subcommand-recovery.ts"],canonical_code:"unknown_subcommand"},{code:"unknown_noun",exit_code:2,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"unknown_option",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","cli/runtime/invocation-options.ts","core/telemetry/observability.ts","sdk/extension/command-options.ts"],owned_states:[{state:"declared_option_is_rejected_on_the_selected_command_path",probe_id:"cross-command-unknown-option",entrypoints:["deps"],expected_exit_class:"usage"}]},{code:"unknown_plan_template",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]},{code:"unknown_provenance_dimension",exit_code:2,stable:!0,sources:["sdk/history-provenance.ts"]},{code:"unknown_status",exit_code:3,stable:!0,sources:["sdk/schema.ts"]},{code:"unknown_subcommand",exit_code:2,stable:!0,sources:["cli/error-guidance.ts","sdk/agent/subcommand-recovery.ts"],aliases:["unknown_lifecycle_action"],owned_states:[{state:"config_action_token_is_not_declared",probe_id:"config-unknown-action",entrypoints:["config"],expected_exit_class:"usage"},{state:"graph_command_token_is_not_declared",probe_id:"graph-unknown-subcommand",entrypoints:["graph"],expected_exit_class:"usage"},{state:"nested_command_token_is_not_declared_by_its_family",probe_id:"schema-unknown-subcommand",entrypoints:["schema"],expected_exit_class:"usage"},{state:"package_lifecycle_token_is_not_declared",probe_id:"package-unknown-action",entrypoints:["package"],expected_exit_class:"usage"}]},{code:"unsafe_init_recovery",exit_code:1,sources:["sdk/agent/tracker-preflight-contracts.ts"]},{code:"unsupported_update_option",exit_code:1,stable:!0,sources:["cli/error-guidance.ts"]},{code:"upsert_key_ambiguous",exit_code:4,sources:["sdk/structured-mutations.ts"]},{code:"upsert_key_conflict",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"upsert_key_duplicate",exit_code:2,sources:["sdk/item-transaction.ts","sdk/structured-mutations.ts"]},{code:"upsert_key_missing",exit_code:2,sources:["sdk/structured-mutations.ts"]},{code:"upsert_match_changed",exit_code:4,sources:["sdk/item-transaction.ts"]},{code:"validate_command_references_stale_pm_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_missing_linked_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_orphaned_paths",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_files_tracked_all_strict_forces_pm_internals",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_format_version_ahead_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_ahead_format_version"},{code:"validate_format_version_outdated_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_item_outdated_format_version"},{code:"validate_hierarchy_parent_cycle",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_hierarchy_parent_cycle_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_history_drift_chain_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_chain_mismatch"},{code:"validate_history_drift_hash_mismatches",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_hash_mismatch"},{code:"validate_history_drift_missing_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_missing_stream"},{code:"validate_history_drift_unreadable_streams",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_unreadable_stream"},{code:"validate_history_drift_version_skews",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_drift_version_skew"},{code:"validate_history_unknown_author_events",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"history_unknown_author_events"},{code:"validate_lifecycle_active_closure_like_metadata",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_active_terminal_parent",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_dependency_cycles_error",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_lifecycle_stale_blockers",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_decisions_unreviewed",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_driver_configuration",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_merge_fence_drift",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_custom_profile_missing_required_fields",exit_code:2,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_duplicate_issue_codes",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_acceptance_criteria",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_close_reason",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_closed_at",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_confidence",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_estimate",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_release",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_reviewer",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_risk",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_metadata_missing_sprint",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_resolution_missing_fields",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_duplicate_item_ids",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_history_conflict_markers",exit_code:4,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"integrity_history_conflict_marker"},{code:"validate_storage_resurrected_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_tracked_runtime_cache_files",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"],canonical_code:"tracked_runtime_cache_files"},{code:"validate_storage_unparseable_config",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unparseable_history",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"validate_storage_unreadable_items",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_embedding_identity_changed",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"vectorization_stale_items_remaining",exit_code:1,stable:!0,sources:["core/diagnostics/remediation.ts"]},{code:"visible_surface_ceiling_exceeded",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"workflow_duplicate_type",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_policy_approval_history_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_audit_failed",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_input_unreadable",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_invalid",exit_code:2,sources:["core/policy/workflow-policy.ts"]},{code:"workflow_policy_refused",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_policy_registry_invalid",exit_code:4,sources:["core/policy/workflow-policy-store.ts"]},{code:"workflow_status_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_transition_malformed",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_empty",exit_code:1,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workflow_type_unknown",exit_code:2,stable:!0,sources:["core/profile/profile-lint.ts"]},{code:"workspace_history_chain_invalid",exit_code:4,sources:["core/history/workspace-history.ts"]},{code:"workspace_history_state_conflict",exit_code:4,stable:!0,sources:["core/history/workspace-history.ts"]},{code:"workspace_root_pm_path",exit_code:2,stable:!0,sources:["sdk/init.ts"]},{code:"workspace_snapshot_force_required",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_manifest_mismatch",exit_code:4,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_name_reserved_fingerprint",exit_code:2,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_not_found",exit_code:3,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_permission_denied",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_resource_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"workspace_snapshot_storage_exhausted",exit_code:1,sources:["sdk/workspace-snapshot.ts"]},{code:"wrong_item_type",exit_code:2,stable:!0,sources:["sdk/lifecycle/plan.ts"],emitting_commands:["plan"]}];(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b525d8c8-3a70-52bd-83db-c956aba0c6fb")}catch{}})();var ze=E(T([...A,...O]));(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c2e89d3c-9abc-5ca7-a290-69a54dd694ab")}catch{}})();var G=Object.freeze({"--body":"Set the item body.","--body-file":"Read the item body from a file, or from stdin when set to -.","--description":"Set the item description.","--stdin":"Read the value from stdin.","--stdin-json":"Read a complete JSON document from stdin."}),B=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),V=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),Y=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),X=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),W=["--allow-","--check-","--dry-run","--explain","--fail-","--fix-","--full","--has-","--include-","--json","--no-","--prune-","--quiet","--refresh-","--require-","--runtime-only","--schema-only","--skip-","--stream","--strict-","--summary","--today","--verbose"],H=new Set(["--activate","--active-only","--adopt","--adopt-all","--all","--all-actionable","--all-affected-ids","--all-day","--all-streams","--acknowledge-linked-tests","--append-stable","--auto-fix","--auto-pm-context","--availability-only","--background","--brief","--by-assignee","--by-priority","--by-tag","--catalog","--claim","--clear","--clear-comments","--clear-criteria","--clear-deps","--clear-docs","--clear-events","--clear-files","--clear-learnings","--clear-notes","--clear-reminders","--clear-tests","--clear-type-options","--cli-only","--closed","--compact","--completion","--count","--counts","--deactivate","--declarative","--defaults","--describe","--diff","--doctor","--empty-body","--explore","--field-utilization","--filter-empty-body","--flags-only","--follow","--force","--global","--highlight","--hybrid","--id-only","--if-available","--ignore-global","--include_unparented","--infer","--init","--install","--isolated","--lean","--list","--local","--manage","--markdown","--metadata-coverage","--next","--normalize-provenance","--only","--only-last","--output-row-contract","--override-linked-pm-context","--override-linked-workspace-context","--packages-only","--past","--phrase-exact","--profile","--progress","--project","--promote-to-item-dep","--provenance","--provenance-summary","--raw","--ready-only","--ready_only","--rebuild","--recent","--reload","--repair","--replace-deps","--replace-docs","--replace-files","--replace-tests","--required","--required-on-create","--run","--runtime-probe","--save-baseline","--scaffold","--semantic","--shared-host-safe","--storage","--title-exact","--token-accounting","--trace","--tree","--unbounded","--uninstall","--validate-paths","--verify","--watch","--with-packages"]),J=new Set(["--only-index"]),K=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),Q=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),Z=new Set(["--regression"]);function ee(e,t){return t==="--stdin"||t==="--stdin-json"?["stdin"]:Y.has(`${e}:${t}`)?["argv","file","stdin"]:t.endsWith("-file")?["argv","file"]:B.has(t)&&V.has(e)?["argv","stdin"]:["argv"]}function te(e,t){let s=K.has(`${e}:${t.flag}`)||t.value_name!==void 0||t.value_type==="string"||t.value_type==="number"||t.list===!0||t.repeatable===!0,o=t.value_type==="boolean"||t.flag==="--stdin"||t.flag==="--stdin-json"||t.flag.startsWith("--filter-")&&(t.flag.endsWith("-missing")||t.flag.startsWith("--filter-has-")||t.flag.startsWith("--filter-no-"))||W.some(i=>t.flag.startsWith(i));return s||J.has(t.flag)||!H.has(t.flag)&&!o}function se(e,t){return t.value_arity!==void 0?t.value_arity:te(e,t)?Z.has(t.flag)||Q.has(`${e}:${t.flag}`)?"optional":"required":"none"}function oe(e,t){let s=f(e),o=se(s,t),i=o!=="none",r=ee(s,t.flag),d=t.description??G[t.flag]??`${i?"Set":"Enable"} ${t.flag.slice(2).replaceAll("-"," ")}.`;return{...t,description:d,takes_value:i,value_required:o==="required",...i?{value_name:t.value_name??"value"}:{},value_type:i?t.value_type??"string":"boolean",required:t.required===!0,repeatable:t.repeatable===!0||t.list===!0,input_sources:r,...r.includes("stdin")&&t.flag!=="--stdin"&&t.flag!=="--stdin-json"?{stdin_token:"-"}:{},...X.has(`${s}:${t.flag}`)?{file_token_prefix:"@"}:{}}}function Be(e,t){return t.map(s=>oe(e,s))}function Ve(e,t,s){let o=e.trim().toLowerCase(),i=[],r=new Map,d=0;for(let c of s)if(c.command.trim().toLowerCase()===o){if(d+=1,r.has(c.flag)){i.push({code:"duplicate_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} was observed more than once.`});continue}r.set(c.flag,c)}let _=new Set(t.map(({flag:c})=>c));for(let c of t){let n=r.get(c.flag);if(!n){i.push({code:"missing_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} has no executable option observation.`});continue}for(let[l,I]of[["takes_value","takes_value_mismatch"],["value_required","value_required_mismatch"],["repeatable","repeatable_mismatch"]])c[l]!==n[l]&&i.push({code:I,command:o,flag:c.flag,detail:`${o} ${c.flag} declares ${l}=${String(c[l])} but the executable option reports ${String(n[l])}.`})}for(let c of r.values())_.has(c.flag)||i.push({code:"undeclared_observation",command:o,flag:c.flag,detail:`${o} ${c.flag} is executable but absent from invocation contracts.`});return i.sort((c,n)=>c.flag.localeCompare(n.flag)||c.code.localeCompare(n.code)),{ok:i.length===0,declared_count:t.length,observed_count:d,findings:i}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="76c420db-b520-5fde-bd43-16a7324feb0a")}catch{}})();var ie=["mutation_receipt","entity","collection","diagnostic","stream"],ce=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),re=new Set(["close-many","update-many"]),ae=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),ne=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function p(e){if(e.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!ie.includes(e.kind))throw new TypeError(`Unsupported output envelope kind: ${e.kind}`);return e}function S(e){let t=e.trim().replace(/\s+/gu," "),[s=t]=t.split(" ");return re.has(s)?p({command:t,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):ce.has(s)?p({command:t,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):ae.has(s)?p({command:t,kind:"collection",wrapper_key:s==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):ne.has(s)?p({command:t,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):p({command:t,kind:s==="get"?"entity":"diagnostic",wrapper_key:s==="get"?"item":null,cardinality:s==="get"?"one":"none",format_flag:"--json"})}var de=u.map(e=>S(e)),_e=new Map(de.map(e=>[e.command,e]));function He(e){let t=e.trim().replace(/\s+/gu," ");if(t.length===0)throw new TypeError("command must be a non-empty command path");let[s=t]=f(t).split(" "),o=_e.get(s);return o?{...o,command:t}:S(t)}function le(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function ue(e){return le(e)&&typeof e.id=="string"&&e.id.length>0&&typeof e.status=="string"&&e.status.length>0&&Number.isSafeInteger(e.changed_field_count)&&Number(e.changed_field_count)>=0&&(e.close_reason===void 0||typeof e.close_reason=="string")&&(e.deleted===void 0||typeof e.deleted=="boolean")&&(e.previous_status===void 0||typeof e.previous_status=="string")&&(e.warnings===void 0||Array.isArray(e.warnings))}function Je(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(s){throw new TypeError(`Mutation receipt must be valid JSON: ${String(s)}`,{cause:s})}if(!ue(t))throw new TypeError("Mutation receipt must be a flat object with top-level id, status, and changed_field_count fields");return{id:t.id,status:t.status,changedFieldCount:t.changed_field_count,...typeof t.close_reason=="string"?{closeReason:t.close_reason}:{},...typeof t.deleted=="boolean"?{deleted:t.deleted}:{},...typeof t.previous_status=="string"?{previousStatus:t.previous_status}:{},...Array.isArray(t.warnings)?{warnings:t.warnings}:{}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0c0bb7ab-6157-5861-ad7e-a63ae62220f4")}catch{}})();var me=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),pe=new Set(["append","comments","config","contracts","deps","docs","events","files","focus","graph","health","history","learnings","list-all","list-blocked","list-closed","list-in-progress","list-open","notes","profile","schema","test"]),fe=Object.freeze({workspace:new Set(["config","gc","health","init","merge","profile","schema","telemetry","workspace"]),intake:new Set(["copy","create","focus","item","restore"]),context:new Set(["activity","aggregate","context","ctx","duplicates","eval","get","help","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","next","search","stats"]),lifecycle:new Set(["claim","close","close-many","close-task","delete","pause-task","item-reopen","release","start-task","update","update-many"]),evidence:new Set(["append","comments","docs","events","files","history","history-attest","history-author-acknowledge","history-compact","history-redact","history-repair","learnings","notes"]),graph:new Set(["deps","graph","plan"]),quality:new Set(["assurance","contracts","test","test-all","validate"]),automation:new Set(["event","meet","remind"])}),ge=new Set(["extension","install","package","packages","upgrade"]);function xe(e){let t=m(e.trim().toLowerCase());if(t==="ops")return"quality";for(let[s,o]of Object.entries(fe))if(o.has(t))return s;return ge.has(t)?"extensions":"internal"}var y=Object.freeze([...u.flatMap(e=>e==="item"?["item","item-reopen"]:[e,...b.filter(t=>t.alias===e).map(t=>t.canonical)]).map(e=>({command:e,tier:me.has(m(e))?"core":pe.has(m(e))?"standard":"full",family:xe(e)})),{command:"ops",tier:"core",family:"quality"},{command:"completion-statuses",tier:"internal",family:"internal"},{command:"completion-tags",tier:"internal",family:"internal"},{command:"completion-types",tier:"internal",family:"internal"},{command:"test-runs-worker",tier:"internal",family:"internal"},{command:"item test worker",tier:"internal",family:"internal"}]),ye=y,et=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),tt=Object.freeze(["-V, --version","--all","--json","--output-include <fields>","--output-limit <count>","--output-budget <tokens|unbounded>","--output-cursor <cursor>","--pm-path <dir>","--no-extensions","--no-pager","--explain","-h, --help"]);var M={core:0,standard:1,full:2,internal:3},N=new Map(ye.map(({command:e,tier:t})=>[e,t]));function st(e,t="standard"){return N.get(e.trim().toLowerCase())??N.get(m(e.trim().toLowerCase()))??t}function ot(e){return be(e,y)}function be(e,t){let s=M[e];return t.filter(o=>o.tier!=="internal"&&M[o.tier]<=s).map(o=>o.command)}function ke(e,t){return t.filter(s=>s.family===e).map(s=>s.command)}var he=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],ve=new Set([...k.filter(e=>e.hidden).map(e=>e.alias),"ctx","extension","install","item-reopen","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","packages","upgrade"]);function it(e=y){return he.map(t=>({family:t,commands:ke(t,e).filter(s=>e.find(o=>o.command===s)?.tier!=="internal"&&!ve.has(s))})).filter(({commands:t})=>t.length>0)}var ct=Object.freeze({pm_append:"append",pm_claim:"claim",pm_close:"close",pm_comments:"comments",pm_config:"config",pm_context:"context",pm_contracts:"contracts",pm_copy:"copy",pm_create:"create",pm_deps:"deps",pm_discover:"help",pm_docs:"docs",pm_events:"history",pm_files:"files",pm_focus:"focus",pm_get:"get",pm_graph:"graph",pm_health:"health",pm_learnings:"learnings",pm_list:"list",pm_mutate:"update",pm_next:"next",pm_notes:"notes",pm_plan:"plan",pm_profile:"profile",pm_release:"release",pm_run:"package",pm_schema:"schema",pm_search:"search",pm_test:"test",pm_update:"update",pm_validate:"validate"});var rt=Object.freeze([{uri:"pm://workspace/context",name:"Workspace context",description:"Bounded project context for orientation, including active hierarchy and progress.",mimeType:"application/json"},{uri:"pm://workspace/focus",name:"Active focus",description:"The session focus that supplies the default create parent.",mimeType:"application/json"},{uri:"pm://workspace/claims",name:"Active claims",description:"Bounded in-progress work and active ownership context.",mimeType:"application/json"},{uri:"pm://workspace/agent-guide",name:"Agent guidance",description:"Repository-local AGENTS.md instructions, bounded for safe host attachment.",mimeType:"text/markdown"}]),at=Object.freeze([{name:"orient",description:"Build bounded live context, search all statuses, and select canonical work without creating duplicates.",arguments:[{name:"request",description:"The user's requested outcome or topic.",required:!0},{name:"scope",description:"Optional bounded workspace or subsystem scope.",required:!1}],template:"Orient to the live pm workspace for: {{request}}. Scope hint: {{scope}}. Read context, search all statuses, inspect full metadata for relevant items, and select canonical lineage before any mutation."},{name:"claim-and-start",description:"Claim one canonical item and begin implementation with linked context.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0}],template:"Read {{id}} in full, claim it, set it in_progress, then implement only its acceptance scope while linking files, docs, tests, and evidence."},{name:"record-evidence-and-close",description:"Record exact verification evidence, close the item, and release ownership.",arguments:[{name:"id",description:"Canonical pm item id.",required:!0},{name:"evidence",description:"Exact verification and outcome evidence.",required:!0}],template:"For {{id}}, record this evidence: {{evidence}}. Verify linked tests, close only if acceptance is met, then release the claim."}]);export{D as a,w as b,R as c,Ee as d,Te as e,Ae as f,Oe as g,Se as h,x as i,E as j,Ne as k,C as l,ze as m,oe as n,Be as o,Ve as p,y as q,st as r,ot as s,it as t,ie as u,p as v,de as w,He as x,ue as y,Je as z};
2
+ //# sourceMappingURL=chunk-IB6TCE7N.js.map
@@ -1,2 +1,2 @@
1
- import{w as p,x as h}from"./chunk-LTQEYE2L.js";import{a as m,b as B}from"./chunk-C3O6JJPO.js";import{U as k,la as O,ta as A}from"./chunk-4LDOL6U7.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a319e7d9-e248-573b-bf1f-35217ce49fd0")}catch{}})();function w(e,n){return(n===void 0?void 0:A(e,n))?.execution_role??O[e.trim().toLowerCase()]??"agent"}var E="blocked_by",L="blocks",G=Object.freeze([E,L]),v="no-active-blocker";function r(e){return e.trim().toLowerCase()}function y(e,n){return n?`external:${e}`:`local:${r(e)}`}function I(e){let n=new Map,t=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(t.length>0&&r(t)!==v){let o=m(t);n.set(y(t,o),o?t:r(t))}for(let o of e.dependencies??[]){let c=typeof o.id=="string"?o.id.trim():"";if(k(o.kind)===E&&c.length>0&&r(c)!==v){let s=m(c)||B(o.source_kind);n.set(y(c,s),s?c:r(c))}}return[...n.values()].sort((o,c)=>o.localeCompare(c))}function _(e){let n=new Map;for(let t of e){let o=r(t.id);o.length!==0&&n.set(o,new Set(I(t)))}for(let t of e){let o=r(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=k(c.kind)===L&&typeof c.id=="string"?r(c.id):"";if(s.length===0||s===v)continue;let l=n.get(s)??new Set;l.add(o),n.set(s,l)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function M(e,n){let t=r(e.id);return t.length>0?_(n).get(t)??I(e):I(e)}function D(e,n,t,o){let c=e,s=typeof c.id=="string"?o?.get(r(c.id))??M(c,[...n.values()]):I(e),l=new Set((e.dependencies??[]).filter(d=>k(d.kind)===E&&B(d.source_kind)&&typeof d.id=="string"&&d.id.trim().length>0).map(d=>y(d.id.trim(),!0)));return s.map(d=>{if(m(d)||l.has(y(d,!0)))return{id:d,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let i=n.get(r(d));return i?{id:d,title:i.title,status:i.status,resolved:h(i.status,t)}:{id:d,title:null,status:null,resolved:!1}})}function R(e,n,t){return D(e,n,t)}function U(e,n){let t=new Map(e.map(l=>[r(l.id),l])),o=_(e),c=new Set([...z(n),...n.blocked_statuses]),s=new Set;for(let l of e){let d=p(l.status,n);c.has(d)&&(n.blocked_statuses.has(d)||D(l,t,n,o).some(i=>!i.resolved))&&s.add(r(l.id))}return s}function W(e,n,t={},o){let c=[...e.ready,...e.decisions,...e.gates];t.includeContainers===!0&&c.push(...e.containers.filter(l=>l.open_blockers.length===0&&!n.blocked_statuses.has(p(l.item.status,n))));let s={ready:[],decisions:[],gates:[]};for(let l of c){let d=w(l.item.type,o);d==="human"&&t.includeDecisions!==!0?s.decisions.push(l):d==="gate"&&t.includeGates!==!0?s.gates.push(l):s.ready.push(l)}return s}function z(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function $(e,n,t){let o=[r(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let l of n.get(s)??[]){if(!h(l.status,t))return!0;o.push(r(l.id))}}}return!1}function j(e){let n=new Map,t=new Map,o=new Map,c=_(e);for(let s of e){n.set(r(s.id),s);let l=typeof s.parent=="string"?s.parent.trim():"";if(l.length>0){let d=r(l),i=t.get(d)??[];i.push(s),t.set(d,i)}for(let d of c.get(r(s.id))){let i=r(d),b=o.get(i)??[];b.push(s.id),o.set(i,b)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function V(e,n,t,o){let{itemsById:c,childrenByParent:s,blockedByReverse:l,blockerIdsByItem:d}=j(n),i=new Set([...z(t),...t.blocked_statuses]),b=new Set(n.filter(a=>!h(a.status,t)).map(a=>r(a.id))),S=[],C=[],g=[],N=[],x=[],T=0;for(let a of e){if(!i.has(p(a.status,t)))continue;T+=1;let K=D(a,c,t,d).filter(u=>!u.resolved),Y=(l.get(r(a.id))??[]).filter(u=>b.has(r(u))).sort((u,F)=>u.localeCompare(F)),f={item:a,open_blockers:K,unblocks:Y};if($(a.id,s,t)){g.push(f);continue}let P=t.blocked_statuses.has(p(a.status,t));if(K.length===0&&!P){let u=w(a.type,o);u==="human"?N.push(f):u==="gate"?x.push(f):S.push(f)}else C.push(f)}return{ready:S,blocked:C,containers:g,decisions:N,gates:x,active_count:T,container_count:g.length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ae1c56b3-148d-502d-9450-e807fdfab4da")}catch{}})();export{w as a,G as b,I as c,_ as d,M as e,R as f,U as g,W as h,V as i};
2
- //# sourceMappingURL=chunk-LW4TN5ZM.js.map
1
+ import{K as p,L as h}from"./chunk-JU62TKJP.js";import{a as m,b as B}from"./chunk-C3O6JJPO.js";import{U as k,la as O,ta as A}from"./chunk-2SQUWQP3.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a319e7d9-e248-573b-bf1f-35217ce49fd0")}catch{}})();function w(e,n){return(n===void 0?void 0:A(e,n))?.execution_role??O[e.trim().toLowerCase()]??"agent"}var E="blocked_by",L="blocks",G=Object.freeze([E,L]),v="no-active-blocker";function r(e){return e.trim().toLowerCase()}function y(e,n){return n?`external:${e}`:`local:${r(e)}`}function I(e){let n=new Map,t=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(t.length>0&&r(t)!==v){let o=m(t);n.set(y(t,o),o?t:r(t))}for(let o of e.dependencies??[]){let c=typeof o.id=="string"?o.id.trim():"";if(k(o.kind)===E&&c.length>0&&r(c)!==v){let s=m(c)||B(o.source_kind);n.set(y(c,s),s?c:r(c))}}return[...n.values()].sort((o,c)=>o.localeCompare(c))}function _(e){let n=new Map;for(let t of e){let o=r(t.id);o.length!==0&&n.set(o,new Set(I(t)))}for(let t of e){let o=r(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=k(c.kind)===L&&typeof c.id=="string"?r(c.id):"";if(s.length===0||s===v)continue;let l=n.get(s)??new Set;l.add(o),n.set(s,l)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function M(e,n){let t=r(e.id);return t.length>0?_(n).get(t)??I(e):I(e)}function D(e,n,t,o){let c=e,s=typeof c.id=="string"?o?.get(r(c.id))??M(c,[...n.values()]):I(e),l=new Set((e.dependencies??[]).filter(d=>k(d.kind)===E&&B(d.source_kind)&&typeof d.id=="string"&&d.id.trim().length>0).map(d=>y(d.id.trim(),!0)));return s.map(d=>{if(m(d)||l.has(y(d,!0)))return{id:d,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let i=n.get(r(d));return i?{id:d,title:i.title,status:i.status,resolved:h(i.status,t)}:{id:d,title:null,status:null,resolved:!1}})}function R(e,n,t){return D(e,n,t)}function U(e,n){let t=new Map(e.map(l=>[r(l.id),l])),o=_(e),c=new Set([...z(n),...n.blocked_statuses]),s=new Set;for(let l of e){let d=p(l.status,n);c.has(d)&&(n.blocked_statuses.has(d)||D(l,t,n,o).some(i=>!i.resolved))&&s.add(r(l.id))}return s}function W(e,n,t={},o){let c=[...e.ready,...e.decisions,...e.gates];t.includeContainers===!0&&c.push(...e.containers.filter(l=>l.open_blockers.length===0&&!n.blocked_statuses.has(p(l.item.status,n))));let s={ready:[],decisions:[],gates:[]};for(let l of c){let d=w(l.item.type,o);d==="human"&&t.includeDecisions!==!0?s.decisions.push(l):d==="gate"&&t.includeGates!==!0?s.gates.push(l):s.ready.push(l)}return s}function z(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function $(e,n,t){let o=[r(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let l of n.get(s)??[]){if(!h(l.status,t))return!0;o.push(r(l.id))}}}return!1}function j(e){let n=new Map,t=new Map,o=new Map,c=_(e);for(let s of e){n.set(r(s.id),s);let l=typeof s.parent=="string"?s.parent.trim():"";if(l.length>0){let d=r(l),i=t.get(d)??[];i.push(s),t.set(d,i)}for(let d of c.get(r(s.id))){let i=r(d),b=o.get(i)??[];b.push(s.id),o.set(i,b)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function V(e,n,t,o){let{itemsById:c,childrenByParent:s,blockedByReverse:l,blockerIdsByItem:d}=j(n),i=new Set([...z(t),...t.blocked_statuses]),b=new Set(n.filter(a=>!h(a.status,t)).map(a=>r(a.id))),S=[],C=[],g=[],N=[],x=[],T=0;for(let a of e){if(!i.has(p(a.status,t)))continue;T+=1;let K=D(a,c,t,d).filter(u=>!u.resolved),Y=(l.get(r(a.id))??[]).filter(u=>b.has(r(u))).sort((u,F)=>u.localeCompare(F)),f={item:a,open_blockers:K,unblocks:Y};if($(a.id,s,t)){g.push(f);continue}let P=t.blocked_statuses.has(p(a.status,t));if(K.length===0&&!P){let u=w(a.type,o);u==="human"?N.push(f):u==="gate"?x.push(f):S.push(f)}else C.push(f)}return{ready:S,blocked:C,containers:g,decisions:N,gates:x,active_count:T,container_count:g.length}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ae1c56b3-148d-502d-9450-e807fdfab4da")}catch{}})();export{w as a,G as b,I as c,_ as d,M as e,R as f,U as g,W as h,V as i};
2
+ //# sourceMappingURL=chunk-IS5FLEZW.js.map
@@ -0,0 +1,91 @@
1
+ import{$a as _e,E as ze,F as Ht,Ma as Xe,Pa as Ge,Qa as Ye,R as J,Ra as Z,S as Wt,T as Q,Za as Ve,hb as Yt,qb as Vt,ua as zt,xa as Xt,yb as Kt,za as Gt,zb as ge}from"./chunk-JU62TKJP.js";import{Ac as We,Ba as je,Ca as Le,Da as k,H as Tt,Ia as At,Jc as x,Oa as Ft,Od as Lt,Pd as Be,Sa as Mt,Ta as Pt,Xe as Bt,a as fe,ac as jt,ce as $t,de as Ut,na as Ot,oa as Dt,qc as q,ra as kt,sc as $e,tc as ye,uc as $,vc as Ue,wa as pe,wc as he,xc as He,ya as Nt}from"./chunk-2SQUWQP3.js";import{A as m,B as xt,C as K,E as L,I as A,m as Rt,t as j,y as Pe,z as f}from"./chunk-G6ERMFJ5.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4e02447f-3fb0-5f7c-9512-be2b348fd082")}catch{}})();var U=new Set(Rt),we=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(i=>e.call(t,i,i,we))},[Symbol.iterator](){return U.values()}});function qt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Jt(e){return typeof e!="string"?null:Tt(e)}function qi(e){try{return structuredClone(e)}catch{return e}}function Ji(e){let t=e.trim(),i=t.indexOf("=");if(i<=0)throw new m(`--field entries must use name=value syntax, received: ${e}`,f.USAGE);let o=t.slice(0,i).trim(),n=t.slice(i+1);return{key:o,value:n}}function Qi(e,t,i){try{let o=JSON.parse(e);if(i==="array"&&Array.isArray(o)||i==="object"&&typeof o=="object"&&o!==null&&!Array.isArray(o))return o}catch{}throw new m(`--field ${t}=... must be valid JSON ${i}`,f.USAGE)}function Zi(e,t,i){if(t==="string")return i;if(t==="number"){let o=i.trim();if(o.length===0)throw new m(`--field ${e}=... must be a number`,f.USAGE);let n=Number(o);if(!Number.isFinite(n))throw new m(`--field ${e}=... must be a number`,f.USAGE);return n}if(t==="boolean"){let o=i.trim().toLowerCase();if(o==="true"||o==="1"||o==="yes")return!0;if(o==="false"||o==="0"||o==="no")return!1;throw new m(`--field ${e}=... must be one of true|false|1|0|yes|no`,f.USAGE)}return t==="string_array"?i.split(/[\n,|]/u).map(o=>o.trim()).filter(o=>o.length>0):Qi(i,e,t)}function Ke(e){let t=new Map;if(!e)return t;for(let i of e.item_fields)for(let o of i.fields){let n=qt(o.name),r=Jt(o.type);if(!n||!r)continue;let s=t.get(n);if(s&&s.type!==r)throw new m(`Extension item field "${n}" is declared with conflicting types: ${s.type}, ${r}`,f.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(n,{name:n,type:r})}return t}function Qt(e){if(we.has(e))throw new m(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[...we].sort((t,i)=>t.localeCompare(i)).join(", ")}.`,f.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function be(e){return[...Ke(e).keys()].sort((t,i)=>t.localeCompare(i))}function ar(e,t,i,o){if(!e||e.length===0)return{};let n=Ke(t),r={};for(let s of e){let{key:a,value:d}=Ji(s),c=n.get(a);if(!c)throw eo(a,n,i,o);Qt(c.name),r[c.name]=Zi(c.name,c.type,d)}return r}function eo(e,t,i,o){if(we.has(e)){let s=i?.(e)??{recovery:{provided_fields:[e]},nextSteps:["Core metadata has no generic --field mutation path. Use the owning lifecycle, evidence, or importer API; inspect pm update <id> --help for declared mutation flags."]};return new m(`--field ${e} is a core item field, not an extension field`,f.USAGE,{code:"core_item_field_requires_dedicated_flag",field:e,...s})}let n=o?.(e);if(n!==void 0){let s=n.recovery?.suggested_flags?.[0];return new m(s===void 0?`--field ${e} is a project-schema field, not an extension field`:`--field ${e} is a project-schema field; set it with its declared flag ${s}`,f.USAGE,{code:"project_schema_field_requires_declared_flag",field:e,changed:!1,...n})}let r=[...t.keys()].sort((s,a)=>s.localeCompare(a));return new m(`--field ${e} is not declared by an active extension item-field registration`,f.USAGE,{code:"extension_item_field_unknown",field:e,recovery:{provided_fields:[e]},nextSteps:r.length>0?[`Use one of the declared fields: ${r.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}function to(e,t){return t==="string"?typeof e=="string":t==="number"?typeof e=="number"&&Number.isFinite(e):t==="boolean"?typeof e=="boolean":t==="array"?Array.isArray(e):t==="string_array"?Array.isArray(e)&&e.every(i=>typeof i=="string"):typeof e=="object"&&e!==null&&!Array.isArray(e)}function io(e,t){return!t||t.length===0?!0:t.some(i=>Object.is(i,e))}function cr(e,t,i={}){if(t){Ke(t);for(let o of t.item_fields)for(let n of o.fields){let r=qt(n.name);if(!r)continue;Qt(r),!(r in e)&&!i.skipDefaultFields?.has(r)&&Object.prototype.hasOwnProperty.call(n,"default")&&(e[r]=qi(n.default));let s=e[r];if(s===void 0)continue;let a=Jt(n.type);if(a&&!to(s,a))throw new TypeError(`Item field "${r}" must be of type ${a}`);let d=Array.isArray(n.values)?n.values:void 0;if(!io(s,d))throw new TypeError(`Item field "${r}" must match one of the configured allowed values`)}}}import oo from"node:crypto";import Ee from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="664124e5-715d-5f86-ae69-89f203db76c3")}catch{}})();function ei(e){let t=[],i=!1;for(let o of(e??"").toLowerCase()){let n=o.charCodeAt(0),r=n>=48&&n<=57,s=n>=97&&n<=122;if(!r&&!s){i=t.length>0;continue}i&&(t.push("-"),i=!1),t.push(o)}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 i=ei(t),o=ee(e);return o.startsWith(i)?o:`${i}${o}`}function no(e){let t=Lt(e);if(t!==void 0)return t;let i="";for(let o=0;o<e;o+=1)i+=oo.randomInt(0,36).toString(36);return i}async function ro(e,t,i){let o=[...new Set(Object.values(i))].flatMap(n=>[Ee.join(e,n,`${t}.md`),Ee.join(e,n,`${t}.toon`)]);return o.push(Ee.join(e,"history",`${t}.jsonl`)),(await Promise.all(o.map(n=>K(n)))).some(Boolean)}var Zt=4,ti=12;function so(e){return typeof e!="number"||!Number.isFinite(e)?Zt:Math.min(ti,Math.max(Zt,Math.trunc(e)))}async function yr(e,t,i={}){let o=so(i.tokenLength),n=Math.min(o+6,ti),r=0;for(;o<=n;){for(let s=0;s<32;s+=1){let a=`${ei(t)}${no(o)}`;if(!await(i.probeExisting===!1?K(Ee.join(e,"history",`${a}.jsonl`)):ro(e,a,i.typeToFolder??j)))return a;r+=1}o+=1}throw new Error(`Unable to generate unique id after ${r} attempts`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5db05e2f-4742-526b-b1c8-b97ff302b40e")}catch{}})();function ie(e,t=!1){let i=e[0];if(i?.op!=="history_compact_baseline")return 0;let o=i.context?.history_compaction,n=typeof o=="object"&&o!==null&&"version_offset"in o?o.version_offset:void 0;if(typeof n=="number"&&Number.isSafeInteger(n)&&n>=0&&Number.isSafeInteger(n+e.length))return n;if(t)return null;throw new m("This compacted stream has no trustworthy version offset; numeric history addresses are unavailable.",f.USAGE,{code:"history_version_mapping_unavailable",required:"Use a retained timestamp or recover the pre-compaction stream from version control.",nextSteps:["Run pm history <id> --full to inspect the retained timestamps and checkpoint evidence."]})}import ii from"node:fs/promises";import oe from"node:path";import{isUtf8 as ao}from"node:buffer";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="697f1dbe-8315-5901-ab11-e0c5211dbdbf")}catch{}})();var co=1048576,lo=4194304;async function oi(e,t){let i=oe.dirname(e);for(;i!==oe.parse(e).root;){let n=await ii.stat(i).catch(r=>{if(L(r))return null;throw r});if(n!==null){if(!n.isDirectory())throw new m("Workflow policy storage ancestor must be a directory.",f.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Restore the policy or approval history directory before retrying."]});break}i=oe.dirname(i)}let o=await ii.open(e,"r").catch(n=>{if(L(n))return null;throw n});if(o===null)return null;try{let n=(await o.stat()).size,r=Buffer.alloc(Math.min(t,n)+1),s=0;for(;s<r.length;){let a=await o.read(r,s,r.length-s,s);if(a.bytesRead===0)break;s+=a.bytesRead}if(s===r.length||!ao(r.subarray(0,s)))throw new m("Workflow policy input exceeds its byte bound or is not valid UTF-8.",f.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Inspect the policy and approval history; reduce the declaration or use verified history compaction before retrying."]});return r.toString("utf8",0,s)}finally{await o.close()}}function uo(e){if(e===null)return{version:1,enforcement:"advise",policies:[]};let t;try{t=JSON.parse(e)}catch{throw new m("schema/policies.json must contain valid JSON.",f.CONFLICT,{code:"workflow_policy_registry_invalid",nextSteps:["Restore valid policy JSON before retrying the mutation."]})}return Ft(t)}async function mo(e){return uo(await oi(oe.join(e,"schema","policies.json"),co))}async function fo(e,t){let i=await oi(k(e,t),lo);if(i===null)return[];let o;try{if(o=i.split(/\r?\n/).filter(n=>n.trim()).map(n=>JSON.parse(n)),!_e(o).ok)throw new Error("invalid chain")}catch{throw new m("Approval evidence requires a valid item history chain.",f.CONFLICT,{code:"workflow_policy_approval_history_invalid",nextSteps:[`Run pm history ${t} --verify before recording or using an approval.`]})}return o.flatMap(n=>{let r=n.context?.workflow_approval;if(n.op!=="policy_approve"||n.record_hash_version!==1||typeof n.record_hash!="string"||typeof r!="object"||r===null)return[];let s=r;return typeof s.policy_fingerprint!="string"||typeof s.content_fingerprint!="string"?[]:[{policy_fingerprint:s.policy_fingerprint,content_fingerprint:s.content_fingerprint,author:n.author}]})}async function po(e,t,i){let o=i.before?.status!==i.after?.status&&t.policies.some(s=>s.rule.kind==="approval"&&Mt(s,i)),n=i.before?.id??i.after?.id,r=o&&typeof n=="string"?await fo(e,n):[];return Pt(t,{...i,approvals:r})}async function qe(e){let t=await mo(e.pmRoot),i=await po(e.pmRoot,t,{operation:e.operation,author:e.author,before:e.before?{...e.before.metadata,body:e.before.body}:null,after:e.after?{...e.after.metadata,body:e.after.body}:null});if(i.allowed)return i;let o=i.decisions.filter(l=>!l.satisfied&&l.effect==="refuse"),n=[],r="";if(!e.dryRun)try{let l=await Yt({pmRoot:e.pmRoot,op:"policy_refused",author:e.author,context:{item_id:e.after?.metadata.id??e.before?.metadata.id,operation:e.operation,workflow_policies:i.decisions},message:"Workflow policy refused a proposed item mutation.",lockTtlSeconds:e.settings.locks.ttl_seconds,lockWaitMs:e.settings.locks.wait_ms});n.push({path:"history/_workspace.jsonl",op:"policy_refused",record_hash:l.entry.record_hash}),r=" Audit appended to tracker-relative history/_workspace.jsonl; retain it with the workspace changes. Each refused attempt records its own audit event."}catch(l){let h=new m("Workflow policy refusal could not be recorded in workspace history.",f.CONFLICT,{code:"workflow_policy_audit_failed",nextSteps:["Resolve workspace-history lock or storage failures, then retry the refused mutation; no item changes were written."]});throw h.cause=l,h}let s=o.slice(0,3).map(l=>({policy_id:l.policy_id,rule:l.rule,description:t.policies.find(h=>h.id===l.policy_id).description,missing_fields:l.missing_fields})),a=[...new Set(s.flatMap(l=>l.missing_fields))],d=s.map(l=>`${l.policy_id} (${l.rule})`).join(", "),c=o.length>3?` and ${o.length-3} more`:"",y=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=Ot("update",l);return h===void 0?`Supply ${l} using its declared SDK or package mutation contract, then retry.`:x(["update",y,Dt("update",h),`<${l}>`,"--pm-path",oe.resolve(e.pmRoot)])});throw new m(`Workflow policy refused ${e.operation}: ${d}${c}.${a.length?` Missing: ${a.join(", ")}.`:""}${r}`,f.CONFLICT,{code:"workflow_policy_refused",side_effects:n,reason:s.map(l=>l.policy_id).join(","),policy_violations:s,policy_violation_count:o.length,required:a.length?`Supply missing fields: ${a.join(", ")}, then retry the refused mutation.`:"Satisfy the declared workflow policy before retrying.",why:s.map(l=>l.description).filter(Boolean).join(" ")||void 0,recovery:{missing_required_fields:a},nextSteps:[...u,...new Set(o.slice(0,3).filter(l=>l.missing_fields.length===0).map(l=>l.remediation)),...o.length>3?[`Inspect all policies with pm schema policies before retrying ${e.operation}.`]:[]]})}import{AsyncLocalStorage as yo}from"node:async_hooks";import{channel as ho}from"node:diagnostics_channel";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b2b2d49a-bb8c-54d7-89d2-1dbe76879129")}catch{}})();var Je=new yo,Qe=ho("@unbrained/pm-cli/item-metadata-enumeration/v1");function ve(e){Qe.publish(e)}async function Mr(e){let t={enumeration_calls:0,metadata_rows:0},i=o=>{Je.getStore()?.includes(t)&&(t.enumeration_calls+=1,t.metadata_rows+=o)};Qe.subscribe(i);try{return{result:await Je.run([...Je.getStore()??[],t],e),work:{...t}}}finally{Qe.unsubscribe(i)}}import{AsyncLocalStorage as ni}from"node:async_hooks";import{realpathSync as _o}from"node:fs";import et from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0d72cf82-14ea-573b-a36e-0077c82c0c1d")}catch{}})();var Ze=new ni;function Xr(e,t){return Ze.run([...Ze.getStore()??[],{...e,pmRoot:et.resolve(e.pmRoot)}],t)}var go=Symbol.for("@unbrained/pm-cli/item-revision-scopes"),wo=globalThis,ne=wo[go]??=new ni;function X(e){let t=et.resolve(e);try{return _o.native(t)}catch{return t}}function Gr(){return{entries:new Map}}function Yr(e,t){return ne.run([...ne.getStore()??[],e],t)}function Vr(e,t,i){let o=X(t);if(e.pmRoot!==void 0&&e.pmRoot!==o)throw new m("An expected-revision scope is already bound to another tracker.",f.USAGE,{code:"expected_revision_scope_conflict",required:"Bind expected item revisions for one tracker per scope."});e.pmRoot=o;for(let{id:n,itemHash:r}of i){let s=e.entries.get(n);if(s!==void 0&&s.declared!==r)throw new m(`Item ${n} has two different expected revisions.`,f.USAGE,{code:"expected_revision_duplicate",item_id:n,required:"Declare at most one expected revision per item."});e.entries.set(n,s??{declared:r,expected:r,checked:!1,committed:!1})}}function Kr(e){let t=[...e.entries.entries()];return{checked:t.filter(([,i])=>i.checked).map(([i])=>i),unchecked:t.filter(([,i])=>!i.checked).map(([i])=>i)}}function tt(e,t){let i=ne.getStore()??[];if(i.length===0)return[];let o=X(e),n=new Set(t.filter(r=>typeof r=="string"));return[...new Set(i.flatMap(r=>r.pmRoot===o?[...n].flatMap(s=>r.entries.get(s)??[]):[]))]}function qr(e){let t=ne.getStore()??[];if(t.length===0)return[];let i=X(e),o=new Map;for(let n of t)if(n.pmRoot===i)for(let[r,s]of n.entries){if(s.expected!==s.declared)return;o.set(r,(o.get(r)??new Set).add(s.expected))}if(![...o.values()].some(n=>n.size>1))return[...o].map(([n,r])=>`${n}=${[...r][0]}`)}function Jr(e){let t=X(e);return(ne.getStore()??[]).some(i=>i.pmRoot===t&&i.entries.size>0)}function bo(e,t,i){let o=tt(e,[i,t.metadata.id]);o.length>0&&ai(o,i,Xe(t),!1,e)}function Qr(e,t,i){let o=tt(e,[t]);o.length>0&&ai(o,t,At(i),!0,e)}var Eo="revision_changed",vo="document_unreadable";function Io(e,t,i={}){let o=[...i.scopeArgs??[]],n=[...i.outputArgs??["--json"]],r=x([...o,"get",e,...n]),s=x([...o,"history",e,"--limit","5",...n]);return{required:t?`Recover ${e} without --expect-hash (${x([...o,"restore",e,"<version>"])}), since no declared revision describes an unreadable document.`:`Re-read ${e} (${r} reports item_hash), decide again against the current revision, then retry with --expect-hash <item_hash>.`,examples:[x([...o,"get",e,"--fields","item_hash",...n]),s],nextSteps:[r,s]}}var Co=Symbol.for("@unbrained/pm-cli/item-revision-refusal-trackers"),So=globalThis,it=So[Co]??=new WeakMap,To=8;function ri(e){for(let t of si(e)){let i=it.get(t);if(i!==void 0)return i}}function*si(e){let t=e;for(let i=0;i<To&&typeof t=="object"&&t!==null;i+=1){yield t;try{t=t.cause}catch{return}}}function ai(e,t,i,o,n){for(let r of e)if(r.checked=!0,!(!o&&r.expected===i))throw Do(n,new m(`Item ${t} is no longer at the expected revision ${r.expected.slice(0,12)}${o?" (its live document cannot be read)":""}; refusing to write over a revision this decision did not see.${r.committed?" Earlier writes by this same invocation already committed.":" Nothing was written to this item."}`,f.CONFLICT,{code:"item_revision_conflict",item_id:t,expected_revision:r.expected,current_revision:i,reason:o?vo:Eo,why:"The caller declared the revision its decision was based on, and another write changed the item before this locked write.",...Io(t,o)}))}function Zr(e,t){let i=ri(e);return i===void 0||i===X(t)}var Ro=Symbol.for("@unbrained/pm-cli/item-revision-scoped-refusals"),xo=globalThis,ot=xo[Ro]??=new WeakSet;function Oo(e){for(let t of si(e))if(ot.has(t))return!0;return!1}function es(e){return ot.add(e),e}function ts(e,t){let i=ri(e);return i!==void 0&&it.set(t,i),Oo(e)&&ot.add(t),t}function Do(e,t){return it.set(t,X(e)),t}function nt(e,t,i=t.metadata.id){bo(e,t,i);for(let o of rt(e,[i,t.metadata.id]))o.validate(t)}function rt(e,t){let i=et.resolve(e);return(Ze.getStore()??[]).filter(o=>o.pmRoot===i&&t.includes(o.id))}function st(e,t,i=t.metadata.id,o=[],n){let r=tt(e,[i,t.metadata.id,...o]);if(r.length>0){let s=n??Xe(t);for(let a of r)a.expected=s,a.committed=!0}for(let s of rt(e,[i,t.metadata.id,...o]))s.committed?.(t)}function ci(e,t){return Object.assign({},...rt(e,t).map(i=>i.historyContext))}import H from"node:fs/promises";import li from"node:path";import{randomUUID as ko}from"node:crypto";import{createRequire as No}from"node:module";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="84a3dae8-69b6-589d-a8ec-11f77c1d103a")}catch{}})();var Ao="metadata-query-index.sqlite",re="5",at;function se(){return at!==void 0||(at=Gt(process.versions.node,No(import.meta.url))),at}function di(e,t){return Math.max(0,Math.floor(e===void 0?t:e))}function G(e){return li.join(e,"runtime",Ao)}function Fo(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,i){e.prepare("INSERT INTO metadata(key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(t,i)}function ui(e,t){let i=t.metadata;e.prepare(`INSERT INTO items(
57
+ id, relative_path, metadata_json, status, type, priority,
58
+ updated_at, created_at, parent, assignee, sprint, release
59
+ ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
60
+ ON CONFLICT(id) DO UPDATE SET
61
+ relative_path = excluded.relative_path,
62
+ metadata_json = excluded.metadata_json,
63
+ status = excluded.status,
64
+ type = excluded.type,
65
+ priority = excluded.priority,
66
+ updated_at = excluded.updated_at,
67
+ created_at = excluded.created_at,
68
+ parent = excluded.parent,
69
+ assignee = excluded.assignee,
70
+ sprint = excluded.sprint,
71
+ release = excluded.release`).run(i.id,t.relativePath,JSON.stringify(i),i.status,i.type,i.priority,i.updated_at,i.created_at,i.parent??null,i.assignee??null,i.sprint??null,i.release??null),e.prepare("DELETE FROM item_metadata_keys WHERE item_id = ?").run(i.id),e.prepare("DELETE FROM item_linked_files WHERE item_id = ?").run(i.id),e.prepare("DELETE FROM item_search WHERE rowid = (SELECT rowid FROM items WHERE id = ?)").run(i.id),e.prepare("INSERT INTO item_search(rowid, id, title, description, tags) SELECT rowid, ?, ?, ?, ? FROM items WHERE id = ?").run(i.id,i.title,i.description,i.tags.join(" "),i.id);let o=e.prepare("INSERT INTO item_metadata_keys(item_id, key) VALUES (?, ?)");for(let r of Object.keys(i))o.run(i.id,r);let n=e.prepare("INSERT INTO item_linked_files(item_id, path, scope, note) VALUES (?, ?, ?, ?)");for(let r of t.linkedFiles??[])n.run(i.id,r.path,r.scope,r.note??null)}async function mi(e){let t=G(e.pmRoot),i=se();if(!i){await H.rm(t,{force:!0});return}await H.mkdir(li.dirname(t),{recursive:!0});let o=`${t}.${ko()}.tmp`,n;try{n=new i(o),Fo(n),n.exec("BEGIN IMMEDIATE"),Ce(n,"version",re),Ce(n,"context_fingerprint",e.contextFingerprint),Ce(n,"source_cursor",e.sourceCursor);for(let r of e.rows)ui(n,r);n.exec("COMMIT"),n.close(),n=void 0,await H.rm(t,{force:!0}),await H.rename(o,t)}catch(r){throw n?.close(),await Promise.allSettled([H.rm(o,{force:!0})]),r}}function Se(e){return Object.fromEntries(e.prepare("SELECT key, value FROM metadata").all().map(t=>[String(t.key),String(t.value)]))}async function fi(e){let t=se();if(!t)return!1;let i=G(e.pmRoot),o;try{await H.access(i),o=new t(i),o.exec("PRAGMA foreign_keys = ON");let n=Se(o);if(n.version!==re||n.context_fingerprint!==e.contextFingerprint||n.source_cursor!==e.expectedSourceCursor)return o.close(),!1;o.exec("BEGIN IMMEDIATE");let r=o.prepare("DELETE FROM items WHERE relative_path = ?"),s=o.prepare("SELECT rowid FROM items WHERE relative_path = ?"),a=o.prepare("DELETE FROM item_search WHERE rowid = ?");for(let d of e.deletedRelativePaths??[]){let c=s.get(d);r.run(d),c&&a.run(c.rowid)}return e.row&&ui(o,e.row),Ce(o,"source_cursor",e.sourceCursor),o.exec("COMMIT"),o.close(),!0}catch{try{o?.exec("ROLLBACK")}catch{}return o?.close(),!1}}function Ie(e,t,i,o,n){!o||o.length===0||(e.push(`${i} ${n} (${o.map(()=>"?").join(", ")})`),t.push(...o))}function Mo(e){let t=[],i=[];Ie(t,i,"status",e.statuses,"IN"),Ie(t,i,"status",e.excludeStatuses,"NOT IN"),Ie(t,i,"type",e.types,"IN"),Ie(t,i,"id",e.ids,"IN");for(let o of e.metadataKeys??[])t.push("EXISTS (SELECT 1 FROM item_metadata_keys AS indexed_key WHERE indexed_key.item_id = items.id AND indexed_key.key = ?)"),i.push(o);for(let[o,n]of[["parent",e.parent],["assignee",e.assignee],["sprint",e.sprint],["release",e.release]])n!==void 0&&(t.push(`${o} = ?`),i.push(n));return e.priority!==void 0&&(t.push("priority = ?"),i.push(e.priority)),{where:t.length===0?"":` WHERE ${t.join(" AND ")}`,parameters:i}}async function ds(e){let t=se();if(!t)return null;let i=e.query??{},{where:o,parameters:n}=Mo(i),r;try{r=new t(G(e.pmRoot),{readOnly:!0});let s=Se(r);if(s.version!==re||s.source_cursor!==e.expectedSourceCursor)return r.close(),null;let a=r.prepare(`SELECT COUNT(*) AS count FROM items${o}`).get(...n),d=[],c="";i.limit!==void 0?(c+=" LIMIT ?",d.push(Math.max(0,Math.floor(i.limit))),i.offset!==void 0&&(c+=" OFFSET ?",d.push(Math.max(0,Math.floor(i.offset))))):i.offset!==void 0&&(c+=" LIMIT -1 OFFSET ?",d.push(Math.max(0,Math.floor(i.offset))));let y=r.prepare(`SELECT metadata_json FROM items${o}
72
+ ORDER BY ${i.terminalStatuses&&i.terminalStatuses.length>0?`CASE WHEN status IN (${i.terminalStatuses.map(()=>"?").join(", ")}) THEN 1 ELSE 0 END ASC, `:""}priority ASC, updated_at DESC, id ASC${c}`).all(...n,...i.terminalStatuses??[],...d).map(u=>{let l=JSON.parse(String(u.metadata_json));if(!l.id)throw new TypeError("Indexed metadata row has no id");return l});return r.close(),{source_cursor:s.source_cursor,total:Number(a.count),items:y}}catch{return r?.close(),null}}async function ls(e){let t=se();if(!t||e.paths.length===0)return null;let i;try{i=new t(G(e.pmRoot),{readOnly:!0});let o=Se(i);if(o.version!==re||o.source_cursor!==e.expectedSourceCursor)return i.close(),null;let n=e.paths.map(()=>"?").join(", "),r=e.scope===void 0?"":" AND scope = ?",s=[...e.paths,...e.scope===void 0?[]:[e.scope]],a=`path IN (${n})${r}`,d=i.prepare(`SELECT COUNT(DISTINCT item_id) AS count
73
+ FROM item_linked_files
74
+ WHERE ${a}`).get(...s),c=di(e.limit,50),y=di(e.offset,0),u=i.prepare(`SELECT items.id, items.metadata_json
75
+ FROM items
76
+ WHERE EXISTS (
77
+ SELECT 1 FROM item_linked_files
78
+ WHERE item_linked_files.item_id = items.id AND ${a}
79
+ )
80
+ ORDER BY items.priority ASC, items.updated_at DESC, items.id ASC
81
+ LIMIT ? OFFSET ?`).all(...s,c,y),l=[];if(u.length>0){let h=u.map(_=>String(_.id)),p=i.prepare(`SELECT item_id, path, scope, note
82
+ FROM item_linked_files
83
+ WHERE item_id IN (${h.map(()=>"?").join(", ")})
84
+ AND ${a}
85
+ ORDER BY path ASC, scope ASC`).all(...h,...s),g=new Map(h.map(_=>[_,[]]));for(let _ of p){let b=String(_.item_id),R=g.get(b);R.push({path:String(_.path),scope:String(_.scope),..._.note===null?{}:{note:String(_.note)}}),g.set(b,R)}for(let _ of u){let b=JSON.parse(String(_.metadata_json));l.push({item:b,files:g.get(String(_.id))})}}return i.close(),{source_cursor:o.source_cursor,total:Number(d.count),matches:l}}catch{return i?.close(),null}}async function us(e){let t=se();if(!t)return null;let i;try{i=new t(G(e.pmRoot),{readOnly:!0});let o=Se(i);if(o.version!==re||o.source_cursor!==e.expectedSourceCursor)return i.close(),null;let n=i.prepare(`SELECT items.metadata_json
86
+ FROM item_search
87
+ JOIN items ON items.id = item_search.id
88
+ WHERE item_search MATCH ?
89
+ ORDER BY bm25(item_search), items.priority, items.updated_at DESC, items.id
90
+ LIMIT ?`).all(e.query,Math.max(0,Math.floor(e.limit))).map(r=>JSON.parse(String(r.metadata_json)));return i.close(),{source_cursor:o.source_cursor,items:n}}catch{return i?.close(),null}}async function Te(e){await H.rm(G(e),{force:!0})}import E from"node:fs/promises";import w from"node:path";import{createHash as Po,randomUUID as gi}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="846c1c5d-8a5c-56ee-832a-bfc780283e70")}catch{}})();var O=8,wi=500,jo="metadata-derived-index",Lo="metadata-cache.json",$o="metadata-cache-bodies.json",Uo="metadata-cache-collections.json",Ho="metadata-cache-delta.json",Wo="metadata-cache-manifest.json",pi=4,Bo=["comments","notes","learnings","files","tests","test_runs","docs"];function bi(){return be(q())}function xe(e){let t={...e},i={};for(let o of Bo)o in t&&(i[o]=t[o],delete t[o]);return{light:t,heavy:i}}function Ei(e,t){return!t||Object.keys(t).length===0?e:{...e,...t}}function vi(e,t,i,o){let n=Po("sha256");n.update(`format:${e??"default"}`);let r=Object.entries(t).sort(([s],[a])=>s.localeCompare(a)).map(([s,a])=>`${s}=${a}`).join(",");return n.update(`|types:${r}`),i&&n.update(`|schema:${JSON.stringify(i)}`),o.length>0&&n.update(`|extension_fields:${o.join(",")}`),n.digest("hex").slice(0,16)}function Oe(e){return w.join(e,"runtime",Lo)}function De(e){return w.join(e,"runtime",$o)}function ke(e){return w.join(e,"runtime",Uo)}function dt(e){return w.join(e,"runtime",Ho)}function lt(e){return w.join(e,"runtime",Wo)}function Ne(e,t){let i=w.extname(e);return`${e.slice(0,-i.length)}.${t}${i}`}var zo=24,T=new Map,Ae=new WeakMap;function ut(e){return Ae.get(e)??e.source_cursor}function Xo(e,t){let i=ut(e);if(!(t.base_source_cursor!==i||e.source_cursor===t.source_cursor)){Ae.set(e,i);for(let[o,n]of Object.entries(t.changes))n.entry?e.entries[o]=n.entry:delete e.entries[o];e.directory_signatures=t.directory_signatures,e.source_cursor=t.source_cursor}}function Go(e,t){if(!e)return;let i=ut(e);if(!(t.base_source_cursor!==i||e.source_cursor===t.source_cursor)){Ae.set(e,i);for(let[o,n]of Object.entries(t.changes))n.body?e.bodies[o]=n.body:delete e.bodies[o];e.source_cursor=t.source_cursor}}function Yo(e,t){if(!e)return;let i=ut(e);if(!(t.base_source_cursor!==i||e.source_cursor===t.source_cursor)){Ae.set(e,i);for(let[o,n]of Object.entries(t.changes))n.collections?e.collections[o]=n.collections:delete e.collections[o];e.source_cursor=t.source_cursor}}function Vo(e,t,i,o){!e||!o||e.context_fingerprint!==o.context_fingerprint||(Xo(e,o),Go(t,o),Yo(i,o))}function ct(e,t){T.size>=zo&&!T.has(e)&&jt(T),T.set(e,t)}async function F(e,t){let i;try{i=await E.stat(e)}catch{return T.delete(e),null}let o=T.get(e);if(o&&ae(o.signature,i.mtimeMs,i.ctimeMs,i.size))return T.delete(e),T.set(e,o),o.envelope;let n;try{n=t(await E.readFile(e,"utf8"))}catch{n=null}return ct(e,{signature:{mtime_ms:i.mtimeMs,ctime_ms:i.ctimeMs,size:i.size},envelope:n}),n}async function Ko(e,t,i){let o=a=>{let d=JSON.parse(a);return d.version!==O||typeof d.source_cursor!="string"||typeof d.entries!="object"||d.entries===null?null:d},n=Oe(e),r=await F(n,o);if(!t||r===null||r.context_fingerprint===t)return r;let s=await F(Ne(n,t),o);return s===null&&le(i,`metadata_cache_context_changed:${r.context_fingerprint}->${t}`),s}async function qo(e,t){let i=r=>{let s=JSON.parse(r);return s.version!==O||typeof s.source_cursor!="string"||typeof s.bodies!="object"||s.bodies===null?null:s},o=De(e),n=await F(o,i);return t&&n?.context_fingerprint!==t?await F(Ne(o,t),i):n}async function Jo(e,t){let i=r=>{let s=JSON.parse(r);return s.version!==O||typeof s.source_cursor!="string"||typeof s.collections!="object"||s.collections===null?null:s},o=ke(e),n=await F(o,i);return t&&n?.context_fingerprint!==t?await F(Ne(o,t),i):n}async function mt(e){let t=dt(e),i=await F(t,o=>{let n=JSON.parse(o);return n.version!==O||typeof n.base_source_cursor!="string"||typeof n.source_cursor!="string"||typeof n.changes!="object"||n.changes===null?null:n});if(i)return{envelope:i,invalid:!1};try{return await E.stat(t),{envelope:null,invalid:!0}}catch{return{envelope:null,invalid:!1}}}async function ft(e){let t=lt(e),i=await F(t,o=>{let n=JSON.parse(o);return n.version!==O||typeof n.context_fingerprint!="string"||typeof n.source_cursor!="string"||!Number.isInteger(n.entry_count)||n.entry_count<0||typeof n.directory_signatures!="object"||n.directory_signatures===null?null:n});if(i)return i;try{await E.stat(t),await Y(e)}catch{}return null}async function ce(e,t){await E.mkdir(w.dirname(e),{recursive:!0}),await A(e,JSON.stringify(t));try{let o=await E.stat(e);ct(e,{signature:{mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size},envelope:t})}catch{T.delete(e)}let i=w.dirname(w.dirname(e));if(e===Oe(i)||e===De(i)||e===ke(i)){let o=Ne(e,t.context_fingerprint);await A(o,JSON.stringify(t));try{let d=await E.stat(o);ct(o,{signature:{mtime_ms:d.mtimeMs,ctime_ms:d.ctimeMs,size:d.size},envelope:t})}catch{T.delete(o)}let n=w.dirname(e),r=w.extname(e),s=w.basename(e,r),a=(await E.readdir(n,{withFileTypes:!0}).catch(()=>[])).filter(d=>d.isFile()&&d.name!==w.basename(e)&&d.name.startsWith(`${s}.`)&&d.name.endsWith(r)).map(d=>w.join(n,d.name));if(a.length>pi){let d=(await Promise.all(a.map(async c=>{try{return{path:c,mtime:(await E.stat(c)).mtimeMs}}catch{return null}}))).filter(c=>c!==null);for(let c of d.sort((y,u)=>y.mtime-u.mtime).slice(0,Math.max(0,d.length-pi)))await E.rm(c.path,{force:!0}),T.delete(c.path)}}}function Qo(e,t,i){return i?t===i&&e!==i:t==="toon"&&e!=="toon"}function Ii(e,t,i){return e===void 0||Qo(e,t,i)}function le(e,t){e&&!e.includes(t)&&e.push(t)}function ae(e,t,i,o){return e.mtime_ms===t&&e.ctime_ms===i&&e.size===o}async function Zo(e,t,i){let o=w.join(e,t);try{let n=await E.readdir(o);return{folder:t,dirPath:o,files:n}}catch(n){return typeof n=="object"&&n!==null&&"code"in n&&!L(n)&&le(i,`item_list_directory_read_failed:${t}`),{folder:t,dirPath:o,files:[]}}}async function en(e,t){try{let i=await E.stat(w.join(e,t));return[t,{exists:!0,mtime_ms:i.mtimeMs,ctime_ms:i.ctimeMs,size:i.size}]}catch{return[t,{exists:!1,mtime_ms:0,ctime_ms:0,size:0}]}}async function Re(e,t){return Object.fromEntries(await Promise.all(t.map(async i=>await en(e,i))))}function de(e,t){return!e||Object.keys(e).length!==Object.keys(t).length?!1:Object.entries(t).every(([i,o])=>{let n=e[i];return n!==void 0&&n.exists===o.exists&&ae(n,o.mtime_ms,o.ctime_ms,o.size)})}function tn(e){return pe.some(t=>e.toLowerCase().endsWith(t))}function on(e,t,i,o,n,r){o||(e.metadata=!0),t&&!n&&(e.body=!0),i&&!r&&(e.collections=!0)}async function nn(e,t,i){if(i)for(let o of await he({path:e,scope:"project"}))le(t,o)}function yi(e,t,i,o){if(e)return t&&i?i.collections:o}async function rn(e,t,i){let o=await E.stat(e),n=o.mtimeMs,r=o.ctimeMs,{size:s}=o,a=Le(e);await nn(e,i.warnings,i.dispatchReadHooks);let d=i.previousEntries[t],c=!i.forceSourceRead&&d!==void 0&&ae(d,n,r,s),y=i.previousBodies[t],u=!i.forceSourceRead&&y!==void 0&&ae(y,n,r,s),l=i.previousCollections[t],h=!i.forceSourceRead&&l!==void 0&&ae(l,n,r,s);if(!(!c||i.includeBody&&!u||i.includeCollections&&!h))return{mtimeMs:n,ctimeMs:r,size:s,itemFormat:a,lightMetadata:d.metadata,heavyMetadata:yi(i.includeCollections,h,l,void 0),bodyLength:d.body_length,body:i.includeBody?y.body:void 0};let p=await E.readFile(e,"utf8"),g=J(p,{format:a,schema:i.schema,extensionFieldNames:i.extensionFieldNames,onWarning:b=>le(i.warnings,b)}),_=xe(g.metadata);return on(i.state.misses,i.includeBody,i.includeCollections,c,u,h),{mtimeMs:n,ctimeMs:r,size:s,itemFormat:a,lightMetadata:c?d.metadata:_.light,heavyMetadata:yi(i.includeCollections,h,l,_.heavy),bodyLength:c?d.body_length:g.body.length,body:i.includeBody?g.body:void 0}}function sn(e,t,i,o){i.state.newEntries[t]={mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size,metadata:o.lightMetadata,body_length:o.bodyLength},i.includeBody&&o.body!==void 0&&(i.state.newBodies[t]={mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size,body:o.body}),i.includeCollections&&o.heavyMetadata!==void 0&&(i.state.newCollections[t]={mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size,collections:o.heavyMetadata});let n=i.includeCollections?Ei(o.lightMetadata,o.heavyMetadata):o.lightMetadata,r=i.state.documentsById.get(n.id),s={metadata:n,body:o.body,item_format:o.itemFormat,item_path:e};Ii(r?.itemFormat,o.itemFormat,i.preferredFormat)&&i.state.documentsById.set(n.id,{candidate:s,itemFormat:o.itemFormat})}async function an(e,t,i,o){try{let n=await rn(t,i,o);sn(t,i,o,n)}catch{le(o.warnings,`item_list_item_read_failed:${e}/${w.basename(t)}`)}}function cn(e,t){return e&&e.context_fingerprint===t?e.entries:{}}function dn(e,t){return e&&e.context_fingerprint===t?e.bodies:{}}function ln(e,t){return e&&e.context_fingerprint===t?e.collections:{}}function un(){return{newEntries:{},newBodies:{},newCollections:{},documentsById:new Map,misses:{metadata:!1,body:!1,collections:!1}}}async function mn(e,t){let i=[];for(let{folder:o,dirPath:n,files:r}of e)for(let s of r){if(!tn(s))continue;let a=w.join(n,s),d=w.relative(t.pmRoot,a);i.push(an(o,a,d,t)),i.length===32&&(await Promise.all(i),i.length=0)}await Promise.all(i)}async function fn(e){if(!(!(e.state.misses.metadata||Object.keys(e.previousEntries).length!==Object.keys(e.state.newEntries).length||!de(e.existingCache?.directory_signatures,e.directorySignatures))&&e.existingCache!==null&&e.existingCache.context_fingerprint===e.contextFingerprint))try{await ce(Oe(e.pmRoot),{version:O,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,directory_signatures:e.directorySignatures,entries:e.state.newEntries}),await ce(lt(e.pmRoot),{version:O,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,entry_count:Object.keys(e.state.newEntries).length,directory_signatures:e.directorySignatures});let t=[...e.state.documentsById.values()].map(({candidate:i})=>({relativePath:w.relative(e.pmRoot,i.item_path),metadata:xe(i.metadata).light,linkedFiles:i.metadata.files??[]}));t.length>=e.minimumIndexedItems?await mi({pmRoot:e.pmRoot,contextFingerprint:e.contextFingerprint,sourceCursor:e.sourceCursor,rows:t}):await Te(e.pmRoot)}catch{}}async function pn(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 ce(De(e.pmRoot),{version:O,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,bodies:e.state.newBodies}).catch(()=>{})}async function yn(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 ce(ke(e.pmRoot),{version:O,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,collections:e.state.newCollections}).catch(()=>{})}async function pt(e,t,i={}){let o=await ft(e);return i.required!==!0&&(o===null||o.entry_count<wi)?async()=>{}:$t(e,jo,30,t,!1,!1,3e3)}async function Cs(e,t){let i=await ft(e);if(i===null)return null;let o=await mt(e);if(o.invalid)return await Y(e),null;let n=o.envelope?.context_fingerprint===i.context_fingerprint&&o.envelope.base_source_cursor===i.source_cursor?o.envelope.source_cursor:i.source_cursor,r=o.envelope?.context_fingerprint===i.context_fingerprint&&o.envelope.base_source_cursor===i.source_cursor?o.envelope.directory_signatures:i.directory_signatures;return t&&!de(r,await Re(e,t))?null:{source_cursor:n,entry_count:i.entry_count}}function hi(e,t){let i=w.relative(e,t);return i===""||i===".."||i.startsWith(`..${w.sep}`)||w.isAbsolute(i)?null:i}async function Y(e){await Promise.all([Oe(e),De(e),ke(e),dt(e),lt(e)].map(async t=>{await E.rm(t,{force:!0}),T.delete(t)})),await Te(e)}async function hn(e){if(e.mutation.document===null)return{entry:null,body:null,collections:null};let t=await E.stat(e.mutation.itemPath),i=xe(e.mutation.document.metadata),o={mtime_ms:t.mtimeMs,ctime_ms:t.ctimeMs,size:t.size};return{entry:{...o,metadata:i.light,body_length:e.mutation.document.body.length},body:{...o,body:e.mutation.document.body},collections:{...o,collections:i.heavy}}}function _n(e,t,i){return e?.context_fingerprint===t&&e.base_source_cursor===i?structuredClone(e.changes):{}}async function yt(e){let t=hi(e.pmRoot,e.itemPath),i=e.previousItemPath?hi(e.pmRoot,e.previousItemPath):void 0;if(t===null||i===null)return await Y(e.pmRoot),["metadata_derived_index_path_invalidated"];try{let o=vi(e.preferredFormat,e.typeToFolder,e.schema,bi()),n=await ft(e.pmRoot);if(n===null||n.context_fingerprint!==o)return[];let r=n.source_cursor,s=await mt(e.pmRoot);if(s.invalid)return await Y(e.pmRoot),["metadata_derived_index_refresh_failed"];let a=_n(s.envelope,o,r),d=s.envelope?.context_fingerprint===o&&s.envelope.base_source_cursor===r?s.envelope.source_cursor:r;i!==void 0&&(a[i]={entry:null,body:null,collections:null}),a[t]=await hn({mutation:e});let c=gi();return await ce(dt(e.pmRoot),{version:O,context_fingerprint:o,base_source_cursor:r,source_cursor:c,directory_signatures:await Re(e.pmRoot,[...new Set(Object.values(e.typeToFolder))]),changes:a}),await fi({pmRoot:e.pmRoot,contextFingerprint:o,expectedSourceCursor:d,sourceCursor:c,row:e.document===null?null:{relativePath:t,metadata:xe(e.document.metadata).light,linkedFiles:e.document.metadata.files},deletedRelativePaths:[...i===void 0?[]:[i],...e.document===null?[t]:[]]})||await Te(e.pmRoot),[]}catch{return await Y(e.pmRoot).catch(()=>{}),["metadata_derived_index_refresh_failed"]}}function gn(e){return[...e.documentsById.values()].sort((t,i)=>t.candidate.metadata.id.localeCompare(i.candidate.metadata.id)).map(t=>t.candidate)}function _i(e,t,i){return e?.context_fingerprint===t&&e.source_cursor===i}function wn(e,t,i,o,n){return e.every(r=>(!t||o[r]!==void 0)&&(!i||n[r]!==void 0))}function bn(e){let t=new Map;for(let[i,o]of Object.entries(e.previousEntries)){let n=Le(i);if(!n)continue;let r=e.includeCollections?Ei(o.metadata,e.previousCollections[i]?.collections):o.metadata,s=t.get(r.id);Ii(s?.itemFormat,n,e.preferredFormat)&&t.set(r.id,{itemFormat:n,candidate:{metadata:r,body:e.includeBody?e.previousBodies[i]?.body:void 0,item_format:n,item_path:w.join(e.pmRoot,i)}})}return[...t.values()].sort((i,o)=>i.candidate.metadata.id.localeCompare(o.candidate.metadata.id)).map(i=>i.candidate)}function En(e){return e.forceSourceScan||He()||e.existingCache?.context_fingerprint!==e.contextFingerprint||e.entryKeys.length<e.minimumIndexedItems||!de(e.existingCache?.directory_signatures,e.directorySignatures)?!1:[!e.includeBody||_i(e.existingBodyCache,e.contextFingerprint,e.existingCache.source_cursor),!e.includeCollections||_i(e.existingCollectionsCache,e.contextFingerprint,e.existingCache.source_cursor)].every(Boolean)&&wn(e.entryKeys,e.includeBody,e.includeCollections,e.previousBodies,e.previousCollections)}async function Fe(e,t,i,o,n,r={}){let s=r.includeBody!==!1,a=r.includeCollections!==!1,d=bi(),c=vi(t,i,n,d),y=await mt(e);y.invalid&&await Y(e);let u=await Ko(e,c,r.cacheDiagnostics),l=s?await qo(e,c):null,h=a?await Jo(e,c):null;Vo(u,l,h,y.envelope);let p=cn(u,c),g=dn(l,c),_=ln(h,c),b=[...new Set(Object.values(i))],R=await Re(e,b),P=Object.keys(p),D=Math.max(1,Math.floor(r.derivedIndexMinimumItems??wi));if(En({forceSourceScan:r.forceSourceScan===!0,contextFingerprint:c,existingCache:u,existingBodyCache:l,existingCollectionsCache:h,directorySignatures:R,entryKeys:P,minimumIndexedItems:D,includeBody:s,includeCollections:a,previousBodies:g,previousCollections:_}))return bn({pmRoot:e,preferredFormat:t,includeBody:s,includeCollections:a,previousEntries:p,previousBodies:g,previousCollections:_});let W=await Promise.all(b.map(me=>Zo(e,me,o))),C=He(),I=un(),B={pmRoot:e,preferredFormat:t,warnings:o,schema:n,extensionFieldNames:d,includeBody:s,includeCollections:a,forceSourceRead:r.forceSourceScan===!0,dispatchReadHooks:C,previousEntries:p,previousBodies:g,previousCollections:_,state:I};await mn(W,B);let z=await Re(e,b),N=de(R,z)?z:{},S=I.misses.metadata||Object.keys(p).length!==Object.keys(I.newEntries).length||!de(u?.directory_signatures,N)||u===null?gi():u.source_cursor;return await fn({pmRoot:e,contextFingerprint:c,sourceCursor:S,existingCache:u,previousEntries:p,directorySignatures:N,state:I,minimumIndexedItems:D}),s&&await pn({pmRoot:e,contextFingerprint:c,sourceCursor:S,existingBodyCache:l,previousBodies:g,state:I}),a&&await yn({pmRoot:e,contextFingerprint:c,sourceCursor:S,existingCollectionsCache:h,previousCollections:_,state:I}),gn(I)}async function Ci(e,t,i,o,n){return(await Fe(e,t,i,o,n,{includeBody:!1})).map(r=>({metadata:r.metadata,body:r.body??""}))}async function Si(e,t,i,o,n){return(await Fe(e,t,i,o,n,{includeBody:!1,includeCollections:!1})).map(r=>({metadata:r.metadata,body:r.body??""}))}import M from"node:fs/promises";import{statSync as Sn}from"node:fs";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="02424d1c-c29f-5a13-b711-d50267170b9f")}catch{}})();function vn(e,t){let i=-1;return e.forEach((o,n)=>{let r=Date.parse(o.ts);if(!Number.isFinite(r))throw new m(`History for this item contains invalid timestamp at entry ${n+1}.`,f.GENERIC_FAILURE);r<=t&&(i=n)}),i}function In(e,t){let i=e[0]?.ts??null,o=e.at(-1)?.ts??null,n={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:i,last_timestamp:o}};return o!==null&&(n.examples=[o],t!==null&&(n.examples.unshift(String(t+1),String(t+e.length)),n.valid_range.first_version=t+1,n.valid_range.last_version=t+e.length)),{guidance:n,lastTimestamp:o}}function Cn(e,t){let i={};if(t instanceof Error&&t.message.trim().length>0&&(i.reason=t.message.trim()),typeof t!="object"||t===null)return i;let o=t;if(typeof o.index=="number"&&Number.isInteger(o.index)&&o.index>=0&&(i.patchIndex=o.index),typeof o.operation=="object"&&o.operation!==null){let n=o.operation;Object.assign(i,Object.fromEntries(["op","path","from"].flatMap(r=>{let s=n[r];return typeof s=="string"?[[r,s]]:[]})))}if(i.patchIndex!==void 0){let n=e[i.patchIndex];n&&(i.op??=n.op,i.path??=n.path,i.from??=n.from)}return i}function Ti(e,t,i={}){let o=e.trim(),n=i.errorSubject??"history",r=n==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=In(t,ie(t,!0));if(!o)throw new m(`Missing ${n} target. Use a timestamp or version number.`,f.USAGE,s);if(/^\d+$/.test(o)){let y=ie(t),u=Number(o);if(u>=1&&u<=y)throw new m(`History version ${u} was pruned by compaction.`,f.USAGE,{...s,code:"history_version_pruned"});if(!Number.isSafeInteger(u)||u<1||u>y+t.length)throw new m(`${r} version must be between ${y+1} and ${y+t.length} for this item.`,f.USAGE,s);return{kind:"version",raw:o,historyIndex:u-y-1}}let d=Date.parse(o);if(!Number.isFinite(d))throw new m(`Invalid ${n} target "${e}". Use a positive version number or ISO timestamp.`,f.USAGE,s);let c=vn(t,d);if(c<0||i.allowFutureTimestamp!==!0&&d>Date.parse(a))throw new m(n==="restore"?`No history entries exist at or before timestamp ${o}.`:`No history entry exists at timestamp ${o}.`,f.USAGE,s);return{kind:"timestamp",raw:o,historyIndex:c}}function ht(e,t,i,o){let n=Ve(e,t);if(n.ok)return n.document;let r=Cn(t,n.error),s=[`history_op=${o}`,r.patchIndex===void 0?null:`patch_index=${r.patchIndex}`,r.op?`op=${r.op}`:null,r.path?`path=${r.path}`:null,r.from?`from=${r.from}`:null].filter(a=>a!==null);throw new m(`Failed to apply history patch at entry ${i} (${s.join(", ")}). ${r.reason??String(n.error)}`,f.GENERIC_FAILURE)}function Ri(e,t){let i=e[0];if(i&&i.op!=="create"&&i.op!=="history_compact_baseline"){let s=Ve(Z,i.patch);if(!s.ok||typeof s.document.metadata.id!="string")throw new m("History starts without a reconstructable item baseline.",f.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the missing baseline."]})}let o=e.slice(0,t+1),n=_e([...o]),r=structuredClone(Z);for(let s=0;s<=t;s+=1){let a=e[s];if(!a)throw new m(`History target entry ${s+1} does not exist.`,f.USAGE);r=ht(r,a.patch,s+1,a.op)}if(!n.ok)throw new m(`History cannot be replayed: ${n.errors.join(", ")}.`,f.GENERIC_FAILURE,{code:"history_replay_invalid",verification_errors:n.errors,required:"Inspect the history integrity findings before attempting recovery.",nextSteps:["Run pm history <id> --verify --full."]});return r}function Ds(e,t){if(Object.keys(e.metadata).length>0){if(typeof e.metadata.id!="string"||!Array.isArray(e.metadata.tags))throw new m("History has no complete item baseline for this target.",f.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the first recorded state."]});return e}throw new m(`History target ${t.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,f.USAGE)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="be69f1e8-4543-5cf5-abb0-9d38ca1d0cc6")}catch{}})();function Tn(e,t){let i=-1,o=structuredClone(Z);for(let[a,d]of e.entries()){if(o=ht(o,d.patch,a+1,d.op),o.metadata.id!==void 0&&o.metadata.id!==t)throw new m(`History belongs to item ${String(o.metadata.id)}, expected ${t}.`,f.GENERIC_FAILURE,{code:"history_replay_invalid",required:"Recover the correct history stream for this item before attempting restoration."});o.metadata.id===t&&Array.isArray(o.metadata.tags)&&(i=a)}let n=ie(e,!0),r=i<0||n===null?null:n+i+1,s=r===null?void 0:String(r);if(i>=0&&s===void 0){let a=e[i].ts;Ti(a,e).historyIndex===i&&(s=a)}return{version:r,target:s}}async function xi(e,t,i){let o=new Set([te(t,i),ee(t)]);for(let n of o){let r=k(e,n);if(!Sn(r,{throwIfNoEntry:!1})?.isFile())continue;let s=await Xt(r,n),a=-1;if(s.forEach((h,p)=>{h.op==="delete"&&(a=p)}),a<0)continue;let d=Ri(s,s.length-1);if(Object.keys(d.metadata).length!==0)continue;let{version:c,target:y}=Tn(s,n),u=y===void 0?["history",n,"--verify"]:["get",n,"--at",y],l=x(u);return new m(`Item ${n} was deleted at ${s[a].ts}; its history is retained.`,f.NOT_FOUND,{code:"item_deleted",required:"Read a retained materialized version, then restore it if the item should exist again.",item_id:n,tombstone:{deleted:!0,deleted_at:s[a].ts,recoverable:y!==void 0,last_materialized_version:c},nextSteps:[l,...y===void 0?["Recover the pre-compaction history from version control."]:[x(["restore",n,y])]],recovery:{suggested_retry:l,suggested_retry_args:u}})}}import{AsyncLocalStorage as Rn}from"node:async_hooks";import Oi from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="c343ed33-0135-5d3a-94a4-67314b295168")}catch{}})();var Di=new Rn;function Xs(e,t){return Di.run({...e,pmRoot:Oi.resolve(e.pmRoot)},t)}function ki(e,t){let i=Di.getStore();return i?.pmRoot===Oi.resolve(e)&&i.itemId===t?{bulk_checkpoint:i.checkpointId}:void 0}import gt from"node:path";import xn from"node:fs/promises";import On from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fd3a41f0-4e82-59ab-bb8c-ed796c96a0d7")}catch{}})();function Dn(e){return[...new Set(e.filter(t=>t.trim().length>0))].sort((t,i)=>t.localeCompare(i))}function kn(e,t){return new m(`Missing history stream for ${e}. ${t} requires history streams when settings.history.missing_stream is strict_error.`,f.NOT_FOUND)}async function Nn(e,t){return await xt(On.dirname(e)),await(await xn.open(e,"a")).close(),$({path:e,scope:"project",op:`${t}:history:auto_create`})}async function _t(e){return An({pmRoot:e.pmRoot,settings:e.settings,itemIds:[e.itemId],commandLabel:e.commandLabel})}async function An(e){let t=Dn(e.itemIds),i=[],o=[];for(let n of t){let r=k(e.pmRoot,n);if(!await K(r)){if(e.settings.history.missing_stream==="strict_error")throw kn(n,e.commandLabel);o.push(...await Nn(r,e.commandLabel)),o.push(`history_stream_auto_created:${n}`),i.push(n)}}return{auto_created_ids:i,warnings:o}}import{isUtf8 as Fn}from"node:buffer";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2bc3df8a-c200-52a0-8227-0deda053a955")}catch{}})();async function Mn(e){try{return await M.access(e),!0}catch{return!1}}function Pn(e,t){e&&(e.includes(t)||e.push(t))}function wt(e){return e??be(q())}function jn(e){return e==="toon"?["toon","json_markdown"]:e==="json_markdown"?["json_markdown","toon"]:["toon","json_markdown"]}async function bt(e,t,i="pm-",o,n=j){let r=t.trim(),s=r.startsWith("#")?r.slice(1):r;if(s.length===0)return null;let a=te(t,i),d=ee(t),c=[...new Set([s,a,d])].filter(l=>l.length>0),y=Object.entries(n),u=jn(o);for(let l of c){let h=new Map;for(let[p]of y)for(let g of u){let _=je(e,p,l,g,n);await Mn(_)&&h.set(_,h.get(_)??{id:l,type:p,itemPath:_,item_format:g})}if(h.size>1){let p=[...h.keys()].map(g=>gt.relative(e,g).split(gt.sep).join("/")).sort();throw new m(`Item ${l} has ambiguous identity across ${p.join(", ")}. Preserve both documents and inspect pm ops validate --check-storage-integrity before resolving the collision.`,f.CONFLICT,{code:"item_identity_ambiguous",item_id:l,paths:p})}for(let p of h.values())return p}return null}async function Ai(e,t={}){let i=await Ln(e,t);if(i.error!==null)throw i.error;return{raw:i.raw,document:i.document}}async function Ln(e,t={}){let i=await M.readFile(e.itemPath);if(!Fn(i))throw new m("Item contains invalid UTF-8; preserve a binary backup before recovering it.",f.CONFLICT,{code:"item_document_encoding_invalid",item_id:e.id,item_path:e.itemPath,byte_length:i.length,empty:!1});let o=i.toString("utf8");await he({path:e.itemPath,scope:"project"});let n;try{n=J(o,{format:e.item_format,requireSupportedFormat:!0,schema:t.schema,extensionFieldNames:wt(t.extensionFieldNames),onWarning:r=>Pn(t.warnings,r)})}catch(r){if(r instanceof m&&r.code==="item_format_version_unsupported")throw new m(`Item ${e.id}: ${r.message}`,r.exitCode,{...r.context,item_id:e.id,item_path:e.itemPath});if(r instanceof m&&r.code==="item_document_invalid")return{raw:o,document:null,error:new m(`Cannot read ${e.id} at ${e.itemPath}${i.length===0?" (zero-length file)":""}: ${r.message}`,r.exitCode,{...r.context,item_id:e.id,item_path:e.itemPath,byte_length:i.length,empty:i.length===0,nextSteps:[`Run pm history ${e.id} --full, then pm restore ${e.id} <version> to recover a recorded state.`]})};throw r}return{raw:o,document:n,error:null}}async function $n(e,t,i=j,o,n){await ge(e);let r=await Ci(e,t,i,o,n);return ve(r.length),r.map(s=>s.metadata)}async function Da(e,t,i=j,o,n){await ge(e);let r=await Si(e,t,i,o,n);return ve(r.length),r.map(s=>s.metadata)}async function ka(e,t,i=j,o,n,r={}){await ge(e);let s=await Fe(e,t,i,o,n,{includeBody:!0,forceSourceScan:r.forceSourceScan});return ve(s.length),s.map(a=>({...a.metadata,body:a.body}))}function Fi(e){return{async get(t){let i=await bt(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!i)return null;let{document:o}=await Ai(i,{schema:e.settings.schema});return{item:o.metadata,body:o.body}},list:()=>$n(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema)}}async function Un(e,t){let i=new Set(Object.values(t)),o=[];return await Promise.all([...i].map(async n=>{try{let r=await M.readdir(gt.join(e,n));for(let s of r)for(let a of pe)if(s.toLowerCase().endsWith(a)){o.push(s.slice(0,-a.length));break}}catch{}})),o}async function Hn(e,t,i,o){let n=te(t,i),r=await Un(e,o);if(r.length===0)return[];let s=Math.max(3,Math.floor(n.length/2));return r.map(a=>({id:a,distance:fe(a,n,s)})).filter(a=>a.distance!==null).sort((a,d)=>a.distance-d.distance).slice(0,3).map(a=>a.id)}async function Wn(e,t,i,o){let n=await xi(e,t,i);if(n)return n;let r=await Hn(e,t,i,o),s=["Confirm the active --path/PM_PATH scope, then retry with a valid id."];return r.length>0&&s.unshift(`Did you mean one of: ${r.join(", ")}?`),new m(`Item ${t} not found`,f.NOT_FOUND,{code:"item_not_found",id:t,nextSteps:s})}function Bn(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 Mi(e){let t=e.typeToFolder??kt(e.settings,q()).type_to_folder,i=await bt(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,t);if(!i)throw await Wn(e.pmRoot,e.id,e.settings.id_prefix,t);let o=await Ut(e.pmRoot,i.id,e.settings.locks.ttl_seconds,e.author,!!e.force,e.settings.governance.force_required_for_stale_lock,e.settings.locks.wait_ms,{waitPolicy:"progress"}),n=o.release;try{let r=[],{raw:s,document:a}=await Ai(i,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames,warnings:r}),d=a.metadata.assignee?.trim(),c=a.metadata.claim_principal?.trim()||d,y=zt(e.author),u=Vt(e.settings);if(d&&c!==y&&!e.force&&!Bn(e.op,e.bypassAssigneeConflict)){if(u.ownership_enforcement==="strict")throw new m(`Item ${i.id} is assigned to ${d}. Use --force to override.`,f.CONFLICT);u.ownership_enforcement==="warn"&&r.push(`ownership_warning:assignee_conflict:${i.id}:${d}`)}return{typeToFolder:t,located:i,originalRaw:s,document:a,warnings:r,releaseLock:n,lease:o}}catch(r){throw await n(),r}}async function Pi(e,t,i,o){return e.fence(async()=>{let n;try{n=await M.readFile(t.itemPath,"utf8")}catch(r){if(!L(r))throw r;n=null}if(n!==i)throw new m(`Item ${t.id} changed after this mutation read it; refusing to overwrite the newer revision. Nothing was written.`,f.CONFLICT,{code:"stale_revision",item_id:t.id,reason:n===null?"item_removed":"item_revision_changed",required:"Re-read the item and apply the mutation again; the newer stored revision was kept."});return o()})}function zn(e,t,i){if(!e.handled||typeof e.result!="object"||e.result===null)return{effectiveTargetItemPath:t,effectiveSerializedAfter:i,skipItemWrite:!1};let o=e.result;return{effectiveTargetItemPath:typeof o.target_item_path=="string"&&o.target_item_path.trim().length>0?o.target_item_path:t,effectiveSerializedAfter:typeof o.contents=="string"?o.contents:i,skipItemWrite:o.skip_write===!0}}async function ji(e){try{let t=await bt(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!t)return{document:Pe};let i=J(await M.readFile(t.itemPath,"utf8"),{format:t.item_format,requireSupportedFormat:!0,schema:e.settings.schema,extensionFieldNames:wt(e.extensionFieldNames)});return i.metadata.id===e.embeddedId?{document:i}:{document:e.fallback,revision:Ni}}catch{return{document:e.fallback,revision:Ni}}}var Ni="unreadable-after-storage-override";async function Xn(e){let t=await We("item_store_delete",e),i=t.handled&&typeof t.result=="object"&&t.result!==null?t.result:{};return{effectiveItemPath:typeof i.item_path=="string"&&i.item_path.trim().length>0?i.item_path:e.item_path,skipDelete:i.skip_delete===!0,warnings:t.warnings}}async function Gn(e){if(!e.skipItemWrite){if(e.effectiveTargetItemPath!==e.originalItemPath){await A(e.originalItemPath,e.originalRaw),await M.rm(e.effectiveTargetItemPath,{force:!0});return}await A(e.originalItemPath,e.originalRaw)}}async function Et(e){Bt(e.op);let t=await Mi({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:e.op,author:e.author,force:e.force,bypassAssigneeConflict:e.bypassAssigneeConflict,extensionFieldNames:e.extensionFieldNames,typeToFolder:e.typeToFolder}),{typeToFolder:i,located:o,originalRaw:n,document:r,warnings:s,releaseLock:a,lease:d}=t;try{nt(e.pmRoot,r,o.id);let c=Q(r,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),y=Q(structuredClone(r),{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),u=await e.mutate(y);if(e.skipNoop===!0&&u.changedFields.length===0)return{item:c.metadata,body:c.body,changedFields:[],warnings:[...s,...u.warnings??[]]};let l={...e.resolveHistoryContext?.(),...ki(e.pmRoot,o.id),...ci(e.pmRoot,[o.id,r.metadata.id])},h=Math.max(ze(c.metadata),ze(y.metadata));Kt(Nt(e.pmRoot),h),h>Ht(y.metadata)&&(y.metadata.pm_format_version=h,u.changedFields.push("pm_format_version")),y.metadata.updated_at=Be();let p=Q(y,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),g=await qe({pmRoot:e.pmRoot,settings:e.settings,operation:e.op,author:e.author,before:c,after:p});await Ue({pm_root:e.pmRoot,operation:e.op,before:c,after:p,changed_fields:u.changedFields,sdk:Fi({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:i})});let _=await _t({pmRoot:e.pmRoot,settings:e.settings,itemId:o.id,commandLabel:e.op}),b="toon",R=Wt(p,{format:b,schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),P=je(e.pmRoot,p.metadata.type,o.id,b,i),D=k(e.pmRoot,o.id),W=await Pi(d,o,n,async()=>{let N=await We("item_store_write",{op:e.op,pm_root:e.pmRoot,item_id:o.id,source_item_path:o.itemPath,target_item_path:P,history_path:D,item_format:b,before:c,after:p,contents:R}),{effectiveTargetItemPath:S,effectiveSerializedAfter:me,skipItemWrite:V}=zn(N,P,R),Gi=await pt(e.pmRoot,e.author),St=[];try{V||await A(S,me),!V&&S!==o.itemPath&&await M.rm(o.itemPath);let Vi=Ge({nowIso:p.metadata.updated_at,author:e.author,op:e.op,before:c,after:p,message:e.message,context:g.decisions.length===0?Object.keys(l).length===0?void 0:l:{...l,workflow_policies:g.decisions}});try{await Ye(D,Vi)}catch(Ki){throw await Gn({skipItemWrite:V,effectiveTargetItemPath:S,originalItemPath:o.itemPath,originalRaw:n}),Ki}V||(St=await yt({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:i,schema:e.settings.schema,itemPath:S,previousItemPath:o.itemPath,document:p}))}finally{await Gi()}let Yi=V||S!==P||me!==R;return{derivedIndexWarnings:St,effectiveTargetItemPath:S,overrideWarnings:N.warnings,stored:Yi?await ji({pmRoot:e.pmRoot,settings:e.settings,id:o.id,typeToFolder:i,extensionFieldNames:e.extensionFieldNames,fallback:p,embeddedId:p.metadata.id}):{document:p}}}),{derivedIndexWarnings:C,effectiveTargetItemPath:I,stored:B}=W;st(e.pmRoot,B.document,o.id,[p.metadata.id],B.revision);let z=[...await $({path:I,scope:"project",op:e.op,item_id:p.metadata.id,item_type:p.metadata.type,before:c,after:p,changed_fields:u.changedFields}),...await $({path:D,scope:"project",op:`${e.op}:history`,item_id:p.metadata.id,item_type:p.metadata.type,before:c,after:p,changed_fields:u.changedFields})];return $e({id:p.metadata.id,op:e.op,item_type:p.metadata.type,previous_status:c.metadata.status,status:p.metadata.status,previous:ye(c.metadata,u.changedFields),current:ye(p.metadata,u.changedFields),changed_fields:u.changedFields}),{item:p.metadata,body:p.body,changedFields:u.changedFields,warnings:[...s,...u.warnings??[],...g.warnings,..._.warnings,...W.overrideWarnings,...C,...z]}}finally{await a()}}async function Na(e){let{historyContext:t,...i}=e;return Et({...i,resolveHistoryContext:()=>t})}async function Aa(e){return Et(e)}async function Fa(e){return Et(e)}async function Ma(e){let t=await Mi({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:"delete",author:e.author,force:e.force}),{located:i,originalRaw:o,document:n,warnings:r,releaseLock:s,lease:a}=t;try{nt(e.pmRoot,n,i.id);let d=wt(void 0),c=Q(n,{schema:e.settings.schema,extensionFieldNames:d}),y=await qe({pmRoot:e.pmRoot,settings:e.settings,operation:"delete",author:e.author,before:c,after:null,dryRun:e.dryRun});await Ue({pm_root:e.pmRoot,operation:"delete",before:c,after:null,changed_fields:["deleted"],sdk:Fi({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:t.typeToFolder})});let u=await _t({pmRoot:e.pmRoot,settings:e.settings,itemId:i.id,commandLabel:"delete"}),l=Be(),h=Pe,p=Ge({nowIso:l,author:e.author,op:"delete",before:c,after:h,message:e.message,context:y.decisions.length===0?void 0:{workflow_policies:y.decisions}}),g=k(e.pmRoot,i.id),_=()=>Xn({op:"delete",pm_root:e.pmRoot,item_id:i.id,item_path:i.itemPath,history_path:g,before:c});if(e.dryRun===!0){let C=await _();return{item:c.metadata,changedFields:["deleted"],targetPath:C.effectiveItemPath,warnings:[...r,...y.warnings,...u.warnings,...C.warnings]}}let b=await Pi(a,i,o,async()=>{let{effectiveItemPath:C,skipDelete:I,warnings:B}=await _(),z=await pt(e.pmRoot,e.author),N=[];try{I||await M.rm(C);try{await Ye(g,p)}catch(S){throw I||await A(C,o),S}I||(N=await yt({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:t.typeToFolder,schema:e.settings.schema,itemPath:C,document:null}))}finally{await z()}return{derivedIndexWarnings:N,effectiveItemPath:C,overrideWarnings:B,stored:I||C!==i.itemPath?await ji({pmRoot:e.pmRoot,settings:e.settings,id:i.id,typeToFolder:t.typeToFolder,fallback:h,embeddedId:n.metadata.id}):{document:h}}}),{derivedIndexWarnings:R,effectiveItemPath:P,stored:D}=b;st(e.pmRoot,D.document,i.id,[n.metadata.id],D.revision);let W=[...await $({path:P,scope:"project",op:"delete",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:h,changed_fields:["deleted"]}),...await $({path:g,scope:"project",op:"delete:history",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:h,changed_fields:["deleted"]})];return $e({id:c.metadata.id,op:"delete",item_type:c.metadata.type,previous_status:c.metadata.status,previous:ye(c.metadata,Object.keys(c.metadata)),changed_fields:["deleted"]}),{item:c.metadata,changedFields:["deleted"],warnings:[...r,...y.warnings,...u.warnings,...b.overrideWarnings,...R,...W]}}finally{await s()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a483f454-e261-5232-bae0-da3cdb8c0518")}catch{}})();var ue=Object.freeze({max_bytes:4096,max_depth:8}),Li=160;var $i=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u,Yn=new Set(["__proto__"]),v=class extends Error{reason;path;constructor(t,i){super(t),this.reason=t,this.path=i}};function Ui(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function Vn(e,t){return/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function Kn(e){if(Buffer.byteLength(e,"utf8")<=Li)return e;let t="",i=Buffer.byteLength("\u2026","utf8");for(let o of e){if(i+=Buffer.byteLength(o,"utf8"),i>Li)break;t+=o}return`${t}\u2026`}function Me(e,t,i){if(e.bytes+=t,!(e.bytes<=ue.max_bytes))throw new v("byte_limit",i)}function Hi(e,t,i){if(e.bytes+t>ue.max_bytes)throw new v("byte_limit",i)}function vt(e,t,i){let o=Object.getOwnPropertyDescriptor(e,t);if(o===void 0||!("value"in o))throw new v("unsupported_value",i);return o.value}function qn(e,t,i){if(typeof e=="number"&&!Number.isFinite(e))throw new v("non_finite_number",t);if(typeof e=="string"&&(Hi(i,e.length+2,t),$i.test(e)))throw new v("malformed_unicode",t);if(e!==null&&!["boolean","number","string"].includes(typeof e))throw new v("unsupported_value",t);return Me(i,Buffer.byteLength(JSON.stringify(e),"utf8"),t),e}function Wi(e,t,i,o){if(typeof e!="object"||e===null)return qn(e,t,o);if(i>=ue.max_depth)throw new v("depth_limit",t);if(Array.isArray(e)){let n=vt(e,"length",t);if(typeof n!="number"||!Number.isSafeInteger(n)||n<0)throw new v("unsupported_value",t);Me(o,n>0?n+1:2,t);let r=[];for(let s=0;s<n;s+=1){let a=`${t}[${s}]`;r.push(Wi(vt(e,String(s),a),a,i+1,o))}return r}if(!Ui(e))throw new v("unsupported_value",t);return Bi(e,t,i+1,o)}function Bi(e,t,i,o){let n=Object.keys(e);Me(o,n.length>0?n.length+1:2,t);let r={};for(let s of n){Hi(o,s.length+3,t);let a=Vn(t,s);if(Yn.has(s))throw new v("reserved_key",a);if($i.test(s))throw new v("malformed_unicode",a);Me(o,Buffer.byteLength(JSON.stringify(s),"utf8")+1,a),r[s]=Wi(vt(e,s,a),a,i,o)}return r}function Jn(e){try{if(e instanceof v)return e}catch{}return new v("unsupported_value","details")}function It(e){let t=ue.max_bytes,i={bytes:0};try{if(!Ui(e))throw new v("not_plain_object","details");return{ok:!0,details:Bi(e,"details",0,i),byte_length:i.bytes}}catch(o){let n=Jn(o);return{ok:!1,omission:n.reason==="byte_limit"?{reason:"byte_limit",byte_limit:t}:{reason:n.reason,path:Kn(n.path),byte_limit:t}}}}function Qn(e){return It(e).ok}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e82bc812-181f-57ab-a29a-61703e8bec1b")}catch{}})();function Ct(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function Ga(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;if(!Ct(t.requested_tokens)||t.basis!=="canonical_retry")return!1;switch(t.minimum_status){case"exact":return Ct(t.minimum_feasible_tokens)&&t.feasible_tokens===t.minimum_feasible_tokens&&t.reason===void 0;case"feasible_only":return t.minimum_feasible_tokens===null&&Ct(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 Zn="PmCliError";function Ya(e){if(!ir(e)||e.code!=="item_already_exists"||e.exitCode!==f.CONFLICT)return!1;let t=e.context;return typeof t=="object"&&t!==null&&t.code==="item_already_exists"&&typeof t.id=="string"&&t.id.trim().length>0&&typeof t.path=="string"&&t.path.trim().length>0}function er(e){if(!Number.isFinite(e))throw new TypeError("createPmCliExpectedError options.exitCode must be a finite number");let t=Math.trunc(e);if(t<=f.SUCCESS)throw new TypeError("createPmCliExpectedError options.exitCode must be a positive exit code");return t}function tr(e){if(e==null)return{};if(!Object.hasOwn(e,"details"))return e;let t=Object.getOwnPropertyDescriptor(e,"details");if(!("value"in t))throw zi("unsupported_value","details");if(t.value===void 0)return e;let i=It(t.value);if(i.ok)return{...e,details:i.details};if(i.omission.reason==="byte_limit"){let{details:o,...n}=e;return{...n,details_omitted:i.omission}}throw zi(i.omission.reason,i.omission.path)}function zi(e,t){let i=new TypeError(`createPmCliExpectedError options.context.details must be plain JSON (${e})`);return Object.defineProperty(i,"path",{value:t,enumerable:!1}),i}function Va(e,t={}){if(typeof e!="string"||e.trim().length===0)throw new TypeError("createPmCliExpectedError message must be a non-empty string");let i=new m(e,er(t.exitCode??f.USAGE),tr(t.context));return"cause"in t&&Object.defineProperty(i,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),i}function ir(e){try{if(!(e instanceof Error)||e.name!==Zn)return!1;let t=e;return typeof t.exitCode=="number"&&Number.isFinite(t.exitCode)&&typeof t.context=="object"&&t.context!==null&&!Array.isArray(t.context)}catch{return!1}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e23f9ca6-9fa6-566b-9bfb-7cbe6d449a59")}catch{}})();function or(e,t){let i=e.trim().toLowerCase();if(i.length===0)return;let o=Math.floor(i.length/3);return t.map(n=>({candidate:n,distance:fe(i,n.toLowerCase(),o)??Number.POSITIVE_INFINITY})).filter(({distance:n})=>Number.isFinite(n)).sort((n,r)=>n.distance!==r.distance?n.distance-r.distance:n.candidate.localeCompare(r.candidate))[0]?.candidate}function Xi(e){return["pm",...e].map(t=>/^[A-Za-z0-9_./:@=-]+$/u.test(t)?t:JSON.stringify(t)).join(" ")}function Za(e){let t=e.command_path.trim().replaceAll(/\s+/gu," "),i=e.token.trim(),o=i.length===0?"<empty>":i,n=[...new Set(e.allowed.map(l=>l.trim()))].filter(Boolean).sort((l,h)=>l.localeCompare(h));if(t.length===0||o.length===0||n.length===0)throw new TypeError("Unknown-subcommand contracts require a path, token, and allowed set");let r=t.split(" "),s=e.trailing_args??[],a=e.display_name??`pm ${t}`,d=e.token_kind??"subcommand",c=e.retry_command?void 0:or(o,n),y=Xi([...r,o,...s]),u=e.retry_command??(c?Xi([...r,c,...s]):void 0);return new m(`Unknown ${a} ${d} "${o}". Allowed: ${n.join(", ")}${e.message_suffix??""}`,e.exit_code??f.USAGE,{code:"unknown_subcommand",reason:"unknown_positional_token",value:o,examples:[...u?[u]:[],...e.examples??[],`pm ${t} --help`],nextSteps:u?[`Retry with the suggested command: ${u}`]:["Choose one value from recovery.allowed_values."],recovery:{attempted_command:y,allowed_values:n,suggested_retry:u,fallback_candidates:e.fallback_candidates}})}export{we as a,be as b,ar as c,cr as d,Za as e,_t as f,An as g,ei as h,ee as i,te as j,yr as k,ie as l,Ti as m,ht as n,Ri as o,Ds as p,co as q,uo as r,mo as s,fo as t,po as u,qe as v,Mr as w,Xr as x,Gr as y,Yr as z,Vr as A,Kr as B,qr as C,Jr as D,Qr as E,Eo as F,vo as G,Io as H,Zr as I,Oo as J,es as K,ts as L,nt as M,st as N,Xs as O,ds as P,ls as Q,us as R,wi as S,Bo as T,pt as U,Cs as V,yt as W,Fe as X,bt as Y,Ai as Z,Ln as _,$n as $,Da as aa,ka as ba,Fi as ca,Wn as da,Na as ea,Aa as fa,Fa as ga,Ma as ha,Qn as ia,Ga as ja,Zn as ka,Ya as la,Va as ma,ir as na};
91
+ //# sourceMappingURL=chunk-J7PWHKZK.js.map