@unbrained/pm-cli 2026.12.1 → 2026.12.2

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 (267) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli-bundle/bundle-manifest.json +1 -1
  3. package/dist/cli-bundle/chunks/{chunk-CWPR234D.js → chunk-7NAO7I75.js} +2 -2
  4. package/dist/cli-bundle/chunks/{chunk-4YQMQOUO.js → chunk-7V65VACG.js} +52 -52
  5. package/dist/cli-bundle/chunks/{chunk-NA6D75V5.js → chunk-G6TARHFK.js} +2 -2
  6. package/dist/cli-bundle/chunks/{chunk-YSVOXCYH.js → chunk-GOEQXVOI.js} +2 -2
  7. package/dist/cli-bundle/chunks/{chunk-OKEJ4U2I.js → chunk-ROTEELDL.js} +3 -3
  8. package/dist/cli-bundle/chunks/{chunk-U7RBJGLF.js → chunk-SDXCJZKB.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-XME6GIFQ.js → chunk-TKUG2X24.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-Q6GLSAJY.js → chunk-UNBW2LF3.js} +2 -2
  11. package/dist/cli-bundle/chunks/chunk-V2S4XAX3.js +2 -0
  12. package/dist/cli-bundle/chunks/{item-transaction-66RDV7PH.js → item-transaction-56J5OCHA.js} +2 -2
  13. package/dist/cli-bundle/chunks/{linked-resource-value-list-E2DX52LY.js → linked-resource-value-list-ZBIY4H23.js} +2 -2
  14. package/dist/cli-bundle/chunks/{register-mutation-2F6JUBST.js → register-mutation-EK6DVIQK.js} +2 -2
  15. package/dist/cli-bundle/chunks/{register-operations-ET3UKPYK.js → register-operations-6MURXE4V.js} +2 -2
  16. package/dist/cli-bundle/chunks/{register-setup-I63QTFCU.js → register-setup-RW26X3GJ.js} +2 -2
  17. package/dist/cli-bundle/focused-chunks/{chunk-SQ72CVUH.js → chunk-3COWDIPX.js} +54 -54
  18. package/dist/cli-bundle/focused-chunks/{chunk-PT7RT3T6.js → chunk-J72TRWR5.js} +3 -3
  19. package/dist/cli-bundle/focused-chunks/{item-transaction-2K4SFLJ7.js → item-transaction-LQLQLZE7.js} +2 -2
  20. package/dist/cli-bundle/main.js +3 -3
  21. package/dist/cli-bundle/sdk-core.js +1 -1
  22. package/dist/cli-bundle/sdk-governance.js +1 -1
  23. package/dist/cli-bundle/sdk-merge.js +1 -1
  24. package/dist/cli-bundle/sdk-runtime.js +1 -1
  25. package/dist/cli-bundle/sdk-testing.js +1 -1
  26. package/dist/cli-bundle/sdk.js +1 -1
  27. package/dist/sdk/extension/install-sources.d.ts +2 -2
  28. package/dist/sdk/extension/install-sources.js +5 -5
  29. package/marketplace.json +1 -1
  30. package/node_modules/tar/README.md +1792 -1147
  31. package/node_modules/tar/dist/commonjs/bytes.d.ts +21 -0
  32. package/node_modules/tar/dist/commonjs/bytes.js +83 -0
  33. package/node_modules/tar/dist/commonjs/codec.d.ts +53 -0
  34. package/node_modules/tar/dist/commonjs/codec.js +35 -0
  35. package/node_modules/tar/dist/commonjs/concat.d.ts +3 -0
  36. package/node_modules/tar/dist/commonjs/concat.js +20 -0
  37. package/node_modules/tar/dist/commonjs/create.d.ts +39 -2
  38. package/node_modules/tar/dist/commonjs/create.js +150 -64
  39. package/node_modules/tar/dist/commonjs/dealias.d.ts +79 -0
  40. package/node_modules/tar/dist/commonjs/dealias.js +50 -0
  41. package/node_modules/tar/dist/commonjs/delete.d.ts +19 -0
  42. package/node_modules/tar/dist/commonjs/delete.js +121 -0
  43. package/node_modules/tar/dist/commonjs/entries.d.ts +82 -0
  44. package/node_modules/tar/dist/commonjs/entries.js +398 -0
  45. package/node_modules/tar/dist/commonjs/extract.d.ts +14 -2
  46. package/node_modules/tar/dist/commonjs/extract.js +40 -81
  47. package/node_modules/tar/dist/commonjs/fs.d.ts +201 -0
  48. package/node_modules/tar/dist/commonjs/fs.js +5 -0
  49. package/node_modules/tar/dist/commonjs/header.d.ts +4 -4
  50. package/node_modules/tar/dist/commonjs/header.js +71 -53
  51. package/node_modules/tar/dist/commonjs/index.d.ts +25 -18
  52. package/node_modules/tar/dist/commonjs/index.js +46 -18
  53. package/node_modules/tar/dist/commonjs/index.min.js +2 -3
  54. package/node_modules/tar/dist/commonjs/large-numbers.d.ts +2 -2
  55. package/node_modules/tar/dist/commonjs/large-numbers.js +4 -4
  56. package/node_modules/tar/dist/commonjs/list.d.ts +23 -6
  57. package/node_modules/tar/dist/commonjs/list.js +99 -138
  58. package/node_modules/tar/dist/commonjs/mkdir.d.ts +16 -11
  59. package/node_modules/tar/dist/commonjs/mkdir.js +121 -159
  60. package/node_modules/tar/dist/commonjs/normalize-unicode.js +9 -0
  61. package/node_modules/tar/dist/commonjs/options.d.ts +284 -513
  62. package/node_modules/tar/dist/commonjs/options.js +20 -61
  63. package/node_modules/tar/dist/commonjs/pack.d.ts +150 -96
  64. package/node_modules/tar/dist/commonjs/pack.js +752 -445
  65. package/node_modules/tar/dist/commonjs/parser.d.ts +98 -0
  66. package/node_modules/tar/dist/commonjs/parser.js +452 -0
  67. package/node_modules/tar/dist/commonjs/path-reservations.d.ts +17 -7
  68. package/node_modules/tar/dist/commonjs/path-reservations.js +110 -140
  69. package/node_modules/tar/dist/commonjs/path.d.ts +19 -0
  70. package/node_modules/tar/dist/commonjs/path.js +90 -0
  71. package/node_modules/tar/dist/commonjs/pax.d.ts +3 -1
  72. package/node_modules/tar/dist/commonjs/pax.js +67 -36
  73. package/node_modules/tar/dist/commonjs/read-entry.d.ts +97 -11
  74. package/node_modules/tar/dist/commonjs/read-entry.js +251 -97
  75. package/node_modules/tar/dist/commonjs/read-file.d.ts +22 -0
  76. package/node_modules/tar/dist/commonjs/read-file.js +104 -0
  77. package/node_modules/tar/dist/commonjs/replace.d.ts +45 -1
  78. package/node_modules/tar/dist/commonjs/replace.js +164 -211
  79. package/node_modules/tar/dist/commonjs/server/codecs.d.ts +38 -0
  80. package/node_modules/tar/dist/commonjs/server/codecs.js +252 -0
  81. package/node_modules/tar/dist/commonjs/server/index.d.ts +115 -0
  82. package/node_modules/tar/dist/commonjs/server/index.js +166 -0
  83. package/node_modules/tar/dist/commonjs/server/index.min.js +3 -0
  84. package/node_modules/tar/dist/commonjs/strip-absolute-path.d.ts +8 -0
  85. package/node_modules/tar/dist/commonjs/strip-absolute-path.js +17 -20
  86. package/node_modules/tar/dist/commonjs/to-stream.d.ts +7 -0
  87. package/node_modules/tar/dist/commonjs/to-stream.js +22 -0
  88. package/node_modules/tar/dist/commonjs/types.d.ts +4 -3
  89. package/node_modules/tar/dist/commonjs/types.js +4 -3
  90. package/node_modules/tar/dist/commonjs/unpack.d.ts +143 -89
  91. package/node_modules/tar/dist/commonjs/unpack.js +780 -725
  92. package/node_modules/tar/dist/commonjs/update.d.ts +11 -1
  93. package/node_modules/tar/dist/commonjs/update.js +37 -28
  94. package/node_modules/tar/dist/commonjs/warn.d.ts +27 -0
  95. package/node_modules/tar/dist/commonjs/warn.js +36 -0
  96. package/node_modules/tar/dist/commonjs/win32-path.d.ts +16 -0
  97. package/node_modules/tar/dist/commonjs/win32-path.js +67 -0
  98. package/node_modules/tar/dist/commonjs/write-entry.d.ts +64 -111
  99. package/node_modules/tar/dist/commonjs/write-entry.js +108 -672
  100. package/node_modules/tar/dist/commonjs/write-flag.d.ts +18 -0
  101. package/node_modules/tar/dist/commonjs/write-flag.js +29 -0
  102. package/node_modules/tar/dist/esm/bytes.d.ts +21 -0
  103. package/node_modules/tar/dist/esm/bytes.js +72 -0
  104. package/node_modules/tar/dist/esm/codec.d.ts +53 -0
  105. package/node_modules/tar/dist/esm/codec.js +32 -0
  106. package/node_modules/tar/dist/esm/concat.d.ts +3 -0
  107. package/node_modules/tar/dist/esm/concat.js +16 -0
  108. package/node_modules/tar/dist/esm/create.d.ts +39 -2
  109. package/node_modules/tar/dist/esm/create.js +144 -61
  110. package/node_modules/tar/dist/esm/dealias.d.ts +79 -0
  111. package/node_modules/tar/dist/esm/dealias.js +46 -0
  112. package/node_modules/tar/dist/esm/delete.d.ts +19 -0
  113. package/node_modules/tar/dist/esm/delete.js +117 -0
  114. package/node_modules/tar/dist/esm/entries.d.ts +82 -0
  115. package/node_modules/tar/dist/esm/entries.js +388 -0
  116. package/node_modules/tar/dist/esm/extract.d.ts +14 -2
  117. package/node_modules/tar/dist/esm/extract.js +37 -44
  118. package/node_modules/tar/dist/esm/fs.d.ts +201 -0
  119. package/node_modules/tar/dist/esm/fs.js +4 -0
  120. package/node_modules/tar/dist/esm/header.d.ts +4 -4
  121. package/node_modules/tar/dist/esm/header.js +71 -53
  122. package/node_modules/tar/dist/esm/index.d.ts +25 -18
  123. package/node_modules/tar/dist/esm/index.js +23 -18
  124. package/node_modules/tar/dist/esm/index.min.js +2 -3
  125. package/node_modules/tar/dist/esm/large-numbers.d.ts +2 -2
  126. package/node_modules/tar/dist/esm/large-numbers.js +4 -4
  127. package/node_modules/tar/dist/esm/list.d.ts +23 -6
  128. package/node_modules/tar/dist/esm/list.js +96 -101
  129. package/node_modules/tar/dist/esm/mkdir.d.ts +16 -11
  130. package/node_modules/tar/dist/esm/mkdir.js +119 -154
  131. package/node_modules/tar/dist/esm/normalize-unicode.js +9 -0
  132. package/node_modules/tar/dist/esm/options.d.ts +284 -513
  133. package/node_modules/tar/dist/esm/options.js +17 -51
  134. package/node_modules/tar/dist/esm/pack.d.ts +150 -96
  135. package/node_modules/tar/dist/esm/pack.js +750 -441
  136. package/node_modules/tar/dist/esm/parser.d.ts +98 -0
  137. package/node_modules/tar/dist/esm/parser.js +448 -0
  138. package/node_modules/tar/dist/esm/path-reservations.d.ts +17 -7
  139. package/node_modules/tar/dist/esm/path-reservations.js +110 -140
  140. package/node_modules/tar/dist/esm/path.d.ts +19 -0
  141. package/node_modules/tar/dist/esm/path.js +80 -0
  142. package/node_modules/tar/dist/esm/pax.d.ts +3 -1
  143. package/node_modules/tar/dist/esm/pax.js +66 -35
  144. package/node_modules/tar/dist/esm/read-entry.d.ts +97 -11
  145. package/node_modules/tar/dist/esm/read-entry.js +248 -96
  146. package/node_modules/tar/dist/esm/read-file.d.ts +22 -0
  147. package/node_modules/tar/dist/esm/read-file.js +99 -0
  148. package/node_modules/tar/dist/esm/replace.d.ts +45 -1
  149. package/node_modules/tar/dist/esm/replace.js +160 -207
  150. package/node_modules/tar/dist/esm/server/codecs.d.ts +38 -0
  151. package/node_modules/tar/dist/esm/server/codecs.js +214 -0
  152. package/node_modules/tar/dist/esm/server/index.d.ts +115 -0
  153. package/node_modules/tar/dist/esm/server/index.js +102 -0
  154. package/node_modules/tar/dist/esm/server/index.min.js +3 -0
  155. package/node_modules/tar/dist/esm/strip-absolute-path.d.ts +8 -0
  156. package/node_modules/tar/dist/esm/strip-absolute-path.js +17 -20
  157. package/node_modules/tar/dist/esm/to-stream.d.ts +7 -0
  158. package/node_modules/tar/dist/esm/to-stream.js +18 -0
  159. package/node_modules/tar/dist/esm/types.d.ts +4 -3
  160. package/node_modules/tar/dist/esm/types.js +4 -3
  161. package/node_modules/tar/dist/esm/unpack.d.ts +143 -89
  162. package/node_modules/tar/dist/esm/unpack.js +776 -719
  163. package/node_modules/tar/dist/esm/update.d.ts +11 -1
  164. package/node_modules/tar/dist/esm/update.js +35 -28
  165. package/node_modules/tar/dist/esm/warn.d.ts +27 -0
  166. package/node_modules/tar/dist/esm/warn.js +31 -0
  167. package/node_modules/tar/dist/esm/win32-path.d.ts +16 -0
  168. package/node_modules/tar/dist/esm/win32-path.js +60 -0
  169. package/node_modules/tar/dist/esm/write-entry.d.ts +64 -111
  170. package/node_modules/tar/dist/esm/write-entry.js +107 -633
  171. package/node_modules/tar/dist/esm/write-flag.d.ts +18 -0
  172. package/node_modules/tar/dist/esm/write-flag.js +25 -0
  173. package/node_modules/tar/package.json +68 -224
  174. package/package.json +2 -2
  175. package/packages/pm-beads/package.json +1 -1
  176. package/packages/pm-calendar/package.json +1 -1
  177. package/packages/pm-command-kit/package.json +1 -1
  178. package/packages/pm-digital-twin/package.json +1 -1
  179. package/packages/pm-governance-audit/package.json +1 -1
  180. package/packages/pm-guide-shell/package.json +1 -1
  181. package/packages/pm-kanban/package.json +1 -1
  182. package/packages/pm-lifecycle-hooks/package.json +1 -1
  183. package/packages/pm-linked-test-adapters/package.json +1 -1
  184. package/packages/pm-search-advanced/package.json +1 -1
  185. package/packages/pm-templates/package.json +1 -1
  186. package/packages/pm-todos/package.json +1 -1
  187. package/packages/pm-vcs/package.json +1 -1
  188. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  189. package/plugins/pm-claude/package.json +1 -1
  190. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  191. package/plugins/pm-codex/package.json +1 -1
  192. package/plugins/pm-codex/plugin.json +1 -1
  193. package/runtime-dependencies.json +1 -1
  194. package/dist/cli-bundle/chunks/chunk-AJLU6KLW.js +0 -2
  195. package/node_modules/@isaacs/fs-minipass/LICENSE +0 -15
  196. package/node_modules/@isaacs/fs-minipass/README.md +0 -71
  197. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.d.ts +0 -118
  198. package/node_modules/@isaacs/fs-minipass/dist/commonjs/index.js +0 -430
  199. package/node_modules/@isaacs/fs-minipass/dist/commonjs/package.json +0 -3
  200. package/node_modules/@isaacs/fs-minipass/dist/esm/index.d.ts +0 -118
  201. package/node_modules/@isaacs/fs-minipass/dist/esm/index.js +0 -420
  202. package/node_modules/@isaacs/fs-minipass/dist/esm/package.json +0 -3
  203. package/node_modules/@isaacs/fs-minipass/package.json +0 -72
  204. package/node_modules/chownr/LICENSE.md +0 -63
  205. package/node_modules/chownr/README.md +0 -3
  206. package/node_modules/chownr/dist/commonjs/index.d.ts +0 -3
  207. package/node_modules/chownr/dist/commonjs/index.js +0 -93
  208. package/node_modules/chownr/dist/commonjs/package.json +0 -3
  209. package/node_modules/chownr/dist/esm/index.d.ts +0 -3
  210. package/node_modules/chownr/dist/esm/index.js +0 -85
  211. package/node_modules/chownr/dist/esm/package.json +0 -3
  212. package/node_modules/chownr/package.json +0 -69
  213. package/node_modules/minipass/LICENSE.md +0 -55
  214. package/node_modules/minipass/README.md +0 -825
  215. package/node_modules/minipass/dist/commonjs/index.d.ts +0 -545
  216. package/node_modules/minipass/dist/commonjs/index.js +0 -1038
  217. package/node_modules/minipass/dist/commonjs/package.json +0 -3
  218. package/node_modules/minipass/dist/esm/index.d.ts +0 -545
  219. package/node_modules/minipass/dist/esm/index.js +0 -1020
  220. package/node_modules/minipass/dist/esm/package.json +0 -3
  221. package/node_modules/minipass/package.json +0 -77
  222. package/node_modules/minizlib/LICENSE +0 -26
  223. package/node_modules/minizlib/README.md +0 -64
  224. package/node_modules/minizlib/dist/commonjs/constants.d.ts +0 -2
  225. package/node_modules/minizlib/dist/commonjs/constants.js +0 -123
  226. package/node_modules/minizlib/dist/commonjs/index.d.ts +0 -99
  227. package/node_modules/minizlib/dist/commonjs/index.js +0 -416
  228. package/node_modules/minizlib/dist/commonjs/package.json +0 -3
  229. package/node_modules/minizlib/dist/esm/constants.d.ts +0 -2
  230. package/node_modules/minizlib/dist/esm/constants.js +0 -117
  231. package/node_modules/minizlib/dist/esm/index.d.ts +0 -99
  232. package/node_modules/minizlib/dist/esm/index.js +0 -363
  233. package/node_modules/minizlib/dist/esm/package.json +0 -3
  234. package/node_modules/minizlib/package.json +0 -80
  235. package/node_modules/tar/dist/commonjs/get-write-flag.d.ts +0 -2
  236. package/node_modules/tar/dist/commonjs/get-write-flag.js +0 -32
  237. package/node_modules/tar/dist/commonjs/make-command.d.ts +0 -49
  238. package/node_modules/tar/dist/commonjs/make-command.js +0 -52
  239. package/node_modules/tar/dist/commonjs/normalize-windows-path.d.ts +0 -2
  240. package/node_modules/tar/dist/commonjs/normalize-windows-path.js +0 -12
  241. package/node_modules/tar/dist/commonjs/parse.d.ts +0 -92
  242. package/node_modules/tar/dist/commonjs/parse.js +0 -655
  243. package/node_modules/tar/dist/commonjs/process-umask.d.ts +0 -2
  244. package/node_modules/tar/dist/commonjs/process-umask.js +0 -7
  245. package/node_modules/tar/dist/commonjs/warn-method.d.ts +0 -24
  246. package/node_modules/tar/dist/commonjs/warn-method.js +0 -31
  247. package/node_modules/tar/dist/esm/get-write-flag.d.ts +0 -2
  248. package/node_modules/tar/dist/esm/get-write-flag.js +0 -26
  249. package/node_modules/tar/dist/esm/make-command.d.ts +0 -49
  250. package/node_modules/tar/dist/esm/make-command.js +0 -48
  251. package/node_modules/tar/dist/esm/normalize-windows-path.d.ts +0 -2
  252. package/node_modules/tar/dist/esm/normalize-windows-path.js +0 -9
  253. package/node_modules/tar/dist/esm/parse.d.ts +0 -92
  254. package/node_modules/tar/dist/esm/parse.js +0 -651
  255. package/node_modules/tar/dist/esm/process-umask.d.ts +0 -2
  256. package/node_modules/tar/dist/esm/process-umask.js +0 -3
  257. package/node_modules/tar/dist/esm/warn-method.d.ts +0 -24
  258. package/node_modules/tar/dist/esm/warn-method.js +0 -27
  259. package/node_modules/yallist/LICENSE.md +0 -63
  260. package/node_modules/yallist/README.md +0 -205
  261. package/node_modules/yallist/dist/commonjs/index.d.ts +0 -39
  262. package/node_modules/yallist/dist/commonjs/index.js +0 -384
  263. package/node_modules/yallist/dist/commonjs/package.json +0 -3
  264. package/node_modules/yallist/dist/esm/index.d.ts +0 -39
  265. package/node_modules/yallist/dist/esm/index.js +0 -379
  266. package/node_modules/yallist/dist/esm/package.json +0 -3
  267. package/node_modules/yallist/package.json +0 -68
@@ -1,4 +1,4 @@
1
- import{A as mn,B as ie,D as Fi,G as Di,H as Cf,Ha as jf,Ia as qf,J as oa,Ja as sr,K as Ef,Ka as ua,M as Rf,Na as Gf,Oc as a_,Rc as c_,U as Tf,_a as or,bb as gn,eb as yn,l as Sf,lb as ji,o as Af,oa as Pf,p as nr,pa as Uf,pb as i_,qb as s_,s as xf,wb as o_,y as rr,yb as ha,z as ir}from"./chunk-ZL6J6JYT.js";import{a as Xo,d as Jo,e as Jp,f as Qo,g as Qp}from"./chunk-X5D5YUHR.js";import{a as Kf}from"./chunk-4QA5O64H.js";import{J as bf,a as Oi,b as Qn,c as Ni,d as ke,e as $i,f as yf,g as wf,h as Li,i as Zn,j as vf,k as kf,l as ra,m as ia,n as er,r as tr,t as Mi,u as X,y as sa}from"./chunk-L2ZSSMYY.js";import{C as Hf,E as Gi,F as Vf,G as Yf,H as ma,I as pa,N as Xf,O as Jf,P as Qf,Q as Zf,R as e_,S as fa,T as _a,U as t_,V as n_,W as r_,Z as d_,a as Mf,aa as l_,da as u_,ia as m_,ja as p_,m as hn,q as Ff,r as Df,t as Pi,u as Ui,v as zf,w as Wf,x as Bf,z as qi}from"./chunk-YSVOXCYH.js";import{Aa as Lf,j as Zp,oa as ca,pa as Nf,qa as da,ra as la,u as Of,va as $f}from"./chunk-4YQMQOUO.js";import{a as Yp,l as aa}from"./chunk-3HKPVOAN.js";import{i as bt,k as pn,l as fn,m as _n}from"./chunk-Q6K7HWZ7.js";import{c as If}from"./chunk-OGVSGXQX.js";import{N as lf,O as Ti,P as uf,Q as ta,S as mf,T as pf,V as ff,W as _f,X as Ii,Y as hf,a as ef,b as tf,c as nf,ca as na,d as rf,f as sf,ga as gf,j as Zo,k as of,l as af,m as ea,n as cf,o as df}from"./chunk-C6WM6ZN4.js";import{a as Gp,e as zp,k as Wp,s as Bp,t as Jn,u as Hp,x as Vp}from"./chunk-QDV7S2QS.js";import{$b as Vn,A as Zd,Ad as Kp,B as Re,C as Wr,E as bl,H as Sl,Ha as Si,J as Al,Jb as Hu,Ka as ln,La as Nu,Ma as $u,Na as Du,Nc as Po,Ob as Vu,Oc as Uo,Pc as jo,Qb as Yu,Qc as qo,R as ti,Tb as Do,U as Eu,Ua as Pu,Vb as Xu,Xb as Ju,Yb as yt,Zb as Qu,_b as wt,ab as Uu,ac as Pt,c as Be,ca as gi,cc as Zu,e as He,eb as qu,f as tn,fb as Gu,fd as nm,g as ho,ga as De,h as Xd,ha as Tu,i as jr,ib as Ku,j as qr,ja as yi,jb as Ai,k as Jd,ka as Iu,kb as zu,l as Gr,la as wi,lc as em,m as Qd,ma as vi,mb as V,na as ki,nb as le,nd as rm,o as _e,p as Kr,pb as xi,pc as tm,q as go,qb as he,r as $e,ra as bi,rb as rt,sb as Wu,sd as im,tb as Dt,td as sm,ua as Ou,ud as Ci,v as Ve,vb as un,vd as om,wb as Ie,x as It,xa as Hn,yb as Fo,z as zr,zb as Bu,zd as Ri}from"./chunk-CBUC4X7Q.js";import{B as ju,H as z,a as Ft,b as Ru,e as cn,f as dn,j as Lu,t as Mu,u as R,v as Fu}from"./chunk-OXC5KBIQ.js";import{A as _o,Aa as si,Bb as Zl,Da as oi,Df as _u,Ea as re,Ec as ru,Ed as ou,Eg as _i,Fa as Lt,Fd as au,Ff as hu,Ga as ae,Gg as hi,Ha as $o,Hb as ui,Hf as Bn,Ia as Lo,Ib as H,Ja as jl,Jf as gu,La as ai,Ld as cu,Mf as yu,Na as ql,Nb as Mt,O as Ao,Oa as an,Pa as Gl,Pg as vu,Q as Ye,Qa as Kl,Qe as lu,Sa as zl,T as Nt,Ua as ci,Ub as eu,Va as Wl,Wa as Bl,X as te,Xg as M,Yc as iu,_ as Zr,a as jd,ab as Hl,ad as su,bb as Vl,cb as Yl,cg as gt,ch as ku,db as Xl,dg as pi,dh as bu,eb as Jl,fa as Rl,fb as di,fd as Mo,fg as fi,ga as on,gb as li,gh as nt,ha as Ro,hf as uu,ia as ei,if as mu,jf as mi,jh as Su,kh as Te,l as qd,lg as wu,m as Gd,mh as Au,n as Kd,nb as Ql,nh as xu,o as zd,oa as Tl,of as pu,oh as Cu,p as Wd,q as Bd,qb as zn,r as We,rb as Wn,s as Hd,se as du,tf as fu,vc as tu,wc as nu,xa as ii,y as Vd,ya as Kn,z as Yd}from"./chunk-NRQCBUYD.js";import{A as pl,B as fl,C as _l,D as hl,E as gl,F as yl,b as ko,c as jn,d as ve,g as F,h as et,i as Yr,j as rn,k as qn,l as Gn,o as I,p as _t,q as tt,r as sn,s as ll,t as ul,u as Me,v as Xr,x as ml,y as bo,z as So}from"./chunk-GSLOAEY2.js";import{g as Xp}from"./chunk-WSEIEDEK.js";import{$ as $m,$a as Cp,Aa as np,Ba as rp,C as zo,Ca as ip,D as Wo,Da as sp,Ea as op,F as vt,Fa as ap,G as pm,Ga as cp,H as fm,Ha as dp,I as _m,Ia as lp,J as hm,Ja as up,K as Ei,L as gm,M as ym,N as wm,Na as mp,O as vm,Oa as pp,P as km,Pa as fp,Q as bm,Qa as _p,R as Sm,Ra as hp,S as Am,Sa as gp,T as xm,Ta as yp,U as Cm,Ua as wp,V as Em,Va as vp,W as Rm,Wa as kp,X as Tm,Xa as bp,Y as Im,Ya as Sp,Z as Om,Za as Ap,_ as Nm,_a as xp,aa as Lm,ab as Ep,ba as Mm,bb as Rp,c as am,ca as Fm,cb as Tp,d as cm,da as Dm,db as Vo,e as dm,ea as Pm,eb as Ip,fb as Op,ga as Um,gb as Yo,ha as Bo,hb as Np,ia as jm,ib as $p,ja as qm,jb as Lp,ka as Gm,kb as Mp,la as Km,lb as Fp,ma as Yn,mb as kt,na as zm,nb as Dp,oa as Wm,ob as Pp,p as Go,pa as Bm,pb as Up,q as lm,qa as Hm,qb as jp,ra as Vm,sa as Ym,sb as qp,t as um,ta as Xm,u as Ko,ua as Jm,v as Ut,va as Qm,vb as Xn,wa as Zm,x as mm,xa as ep,ya as Ho,za as tp}from"./chunk-A5ZEMOVR.js";import{$ as Oo,A as Ot,B as xo,C as wl,D as Qr,E as vl,F as Co,I as kl,K as xl,Q as O,S as Eo,T as Cl,U as El,W as se,_ as Ll,a as Z,aa as Ml,b as Un,ba as No,ca as Fl,da as ri,fa as Dl,ga as Pl,ha as Ul,i as ze,k as P,l as Ur,m as Tt,v as Jr,x as L}from"./chunk-I4SPJQQI.js";import{E as dl,I as Il,P as To,T as Ol,W as Nl,X as $l,Z as Io,_ as ni,ba as q,ca as Fe,d as yo,da as $t,fa as ht,h as wo,i as Br,j as Hr,k as Vr,l as nl,n as rl,o as il,p as sl,q as ol,s as al,t as cl,u as vo}from"./chunk-TE6FBDHP.js";import{A as p,C as f,D as nn,E as me,F as el,G as B,H as ee,L as Le,N as tl,a as Ld,m as Md,p as Fd,s as Dd,u as Pd,w as Ud,x as Pr,y as Rt}from"./chunk-K672XXGQ.js";var Hb=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."}),Vb=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),Yb=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),Xb=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),Jb=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),Qb=["--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"],Zb=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"]),eS=new Set(["--only-index"]),tS=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),nS=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),rS=new Set(["--regression"]);function iS(e,t){return t==="--stdin"||t==="--stdin-json"?["stdin"]:Xb.has(`${e}:${t}`)?["argv","file","stdin"]:t.endsWith("-file")?["argv","file"]:Vb.has(t)&&Yb.has(e)?["argv","stdin"]:["argv"]}function sS(e,t){let n=tS.has(`${e}:${t.flag}`)||t.value_name!==void 0||t.value_type==="string"||t.value_type==="number"||t.list===!0||t.repeatable===!0,r=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-"))||Qb.some(i=>t.flag.startsWith(i));return n||eS.has(t.flag)||!Zb.has(t.flag)&&!r}function oS(e,t){return t.value_arity!==void 0?t.value_arity:sS(e,t)?rS.has(t.flag)||nS.has(`${e}:${t.flag}`)?"optional":"required":"none"}function aS(e,t){let n=Ur(e),r=oS(n,t),i=r!=="none",s=iS(n,t.flag),o=t.description??Hb[t.flag]??`${i?"Set":"Enable"} ${t.flag.slice(2).replaceAll("-"," ")}.`;return{...t,description:o,takes_value:i,value_required:r==="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:s,...s.includes("stdin")&&t.flag!=="--stdin"&&t.flag!=="--stdin-json"?{stdin_token:"-"}:{},...Jb.has(`${n}:${t.flag}`)?{file_token_prefix:"@"}:{}}}function f_(e,t){return t.map(n=>aS(e,n))}function MF(e,t,n){let r=e.trim().toLowerCase(),i=[],s=new Map,o=0;for(let c of n)if(c.command.trim().toLowerCase()===r){if(o+=1,s.has(c.flag)){i.push({code:"duplicate_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} was observed more than once.`});continue}s.set(c.flag,c)}let a=new Set(t.map(({flag:c})=>c));for(let c of t){let d=s.get(c.flag);if(!d){i.push({code:"missing_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} has no executable option observation.`});continue}for(let[l,u]of[["takes_value","takes_value_mismatch"],["value_required","value_required_mismatch"],["repeatable","repeatable_mismatch"]])c[l]!==d[l]&&i.push({code:u,command:r,flag:c.flag,detail:`${r} ${c.flag} declares ${l}=${String(c[l])} but the executable option reports ${String(d[l])}.`})}for(let c of s.values())a.has(c.flag)||i.push({code:"undeclared_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} is executable but absent from invocation contracts.`});return i.sort((c,d)=>c.flag.localeCompare(d.flag)||c.code.localeCompare(d.code)),{ok:i.length===0,declared_count:t.length,observed_count:o,findings:i}}import{readFile as cS}from"node:fs/promises";function tD(e){let t={...e,...e.full===!0?{fullHistory:!0}:{}};return delete t.full,Ve(e,t)}function v_(e){return Object.prototype.toString.call(e)==="[object Object]"}function dS(e,t,n,r){let i=O();if(!v_(e))return{...r({created_at:i,author:n,text:t}),text:t,edited_at:i};let s=o=>typeof o=="string"&&o!=="";return{...e,...s(e.created_at)?{}:{created_at:i},...s(e.author)?{}:{author:n},text:t,edited_at:i}}function __(e,t){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new f(`Structured context events are append-only and cannot be ${t}.`,p.USAGE,{code:"structured_event_immutable"})}function lS(e,t){return t===void 0?e:t===0?[]:e.slice(Math.max(0,e.length-t))}function jt(e,t){let n=e[t];return Array.isArray(n)?n:[]}function nD(e,t={}){let n=e.trim();if(!n)return"";let r=/^(?:[-*+]\s*)?text\s*[:=]/i.exec(n);if(t.stripPlainTextPrefix===!0&&r&&!n.startsWith("```"))return n.slice(r[0].length).trim()||n;if(!(/^(?:[-*+]\s*)?text\s*[:=]/im.test(n)||n.startsWith("```")))return n;try{let s=_e(n,"--add");return Object.keys(s).map(c=>c.trim().toLowerCase()).some(c=>c!=="text")?n:s.text?.trim()||n}catch{return n}}function uS(e){return typeof e=="object"&&e!==null&&"code"in e}function h_(e,t){if(!It(e))throw new f(`${t} cannot read process stdin through the MCP JSON-RPC transport. Pass annotation text in options.add instead.`,p.USAGE,{code:"mcp_stdin_unavailable",required:"Pass annotation text as JSON data; the MCP protocol already owns process stdin."})}async function mS(e,t){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new f(`Specify ${t} text using only one input source: --add, --stdin, or --file`,p.USAGE);let r=Zd(),i=It(e);if(e.add!==void 0)return{value:await r.resolveValue(e.add,"--add",i)??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return h_(e,"--stdin"),{value:await r.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let s=e.file.trim();if(!s)throw new f("--file path cannot be empty",p.USAGE);if(s==="-")return h_(e,"--file -"),{value:await r.resolveValue("-","--file")??"",emptyFlag:"--file"};try{return{value:await cS(s,"utf8"),emptyFlag:"--file"}}catch(o){if(uS(o)&&el(o))throw new f(`--file path not found: ${s}. Use --file - to read stdin.`,p.USAGE);let a=o instanceof Error?o.message:String(o);throw new f(`Failed to read --file path "${s}": ${a}. Use --file - to read stdin.`,p.USAGE)}}async function rD(e,t){if(e.edit!==void 0&&e.delete!==void 0)throw new f("Specify only one of --edit or --delete",p.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new f("--delete cannot be combined with replacement text",p.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new f("--delete must be a positive integer",p.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new f("--edit must be a positive integer",p.USAGE);let n=await mS(e,t);if(e.edit!==void 0){if(!n)throw new f("--edit requires replacement text from --add, --stdin, or --file",p.USAGE);return{mode:"edit",index:e.edit,...n}}return n?{mode:"add",...n}:{mode:"list"}}function ar(e,t){throw e instanceof f&&e.exitCode===p.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new f(e.message,e.exitCode,{code:"ownership_conflict",required:t.required,examples:t.examples,nextSteps:t.nextSteps}):e}function k_(e){return e==="comments"?"--stdin":"--add -"}var iD="annotation_flag_like_value";function pS(e){return/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(e.trim())}function fS(e){return e==="--file"?"--file <path>":e.startsWith("--file=")?e:e==="--stdin"?"--stdin":void 0}function _S(e){let t=e.value.trim(),n=e.collectionKey.replace(/s$/,""),r=fS(t),i=k_(e.collectionKey),s=e.retryArgs===void 0?{}:{field:e.textFlag,recovery:{suggested_flags:[t],suggested_retry:L(e.retryArgs),suggested_retry_args:[...e.retryArgs]}};if(r!==void 0){let o=r.split(/[ =]/,1)[0],a=o==="--file"?"that file":"stdin",c=e.conflictingOperand===void 0?"":` "${e.conflictingOperand}" was read as positional text, which ${o} cannot be combined with: drop it, or pass it as the text without ${o}.`;return new f(`${e.textFlag} value "${t}" looks like an option, not annotation text: ${e.textFlag} took ${o} as its value. Drop ${e.textFlag} and pass ${r} on its own.${c}`,p.USAGE,{code:"annotation_flag_like_value",required:`Drop ${e.textFlag}: ${r} reads the ${n} text from ${a} by itself. Use ${e.textFlag} text=${t} only when the text really is "${t}".`,examples:[`${e.commandPrefix} ${r}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...s})}return new f(`${e.textFlag} value "${t}" looks like an option, not annotation text. Use ${i} to read stdin, or use text=${t} for literal dash-leading text.`,p.USAGE,{code:"annotation_flag_like_value",required:`Use ${i} for stdin input, pass plain text, or use text=${t} when the text really starts with "-".`,examples:[`${e.commandPrefix} ${i}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...s})}function hS(e,t){if(!((t.input.emptyFlag??"--add")!=="--add"||!pS(e)))throw _S({collectionKey:t.collectionKey,textFlag:"--add",value:e,commandPrefix:t.input.mode==="edit"?`pm ${t.collectionKey} <id> --edit <index>`:`pm ${t.collectionKey} <id>`})}function gS(e,t,n,r,i){if(n.input.mode!=="edit")return;let s=nu(t);if(s===void 0)return;let o=n.collectionKey.replace(/s$/,""),a=n.input.index,c=Ye(r)[0]==="--pm-path"?["--pm-path",i]:[];throw new f(`Replacement text for ${o} ${a} on ${e} ends with the read-output compaction marker, so it was copied from a compacted read that left out ${s} characters. Nothing was written.`,p.USAGE,{code:"annotation_text_compacted",item_id:e,details:{collection:n.collectionKey,entry_index:a,omitted_characters:s},required:`Read the whole ${o} with --output-budget unbounded, apply the change to the full text, and retry the edit without the trailing marker.`,why:"A budgeted read shortens long entries to a prefix plus a marker naming how many characters it left out; editing from that text would replace the stored entry with the shortened prefix.",examples:[L([...c,n.collectionKey,e,"--output-budget","unbounded","--json"]),`${L([...c,n.collectionKey,e,"--edit",String(a),"--file"])} <full-text-file>`]})}function yS(e,t){if(t.ifAbsent===!0&&!["add","stdin","file"].includes(e.input.mode))throw new f(`--if-absent requires a ${e.collectionKey.replace(/s$/,"")} append`,p.USAGE,{code:"annotation_if_absent_without_append",required:"Combine --if-absent with one append text source; omit it for list, edit, and delete operations."});if(wS(e,t),e.input.mode!=="list"||t.message===void 0)return;let n=e.collectionKey.replace(/s$/,"");throw new f(`--message labels a ${n} mutation but does not provide ${n} text. Pass text positionally or with --add, --stdin, or --file.`,p.USAGE,{code:"annotation_message_without_text",required:`Provide ${n} text through a content source; --message only annotates the history entry of a mutation.`,examples:[`pm ${e.collectionKey} <id> --add "text" --message "why"`,`pm ${e.collectionKey} <id> ${k_(e.collectionKey)}`]})}function wS(e,t){if(t.expectAt!==void 0){if(e.input.mode!=="edit"&&e.input.mode!=="delete")throw new f(`--expect-at guards an --edit or --delete of one ${e.collectionKey.replace(/s$/,"")}`,p.USAGE,{code:"annotation_expectation_without_target",required:"Combine --expect-at with --edit <index> or --delete <index>; omit it for list and append operations.",examples:[`pm ${e.collectionKey} <id> --edit <index> --expect-at <created_at> --add "<text>"`,`pm ${e.collectionKey} <id> --delete <index> --expect-at <created_at>`]});if(typeof t.expectAt!="string"||t.expectAt.trim().length===0)throw new f("--expect-at must be the non-empty created_at timestamp of the entry you read",p.USAGE,{code:"annotation_expectation_invalid",required:"Pass the created_at value of the row you read at that index, as a string."})}}function g_(e,t,n,r,i){if(i===void 0)return;let s=t[n]?.created_at,o=typeof s=="string"?s:null;if(o===i)return;let a=t.flatMap((m,_)=>m?.created_at===i?[_+1]:[]),c=r.collectionKey.replace(/s$/,""),d=r.input.mode==="delete"?"--delete":"--edit",l=n+1,u=a.length===1?` The ${c} created at ${i} is at index ${a[0]}.`:a.length>1?` ${a.length} ${r.collectionKey} were created at ${i}: indexes ${a.join(", ")}.`:` No ${c} on ${e} was created at ${i}.`;throw new f(`${c.charAt(0).toUpperCase()}${c.slice(1)} ${l} on ${e} was created at ${o||"an unrecorded time (malformed entry)"}, not ${i}; refusing ${d} of an entry the caller did not read. Nothing was written.${u}`,p.CONFLICT,{code:"annotation_entry_mismatch",item_id:e,details:{collection:r.collectionKey,entry_index:l,expected_created_at:i,actual_created_at:o,matching_indexes:a},required:`Address the ${c} by the index its listing row reports and keep --expect-at set to that row's created_at. When several indexes share the timestamp, inspect those rows before retrying, because the guard compares timestamps, not entry identities.`,why:"A listing page's position or count is not an entry address; only the row's index is, and the expectation checks that the entry at that index still carries the created_at that was read.",examples:[`pm ${r.collectionKey} ${e} --limit 5`,`pm ${r.collectionKey} ${e} ${d} ${a.length===1?a[0]:"<index>"} --expect-at ${i}${d==="--edit"?' --add "<text>"':""}`]})}function vS(e,t,n,r,i,s){let o=jt(e.metadata,t),a=i?o.findIndex(c=>v_(c)&&c.author===n&&c.text===r):-1;return a>=0?{changedFields:[],written:o,position:a}:(o.push(s({created_at:O(),author:n,text:r})),e.metadata[t]=o,{changedFields:[t],written:o,position:o.length-1})}function y_(e,t,n){return Gl.has(e)?t.map((i,s)=>s).sort((i,s)=>Kl(t[i],t[s])||i-s).indexOf(n)+1:n+1}async function sD(e,t,n,r){yS(r,t);let i=I(process.cwd(),n.path);await z(i);let s=await R(i),o=F(s,M()),a=Hn(t.limit);if(r.input.mode==="list"){let h=await V(i,e,s.id_prefix,s.item_format,o.type_to_folder);if(!h)throw new f(`Item ${e} not found`,p.NOT_FOUND);let g=await le(h,{schema:s.schema}),y=jt(g.document.metadata,r.collectionKey);return Ki(h.id,r.collectionKey,y,a,t.includeMeta===!0)}let c=H(t.author,s.author_default);if(r.input.mode==="delete"){let h=r.deleteOp??r.op,g;try{g=await Ie({pmRoot:i,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(w){let v=jt(w.metadata,r.collectionKey),k=w_(r.input.index,v.length,r.collectionKey);return g_(e,v,k,r,t.expectAt),__(v[k],"deleted"),v.splice(k,1),w.metadata[r.collectionKey]=v,{changedFields:[r.collectionKey]}}})}catch(w){ar(w,r.conflictGuidance)}let y=jt(g.item,r.collectionKey);return Ki(g.item.id,r.collectionKey,y,a,t.includeMeta===!0,{action:"delete",entryIndex:r.input.index},t.fullHistory===!0)}let d=r.input.rawValue??r.input.value??"";hS(d,r);let l=r.parseText(r.input.value??"");if(!l.trim())throw new f(`${r.input.emptyFlag??"--add"} text cannot be empty`,p.USAGE);if(gS(e,l,r,n,i),r.input.mode==="edit"){let h=r.editOp??r.op,g,y=0;try{g=await Ie({pmRoot:i,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(k){let b=jt(k.metadata,r.collectionKey),A=w_(r.input.index,b.length,r.collectionKey);g_(e,b,A,r,t.expectAt);let C=b[A];return __(C,"edited"),b[A]=dS(C,l,c,r.createEntry),y=y_(r.collectionKey,b,A),k.metadata[r.collectionKey]=b,{changedFields:[r.collectionKey]}}})}catch(k){ar(k,r.conflictGuidance)}let w=jt(g.item,r.collectionKey),v=y;return Ki(g.item.id,r.collectionKey,w,a,t.includeMeta===!0,{action:"edit",entryIndex:v,entry:w[v-1]},t.fullHistory===!0)}let u,m=0;try{u=await Ie({pmRoot:i,settings:s,id:e,op:r.op,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,skipNoop:t.ifAbsent===!0,mutate(h){let g=vS(h,r.collectionKey,c,l,t.ifAbsent===!0,r.createEntry);return m=y_(r.collectionKey,g.written,g.position),{changedFields:g.changedFields}}})}catch(h){ar(h,r.conflictGuidance)}let _=jt(u.item,r.collectionKey);return Ki(u.item.id,r.collectionKey,_,a,t.includeMeta===!0,{action:"add",entryIndex:m,entry:_[m-1],changedCount:t.ifAbsent===!0?Math.min(u.changedFields.length,1):void 0},t.fullHistory===!0)}function w_(e,t,n){if(e===void 0||!Number.isInteger(e)||e<1||e>t){let r=n.replace(/s$/,""),i=`${r.charAt(0).toUpperCase()}${r.slice(1)}`,s=t===1?`1 ${r}`:`${t} ${n}`;throw new f(`${i} index ${e??"(missing)"} out of range (item has ${s})`,p.USAGE)}return e-1}function kS(e,t,n){return t===void 0?{}:{mutation_receipt:{action:t.action,entry_index:t.entryIndex,changed_count:t.changedCount??1,full_history_included:!n},omission_receipt:{has_omissions:n,omitted_field_group_count:n?1:0,omitted_field_groups:n?[{name:`${e}_history`,restore_with:{selector:"full_history",cli_flag:"--full-history",sdk_option:"fullHistory",mcp_option:"full"}}]:[]}}}function b_(e,t){if(Object.prototype.toString.call(e)!=="[object Object]")return e;let n={index:t,...e};return n.index=t,n}function bS(e,t){let n=e.length-t.length;return t.map((r,i)=>b_(r,n+i+1))}function Ki(e,t,n,r,i,s,o=!1){let a=s===void 0||o?bS(n,lS(n,s!==void 0&&o?void 0:r)):s.entry===void 0?[]:[b_(s.entry,s.entryIndex)],c=s!==void 0&&a.length<n.length;return{id:e,[t]:a,count:a.length,...s?.changedCount===void 0?{}:{changed:s.changedCount===1},...[i,s!==void 0].includes(!0)?{total_count:n.length,returned_count:a.length,has_more:c||a.length<n.length,...r!==void 0?{limit:r}:{}}:{},...kS(t,s,c)}}import{isDeepStrictEqual as R_}from"node:util";var SS=new Set(["__proto__","prototype","constructor"]),cr=Symbol("looseOptionOccurrences");function it(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,r)=>r.toUpperCase())}function AS(e,t,n){let r=e[t];if(r===void 0){e[t]=n;return}if(Array.isArray(r)){r.push(n),e[t]=r;return}e[t]=[r,n]}function ga(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let o=n.indexOf("=");if(o>=0)return{consumed:1,key:n.slice(1,o).trim(),value:n.slice(o+1),attached:!0};let a=n.slice(1).trim(),c=e[t+1];return typeof c=="string"&&!c.startsWith("-")?{consumed:2,key:a,value:c}:{consumed:1,key:a,value:!0}}let r=n.indexOf("=");if(r>=0)return{consumed:1,key:n.slice(2,r).trim(),value:n.slice(r+1),attached:!0};if(n.startsWith("--no-"))return{consumed:1,key:n.slice(5).trim(),value:!1};let i=n.slice(2).trim(),s=e[t+1];return typeof s=="string"&&!s.startsWith("-")?{consumed:2,key:i,value:s}:{consumed:1,key:i,value:!0}}function Wi(e){return SS.has(e)}function Hi(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Rl(t)}function wn(e){let t=[],n=Nt(e.long)??"",r=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let i=it(n.slice(2));i.length>0&&!Wi(i)&&t.push(i)}if(r.startsWith("-")&&!r.startsWith("--")){let i=it(r.slice(1));i.length>0&&!Wi(i)&&t.push(i)}return[...new Set(t)]}function uD(e){let t=new Set;for(let n of e)for(let r of wn(n))t.add(r);return t}function qt(e){let t=Nt(e.long)??"";if(t.startsWith("--")){let n=it(t.slice(2));if(n.length>0&&!Wi(n))return n}return wn(e)[0]??null}function vn(e){let t=Nt(e.long)??"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function T_(e,t){return[...(t.definitions??e).map(r=>vn(r)).filter(r=>r!==null),...t.inheritedFlags??[]]}function mD(e,t,n,r={}){if(t.length===0)return;let i=new Set,s=new Map,o=[],a=T_(t,r);for(let c of t){let d=wn(c),l=vn(c);for(let u of d)i.add(u),c.enabled===!1&&s.set(u,l);c.required===!0&&c.enabled!==!1&&d.length>0&&o.push({keys:d,label:l,definition:c})}for(let c of Object.keys(e)){i.has(c)||I_(`--${c}`,`--${c}`,n,a);let d=s.get(c);d&&O_(d,n)}for(let c of o){let d=l=>Object.hasOwn(e,l)&&(c.definition.list!==!0||wa(c.definition,e[l]));c.keys.some(d)||N_(c.definition,c.keys[0],c.label,n)}}function I_(e,t,n,r){let i=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new f(`Unknown option '${e}' for extension command '${n}'.${i}`,p.USAGE,{code:"unknown_option",flag:t,required:`Use a flag the command accepts; run pm contracts --command ${n} --flags-only --json to list them.`})}function O_(e,t){throw new f(`Option '${e}' is disabled for extension command '${t}'.`,p.USAGE,{code:"extension_option_disabled",flag:e,required:`Remove ${e}; the command declares it with enabled: false.`,why:"A disabled declaration keeps the flag in the contract while refusing every value for it.",examples:[`pm ${t} --help`],nextSteps:[`Run pm contracts --command ${t} --flags-only --json to list the flags this command accepts.`]})}function N_(e,t,n,r){let i=on(e),s=i.value_arity==="none"?n:i.value_arity==="optional"?`${n} [${i.value_name}]`:`${n} <${i.value_name}>`;throw new f(`Missing required option '${n}' for extension command '${r}'.`,p.USAGE,{code:"missing_required_option",flag:n,field:t,required:`Pass ${s}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${r} ${s}`],nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[n]}})}function xS(e){return typeof e=="string"||e==null?e:String(e)}function CS(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function $_(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var ES={string:xS,number:CS,boolean:$_};function Gt(e,t){return Array.isArray(e)?e.map(n=>Gt(n,t)):ES[t](e)}function ya(e,t,n){let r=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(i=>i!=null&&i!==""):Ro(e);return t?r.map(i=>Gt(i,t)):r}function wa(e,t){return ya(t,null,e.repeatable===!0).length>0}function RS(e,t,n,r){return n?ya(e,t,r):t?Gt(e,t):e}function TS(e,t,n){let r=M_(e,t);return r.length===0?n:r.map(i=>i.value)}function L_(e){return on(e).value_arity==="none"}function va(e,t,n,r,i){let s=vn(e),o=i?` for extension command '${i}'`:"",a=n===!0?"no value":JSON.stringify(n);throw new f(`Option '${s}'${o} expects ${r}; received ${a}.`,p.USAGE,{code:"extension_flag_value_invalid",flag:s,required:`Pass ${s} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${s}.`,`Run pm ${i??"<command>"} --help to review the declared flag contract.`]})}function ka(e,t){return e.value_validation==="strict"&&t!=="string"}function M_(e,t){let n=e[cr];if(!n)return[];let r=new Set(t);return n.filter(i=>r.has(i.key))}function IS(e,t,n,r){if(L_(e))for(let i of M_(n,t)){if(i.attached!==!0)continue;let s=e.list===!0&&e.repeatable!==!0?Ro(i.value):[i.value];for(let o of s){let a=ei(Gt(o,"boolean"),"boolean");a!==null&&va(e,"boolean",o,a.expected,r)}}}function OS(e,t,n,r,i){let s=Array.isArray(n)?n.flat(1/0):[n],o=r?s:s.flatMap(a=>typeof a=="string"?a.split(","):[a]);for(let a of o)if(typeof a=="string"&&a.trim().length===0){let c=ei(a,t);va(e,t,a,c.expected,i)}}function ba(e,t,n,r){if(!ka(e,n))return t;let i=n==="boolean"&&L_(e),s=o=>{let a=ei(o,n);return a===null?o:i&&typeof o=="string"?!0:va(e,n,o,a.expected,r)};return Array.isArray(t)?t.map(s):s(t)}function NS(e,t,n,r){for(let i of n)if(!(i===t||!Object.hasOwn(e,i))){if(Object.hasOwn(e,t)){if(r){let s=e[t],o=e[i];e[t]=[...Array.isArray(s)?s:[s],...Array.isArray(o)?o:[o]].filter(a=>a!=null)}delete e[i];continue}e[t]=e[i],delete e[i]}}function F_(e,t,n=e,r){if(t.length===0)return e;let i=Object.create(null);for(let[o,a]of Object.entries(e))i[o]=a;let s=new Set(t.map(o=>qt(o)).filter(o=>o!==null));for(let o of t){let a=qt(o);if(a){let c=wn(o).filter(d=>d===a||!s.has(d));$S(i,o,a,c,n,r)}}return i}function $S(e,t,n,r,i,s){let o=t.list===!0,a=Hi(t);a&&!o&&LS(e,t,n,r,a,s),NS(e,n,r,o);let c=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=RS(t.default,a,o,c));return}if(a==="boolean"&&ka(t,a)&&IS(t,r,i,s),o){e[n]=MS(t,r,i,e[n],a,c,s);return}a&&(e[n]=ba(t,Gt(e[n],a),a,s))}function LS(e,t,n,r,i,s){for(let o of r)o!==n&&Object.hasOwn(e,o)&&ba(t,Gt(e[o],i),i,s)}function MS(e,t,n,r,i,s,o){let a=TS(n,t,r);i&&ka(e,i)&&OS(e,i,a,s,o);let c=ya(a,i,s);return i?ba(e,c,i,o):c}function pD(e){let t=Object.create(null),n=[];Object.defineProperty(t,cr,{value:n});let r=0;for(;r<e.length;){let i=ga(e,r);if(!i){r+=1;continue}let s=it(i.key);if(s.length===0||Wi(s)){r+=i.consumed;continue}AS(t,s,i.value),n.push({...i,key:s}),r+=i.consumed}return t}function fD(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let r=ga(e,n);if(r){n+=Math.max(1,r.consumed);continue}t.push(e[n]),n+=1}return t}function _D(e,t){if(t.length===0)return[...e];let n=new Set,r=new Set;for(let o of t){let a=Hi(o);for(let c of wn(o))n.add(c),a==="boolean"&&r.add(c)}if(n.size===0)return[...e];let i=[],s=0;for(;s<e.length;){if(e[s]==="--"){i.push(...e.slice(s+1));break}let o=ga(e,s);if(o){let a=it(o.key);if(n.has(a)){let c=e[s],d=r.has(a)&&!c.includes("=")?1:o.consumed;s+=d;continue}}i.push(e[s]),s+=1}return i}function Sa(e){return qt(e)}function S_(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t.length>0).join(" ")}function hD(e,t){let n=S_(t);if(n.length===0)return[];let r=P(n);return e.flags.filter(i=>P(S_(i.target_command))===r).flatMap(i=>[...i.flags])}function D_(e,t,n,r){let i=vn(e),[s,o]=n;throw new f(`Options '${s}' and '${o}' both set ${i} for extension command '${r}' with different values.`,p.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${i} once, under the handler key '${t}'.`,why:`'${s}' and '${o}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${s}' or '${o}' and pass one value as '${t}'.`,`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`]})}function gD(e,t,n,r={}){if(t.length===0)return e;let i=t.map(l=>l.repeatable===!0&&l.list!==!0?{...l,list:!0}:l),s=j_(i),o=jS(e,s,n),a=new Set([...s.long.values()].map(({handlerKey:l})=>l)),c=Object.create(null),d=Object.create(null);for(let[l,u]of Object.entries(o))a.has(l)?c[l]=u:u===void 0||r.undeclaredKeys==="pass"||DS(l)?d[l]=u:I_(l,PS(l),n,T_(i,{}));return U_(c,i,n),Object.assign(d,F_(c,i,P_(c,s),n))}function P_(e,t){let n=new Set([...t.long.values()].map(({handlerKey:s})=>s)),r=Object.entries(e).filter(([s])=>n.has(s)).flatMap(([s,o])=>(Array.isArray(o)?o.flat(1/0):[o]).map(a=>({consumed:1,key:s,value:a,attached:!0}))),i=Object.create(null);return Object.defineProperty(i,cr,{value:r}),i}function U_(e,t,n){for(let r of t){let i=qt(r);if(i===null)continue;let s=vn(r),o=e[i],a=Object.hasOwn(e,i);r.enabled===!1&&a&&O_(s,n);let c=a&&(r.list!==!0||wa(r,o));r.required===!0&&r.enabled!==!1&&!c&&N_(r,i,s,n),r.list!==!0&&Array.isArray(o)&&FS(s,n)}}function FS(e,t){throw new f(`Option '${e}' for extension command '${t}' takes one value; received an array.`,p.USAGE,{code:"extension_flag_value_invalid",flag:e,required:`Pass one value for ${e}, or ask the package to declare it with list: true or repeatable: true.`,why:"The flag is not declared list or repeatable, so pm refuses an array before the extension handler runs instead of handing it a value of the wrong shape.",nextSteps:[`Run pm contracts --command ${t} --flags-only --json to read each flag's value contract.`]})}var A_=new Set([...[...xl].filter(e=>e.startsWith("--")).flatMap(e=>{let t=e.replace(/^--/u,"");return[t,...t.startsWith("no-")?[t.slice(3)]:[]].flatMap(r=>[it(r),r.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function DS(e){return A_.has(e)||A_.has(it(e.replace(/^-{1,2}/u,"")))}function PS(e){return`--${e.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function j_(e){let t={long:new Map,short:new Map},n=(r,i,s)=>{i.length>0&&!r.has(i)&&r.set(i,s)};for(let r of e){let i=qt(r);if(i===null)continue;let s={handlerKey:i,definition:r};n(t.long,i,s);let o=typeof r.short=="string"?r.short.trim():"";o.startsWith("-")&&!o.startsWith("--")&&n(t.short,o.slice(1),s)}return t}function Bi(e,t){return e.long.get(t)??e.short.get(t.replace(/^-(?!-)/u,""))??e.long.get(it(t.replace(/^-{1,2}/u,"")))}function q_(e,t,n,r){let i=/^(?:--)?no-(.+)$/u.exec(t)?.[1];if(i===void 0||Bi(e,t)!==void 0)return{spelling:t,value:n};let s=Bi(e,i);return s===void 0||Hi(s.definition)!=="boolean"?{spelling:t,value:n}:(s.definition.list===!0||s.definition.repeatable===!0)&&Array.isArray(n)?{spelling:i,value:n.flat(1/0).map(o=>x_(t,s.definition,o,r))}:s.definition.list===!0&&n!==void 0?{spelling:i,value:x_(t,s.definition,n,r)}:{spelling:i,value:n===void 0?n:zi(t,s.definition,n,r)}}function yD(e,t,n){let r=j_(e);try{let i=q_(r,t,n,"");if(i.spelling===t)return;let s=Bi(r,i.spelling);return(s.definition.list===!0||s.definition.repeatable===!0)&&!wa(s.definition,i.value)?void 0:{key:s.handlerKey,value:i.value}}catch{return}}function x_(e,t,n,r){let i=s=>s.trim().length===0?s:String(zi(e,t,s.trim(),r));return n==null?n:typeof n!="string"?zi(e,t,n,r):n.trim().length===0?n:t.repeatable===!0||!n.includes(",")?zi(e,t,n,r):n.split(",").map(i).join(",")}function zi(e,t,n,r){let i=$_(n);return typeof i=="boolean"?!i:US(e,t,n,r)}function US(e,t,n,r){let i=vn(t);throw new f(`Option '${e}' for extension command '${r}' negates ${i} and expects true, false, 1, or 0; received ${JSON.stringify(n)}.`,p.USAGE,{code:"extension_flag_value_invalid",flag:i,required:`Pass ${i} as true or false, or '${e}' as true.`,why:`'${e}' is the negated spelling of the boolean ${i}, so only a boolean value can be inverted before the extension handler runs.`,nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's value contract.`]})}function jS(e,t,n){let r=Object.create(null),i=new Map;for(let[s,o]of Object.entries(e)){let{spelling:a,value:c}=q_(t,s,o,n),d=Bi(t,a);if(d===void 0)r[a]=c;else if(c!==void 0){let l=i.get(d.handlerKey);l===void 0?(i.set(d.handlerKey,a),r[d.handlerKey]=c):R_(C_(d.definition,d.handlerKey,r[d.handlerKey],t,n),C_(d.definition,d.handlerKey,c,t,n))||D_(d.definition,d.handlerKey,[l,a],n)}}return r}function C_(e,t,n,r,i){let s={[t]:n};return U_(s,[e],i),F_(s,[e],P_(s,r),i)[t]}function G_(e){let t=new Map;for(let n of e){let r=qt(n);if(r===null)continue;let i={definition:n,handlerKey:r,kind:Hi(n),arity:on(n).value_arity,scalar:n.list!==!0},s=[Nt(n.long),typeof n.short=="string"?n.short.trim():""];for(let o of s.filter(a=>a?.startsWith("-")===!0))t.has(o)||t.set(o,i)}return t}function K_(e,t,n,r=YS){let i=e.optionOf(n),s=t.get(n),o=s!==void 0&&r(s)?s:void 0;if(i!==void 0){let a={arity:i.arity,...i.variadic===!0?{variadic:!0}:{}};if(o?.handlerKey===i.key)return{...a,declared:o};if(s!==void 0)return a;let c=VS(t,n,i,r);return c===void 0?a:{...a,declared:c,negates:!0}}if(!(!e.includesLooseFlags||s===void 0))return o===void 0?{arity:s.arity,loose:!0}:{arity:s.arity,declared:o,loose:!0}}function Aa(e){return e.length>1&&e.startsWith("-")}var z_=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function W_(e,t,n){let{tokens:r}=e,i=0,s,o=!1,a=!1;for(;i<r.length||s!==void 0;){let c=s??r[i++];if(c==="--")return;if(a&&s===void 0&&qS(e,c))continue;let d=Aa(c)?KS(e,c,r[i],t,n):{consumedByCommander:!1,consumed:0};if(i+=d.consumed,s=d.group,a=d.variadic===!0,!d.consumedByCommander){if(GS(e.stop,c,o))return;o=!0}}}function qS(e,t){return!Aa(t)||e.negativeNumbersAreValues&&z_.test(t)}function GS(e,t,n){return e!==void 0&&(e.atFirstUnrecognized||!n&&e.atSubcommand(t))}function KS(e,t,n,r,i){let s=zS(t,n,r);if(s!==void 0)return i(s.spelling,s.entry,s.value,"loose"),{consumedByCommander:!1,consumed:s.consumed};let o=r(t);if(o!==void 0){let a=o.arity==="required"||o.arity==="optional"&&n!==void 0&&(!Aa(n)||e.negativeNumbersAreValues&&z_.test(n));return i(t,o,o.negates===!0?!1:a?n:!0,"commander"),{consumedByCommander:!0,consumed:a?1:0,variadic:o.variadic===!0}}return t[1]!=="-"?{consumed:0,...WS(t,r,i)}:{consumedByCommander:BS(t,r,i,e.includesLooseFlags?i:()=>{}),consumed:0}}function zS(e,t,n){let r=e.indexOf("="),i=r>1?e.slice(0,r):e,s=n(i);if(s?.loose===!0)return r>1?{spelling:i,entry:s,value:e.slice(r+1),consumed:0}:t!==void 0&&!t.startsWith("-")?{spelling:i,entry:s,value:t,consumed:1}:{spelling:i,entry:s,value:!0,consumed:0};let o=r<0&&e.startsWith("--no-")?n(`--${e.slice(5)}`):void 0;return o?.loose===!0&&o.declared?.kind==="boolean"?{spelling:e,entry:o,value:!1,consumed:0}:void 0}function WS(e,t,n){let r=e.slice(0,2),i=e.length>2?t(r):void 0;return i===void 0||i.loose===!0?{consumedByCommander:!1}:i.arity!=="none"?(n(r,i,e.slice(2),"commander"),{consumedByCommander:!0}):(n(r,i,!0,"commander"),{consumedByCommander:!0,group:`-${e.slice(2)}`})}function BS(e,t,n,r){let i=e.indexOf("=");if(i>2){let o=e.slice(0,i),a=t(o);return a!==void 0&&a.arity!=="none"?(n(o,a,e.slice(i+1),"commander"),!0):(a?.declared?.kind==="boolean"&&r(o,a,e.slice(i+1),"loose"),!1)}let s=e.startsWith("--no-")?t(`--${e.slice(5)}`):void 0;return s?.declared?.kind==="boolean"&&r(e,s,!1,"loose"),!1}function wD(e,t,n){let r=G_(t),i=new Map;for(let s of e)W_(s,o=>K_(s,r,o),(o,a,c)=>{a.declared!==void 0&&HS(i,a.declared,o,c,n)})}function HS(e,t,n,r,i){let{definition:s,handlerKey:o,kind:a}=t,c=a?Gt(r,a):r,d=e.get(o)??new Map,l=[...d].find(([u,m])=>u!==n&&!R_(m,c));l!==void 0&&D_(s,o,[l[0],n],i),d.set(n,c),e.set(o,d)}function VS(e,t,n,r){let i=t.startsWith("--no-")?e.get(`--${t.slice(5)}`):void 0;return i!==void 0&&r(i)&&i.kind==="boolean"&&i.handlerKey===n.key?i:void 0}function YS(e){return e.scalar}function E_(e){return!e.scalar&&e.kind==="boolean"&&e.arity==="none"}function vD(e,t,n){let r=G_(n),i=[...new Set(r.values())].filter(E_);if(i.length===0)return e;let s=new Set(n.map(m=>qt(m)).filter(m=>m!==null)),o=m=>wn(m.definition).filter(_=>_===m.handlerKey||!s.has(_)),a=new Map([...i].reverse().flatMap(m=>o(m).map(_=>[_,m]))),c=new Map;for(let m of t)W_(m,_=>K_(m,r,_,E_)??XS(m,a,_),(_,h,g,y)=>{if(h.declared===void 0)return;let w=c.get(h.declared)??[];w.push(y==="commander"?{value:g}:null),c.set(h.declared,w)});let d=[...c].filter(([,m])=>m.some(_=>_!==null));if(d.length===0)return e;let l=e[cr]??[];for(let[m,_]of d){let h=new Set(o(m)),g=l.filter(({key:k})=>h.has(k));if(g.length===0)continue;let y=k=>({consumed:0,key:m.handlerKey,value:k.value}),w=0,v=_.filter(k=>k===null).length===g.length?_.map(k=>k===null?g[w++]:y(k)):[...g,..._.filter(k=>k!==null).map(y)];l=[...l.filter(({key:k})=>!h.has(k)),...v]}let u=Object.assign(Object.create(null),e);return Object.defineProperty(u,cr,{value:l}),u}function XS(e,t,n){let r=!n.startsWith("--")&&e.optionOf(n.slice(0,2))!==void 0;if(!e.includesLooseFlags||r)return;let i=t.get(it(n.replace(/^-+/u,"")));return i===void 0?void 0:{arity:i.arity,declared:i,loose:!0}}var JS=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),QS=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"]),ZS=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"])}),eA=new Set(["extension","install","package","packages","upgrade"]);function tA(e){let t=P(e.trim().toLowerCase());if(t==="ops")return"quality";for(let[n,r]of Object.entries(ZS))if(r.has(t))return n;return eA.has(t)?"extensions":"internal"}var kn=Object.freeze([...We.flatMap(e=>e==="item"?["item","item-reopen"]:[e,...ze.filter(t=>t.alias===e).map(t=>t.canonical)]).map(e=>({command:e,tier:JS.has(P(e))?"core":QS.has(P(e))?"standard":"full",family:tA(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"}]),nA=kn,B_=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),AD=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"]);function xD(e){let t=e===""?0:e.split(/\r?\n/).length,n=Buffer.byteLength(e,"utf8");return{lines:t,utf8_bytes:n,within_budget:t<=B_.max_lines&&n<=B_.max_utf8_bytes}}var H_={core:0,standard:1,full:2,internal:3},V_=new Map(nA.map(({command:e,tier:t})=>[e,t]));function xa(e,t="standard"){return V_.get(e.trim().toLowerCase())??V_.get(P(e.trim().toLowerCase()))??t}function CD(e){return Y_(e,kn)}function Y_(e,t){let n=H_[e];return t.filter(r=>r.tier!=="internal"&&H_[r.tier]<=n).map(r=>r.command)}function ED(e){return X_(e,kn)}function X_(e,t){return t.filter(n=>n.family===e).map(n=>n.command)}var rA=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],iA=new Set([...Tt.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 RD(e=kn){return rA.map(t=>({family:t,commands:X_(t,e).filter(n=>e.find(r=>r.command===n)?.tier!=="internal"&&!iA.has(n))})).filter(({commands:t})=>t.length>0)}var sA=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"});function TD(e,t){return oA(e,t,kn)}function oA(e,t,n){if(t==="full")return[...e];let r=new Set(Y_(t,n));return e.filter(i=>{let s=sA[i];return s!==void 0&&r.has(s)})}var ID=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"}]),OD=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."}]);function ND(){return aA(kn)}function aA(e){return["# Generated agent command surface","","This file is generated from `PM_COMMAND_CAPABILITY_CONTRACTS`. Do not edit it manually.","","| Command | Minimum visibility tier | Capability family |","| --- | --- | --- |",...e.map(({command:n,tier:r,family:i})=>`| \`${n}\` | ${r} | ${i} |`),""].join(`
1
+ import{A as mn,B as ie,D as Fi,G as Di,H as Cf,Ha as jf,Ia as qf,J as oa,Ja as sr,K as Ef,Ka as ua,M as Rf,Na as Gf,Oc as a_,Rc as c_,U as Tf,_a as or,bb as gn,eb as yn,l as Sf,lb as ji,o as Af,oa as Pf,p as nr,pa as Uf,pb as i_,qb as s_,s as xf,wb as o_,y as rr,yb as ha,z as ir}from"./chunk-ZL6J6JYT.js";import{a as Xo,d as Jo,e as Jp,f as Qo,g as Qp}from"./chunk-X5D5YUHR.js";import{a as Kf}from"./chunk-4QA5O64H.js";import{J as bf,a as Oi,b as Qn,c as Ni,d as ke,e as $i,f as yf,g as wf,h as Li,i as Zn,j as vf,k as kf,l as ra,m as ia,n as er,r as tr,t as Mi,u as X,y as sa}from"./chunk-L2ZSSMYY.js";import{C as Hf,E as Gi,F as Vf,G as Yf,H as ma,I as pa,N as Xf,O as Jf,P as Qf,Q as Zf,R as e_,S as fa,T as _a,U as t_,V as n_,W as r_,Z as d_,a as Mf,aa as l_,da as u_,ia as m_,ja as p_,m as hn,q as Ff,r as Df,t as Pi,u as Ui,v as zf,w as Wf,x as Bf,z as qi}from"./chunk-GOEQXVOI.js";import{Aa as Lf,j as Zp,oa as ca,pa as Nf,qa as da,ra as la,u as Of,va as $f}from"./chunk-7V65VACG.js";import{a as Yp,l as aa}from"./chunk-3HKPVOAN.js";import{i as bt,k as pn,l as fn,m as _n}from"./chunk-Q6K7HWZ7.js";import{c as If}from"./chunk-OGVSGXQX.js";import{N as lf,O as Ti,P as uf,Q as ta,S as mf,T as pf,V as ff,W as _f,X as Ii,Y as hf,a as ef,b as tf,c as nf,ca as na,d as rf,f as sf,ga as gf,j as Zo,k as of,l as af,m as ea,n as cf,o as df}from"./chunk-C6WM6ZN4.js";import{a as Gp,e as zp,k as Wp,s as Bp,t as Jn,u as Hp,x as Vp}from"./chunk-QDV7S2QS.js";import{$b as Vn,A as Zd,Ad as Kp,B as Re,C as Wr,E as bl,H as Sl,Ha as Si,J as Al,Jb as Hu,Ka as ln,La as Nu,Ma as $u,Na as Du,Nc as Po,Ob as Vu,Oc as Uo,Pc as jo,Qb as Yu,Qc as qo,R as ti,Tb as Do,U as Eu,Ua as Pu,Vb as Xu,Xb as Ju,Yb as yt,Zb as Qu,_b as wt,ab as Uu,ac as Pt,c as Be,ca as gi,cc as Zu,e as He,eb as qu,f as tn,fb as Gu,fd as nm,g as ho,ga as De,h as Xd,ha as Tu,i as jr,ib as Ku,j as qr,ja as yi,jb as Ai,k as Jd,ka as Iu,kb as zu,l as Gr,la as wi,lc as em,m as Qd,ma as vi,mb as V,na as ki,nb as le,nd as rm,o as _e,p as Kr,pb as xi,pc as tm,q as go,qb as he,r as $e,ra as bi,rb as rt,sb as Wu,sd as im,tb as Dt,td as sm,ua as Ou,ud as Ci,v as Ve,vb as un,vd as om,wb as Ie,x as It,xa as Hn,yb as Fo,z as zr,zb as Bu,zd as Ri}from"./chunk-CBUC4X7Q.js";import{B as ju,H as z,a as Ft,b as Ru,e as cn,f as dn,j as Lu,t as Mu,u as R,v as Fu}from"./chunk-OXC5KBIQ.js";import{A as _o,Aa as si,Bb as Zl,Da as oi,Df as _u,Ea as re,Ec as ru,Ed as ou,Eg as _i,Fa as Lt,Fd as au,Ff as hu,Ga as ae,Gg as hi,Ha as $o,Hb as ui,Hf as Bn,Ia as Lo,Ib as H,Ja as jl,Jf as gu,La as ai,Ld as cu,Mf as yu,Na as ql,Nb as Mt,O as Ao,Oa as an,Pa as Gl,Pg as vu,Q as Ye,Qa as Kl,Qe as lu,Sa as zl,T as Nt,Ua as ci,Ub as eu,Va as Wl,Wa as Bl,X as te,Xg as M,Yc as iu,_ as Zr,a as jd,ab as Hl,ad as su,bb as Vl,cb as Yl,cg as gt,ch as ku,db as Xl,dg as pi,dh as bu,eb as Jl,fa as Rl,fb as di,fd as Mo,fg as fi,ga as on,gb as li,gh as nt,ha as Ro,hf as uu,ia as ei,if as mu,jf as mi,jh as Su,kh as Te,l as qd,lg as wu,m as Gd,mh as Au,n as Kd,nb as Ql,nh as xu,o as zd,oa as Tl,of as pu,oh as Cu,p as Wd,q as Bd,qb as zn,r as We,rb as Wn,s as Hd,se as du,tf as fu,vc as tu,wc as nu,xa as ii,y as Vd,ya as Kn,z as Yd}from"./chunk-NRQCBUYD.js";import{A as pl,B as fl,C as _l,D as hl,E as gl,F as yl,b as ko,c as jn,d as ve,g as F,h as et,i as Yr,j as rn,k as qn,l as Gn,o as I,p as _t,q as tt,r as sn,s as ll,t as ul,u as Me,v as Xr,x as ml,y as bo,z as So}from"./chunk-GSLOAEY2.js";import{g as Xp}from"./chunk-WSEIEDEK.js";import{$ as $m,$a as Cp,Aa as np,Ba as rp,C as zo,Ca as ip,D as Wo,Da as sp,Ea as op,F as vt,Fa as ap,G as pm,Ga as cp,H as fm,Ha as dp,I as _m,Ia as lp,J as hm,Ja as up,K as Ei,L as gm,M as ym,N as wm,Na as mp,O as vm,Oa as pp,P as km,Pa as fp,Q as bm,Qa as _p,R as Sm,Ra as hp,S as Am,Sa as gp,T as xm,Ta as yp,U as Cm,Ua as wp,V as Em,Va as vp,W as Rm,Wa as kp,X as Tm,Xa as bp,Y as Im,Ya as Sp,Z as Om,Za as Ap,_ as Nm,_a as xp,aa as Lm,ab as Ep,ba as Mm,bb as Rp,c as am,ca as Fm,cb as Tp,d as cm,da as Dm,db as Vo,e as dm,ea as Pm,eb as Ip,fb as Op,ga as Um,gb as Yo,ha as Bo,hb as Np,ia as jm,ib as $p,ja as qm,jb as Lp,ka as Gm,kb as Mp,la as Km,lb as Fp,ma as Yn,mb as kt,na as zm,nb as Dp,oa as Wm,ob as Pp,p as Go,pa as Bm,pb as Up,q as lm,qa as Hm,qb as jp,ra as Vm,sa as Ym,sb as qp,t as um,ta as Xm,u as Ko,ua as Jm,v as Ut,va as Qm,vb as Xn,wa as Zm,x as mm,xa as ep,ya as Ho,za as tp}from"./chunk-A5ZEMOVR.js";import{$ as Oo,A as Ot,B as xo,C as wl,D as Qr,E as vl,F as Co,I as kl,K as xl,Q as O,S as Eo,T as Cl,U as El,W as se,_ as Ll,a as Z,aa as Ml,b as Un,ba as No,ca as Fl,da as ri,fa as Dl,ga as Pl,ha as Ul,i as ze,k as P,l as Ur,m as Tt,v as Jr,x as L}from"./chunk-I4SPJQQI.js";import{E as dl,I as Il,P as To,T as Ol,W as Nl,X as $l,Z as Io,_ as ni,ba as q,ca as Fe,d as yo,da as $t,fa as ht,h as wo,i as Br,j as Hr,k as Vr,l as nl,n as rl,o as il,p as sl,q as ol,s as al,t as cl,u as vo}from"./chunk-TE6FBDHP.js";import{A as p,C as f,D as nn,E as me,F as el,G as B,H as ee,L as Le,N as tl,a as Ld,m as Md,p as Fd,s as Dd,u as Pd,w as Ud,x as Pr,y as Rt}from"./chunk-K672XXGQ.js";var Hb=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."}),Vb=new Set(["--add","--body","--comment","--dep","--dep-remove","--description","--doc","--event","--field","--file","--learning","--note","--remove","--reminder","--test","--type-option"]),Yb=new Set(["append","comments","create","docs","files","learnings","notes","test","update","update-many"]),Xb=new Set(["close-many:--ids","comments:--file","create:--body-file","history-compact:--ids","learnings:--file","notes:--file","update:--body-file","update-many:--ids"]),Jb=new Set(["close-many:--ids","history-compact:--ids","update-many:--ids"]),Qb=["--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"],Zb=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"]),eS=new Set(["--only-index"]),tS=new Set(["activity:--stream","eval:--fail-under","validate:--fix-scope"]),nS=new Set(["activity:--stream","close:--validate-close","close-many:--validate-close","comments:--author","learnings:--author","notes:--author"]),rS=new Set(["--regression"]);function iS(e,t){return t==="--stdin"||t==="--stdin-json"?["stdin"]:Xb.has(`${e}:${t}`)?["argv","file","stdin"]:t.endsWith("-file")?["argv","file"]:Vb.has(t)&&Yb.has(e)?["argv","stdin"]:["argv"]}function sS(e,t){let n=tS.has(`${e}:${t.flag}`)||t.value_name!==void 0||t.value_type==="string"||t.value_type==="number"||t.list===!0||t.repeatable===!0,r=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-"))||Qb.some(i=>t.flag.startsWith(i));return n||eS.has(t.flag)||!Zb.has(t.flag)&&!r}function oS(e,t){return t.value_arity!==void 0?t.value_arity:sS(e,t)?rS.has(t.flag)||nS.has(`${e}:${t.flag}`)?"optional":"required":"none"}function aS(e,t){let n=Ur(e),r=oS(n,t),i=r!=="none",s=iS(n,t.flag),o=t.description??Hb[t.flag]??`${i?"Set":"Enable"} ${t.flag.slice(2).replaceAll("-"," ")}.`;return{...t,description:o,takes_value:i,value_required:r==="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:s,...s.includes("stdin")&&t.flag!=="--stdin"&&t.flag!=="--stdin-json"?{stdin_token:"-"}:{},...Jb.has(`${n}:${t.flag}`)?{file_token_prefix:"@"}:{}}}function f_(e,t){return t.map(n=>aS(e,n))}function MF(e,t,n){let r=e.trim().toLowerCase(),i=[],s=new Map,o=0;for(let c of n)if(c.command.trim().toLowerCase()===r){if(o+=1,s.has(c.flag)){i.push({code:"duplicate_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} was observed more than once.`});continue}s.set(c.flag,c)}let a=new Set(t.map(({flag:c})=>c));for(let c of t){let d=s.get(c.flag);if(!d){i.push({code:"missing_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} has no executable option observation.`});continue}for(let[l,u]of[["takes_value","takes_value_mismatch"],["value_required","value_required_mismatch"],["repeatable","repeatable_mismatch"]])c[l]!==d[l]&&i.push({code:u,command:r,flag:c.flag,detail:`${r} ${c.flag} declares ${l}=${String(c[l])} but the executable option reports ${String(d[l])}.`})}for(let c of s.values())a.has(c.flag)||i.push({code:"undeclared_observation",command:r,flag:c.flag,detail:`${r} ${c.flag} is executable but absent from invocation contracts.`});return i.sort((c,d)=>c.flag.localeCompare(d.flag)||c.code.localeCompare(d.code)),{ok:i.length===0,declared_count:t.length,observed_count:o,findings:i}}import{readFile as cS}from"node:fs/promises";function tD(e){let t={...e,...e.full===!0?{fullHistory:!0}:{}};return delete t.full,Ve(e,t)}function v_(e){return Object.prototype.toString.call(e)==="[object Object]"}function dS(e,t,n,r){let i=O();if(!v_(e))return{...r({created_at:i,author:n,text:t}),text:t,edited_at:i};let s=o=>typeof o=="string"&&o!=="";return{...e,...s(e.created_at)?{}:{created_at:i},...s(e.author)?{}:{author:n},text:t,edited_at:i}}function __(e,t){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new f(`Structured context events are append-only and cannot be ${t}.`,p.USAGE,{code:"structured_event_immutable"})}function lS(e,t){return t===void 0?e:t===0?[]:e.slice(Math.max(0,e.length-t))}function jt(e,t){let n=e[t];return Array.isArray(n)?n:[]}function nD(e,t={}){let n=e.trim();if(!n)return"";let r=/^(?:[-*+]\s*)?text\s*[:=]/i.exec(n);if(t.stripPlainTextPrefix===!0&&r&&!n.startsWith("```"))return n.slice(r[0].length).trim()||n;if(!(/^(?:[-*+]\s*)?text\s*[:=]/im.test(n)||n.startsWith("```")))return n;try{let s=_e(n,"--add");return Object.keys(s).map(c=>c.trim().toLowerCase()).some(c=>c!=="text")?n:s.text?.trim()||n}catch{return n}}function uS(e){return typeof e=="object"&&e!==null&&"code"in e}function h_(e,t){if(!It(e))throw new f(`${t} cannot read process stdin through the MCP JSON-RPC transport. Pass annotation text in options.add instead.`,p.USAGE,{code:"mcp_stdin_unavailable",required:"Pass annotation text as JSON data; the MCP protocol already owns process stdin."})}async function mS(e,t){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new f(`Specify ${t} text using only one input source: --add, --stdin, or --file`,p.USAGE);let r=Zd(),i=It(e);if(e.add!==void 0)return{value:await r.resolveValue(e.add,"--add",i)??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return h_(e,"--stdin"),{value:await r.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let s=e.file.trim();if(!s)throw new f("--file path cannot be empty",p.USAGE);if(s==="-")return h_(e,"--file -"),{value:await r.resolveValue("-","--file")??"",emptyFlag:"--file"};try{return{value:await cS(s,"utf8"),emptyFlag:"--file"}}catch(o){if(uS(o)&&el(o))throw new f(`--file path not found: ${s}. Use --file - to read stdin.`,p.USAGE);let a=o instanceof Error?o.message:String(o);throw new f(`Failed to read --file path "${s}": ${a}. Use --file - to read stdin.`,p.USAGE)}}async function rD(e,t){if(e.edit!==void 0&&e.delete!==void 0)throw new f("Specify only one of --edit or --delete",p.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new f("--delete cannot be combined with replacement text",p.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new f("--delete must be a positive integer",p.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new f("--edit must be a positive integer",p.USAGE);let n=await mS(e,t);if(e.edit!==void 0){if(!n)throw new f("--edit requires replacement text from --add, --stdin, or --file",p.USAGE);return{mode:"edit",index:e.edit,...n}}return n?{mode:"add",...n}:{mode:"list"}}function ar(e,t){throw e instanceof f&&e.exitCode===p.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new f(e.message,e.exitCode,{code:"ownership_conflict",required:t.required,examples:t.examples,nextSteps:t.nextSteps}):e}function k_(e){return e==="comments"?"--stdin":"--add -"}var iD="annotation_flag_like_value";function pS(e){return/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(e.trim())}function fS(e){return e==="--file"?"--file <path>":e.startsWith("--file=")?e:e==="--stdin"?"--stdin":void 0}function _S(e){let t=e.value.trim(),n=e.collectionKey.replace(/s$/,""),r=fS(t),i=k_(e.collectionKey),s=e.retryArgs===void 0?{}:{field:e.textFlag,recovery:{suggested_flags:[t],suggested_retry:L(e.retryArgs),suggested_retry_args:[...e.retryArgs]}};if(r!==void 0){let o=r.split(/[ =]/,1)[0],a=o==="--file"?"that file":"stdin",c=e.conflictingOperand===void 0?"":` "${e.conflictingOperand}" was read as positional text, which ${o} cannot be combined with: drop it, or pass it as the text without ${o}.`;return new f(`${e.textFlag} value "${t}" looks like an option, not annotation text: ${e.textFlag} took ${o} as its value. Drop ${e.textFlag} and pass ${r} on its own.${c}`,p.USAGE,{code:"annotation_flag_like_value",required:`Drop ${e.textFlag}: ${r} reads the ${n} text from ${a} by itself. Use ${e.textFlag} text=${t} only when the text really is "${t}".`,examples:[`${e.commandPrefix} ${r}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...s})}return new f(`${e.textFlag} value "${t}" looks like an option, not annotation text. Use ${i} to read stdin, or use text=${t} for literal dash-leading text.`,p.USAGE,{code:"annotation_flag_like_value",required:`Use ${i} for stdin input, pass plain text, or use text=${t} when the text really starts with "-".`,examples:[`${e.commandPrefix} ${i}`,`${e.commandPrefix} ${e.textFlag} text=${t}`],...s})}function hS(e,t){if(!((t.input.emptyFlag??"--add")!=="--add"||!pS(e)))throw _S({collectionKey:t.collectionKey,textFlag:"--add",value:e,commandPrefix:t.input.mode==="edit"?`pm ${t.collectionKey} <id> --edit <index>`:`pm ${t.collectionKey} <id>`})}function gS(e,t,n,r,i){if(n.input.mode!=="edit")return;let s=nu(t);if(s===void 0)return;let o=n.collectionKey.replace(/s$/,""),a=n.input.index,c=Ye(r)[0]==="--pm-path"?["--pm-path",i]:[];throw new f(`Replacement text for ${o} ${a} on ${e} ends with the read-output compaction marker, so it was copied from a compacted read that left out ${s} characters. Nothing was written.`,p.USAGE,{code:"annotation_text_compacted",item_id:e,details:{collection:n.collectionKey,entry_index:a,omitted_characters:s},required:`Read the whole ${o} with --output-budget unbounded, apply the change to the full text, and retry the edit without the trailing marker.`,why:"A budgeted read shortens long entries to a prefix plus a marker naming how many characters it left out; editing from that text would replace the stored entry with the shortened prefix.",examples:[L([...c,n.collectionKey,e,"--output-budget","unbounded","--json"]),`${L([...c,n.collectionKey,e,"--edit",String(a),"--file"])} <full-text-file>`]})}function yS(e,t){if(t.ifAbsent===!0&&!["add","stdin","file"].includes(e.input.mode))throw new f(`--if-absent requires a ${e.collectionKey.replace(/s$/,"")} append`,p.USAGE,{code:"annotation_if_absent_without_append",required:"Combine --if-absent with one append text source; omit it for list, edit, and delete operations."});if(wS(e,t),e.input.mode!=="list"||t.message===void 0)return;let n=e.collectionKey.replace(/s$/,"");throw new f(`--message labels a ${n} mutation but does not provide ${n} text. Pass text positionally or with --add, --stdin, or --file.`,p.USAGE,{code:"annotation_message_without_text",required:`Provide ${n} text through a content source; --message only annotates the history entry of a mutation.`,examples:[`pm ${e.collectionKey} <id> --add "text" --message "why"`,`pm ${e.collectionKey} <id> ${k_(e.collectionKey)}`]})}function wS(e,t){if(t.expectAt!==void 0){if(e.input.mode!=="edit"&&e.input.mode!=="delete")throw new f(`--expect-at guards an --edit or --delete of one ${e.collectionKey.replace(/s$/,"")}`,p.USAGE,{code:"annotation_expectation_without_target",required:"Combine --expect-at with --edit <index> or --delete <index>; omit it for list and append operations.",examples:[`pm ${e.collectionKey} <id> --edit <index> --expect-at <created_at> --add "<text>"`,`pm ${e.collectionKey} <id> --delete <index> --expect-at <created_at>`]});if(typeof t.expectAt!="string"||t.expectAt.trim().length===0)throw new f("--expect-at must be the non-empty created_at timestamp of the entry you read",p.USAGE,{code:"annotation_expectation_invalid",required:"Pass the created_at value of the row you read at that index, as a string."})}}function g_(e,t,n,r,i){if(i===void 0)return;let s=t[n]?.created_at,o=typeof s=="string"?s:null;if(o===i)return;let a=t.flatMap((m,_)=>m?.created_at===i?[_+1]:[]),c=r.collectionKey.replace(/s$/,""),d=r.input.mode==="delete"?"--delete":"--edit",l=n+1,u=a.length===1?` The ${c} created at ${i} is at index ${a[0]}.`:a.length>1?` ${a.length} ${r.collectionKey} were created at ${i}: indexes ${a.join(", ")}.`:` No ${c} on ${e} was created at ${i}.`;throw new f(`${c.charAt(0).toUpperCase()}${c.slice(1)} ${l} on ${e} was created at ${o||"an unrecorded time (malformed entry)"}, not ${i}; refusing ${d} of an entry the caller did not read. Nothing was written.${u}`,p.CONFLICT,{code:"annotation_entry_mismatch",item_id:e,details:{collection:r.collectionKey,entry_index:l,expected_created_at:i,actual_created_at:o,matching_indexes:a},required:`Address the ${c} by the index its listing row reports and keep --expect-at set to that row's created_at. When several indexes share the timestamp, inspect those rows before retrying, because the guard compares timestamps, not entry identities.`,why:"A listing page's position or count is not an entry address; only the row's index is, and the expectation checks that the entry at that index still carries the created_at that was read.",examples:[`pm ${r.collectionKey} ${e} --limit 5`,`pm ${r.collectionKey} ${e} ${d} ${a.length===1?a[0]:"<index>"} --expect-at ${i}${d==="--edit"?' --add "<text>"':""}`]})}function vS(e,t,n,r,i,s){let o=jt(e.metadata,t),a=i?o.findIndex(c=>v_(c)&&c.author===n&&c.text===r):-1;return a>=0?{changedFields:[],written:o,position:a}:(o.push(s({created_at:O(),author:n,text:r})),e.metadata[t]=o,{changedFields:[t],written:o,position:o.length-1})}function y_(e,t,n){return Gl.has(e)?t.map((i,s)=>s).sort((i,s)=>Kl(t[i],t[s])||i-s).indexOf(n)+1:n+1}async function sD(e,t,n,r){yS(r,t);let i=I(process.cwd(),n.path);await z(i);let s=await R(i),o=F(s,M()),a=Hn(t.limit);if(r.input.mode==="list"){let h=await V(i,e,s.id_prefix,s.item_format,o.type_to_folder);if(!h)throw new f(`Item ${e} not found`,p.NOT_FOUND);let g=await le(h,{schema:s.schema}),y=jt(g.document.metadata,r.collectionKey);return Ki(h.id,r.collectionKey,y,a,t.includeMeta===!0)}let c=H(t.author,s.author_default);if(r.input.mode==="delete"){let h=r.deleteOp??r.op,g;try{g=await Ie({pmRoot:i,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(w){let v=jt(w.metadata,r.collectionKey),k=w_(r.input.index,v.length,r.collectionKey);return g_(e,v,k,r,t.expectAt),__(v[k],"deleted"),v.splice(k,1),w.metadata[r.collectionKey]=v,{changedFields:[r.collectionKey]}}})}catch(w){ar(w,r.conflictGuidance)}let y=jt(g.item,r.collectionKey);return Ki(g.item.id,r.collectionKey,y,a,t.includeMeta===!0,{action:"delete",entryIndex:r.input.index},t.fullHistory===!0)}let d=r.input.rawValue??r.input.value??"";hS(d,r);let l=r.parseText(r.input.value??"");if(!l.trim())throw new f(`${r.input.emptyFlag??"--add"} text cannot be empty`,p.USAGE);if(gS(e,l,r,n,i),r.input.mode==="edit"){let h=r.editOp??r.op,g,y=0;try{g=await Ie({pmRoot:i,settings:s,id:e,op:h,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,mutate(k){let b=jt(k.metadata,r.collectionKey),A=w_(r.input.index,b.length,r.collectionKey);g_(e,b,A,r,t.expectAt);let C=b[A];return __(C,"edited"),b[A]=dS(C,l,c,r.createEntry),y=y_(r.collectionKey,b,A),k.metadata[r.collectionKey]=b,{changedFields:[r.collectionKey]}}})}catch(k){ar(k,r.conflictGuidance)}let w=jt(g.item,r.collectionKey),v=y;return Ki(g.item.id,r.collectionKey,w,a,t.includeMeta===!0,{action:"edit",entryIndex:v,entry:w[v-1]},t.fullHistory===!0)}let u,m=0;try{u=await Ie({pmRoot:i,settings:s,id:e,op:r.op,author:c,message:t.message,force:t.force,bypassAssigneeConflict:r.bypassOwnershipConflict,skipNoop:t.ifAbsent===!0,mutate(h){let g=vS(h,r.collectionKey,c,l,t.ifAbsent===!0,r.createEntry);return m=y_(r.collectionKey,g.written,g.position),{changedFields:g.changedFields}}})}catch(h){ar(h,r.conflictGuidance)}let _=jt(u.item,r.collectionKey);return Ki(u.item.id,r.collectionKey,_,a,t.includeMeta===!0,{action:"add",entryIndex:m,entry:_[m-1],changedCount:t.ifAbsent===!0?Math.min(u.changedFields.length,1):void 0},t.fullHistory===!0)}function w_(e,t,n){if(e===void 0||!Number.isInteger(e)||e<1||e>t){let r=n.replace(/s$/,""),i=`${r.charAt(0).toUpperCase()}${r.slice(1)}`,s=t===1?`1 ${r}`:`${t} ${n}`;throw new f(`${i} index ${e??"(missing)"} out of range (item has ${s})`,p.USAGE)}return e-1}function kS(e,t,n){return t===void 0?{}:{mutation_receipt:{action:t.action,entry_index:t.entryIndex,changed_count:t.changedCount??1,full_history_included:!n},omission_receipt:{has_omissions:n,omitted_field_group_count:n?1:0,omitted_field_groups:n?[{name:`${e}_history`,restore_with:{selector:"full_history",cli_flag:"--full-history",sdk_option:"fullHistory",mcp_option:"full"}}]:[]}}}function b_(e,t){if(Object.prototype.toString.call(e)!=="[object Object]")return e;let n={index:t,...e};return n.index=t,n}function bS(e,t){let n=e.length-t.length;return t.map((r,i)=>b_(r,n+i+1))}function Ki(e,t,n,r,i,s,o=!1){let a=s===void 0||o?bS(n,lS(n,s!==void 0&&o?void 0:r)):s.entry===void 0?[]:[b_(s.entry,s.entryIndex)],c=s!==void 0&&a.length<n.length;return{id:e,[t]:a,count:a.length,...s?.changedCount===void 0?{}:{changed:s.changedCount===1},...[i,s!==void 0].includes(!0)?{total_count:n.length,returned_count:a.length,has_more:c||a.length<n.length,...r!==void 0?{limit:r}:{}}:{},...kS(t,s,c)}}import{isDeepStrictEqual as R_}from"node:util";var SS=new Set(["__proto__","prototype","constructor"]),cr=Symbol("looseOptionOccurrences");function it(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,r)=>r.toUpperCase())}function AS(e,t,n){let r=e[t];if(r===void 0){e[t]=n;return}if(Array.isArray(r)){r.push(n),e[t]=r;return}e[t]=[r,n]}function ga(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let o=n.indexOf("=");if(o>=0)return{consumed:1,key:n.slice(1,o).trim(),value:n.slice(o+1),attached:!0};let a=n.slice(1).trim(),c=e[t+1];return typeof c=="string"&&!c.startsWith("-")?{consumed:2,key:a,value:c}:{consumed:1,key:a,value:!0}}let r=n.indexOf("=");if(r>=0)return{consumed:1,key:n.slice(2,r).trim(),value:n.slice(r+1),attached:!0};if(n.startsWith("--no-"))return{consumed:1,key:n.slice(5).trim(),value:!1};let i=n.slice(2).trim(),s=e[t+1];return typeof s=="string"&&!s.startsWith("-")?{consumed:2,key:i,value:s}:{consumed:1,key:i,value:!0}}function Wi(e){return SS.has(e)}function Hi(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Rl(t)}function wn(e){let t=[],n=Nt(e.long)??"",r=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let i=it(n.slice(2));i.length>0&&!Wi(i)&&t.push(i)}if(r.startsWith("-")&&!r.startsWith("--")){let i=it(r.slice(1));i.length>0&&!Wi(i)&&t.push(i)}return[...new Set(t)]}function uD(e){let t=new Set;for(let n of e)for(let r of wn(n))t.add(r);return t}function qt(e){let t=Nt(e.long)??"";if(t.startsWith("--")){let n=it(t.slice(2));if(n.length>0&&!Wi(n))return n}return wn(e)[0]??null}function vn(e){let t=Nt(e.long)??"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function T_(e,t){return[...(t.definitions??e).map(r=>vn(r)).filter(r=>r!==null),...t.inheritedFlags??[]]}function mD(e,t,n,r={}){if(t.length===0)return;let i=new Set,s=new Map,o=[],a=T_(t,r);for(let c of t){let d=wn(c),l=vn(c);for(let u of d)i.add(u),c.enabled===!1&&s.set(u,l);c.required===!0&&c.enabled!==!1&&d.length>0&&o.push({keys:d,label:l,definition:c})}for(let c of Object.keys(e)){i.has(c)||I_(`--${c}`,`--${c}`,n,a);let d=s.get(c);d&&O_(d,n)}for(let c of o){let d=l=>Object.hasOwn(e,l)&&(c.definition.list!==!0||wa(c.definition,e[l]));c.keys.some(d)||N_(c.definition,c.keys[0],c.label,n)}}function I_(e,t,n,r){let i=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new f(`Unknown option '${e}' for extension command '${n}'.${i}`,p.USAGE,{code:"unknown_option",flag:t,required:`Use a flag the command accepts; run pm contracts --command ${n} --flags-only --json to list them.`})}function O_(e,t){throw new f(`Option '${e}' is disabled for extension command '${t}'.`,p.USAGE,{code:"extension_option_disabled",flag:e,required:`Remove ${e}; the command declares it with enabled: false.`,why:"A disabled declaration keeps the flag in the contract while refusing every value for it.",examples:[`pm ${t} --help`],nextSteps:[`Run pm contracts --command ${t} --flags-only --json to list the flags this command accepts.`]})}function N_(e,t,n,r){let i=on(e),s=i.value_arity==="none"?n:i.value_arity==="optional"?`${n} [${i.value_name}]`:`${n} <${i.value_name}>`;throw new f(`Missing required option '${n}' for extension command '${r}'.`,p.USAGE,{code:"missing_required_option",flag:n,field:t,required:`Pass ${s}.`,why:"The command declares this flag as required, so pm refuses the invocation before the extension handler runs.",examples:[`pm ${r} ${s}`],nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`],recovery:{missing:[n]}})}function xS(e){return typeof e=="string"||e==null?e:String(e)}function CS(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function $_(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var ES={string:xS,number:CS,boolean:$_};function Gt(e,t){return Array.isArray(e)?e.map(n=>Gt(n,t)):ES[t](e)}function ya(e,t,n){let r=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(i=>i!=null&&i!==""):Ro(e);return t?r.map(i=>Gt(i,t)):r}function wa(e,t){return ya(t,null,e.repeatable===!0).length>0}function RS(e,t,n,r){return n?ya(e,t,r):t?Gt(e,t):e}function TS(e,t,n){let r=M_(e,t);return r.length===0?n:r.map(i=>i.value)}function L_(e){return on(e).value_arity==="none"}function va(e,t,n,r,i){let s=vn(e),o=i?` for extension command '${i}'`:"",a=n===!0?"no value":JSON.stringify(n);throw new f(`Option '${s}'${o} expects ${r}; received ${a}.`,p.USAGE,{code:"extension_flag_value_invalid",flag:s,required:`Pass ${s} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${s}.`,`Run pm ${i??"<command>"} --help to review the declared flag contract.`]})}function ka(e,t){return e.value_validation==="strict"&&t!=="string"}function M_(e,t){let n=e[cr];if(!n)return[];let r=new Set(t);return n.filter(i=>r.has(i.key))}function IS(e,t,n,r){if(L_(e))for(let i of M_(n,t)){if(i.attached!==!0)continue;let s=e.list===!0&&e.repeatable!==!0?Ro(i.value):[i.value];for(let o of s){let a=ei(Gt(o,"boolean"),"boolean");a!==null&&va(e,"boolean",o,a.expected,r)}}}function OS(e,t,n,r,i){let s=Array.isArray(n)?n.flat(1/0):[n],o=r?s:s.flatMap(a=>typeof a=="string"?a.split(","):[a]);for(let a of o)if(typeof a=="string"&&a.trim().length===0){let c=ei(a,t);va(e,t,a,c.expected,i)}}function ba(e,t,n,r){if(!ka(e,n))return t;let i=n==="boolean"&&L_(e),s=o=>{let a=ei(o,n);return a===null?o:i&&typeof o=="string"?!0:va(e,n,o,a.expected,r)};return Array.isArray(t)?t.map(s):s(t)}function NS(e,t,n,r){for(let i of n)if(!(i===t||!Object.hasOwn(e,i))){if(Object.hasOwn(e,t)){if(r){let s=e[t],o=e[i];e[t]=[...Array.isArray(s)?s:[s],...Array.isArray(o)?o:[o]].filter(a=>a!=null)}delete e[i];continue}e[t]=e[i],delete e[i]}}function F_(e,t,n=e,r){if(t.length===0)return e;let i=Object.create(null);for(let[o,a]of Object.entries(e))i[o]=a;let s=new Set(t.map(o=>qt(o)).filter(o=>o!==null));for(let o of t){let a=qt(o);if(a){let c=wn(o).filter(d=>d===a||!s.has(d));$S(i,o,a,c,n,r)}}return i}function $S(e,t,n,r,i,s){let o=t.list===!0,a=Hi(t);a&&!o&&LS(e,t,n,r,a,s),NS(e,n,r,o);let c=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=RS(t.default,a,o,c));return}if(a==="boolean"&&ka(t,a)&&IS(t,r,i,s),o){e[n]=MS(t,r,i,e[n],a,c,s);return}a&&(e[n]=ba(t,Gt(e[n],a),a,s))}function LS(e,t,n,r,i,s){for(let o of r)o!==n&&Object.hasOwn(e,o)&&ba(t,Gt(e[o],i),i,s)}function MS(e,t,n,r,i,s,o){let a=TS(n,t,r);i&&ka(e,i)&&OS(e,i,a,s,o);let c=ya(a,i,s);return i?ba(e,c,i,o):c}function pD(e){let t=Object.create(null),n=[];Object.defineProperty(t,cr,{value:n});let r=0;for(;r<e.length;){let i=ga(e,r);if(!i){r+=1;continue}let s=it(i.key);if(s.length===0||Wi(s)){r+=i.consumed;continue}AS(t,s,i.value),n.push({...i,key:s}),r+=i.consumed}return t}function fD(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let r=ga(e,n);if(r){n+=Math.max(1,r.consumed);continue}t.push(e[n]),n+=1}return t}function _D(e,t){if(t.length===0)return[...e];let n=new Set,r=new Set;for(let o of t){let a=Hi(o);for(let c of wn(o))n.add(c),a==="boolean"&&r.add(c)}if(n.size===0)return[...e];let i=[],s=0;for(;s<e.length;){if(e[s]==="--"){i.push(...e.slice(s+1));break}let o=ga(e,s);if(o){let a=it(o.key);if(n.has(a)){let c=e[s],d=r.has(a)&&!c.includes("=")?1:o.consumed;s+=d;continue}}i.push(e[s]),s+=1}return i}function Sa(e){return qt(e)}function S_(e){return e.trim().toLowerCase().split(/\s+/u).filter(t=>t.length>0).join(" ")}function hD(e,t){let n=S_(t);if(n.length===0)return[];let r=P(n);return e.flags.filter(i=>P(S_(i.target_command))===r).flatMap(i=>[...i.flags])}function D_(e,t,n,r){let i=vn(e),[s,o]=n;throw new f(`Options '${s}' and '${o}' both set ${i} for extension command '${r}' with different values.`,p.USAGE,{code:"extension_option_spelling_conflict",required:`Pass ${i} once, under the handler key '${t}'.`,why:`'${s}' and '${o}' are spellings of the same declared flag, and pm refuses to choose between two different values.`,nextSteps:[`Remove '${s}' or '${o}' and pass one value as '${t}'.`,`Run pm contracts --command ${r} --flags-only --json to read each flag's sdk_option key.`]})}function gD(e,t,n,r={}){if(t.length===0)return e;let i=t.map(l=>l.repeatable===!0&&l.list!==!0?{...l,list:!0}:l),s=j_(i),o=jS(e,s,n),a=new Set([...s.long.values()].map(({handlerKey:l})=>l)),c=Object.create(null),d=Object.create(null);for(let[l,u]of Object.entries(o))a.has(l)?c[l]=u:u===void 0||r.undeclaredKeys==="pass"||DS(l)?d[l]=u:I_(l,PS(l),n,T_(i,{}));return U_(c,i,n),Object.assign(d,F_(c,i,P_(c,s),n))}function P_(e,t){let n=new Set([...t.long.values()].map(({handlerKey:s})=>s)),r=Object.entries(e).filter(([s])=>n.has(s)).flatMap(([s,o])=>(Array.isArray(o)?o.flat(1/0):[o]).map(a=>({consumed:1,key:s,value:a,attached:!0}))),i=Object.create(null);return Object.defineProperty(i,cr,{value:r}),i}function U_(e,t,n){for(let r of t){let i=qt(r);if(i===null)continue;let s=vn(r),o=e[i],a=Object.hasOwn(e,i);r.enabled===!1&&a&&O_(s,n);let c=a&&(r.list!==!0||wa(r,o));r.required===!0&&r.enabled!==!1&&!c&&N_(r,i,s,n),r.list!==!0&&Array.isArray(o)&&FS(s,n)}}function FS(e,t){throw new f(`Option '${e}' for extension command '${t}' takes one value; received an array.`,p.USAGE,{code:"extension_flag_value_invalid",flag:e,required:`Pass one value for ${e}, or ask the package to declare it with list: true or repeatable: true.`,why:"The flag is not declared list or repeatable, so pm refuses an array before the extension handler runs instead of handing it a value of the wrong shape.",nextSteps:[`Run pm contracts --command ${t} --flags-only --json to read each flag's value contract.`]})}var A_=new Set([...[...xl].filter(e=>e.startsWith("--")).flatMap(e=>{let t=e.replace(/^--/u,"");return[t,...t.startsWith("no-")?[t.slice(3)]:[]].flatMap(r=>[it(r),r.replaceAll("-","_")])}),"force","subcommand","inputResponses","requestState"]);function DS(e){return A_.has(e)||A_.has(it(e.replace(/^-{1,2}/u,"")))}function PS(e){return`--${e.replace(/^-+/u,"").replace(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`}function j_(e){let t={long:new Map,short:new Map},n=(r,i,s)=>{i.length>0&&!r.has(i)&&r.set(i,s)};for(let r of e){let i=qt(r);if(i===null)continue;let s={handlerKey:i,definition:r};n(t.long,i,s);let o=typeof r.short=="string"?r.short.trim():"";o.startsWith("-")&&!o.startsWith("--")&&n(t.short,o.slice(1),s)}return t}function Bi(e,t){return e.long.get(t)??e.short.get(t.replace(/^-(?!-)/u,""))??e.long.get(it(t.replace(/^-{1,2}/u,"")))}function q_(e,t,n,r){let i=/^(?:--)?no-(.+)$/u.exec(t)?.[1];if(i===void 0||Bi(e,t)!==void 0)return{spelling:t,value:n};let s=Bi(e,i);return s===void 0||Hi(s.definition)!=="boolean"?{spelling:t,value:n}:(s.definition.list===!0||s.definition.repeatable===!0)&&Array.isArray(n)?{spelling:i,value:n.flat(1/0).map(o=>x_(t,s.definition,o,r))}:s.definition.list===!0&&n!==void 0?{spelling:i,value:x_(t,s.definition,n,r)}:{spelling:i,value:n===void 0?n:zi(t,s.definition,n,r)}}function yD(e,t,n){let r=j_(e);try{let i=q_(r,t,n,"");if(i.spelling===t)return;let s=Bi(r,i.spelling);return(s.definition.list===!0||s.definition.repeatable===!0)&&!wa(s.definition,i.value)?void 0:{key:s.handlerKey,value:i.value}}catch{return}}function x_(e,t,n,r){let i=s=>s.trim().length===0?s:String(zi(e,t,s.trim(),r));return n==null?n:typeof n!="string"?zi(e,t,n,r):n.trim().length===0?n:t.repeatable===!0||!n.includes(",")?zi(e,t,n,r):n.split(",").map(i).join(",")}function zi(e,t,n,r){let i=$_(n);return typeof i=="boolean"?!i:US(e,t,n,r)}function US(e,t,n,r){let i=vn(t);throw new f(`Option '${e}' for extension command '${r}' negates ${i} and expects true, false, 1, or 0; received ${JSON.stringify(n)}.`,p.USAGE,{code:"extension_flag_value_invalid",flag:i,required:`Pass ${i} as true or false, or '${e}' as true.`,why:`'${e}' is the negated spelling of the boolean ${i}, so only a boolean value can be inverted before the extension handler runs.`,nextSteps:[`Run pm contracts --command ${r} --flags-only --json to read each flag's value contract.`]})}function jS(e,t,n){let r=Object.create(null),i=new Map;for(let[s,o]of Object.entries(e)){let{spelling:a,value:c}=q_(t,s,o,n),d=Bi(t,a);if(d===void 0)r[a]=c;else if(c!==void 0){let l=i.get(d.handlerKey);l===void 0?(i.set(d.handlerKey,a),r[d.handlerKey]=c):R_(C_(d.definition,d.handlerKey,r[d.handlerKey],t,n),C_(d.definition,d.handlerKey,c,t,n))||D_(d.definition,d.handlerKey,[l,a],n)}}return r}function C_(e,t,n,r,i){let s={[t]:n};return U_(s,[e],i),F_(s,[e],P_(s,r),i)[t]}function G_(e){let t=new Map;for(let n of e){let r=qt(n);if(r===null)continue;let i={definition:n,handlerKey:r,kind:Hi(n),arity:on(n).value_arity,scalar:n.list!==!0},s=[Nt(n.long),typeof n.short=="string"?n.short.trim():""];for(let o of s.filter(a=>a?.startsWith("-")===!0))t.has(o)||t.set(o,i)}return t}function K_(e,t,n,r=YS){let i=e.optionOf(n),s=t.get(n),o=s!==void 0&&r(s)?s:void 0;if(i!==void 0){let a={arity:i.arity,...i.variadic===!0?{variadic:!0}:{}};if(o?.handlerKey===i.key)return{...a,declared:o};if(s!==void 0)return a;let c=VS(t,n,i,r);return c===void 0?a:{...a,declared:c,negates:!0}}if(!(!e.includesLooseFlags||s===void 0))return o===void 0?{arity:s.arity,loose:!0}:{arity:s.arity,declared:o,loose:!0}}function Aa(e){return e.length>1&&e.startsWith("-")}var z_=/^-(\d+|\d*\.\d+)(e[+-]?\d+)?$/u;function W_(e,t,n){let{tokens:r}=e,i=0,s,o=!1,a=!1;for(;i<r.length||s!==void 0;){let c=s??r[i++];if(c==="--")return;if(a&&s===void 0&&qS(e,c))continue;let d=Aa(c)?KS(e,c,r[i],t,n):{consumedByCommander:!1,consumed:0};if(i+=d.consumed,s=d.group,a=d.variadic===!0,!d.consumedByCommander){if(GS(e.stop,c,o))return;o=!0}}}function qS(e,t){return!Aa(t)||e.negativeNumbersAreValues&&z_.test(t)}function GS(e,t,n){return e!==void 0&&(e.atFirstUnrecognized||!n&&e.atSubcommand(t))}function KS(e,t,n,r,i){let s=zS(t,n,r);if(s!==void 0)return i(s.spelling,s.entry,s.value,"loose"),{consumedByCommander:!1,consumed:s.consumed};let o=r(t);if(o!==void 0){let a=o.arity==="required"||o.arity==="optional"&&n!==void 0&&(!Aa(n)||e.negativeNumbersAreValues&&z_.test(n));return i(t,o,o.negates===!0?!1:a?n:!0,"commander"),{consumedByCommander:!0,consumed:a?1:0,variadic:o.variadic===!0}}return t[1]!=="-"?{consumed:0,...WS(t,r,i)}:{consumedByCommander:BS(t,r,i,e.includesLooseFlags?i:()=>{}),consumed:0}}function zS(e,t,n){let r=e.indexOf("="),i=r>1?e.slice(0,r):e,s=n(i);if(s?.loose===!0)return r>1?{spelling:i,entry:s,value:e.slice(r+1),consumed:0}:t!==void 0&&!t.startsWith("-")?{spelling:i,entry:s,value:t,consumed:1}:{spelling:i,entry:s,value:!0,consumed:0};let o=r<0&&e.startsWith("--no-")?n(`--${e.slice(5)}`):void 0;return o?.loose===!0&&o.declared?.kind==="boolean"?{spelling:e,entry:o,value:!1,consumed:0}:void 0}function WS(e,t,n){let r=e.slice(0,2),i=e.length>2?t(r):void 0;return i===void 0||i.loose===!0?{consumedByCommander:!1}:i.arity!=="none"?(n(r,i,e.slice(2),"commander"),{consumedByCommander:!0}):(n(r,i,!0,"commander"),{consumedByCommander:!0,group:`-${e.slice(2)}`})}function BS(e,t,n,r){let i=e.indexOf("=");if(i>2){let o=e.slice(0,i),a=t(o);return a!==void 0&&a.arity!=="none"?(n(o,a,e.slice(i+1),"commander"),!0):(a?.declared?.kind==="boolean"&&r(o,a,e.slice(i+1),"loose"),!1)}let s=e.startsWith("--no-")?t(`--${e.slice(5)}`):void 0;return s?.declared?.kind==="boolean"&&r(e,s,!1,"loose"),!1}function wD(e,t,n){let r=G_(t),i=new Map;for(let s of e)W_(s,o=>K_(s,r,o),(o,a,c)=>{a.declared!==void 0&&HS(i,a.declared,o,c,n)})}function HS(e,t,n,r,i){let{definition:s,handlerKey:o,kind:a}=t,c=a?Gt(r,a):r,d=e.get(o)??new Map,l=[...d].find(([u,m])=>u!==n&&!R_(m,c));l!==void 0&&D_(s,o,[l[0],n],i),d.set(n,c),e.set(o,d)}function VS(e,t,n,r){let i=t.startsWith("--no-")?e.get(`--${t.slice(5)}`):void 0;return i!==void 0&&r(i)&&i.kind==="boolean"&&i.handlerKey===n.key?i:void 0}function YS(e){return e.scalar}function E_(e){return!e.scalar&&e.kind==="boolean"&&e.arity==="none"}function vD(e,t,n){let r=G_(n),i=[...new Set(r.values())].filter(E_);if(i.length===0)return e;let s=new Set(n.map(m=>qt(m)).filter(m=>m!==null)),o=m=>wn(m.definition).filter(_=>_===m.handlerKey||!s.has(_)),a=new Map([...i].reverse().flatMap(m=>o(m).map(_=>[_,m]))),c=new Map;for(let m of t)W_(m,_=>K_(m,r,_,E_)??XS(m,a,_),(_,h,g,y)=>{if(h.declared===void 0)return;let w=c.get(h.declared)??[];w.push(y==="commander"?{value:g}:null),c.set(h.declared,w)});let d=[...c].filter(([,m])=>m.some(_=>_!==null));if(d.length===0)return e;let l=e[cr]??[];for(let[m,_]of d){let h=new Set(o(m)),g=l.filter(({key:k})=>h.has(k));if(g.length===0)continue;let y=k=>({consumed:0,key:m.handlerKey,value:k.value}),w=0,v=_.filter(k=>k===null).length===g.length?_.map(k=>k===null?g[w++]:y(k)):[...g,..._.filter(k=>k!==null).map(y)];l=[...l.filter(({key:k})=>!h.has(k)),...v]}let u=Object.assign(Object.create(null),e);return Object.defineProperty(u,cr,{value:l}),u}function XS(e,t,n){let r=!n.startsWith("--")&&e.optionOf(n.slice(0,2))!==void 0;if(!e.includesLooseFlags||r)return;let i=t.get(it(n.replace(/^-+/u,"")));return i===void 0?void 0:{arity:i.arity,declared:i,loose:!0}}var JS=new Set(["claim","close","context","create","get","help","init","list","next","plan","release","search","update","validate","workspace"]),QS=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"]),ZS=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"])}),eA=new Set(["extension","install","package","packages","upgrade"]);function tA(e){let t=P(e.trim().toLowerCase());if(t==="ops")return"quality";for(let[n,r]of Object.entries(ZS))if(r.has(t))return n;return eA.has(t)?"extensions":"internal"}var kn=Object.freeze([...We.flatMap(e=>e==="item"?["item","item-reopen"]:[e,...ze.filter(t=>t.alias===e).map(t=>t.canonical)]).map(e=>({command:e,tier:JS.has(P(e))?"core":QS.has(P(e))?"standard":"full",family:tA(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"}]),nA=kn,B_=Object.freeze({max_lines:50,max_utf8_bytes:6e3}),AD=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"]);function xD(e){let t=e===""?0:e.split(/\r?\n/).length,n=Buffer.byteLength(e,"utf8");return{lines:t,utf8_bytes:n,within_budget:t<=B_.max_lines&&n<=B_.max_utf8_bytes}}var H_={core:0,standard:1,full:2,internal:3},V_=new Map(nA.map(({command:e,tier:t})=>[e,t]));function xa(e,t="standard"){return V_.get(e.trim().toLowerCase())??V_.get(P(e.trim().toLowerCase()))??t}function CD(e){return Y_(e,kn)}function Y_(e,t){let n=H_[e];return t.filter(r=>r.tier!=="internal"&&H_[r.tier]<=n).map(r=>r.command)}function ED(e){return X_(e,kn)}function X_(e,t){return t.filter(n=>n.family===e).map(n=>n.command)}var rA=["workspace","intake","context","lifecycle","evidence","graph","quality","automation","extensions","internal"],iA=new Set([...Tt.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 RD(e=kn){return rA.map(t=>({family:t,commands:X_(t,e).filter(n=>e.find(r=>r.command===n)?.tier!=="internal"&&!iA.has(n))})).filter(({commands:t})=>t.length>0)}var sA=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"});function TD(e,t){return oA(e,t,kn)}function oA(e,t,n){if(t==="full")return[...e];let r=new Set(Y_(t,n));return e.filter(i=>{let s=sA[i];return s!==void 0&&r.has(s)})}var ID=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"}]),OD=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."}]);function ND(){return aA(kn)}function aA(e){return["# Generated agent command surface","","This file is generated from `PM_COMMAND_CAPABILITY_CONTRACTS`. Do not edit it manually.","","| Command | Minimum visibility tier | Capability family |","| --- | --- | --- |",...e.map(({command:n,tier:r,family:i})=>`| \`${n}\` | ${r} | ${i} |`),""].join(`
2
2
  `)}var Ca=[{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"}],cA=new Map(Ca.map(e=>[e.exit_code,e.class]));function Vi(e){return[...new Set(e.map(t=>t.trim()).filter(Boolean))].sort()}function dA(e){if(!e)return[];let t=new Set,n=new Set;return e.map(r=>{let i=r.state.trim(),s=r.probe_id.trim(),o=Vi(r.entrypoints);if(!/^[a-z][a-z0-9_]*$/.test(i)||!/^[a-z][a-z0-9-]*$/.test(s)||o.length===0||t.has(i)||n.has(s))throw new TypeError("Invalid pm refusal state contract");return t.add(i),n.add(s),{state:i,probe_id:s,entrypoints:o,expected_exit_class:r.expected_exit_class}}).sort((r,i)=>r.state.localeCompare(i.state))}function lA(e,t,n,r,i){return![[1,2,3,4,5].includes(e.exit_code),e.meaning.trim().length>0,e.recovery.trim().length>0,t.length>0,n.length>0,/^[a-z][a-z0-9_]*$/.test(r),i.every(s=>/^[a-z][a-z0-9_]*$/.test(s)),cA.get(e.exit_code)===e.class].includes(!1)}function uA(e,t){let n=e,r=new Set;for(;n.canonical_code!==n.code;){if(r.has(n.code))throw new TypeError(`Alias cycle in pm error code catalog: ${e.code}`);r.add(n.code);let i=t.get(n.canonical_code);if(!i)throw new TypeError(`Invalid pm error code contract: ${e.code}`);n=i}return n}function mA(e){let t=new Map(e.map(n=>[n.code,n]));for(let n of e){let r=uA(n,t);if(r.exit_code!==n.exit_code||r.class!==n.class)throw new TypeError(`Alias transport mismatch for pm error code: ${n.code}`);let i=e.filter(s=>s.code!==r.code&&s.canonical_code===r.code).map(s=>s.code).sort();if(n.code===r.code?JSON.stringify(n.aliases)!==JSON.stringify(i):n.aliases.length>0)throw new TypeError(`Invalid pm error code contract: ${n.code}`)}}function Q_(e){let t=new Set,n=e.map(r=>{let i=r.code.trim();if(!/^[a-z][a-z0-9_]*$/.test(i))throw new TypeError(`Invalid pm error code: ${JSON.stringify(r.code)}`);if(t.has(i))throw new TypeError(`Duplicate pm error code: ${i}`);t.add(i);let s=Vi(r.sources),o=Vi(r.emitting_commands),a=(r.canonical_code??i).trim(),c=Vi(r.aliases??[]),d=dA(r.owned_states);if(!lA(r,s,o,a,c))throw new TypeError(`Invalid pm error code contract: ${i}`);if(d.some(l=>l.expected_exit_class!==r.class))throw new TypeError(`Invalid pm refusal state exit class: ${i}`);return Object.freeze({...r,code:i,meaning:r.meaning.trim(),recovery:r.recovery.trim(),sources:s,emitting_commands:o,canonical_code:a,aliases:c,owned_states:d})});return mA(n),Object.freeze(n.sort((r,i)=>r.code.localeCompare(i.code)))}function LD(e,t){let n=J_(e,t);return J_(n.canonical_code??n.code,t)}function J_(e,t){let n=e.trim(),r=t.find(i=>i.code===n);if(!r)throw new TypeError(`Unknown pm error code "${n}"`);return r}var pA="Inspect the structured error guidance, then retry the suggested command when one is present.",fA=new Map(Ca.map(e=>[e.exit_code,e.class]));function Z_(e){return e.map(t=>{let n=`${t.code.replaceAll("_"," ")} condition.`,r={code:t.code,meaning:`${n.charAt(0).toUpperCase()}${n.slice(1)}`,stability:t.stable?"stable":"provisional",exit_code:t.exit_code,class:fA.get(t.exit_code),recovery:pA,sources:t.sources,emitting_commands:t.emitting_commands??["*"],canonical_code:t.canonical_code??t.code,aliases:t.aliases??[]};return t.owned_states&&(r.owned_states=t.owned_states),r})}var eh=[{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_flag_invalid",exit_code:2,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:"field_option_collision",exit_code:1,sources:["core/profile/profile-lint.ts"]},{code:"finalization_invalid_document",exit_code:2,sources:["sdk/transactions/item-finalization.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_append_only_repair_unavailable",exit_code:4,sources:["sdk/history/append-only-repair.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_compact_boundary_bridged",exit_code:2,sources:["sdk/history-compact.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_chain_unbridgeable",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{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_unrepairable_stream",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{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_record_integrity_invalid",exit_code:4,sources:["sdk/history/reanchor-refusal.ts"]},{code:"history_record_invalid",exit_code:1,sources:["core/history/read.ts"]},{code:"history_record_version_unsupported",exit_code:4,sources:["sdk/history/reanchor-refusal.ts"]},{code:"history_redact_bridge_unlocated",exit_code:1,sources:["sdk/history-redact.ts"]},{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:"history_version_unreconstructable",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/extension/listing-fields.ts","sdk/extension/static-inventory.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.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_resource_value_list",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"]}];var th=[{code:"merge_fence_drift",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_fence_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_git_config_unwritable",exit_code:5,stable:!0,sources:["sdk/merge/install.ts"]},{code:"merge_receipt_evidence_invalid",exit_code:4,sources:["core/diagnostics/remediation.ts","sdk/merge/reconcile.ts"]},{code:"merge_receipt_history_reference_missing",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{code:"merge_receipt_not_portable",exit_code:4,sources:["sdk/merge/receipts.ts"]},{code:"merge_receipts_pending",exit_code:1,sources:["core/diagnostics/remediation.ts"]},{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:"npm_source_shorthand_ambiguous",exit_code:2,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:"read_output_surface_unsupported",exit_code:2,sources:["sdk/extension/static-inventory.ts","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_field_flag_invalid",exit_code:2,sources:["sdk/schema/field-option-collisions.ts"]},{code:"schema_field_option_collision",exit_code:2,sources:["sdk/schema/field-option-collisions.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_schema_field_option_collision",exit_code:1,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"]}];var nh=Q_(Z_([...eh,...th]));var _A=["mutation_receipt","entity","collection","diagnostic","stream"],hA=new Set(["append","claim","close","close-task","copy","create","delete","focus","pause-task","release","restore","start-task","update"]),gA=new Set(["close-many","update-many"]),yA=new Set(["activity","comments","contracts","events","history","learnings","list","notes","search"]),wA=new Set(["aggregate","deps","graph","health","history-redact","history-repair","history-compact","stats","validate"]);function bn(e){if(e.command.trim().length===0)throw new TypeError("command must be a non-empty command path");if(!_A.includes(e.kind))throw new TypeError(`Unsupported output envelope kind: ${e.kind}`);return e}function rh(e){let t=e.trim().replace(/\s+/gu," "),[n=t]=t.split(" ");return gA.has(n)?bn({command:t,kind:"collection",wrapper_key:"rows",cardinality:"many",format_flag:"--json"}):hA.has(n)?bn({command:t,kind:"mutation_receipt",wrapper_key:null,cardinality:"one",format_flag:"--json"}):yA.has(n)?bn({command:t,kind:"collection",wrapper_key:n==="contracts"?null:"items",cardinality:"many",format_flag:"--json"}):wA.has(n)?bn({command:t,kind:"diagnostic",wrapper_key:null,cardinality:"none",format_flag:"--json"}):bn({command:t,kind:n==="get"?"entity":"diagnostic",wrapper_key:n==="get"?"item":null,cardinality:n==="get"?"one":"none",format_flag:"--json"})}var vA=We.map(e=>rh(e)),kA=new Map(vA.map(e=>[e.command,e])),bA=new Map([["files lookup",bn({command:"files lookup",kind:"collection",wrapper_key:"matches",cardinality:"many",format_flag:"--json"})]]);function ih(e){let t=e.trim().replace(/\s+/gu," ");if(t.length===0)throw new TypeError("command must be a non-empty command path");let n=Ur(t),r=bA.get(n);if(r!==void 0)return{...r,command:t};let[i=t]=n.split(" "),s=kA.get(i);return s?{...s,command:t}:rh(t)}function SA(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function AA(e){return SA(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 HD(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch(n){throw new TypeError(`Mutation receipt must be valid JSON: ${String(n)}`,{cause:n})}if(!AA(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}:{}}}var Ea=[{exit_code:p.SUCCESS,outcome:"effect",success:!0,meaning:"The requested operation completed with its intended effect."},{exit_code:p.GENERIC_FAILURE,outcome:"internal_failure",success:!1,meaning:"An unexpected runtime or internal failure prevented completion."},{exit_code:p.USAGE,outcome:"refused_input",success:!1,meaning:"The invocation was refused because its input or composition was invalid."},{exit_code:p.NOT_FOUND,outcome:"refused_tracker_state",success:!1,meaning:"The requested tracker, item, or resource was not present."},{exit_code:p.CONFLICT,outcome:"conflict",success:!1,meaning:"Current state or concurrency prevented the requested effect."},{exit_code:p.DEPENDENCY_FAILED,outcome:"dependency_failed",success:!1,meaning:"A required dependency operation failed."},{exit_code:p.NO_EFFECT,outcome:"no_effect",success:!0,meaning:"The request was valid and completed, but matched nothing to change."},{exit_code:p.PARTIAL_EFFECT,outcome:"partial_effect",success:!0,meaning:"The request completed and changed some, but not all, selected targets."}],sh=[p.SUCCESS,p.GENERIC_FAILURE,p.USAGE,p.NOT_FOUND,p.CONFLICT,p.DEPENDENCY_FAILED],xA=new Set(["close-many","update-many"]),ah=We.map(e=>({command:e,exit_codes:xA.has(e)?[...sh,p.NO_EFFECT,p.PARTIAL_EFFECT]:[...sh]})),oh=new Map(ah.map(e=>[e.command,e])),CA=[p.SUCCESS,p.NO_EFFECT,p.PARTIAL_EFFECT];function JD(e){return CA.includes(e)}function QD(e){return Ea.some(t=>t.exit_code===e)}function ch(e){let t=e.trim().toLowerCase().split(/\s+/u).filter(Boolean).join(" ");return oh.get(t)??oh.get(t.split(" ")[0])}function ZD(e,t=We,n=ah){let r=new Map(n.map(d=>[d.command,d])),i=t.filter(d=>!r.has(d)),s=e.filter(d=>{let l=r.get(d.command)??r.get(d.command.split(" ")[0]);return l===void 0||!l.exit_codes.includes(d.exit_code)}),o=new Set(e.map(d=>d.exit_code)),c=[...new Set(n.flatMap(d=>d.exit_codes))].filter(d=>!o.has(d)).sort((d,l)=>d-l);return{ok:i.length===0&&s.length===0&&c.length===0,missing_commands:i,undeclared_observations:s,unreachable_exit_codes:c}}function eP(e){return e.applied===0&&e.failed>0?{outcome:"dependency_failed",exit_code:p.DEPENDENCY_FAILED}:e.applied===0?{outcome:"no_effect",exit_code:p.NO_EFFECT}:e.skipped>0||e.failed>0||e.unmatched>0?{outcome:"partial_effect",exit_code:p.PARTIAL_EFFECT}:{outcome:"effect",exit_code:p.SUCCESS}}var $=class extends TypeError{constructor(t){super(t),this.name="AssuranceMutationRefusalError"}},be=class extends TypeError{context;constructor(t,n={}){super(t),this.name="AssuranceEvaluationRefusalError",this.context=n}},Xe=class extends TypeError{measurement_id;source_kind;field;check;constructor(t,n){super(t),this.name="AssuranceSourceResolutionError",this.measurement_id=n.measurement_id,this.source_kind=n.source_kind,this.field=n.field,this.check=n.check}};async function Sn(e){try{return await e()}catch(t){throw t instanceof $?new f(t.message,p.USAGE,{code:"invalid_argument_value",reason:"assurance_mutation_refused"}):t}}async function Ra(e){try{return await e()}catch(t){throw t instanceof be?new f(t.message,p.USAGE,{code:"invalid_argument_value",reason:"assurance_evaluation_refused",...t.context}):t}}import{createHash as EA}from"node:crypto";import RA from"node:path";var lh=1,st=["pre-commit","pre-push","pre-merge","ci","pre-release","post-release","scheduled","on-claim","on-close"],dr=["items","dependency_kind","prose_edge_gap","graph","validate","health","history","links","provider","derived"],TA=["ceiling","floor","equals","zero","monotone_nondecreasing","monotone_nonincreasing","subset_of"],IA=/^[a-z0-9]+(?:[._-][a-z0-9]+)*$/,Yi=30,Xi=5e3,uh=4,OA=50;function ot(e,t){if(!IA.test(e))throw new $(`${t} must be a stable lowercase id`)}function NA(e,t){if(!Number.isFinite(e)||e<0)throw new $(`${t} must be a finite non-negative number`)}function ur(e){let t=TA.filter(i=>e[i]!==void 0);if(t.length!==1)throw new $(`assertion ${e.id} must declare exactly one polarity`);let n=t[0],r=e[n];return{polarity:n,value:n==="zero"?0:r}}function Ia(e,t){return Z(e)===Z(t)}function mh(e,t){if(t.polarity==="equals")return Ia(e,t.value);if(t.polarity==="subset_of"){if(!Array.isArray(e)||!Array.isArray(t.value))return!1;let r=t.value;return e.every(i=>r.includes(i))}if(typeof e!="number")return!1;let n=t.value;return t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?e<=n:t.polarity==="floor"||t.polarity==="monotone_nondecreasing"?e>=n:e===0}function ph(e){let t=ur(e),n=e.negative_control.cases;return n.some(r=>r.expected==="pass")&&n.some(r=>r.expected==="fail")&&n.every(r=>mh(r.observed,t)===(r.expected==="pass"))}function $A(e,t){if(e.polarity!==t.polarity)return!0;if(typeof e.value=="number"&&typeof t.value=="number")return e.polarity==="ceiling"||e.polarity==="monotone_nonincreasing"?t.value>e.value:e.polarity==="floor"||e.polarity==="monotone_nondecreasing"?t.value<e.value:t.value!==e.value;if(e.polarity==="subset_of"){let n=e.value,r=t.value;return!Array.isArray(n)||!Array.isArray(r)||r.some(i=>!n.includes(i))}return!Ia(e.value,t.value)}function LA(e,t){if(e.measurement_id!==t.measurement_id||e.owner_item_id!==t.owner_item_id||Z(e.scope)!==Z(t.scope))return!0;let n={observe:0,warn:1,block:2},r=(e.lifetime??"hold")==="hold"&&(t.lifetime??"hold")==="retire";return $A(ur(e),ur(t))||n[t.enforcement]<n[e.enforcement]||r}function MA(e){if(e.state!==void 0&&!(e.state==="present"||e.state==="missing"))throw new $("items source state must be present or missing");let t=Object.hasOwn(e,"equals"),n=e.state!==void 0,r=Number(t)+Number(n);if(e.field!==void 0&&r!==1)throw new $("items source with field requires exactly one of equals or state");if(e.field===void 0&&r!==0)throw new $("items source equals/state requires field")}function FA(e){if(typeof e.dependency_kind!="string"||e.dependency_kind.trim().length===0)throw new $("dependency_kind source requires dependency_kind");if([e.source_kind,e.source_kind_prefix,e.source_kind_state].filter(n=>n!==void 0).length>1)throw new $("dependency_kind source accepts at most one source_kind predicate");if(e.source_kind!==void 0&&e.source_kind.trim().length===0||e.source_kind_prefix!==void 0&&e.source_kind_prefix.trim().length===0)throw new $("dependency_kind source provenance values must not be empty");if(e.source_kind_state!==void 0&&e.source_kind_state!=="present"&&e.source_kind_state!=="missing")throw new $("dependency_kind source source_kind_state must be present or missing")}function DA(e){if(e.sample_limit!==void 0&&(!Number.isInteger(e.sample_limit)||e.sample_limit<1))throw new $("prose_edge_gap sample_limit must be a positive integer");for(let t of e.exemptions??[]){if(typeof t.holder_id!="string"||t.holder_id.trim().length===0||typeof t.reason!="string"||t.reason.trim().length===0)throw new $("prose_edge_gap exemptions require holder_id and reason");if(t.target_id!==void 0&&t.target_id.trim().length===0||t.text_contains!==void 0&&t.text_contains.trim().length===0)throw new $("prose_edge_gap exemption selectors must not be empty")}}function Oa(e){ot(e.id,"measurement.id"),e.max_cost!==void 0&&NA(e.max_cost,"measurement.max_cost");let t=e.source;if(Object.prototype.toString.call(t)!=="[object Object]")throw new $(`measurement.source.kind must be one of ${dr.join(", ")}`);let n=Reflect.get(t,"kind");if(!dr.includes(n))throw new $(`measurement.source.kind must be one of ${dr.join(", ")}`);let r=t;if(r.kind==="items"&&MA(r),r.kind==="dependency_kind"&&FA(r),r.kind==="prose_edge_gap"&&DA(r),(r.kind==="graph"||r.kind==="validate"||r.kind==="health")&&(typeof r.field!="string"||r.field.trim().length===0))throw new $(`${r.kind} source requires field`);return r.kind==="provider"&&(ot(r.provider,"provider source provider"),ot(r.key,"provider source key")),e}function Na(e){if(ot(e.id,"assertion.id"),ot(e.measurement_id,"assertion.measurement_id"),typeof e.owner_item_id!="string"||e.owner_item_id.trim().length===0)throw new $("assertion.owner_item_id is required");let t=ur(e);if(typeof t.value=="number"&&!Number.isFinite(t.value))throw new $(`assertion.${t.polarity} must be a finite number`);if(e.lifetime==="retire"&&(typeof e.retire_reason!="string"||e.retire_reason.trim().length===0))throw new $("retired assertion requires retire_reason");e.scope.kind==="filter"&&ot(e.scope.measurement_id,"assertion.scope.measurement_id");let n=e.negative_control?.cases;if(!Array.isArray(n)||!n.some(r=>r.expected==="pass")||!n.some(r=>r.expected==="fail"))throw new $("assertion negative control requires pass and fail cases");if(!ph(e))throw new $(`assertion ${e.id} negative control does not prove its bound`);return e}function PA(e){if(!Array.isArray(e.allowed_providers))throw new $("gate provider_policy.allowed_providers must be an array");for(let t of e.allowed_providers)ot(t,"gate.provider_policy.allowed_provider");if(typeof e.triggers!="object"||e.triggers===null||Array.isArray(e.triggers))throw new $("gate provider_policy.triggers must be an object");for(let[t,n]of Object.entries(e.triggers)){if(!st.includes(t))throw new $(`gate provider policy has unknown trigger ${t}`);if(typeof n!="object"||n===null||!["low","medium","high"].includes(n.max_cost_class)||typeof n.allow_network!="boolean")throw new $(`gate provider policy trigger ${t} is invalid`)}}function fh(e){if(ot(e.id,"gate.id"),!Array.isArray(e.assertion_ids))throw new $("gate.assertion_ids is required and must be an array");if(e.assertion_ids.length===0)throw new $("gate requires at least one assertion");for(let t of e.assertion_ids)ot(t,"gate.assertion_id");if(!Array.isArray(e.triggers))throw new $(`gate.triggers is required and must be an array of ${st.join(", ")}`);if(e.triggers.length===0)throw new $("gate requires at least one trigger");for(let t of e.triggers)if(!st.includes(t))throw new $(`gate trigger must be one of ${st.join(", ")}`);return e.provider_policy&&PA(e.provider_policy),e}function An(e){if(e.version!==lh)throw new $(`unsupported assurance document version ${String(e.version)}`);let t=new Set;for(let r of e.measurements){if(Oa(r),t.has(`measurement:${r.id}`))throw new $(`duplicate measurement ${r.id}`);t.add(`measurement:${r.id}`)}for(let r of e.assertions){if(Na(r),t.has(`assertion:${r.id}`))throw new $(`duplicate assertion ${r.id}`);t.add(`assertion:${r.id}`)}for(let r of e.gates){fh(r);let i=r.assertion_ids.filter(s=>!e.assertions.some(o=>o.id===s));if(i.length>0)throw new $(`gate ${r.id} references missing assertions: ${i.join(", ")}`);if(t.has(`gate:${r.id}`))throw new $(`duplicate gate ${r.id}`);t.add(`gate:${r.id}`)}let n=new Set(e.measurements.map(r=>r.id));for(let[r,i]of _h(e))if(!n.has(r))throw new $(`${i.join(", ")} references missing measurement ${r}`);return e}function $a(e,t){if("measurement"in e){t.push(e.measurement);return}if("operator"in e)for(let n of e.operands)$a(n,t)}function _h(e){let t=new Map,n=(r,i)=>{let s=t.get(r)??[];s.push(i),t.set(r,s)};for(let r of e.assertions)n(r.measurement_id,`assertion ${r.id}`),r.scope.kind==="filter"&&n(r.scope.measurement_id,`assertion ${r.id} scope`);for(let r of e.measurements){if(r.source.kind!=="derived")continue;let i=[];$a(r.source.expression,i);for(let s of i)n(s,`derived measurement ${r.id}`)}return t}function UA(e,t){let n=e.assertion_ids.flatMap(s=>{let o=t.assertions.find(a=>a.id===s);return[o.measurement_id,...o.scope.kind==="filter"?[o.scope.measurement_id]:[]]}),r=new Set,i=new Set;for(;n.length>0;){let s=n.pop();if(r.has(s))continue;r.add(s);let o=t.measurements.find(a=>a.id===s);o.source.kind==="provider"?i.add(o.source.provider):o.source.kind==="derived"&&$a(o.source.expression,n)}return i}function mr(){return{version:lh,measurements:[],assertions:[],gates:[]}}function jA(e,t){let n=t.items.filter(r=>(e.statuses===void 0||e.statuses.includes(r.status))&&(e.types===void 0||e.types.includes(r.type))&&(e.tags===void 0||e.tags.every(i=>r.tags?.includes(i)))&&(e.field===void 0||(()=>{let i=r[e.field];if(e.state!==void 0){let s=i==null||i===""||Array.isArray(i)&&i.length===0;return e.state==="missing"?s:!s}return Ia(i,e.equals)})()));return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function qA(e,t){return e.source_kind!==void 0?t?.toLowerCase()===e.source_kind.trim().toLowerCase():e.source_kind_prefix!==void 0?t?.toLowerCase().startsWith(e.source_kind_prefix.trim().toLowerCase())===!0:e.source_kind_state==="present"?t!==void 0&&t.length>0:e.source_kind_state==="missing"?t===void 0||t.length===0:!0}function GA(e,t){let n=[],r=Bn(e.dependency_kind)??e.dependency_kind.trim().toLowerCase();for(let i of t.items)for(let s of i.dependencies??[]){let o=Bn(s.kind)??s.kind.trim().toLowerCase(),a=s.source_kind?.trim();o===r&&qA(e,a)&&n.push(`${i.id}->${s.id}${a?`@${a}`:""}`)}return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n}}function KA(e){let t=[e.description,e.body].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean);for(let n of["comments","notes","learnings"]){let r=e[n];if(Array.isArray(r)){for(let i of r)if(typeof i=="string")t.push(i);else if(typeof i=="object"&&i!==null){let s=Reflect.get(i,"text");typeof s=="string"&&t.push(s)}}}return t}function zA(e,t,n,r){return e.some(i=>i.holder_id.trim().toLowerCase()===t.toLowerCase()&&(i.target_id===void 0||i.target_id.trim().toLowerCase()===n.toLowerCase())&&(i.text_contains===void 0||r.toLowerCase().includes(i.text_contains.trim().toLowerCase())))}function Ta(e,t){return[e.toLowerCase(),t.toLowerCase()].sort().join("\0")}function WA(e){let t=new Map,n=new Set,r=[],i=/(?<![\w-])[a-z0-9]+(?:-+[a-z0-9]+)+(?![\w-])/giu,s=0;for(let o of e){t.set(o.id.toLowerCase(),o.id);for(let a of o.dependencies??[])n.add(Ta(o.id,a.id));for(let a of[o.parent,o.blocked_by])typeof a=="string"&&n.add(Ta(o.id,a));for(let a of KA(o)){let c=[...a.matchAll(i)].map(d=>d[0]);s+=c.length,r.push({holder_id:o.id,segment:a,mentioned_ids:c})}}return{canonical_ids:t,linked_pairs:n,prose_mentions:r,mention_count:s}}function BA(e,t){let n=WA(t.items),r=new Map;for(let o of n.prose_mentions){let a=o.mentioned_ids.map(d=>n.canonical_ids.get(d.toLowerCase())).filter(d=>d!==void 0&&d!==o.holder_id),c=[...new Set(a)];for(let d of c){let l=Ta(o.holder_id,d);if(n.linked_pairs.has(l)||zA(e.exemptions??[],o.holder_id,d,o.segment))continue;let u=c.some(m=>m!==d);r.get(l)?.explicit===!0&&!u||r.set(l,{contributor:`${o.holder_id}->${d}|subject=${u?"explicit":"implicit"}`,explicit:u})}}let i=[...r.values()],s=i.map(o=>o.contributor).sort();return{value:s.length,population_size:n.canonical_ids.size,cost:t.items.length+n.linked_pairs.size+n.mention_count,contributors:s.slice(0,e.sample_limit??25),partitions:{explicit_subject:i.filter(o=>o.explicit).length,implicit_subject:i.filter(o=>!o.explicit).length}}}function HA(e,t){return{value:t.history.filter(r=>(e.op===void 0||r.op===e.op)&&(e.author===void 0||r.author===e.author)&&(e.harness===void 0||r.agent_harness===e.harness)&&(e.model===void 0||r.agent_model===e.model)).length,population_size:t.history.length,cost:t.history.length}}function VA(e,t){let n=t.items.filter(r=>{let i=r[e.link],s=Array.isArray(i)&&i.length>0;return e.state==="present"?s:!s});return{value:n.length,population_size:t.items.length,cost:t.items.length,contributors:n.map(r=>r.id)}}function YA(e,t){let n=e.source;return n.kind==="items"?jA(n,t):n.kind==="dependency_kind"?GA(n,t):n.kind==="prose_edge_gap"?BA(n,t):n.kind==="history"?HA(n,t):n.kind==="links"?VA(n,t):null}function hh(e,t){return e.reduce((n,r)=>({units:n.units+r.units,items_scanned:n.items_scanned+r.items_scanned,history_entries:n.history_entries+r.history_entries,provider_calls:n.provider_calls+r.provider_calls,duration_ms:t}),{units:0,items_scanned:0,history_entries:0,provider_calls:0,duration_ms:t})}function XA(e,t){if(t.length===0)throw new TypeError(`derived ${e} requires operands`);if(e==="add")return t.reduce((n,r)=>n+r,0);if(e==="subtract")return t.slice(1).reduce((n,r)=>n-r,t[0]);if(e==="multiply")return t.reduce((n,r)=>n*r,1);if(e==="divide"){if(t.slice(1).includes(0))throw new TypeError("derived divide cannot divide by zero");return t.slice(1).reduce((n,r)=>n/r,t[0])}return e==="min"?Math.min(...t):Math.max(...t)}async function gh(e,t,n){let r=new Array(e.length),i=0,s=Array.from({length:Math.min(t,e.length)},async()=>{for(;i<e.length;){let o=i;i+=1,r[o]=await n(e[o],o)}});return await Promise.all(s),r}async function yh(e,t,n,r,i){if("literal"in e)return{value:e.literal,costs:[],population_size:0,contributors:[]};if("measurement"in e){let o=n.find(d=>d.id===e.measurement);if(!o)throw new TypeError(`derived measurement references missing ${e.measurement}`);let a=await wh(o,t,n,r,i);if(typeof a.value!="number")throw new TypeError(`derived measurement ${o.id} is not numeric`);let c=i.charged.has(o.id)?[]:[a.cost];return i.charged.add(o.id),{value:a.value,costs:c,population_size:a.population_size,contributors:a.contributors}}let s=await gh(e.operands,uh,o=>yh(o,t,n,r,i));return{value:XA(e.operator,s.map(o=>o.value)),costs:s.flatMap(o=>o.costs),population_size:Math.max(0,...s.map(o=>o.population_size)),contributors:[...new Set(s.flatMap(o=>o.contributors))]}}async function JA(e,t,n,r,i){Oa(e);let s=Date.now(),o,a=[],c=0;if(e.source.kind==="derived"){let u=await yh(e.source.expression,t,n,[...r,e.id],i);o={value:u.value,population_size:u.population_size,cost:0,contributors:u.contributors},a=u.costs}else{let u=YA(e,t);u!==null?o=u:(o=await t.external(e.source),c=1)}let d={units:o.cost,items_scanned:e.source.kind==="items"||e.source.kind==="dependency_kind"||e.source.kind==="prose_edge_gap"||e.source.kind==="links"?t.items.length:0,history_entries:e.source.kind==="history"?t.history.length:0,provider_calls:c,duration_ms:Date.now()-s},l=hh([...a,d],Date.now()-s);if(e.max_cost!==void 0&&l.units>e.max_cost)throw new be(`measurement ${e.id} exceeded cost ceiling ${e.max_cost} with ${l.units}`);return{id:e.id,definition_fingerprint:`sha256:${EA("sha256").update(Z(e)).digest("hex")}`,value:o.value,population_size:o.population_size,cost:l,contributors:o.contributors??[],...o.partitions?{partitions:o.partitions}:{}}}function wh(e,t,n,r,i){if(r.includes(e.id))throw new TypeError(`derived measurement cycle: ${[...r,e.id].join(" -> ")}`);let s=i.cache.get(e.id);if(s)return s;let o=JA(e,t,n,r,i).catch(a=>{if(a instanceof Xe&&a.measurement_id===void 0){let c={measurement_id:e.id,source_kind:a.source_kind,field:a.field,...a.check?{check:a.check}:{}},d=new Xe(a.message,c);throw d.cause=a,d}throw a});return i.cache.set(e.id,o),o}async function La(e,t,n=[e]){return wh(e,t,n,[],{cache:new Map,charged:new Set})}function QA(e,t){return typeof e!="number"||typeof t.value!="number"?null:t.polarity==="ceiling"||t.polarity==="monotone_nonincreasing"?t.value-e:(t.polarity==="floor"||t.polarity==="monotone_nondecreasing",e-t.value)}function ZA(e,t,n={}){Na(e);let r=ur(e),i=e.lifetime==="retire"&&n.owner_terminal===!0;return{assertion_id:e.id,measurement_id:e.measurement_id,measurement_definition_fingerprint:t.definition_fingerprint,scope:e.scope,population_size:t.population_size,observed:t.value,bound:r,distance:QA(t.value,r),verdict:i?"retired":mh(t.value,r)?"pass":"fail",enforcement:e.enforcement,negative_control_proven:ph(e),cost:t.cost,contributors:t.contributors,...t.partitions?{partitions:t.partitions}:{}}}function ex(e,t,n,r){let i=UA(e,t);if(i.size===0)return;let s=e.provider_policy,o=s?.triggers[r];if(!s||!o)throw new be(`assurance gate ${e.id} refuses provider execution at trigger ${r} without an explicit provider policy`);let a=new Set(s.allowed_providers),c={low:0,medium:1,high:2};for(let d of i){if(!a.has(d))throw new be(`assurance gate ${e.id} refuses provider ${d}`);let l=n.provider_capabilities?.[d];if(!l)throw new be(`assurance provider ${d} has no declared capabilities`);if(c[l.cost_class]>c[o.max_cost_class])throw new be(`assurance gate ${e.id} refuses ${l.cost_class}-cost provider ${d} at trigger ${r}`);if(l.network&&!o.allow_network)throw new be(`assurance gate ${e.id} refuses network provider ${d} at trigger ${r}`)}}async function dh(e,t,n,r,i){try{return await La(n,r,i)}catch(s){if(s instanceof Xe){let o=s.check?` check ${s.check}`:"",a=s.measurement_id??n.id,c=new be(`assurance gate ${e} assertion ${t} measurement ${a} source ${s.source_kind}${o} field ${s.field} could not resolve: ${s.message}`,{gate_id:e,assertion_id:t,measurement_id:a,source_kind:s.source_kind,field:s.field,...s.check?{check:s.check}:{}});throw c.cause=s,c}throw s}}async function vh(e,t,n,r){An(t);let i=t.gates.find(c=>c.id===e);if(!i)throw new be(`assurance gate ${e} not found`);if(!i.triggers.includes(r.trigger))throw new be(`assurance gate ${e} does not declare trigger ${r.trigger}`);ex(i,t,n,r.trigger);let s=await gh(i.assertion_ids,uh,async c=>{let d=t.assertions.find(h=>h.id===c),l=t.measurements.find(h=>h.id===d.measurement_id),u=n;if(d.scope.kind==="active"){let h=new Set(n.terminal_statuses??["closed","canceled"]);u={...n,items:n.items.filter(g=>!h.has(g.status))}}else if(d.scope.kind==="filter"){let h=d.scope.measurement_id,g=t.measurements.find(v=>v.id===h),y=await dh(i.id,d.id,g,n,t.measurements),w=new Set(y.contributors);u={...n,items:n.items.filter(v=>w.has(v.id))}}let m=n.items.find(h=>h.id===d.owner_item_id),_=m!==void 0&&new Set(n.terminal_statuses??["closed","canceled"]).has(m.status);return ZA(d,await dh(i.id,d.id,l,u,t.measurements),{owner_terminal:_})}),o=s.some(c=>c.verdict==="fail"&&c.enforcement==="block"),a=s.some(c=>c.verdict==="fail"&&c.enforcement==="warn");return{gate_id:i.id,tree_id:n.tree_id,trigger:r.trigger,dry_run:r.dry_run===!0,evaluated_at:new Date().toISOString(),verdict:o?"block":a?"warn":"pass",exit_code:o?1:0,assertions:s,assertions_total:s.length,row_contract:{row_keys:["assertions"],jq_selector:".assertions[]"},cost:hh(s.map(c=>c.cost),Math.max(0,...s.map(c=>c.cost.duration_ms)))}}function Ji(e){return RA.join(e,"assurance.json")}async function kh(e){let t=await ee(Ji(e));return t===null?mr():Qi(t)}function Qi(e){try{return An(JSON.parse(e))}catch(t){throw new f("The assurance registry is invalid. Repair or restore .agents/pm/assurance.json and retry.",p.GENERIC_FAILURE,{code:"assurance_registry_invalid",reason:String(t),nextSteps:["Restore a valid assurance.json from version control or repair its declaration references.","Run pm assurance list measurement after the repair."]})}}function Zi(e,t){return t==="measurement"?e.measurements:t==="assertion"?e.assertions:e.gates}function tx(e,t){e==="measurement"?Oa(t):e==="assertion"?Na(t):fh(t)}async function pr(e,t){let n=structuredClone(Zi(await kh(e),t));return{items:n,count:n.length,row_contract:{row_keys:["items"],jq_selector:".items[]"}}}async function bh(e,t,n){let r=Zi(await kh(e),t).find(i=>i.id===n);if(!r)throw new be(`assurance ${t} ${n} not found`);return structuredClone(r)}async function es(e,t,n,r={}){tx(t,n);let i=await R(e),s=H(r.author,i.author_default),o=await dn({pmRoot:e,filePath:Ji(e),op:`assurance:${t}:put`,author:s,message:r.message,lockTtlSeconds:Yi,lockWaitMs:Xi,mutate:a=>{let c=a===null?mr():Qi(a),d=Zi(c,t),l=d.findIndex(m=>m.id===n.id),u=l<0?"created":"updated";if(t==="assertion"&&l>=0&&LA(d[l],n)){let m=n.authorization_decision;if(!m||!r.authorized_decision_ids?.includes(m))throw new $(`loosening assertion ${n.id} requires a verified authorization_decision`)}return l<0?d.push(structuredClone(n)):d[l]=structuredClone(n),An(c),{raw:`${JSON.stringify(c,null,2)}
3
3
  `,result:{changed:!0,action:u,kind:t,id:n.id}}}});return{...o.result,changed:o.changed}}async function Ma(e,t,n={}){let r=mr();r.measurements=structuredClone(t.measurements),r.assertions=structuredClone(t.assertions),r.gates=structuredClone(t.gates),An(r);let i=await R(e),s=H(n.author,i.author_default),o=await dn({pmRoot:e,filePath:Ji(e),op:"assurance:bundle:apply",author:s,message:n.message,lockTtlSeconds:Yi,lockWaitMs:Xi,mutate:a=>{let c=a===null?mr():Qi(a),d=[],l=[],u=(m,_,h)=>{for(let g of _){let y=m.find(w=>w.id===g.id);if(!y){m.push(structuredClone(g)),d.push(`${h}:${g.id}`);continue}if(Z(y)!==Z(g))throw new $(`assurance bundle refuses to replace divergent ${h} ${g.id}`);l.push(`${h}:${g.id}`)}};return u(c.measurements,r.measurements,"measurement"),u(c.assertions,r.assertions,"assertion"),u(c.gates,r.gates,"gate"),An(c),{raw:`${JSON.stringify(c,null,2)}
4
4
  `,result:{changed:d.length>0,created_ids:d,unchanged_ids:l}}}});return{...o.result,changed:o.changed}}async function Sh(e,t,n,r={}){let i=await R(e),s=H(r.author,i.author_default),o=await dn({pmRoot:e,filePath:Ji(e),op:`assurance:${t}:remove`,author:s,message:r.message,lockTtlSeconds:Yi,lockWaitMs:Xi,mutate:a=>{let c=a===null?mr():Qi(a);if(t==="measurement"){let u=_h(c).get(n);if(u&&u.length>0)throw new $(`assurance measurement ${n} is referenced by ${u.join(", ")}`)}if(t==="assertion"&&c.gates.some(u=>u.assertion_ids.includes(n)))throw new $(`assurance assertion ${n} is referenced by gate`);let d=Zi(c,t),l=d.findIndex(u=>u.id===n);if(l<0)throw new $(`assurance ${t} ${n} not found`);return d.splice(l,1),An(c),{raw:`${JSON.stringify(c,null,2)}
@@ -20,4 +20,4 @@ import{A as mn,B as ie,D as Fi,G as Di,H as Cf,Ha as jf,Ia as qf,J as oa,Ja as s
20
20
  `)}async function Dn(e,t){let n=So(e,t),r=await ee(n);return r?rb(r,n):null}async function cF(e){let t=bo(e);return await me(t)?(await Mn.readdir(t,{withFileTypes:!0})).filter(r=>r.isFile()&&r.name.endsWith(".json")).map(r=>$r.join(t,r.name)).sort((r,i)=>i.localeCompare(r)):[]}function dF(e){let t=e.match(/^VmRSS:\s+(\d+)\s+kB$/m);if(t)return Number.parseInt(t[1],10)*1024}async function lF(e){if(process.platform==="linux")try{let t=await Mn.readFile(`/proc/${e}/status`,"utf8");return dF(t)}catch{return}}function uF(e){let t=e.lastIndexOf(")");if(t<0)return{};let r=e.slice(t+2).trim().split(/\s+/),i=Number.parseInt(r[11],10),s=Number.parseInt(r[12],10);return!Number.isFinite(i)||!Number.isFinite(s)?{}:{cpu_user_seconds:i/Vk,cpu_system_seconds:s/Vk}}async function mF(e){if(process.platform!=="linux")return{};try{let t=await Mn.readFile(`/proc/${e}/stat`,"utf8");return uF(t)}catch{return{}}}async function gd(e){let t=e.child_pid??e.worker_pid;if(!Fn(t))return;let n=await lF(t),r=await mF(t),i=e.started_at?Date.parse(e.started_at):Number.NaN,s=Number.isFinite(i)?Math.max(0,(tb()-i)/1e3):void 0;return{recorded_at:O(),rss_bytes:n,cpu_user_seconds:r.cpu_user_seconds,cpu_system_seconds:r.cpu_system_seconds,uptime_seconds:s}}function hd(e){return typeof e=="number"&&Number.isFinite(e)?e:0}function pF(e,t){if(!t||typeof t!="object")return{summary:{passed:0,failed:1,skipped:0},parsedResult:null};let n=t;if(e==="test-all"){let a=n.totals??{};return{summary:{items:typeof a.items=="number"?a.items:void 0,linked_tests:typeof a.linked_tests=="number"?a.linked_tests:void 0,passed:hd(a.passed),failed:hd(a.failed),skipped:hd(a.skipped),fail_on_skipped_triggered:n.fail_on_skipped_triggered===!0?!0:void 0},parsedResult:t}}let r=Array.isArray(n.run_results)?n.run_results:[],i=0,s=0,o=0;for(let a of r){if(!a||typeof a!="object")continue;let c=a.status;if(c==="passed"){i+=1;continue}if(c==="failed"||c==="refused"){s+=1;continue}o+=1}return{summary:{passed:i,failed:s,skipped:o,fail_on_skipped_triggered:n.fail_on_skipped_triggered===!0?!0:void 0},parsedResult:t}}function fF(e){let t=e.trim();if(t.length===0)return null;let n=t.match(/\[pm test-all\]\s+item\s+(\d+)\/(\d+)\s+(start|end)\s+id=([^\s]+)/i);if(n){let d=Number.parseInt(n[1],10),l=Number.parseInt(n[2],10);return{item_index:d,item_total:l,item_id:n[4],linked_test_index:void 0,linked_test_total:void 0,current_command:void 0,elapsed_ms:void 0,heartbeat_at:O(),phase:n[3]?.toLowerCase()==="end"?"finished":"running"}}let r=t.match(/\[pm test\]\s+linked-test\s+(\d+)\/(\d+)\s+(start|running|end)(?:.*elapsed_ms=(\d+))?/i);if(!r)return null;let i=Number.parseInt(r[1],10),s=Number.parseInt(r[2],10),o=r[4]?Number.parseInt(r[4],10):void 0,a=t.match(/\scommand="((?:\\.|[^"\\])*)"/),c=a?a[1].replaceAll('\\"','"').replaceAll("\\\\","\\"):void 0;return{linked_test_index:i,linked_test_total:s,current_command:c,elapsed_ms:Number.isFinite(o)?o:void 0,heartbeat_at:O(),phase:r[3]?.toLowerCase()==="end"?"finished":"running"}}function _F(e){return e.split(/\r?\n/).map(t=>t.trimEnd()).filter(t=>t.length>0)}function yd(e,t){if(t<=0)return[];let n=_F(e);return n.length<=t?n:n.slice(n.length-t)}async function ib(e){let t=process.env.PM_BACKGROUND_CLI_ENTRY?.trim();if(t&&t.length>0){let i=$r.resolve(e,t);if(await me(i))return i}let n=$r.resolve(e,"dist","cli.js");if(await me(n))return n;let r=process.argv[1]?.trim();if(r&&r.length>0){let i=$r.resolve(e,r);if(await me(i))return i}throw new f("Unable to resolve a CLI entrypoint for background test runs. Build the project or set PM_BACKGROUND_CLI_ENTRY.",p.GENERIC_FAILURE)}async function Lr(e,t){if(!Zk.has(t.status)||Fn(t.worker_pid)||t.finished_at)return t;let r={...t,status:"failed",finished_at:O(),error:t.error??"Background test run worker exited before writing terminal status."};return await Qe(e,r),r}async function vd(e){await aF(e.pmRoot);let t=nb(e.commandArgs);if(t.length===0)throw new f("Background test run requires command arguments.",p.USAGE);let n=oF(e.kind,t,e.pmRoot),r=await bd(e.pmRoot,{});for(let l of r){let u=await Lr(e.pmRoot,l);if(u.fingerprint===n&&!(!Zk.has(u.status)||!Fn(u.worker_pid)))return{started:!1,run:{...u,duplicate_of:u.id},duplicate_of:u.id}}let i=sF(),s=O(),o=_l(e.pmRoot,i),a=hl(e.pmRoot,i),c=yl(e.pmRoot,i);await Mn.writeFile(o,"","utf8"),await Mn.writeFile(a,"","utf8");let d={id:i,kind:e.kind,status:"queued",created_at:s,updated_at:s,requested_by:e.requestedBy,fingerprint:n,command_args:t,command_label:iF(t),pm_root:e.pmRoot,global_pm_root:e.globalPmRoot,target_id:e.targetId,status_filter:e.statusFilter,attempt:typeof e.attempt=="number"&&Number.isFinite(e.attempt)&&e.attempt>=1?Math.floor(e.attempt):1,resumed_from:e.resumedFrom,resumed_by:e.resumedBy,stdout_path:o,stderr_path:a,result_path:c,progress:{phase:"queued",message:"Queued for background execution.",heartbeat_at:s}};return await Qe(e.pmRoot,d),{started:!0,run:d}}async function kd(e){let t=await Dn(e.pmRoot,e.runId);if(!t)throw new f(`Background test run ${e.runId} not found`,p.NOT_FOUND);if(wd.has(t.status))throw new f(`Background test run ${t.id} is already terminal (${t.status}).`,p.CONFLICT);let n=await ib(process.cwd()),r=[];e.noExtensions===!0&&r.push("--no-extensions"),r.push("--path",t.pm_root,"test-runs-worker",t.id);let i={...process.env,PM_PATH:t.pm_root,PM_GLOBAL_PATH:t.global_pm_root,PM_BACKGROUND_TEST_RUN_ID:t.id,PM_BACKGROUND_TEST_RUN_ATTEMPT:String(t.attempt),PM_BACKGROUND_TEST_RUN_RESUMED_FROM:t.resumed_from??"",FORCE_COLOR:"0"},s=Qk(process.execPath,[n,...r],{cwd:process.cwd(),env:i,detached:!0,stdio:"ignore",windowsHide:!0});s.unref();let o={...t,status:"queued",worker_pid:s.pid,progress:{phase:"queued",message:"Worker process started.",heartbeat_at:O()}};return await Qe(e.pmRoot,o),o}async function Yk(e,t,n){await e,await Mn.appendFile(t,n,"utf8")}function sb(e,t){let n=Number.parseInt(process.env[e]??"",10);return Number.isFinite(n)&&n>0?n:t}function hF(e){return{...process.env,PM_PATH:e.pm_root,PM_GLOBAL_PATH:e.global_pm_root,FORCE_COLOR:"0"}}function gF(e,t){return t?["--no-extensions",...e.command_args]:[...e.command_args]}function yF(e,t){let n=Promise.resolve();return{schedule(){n=n.then(async()=>{try{await Qe(e,t)}catch{}})},async flush(){await n}}}function Xk(e,t){try{e.kill(t)}catch{}}async function wF(e,t,n,r){if(n.stopRequested)return;n.stopRequested=!0,e.stop_requested_at=O(),e.progress={...e.progress,phase:"stopping",message:"Stop requested for background run.",heartbeat_at:O()},r(),Xk(t,"SIGTERM"),setTimeout(()=>Xk(t,"SIGKILL"),sb("PM_BACKGROUND_RUN_FORCE_KILL_DELAY_MS",nF)).unref?.()}function vF(e,t,n){return{phase:n,message:e,heartbeat_at:O(),item_index:t.item_index,item_total:t.item_total,item_id:t.item_id,linked_test_index:void 0,linked_test_total:void 0,current_command:void 0,elapsed_ms:void 0}}function kF(e,t,n,r){return{phase:r,message:e,heartbeat_at:O(),item_index:n.item_index??t.progress?.item_index,item_total:n.item_total??t.progress?.item_total,item_id:n.item_id??t.progress?.item_id,linked_test_index:n.linked_test_index,linked_test_total:n.linked_test_total,current_command:n.current_command,elapsed_ms:n.elapsed_ms}}function Jk(e,t,n){let r=fF(t);if(!r)return!1;let i=e.progress?.phase==="stopping"?"stopping":"running";return e.progress=r.item_id?vF(t,r,i):kF(t,e,r,i),r.phase==="finished"&&!n&&(e.progress.phase="running"),!0}function bF(e){if(e.trim().length===0)return null;try{return JSON.parse(e)}catch{return null}}function SF(e,t,n){return n?"stopped":e===0&&t.failed===0&&t.fail_on_skipped_triggered!==!0?"passed":"failed"}function AF(e,t){return{phase:"finished",message:t?"Background run stopped.":`Background run finished with status=${e.status}.`,heartbeat_at:O(),item_index:e.progress?.item_index,item_total:e.progress?.item_total,item_id:e.progress?.item_id,linked_test_index:e.progress?.linked_test_index,linked_test_total:e.progress?.linked_test_total,current_command:e.progress?.current_command,elapsed_ms:e.progress?.elapsed_ms}}async function xF(e,t,n){if(t!==null){await Le(e.result_path,`${JSON.stringify(t,null,2)}
21
21
  `);return}await Le(e.result_path,`${JSON.stringify({parse_error:"Background run output was not valid JSON.",stdout_excerpt:yd(n,eb)},null,2)}
22
22
  `)}async function ob(e,t,n=!1){let r=await Dn(e,t);if(!r)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let i={...r,status:"running",started_at:r.started_at??O(),worker_pid:process.pid,progress:{phase:"running",message:"Worker started.",heartbeat_at:O()}},s=await ib(process.cwd()),o=hF(i);await Qe(e,i);let a=gF(i,n),c=Qk(process.execPath,[s,...a],{cwd:process.cwd(),env:o,detached:!1,stdio:["ignore","pipe","pipe"],windowsHide:!0});i.child_pid=c.pid;let d=yF(e,i),l=d.schedule,u=Promise.resolve(),m=Promise.resolve(),_="",h="",g={stopRequested:!1},y=()=>{wF(i,c,g,l)};process.on("SIGTERM",y),process.on("SIGINT",y);let w=setInterval(()=>{(async()=>(i.resource=await gd(i),i.progress.heartbeat_at=O(),l()))()},sb("PM_BACKGROUND_RUN_RESOURCE_INTERVAL_MS",tF));w.unref?.(),c.stdout?.on("data",S=>{let x=S.toString("utf8");_+=x,u=Yk(u,i.stdout_path,x)}),c.stderr?.on("data",S=>{let x=S.toString("utf8");m=Yk(m,i.stderr_path,x),h+=x;let D=h.split(/\r?\n/);h=D.pop();let j=!1;for(let T of D){let E=T.trimEnd();E.length>0&&Jk(i,E,g.stopRequested)&&(j=!0)}j&&l()});let v=null,k=null;try{({code:v,signal:k}=await new Promise(S=>{c.on("close",(x,D)=>{S({code:x,signal:D})})}))}finally{clearInterval(w),process.off("SIGTERM",y),process.off("SIGINT",y)}await u,await m;let b=h.trimEnd();b.length>0&&Jk(i,b,g.stopRequested)&&l(),h="";let A=bF(_),C=pF(i.kind,A);return i.summary=C.summary,i.exit_code=typeof v=="number"?v:void 0,i.signal=k??void 0,i.finished_at=O(),i.status=SF(i.exit_code,C.summary,g.stopRequested),i.progress=AF(i,g.stopRequested),i.resource=await gd(i),await xF(i,A,_),await Qe(e,i),await d.flush(),i}async function bd(e,t){let n=await cF(e),r=[];for(let c of n){let d=await ee(c);if(!d)continue;let l=await rb(d,c);r.push(l)}let i=[];for(let c of r)i.push(await Lr(e,c));let o=(t.status?i.filter(c=>c.status===t.status):i).sort((c,d)=>{let l=Date.parse(d.updated_at)-Date.parse(c.updated_at);return Number.isFinite(l)&&l!==0?l:d.id.localeCompare(c.id)}),a=typeof t.limit=="number"&&t.limit>=0?t.limit:void 0;return a===void 0?o:o.slice(0,a)}async function ab(e,t){let n=await Dn(e,t);if(!n)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let r=await Lr(e,n),i=Fn(r.worker_pid),s=Fn(r.child_pid);r.status==="running"&&!s&&!r.finished_at&&!i&&(r.status="failed",r.finished_at=O(),r.error=r.error??"Background run process exited unexpectedly.",await Qe(e,r)),r.status==="running"&&(r.resource=await gd(r),await Qe(e,r));let o=r.progress?.heartbeat_at,a=o?Date.parse(o):Number.NaN,c=Number.isFinite(a)?Math.max(0,tb()-a):void 0,d=Number.parseInt(process.env.PM_BACKGROUND_RUN_HEARTBEAT_STALE_MS??"",10),l=Number.isFinite(d)&&d>0?d:rF,u=r.status==="running"?c!==void 0&&c>l?"stale":"healthy":"inactive";return{run:r,health:{state:u,last_heartbeat_at:o,heartbeat_lag_ms:c,worker_alive:i,child_alive:s}}}function CF(e,t){let n=t?"SIGKILL":"SIGTERM";if(!Fn(e.worker_pid)||!e.worker_pid)return"none";try{return process.kill(e.worker_pid,n),n}catch{return"none"}}function EF(e,t){return{phase:"stopping",message:t==="none"?"Run marked stopped.":`Stop requested via ${t}.`,heartbeat_at:O(),item_index:e.progress?.item_index,item_total:e.progress?.item_total,item_id:e.progress?.item_id,linked_test_index:e.progress?.linked_test_index,linked_test_total:e.progress?.linked_test_total,current_command:e.progress?.current_command,elapsed_ms:e.progress?.elapsed_ms}}async function cb(e,t,n=!1){let r=await Dn(e,t);if(!r)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let i=await Lr(e,r);if(wd.has(i.status))return{run:i,signal_sent:"none"};let s=CF(i,n);return s==="none"&&(i.status="stopped",i.finished_at=i.finished_at??O()),i.stop_requested_at=O(),i.progress=EF(i,s),await Qe(e,i),{run:i,signal_sent:s}}async function db(e,t,n,r=!1){let i=await Dn(e,t);if(!i)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let s=await Lr(e,i);if(!wd.has(s.status))throw new f(`Background test run ${t} is not terminal and cannot be resumed.`,p.CONFLICT);let o=await vd({pmRoot:s.pm_root,globalPmRoot:s.global_pm_root,kind:s.kind,commandArgs:s.command_args,requestedBy:n,targetId:s.target_id,statusFilter:s.status_filter,resumedFrom:s.id,resumedBy:n,attempt:s.attempt+1});if(!o.started)return o.run;let a=await kd({pmRoot:e,runId:o.run.id,noExtensions:r}),c={...s,resumed_by:a.id};return await Qe(e,c),a}async function lb(e,t,n,r){let i=await Dn(e,t);if(!i)throw new f(`Background test run ${t} not found`,p.NOT_FOUND);let s=typeof r=="number"&&Number.isFinite(r)&&r>=0?Math.floor(r):eb,o=n==="stdout"||n==="both"?await ee(i.stdout_path)??"":"",a=n==="stderr"||n==="both"?await ee(i.stderr_path)??"":"";return{run:i,stream:n,tail:s,stdout:n==="stdout"||n==="both"?yd(o,s):[],stderr:n==="stderr"||n==="both"?yd(a,s):[]}}var TF=["queued","running","passed","failed","stopped","canceled"],IF=["stdout","stderr","both"];function OF(e){if(e===void 0)return;let t=e.trim().toLowerCase();if(TF.includes(t))return t;throw new f(`Invalid --status value "${e}"`,p.USAGE)}function NF(e){if(e===void 0||e.trim().length===0)return"stderr";let t=e.trim().toLowerCase();if(IF.includes(t))return t;throw new f(`Invalid --stream value "${e}"`,p.USAGE)}function $F(){try{let e=RF.userInfo().username.trim();if(e.length>0)return e}catch{}}function ub(e,t){let n=[e,Zl(),t,process.env.USER,process.env.LOGNAME,process.env.USERNAME,$F()];for(let r of n){if(typeof r!="string")continue;let i=r.trim();if(i.length>0)return i}return"unknown"}async function Jt(e){await z(e)}async function fY(e,t){let n=I(process.cwd(),t.path),r=tt(process.cwd());await Jt(n);let i=await R(n),s=ub(e.author,i.author_default),o=await vd({pmRoot:n,globalPmRoot:r,kind:e.kind,commandArgs:e.commandArgs,requestedBy:s,targetId:e.targetId,statusFilter:e.statusFilter});return o.started?{started:!0,run:await kd({pmRoot:n,runId:o.run.id,noExtensions:e.noExtensions===!0})}:{started:!1,duplicate_of:o.duplicate_of,run:o.run}}async function _Y(e,t){let n=I(process.cwd(),t.path);await Jt(n);let r=OF(e.status),i=Hn(e.limit,"limit"),s=await bd(n,{status:r,limit:i});return{runs:s,count:s.length,filters:{status:r,limit:i}}}async function hY(e,t){let n=I(process.cwd(),t.path);await Jt(n);let r=await ab(n,e);return{run:r.run,health:r.health}}async function gY(e,t,n){let r=I(process.cwd(),n.path);await Jt(r);let i=NF(t.stream),s=Hn(t.tail,"tail"),o=await lb(r,e,i,s);return{run:o.run,stream:o.stream,tail:o.tail,stdout:o.stdout,stderr:o.stderr}}async function yY(e,t,n){let r=I(process.cwd(),n.path);await Jt(r);let i=await cb(r,e,t.force===!0);return{run:i.run,signal_sent:i.signal_sent}}async function wY(e,t,n){let r=I(process.cwd(),n.path);await Jt(r);let i=await R(r),s=ub(t.author,i.author_default),o=await db(r,e,s,t.noExtensions===!0);return{resumed_from:e,run:o}}async function vY(e,t){let n=I(process.cwd(),t.path);await Jt(n);let r=await ob(n,e,t.noExtensions===!0);return{id:r.id,status:r.status,exit_code:r.exit_code}}export{aS as a,f_ as b,MF as c,tD as d,lS as e,jt as f,nD as g,uS as h,h_ as i,rD as j,ar as k,iD as l,pS as m,_S as n,sD as o,w_ as p,uD as q,mD as r,F_ as s,pD as t,fD as u,_D as v,Sa as w,hD as x,gD as y,yD as z,wD as A,vD as B,tA as C,kn as D,nA as E,AD as F,xD as G,xa as H,CD as I,ED as J,RD as K,sA as L,TD as M,ID as N,OD as O,ND as P,Ca as Q,Q_ as R,LD as S,J_ as T,nh as U,_A as V,bn as W,vA as X,ih as Y,AA as Z,HD as _,Ea as $,ah as aa,CA as ba,JD as ca,QD as da,ch as ea,ZD as fa,eP as ga,$ as ha,be as ia,Xe as ja,Sn as ka,Ra as la,lh as ma,st as na,dr as oa,LA as pa,Oa as qa,Na as ra,fh as sa,An as ta,mr as ua,La as va,ZA as wa,vh as xa,pr as ya,bh as za,es as Aa,Ma as Ba,Sh as Ca,Ah as Da,xh as Ea,Nx as Fa,jP as Ga,SC as Ha,Zh as Ia,XP as Ja,yr as Ka,JP as La,IC as Ma,OC as Na,QP as Oa,NC as Pa,rg as Qa,og as Ra,wU as Sa,qC as Ta,GC as Ua,lg as Va,qa as Wa,AU as Xa,TU as Ya,fg as Za,hg as _a,HU as $a,VU as ab,wr as bb,cs as cb,vg as db,kg as eb,bg as fb,Sg as gb,Eg as hb,Rg as ib,pE as jb,Ig as kb,_E as lb,gE as mb,yE as nb,wE as ob,Mg as pb,Fg as qb,Dg as rb,ls as sb,us as tb,wy as ub,Kq as vb,vy as wb,by as xb,Sy as yb,Cy as zb,Ry as Ab,LT as Bb,jG as Cb,xw as Db,Ar as Eb,Rw as Fb,Tw as Gb,Iw as Hb,Cc as Ib,KI as Jb,SK as Kb,Fw as Lb,BK as Mb,XK as Nb,iO as Ob,xs as Pb,Ic as Qb,jw as Rb,mz as Sb,EO as Tb,Cs as Ub,Es as Vb,Ts as Wb,Zw as Xb,Ds as Yb,MO as Zb,$c as _b,jW as $b,Ht as ac,oN as bc,Ws as cc,Av as dc,xv as ec,WB as fc,bN as gc,jN as hc,GN as ic,Tr as jc,BB as kc,yH as lc,O$ as mc,Zc as nc,wH as oc,vH as pc,Js as qc,MH as rc,FH as sc,DH as tc,lk as uc,YH as vc,nL as wc,od as xc,rL as yc,iL as zc,sL as Ac,XH as Bc,JH as Cc,lV as Dc,uV as Ec,mV as Fc,Ck as Gc,Ek as Hc,wL as Ic,Rk as Jc,LV as Kc,Tk as Lc,MV as Mc,FV as Nc,Zs as Oc,FL as Pc,KV as Qc,cd as Rc,zV as Sc,dd as Tc,u2 as Uc,Mk as Vc,x2 as Wc,C2 as Xc,H2 as Yc,fY as Zc,_Y as _c,hY as $c,gY as ad,yY as bd,wY as cd,vY as dd};
23
- //# sourceMappingURL=chunk-U7RBJGLF.js.map
23
+ //# sourceMappingURL=chunk-SDXCJZKB.js.map