@unbrained/pm-cli 2026.10.25 → 2026.10.26

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 (175) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +28 -0
  3. package/dist/cli/error-guidance.d.ts +5 -0
  4. package/dist/cli/error-guidance.js +2 -2
  5. package/dist/cli/register-mutation.js +2 -2
  6. package/dist/cli-bundle/bundle-manifest.json +1 -1
  7. package/dist/cli-bundle/chunks/{chunk-O3ZTGRIH.js → chunk-25MTQAHX.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-TLMXSYJA.js → chunk-57YPOOED.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-4GD6QOP6.js → chunk-7UDQAINZ.js} +3 -3
  10. package/dist/cli-bundle/chunks/{chunk-LNKPH2DD.js → chunk-ER7RLJW5.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-YCCGZHOR.js → chunk-MWCG25PO.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-444VPGQT.js → chunk-N6FTEILW.js} +5 -5
  13. package/dist/cli-bundle/chunks/{chunk-FNZT4BTE.js → chunk-NGKTROAO.js} +86 -86
  14. package/dist/cli-bundle/chunks/chunk-OCDRHIVQ.js +6 -0
  15. package/dist/cli-bundle/chunks/{chunk-3CYXE6BV.js → chunk-ONC4BBQP.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-RQKDANP7.js → chunk-OUDR2HWR.js} +3 -3
  17. package/dist/cli-bundle/chunks/{chunk-RD6UW3MW.js → chunk-T7T4WLUY.js} +3 -3
  18. package/dist/cli-bundle/chunks/{chunk-MVJGGCGQ.js → chunk-TGOG5BFM.js} +2 -2
  19. package/dist/cli-bundle/chunks/chunk-UF6EXZSP.js +2 -0
  20. package/dist/cli-bundle/chunks/chunk-VS2IIV3F.js +128 -0
  21. package/dist/cli-bundle/chunks/chunk-XAIR53QZ.js +2 -0
  22. package/dist/cli-bundle/chunks/{chunk-VAEB6IUQ.js → chunk-Y42DYMZX.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-EYCVAAIP.js → chunk-YJBIPNDL.js} +2 -2
  24. package/dist/cli-bundle/chunks/{chunk-UI3FD3DW.js → chunk-Z35XAHUN.js} +2 -2
  25. package/dist/cli-bundle/chunks/{chunk-7C3GCLOO.js → chunk-ZLVFUZI4.js} +27 -27
  26. package/dist/cli-bundle/chunks/{chunk-7T3H24HN.js → chunk-ZT64RDMF.js} +2 -2
  27. package/dist/cli-bundle/chunks/{indexed-receipt-blobs-47I6KKDO.js → indexed-receipt-blobs-NWQIDTH7.js} +2 -2
  28. package/dist/cli-bundle/chunks/{mutation-admission-747C6IUR.js → mutation-admission-VTNV6JV2.js} +2 -2
  29. package/dist/cli-bundle/chunks/{register-list-query-COST6KRV.js → register-list-query-LZDWUZS4.js} +2 -2
  30. package/dist/cli-bundle/chunks/register-mutation-M2A7PH42.js +20 -0
  31. package/dist/cli-bundle/chunks/{register-operations-S4LKLUBJ.js → register-operations-E7P2JTXM.js} +2 -2
  32. package/dist/cli-bundle/chunks/{register-setup-3ITZXPOL.js → register-setup-DOV7KGSH.js} +2 -2
  33. package/dist/cli-bundle/chunks/{settlement-hook-5IVCF6ZY.js → settlement-hook-SVD6CO7U.js} +2 -2
  34. package/dist/cli-bundle/chunks/{stage-3UUIYROS.js → stage-LYLEOAQB.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-HMYDUEQK.js → chunk-226XKW3W.js} +3 -3
  36. package/dist/cli-bundle/focused-chunks/chunk-ABMNYWV6.js +2 -0
  37. package/dist/cli-bundle/focused-chunks/{chunk-3M5FZCMC.js → chunk-ADSBGYLW.js} +8 -8
  38. package/dist/cli-bundle/focused-chunks/{chunk-22727JYL.js → chunk-B266DDBJ.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-Y4JHHY24.js → chunk-BH7RE2ZY.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/chunk-BL77VCRB.js +22 -0
  41. package/dist/cli-bundle/focused-chunks/{chunk-77NU7NPN.js → chunk-CSCZYSNZ.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{chunk-URWYYJ7K.js → chunk-D5YQ4KAE.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-ZYCOMRFT.js → chunk-E5C24MCV.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/{chunk-74KC7FUQ.js → chunk-I7H3XF25.js} +2 -2
  45. package/dist/cli-bundle/focused-chunks/chunk-IF6C43IP.js +2 -0
  46. package/dist/cli-bundle/focused-chunks/chunk-KERJNFXY.js +2 -0
  47. package/dist/cli-bundle/focused-chunks/{chunk-46KDJH3K.js → chunk-KTXU5WU6.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-NE27VCU7.js +91 -0
  49. package/dist/cli-bundle/focused-chunks/{chunk-NI5SG2M2.js → chunk-NFN2P4TW.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-NC5HUGHU.js → chunk-NLZUI234.js} +4 -4
  51. package/dist/cli-bundle/focused-chunks/chunk-PK5FJIVA.js +12 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-LWJ2X75I.js → chunk-UHWTPOM4.js} +2 -2
  53. package/dist/cli-bundle/focused-chunks/{chunk-B5JOVH5F.js → chunk-UP765R2V.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-U6HXIF6G.js → chunk-WDWHUJQW.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-7DEZT4JN.js → chunk-YQKLKRMW.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/chunk-YTEC2EPM.js +3 -0
  57. package/dist/cli-bundle/focused-chunks/{chunk-3FM75SBJ.js → chunk-YW5GHQN2.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-YCLN2ZZG.js → indexed-receipt-blobs-YFDNGHCM.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{mutation-admission-BQBQXILV.js → mutation-admission-L42E3U5U.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{settlement-hook-XVS6P2XI.js → settlement-hook-3CADO4XZ.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{stage-VSIL4MTZ.js → stage-TUQHWU7N.js} +2 -2
  62. package/dist/cli-bundle/main.js +4 -4
  63. package/dist/cli-bundle/sdk-authoring.js +1 -1
  64. package/dist/cli-bundle/sdk-contracts.js +2 -2
  65. package/dist/cli-bundle/sdk-core.js +23 -23
  66. package/dist/cli-bundle/sdk-governance.js +1 -1
  67. package/dist/cli-bundle/sdk-graph.js +1 -1
  68. package/dist/cli-bundle/sdk-merge.js +57 -57
  69. package/dist/cli-bundle/sdk-query.js +1 -1
  70. package/dist/cli-bundle/sdk-runtime.js +1 -1
  71. package/dist/cli-bundle/sdk-testing.js +1 -1
  72. package/dist/cli-bundle/sdk.js +9 -9
  73. package/dist/core/extensions/extension-types.d.ts +3 -0
  74. package/dist/core/extensions/extension-types.js +1 -1
  75. package/dist/core/output/mutation-projection.js +1 -1
  76. package/dist/core/policy/workflow-policy-store.js +1 -1
  77. package/dist/core/shared/errors.d.ts +9 -0
  78. package/dist/core/shared/errors.js +1 -1
  79. package/dist/core/shared/secret-rules.d.ts +17 -0
  80. package/dist/core/shared/secret-rules.js +2 -1
  81. package/dist/core/store/item-mutation-precondition.d.ts +8 -0
  82. package/dist/core/store/item-mutation-precondition.js +1 -1
  83. package/dist/core/store/item-store.js +1 -1
  84. package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
  85. package/dist/sdk/cli-contracts/completeness.js +1 -1
  86. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  87. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  88. package/dist/sdk/cli-contracts/registration-helpers.d.ts +1 -1
  89. package/dist/sdk/cli-contracts/registration-helpers.js +1 -1
  90. package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +4 -0
  91. package/dist/sdk/cli-contracts/tool-option-contracts.js +1 -1
  92. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  93. package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
  94. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  95. package/dist/sdk/context-signal-store.js +2 -2
  96. package/dist/sdk/core.d.ts +1 -1
  97. package/dist/sdk/core.js +1 -1
  98. package/dist/sdk/extension-command-context.js +2 -2
  99. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  100. package/dist/sdk/index.d.ts +2 -1
  101. package/dist/sdk/index.js +1 -1
  102. package/dist/sdk/item-transaction.js +1 -1
  103. package/dist/sdk/lifecycle/close-many.d.ts +3 -0
  104. package/dist/sdk/lifecycle/close-many.js +1 -1
  105. package/dist/sdk/lifecycle/close.d.ts +3 -1
  106. package/dist/sdk/lifecycle/close.js +1 -1
  107. package/dist/sdk/lifecycle/create.d.ts +2 -0
  108. package/dist/sdk/lifecycle/create.js +1 -1
  109. package/dist/sdk/lifecycle/plan.d.ts +2 -0
  110. package/dist/sdk/lifecycle/plan.js +1 -1
  111. package/dist/sdk/lifecycle/restore.js +1 -1
  112. package/dist/sdk/lifecycle-policy.d.ts +11 -0
  113. package/dist/sdk/lifecycle-policy.js +1 -1
  114. package/dist/sdk/mutation-guard.d.ts +6 -1
  115. package/dist/sdk/mutation-guard.js +1 -1
  116. package/dist/sdk/output/fit-envelope.d.ts +98 -0
  117. package/dist/sdk/output/fit-envelope.js +2 -0
  118. package/dist/sdk/public-surface.json +1 -1
  119. package/dist/sdk/query.d.ts +1 -0
  120. package/dist/sdk/query.js +1 -1
  121. package/dist/sdk/read-output-session.d.ts +1 -1
  122. package/dist/sdk/read-output-session.js +1 -1
  123. package/dist/sdk/runtime-input.js +1 -1
  124. package/dist/sdk/runtime-primitives.d.ts +1 -1
  125. package/dist/sdk/runtime-primitives.js +1 -1
  126. package/dist/sdk/runtime.d.ts +2 -2
  127. package/dist/sdk/runtime.js +1 -1
  128. package/dist/sdk/scheduling-shortcuts.d.ts +2 -0
  129. package/dist/sdk/scheduling-shortcuts.js +1 -1
  130. package/dist/sdk/workspace-transaction.d.ts +3 -1
  131. package/dist/sdk/workspace-transaction.js +2 -2
  132. package/docs/COMMANDS.md +2 -1
  133. package/docs/MUTATION_INTEGRITY.md +33 -0
  134. package/docs/QUALITY_EVIDENCE.md +9 -0
  135. package/docs/READ_OUTPUT_CONTRACTS.md +55 -1
  136. package/docs/SDK.md +88 -6
  137. package/docs/WORKFLOW_POLICIES.md +14 -1
  138. package/docs/agent-task-token-baseline.json +1 -1
  139. package/docs/agent-task-transcripts.json +1 -1
  140. package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
  141. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  142. package/marketplace.json +1 -1
  143. package/package.json +1 -1
  144. package/packages/pm-beads/package.json +1 -1
  145. package/packages/pm-calendar/extensions/calendar/shortcuts.ts +2 -2
  146. package/packages/pm-calendar/package.json +1 -1
  147. package/packages/pm-command-kit/package.json +1 -1
  148. package/packages/pm-digital-twin/package.json +1 -1
  149. package/packages/pm-governance-audit/package.json +1 -1
  150. package/packages/pm-guide-shell/package.json +1 -1
  151. package/packages/pm-kanban/package.json +1 -1
  152. package/packages/pm-lifecycle-hooks/package.json +1 -1
  153. package/packages/pm-linked-test-adapters/package.json +1 -1
  154. package/packages/pm-search-advanced/package.json +1 -1
  155. package/packages/pm-templates/package.json +1 -1
  156. package/packages/pm-todos/package.json +1 -1
  157. package/packages/pm-vcs/package.json +1 -1
  158. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  159. package/plugins/pm-claude/package.json +1 -1
  160. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  161. package/plugins/pm-codex/package.json +1 -1
  162. package/plugins/pm-codex/plugin.json +1 -1
  163. package/runtime-dependencies.json +1 -1
  164. package/dist/cli-bundle/chunks/chunk-5ZPT67NJ.js +0 -127
  165. package/dist/cli-bundle/chunks/chunk-HMJSFWHK.js +0 -2
  166. package/dist/cli-bundle/chunks/chunk-RLXK2S7P.js +0 -2
  167. package/dist/cli-bundle/chunks/chunk-XYLBOXSH.js +0 -6
  168. package/dist/cli-bundle/chunks/register-mutation-JZVVJUHY.js +0 -20
  169. package/dist/cli-bundle/focused-chunks/chunk-5LBZR6YW.js +0 -2
  170. package/dist/cli-bundle/focused-chunks/chunk-IVLIUPVV.js +0 -12
  171. package/dist/cli-bundle/focused-chunks/chunk-KIIGME23.js +0 -2
  172. package/dist/cli-bundle/focused-chunks/chunk-MT5TYMEU.js +0 -3
  173. package/dist/cli-bundle/focused-chunks/chunk-QH5KMIYZ.js +0 -91
  174. package/dist/cli-bundle/focused-chunks/chunk-W7MCCFYV.js +0 -2
  175. package/dist/cli-bundle/focused-chunks/chunk-WMPDY5ZU.js +0 -21
@@ -1,5 +1,5 @@
1
- import{F as Wa,I as Tt,J as Ot,Kc as Ha,M as Pe,R as Ba,S as un,g as Se,hd as Ka,id as Re,jd as at,k as Ua,kd as Va,l as za,ld as Ya,m as Ee,md as ae,n as Ga,nd as Ue,o as Ja,od as Xa,pd as se,wf as Ct,z as qa,ze as Za}from"./chunk-5ZPT67NJ.js";import{i as ei,n as ti,p as ni}from"./chunk-RD6UW3MW.js";import{Aa as ya,Ac as Ca,Ai as xe,Bb as xa,Bd as Na,Cb as Sa,Cc as It,Cd as oe,Db as Ea,Dc as Pa,Ec as Ra,G as ma,Gb as $a,Hb as Ia,Oc as J,Pb as Aa,Q as St,R as on,Rb as Ta,Rf as Me,S as sn,Sa as Et,Se as T,Ta as _a,Ua as cn,Ub as Ce,Va as dn,Wa as ln,Ya as wa,Za as va,Zc as B,ab as ba,bf as ne,eg as I,fg as V,gg as Da,hb as ka,hg as K,ig as Q,j as ca,jh as La,ji as mn,kg as ja,li as Fa,mg as nt,mi as ke,na as ua,oa as fa,og as At,oh as q,pa as W,rc as pn,ri as Ma,sc as Oa,tc as $t,ui as ue,v as H,vc as ve,xa as F,xc as be,ya as ha,z as we,za as ga,zi as A}from"./chunk-RQKDANP7.js";import{f as Qa}from"./chunk-LNKPH2DD.js";import{A as h,C as f,E as k,F as xt,G as _e,H as M,K as me,a as da,d as kt,m as la,t as an,v as pa,y as rn}from"./chunk-3CYXE6BV.js";import{mkdir as ws,readFile as vs}from"node:fs/promises";import oi from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="1fae5539-4eb8-5eba-bfd6-a191c89448ec")}catch{}})();var fn=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},bs="sdk-workspace-transaction",ks=/^[a-zA-Z0-9._-]+$/,xs=30,Ss=3e3;function si(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!ks.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function ai(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 Es(e){return{pmRoot:ai(e.pmRoot,"Transaction pmRoot"),transactionId:si(e.transactionId,"Transaction id"),author:ai(e.author,"Transaction author")}}function ii(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 ci(e,t){return oi.join(e,"transactions","sdk",`${t}.json`)}async function $e(e,t){t.updatedAt=T();let n=ci(e,t.transactionId);await ws(oi.dirname(n),{recursive:!0}),await me(n,`${JSON.stringify(t,null,2)}
2
- `)}function $s(e){return Number.isInteger(e.attempt)&&typeof e.author=="string"&&typeof e.createdAt=="string"&&typeof e.updatedAt=="string"}function Ne(e){return Object.assign(Object.create(null),e)}function Is(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 hn(e,t){return e===void 0?void 0:Is(e,t)}function gn(e,t,n,a){let i=hn(n,a);i===void 0?delete e[t]:e[t]=i}function ri(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function yn(e,t){return Array.isArray(e)&&new Set(e).size===e.length&&e.every(n=>typeof n=="string"&&t.includes(n))}function As(e,t){if(!yn(e.startedStepIds,t)||!yn(e.completedStepIds,t)||!ri(e.results)||!ri(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)):e.status!=="compensated"||r.size===0&&a.size===0}function Pt(e,t){return new f(`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 Ts(e){return new f(`Workspace transaction ${e} journal does not match the supplied plan`,h.CONFLICT,{code:"transaction_plan_mismatch",required:"Replay the exact plan that started this transaction, or start a new transaction with a different id.",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.","Pass --transaction-id <new-id> (or a new transactionId over MCP) to commit the changed plan as its own transaction.","Run pm ops gc --scope transactions --dry-run to inspect abandoned journals before pruning them."]})}function Os(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.transactionId===t))throw Pt(t,"schema version or transaction id does not match the journal file");let r=i.stepIds;if(!Array.isArray(r)||!yn(r,r)||!As(i,r)||!$s(i)||typeof i.status!="string"||!["applying","compensating","compensated","committed"].includes(i.status))throw Pt(t,"invalid lifecycle, metadata, status or step ids");if(!(i.status==="compensated"||r.length===n.length&&r.every((o,s)=>o===n[s])))throw Ts(t);return{...i,results:Ne(i.results),compensationData:Ne(i.compensationData)}}async function Cs(e,t,n,a,i){let r=i,o=r!==void 0;if(r?.status==="compensating"&&await di(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:Ne(),compensationData:Ne()},await $e(e.pmRoot,r),await fe(e,r,"prepared")}return{journal:r,recovered:o}}async function Ps(e,t,n){try{await Ns(t,e.steps),await $e(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=hn(o.result,`Step ${r.id} result`);if(o.state!=="applied"){let d=await r.prepareCompensation?.();gn(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 $e(e.pmRoot,t);let c=await r.apply();s=hn(c,`Step ${r.id} result`)}await fe(e,t,"step_applied",r.id),a.add(r.id),t.completedStepIds=e.steps.map(d=>d.id).filter(d=>a.has(d)),gn(t.results,r.id,s,`Step ${r.id} result`),await $e(e.pmRoot,t),await fe(e,t,"step_recorded",r.id)}return await fe(e,t,"committing"),t.status="committed",await $e(e.pmRoot,t),await fe(e,t,"committed"),{transactionId:t.transactionId,status:"committed",recovered:n,results:Ne(t.results)}}catch(a){if(a instanceof fn||t.status==="committed")throw a;try{await di(e,t)}catch(i){throw new AggregateError([a,i],`Workspace transaction failed and compensation failed: ${String(i)}`,{cause:i})}throw a}}async function Rs(e,t,n){try{return Os(await vs(ci(e,t),"utf8"),t,n)}catch(a){if(a!==null&&typeof a=="object"&&"code"in a&&_e(a))return;throw a}}async function fe(e,t,n,a){await e.onTransition?.({transactionId:t.transactionId,attempt:t.attempt,transition:n,...a===void 0?{}:{stepId:a}})}async function Ns(e,t){let n=new Set,a=Ne();for(let i of t){let r=await i.inspect();r.state==="applied"&&(n.add(i.id),gn(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 di(e,t){t.status="compensating",await $e(e.pmRoot,t),await fe(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{r=a.has(i.id)&&(await i.inspect()).state==="applied"}catch{r=a.has(i.id)}r&&(await fe(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 $e(e.pmRoot,t),await fe(e,t,"step_compensated",i.id)}t.status="compensated",await $e(e.pmRoot,t),await fe(e,t,"compensated")}async function li(e){let{pmRoot:t,transactionId:n,author:a}=Es(e),i=ii(e.lockTtlSeconds,xs,"Transaction lock TTL"),r=ii(e.lockWaitMs,Ss,"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=si(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 ne(t,bs,i,a,!1,!1,r);try{let l=await Rs(t,n,s),p=l!==void 0;if(l?.status==="committed")return{transactionId:n,status:"committed",recovered:!0,results:Ne(l.results)};let m=await Cs(d,n,a,s,l);return await Ps(d,m.journal,p||m.recovered)}finally{await c()}}import Ds from"node:fs/promises";import js 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 _n(e){return js.join(e,"extension-migrations.json")}function pi(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 mi(e,t){return`${e.layer}:${e.name}:${t}`}async function Ls(e){let t=_n(e);if(!await k(t))return{version:1,updated_at:"",entries:[]};let n=JSON.parse(await Ds.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 Fs(e,t){let n=await Ls(e),a=new Map(n.entries.map(i=>[i.key,i]));return t.forEach((i,r)=>{let o=pi(i,r),s=a.get(mi(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 Ms(e){let t=await Fs(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=pi(l,p),y=mi(l,m),g=n.get(y),_=String(l.definition.status??"pending").toLowerCase(),u=g?.status??(_==="applied"||_==="failed"?_:"pending");if(u==="applied"){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:u,outcome:"skipped"});continue}if(e.dryRun===!0){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:u,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:u,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:u}));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:u,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:u,outcome:"failed",error:S}),i=!0}}if(i){let l=await A(e.pmRoot),p={version:1,updated_at:new Date().toISOString(),entries:[...n.values()].sort((m,y)=>m.key.localeCompare(y.key))};await ke({pmRoot:e.pmRoot,filePath:_n(e.pmRoot),raw:`${JSON.stringify(p,null,2)}
1
+ import{A as qa,Ae as Za,G as Wa,J as Tt,K as Ot,Lc as Ha,N as Pe,S as Ba,T as un,g as Se,id as Ka,jd as Re,k as Ua,kd as at,l as za,ld as Va,m as Ee,md as Ya,n as Ga,nd as ae,o as Ja,od as Ue,pd as Xa,qd as se,xf as Ct}from"./chunk-VS2IIV3F.js";import{i as ei,n as ti,p as ni}from"./chunk-T7T4WLUY.js";import{Aa as ya,Ac as Ca,Ai as xe,Bb as xa,Bd as Na,Cb as Sa,Cc as It,Cd as oe,Db as Ea,Dc as Pa,Ec as Ra,G as ma,Gb as $a,Hb as Ia,Oc as J,Pb as Aa,Q as St,R as on,Rb as Ta,Rf as Me,S as sn,Sa as Et,Se as T,Ta as _a,Ua as cn,Ub as Ce,Va as dn,Wa as ln,Ya as wa,Za as va,Zc as B,ab as ba,bf as ne,eg as I,fg as V,gg as Da,hb as ka,hg as K,ig as Q,j as ca,jh as La,ji as mn,kg as ja,li as Fa,mg as nt,mi as ke,na as ua,oa as fa,og as At,oh as q,pa as W,rc as pn,ri as Ma,sc as Oa,tc as $t,ui as ue,v as H,vc as ve,xa as F,xc as be,ya as ha,z as we,za as ga,zi as A}from"./chunk-OUDR2HWR.js";import{f as Qa}from"./chunk-ER7RLJW5.js";import{A as h,C as f,E as k,F as xt,G as _e,H as M,K as me,a as da,d as kt,m as la,t as an,v as pa,y as rn}from"./chunk-ONC4BBQP.js";import{mkdir as ws,readFile as vs}from"node:fs/promises";import oi from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d913251a-fc99-5767-b19d-ae9473adc138")}catch{}})();var fn=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},bs="sdk-workspace-transaction",ks=/^[a-zA-Z0-9._-]+$/,xs=30,Ss=3e3;function si(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!ks.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function ai(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 Es(e){return{pmRoot:ai(e.pmRoot,"Transaction pmRoot"),transactionId:si(e.transactionId,"Transaction id"),author:ai(e.author,"Transaction author")}}function ii(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 ci(e,t){return oi.join(e,"transactions","sdk",`${t}.json`)}async function $e(e,t){t.updatedAt=T();let n=ci(e,t.transactionId);await ws(oi.dirname(n),{recursive:!0}),await me(n,`${JSON.stringify(t,null,2)}
2
+ `)}function $s(e){return Number.isInteger(e.attempt)&&typeof e.author=="string"&&typeof e.createdAt=="string"&&typeof e.updatedAt=="string"}function Ne(e){return Object.assign(Object.create(null),e)}function Is(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 hn(e,t){return e===void 0?void 0:Is(e,t)}function gn(e,t,n,a){let i=hn(n,a);i===void 0?delete e[t]:e[t]=i}function ri(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function yn(e,t){return Array.isArray(e)&&new Set(e).size===e.length&&e.every(n=>typeof n=="string"&&t.includes(n))}function As(e,t){if(!yn(e.startedStepIds,t)||!yn(e.completedStepIds,t)||!ri(e.results)||!ri(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)):e.status!=="compensated"||r.size===0&&a.size===0}function Pt(e,t){return new f(`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 Ts(e){return new f(`Workspace transaction ${e} journal does not match the supplied plan`,h.CONFLICT,{code:"transaction_plan_mismatch",required:"Replay the exact plan that started this transaction, or start a new transaction with a different id.",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.","Pass --transaction-id <new-id> (or a new transactionId over MCP) to commit the changed plan as its own transaction.","Run pm ops gc --scope transactions --dry-run to inspect abandoned journals before pruning them."]})}function Os(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.transactionId===t))throw Pt(t,"schema version or transaction id does not match the journal file");let r=i.stepIds;if(!Array.isArray(r)||!yn(r,r)||!As(i,r)||!$s(i)||typeof i.status!="string"||!["applying","compensating","compensated","committed"].includes(i.status))throw Pt(t,"invalid lifecycle, metadata, status or step ids");if(!(i.status==="compensated"||r.length===n.length&&r.every((o,s)=>o===n[s])))throw Ts(t);return{...i,results:Ne(i.results),compensationData:Ne(i.compensationData)}}async function Cs(e,t,n,a,i){let r=i,o=r!==void 0;if(r?.status==="compensating"&&await di(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:Ne(),compensationData:Ne()},await $e(e.pmRoot,r),await fe(e,r,"prepared")}return{journal:r,recovered:o}}async function Ps(e,t,n){try{await Ns(t,e.steps),await $e(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=hn(o.result,`Step ${r.id} result`);if(o.state!=="applied"){let d=await r.prepareCompensation?.();gn(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 $e(e.pmRoot,t);let c=await r.apply();s=hn(c,`Step ${r.id} result`)}await fe(e,t,"step_applied",r.id),a.add(r.id),t.completedStepIds=e.steps.map(d=>d.id).filter(d=>a.has(d)),gn(t.results,r.id,s,`Step ${r.id} result`),await $e(e.pmRoot,t),await fe(e,t,"step_recorded",r.id)}return await fe(e,t,"committing"),t.status="committed",await $e(e.pmRoot,t),await fe(e,t,"committed"),{transactionId:t.transactionId,status:"committed",recovered:n,results:Ne(t.results)}}catch(a){if(a instanceof fn||t.status==="committed")throw a;try{await di(e,t)}catch(i){throw new AggregateError([a,i],`Workspace transaction failed and compensation failed: ${String(i)}`,{cause:i})}throw a}}async function Rs(e,t,n){try{return Os(await vs(ci(e,t),"utf8"),t,n)}catch(a){if(a!==null&&typeof a=="object"&&"code"in a&&_e(a))return;throw a}}async function fe(e,t,n,a){await e.onTransition?.({transactionId:t.transactionId,attempt:t.attempt,transition:n,...a===void 0?{}:{stepId:a}})}async function Ns(e,t){let n=new Set,a=Ne();for(let i of t){let r=await i.inspect();r.state==="applied"&&(n.add(i.id),gn(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 di(e,t){t.status="compensating",await $e(e.pmRoot,t),await fe(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 fe(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 $e(e.pmRoot,t),await fe(e,t,"step_compensated",i.id)}t.status="compensated",await $e(e.pmRoot,t),await fe(e,t,"compensated")}async function li(e){let{pmRoot:t,transactionId:n,author:a}=Es(e),i=ii(e.lockTtlSeconds,xs,"Transaction lock TTL"),r=ii(e.lockWaitMs,Ss,"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=si(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 ne(t,bs,i,a,!1,!1,r);try{let l=await Rs(t,n,s),p=l!==void 0;if(l?.status==="committed")return{transactionId:n,status:"committed",recovered:!0,results:Ne(l.results)};let m=await Cs(d,n,a,s,l);return await Ps(d,m.journal,p||m.recovered)}finally{await c()}}import Ds from"node:fs/promises";import js 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 _n(e){return js.join(e,"extension-migrations.json")}function pi(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 mi(e,t){return`${e.layer}:${e.name}:${t}`}async function Ls(e){let t=_n(e);if(!await k(t))return{version:1,updated_at:"",entries:[]};let n=JSON.parse(await Ds.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 Fs(e,t){let n=await Ls(e),a=new Map(n.entries.map(i=>[i.key,i]));return t.forEach((i,r)=>{let o=pi(i,r),s=a.get(mi(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 Ms(e){let t=await Fs(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=pi(l,p),y=mi(l,m),g=n.get(y),_=String(l.definition.status??"pending").toLowerCase(),u=g?.status??(_==="applied"||_==="failed"?_:"pending");if(u==="applied"){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:u,outcome:"skipped"});continue}if(e.dryRun===!0){a.push({key:y,layer:l.layer,extension:l.name,id:m,before:u,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:u,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:u}));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:u,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:u,outcome:"failed",error:S}),i=!0}}if(i){let l=await A(e.pmRoot),p={version:1,updated_at:new Date().toISOString(),entries:[...n.values()].sort((m,y)=>m.key.localeCompare(y.key))};await ke({pmRoot:e.pmRoot,filePath:_n(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:_n(e.pmRoot),total:a.length,pending_count:o,applied_count:s,skipped_count:d,failed_count:c,migrations:a}}async function ui(e){let t=await A(e.resolvedRoots.settings_root),n=await ve({pmRoot:e.resolvedRoots.pm_root,settings:t,cwd:process.cwd(),noExtensions:e.global.noExtensions===!0}),a=await be(n);e.warnings.push(...n.warnings,...a.warnings);let i=await Ms({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 Us=[["beforeCommand","before_command"],["beforeMutation","before_mutation"],["afterCommand","after_command"],["onWrite","on_write"],["onRead","on_read"],["onIndex","on_index"]];function ze(e,t={}){let n=new Set;t.extensionName!==void 0&&n.add(It(t.extensionName));for(let u of t.extensionNames??[])n.add(It(u));let a=u=>n.size===0||n.has(It(u)),i=(u,w)=>fi(u.filter(v=>a(v.name)).map(w)),r=(u,w)=>fi(u.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??[],u=>u.definitions.map(w=>w.kind)),g=p.overrides.filter(u=>a(u.name)&&((u.commands?.length??0)>0||u.resultDiscriminator!==void 0)).map(u=>({format:u.format,commands:[...u.commands??[]],result_discriminator:u.resultDiscriminator!==void 0})).sort((u,w)=>u.format.localeCompare(w.format)),_=i(o.assurance_providers??[],u=>u.definition.id);return{capabilities:Pa(e,t),commands:i(o.commands,u=>u.command),command_overrides:i(s.overrides,u=>u.command),command_handlers:i(s.handlers,u=>u.command),hooks:Us.filter(([u])=>m[u].some(w=>a(w.name))).map(([,u])=>u),flag_commands:i(o.flags,u=>u.target_command),item_types:r(o.item_types,u=>u.types.map(w=>w.name)),item_fields:r(o.item_fields,u=>u.fields.map(w=>w.name)),...y.length>0?{relationship_kinds:y}:{},migrations:r(o.migrations,u=>typeof u.definition.id=="string"?[u.definition.id]:[]),profiles:i(o.profiles,u=>u.profile.name),importers:i(o.importers,u=>u.importer),exporters:i(o.exporters,u=>u.exporter),search_providers:i(o.search_providers,u=>u.definition.name),vector_store_adapters:i(o.vector_store_adapters,u=>u.definition.name),..._.length>0?{assurance_providers:_}:{},parser_overrides:i(d.overrides,u=>u.command),service_overrides:i(l.overrides,u=>u.service),renderer_overrides:i(p.overrides,u=>u.format),...g.length>0?{renderer_ownership:g}:{},preflight_overrides:c.overrides.filter(u=>a(u.name)).length,preflight_ownership:c.overrides.filter(u=>a(u.name)).map(u=>({commands:[...u.commands??[]]}))}}function fi(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 it={type:"string",minLength:1,maxLength:128,pattern:"\\S"},Rt={type:"array",minItems:1,maxItems:cn,items:it},hi={...Rt,items:{...it,pattern:"^(?!(?:.*\\.)?(?:__proto__|constructor|prototype)(?:\\.|$))[a-zA-Z_][a-zA-Z0-9_]*(?:\\.[a-zA-Z_][a-zA-Z0-9_]*){0,7}$"}},zs={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,Rt])),dependency:{type:"object",additionalProperties:!1,required:["kind"],properties:{kind:it,id:it}}}},rule:{oneOf:[{type:"object",additionalProperties:!1,required:["kind","fields"],properties:{kind:{const:"require_fields"},fields:hi}},{type:"object",additionalProperties:!1,required:["kind","authors"],properties:{kind:{const:"authors"},authors:Rt}},...["field_writers","approval"].map(e=>({type:"object",additionalProperties:!1,required:["kind","fields","authors"],properties:{kind:{const:e},fields:hi,authors:Rt}})),{type:"object",additionalProperties:!1,required:["kind","allowed"],properties:{kind:{const:"transition"},allowed:{type:"array",maxItems:cn,items:{type:"array",minItems:2,maxItems:2,items:it}}}}]}}},Pu={$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:_a,items:zs}}};(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 ju(e,t,n,a){let i=await Ee(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"]}:gi(i,t,n,a)}function Gs(e,t,n){return e===0?"undeclared":t===0?"empty":n===0?"inapplicable":n===t?"covered":"partial"}function gi(e,t,n=5,a=!1){let i=[],r=new Map,o=e.policies.filter(u=>u.rule.kind==="require_fields"),s=o.filter(u=>u.subject?.operations===void 0),d=new Set,c=0,l=0,p=0,m=0,y=0,g=ba(e);for(let u of t){let w=g({operation:"",author:"",before:u,after:u,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(u.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:u.id,type:u.type,status:u.status,decision:S});r.set(u.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:Gs(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 Js 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 qs(){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 wi(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{throw new f("Policy definition must be valid JSON.",h.USAGE)}if(typeof t!="object"||t===null||Array.isArray(t))throw new f("Policy definition must be an object.",h.USAGE);return t}async function Ws(e,t){let n=F(process.cwd(),e.path);await Me(n);let a=await A(n);return{pmRoot:n,settings:a,author:q(t,a.author_default)}}function yi(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
  `)>Ua)throw new f("Policy registry exceeds its byte ceiling.",h.USAGE);return o}async function _i(e,t,n,a){if(n.dryRun)return{policy_result:!0,action:e,changed:!1,result:yi(e,t,await Ee(a.pmRoot),n)};let i=await Fa({pmRoot:a.pmRoot,filePath:Js.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=yi(e,t,za(r),n);return{raw:`${JSON.stringify(o,null,2)}
5
5
  `,result:o}}});return{policy_result:!0,action:e,changed:i.changed,result:i.result}}async function Bs(e,t,n){let a,i=await Ba({...n,id:e,op:"policy_approve",message:t.message,resolveHistoryContext:()=>({workflow_approval:a}),async mutate(r){let o=(await Ee(n.pmRoot)).policies.find(s=>s.id===t.policy);if(!o||o.rule.kind!=="approval")throw new f("--policy must name an approval rule.",h.USAGE);if(!o.rule.authors.includes(n.author))throw new f("This actor is not a declared approver.",h.CONFLICT);return await Ga(n.pmRoot,r.metadata.id),a={policy_id:o.id,policy_fingerprint:wa(o),content_fingerprint:va(o,{...r.metadata,body:r.body})},{changedFields:[]}}});return{policy_result:!0,action:"policy-approve",changed:!0,result:{id:i.item.id,...a,warnings:i.warnings}}}function Hs(e,t){let n=wi(t),a=dn({...n,id:n.id===void 0?e:n.id});if(e!==void 0&&e.trim()!==a.id)throw new f("Policy id operand does not match definition.id.",h.USAGE,{required:"Use the same policy id operand and definition.id, or supply only one of them.",nextSteps:["Omit the policy id operand to use definition.id, or omit definition.id to use the operand."]});return a}async function Qu(e,t,n={},a={}){if(!Et.includes(e))throw new f("Unknown workflow policy action.",h.USAGE);if(e==="policy-presets")return{policy_result:!0,action:e,changed:!1,result:qs()};let i=await Ws(a,n.author);if(e==="policies")return{policy_result:!0,action:e,changed:!1,result:await Ee(i.pmRoot)};if(e==="policy-put"){let l=Hs(t,n.definition);return _i(e,l.id,{...n,definition:l},i)}if(!t?.trim())throw new f(`schema ${e} requires an operand.`,h.USAGE);if(["policy-remove","policy-mode"].includes(e))return _i(e,t,n,i);if(e==="policy-approve"){if(n.dryRun)throw new f("Use policy-check to preview; policy-approve records an approval.",h.USAGE);return Bs(t,n,i)}let r=W(i.settings,J()),o=await Tt(i.pmRoot,t,i.settings.id_prefix,i.settings.item_format,r.type_to_folder);if(!o)throw new f(`Item ${t} not found.`,h.NOT_FOUND);let{document:s}=await Ot(o,{schema:i.settings.schema}),d={...s.metadata,body:s.body},c=n.definition===void 0?d:{...d,...wi(n.definition)};if(c.id!==d.id)throw new f("Policy preview cannot change the item id.",h.USAGE);return{policy_result:!0,action:e,changed:!1,result:await Ja(i.pmRoot,await Ee(i.pmRoot),{operation:"update",author:i.author,before:d,after:c,completeness_only:n.definition===void 0})}}import{createHash as Ri}from"node:crypto";import He from"node:fs/promises";import Ke 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]="68be16cc-4cb4-5df6-90f0-897d4fe82339")}catch{}})();var Ks=new Set(on),Vs=new Set(sn),vi=new Set([...la.filter(e=>e!=="severity"),"id","title","type","status","priority","tags","assignee","parent","description","body","created_at","updated_at","closed_at","completed_at","author","deadline","estimate","sprint","release","risk","confidence","reviewer","resolution","expected","actual"]),Ys=["create","update"];function Si(e){if(typeof e!="string")return"";let t=e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return t.startsWith("--")?t.slice(2):t}function bi(e){return e.replaceAll("_","-")}function Xs(e,t){let n=new Set;for(let a of e){let i=Si(a);i.length>0&&i!==t&&n.add(i)}return[...n].sort((a,i)=>a.localeCompare(i))}function Zs(e){let t=new Set;for(let n of e??[]){let a=n.trim();a.length>0&&t.add(a)}return[...t].sort((n,a)=>n.localeCompare(a))}function Qs(e){let t=new Set,n=[];for(let a of e??[]){let i=a.trim().toLowerCase();if(i.length!==0){if(!Vs.has(i))throw new Error(`Invalid field command "${a}". Allowed: ${sn.join(", ")}.`);t.has(i)||(t.add(i),n.push(i))}}return e===void 0||n.length===0?[...Ys]:n}function Ei(e){let t=I(e.key);if(t.length===0)throw new Error("Field key must not be empty.");if(vi.has(t))throw new Error(`Cannot define custom field "${t}": custom schema field "${t}" collides with built-in item metadata "${t}". Rename the custom field with a project-specific prefix. Reserved fields: ${[...vi].sort((l,p)=>l.localeCompare(p)).join(", ")}.`);let n=typeof e.type=="string"&&e.type.trim().length>0?e.type.trim().toLowerCase():"string";if(!Ks.has(n))throw new Error(`Invalid field type "${e.type}". Allowed: ${on.join(", ")}.`);let a=n,i=Qs(e.commands),r=Si(e.cliFlag),o=r.length>0&&r!==bi(t)?r:void 0,s=o??bi(t),d=Xs(e.aliases??[],s),c=e.description?.trim();return{key:t,type:a,commands:i,description:c&&c.length>0?c:void 0,cliFlag:o,cliAliases:d,required:e.required===!0,requiredOnCreate:e.requiredOnCreate===!0,allowUnset:e.allowUnset!==!1,requiredTypes:Zs(e.requiredTypes)}}function ec(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function tc(e){let t=ec(e);if(!t)return[];let n=[];for(let a of t){if(typeof a!="object"||a===null||Array.isArray(a))continue;let i=a;typeof i.key!="string"||i.key.trim().length===0||n.push(i)}return n}function Ge(e){if(e==null||e.trim().length===0)return{fields:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/fields.json contains invalid JSON.")}return{fields:tc(t)}}function Je(e){return`${JSON.stringify({fields:e.fields},null,2)}
@@ -67,4 +67,4 @@ Agent guidance check
67
67
  `),X.write(`Telemetry helps improve reliability and can be disabled anytime via pm config.
68
68
  `);let d=t?"Y/n":"y/N",c=await n.question(`Enable telemetry for this project? [${d}] `),l=rs(c,t);return X.write(`
69
69
  `),{prefix:i,preset:s,telemetry_enabled:l}}finally{n.close()}}function eu(e){return{presetFromOption:ia(e.preset),useDefaults:e.defaults===!0,authorFromOption:ts(e.author),installBundledPackages:e.withPackages===!0,agentGuidanceMode:is(e.agentGuidance),typePreset:es(e.typePreset)}}function tu(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 nu(e,t,n,a){if(t.length===0||n)return;let i=a.discovery==="ancestor";throw new f(`${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 au(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&&(ra(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 iu(e){let t=await A(e.pmRoot);e.warnings.push(`already_exists:${e.settingsPath}`);let n=tu({settings:t,normalizedPrefix:e.normalizedPrefix,prefixArg:e.prefixArg,presetFromOption:e.normalizedOptions.presetFromOption,authorFromOption:e.normalizedOptions.authorFromOption});return nu(e.settingsPath,n,e.options.force===!0,e.target),au({settings:t,normalizedPrefix:e.normalizedPrefix,prefixArg:e.prefixArg,presetFromOption:e.normalizedOptions.presetFromOption,authorFromOption:e.normalizedOptions.authorFromOption,warnings:e.warnings})&&await xe(e.pmRoot,t),{settings:t,normalizedPrefix:e.normalizedPrefix,chosenPreset:e.normalizedOptions.presetFromOption,wizardUsed:!1}}async function ru(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 d=await ps(t,rn.telemetry.enabled);t=d.prefix,n=d.preset,a=d.telemetry_enabled,i=!0}let r=n??"minimal",o=Xm();o.id_prefix=t,ra(o,r);let s=La()?.trim()||void 0;return o.author_default=e.normalizedOptions.authorFromOption??s??"",a!==void 0&&(o.telemetry.enabled=a,o.telemetry.first_run_prompt_completed=!0),await xe(e.pmRoot,o),{settings:o,normalizedPrefix:t,chosenPreset:n,wizardUsed:i}}async function Yo(e){return e.settingsExists?await iu(e):await ru({pmRoot:e.pmRoot,normalizedPrefix:e.normalizedPrefix,normalizedOptions:e.normalizedOptions})}async function ou(e){let t=await Vo({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 xe(e.pmRoot,e.settings),{...t.summary,next_steps:t.next_steps}}async function su(e,t){let n=[],a=[],i=await ja(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 cu(e){if(e.typePreset===void 0)return;let t=await ss(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 du(e){let t=W(e.settings,J()).folders.filter(a=>!an.includes(a)),n=await ls(e.pmRoot,t);e.createdDirs.push(...n.createdDirs),e.warnings.push(...n.warnings)}function lu(e){let t=j.resolve(e.tracker_root),n=j.dirname(t);return j.basename(t)==="pm"&&j.basename(n)===".agents"?j.dirname(n):e.workspace_root}async function pu(e,t,n,a){if(!e)return;let i=await Vn("all",{install:!0,project:!0},{...t,path:n});a.push(...i.warnings);let r=os(i),o=r.packages.filter(s=>!s.ok).map(s=>s.alias);if(!r.installed_all||o.length>0)throw new f(`pm init --with-packages did not install all bundled packages successfully${o.length>0?`: ${o.join(", ")}`:"."}`,h.GENERIC_FAILURE);return r}function ms(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 us(e,t,n,a=ni){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 f))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 mu(e,t,n,a){if(e==null||n==="status")return;let i=await Qa(e,{pmRoot:t});i.changed&&a.push(`updated:gitignore:${i.path}`)}async function Ww(e,t,n={}){let a=t[Vm],i=typeof a=="string"?a:process.cwd(),r=ns(i,t,e,n.workspace),o=r.pmRoot;e=as(r.prefixArg,n.idPrefix);let s=eu(n);await ds(o,r.target.mode==="tracker-path",n.force===!0);let d=[],c=[],l=j.join(o,"settings.json"),p=await k(l),m;p&&(m=await Yo({pmRoot:o,settingsPath:l,settingsExists:p,normalizedPrefix:Se(e),prefixArg:e,options:n,normalizedOptions:s,warnings:c,target:r.target}));let y=await ls(o,an);d.push(...y.createdDirs),c.push(...y.warnings),m??=await Yo({pmRoot:o,settingsPath:l,settingsExists:p,normalizedPrefix:Se(e),prefixArg:e,options:n,normalizedOptions:s,warnings:c,target:r.target});let{settings:g}=m,_=lu(r.target),u=await ei(_??j.dirname(o)),w=_??u,v=await ou({pmRoot:o,cwd:w??i,agentGuidanceMode:s.agentGuidanceMode,settings:g,warnings:c}),E=await su(o,g);d.push(...E.createdDirs),c.push(...E.warnings);let S=await cu({pmRoot:o,settings:g,typePreset:s.typePreset,warnings:c});S&&(g=await A(o)),await du({pmRoot:o,settings:g,createdDirs:d,warnings:c}),await mu(w,o,s.agentGuidanceMode,c),!p&&n.mergeFence!==!1&&s.agentGuidanceMode!=="status"&&await us(o,u,c);let C=await pu(s.installBundledPackages,t,o,c),te=ms({installBundledPackages:s.installBundledPackages,registeredTypePreset:S,agentGuidanceNextSteps:v.next_steps,target:r.target});return{ok:!0,path:o,target:r.target,settings: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:te,agent_guidance:v}}export{fn as a,Es as b,li as c,_n as d,Ls as e,Fs as f,Ms as g,ui as h,Ol as i,ze as j,Ai as k,qe as l,We as m,Ti as n,Ei as o,Ge as p,Je as q,$i as r,zs as s,Pu as t,ju as u,gi as v,qs as w,Qu as x,Di as y,Mi as z,Tc as A,Oc as B,ny as C,ry as D,oy as E,yt as F,sy as G,cy as H,dy as I,ly as J,py as K,my as L,uy as M,fy as N,hy as O,gy as P,yy as Q,_y as R,wy as S,vy as T,by as U,ky as V,xy as W,Sy as X,Ey as Y,$y as Z,Iy as _,Ay as $,Ty as aa,Oy as ba,Cy as ca,Z as da,b as ea,En as fa,Hc as ga,de as ha,Dt as ia,Cc as ja,rt as ka,jt as la,er as ma,dr as na,Fn as oa,kr as pa,Kh as qa,Br as ra,Zl as sa,ao as ta,io as ua,qn as va,Nr as wa,El as xa,up as ya,jr as za,Vn as Aa,Lo as Ba,ww as Ca,Vo as Da,Vm as Ea,Jw as Fa,qw as Ga,Ww as Ha};
70
- //# sourceMappingURL=chunk-4GD6QOP6.js.map
70
+ //# sourceMappingURL=chunk-7UDQAINZ.js.map
@@ -1,4 +1,4 @@
1
- import{A as h,C as u,G as p}from"./chunk-3CYXE6BV.js";import{readFile as b,realpath as y,stat as _,writeFile as $}from"node:fs/promises";import l from"node:path";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="38df9536-d87a-52ac-958d-091a17c9da9c")}catch{}})();var d="# pm-cli:runtime-cache:start",f="# pm-cli:runtime-cache:end",E=".agents/pm";async function m(n){let e=l.resolve(n),t=[];for(;;)try{let i=await y(e);if(!(await _(i)).isDirectory())throw Object.assign(new Error("Initialization path ancestry must be a directory."),{code:"ENOTDIR"});return l.join(i,...t)}catch(i){if(!p(i)||l.dirname(e)===e)throw i;t.unshift(l.basename(e)),e=l.dirname(e)}}var R=["runtime/","search/","locks/","transactions/","checkpoints/"],T=["search/eval-queries.json"];async function w(n){try{return await n()}catch(e){throw e instanceof Error&&"code"in e&&typeof e.code=="string"&&["EACCES","EPERM","EROFS"].includes(e.code)?new u("The workspace .gitignore is not writable.",h.GENERIC_FAILURE,{code:"init_gitignore_unwritable",reason:e.code.toLowerCase(),required:"Grant the current user read and write access to the workspace .gitignore before initialization.",why:"pm init must publish its managed runtime-cache ignore fence without replacing unrelated entries.",nextSteps:["Grant read and write access to the workspace .gitignore and rerun pm init.","If the workspace is intentionally read-only, initialize pm in a writable workspace or clone."]}):e}}function I(n){let e=n.split(l.sep).join("/").replace(/^\.\/+/,""),t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}function k(n){let e=n.replaceAll("\\","/");return l.isAbsolute(n)||e===".."||e.startsWith("../")}function G(n=E){let e=I(n);if(/[\r\n]/u.test(e))throw new u("A tracker path containing a line break cannot be represented safely in .gitignore.",h.USAGE,{code:"invalid_argument_value",required:"a tracker path without line breaks",nextSteps:["Choose a tracker path without carriage returns or newlines and rerun pm init."]});let t=e.replace(/[\\*?[\]#! \t]/gu,"\\$&");return[d,...R.map(i=>i==="search/"?`${t}/${i}*`:`${t}/${i}`),...T.map(i=>`!${t}/${i}`),f].join(`
1
+ import{A as h,C as u,G as p}from"./chunk-ONC4BBQP.js";import{readFile as b,realpath as y,stat as _,writeFile as $}from"node:fs/promises";import l from"node:path";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="38df9536-d87a-52ac-958d-091a17c9da9c")}catch{}})();var d="# pm-cli:runtime-cache:start",f="# pm-cli:runtime-cache:end",E=".agents/pm";async function m(n){let e=l.resolve(n),t=[];for(;;)try{let i=await y(e);if(!(await _(i)).isDirectory())throw Object.assign(new Error("Initialization path ancestry must be a directory."),{code:"ENOTDIR"});return l.join(i,...t)}catch(i){if(!p(i)||l.dirname(e)===e)throw i;t.unshift(l.basename(e)),e=l.dirname(e)}}var R=["runtime/","search/","locks/","transactions/","checkpoints/"],T=["search/eval-queries.json"];async function w(n){try{return await n()}catch(e){throw e instanceof Error&&"code"in e&&typeof e.code=="string"&&["EACCES","EPERM","EROFS"].includes(e.code)?new u("The workspace .gitignore is not writable.",h.GENERIC_FAILURE,{code:"init_gitignore_unwritable",reason:e.code.toLowerCase(),required:"Grant the current user read and write access to the workspace .gitignore before initialization.",why:"pm init must publish its managed runtime-cache ignore fence without replacing unrelated entries.",nextSteps:["Grant read and write access to the workspace .gitignore and rerun pm init.","If the workspace is intentionally read-only, initialize pm in a writable workspace or clone."]}):e}}function I(n){let e=n.split(l.sep).join("/").replace(/^\.\/+/,""),t=e.length;for(;t>0&&e[t-1]==="/";)t-=1;return e.slice(0,t)}function k(n){let e=n.replaceAll("\\","/");return l.isAbsolute(n)||e===".."||e.startsWith("../")}function G(n=E){let e=I(n);if(/[\r\n]/u.test(e))throw new u("A tracker path containing a line break cannot be represented safely in .gitignore.",h.USAGE,{code:"invalid_argument_value",required:"a tracker path without line breaks",nextSteps:["Choose a tracker path without carriage returns or newlines and rerun pm init."]});let t=e.replace(/[\\*?[\]#! \t]/gu,"\\$&");return[d,...R.map(i=>i==="search/"?`${t}/${i}*`:`${t}/${i}`),...T.map(i=>`!${t}/${i}`),f].join(`
2
2
  `)}function O(n,e,t){let i=e.replace(/[\\*?[\]#! \t]/gu,"\\$&"),o=[...new Set([e,i])].flatMap(s=>R.flatMap(c=>[`${s}/${c}`,`!${s}/${c}`])),a=[],r=!1;for(let s of n)o.some(c=>s.startsWith(c))?(r||a.push(...t),r=!0):a.push(s);return r||a.push(...t),a}function P(n){let e=[],t=-1,i=0,o=0;for(let a of n.split(`
3
3
  `)){let r=a.endsWith("\r")?a.slice(0,-1):a;r===d?(t=o,i=o+a.length+1):r===f&&t>=0&&(e.push({index:t,end:o+r.length,lines:n.slice(i,o).split(/\r?\n/u).filter(s=>s.length>0)}),t=-1),o+=a.length+1}return e}function v(n,e){let t=n.includes(`\r
4
4
  `)?`\r
@@ -6,4 +6,4 @@ import{A as h,C as u,G as p}from"./chunk-3CYXE6BV.js";import{readFile as b,realp
6
6
  `,i=G(e).split(`
7
7
  `).slice(1,-1),o=P(n),a=o.flatMap(c=>c.lines),r=[d,...O(a,e,i),f].join(t);if(o.length===0){let c=n.length===0?"":n.endsWith(`
8
8
  `)?t:`${t}${t}`;return`${n}${c}${r}${t}`}let s=n;for(let[c,g]of[...o.entries()].reverse())s=`${s.slice(0,g.index)}${c===0?r:""}${s.slice(g.end)}`;return s}async function S(n,e={}){let t=l.join(n,".gitignore"),i=E;if(e.pmRoot!==void 0){let r=I(l.relative(await m(n),await m(e.pmRoot)));if(k(r))return{path:t,changed:!1};i=r}let o="";try{o=await w(()=>b(t,"utf8"))}catch(r){if(!(r instanceof Error&&"code"in r&&p(r)))throw r}let a=v(o,i);return a===o?{path:t,changed:!1}:(await w(()=>$(t,a,"utf8")),{path:t,changed:!0})}export{d as a,f as b,R as c,k as d,G as e,S as f};
9
- //# sourceMappingURL=chunk-LNKPH2DD.js.map
9
+ //# sourceMappingURL=chunk-ER7RLJW5.js.map
@@ -1,3 +1,3 @@
1
- import{a as k,c as I,d as A,e as _,k as T,m as C}from"./chunk-XYLBOXSH.js";import{Db as b,Eb as v,Fb as R}from"./chunk-444VPGQT.js";import{Nf as f,Qf as g,Rc as x,Rf as a,gg as w,ze as H}from"./chunk-5ZPT67NJ.js";import{Kf as D,Nf as m,Of as y,Tc as E}from"./chunk-RQKDANP7.js";import{A as c,C as p}from"./chunk-3CYXE6BV.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="631e56aa-4d7e-58b6-bbea-a0d320716b82")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="0bcdd63c-5fd3-585d-a6c5-9393029ef864")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="4dce4f19-071c-54a8-be0d-5975d9e3b34b")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f330a0c5-a967-5383-9c27-efa4a39e0f0d")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="a178bd8b-fc53-5633-84d5-621b61930581")}catch{}})();function O(t,e){if(typeof t!="string")return;let o=Number.parseInt(t,10);if(!/^\d+$/.test(t.trim())||!Number.isSafeInteger(o))throw new p(`history-compact ${e} must be a non-negative integer.`,c.USAGE);return o}async function S(t,e,o){let r=f(o),n=Date.now(),i=await x(a(e,"ids")),l=i===void 0?void 0:H(i),d=O(e.allOver,"--all-over"),u=O(e.minEntries,"--min-entries");if(e.closed===!0&&e.allStreams===!0)throw new p("history-compact: --closed and --all-streams are mutually exclusive; pick one lifecycle scope.",c.USAGE);let s=e.closed===!0?"closed":e.allStreams===!0?"all-streams":void 0;if((l!==void 0||d!==void 0||s!==void 0)&&typeof e.before=="string")throw new p("history-compact: --before applies only in single-id mode (bulk mode always compacts full streams).",c.USAGE);if(I(t,{ids:l,allOver:d,scope:s}),t!==void 0&&u!==void 0)throw new p("history-compact: --min-entries applies only in bulk mode (single-id mode compacts the named stream).",c.USAGE);if(t===void 0){let h=await A({ids:l,scope:s,allOver:d,minEntries:u,dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r),h.totals.items_errored>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let h=await k(t,{before:a(e,"before"),dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r)}r.profile&&y(`profile:command=history-compact took_ms=${Date.now()-n}`)}async function N(t,e,o,r){let n=f(r),i=Date.now(),l=await C(t,e,{author:a(o,"author"),message:a(o,"message"),force:!!o.force},n);await w(n,l),m(l,n),n.profile&&y(`profile:command=restore took_ms=${Date.now()-i}`)}async function B(t,e){let o=f(e),r=await T({verify:a(t,"verify"),output:a(t,"output"),hashAlgorithm:a(t,"hashAlgorithm")},o);"format"in r?(E(r),o.quiet||D(`${JSON.stringify(r,null,2)}
1
+ import{a as k,c as I,d as A,e as _,k as T,m as C}from"./chunk-OCDRHIVQ.js";import{Db as b,Eb as v,Fb as R}from"./chunk-N6FTEILW.js";import{Ae as H,Of as f,Rf as g,Sc as x,Sf as a,hg as w}from"./chunk-VS2IIV3F.js";import{Kf as D,Nf as m,Of as y,Tc as E}from"./chunk-OUDR2HWR.js";import{A as c,C as p}from"./chunk-ONC4BBQP.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="631e56aa-4d7e-58b6-bbea-a0d320716b82")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="0bcdd63c-5fd3-585d-a6c5-9393029ef864")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="4dce4f19-071c-54a8-be0d-5975d9e3b34b")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="f330a0c5-a967-5383-9c27-efa4a39e0f0d")}catch{}})();(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="a178bd8b-fc53-5633-84d5-621b61930581")}catch{}})();function O(t,e){if(typeof t!="string")return;let o=Number.parseInt(t,10);if(!/^\d+$/.test(t.trim())||!Number.isSafeInteger(o))throw new p(`history-compact ${e} must be a non-negative integer.`,c.USAGE);return o}async function S(t,e,o){let r=f(o),n=Date.now(),i=await x(a(e,"ids")),l=i===void 0?void 0:H(i),d=O(e.allOver,"--all-over"),u=O(e.minEntries,"--min-entries");if(e.closed===!0&&e.allStreams===!0)throw new p("history-compact: --closed and --all-streams are mutually exclusive; pick one lifecycle scope.",c.USAGE);let s=e.closed===!0?"closed":e.allStreams===!0?"all-streams":void 0;if((l!==void 0||d!==void 0||s!==void 0)&&typeof e.before=="string")throw new p("history-compact: --before applies only in single-id mode (bulk mode always compacts full streams).",c.USAGE);if(I(t,{ids:l,allOver:d,scope:s}),t!==void 0&&u!==void 0)throw new p("history-compact: --min-entries applies only in bulk mode (single-id mode compacts the named stream).",c.USAGE);if(t===void 0){let h=await A({ids:l,scope:s,allOver:d,minEntries:u,dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r),h.totals.items_errored>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let h=await k(t,{before:a(e,"before"),dryRun:e.dryRun===!0,author:a(e,"author"),message:a(e,"message"),force:!!e.force},r);m(h,r)}r.profile&&y(`profile:command=history-compact took_ms=${Date.now()-n}`)}async function N(t,e,o,r){let n=f(r),i=Date.now(),l=await C(t,e,{author:a(o,"author"),message:a(o,"message"),force:!!o.force},n);await w(n,l),m(l,n),n.profile&&y(`profile:command=restore took_ms=${Date.now()-i}`)}async function B(t,e){let o=f(e),r=await T({verify:a(t,"verify"),output:a(t,"output"),hashAlgorithm:a(t,"hashAlgorithm")},o);"format"in r?(E(r),o.quiet||D(`${JSON.stringify(r,null,2)}
2
2
  `)):m(r,o),"ok"in r&&!r.ok&&(process.exitCode=c.GENERIC_FAILURE)}function Z(t,e){t.command(e?"attest":"history-attest",{hidden:!e}).summary("Export or verify history proof.").option("--verify <file>","Compare retained streams with a detached JSON proof").option("--output <file>","Create a proof file and return a compact receipt").option("--hash-algorithm <name>","Bundle digest algorithm: sha256 (default) or sha512").description("Export exact-byte history commitments, or verify an independently retained proof without tracker writes.").action(B),t.command("restore",{hidden:!e}).summary("Restore a version.").argument("<id>","Item id").argument("<target>","Restore target timestamp or version number").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership/lock override").description("Restore an item to an earlier timestamp or version.").action(N),t.command(e?"redact":"history-redact",{hidden:!e}).summary("Redact sensitive values.").argument("<id>","Item id").option("--literal <value>","Literal string to redact (repeatable)",g).option("--regex <value>","Regex pattern to redact (repeatable; accepts /pattern/flags or raw pattern)",g).option("--replacement <value>",'Replacement string (default: "[redacted]")').option("--dry-run","Preview redaction impact without writing item/history files").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the redaction marker entry").option("--force","Force ownership/lock override").description("Redact sensitive literals/patterns from an item history stream and recompute hashes.").action(async(o,r,n)=>{let i=f(n),l=Date.now(),d=Array.isArray(r.literal)?r.literal:void 0,u=Array.isArray(r.regex)?r.regex:void 0,s=await _(o,{literal:d,regex:u,replacement:a(r,"replacement"),dryRun:r.dryRun===!0,author:a(r,"author"),message:a(r,"message"),force:!!r.force},i);s.changed&&!s.dry_run&&await w(i,s),m(s,i),i.profile&&y(`profile:command=history-redact took_ms=${Date.now()-l}`)}),t.command(e?"repair":"history-repair",{hidden:!e}).summary("Repair drift.").argument("[id]","Item id (omit with --all)").option("--salvage-tail","Recover invalid tail; requires verified prefix").option("--all","Scan every stream for drift and repair each drifted stream in one audited pass").option("--dry-run","Preview the re-anchor impact without writing the history file").option("--normalize-provenance","Remove invalid provenance; return aggregate-only evidence").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the repair marker entry").option("--force","Force ownership/lock override").description("Re-anchor a drifted item history chain (recompute hashes, reconcile with the on-disk item) and record an audit marker. Use --all to repair every drifted stream.").action(async(o,r,n)=>{let i=f(n),l=Date.now(),d=r.all===!0;v(o,d);let u={dryRun:r.dryRun===!0,author:a(r,"author"),message:a(r,"message"),force:!!r.force,normalizeProvenance:r.normalizeProvenance===!0,salvageTail:r.salvageTail===!0};if(d){let s=await R(u,i);m(s,i),s.totals.failed>0&&(process.exitCode=c.GENERIC_FAILURE)}else{let s=await b(o,u,i);m(s,i)}i.profile&&y(`profile:command=history-repair took_ms=${Date.now()-l}`)}),t.command(e?"compact":"history-compact",{hidden:!e}).summary("Compact streams.").argument("[id]","Item id (omit when using a bulk selector)").option("--before <value>","Compact entries strictly before this version number or ISO timestamp (single-id mode only)").option("--ids <value>","Bulk IDs: comma/newline text, - stdin, or @path file").option("--all-over <n>","Bulk: compact every stream with more than N entries").option("--closed","Bulk: compact only closed (terminal) items' streams").option("--all-streams","Bulk: compact every history stream regardless of lifecycle state").option("--min-entries <n>","Bulk: skip streams with at most N entries (already compact; default 3)").option("--dry-run","Preview compaction impact without writing the history file").option("--author <value>","Mutation author").option("--message <value>","Audit history message for the compaction marker entry").option("--force","Force ownership/lock override").description("Compact item history streams into a synthetic baseline plus retained tail entries. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to compact many.").action(S)}export{Z as a};
3
- //# sourceMappingURL=chunk-YCCGZHOR.js.map
3
+ //# sourceMappingURL=chunk-MWCG25PO.js.map