@unbrained/pm-cli 2026.11.20 → 2026.11.22

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 (265) hide show
  1. package/.agents/skills/pm-developer/SKILL.md +1 -1
  2. package/.agents/skills/pm-sdk/SKILL.md +1 -1
  3. package/.agents/skills/pm-test-audit/SKILL.md +1 -1
  4. package/.claude-plugin/marketplace.json +1 -1
  5. package/CONTRIBUTING.md +2 -1
  6. package/dist/cli/error-guidance.js +2 -2
  7. package/dist/cli/register-history-maintenance.js +2 -2
  8. package/dist/cli/register-list-query.js +2 -2
  9. package/dist/cli/runtime/refusal-credential-redaction.js +1 -1
  10. package/dist/cli-bundle/bundle-manifest.json +1 -1
  11. package/dist/cli-bundle/chunks/chunk-3W47ZZ5T.js +9 -0
  12. package/dist/cli-bundle/chunks/chunk-4TB5D6HL.js +125 -0
  13. package/dist/cli-bundle/chunks/{chunk-4TZW4NLM.js → chunk-5ZMVLWE3.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-6BBDEIKC.js +33 -0
  15. package/dist/cli-bundle/chunks/{chunk-GXGW6KHB.js → chunk-AR4NP5HI.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-6X2AGUOT.js → chunk-B4PPFOPY.js} +3 -3
  17. package/dist/cli-bundle/chunks/{chunk-XK25TAJZ.js → chunk-B76TFRO2.js} +47 -45
  18. package/dist/cli-bundle/chunks/chunk-CAR2L5NW.js +8 -0
  19. package/dist/cli-bundle/chunks/{chunk-KDDIHGAO.js → chunk-EIGUKEV6.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-ZAO7VGX3.js → chunk-GTPCAJMZ.js} +2 -2
  21. package/dist/cli-bundle/chunks/chunk-GYP24M7W.js +2 -0
  22. package/dist/cli-bundle/chunks/{chunk-KQSPKWFH.js → chunk-HC2OPETM.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-5LF5QZT3.js → chunk-HKUV74K3.js} +2 -2
  24. package/dist/cli-bundle/chunks/chunk-HXHYDO2R.js +115 -0
  25. package/dist/cli-bundle/chunks/{chunk-FF4TXJDH.js → chunk-J2LABXBL.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-3BOR22MC.js → chunk-J52BEBSS.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-KQIZ34SF.js +3 -0
  28. package/dist/cli-bundle/chunks/chunk-LQBWLNZJ.js +3 -0
  29. package/dist/cli-bundle/chunks/chunk-OJTMGDON.js +31 -0
  30. package/dist/cli-bundle/chunks/{chunk-DG2EOOFX.js → chunk-TC6XLIYO.js} +2 -2
  31. package/dist/cli-bundle/chunks/{chunk-MGYAJONE.js → chunk-U7EL3AYA.js} +2 -2
  32. package/dist/cli-bundle/chunks/chunk-VQFWW4EF.js +6 -0
  33. package/dist/cli-bundle/chunks/{chunk-ZVEHACE6.js → chunk-X6MIWTTT.js} +2 -2
  34. package/dist/cli-bundle/chunks/chunk-XC5Q2ZV7.js +2 -0
  35. package/dist/cli-bundle/chunks/{chunk-KEBLUTC3.js → chunk-XFHPKXAE.js} +2 -2
  36. package/dist/cli-bundle/chunks/{chunk-OXG5XPC7.js → chunk-YHVLVSEZ.js} +2 -2
  37. package/dist/cli-bundle/chunks/{chunk-Y4LXVPA5.js → chunk-YMUSRWV4.js} +2 -2
  38. package/dist/cli-bundle/chunks/{chunk-HQYIKAC6.js → chunk-YR2KEBHP.js} +2 -2
  39. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-ELEMA7IW.js → indexed-receipt-blobs-ITTXIN4K.js} +2 -2
  40. package/dist/cli-bundle/chunks/{item-revision-GE2CQECR.js → item-revision-4QBMZXKX.js} +2 -2
  41. package/dist/cli-bundle/chunks/item-transaction-QY3PUHEI.js +2 -0
  42. package/dist/cli-bundle/chunks/{mutation-actor-5GYX7LP3.js → mutation-actor-FWLYWJ37.js} +2 -2
  43. package/dist/cli-bundle/chunks/{mutation-admission-72TYKPGU.js → mutation-admission-7ZDCK3G2.js} +2 -2
  44. package/dist/cli-bundle/chunks/{register-list-query-OQZZEWEB.js → register-list-query-RR5KACJ3.js} +10 -10
  45. package/dist/cli-bundle/chunks/{register-mutation-YZEUZ6XT.js → register-mutation-57AJQWFV.js} +2 -2
  46. package/dist/cli-bundle/chunks/{register-operations-JNVCF7EW.js → register-operations-RKWST7CU.js} +2 -2
  47. package/dist/cli-bundle/chunks/{register-setup-LDKULZSD.js → register-setup-CMI23PC5.js} +2 -2
  48. package/dist/cli-bundle/chunks/{settlement-hook-E5LHZ4RD.js → settlement-hook-BXN5LEQD.js} +2 -2
  49. package/dist/cli-bundle/chunks/{stage-Q2QZ2IBG.js → stage-4KDVXC5Z.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-JUYJ7NXL.js → chunk-2ZD7275J.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-7SB6VKEI.js → chunk-324AHXJO.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-IXYBN6D2.js → chunk-3IRCYJI5.js} +3 -3
  53. package/dist/cli-bundle/focused-chunks/{chunk-DH4DHL6V.js → chunk-3V53UBHN.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/chunk-3XSWH6QC.js +91 -0
  55. package/dist/cli-bundle/focused-chunks/{chunk-V55XZFOP.js → chunk-4JZITIJB.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/chunk-4KTFKSS3.js +2 -0
  57. package/dist/cli-bundle/focused-chunks/chunk-5C5TK3ET.js +78 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-AKJYOZZP.js +2 -0
  59. package/dist/cli-bundle/focused-chunks/{chunk-BZCLW5V7.js → chunk-BRZV7BFV.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/chunk-CR7CGEB2.js +3 -0
  61. package/dist/cli-bundle/focused-chunks/{chunk-PKMDWIP3.js → chunk-HDEKFSOK.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-O25KFLLA.js → chunk-IWOXAUDU.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-UATP3RK3.js → chunk-ML3JHCC6.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/{chunk-ZKGGGU2K.js → chunk-OPGOOP25.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-PRFEOCNZ.js → chunk-RE7ZWT7D.js} +3 -3
  66. package/dist/cli-bundle/focused-chunks/chunk-RKQNVYGF.js +3 -0
  67. package/dist/cli-bundle/focused-chunks/chunk-RQ252B6V.js +8 -0
  68. package/dist/cli-bundle/focused-chunks/{chunk-KQJNJZKP.js → chunk-URGHTTT3.js} +2 -2
  69. package/dist/cli-bundle/focused-chunks/chunk-USPYKWQG.js +13 -0
  70. package/dist/cli-bundle/focused-chunks/chunk-UWS3FC4D.js +102 -0
  71. package/dist/cli-bundle/focused-chunks/chunk-UXQGFGAT.js +44 -0
  72. package/dist/cli-bundle/focused-chunks/{chunk-PQXTZLK3.js → chunk-WZWXGDYY.js} +2 -2
  73. package/dist/cli-bundle/focused-chunks/{chunk-5VSXKA35.js → chunk-YKSLZPLT.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/chunk-ZWJTY4ID.js +2 -0
  75. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-ZTRFCPH7.js → indexed-receipt-blobs-AF4U3F3D.js} +2 -2
  76. package/dist/cli-bundle/focused-chunks/{item-revision-OXDZHMJ7.js → item-revision-2O6MLPEX.js} +2 -2
  77. package/dist/cli-bundle/focused-chunks/item-transaction-GLACUTPL.js +2 -0
  78. package/dist/cli-bundle/focused-chunks/{mutation-actor-6DYIF6NH.js → mutation-actor-TCYDPUGG.js} +2 -2
  79. package/dist/cli-bundle/focused-chunks/{mutation-admission-2BYXANVJ.js → mutation-admission-LY73EJWM.js} +2 -2
  80. package/dist/cli-bundle/focused-chunks/{settlement-hook-OUBUN45C.js → settlement-hook-ARYCZQY4.js} +2 -2
  81. package/dist/cli-bundle/focused-chunks/{stage-FGHSB3QX.js → stage-DQ7RQQ52.js} +2 -2
  82. package/dist/cli-bundle/main.js +25 -25
  83. package/dist/cli-bundle/sdk-authoring.js +1 -1
  84. package/dist/cli-bundle/sdk-contracts.js +2 -2
  85. package/dist/cli-bundle/sdk-core.js +1 -1
  86. package/dist/cli-bundle/sdk-governance.js +1 -1
  87. package/dist/cli-bundle/sdk-graph.js +1 -1
  88. package/dist/cli-bundle/sdk-merge.js +70 -57
  89. package/dist/cli-bundle/sdk-query.js +1 -1
  90. package/dist/cli-bundle/sdk-runtime.js +1 -1
  91. package/dist/cli-bundle/sdk-testing.js +1 -1
  92. package/dist/cli-bundle/sdk.js +11 -11
  93. package/dist/core/diagnostics/remediation.js +1 -1
  94. package/dist/core/extensions/index.d.ts +2 -0
  95. package/dist/core/extensions/index.js +1 -1
  96. package/dist/core/fs/atomic-create.js +1 -1
  97. package/dist/core/fs/file-glob.js +1 -1
  98. package/dist/core/fs/fs-utils.d.ts +3 -1
  99. package/dist/core/fs/fs-utils.js +1 -1
  100. package/dist/core/history/bridge.js +2 -0
  101. package/dist/core/history/drift-scan.js +1 -1
  102. package/dist/core/history/history-rewrite.js +1 -1
  103. package/dist/core/history/history-stream-policy.js +1 -1
  104. package/dist/core/history/history.d.ts +12 -0
  105. package/dist/core/history/history.js +2 -2
  106. package/dist/core/history/projection.js +1 -1
  107. package/dist/core/history/read.d.ts +20 -1
  108. package/dist/core/history/read.js +1 -1
  109. package/dist/core/history/replay.d.ts +46 -5
  110. package/dist/core/history/replay.js +2 -2
  111. package/dist/core/history/stream-summary.d.ts +129 -0
  112. package/dist/core/history/stream-summary.js +3 -0
  113. package/dist/core/shared/errors.d.ts +8 -0
  114. package/dist/core/shared/errors.js +1 -1
  115. package/dist/core/shared/url-credentials.js +1 -1
  116. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  117. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  118. package/dist/sdk/cli-contracts/registration-helpers.js +2 -2
  119. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  120. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  121. package/dist/sdk/cli-contracts/typed-action-inputs.d.ts +2 -2
  122. package/dist/sdk/completion/fish.js +3 -2
  123. package/dist/sdk/completion/zsh.js +3 -2
  124. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  125. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  126. package/dist/sdk/governance/gc.js +1 -1
  127. package/dist/sdk/governance/health/history-drift-remedies.js +2 -0
  128. package/dist/sdk/governance/health-merge-evidence.js +1 -1
  129. package/dist/sdk/governance/health.js +2 -2
  130. package/dist/sdk/governance/validate.js +1 -1
  131. package/dist/sdk/governance/workspace-position.js +1 -1
  132. package/dist/sdk/history/append-only-repair.d.ts +30 -0
  133. package/dist/sdk/history/append-only-repair.js +6 -0
  134. package/dist/sdk/history/maintenance.d.ts +8 -2
  135. package/dist/sdk/history/maintenance.js +1 -1
  136. package/dist/sdk/history/reanchor-refusal.js +2 -0
  137. package/dist/sdk/history/reseed.d.ts +15 -0
  138. package/dist/sdk/history/reseed.js +2 -0
  139. package/dist/sdk/history/salvage.d.ts +19 -8
  140. package/dist/sdk/history/salvage.js +5 -3
  141. package/dist/sdk/history-compact.js +1 -1
  142. package/dist/sdk/history-provenance.js +1 -1
  143. package/dist/sdk/history-redact.js +1 -1
  144. package/dist/sdk/history-repair.d.ts +8 -2
  145. package/dist/sdk/history-repair.js +1 -1
  146. package/dist/sdk/index.d.ts +1 -1
  147. package/dist/sdk/item-transaction.d.ts +33 -1
  148. package/dist/sdk/item-transaction.js +1 -1
  149. package/dist/sdk/lifecycle/restore.js +1 -1
  150. package/dist/sdk/merge/index.d.ts +1 -1
  151. package/dist/sdk/merge/index.js +1 -1
  152. package/dist/sdk/merge/install.d.ts +20 -6
  153. package/dist/sdk/merge/install.js +3 -3
  154. package/dist/sdk/merge/three-way.d.ts +22 -3
  155. package/dist/sdk/merge/three-way.js +8 -2
  156. package/dist/sdk/merge/worktree-config.js +2 -1
  157. package/dist/sdk/public-surface.json +1 -1
  158. package/dist/sdk/query/activity.d.ts +67 -5
  159. package/dist/sdk/query/activity.js +1 -1
  160. package/dist/sdk/query/context.d.ts +13 -3
  161. package/dist/sdk/query/context.js +2 -2
  162. package/dist/sdk/query.d.ts +1 -1
  163. package/dist/sdk/runtime/actions.js +1 -1
  164. package/dist/sdk/runtime-input.d.ts +6 -2
  165. package/dist/sdk/runtime-input.js +1 -1
  166. package/dist/sdk/runtime-primitives.d.ts +1 -1
  167. package/dist/sdk/runtime-primitives.js +1 -1
  168. package/dist/sdk/runtime.d.ts +7 -0
  169. package/dist/sdk/runtime.js +1 -1
  170. package/dist/sdk/structured-mutations.d.ts +5 -5
  171. package/dist/sdk/structured-mutations.js +1 -1
  172. package/dist/sdk/transactions/item-finalization.js +2 -0
  173. package/dist/types.d.ts +20 -0
  174. package/dist/types.js +1 -1
  175. package/docs/AGENT_GUIDE.md +1 -1
  176. package/docs/AGENT_RUNTIME_PRIMITIVES.md +1 -1
  177. package/docs/COMMANDS.md +62 -4
  178. package/docs/HISTORY_RECOVERY.md +229 -5
  179. package/docs/MERGE_SAFETY.md +8 -0
  180. package/docs/MUTATION_INTEGRITY.md +3 -1
  181. package/docs/README.md +8 -6
  182. package/docs/SDK.md +128 -5
  183. package/docs/SDK_CONTEXT_COORDINATION.md +3 -2
  184. package/docs/TESTING.md +8 -697
  185. package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +1 -1
  186. package/marketplace.json +1 -1
  187. package/node_modules/tar/package.json +2 -3
  188. package/package.json +35 -3
  189. package/packages/pm-beads/package.json +1 -1
  190. package/packages/pm-calendar/package.json +1 -1
  191. package/packages/pm-command-kit/package.json +1 -1
  192. package/packages/pm-digital-twin/package.json +1 -1
  193. package/packages/pm-governance-audit/package.json +1 -1
  194. package/packages/pm-guide-shell/package.json +1 -1
  195. package/packages/pm-kanban/package.json +1 -1
  196. package/packages/pm-lifecycle-hooks/package.json +1 -1
  197. package/packages/pm-linked-test-adapters/package.json +1 -1
  198. package/packages/pm-search-advanced/package.json +1 -1
  199. package/packages/pm-templates/package.json +1 -1
  200. package/packages/pm-todos/package.json +1 -1
  201. package/packages/pm-vcs/package.json +1 -1
  202. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  203. package/plugins/pm-claude/package.json +1 -1
  204. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  205. package/plugins/pm-codex/package.json +1 -1
  206. package/plugins/pm-codex/plugin.json +1 -1
  207. package/runtime-dependencies.json +1 -1
  208. package/dist/cli-bundle/chunks/chunk-2IZGNOGT.js +0 -6
  209. package/dist/cli-bundle/chunks/chunk-4QQPM3IY.js +0 -2
  210. package/dist/cli-bundle/chunks/chunk-5OFMWP3Q.js +0 -3
  211. package/dist/cli-bundle/chunks/chunk-6HRPGEBF.js +0 -2
  212. package/dist/cli-bundle/chunks/chunk-7ESF676D.js +0 -125
  213. package/dist/cli-bundle/chunks/chunk-7EZZ4W7O.js +0 -20
  214. package/dist/cli-bundle/chunks/chunk-FOYRE23V.js +0 -115
  215. package/dist/cli-bundle/chunks/chunk-HJQ3XPS3.js +0 -31
  216. package/dist/cli-bundle/chunks/chunk-M5D3CEMY.js +0 -9
  217. package/dist/cli-bundle/chunks/chunk-VS565KBX.js +0 -2
  218. package/dist/cli-bundle/chunks/chunk-W4TLA5H3.js +0 -8
  219. package/dist/cli-bundle/chunks/item-transaction-YSAWJRA2.js +0 -2
  220. package/dist/cli-bundle/focused-chunks/chunk-3LRSQXCN.js +0 -2
  221. package/dist/cli-bundle/focused-chunks/chunk-FOA7XKWP.js +0 -2
  222. package/dist/cli-bundle/focused-chunks/chunk-FPKVHC3Q.js +0 -2
  223. package/dist/cli-bundle/focused-chunks/chunk-I7XBR2RM.js +0 -91
  224. package/dist/cli-bundle/focused-chunks/chunk-MJP3TFVW.js +0 -2
  225. package/dist/cli-bundle/focused-chunks/chunk-PZSTRYTA.js +0 -102
  226. package/dist/cli-bundle/focused-chunks/chunk-QNJQPJWO.js +0 -44
  227. package/dist/cli-bundle/focused-chunks/chunk-SIPDQBJI.js +0 -8
  228. package/dist/cli-bundle/focused-chunks/chunk-SJE3PYPI.js +0 -3
  229. package/dist/cli-bundle/focused-chunks/chunk-TNKI6WKG.js +0 -66
  230. package/dist/cli-bundle/focused-chunks/chunk-TRCXANRR.js +0 -12
  231. package/dist/cli-bundle/focused-chunks/item-transaction-54VSTT6L.js +0 -2
  232. package/dist/sdk/agent/refusal-closure.js +0 -2
  233. package/dist/sdk/agent/refusal-reachability.js +0 -4
  234. package/dist/sdk/agent/task-transcript-contracts.js +0 -2
  235. package/dist/sdk/agent/tracker-preflight-contracts.js +0 -2
  236. package/dist/sdk/authoring.js +0 -2
  237. package/dist/sdk/compose.js +0 -2
  238. package/dist/sdk/contracts.js +0 -2
  239. package/dist/sdk/core-governance.js +0 -2
  240. package/dist/sdk/core.js +0 -2
  241. package/dist/sdk/corpus-shape.js +0 -2
  242. package/dist/sdk/define.js +0 -2
  243. package/dist/sdk/environment/agent-environment.js +0 -2
  244. package/dist/sdk/governance/artifact-ledgers.js +0 -2
  245. package/dist/sdk/governance/coverage-assurance.js +0 -2
  246. package/dist/sdk/governance/reliability.js +0 -2
  247. package/dist/sdk/governance.js +0 -2
  248. package/dist/sdk/graph/adapter.js +0 -2
  249. package/dist/sdk/graph/conformance.js +0 -2
  250. package/dist/sdk/graph/index.js +0 -2
  251. package/dist/sdk/graph.js +0 -2
  252. package/dist/sdk/index.js +0 -2
  253. package/dist/sdk/query.js +0 -2
  254. package/dist/sdk/relationship-migration.js +0 -2
  255. package/dist/sdk/testing.js +0 -8
  256. package/dist/sdk/workspace-recipe.js +0 -2
  257. package/docs/AGENT_PROVENANCE_ADR.md +0 -206
  258. package/docs/DEFECT_RECURRENCE.md +0 -257
  259. package/docs/MCP_2026_07_28_CONFORMANCE.md +0 -41
  260. package/docs/PERFORMANCE.md +0 -189
  261. package/docs/QUALITY_EVIDENCE.md +0 -130
  262. package/docs/generated/FLAG_LEXICON_BUDGETS.md +0 -117
  263. package/docs/performance/cli-transport-overhead.md +0 -51
  264. package/docs/performance/runner-qualification.md +0 -36
  265. package/docs/performance/sdk-entrypoint-import-costs.md +0 -32
@@ -1,91 +0,0 @@
1
- import{e as Wt,n as Bt,v as zt,x as he}from"./chunk-BZCLW5V7.js";import{Ad as q,Ba as Me,Bd as Ft,Be as fe,Ca as Pe,Cd as K,Da as D,Dc as Dt,Ec as je,Ge as $t,Gf as Q,H as gt,If as Xe,Jf as ye,Kf as L,Mc as V,Md as Mt,Nd as Pt,Nf as Ge,Oa as Tt,Of as pe,Pf as Ye,Sa as St,Sf as Ve,Ta as xt,Uc as kt,Xe as Ue,Ye as He,a as ue,bc as Rt,gd as Le,hd as Nt,me as jt,mf as We,na as Et,nf as Be,oa as vt,of as Ut,pe as Lt,pf as ze,qf as Ht,ra as It,re as J,td as At,wa as me,xc as Ot,ya as Ct,ze as $e}from"./chunk-PZSTRYTA.js";import{A as m,B as bt,C as Y,E as j,I as N,m as wt,t as P,y as Fe,z as f}from"./chunk-IXYBN6D2.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4e02447f-3fb0-5f7c-9512-be2b348fd082")}catch{}})();var $=new Set(wt),_e=Object.freeze({get size(){return $.size},has(e){return $.has(e)},entries(){return $.entries()},keys(){return $.keys()},values(){return $.values()},forEach(e,t){$.forEach(i=>e.call(t,i,i,_e))},[Symbol.iterator](){return $.values()}});function Xt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Gt(e){return typeof e!="string"?null:gt(e)}function Hi(e){try{return structuredClone(e)}catch{return e}}function Wi(e){let t=e.trim(),i=t.indexOf("=");if(i<=0)throw new m(`--field entries must use name=value syntax, received: ${e}`,f.USAGE);let o=t.slice(0,i).trim(),r=t.slice(i+1);return{key:o,value:r}}function Bi(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 r=Number(o);if(!Number.isFinite(r))throw new m(`--field ${e}=... must be a number`,f.USAGE);return r}if(t==="boolean"){let o=i.trim().toLowerCase();if(o==="true"||o==="1"||o==="yes")return!0;if(o==="false"||o==="0"||o==="no")return!1;throw new m(`--field ${e}=... must be one of true|false|1|0|yes|no`,f.USAGE)}return t==="string_array"?i.split(/[\n,|]/u).map(o=>o.trim()).filter(o=>o.length>0):Bi(i,e,t)}function qe(e){let t=new Map;if(!e)return t;for(let i of e.item_fields)for(let o of i.fields){let r=Xt(o.name),n=Gt(o.type);if(!r||!n)continue;let s=t.get(r);if(s&&s.type!==n)throw new m(`Extension item field "${r}" is declared with conflicting types: ${s.type}, ${n}`,f.USAGE,{code:"extension_item_field_type_conflict",nextSteps:["Make every active extension declaration for this field use the same type."]});t.set(r,{name:r,type:n})}return t}function Yt(e){if(_e.has(e))throw new m(`Extension item field "${e}" collides with built-in item metadata "${e}"; rename the extension field with an extension-specific prefix. Reserved fields: ${[..._e].sort((t,i)=>t.localeCompare(i)).join(", ")}.`,f.USAGE,{code:"extension_item_field_reserved",nextSteps:["Rename the extension item field, preferably with an extension-specific prefix."]})}function ge(e){return[...qe(e).keys()].sort((t,i)=>t.localeCompare(i))}function Ur(e,t,i,o){if(!e||e.length===0)return{};let r=qe(t),n={};for(let s of e){let{key:a,value:d}=Wi(s),c=r.get(a);if(!c)throw Xi(a,r,i,o);Yt(c.name),n[c.name]=zi(c.name,c.type,d)}return n}function Xi(e,t,i,o){if(_e.has(e)){let s=i?.(e)??{recovery:{provided_fields:[e]},nextSteps:["Core metadata has no generic --field mutation path. Use the owning lifecycle, evidence, or importer API; inspect pm update <id> --help for declared mutation flags."]};return new m(`--field ${e} is a core item field, not an extension field`,f.USAGE,{code:"core_item_field_requires_dedicated_flag",field:e,...s})}let r=o?.(e);if(r!==void 0){let s=r.recovery?.suggested_flags?.[0];return new m(s===void 0?`--field ${e} is a project-schema field, not an extension field`:`--field ${e} is a project-schema field; set it with its declared flag ${s}`,f.USAGE,{code:"project_schema_field_requires_declared_flag",field:e,changed:!1,...r})}let n=[...t.keys()].sort((s,a)=>s.localeCompare(a));return new m(`--field ${e} is not declared by an active extension item-field registration`,f.USAGE,{code:"extension_item_field_unknown",field:e,recovery:{provided_fields:[e]},nextSteps:n.length>0?[`Use one of the declared fields: ${n.join(", ")}`]:["Activate an extension that calls registerItemFields before setting extension fields."]})}function Gi(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 Yi(e,t){return!t||t.length===0?!0:t.some(i=>Object.is(i,e))}function Hr(e,t,i={}){if(t){qe(t);for(let o of t.item_fields)for(let r of o.fields){let n=Xt(r.name);if(!n)continue;Yt(n),!(n in e)&&!i.skipDefaultFields?.has(n)&&Object.prototype.hasOwnProperty.call(r,"default")&&(e[n]=Hi(r.default));let s=e[n];if(s===void 0)continue;let a=Gt(r.type);if(a&&!Gi(s,a))throw new TypeError(`Item field "${n}" must be of type ${a}`);let d=Array.isArray(r.values)?r.values:void 0;if(!Yi(s,d))throw new TypeError(`Item field "${n}" must match one of the configured allowed values`)}}}import Vi from"node:crypto";import we from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="664124e5-715d-5f86-ae69-89f203db76c3")}catch{}})();function qt(e){let t=[],i=!1;for(let o of(e??"").toLowerCase()){let r=o.charCodeAt(0),n=r>=48&&r<=57,s=r>=97&&r<=122;if(!n&&!s){i=t.length>0;continue}i&&(t.push("-"),i=!1),t.push(o)}return t.length===0?"pm-":`${t.join("")}-`}function Z(e){let t=e.trim().toLowerCase();return t.startsWith("#")&&(t=t.slice(1)),t}function ee(e,t){let i=qt(t),o=Z(e);return o.startsWith(i)?o:`${i}${o}`}function qi(e){let t=Dt(e);if(t!==void 0)return t;let i="";for(let o=0;o<e;o+=1)i+=Vi.randomInt(0,36).toString(36);return i}async function Ki(e,t,i){let o=[...new Set(Object.values(i))].flatMap(r=>[we.join(e,r,`${t}.md`),we.join(e,r,`${t}.toon`)]);return o.push(we.join(e,"history",`${t}.jsonl`)),(await Promise.all(o.map(r=>Y(r)))).some(Boolean)}var Vt=4,Kt=12;function Ji(e){return typeof e!="number"||!Number.isFinite(e)?Vt:Math.min(Kt,Math.max(Vt,Math.trunc(e)))}async function Vr(e,t,i={}){let o=Ji(i.tokenLength),r=Math.min(o+6,Kt),n=0;for(;o<=r;){for(let s=0;s<32;s+=1){let a=`${qt(t)}${qi(o)}`;if(!await(i.probeExisting===!1?Y(we.join(e,"history",`${a}.jsonl`)):Ki(e,a,i.typeToFolder??P)))return a;n+=1}o+=1}throw new Error(`Unable to generate unique id after ${n} attempts`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5db05e2f-4742-526b-b1c8-b97ff302b40e")}catch{}})();function te(e,t=!1){let i=e[0];if(i?.op!=="history_compact_baseline")return 0;let o=i.context?.history_compaction,r=typeof o=="object"&&o!==null&&"version_offset"in o?o.version_offset:void 0;if(typeof r=="number"&&Number.isSafeInteger(r)&&r>=0&&Number.isSafeInteger(r+e.length))return r;if(t)return null;throw new m("This compacted stream has no trustworthy version offset; numeric history addresses are unavailable.",f.USAGE,{code:"history_version_mapping_unavailable",required:"Use a retained timestamp or recover the pre-compaction stream from version control.",nextSteps:["Run pm history <id> --full to inspect the retained timestamps and checkpoint evidence."]})}import Jt from"node:fs/promises";import ie from"node:path";import{isUtf8 as Qi}from"node:buffer";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9fa43d4b-3e4e-5d96-a256-0ce743f52372")}catch{}})();var Zi=1048576,eo=4194304;async function Qt(e,t){let i=ie.dirname(e);for(;i!==ie.parse(e).root;){let r=await Jt.stat(i).catch(n=>{if(j(n))return null;throw n});if(r!==null){if(!r.isDirectory())throw new m("Workflow policy storage ancestor must be a directory.",f.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Restore the policy or approval history directory before retrying."]});break}i=ie.dirname(i)}let o=await Jt.open(e,"r").catch(r=>{if(j(r))return null;throw r});if(o===null)return null;try{let r=(await o.stat()).size,n=Buffer.alloc(Math.min(t,r)+1),s=0;for(;s<n.length;){let a=await o.read(n,s,n.length-s,s);if(a.bytesRead===0)break;s+=a.bytesRead}if(s===n.length||!Qi(n.subarray(0,s)))throw new m("Workflow policy input exceeds its byte bound or is not valid UTF-8.",f.CONFLICT,{code:"workflow_policy_input_unreadable",nextSteps:["Inspect the policy and approval history; reduce the declaration or use verified history compaction before retrying."]});return n.toString("utf8",0,s)}finally{await o.close()}}function to(e){if(e===null)return{version:1,enforcement:"advise",policies:[]};let t;try{t=JSON.parse(e)}catch{throw new m("schema/policies.json must contain valid JSON.",f.CONFLICT,{code:"workflow_policy_registry_invalid",nextSteps:["Restore valid policy JSON before retrying the mutation."]})}return Tt(t)}async function io(e){return to(await Qt(ie.join(e,"schema","policies.json"),Zi))}async function oo(e,t){let i=await Qt(D(e,t),eo);if(i===null)return[];let o;try{if(o=i.split(/\r?\n/).filter(r=>r.trim()).map(r=>JSON.parse(r)),!fe(o).ok)throw new Error("invalid chain")}catch{throw new m("Approval evidence requires a valid item history chain.",f.CONFLICT,{code:"workflow_policy_approval_history_invalid",nextSteps:[`Run pm history ${t} --verify before recording or using an approval.`]})}return o.flatMap(r=>{let n=r.context?.workflow_approval;if(r.op!=="policy_approve"||r.record_hash_version!==1||typeof r.record_hash!="string"||typeof n!="object"||n===null)return[];let s=n;return typeof s.policy_fingerprint!="string"||typeof s.content_fingerprint!="string"?[]:[{policy_fingerprint:s.policy_fingerprint,content_fingerprint:s.content_fingerprint,author:r.author}]})}async function ro(e,t,i){let o=i.before?.status!==i.after?.status&&t.policies.some(s=>s.rule.kind==="approval"&&St(s,i)),r=i.before?.id??i.after?.id,n=o&&typeof r=="string"?await oo(e,r):[];return xt(t,{...i,approvals:n})}function no(e,t){if(e.dryRun===!0)return!1;let i=Ut(e.pmRoot,[e.before?.metadata.id,e.after?.metadata.id],e.operation);return i===void 0?!1:(i.overrides.push(...t.map(o=>({source:"workflow_policy",policy_id:o.policy_id,rule:o.rule}))),!0)}async function Ke(e){let t=await io(e.pmRoot),i=await ro(e.pmRoot,t,{operation:e.operation,author:e.author,before:e.before?{...e.before.metadata,body:e.before.body}:null,after:e.after?{...e.after.metadata,body:e.after.body}:null});if(i.allowed)return i;let o=i.decisions.filter(r=>!r.satisfied&&r.effect==="refuse");return no(e,o)?i:so(e,t,i,o)}async function so(e,t,i,o){let r=[],n="";if(!e.dryRun)try{let l=await Wt({pmRoot:e.pmRoot,op:"policy_refused",author:e.author,context:{item_id:e.after?.metadata.id??e.before?.metadata.id,operation:e.operation,workflow_policies:i.decisions},message:"Workflow policy refused a proposed item mutation.",lockTtlSeconds:e.settings.locks.ttl_seconds,lockWaitMs:e.settings.locks.wait_ms});r.push({path:"history/_workspace.jsonl",op:"policy_refused",record_hash:l.entry.record_hash}),n=" Audit appended to tracker-relative history/_workspace.jsonl; retain it with the workspace changes. Each refused attempt records its own audit event."}catch(l){let h=new m("Workflow policy refusal could not be recorded in workspace history.",f.CONFLICT,{code:"workflow_policy_audit_failed",nextSteps:["Resolve workspace-history lock or storage failures, then retry the refused mutation; no item changes were written."]});throw h.cause=l,h}let s=o.slice(0,3).map(l=>({policy_id:l.policy_id,rule:l.rule,description:t.policies.find(h=>h.id===l.policy_id).description,missing_fields:l.missing_fields})),a=[...new Set(s.flatMap(l=>l.missing_fields))],d=s.map(l=>`${l.policy_id} (${l.rule})`).join(", "),c=o.length>3?` and ${o.length-3} more`:"",p=e.after?.metadata.id??e.before.metadata.id,u=a.map(l=>{if(e.before===null)return`Supply ${l} in the original ${e.operation} request, then retry; the item was not created.`;let h=Et("update",l);return h===void 0?`Supply ${l} using its declared SDK or package mutation contract, then retry.`:V(["update",p,vt("update",h),`<${l}>`,"--pm-path",ie.resolve(e.pmRoot)])});throw new m(`Workflow policy refused ${e.operation}: ${d}${c}.${a.length?` Missing: ${a.join(", ")}.`:""}${n}`,f.CONFLICT,{code:"workflow_policy_refused",side_effects:r,reason:s.map(l=>l.policy_id).join(","),policy_violations:s,policy_violation_count:o.length,required:a.length?`Supply missing fields: ${a.join(", ")}, then retry the refused mutation.`:"Satisfy the declared workflow policy before retrying.",why:s.map(l=>l.description).filter(Boolean).join(" ")||void 0,recovery:{missing_required_fields:a},nextSteps:[...u,...new Set(o.slice(0,3).filter(l=>l.missing_fields.length===0).map(l=>l.remediation)),...o.length>3?[`Inspect all policies with pm schema policies before retrying ${e.operation}.`]:[]]})}import{AsyncLocalStorage as ao}from"node:async_hooks";import{channel as co}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 ao,Qe=co("@unbrained/pm-cli/item-metadata-enumeration/v1");function be(e){Qe.publish(e)}async function hn(e){let t={enumeration_calls:0,metadata_rows:0},i=o=>{Je.getStore()?.includes(t)&&(t.enumeration_calls+=1,t.metadata_rows+=o)};Qe.subscribe(i);try{return{result:await Je.run([...Je.getStore()??[],t],e),work:{...t}}}finally{Qe.unsubscribe(i)}}import U from"node:fs/promises";import ei from"node:path";import{randomUUID as lo}from"node:crypto";import{createRequire as uo}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 mo="metadata-query-index.sqlite",oe="5",Ze;function re(){return Ze!==void 0||(Ze=$t(process.versions.node,uo(import.meta.url))),Ze}function Zt(e,t){return Math.max(0,Math.floor(e===void 0?t:e))}function z(e){return ei.join(e,"runtime",mo)}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 ve(e,t,i){e.prepare("INSERT INTO metadata(key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run(t,i)}function ti(e,t){let i=t.metadata;e.prepare(`INSERT INTO items(
57
- id, relative_path, metadata_json, status, type, priority,
58
- updated_at, created_at, parent, assignee, sprint, release
59
- ) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
60
- ON CONFLICT(id) DO UPDATE SET
61
- relative_path = excluded.relative_path,
62
- metadata_json = excluded.metadata_json,
63
- status = excluded.status,
64
- type = excluded.type,
65
- priority = excluded.priority,
66
- updated_at = excluded.updated_at,
67
- created_at = excluded.created_at,
68
- parent = excluded.parent,
69
- assignee = excluded.assignee,
70
- sprint = excluded.sprint,
71
- release = excluded.release`).run(i.id,t.relativePath,JSON.stringify(i),i.status,i.type,i.priority,i.updated_at,i.created_at,i.parent??null,i.assignee??null,i.sprint??null,i.release??null),e.prepare("DELETE FROM item_metadata_keys WHERE item_id = ?").run(i.id),e.prepare("DELETE FROM item_linked_files WHERE item_id = ?").run(i.id),e.prepare("DELETE FROM item_search WHERE rowid = (SELECT rowid FROM items WHERE id = ?)").run(i.id),e.prepare("INSERT INTO item_search(rowid, id, title, description, tags) SELECT rowid, ?, ?, ?, ? FROM items WHERE id = ?").run(i.id,i.title,i.description,i.tags.join(" "),i.id);let o=e.prepare("INSERT INTO item_metadata_keys(item_id, key) VALUES (?, ?)");for(let n of Object.keys(i))o.run(i.id,n);let r=e.prepare("INSERT INTO item_linked_files(item_id, path, scope, note) VALUES (?, ?, ?, ?)");for(let n of t.linkedFiles??[])r.run(i.id,n.path,n.scope,n.note??null)}async function ii(e){let t=z(e.pmRoot),i=re();if(!i){await U.rm(t,{force:!0});return}await U.mkdir(ei.dirname(t),{recursive:!0});let o=`${t}.${lo()}.tmp`,r;try{r=new i(o),fo(r),r.exec("BEGIN IMMEDIATE"),ve(r,"version",oe),ve(r,"context_fingerprint",e.contextFingerprint),ve(r,"source_cursor",e.sourceCursor);for(let n of e.rows)ti(r,n);r.exec("COMMIT"),r.close(),r=void 0,await U.rm(t,{force:!0}),await U.rename(o,t)}catch(n){throw r?.close(),await Promise.allSettled([U.rm(o,{force:!0})]),n}}function Ie(e){return Object.fromEntries(e.prepare("SELECT key, value FROM metadata").all().map(t=>[String(t.key),String(t.value)]))}async function oi(e){let t=re();if(!t)return!1;let i=z(e.pmRoot),o;try{await U.access(i),o=new t(i),o.exec("PRAGMA foreign_keys = ON");let r=Ie(o);if(r.version!==oe||r.context_fingerprint!==e.contextFingerprint||r.source_cursor!==e.expectedSourceCursor)return o.close(),!1;o.exec("BEGIN IMMEDIATE");let n=o.prepare("DELETE FROM items WHERE relative_path = ?"),s=o.prepare("SELECT rowid FROM items WHERE relative_path = ?"),a=o.prepare("DELETE FROM item_search WHERE rowid = ?");for(let d of e.deletedRelativePaths??[]){let c=s.get(d);n.run(d),c&&a.run(c.rowid)}return e.row&&ti(o,e.row),ve(o,"source_cursor",e.sourceCursor),o.exec("COMMIT"),o.close(),!0}catch{try{o?.exec("ROLLBACK")}catch{}return o?.close(),!1}}function Ee(e,t,i,o,r){!o||o.length===0||(e.push(`${i} ${r} (${o.map(()=>"?").join(", ")})`),t.push(...o))}function yo(e){let t=[],i=[];Ee(t,i,"status",e.statuses,"IN"),Ee(t,i,"status",e.excludeStatuses,"NOT IN"),Ee(t,i,"type",e.types,"IN"),Ee(t,i,"id",e.ids,"IN");for(let o of e.metadataKeys??[])t.push("EXISTS (SELECT 1 FROM item_metadata_keys AS indexed_key WHERE indexed_key.item_id = items.id AND indexed_key.key = ?)"),i.push(o);for(let[o,r]of[["parent",e.parent],["assignee",e.assignee],["sprint",e.sprint],["release",e.release]])r!==void 0&&(t.push(`${o} = ?`),i.push(r));return e.priority!==void 0&&(t.push("priority = ?"),i.push(e.priority)),{where:t.length===0?"":` WHERE ${t.join(" AND ")}`,parameters:i}}async function Cn(e){let t=re();if(!t)return null;let i=e.query??{},{where:o,parameters:r}=yo(i),n;try{n=new t(z(e.pmRoot),{readOnly:!0});let s=Ie(n);if(s.version!==oe||s.source_cursor!==e.expectedSourceCursor)return n.close(),null;let a=n.prepare(`SELECT COUNT(*) AS count FROM items${o}`).get(...r),d=[],c="";i.limit!==void 0?(c+=" LIMIT ?",d.push(Math.max(0,Math.floor(i.limit))),i.offset!==void 0&&(c+=" OFFSET ?",d.push(Math.max(0,Math.floor(i.offset))))):i.offset!==void 0&&(c+=" LIMIT -1 OFFSET ?",d.push(Math.max(0,Math.floor(i.offset))));let p=n.prepare(`SELECT metadata_json FROM items${o}
72
- ORDER BY ${i.terminalStatuses&&i.terminalStatuses.length>0?`CASE WHEN status IN (${i.terminalStatuses.map(()=>"?").join(", ")}) THEN 1 ELSE 0 END ASC, `:""}priority ASC, updated_at DESC, id ASC${c}`).all(...r,...i.terminalStatuses??[],...d).map(u=>{let l=JSON.parse(String(u.metadata_json));if(!l.id)throw new TypeError("Indexed metadata row has no id");return l});return n.close(),{source_cursor:s.source_cursor,total:Number(a.count),items:p}}catch{return n?.close(),null}}async function Tn(e){let t=re();if(!t||e.paths.length===0)return null;let i;try{i=new t(z(e.pmRoot),{readOnly:!0});let o=Ie(i);if(o.version!==oe||o.source_cursor!==e.expectedSourceCursor)return i.close(),null;let r=e.paths.map(()=>"?").join(", "),n=e.scope===void 0?"":" AND scope = ?",s=[...e.paths,...e.scope===void 0?[]:[e.scope]],a=`path IN (${r})${n}`,d=i.prepare(`SELECT COUNT(DISTINCT item_id) AS count
73
- FROM item_linked_files
74
- WHERE ${a}`).get(...s),c=Zt(e.limit,50),p=Zt(e.offset,0),u=i.prepare(`SELECT items.id, items.metadata_json
75
- FROM items
76
- WHERE EXISTS (
77
- SELECT 1 FROM item_linked_files
78
- WHERE item_linked_files.item_id = items.id AND ${a}
79
- )
80
- ORDER BY items.priority ASC, items.updated_at DESC, items.id ASC
81
- LIMIT ? OFFSET ?`).all(...s,c,p),l=[];if(u.length>0){let h=u.map(_=>String(_.id)),y=i.prepare(`SELECT item_id, path, scope, note
82
- FROM item_linked_files
83
- WHERE item_id IN (${h.map(()=>"?").join(", ")})
84
- AND ${a}
85
- ORDER BY path ASC, scope ASC`).all(...h,...s),g=new Map(h.map(_=>[_,[]]));for(let _ of y){let b=String(_.item_id),x=g.get(b);x.push({path:String(_.path),scope:String(_.scope),..._.note===null?{}:{note:String(_.note)}}),g.set(b,x)}for(let _ of u){let b=JSON.parse(String(_.metadata_json));l.push({item:b,files:g.get(String(_.id))})}}return i.close(),{source_cursor:o.source_cursor,total:Number(d.count),matches:l}}catch{return i?.close(),null}}async function Sn(e){let t=re();if(!t)return null;let i;try{i=new t(z(e.pmRoot),{readOnly:!0});let o=Ie(i);if(o.version!==oe||o.source_cursor!==e.expectedSourceCursor)return i.close(),null;let r=i.prepare(`SELECT items.metadata_json
86
- FROM item_search
87
- JOIN items ON items.id = item_search.id
88
- WHERE item_search MATCH ?
89
- ORDER BY bm25(item_search), items.priority, items.updated_at DESC, items.id
90
- LIMIT ?`).all(e.query,Math.max(0,Math.floor(e.limit))).map(n=>JSON.parse(String(n.metadata_json)));return i.close(),{source_cursor:o.source_cursor,items:r}}catch{return i?.close(),null}}async function Ce(e){await U.rm(z(e),{force:!0})}import E from"node:fs/promises";import w from"node:path";import{createHash as po,randomUUID as ci}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 R=8,di=500,ho="metadata-derived-index",_o="metadata-cache.json",go="metadata-cache-bodies.json",wo="metadata-cache-collections.json",bo="metadata-cache-delta.json",Eo="metadata-cache-manifest.json",ri=4,vo=["comments","notes","learnings","files","tests","test_runs","docs"];function li(){return ge(Q())}function Se(e){let t={...e},i={};for(let o of vo)o in t&&(i[o]=t[o],delete t[o]);return{light:t,heavy:i}}function ui(e,t){return!t||Object.keys(t).length===0?e:{...e,...t}}function mi(e,t,i,o){let r=po("sha256");r.update(`format:${e??"default"}`);let n=Object.entries(t).sort(([s],[a])=>s.localeCompare(a)).map(([s,a])=>`${s}=${a}`).join(",");return r.update(`|types:${n}`),i&&r.update(`|schema:${JSON.stringify(i)}`),o.length>0&&r.update(`|extension_fields:${o.join(",")}`),r.digest("hex").slice(0,16)}function xe(e){return w.join(e,"runtime",_o)}function Re(e){return w.join(e,"runtime",go)}function Oe(e){return w.join(e,"runtime",wo)}function tt(e){return w.join(e,"runtime",bo)}function it(e){return w.join(e,"runtime",Eo)}function De(e,t){let i=w.extname(e);return`${e.slice(0,-i.length)}.${t}${i}`}var Io=24,S=new Map,ke=new WeakMap;function ot(e){return ke.get(e)??e.source_cursor}function Co(e,t){let i=ot(e);if(!(t.base_source_cursor!==i||e.source_cursor===t.source_cursor)){ke.set(e,i);for(let[o,r]of Object.entries(t.changes))r.entry?e.entries[o]=r.entry:delete e.entries[o];e.directory_signatures=t.directory_signatures,e.source_cursor=t.source_cursor}}function To(e,t){if(!e)return;let i=ot(e);if(!(t.base_source_cursor!==i||e.source_cursor===t.source_cursor)){ke.set(e,i);for(let[o,r]of Object.entries(t.changes))r.body?e.bodies[o]=r.body:delete e.bodies[o];e.source_cursor=t.source_cursor}}function So(e,t){if(!e)return;let i=ot(e);if(!(t.base_source_cursor!==i||e.source_cursor===t.source_cursor)){ke.set(e,i);for(let[o,r]of Object.entries(t.changes))r.collections?e.collections[o]=r.collections:delete e.collections[o];e.source_cursor=t.source_cursor}}function xo(e,t,i,o){!e||!o||e.context_fingerprint!==o.context_fingerprint||(Co(e,o),To(t,o),So(i,o))}function et(e,t){S.size>=Io&&!S.has(e)&&Rt(S),S.set(e,t)}async function A(e,t){let i;try{i=await E.stat(e)}catch{return S.delete(e),null}let o=S.get(e);if(o&&ne(o.signature,i.mtimeMs,i.ctimeMs,i.size))return S.delete(e),S.set(e,o),o.envelope;let r;try{r=t(await E.readFile(e,"utf8"))}catch{r=null}return et(e,{signature:{mtime_ms:i.mtimeMs,ctime_ms:i.ctimeMs,size:i.size},envelope:r}),r}async function Ro(e,t,i){let o=a=>{let d=JSON.parse(a);return d.version!==R||typeof d.source_cursor!="string"||typeof d.entries!="object"||d.entries===null?null:d},r=xe(e),n=await A(r,o);if(!t||n===null||n.context_fingerprint===t)return n;let s=await A(De(r,t),o);return s===null&&ce(i,`metadata_cache_context_changed:${n.context_fingerprint}->${t}`),s}async function Oo(e,t){let i=n=>{let s=JSON.parse(n);return s.version!==R||typeof s.source_cursor!="string"||typeof s.bodies!="object"||s.bodies===null?null:s},o=Re(e),r=await A(o,i);return t&&r?.context_fingerprint!==t?await A(De(o,t),i):r}async function Do(e,t){let i=n=>{let s=JSON.parse(n);return s.version!==R||typeof s.source_cursor!="string"||typeof s.collections!="object"||s.collections===null?null:s},o=Oe(e),r=await A(o,i);return t&&r?.context_fingerprint!==t?await A(De(o,t),i):r}async function rt(e){let t=tt(e),i=await A(t,o=>{let r=JSON.parse(o);return r.version!==R||typeof r.base_source_cursor!="string"||typeof r.source_cursor!="string"||typeof r.changes!="object"||r.changes===null?null:r});if(i)return{envelope:i,invalid:!1};try{return await E.stat(t),{envelope:null,invalid:!0}}catch{return{envelope:null,invalid:!1}}}async function nt(e){let t=it(e),i=await A(t,o=>{let r=JSON.parse(o);return r.version!==R||typeof r.context_fingerprint!="string"||typeof r.source_cursor!="string"||!Number.isInteger(r.entry_count)||r.entry_count<0||typeof r.directory_signatures!="object"||r.directory_signatures===null?null:r});if(i)return i;try{await E.stat(t),await X(e)}catch{}return null}async function se(e,t){await E.mkdir(w.dirname(e),{recursive:!0}),await N(e,JSON.stringify(t));try{let o=await E.stat(e);et(e,{signature:{mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size},envelope:t})}catch{S.delete(e)}let i=w.dirname(w.dirname(e));if(e===xe(i)||e===Re(i)||e===Oe(i)){let o=De(e,t.context_fingerprint);await N(o,JSON.stringify(t));try{let d=await E.stat(o);et(o,{signature:{mtime_ms:d.mtimeMs,ctime_ms:d.ctimeMs,size:d.size},envelope:t})}catch{S.delete(o)}let r=w.dirname(e),n=w.extname(e),s=w.basename(e,n),a=(await E.readdir(r,{withFileTypes:!0}).catch(()=>[])).filter(d=>d.isFile()&&d.name!==w.basename(e)&&d.name.startsWith(`${s}.`)&&d.name.endsWith(n)).map(d=>w.join(r,d.name));if(a.length>ri){let d=(await Promise.all(a.map(async c=>{try{return{path:c,mtime:(await E.stat(c)).mtimeMs}}catch{return null}}))).filter(c=>c!==null);for(let c of d.sort((p,u)=>p.mtime-u.mtime).slice(0,Math.max(0,d.length-ri)))await E.rm(c.path,{force:!0}),S.delete(c.path)}}}function ko(e,t,i){return i?t===i&&e!==i:t==="toon"&&e!=="toon"}function fi(e,t,i){return e===void 0||ko(e,t,i)}function ce(e,t){e&&!e.includes(t)&&e.push(t)}function ne(e,t,i,o){return e.mtime_ms===t&&e.ctime_ms===i&&e.size===o}async function No(e,t,i){let o=w.join(e,t);try{let r=await E.readdir(o);return{folder:t,dirPath:o,files:r}}catch(r){return typeof r=="object"&&r!==null&&"code"in r&&!j(r)&&ce(i,`item_list_directory_read_failed:${t}`),{folder:t,dirPath:o,files:[]}}}async function Ao(e,t){try{let i=await E.stat(w.join(e,t));return[t,{exists:!0,mtime_ms:i.mtimeMs,ctime_ms:i.ctimeMs,size:i.size}]}catch{return[t,{exists:!1,mtime_ms:0,ctime_ms:0,size:0}]}}async function Te(e,t){return Object.fromEntries(await Promise.all(t.map(async i=>await Ao(e,i))))}function ae(e,t){return!e||Object.keys(e).length!==Object.keys(t).length?!1:Object.entries(t).every(([i,o])=>{let r=e[i];return r!==void 0&&r.exists===o.exists&&ne(r,o.mtime_ms,o.ctime_ms,o.size)})}function Fo(e){return me.some(t=>e.toLowerCase().endsWith(t))}function Mo(e,t,i,o,r,n){o||(e.metadata=!0),t&&!r&&(e.body=!0),i&&!n&&(e.collections=!0)}async function Po(e,t,i){if(i)for(let o of await pe({path:e,scope:"project"}))ce(t,o)}function ni(e,t,i,o){if(e)return t&&i?i.collections:o}async function jo(e,t,i){let o=await E.stat(e),r=o.mtimeMs,n=o.ctimeMs,{size:s}=o,a=Pe(e);await Po(e,i.warnings,i.dispatchReadHooks);let d=i.previousEntries[t],c=!i.forceSourceRead&&d!==void 0&&ne(d,r,n,s),p=i.previousBodies[t],u=!i.forceSourceRead&&p!==void 0&&ne(p,r,n,s),l=i.previousCollections[t],h=!i.forceSourceRead&&l!==void 0&&ne(l,r,n,s);if(!(!c||i.includeBody&&!u||i.includeCollections&&!h))return{mtimeMs:r,ctimeMs:n,size:s,itemFormat:a,lightMetadata:d.metadata,heavyMetadata:ni(i.includeCollections,h,l,void 0),bodyLength:d.body_length,body:i.includeBody?p.body:void 0};let y=await E.readFile(e,"utf8"),g=q(y,{format:a,schema:i.schema,extensionFieldNames:i.extensionFieldNames,onWarning:b=>ce(i.warnings,b)}),_=Se(g.metadata);return Mo(i.state.misses,i.includeBody,i.includeCollections,c,u,h),{mtimeMs:r,ctimeMs:n,size:s,itemFormat:a,lightMetadata:c?d.metadata:_.light,heavyMetadata:ni(i.includeCollections,h,l,_.heavy),bodyLength:c?d.body_length:g.body.length,body:i.includeBody?g.body:void 0}}function Lo(e,t,i,o){i.state.newEntries[t]={mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size,metadata:o.lightMetadata,body_length:o.bodyLength},i.includeBody&&o.body!==void 0&&(i.state.newBodies[t]={mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size,body:o.body}),i.includeCollections&&o.heavyMetadata!==void 0&&(i.state.newCollections[t]={mtime_ms:o.mtimeMs,ctime_ms:o.ctimeMs,size:o.size,collections:o.heavyMetadata});let r=i.includeCollections?ui(o.lightMetadata,o.heavyMetadata):o.lightMetadata,n=i.state.documentsById.get(r.id),s={metadata:r,body:o.body,item_format:o.itemFormat,item_path:e};fi(n?.itemFormat,o.itemFormat,i.preferredFormat)&&i.state.documentsById.set(r.id,{candidate:s,itemFormat:o.itemFormat})}async function $o(e,t,i,o){try{let r=await jo(t,i,o);Lo(t,i,o,r)}catch{ce(o.warnings,`item_list_item_read_failed:${e}/${w.basename(t)}`)}}function Uo(e,t){return e&&e.context_fingerprint===t?e.entries:{}}function Ho(e,t){return e&&e.context_fingerprint===t?e.bodies:{}}function Wo(e,t){return e&&e.context_fingerprint===t?e.collections:{}}function Bo(){return{newEntries:{},newBodies:{},newCollections:{},documentsById:new Map,misses:{metadata:!1,body:!1,collections:!1}}}async function zo(e,t){let i=[];for(let{folder:o,dirPath:r,files:n}of e)for(let s of n){if(!Fo(s))continue;let a=w.join(r,s),d=w.relative(t.pmRoot,a);i.push($o(o,a,d,t)),i.length===32&&(await Promise.all(i),i.length=0)}await Promise.all(i)}async function Xo(e){if(!(!(e.state.misses.metadata||Object.keys(e.previousEntries).length!==Object.keys(e.state.newEntries).length||!ae(e.existingCache?.directory_signatures,e.directorySignatures))&&e.existingCache!==null&&e.existingCache.context_fingerprint===e.contextFingerprint))try{await se(xe(e.pmRoot),{version:R,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,directory_signatures:e.directorySignatures,entries:e.state.newEntries}),await se(it(e.pmRoot),{version:R,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,entry_count:Object.keys(e.state.newEntries).length,directory_signatures:e.directorySignatures});let t=[...e.state.documentsById.values()].map(({candidate:i})=>({relativePath:w.relative(e.pmRoot,i.item_path),metadata:Se(i.metadata).light,linkedFiles:i.metadata.files??[]}));t.length>=e.minimumIndexedItems?await ii({pmRoot:e.pmRoot,contextFingerprint:e.contextFingerprint,sourceCursor:e.sourceCursor,rows:t}):await Ce(e.pmRoot)}catch{}}async function Go(e){!(e.state.misses.body||Object.keys(e.previousBodies).length!==Object.keys(e.state.newBodies).length)&&e.existingBodyCache!==null&&e.existingBodyCache.context_fingerprint===e.contextFingerprint||await se(Re(e.pmRoot),{version:R,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,bodies:e.state.newBodies}).catch(()=>{})}async function Yo(e){!(e.state.misses.collections||Object.keys(e.previousCollections).length!==Object.keys(e.state.newCollections).length)&&e.existingCollectionsCache!==null&&e.existingCollectionsCache.context_fingerprint===e.contextFingerprint||await se(Oe(e.pmRoot),{version:R,context_fingerprint:e.contextFingerprint,source_cursor:e.sourceCursor,collections:e.state.newCollections}).catch(()=>{})}async function st(e,t,i={}){let o=await nt(e);return i.required!==!0&&(o===null||o.entry_count<di)?async()=>{}:Mt(e,ho,30,t,!1,!1,3e3)}async function $n(e,t){let i=await nt(e);if(i===null)return null;let o=await rt(e);if(o.invalid)return await X(e),null;let r=o.envelope?.context_fingerprint===i.context_fingerprint&&o.envelope.base_source_cursor===i.source_cursor?o.envelope.source_cursor:i.source_cursor,n=o.envelope?.context_fingerprint===i.context_fingerprint&&o.envelope.base_source_cursor===i.source_cursor?o.envelope.directory_signatures:i.directory_signatures;return t&&!ae(n,await Te(e,t))?null:{source_cursor:r,entry_count:i.entry_count}}function si(e,t){let i=w.relative(e,t);return i===""||i===".."||i.startsWith(`..${w.sep}`)||w.isAbsolute(i)?null:i}async function X(e){await Promise.all([xe(e),Re(e),Oe(e),tt(e),it(e)].map(async t=>{await E.rm(t,{force:!0}),S.delete(t)})),await Ce(e)}async function Vo(e){if(e.mutation.document===null)return{entry:null,body:null,collections:null};let t=await E.stat(e.mutation.itemPath),i=Se(e.mutation.document.metadata),o={mtime_ms:t.mtimeMs,ctime_ms:t.ctimeMs,size:t.size};return{entry:{...o,metadata:i.light,body_length:e.mutation.document.body.length},body:{...o,body:e.mutation.document.body},collections:{...o,collections:i.heavy}}}function qo(e,t,i){return e?.context_fingerprint===t&&e.base_source_cursor===i?structuredClone(e.changes):{}}async function at(e){let t=si(e.pmRoot,e.itemPath),i=e.previousItemPath?si(e.pmRoot,e.previousItemPath):void 0;if(t===null||i===null)return await X(e.pmRoot),["metadata_derived_index_path_invalidated"];try{let o=mi(e.preferredFormat,e.typeToFolder,e.schema,li()),r=await nt(e.pmRoot);if(r===null||r.context_fingerprint!==o)return[];let n=r.source_cursor,s=await rt(e.pmRoot);if(s.invalid)return await X(e.pmRoot),["metadata_derived_index_refresh_failed"];let a=qo(s.envelope,o,n),d=s.envelope?.context_fingerprint===o&&s.envelope.base_source_cursor===n?s.envelope.source_cursor:n;i!==void 0&&(a[i]={entry:null,body:null,collections:null}),a[t]=await Vo({mutation:e});let c=ci();return await se(tt(e.pmRoot),{version:R,context_fingerprint:o,base_source_cursor:n,source_cursor:c,directory_signatures:await Te(e.pmRoot,[...new Set(Object.values(e.typeToFolder))]),changes:a}),await oi({pmRoot:e.pmRoot,contextFingerprint:o,expectedSourceCursor:d,sourceCursor:c,row:e.document===null?null:{relativePath:t,metadata:Se(e.document.metadata).light,linkedFiles:e.document.metadata.files},deletedRelativePaths:[...i===void 0?[]:[i],...e.document===null?[t]:[]]})||await Ce(e.pmRoot),[]}catch{return await X(e.pmRoot).catch(()=>{}),["metadata_derived_index_refresh_failed"]}}function Ko(e){return[...e.documentsById.values()].sort((t,i)=>t.candidate.metadata.id.localeCompare(i.candidate.metadata.id)).map(t=>t.candidate)}function ai(e,t,i){return e?.context_fingerprint===t&&e.source_cursor===i}function Jo(e,t,i,o,r){return e.every(n=>(!t||o[n]!==void 0)&&(!i||r[n]!==void 0))}function Qo(e){let t=new Map;for(let[i,o]of Object.entries(e.previousEntries)){let r=Pe(i);if(!r)continue;let n=e.includeCollections?ui(o.metadata,e.previousCollections[i]?.collections):o.metadata,s=t.get(n.id);fi(s?.itemFormat,r,e.preferredFormat)&&t.set(n.id,{itemFormat:r,candidate:{metadata:n,body:e.includeBody?e.previousBodies[i]?.body:void 0,item_format:r,item_path:w.join(e.pmRoot,i)}})}return[...t.values()].sort((i,o)=>i.candidate.metadata.id.localeCompare(o.candidate.metadata.id)).map(i=>i.candidate)}function Zo(e){return e.forceSourceScan||Ye()||e.existingCache?.context_fingerprint!==e.contextFingerprint||e.entryKeys.length<e.minimumIndexedItems||!ae(e.existingCache?.directory_signatures,e.directorySignatures)?!1:[!e.includeBody||ai(e.existingBodyCache,e.contextFingerprint,e.existingCache.source_cursor),!e.includeCollections||ai(e.existingCollectionsCache,e.contextFingerprint,e.existingCache.source_cursor)].every(Boolean)&&Jo(e.entryKeys,e.includeBody,e.includeCollections,e.previousBodies,e.previousCollections)}async function Ne(e,t,i,o,r,n={}){let s=n.includeBody!==!1,a=n.includeCollections!==!1,d=li(),c=mi(t,i,r,d),p=await rt(e);p.invalid&&await X(e);let u=await Ro(e,c,n.cacheDiagnostics),l=s?await Oo(e,c):null,h=a?await Do(e,c):null;xo(u,l,h,p.envelope);let y=Uo(u,c),g=Ho(l,c),_=Wo(h,c),b=[...new Set(Object.values(i))],x=await Te(e,b),M=Object.keys(y),O=Math.max(1,Math.floor(n.derivedIndexMinimumItems??di));if(Zo({forceSourceScan:n.forceSourceScan===!0,contextFingerprint:c,existingCache:u,existingBodyCache:l,existingCollectionsCache:h,directorySignatures:x,entryKeys:M,minimumIndexedItems:O,includeBody:s,includeCollections:a,previousBodies:g,previousCollections:_}))return Qo({pmRoot:e,preferredFormat:t,includeBody:s,includeCollections:a,previousEntries:y,previousBodies:g,previousCollections:_});let H=await Promise.all(b.map(le=>No(e,le,o))),C=Ye(),I=Bo(),W={pmRoot:e,preferredFormat:t,warnings:o,schema:r,extensionFieldNames:d,includeBody:s,includeCollections:a,forceSourceRead:n.forceSourceScan===!0,dispatchReadHooks:C,previousEntries:y,previousBodies:g,previousCollections:_,state:I};await zo(H,W);let B=await Te(e,b),k=ae(x,B)?B:{},T=I.misses.metadata||Object.keys(y).length!==Object.keys(I.newEntries).length||!ae(u?.directory_signatures,k)||u===null?ci():u.source_cursor;return await Xo({pmRoot:e,contextFingerprint:c,sourceCursor:T,existingCache:u,previousEntries:y,directorySignatures:k,state:I,minimumIndexedItems:O}),s&&await Go({pmRoot:e,contextFingerprint:c,sourceCursor:T,existingBodyCache:l,previousBodies:g,state:I}),a&&await Yo({pmRoot:e,contextFingerprint:c,sourceCursor:T,existingCollectionsCache:h,previousCollections:_,state:I}),Ko(I)}async function yi(e,t,i,o,r){return(await Ne(e,t,i,o,r,{includeBody:!1})).map(n=>({metadata:n.metadata,body:n.body??""}))}async function pi(e,t,i,o,r){return(await Ne(e,t,i,o,r,{includeBody:!1,includeCollections:!1})).map(n=>({metadata:n.metadata,body:n.body??""}))}import F from"node:fs/promises";import{statSync as or}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 er(e,t){let i=-1;return e.forEach((o,r)=>{let n=Date.parse(o.ts);if(!Number.isFinite(n))throw new m(`History for this item contains invalid timestamp at entry ${r+1}.`,f.GENERIC_FAILURE);n<=t&&(i=r)}),i}function tr(e,t){let i=e[0]?.ts??null,o=e.at(-1)?.ts??null,r={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:i,last_timestamp:o}};return o!==null&&(r.examples=[o],t!==null&&(r.examples.unshift(String(t+1),String(t+e.length)),r.valid_range.first_version=t+1,r.valid_range.last_version=t+e.length)),{guidance:r,lastTimestamp:o}}function ir(e,t){let i={};if(t instanceof Error&&t.message.trim().length>0&&(i.reason=t.message.trim()),typeof t!="object"||t===null)return i;let o=t;if(typeof o.index=="number"&&Number.isInteger(o.index)&&o.index>=0&&(i.patchIndex=o.index),typeof o.operation=="object"&&o.operation!==null){let r=o.operation;Object.assign(i,Object.fromEntries(["op","path","from"].flatMap(n=>{let s=r[n];return typeof s=="string"?[[n,s]]:[]})))}if(i.patchIndex!==void 0){let r=e[i.patchIndex];r&&(i.op??=r.op,i.path??=r.path,i.from??=r.from)}return i}function hi(e,t,i={}){let o=e.trim(),r=i.errorSubject??"history",n=r==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=tr(t,te(t,!0));if(!o)throw new m(`Missing ${r} target. Use a timestamp or version number.`,f.USAGE,s);if(/^\d+$/.test(o)){let p=te(t),u=Number(o);if(u>=1&&u<=p)throw new m(`History version ${u} was pruned by compaction.`,f.USAGE,{...s,code:"history_version_pruned"});if(!Number.isSafeInteger(u)||u<1||u>p+t.length)throw new m(`${n} version must be between ${p+1} and ${p+t.length} for this item.`,f.USAGE,s);return{kind:"version",raw:o,historyIndex:u-p-1}}let d=Date.parse(o);if(!Number.isFinite(d))throw new m(`Invalid ${r} target "${e}". Use a positive version number or ISO timestamp.`,f.USAGE,s);let c=er(t,d);if(c<0||i.allowFutureTimestamp!==!0&&d>Date.parse(a))throw new m(r==="restore"?`No history entries exist at or before timestamp ${o}.`:`No history entry exists at timestamp ${o}.`,f.USAGE,s);return{kind:"timestamp",raw:o,historyIndex:c}}function ct(e,t,i,o){let r=$e(e,t);if(r.ok)return r.document;let n=ir(t,r.error),s=[`history_op=${o}`,n.patchIndex===void 0?null:`patch_index=${n.patchIndex}`,n.op?`op=${n.op}`:null,n.path?`path=${n.path}`:null,n.from?`from=${n.from}`:null].filter(a=>a!==null);throw new m(`Failed to apply history patch at entry ${i} (${s.join(", ")}). ${n.reason??String(r.error)}`,f.GENERIC_FAILURE)}function _i(e,t){let i=e[0];if(i&&i.op!=="create"&&i.op!=="history_compact_baseline"){let s=$e(J,i.patch);if(!s.ok||typeof s.document.metadata.id!="string")throw new m("History starts without a reconstructable item baseline.",f.GENERIC_FAILURE,{code:"history_baseline_unavailable",required:"Recover the original create entry or a complete checkpoint from version control.",nextSteps:["Run pm history <id> --full to inspect the missing baseline."]})}let o=e.slice(0,t+1),r=fe([...o]),n=structuredClone(J);for(let s=0;s<=t;s+=1){let a=e[s];if(!a)throw new m(`History target entry ${s+1} does not exist.`,f.USAGE);n=ct(n,a.patch,s+1,a.op)}if(!r.ok)throw new m(`History cannot be replayed: ${r.errors.join(", ")}.`,f.GENERIC_FAILURE,{code:"history_replay_invalid",verification_errors:r.errors,required:"Inspect the history integrity findings before attempting recovery.",nextSteps:["Run pm history <id> --verify --full."]});return n}function Xn(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 rr(e,t){let i=-1,o=structuredClone(J);for(let[a,d]of e.entries()){if(o=ct(o,d.patch,a+1,d.op),o.metadata.id!==void 0&&o.metadata.id!==t)throw new m(`History belongs to item ${String(o.metadata.id)}, expected ${t}.`,f.GENERIC_FAILURE,{code:"history_replay_invalid",required:"Recover the correct history stream for this item before attempting restoration."});o.metadata.id===t&&Array.isArray(o.metadata.tags)&&(i=a)}let r=te(e,!0),n=i<0||r===null?null:r+i+1,s=n===null?void 0:String(n);if(i>=0&&s===void 0){let a=e[i].ts;hi(a,e).historyIndex===i&&(s=a)}return{version:n,target:s}}async function gi(e,t,i){let o=new Set([ee(t,i),Z(t)]);for(let r of o){let n=D(e,r);if(!or(n,{throwIfNoEntry:!1})?.isFile())continue;let s=await Lt(n,r),a=-1;if(s.forEach((h,y)=>{h.op==="delete"&&(a=y)}),a<0)continue;let d=_i(s,s.length-1);if(Object.keys(d.metadata).length!==0)continue;let{version:c,target:p}=rr(s,r),u=p===void 0?["history",r,"--verify"]:["get",r,"--at",p],l=V(u);return new m(`Item ${r} was deleted at ${s[a].ts}; its history is retained.`,f.NOT_FOUND,{code:"item_deleted",required:"Read a retained materialized version, then restore it if the item should exist again.",item_id:r,tombstone:{deleted:!0,deleted_at:s[a].ts,recoverable:p!==void 0,last_materialized_version:c},nextSteps:[l,...p===void 0?["Recover the pre-compaction history from version control."]:[V(["restore",r,p])]],recovery:{suggested_retry:l,suggested_retry_args:u}})}}import{AsyncLocalStorage as nr}from"node:async_hooks";import wi 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 bi=new nr;function ss(e,t){return bi.run({...e,pmRoot:wi.resolve(e.pmRoot)},t)}function Ei(e,t){let i=bi.getStore();return i?.pmRoot===wi.resolve(e)&&i.itemId===t?{bulk_checkpoint:i.checkpointId}:void 0}import lt from"node:path";import sr from"node:fs/promises";import ar 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 cr(e){return[...new Set(e.filter(t=>t.trim().length>0))].sort((t,i)=>t.localeCompare(i))}function dr(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 lr(e,t){return await bt(ar.dirname(e)),await(await sr.open(e,"a")).close(),L({path:e,scope:"project",op:`${t}:history:auto_create`})}async function dt(e){return ur({pmRoot:e.pmRoot,settings:e.settings,itemIds:[e.itemId],commandLabel:e.commandLabel})}async function ur(e){let t=cr(e.itemIds),i=[],o=[];for(let r of t){let n=D(e.pmRoot,r);if(!await Y(n)){if(e.settings.history.missing_stream==="strict_error")throw dr(r,e.commandLabel);o.push(...await lr(n,e.commandLabel)),o.push(`history_stream_auto_created:${r}`),i.push(r)}}return{auto_created_ids:i,warnings:o}}import{isUtf8 as mr}from"node:buffer";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2fda779c-a87f-517c-b71a-626c4fef98e5")}catch{}})();async function fr(e){try{return await F.access(e),!0}catch{return!1}}function yr(e,t){e&&(e.includes(t)||e.push(t))}function ut(e){return e??ge(Q())}function pr(e){return e==="toon"?["toon","json_markdown"]:e==="json_markdown"?["json_markdown","toon"]:["toon","json_markdown"]}async function mt(e,t,i="pm-",o,r=P){let n=t.trim(),s=n.startsWith("#")?n.slice(1):n;if(s.length===0)return null;let a=ee(t,i),d=Z(t),c=[...new Set([s,a,d])].filter(l=>l.length>0),p=Object.entries(r),u=pr(o);for(let l of c){let h=new Map;for(let[y]of p)for(let g of u){let _=Me(e,y,l,g,r);await fr(_)&&h.set(_,h.get(_)??{id:l,type:y,itemPath:_,item_format:g})}if(h.size>1){let y=[...h.keys()].map(g=>lt.relative(e,g).split(lt.sep).join("/")).sort();throw new m(`Item ${l} has ambiguous identity across ${y.join(", ")}. Preserve both documents and inspect pm ops validate --check-storage-integrity before resolving the collision.`,f.CONFLICT,{code:"item_identity_ambiguous",item_id:l,paths:y})}for(let y of h.values())return y}return null}async function Ii(e,t={}){let i=await hr(e,t);if(i.error!==null)throw i.error;return{raw:i.raw,document:i.document}}async function hr(e,t={}){let i=await F.readFile(e.itemPath);if(!mr(i))throw new m("Item contains invalid UTF-8; preserve a binary backup before recovering it.",f.CONFLICT,{code:"item_document_encoding_invalid",item_id:e.id,item_path:e.itemPath,byte_length:i.length,empty:!1});let o=i.toString("utf8");await pe({path:e.itemPath,scope:"project"});let r;try{r=q(o,{format:e.item_format,requireSupportedFormat:!0,schema:t.schema,extensionFieldNames:ut(t.extensionFieldNames),onWarning:n=>yr(t.warnings,n)})}catch(n){if(n instanceof m&&n.code==="item_format_version_unsupported")throw new m(`Item ${e.id}: ${n.message}`,n.exitCode,{...n.context,item_id:e.id,item_path:e.itemPath});if(n instanceof m&&n.code==="item_document_invalid")return{raw:o,document:null,error:new m(`Cannot read ${e.id} at ${e.itemPath}${i.length===0?" (zero-length file)":""}: ${n.message}`,n.exitCode,{...n.context,item_id:e.id,item_path:e.itemPath,byte_length:i.length,empty:i.length===0,nextSteps:[`Run pm history ${e.id} --full, then pm restore ${e.id} <version> to recover a recorded state.`]})};throw n}return{raw:o,document:r,error:null}}async function _r(e,t,i=P,o,r){await he(e);let n=await yi(e,t,i,o,r);return be(n.length),n.map(s=>s.metadata)}async function Ys(e,t,i=P,o,r){await he(e);let n=await pi(e,t,i,o,r);return be(n.length),n.map(s=>s.metadata)}async function Vs(e,t,i=P,o,r,n={}){await he(e);let s=await Ne(e,t,i,o,r,{includeBody:!0,forceSourceScan:n.forceSourceScan});return be(s.length),s.map(a=>({...a.metadata,body:a.body}))}function Ci(e){return{async get(t){let i=await mt(e.pmRoot,t,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!i)return null;let{document:o}=await Ii(i,{schema:e.settings.schema});return{item:o.metadata,body:o.body}},list:()=>_r(e.pmRoot,e.settings.item_format,e.typeToFolder,void 0,e.settings.schema)}}async function gr(e,t){let i=new Set(Object.values(t)),o=[];return await Promise.all([...i].map(async r=>{try{let n=await F.readdir(lt.join(e,r));for(let s of n)for(let a of me)if(s.toLowerCase().endsWith(a)){o.push(s.slice(0,-a.length));break}}catch{}})),o}async function wr(e,t,i,o){let r=ee(t,i),n=await gr(e,o);if(n.length===0)return[];let s=Math.max(3,Math.floor(r.length/2));return n.map(a=>({id:a,distance:ue(a,r,s)})).filter(a=>a.distance!==null).sort((a,d)=>a.distance-d.distance).slice(0,3).map(a=>a.id)}async function br(e,t,i,o){let r=await gi(e,t,i);if(r)return r;let n=await wr(e,t,i,o),s=["Confirm the active --path/PM_PATH scope, then retry with a valid id."];return n.length>0&&s.unshift(`Did you mean one of: ${n.join(", ")}?`),new m(`Item ${t} not found`,f.NOT_FOUND,{code:"item_not_found",id:t,nextSteps:s})}function Er(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 Ti(e){let t=e.typeToFolder??It(e.settings,Q()).type_to_folder,i=await mt(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,t);if(!i)throw await br(e.pmRoot,e.id,e.settings.id_prefix,t);let o=await Pt(e.pmRoot,i.id,e.settings.locks.ttl_seconds,e.author,!!e.force,e.settings.governance.force_required_for_stale_lock,e.settings.locks.wait_ms,{waitPolicy:"progress"}),r=o.release;try{let n=[],{raw:s,document:a}=await Ii(i,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames,warnings:n}),d=a.metadata.assignee?.trim(),c=kt(d),p=a.metadata.claim_principal?.trim()||d,u=jt(e.author),l=Bt(e.settings);if(c&&p!==u&&!e.force&&!Er(e.op,e.bypassAssigneeConflict)){if(l.ownership_enforcement==="strict")throw new m(`Item ${i.id} is assigned to ${c}. Use --force to override.`,f.CONFLICT);l.ownership_enforcement==="warn"&&n.push(`ownership_warning:assignee_conflict:${i.id}:${c}`)}return{typeToFolder:t,located:i,originalRaw:s,document:a,warnings:n,releaseLock:r,lease:o}}catch(n){throw await r(),n}}function Si(e){return Object.keys(e).length===0?void 0:e}async function xi(e,t,i,o){return e.fence(async()=>{let r;try{r=await F.readFile(t.itemPath,"utf8")}catch(n){if(!j(n))throw n;r=null}if(r!==i)throw new m(`Item ${t.id} changed after this mutation read it; refusing to overwrite the newer revision. Nothing was written.`,f.CONFLICT,{code:"stale_revision",item_id:t.id,reason:r===null?"item_removed":"item_revision_changed",required:"Re-read the item and apply the mutation again; the newer stored revision was kept."});return o()})}function vr(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 Ri(e){try{let t=await mt(e.pmRoot,e.id,e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(!t)return{document:Fe};let i=q(await F.readFile(t.itemPath,"utf8"),{format:t.item_format,requireSupportedFormat:!0,schema:e.settings.schema,extensionFieldNames:ut(e.extensionFieldNames)});return i.metadata.id===e.embeddedId?{document:i}:{document:e.fallback,revision:vi}}catch{return{document:e.fallback,revision:vi}}}var vi="unreadable-after-storage-override";async function Ir(e){let t=await Ve("item_store_delete",e),i=t.handled&&typeof t.result=="object"&&t.result!==null?t.result:{};return{effectiveItemPath:typeof i.item_path=="string"&&i.item_path.trim().length>0?i.item_path:e.item_path,skipDelete:i.skip_delete===!0,warnings:t.warnings}}async function Cr(e){if(!e.skipItemWrite){if(e.effectiveTargetItemPath!==e.originalItemPath){await N(e.originalItemPath,e.originalRaw),await F.rm(e.effectiveTargetItemPath,{force:!0});return}await N(e.originalItemPath,e.originalRaw)}}function Tr(e,t){At(e.metadata)&&t.push("deferred_fields")}async function ft(e){Ot(e.op);let t=await Ti({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:e.op,author:e.author,force:e.force,bypassAssigneeConflict:e.bypassAssigneeConflict,extensionFieldNames:e.extensionFieldNames,typeToFolder:e.typeToFolder}),{typeToFolder:i,located:o,originalRaw:r,document:n,warnings:s,releaseLock:a,lease:d}=t;try{We(e.pmRoot,n,o.id);let c=K(n,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),p=K(structuredClone(n),{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),u=await e.mutate(p,{storageId:o.id});if(Tr(p,u.changedFields),e.skipNoop===!0&&u.changedFields.length===0)return{item:c.metadata,body:c.body,changedFields:[],warnings:[...s,...u.warnings??[]]};let l={...e.resolveHistoryContext?.(),...Ei(e.pmRoot,o.id),...Ht(e.pmRoot,[o.id,n.metadata.id])},h=Math.max(Le(c.metadata),Le(p.metadata));zt(Ct(e.pmRoot),h),h>Nt(p.metadata)&&(p.metadata.pm_format_version=h,u.changedFields.push("pm_format_version")),p.metadata.updated_at=je();let y=K(p,{schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),g=await Ke({pmRoot:e.pmRoot,settings:e.settings,operation:e.op,author:e.author,before:c,after:y});await Ge({pm_root:e.pmRoot,operation:e.op,before:c,after:y,changed_fields:u.changedFields,author:e.author,sdk:Ci({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:i})});let _=await dt({pmRoot:e.pmRoot,settings:e.settings,itemId:o.id,commandLabel:e.op}),b="toon",x=Ft(y,{format:b,schema:e.settings.schema,extensionFieldNames:e.extensionFieldNames}),M=Me(e.pmRoot,y.metadata.type,o.id,b,i),O=D(e.pmRoot,o.id),H=await xi(d,o,r,async()=>{let k=await Ve("item_store_write",{op:e.op,pm_root:e.pmRoot,item_id:o.id,source_item_path:o.itemPath,target_item_path:M,history_path:O,item_format:b,before:c,after:y,contents:x}),{effectiveTargetItemPath:T,effectiveSerializedAfter:le,skipItemWrite:G}=vr(k,M,x),ji=await st(e.pmRoot,e.author),_t=[];try{G||await N(T,le),!G&&T!==o.itemPath&&await F.rm(o.itemPath);let $i=Ue({nowIso:y.metadata.updated_at,author:e.author,op:e.op,before:c,after:y,message:e.message,context:Si({...l,...g.decisions.length===0?{}:{workflow_policies:g.decisions},...ze(e.pmRoot,[o.id,n.metadata.id],e.op)})});try{await He(O,$i)}catch(Ui){throw await Cr({skipItemWrite:G,effectiveTargetItemPath:T,originalItemPath:o.itemPath,originalRaw:r}),Ui}G||(_t=await at({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:i,schema:e.settings.schema,itemPath:T,previousItemPath:o.itemPath,document:y}))}finally{await ji()}let Li=G||T!==M||le!==x;return{derivedIndexWarnings:_t,effectiveTargetItemPath:T,overrideWarnings:k.warnings,stored:Li?await Ri({pmRoot:e.pmRoot,settings:e.settings,id:o.id,typeToFolder:i,extensionFieldNames:e.extensionFieldNames,fallback:y,embeddedId:y.metadata.id}):{document:y}}}),{derivedIndexWarnings:C,effectiveTargetItemPath:I,stored:W}=H;Be(e.pmRoot,W.document,o.id,[y.metadata.id],W.revision);let B=[...await L({path:I,scope:"project",op:e.op,item_id:y.metadata.id,item_type:y.metadata.type,before:c,after:y,changed_fields:u.changedFields}),...await L({path:O,scope:"project",op:`${e.op}:history`,item_id:y.metadata.id,item_type:y.metadata.type,before:c,after:y,changed_fields:u.changedFields})];return Xe({id:y.metadata.id,op:e.op,item_type:y.metadata.type,previous_status:c.metadata.status,status:y.metadata.status,previous:ye(c.metadata,u.changedFields),current:ye(y.metadata,u.changedFields),changed_fields:u.changedFields}),{item:y.metadata,body:y.body,changedFields:u.changedFields,warnings:[...s,...u.warnings??[],...g.warnings,..._.warnings,...H.overrideWarnings,...C,...B]}}finally{await a()}}async function qs(e){let{historyContext:t,...i}=e;return ft({...i,resolveHistoryContext:()=>t})}async function Ks(e){return ft(e)}async function Js(e){return ft(e)}async function Qs(e){let t=await Ti({pmRoot:e.pmRoot,settings:e.settings,id:e.id,op:"delete",author:e.author,force:e.force}),{located:i,originalRaw:o,document:r,warnings:n,releaseLock:s,lease:a}=t;try{We(e.pmRoot,r,i.id);let d=ut(void 0),c=K(r,{schema:e.settings.schema,extensionFieldNames:d}),p=await Ke({pmRoot:e.pmRoot,settings:e.settings,operation:"delete",author:e.author,before:c,after:null,dryRun:e.dryRun});await Ge({pm_root:e.pmRoot,operation:"delete",before:c,after:null,changed_fields:["deleted"],author:e.author,dry_run:e.dryRun===!0,sdk:Ci({pmRoot:e.pmRoot,settings:e.settings,typeToFolder:t.typeToFolder})});let u=await dt({pmRoot:e.pmRoot,settings:e.settings,itemId:i.id,commandLabel:"delete"}),l=je(),h=Fe,y=Ue({nowIso:l,author:e.author,op:"delete",before:c,after:h,message:e.message,context:Si({...p.decisions.length===0?{}:{workflow_policies:p.decisions},...ze(e.pmRoot,[i.id,r.metadata.id],"delete")})}),g=D(e.pmRoot,i.id),_=()=>Ir({op:"delete",pm_root:e.pmRoot,item_id:i.id,item_path:i.itemPath,history_path:g,before:c});if(e.dryRun===!0){let C=await _();return{item:c.metadata,changedFields:["deleted"],targetPath:C.effectiveItemPath,warnings:[...n,...p.warnings,...u.warnings,...C.warnings]}}let b=await xi(a,i,o,async()=>{let{effectiveItemPath:C,skipDelete:I,warnings:W}=await _(),B=await st(e.pmRoot,e.author),k=[];try{I||await F.rm(C);try{await He(g,y)}catch(T){throw I||await N(C,o),T}I||(k=await at({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:t.typeToFolder,schema:e.settings.schema,itemPath:C,document:null}))}finally{await B()}return{derivedIndexWarnings:k,effectiveItemPath:C,overrideWarnings:W,stored:I||C!==i.itemPath?await Ri({pmRoot:e.pmRoot,settings:e.settings,id:i.id,typeToFolder:t.typeToFolder,fallback:h,embeddedId:r.metadata.id}):{document:h}}}),{derivedIndexWarnings:x,effectiveItemPath:M,stored:O}=b;Be(e.pmRoot,O.document,i.id,[r.metadata.id],O.revision);let H=[...await L({path:M,scope:"project",op:"delete",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:h,changed_fields:["deleted"]}),...await L({path:g,scope:"project",op:"delete:history",item_id:c.metadata.id,item_type:c.metadata.type,before:c,after:h,changed_fields:["deleted"]})];return Xe({id:c.metadata.id,op:"delete",item_type:c.metadata.type,previous_status:c.metadata.status,previous:ye(c.metadata,Object.keys(c.metadata)),changed_fields:["deleted"]}),{item:c.metadata,changedFields:["deleted"],warnings:[...n,...p.warnings,...u.warnings,...b.overrideWarnings,...x,...H]}}finally{await s()}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a483f454-e261-5232-bae0-da3cdb8c0518")}catch{}})();var de=Object.freeze({max_bytes:4096,max_depth:8}),Oi=160;var Di=/[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?<![\uD800-\uDBFF])[\uDC00-\uDFFF]/u,Sr=new Set(["__proto__"]),v=class extends Error{reason;path;constructor(t,i){super(t),this.reason=t,this.path=i}};function ki(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function xr(e,t){return/^[A-Za-z_$][\w$]*$/u.test(t)?`${e}.${t}`:`${e}[${JSON.stringify(t)}]`}function Rr(e){if(Buffer.byteLength(e,"utf8")<=Oi)return e;let t="",i=Buffer.byteLength("\u2026","utf8");for(let o of e){if(i+=Buffer.byteLength(o,"utf8"),i>Oi)break;t+=o}return`${t}\u2026`}function Ae(e,t,i){if(e.bytes+=t,!(e.bytes<=de.max_bytes))throw new v("byte_limit",i)}function Ni(e,t,i){if(e.bytes+t>de.max_bytes)throw new v("byte_limit",i)}function yt(e,t,i){let o=Object.getOwnPropertyDescriptor(e,t);if(o===void 0||!("value"in o))throw new v("unsupported_value",i);return o.value}function Or(e,t,i){if(typeof e=="number"&&!Number.isFinite(e))throw new v("non_finite_number",t);if(typeof e=="string"&&(Ni(i,e.length+2,t),Di.test(e)))throw new v("malformed_unicode",t);if(e!==null&&!["boolean","number","string"].includes(typeof e))throw new v("unsupported_value",t);return Ae(i,Buffer.byteLength(JSON.stringify(e),"utf8"),t),e}function Ai(e,t,i,o){if(typeof e!="object"||e===null)return Or(e,t,o);if(i>=de.max_depth)throw new v("depth_limit",t);if(Array.isArray(e)){let r=yt(e,"length",t);if(typeof r!="number"||!Number.isSafeInteger(r)||r<0)throw new v("unsupported_value",t);Ae(o,r>0?r+1:2,t);let n=[];for(let s=0;s<r;s+=1){let a=`${t}[${s}]`;n.push(Ai(yt(e,String(s),a),a,i+1,o))}return n}if(!ki(e))throw new v("unsupported_value",t);return Fi(e,t,i+1,o)}function Fi(e,t,i,o){let r=Object.keys(e);Ae(o,r.length>0?r.length+1:2,t);let n={};for(let s of r){Ni(o,s.length+3,t);let a=xr(t,s);if(Sr.has(s))throw new v("reserved_key",a);if(Di.test(s))throw new v("malformed_unicode",a);Ae(o,Buffer.byteLength(JSON.stringify(s),"utf8")+1,a),n[s]=Ai(yt(e,s,a),a,i,o)}return n}function Dr(e){try{if(e instanceof v)return e}catch{}return new v("unsupported_value","details")}function pt(e){let t=de.max_bytes,i={bytes:0};try{if(!ki(e))throw new v("not_plain_object","details");return{ok:!0,details:Fi(e,"details",0,i),byte_length:i.bytes}}catch(o){let r=Dr(o);return{ok:!1,omission:r.reason==="byte_limit"?{reason:"byte_limit",byte_limit:t}:{reason:r.reason,path:Rr(r.path),byte_limit:t}}}}function kr(e){return pt(e).ok}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="e82bc812-181f-57ab-a29a-61703e8bec1b")}catch{}})();function ht(e){return typeof e=="number"&&Number.isSafeInteger(e)&&e>0}function da(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e;if(!ht(t.requested_tokens)||t.basis!=="canonical_retry")return!1;switch(t.minimum_status){case"exact":return ht(t.minimum_feasible_tokens)&&t.feasible_tokens===t.minimum_feasible_tokens&&t.reason===void 0;case"feasible_only":return t.minimum_feasible_tokens===null&&ht(t.feasible_tokens)&&t.reason===void 0;case"unavailable":return t.minimum_feasible_tokens===null&&t.feasible_tokens===null&&["query_cost_limit","search_limit","output_constraints"].includes(t.reason);default:return!1}}var Nr="PmCliError";function la(e){if(!Mr(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 Ar(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 Fr(e){if(e==null)return{};if(!Object.hasOwn(e,"details"))return e;let t=Object.getOwnPropertyDescriptor(e,"details");if(!("value"in t))throw Mi("unsupported_value","details");if(t.value===void 0)return e;let i=pt(t.value);if(i.ok)return{...e,details:i.details};if(i.omission.reason==="byte_limit"){let{details:o,...r}=e;return{...r,details_omitted:i.omission}}throw Mi(i.omission.reason,i.omission.path)}function Mi(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 ua(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,Ar(t.exitCode??f.USAGE),Fr(t.context));return"cause"in t&&Object.defineProperty(i,"cause",{value:t.cause,enumerable:!1,configurable:!0,writable:!0}),i}function Mr(e){try{if(!(e instanceof Error)||e.name!==Nr)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 Pr(e,t){let i=e.trim().toLowerCase();if(i.length===0)return;let o=Math.floor(i.length/3);return t.map(r=>({candidate:r,distance:ue(i,r.toLowerCase(),o)??Number.POSITIVE_INFINITY})).filter(({distance:r})=>Number.isFinite(r)).sort((r,n)=>r.distance!==n.distance?r.distance-n.distance:r.candidate.localeCompare(n.candidate))[0]?.candidate}function Pi(e){return["pm",...e].map(t=>/^[A-Za-z0-9_./:@=-]+$/u.test(t)?t:JSON.stringify(t)).join(" ")}function ha(e){let t=e.command_path.trim().replaceAll(/\s+/gu," "),i=e.token.trim(),o=i.length===0?"<empty>":i,r=[...new Set(e.allowed.map(l=>l.trim()))].filter(Boolean).sort((l,h)=>l.localeCompare(h));if(t.length===0||o.length===0||r.length===0)throw new TypeError("Unknown-subcommand contracts require a path, token, and allowed set");let n=t.split(" "),s=e.trailing_args??[],a=e.display_name??`pm ${t}`,d=e.token_kind??"subcommand",c=e.retry_command?void 0:Pr(o,r),p=Pi([...n,o,...s]),u=e.retry_command??(c?Pi([...n,c,...s]):void 0);return new m(`Unknown ${a} ${d} "${o}". Allowed: ${r.join(", ")}${e.message_suffix??""}`,e.exit_code??f.USAGE,{code:"unknown_subcommand",reason:"unknown_positional_token",value:o,examples:[...u?[u]:[],...e.examples??[],`pm ${t} --help`],nextSteps:u?[`Retry with the suggested command: ${u}`]:["Choose one value from recovery.allowed_values."],recovery:{attempted_command:p,allowed_values:r,suggested_retry:u,fallback_candidates:e.fallback_candidates}})}export{_e as a,ge as b,Ur as c,Hr as d,ha as e,dt as f,ur as g,qt as h,Z as i,ee as j,Vr as k,te as l,hi as m,ct as n,_i as o,Xn as p,Zi as q,to as r,io as s,oo as t,ro as u,Ke as v,hn as w,ss as x,Cn as y,Tn as z,Sn as A,di as B,vo as C,st as D,$n as E,at as F,Ne as G,mt as H,Ii as I,hr as J,_r as K,Ys as L,Vs as M,Ci as N,br as O,qs as P,Ks as Q,Js as R,Qs as S,kr as T,da as U,Nr as V,la as W,ua as X,Mr as Y};
91
- //# sourceMappingURL=chunk-I7XBR2RM.js.map
@@ -1,2 +0,0 @@
1
- import{$a as m,Za as k,ab as f,bb as b,lb as u}from"./chunk-PZSTRYTA.js";import{z as a}from"./chunk-IXYBN6D2.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"}],q=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 L(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)),q.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=L(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]="1cc13594-afb5-5125-bc33-490d0d1c15a4")}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_compacted",exit_code:2,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_deferred_fields",exit_code:2,sources:["sdk/lifecycle/close.ts"],emitting_commands:["close"]},{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","sdk/config.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_deferral_conflict",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_field_unsupported",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_fields_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{code:"create_deferral_reason_required",exit_code:2,sources:["sdk/lifecycle/create-deferrals.ts"],emitting_commands:["create"]},{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/dependency-removal.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_disabled",exit_code:2,sources:["sdk/extension/command-options.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:"in_progress_idle",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"in_progress_unowned",exit_code:1,sources:["core/diagnostics/remediation.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/shared/url-credentials.ts","core/telemetry/observability.ts","sdk/config.ts","sdk/context-intent-contracts.ts","sdk/dependencies.ts","sdk/governance/assurance-mutation-error.ts","sdk/history-redact.ts","sdk/lifecycle/create.ts","sdk/lifecycle/task-composition.ts","sdk/lifecycle/update-many.ts","sdk/lifecycle/update.ts","sdk/linked-artifacts.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/test/run-phases.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_artifact_note_conflict",exit_code:4,sources:["sdk/linked-artifacts.ts"]},{code:"linked_artifact_note_key_misread",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"]}];(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]="1295716e-cbc9-5497-9a14-30274f1f7086")}catch{}})();var O=[{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"]},{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","sdk/linked-artifacts.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/extension/command-options.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:"output_budget_exceeded",exit_code:2,sources:["sdk/testing.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_claim_takeover_refused",exit_code:4,sources:["sdk/lifecycle/claim.ts"],emitting_commands:["claim"]},{code:"stale_destination",exit_code:1,sources:["sdk/cli-contracts/grammar-contracts.ts"]},{code:"stale_in_progress_items",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"stale_lock_requires_override",exit_code:4,sources:["core/lock/lock.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_entry_key_repeated",exit_code:2,sources:["core/item/parse.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]="11e0a702-31a9-577b-a9c3-464830765883")}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","--takeover-stale","--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,...k.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 ke(e,y)}function ke(e,t){let s=M[e];return t.filter(o=>o.tier!=="internal"&&M[o.tier]<=s).map(o=>o.command)}function be(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([...b.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:be(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-MJP3TFVW.js.map