@unbrained/pm-cli 2026.11.10 → 2026.11.12

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 (190) hide show
  1. package/.agents/skills/pm-test-audit/SKILL.md +2 -1
  2. package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +2 -1
  3. package/.claude-plugin/marketplace.json +1 -1
  4. package/AGENTS.md +2 -2
  5. package/CHANGELOG.md +31 -0
  6. package/CONTRIBUTING.md +1 -1
  7. package/README.md +1 -1
  8. package/dist/cli/commander-usage.js +2 -2
  9. package/dist/cli/error-guidance.js +3 -3
  10. package/dist/cli/help-json-payload.js +1 -1
  11. package/dist/cli/main.js +4 -4
  12. package/dist/cli/register-mutation.js +2 -2
  13. package/dist/cli/register-operations.js +1 -1
  14. package/dist/cli/runtime/refusal-credential-redaction.js +2 -0
  15. package/dist/cli-bundle/bundle-manifest.json +1 -1
  16. package/dist/cli-bundle/chunks/{chunk-BSJSGDA3.js → chunk-2DUUL53Z.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-YSWD2NXB.js → chunk-2K6GJUW7.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-TBBWPEF5.js → chunk-3DWEBVIK.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-L4WWG2H6.js → chunk-5NGGI7JC.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-U7LILCUN.js → chunk-5NY6EQSX.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-X7NM5HVQ.js → chunk-6ESY4Y2B.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-CZETQYKO.js → chunk-A7L5IEYV.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-5CAMQHEW.js → chunk-EALO2FPM.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-7NAAW5EX.js → chunk-FJNHTBJ2.js} +2 -2
  25. package/dist/cli-bundle/chunks/chunk-FOT5K5OM.js +124 -0
  26. package/dist/cli-bundle/chunks/{chunk-F7P2NZEG.js → chunk-GDS4DC5A.js} +47 -43
  27. package/dist/cli-bundle/chunks/{chunk-F6FBGLR7.js → chunk-GLPUIQDB.js} +2 -2
  28. package/dist/cli-bundle/chunks/{chunk-4FLAKTZW.js → chunk-KJL42AN5.js} +2 -2
  29. package/dist/cli-bundle/chunks/{chunk-FYD6LSJA.js → chunk-L3SA3354.js} +2 -2
  30. package/dist/cli-bundle/chunks/chunk-MR3CRLA7.js +2 -0
  31. package/dist/cli-bundle/chunks/{chunk-NZAFLDSH.js → chunk-OBTU2BHJ.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-4AASUCHO.js → chunk-OFIXSWJS.js} +2 -2
  33. package/dist/cli-bundle/chunks/chunk-PS2YAPXC.js +9 -0
  34. package/dist/cli-bundle/chunks/{chunk-WNEUWDUE.js → chunk-PZI6CR24.js} +46 -46
  35. package/dist/cli-bundle/chunks/{chunk-NNE63MSM.js → chunk-T4UC3ZKL.js} +2 -2
  36. package/dist/cli-bundle/chunks/{chunk-EHDGHFMJ.js → chunk-U7MZIX3D.js} +2 -2
  37. package/dist/cli-bundle/chunks/chunk-UTNPDAID.js +31 -0
  38. package/dist/cli-bundle/chunks/{chunk-OJ2KEDUX.js → chunk-UY7Z3ZHQ.js} +2 -2
  39. package/dist/cli-bundle/chunks/{item-revision-M7KXLQXF.js → item-revision-SYJT6TVZ.js} +2 -2
  40. package/dist/cli-bundle/chunks/item-transaction-YXZ27UC6.js +2 -0
  41. package/dist/cli-bundle/chunks/{mutation-admission-374UR7NI.js → mutation-admission-T57TAVWI.js} +2 -2
  42. package/dist/cli-bundle/chunks/{register-list-query-GSB7PP5P.js → register-list-query-5XZXTPNG.js} +2 -2
  43. package/dist/cli-bundle/chunks/register-mutation-V6WJFL77.js +20 -0
  44. package/dist/cli-bundle/chunks/register-operations-5RAWXY2F.js +2 -0
  45. package/dist/cli-bundle/chunks/{register-setup-QDZ2Y3CI.js → register-setup-HCKCSQWQ.js} +2 -2
  46. package/dist/cli-bundle/chunks/{stage-67WGPKPH.js → stage-VIDXGF3T.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-PAGW6A2X.js → chunk-3FN4ON2Z.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-5OCUNAQN.js +2 -0
  49. package/dist/cli-bundle/focused-chunks/chunk-AIYJHVKV.js +44 -0
  50. package/dist/cli-bundle/focused-chunks/{chunk-QHGGO7SY.js → chunk-AXPRCCYM.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/chunk-BB2GMKRB.js +2 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-QCHCEFTO.js → chunk-BHYGUVAU.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/chunk-GAXO2UQX.js +2 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-3K2MYE7R.js → chunk-GB2N4OM7.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-HTMQDNVC.js → chunk-GBW2EAAG.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-ZBOCYFBE.js → chunk-HIKZYZ26.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/chunk-IPIFI4NT.js +3 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-KN7RBRRH.js +26 -0
  59. package/dist/cli-bundle/focused-chunks/{chunk-3DWNH72D.js → chunk-LAIN47EJ.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-2SQUWQP3.js → chunk-MK7UQEE5.js} +18 -18
  61. package/dist/cli-bundle/focused-chunks/{chunk-LY3JXL25.js → chunk-NP5C2TQM.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-RFMKS7VD.js → chunk-NSOXVVQX.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-WJHDUON5.js → chunk-NY65XTX7.js} +2 -2
  64. package/dist/cli-bundle/focused-chunks/{chunk-67M7E2Z3.js → chunk-P6KYUJD4.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/chunk-RXY6BFRW.js +2 -0
  66. package/dist/cli-bundle/focused-chunks/{chunk-2Y4H4LIX.js → chunk-SPAEZKVA.js} +2 -2
  67. package/dist/cli-bundle/focused-chunks/chunk-TZO6L523.js +2 -0
  68. package/dist/cli-bundle/focused-chunks/{chunk-BE2GK2G7.js → chunk-VUNX6NBR.js} +53 -53
  69. package/dist/cli-bundle/focused-chunks/{item-revision-XC4ZJ7MY.js → item-revision-PWJNBW3F.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/{item-transaction-CVGK4RJP.js → item-transaction-T6HXC3NS.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/{mutation-admission-N27D5H64.js → mutation-admission-CLPOLSXZ.js} +2 -2
  72. package/dist/cli-bundle/focused-chunks/{stage-KPK2UHVO.js → stage-EKYWEU2Y.js} +2 -2
  73. package/dist/cli-bundle/main.js +32 -32
  74. package/dist/cli-bundle/sdk-authoring.js +1 -1
  75. package/dist/cli-bundle/sdk-contracts.js +2 -2
  76. package/dist/cli-bundle/sdk-core.js +1 -1
  77. package/dist/cli-bundle/sdk-governance.js +1 -1
  78. package/dist/cli-bundle/sdk-graph.js +1 -1
  79. package/dist/cli-bundle/sdk-merge.js +57 -57
  80. package/dist/cli-bundle/sdk-query.js +1 -1
  81. package/dist/cli-bundle/sdk-runtime.js +1 -1
  82. package/dist/cli-bundle/sdk-testing.js +1 -1
  83. package/dist/cli-bundle/sdk.js +12 -12
  84. package/dist/core/item/parse.d.ts +13 -1
  85. package/dist/core/item/parse.js +4 -4
  86. package/dist/core/sentry/instrument.js +1 -1
  87. package/dist/core/shared/secret-rules.d.ts +18 -2
  88. package/dist/core/shared/secret-rules.js +4 -2
  89. package/dist/core/shared/url-credentials.d.ts +37 -0
  90. package/dist/core/shared/url-credentials.js +2 -0
  91. package/dist/core/telemetry/runtime.js +2 -2
  92. package/dist/sdk/agent/command-recovery.js +1 -1
  93. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  94. package/dist/sdk/cli-contracts/completeness.js +1 -1
  95. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  96. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  97. package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
  98. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  99. package/dist/sdk/command-line.d.ts +1 -1
  100. package/dist/sdk/command-line.js +1 -1
  101. package/dist/sdk/completion/bash.js +1 -1
  102. package/dist/sdk/completion/fish.js +3 -1
  103. package/dist/sdk/completion/zsh.js +3 -1
  104. package/dist/sdk/docs.d.ts +14 -2
  105. package/dist/sdk/docs.js +1 -1
  106. package/dist/sdk/files.d.ts +14 -2
  107. package/dist/sdk/files.js +1 -1
  108. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  109. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  110. package/dist/sdk/governance/boundary-fixtures.d.ts +25 -0
  111. package/dist/sdk/governance/boundary-fixtures.js +1 -1
  112. package/dist/sdk/governance/defect-recurrence.d.ts +8 -1
  113. package/dist/sdk/governance/defect-recurrence.js +2 -2
  114. package/dist/sdk/guide-topics.js +1 -1
  115. package/dist/sdk/index.d.ts +1 -1
  116. package/dist/sdk/index.js +1 -1
  117. package/dist/sdk/lifecycle/dependency-removal.js +2 -0
  118. package/dist/sdk/lifecycle/item-revision.js +1 -1
  119. package/dist/sdk/lifecycle/start-blockers.d.ts +9 -0
  120. package/dist/sdk/lifecycle/start-blockers.js +1 -1
  121. package/dist/sdk/lifecycle/update.d.ts +10 -4
  122. package/dist/sdk/lifecycle/update.js +2 -2
  123. package/dist/sdk/linked-artifacts.d.ts +73 -3
  124. package/dist/sdk/linked-artifacts.js +2 -2
  125. package/dist/sdk/public-surface.json +1 -1
  126. package/dist/sdk/runtime/actions.js +1 -1
  127. package/dist/sdk/test/command-args.js +1 -1
  128. package/dist/sdk/test/execution.d.ts +15 -3
  129. package/dist/sdk/test/execution.js +2 -2
  130. package/docs/AGENT_GUIDE.md +2 -2
  131. package/docs/AGENT_UX_CONTRACTS.md +7 -1
  132. package/docs/BUILD_AND_RELEASE_ACCEPTANCE.md +1 -1
  133. package/docs/CODEX_PLUGIN.md +2 -1
  134. package/docs/COMMANDS.md +16 -9
  135. package/docs/CONFIGURATION.md +16 -0
  136. package/docs/CORPUS_SHAPES.md +1 -1
  137. package/docs/DEFECT_RECURRENCE.md +20 -1
  138. package/docs/MUTATION_INTEGRITY.md +65 -0
  139. package/docs/ONBOARDING.md +1 -1
  140. package/docs/README.md +8 -8
  141. package/docs/SDK.md +46 -0
  142. package/docs/SDK_CONTEXT_INTEGRITY.md +2 -0
  143. package/docs/TESTING.md +1 -1
  144. package/docs/generated/FLAG_LEXICON_BUDGETS.md +6 -6
  145. package/marketplace.json +1 -1
  146. package/package.json +9 -1
  147. package/packages/pm-beads/package.json +1 -1
  148. package/packages/pm-calendar/package.json +1 -1
  149. package/packages/pm-command-kit/package.json +1 -1
  150. package/packages/pm-digital-twin/package.json +1 -1
  151. package/packages/pm-governance-audit/package.json +1 -1
  152. package/packages/pm-guide-shell/package.json +1 -1
  153. package/packages/pm-kanban/package.json +1 -1
  154. package/packages/pm-lifecycle-hooks/package.json +1 -1
  155. package/packages/pm-linked-test-adapters/package.json +1 -1
  156. package/packages/pm-search-advanced/package.json +1 -1
  157. package/packages/pm-templates/package.json +1 -1
  158. package/packages/pm-todos/package.json +1 -1
  159. package/packages/pm-vcs/package.json +1 -1
  160. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  161. package/plugins/pm-claude/package.json +1 -1
  162. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  163. package/plugins/pm-codex/package.json +1 -1
  164. package/plugins/pm-codex/plugin.json +1 -1
  165. package/runtime-dependencies.json +1 -1
  166. package/dist/cli-bundle/chunks/chunk-D727C4RO.js +0 -122
  167. package/dist/cli-bundle/chunks/chunk-T2MNRM3S.js +0 -9
  168. package/dist/cli-bundle/chunks/chunk-UFPLZ6LZ.js +0 -2
  169. package/dist/cli-bundle/chunks/chunk-UL64P6MR.js +0 -31
  170. package/dist/cli-bundle/chunks/item-transaction-4N5P34GO.js +0 -2
  171. package/dist/cli-bundle/chunks/register-mutation-ZBF6ITYK.js +0 -20
  172. package/dist/cli-bundle/chunks/register-operations-PWF6GOHE.js +0 -2
  173. package/dist/cli-bundle/focused-chunks/chunk-56MIAFEN.js +0 -24
  174. package/dist/cli-bundle/focused-chunks/chunk-ALLOWZSH.js +0 -2
  175. package/dist/cli-bundle/focused-chunks/chunk-LWMPQRJT.js +0 -2
  176. package/dist/cli-bundle/focused-chunks/chunk-NZQYHPUN.js +0 -3
  177. package/dist/cli-bundle/focused-chunks/chunk-QK7FX4O5.js +0 -44
  178. package/dist/cli-bundle/focused-chunks/chunk-U7HWWEJ2.js +0 -2
  179. package/dist/cli-bundle/focused-chunks/chunk-UIZVD36C.js +0 -2
  180. package/dist/cli-bundle/focused-chunks/chunk-WK773UVA.js +0 -2
  181. package/docs/CHATGPT_CODEX_PLUGIN_IMPLEMENTATION.md +0 -776
  182. package/docs/CONTEXT_ALGORITHM_PORTFOLIO.md +0 -167
  183. package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +0 -246
  184. package/docs/PR_REVIEW_LOOP.md +0 -96
  185. package/docs/RELEASE_LEDGER_RECONCILIATION.md +0 -148
  186. package/docs/RELEASE_RELIABILITY.md +0 -147
  187. package/docs/RELEASING.md +0 -805
  188. package/docs/performance/corpus-shape-comparison.json +0 -1
  189. package/docs/performance/latest-scale-report.json +0 -1
  190. package/docs/performance/scale-100k-report.json +0 -1
@@ -1,2 +1,2 @@
1
- import{ga as p,ha as i,ia as v,ja as _}from"./chunk-NZAFLDSH.js";import{Pa as h}from"./chunk-WNEUWDUE.js";import u from"node:fs/promises";import c 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]="846100a9-4314-5f7c-b892-fa16e09bee5b")}catch{}})();function f(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function y(e){return e!=="invalid"&&e!=="unreadable"}function j(e){let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new SyntaxError("Invalid settings object");let r=t.extensions;if(r===void 0)return{enabled:[],disabled:[]};if(typeof r!="object"||r===null||Array.isArray(r))throw new SyntaxError("Invalid extensions settings");let n=r;if(n.enabled!==void 0&&(!Array.isArray(n.enabled)||!n.enabled.every(a=>typeof a=="string"))||n.disabled!==void 0&&(!Array.isArray(n.disabled)||!n.disabled.every(a=>typeof a=="string")))throw new SyntaxError("Invalid extension enablement lists");return{enabled:n.enabled??[],disabled:n.disabled??[]}}async function S(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{status:"absent",enabled:[],disabled:[]}:{status:"unreadable",enabled:[],disabled:[],error:{code:"settings_unreadable",path:e}}}try{return{status:"ok",...j(t)}}catch{return{status:"invalid",enabled:[],disabled:[],error:{code:"settings_invalid",path:e}}}}async function A(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){if(f(r))try{if((await u.stat(c.dirname(e))).isDirectory())return{status:"absent",entries:[]}}catch(n){if(f(n))return{status:"absent",entries:[]}}return{status:"unreadable",entries:[],error:{code:"managed_state_unreadable",path:e}}}try{let r=JSON.parse(t),n=_(r);if(!n||typeof r!="object"||r===null||!Array.isArray(r.entries)||n.entries.length!==r.entries.length)throw new SyntaxError("Invalid managed extension state");return{status:"ok",entries:n.entries}}catch{return{status:"invalid",entries:[],error:{code:"managed_state_invalid",path:e}}}}async function I(e){try{return{directories:(await u.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,r)=>t.localeCompare(r))}}catch(t){return f(t)?{directories:[]}:{directories:[],error:{code:"extensions_unreadable",path:e}}}}async function D(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{manifest:null,error:{code:"manifest_invalid",path:e}}:{manifest:null,error:{code:"manifest_unreadable",path:e}}}try{let r=v(JSON.parse(t));return r?{manifest:r}:{manifest:null,error:{code:"manifest_invalid",path:e}}}catch{return{manifest:null,error:{code:"manifest_invalid",path:e}}}}function M(e){let t=e.manifest?.name??e.directory,r=new Set(p(e.settings.enabled)),n=new Set(p(e.settings.disabled)),a=!y(e.settings.status)||!e.manifest?null:!n.has(t)&&(r.size===0||r.has(t)),o=y(e.managed.status)?e.managed.entries.some(d=>i(d.name)===i(t)||i(d.directory)===i(e.directory)):null;return{name:t,directory:e.directory,scope:e.scope,installed:!0,status:e.manifest?a===!1?"inactive":"installed":"malformed_manifest",configured_enabled:a,managed:o,runtime_active:null,...e.manifest?{version:e.manifest.version}:{}}}async function R(e){let t=e.scope??"project",r=t==="global"?h(e.cwd??process.cwd()):e.pmRoot,n=c.join(r,"extensions"),a=await S(c.join(r,"settings.json")),o=await A(c.join(n,".managed-extensions.json")),d=await I(n),l=[];for(let s of[a,o,d])s.error&&l.push(s.error);let m=e.name?.trim(),b=[];for(let s of d.directories){let x=c.join(n,s,"manifest.json"),g=await D(x);g.error&&l.push(g.error);let w=M({directory:s,scope:t,manifest:g.manifest,settings:a,managed:o});m&&![w.name,s].some(E=>i(E)===i(m))||b.push(w)}return m&&b.length===0&&l.every(s=>s.code!=="extensions_unreadable")&&b.push({name:m,directory:null,scope:t,installed:!1,status:"absent",configured_enabled:y(a.status)?!1:null,managed:y(o.status)?!1:null,runtime_active:null}),{scope:t,complete:l.length===0,settings_status:a.status,managed_state_status:o.status,extensions:b,errors:l}}export{R as a};
2
- //# sourceMappingURL=chunk-F6FBGLR7.js.map
1
+ import{ga as p,ha as i,ia as v,ja as _}from"./chunk-OBTU2BHJ.js";import{Pa as h}from"./chunk-PZI6CR24.js";import u from"node:fs/promises";import c 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]="846100a9-4314-5f7c-b892-fa16e09bee5b")}catch{}})();function f(e){return typeof e=="object"&&e!==null&&"code"in e&&e.code==="ENOENT"}function y(e){return e!=="invalid"&&e!=="unreadable"}function j(e){let t=JSON.parse(e);if(typeof t!="object"||t===null||Array.isArray(t))throw new SyntaxError("Invalid settings object");let r=t.extensions;if(r===void 0)return{enabled:[],disabled:[]};if(typeof r!="object"||r===null||Array.isArray(r))throw new SyntaxError("Invalid extensions settings");let n=r;if(n.enabled!==void 0&&(!Array.isArray(n.enabled)||!n.enabled.every(a=>typeof a=="string"))||n.disabled!==void 0&&(!Array.isArray(n.disabled)||!n.disabled.every(a=>typeof a=="string")))throw new SyntaxError("Invalid extension enablement lists");return{enabled:n.enabled??[],disabled:n.disabled??[]}}async function S(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{status:"absent",enabled:[],disabled:[]}:{status:"unreadable",enabled:[],disabled:[],error:{code:"settings_unreadable",path:e}}}try{return{status:"ok",...j(t)}}catch{return{status:"invalid",enabled:[],disabled:[],error:{code:"settings_invalid",path:e}}}}async function A(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){if(f(r))try{if((await u.stat(c.dirname(e))).isDirectory())return{status:"absent",entries:[]}}catch(n){if(f(n))return{status:"absent",entries:[]}}return{status:"unreadable",entries:[],error:{code:"managed_state_unreadable",path:e}}}try{let r=JSON.parse(t),n=_(r);if(!n||typeof r!="object"||r===null||!Array.isArray(r.entries)||n.entries.length!==r.entries.length)throw new SyntaxError("Invalid managed extension state");return{status:"ok",entries:n.entries}}catch{return{status:"invalid",entries:[],error:{code:"managed_state_invalid",path:e}}}}async function I(e){try{return{directories:(await u.readdir(e,{withFileTypes:!0})).filter(t=>t.isDirectory()).map(t=>t.name).sort((t,r)=>t.localeCompare(r))}}catch(t){return f(t)?{directories:[]}:{directories:[],error:{code:"extensions_unreadable",path:e}}}}async function D(e){let t;try{t=await u.readFile(e,"utf8")}catch(r){return f(r)?{manifest:null,error:{code:"manifest_invalid",path:e}}:{manifest:null,error:{code:"manifest_unreadable",path:e}}}try{let r=v(JSON.parse(t));return r?{manifest:r}:{manifest:null,error:{code:"manifest_invalid",path:e}}}catch{return{manifest:null,error:{code:"manifest_invalid",path:e}}}}function M(e){let t=e.manifest?.name??e.directory,r=new Set(p(e.settings.enabled)),n=new Set(p(e.settings.disabled)),a=!y(e.settings.status)||!e.manifest?null:!n.has(t)&&(r.size===0||r.has(t)),o=y(e.managed.status)?e.managed.entries.some(d=>i(d.name)===i(t)||i(d.directory)===i(e.directory)):null;return{name:t,directory:e.directory,scope:e.scope,installed:!0,status:e.manifest?a===!1?"inactive":"installed":"malformed_manifest",configured_enabled:a,managed:o,runtime_active:null,...e.manifest?{version:e.manifest.version}:{}}}async function R(e){let t=e.scope??"project",r=t==="global"?h(e.cwd??process.cwd()):e.pmRoot,n=c.join(r,"extensions"),a=await S(c.join(r,"settings.json")),o=await A(c.join(n,".managed-extensions.json")),d=await I(n),l=[];for(let s of[a,o,d])s.error&&l.push(s.error);let m=e.name?.trim(),b=[];for(let s of d.directories){let x=c.join(n,s,"manifest.json"),g=await D(x);g.error&&l.push(g.error);let w=M({directory:s,scope:t,manifest:g.manifest,settings:a,managed:o});m&&![w.name,s].some(E=>i(E)===i(m))||b.push(w)}return m&&b.length===0&&l.every(s=>s.code!=="extensions_unreadable")&&b.push({name:m,directory:null,scope:t,installed:!1,status:"absent",configured_enabled:y(a.status)?!1:null,managed:y(o.status)?!1:null,runtime_active:null}),{scope:t,complete:l.length===0,settings_status:a.status,managed_state_status:o.status,extensions:b,errors:l}}export{R as a};
2
+ //# sourceMappingURL=chunk-GLPUIQDB.js.map
@@ -1,2 +1,2 @@
1
- import{kb as h}from"./chunk-T2MNRM3S.js";import{$ as g,Cb as $,Db as R,Ib as V,Ph as U,Qf as L,Rb as v,Rf as W,X as I,Y as k,Z as F,_ as A,aa as C,fc as B,gb as D,gc as z,nf as G,of as S,t as N,u as p,w as E,x as M,y as w}from"./chunk-WNEUWDUE.js";import{A as y,C as _}from"./chunk-O4ZLEN4T.js";import{Command as ae}from"commander";(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]="a851f5ac-99a5-5061-a0c3-a08d898ea20b")}catch{}})();function nt(e){return new ae().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(e).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:t=>{U(t)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the result encoding for reads and mutations").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume continuation_kind=output_cursor").option("--output-row-contract","Include row selectors, encoding metadata, and read-output receipts").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--all","Reveal every public command and compatibility alias").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").option("--expect-hash <revision>","Refuse writes to the named item unless it is still at this item_hash from pm get (a bare hash names the command's <id>; guard each other item with <id>=<item_hash>, repeatable)",(t,n)=>[...n??[],t]).exitOverride()}(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]="8efedca0-725e-520f-ad06-825a0cccddaa")}catch{}})();var j=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),q=new Map([["files","discover"],["item","complete"]]),le=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function K(e){let t=p(e?.trim().toLowerCase()??"");return j.has(t)||q.has(t)}function ce(e,t,n){let o=j.has(n)?t+1:void 0,s=g(e.slice(t+1));if(s===void 0)return o;let r=t+1+s,a=`${n} ${e[r]}`,i=p(a);return i===a?n==="item"&&e[r]==="complete"?r+1:o:K(i)?P(e,r,i):void 0}function P(e,t,n){if(["history","context","ctx","update","close","item"].includes(n))return ce(e,t,n);let o=q.get(n);if(o===void 0)return t+1;let s=e[t+1]?.toLowerCase()===o;return t+(s?2:1)}function ue(e){let t=new Map;for(let n of h(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function de(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function fe(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let o=n.get(e);return o!==void 0&&o.value_type!=="boolean"}function pe(e,t,n,o,s){let r=0;for(let a=t;a<e.length;a+=1){let i=e[a];if(i==="--")break;if(i==="--id"){a+=1;continue}if(!i.startsWith("--id=")){if(!i.startsWith("-")){if(a<o)return!0;r+=1;continue}fe(i,e[a+1],s)&&(a+=1)}}return r>(le.get(p(n))??0)}function Y(e){let t=g(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(n!=="context"&&n!=="ctx"&&!K(n))return{argv:[...e],changed:!1,conflict:!1};let o=P(e,t,n);if(o===void 0)return{argv:[...e],changed:!1,conflict:!1};let s=o>t+1?`${p(e.slice(t,o-1).join(" "))} ${e[o-1]}`:n,r=ue(s),a=de(e),i=a[0];if(!i||!i.value?.trim())return{argv:[...e],changed:!1,conflict:!1};if(a.length>1||pe(e,o,s,i.index,r))return{argv:[...e],changed:!1,conflict:!0,itemId:i.value};let l=[...e.slice(0,i.index),...e.slice(i.index+i.consumed)],c=g(l),u=P(l,c,n);return l.splice(u,0,i.value),{argv:l,changed:!0,conflict:!1,itemId:i.value}}(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]="7b271a35-800c-52bf-9368-0410e76b8d4e")}catch{}})();var me=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),he=new Set(["toon","json"]);function ge(e,t,n){let o=e[t];if(k.has(o))return n.booleanFlags.add(o),1;let s=o.indexOf("="),r=s>0?o.slice(0,s):o;if(!I.has(r))return 1;let a=s>0?o.slice(s+1):void 0,i=a===void 0&&A(r,e[t+1]),l=a??(i?e[t+1]:void 0);return r==="--author"?n.author=l??"":typeof l=="string"&&l.length>0&&(me.has(r)?n.outputValues:n.pathValues).set(r,l),i?2:1}function be(e){return e.outputValues.get("--output-format")!=="toon"&&(e.booleanFlags.has("--json")||e.outputValues.get("--output-format")==="json"||e.pathValues.get("--format")?.trim().toLowerCase()==="json")}function ye(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=ge(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions")||["history attest","history-attest"].includes(ee(e)??""),noPager:t.booleanFlags.has("--no-pager"),json:be(t),quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...he.has(t.outputValues.get("--output-format"))?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function Z(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(k.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(I.has(o)){n+=A(o,e[n+1])?2:1;continue}if(F(o)){n+=1;continue}t.push(o),n+=1}return t}function _e(e){let t=Z(e);if(t[0]?.trim().toLowerCase()==="help"){let o=[];for(let s=1;s<t.length;s+=1){let r=t[s];if(r.startsWith("-"))break;o.push(r.trim().toLowerCase())}return{requested:!0,commandPathTokens:o}}if(t.findIndex(o=>o==="--help"||o==="-h")<0)return{requested:!1,commandPathTokens:[]};let n=[];for(let o of t){if(o.startsWith("-"))break;n.push(o.trim().toLowerCase())}return{requested:!0,commandPathTokens:n}}function T(e){return g(e)}function Ie(e){return C(e)}function we(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:_e(e).requested}function bt(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(r=>process.env[r]),o=()=>{for(let[r,a]of t.entries()){let i=n[r];i===void 0?delete process.env[a]:process.env[a]=i}},s=ye(e);return we(e,s)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var ke=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function Ce(e){let t=T(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!ke.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var ve=new Set(["pm","pm-cli"]);function Se(e,t){let n=T(e);if(n===void 0)return e;let o=e[n];return ve.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function Te(e,t){let n=T(e);if(n!==void 0&&e[n]==="help"){let i=T(e.slice(n+1));n=i===void 0?void 0:n+1+i}if(n===void 0)return e;let o=e[n],s=M[o.trim().toLowerCase()];if(!s)return e;let r=s.split(" "),a=[...e.slice(0,n),...r,...e.slice(n+1)];return t.push({from:o,to:r,reason:"command_alias",confidence:"high"}),a}function x(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function X(e){return x(e).replace(/-/g,"")}function J(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function xe(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function Oe(e,t){let n=t??h(e),o=new Map,s=new Map,r=new Map,a=new Set;for(let i of n){let l=xe(i);if(l.length===0)continue;let c=`--${x(l[0])}`;for(let d of l)J(o,x(d),c),J(s,X(d),c);let u=X(c);r.has(c)||r.set(c,u),i.list===!0&&a.add(c)}return{canonicalByNormalized:o,canonicalByCompact:s,canonicalComparables:[...r.entries()].map(([i,l])=>({canonicalFlag:i,comparable:l})),listCanonicalFlags:a}}function H(e,t){let n=x(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let s=n.replace(/-/g,""),r=t.canonicalByCompact.get(s);if(typeof r=="string")return{flag:r,reason:"flag_alias",confidence:"high"};let a=s.length>=8?2:1,i=Number.POSITIVE_INFINITY,l,c=!1;for(let u of t.canonicalComparables){let d=v(s,u.comparable,a);if(d!==null){if(d<i){i=d,l=u.canonicalFlag,c=!1;continue}d===i&&l!==u.canonicalFlag&&(c=!0)}}return!l||c||!Number.isFinite(i)||i<=0?null:{flag:l,reason:"flag_typo",confidence:i>=2?"medium":"high"}}function yt(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function Ee(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],s=n[3];return s.length===0?null:{key:o,value:s}}function Ae(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),s=o>=0?e.slice(0,o):e,r=o>=0?e.slice(o+1):void 0,a=H(s,t);if(!a)return{tokens:[e]};let i=r===void 0?a.flag:`${a.flag}=${r}`;return i===e?{tokens:[e]}:{tokens:[i],event:{from:e,to:[i],reason:a.reason,confidence:a.confidence}}}function Le(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let s=e[o];n=s==="--path"||s==="--pm-path"}return t}function Pe(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function Ne(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function Me(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let s=[],r=t+1;for(;r<e.length&&e[r]!=="--"&&!e[r].startsWith("-")&&(s.length===0||o.has(n.flag));)s.push(e[r]),r+=1;let a=s.length===0?1:1+s.length;return{originalTokens:e.slice(t,t+a),value:s.length===0?void 0:s.join(","),consumed:a}}function Fe(e,t,n,o){let s=e.get(n);if(s){s.values.push(o.value),s.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function De(e,t){let n=[],o=[];for(let[s,r]of e){if(!(r.occurrences>=2||t.has(s)&&r.originalTokens.length>2)){o.push({outputIndex:r.outputIndex,tokens:r.originalTokens});continue}let a=`${s}=${r.values.join(",")}`;o.push({outputIndex:r.outputIndex,tokens:[a]}),n.push({from:`${s} (x${r.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function $e(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function Re(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let s=[],r=new Map,a=0;for(;a<e.length;){let c=e[a];if(c==="--"){s.push(...e.slice(a));break}if(n.has(c)){a=Ne(e,a,s);continue}let u=Pe(c);if(!u||!t.has(u.flag)){s.push(c),a+=1;continue}let d=Me(e,a,u,o);if(d.value===void 0){s.push(c),a+=d.consumed;continue}Fe(r,s,u.flag,{originalTokens:d.originalTokens,value:d.value}),a+=d.consumed}let{events:i,splices:l}=De(r,o);return $e(s,l),{argv:s,events:i}}var Q=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function Ve(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],s=Q.get(o);return s!==void 0&&s.has(n)}function Be(e,t,n){if(t!=="test")return e;let o=[],s=0;for(;s<e.length;){let r=e[s];if(r==="--")return o.push(...e.slice(s)),o;let a=Q.get(r),i=a?e[s+1]:void 0;if(!a||typeof i!="string"||!a.has(i)){o.push(r),s+=1;continue}let l=s+2;for(;l<e.length&&!e[l].startsWith("-");)l+=1;if(l-(s+2)!==1){o.push(r),s+=1;continue}let c=e[s+2],u=`${i}=${c}`;o.push(r,u),n.push({from:`${r} ${i} ${c}`,to:[r,u],reason:"bare_key_value",confidence:"high"}),s+=3}return o}function ze(e,t,n,o){let s=[],r=Le(e);for(let a=0;a<e.length;a+=1){let i=e[a];if(i==="--"){s.push(...e.slice(a));break}let l=r.has(a),c=s[s.length-1];if(i.startsWith("--")){let b=Ae(i,t,l);s.push(...b.tokens),b.event&&o.push(b.event);continue}let u=Ee(i,l);if(!u||typeof c=="string"&&c.startsWith("-")&&!c.includes("=")||["search","comments","notes","learnings"].includes(n)||Ve(n,s)){s.push(i);continue}let d=H(u.key,t);if(!d){s.push(i);continue}let m=u.value.startsWith("-")?[`${d.flag}=${u.value}`]:[d.flag,u.value];s.push(...m),o.push({from:i,to:m,reason:"bare_key_value",confidence:d.confidence})}return s}function Ge(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--verify"){let o=e[t+1];if(o===void 0||o==="--")throw new _("history attest --verify requires a bundle file.",y.USAGE);e.splice(t,2,`--verify=${o}`)}else(I.has(n)||n==="--output"||n==="--hash-algorithm")&&(t+=1)}}function We(e,t){if(!e.some(o=>o==="--help"||o==="-h"))return;let n=new Set(h(t).flatMap(o=>[o.flag,...o.aliases??[],...o.short===void 0?[]:[o.short]]));for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="--")break;s!=="--help"&&s!=="-h"||n.has(e[o-1])&&!k.has(e[o-1])&&(e[o-1]=s)}}function _t(e){let t=[],n=Se(e,t),o=Ce(n);(o.length!==n.length||o.some((b,re)=>b!==n[re]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let s=Te(o,t),r=Y(s);if(r.conflict)throw new _("Provide the item id either positionally or with --id, not both.",y.USAGE);r.changed&&t.push({from:`--id ${r.itemId}`,to:[r.itemId],reason:"item_id_alias",confidence:"high"});let a=Ie(r.argv),i=ee(r.argv),l=p(i??a??""),c=Oe(i??a),u=ze(r.argv,c,l,t),d=Be(u,l,t),m=Re(d,c.listCanonicalFlags,I,a==="create"?new Set(["--tags"]):new Set);for(let b of m.events)t.push(b);return We(m.argv,i??a),i==="history attest"&&Ge(m.argv),{argv:m.argv,commandName:a,trace:t}}function ee(e){let t=Z(e),n=t[0]?.trim().toLowerCase(),o=t[1]?.trim().toLowerCase(),s=N(t);return s?s.canonical:(n==="extension"||n==="package"||n==="packages")&&typeof o=="string"&&o.length>0&&!o.startsWith("-")?`${n} ${o}`:n}function It(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return o}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fb625cd9-f8a8-56cf-88ab-abef64051497")}catch{}})();function St(e){if(e===void 0)return()=>{};let t=e.trim();if(t.length===0)throw new _("--author requires a non-empty value.",y.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let n=G();S(t);let o=!1;return()=>{o||(o=!0,n===void 0?S(void 0):S(n))}}(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]="d0e60f7e-e0a8-5ef4-9af7-4a1f102ccb7d")}catch{}})();var f=Object.freeze({clock:"PM_CLOCK",tickMs:"PM_CLOCK_TICK_MS",seed:"PM_SEED"});function O(e,t,n,o){return new _(e,y.USAGE,{code:"invalid_reproducible_process_environment",reason:t,field:n,required:`${f.clock} and ${f.seed}; ${f.tickMs} is optional`,nextSteps:[`Set ${f.clock} to an ISO-8601 instant with Z or a numeric UTC offset and ${f.seed} to a non-empty reproducibility seed.`,`Optionally set ${f.tickMs} to a non-negative integer; it defaults to 1.`,"Unset all three variables to retain normal wall-clock and cryptographic-random behavior."],recovery:{recovery_mode:"compact",provided_fields:o,missing_required_fields:t==="incomplete"?[f.clock,f.seed].filter(s=>!o.includes(s)):void 0}})}function Ue(e){let t=e[f.clock],n=e[f.tickMs],o=e[f.seed],s=[[f.clock,t],[f.tickMs,n],[f.seed,o]].filter(a=>a[1]!==void 0).map(([a])=>a);if(s.length===0)return;if(t===void 0||o===void 0)throw O("Reproducible process execution requires PM_CLOCK and PM_SEED together.","incomplete",t===void 0?f.clock:f.seed,s);if(o.trim().length===0)throw O(`${f.seed} must not be empty.`,"invalid_value",f.seed,s);if(!V(t))throw O(`${f.clock} must be a valid ISO-8601 instant with Z or a numeric UTC offset.`,"invalid_value",f.clock,s);let r=n===void 0?1:Number(n);if(n?.trim().length===0||!Number.isSafeInteger(r)||r<0)throw O(`${f.tickMs} must be a non-negative integer.`,"invalid_value",f.tickMs,s);return $({clock:t,seed:o,tickMs:r})}function je(e){let t=Ue(e);return t===void 0?n=>n():R(t)}async function Lt(e,t){return je(e)(t)}(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]="682c27fa-94d8-529b-92fc-ac8a2eb7e138")}catch{}})();var te=new Set([...Object.values(B),...z,"--full","--brief","--compact","--summary","--fields","--section","--token-budget"]),ne=new Set(["--full-changed-fields","--no-changed-fields","--id-only"]);function zt(e,t){if(!["block","unblock"].includes(e)||t.includes(e)||!t.includes("update"))return;let n=new Set(h("update").map(o=>o.flag));if((e==="block"?["--blocked-by","--blocked-reason"]:["--unset","--unblock-note"]).every(o=>n.has(o)))return e==="block"?{examples:[["update","<item-id>","--blocked-by","<blocker-id>","--blocked-reason","<reason>"]],nextSteps:["Choose the actual item and blocker identifiers before running update. --blocked-by records the blocker field and its blocked_by relationship."]}:{examples:[["update","<item-id>","--unset","blocked-by","--unset","blocked-reason","--unblock-note","<note>"]],nextSteps:["Inspect the item's blockers before running update. --unset blocked-by removes the blocker field and all blocked_by relationships; --unset blocked-reason clears the stale reason. --unblock-note alone records a note and does not unblock the item.","If your project also uses a blocked lifecycle status, choose its appropriate next status separately with update --status."]}}function qe(e,t){let n=e.includes("="),o=n?e.slice(e.indexOf("=")+1):t;if(!(!o||o.startsWith("--")))return{consumed:n?1:2,replacement:["--from",o],conflicts:["--from"]}}var Ke=["--depth","--output-include","--fields","--section","--for"];function Ye(e){let t=L(p(e.trim().toLowerCase()));if(t===void 0)return;let n=h(t),o=n.flatMap(a=>[a.flag,...a.aliases??[]]),s=[...W(t).keys()].filter(a=>o.includes(`--${a}`)),r=[...n.find(a=>a.flag==="--depth")?.values??[]];if(!(s.length===0&&r.length===0))return{command:t,modes:s,depth_values:r,declared_flags:o}}function Gt(e){return[...e.depth_values.length>0?[`--depth ${e.depth_values.join("|")}`]:[],...e.modes.map(t=>`--${t}`)].join(", ")}function Xe(e,t,n,o){let s=Ye(e);if(s===void 0||s.declared_flags.includes(t))return;let r=[...Ke,...s.modes.map(i=>`--${i}`)].filter(i=>i!==t);if(t==="--depth"){let i=n.includes("="),l=(i?n.slice(n.indexOf("=")+1):o)?.trim().toLowerCase();if(!l)return;let c=i?1:2;return s.modes.includes(l)?{consumed:c,replacement:[`--${l}`],conflicts:r}:l==="standard"?{consumed:c,replacement:[],conflicts:r}:void 0}let a=t.slice(2);return n===t&&s.depth_values.includes(a)?{consumed:1,replacement:["--depth",a],conflicts:r}:void 0}function Je(e,t,n,o){return t==="--since"&&e==="activity"?qe(n,o):t==="--toon"&&n===t?{consumed:1,replacement:["--output-format","toon"],conflicts:["--json","--format","--output-format","--stream"]}:Xe(e,t,n,o)}function Ze(e){let t=g(e);if(t===void 0)return;let n=e[t].trim().toLowerCase(),o=`${n} ${e[t+1]?.trim().toLowerCase()??""}`,s=p(o);return s!==o.trim()?s:n==="ctx"?"context":p(n)}function Wt(e,t,n){let o=e==="ctx"?"context":p(e);if(L(o)===void 0||t.includes("--")||Ze(t)!==o)return;let s=n.split("=",1)[0],r=t.flatMap((d,m)=>d===s||d.startsWith(`${s}=`)?[m]:[]);if(r.length!==1)return;let a=r[0],i=Je(o,s,t[a],t[a+1]);if(!i)return;let{replacement:l,consumed:c,conflicts:u}=i;if(!t.some(d=>u.includes(d.split("=",1)[0])))return[...t.slice(0,a),...l,...t.slice(a+c)]}function oe(e){let t=e.split("=",1)[0].replaceAll("_","-");return te.has(t)||t.length>=5&&[...te].some(n=>n.startsWith(t))}function Ut(e,t){let n=e.split("=",1)[0].replaceAll("_","-");return oe(n)?!ne.has(t):ne.has(n)?!oe(t):!0}function se(e){return e.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function jt(e){if(!(!Array.isArray(e)||e.length===0))return C(e)}function He(e,t){let n=se(t);if(!n)return;let o=h(e).find(s=>s.flag===n||s.aliases?.includes(n));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function qt(e,t,n){let o=[...e],s=o.indexOf("--"),r=s<0?o.length:s;for(let a of n){let i=se(a);if(!i||o.slice(0,r).some(u=>u===i||u.startsWith(`${i}=`)))continue;let l=He(t,i),c=l?[i,l]:[i];o.splice(r,0,...c),r+=c.length}return o.length===e.length?void 0:D(o)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bd9a8d3b-bc6f-5309-a3fb-7e5f41ef9dab")}catch{}})();(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]="12066389-daef-5fce-b7a6-0ecffa926d66")}catch{}})();function Qt(e,t){let n=e.trim().split(/\s+/u);if(!(n.length<2||t.includes(n.join(" "))))for(let o=1;o<n.length;o+=1){if(!t.includes(n.slice(0,o).join(" ")))return;let s=n.slice(o).join(" "),r=w(s),a=new Set(t.filter(i=>i===s||i.endsWith(` ${s}`)||i===r?.canonical).map(i=>w(i)?.canonical??i).filter(i=>t.includes(i)));if(a.size>0)return a.size===1?[...a][0]:void 0}}var Qe={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"],start:["start-task"]};function ie(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let s=n.split(" "),r=Qe[o]?.indexOf(p(n));if(r!==void 0&&r>=0)return r;if(n===o)return 10;if(s.includes(o))return 11;if(s.some(l=>l.startsWith(o)))return 12;let a=o.length>=5?2:1,i=Number.POSITIVE_INFINITY;for(let l of s){let c=v(l,o,a);c!==null&&(i=Math.min(i,c))}return Number.isFinite(i)?20+i:n.includes(o)?30:Number.POSITIVE_INFINITY}function en(e,t){return e.map(n=>({path:n,score:ie(n,t)})).filter(n=>Number.isFinite(n.score)).sort((n,o)=>n.score!==o.score?n.score-o.score:n.path===o.path?0:n.path<o.path?-1:1).map(n=>n.path)}function tn(e,t,n){let o=new Set(t),s=E.filter(i=>i.lifecycle==="deprecated").slice().sort((i,l)=>l.alias.length-i.alias.length),r=[],a=e.flatMap(i=>{let l=s.find(u=>i===u.alias||i.startsWith(`${u.alias} `)),c=i;if(l){let u=i.slice(l.alias.length);if(!o.has(`${l.canonical}${u}`))return[];c=`${l.canonical_argv.join(" ")}${u}`}return n!==void 0&&ie(i,n)<10&&r.push(c),[c]});return[...new Set(r.length>0?r:a)]}export{nt as a,K as b,Y as c,ye as d,Z as e,_e as f,T as g,Ie as h,bt as i,Ce as j,yt as k,Re as l,Be as m,_t as n,It as o,St as p,f as q,Ue as r,je as s,Lt as t,zt as u,Ye as v,Gt as w,Wt as x,oe as y,Ut as z,jt as A,He as B,qt as C,Qt as D,ie as E,en as F,tn as G};
2
- //# sourceMappingURL=chunk-4FLAKTZW.js.map
1
+ import{kb as h}from"./chunk-PS2YAPXC.js";import{$ as g,Hb as $,Ib as R,Nb as V,Uh as U,Vf as L,Wb as v,Wf as W,X as w,Y as k,Z as F,_ as A,aa as C,gb as D,kc as B,lc as z,sf as G,t as N,tf as S,u as p,w as E,x as M,y as I}from"./chunk-PZI6CR24.js";import{A as y,C as _}from"./chunk-O4ZLEN4T.js";import{Command as ae}from"commander";(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]="a851f5ac-99a5-5061-a0c3-a08d898ea20b")}catch{}})();function nt(e){return new ae().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(e).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:t=>{U(t)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the result encoding for reads and mutations").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume continuation_kind=output_cursor").option("--output-row-contract","Include row selectors, encoding metadata, and read-output receipts").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--all","Reveal every public command and compatibility alias").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").option("--expect-hash <revision>","Refuse writes to the named item unless it is still at this item_hash from pm get (a bare hash names the command's <id>; guard each other item with <id>=<item_hash>, repeatable)",(t,n)=>[...n??[],t]).exitOverride()}(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]="8efedca0-725e-520f-ad06-825a0cccddaa")}catch{}})();var j=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),q=new Map([["files","discover"],["item","complete"]]),le=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function K(e){let t=p(e?.trim().toLowerCase()??"");return j.has(t)||q.has(t)}function ce(e,t,n){let o=j.has(n)?t+1:void 0,s=g(e.slice(t+1));if(s===void 0)return o;let r=t+1+s,a=`${n} ${e[r]}`,i=p(a);return i===a?n==="item"&&e[r]==="complete"?r+1:o:K(i)?P(e,r,i):void 0}function P(e,t,n){if(["history","context","ctx","update","close","item"].includes(n))return ce(e,t,n);let o=q.get(n);if(o===void 0)return t+1;let s=e[t+1]?.toLowerCase()===o;return t+(s?2:1)}function ue(e){let t=new Map;for(let n of h(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function de(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function fe(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let o=n.get(e);return o!==void 0&&o.value_type!=="boolean"}function pe(e,t,n,o,s){let r=0;for(let a=t;a<e.length;a+=1){let i=e[a];if(i==="--")break;if(i==="--id"){a+=1;continue}if(!i.startsWith("--id=")){if(!i.startsWith("-")){if(a<o)return!0;r+=1;continue}fe(i,e[a+1],s)&&(a+=1)}}return r>(le.get(p(n))??0)}function Y(e){let t=g(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(n!=="context"&&n!=="ctx"&&!K(n))return{argv:[...e],changed:!1,conflict:!1};let o=P(e,t,n);if(o===void 0)return{argv:[...e],changed:!1,conflict:!1};let s=o>t+1?`${p(e.slice(t,o-1).join(" "))} ${e[o-1]}`:n,r=ue(s),a=de(e),i=a[0];if(!i||!i.value?.trim())return{argv:[...e],changed:!1,conflict:!1};if(a.length>1||pe(e,o,s,i.index,r))return{argv:[...e],changed:!1,conflict:!0,itemId:i.value};let l=[...e.slice(0,i.index),...e.slice(i.index+i.consumed)],c=g(l),u=P(l,c,n);return l.splice(u,0,i.value),{argv:l,changed:!0,conflict:!1,itemId:i.value}}(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]="7b271a35-800c-52bf-9368-0410e76b8d4e")}catch{}})();var me=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),he=new Set(["toon","json"]);function ge(e,t,n){let o=e[t];if(k.has(o))return n.booleanFlags.add(o),1;let s=o.indexOf("="),r=s>0?o.slice(0,s):o;if(!w.has(r))return 1;let a=s>0?o.slice(s+1):void 0,i=a===void 0&&A(r,e[t+1]),l=a??(i?e[t+1]:void 0);return r==="--author"?n.author=l??"":typeof l=="string"&&l.length>0&&(me.has(r)?n.outputValues:n.pathValues).set(r,l),i?2:1}function be(e){return e.outputValues.get("--output-format")!=="toon"&&(e.booleanFlags.has("--json")||e.outputValues.get("--output-format")==="json"||e.pathValues.get("--format")?.trim().toLowerCase()==="json")}function ye(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=ge(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions")||["history attest","history-attest"].includes(ee(e)??""),noPager:t.booleanFlags.has("--no-pager"),json:be(t),quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...he.has(t.outputValues.get("--output-format"))?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function Z(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(k.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(w.has(o)){n+=A(o,e[n+1])?2:1;continue}if(F(o)){n+=1;continue}t.push(o),n+=1}return t}function _e(e){let t=Z(e);if(t[0]?.trim().toLowerCase()==="help"){let o=[];for(let s=1;s<t.length;s+=1){let r=t[s];if(r.startsWith("-"))break;o.push(r.trim().toLowerCase())}return{requested:!0,commandPathTokens:o}}if(t.findIndex(o=>o==="--help"||o==="-h")<0)return{requested:!1,commandPathTokens:[]};let n=[];for(let o of t){if(o.startsWith("-"))break;n.push(o.trim().toLowerCase())}return{requested:!0,commandPathTokens:n}}function T(e){return g(e)}function we(e){return C(e)}function Ie(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:_e(e).requested}function bt(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(r=>process.env[r]),o=()=>{for(let[r,a]of t.entries()){let i=n[r];i===void 0?delete process.env[a]:process.env[a]=i}},s=ye(e);return Ie(e,s)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var ke=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function Ce(e){let t=T(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!ke.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var ve=new Set(["pm","pm-cli"]);function Se(e,t){let n=T(e);if(n===void 0)return e;let o=e[n];return ve.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function Te(e,t){let n=T(e);if(n!==void 0&&e[n]==="help"){let i=T(e.slice(n+1));n=i===void 0?void 0:n+1+i}if(n===void 0)return e;let o=e[n],s=M[o.trim().toLowerCase()];if(!s)return e;let r=s.split(" "),a=[...e.slice(0,n),...r,...e.slice(n+1)];return t.push({from:o,to:r,reason:"command_alias",confidence:"high"}),a}function x(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function X(e){return x(e).replace(/-/g,"")}function J(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function xe(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function Oe(e,t){let n=t??h(e),o=new Map,s=new Map,r=new Map,a=new Set;for(let i of n){let l=xe(i);if(l.length===0)continue;let c=`--${x(l[0])}`;for(let d of l)J(o,x(d),c),J(s,X(d),c);let u=X(c);r.has(c)||r.set(c,u),i.list===!0&&a.add(c)}return{canonicalByNormalized:o,canonicalByCompact:s,canonicalComparables:[...r.entries()].map(([i,l])=>({canonicalFlag:i,comparable:l})),listCanonicalFlags:a}}function H(e,t){let n=x(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let s=n.replace(/-/g,""),r=t.canonicalByCompact.get(s);if(typeof r=="string")return{flag:r,reason:"flag_alias",confidence:"high"};let a=s.length>=8?2:1,i=Number.POSITIVE_INFINITY,l,c=!1;for(let u of t.canonicalComparables){let d=v(s,u.comparable,a);if(d!==null){if(d<i){i=d,l=u.canonicalFlag,c=!1;continue}d===i&&l!==u.canonicalFlag&&(c=!0)}}return!l||c||!Number.isFinite(i)||i<=0?null:{flag:l,reason:"flag_typo",confidence:i>=2?"medium":"high"}}function yt(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function Ee(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],s=n[3];return s.length===0?null:{key:o,value:s}}function Ae(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),s=o>=0?e.slice(0,o):e,r=o>=0?e.slice(o+1):void 0,a=H(s,t);if(!a)return{tokens:[e]};let i=r===void 0?a.flag:`${a.flag}=${r}`;return i===e?{tokens:[e]}:{tokens:[i],event:{from:e,to:[i],reason:a.reason,confidence:a.confidence}}}function Le(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let s=e[o];n=s==="--path"||s==="--pm-path"}return t}function Pe(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function Ne(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function Me(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let s=[],r=t+1;for(;r<e.length&&e[r]!=="--"&&!e[r].startsWith("-")&&(s.length===0||o.has(n.flag));)s.push(e[r]),r+=1;let a=s.length===0?1:1+s.length;return{originalTokens:e.slice(t,t+a),value:s.length===0?void 0:s.join(","),consumed:a}}function Fe(e,t,n,o){let s=e.get(n);if(s){s.values.push(o.value),s.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function De(e,t){let n=[],o=[];for(let[s,r]of e){if(!(r.occurrences>=2||t.has(s)&&r.originalTokens.length>2)){o.push({outputIndex:r.outputIndex,tokens:r.originalTokens});continue}let a=`${s}=${r.values.join(",")}`;o.push({outputIndex:r.outputIndex,tokens:[a]}),n.push({from:`${s} (x${r.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function $e(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function Re(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let s=[],r=new Map,a=0;for(;a<e.length;){let c=e[a];if(c==="--"){s.push(...e.slice(a));break}if(n.has(c)){a=Ne(e,a,s);continue}let u=Pe(c);if(!u||!t.has(u.flag)){s.push(c),a+=1;continue}let d=Me(e,a,u,o);if(d.value===void 0){s.push(c),a+=d.consumed;continue}Fe(r,s,u.flag,{originalTokens:d.originalTokens,value:d.value}),a+=d.consumed}let{events:i,splices:l}=De(r,o);return $e(s,l),{argv:s,events:i}}var Q=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function Ve(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],s=Q.get(o);return s!==void 0&&s.has(n)}function Be(e,t,n){if(t!=="test")return e;let o=[],s=0;for(;s<e.length;){let r=e[s];if(r==="--")return o.push(...e.slice(s)),o;let a=Q.get(r),i=a?e[s+1]:void 0;if(!a||typeof i!="string"||!a.has(i)){o.push(r),s+=1;continue}let l=s+2;for(;l<e.length&&!e[l].startsWith("-");)l+=1;if(l-(s+2)!==1){o.push(r),s+=1;continue}let c=e[s+2],u=`${i}=${c}`;o.push(r,u),n.push({from:`${r} ${i} ${c}`,to:[r,u],reason:"bare_key_value",confidence:"high"}),s+=3}return o}function ze(e,t,n,o){let s=[],r=Le(e);for(let a=0;a<e.length;a+=1){let i=e[a];if(i==="--"){s.push(...e.slice(a));break}let l=r.has(a),c=s[s.length-1];if(i.startsWith("--")){let b=Ae(i,t,l);s.push(...b.tokens),b.event&&o.push(b.event);continue}let u=Ee(i,l);if(!u||typeof c=="string"&&c.startsWith("-")&&!c.includes("=")||["search","comments","notes","learnings"].includes(n)||Ve(n,s)){s.push(i);continue}let d=H(u.key,t);if(!d){s.push(i);continue}let m=u.value.startsWith("-")?[`${d.flag}=${u.value}`]:[d.flag,u.value];s.push(...m),o.push({from:i,to:m,reason:"bare_key_value",confidence:d.confidence})}return s}function Ge(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--verify"){let o=e[t+1];if(o===void 0||o==="--")throw new _("history attest --verify requires a bundle file.",y.USAGE);e.splice(t,2,`--verify=${o}`)}else(w.has(n)||n==="--output"||n==="--hash-algorithm")&&(t+=1)}}function We(e,t){if(!e.some(o=>o==="--help"||o==="-h"))return;let n=new Set(h(t).flatMap(o=>[o.flag,...o.aliases??[],...o.short===void 0?[]:[o.short]]));for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="--")break;s!=="--help"&&s!=="-h"||n.has(e[o-1])&&!k.has(e[o-1])&&(e[o-1]=s)}}function _t(e){let t=[],n=Se(e,t),o=Ce(n);(o.length!==n.length||o.some((b,re)=>b!==n[re]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let s=Te(o,t),r=Y(s);if(r.conflict)throw new _("Provide the item id either positionally or with --id, not both.",y.USAGE);r.changed&&t.push({from:`--id ${r.itemId}`,to:[r.itemId],reason:"item_id_alias",confidence:"high"});let a=we(r.argv),i=ee(r.argv),l=p(i??a??""),c=Oe(i??a),u=ze(r.argv,c,l,t),d=Be(u,l,t),m=Re(d,c.listCanonicalFlags,w,a==="create"?new Set(["--tags"]):new Set);for(let b of m.events)t.push(b);return We(m.argv,i??a),i==="history attest"&&Ge(m.argv),{argv:m.argv,commandName:a,trace:t}}function ee(e){let t=Z(e),n=t[0]?.trim().toLowerCase(),o=t[1]?.trim().toLowerCase(),s=N(t);return s?s.canonical:(n==="extension"||n==="package"||n==="packages")&&typeof o=="string"&&o.length>0&&!o.startsWith("-")?`${n} ${o}`:n}function wt(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return o}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fb625cd9-f8a8-56cf-88ab-abef64051497")}catch{}})();function St(e){if(e===void 0)return()=>{};let t=e.trim();if(t.length===0)throw new _("--author requires a non-empty value.",y.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let n=G();S(t);let o=!1;return()=>{o||(o=!0,n===void 0?S(void 0):S(n))}}(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]="d0e60f7e-e0a8-5ef4-9af7-4a1f102ccb7d")}catch{}})();var f=Object.freeze({clock:"PM_CLOCK",tickMs:"PM_CLOCK_TICK_MS",seed:"PM_SEED"});function O(e,t,n,o){return new _(e,y.USAGE,{code:"invalid_reproducible_process_environment",reason:t,field:n,required:`${f.clock} and ${f.seed}; ${f.tickMs} is optional`,nextSteps:[`Set ${f.clock} to an ISO-8601 instant with Z or a numeric UTC offset and ${f.seed} to a non-empty reproducibility seed.`,`Optionally set ${f.tickMs} to a non-negative integer; it defaults to 1.`,"Unset all three variables to retain normal wall-clock and cryptographic-random behavior."],recovery:{recovery_mode:"compact",provided_fields:o,missing_required_fields:t==="incomplete"?[f.clock,f.seed].filter(s=>!o.includes(s)):void 0}})}function Ue(e){let t=e[f.clock],n=e[f.tickMs],o=e[f.seed],s=[[f.clock,t],[f.tickMs,n],[f.seed,o]].filter(a=>a[1]!==void 0).map(([a])=>a);if(s.length===0)return;if(t===void 0||o===void 0)throw O("Reproducible process execution requires PM_CLOCK and PM_SEED together.","incomplete",t===void 0?f.clock:f.seed,s);if(o.trim().length===0)throw O(`${f.seed} must not be empty.`,"invalid_value",f.seed,s);if(!V(t))throw O(`${f.clock} must be a valid ISO-8601 instant with Z or a numeric UTC offset.`,"invalid_value",f.clock,s);let r=n===void 0?1:Number(n);if(n?.trim().length===0||!Number.isSafeInteger(r)||r<0)throw O(`${f.tickMs} must be a non-negative integer.`,"invalid_value",f.tickMs,s);return $({clock:t,seed:o,tickMs:r})}function je(e){let t=Ue(e);return t===void 0?n=>n():R(t)}async function Lt(e,t){return je(e)(t)}(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]="94bdb20f-d193-5767-91f2-8207169b82d1")}catch{}})();var te=new Set([...Object.values(B),...z,"--full","--brief","--compact","--summary","--fields","--section","--token-budget"]),ne=new Set(["--full-changed-fields","--no-changed-fields","--id-only"]);function zt(e,t){if(!["block","unblock"].includes(e)||t.includes(e)||!t.includes("update"))return;let n=new Set(h("update").map(o=>o.flag));if((e==="block"?["--blocked-by","--blocked-reason"]:["--unset","--unblock-note"]).every(o=>n.has(o)))return e==="block"?{examples:[["update","<item-id>","--blocked-by","<blocker-id>","--blocked-reason","<reason>"]],nextSteps:["Choose the actual item and blocker identifiers before running update. --blocked-by records the blocker field and its blocked_by relationship."]}:{examples:[["update","<item-id>","--unset","blocked-by","--unset","blocked-reason","--unblock-note","<note>"]],nextSteps:[`Inspect the item's blockers before running update. --unset blocked-by removes the blocker field and the blocked_by rows naming it; other blocked_by relationships stay, so remove one with --dep-remove "id=<id>,kind=blocked_by" or all with --dep-remove kind=blocked_by. --unset blocked-reason clears the stale reason. --unblock-note alone records a note and does not unblock the item.`,"If your project also uses a blocked lifecycle status, choose its appropriate next status separately with update --status."]}}function qe(e,t){let n=e.includes("="),o=n?e.slice(e.indexOf("=")+1):t;if(!(!o||o.startsWith("--")))return{consumed:n?1:2,replacement:["--from",o],conflicts:["--from"]}}var Ke=["--depth","--output-include","--fields","--section","--for"];function Ye(e){let t=L(p(e.trim().toLowerCase()));if(t===void 0)return;let n=h(t),o=n.flatMap(a=>[a.flag,...a.aliases??[]]),s=[...W(t).keys()].filter(a=>o.includes(`--${a}`)),r=[...n.find(a=>a.flag==="--depth")?.values??[]];if(!(s.length===0&&r.length===0))return{command:t,modes:s,depth_values:r,declared_flags:o}}function Gt(e){return[...e.depth_values.length>0?[`--depth ${e.depth_values.join("|")}`]:[],...e.modes.map(t=>`--${t}`)].join(", ")}function Xe(e,t,n,o){let s=Ye(e);if(s===void 0||s.declared_flags.includes(t))return;let r=[...Ke,...s.modes.map(i=>`--${i}`)].filter(i=>i!==t);if(t==="--depth"){let i=n.includes("="),l=(i?n.slice(n.indexOf("=")+1):o)?.trim().toLowerCase();if(!l)return;let c=i?1:2;return s.modes.includes(l)?{consumed:c,replacement:[`--${l}`],conflicts:r}:l==="standard"?{consumed:c,replacement:[],conflicts:r}:void 0}let a=t.slice(2);return n===t&&s.depth_values.includes(a)?{consumed:1,replacement:["--depth",a],conflicts:r}:void 0}function Je(e,t,n,o){return t==="--since"&&e==="activity"?qe(n,o):t==="--toon"&&n===t?{consumed:1,replacement:["--output-format","toon"],conflicts:["--json","--format","--output-format","--stream"]}:Xe(e,t,n,o)}function Ze(e){let t=g(e);if(t===void 0)return;let n=e[t].trim().toLowerCase(),o=`${n} ${e[t+1]?.trim().toLowerCase()??""}`,s=p(o);return s!==o.trim()?s:n==="ctx"?"context":p(n)}function Wt(e,t,n){let o=e==="ctx"?"context":p(e);if(L(o)===void 0||t.includes("--")||Ze(t)!==o)return;let s=n.split("=",1)[0],r=t.flatMap((d,m)=>d===s||d.startsWith(`${s}=`)?[m]:[]);if(r.length!==1)return;let a=r[0],i=Je(o,s,t[a],t[a+1]);if(!i)return;let{replacement:l,consumed:c,conflicts:u}=i;if(!t.some(d=>u.includes(d.split("=",1)[0])))return[...t.slice(0,a),...l,...t.slice(a+c)]}function oe(e){let t=e.split("=",1)[0].replaceAll("_","-");return te.has(t)||t.length>=5&&[...te].some(n=>n.startsWith(t))}function Ut(e,t){let n=e.split("=",1)[0].replaceAll("_","-");return oe(n)?!ne.has(t):ne.has(n)?!oe(t):!0}function se(e){return e.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function jt(e){if(!(!Array.isArray(e)||e.length===0))return C(e)}function He(e,t){let n=se(t);if(!n)return;let o=h(e).find(s=>s.flag===n||s.aliases?.includes(n));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function qt(e,t,n){let o=[...e],s=o.indexOf("--"),r=s<0?o.length:s;for(let a of n){let i=se(a);if(!i||o.slice(0,r).some(u=>u===i||u.startsWith(`${i}=`)))continue;let l=He(t,i),c=l?[i,l]:[i];o.splice(r,0,...c),r+=c.length}return o.length===e.length?void 0:D(o)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bd9a8d3b-bc6f-5309-a3fb-7e5f41ef9dab")}catch{}})();(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]="12066389-daef-5fce-b7a6-0ecffa926d66")}catch{}})();function Qt(e,t){let n=e.trim().split(/\s+/u);if(!(n.length<2||t.includes(n.join(" "))))for(let o=1;o<n.length;o+=1){if(!t.includes(n.slice(0,o).join(" ")))return;let s=n.slice(o).join(" "),r=I(s),a=new Set(t.filter(i=>i===s||i.endsWith(` ${s}`)||i===r?.canonical).map(i=>I(i)?.canonical??i).filter(i=>t.includes(i)));if(a.size>0)return a.size===1?[...a][0]:void 0}}var Qe={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"],start:["start-task"]};function ie(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let s=n.split(" "),r=Qe[o]?.indexOf(p(n));if(r!==void 0&&r>=0)return r;if(n===o)return 10;if(s.includes(o))return 11;if(s.some(l=>l.startsWith(o)))return 12;let a=o.length>=5?2:1,i=Number.POSITIVE_INFINITY;for(let l of s){let c=v(l,o,a);c!==null&&(i=Math.min(i,c))}return Number.isFinite(i)?20+i:n.includes(o)?30:Number.POSITIVE_INFINITY}function en(e,t){return e.map(n=>({path:n,score:ie(n,t)})).filter(n=>Number.isFinite(n.score)).sort((n,o)=>n.score!==o.score?n.score-o.score:n.path===o.path?0:n.path<o.path?-1:1).map(n=>n.path)}function tn(e,t,n){let o=new Set(t),s=E.filter(i=>i.lifecycle==="deprecated").slice().sort((i,l)=>l.alias.length-i.alias.length),r=[],a=e.flatMap(i=>{let l=s.find(u=>i===u.alias||i.startsWith(`${u.alias} `)),c=i;if(l){let u=i.slice(l.alias.length);if(!o.has(`${l.canonical}${u}`))return[];c=`${l.canonical_argv.join(" ")}${u}`}return n!==void 0&&ie(i,n)<10&&r.push(c),[c]});return[...new Set(r.length>0?r:a)]}export{nt as a,K as b,Y as c,ye as d,Z as e,_e as f,T as g,we as h,bt as i,Ce as j,yt as k,Re as l,Be as m,_t as n,wt as o,St as p,f as q,Ue as r,je as s,Lt as t,zt as u,Ye as v,Gt as w,Wt as x,oe as y,Ut as z,jt as A,He as B,qt as C,Qt as D,ie as E,en as F,tn as G};
2
+ //# sourceMappingURL=chunk-KJL42AN5.js.map
@@ -1,8 +1,8 @@
1
- import{Fa as G,Gb as B,Na as E,Oi as H,Te as $,Ui as P,Zi as L,cc as U,ej as V,sf as W}from"./chunk-WNEUWDUE.js";import{d as K}from"./chunk-RSAN2YUU.js";import{a as X,b as v,c as q}from"./chunk-VS565KBX.js";import{A as b,C as k,E as S,G as j,H as N,K as F}from"./chunk-O4ZLEN4T.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="6d1f8e03-97b4-5d83-b85c-e47f39c07d48")}catch{}})();var se="PM_SOURCE_CONTEXT_ACCESS",ce="PM_ALLOW_SOURCE_CONTEXT_WRITES";function J(e){let r=e[se],i=r===void 0||r.trim().toLowerCase()==="write"?"write":"read_only",t=i==="read_only"&&e[ce]?.trim()==="1";return{access:i,write_override_applied:t,source_writes_allowed:i==="write"||t}}import{access as le,readFile as A,realpath as w}from"node:fs/promises";import{constants as me}from"node:fs";import{execFile as ue}from"node:child_process";import c from"node:path";import{promisify as de}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="b1828465-0619-514c-8956-2a81dea9efbc")}catch{}})();var _=de(ue),T="# pm-cli:merge-drivers:start",pe="# pm-cli:merge-drivers:end",x="# pm-cli:merge-drivers:v2:start",Q="# pm-cli:merge-drivers:v2:end",fe="merge-fence",ge="merge-attributes";function R(e){return`'${e.replaceAll("'",`'"'"'`)}'`}async function he(e,r){let i=await w(e);if(/(?:^|[\\/])bun-node-[^\\/]+[\\/]bun(?:\.exe)?$/iu.test(i))return;let{stdout:t}=await _(e,["--version"],{encoding:"utf8",windowsHide:!0,timeout:1e4});return t.trim()===r?i:void 0}async function we(){let e=U(import.meta.url,["../../.."]),r=process.execPath,i=!1,t=await w(process.execPath),o=process.versions.bun,a=(process.env.PATH??"").split(c.delimiter).filter(n=>c.isAbsolute(n)).map(n=>c.join(n,o===void 0?c.basename(process.execPath):process.platform==="win32"?"bun.exe":"bun")),s=o===void 0?a:[process.env.npm_execpath??"",...a,t].filter(n=>c.isAbsolute(n)&&/^(?:bun|bun\.exe)$/iu.test(c.basename(n)));for(let n of s)try{if(await le(n,me.X_OK),o!==void 0){let p=await he(n,o);if(p!==void 0){r=p,i=!0;break}continue}if(n!==t&&await w(n)===t){r=n;break}}catch{}if(o!==void 0&&!i)throw new k("Cannot install Bun merge drivers without a durable executable matching the current Bun version.",b.DEPENDENCY_FAILED,{code:"merge_bun_launcher_unavailable",why:"The current Bun process may be a temporary bunx launcher that Git cannot reuse after this command exits.",nextSteps:["Run with a durable version-matched Bun executable, expose one on an absolute PATH entry, or invoke pm through a Bun runner that publishes an absolute npm_execpath.","Retry pm merge install, then check pm health --strict-exit before merging branches."]});return`${R(r)} ${R(c.join(e,"dist","cli.js"))}`}var Z=[{key:"pm-item-toon",name:"pm field-aware TOON item document merge",artifact:"item",itemPath:"%P"},{key:"pm-item-markdown",name:"pm field-aware JSON-markdown item document merge",artifact:"item",itemPath:"%P"},{key:"pm-history",name:"pm append-only history stream merge",artifact:"history",itemPath:void 0},{key:"pm-relationship",name:"pm append-only relationship event store merge",artifact:"relationship",itemPath:void 0},{key:"pm-json",name:"pm key-level JSON config merge",artifact:"json",itemPath:void 0}];function ye(e){let r=e.explicitPath?.trim(),i=e.environment.PM_SOURCE_WORKSPACE_ROOT?.trim(),t=e.environment.PM_SOURCE_PM_PATH?.trim(),o=J(e.environment),a=!!(i&&t),s=r===void 0&&a&&(e.dryRun||o.source_writes_allowed);if(r!==void 0){let n=E(e.cwd,r);return{pm_root:n,workspace_start:n,source_coordinates_available:a,source_context_selected:!1,source_policy:o}}return s?{pm_root:c.resolve(t),workspace_start:c.resolve(i),source_coordinates_available:!0,source_context_selected:!0,source_policy:o}:{pm_root:a?E(e.cwd,".agents/pm"):E(e.cwd),workspace_start:e.cwd,source_coordinates_available:a,source_context_selected:!1,source_policy:o}}async function ee(e){try{let{stdout:r}=await _("git",["rev-parse","--show-toplevel"],{cwd:e,env:v(),encoding:"utf8",windowsHide:!0,timeout:1e4});return await w(r.trim())}catch{return null}}async function te(e){let r=await ee(e);if(r===null)throw new k("pm merge install requires a git repository (merge drivers are git configuration).",b.USAGE);return r}function O(e,r){return c.relative(e,r).split(c.sep).join("/")}function z(e){return e.replace(/[\\*?[\]!]/gu,"\\$&")}function h(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}function Y(e,r){if(e[r]!=="'")return null;let i="";for(let t=r+1;t<e.length;t+=1){if(e.startsWith(`'"'"'`,t)){i+="'",t+=4;continue}if(e[t]==="'")return{value:i,nextOffset:t+1};i+=e[t]}return null}async function ve(e,r,i){if(L(r).filter(o=>o.constraint==="exact").some(o=>o.version!==i))return!1;let t=await ee(e);if(t!==null&&t!==await w(r)){let o=await Promise.all([t,r].map(async a=>{let s=await _("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:a,env:v(),timeout:1e4});return w(s.stdout.trim())}));if(o[0]===o[1])return!1}return!0}async function _e(e,r,i){let t=Y(e,0);if(t===null||e[t.nextOffset]!==" ")return!1;let o=Y(e,t.nextOffset+1);if(o===null||e.slice(o.nextOffset)!==r||!/^(?:node|bun)(?:\.exe)?$/iu.test(c.basename(t.value))||c.basename(o.value)!=="cli.js"||c.basename(c.dirname(o.value))!=="dist"||!await S(t.value)||!await S(o.value))return!1;try{let a=c.dirname(c.dirname(o.value)),s=JSON.parse(await A(c.join(a,"package.json"),"utf8")),n=typeof s.bin=="string"?s.bin:s.bin?.pm;return await ve(a,i,s.version)?s.name==="@unbrained/pm-cli"&&n==="dist/cli.js":!1}catch{return!1}}function M(e,r){let i=e.length>0?`${z(e)}/`:"",t=[`${h(`${i}**/*.toon`)} merge=pm-item-toon`,`${h(`${i}**/*.md`)} merge=pm-item-markdown`];for(let o of r){let a=z(o);t.push(`${h(`${i}${a}/*.toon`)} merge=pm-item-toon`),t.push(`${h(`${i}${a}/*.md`)} merge=pm-item-markdown`)}return t.push(`${h(`${i}**/*.jsonl`)} merge=pm-relationship`),t.push(`${h(`${i}history/*.jsonl`)} merge=pm-history`),t.push(`${h(`${i}settings.json`)} merge=pm-json`),t.push(`${h(`${i}**/*.json`)} merge=pm-json`),t.push(`${h(`${i}extensions/**`)} merge=text`),t.push(`${h(`${i}extensions/.managed-extensions.json`)} merge=pm-json`),t}function re(e){let r=[],i=0;for(;i<e.length;){let t=e.indexOf(T,i),o=e.indexOf(x,i),a=t===-1?o:o===-1?t:Math.min(t,o);if(a===-1)break;let s=a===o,n=s?x:T,p=s?Q:pe,u=e.indexOf(p,a+n.length),m=u===-1?e.length:u+p.length;r.push({start:a,end:m,closed:u!==-1,lines:e.slice(a+n.length,u===-1?m:u).split(`
1
+ import{Fa as G,Lb as B,Na as E,Ti as H,Ye as $,Zi as P,cj as L,hc as U,jj as V,xf as W}from"./chunk-PZI6CR24.js";import{d as K}from"./chunk-RSAN2YUU.js";import{a as X,b as v,c as q}from"./chunk-VS565KBX.js";import{A as b,C as k,E as S,G as j,H as N,K as F}from"./chunk-O4ZLEN4T.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="6d1f8e03-97b4-5d83-b85c-e47f39c07d48")}catch{}})();var se="PM_SOURCE_CONTEXT_ACCESS",ce="PM_ALLOW_SOURCE_CONTEXT_WRITES";function J(e){let r=e[se],i=r===void 0||r.trim().toLowerCase()==="write"?"write":"read_only",t=i==="read_only"&&e[ce]?.trim()==="1";return{access:i,write_override_applied:t,source_writes_allowed:i==="write"||t}}import{access as le,readFile as A,realpath as w}from"node:fs/promises";import{constants as me}from"node:fs";import{execFile as ue}from"node:child_process";import c from"node:path";import{promisify as de}from"node:util";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="b1828465-0619-514c-8956-2a81dea9efbc")}catch{}})();var _=de(ue),T="# pm-cli:merge-drivers:start",pe="# pm-cli:merge-drivers:end",x="# pm-cli:merge-drivers:v2:start",Q="# pm-cli:merge-drivers:v2:end",fe="merge-fence",ge="merge-attributes";function R(e){return`'${e.replaceAll("'",`'"'"'`)}'`}async function he(e,r){let i=await w(e);if(/(?:^|[\\/])bun-node-[^\\/]+[\\/]bun(?:\.exe)?$/iu.test(i))return;let{stdout:t}=await _(e,["--version"],{encoding:"utf8",windowsHide:!0,timeout:1e4});return t.trim()===r?i:void 0}async function we(){let e=U(import.meta.url,["../../.."]),r=process.execPath,i=!1,t=await w(process.execPath),o=process.versions.bun,a=(process.env.PATH??"").split(c.delimiter).filter(n=>c.isAbsolute(n)).map(n=>c.join(n,o===void 0?c.basename(process.execPath):process.platform==="win32"?"bun.exe":"bun")),s=o===void 0?a:[process.env.npm_execpath??"",...a,t].filter(n=>c.isAbsolute(n)&&/^(?:bun|bun\.exe)$/iu.test(c.basename(n)));for(let n of s)try{if(await le(n,me.X_OK),o!==void 0){let p=await he(n,o);if(p!==void 0){r=p,i=!0;break}continue}if(n!==t&&await w(n)===t){r=n;break}}catch{}if(o!==void 0&&!i)throw new k("Cannot install Bun merge drivers without a durable executable matching the current Bun version.",b.DEPENDENCY_FAILED,{code:"merge_bun_launcher_unavailable",why:"The current Bun process may be a temporary bunx launcher that Git cannot reuse after this command exits.",nextSteps:["Run with a durable version-matched Bun executable, expose one on an absolute PATH entry, or invoke pm through a Bun runner that publishes an absolute npm_execpath.","Retry pm merge install, then check pm health --strict-exit before merging branches."]});return`${R(r)} ${R(c.join(e,"dist","cli.js"))}`}var Z=[{key:"pm-item-toon",name:"pm field-aware TOON item document merge",artifact:"item",itemPath:"%P"},{key:"pm-item-markdown",name:"pm field-aware JSON-markdown item document merge",artifact:"item",itemPath:"%P"},{key:"pm-history",name:"pm append-only history stream merge",artifact:"history",itemPath:void 0},{key:"pm-relationship",name:"pm append-only relationship event store merge",artifact:"relationship",itemPath:void 0},{key:"pm-json",name:"pm key-level JSON config merge",artifact:"json",itemPath:void 0}];function ye(e){let r=e.explicitPath?.trim(),i=e.environment.PM_SOURCE_WORKSPACE_ROOT?.trim(),t=e.environment.PM_SOURCE_PM_PATH?.trim(),o=J(e.environment),a=!!(i&&t),s=r===void 0&&a&&(e.dryRun||o.source_writes_allowed);if(r!==void 0){let n=E(e.cwd,r);return{pm_root:n,workspace_start:n,source_coordinates_available:a,source_context_selected:!1,source_policy:o}}return s?{pm_root:c.resolve(t),workspace_start:c.resolve(i),source_coordinates_available:!0,source_context_selected:!0,source_policy:o}:{pm_root:a?E(e.cwd,".agents/pm"):E(e.cwd),workspace_start:e.cwd,source_coordinates_available:a,source_context_selected:!1,source_policy:o}}async function ee(e){try{let{stdout:r}=await _("git",["rev-parse","--show-toplevel"],{cwd:e,env:v(),encoding:"utf8",windowsHide:!0,timeout:1e4});return await w(r.trim())}catch{return null}}async function te(e){let r=await ee(e);if(r===null)throw new k("pm merge install requires a git repository (merge drivers are git configuration).",b.USAGE);return r}function O(e,r){return c.relative(e,r).split(c.sep).join("/")}function z(e){return e.replace(/[\\*?[\]!]/gu,"\\$&")}function h(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"','\\"')}"`}function Y(e,r){if(e[r]!=="'")return null;let i="";for(let t=r+1;t<e.length;t+=1){if(e.startsWith(`'"'"'`,t)){i+="'",t+=4;continue}if(e[t]==="'")return{value:i,nextOffset:t+1};i+=e[t]}return null}async function ve(e,r,i){if(L(r).filter(o=>o.constraint==="exact").some(o=>o.version!==i))return!1;let t=await ee(e);if(t!==null&&t!==await w(r)){let o=await Promise.all([t,r].map(async a=>{let s=await _("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:a,env:v(),timeout:1e4});return w(s.stdout.trim())}));if(o[0]===o[1])return!1}return!0}async function _e(e,r,i){let t=Y(e,0);if(t===null||e[t.nextOffset]!==" ")return!1;let o=Y(e,t.nextOffset+1);if(o===null||e.slice(o.nextOffset)!==r||!/^(?:node|bun)(?:\.exe)?$/iu.test(c.basename(t.value))||c.basename(o.value)!=="cli.js"||c.basename(c.dirname(o.value))!=="dist"||!await S(t.value)||!await S(o.value))return!1;try{let a=c.dirname(c.dirname(o.value)),s=JSON.parse(await A(c.join(a,"package.json"),"utf8")),n=typeof s.bin=="string"?s.bin:s.bin?.pm;return await ve(a,i,s.version)?s.name==="@unbrained/pm-cli"&&n==="dist/cli.js":!1}catch{return!1}}function M(e,r){let i=e.length>0?`${z(e)}/`:"",t=[`${h(`${i}**/*.toon`)} merge=pm-item-toon`,`${h(`${i}**/*.md`)} merge=pm-item-markdown`];for(let o of r){let a=z(o);t.push(`${h(`${i}${a}/*.toon`)} merge=pm-item-toon`),t.push(`${h(`${i}${a}/*.md`)} merge=pm-item-markdown`)}return t.push(`${h(`${i}**/*.jsonl`)} merge=pm-relationship`),t.push(`${h(`${i}history/*.jsonl`)} merge=pm-history`),t.push(`${h(`${i}settings.json`)} merge=pm-json`),t.push(`${h(`${i}**/*.json`)} merge=pm-json`),t.push(`${h(`${i}extensions/**`)} merge=text`),t.push(`${h(`${i}extensions/.managed-extensions.json`)} merge=pm-json`),t}function re(e){let r=[],i=0;for(;i<e.length;){let t=e.indexOf(T,i),o=e.indexOf(x,i),a=t===-1?o:o===-1?t:Math.min(t,o);if(a===-1)break;let s=a===o,n=s?x:T,p=s?Q:pe,u=e.indexOf(p,a+n.length),m=u===-1?e.length:u+p.length;r.push({start:a,end:m,closed:u!==-1,lines:e.slice(a+n.length,u===-1?m:u).split(`
2
2
  `).map(l=>l.trim()).filter(Boolean)}),i=m}return r}function ie(e,r,i){let t=new Set(r),o=h(i.length>0?`${i}/`:"").slice(0,-1);return e.some(a=>t.has(a)||a.startsWith(o)&&/^[^/]+\/\*\.(?:toon|md)" merge=pm-item-(?:toon|markdown)$/u.test(a.slice(o.length)))}async function oe(e,r,i,t){let o=c.join(e,".gitattributes"),a=t?null:(await _("git",["rev-parse","--absolute-git-dir"],{cwd:e,env:v(),encoding:"utf8",windowsHide:!0,timeout:1e4})).stdout.trim(),s=a===null?null:await $(a,ge,120,"merge-fence",!1,!0,5e3);try{let n=await N(o)??"",p=[x,...i,Q].join(`
3
3
  `),u=re(n),m=u.filter(d=>ie(d.lines,i,r));m.length===0&&r===".agents/pm"&&u.length===1&&u[0].lines.every(d=>!d.includes("/"))&&m.push(u[0]);let l;if(m.length>0){let d=m[0];l=n;for(let y of m.slice(1).reverse())l=`${l.slice(0,y.start)}${l.slice(y.end)}`;l=`${l.slice(0,d.start)}${p}${l.slice(d.end)}`}else{let d=n.trimEnd();l=`${d.length>0?`${d}
4
4
 
5
5
  `:""}${p}
6
6
  `}return l===n?{path:o,changed:!1}:(t||await F(o,l),{path:o,changed:!0})}finally{await s?.()}}function ne(e){let r=G(e,null);return[...new Set(Object.values(r.type_to_folder))].sort((i,t)=>i.localeCompare(t))}async function Ve(e,r){let i=c.resolve(e),t=null,o="",a=i;for(let g=0;g<8;g+=1){let ae=c.join(a,".gitattributes");try{let C=await A(ae,"utf8");if(C.includes(x)||C.includes(T)){t=a,o=C;break}}catch{}let D=c.dirname(a);if(D===a)break;a=D}if(t===null)return{status:"not_installed",missing_patterns:[],stale_patterns:[],schema_scope:"project"};let s=c.join(t,".gitattributes"),n=O(t,i),p=re(o),u=M(n,r),m=p.filter(g=>ie(g.lines,u,n)),l=m.flatMap(g=>g.closed?g.lines:[]),d=new Set(l),y=new Set(u),f=u.filter(g=>!d.has(g)),I=l.filter(g=>!y.has(g));return{status:m.length!==1||!m[0].closed||f.length>0||I.length>0?"drift":"ok",path:s,missing_patterns:f,stale_patterns:I,schema_scope:"project"}}async function Ke(e){let r=[],i=[];for(let t of Z){let o=`merge.${t.key}.driver`,a=` merge driver ${t.artifact} "%O" "%A" "%B"${t.itemPath===void 0?"":` --item-path ${t.itemPath}`}`;try{let{stdout:s}=await _("git",["config","--get",o],{cwd:e,env:v(),encoding:"utf8",windowsHide:!0,timeout:1e4}),n=s.trim();await _e(n,a,e)||i.push(o)}catch{r.push(o)}}return{status:r.length>0?"missing":i.length>0?"drift":"ok",missing_keys:r,drifted_keys:i}}async function Xe(e){let r;try{r=await te(c.resolve(e))}catch{return{status:"no_git"}}let i=O(r,c.resolve(e)),t=await P(e),o=W(void 0,t.author_default),a=await $(e,fe,t.locks.ttl_seconds,o,!1,H(t).force_required_for_stale_lock,t.locks.wait_ms);try{let s=c.join(r,".gitattributes"),n;try{n=await A(s,"utf8")}catch(l){if(l instanceof Error&&"code"in l&&j(l))return{status:"not_installed",path:s};throw l}if(!n.includes(x)&&!n.includes(T))return{status:"not_installed",path:s};let p=await P(e),u=ne(p),m=await oe(r,i,M(i,u),!1);return{status:m.changed?"refreshed":"unchanged",path:m.path}}finally{await a()}}async function qe(e,r){let i=ye({cwd:process.cwd(),explicitPath:r.path,dryRun:e.dryRun===!0,environment:process.env}),t=i.pm_root;await V(t);let o=await te(i.workspace_start);return ke({pmRoot:t,workspaceRoot:o,dryRun:e.dryRun===!0,preCommitHook:e.preCommitHook===!0})}async function be(e,r){let i=(await _("git",["rev-parse","--path-format=absolute","--git-common-dir"],{cwd:e,env:v(),timeout:1e4})).stdout.trim(),t=await $(i,"merge-driver-config",120,"merge-install",!1,!0,5e3);try{let o=await q(e),a;try{a=(await _("git",["config",o,"--null","--get-regexp","."],{cwd:e,env:v(),timeout:1e4})).stdout}catch(n){if(typeof n!="object"||n===null||!("code"in n)||n.code!==1)throw n;a=""}let s=new Map(a.split("\0").filter(Boolean).map(n=>{let p=n.indexOf(`
7
7
  `);return[n.slice(0,p),n.slice(p+1)]}));for(let n of r)s.get(n.key)!==n.value&&await X(e,[o,n.key,n.value])}finally{await t()}}async function ke(e){let r=c.resolve(e.pmRoot),i=c.resolve(e.workspaceRoot),t=e.dryRun===!0,o,a;try{[o,a]=await Promise.all([w(r),w(i)])}catch(f){throw new k(`Cannot resolve tracker root ${r} or workspace root ${i}: ${String(f)}`,b.NOT_FOUND,{code:"merge_root_not_found",nextSteps:["Initialize the tracker and ensure both paths are accessible.",'Retry "pm merge install" from the repository workspace.']})}let s=O(a,o);if(K(s))throw new k(`Tracker root ${r} is outside the git repository ${i}; there is nothing to configure for this repository.`,b.USAGE);let n=await P(o),p=ne(n),u=M(s,p),m=[],l=await we(),d=e.preCommitHook===!0?await import("./settlement-hook-JHXLUBEN.js").then(async f=>({plan:await f.prepareMergeSettlementHook(a,`${l} --pm-path ${R(s||".")}`),write:f.writeMergeSettlementHook})):void 0;for(let f of Z)m.push({key:`merge.${f.key}.name`,value:f.name}),m.push({key:`merge.${f.key}.driver`,value:`${l} merge driver ${f.artifact} "%O" "%A" "%B"${f.itemPath===void 0?"":` --item-path ${f.itemPath}`}`});if(!t)try{await be(a,m)}catch{throw new k(`Cannot install repository-local merge drivers in ${a}. Ensure the repository Git config is writable and no other Git process holds its lock, then retry.`,b.DEPENDENCY_FAILED,{code:"merge_git_config_unwritable",why:"pm merge install must persist clone-local driver commands before publishing their shared .gitattributes mappings.",nextSteps:["Make the repository Git config writable or wait for the process holding its lock to finish.",'Retry "pm merge install"; the operation is idempotent.','Use "pm merge install --dry-run --json" when the workspace is intentionally read-only.']})}let y=await oe(a,s,u,t);return d!==void 0&&!t&&await d.write(d.plan),{ok:!0,dry_run:t,workspace_root:a,pm_root:o,gitattributes:{path:y.path,changed:y.changed,patterns:u,schema_scope:"project"},git_config:m,...d===void 0?{}:{settlement_hook:{path:d.plan.path,changed:d.plan.changed}},guidance:["Commit .gitattributes so every branch and collaborator shares the merge mapping.",'git config is per-clone: each collaborator (and each fresh worktree/clone) runs "pm merge install" once.','After merging branches, run "pm merge reconcile --dry-run" to inspect the complete receipt and history repair, then apply "pm merge reconcile"; use --force only after explicitly accepting any discarded values.',"Custom item types registered later refresh this fence automatically (pm schema add-type/remove-type); rerun pm merge install only after out-of-band type-folder edits."],generated_at:B()}}export{se as a,ce as b,J as c,T as d,pe as e,x as f,Q as g,ye as h,ee as i,M as j,ne as k,Ve as l,Ke as m,Xe as n,qe as o,ke as p};
8
- //# sourceMappingURL=chunk-FYD6LSJA.js.map
8
+ //# sourceMappingURL=chunk-L3SA3354.js.map
@@ -0,0 +1,2 @@
1
+ import{b as ve}from"./chunk-OFIXSWJS.js";import{Cd as g,Dd as b,Gc as ge,Hb as x,Hc as ye,Ib as k,Ob as _e,ad as Ie,hb as T,ib as ce,jb as B,kb as ae,lb as de,ob as le,pb as fe,qb as ue,rb as me,sb as he,tb as pe,ub as N}from"./chunk-FOT5K5OM.js";import{$b as p,Fa as X,Ha as J,N as V,Na as Q,Ta as Z,W as Y,Zi as se,ae as ie,hb as ee,ib as te,ki as re,ud as ne,ve as v,we as w,za as j,zf as oe}from"./chunk-PZI6CR24.js";import{A as u,C as l,z as W}from"./chunk-O4ZLEN4T.js";import{readdir as Ke}from"node:fs/promises";import H 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]="a319e7d9-e248-573b-bf1f-35217ce49fd0")}catch{}})();function D(e,t){return(t===void 0?void 0:J(e,t))?.execution_role??j[e.trim().toLowerCase()]??"agent"}var O="blocked_by",be="blocks",Le=Object.freeze([O,be]),A="no-active-blocker";function d(e){return e.trim().toLowerCase()}function E(e,t){return t?`external:${e}`:`local:${d(e)}`}function _(e){let t=new Map,n=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(n.length>0&&d(n)!==A){let i=g(n);t.set(E(n,i),i?n:d(n))}for(let i of e.dependencies??[]){let o=typeof i.id=="string"?i.id.trim():"";if(p(i.kind)===O&&o.length>0&&d(o)!==A){let r=g(o)||b(i.source_kind);t.set(E(o,r),r?o:d(o))}}return[...t.values()].sort((i,o)=>i.localeCompare(o))}function C(e){let t=new Map;for(let n of e){let i=d(n.id);i.length!==0&&t.set(i,new Set(_(n)))}for(let n of e){let i=d(n.id);if(i.length!==0)for(let o of n.dependencies??[]){let r=p(o.kind)===be&&typeof o.id=="string"?d(o.id):"";if(r.length===0||r===A)continue;let c=t.get(r)??new Set;c.add(i),t.set(r,c)}}return new Map([...t].map(([n,i])=>[n,[...i].sort((o,r)=>o.localeCompare(r))]))}function we(e,t){let n=d(e.id);return n.length>0?C(t).get(n)??_(e):_(e)}function L(e,t,n,i){let o=e,r=typeof o.id=="string"?i?.get(d(o.id))??we(o,[...t.values()]):_(e),c=new Set((e.dependencies??[]).filter(s=>p(s.kind)===O&&b(s.source_kind)&&typeof s.id=="string"&&s.id.trim().length>0).map(s=>E(s.id.trim(),!0)));return r.map(s=>{if(g(s)||c.has(E(s,!0)))return{id:s,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let a=t.get(d(s));return a?{id:s,title:a.title,status:a.status,resolved:w(a.status,n)}:{id:s,title:null,status:null,resolved:!1}})}function M(e,t,n){return L(e,t,n)}function Me(e,t){let n=new Map(e.map(c=>[d(c.id),c])),i=C(e),o=new Set([...xe(t),...t.blocked_statuses]),r=new Set;for(let c of e){let s=v(c.status,t);o.has(s)&&(t.blocked_statuses.has(s)||L(c,n,t,i).some(a=>!a.resolved))&&r.add(d(c.id))}return r}function He(e,t,n={},i){let o=[...e.ready,...e.decisions,...e.gates];n.includeContainers===!0&&o.push(...e.containers.filter(c=>c.open_blockers.length===0&&!t.blocked_statuses.has(v(c.item.status,t))));let r={ready:[],decisions:[],gates:[]};for(let c of o){let s=D(c.item.type,i);s==="human"&&n.includeDecisions!==!0?r.decisions.push(c):s==="gate"&&n.includeGates!==!0?r.gates.push(c):r.ready.push(c)}return r}function xe(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function Pe(e,t,n){let i=[d(e)],o=new Set;for(;i.length>0;){let r=i.pop();if(!o.has(r)){o.add(r);for(let c of t.get(r)??[]){if(!w(c.status,n))return!0;i.push(d(c.id))}}}return!1}function $e(e){let t=new Map,n=new Map,i=new Map,o=C(e);for(let r of e){t.set(d(r.id),r);let c=typeof r.parent=="string"?r.parent.trim():"";if(c.length>0){let s=d(c),a=n.get(s)??[];a.push(r),n.set(s,a)}for(let s of o.get(d(r.id))){let a=d(s),m=i.get(a)??[];m.push(r.id),i.set(a,m)}}return{itemsById:t,childrenByParent:n,blockedByReverse:i,blockerIdsByItem:o}}function Fe(e,t,n,i){let{itemsById:o,childrenByParent:r,blockedByReverse:c,blockerIdsByItem:s}=$e(t),a=new Set([...xe(n),...n.blocked_statuses]),m=new Set(t.filter(f=>!w(f.status,n)).map(f=>d(f.id))),F=[],K=[],S=[],U=[],G=[],q=0;for(let f of e){if(!a.has(v(f.status,n)))continue;q+=1;let z=L(f,o,n,s).filter(h=>!h.resolved),Ae=(c.get(d(f.id))??[]).filter(h=>m.has(d(h))).sort((h,Oe)=>h.localeCompare(Oe)),I={item:f,open_blockers:z,unblocks:Ae};if(Pe(f.id,r,n)){S.push(I);continue}let De=n.blocked_statuses.has(v(f.status,n));if(z.length===0&&!De){let h=D(f.type,i);h==="human"?U.push(I):h==="gate"?G.push(I):F.push(I)}else K.push(I)}return{ready:F,blocked:K,containers:S,decisions:U,gates:G,active_count:q,container_count:S.length}}(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]="ae1c56b3-148d-502d-9450-e807fdfab4da")}catch{}})();(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]="e9b7731d-e6f5-51a8-970b-462c0b728a9c")}catch{}})();function Ue(e,t){let n=new Map;for(let i of e){let o=i.external?i.id:t.get(i.id.toLowerCase())?.id??i.id;n.set(i.external?`external:${o}`:`local:${o.toLowerCase()}`,{...i,id:o})}return[...n.values()]}async function P(e,t){let n=H.basename(e),i=(await Ke(H.dirname(e)).catch(o=>{throw ge("Cannot verify the blocker's physical file identity",{exitCode:u.GENERIC_FAILURE,context:{code:"blocker_identity_read_failed",required:"Restore access to the blocker item directory, then retry the item read."},cause:o})})).filter(o=>o.toLowerCase()===n.toLowerCase()).sort((o,r)=>+(r===n)-+(o===n)||o.localeCompare(r)).map(o=>H.parse(o).name)[0];if(i===void 0)throw new l(`Blocker canonical file disappeared during identity verification: ${t}`,u.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker file and validate storage integrity before retrying the item read."});return i}async function ht(e){let t=_(e.metadata);if(t.length===0)return[];let n=new Map([e.metadata.blocked_by,...(e.metadata.dependencies??[]).filter(o=>p(o.kind)==="blocked_by").map(o=>o.id)].filter(o=>typeof o=="string").map(o=>[o.trim().toLowerCase(),o.trim()])),i=new Map;for(let o of t){if(g(o)||!/^(?!\.{1,2}$)[^/\\:\0]+$/u.test(o)||e.metadata.dependencies?.some(s=>s.id.trim()===o&&p(s.kind)==="blocked_by"&&b(s.source_kind)))continue;let r=await x(e.pmRoot,n.get(o),e.settings.id_prefix,e.settings.item_format,e.typeToFolder);if(r===null)continue;let c=await k(r,{schema:e.settings.schema});if(r.id=await P(r.itemPath,r.id),c.document.metadata.id!==r.id)throw new l(`Blocker identity differs from its canonical file: ${r.id}`,u.CONFLICT,{code:"item_identity_conflict",required:"Restore the canonical blocker identity and validate storage integrity before retrying the item read."});i.set(o.toLowerCase(),c.document.metadata)}return Ue(M({blocked_by:e.metadata.blocked_by,dependencies:e.metadata.dependencies,updated_at:e.metadata.updated_at},i,ie(e.settings.schema)),i)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="222cbba7-e2df-5afb-8d75-14f9f99b3bd2")}catch{}})();var Ee="item_revision_conflict",Ge=10,Ce=/^[0-9a-f]{64}$/u;function y(e,t){return new l(`Invalid expected revision ${JSON.stringify(e)}: ${t}.`,u.USAGE,{code:"expect_hash_invalid",value:e,required:"Pass the 64-character item_hash from pm get <id> --json, optionally as <id>=<item_hash>.",examples:["--expect-hash <item_hash>","--expect-hash pm-a1b2=<item_hash>"]})}function Re(e){let t=typeof e=="string"?e.trim().toLowerCase():"";if(!Ce.test(t))throw y(String(e),"the revision is not a 64-character hexadecimal item_hash");return t}function qe(e){return(e===void 0?[]:typeof e=="string"?[e]:e).flatMap(t=>{if(typeof t!="string")throw y(String(t),"expected a string");let n=t.split(",").map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)throw y(t,"the value is empty");let i=o=>te(t)===t?o:ee;return n.map(o=>{let r=o.lastIndexOf("="),c=r===-1?void 0:o.slice(0,r).trim();if(c!==void 0&&c.length===0)throw y(i(o),"the item id before = is empty");let s=r===-1?o:o.slice(r+1);if(!Ce.test(s.trim().toLowerCase()))throw y(i(s),"the revision is not a 64-character hexadecimal item_hash");let a=Re(s);return c===void 0?{itemHash:a}:{id:c,itemHash:a}})})}async function Se(e,t){let n=await se(e),i=X(n,ne()).type_to_folder,o=await x(e,t,n.id_prefix,n.item_format,i);if(o){let{document:r}=await k(o,{schema:n.schema});if(r.metadata.id!==await P(o.itemPath,o.id))throw new l(`Item file ${o.id} embeds the id ${r.metadata.id}; no revision can be bound to an item whose identity is in conflict.`,u.CONFLICT,{code:"item_identity_conflict",item_id:o.id,required:`Repair ${o.id}'s identity first (pm validate reports it; pm restore ${o.id} <version> recovers a recorded state), then read its item_hash again.`});return{id:r.metadata.id,document:r}}try{return{id:(await ve(e,t,n,i)).id,document:W}}catch{throw await _e(e,t,n.id_prefix,i)}}function $(e){return Q(e.cwd??process.cwd(),e.pmRoot)}async function Dt(e,t={}){let n=await Se($(t),e);return{id:n.id,item_hash:re(n.document)}}async function Te(e,t,n){let i=[];for(let o of t){let r=o.id??n;if(r===void 0||r.trim().length===0)throw new l("A bare expected revision needs an item to bind to.",u.USAGE,{code:"expect_hash_target_required",required:"This command has no single item argument; name each target as --expect-hash <id>=<item_hash>.",examples:["--expect-hash pm-a1b2=<item_hash>"]});i.push({id:(await Se(e,r)).id,itemHash:o.itemHash})}return i}function ze(e){return[...new Set(e.patch.map(t=>{let n=t.path.split("/");return String(n[1]==="metadata"?n[2]:n[1])}))].sort()}async function We(e,t,n){let i;try{i=await oe(Z(e,t),t)}catch{return}let o=-1;for(let s=i.length-1;s>=0;s-=1){let a=i[s];if(a.after_hash===n){o=s+1;break}if(a.before_hash===n){o=s;break}}if(o===-1)return{expected_revision_recorded:!1,changes_since:[],changes_since_omitted:0};let r=i.slice(o),c=r.slice(-Ge);return{expected_revision_recorded:!0,changes_since:c.map(s=>({ts:s.ts,op:s.op,author:s.author,fields:ze(s)})),changes_since_omitted:r.length-c.length}}async function Ot(e,t){if(!R(e))return{};let n=await Be(e,t);return{error_code:Ee,expected_revision:String(n.context.expected_revision),current_revision:String(n.context.current_revision),details:n.context.details}}function R(e){return ye(e)&&e.context.code===Ee}function Lt(e){let t=e.find(n=>R(n));if(t!==void 0)throw t}function Mt(){return new l("--expect-hash cannot guard an invocation an extension override rewrote: which item it writes is not provable.",u.USAGE,{code:"expect_hash_invocation_rewritten",required:"Run the command without the rewriting extension (--no-extensions), or drop --expect-hash.",why:"An extension parser or preflight override changed this invocation's tracker or arguments, and final dispatch, the extension SDK client and the guard do not share one rewritten view."})}function Ve(e,t){if(t===void 0||!R(e)||typeof e.context.item_id!="string"||he(e))return e;let n=e.context.reason===fe;if(!n&&e.context.reason!==le)return e;let i=pe(N(e,new l(e.message,e.exitCode,{...e.context,...ue(e.context.item_id,n,t)})));return i.stack=e.stack,i}async function Be(e,t,n){if(!me(e,t))return e;let i=Ve(e,n);if(!R(i)||i.context.details!==void 0)return i;let o=i.context.item_id,r=i.context.expected_revision;if(typeof o!="string"||typeof r!="string")return i;let c;try{c=await We(t,o,r)}catch{return i}if(c===void 0)return i;let s={expected_revision_recorded:c.expected_revision_recorded,changes_since:c.changes_since.map(m=>({ts:m.ts,op:m.op,author:m.author,fields:[...m.fields]})),changes_since_omitted:c.changes_since_omitted},a=N(i,new l(i.message,i.exitCode,{...i.context,details:s}));return a.stack=i.stack,a}async function Ne(e,t,n){try{return{result:await ce(e,t),...ae(e)}}catch(i){throw e.pmRoot===void 0?i:await Be(i,e.pmRoot,n)}}function Ye(e){return e.cwd===void 0&&e.pmRoot===void 0?void 0:{scopeArgs:["--pm-path",$(e)]}}async function Ht(e,t,n={}){return Ne(await je(e,n),t,Ye(n))}async function je(e,t={}){let n=$(t),i=e.map(({id:r,itemHash:c})=>({id:r,itemHash:Re(c)})),o=T();return B(o,n,await Te(n,i)),o}function Pt(e){let t=de(e);return t===void 0||t.length>0}function Xe(e){return`expect_hash_unchecked:${e}:no_locked_write_reached_this_item`}var ke=new Set(V);function Je(e,t={}){let n=e.trim().replace(/\s+/gu,"-"),i=ke.has(n)?n:e;if(ke.has(i)&&(!Ie(i)||i==="deps")&&!Y.has(i))throw Qe(i);if((i==="test"||i==="test-all")&&t.background===!0)throw new l(`--expect-hash cannot guard ${i} --background: the worker runs in another process.`,u.USAGE,{code:"expect_hash_background_unsupported",required:`Run ${i} in the foreground to guard its result recording, or drop --expect-hash for a background run.`})}function Qe(e){return new l(`--expect-hash guards item writes, and ${e} is not a mutation.`,u.USAGE,{code:"expect_hash_requires_mutation",required:"Use --expect-hash (MCP/SDK expectHash) only on a command or action that writes items."})}function Ze(e,t){if(t.length===0||typeof e!="object"||e===null||Array.isArray(e))return e;let n=e,i=Array.isArray(n.warnings)?n.warnings:[];return{...n,warnings:[...i,...t.map(Xe)]}}async function $t(e){let t=e.expectHash;if(t!==void 0&&typeof t!="string"&&!(Array.isArray(t)&&t.every(r=>typeof r=="string")))throw y(JSON.stringify(t)??String(t),"expected a string or an array of strings");let n=qe(t);if(n.length===0)return e.run();Je(e.action,{background:e.background===!0||e.options?.background===!0});let i=T();B(i,e.pmRoot,await Te(e.pmRoot,n,e.defaultId));let o=await Ne(i,e.run,e.invocation);return Ze(o.result,o.unchecked)}export{D as a,Le as b,_ as c,C as d,we as e,M as f,Me as g,He as h,Fe as i,ht as j,Ee as k,Ge as l,Re as m,qe as n,Dt as o,Te as p,We as q,Ot as r,R as s,Lt as t,Mt as u,Ve as v,Be as w,Ne as x,Ht as y,je as z,Pt as A,Xe as B,Je as C,Qe as D,$t as E};
2
+ //# sourceMappingURL=chunk-MR3CRLA7.js.map
@@ -1,4 +1,4 @@
1
- import{i as mi,n as ui,p as fi}from"./chunk-FYD6LSJA.js";import{ec as Rt}from"./chunk-T2MNRM3S.js";import{$a as ai,Ba as Xa,Ca as Pe,Da as it,Db as si,Ea as Za,Fa as Qa,Ga as ae,Gb as Ot,Ha as Ue,Hb as Ct,Ia as ei,Ja as se,Kb as Ne,Pb as ci,Q as Ra,Qb as gn,_a as ni,ab as $e,bb as ii,cb as ri,ha as Ee,md as li,vc as di,xb as oi}from"./chunk-D727C4RO.js";import{Ad as B,Ai as Ka,Bc as Re,Ci as fn,Da as Ea,Di as Va,Ea as $a,Ei as Ya,Fa as W,Fi as Se,G as Sa,Gb as T,Li as ti,Na as F,Oa as Ia,Oi as fe,Pa as Ce,Pd as A,Qa as Aa,Qd as V,Qi as hn,Rb as Ca,Rd as Ja,Sd as K,Td as Q,Te as ee,Uc as un,Ui as I,Vc as Ma,Vd as qa,Vi as he,Wc as It,Xd as at,Yc as ke,Zd as Tt,_c as xe,bd as Ua,cc as be,d as St,db as H,dd as At,e as wa,ea as $t,ed as za,ej as ze,f as cn,fa as pn,fb as Ta,fd as Ga,g as dn,ga as mn,gb as oe,h as ln,j as va,jc as Pa,k as ba,kc as Na,n as ka,nc as Da,nf as Wa,oc as ja,pd as J,sf as q,ub as Oa,uf as Ba,wc as La,x as xa,yc as Fa,zi as Ha}from"./chunk-WNEUWDUE.js";import{f as pi}from"./chunk-RSAN2YUU.js";import{A as h,C as u,E as k,F as Et,G as ve,H as M,K as ue,a as ha,d as xt,m as ga,t as sn,v as ya,y as _a}from"./chunk-O4ZLEN4T.js";import{mkdir as Ds,readFile as js}from"node:fs/promises";import gi from"node:path";import{createHash as Ls}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24a18484-0b8b-55d7-aa23-08a23b8d78ce")}catch{}})();var yn=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},yi="sdk-workspace-transaction",_i=/^[a-zA-Z0-9._-]+$/,wi=30,vi=3e3;function kn(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!_i.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function _n(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n)throw new TypeError(`${t} must be non-empty`);return n}function xn(e){return{pmRoot:_n(e.pmRoot,"Transaction pmRoot"),transactionId:kn(e.transactionId,"Transaction id"),author:_n(e.author,"Transaction author")}}function Nt(e,t,n){let a=e??t;if(!Number.isInteger(a)||a<=0)throw new TypeError(`${n} must be a positive integer`);return a}function bi(e,t){return gi.join(e,"transactions","sdk",`${t}.json`)}async function ce(e,t){t.updatedAt=T();let n=bi(e,t.transactionId);await Ds(gi.dirname(n),{recursive:!0}),await ue(n,`${JSON.stringify(t,null,2)}
1
+ import{i as mi,n as ui,p as fi}from"./chunk-L3SA3354.js";import{kc as Rt}from"./chunk-PS2YAPXC.js";import{$a as ni,Ca as Xa,Da as Pe,Ea as it,Eb as si,Fa as Za,Ga as Qa,Ha as ae,Hb as Ot,Ia as Ue,Ib as Ct,Ja as ei,Ka as se,Lb as Ne,Qb as ci,R as Ra,Rb as gn,ab as ai,bb as $e,cb as ii,db as ri,ia as Ee,nd as li,wc as di,yb as oi}from"./chunk-FOT5K5OM.js";import{$c as It,Bc as La,Da as Ea,Dc as Fa,Ea as $a,Ei as Ha,Fa as W,Fd as B,Fi as Ka,G as Sa,Gc as Re,Hi as fn,Ii as Va,Ji as Ya,Ki as Se,Lb as T,Na as F,Oa as Ia,Pa as Ce,Qa as Aa,Qi as ti,Ti as fe,Ud as A,Vd as V,Vi as hn,Wb as Ca,Wd as Ja,Xd as K,Yd as Q,Ye as ee,Zc as un,Zi as I,_c as Ma,_d as qa,_i as he,ae as at,bd as ke,ce as Tt,d as St,db as H,dd as xe,e as wa,ea as $t,f as cn,fa as pn,fb as Ta,g as dn,ga as mn,gb as oe,gd as Ua,h as ln,hc as be,id as At,j as va,jd as za,jj as ze,k as ba,kd as Ga,n as ka,oc as Pa,pc as Na,sc as Da,sf as Wa,tc as ja,ud as J,x as xa,xf as q,zb as Oa,zf as Ba}from"./chunk-PZI6CR24.js";import{f as pi}from"./chunk-RSAN2YUU.js";import{A as h,C as u,E as k,F as Et,G as ve,H as M,K as ue,a as ha,d as xt,m as ga,t as sn,v as ya,y as _a}from"./chunk-O4ZLEN4T.js";import{mkdir as Ds,readFile as js}from"node:fs/promises";import gi from"node:path";import{createHash as Ls}from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="24a18484-0b8b-55d7-aa23-08a23b8d78ce")}catch{}})();var yn=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},yi="sdk-workspace-transaction",_i=/^[a-zA-Z0-9._-]+$/,wi=30,vi=3e3;function kn(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!_i.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function _n(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n)throw new TypeError(`${t} must be non-empty`);return n}function xn(e){return{pmRoot:_n(e.pmRoot,"Transaction pmRoot"),transactionId:kn(e.transactionId,"Transaction id"),author:_n(e.author,"Transaction author")}}function Nt(e,t,n){let a=e??t;if(!Number.isInteger(a)||a<=0)throw new TypeError(`${n} must be a positive integer`);return a}function bi(e,t){return gi.join(e,"transactions","sdk",`${t}.json`)}async function ce(e,t){t.updatedAt=T();let n=bi(e,t.transactionId);await Ds(gi.dirname(n),{recursive:!0}),await ue(n,`${JSON.stringify(t,null,2)}
2
2
  `)}function Fs(e){return Number.isInteger(e.attempt)&&typeof e.author=="string"&&typeof e.createdAt=="string"&&typeof e.updatedAt=="string"&&Ms(e)}function Ms(e){let t=e.abandonment;return t===void 0?e.schemaVersion===1&&e.status!=="abandoned":e.schemaVersion!==2||t===null||typeof t!="object"||e.status==="committed"?!1:typeof t.reason=="string"&&t.reason.trim().length>0&&typeof t.author=="string"&&t.author.trim().length>0&&(t.supersededBy===void 0||typeof t.supersededBy=="string"&&_i.test(t.supersededBy)&&t.supersededBy!==e.transactionId)}function De(e){return Object.assign(Object.create(null),e)}function ki(e,t){try{let n=JSON.stringify(e,(a,i)=>{if(typeof i=="number"&&!Number.isFinite(i))throw new TypeError(`${t} contains a non-finite number`);if(i===void 0||typeof i=="function"||typeof i=="symbol")throw new TypeError(`${t} contains a non-JSON value`);return i});return JSON.parse(n)}catch(n){throw new TypeError(`${t} must be JSON serializable`,{cause:n})}}function wn(e,t){return e===void 0?void 0:ki(e,t)}function vn(e,t,n,a){let i=wn(n,a);i===void 0?delete e[t]:e[t]=i}function hi(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function bn(e,t){return Array.isArray(e)&&new Set(e).size===e.length&&e.every(n=>typeof n=="string"&&t.includes(n))}function Us(e,t){if(!bn(e.startedStepIds,t)||!bn(e.completedStepIds,t)||!hi(e.results)||!hi(e.compensationData))return!1;let n=e.startedStepIds,a=new Set(n),i=e.completedStepIds,r=new Set(i);return Object.keys(e.compensationData).some(o=>!a.has(o))||Object.keys(e.results).some(o=>!r.has(o))?!1:e.status==="committed"?t.every(o=>r.has(o)):!["compensated","abandoned"].includes(e.status??"")||r.size===0&&a.size===0}function Pt(e,t){return new u(`Workspace transaction ${e} journal is invalid (${t})`,h.CONFLICT,{code:"transaction_journal_invalid",required:"A valid durable journal is required before transaction recovery can continue.",why:"Corrupt journal data cannot establish which steps applied or still require compensation.",nextSteps:["Preserve the journal and inspect its integrity or restore a verified backup before retrying.","Do not switch to a new transaction id to bypass an unreadable journal; previously applied work may remain."]})}function xi(e){return new u(`Workspace transaction ${e} journal does not match the supplied plan`,h.CONFLICT,{code:"transaction_plan_mismatch",required:"Replay the original plan or safely abandon the interrupted transaction before replacing it.",why:"A journal records the plan it is resuming; applying a different plan under the same id could skip or duplicate steps.",nextSteps:["Re-run with the original document to resume or replay it.","For item batches use client.itemTransactions.status(transactionId), then client.itemTransactions.abandon(transactionId, { reason }) before committing a changed plan with a new transactionId.","Run pm ops gc --scope transactions --dry-run to inspect retention; active and explicitly abandoned journals remain protected."]})}function zs(e,t,n){return n===void 0||e.abandonment!==void 0||e.status==="compensated"||t.length===n.length&&t.every((a,i)=>a===n[i])}function Gs(e,t,n){let a;try{a=JSON.parse(e)}catch{throw Pt(t,"invalid JSON")}if(!a||typeof a!="object"||Array.isArray(a))throw Pt(t,"expected an object");let i=a;if(!((i.schemaVersion===1||i.schemaVersion===2)&&i.transactionId===t))throw Pt(t,"schema version or transaction id does not match the journal file");let r=i.stepIds;if(!Array.isArray(r)||!bn(r,r)||!Us(i,r)||!Fs(i)||typeof i.status!="string"||!["applying","compensating","compensated","committed","abandoned"].includes(i.status))throw Pt(t,"invalid lifecycle, metadata, status or step ids");if(!zs(i,r,n))throw xi(t);return{...i,results:De(i.results),compensationData:De(i.compensationData)}}async function Js(e,t,n,a,i){let r=i,o=r!==void 0;if(r?.status==="compensating"&&await Sn(e,r),r===void 0||r.status==="compensated"){let s=T();r={schemaVersion:1,transactionId:t,author:n,status:"applying",attempt:(r?.attempt??0)+1,createdAt:r?.createdAt??s,updatedAt:s,stepIds:a,startedStepIds:[],completedStepIds:[],results:De(),compensationData:De(),...e.recoveryData===void 0?{}:{recoveryData:ki(e.recoveryData,"Transaction recovery data")}},await ce(e.pmRoot,r),await ge(e,r,"prepared")}return{journal:r,recovered:o}}async function qs(e,t,n){try{await Ws(t,e.steps),await ce(e.pmRoot,t);let a=new Set(t.completedStepIds),i=new Set(t.startedStepIds);for(let r of e.steps){if(a.has(r.id))continue;let o=await r.inspect(),s=wn(o.result,`Step ${r.id} result`);if(o.state!=="applied"){let d=await r.prepareCompensation?.();vn(t.compensationData,r.id,d,`Step ${r.id} compensation data`),i.add(r.id),t.startedStepIds=e.steps.map(l=>l.id).filter(l=>i.has(l)),await ce(e.pmRoot,t);let c=await r.apply();s=wn(c,`Step ${r.id} result`)}await ge(e,t,"step_applied",r.id),a.add(r.id),t.completedStepIds=e.steps.map(d=>d.id).filter(d=>a.has(d)),vn(t.results,r.id,s,`Step ${r.id} result`),await ce(e.pmRoot,t),await ge(e,t,"step_recorded",r.id)}return await ge(e,t,"committing"),t.status="committed",await ce(e.pmRoot,t),await ge(e,t,"committed"),{transactionId:t.transactionId,status:"committed",recovered:n,results:De(t.results)}}catch(a){if(a instanceof yn||t.status==="committed")throw a;try{await Sn(e,t)}catch(i){throw new AggregateError([a,i],`Workspace transaction failed and compensation failed: ${String(i)}`,{cause:i})}throw a}}async function Dt(e,t,n){try{return Gs(await js(bi(e,t),"utf8"),t,n)}catch(a){if(a!==null&&typeof a=="object"&&"code"in a&&ve(a))return;throw a}}async function ge(e,t,n,a){await e.onTransition?.({transactionId:t.transactionId,attempt:t.attempt,transition:n,...a===void 0?{}:{stepId:a}})}async function Ws(e,t){let n=new Set,a=De();for(let i of t){let r=await i.inspect();r.state==="applied"&&(n.add(i.id),vn(a,i.id,r.result,`Step ${i.id} result`))}e.results=a,e.completedStepIds=t.map(i=>i.id).filter(i=>n.has(i))}async function Sn(e,t){t.status="compensating",await ce(e.pmRoot,t),await ge(e,t,"compensating");let n=new Set(t.completedStepIds),a=new Set(t.startedStepIds);for(let i of[...e.steps].reverse()){if(!a.has(i.id)&&!n.has(i.id))continue;let r;try{let o=(await i.inspect()).state;r=a.has(i.id)&&(o==="applied"||o==="pending"&&i.compensatePending===!0)}catch{r=a.has(i.id)}r&&(await ge(e,t,"step_compensating",i.id),await i.compensate(t.compensationData[i.id])),n.delete(i.id),a.delete(i.id),t.completedStepIds=e.steps.map(o=>o.id).filter(o=>n.has(o)),t.startedStepIds=e.steps.map(o=>o.id).filter(o=>a.has(o)),delete t.results[i.id],delete t.compensationData[i.id],await ce(e.pmRoot,t),await ge(e,t,"step_compensated",i.id)}t.status="compensated",await ce(e.pmRoot,t),await ge(e,t,"compensated")}async function Si(e){let{pmRoot:t,transactionId:n,author:a}=xn(e),i=Nt(e.lockTtlSeconds,wi,"Transaction lock TTL"),r=Nt(e.lockWaitMs,vi,"Transaction lock wait"),o=[...e.steps];if(o.length===0)throw new TypeError("Workspace transaction requires at least one step");let s=o.map(l=>{let p=kn(l.id,"Transaction step id");if(p!==l.id)throw new TypeError("Transaction step id must not contain surrounding whitespace");return p});if(new Set(s).size!==s.length)throw new TypeError("Workspace transaction step ids must be unique");let d={...e,pmRoot:t,transactionId:n,author:a,steps:o,lockTtlSeconds:i,lockWaitMs:r},c=await ee(t,yi,i,a,!1,!1,r);try{let l=await Dt(t,n,s);if(l?.status==="abandoned"||l?.abandonment!==void 0)throw Ei(l);let p=l!==void 0;if(l?.status==="committed")return{transactionId:n,status:"committed",recovered:!0,results:De(l.results)};let m=await Js(d,n,a,s,l);return await qs(d,m.journal,p||m.recovered)}finally{await c()}}function Ei(e){let t=e.status!=="abandoned",n=e.abandonment.supersededBy,a=n===void 0?`Retry abandonment without supersededBy to finish retirement of ${JSON.stringify(e.transactionId)}.`:`Retry abandonment with supersededBy ${JSON.stringify(n)} to finish retirement of ${JSON.stringify(e.transactionId)}.`;return new u(t?`Transaction ${e.transactionId} retirement is incomplete`:`Transaction ${e.transactionId} has been abandoned`,h.CONFLICT,{code:"transaction_abandoned",required:t?a:"Use a new transactionId for the replacement plan.",why:t?"Forward replay is fenced, but the recorded retirement has not finished. Preserve its replacement identity.":"An explicitly retired transaction identity cannot be resumed.",...t?{retirement:{state:"pending",superseded_by:n??null},nextSteps:[a]}:{}})}async function Uu(e,t){let n=xn({pmRoot:e,transactionId:t,author:"reader"});return Dt(n.pmRoot,n.transactionId)}function Bs(e){return Ls("sha256").update(JSON.stringify(e.stepIds)).digest("hex")}async function zu(e){let t=xn(e),n=_n(e.reason,"Abandonment reason"),a=e.supersededBy===void 0?void 0:kn(e.supersededBy,"Replacement transaction id");if(a===t.transactionId)throw new TypeError("Replacement transaction id must differ from the abandoned id");let i=Nt(e.lockTtlSeconds,wi,"Transaction lock TTL"),r=Nt(e.lockWaitMs,vi,"Transaction lock wait"),o=await ee(t.pmRoot,yi,i,t.author,!1,!1,r);try{let s=await Dt(t.pmRoot,t.transactionId);if(s===void 0)throw new u(`Transaction ${t.transactionId} was not found`,h.NOT_FOUND);if(s.status==="committed")throw new u(`Transaction ${t.transactionId} is committed and cannot be abandoned`,h.CONFLICT,{code:"transaction_committed",required:"Plan a separate explicit corrective mutation.",why:"Recovery cannot silently undo committed work."});if(s.abandonment!==void 0&&s.abandonment.supersededBy!==a)throw Ei(s);if(s.status==="abandoned")return s;let d=e.resolveSteps(structuredClone(s));if(JSON.stringify(d.map(c=>c.id))!==JSON.stringify(s.stepIds))throw xi(t.transactionId);if(s.abandonment===void 0){if(a!==void 0&&await Dt(t.pmRoot,a)!==void 0)throw new u(`Replacement transaction ${a} already exists`,h.CONFLICT);s.schemaVersion=2,s.abandonment={reason:n,author:t.author,...a===void 0?{}:{supersededBy:a}},await ce(t.pmRoot,s)}return s.status!=="compensated"&&await Sn({...e,...t,steps:d},s),await Hs(s,t.pmRoot,i,r),s.status="abandoned",await ce(t.pmRoot,s),s}finally{await o()}}async function Hs(e,t,n,a){let i=Bs(e);if((await Ba(Ka(t),Ha)).some(o=>o.op==="transaction_abandon"&&o.context?.transaction_id===e.transactionId&&o.context?.attempt===e.attempt&&o.context?.plan_digest===i))return;let r=e.abandonment;await Va({pmRoot:t,author:r.author,lockTtlSeconds:n,lockWaitMs:a,op:"transaction_abandon",message:r.reason,context:{transaction_id:e.transactionId,attempt:e.attempt,plan_digest:i,...r.supersededBy===void 0?{}:{superseded_by:r.supersededBy}}})}import Ks from"node:fs/promises";import Vs 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]="7be00b26-4a56-5399-94f6-f2f67cc5c1e6")}catch{}})();function En(e){return Vs.join(e,"extension-migrations.json")}function $i(e,t){let n=e.definition.id;return typeof n=="string"&&n.trim().length>0?n.trim():`migration-${String(t+1).padStart(3,"0")}`}function Ii(e,t){return`${e.layer}:${e.name}:${t}`}async function Ys(e){let t=En(e);if(!await k(t))return{version:1,updated_at:"",entries:[]};let n=JSON.parse(await Ks.readFile(t,"utf8"));return{version:1,updated_at:typeof n.updated_at=="string"?n.updated_at:"",entries:Array.isArray(n.entries)?n.entries.filter(a=>typeof a?.key=="string"&&(a.status==="applied"||a.status==="failed")):[]}}async function Xs(e,t){let n=await Ys(e),a=new Map(n.entries.map(i=>[i.key,i]));return t.forEach((i,r)=>{let o=$i(i,r),s=a.get(Ii(i,o));s&&(i.definition.status=s.status,s.status==="failed"?i.definition.reason=s.error:(delete i.definition.reason,delete i.definition.error,delete i.definition.message))}),n}async function Zs(e){let t=await Xs(e.pmRoot,e.migrations),n=new Map(t.entries.map(l=>[l.key,l])),a=[],i=!1,r=e.migrations.map((l,p)=>({migration:l,index:p})).filter(({migration:l})=>e.scope===void 0||l.layer===e.scope);for(let{migration:l,index:p}of r){let m=$i(l,p),y=Ii(l,m),g=n.get(y),_=String(l.definition.status??"pending").toLowerCase(),f=g?.status??(_==="applied"||_==="failed"?_:"pending");if(f==="applied"){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:f,outcome:"skipped"});continue}if(e.dryRun===!0){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:f,outcome:"pending"});continue}let w=l.runtime_definition?.run??l.definition.run;if(typeof w!="function"){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:f,outcome:"pending"});continue}let v=new Date().toISOString();try{await Promise.resolve(w({id:m,command:"migration",layer:l.layer,extension:l.name,pm_root:e.pmRoot,status:f}));let E={key:y,layer:l.layer,extension:l.name,id:m,status:"applied",attempted_at:v};n.set(y,E),l.definition.status="applied",delete l.definition.reason,delete l.definition.error,delete l.definition.message,a.push({key:y,layer:l.layer,extension:l.name,id:m,before:f,outcome:"applied"}),i=!0}catch(E){let S=E instanceof Error?E.message:String(E),C={key:y,layer:l.layer,extension:l.name,id:m,status:"failed",attempted_at:v,error:S};n.set(y,C),l.definition.status="failed",l.definition.reason=S,a.push({key:y,layer:l.layer,extension:l.name,id:m,before:f,outcome:"failed",error:S}),i=!0}}if(i){let l=await I(e.pmRoot),p={version:1,updated_at:new Date().toISOString(),entries:[...n.values()].sort((m,y)=>m.key.localeCompare(y.key))};await Se({pmRoot:e.pmRoot,filePath:En(e.pmRoot),raw:`${JSON.stringify(p,null,2)}
3
3
  `,op:"extension_migrations_apply",author:e.author,lockTtlSeconds:l.locks.ttl_seconds,lockWaitMs:l.locks.wait_ms})}let o=a.filter(l=>l.outcome==="pending").length,s=a.filter(l=>l.outcome==="applied").length,d=a.filter(l=>l.outcome==="skipped").length,c=a.filter(l=>l.outcome==="failed").length;return{ok:c===0,dry_run:e.dryRun===!0,state_path:En(e.pmRoot),total:a.length,pending_count:o,applied_count:s,skipped_count:d,failed_count:c,migrations:a}}async function Ai(e){let t=await I(e.resolvedRoots.settings_root),n=await ke({pmRoot:e.resolvedRoots.pm_root,settings:t,cwd:process.cwd(),noExtensions:e.global.noExtensions===!0}),a=await xe(n);e.warnings.push(...n.warnings,...a.warnings);let i=await Zs({pmRoot:e.resolvedRoots.pm_root,migrations:a.registrations.migrations,author:typeof e.global.author=="string"&&e.global.author.trim().length>0?e.global.author.trim():"pm-extension-migration",dryRun:e.options.dryRun===!0,...e.scope==="global"?{scope:"global"}:{}});return e.withResult({migration:i,load_failure_count:n.failed.length,activation_failure_count:a.failed.length},i.ok)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="184c43e0-a543-5b0b-ac09-9139ba5ded6a")}catch{}})();var Qs=[["beforeCommand","before_command"],["beforeMutation","before_mutation"],["afterCommand","after_command"],["onWrite","on_write"],["onRead","on_read"],["onIndex","on_index"]];function Ge(e,t={}){let n=new Set;t.extensionName!==void 0&&n.add(At(t.extensionName));for(let f of t.extensionNames??[])n.add(At(f));let a=f=>n.size===0||n.has(At(f)),i=(f,w)=>Ti(f.filter(v=>a(v.name)).map(w)),r=(f,w)=>Ti(f.filter(v=>a(v.name)).flatMap(w)),{registrations:o,commands:s,parsers:d,preflight:c,services:l,renderers:p,hooks:m}=e,y=r(o.relationship_kinds??[],f=>f.definitions.map(w=>w.kind)),g=p.overrides.filter(f=>a(f.name)&&((f.commands?.length??0)>0||f.resultDiscriminator!==void 0)).map(f=>({format:f.format,commands:[...f.commands??[]],result_discriminator:f.resultDiscriminator!==void 0})).sort((f,w)=>f.format.localeCompare(w.format)),_=i(o.assurance_providers??[],f=>f.definition.id);return{capabilities:za(e,t),commands:i(o.commands,f=>f.command),command_overrides:i(s.overrides,f=>f.command),command_handlers:i(s.handlers,f=>f.command),hooks:Qs.filter(([f])=>m[f].some(w=>a(w.name))).map(([,f])=>f),flag_commands:i(o.flags,f=>f.target_command),item_types:r(o.item_types,f=>f.types.map(w=>w.name)),item_fields:r(o.item_fields,f=>f.fields.map(w=>w.name)),...y.length>0?{relationship_kinds:y}:{},migrations:r(o.migrations,f=>typeof f.definition.id=="string"?[f.definition.id]:[]),profiles:i(o.profiles,f=>f.profile.name),importers:i(o.importers,f=>f.importer),exporters:i(o.exporters,f=>f.exporter),search_providers:i(o.search_providers,f=>f.definition.name),vector_store_adapters:i(o.vector_store_adapters,f=>f.definition.name),..._.length>0?{assurance_providers:_}:{},parser_overrides:i(d.overrides,f=>f.command),service_overrides:i(l.overrides,f=>f.service),renderer_overrides:i(p.overrides,f=>f.format),...g.length>0?{renderer_ownership:g}:{},preflight_overrides:c.overrides.filter(f=>a(f.name)).length,preflight_ownership:c.overrides.filter(f=>a(f.name)).map(f=>({commands:[...f.commands??[]]}))}}function Ti(e){return[...new Set(e)].sort((t,n)=>t.localeCompare(n))}(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]="caa9f916-c7ce-5e74-a00b-dd0fc6a41b5d")}catch{}})();var rt={type:"string",minLength:1,maxLength:128,pattern:"\\S"},jt={type:"array",minItems:1,maxItems:cn,items:rt},Oi={...jt,items:{...rt,pattern:"^(?!(?:.*\\.)?(?:__proto__|constructor|prototype)(?:\\.|$))[a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$"}},ec={type:"object",additionalProperties:!1,required:["id","rule"],properties:{id:{type:"string",minLength:1,maxLength:128,pattern:"^[a-zA-Z0-9][a-zA-Z0-9._-]*$"},description:{type:"string",minLength:1,maxLength:500,pattern:"\\S"},effect:{enum:["advise","warn","refuse"]},subject:{type:"object",additionalProperties:!1,properties:{...Object.fromEntries(["types","tags","statuses","operations","parents"].map(e=>[e,jt])),dependency:{type:"object",additionalProperties:!1,required:["kind"],properties:{kind:rt,id:rt}}}},rule:{oneOf:[{type:"object",additionalProperties:!1,required:["kind","fields"],properties:{kind:{const:"require_fields"},fields:Oi}},{type:"object",additionalProperties:!1,required:["kind","authors"],properties:{kind:{const:"authors"},authors:jt}},...["field_writers","approval"].map(e=>({type:"object",additionalProperties:!1,required:["kind","fields","authors"],properties:{kind:{const:e},fields:Oi,authors:jt}})),{type:"object",additionalProperties:!1,required:["kind","allowed"],properties:{kind:{const:"transition"},allowed:{type:"array",maxItems:cn,items:{type:"array",minItems:2,maxItems:2,items:rt}}}}]}}},Qu={$schema:"https://json-schema.org/draft/2020-12/schema",title:"pm workflow policy registry",type:"object",additionalProperties:!1,required:["version","policies"],properties:{version:{const:1},enforcement:{enum:["advise","refuse"],default:"advise"},policies:{type:"array",maxItems:wa,items:ec}}};(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]="808f3bb5-cca5-5f9c-b557-7923c79ae6ce")}catch{}})();async function af(e,t,n,a){let i=await $e(e).catch(()=>null);return i===null?{check:{name:"completeness",status:"error",ok:!1,details:{policy_registry_readable:!1,policy_registry_path:"schema/policies.json",remediation_hint:"Repair schema/policies.json, then rerun pm validate."}},warnings:["validate_completeness_policy_registry_unreadable"]}:Ci(i,t,n,a)}function tc(e,t,n){return e===0?"undeclared":t===0?"empty":n===0?"inapplicable":n===t?"covered":"partial"}function Ci(e,t,n=5,a=!1){let i=[],r=new Map,o=e.policies.filter(f=>f.rule.kind==="require_fields"),s=o.filter(f=>f.subject?.operations===void 0),d=new Set,c=0,l=0,p=0,m=0,y=0,g=ka(e);for(let f of t){let w=g({operation:"",author:"",before:f,after:f,completeness_only:!0});c+=+(w.decisions.length>0),l+=w.decisions.length,w.decisions.forEach(S=>d.add(S.policy_id));let v=w.decisions.filter(S=>!S.satisfied);if(v.length===0)continue;m+=1;let E=r.get(f.type)??{items:0,violations:0,missing_fields:0};E.items+=1;for(let S of v)p+=1,E.violations+=1,E.missing_fields+=S.missing_fields.length,S.effect==="refuse"&&(y+=1),i.length<n&&i.push({id:f.id,type:f.type,status:f.status,decision:S});r.set(f.type,E)}let _=a||y>0?"error":p>0?"warn":"ok";return{check:{name:"completeness",status:_,ok:_==="ok",details:{scope:"operation_independent_require_fields",declared_requirement_count:o.length,state_requirement_count:s.length,applicable_requirement_count:d.size,requirement_application_count:l,governed_items:c,ungoverned_items:t.length-c,contract_status:tc(o.length,t.length,c),applied_policy_ids:[...d].sort().slice(0,Math.max(0,n)),applied_policy_ids_truncated:d.size>Math.max(0,n),checked_items:t.length,incomplete_items:m,violation_count:p,refused_violations:y,missing_by_type:Object.fromEntries(r),violations:i,violations_truncated:i.length<p,enforcement:e.enforcement}},warnings:[...p>0?[`validate_completeness_missing_fields:${p}`]:[],...a?["validate_completeness_source_incomplete"]:[]]}}import nc 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]="0c3bed4d-4a17-5004-a1c5-65f6acec2a9b")}catch{}})();function ac(){return{version:1,enforcement:"advise",policies:[...[["Epic",["goal","objective","body"]],["Story",["description","value","acceptance_criteria"]],["Decision",["body","resolution"]],["Feature",["acceptance_criteria","expected_result"]],["Task",["description"]],["Issue",["repro_steps","expected_result"]],["Chore",["description"]]].map(([e,t])=>({id:`completeness-${e.toLowerCase()}`,effect:"advise",description:`Evidence expected when ${e} work reaches completion.`,subject:{types:[e],statuses:["closed"]},rule:{kind:"require_fields",fields:[...t]}})),{id:"completeness-resolution",effect:"advise",subject:{statuses:["closed"]},rule:{kind:"require_fields",fields:["resolution","expected_result","actual_result"]}}]}}function Ni(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{throw new u("Policy definition must be valid JSON.",h.USAGE)}if(typeof t!="object"||t===null||Array.isArray(t))throw new u("Policy definition must be an object.",h.USAGE);return t}async function ic(e,t){let n=F(process.cwd(),e.path);await ze(n);let a=await I(n);return{pmRoot:n,settings:a,author:q(t,a.author_default)}}function Ri(e,t,n,a){if(e==="policy-mode")return ln({...n,enforcement:t});let i=n.policies.filter(s=>s.id!==t);if(e==="policy-remove")return{...n,policies:i};let r=dn(a.definition),o=ln({...n,policies:[...i,r].sort((s,d)=>s.id.localeCompare(d.id))});if(Buffer.byteLength(`${JSON.stringify(o,null,2)}
4
4
  `)>ni)throw new u("Policy registry exceeds its byte ceiling.",h.USAGE);return o}async function Pi(e,t,n,a){if(n.dryRun)return{policy_result:!0,action:e,changed:!1,result:Ri(e,t,await $e(a.pmRoot),n)};let i=await Ya({pmRoot:a.pmRoot,filePath:nc.join(a.pmRoot,"schema","policies.json"),op:`schema:${e}`,author:a.author,message:n.message,lockTtlSeconds:a.settings.locks.ttl_seconds,lockWaitMs:a.settings.locks.wait_ms,mutate(r){let o=Ri(e,t,ai(r),n);return{raw:`${JSON.stringify(o,null,2)}
@@ -67,4 +67,4 @@ Agent guidance check
67
67
  `),X.write(`Telemetry helps improve reliability. The choice applies to this CLI install; change it with pm config global set telemetry-tracking.
68
68
  `);let l=await n.question(`Enable telemetry for this CLI install? [${t?"Y/n":"y/N"}] `);c=vs(l,t)}return X.write(`
69
69
  `),{prefix:r,preset:d,telemetry_enabled:c}}finally{n.close()}}function uu(e){return{presetFromOption:pa(e.preset),useDefaults:e.defaults===!0,authorFromOption:gs(e.author),installBundledPackages:e.withPackages===!0,agentGuidanceMode:ws(e.agentGuidance),typePreset:hs(e.typePreset)}}function fu(e){let t=[];return e.prefixArg!==void 0&&e.settings.id_prefix!==e.normalizedPrefix&&t.push("id_prefix"),e.presetFromOption!==void 0&&e.settings.governance.preset!==e.presetFromOption&&t.push("governance_preset"),e.authorFromOption!==void 0&&e.settings.author_default!==e.authorFromOption&&t.push("author_default"),t}function hu(e,t,n,a){if(t.length===0||n)return;let i=a.discovery==="ancestor";throw new u(`${i?`No tracker exists in ${a.requested_cwd}; pm init found an ancestor tracker at ${a.tracker_root}. `:""}Refusing to update existing tracker settings at ${e} without --force.`,h.USAGE,{code:"init_existing_settings_requires_force",type:"urn:pm-cli:error:init_existing_settings_requires_force",required:`--force for ${t.join(", ")}`,why:i?"Ancestor discovery is useful for normal commands, but init must make the selected existing workspace explicit before changing its identity or policy settings.":"pm init is safe to rerun, but changing id prefix, governance preset, or default author on an existing tracker can corrupt long-lived project context when an agent meant to initialize a sandbox path.",resolved_path:a.tracker_root,requested_path:a.requested_cwd,suggested_path:a.suggested_current_tracker_root,examples:["pm init --yes","pm init ./sandbox-pm --yes",...i?['pm init <name> --yes --pm-path "$PWD/.agents/pm"']:[],"pm init acme --yes --force"],nextSteps:[...i?['To create a new tracker in the current directory, rerun with --pm-path "$PWD/.agents/pm".']:[],"If you meant to initialize a sandbox tracker, pass a path-like positional such as ./sandbox-pm or /tmp/pm-test.","If you intentionally want to rewrite this existing tracker's init-managed settings, rerun with --force."]})}function gu(e){let t=!1;return e.prefixArg!==void 0&&e.settings.id_prefix!==e.normalizedPrefix&&(e.settings.id_prefix=e.normalizedPrefix,e.warnings.push(`updated:id_prefix:${e.normalizedPrefix}`),t=!0),e.presetFromOption!==void 0&&e.settings.governance.preset!==e.presetFromOption&&(ma(e.settings,e.presetFromOption),e.warnings.push(`updated:governance_preset:${e.presetFromOption}`),t=!0),e.authorFromOption!==void 0&&e.settings.author_default!==e.authorFromOption&&(e.settings.author_default=e.authorFromOption,e.warnings.push(`updated:author_default:${e.authorFromOption}`),t=!0),t}async function yu(e){let t=await I(e.pmRoot);e.warnings.push(`already_exists:${e.settingsPath}`);let n=fu({settings:t,normalizedPrefix:e.normalizedPrefix,prefixArg:e.prefixArg,presetFromOption:e.normalizedOptions.presetFromOption,authorFromOption:e.normalizedOptions.authorFromOption});return hu(e.settingsPath,n,e.options.force===!0,e.target),gu({settings:t,normalizedPrefix:e.normalizedPrefix,prefixArg:e.prefixArg,presetFromOption:e.normalizedOptions.presetFromOption,authorFromOption:e.normalizedOptions.authorFromOption,warnings:e.warnings})&&await he(e.pmRoot,t),{settings:t,normalizedPrefix:e.normalizedPrefix,chosenPreset:e.normalizedOptions.presetFromOption,wizardUsed:!1}}async function _u(e){let t=e.normalizedPrefix,n=e.normalizedOptions.presetFromOption,a,i=!1;if(e.normalizedOptions.presetFromOption===void 0&&!e.normalizedOptions.useDefaults&&process.stdin.isTTY===!0&&process.stdout.isTTY===!0){let c=await $s(t,await wu());t=c.prefix,n=c.preset,a=c.telemetry_enabled,i=!0}let r=n??"minimal",o=lu();o.id_prefix=t,ma(o,r);let s=Wa()?.trim()||void 0;o.author_default=e.normalizedOptions.authorFromOption??s??"";let d=Is(e.pmRoot);return a!==void 0&&(o.telemetry.enabled=a,o.telemetry.first_run_prompt_completed=!0),await he(e.pmRoot,o,void 0,d),a!==void 0&&d.omitSections&&await vu(a,e.warnings),{settings:o,normalizedPrefix:t,chosenPreset:n,wizardUsed:i}}function Is(e){return P.resolve(e)===P.resolve(Ce(process.cwd()))?{}:{omitSections:["telemetry"]}}async function wu(){let e=await I(Ce(process.cwd()));if(!(di().telemetry_disabled||e.telemetry.first_run_prompt_completed||hn(e)))return e.telemetry.enabled}async function vu(e,t){let n=Ce(process.cwd()),a=await I(n);if(hn(a)){t.push("telemetry_consent_not_recorded:global_settings_unreadable");return}let i=!1;a.telemetry.enabled=e,a.telemetry.first_run_prompt_completed=!0,await he(n,a,"telemetry:first_run_prompt",{skipIfStored:r=>i=r.telemetry?.first_run_prompt_completed===!0}),i&&t.push("telemetry_consent_kept:recorded_while_prompting")}async function bu(e){let{telemetry:t}=await I(Ce(process.cwd()));return{...e,telemetry:{...e.telemetry,enabled:t.enabled,first_run_prompt_completed:t.first_run_prompt_completed,capture_level:t.capture_level}}}async function ps(e){return e.settingsExists?await yu(e):await _u({pmRoot:e.pmRoot,normalizedPrefix:e.normalizedPrefix,normalizedOptions:e.normalizedOptions,warnings:e.warnings})}async function ku(e){let t=await ls({pm_root:e.pmRoot,cwd:e.cwd,mode:e.agentGuidanceMode,interactive:process.stdin.isTTY===!0&&process.stdout.isTTY===!0,settings:e.settings});return e.warnings.push(...t.warnings),t.settings_changed&&await he(e.pmRoot,e.settings,void 0,Is(e.pmRoot)),{...t.summary,next_steps:t.next_steps}}async function xu(e,t){let n=[],a=[],i=await qa(e,t.schema);for(let r of i.created_paths)n.push(r),a.push(...await B({path:r,scope:"project",op:"init:runtime_schema_file"}));return{createdDirs:n,warnings:a}}async function Su(e){if(e.typePreset===void 0)return;let t=await ks(e.pmRoot,e.settings,e.typePreset);return e.warnings.push(`registered_type_preset:${e.typePreset}`),e.warnings.push(...await B({path:t.file,scope:"project",op:"init:type_preset"})),t}async function Eu(e){let t=W(e.settings,J()).folders.filter(a=>!sn.includes(a)),n=await Es(e.pmRoot,t);e.createdDirs.push(...n.createdDirs),e.warnings.push(...n.warnings)}function $u(e){let t=P.resolve(e.tracker_root),n=P.dirname(t);return P.basename(t)==="pm"&&P.basename(n)===".agents"?P.dirname(n):e.workspace_root}async function Iu(e,t,n,a){if(!e)return;let i=await na("all",{install:!0,project:!0},{...t,path:n});a.push(...i.warnings);let r=bs(i),o=r.packages.filter(s=>!s.ok).map(s=>s.alias);if(!r.installed_all||o.length>0)throw new u(`pm init --with-packages did not install all bundled packages successfully${o.length>0?`: ${o.join(", ")}`:"."}`,h.GENERIC_FAILURE);return r}function As(e){let t=a=>oe([...e.target.mode==="workspace-discovery"?[]:["--pm-path",e.target.tracker_root],...a]),n=[`Create your first item: ${t(["create","--type","Task","--title","<title>"])}`,`List active items: ${t(["list"])}`,`Get agent-friendly project context: ${t(["context"])}`];e.installBundledPackages?n.push(`Explore newly-available commands: ${t(["cal"])}, ${t(["templates"])}, ${t(["guide"])}`):(n.push(`Add optional packages for richer workflows: ${t(["install","calendar","--project"])}, ${t(["install","templates","--project"])}, ${t(["install","guide-shell","--project"])}`),n.push(`Or install everything bundled: ${t(["init","--with-packages"])} (idempotent on re-run)`)),e.registeredTypePreset&&n.push(`Inspect registered preset types: ${t(["schema","list"])}, ${t(["schema","show",e.registeredTypePreset.registered[0]??e.registeredTypePreset.updated[0]])}`),n.push("Supported agent harnesses are attributed automatically; use --author or PM_AUTHOR only when an explicit identity override is required.");for(let a of e.agentGuidanceNextSteps){let i=e.target.mode==="workspace-discovery"?a:a.replace(/\bpm (?=[a-z])/g,()=>`${t([])} `);n.includes(i)||n.push(i)}return n}async function Ts(e,t,n,a=fi){if(t===null){n.push("merge_fence_skipped:not_git_repository:run pm merge install after moving the tracker into a Git repository");return}try{let i=await a({pmRoot:e,workspaceRoot:t});i.gitattributes.changed&&n.push(`updated:merge_fence:${i.gitattributes.path}`)}catch(i){if(!(i instanceof u))throw i;n.push(`merge_fence_skipped:install_failed:${i.context.code??"pm_error"}:${i.message}:run pm merge install after resolving the Git repository error`)}}async function Au(e,t,n,a){if(e==null||n==="status")return;let i=await pi(e,{pmRoot:t});i.changed&&a.push(`updated:gitignore:${i.path}`)}async function uv(e,t,n={}){let a=t[cu],i=typeof a=="string"?a:process.cwd(),r=ys(i,t,e,n.workspace),o=r.pmRoot;e=_s(r.prefixArg,n.idPrefix);let s=uu(n);await Ss(o,r.target.mode==="tracker-path",n.force===!0);let d=[],c=[],l=P.join(o,"settings.json"),p=await k(l),m;p&&(m=await ps({pmRoot:o,settingsPath:l,settingsExists:p,normalizedPrefix:Ee(e),prefixArg:e,options:n,normalizedOptions:s,warnings:c,target:r.target}));let y=await Es(o,sn);d.push(...y.createdDirs),c.push(...y.warnings),m??=await ps({pmRoot:o,settingsPath:l,settingsExists:p,normalizedPrefix:Ee(e),prefixArg:e,options:n,normalizedOptions:s,warnings:c,target:r.target});let{settings:g}=m,_=$u(r.target),f=await mi(_??P.dirname(o)),w=_??f,v=await ku({pmRoot:o,cwd:w??i,agentGuidanceMode:s.agentGuidanceMode,settings:g,warnings:c}),E=await xu(o,g);d.push(...E.createdDirs),c.push(...E.warnings);let S=await Su({pmRoot:o,settings:g,typePreset:s.typePreset,warnings:c});S&&(g=await I(o)),await Eu({pmRoot:o,settings:g,createdDirs:d,warnings:c}),await Au(w,o,s.agentGuidanceMode,c),!p&&n.mergeFence!==!1&&s.agentGuidanceMode!=="status"&&await Ts(o,f,c);let C=await Iu(s.installBundledPackages,t,o,c),ne=As({installBundledPackages:s.installBundledPackages,registeredTypePreset:S,agentGuidanceNextSteps:v.next_steps,target:r.target});return{ok:!0,path:o,target:r.target,settings:await bu(g),created_dirs:d,warnings:c,governance_preset:g.governance.preset,wizard_used:m.wizardUsed,...S?{registered_type_preset:S}:{},...C?{installed_packages:C}:{},next_steps:ne,agent_guidance:v}}export{yn as a,xn as b,Si as c,Uu as d,Bs as e,zu as f,En as g,Ys as h,Xs as i,Zs as j,Ai as k,Jl as l,Ge as m,Ji as n,We as o,Be as p,qi as q,Ui as r,Je as s,qe as t,zi as u,ec as v,Qu as w,af as x,Ci as y,ac as z,bf as A,Yi as B,er as C,Gc as D,Jc as E,xy as F,$y as G,Iy as H,_t as I,Ay as J,Ty as K,Oy as L,Cy as M,Ry as N,Py as O,Ny as P,Dy as Q,jy as R,Ly as S,Fy as T,My as U,Uy as V,zy as W,Gy as X,Jy as Y,qy as Z,Wy as _,By as $,Hy as aa,Ky as ba,Vy as ca,Yy as da,Xy as ea,Zy as fa,Z as ga,b as ha,Rn as ia,od as ja,le as ka,Ft as la,qc as ma,ot as na,Mt as oa,hr as pa,Sr as qa,Wn as ra,Lr as sa,hg as ta,so as ua,pp as va,wo as wa,vo as xa,Xn as ya,Vr as za,Fl as Aa,$p as Ba,Xr as Ca,na as Da,Zo as Ea,Uw as Fa,ls as Ga,cu as Ha,pv as Ia,mv as Ja,uv as Ka};
70
- //# sourceMappingURL=chunk-NZAFLDSH.js.map
70
+ //# sourceMappingURL=chunk-OBTU2BHJ.js.map
@@ -1,2 +1,2 @@
1
- import{Gb as b,ia as s,ja as w}from"./chunk-D727C4RO.js";import{Fa as y,Na as u,Ta as i,Ui as g,ej as h,pd as I}from"./chunk-WNEUWDUE.js";import{A as c,C as l,E as p}from"./chunk-O4ZLEN4T.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new o.Error().stack;t&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[t]="59842825-3a81-53f4-845d-db2257ec6286")}catch{}})();async function R(o){let t=u(process.cwd(),o);await h(t);let r=await g(t),n=y(r,I());return{pmRoot:t,settings:r,typeRegistry:n}}async function C(o,t,r,n){i(o,s(t));let e=await b(o,t,r.id_prefix,r.item_format,n);if(e)return{id:e.id,historyPath:i(o,e.id),located:e};let a=w(t,r.id_prefix),d=s(t),_=a===d?[a]:[a,d];for(let f of _){let m=i(o,f);if(await p(m))return{id:f,historyPath:m,located:null}}throw new l(`Item ${t} not found`,c.NOT_FOUND)}export{R as a,C as b};
2
- //# sourceMappingURL=chunk-4AASUCHO.js.map
1
+ import{Hb as b,ja as s,ka as w}from"./chunk-FOT5K5OM.js";import{Fa as y,Na as u,Ta as i,Zi as g,jj as h,ud as I}from"./chunk-PZI6CR24.js";import{A as c,C as l,E as p}from"./chunk-O4ZLEN4T.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new o.Error().stack;t&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[t]="59842825-3a81-53f4-845d-db2257ec6286")}catch{}})();async function R(o){let t=u(process.cwd(),o);await h(t);let r=await g(t),n=y(r,I());return{pmRoot:t,settings:r,typeRegistry:n}}async function C(o,t,r,n){i(o,s(t));let e=await b(o,t,r.id_prefix,r.item_format,n);if(e)return{id:e.id,historyPath:i(o,e.id),located:e};let a=w(t,r.id_prefix),d=s(t),_=a===d?[a]:[a,d];for(let f of _){let m=i(o,f);if(await p(m))return{id:f,historyPath:m,located:null}}throw new l(`Item ${t} not found`,c.NOT_FOUND)}export{R as a,C as b};
2
+ //# sourceMappingURL=chunk-OFIXSWJS.js.map