@unbrained/pm-cli 2026.8.5 → 2026.8.7

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 (251) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +44 -0
  3. package/dist/cli/main.js +14 -37
  4. package/dist/cli/register-operations.js +11 -2
  5. package/dist/cli/register-setup.d.ts +1 -1
  6. package/dist/cli/register-setup.js +46 -20
  7. package/dist/cli/stats-analytics-json.d.ts +9 -0
  8. package/dist/cli/stats-analytics-json.js +69 -0
  9. package/dist/cli-bundle/bundle-manifest.json +403 -403
  10. package/dist/cli-bundle/chunks/append-7BXBFDGD.js +2 -0
  11. package/dist/cli-bundle/chunks/{chunk-PMXJEU3F.js → chunk-2AXF3VSK.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-MHK6LIWE.js → chunk-2XS43CCV.js} +2 -2
  13. package/dist/cli-bundle/chunks/chunk-3A6KWB72.js +8 -0
  14. package/dist/cli-bundle/chunks/chunk-3ISTDB42.js +8 -0
  15. package/dist/cli-bundle/chunks/{chunk-45G53IU4.js → chunk-4MTI7XOV.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-7C4PTJG6.js → chunk-6BX5UDCN.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-4YUBDMQM.js → chunk-6QPO7KLR.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-HWRRMBJO.js → chunk-7MXHZHSQ.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-3FTILRJ2.js → chunk-7ZPMJW4U.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-2WFXWAYX.js → chunk-AGYNSNCI.js} +2 -2
  21. package/dist/cli-bundle/chunks/chunk-B4H7FEFH.js +5 -0
  22. package/dist/cli-bundle/chunks/{chunk-43HQQI6S.js → chunk-B4KLBBMN.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-VCKLFEUN.js → chunk-CALJHNBL.js} +12 -12
  24. package/dist/cli-bundle/chunks/{chunk-CSI3WS5I.js → chunk-CFIGP5LY.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-V3EUXXOF.js → chunk-CS6MRHG7.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-YSO3YFZ4.js → chunk-CUGNQQKH.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-D4FPS43D.js +164 -0
  28. package/dist/cli-bundle/chunks/{chunk-BXQLRKWF.js → chunk-H5Y5YE6A.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-54FNT7U2.js → chunk-H5Y6UV6E.js} +2 -2
  30. package/dist/cli-bundle/chunks/{chunk-UP7DTVMD.js → chunk-H7KGWPDF.js} +2 -2
  31. package/dist/cli-bundle/chunks/{chunk-E2RKBKWB.js → chunk-HFSD77TQ.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-V3774P7D.js → chunk-HX2GTA6L.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-UZBWIUYD.js → chunk-J2IEKAVR.js} +2 -2
  34. package/dist/cli-bundle/chunks/{chunk-HNFD72UK.js → chunk-K44PYFXH.js} +2 -2
  35. package/dist/cli-bundle/chunks/{chunk-5ZBOIPGP.js → chunk-K4KGEEBT.js} +2 -2
  36. package/dist/cli-bundle/chunks/chunk-KFLK5TRH.js +21 -0
  37. package/dist/cli-bundle/chunks/{chunk-OMXVBQ2N.js → chunk-KL6IEBV2.js} +2 -2
  38. package/dist/cli-bundle/chunks/{chunk-7A5OT5J2.js → chunk-KWQZDZSS.js} +2 -2
  39. package/dist/cli-bundle/chunks/{chunk-M72BKL5Q.js → chunk-KZ4X3DGU.js} +2 -2
  40. package/dist/cli-bundle/chunks/chunk-LD77HJMQ.js +13 -0
  41. package/dist/cli-bundle/chunks/{chunk-VN5VITU3.js → chunk-ME2JJ4LA.js} +2 -2
  42. package/dist/cli-bundle/chunks/chunk-NFLJ3FHD.js +2 -0
  43. package/dist/cli-bundle/chunks/{chunk-A62CYISG.js → chunk-NG6OXIBR.js} +8 -8
  44. package/dist/cli-bundle/chunks/{chunk-42E7YPLG.js → chunk-NYIGHWQY.js} +2 -2
  45. package/dist/cli-bundle/chunks/{chunk-RKAVWO3O.js → chunk-NZ75GNSA.js} +2 -2
  46. package/dist/cli-bundle/chunks/{chunk-DXDREUXT.js → chunk-PCJWJNC2.js} +2 -2
  47. package/dist/cli-bundle/chunks/{chunk-ZYHOB3SN.js → chunk-PD3225AM.js} +2 -2
  48. package/dist/cli-bundle/chunks/{chunk-OTHLDSFP.js → chunk-PDEGKG7P.js} +2 -2
  49. package/dist/cli-bundle/chunks/chunk-PIE5HBNA.js +2 -0
  50. package/dist/cli-bundle/chunks/chunk-PW2H7YJR.js +56 -0
  51. package/dist/cli-bundle/chunks/{chunk-L3AZOELJ.js → chunk-TPKN3S7S.js} +2 -2
  52. package/dist/cli-bundle/chunks/{chunk-LKDGK44W.js → chunk-TPXAXTCO.js} +2 -2
  53. package/dist/cli-bundle/chunks/chunk-UFWUJO4V.js +2 -0
  54. package/dist/cli-bundle/chunks/{chunk-R546TPDE.js → chunk-UQLZQVFW.js} +2 -2
  55. package/dist/cli-bundle/chunks/{chunk-BPELKUQD.js → chunk-VT3Z5G7D.js} +2 -2
  56. package/dist/cli-bundle/chunks/chunk-WOD3WWUN.js +2 -0
  57. package/dist/cli-bundle/chunks/{chunk-4VN6GS4U.js → chunk-WSJEIGJF.js} +2 -2
  58. package/dist/cli-bundle/chunks/{chunk-UN66FZRO.js → chunk-WYNUU7ZW.js} +49 -46
  59. package/dist/cli-bundle/chunks/{chunk-NY4T3JWN.js → chunk-YGPNCCXZ.js} +2 -2
  60. package/dist/cli-bundle/chunks/close-CMY3BAUG.js +2 -0
  61. package/dist/cli-bundle/chunks/close-many-SA4XZCTK.js +2 -0
  62. package/dist/cli-bundle/chunks/comments-EZ556ZD3.js +2 -0
  63. package/dist/cli-bundle/chunks/copy-ZSGPA52X.js +2 -0
  64. package/dist/cli-bundle/chunks/{create-XLKTXTUF.js → create-I5DVV4YG.js} +2 -2
  65. package/dist/cli-bundle/chunks/delete-RL3JACSW.js +2 -0
  66. package/dist/cli-bundle/chunks/{deps-ITTY3GIC.js → deps-S7UBCECS.js} +2 -2
  67. package/dist/cli-bundle/chunks/{docs-W4OSRTYR.js → docs-ZZNVBBYO.js} +2 -2
  68. package/dist/cli-bundle/chunks/{files-EOK4AZI4.js → files-27C337VT.js} +2 -2
  69. package/dist/cli-bundle/chunks/focus-5Z2SG7LU.js +2 -0
  70. package/dist/cli-bundle/chunks/{history-compact-7UGTMLL3.js → history-compact-HJQK67CZ.js} +2 -2
  71. package/dist/cli-bundle/chunks/{history-redact-4DZRMD6Z.js → history-redact-PWC6PDWA.js} +2 -2
  72. package/dist/cli-bundle/chunks/{history-repair-UPOSZW5R.js → history-repair-N3CY4WBF.js} +2 -2
  73. package/dist/cli-bundle/chunks/{learnings-GMRNCBS3.js → learnings-4FH23XDT.js} +2 -2
  74. package/dist/cli-bundle/chunks/{profile-2MUUMHRE.js → profile-5Y5XXH5N.js} +2 -2
  75. package/dist/cli-bundle/chunks/{register-list-query-LR3SQ5ZF.js → register-list-query-FJZCJ67O.js} +2 -2
  76. package/dist/cli-bundle/chunks/{register-mutation-SUOHFVWM.js → register-mutation-YGYPW3BL.js} +3 -3
  77. package/dist/cli-bundle/chunks/register-operations-WMDSUMQF.js +2 -0
  78. package/dist/cli-bundle/chunks/register-setup-DL7FFABC.js +2 -0
  79. package/dist/cli-bundle/chunks/restore-6KYBV5BY.js +2 -0
  80. package/dist/cli-bundle/chunks/{schema-FJ4EA3XF.js → schema-EQGKBYXJ.js} +2 -2
  81. package/dist/cli-bundle/chunks/update-QVTYOD6I.js +2 -0
  82. package/dist/cli-bundle/chunks/update-many-DJSBU525.js +2 -0
  83. package/dist/cli-bundle/focused-chunks/{chunk-MJ7HWSFK.js → chunk-2ECLECMK.js} +3 -3
  84. package/dist/cli-bundle/focused-chunks/{chunk-A7BJ5SS6.js → chunk-3K4XV2BF.js} +2 -2
  85. package/dist/cli-bundle/focused-chunks/{chunk-PIMMYG7Q.js → chunk-4EX25PXM.js} +2 -2
  86. package/dist/cli-bundle/focused-chunks/chunk-4VJQTS3P.js +2 -0
  87. package/dist/cli-bundle/focused-chunks/chunk-73JUDYXT.js +2 -0
  88. package/dist/cli-bundle/focused-chunks/{chunk-WVIVUWVL.js → chunk-CIXVQPB7.js} +2 -2
  89. package/dist/cli-bundle/focused-chunks/chunk-DLTS3IHM.js +2 -0
  90. package/dist/cli-bundle/focused-chunks/{chunk-FGKY4MBE.js → chunk-DQ6FKGL3.js} +10 -10
  91. package/dist/cli-bundle/focused-chunks/{chunk-QVHKCI4T.js → chunk-HNL6IFGS.js} +2 -2
  92. package/dist/cli-bundle/focused-chunks/chunk-JLG2C4EQ.js +2 -0
  93. package/dist/cli-bundle/focused-chunks/{chunk-G6ETT4QK.js → chunk-MHMTKV5V.js} +2 -2
  94. package/dist/cli-bundle/focused-chunks/{chunk-7J5TUBUJ.js → chunk-MOTJFQ3F.js} +22 -22
  95. package/dist/cli-bundle/focused-chunks/{chunk-UIL2M2NA.js → chunk-NBJKQP4S.js} +2 -2
  96. package/dist/cli-bundle/focused-chunks/{chunk-RUR5I3TK.js → chunk-QHRTT7WT.js} +2 -2
  97. package/dist/cli-bundle/focused-chunks/{chunk-B7LJWAZE.js → chunk-R2LEMEV5.js} +2 -2
  98. package/dist/cli-bundle/focused-chunks/{chunk-SV3O7TSH.js → chunk-RPNYG5MO.js} +2 -2
  99. package/dist/cli-bundle/focused-chunks/chunk-RW5IYD4J.js +4 -0
  100. package/dist/cli-bundle/focused-chunks/chunk-TIKDBG4D.js +29 -0
  101. package/dist/cli-bundle/focused-chunks/{chunk-IPWSFADF.js → chunk-VZFU2R4M.js} +2 -2
  102. package/dist/cli-bundle/focused-chunks/{chunk-WEM2E2PE.js → chunk-YZEZAPJK.js} +2 -2
  103. package/dist/cli-bundle/focused-chunks/chunk-ZJIMJHDB.js +2 -0
  104. package/dist/cli-bundle/main.js +13 -13
  105. package/dist/cli-bundle/sdk-authoring.js +1 -1
  106. package/dist/cli-bundle/sdk-contracts.js +1 -1
  107. package/dist/cli-bundle/sdk-core.js +29 -28
  108. package/dist/cli-bundle/sdk-governance.js +1 -1
  109. package/dist/cli-bundle/sdk-graph.js +1 -1
  110. package/dist/cli-bundle/sdk-merge.js +1 -1
  111. package/dist/cli-bundle/sdk-query.js +1 -1
  112. package/dist/cli-bundle/sdk-runtime.js +1 -1
  113. package/dist/cli-bundle/sdk-testing.js +1 -1
  114. package/dist/cli-bundle/sdk.js +1 -1
  115. package/dist/core/extensions/activation-summary.d.ts +4 -0
  116. package/dist/core/extensions/activation-summary.js +5 -2
  117. package/dist/core/extensions/contribution-inventory.d.ts +1 -0
  118. package/dist/core/extensions/contribution-inventory.js +35 -2
  119. package/dist/core/extensions/extension-hook-runtime.js +5 -3
  120. package/dist/core/extensions/extension-types.d.ts +18 -1
  121. package/dist/core/extensions/extension-types.js +2 -2
  122. package/dist/core/extensions/loader.js +5 -13
  123. package/dist/core/extensions/preflight-ownership.d.ts +5 -0
  124. package/dist/core/extensions/preflight-ownership.js +42 -0
  125. package/dist/core/extensions/reserved-host-flags.js +3 -2
  126. package/dist/core/history/workspace-history.d.ts +22 -2
  127. package/dist/core/history/workspace-history.js +60 -36
  128. package/dist/core/output/output.d.ts +2 -0
  129. package/dist/core/output/output.js +3 -2
  130. package/dist/core/shared/command-types.d.ts +2 -0
  131. package/dist/core/shared/command-types.js +2 -2
  132. package/dist/mcp/tool-definitions.js +6 -2
  133. package/dist/sdk/author-attribution.js +23 -7
  134. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  135. package/dist/sdk/cli-bootstrap.js +7 -2
  136. package/dist/sdk/cli-contracts/completeness.js +51 -4
  137. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  138. package/dist/sdk/cli-contracts/flag-contracts.js +9 -2
  139. package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
  140. package/dist/sdk/cli-contracts/runtime-contracts.js +16 -9
  141. package/dist/sdk/cli-contracts/tool-parameter-tables.js +116 -10
  142. package/dist/sdk/cli-contracts/tool-schema.js +18 -2
  143. package/dist/sdk/cli-contracts.d.ts +1 -1
  144. package/dist/sdk/cli-contracts.js +3 -3
  145. package/dist/sdk/cli-program.js +3 -2
  146. package/dist/sdk/completion.js +5 -2
  147. package/dist/sdk/compose.d.ts +2 -2
  148. package/dist/sdk/compose.js +7 -2
  149. package/dist/sdk/contracts.d.ts +1 -0
  150. package/dist/sdk/contracts.js +2 -2
  151. package/dist/sdk/core.d.ts +3 -1
  152. package/dist/sdk/core.js +4 -3
  153. package/dist/sdk/define.d.ts +3 -1
  154. package/dist/sdk/define.js +3 -8
  155. package/dist/sdk/extension/install-sources.d.ts +43 -5
  156. package/dist/sdk/extension/install-sources.js +36 -2
  157. package/dist/sdk/extension/migrations.d.ts +114 -0
  158. package/dist/sdk/extension/migrations.js +175 -0
  159. package/dist/sdk/extension/scaffold.js +14 -9
  160. package/dist/sdk/extension/source-resolution.d.ts +50 -0
  161. package/dist/sdk/extension/source-resolution.js +66 -0
  162. package/dist/sdk/extension.d.ts +5 -1
  163. package/dist/sdk/extension.js +31 -35
  164. package/dist/sdk/generated-error-code-catalog.js +112 -2
  165. package/dist/sdk/governance/health.js +11 -2
  166. package/dist/sdk/history-analytics.d.ts +141 -0
  167. package/dist/sdk/history-analytics.js +283 -0
  168. package/dist/sdk/improvement-ledger-validation.d.ts +3 -0
  169. package/dist/sdk/improvement-ledger-validation.js +63 -0
  170. package/dist/sdk/improvement-ledger.d.ts +139 -0
  171. package/dist/sdk/improvement-ledger.js +261 -0
  172. package/dist/sdk/index.d.ts +11 -3
  173. package/dist/sdk/index.js +12 -4
  174. package/dist/sdk/lifecycle/plan.js +6 -3
  175. package/dist/sdk/merge/install.js +10 -2
  176. package/dist/sdk/package-migrations.d.ts +10 -0
  177. package/dist/sdk/package-migrations.js +21 -0
  178. package/dist/sdk/read-output-budget.js +24 -22
  179. package/dist/sdk/read-output-contracts.d.ts +10 -2
  180. package/dist/sdk/read-output-contracts.js +124 -65
  181. package/dist/sdk/read-output-rows.d.ts +29 -0
  182. package/dist/sdk/read-output-rows.js +100 -0
  183. package/dist/sdk/read-output-session.d.ts +69 -0
  184. package/dist/sdk/read-output-session.js +200 -0
  185. package/dist/sdk/runtime-input.d.ts +2 -0
  186. package/dist/sdk/runtime-input.js +14 -2
  187. package/dist/sdk/runtime-primitives.d.ts +1 -1
  188. package/dist/sdk/runtime-primitives.js +3 -3
  189. package/dist/sdk/runtime-stats-options.d.ts +9 -0
  190. package/dist/sdk/runtime-stats-options.js +38 -0
  191. package/dist/sdk/runtime.d.ts +3 -0
  192. package/dist/sdk/runtime.js +10 -27
  193. package/dist/sdk/stats.d.ts +40 -0
  194. package/dist/sdk/stats.js +112 -29
  195. package/docs/COMMANDS.md +9 -0
  196. package/docs/EXTENSIONS.md +2 -2
  197. package/docs/EXTENSION_LIFECYCLE.md +46 -0
  198. package/docs/IMPROVEMENT_ANALYTICS.md +103 -0
  199. package/docs/OUTPUT_PROJECTION_CONTRACTS.md +5 -5
  200. package/docs/README.md +2 -0
  201. package/docs/READ_OUTPUT_CONTRACTS.md +60 -1
  202. package/docs/RELEASING.md +33 -20
  203. package/docs/SDK.md +31 -3
  204. package/marketplace.json +2 -2
  205. package/package.json +5 -5
  206. package/packages/pm-beads/package.json +1 -1
  207. package/packages/pm-calendar/package.json +1 -1
  208. package/packages/pm-command-kit/package.json +1 -1
  209. package/packages/pm-digital-twin/package.json +1 -1
  210. package/packages/pm-governance-audit/package.json +1 -1
  211. package/packages/pm-guide-shell/package.json +1 -1
  212. package/packages/pm-kanban/package.json +1 -1
  213. package/packages/pm-lifecycle-hooks/package.json +1 -1
  214. package/packages/pm-linked-test-adapters/package.json +1 -1
  215. package/packages/pm-search-advanced/package.json +1 -1
  216. package/packages/pm-templates/package.json +1 -1
  217. package/packages/pm-todos/package.json +1 -1
  218. package/packages/pm-vcs/package.json +1 -1
  219. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  220. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  221. package/sdk/public-surface.json +566 -815
  222. package/dist/cli-bundle/chunks/append-VXXGOXSG.js +0 -2
  223. package/dist/cli-bundle/chunks/chunk-6MSQJOTG.js +0 -13
  224. package/dist/cli-bundle/chunks/chunk-EGJ4JTUG.js +0 -55
  225. package/dist/cli-bundle/chunks/chunk-FPBQHMFT.js +0 -8
  226. package/dist/cli-bundle/chunks/chunk-GE4KCSZP.js +0 -164
  227. package/dist/cli-bundle/chunks/chunk-LN2WFEU4.js +0 -2
  228. package/dist/cli-bundle/chunks/chunk-OPVH7SKD.js +0 -8
  229. package/dist/cli-bundle/chunks/chunk-Q35VBGOQ.js +0 -5
  230. package/dist/cli-bundle/chunks/chunk-SSF4PIUR.js +0 -2
  231. package/dist/cli-bundle/chunks/chunk-WRL4KNDL.js +0 -20
  232. package/dist/cli-bundle/chunks/chunk-XCEZYMNI.js +0 -2
  233. package/dist/cli-bundle/chunks/chunk-YEWNL576.js +0 -2
  234. package/dist/cli-bundle/chunks/close-VZ3OQPN5.js +0 -2
  235. package/dist/cli-bundle/chunks/close-many-SB4TI27P.js +0 -2
  236. package/dist/cli-bundle/chunks/comments-BIF3Q4KY.js +0 -2
  237. package/dist/cli-bundle/chunks/copy-6AI5Z57X.js +0 -2
  238. package/dist/cli-bundle/chunks/delete-ZY2VHQTP.js +0 -2
  239. package/dist/cli-bundle/chunks/focus-DLBNWL7L.js +0 -2
  240. package/dist/cli-bundle/chunks/register-operations-ARRRKOVN.js +0 -2
  241. package/dist/cli-bundle/chunks/register-setup-O6AYP6NP.js +0 -2
  242. package/dist/cli-bundle/chunks/restore-ZVCVHTB5.js +0 -2
  243. package/dist/cli-bundle/chunks/update-YHV52CSS.js +0 -2
  244. package/dist/cli-bundle/chunks/update-many-M6YHVNXM.js +0 -2
  245. package/dist/cli-bundle/focused-chunks/chunk-BIMTMOS7.js +0 -4
  246. package/dist/cli-bundle/focused-chunks/chunk-GJ2TG2CW.js +0 -28
  247. package/dist/cli-bundle/focused-chunks/chunk-N5XU5UVK.js +0 -2
  248. package/dist/cli-bundle/focused-chunks/chunk-PG2RIZBX.js +0 -2
  249. package/dist/cli-bundle/focused-chunks/chunk-VLYOEYML.js +0 -2
  250. package/dist/cli-bundle/focused-chunks/chunk-W7BJEWHX.js +0 -2
  251. package/dist/cli-bundle/focused-chunks/chunk-Y4LDYLLT.js +0 -2
@@ -1,2 +1,2 @@
1
- import{bd as u,cd as p}from"./chunk-GE4KCSZP.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf429f76-9722-5e34-a5f0-6ced8d1ed667")}catch{}})();var D="blocked_by",B="no-active-blocker";function d(e){return e.trim().toLowerCase()}function b(e){let t=new Set,n=typeof e.blocked_by=="string"?e.blocked_by.trim():"";n.length>0&&n.toLowerCase()!==B&&t.add(n);for(let o of e.dependencies??[])o.kind===D&&typeof o.id=="string"&&o.id.trim().length>0&&o.id.trim().toLowerCase()!==B&&t.add(o.id.trim());return[...t].sort((o,c)=>o.localeCompare(c))}function k(e,t,n){return b(e).map(o=>{let c=t.get(d(o));return c?{id:o,title:c.title,status:c.status,resolved:p(c.status,n)}:{id:o,title:null,status:null,resolved:!1}})}function C(e,t){let n=new Map(e.map(s=>[d(s.id),s])),o=new Set([...I(t),...t.blocked_statuses]),c=new Set;for(let s of e){let l=u(s.status,t);if(!o.has(l))continue;(t.blocked_statuses.has(l)||k(s,n,t).some(a=>!a.resolved))&&c.add(d(s.id))}return c}function I(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function E(e,t,n){let o=[d(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let l of t.get(s)??[]){if(!p(l.status,n))return!0;o.push(d(l.id))}}}return!1}function T(e){let t=new Map,n=new Map,o=new Map;for(let c of e){t.set(d(c.id),c);let s=typeof c.parent=="string"?c.parent.trim():"";if(s.length>0){let l=d(s),i=n.get(l)??[];i.push(c),n.set(l,i)}for(let l of b(c)){let i=d(l),a=o.get(i)??[];a.push(c.id),o.set(i,a)}}return{itemsById:t,childrenByParent:n,blockedByReverse:o}}function x(e,t,n){let{itemsById:o,childrenByParent:c,blockedByReverse:s}=T(t),l=new Set([...I(n),...n.blocked_statuses]),i=new Set(t.filter(r=>!p(r.status,n)).map(r=>d(r.id))),a=[],y=[],m=0,h=0;for(let r of e){if(!l.has(u(r.status,n)))continue;if(m+=1,E(r.id,c,n)){h+=1;continue}let w=k(r,o,n).filter(f=>!f.resolved),v=(s.get(d(r.id))??[]).filter(f=>i.has(d(f))).sort((f,S)=>f.localeCompare(S)),_={item:r,open_blockers:w,unblocks:v},g=n.blocked_statuses.has(u(r.status,n));w.length===0&&!g?a.push(_):y.push(_)}return{ready:a,blocked:y,active_count:m,container_count:h}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9184e723-8269-5e45-8c6a-52fd02da60e6")}catch{}})();export{b as a,k as b,C as c,x as d};
2
- //# sourceMappingURL=chunk-BXQLRKWF.js.map
1
+ import{bd as u,cd as p}from"./chunk-D4FPS43D.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bf429f76-9722-5e34-a5f0-6ced8d1ed667")}catch{}})();var D="blocked_by",B="no-active-blocker";function d(e){return e.trim().toLowerCase()}function b(e){let t=new Set,n=typeof e.blocked_by=="string"?e.blocked_by.trim():"";n.length>0&&n.toLowerCase()!==B&&t.add(n);for(let o of e.dependencies??[])o.kind===D&&typeof o.id=="string"&&o.id.trim().length>0&&o.id.trim().toLowerCase()!==B&&t.add(o.id.trim());return[...t].sort((o,c)=>o.localeCompare(c))}function k(e,t,n){return b(e).map(o=>{let c=t.get(d(o));return c?{id:o,title:c.title,status:c.status,resolved:p(c.status,n)}:{id:o,title:null,status:null,resolved:!1}})}function C(e,t){let n=new Map(e.map(s=>[d(s.id),s])),o=new Set([...I(t),...t.blocked_statuses]),c=new Set;for(let s of e){let l=u(s.status,t);if(!o.has(l))continue;(t.blocked_statuses.has(l)||k(s,n,t).some(a=>!a.resolved))&&c.add(d(s.id))}return c}function I(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function E(e,t,n){let o=[d(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let l of t.get(s)??[]){if(!p(l.status,n))return!0;o.push(d(l.id))}}}return!1}function T(e){let t=new Map,n=new Map,o=new Map;for(let c of e){t.set(d(c.id),c);let s=typeof c.parent=="string"?c.parent.trim():"";if(s.length>0){let l=d(s),i=n.get(l)??[];i.push(c),n.set(l,i)}for(let l of b(c)){let i=d(l),a=o.get(i)??[];a.push(c.id),o.set(i,a)}}return{itemsById:t,childrenByParent:n,blockedByReverse:o}}function x(e,t,n){let{itemsById:o,childrenByParent:c,blockedByReverse:s}=T(t),l=new Set([...I(n),...n.blocked_statuses]),i=new Set(t.filter(r=>!p(r.status,n)).map(r=>d(r.id))),a=[],y=[],m=0,h=0;for(let r of e){if(!l.has(u(r.status,n)))continue;if(m+=1,E(r.id,c,n)){h+=1;continue}let w=k(r,o,n).filter(f=>!f.resolved),v=(s.get(d(r.id))??[]).filter(f=>i.has(d(f))).sort((f,S)=>f.localeCompare(S)),_={item:r,open_blockers:w,unblocks:v},g=n.blocked_statuses.has(u(r.status,n));w.length===0&&!g?a.push(_):y.push(_)}return{ready:a,blocked:y,active_count:m,container_count:h}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="9184e723-8269-5e45-8c6a-52fd02da60e6")}catch{}})();export{b as a,k as b,C as c,x as d};
2
+ //# sourceMappingURL=chunk-H5Y5YE6A.js.map
@@ -1,2 +1,2 @@
1
- import{a as T}from"./chunk-5ZBOIPGP.js";import{f as F,i as I}from"./chunk-42E7YPLG.js";import{A as s,Af as N,C as o,Da as _,La as g,Lf as O,Mf as k,Oa as U,R as E,Sf as x,b as K,lc as C,zd as G}from"./chunk-GE4KCSZP.js";import{readFile as L}from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="eeb7b433-094b-5c4f-bc81-d4988ac297b4")}catch{}})();function P(e,n){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new o(`Structured context events are append-only and cannot be ${n}.`,s.USAGE,{code:"structured_event_immutable"})}function V(e,n){return n===void 0?e:n===0?[]:e.slice(Math.max(0,e.length-n))}function p(e,n){let r=e[n];return Array.isArray(r)?r:[]}function se(e,n={}){let r=e.trim();if(!r)return"";let t=/^(?:[-*+]\s*)?text\s*[:=]/i.exec(r);if(n.stripPlainTextPrefix===!0&&t&&!r.startsWith("```"))return r.slice(t[0].length).trim()||r;if(!(/^(?:[-*+]\s*)?text\s*[:=]/im.test(r)||r.startsWith("```")))return r;try{let i=F(r,"--add");return Object.keys(i).map(m=>m.trim().toLowerCase()).some(m=>m!=="text")?r:i.text?.trim()||r}catch{return r}}function j(e){return typeof e=="object"&&e!==null&&"code"in e}async function H(e,n){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new o(`Specify ${n} text using only one input source: --add, --stdin, or --file`,s.USAGE);let t=I();if(e.add!==void 0)return{value:await t.resolveValue(e.add,"--add")??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return{value:await t.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let a=e.file.trim();if(!a)throw new o("--file path cannot be empty",s.USAGE);try{return{value:await L(a,"utf8"),emptyFlag:"--file"}}catch(i){if(j(i)&&i.code==="ENOENT")throw new o(`--file path not found: ${a}`,s.USAGE);let w=i instanceof Error?i.message:String(i);throw new o(`Failed to read --file path "${a}": ${w}`,s.USAGE)}}async function de(e,n){if(e.edit!==void 0&&e.delete!==void 0)throw new o("Specify only one of --edit or --delete",s.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new o("--delete cannot be combined with replacement text",s.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new o("--delete must be a positive integer",s.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new o("--edit must be a positive integer",s.USAGE);let r=await H(e,n);if(e.edit!==void 0){if(!r)throw new o("--edit requires replacement text from --add, --stdin, or --file",s.USAGE);return{mode:"edit",index:e.edit,...r}}return r?{mode:"add",...r}:{mode:"list"}}function v(e,n){throw e instanceof o&&e.exitCode===s.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new o(e.message,e.exitCode,{code:"ownership_conflict",required:n.required,examples:n.examples,nextSteps:n.nextSteps}):e}function M(e){return e==="comments"?"--stdin":"--add -"}function z(e,n){if((n.input.emptyFlag??"--add")!=="--add")return;let t=e.trim();if(!/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(t))return;let a=M(n.collectionKey),i=n.input.mode==="edit"?`pm ${n.collectionKey} <id> --edit <index>`:`pm ${n.collectionKey} <id>`;throw new o(`--add value "${t}" looks like an option, not annotation text. Use ${a} to read stdin, or use text=${t} for literal dash-leading text.`,s.USAGE,{code:"annotation_flag_like_value",required:`Use ${a} for stdin input, pass plain text, or use text=${t} when the text really starts with "-".`,examples:[`${i} ${a}`,`${i} --add text=${t}`]})}function W(e,n){if(e.input.mode!=="list"||n.message===void 0)return;let r=e.collectionKey.replace(/s$/,"");throw new o(`--message labels a ${r} mutation but does not provide ${r} text. Pass text positionally or with --add, --stdin, or --file.`,s.USAGE,{code:"annotation_message_without_text",required:`Provide ${r} 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> ${M(e.collectionKey)}`]})}async function le(e,n,r,t){W(t,n);let a=g(process.cwd(),r.path);if(!await K(U(a)))throw new o(`Tracker is not initialized at ${a}. Run pm init first.`,s.NOT_FOUND);let i=await N(a),w=_(i,C()),y=T(n.limit);if(t.input.mode==="list"){let d=await O(a,e,i.id_prefix,i.item_format,w.type_to_folder);if(!d)throw new o(`Item ${e} not found`,s.NOT_FOUND);let l=await k(d,{schema:i.schema}),f=p(l.document.metadata,t.collectionKey);return b(d.id,t.collectionKey,f,y,n.includeMeta===!0)}let m=G(n.author,i.author_default);if(t.input.mode==="delete"){let d=t.deleteOp??t.op,l;try{l=await x({pmRoot:a,settings:i,id:e,op:d,author:m,message:n.message,force:n.force,bypassAssigneeConflict:t.bypassOwnershipConflict,mutate(u){let c=p(u.metadata,t.collectionKey),h=R(t.input.index,c.length,t.collectionKey);return P(c[h],"deleted"),c.splice(h,1),u.metadata[t.collectionKey]=c,{changedFields:[t.collectionKey]}}})}catch(u){v(u,t.conflictGuidance)}let f=p(l.item,t.collectionKey);return b(l.item.id,t.collectionKey,f,y,n.includeMeta===!0)}let D=t.input.rawValue??t.input.value??"";z(D,t);let $=t.parseText(t.input.value??"");if(!$.trim())throw new o(`${t.input.emptyFlag??"--add"} text cannot be empty`,s.USAGE);if(t.input.mode==="edit"){let d=t.editOp??t.op,l;try{l=await x({pmRoot:a,settings:i,id:e,op:d,author:m,message:n.message,force:n.force,bypassAssigneeConflict:t.bypassOwnershipConflict,mutate(u){let c=p(u.metadata,t.collectionKey),h=R(t.input.index,c.length,t.collectionKey),S=c[h];return P(S,"edited"),c[h]={...S,text:$,edited_at:E()},u.metadata[t.collectionKey]=c,{changedFields:[t.collectionKey]}}})}catch(u){v(u,t.conflictGuidance)}let f=p(l.item,t.collectionKey);return b(l.item.id,t.collectionKey,f,y,n.includeMeta===!0)}let A;try{A=await x({pmRoot:a,settings:i,id:e,op:t.op,author:m,message:n.message,force:n.force,bypassAssigneeConflict:t.bypassOwnershipConflict,mutate(d){let l=p(d.metadata,t.collectionKey),f={created_at:E(),author:m,text:$};return l.push(t.createEntry(f)),d.metadata[t.collectionKey]=l,{changedFields:[t.collectionKey]}}})}catch(d){v(d,t.conflictGuidance)}let q=p(A.item,t.collectionKey);return b(A.item.id,t.collectionKey,q,y,n.includeMeta===!0)}function R(e,n,r){if(e===void 0||!Number.isInteger(e)||e<1||e>n){let t=r.replace(/s$/,""),a=`${t.charAt(0).toUpperCase()}${t.slice(1)}`,i=n===1?`1 ${t}`:`${n} ${r}`;throw new o(`${a} index ${e??"(missing)"} out of range (item has ${i})`,s.USAGE)}return e-1}function b(e,n,r,t,a){let i=V(r,t);return{id:e,[n]:i,count:i.length,...a?{total_count:r.length,returned_count:i.length,has_more:i.length<r.length,...t!==void 0?{limit:t}:{}}:{}}}export{V as a,p as b,se as c,j as d,de as e,v as f,le as g,R as h};
2
- //# sourceMappingURL=chunk-54FNT7U2.js.map
1
+ import{a as T}from"./chunk-K4KGEEBT.js";import{f as F,i as I}from"./chunk-NYIGHWQY.js";import{A as s,C as o,Da as _,La as g,Nf as N,Oa as U,R as E,Yf as O,Zf as k,b as K,dg as x,lc as C,zd as G}from"./chunk-D4FPS43D.js";import{readFile as L}from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="eeb7b433-094b-5c4f-bc81-d4988ac297b4")}catch{}})();function P(e,n){if(typeof e=="object"&&e!==null&&"format"in e&&e.format==="json")throw new o(`Structured context events are append-only and cannot be ${n}.`,s.USAGE,{code:"structured_event_immutable"})}function V(e,n){return n===void 0?e:n===0?[]:e.slice(Math.max(0,e.length-n))}function p(e,n){let r=e[n];return Array.isArray(r)?r:[]}function se(e,n={}){let r=e.trim();if(!r)return"";let t=/^(?:[-*+]\s*)?text\s*[:=]/i.exec(r);if(n.stripPlainTextPrefix===!0&&t&&!r.startsWith("```"))return r.slice(t[0].length).trim()||r;if(!(/^(?:[-*+]\s*)?text\s*[:=]/im.test(r)||r.startsWith("```")))return r;try{let i=F(r,"--add");return Object.keys(i).map(m=>m.trim().toLowerCase()).some(m=>m!=="text")?r:i.text?.trim()||r}catch{return r}}function j(e){return typeof e=="object"&&e!==null&&"code"in e}async function H(e,n){if(+(e.add!==void 0)+ +(e.stdin===!0)+ +(typeof e.file=="string")>1)throw new o(`Specify ${n} text using only one input source: --add, --stdin, or --file`,s.USAGE);let t=I();if(e.add!==void 0)return{value:await t.resolveValue(e.add,"--add")??"",rawValue:e.add,emptyFlag:"--add"};if(e.stdin===!0)return{value:await t.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};if(typeof e.file!="string")return;let a=e.file.trim();if(!a)throw new o("--file path cannot be empty",s.USAGE);try{return{value:await L(a,"utf8"),emptyFlag:"--file"}}catch(i){if(j(i)&&i.code==="ENOENT")throw new o(`--file path not found: ${a}`,s.USAGE);let w=i instanceof Error?i.message:String(i);throw new o(`Failed to read --file path "${a}": ${w}`,s.USAGE)}}async function de(e,n){if(e.edit!==void 0&&e.delete!==void 0)throw new o("Specify only one of --edit or --delete",s.USAGE);if(e.delete!==void 0){if(e.add!==void 0||e.stdin===!0||typeof e.file=="string")throw new o("--delete cannot be combined with replacement text",s.USAGE);if(!Number.isInteger(e.delete)||e.delete<1)throw new o("--delete must be a positive integer",s.USAGE);return{mode:"delete",index:e.delete}}if(e.edit!==void 0&&(!Number.isInteger(e.edit)||e.edit<1))throw new o("--edit must be a positive integer",s.USAGE);let r=await H(e,n);if(e.edit!==void 0){if(!r)throw new o("--edit requires replacement text from --add, --stdin, or --file",s.USAGE);return{mode:"edit",index:e.edit,...r}}return r?{mode:"add",...r}:{mode:"list"}}function v(e,n){throw e instanceof o&&e.exitCode===s.CONFLICT&&e.message.includes("is assigned to")&&e.message.includes("Use --force to override")?new o(e.message,e.exitCode,{code:"ownership_conflict",required:n.required,examples:n.examples,nextSteps:n.nextSteps}):e}function M(e){return e==="comments"?"--stdin":"--add -"}function z(e,n){if((n.input.emptyFlag??"--add")!=="--add")return;let t=e.trim();if(!/^-{1,2}[A-Za-z][\w-]*(?:=.*)?$/.test(t))return;let a=M(n.collectionKey),i=n.input.mode==="edit"?`pm ${n.collectionKey} <id> --edit <index>`:`pm ${n.collectionKey} <id>`;throw new o(`--add value "${t}" looks like an option, not annotation text. Use ${a} to read stdin, or use text=${t} for literal dash-leading text.`,s.USAGE,{code:"annotation_flag_like_value",required:`Use ${a} for stdin input, pass plain text, or use text=${t} when the text really starts with "-".`,examples:[`${i} ${a}`,`${i} --add text=${t}`]})}function W(e,n){if(e.input.mode!=="list"||n.message===void 0)return;let r=e.collectionKey.replace(/s$/,"");throw new o(`--message labels a ${r} mutation but does not provide ${r} text. Pass text positionally or with --add, --stdin, or --file.`,s.USAGE,{code:"annotation_message_without_text",required:`Provide ${r} 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> ${M(e.collectionKey)}`]})}async function le(e,n,r,t){W(t,n);let a=g(process.cwd(),r.path);if(!await K(U(a)))throw new o(`Tracker is not initialized at ${a}. Run pm init first.`,s.NOT_FOUND);let i=await N(a),w=_(i,C()),y=T(n.limit);if(t.input.mode==="list"){let d=await O(a,e,i.id_prefix,i.item_format,w.type_to_folder);if(!d)throw new o(`Item ${e} not found`,s.NOT_FOUND);let l=await k(d,{schema:i.schema}),f=p(l.document.metadata,t.collectionKey);return b(d.id,t.collectionKey,f,y,n.includeMeta===!0)}let m=G(n.author,i.author_default);if(t.input.mode==="delete"){let d=t.deleteOp??t.op,l;try{l=await x({pmRoot:a,settings:i,id:e,op:d,author:m,message:n.message,force:n.force,bypassAssigneeConflict:t.bypassOwnershipConflict,mutate(u){let c=p(u.metadata,t.collectionKey),h=R(t.input.index,c.length,t.collectionKey);return P(c[h],"deleted"),c.splice(h,1),u.metadata[t.collectionKey]=c,{changedFields:[t.collectionKey]}}})}catch(u){v(u,t.conflictGuidance)}let f=p(l.item,t.collectionKey);return b(l.item.id,t.collectionKey,f,y,n.includeMeta===!0)}let D=t.input.rawValue??t.input.value??"";z(D,t);let $=t.parseText(t.input.value??"");if(!$.trim())throw new o(`${t.input.emptyFlag??"--add"} text cannot be empty`,s.USAGE);if(t.input.mode==="edit"){let d=t.editOp??t.op,l;try{l=await x({pmRoot:a,settings:i,id:e,op:d,author:m,message:n.message,force:n.force,bypassAssigneeConflict:t.bypassOwnershipConflict,mutate(u){let c=p(u.metadata,t.collectionKey),h=R(t.input.index,c.length,t.collectionKey),S=c[h];return P(S,"edited"),c[h]={...S,text:$,edited_at:E()},u.metadata[t.collectionKey]=c,{changedFields:[t.collectionKey]}}})}catch(u){v(u,t.conflictGuidance)}let f=p(l.item,t.collectionKey);return b(l.item.id,t.collectionKey,f,y,n.includeMeta===!0)}let A;try{A=await x({pmRoot:a,settings:i,id:e,op:t.op,author:m,message:n.message,force:n.force,bypassAssigneeConflict:t.bypassOwnershipConflict,mutate(d){let l=p(d.metadata,t.collectionKey),f={created_at:E(),author:m,text:$};return l.push(t.createEntry(f)),d.metadata[t.collectionKey]=l,{changedFields:[t.collectionKey]}}})}catch(d){v(d,t.conflictGuidance)}let q=p(A.item,t.collectionKey);return b(A.item.id,t.collectionKey,q,y,n.includeMeta===!0)}function R(e,n,r){if(e===void 0||!Number.isInteger(e)||e<1||e>n){let t=r.replace(/s$/,""),a=`${t.charAt(0).toUpperCase()}${t.slice(1)}`,i=n===1?`1 ${t}`:`${n} ${r}`;throw new o(`${a} index ${e??"(missing)"} out of range (item has ${i})`,s.USAGE)}return e-1}function b(e,n,r,t,a){let i=V(r,t);return{id:e,[n]:i,count:i.length,...a?{total_count:r.length,returned_count:i.length,has_more:i.length<r.length,...t!==void 0?{limit:t}:{}}:{}}}export{V as a,p as b,se as c,j as d,de as e,v as f,le as g,R as h};
2
+ //# sourceMappingURL=chunk-H5Y6UV6E.js.map
@@ -1,2 +1,2 @@
1
- import{E as i}from"./chunk-GE4KCSZP.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5b7b3eaf-a792-5f44-9981-8c82ce511070")}catch{}})();function M(e,n){let t=e.trim().toLowerCase();return n.alias_to_id.get(t)??t}function B(e){return{isTerminal(n){return e.terminal_statuses.has(M(n,e))},classify(n){let t=M(n,e);return e.terminal_canceled_statuses.has(t)?"canceled":e.terminal_statuses.has(t)?"closed":e.blocked_statuses.has(t)?"blocked":e.draft_statuses.has(t)?"draft":t===e.open_status?"open":e.active_statuses.has(t)?"in_progress":"other"}}}function p(e){return i(e.acceptance_criteria)===void 0}function d(e){return!Number.isFinite(e.estimated_minutes)}function m(e,n){return n.isTerminal(e.status)?i(e.resolution)===void 0:!1}function x(e){return i(e.reviewer)===void 0}function k(e){return i(e.risk)===void 0}function w(e){return typeof e.confidence=="number"?!Number.isFinite(e.confidence):i(e.confidence)===void 0}function v(e){return i(e.sprint)===void 0}function E(e){return i(e.release)===void 0}function R(e){return!!(e.acMissing||e.estimatesMissing||e.resolutionMissing||e.reviewerMissing||e.riskMissing||e.confidenceMissing||e.sprintMissing||e.releaseMissing||e.metadataMissing)}function C(e,n,t){return[[n.acMissing,p(e)],[n.estimatesMissing,d(e)],[n.resolutionMissing,m(e,t)],[n.reviewerMissing,x(e)],[n.riskMissing,k(e)],[n.confidenceMissing,w(e)],[n.sprintMissing,v(e)],[n.releaseMissing,E(e)]].every(([s,o])=>s!==!0||o)}function F(e,n){return p(e)||d(e)||m(e,n)}function U(e,n,t){return R(n)?!(!C(e,n,t)||n.metadataMissing&&!F(e,t)):!0}var g=["acceptance_criteria","estimated_minutes","resolution","tags","parent"];function A(e,n){switch(n){case"acceptance_criteria":return!p(e);case"estimated_minutes":return!d(e);case"resolution":return i(e.resolution)!==void 0;case"tags":return Array.isArray(e.tags)&&e.tags.length>0;default:return i(e.parent)!==void 0}}function D(e,n,t){return n==="resolution"?t.isTerminal(e.status):!0}function I(e,n){return n===0?100:Math.round(e/n*1e3)/10}function b(){let e={};for(let n of g)e[n]={present:0,applicable:0,percent:100};return e}function _(e,n,t){for(let r of g){if(!D(n,r,t))continue;let s=e[r];s.applicable+=1,A(n,r)&&(s.present+=1)}}function h(e){for(let n of g){let t=e[n];t.percent=I(t.present,t.applicable)}}function G(e,n){let t=b(),r={};for(let s of e){_(t,s,n);let o=r[s.type]??(r[s.type]=b());_(o,s,n)}h(t);for(let s of Object.values(r))h(s);return{overall:t,by_type:r}}var L={assignee:"(unassigned)",priority:"(no priority)",tag:"(untagged)",parent:"(unparented)",type:"(untyped)",status:"(no status)"};function T(e){return L[e]}function P(){return{open:0,in_progress:0,blocked:0,draft:0,closed:0,canceled:0,other:0}}function O(e,n,t){switch(n){case"assignee":return[i(e.assignee)??null];case"parent":return[i(e.parent)??null];case"type":return[i(e.type)??null];case"status":return[i(e.status)??null];case"priority":return[typeof e.priority=="number"?`P${e.priority}`:null];default:{let r=t.tagPrefix?.trim(),o=(Array.isArray(e.tags)?e.tags:[]).filter(c=>typeof c=="string"&&c.length>0&&(!r||c.startsWith(r)));return o.length>0?o:[null]}}}function K(e,n,t,r={}){let s=new Map,o=0;for(let a of e){o+=1;let u=t.classify(a.status);for(let l of O(a,n,r)){let y=l??"\0empty",f=s.get(y);f||(f={label:l??T(n),key:l,buckets:P(),total:0},s.set(y,f)),f.buckets[u]+=1,f.total+=1}}let c=[...s.values()].sort((a,u)=>u.total!==a.total?u.total-a.total:a.key===null?1:u.key===null?-1:a.label.localeCompare(u.label));return{dimension:n,rows:c,total_items:o}}export{B as a,R as b,U as c,G as d,K as e};
2
- //# sourceMappingURL=chunk-UP7DTVMD.js.map
1
+ import{E as i}from"./chunk-D4FPS43D.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="5b7b3eaf-a792-5f44-9981-8c82ce511070")}catch{}})();function M(e,n){let t=e.trim().toLowerCase();return n.alias_to_id.get(t)??t}function B(e){return{isTerminal(n){return e.terminal_statuses.has(M(n,e))},classify(n){let t=M(n,e);return e.terminal_canceled_statuses.has(t)?"canceled":e.terminal_statuses.has(t)?"closed":e.blocked_statuses.has(t)?"blocked":e.draft_statuses.has(t)?"draft":t===e.open_status?"open":e.active_statuses.has(t)?"in_progress":"other"}}}function p(e){return i(e.acceptance_criteria)===void 0}function d(e){return!Number.isFinite(e.estimated_minutes)}function m(e,n){return n.isTerminal(e.status)?i(e.resolution)===void 0:!1}function x(e){return i(e.reviewer)===void 0}function k(e){return i(e.risk)===void 0}function w(e){return typeof e.confidence=="number"?!Number.isFinite(e.confidence):i(e.confidence)===void 0}function v(e){return i(e.sprint)===void 0}function E(e){return i(e.release)===void 0}function R(e){return!!(e.acMissing||e.estimatesMissing||e.resolutionMissing||e.reviewerMissing||e.riskMissing||e.confidenceMissing||e.sprintMissing||e.releaseMissing||e.metadataMissing)}function C(e,n,t){return[[n.acMissing,p(e)],[n.estimatesMissing,d(e)],[n.resolutionMissing,m(e,t)],[n.reviewerMissing,x(e)],[n.riskMissing,k(e)],[n.confidenceMissing,w(e)],[n.sprintMissing,v(e)],[n.releaseMissing,E(e)]].every(([s,o])=>s!==!0||o)}function F(e,n){return p(e)||d(e)||m(e,n)}function U(e,n,t){return R(n)?!(!C(e,n,t)||n.metadataMissing&&!F(e,t)):!0}var g=["acceptance_criteria","estimated_minutes","resolution","tags","parent"];function A(e,n){switch(n){case"acceptance_criteria":return!p(e);case"estimated_minutes":return!d(e);case"resolution":return i(e.resolution)!==void 0;case"tags":return Array.isArray(e.tags)&&e.tags.length>0;default:return i(e.parent)!==void 0}}function D(e,n,t){return n==="resolution"?t.isTerminal(e.status):!0}function I(e,n){return n===0?100:Math.round(e/n*1e3)/10}function b(){let e={};for(let n of g)e[n]={present:0,applicable:0,percent:100};return e}function _(e,n,t){for(let r of g){if(!D(n,r,t))continue;let s=e[r];s.applicable+=1,A(n,r)&&(s.present+=1)}}function h(e){for(let n of g){let t=e[n];t.percent=I(t.present,t.applicable)}}function G(e,n){let t=b(),r={};for(let s of e){_(t,s,n);let o=r[s.type]??(r[s.type]=b());_(o,s,n)}h(t);for(let s of Object.values(r))h(s);return{overall:t,by_type:r}}var L={assignee:"(unassigned)",priority:"(no priority)",tag:"(untagged)",parent:"(unparented)",type:"(untyped)",status:"(no status)"};function T(e){return L[e]}function P(){return{open:0,in_progress:0,blocked:0,draft:0,closed:0,canceled:0,other:0}}function O(e,n,t){switch(n){case"assignee":return[i(e.assignee)??null];case"parent":return[i(e.parent)??null];case"type":return[i(e.type)??null];case"status":return[i(e.status)??null];case"priority":return[typeof e.priority=="number"?`P${e.priority}`:null];default:{let r=t.tagPrefix?.trim(),o=(Array.isArray(e.tags)?e.tags:[]).filter(c=>typeof c=="string"&&c.length>0&&(!r||c.startsWith(r)));return o.length>0?o:[null]}}}function K(e,n,t,r={}){let s=new Map,o=0;for(let a of e){o+=1;let u=t.classify(a.status);for(let l of O(a,n,r)){let y=l??"\0empty",f=s.get(y);f||(f={label:l??T(n),key:l,buckets:P(),total:0},s.set(y,f)),f.buckets[u]+=1,f.total+=1}}let c=[...s.values()].sort((a,u)=>u.total!==a.total?u.total-a.total:a.key===null?1:u.key===null?-1:a.label.localeCompare(u.label));return{dimension:n,rows:c,total_items:o}}export{B as a,R as b,U as c,G as d,K as e};
2
+ //# sourceMappingURL=chunk-H7KGWPDF.js.map
@@ -1,2 +1,2 @@
1
- import{Ra as g,Xe as H,d as _,hf as v,nf as u,of as w}from"./chunk-GE4KCSZP.js";import l from"node:fs/promises";import{createHash as N}from"node:crypto";import S from"node:path";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="90364096-b94c-591c-9024-e697fa9322a5")}catch{}})();var b=3,F="history-drift-cache.json";function D(t){return S.join(t,"runtime",F)}async function T(t){try{let e=await l.readFile(D(t),"utf8"),n=JSON.parse(e);return n.version!==b||typeof n.entries!="object"||n.entries===null?null:n}catch{return null}}function p(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}async function j(t,e,n,i,r){let h=w(t),s;try{s=await l.stat(h)}catch(y){return p(y,"ENOENT")||r.unreadableStreams.push(u),!1}let c=r.missingStreams.length,o=await M({itemId:u,historyPath:h,stat:s,cached:e[u],verifyCacheHitByContent:i,accumulator:r});return o.verification?(o.verification.chainOk||r.chainMismatches.push(u),n[u]={mtime_ms:s.mtimeMs,ctime_ms:s.ctimeMs,size:s.size,content_hash:o.verification.contentHash,latest_after_hash:o.verification.latestAfterHash,chain_ok:o.verification.chainOk},o.cacheDirty):(r.missingStreams.splice(c),o.cacheDirty)}function k(t){return N("sha256").update(t).digest("hex")}async function z(t){let e=await l.readFile(t,"utf8");return k(e)}async function V(t){let e=await l.readFile(t,"utf8"),n=k(e);if(e.trim().length===0)return null;let i=[],r=null;for(let h of e.split(/\r?\n/)){let s=h.trim();if(s.length===0)continue;let c=JSON.parse(s);if(typeof c.after_hash!="string"||c.after_hash.trim().length===0)throw new Error("missing after_hash");i.push(c),r=c.after_hash}return r?{latestAfterHash:r,chainOk:v(i).ok,contentHash:n}:null}function x(t,e){return t!==void 0&&t.mtime_ms===e.mtimeMs&&t.ctime_ms===e.ctimeMs&&t.size===e.size}async function C(t,e,n){try{let i=await V(e);return i||(n.missingStreams.push(t),null)}catch{return n.unreadableStreams.push(t),null}}async function M(t){let e=typeof t.cached?.content_hash=="string"&&t.cached.content_hash.length>0?t.cached.content_hash:void 0;if(!(x(t.cached,t.stat)&&e!==void 0&&t.cached!==void 0)||!t.cached)return{verification:await C(t.itemId,t.historyPath,t.accumulator),cacheDirty:!0};let i;if(t.verifyCacheHitByContent)try{i=await z(t.historyPath)}catch{return t.accumulator.unreadableStreams.push(t.itemId),{verification:null,cacheDirty:!1}}else i=e;return!t.verifyCacheHitByContent||i===e?{verification:{latestAfterHash:t.cached.latest_after_hash,chainOk:t.cached.chain_ok,contentHash:i},cacheDirty:!1}:{verification:await C(t.itemId,t.historyPath,t.accumulator),cacheDirty:!0}}async function G(t,e,n={}){let i={missingStreams:[],unreadableStreams:[],hashMismatches:[],chainMismatches:[]},h=(await T(t))?.entries??{},s={},c=!1,o=n.cacheHitVerification!=="metadata";for(let a of e){let m=g(t,a.id),d;try{d=await l.stat(m)}catch(P){p(P,"ENOENT")?i.missingStreams.push(a.id):i.unreadableStreams.push(a.id);continue}let E=h[a.id],f=await M({itemId:a.id,historyPath:m,stat:d,cached:E,verifyCacheHitByContent:o,accumulator:i});if(c||=f.cacheDirty,!f.verification)continue;f.verification.chainOk||i.chainMismatches.push(a.id),s[a.id]={mtime_ms:d.mtimeMs,ctime_ms:d.ctimeMs,size:d.size,content_hash:f.verification.contentHash,latest_after_hash:f.verification.latestAfterHash,chain_ok:f.verification.chainOk};let{body:I,...A}=a;H({metadata:A,body:I})!==f.verification.latestAfterHash&&i.hashMismatches.push(a.id)}let y=await j(t,h,s,o,i);if(c||=y,c||Object.keys(h).length!==Object.keys(s).length){let a=D(t);try{await l.mkdir(S.dirname(a),{recursive:!0}),await _(a,JSON.stringify({version:b,entries:s}))}catch{}}let O=[...new Set([...i.missingStreams,...i.unreadableStreams,...i.hashMismatches,...i.chainMismatches])].sort((a,m)=>a.localeCompare(m));return{...i,driftedItems:O}}export{G as a};
2
- //# sourceMappingURL=chunk-E2RKBKWB.js.map
1
+ import{Af as w,Ra as g,d as _,hf as H,tf as v,zf as u}from"./chunk-D4FPS43D.js";import l from"node:fs/promises";import{createHash as N}from"node:crypto";import S from"node:path";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="90364096-b94c-591c-9024-e697fa9322a5")}catch{}})();var b=3,F="history-drift-cache.json";function D(t){return S.join(t,"runtime",F)}async function T(t){try{let e=await l.readFile(D(t),"utf8"),n=JSON.parse(e);return n.version!==b||typeof n.entries!="object"||n.entries===null?null:n}catch{return null}}function p(t,e){return typeof t=="object"&&t!==null&&"code"in t&&t.code===e}async function j(t,e,n,i,r){let h=w(t),s;try{s=await l.stat(h)}catch(y){return p(y,"ENOENT")||r.unreadableStreams.push(u),!1}let c=r.missingStreams.length,o=await M({itemId:u,historyPath:h,stat:s,cached:e[u],verifyCacheHitByContent:i,accumulator:r});return o.verification?(o.verification.chainOk||r.chainMismatches.push(u),n[u]={mtime_ms:s.mtimeMs,ctime_ms:s.ctimeMs,size:s.size,content_hash:o.verification.contentHash,latest_after_hash:o.verification.latestAfterHash,chain_ok:o.verification.chainOk},o.cacheDirty):(r.missingStreams.splice(c),o.cacheDirty)}function k(t){return N("sha256").update(t).digest("hex")}async function z(t){let e=await l.readFile(t,"utf8");return k(e)}async function V(t){let e=await l.readFile(t,"utf8"),n=k(e);if(e.trim().length===0)return null;let i=[],r=null;for(let h of e.split(/\r?\n/)){let s=h.trim();if(s.length===0)continue;let c=JSON.parse(s);if(typeof c.after_hash!="string"||c.after_hash.trim().length===0)throw new Error("missing after_hash");i.push(c),r=c.after_hash}return r?{latestAfterHash:r,chainOk:v(i).ok,contentHash:n}:null}function x(t,e){return t!==void 0&&t.mtime_ms===e.mtimeMs&&t.ctime_ms===e.ctimeMs&&t.size===e.size}async function C(t,e,n){try{let i=await V(e);return i||(n.missingStreams.push(t),null)}catch{return n.unreadableStreams.push(t),null}}async function M(t){let e=typeof t.cached?.content_hash=="string"&&t.cached.content_hash.length>0?t.cached.content_hash:void 0;if(!(x(t.cached,t.stat)&&e!==void 0&&t.cached!==void 0)||!t.cached)return{verification:await C(t.itemId,t.historyPath,t.accumulator),cacheDirty:!0};let i;if(t.verifyCacheHitByContent)try{i=await z(t.historyPath)}catch{return t.accumulator.unreadableStreams.push(t.itemId),{verification:null,cacheDirty:!1}}else i=e;return!t.verifyCacheHitByContent||i===e?{verification:{latestAfterHash:t.cached.latest_after_hash,chainOk:t.cached.chain_ok,contentHash:i},cacheDirty:!1}:{verification:await C(t.itemId,t.historyPath,t.accumulator),cacheDirty:!0}}async function G(t,e,n={}){let i={missingStreams:[],unreadableStreams:[],hashMismatches:[],chainMismatches:[]},h=(await T(t))?.entries??{},s={},c=!1,o=n.cacheHitVerification!=="metadata";for(let a of e){let m=g(t,a.id),d;try{d=await l.stat(m)}catch(P){p(P,"ENOENT")?i.missingStreams.push(a.id):i.unreadableStreams.push(a.id);continue}let E=h[a.id],f=await M({itemId:a.id,historyPath:m,stat:d,cached:E,verifyCacheHitByContent:o,accumulator:i});if(c||=f.cacheDirty,!f.verification)continue;f.verification.chainOk||i.chainMismatches.push(a.id),s[a.id]={mtime_ms:d.mtimeMs,ctime_ms:d.ctimeMs,size:d.size,content_hash:f.verification.contentHash,latest_after_hash:f.verification.latestAfterHash,chain_ok:f.verification.chainOk};let{body:I,...A}=a;H({metadata:A,body:I})!==f.verification.latestAfterHash&&i.hashMismatches.push(a.id)}let y=await j(t,h,s,o,i);if(c||=y,c||Object.keys(h).length!==Object.keys(s).length){let a=D(t);try{await l.mkdir(S.dirname(a),{recursive:!0}),await _(a,JSON.stringify({version:b,entries:s}))}catch{}}let O=[...new Set([...i.missingStreams,...i.unreadableStreams,...i.hashMismatches,...i.chainMismatches])].sort((a,m)=>a.localeCompare(m));return{...i,driftedItems:O}}export{G as a};
2
+ //# sourceMappingURL=chunk-HFSD77TQ.js.map
@@ -1,2 +1,2 @@
1
- import{c as m,d as p,g as w}from"./chunk-54FNT7U2.js";import{i as f}from"./chunk-42E7YPLG.js";import{A as i,C as s}from"./chunk-GE4KCSZP.js";import{readFile as y}from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="500e83b0-28a8-58b1-a625-2d81eb245eb4")}catch{}})();async function c(e,t){let d=e.add!==void 0,a=e.stdin===!0,o=typeof e.file=="string",l=Number(d)+Number(a)+Number(o);if(l===0)return;if(l>1)throw new s("Specify comment text using only one input source: --add, --stdin, or --file",i.USAGE);if(d)return{value:await t.resolveValue(e.add,"--add")??"",emptyFlag:"--add"};if(a)return{value:await t.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};let n=e.file.trim();if(!n)throw new s("--file path cannot be empty",i.USAGE);try{return{value:await y(n,"utf8"),emptyFlag:"--file"}}catch(r){if(p(r)&&r.code==="ENOENT")throw new s(`--file path not found: ${n}`,i.USAGE);let u=r instanceof Error?r.message:String(r);throw new s(`Failed to read --file path "${n}": ${u}`,i.USAGE)}}async function h(e,t){let d=e.edit,a=e.delete,o=d!==void 0,l=a!==void 0;if(o&&l)throw new s("Specify only one of --edit or --delete",i.USAGE);if(d!==void 0&&(!Number.isInteger(d)||d<1))throw new s("--edit must be a positive integer",i.USAGE);if(a!==void 0&&(!Number.isInteger(a)||a<1))throw new s("--delete must be a positive integer",i.USAGE);if(l){if(await c(e,t)!==void 0)throw new s("--delete does not take comment text",i.USAGE);return{mode:"delete",index:a}}if(o){let u=await c(e,t);if(u===void 0)throw new s("--edit requires replacement text via positional [text], --add, --stdin, or --file",i.USAGE);return{mode:"edit",index:d,value:u.value,emptyFlag:u.emptyFlag}}let n=await c(e,t);return n===void 0?{mode:"list"}:{mode:n.emptyFlag==="--add"?"add":n.emptyFlag==="--stdin"?"stdin":"file",value:n.value,emptyFlag:n.emptyFlag}}async function x(e,t,d){let a=f(),o=await h(t,a),l=o.mode==="add"||o.mode==="edit",n=o.value??"";return w(e,t,d,{input:{...o,rawValue:t.add??n,value:l?m(n,{stripPlainTextPrefix:!0}):n},collectionKey:"comments",op:"comment_add",editOp:"comment_edit",deleteOp:"comment_delete",parseText:r=>r,createEntry:r=>r,bypassOwnershipConflict:!!(o.mode==="add"&&t.ownershipAppendBypass),conflictGuidance:{required:"For an approved append-only handoff on another owner's item, use the package-provided ownership bypass before considering --force.",examples:['pm comments pm-a1b2 --add "review note" --author "reviewer" --force'],nextSteps:["Use an installed package's narrow append-only ownership bypass when available.","Use --force only when an ownership override is explicitly approved."]}})}export{x as a};
2
- //# sourceMappingURL=chunk-V3774P7D.js.map
1
+ import{c as m,d as p,g as w}from"./chunk-H5Y6UV6E.js";import{i as f}from"./chunk-NYIGHWQY.js";import{A as i,C as s}from"./chunk-D4FPS43D.js";import{readFile as y}from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="500e83b0-28a8-58b1-a625-2d81eb245eb4")}catch{}})();async function c(e,t){let d=e.add!==void 0,a=e.stdin===!0,o=typeof e.file=="string",l=Number(d)+Number(a)+Number(o);if(l===0)return;if(l>1)throw new s("Specify comment text using only one input source: --add, --stdin, or --file",i.USAGE);if(d)return{value:await t.resolveValue(e.add,"--add")??"",emptyFlag:"--add"};if(a)return{value:await t.resolveValue("-","--stdin")??"",emptyFlag:"--stdin"};let n=e.file.trim();if(!n)throw new s("--file path cannot be empty",i.USAGE);try{return{value:await y(n,"utf8"),emptyFlag:"--file"}}catch(r){if(p(r)&&r.code==="ENOENT")throw new s(`--file path not found: ${n}`,i.USAGE);let u=r instanceof Error?r.message:String(r);throw new s(`Failed to read --file path "${n}": ${u}`,i.USAGE)}}async function h(e,t){let d=e.edit,a=e.delete,o=d!==void 0,l=a!==void 0;if(o&&l)throw new s("Specify only one of --edit or --delete",i.USAGE);if(d!==void 0&&(!Number.isInteger(d)||d<1))throw new s("--edit must be a positive integer",i.USAGE);if(a!==void 0&&(!Number.isInteger(a)||a<1))throw new s("--delete must be a positive integer",i.USAGE);if(l){if(await c(e,t)!==void 0)throw new s("--delete does not take comment text",i.USAGE);return{mode:"delete",index:a}}if(o){let u=await c(e,t);if(u===void 0)throw new s("--edit requires replacement text via positional [text], --add, --stdin, or --file",i.USAGE);return{mode:"edit",index:d,value:u.value,emptyFlag:u.emptyFlag}}let n=await c(e,t);return n===void 0?{mode:"list"}:{mode:n.emptyFlag==="--add"?"add":n.emptyFlag==="--stdin"?"stdin":"file",value:n.value,emptyFlag:n.emptyFlag}}async function x(e,t,d){let a=f(),o=await h(t,a),l=o.mode==="add"||o.mode==="edit",n=o.value??"";return w(e,t,d,{input:{...o,rawValue:t.add??n,value:l?m(n,{stripPlainTextPrefix:!0}):n},collectionKey:"comments",op:"comment_add",editOp:"comment_edit",deleteOp:"comment_delete",parseText:r=>r,createEntry:r=>r,bypassOwnershipConflict:!!(o.mode==="add"&&t.ownershipAppendBypass),conflictGuidance:{required:"For an approved append-only handoff on another owner's item, use the package-provided ownership bypass before considering --force.",examples:['pm comments pm-a1b2 --add "review note" --author "reviewer" --force'],nextSteps:["Use an installed package's narrow append-only ownership bypass when available.","Use --force only when an ownership override is explicitly approved."]}})}export{x as a};
2
+ //# sourceMappingURL=chunk-HX2GTA6L.js.map
@@ -1,2 +1,2 @@
1
- import{h as _,l as Q,m as Y,o as ee,p as te}from"./chunk-4VN6GS4U.js";import{A as m,Af as D,C as h,Da as P,Df as G,If as V,La as T,Lf as H,Ma as $,Mf as X,Nf as B,Oa as L,Sf as J,Y as E,b as I,lc as z,xc as W,zd as Z}from"./chunk-GE4KCSZP.js";import oe from"node:fs/promises";import p from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5e45d0f1-a1a7-50ea-a9a3-ec6283d3471d")}catch{}})();var ne=32768;function b(e){return _(p.normalize(e))}async function v(e){try{return await oe.realpath(e)}catch{return p.resolve(e)}}function g(e,t){let c=p.isAbsolute(e.path)?p.resolve(e.path):p.resolve(t,e.path);return`${b(c)}::${e.scope}`}function R(e,t,c){if(typeof e=="string"){let n=e.trim();n.length>0&&c.push({field:t,value:n});return}if(Array.isArray(e)){e.forEach((n,s)=>R(n,`${t}[${s}]`,c));return}if(typeof e=="object"&&e!==null)for(let[n,s]of Object.entries(e))R(s,t?`${t}.${n}`:n,c)}function se(e){let t=[];return R(e.metadata,"metadata",t),R(e.body,"body",t),t}function ae(e){let t=e.trim();return t=t.replace(/^[`"'<([{]+/u,""),t=t.replace(/[`"'>)\]},;!?]+$/u,""),t=t.replace(/[.]+$/u,""),t=t.replace(/:(?:\d+)(?::\d+)?$/u,""),t=t.replace(/[.]+$/u,""),t}function ie(e){let t=[],c=/(?:[A-Za-z]:[\\/]|\/)[^\s"'`<>()[\]{},;]+/gu,n=/(?:\.{1,2}[\\/])?(?:(?:[A-Za-z0-9_.@-]+[\\/])+[A-Za-z0-9_.@-]+|[A-Za-z0-9_.@-]+\.[A-Za-z0-9][A-Za-z0-9._-]*)/gu;for(let s of e){let l=new Set,a=s.value.slice(0,ne);for(let[i,r]of[[c,s.value],[n,a]]){i.lastIndex=0;for(let o of r.matchAll(i)){let d=ae(o[0]);!d||l.has(d)||(l.add(d),t.push({field:s.field,value:d}))}}}return t}async function re(e,t,c=t){let n=p.isAbsolute(e)?p.resolve(e):p.resolve(c,e),s;try{s=await oe.stat(n)}catch{return}if(!s.isFile())return;let[l,a]=await Promise.all([v(t),v(n)]);if(E(l,a)){let i=p.relative(l,a);return!i||i.startsWith("..")||p.isAbsolute(i)?void 0:{path:b(i),scope:"project"}}return{path:b(n),scope:"global"}}async function ce(e,t,c=t){let n=new Set((e.metadata.files??[]).map(r=>g(r,t))),s=new Map,l=ie(se(e)),a=new Map;await Promise.all([...new Set(l.map(r=>r.value))].map(async r=>{a.set(r,await re(r,t,c))}));let i=l.map(r=>({reference:r,resolved:a.get(r.value)}));for(let{reference:r,resolved:o}of i){if(!o)continue;let d=g(o,t),f=s.get(d)??{path:o.path,scope:o.scope,sourceFields:new Set,originalPaths:new Set,sourceCount:0};f.sourceFields.add(r.field),f.originalPaths.add(r.value),f.sourceCount+=1,s.set(d,f)}return[...s.entries()].map(([r,o])=>({path:o.path,scope:o.scope,status:n.has(r)?"already_linked":"addable",source_count:o.sourceCount,source_fields:[...o.sourceFields].sort((d,f)=>d.localeCompare(f)),original_paths:[...o.originalPaths].sort((d,f)=>d.localeCompare(f))})).sort((r,o)=>{let d=r.status.localeCompare(o.status);if(d!==0)return d;let f=r.path.localeCompare(o.path);return f!==0?f:r.scope.localeCompare(o.scope)})}var $e={relativeReferenceScanMaxChars:ne,normalizeCandidatePathForOutput:b,realpathForContainment:v,linkedFileResolvedKey:g,collectTextReferences:R,collectItemTextReferences:se,cleanupPathToken:ae,extractRawPathReferences:ie,resolveDiscoveredFile:re,discoverReferencedFiles:ce};async function Le(e,t,c){let n=await ee(e,t,c,{metadataKey:"files",op:"files_add",bareNoun:"file",supportsAppendStable:!0});return te(n,"files")}async function me(e,t){let c=await v(t),n=await Promise.all(e.map(async l=>{let a=l.trim();if(!a)throw new h("Files lookup paths must not be empty.",m.USAGE);if(!p.isAbsolute(a))return _(a);let i=await v(a);return E(c,i)?_(p.relative(c,i)):_(i)})),s=[...new Set(n)].sort((l,a)=>l.localeCompare(a));if(s.length===0)throw new h("Files lookup requires at least one path.",m.USAGE);return s}function he(e){for(let[n,s]of[["limit",e.limit],["offset",e.offset]])if(s!==void 0&&(!Number.isInteger(s)||s<0))throw new h(`Files lookup ${n} must be a non-negative integer.`,m.USAGE);let{offset:t=0,limit:c=50}=e;return{offset:Math.max(0,Math.floor(t)),limit:e.noTruncate?void 0:Math.max(0,Math.floor(c))}}function le(e){return{id:e.id,title:e.title,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}async function ge(e){if([e.strictRead,e.noTruncate,W()].includes(!0))return null;let t=await V(e.pmRoot,[...new Set(Object.values(e.typeToFolder))]);return t?G({pmRoot:e.pmRoot,expectedSourceCursor:t.source_cursor,paths:e.paths,scope:e.scope,limit:e.limit,offset:e.offset}):null}async function ye(e){let t=[],n=(await B(e.pmRoot,e.settings.item_format,e.typeToFolder,t,e.settings.schema)).map(a=>({item:a,files:(a.files??[]).filter(i=>e.paths.includes(_(i.path))&&(e.scope===void 0||i.scope===e.scope)).sort((i,r)=>{let o=i.path.localeCompare(r.path);return o===0?i.scope.localeCompare(r.scope):o})})).filter(a=>a.files.length>0).sort((a,i)=>{let r=a.item.priority-i.item.priority;if(r!==0)return r;let o=i.item.updated_at.localeCompare(a.item.updated_at);return o===0?a.item.id.localeCompare(i.item.id):o}),s=t.filter(a=>/^item_list_(?:item|directory)_read_failed:/u.test(a));if(e.strictRead&&s.length>0)throw new h(`Files lookup could not read every item: ${s.join("; ")}`,m.GENERIC_FAILURE);let l=n.slice(e.offset,e.limit===void 0?void 0:e.offset+e.limit);return{paths:e.paths,total:n.length,count:l.length,offset:e.offset,limit:e.limit??null,has_more:e.offset+l.length<n.length,truncated:e.offset+l.length<n.length,completeness:{status:s.length===0?"complete":"partial",source:"source_scan"},warnings:t,matches:l.map(a=>({item:le(a.item),files:a.files}))}}async function ze(e,t){let c=T(process.cwd(),t.path),n=$(c);if(!await I(L(c)))throw new h(`Tracker is not initialized at ${c}. Run pm init first.`,m.NOT_FOUND);let s=await me(e.paths,n),l=await D(c),a=P(l,z()),{offset:i,limit:r}=he(e),o=await ge({pmRoot:c,typeToFolder:a.type_to_folder,paths:s,scope:e.scope,limit:r,offset:i,strictRead:e.strictRead===!0,noTruncate:e.noTruncate===!0});return o?{paths:s,total:o.total,count:o.matches.length,offset:i,limit:r,has_more:i+o.matches.length<o.total,truncated:i+o.matches.length<o.total,completeness:{status:"unchecked",source:"index"},warnings:[],matches:o.matches.map(d=>({item:le(d.item),files:d.files}))}:ye({pmRoot:c,settings:l,typeToFolder:a.type_to_folder,paths:s,scope:e.scope,limit:r,offset:i,strictRead:e.strictRead===!0})}async function De(e,t,c){let n=T(process.cwd(),c.path),s=$(n);if(!await I(L(n)))throw new h(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let l=await D(n),a=P(l,z()),i=await H(n,e,l.id_prefix,l.item_format,a.type_to_folder);if(!i)throw new h(`Item ${e} not found`,m.NOT_FOUND);let r=await X(i,{schema:l.schema}),o=await ce(r.document,s,process.cwd()),d=o.filter(u=>u.status==="addable"),f=o.filter(u=>u.status==="already_linked"),O=t.apply===!0,de=t.note?.trim()||"discovered from item text";if(!O||d.length===0){let u=r.document.metadata.files??[];return{id:i.id,files:u,changed:!1,apply:O,count:u.length,candidate_count:o.length,addable_count:d.length,added_count:0,skipped_existing_count:f.length,candidates:o,added:[],skipped_existing:f}}let ue=Z(t.author,l.author_default),A=d.map(u=>({path:u.path,scope:u.scope,note:de})),y=[],x=new Set,M=await J({pmRoot:n,settings:l,id:e,op:"files_discover",author:ue,message:t.message??"Discover referenced file links",force:t.force,mutate(u){let w=[...u.metadata.files??[]],U=new Set(w.map(S=>g(S,s)));y=[],x.clear();for(let[S,C]of A.entries()){let q=g(C,s);U.has(q)||(w.push(C),U.add(q),y.push(C),x.add(S))}let j=Y(w),K=t.appendStable?j:Q(j);return K.length>0?u.metadata.files=K:delete u.metadata.files,{changedFields:y.length>0?["files"]:[],warnings:y.length!==A.length?[`files_discover_skipped_existing:${A.length-y.length}`]:[]}}}),k=M.item.files??[],fe=new Set(y.map(u=>g(u,s))),F=k.filter(u=>fe.has(g(u,s))),pe=d.filter((u,w)=>!x.has(w)),N=[...f,...pe];return{id:M.item.id,files:k,changed:F.length>0,apply:!0,count:k.length,candidate_count:o.length,addable_count:d.length,added_count:F.length,skipped_existing_count:N.length,candidates:o,added:F,skipped_existing:N}}export{$e as a,Le as b,ze as c,De as d};
2
- //# sourceMappingURL=chunk-UZBWIUYD.js.map
1
+ import{h as _,l as Q,m as Y,o as ee,p as te}from"./chunk-WSJEIGJF.js";import{A as m,C as h,Da as P,La as T,Ma as $,Nf as D,Oa as L,Qf as G,Vf as V,Y as E,Yf as H,Zf as X,_f as B,b as I,dg as J,lc as z,xc as W,zd as Z}from"./chunk-D4FPS43D.js";import oe from"node:fs/promises";import p from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5e45d0f1-a1a7-50ea-a9a3-ec6283d3471d")}catch{}})();var ne=32768;function b(e){return _(p.normalize(e))}async function v(e){try{return await oe.realpath(e)}catch{return p.resolve(e)}}function g(e,t){let c=p.isAbsolute(e.path)?p.resolve(e.path):p.resolve(t,e.path);return`${b(c)}::${e.scope}`}function R(e,t,c){if(typeof e=="string"){let n=e.trim();n.length>0&&c.push({field:t,value:n});return}if(Array.isArray(e)){e.forEach((n,s)=>R(n,`${t}[${s}]`,c));return}if(typeof e=="object"&&e!==null)for(let[n,s]of Object.entries(e))R(s,t?`${t}.${n}`:n,c)}function se(e){let t=[];return R(e.metadata,"metadata",t),R(e.body,"body",t),t}function ae(e){let t=e.trim();return t=t.replace(/^[`"'<([{]+/u,""),t=t.replace(/[`"'>)\]},;!?]+$/u,""),t=t.replace(/[.]+$/u,""),t=t.replace(/:(?:\d+)(?::\d+)?$/u,""),t=t.replace(/[.]+$/u,""),t}function ie(e){let t=[],c=/(?:[A-Za-z]:[\\/]|\/)[^\s"'`<>()[\]{},;]+/gu,n=/(?:\.{1,2}[\\/])?(?:(?:[A-Za-z0-9_.@-]+[\\/])+[A-Za-z0-9_.@-]+|[A-Za-z0-9_.@-]+\.[A-Za-z0-9][A-Za-z0-9._-]*)/gu;for(let s of e){let l=new Set,a=s.value.slice(0,ne);for(let[i,r]of[[c,s.value],[n,a]]){i.lastIndex=0;for(let o of r.matchAll(i)){let d=ae(o[0]);!d||l.has(d)||(l.add(d),t.push({field:s.field,value:d}))}}}return t}async function re(e,t,c=t){let n=p.isAbsolute(e)?p.resolve(e):p.resolve(c,e),s;try{s=await oe.stat(n)}catch{return}if(!s.isFile())return;let[l,a]=await Promise.all([v(t),v(n)]);if(E(l,a)){let i=p.relative(l,a);return!i||i.startsWith("..")||p.isAbsolute(i)?void 0:{path:b(i),scope:"project"}}return{path:b(n),scope:"global"}}async function ce(e,t,c=t){let n=new Set((e.metadata.files??[]).map(r=>g(r,t))),s=new Map,l=ie(se(e)),a=new Map;await Promise.all([...new Set(l.map(r=>r.value))].map(async r=>{a.set(r,await re(r,t,c))}));let i=l.map(r=>({reference:r,resolved:a.get(r.value)}));for(let{reference:r,resolved:o}of i){if(!o)continue;let d=g(o,t),f=s.get(d)??{path:o.path,scope:o.scope,sourceFields:new Set,originalPaths:new Set,sourceCount:0};f.sourceFields.add(r.field),f.originalPaths.add(r.value),f.sourceCount+=1,s.set(d,f)}return[...s.entries()].map(([r,o])=>({path:o.path,scope:o.scope,status:n.has(r)?"already_linked":"addable",source_count:o.sourceCount,source_fields:[...o.sourceFields].sort((d,f)=>d.localeCompare(f)),original_paths:[...o.originalPaths].sort((d,f)=>d.localeCompare(f))})).sort((r,o)=>{let d=r.status.localeCompare(o.status);if(d!==0)return d;let f=r.path.localeCompare(o.path);return f!==0?f:r.scope.localeCompare(o.scope)})}var $e={relativeReferenceScanMaxChars:ne,normalizeCandidatePathForOutput:b,realpathForContainment:v,linkedFileResolvedKey:g,collectTextReferences:R,collectItemTextReferences:se,cleanupPathToken:ae,extractRawPathReferences:ie,resolveDiscoveredFile:re,discoverReferencedFiles:ce};async function Le(e,t,c){let n=await ee(e,t,c,{metadataKey:"files",op:"files_add",bareNoun:"file",supportsAppendStable:!0});return te(n,"files")}async function me(e,t){let c=await v(t),n=await Promise.all(e.map(async l=>{let a=l.trim();if(!a)throw new h("Files lookup paths must not be empty.",m.USAGE);if(!p.isAbsolute(a))return _(a);let i=await v(a);return E(c,i)?_(p.relative(c,i)):_(i)})),s=[...new Set(n)].sort((l,a)=>l.localeCompare(a));if(s.length===0)throw new h("Files lookup requires at least one path.",m.USAGE);return s}function he(e){for(let[n,s]of[["limit",e.limit],["offset",e.offset]])if(s!==void 0&&(!Number.isInteger(s)||s<0))throw new h(`Files lookup ${n} must be a non-negative integer.`,m.USAGE);let{offset:t=0,limit:c=50}=e;return{offset:Math.max(0,Math.floor(t)),limit:e.noTruncate?void 0:Math.max(0,Math.floor(c))}}function le(e){return{id:e.id,title:e.title,type:e.type,status:e.status,priority:e.priority,updated_at:e.updated_at}}async function ge(e){if([e.strictRead,e.noTruncate,W()].includes(!0))return null;let t=await V(e.pmRoot,[...new Set(Object.values(e.typeToFolder))]);return t?G({pmRoot:e.pmRoot,expectedSourceCursor:t.source_cursor,paths:e.paths,scope:e.scope,limit:e.limit,offset:e.offset}):null}async function ye(e){let t=[],n=(await B(e.pmRoot,e.settings.item_format,e.typeToFolder,t,e.settings.schema)).map(a=>({item:a,files:(a.files??[]).filter(i=>e.paths.includes(_(i.path))&&(e.scope===void 0||i.scope===e.scope)).sort((i,r)=>{let o=i.path.localeCompare(r.path);return o===0?i.scope.localeCompare(r.scope):o})})).filter(a=>a.files.length>0).sort((a,i)=>{let r=a.item.priority-i.item.priority;if(r!==0)return r;let o=i.item.updated_at.localeCompare(a.item.updated_at);return o===0?a.item.id.localeCompare(i.item.id):o}),s=t.filter(a=>/^item_list_(?:item|directory)_read_failed:/u.test(a));if(e.strictRead&&s.length>0)throw new h(`Files lookup could not read every item: ${s.join("; ")}`,m.GENERIC_FAILURE);let l=n.slice(e.offset,e.limit===void 0?void 0:e.offset+e.limit);return{paths:e.paths,total:n.length,count:l.length,offset:e.offset,limit:e.limit??null,has_more:e.offset+l.length<n.length,truncated:e.offset+l.length<n.length,completeness:{status:s.length===0?"complete":"partial",source:"source_scan"},warnings:t,matches:l.map(a=>({item:le(a.item),files:a.files}))}}async function ze(e,t){let c=T(process.cwd(),t.path),n=$(c);if(!await I(L(c)))throw new h(`Tracker is not initialized at ${c}. Run pm init first.`,m.NOT_FOUND);let s=await me(e.paths,n),l=await D(c),a=P(l,z()),{offset:i,limit:r}=he(e),o=await ge({pmRoot:c,typeToFolder:a.type_to_folder,paths:s,scope:e.scope,limit:r,offset:i,strictRead:e.strictRead===!0,noTruncate:e.noTruncate===!0});return o?{paths:s,total:o.total,count:o.matches.length,offset:i,limit:r,has_more:i+o.matches.length<o.total,truncated:i+o.matches.length<o.total,completeness:{status:"unchecked",source:"index"},warnings:[],matches:o.matches.map(d=>({item:le(d.item),files:d.files}))}:ye({pmRoot:c,settings:l,typeToFolder:a.type_to_folder,paths:s,scope:e.scope,limit:r,offset:i,strictRead:e.strictRead===!0})}async function De(e,t,c){let n=T(process.cwd(),c.path),s=$(n);if(!await I(L(n)))throw new h(`Tracker is not initialized at ${n}. Run pm init first.`,m.NOT_FOUND);let l=await D(n),a=P(l,z()),i=await H(n,e,l.id_prefix,l.item_format,a.type_to_folder);if(!i)throw new h(`Item ${e} not found`,m.NOT_FOUND);let r=await X(i,{schema:l.schema}),o=await ce(r.document,s,process.cwd()),d=o.filter(u=>u.status==="addable"),f=o.filter(u=>u.status==="already_linked"),O=t.apply===!0,de=t.note?.trim()||"discovered from item text";if(!O||d.length===0){let u=r.document.metadata.files??[];return{id:i.id,files:u,changed:!1,apply:O,count:u.length,candidate_count:o.length,addable_count:d.length,added_count:0,skipped_existing_count:f.length,candidates:o,added:[],skipped_existing:f}}let ue=Z(t.author,l.author_default),A=d.map(u=>({path:u.path,scope:u.scope,note:de})),y=[],x=new Set,M=await J({pmRoot:n,settings:l,id:e,op:"files_discover",author:ue,message:t.message??"Discover referenced file links",force:t.force,mutate(u){let w=[...u.metadata.files??[]],U=new Set(w.map(S=>g(S,s)));y=[],x.clear();for(let[S,C]of A.entries()){let q=g(C,s);U.has(q)||(w.push(C),U.add(q),y.push(C),x.add(S))}let j=Y(w),K=t.appendStable?j:Q(j);return K.length>0?u.metadata.files=K:delete u.metadata.files,{changedFields:y.length>0?["files"]:[],warnings:y.length!==A.length?[`files_discover_skipped_existing:${A.length-y.length}`]:[]}}}),k=M.item.files??[],fe=new Set(y.map(u=>g(u,s))),F=k.filter(u=>fe.has(g(u,s))),pe=d.filter((u,w)=>!x.has(w)),N=[...f,...pe];return{id:M.item.id,files:k,changed:F.length>0,apply:!0,count:k.length,candidate_count:o.length,addable_count:d.length,added_count:F.length,skipped_existing_count:N.length,candidates:o,added:F,skipped_existing:N}}export{$e as a,Le as b,ze as c,De as d};
2
+ //# sourceMappingURL=chunk-J2IEKAVR.js.map
@@ -1,2 +1,2 @@
1
- import{a as ne,b as ie,c as se,d as P,e as C}from"./chunk-ZYHOB3SN.js";import{A as f,Ad as G,Af as te,C as h,Da as N,Hf as oe,Jf as re,La as S,Lf as F,Mf as O,Oa as $,Pa as W,Qf as ae,R as A,Ra as b,Ze as X,_e as J,b as R,c as v,cf as K,d as p,df as Q,ef as T,hd as B,id as M,kf as V,lc as j,mf as Y,qc as z,rc as k,tf as Z,uc as x,uf as ee,vc as U,zd as q}from"./chunk-GE4KCSZP.js";import Re from"fast-json-patch";import L from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="353be665-9f67-5d0e-99c9-6bbb7e927e0b")}catch{}})();function ce(e,t){return ie(e,t,{errorSubject:"restore",allowFutureTimestamp:!0})}function de(e){let t=P(e,e.length-1);return Object.keys(t.metadata).length===0?{metadata:{},body:t.body}:M(K(t))}async function le(e,t,a,d){let r=await F(e,t,a.id_prefix,a.item_format,d);if(r){let c=b(e,r.id),m=await V({pmRoot:e,settings:a,itemId:r.id,commandLabel:"restore"});return{id:r.id,historyPath:c,located:r,historyPolicyWarnings:m.warnings}}let o=ee(t,a.id_prefix),i=Z(t),n=o===i?[o]:[o,i];for(let c of n){let m=b(e,c);if(await R(m))return{id:c,historyPath:m,located:null,historyPolicyWarnings:[]}}throw new h(`Item ${t} not found`,f.NOT_FOUND)}function fe(e,t){let a=T(e),d=T(t),r=Re.compare(a,d),o=new Set;for(let i of r){if(i.path==="/body"||i.path.startsWith("/body/")){o.add("body");continue}let n=i.path.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];o.add(n.replaceAll("~1","/").replaceAll("~0","~"))}return Array.from(o).sort((i,n)=>i.localeCompare(n))}async function ve(e){if(await v(e.subject.historyPath)!==e.historyRawBeforeLock)throw new h(`History for ${e.resolvedId} changed while waiting for lock; retry restore.`,f.CONFLICT);let a=await F(e.pmRoot,e.resolvedId,e.settings.id_prefix,e.settings.item_format,e.typeToFolder),d=a?await O(a,{schema:e.settings.schema}):null;if((d?.raw??null)!==e.currentItemRawBeforeLock)throw new h(`Item ${e.resolvedId} changed while waiting for lock; retry restore.`,f.CONFLICT);return{loadedItemUnderLock:d,existingItemPath:a?.itemPath??null}}function be(e,t){return e?{document:e.document,originalRaw:e.raw}:{document:de(t),originalRaw:null}}function ke(e){let t=e.document.metadata.assignee?.trim();if(!(t&&t!==e.author&&!e.force))return[];if(e.enforcement==="strict")throw new h(`Item ${e.resolvedId} is assigned to ${t}. Use --force to override.`,f.CONFLICT);return e.enforcement==="warn"?[`ownership_warning:assignee_conflict:${e.resolvedId}:${t}`]:[]}async function xe(e){if(e.existingItemPath&&e.resolvedOriginalRaw!==null&&e.restoredItemPath!==e.existingItemPath){await p(e.existingItemPath,e.resolvedOriginalRaw),await L.rm(e.restoredItemPath,{force:!0});return}if(e.existingItemPath&&e.resolvedOriginalRaw!==null){await p(e.existingItemPath,e.resolvedOriginalRaw);return}await L.rm(e.restoredItemPath,{force:!0})}async function Te(e){return[...await x({path:e.restoredItemPath,scope:"project",op:"restore",item_id:e.after.metadata.id,item_type:e.after.metadata.type,before:e.before,after:e.after,changed_fields:["restored"]}),...await x({path:e.historyPath,scope:"project",op:"restore:history",item_id:e.after.metadata.id,item_type:e.after.metadata.type,before:e.before,after:e.after,changed_fields:["restored"]})]}async function He(e,t,a,d){let r=S(process.cwd(),d.path);if(!await R($(r)))throw new h(`Tracker is not initialized at ${r}. Run pm init first.`,f.NOT_FOUND);let o=await te(r),i=N(o,j()),n=await le(r,e,o,i.type_to_folder),c=n.id,m=await v(n.historyPath),y=await G(n.historyPath,c);if(y.length===0)throw new h(`No history exists for ${c}; restore is unavailable.`,f.NOT_FOUND);let u=ce(t,y),he=C(P(y,u.historyIndex),u),s=Q(he,{schema:o.schema});if(s.metadata.id!==c)throw new h(`Restore target resolved to item ${s.metadata.id}, expected ${c}.`,f.GENERIC_FAILURE);let me=(n.located?await O(n.located,{schema:o.schema}):null)?.raw??null,_=q(a.author,o.author_default),ue=await Y(r,c,o.locks.ttl_seconds,_,!!a.force,o.governance.force_required_for_stale_lock,o.locks.wait_ms);try{let{loadedItemUnderLock:ye,existingItemPath:w}=await ve({pmRoot:r,resolvedId:c,subject:n,settings:o,typeToFolder:i.type_to_folder,historyRawBeforeLock:m,currentItemRawBeforeLock:me}),D="toon",l=be(ye,y),we=ke({document:l.document,author:_,force:a.force,enforcement:o.governance.ownership_enforcement,resolvedId:c}),g=fe(l.document,s);await U({pm_root:r,operation:"restore",before:l.document,after:s,changed_fields:g,sdk:ae({pmRoot:r,settings:o,typeToFolder:i.type_to_folder})});let ge=B(s,{format:D,schema:o.schema}),I=W(r,s.metadata.type,c,D,i.type_to_folder),Ie=await oe(r,_),E=[];try{await p(I,ge),w&&I!==w&&await L.rm(w);let pe=X({nowIso:A(),author:_,op:"restore",before:l.document,after:s,message:a.message});try{await J(n.historyPath,pe)}catch(Pe){throw await xe({existingItemPath:w,resolvedOriginalRaw:l.originalRaw,restoredItemPath:I}),Pe}E=await re({pmRoot:r,preferredFormat:o.item_format,typeToFolder:i.type_to_folder,schema:o.schema,itemPath:I,previousItemPath:w??void 0,document:s})}finally{await Ie()}let _e=await Te({restoredItemPath:I,historyPath:n.historyPath,before:l.document,after:s});z({id:s.metadata.id,op:"restore",item_type:s.metadata.type,previous_status:l.document.metadata.status,status:s.metadata.status,previous:k(l.document.metadata,g),current:k(s.metadata,g),changed_fields:g});let H=y[u.historyIndex];return{item:s.metadata,restored_from:{kind:u.kind,target:u.raw,history_index:u.historyIndex+1,entry_ts:H.ts,entry_op:H.op},changed_fields:g,warnings:[...n.historyPolicyWarnings,...we,...E,..._e]}}finally{await ue()}}var Ae={applyHistoryPatch:se,changedFields:fe,ensureMaterializedRestoreTarget:C,ensureReplayTarget:ce,extractPatchFailureContext:ne,replayCurrentDocument:de,replayToTarget:P,resolveRestoreSubject:le};export{He as a,Ae as b};
2
- //# sourceMappingURL=chunk-HNFD72UK.js.map
1
+ import{a as ne,b as ie,c as se,d as P,e as C}from"./chunk-PD3225AM.js";import{A as f,Ad as G,C as h,Da as N,Gf as Z,Hf as ee,La as S,Nf as te,Oa as $,Pa as W,R as A,Ra as b,Uf as oe,Wf as re,Yf as F,Zf as O,b as R,bg as ae,c as v,d as p,hd as B,id as M,jf as X,kf as J,lc as j,of as K,pf as Q,qc as z,qf as T,rc as k,uc as x,vc as U,wf as V,yf as Y,zd as q}from"./chunk-D4FPS43D.js";import Re from"fast-json-patch";import L from"node:fs/promises";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="353be665-9f67-5d0e-99c9-6bbb7e927e0b")}catch{}})();function ce(e,t){return ie(e,t,{errorSubject:"restore",allowFutureTimestamp:!0})}function de(e){let t=P(e,e.length-1);return Object.keys(t.metadata).length===0?{metadata:{},body:t.body}:M(K(t))}async function le(e,t,a,d){let r=await F(e,t,a.id_prefix,a.item_format,d);if(r){let c=b(e,r.id),m=await V({pmRoot:e,settings:a,itemId:r.id,commandLabel:"restore"});return{id:r.id,historyPath:c,located:r,historyPolicyWarnings:m.warnings}}let o=ee(t,a.id_prefix),i=Z(t),n=o===i?[o]:[o,i];for(let c of n){let m=b(e,c);if(await R(m))return{id:c,historyPath:m,located:null,historyPolicyWarnings:[]}}throw new h(`Item ${t} not found`,f.NOT_FOUND)}function fe(e,t){let a=T(e),d=T(t),r=Re.compare(a,d),o=new Set;for(let i of r){if(i.path==="/body"||i.path.startsWith("/body/")){o.add("body");continue}let n=i.path.replace(/^\/(?:metadata|front_matter)\/?/,"").split("/")[0];o.add(n.replaceAll("~1","/").replaceAll("~0","~"))}return Array.from(o).sort((i,n)=>i.localeCompare(n))}async function ve(e){if(await v(e.subject.historyPath)!==e.historyRawBeforeLock)throw new h(`History for ${e.resolvedId} changed while waiting for lock; retry restore.`,f.CONFLICT);let a=await F(e.pmRoot,e.resolvedId,e.settings.id_prefix,e.settings.item_format,e.typeToFolder),d=a?await O(a,{schema:e.settings.schema}):null;if((d?.raw??null)!==e.currentItemRawBeforeLock)throw new h(`Item ${e.resolvedId} changed while waiting for lock; retry restore.`,f.CONFLICT);return{loadedItemUnderLock:d,existingItemPath:a?.itemPath??null}}function be(e,t){return e?{document:e.document,originalRaw:e.raw}:{document:de(t),originalRaw:null}}function ke(e){let t=e.document.metadata.assignee?.trim();if(!(t&&t!==e.author&&!e.force))return[];if(e.enforcement==="strict")throw new h(`Item ${e.resolvedId} is assigned to ${t}. Use --force to override.`,f.CONFLICT);return e.enforcement==="warn"?[`ownership_warning:assignee_conflict:${e.resolvedId}:${t}`]:[]}async function xe(e){if(e.existingItemPath&&e.resolvedOriginalRaw!==null&&e.restoredItemPath!==e.existingItemPath){await p(e.existingItemPath,e.resolvedOriginalRaw),await L.rm(e.restoredItemPath,{force:!0});return}if(e.existingItemPath&&e.resolvedOriginalRaw!==null){await p(e.existingItemPath,e.resolvedOriginalRaw);return}await L.rm(e.restoredItemPath,{force:!0})}async function Te(e){return[...await x({path:e.restoredItemPath,scope:"project",op:"restore",item_id:e.after.metadata.id,item_type:e.after.metadata.type,before:e.before,after:e.after,changed_fields:["restored"]}),...await x({path:e.historyPath,scope:"project",op:"restore:history",item_id:e.after.metadata.id,item_type:e.after.metadata.type,before:e.before,after:e.after,changed_fields:["restored"]})]}async function He(e,t,a,d){let r=S(process.cwd(),d.path);if(!await R($(r)))throw new h(`Tracker is not initialized at ${r}. Run pm init first.`,f.NOT_FOUND);let o=await te(r),i=N(o,j()),n=await le(r,e,o,i.type_to_folder),c=n.id,m=await v(n.historyPath),y=await G(n.historyPath,c);if(y.length===0)throw new h(`No history exists for ${c}; restore is unavailable.`,f.NOT_FOUND);let u=ce(t,y),he=C(P(y,u.historyIndex),u),s=Q(he,{schema:o.schema});if(s.metadata.id!==c)throw new h(`Restore target resolved to item ${s.metadata.id}, expected ${c}.`,f.GENERIC_FAILURE);let me=(n.located?await O(n.located,{schema:o.schema}):null)?.raw??null,_=q(a.author,o.author_default),ue=await Y(r,c,o.locks.ttl_seconds,_,!!a.force,o.governance.force_required_for_stale_lock,o.locks.wait_ms);try{let{loadedItemUnderLock:ye,existingItemPath:w}=await ve({pmRoot:r,resolvedId:c,subject:n,settings:o,typeToFolder:i.type_to_folder,historyRawBeforeLock:m,currentItemRawBeforeLock:me}),D="toon",l=be(ye,y),we=ke({document:l.document,author:_,force:a.force,enforcement:o.governance.ownership_enforcement,resolvedId:c}),g=fe(l.document,s);await U({pm_root:r,operation:"restore",before:l.document,after:s,changed_fields:g,sdk:ae({pmRoot:r,settings:o,typeToFolder:i.type_to_folder})});let ge=B(s,{format:D,schema:o.schema}),I=W(r,s.metadata.type,c,D,i.type_to_folder),Ie=await oe(r,_),E=[];try{await p(I,ge),w&&I!==w&&await L.rm(w);let pe=X({nowIso:A(),author:_,op:"restore",before:l.document,after:s,message:a.message});try{await J(n.historyPath,pe)}catch(Pe){throw await xe({existingItemPath:w,resolvedOriginalRaw:l.originalRaw,restoredItemPath:I}),Pe}E=await re({pmRoot:r,preferredFormat:o.item_format,typeToFolder:i.type_to_folder,schema:o.schema,itemPath:I,previousItemPath:w??void 0,document:s})}finally{await Ie()}let _e=await Te({restoredItemPath:I,historyPath:n.historyPath,before:l.document,after:s});z({id:s.metadata.id,op:"restore",item_type:s.metadata.type,previous_status:l.document.metadata.status,status:s.metadata.status,previous:k(l.document.metadata,g),current:k(s.metadata,g),changed_fields:g});let H=y[u.historyIndex];return{item:s.metadata,restored_from:{kind:u.kind,target:u.raw,history_index:u.historyIndex+1,entry_ts:H.ts,entry_op:H.op},changed_fields:g,warnings:[...n.historyPolicyWarnings,...we,...E,..._e]}}finally{await ue()}}var Ae={applyHistoryPatch:se,changedFields:fe,ensureMaterializedRestoreTarget:C,ensureReplayTarget:ce,extractPatchFailureContext:ne,replayCurrentDocument:de,replayToTarget:P,resolveRestoreSubject:le};export{He as a,Ae as b};
2
+ //# sourceMappingURL=chunk-K44PYFXH.js.map
@@ -1,2 +1,2 @@
1
- import{A as i,C as t}from"./chunk-GE4KCSZP.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function f(e,n="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new t(`${n} must be a non-negative number`,i.USAGE);return Math.floor(r)}export{f as a};
2
- //# sourceMappingURL=chunk-5ZBOIPGP.js.map
1
+ import{A as i,C as t}from"./chunk-D4FPS43D.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function f(e,n="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new t(`${n} must be a non-negative number`,i.USAGE);return Math.floor(r)}export{f as a};
2
+ //# sourceMappingURL=chunk-K4KGEEBT.js.map