@unbrained/pm-cli 2026.11.26 → 2026.11.28

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 (185) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/dist/cli-bundle/bundle-manifest.json +1 -1
  3. package/dist/cli-bundle/chunks/{chunk-BITDGTAX.js → chunk-2YD2AERA.js} +2 -2
  4. package/dist/cli-bundle/chunks/chunk-54AQJTUH.js +3 -0
  5. package/dist/cli-bundle/chunks/chunk-56DKWGHE.js +2 -0
  6. package/dist/cli-bundle/chunks/chunk-56GUDMXN.js +113 -0
  7. package/dist/cli-bundle/chunks/chunk-5ECCMDSU.js +2 -0
  8. package/dist/cli-bundle/chunks/chunk-6RBD2AKU.js +2 -0
  9. package/dist/cli-bundle/chunks/{chunk-PQSEEVOA.js → chunk-C4O5TZY3.js} +46 -46
  10. package/dist/cli-bundle/chunks/chunk-CATRDGAB.js +125 -0
  11. package/dist/cli-bundle/chunks/{chunk-5FY2VHRF.js → chunk-CDUV7DFD.js} +2 -2
  12. package/dist/cli-bundle/chunks/chunk-CTM26LUE.js +4 -0
  13. package/dist/cli-bundle/chunks/chunk-D3I5AHNN.js +2 -0
  14. package/dist/cli-bundle/chunks/chunk-E2LQ6LCJ.js +2 -0
  15. package/dist/cli-bundle/chunks/{chunk-B2GM6KOM.js → chunk-FG4TNQQM.js} +2 -2
  16. package/dist/cli-bundle/chunks/chunk-JQYPSABI.js +2 -0
  17. package/dist/cli-bundle/chunks/chunk-LMDIKSDZ.js +9 -0
  18. package/dist/cli-bundle/chunks/chunk-LRGYV6QQ.js +2 -0
  19. package/dist/cli-bundle/chunks/chunk-MO6PPUI6.js +2 -0
  20. package/dist/cli-bundle/chunks/chunk-O2SWNEBW.js +8 -0
  21. package/dist/cli-bundle/chunks/{chunk-5AAIRHNE.js → chunk-O2WNNIKK.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-LNZKNVMT.js → chunk-OFIYA3PI.js} +3 -3
  23. package/dist/cli-bundle/chunks/{chunk-DYL2N3OC.js → chunk-Q6BGQRCB.js} +2 -2
  24. package/dist/cli-bundle/chunks/chunk-RGE3XW3A.js +2 -0
  25. package/dist/cli-bundle/chunks/chunk-SP6CDM6B.js +31 -0
  26. package/dist/cli-bundle/chunks/{chunk-T3GJPXIZ.js → chunk-T7RZPIOB.js} +14 -14
  27. package/dist/cli-bundle/chunks/{chunk-MNFCJNQA.js → chunk-T7UTG56V.js} +4 -4
  28. package/dist/cli-bundle/chunks/chunk-TWRUA2NH.js +3 -0
  29. package/dist/cli-bundle/chunks/chunk-WKDKBS4P.js +4 -0
  30. package/dist/cli-bundle/chunks/chunk-YEMFOKFG.js +2 -0
  31. package/dist/cli-bundle/chunks/{chunk-ZDL45VTB.js → chunk-YLS2N4SN.js} +2 -2
  32. package/dist/cli-bundle/chunks/{chunk-FWBR3OW7.js → chunk-ZXERHBMA.js} +2 -2
  33. package/dist/cli-bundle/chunks/field-definition-losses-JFMMMVTV.js +2 -0
  34. package/dist/cli-bundle/chunks/field-option-collisions-G4LQ2646.js +2 -0
  35. package/dist/cli-bundle/{focused-chunks/item-revision-RPTXN7WW.js → chunks/item-revision-O7L3AA2W.js} +2 -2
  36. package/dist/cli-bundle/chunks/item-transaction-4XC74ULD.js +2 -0
  37. package/dist/cli-bundle/chunks/mutation-actor-A45DFDEO.js +2 -0
  38. package/dist/cli-bundle/chunks/mutation-admission-SIUIMAEO.js +2 -0
  39. package/dist/cli-bundle/chunks/{register-list-query-EKSCZWEZ.js → register-list-query-FCPGG2UT.js} +2 -2
  40. package/dist/cli-bundle/chunks/{register-mutation-ZIAOKKUJ.js → register-mutation-VD3JX23I.js} +2 -2
  41. package/dist/cli-bundle/chunks/register-operations-KHJD4GFZ.js +2 -0
  42. package/dist/cli-bundle/chunks/register-setup-EWAZZWPL.js +2 -0
  43. package/dist/cli-bundle/chunks/runtime-schema-3RAXYNG5.js +2 -0
  44. package/dist/cli-bundle/chunks/{settlement-hook-ESAAEBRM.js → settlement-hook-KWBOSRDZ.js} +2 -2
  45. package/dist/cli-bundle/chunks/stage-UIDZMTE5.js +2 -0
  46. package/dist/cli-bundle/focused-chunks/chunk-5MZXU6HB.js +2 -0
  47. package/dist/cli-bundle/focused-chunks/chunk-64DSKZJN.js +100 -0
  48. package/dist/cli-bundle/focused-chunks/{chunk-YSZZSV6M.js → chunk-7EKKUYN5.js} +2 -2
  49. package/dist/cli-bundle/focused-chunks/chunk-7P6OGPEG.js +2 -0
  50. package/dist/cli-bundle/focused-chunks/chunk-A5B43EWU.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/chunk-AHCOSTL7.js +2 -0
  52. package/dist/cli-bundle/focused-chunks/chunk-CQLOYNJY.js +2 -0
  53. package/dist/cli-bundle/focused-chunks/chunk-E4C6T3NL.js +2 -0
  54. package/dist/cli-bundle/focused-chunks/{chunk-3GQRWIT5.js → chunk-HCWDMFWA.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-GQBWI4KA.js → chunk-J4V3J5MC.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/chunk-JD45Y2BR.js +91 -0
  57. package/dist/cli-bundle/focused-chunks/chunk-KMGI5GZP.js +2 -0
  58. package/dist/cli-bundle/focused-chunks/chunk-MSLRDKWL.js +4 -0
  59. package/dist/cli-bundle/focused-chunks/chunk-O33WUEAF.js +3 -0
  60. package/dist/cli-bundle/focused-chunks/{chunk-QNWNUQSJ.js → chunk-OEMI52ZS.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-AAB3ZR7Z.js → chunk-Q6JCMFGU.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/chunk-RBOWKXFV.js +8 -0
  63. package/dist/cli-bundle/focused-chunks/chunk-TF57RHS2.js +2 -0
  64. package/dist/cli-bundle/focused-chunks/{chunk-TNVLDU7Z.js → chunk-VNU3IFBL.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/chunk-X5ZVPFK7.js +4 -0
  66. package/dist/cli-bundle/focused-chunks/chunk-XVCMYFQU.js +27 -0
  67. package/dist/cli-bundle/focused-chunks/{chunk-RDELKGLS.js → chunk-Y7EC2L2G.js} +3 -3
  68. package/dist/cli-bundle/focused-chunks/{chunk-FQWKESMI.js → chunk-YC3PFFDE.js} +56 -56
  69. package/dist/cli-bundle/focused-chunks/{chunk-QSRXF6XS.js → chunk-YX75PQFO.js} +2 -2
  70. package/dist/cli-bundle/focused-chunks/{chunk-KEZ4VXYD.js → chunk-Z4FWJGQG.js} +2 -2
  71. package/dist/cli-bundle/focused-chunks/chunk-ZHHFOQSL.js +44 -0
  72. package/dist/cli-bundle/focused-chunks/chunk-ZUAPUBJK.js +2 -0
  73. package/dist/cli-bundle/focused-chunks/{chunk-NXUFVQ33.js → chunk-ZYHGQIQ7.js} +2 -2
  74. package/dist/cli-bundle/focused-chunks/field-definition-losses-NUZO3JCP.js +2 -0
  75. package/dist/cli-bundle/focused-chunks/field-option-collisions-63YQ2J3N.js +2 -0
  76. package/dist/cli-bundle/focused-chunks/item-revision-PV5O6F5Y.js +2 -0
  77. package/dist/cli-bundle/focused-chunks/item-transaction-S5QXBGAT.js +2 -0
  78. package/dist/cli-bundle/{chunks/mutation-actor-HGG47KXV.js → focused-chunks/mutation-actor-2AAUJG2Z.js} +2 -2
  79. package/dist/cli-bundle/focused-chunks/mutation-admission-X7HHNERR.js +2 -0
  80. package/dist/cli-bundle/focused-chunks/runtime-schema-5J2ONRNV.js +2 -0
  81. package/dist/cli-bundle/focused-chunks/stage-56RYPMBK.js +2 -0
  82. package/dist/cli-bundle/main.js +2 -2
  83. package/dist/cli-bundle/sdk-authoring.js +1 -1
  84. package/dist/cli-bundle/sdk-contracts.js +1 -1
  85. package/dist/cli-bundle/sdk-core.js +1 -1
  86. package/dist/cli-bundle/sdk-governance.js +1 -1
  87. package/dist/cli-bundle/sdk-graph.js +1 -1
  88. package/dist/cli-bundle/sdk-merge.js +63 -63
  89. package/dist/cli-bundle/sdk-query.js +1 -1
  90. package/dist/cli-bundle/sdk-runtime.js +1 -1
  91. package/dist/cli-bundle/sdk-testing.js +1 -1
  92. package/dist/cli-bundle/sdk.js +2 -2
  93. package/dist/core/extensions/index.js +1 -1
  94. package/dist/core/extensions/item-fields.d.ts +15 -1
  95. package/dist/core/extensions/item-fields.js +1 -1
  96. package/dist/core/extensions/loader.js +1 -1
  97. package/dist/core/profile/profile-lint.js +1 -1
  98. package/dist/core/schema/runtime-schema.d.ts +20 -1
  99. package/dist/core/schema/runtime-schema.js +2 -2
  100. package/dist/core/shared/command-line.d.ts +2 -2
  101. package/dist/core/shared/command-line.js +1 -1
  102. package/dist/core/shared/secret-rules.js +5 -5
  103. package/dist/sdk/agent/refusal-reachability.d.ts +1 -1
  104. package/dist/sdk/extension/command-options.d.ts +8 -0
  105. package/dist/sdk/extension/command-options.js +1 -1
  106. package/dist/sdk/extension-command-context.js +2 -2
  107. package/dist/sdk/governance/validate.js +1 -1
  108. package/dist/sdk/lifecycle/create.js +1 -1
  109. package/dist/sdk/lifecycle/update.js +2 -2
  110. package/dist/sdk/profile.js +1 -1
  111. package/dist/sdk/read-output-contracts.js +1 -1
  112. package/dist/sdk/schema/field-definition-losses.js +2 -0
  113. package/dist/sdk/schema/field-option-collisions.js +1 -1
  114. package/dist/sdk/schema.js +2 -2
  115. package/docs/COMMANDS.md +1 -1
  116. package/docs/CONFIGURATION.md +3 -1
  117. package/docs/EXTENSIONS.md +1 -1
  118. package/docs/MUTATION_INTEGRITY.md +47 -0
  119. package/docs/SDK.md +3 -1
  120. package/docs/SDK_AUDITED_MUTATIONS.md +12 -3
  121. package/marketplace.json +1 -1
  122. package/package.json +1 -1
  123. package/packages/pm-beads/package.json +1 -1
  124. package/packages/pm-calendar/package.json +1 -1
  125. package/packages/pm-command-kit/package.json +1 -1
  126. package/packages/pm-digital-twin/package.json +1 -1
  127. package/packages/pm-governance-audit/package.json +1 -1
  128. package/packages/pm-guide-shell/package.json +1 -1
  129. package/packages/pm-kanban/package.json +1 -1
  130. package/packages/pm-lifecycle-hooks/package.json +1 -1
  131. package/packages/pm-linked-test-adapters/package.json +1 -1
  132. package/packages/pm-search-advanced/package.json +1 -1
  133. package/packages/pm-templates/package.json +1 -1
  134. package/packages/pm-todos/package.json +1 -1
  135. package/packages/pm-vcs/package.json +1 -1
  136. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  137. package/plugins/pm-claude/package.json +1 -1
  138. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  139. package/plugins/pm-codex/package.json +1 -1
  140. package/plugins/pm-codex/plugin.json +1 -1
  141. package/runtime-dependencies.json +1 -1
  142. package/dist/cli-bundle/chunks/chunk-5BPDT7G2.js +0 -2
  143. package/dist/cli-bundle/chunks/chunk-7F3UFYZA.js +0 -2
  144. package/dist/cli-bundle/chunks/chunk-CBBKXTJG.js +0 -2
  145. package/dist/cli-bundle/chunks/chunk-DUJSME77.js +0 -3
  146. package/dist/cli-bundle/chunks/chunk-GQXK4KKH.js +0 -31
  147. package/dist/cli-bundle/chunks/chunk-HOLQZ56F.js +0 -8
  148. package/dist/cli-bundle/chunks/chunk-HTGN24XM.js +0 -3
  149. package/dist/cli-bundle/chunks/chunk-IGW3RVJC.js +0 -3
  150. package/dist/cli-bundle/chunks/chunk-KCRRTJ4X.js +0 -125
  151. package/dist/cli-bundle/chunks/chunk-KES4VHU4.js +0 -2
  152. package/dist/cli-bundle/chunks/chunk-NDS4MXZX.js +0 -2
  153. package/dist/cli-bundle/chunks/chunk-QMM46SJM.js +0 -4
  154. package/dist/cli-bundle/chunks/chunk-RFK3ERYX.js +0 -2
  155. package/dist/cli-bundle/chunks/chunk-SX76UGEY.js +0 -3
  156. package/dist/cli-bundle/chunks/chunk-WZOJSHJT.js +0 -113
  157. package/dist/cli-bundle/chunks/chunk-XRCE4QNL.js +0 -9
  158. package/dist/cli-bundle/chunks/field-option-collisions-CGRJEAPQ.js +0 -2
  159. package/dist/cli-bundle/chunks/item-revision-FGDR5NSF.js +0 -2
  160. package/dist/cli-bundle/chunks/item-transaction-C3KAMEYO.js +0 -2
  161. package/dist/cli-bundle/chunks/mutation-admission-LLHIRY6O.js +0 -2
  162. package/dist/cli-bundle/chunks/register-operations-ECVBZ5FM.js +0 -2
  163. package/dist/cli-bundle/chunks/register-setup-3QYD5H4H.js +0 -2
  164. package/dist/cli-bundle/chunks/runtime-schema-Y4SHTEXL.js +0 -2
  165. package/dist/cli-bundle/chunks/stage-RSCSUYEJ.js +0 -2
  166. package/dist/cli-bundle/focused-chunks/chunk-3BR5NWQI.js +0 -2
  167. package/dist/cli-bundle/focused-chunks/chunk-AVLB4L7M.js +0 -44
  168. package/dist/cli-bundle/focused-chunks/chunk-FW5Q26HA.js +0 -2
  169. package/dist/cli-bundle/focused-chunks/chunk-IWEGGRRD.js +0 -2
  170. package/dist/cli-bundle/focused-chunks/chunk-JUG3BAZZ.js +0 -2
  171. package/dist/cli-bundle/focused-chunks/chunk-NSFS3VWP.js +0 -100
  172. package/dist/cli-bundle/focused-chunks/chunk-OCKKIECS.js +0 -3
  173. package/dist/cli-bundle/focused-chunks/chunk-R6QFPHWW.js +0 -3
  174. package/dist/cli-bundle/focused-chunks/chunk-RFJ3MEFP.js +0 -27
  175. package/dist/cli-bundle/focused-chunks/chunk-RMJKVQYE.js +0 -3
  176. package/dist/cli-bundle/focused-chunks/chunk-UA2JNKMY.js +0 -4
  177. package/dist/cli-bundle/focused-chunks/chunk-VV2QF5IE.js +0 -91
  178. package/dist/cli-bundle/focused-chunks/chunk-WHHFPATO.js +0 -8
  179. package/dist/cli-bundle/focused-chunks/chunk-YNRW2FWB.js +0 -2
  180. package/dist/cli-bundle/focused-chunks/field-option-collisions-WV6GPYYP.js +0 -2
  181. package/dist/cli-bundle/focused-chunks/item-transaction-A6MVNPT7.js +0 -2
  182. package/dist/cli-bundle/focused-chunks/mutation-actor-6ZVW6OME.js +0 -2
  183. package/dist/cli-bundle/focused-chunks/mutation-admission-2DA4CINP.js +0 -2
  184. package/dist/cli-bundle/focused-chunks/runtime-schema-YXPYDD2C.js +0 -2
  185. package/dist/cli-bundle/focused-chunks/stage-RG3PKST7.js +0 -2
@@ -1,9 +0,0 @@
1
- import{Cc as pt,Gc as ht,Ic as V,Mb as D,O as st,Oh as yt,Sh as kt,Tf as oe,Uf as ie,ca as ct,cb as ut,ea as B,eb as _t,nc as ft,sc as F,zc as mt}from"./chunk-WZOJSHJT.js";import{Q as ee,a as N,b as P,d as p,x as lt}from"./chunk-DUJSME77.js";import{F as te,J as ne,K as re,N as dt,d as et,e as tt,f as nt,g as rt,m as ot,r as it,z as at}from"./chunk-SX76UGEY.js";import{A as v,C as x,E as Qe,F as le,H as I,I as Ze,J as Te,K as Z,v as Xe,y as u,z as Q}from"./chunk-6OIHST4I.js";import wt from"node:fs/promises";import G from"node:path";var R="_workspace";function W(e){return G.join(e,"history",`${R}.jsonl`)}function Ce(e,t){return{metadata:{id:R,title:"Workspace state",description:"Audited singleton workspace document state.",type:"Chore",status:"open",priority:2,tags:["workspace-history"],created_at:t,updated_at:t,documents:e},body:""}}function U(e,t=e.length){let n=mt();for(let r of e.slice(0,t))n=ht(n,r.patch).document;return pt(n)}function K(e){return"documents"in e.metadata&&typeof e.metadata.documents=="object"&&e.metadata.documents!==null&&!Array.isArray(e.metadata.documents)?e.metadata.documents:{}}function J(e){throw new x(`Workspace history verification failed: ${e.join(", ")}`,v.CONFLICT,{code:"workspace_history_chain_invalid",reason:"workspace_history_chain_verification_failed",verification_errors:[...e],required:"Repair the _workspace history chain before reading, reconciling, restoring, or appending audited singleton state.",why:"Continuing against an unverifiable append-only stream could hide or compound workspace state corruption.",examples:["pm history _workspace --verify --json","pm validate --check-history-drift --fix-hints --json"],nextSteps:["Inspect the exact verification_errors and preserve the corrupt stream as evidence.","Use the history-drift remediation returned by validate before retrying the refused operation."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify --json"}})}function de(e,t){let n=G.resolve(t),r=G.relative(e,n).replaceAll("\\","/");if(r.length===0||r===".."||r.startsWith("../")||G.isAbsolute(r))throw new TypeError("Workspace history document path must stay inside the tracker root");return{documentPath:r,absolutePath:n}}async function Jr(e){let t=await F(W(e),R),n=V(t);n.ok||J(n.errors);let r=K(t.length===0?Q:U(t)),i=[],a=[],s=[],l=[];for(let _ of Object.keys(r).sort()){let f;try{let w=de(e,G.resolve(e,_));if(f=await I(w.absolutePath),f===null){s.push(_);continue}let g=JSON.parse(f);(N(g)===N(r[_])?i:a).push(_)}catch{l.push(_)}}return{ok:a.length===0&&s.length===0&&l.length===0,document_count:Object.keys(r).length,matching_documents:i,mismatched_documents:a,missing_documents:s,unreadable_documents:l}}async function gt(e){let t=W(e.pmRoot),n=await F(t,R),r=V(n);r.ok||J(r.errors);let i=e.idempotencyKey===void 0?void 0:n.find(g=>g.op===`${e.op}:${e.idempotencyKey}`);if(i)return{entry:i,historyPath:t};let a=ee(),s=n.length===0?Q:U(n),l=K(s),_=l[e.documentPath];if(_!==void 0&&N(_)!==N(e.before))throw new x(`Workspace history state for "${e.documentPath}" changed outside the audited mutation path.`,v.CONFLICT,{code:"workspace_history_state_conflict",reason:"out_of_band_workspace_state",required:"Reconcile the singleton document with its matching _workspace history state before retrying the mutation.",why:"Accepting the write would make the append-only audit stream describe a state that was not actually observed.",examples:["pm history _workspace --verify","pm validate --check-history-drift --fix-hints"],nextSteps:["Review the version-control change that altered the singleton and preserve the intended document plus its matching workspace history.","Rerun the original mutation only after the on-disk singleton agrees with the latest audited workspace state."],recovery:{recovery_mode:"compact",next_best_command:"pm history _workspace --verify"}});let f=Ce({...l,[e.documentPath]:e.after},n.length===0?a:s.metadata.created_at),w=oe({nowIso:a,author:e.author,op:e.idempotencyKey===void 0?e.op:`${e.op}:${e.idempotencyKey}`,before:s,after:f,message:e.message});return await ie(t,w),{entry:w,historyPath:t}}async function Yr(e){let t=await D(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await gt(e)}finally{await t()}}async function Xr(e){let t=await D(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let n=W(e.pmRoot),r=await F(n,R),i=V(r);i.ok||J(i.errors);let a=r.length===0?Q:U(r),s=oe({nowIso:ee(),author:e.author,op:e.op,before:a,after:a,message:e.message,context:e.context});return await ie(n,s),{entry:s,historyPath:n}}finally{await t()}}async function bt(e,t){if(t===e.raw)return!1;let n=t===null?null:JSON.parse(t),r=JSON.parse(e.raw);await Z(e.filePath,e.raw);try{(t!==null||e.recordCreation!==!1)&&await gt({pmRoot:e.pmRoot,documentPath:G.relative(e.pmRoot,e.filePath).replaceAll("\\","/"),before:n,after:r,op:e.op,idempotencyKey:e.idempotencyKey,author:e.author,lockTtlSeconds:e.lockTtlSeconds,lockWaitMs:e.lockWaitMs,message:e.message})}catch(i){throw t===null?await wt.rm(e.filePath,{force:!0}):await Z(e.filePath,t),i}return!0}async function vt(e){let{documentPath:t}=de(e.pmRoot,e.filePath),n=await D(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let r=await I(e.filePath);if(e.dryRun===!0||e.idempotencyKey!==void 0){let a=await F(W(e.pmRoot),R),s=V(a);s.ok||J(s.errors);let l=K(a.length===0?Q:U(a))[t];if(l!==void 0&&N(l)!==N(r===null?null:JSON.parse(r)))throw new x(`Workspace history state for "${t}" changed outside the audited mutation path.`,v.CONFLICT,{code:"workspace_history_state_conflict"});if(e.idempotencyKey!==void 0&&a.some(_=>_.op===`${e.op}:${e.idempotencyKey}`))return{changed:!1,result:void 0,replayed:!0}}let i=await e.mutate(r);return JSON.parse(i.raw),e.dryRun===!0?{changed:r!==i.raw,result:i.result}:{changed:await bt({...e,raw:i.raw},r),result:i.result}}finally{await n()}}async function Qr(e){let t=await D(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{return await bt(e,await I(e.filePath))}finally{await t()}}async function Zr(e){let t=e.authorizationDecision.trim();if(!t)throw new TypeError("Workspace history reconciliation requires an authorization decision");let n=await D(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let{documentPath:r,absolutePath:i}=de(e.pmRoot,e.filePath),a=W(e.pmRoot),s=await F(a,R),l=V(s);l.ok||J(l.errors);let _=U(s),f=K(_);if(!Object.hasOwn(f,r))throw new TypeError(`Workspace history does not govern document ${r}`);let w=await I(i);if(w===null)throw new TypeError(`Workspace history document is missing: ${r}`);let g=JSON.parse(w);if(N(f[r])===N(g))return{changed:!1,historyPath:a};let S=ee(),X=oe({nowIso:S,author:e.author,op:e.op,before:_,after:Ce({...f,[r]:g},_.metadata.created_at),message:e.message,context:{reason:"out_of_band_workspace_state_reconciliation",document_path:r,authorization_decision:t}});return await ie(a,X),{changed:!0,entry:X,historyPath:a}}finally{await n()}}async function eo(e){let t=await D(e.pmRoot,"workspace-history",e.lockTtlSeconds,e.author,!1,!1,e.lockWaitMs);try{let{documentPath:n,absolutePath:r}=de(e.pmRoot,e.filePath),i=await F(W(e.pmRoot),R),a=V(i);if(a.ok||J(a.errors),!Number.isInteger(e.targetVersion)||e.targetVersion<1||e.targetVersion>i.length)throw new TypeError(`Invalid workspace history target version: ${String(e.targetVersion)}`);let s=K(U(i,e.targetVersion))[n];if(s===void 0)throw new TypeError(`Workspace history version ${e.targetVersion} does not contain ${n}`);let l=await I(r),_=`${JSON.stringify(s,null,2)}
2
- `;if(l===_)return{document_path:n,restored_from_version:e.targetVersion,changed:!1};let f=U(i),w=ee(),g=oe({nowIso:w,author:e.author,op:e.op,before:f,after:Ce({...K(f),[n]:s},f.metadata.created_at),message:e.message,context:{reason:"workspace_state_restore",document_path:n,restored_from_version:e.targetVersion,replaced_out_of_band_state:!0}});await Z(r,_);try{await ie(W(e.pmRoot),g)}catch(S){throw l===null?await wt.rm(r,{force:!0}):await Z(r,l),S}return{document_path:n,restored_from_version:e.targetVersion,changed:!0}}finally{await t()}}var O={ok:!1,path:[]};function Pe(e,t){return{ok:!1,path:[e,...t.path]}}var c=e=>typeof e=="string"?{ok:!0,value:e}:O,h=e=>typeof e=="boolean"?{ok:!0,value:e}:O;function k(e={}){return t=>typeof t!="number"||!Number.isFinite(t)||e.int&&(!Number.isInteger(t)||!Number.isSafeInteger(t))||e.positive&&t<=0||typeof e.min=="number"&&t<e.min||typeof e.max=="number"&&t>e.max?O:{ok:!0,value:t}}function y(...e){return t=>typeof t=="string"&&e.includes(t)?{ok:!0,value:t}:O}function d(e,t){return n=>{if(!Array.isArray(n)||t!==void 0&&n.length>t)return O;let r=[];for(let[i,a]of n.entries()){let s=e(a);if(!s.ok)return Pe(String(i),s);r.push(s.value)}return{ok:!0,value:r}}}function je(e,t){return n=>typeof n=="string"&&n.length>0&&n.length<=e&&n===n.trim()&&(t===void 0||t.test(n))?{ok:!0,value:n}:O}function o(e){return t=>t===void 0?{ok:!0,value:void 0}:e(t)}function ue(e){return t=>{if(typeof t!="object"||t===null||Array.isArray(t))return O;let n={};for(let[r,i]of Object.entries(t)){let a=e(i);if(!a.ok)return Pe(r,a);n[r]=a.value}return{ok:!0,value:n}}}function m(e){return t=>{if(typeof t!="object"||t===null||Array.isArray(t))return O;let n=t,r={};for(let[i,a]of Object.entries(e)){let s=a(n[i]);if(!s.ok)return Pe(i,s);s.value!==void 0&&(r[i]=s.value)}return{ok:!0,value:r}}}var mn=m({key:c,values:d(c),required:o(h),aliases:o(d(c)),description:o(c)}),pn=m({command:y("create","update"),option:c,required:o(h),visible:o(h),enabled:o(h)}),hn=m({name:c,description:o(c),default_status:o(c),execution_role:o(y("agent","human","gate")),folder:o(c),aliases:o(d(c)),required_create_fields:o(d(c)),required_create_repeatables:o(d(c)),options:o(d(mn)),command_option_policies:o(d(pn))}),yn=m({id:c,aliases:o(d(c)),roles:o(d(y(...et))),description:o(c),order:o(k())}),kn=m({key:c,metadata_key:o(c),front_matter_key:o(c),cli_flag:o(c),cli_aliases:o(d(c)),description:o(c),type:o(y(...tt)),commands:o(d(y(...nt))),repeatable:o(h),required:o(h),required_on_create:o(h),required_types:o(d(c)),allow_unset:o(h)}),wn=e=>{if(!Array.isArray(e)||e.length!==2)return O;let[t,n]=e;return typeof t!="string"||typeof n!="string"?O:{ok:!0,value:[t,n]}},gn=m({type:c,allowed_transitions:d(wn)}),bn=o(m({version:o(k({int:!0})),files:o(m({types:o(c),statuses:o(c),fields:o(c),workflows:o(c)})),statuses:o(d(yn)),fields:o(d(kn)),workflow:o(m({draft_status:o(c),open_status:o(c),in_progress_status:o(c),blocked_status:o(c),close_status:o(c),canceled_status:o(c)})),type_workflows:o(d(gn)),unknown_field_policy:o(y(...rt))})),vn=o(m({preset:o(y(...ot)),ownership_enforcement:o(y("none","warn","strict")),create_mode_default:o(y("progressive","strict")),close_validation_default:o(y("off","warn","strict")),require_close_reason:o(h),parent_reference:o(y("warn","strict_error")),metadata_profile:o(y("core","strict","custom")),force_required_for_stale_lock:o(h),create_default_type:o(c),workflow_enforcement:o(y("off","warn","strict")),start_blocker_enforcement:o(y("off","warn","strict")),duplicate_detection_mode:o(y("off","advisory","strict")),duplicate_detection_threshold:o(k({min:0,max:1})),duplicate_detection_limit:o(k({int:!0,min:0,max:20}))})),xn=m({name:c,disabled:o(h),require_trusted:o(h),require_provenance:o(h),sandbox_profile:o(y("none","restricted","strict")),allowed_capabilities:o(d(c)),blocked_capabilities:o(d(c)),allowed_surfaces:o(d(c)),blocked_surfaces:o(d(c)),allowed_commands:o(d(c)),blocked_commands:o(d(c)),allowed_actions:o(d(c)),blocked_actions:o(d(c)),allowed_services:o(d(c)),blocked_services:o(d(c))}),Ae=y("block","warn"),Sn=e=>typeof e=="string"?Ae(e):m({global:o(Ae),project:o(Ae)})(e),En=o(m({mode:o(y("off","warn","enforce")),trust_mode:o(y("off","warn","enforce")),pm_max_version_exceeded_mode:o(Sn),require_provenance:o(h),trusted_extensions:o(d(c)),default_sandbox_profile:o(y("none","restricted","strict")),allowed_extensions:o(d(c)),blocked_extensions:o(d(c)),allowed_capabilities:o(d(c)),blocked_capabilities:o(d(c)),allowed_surfaces:o(d(c)),blocked_surfaces:o(d(c)),allowed_commands:o(d(c)),blocked_commands:o(d(c)),allowed_actions:o(d(c)),blocked_actions:o(d(c)),allowed_services:o(d(c)),blocked_services:o(d(c)),extension_overrides:o(d(xn))})),$=je(128),On=m({harness:je(128,/^[a-z0-9]+(?:-[a-z0-9]+)*$/u),environment_keys:o(d($,64)),model_environment_keys:o(d($,64)),session_environment_keys:o(d($,64)),provenance_environment_keys:o(ue(d($,64))),provenance_resolvers:o(ue(y("ai_agent_version","claude_session_file"))),provenance_unavailable_dimensions:o(d($,64)),argv_markers:o(d($,64)),client_names:o(d($,64))}),xt={version:k({int:!0}),id_prefix:c,ids:o(m({token_length:o(k({int:!0,min:4,max:12}))})),author_default:c,agent_identity:o(m({probes_enabled:o(h),identity_vocabulary:o(m({version:k({int:!0,positive:!0}),aliases:ue(je(128,/^[a-z0-9]+(?:-[a-z0-9]+)*$/u))})),harness_signals:d(On)})),mutation_guard:o(m({require_attributed_author:o(h),secret_guard:o(y("off","advise","block")),stale_in_progress_hours:o(k({int:!0,positive:!0}))})),item_format:o(y("toon","json_markdown")),locks:m({ttl_seconds:k({int:!0}),wait_ms:o(k({int:!0,min:0}))}),checkpoints:o(m({retention_days:o(k({int:!0,positive:!0}))})),output:m({default_format:y("toon","json")}),ux:o(m({deprecation_hints:o(h)})),history:o(m({missing_stream:y("auto_create","strict_error"),compact_policy:o(m({enabled:o(h),max_entries:o(k({int:!0,positive:!0})),trigger:o(y("health_warn","auto"))}))})),validation:o(m({sprint_release_format:y("warn","strict_error"),parent_reference:o(y("warn","strict_error")),metadata_profile:o(y("core","strict","custom")),metadata_required_fields:o(d(c)),lifecycle_stale_blocker_reason_patterns:o(d(c)),lifecycle_closure_like_blocked_reason_patterns:o(d(c)),lifecycle_closure_like_resolution_patterns:o(d(c)),lifecycle_closure_like_actual_result_patterns:o(d(c)),estimate_defaults_by_type:o(ue(k({int:!0,positive:!0})))})),governance:vn,workflow:o(m({definition_of_done:d(c)})),testing:o(m({record_results_to_items:h,allow_untrusted_linked_tests:o(h)})),telemetry:o(m({enabled:h,first_run_prompt_completed:o(h),capture_level:o(y("minimal","redacted","max")),endpoint:o(c),installation_id:o(c),retention_days:o(k({int:!0,positive:!0}))})),agent_guidance:o(m({prompt_completed:o(h),declined:o(h),declined_at:o(c),template_version:o(k({int:!0,positive:!0})),last_checked_files:o(d(c))})),item_types:o(m({definitions:d(hn)})),schema:bn,context:o(m({default_depth:o(y(...at)),activity_limit:o(k({int:!0,positive:!0})),stale_threshold_days:o(k({int:!0,positive:!0})),next_ranking_policy:o(y("priority_floor","weighted")),sections:o(m({hierarchy:o(h),activity:o(h),progress:o(h),recently_created:o(h),unparented:o(h),blockers:o(h),files:o(h),workload:o(h),staleness:o(h),tests:o(h)}))})),extensions:m({enabled:d(c),disabled:d(c),policy:En}),search:m({score_threshold:k(),hybrid_semantic_weight:o(k()),max_results:k({int:!0}),embedding_model:c,embedding_corpus_max_characters:o(k()),embedding_batch_size:k({int:!0}),embedding_timeout_ms:o(k({int:!0})),scanner_max_batch_retries:k({int:!0}),provider:o(c),default_mode:o(y("auto","keyword","semantic","hybrid")),corpus_fields:o(d(c)),mutation_refresh_policy:o(y("cache_only","semantic_configured","semantic_auto")),query_expansion:o(m({enabled:o(h),provider:o(c)})),rerank:o(m({enabled:o(h),model:o(c),top_k:o(k({int:!0,positive:!0}))})),bm25:o(m({k1:o(k()),b:o(k())}))}),providers:m({openai:m({base_url:c,api_key:c,model:c}),ollama:m({base_url:c,model:c})}),vector_store:m({adapter:o(c),collection_name:o(c),qdrant:m({url:c,api_key:c}),lancedb:m({path:c})})},Tn=m(xt),St=Object.freeze(Object.keys(xt));function _e(e){let t=Tn(e);return t.ok?{success:!0,data:t.value}:{success:!1,path:t.path.join(".")}}import{AsyncLocalStorage as In}from"node:async_hooks";import{lstat as Rn,realpath as Lt}from"node:fs/promises";import qt from"node:path";function fe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ne(e,t,n,r=[]){if(P(e,t)&&(r.length>0||fe(n)))return n;if(P(e,n)||P(t,n))return t;if((e===void 0||fe(e))&&fe(t)&&fe(n)){let i=e??{},a=new Set([...Object.keys(i),...Object.keys(t),...Object.keys(n)]);return Object.fromEntries([...a].flatMap(s=>{let l=Ne(Object.hasOwn(i,s)?i[s]:void 0,Object.hasOwn(t,s)?t[s]:void 0,Object.hasOwn(n,s)?n[s]:void 0,[...r,s]);return l===void 0?[]:[[s,l]]}))}throw new x(`Settings changed concurrently at ${r.join(".")||"<root>"}; read the latest settings and reapply the intended change.`,v.CONFLICT,{reason:"stale_settings_snapshot",required:"Read a fresh settings snapshot and reapply the intended change.",why:"Another writer changed the same setting after this snapshot was read.",examples:["pm config project export --json"],nextSteps:["Read the current settings, then retry the original config operation."]})}var Cn={Epic:2880,Feature:480,Story:480,Milestone:2880,Task:120,Issue:60,Bug:60,Chore:30,Decision:15,Plan:120},Et=120;function Ie(e){return typeof e=="number"&&Number.isFinite(e)&&e>0}function Tt(e){let t=new Map;for(let[n,r]of Object.entries(e))t.set(n.toLowerCase(),r);return t}var An=Tt(Cn),Ot=new WeakMap;function Pn(e){let t=Ot.get(e);if(t)return t;let n=Tt(e);return Ot.set(e,n),n}function co(e,t){let n=(e??"").trim().toLowerCase();if(n.length===0)return Et;if(t){let i=Pn(t).get(n);if(Ie(i))return Math.floor(i)}let r=An.get(n);return Ie(r)?Math.floor(r):Et}function Re(e){let t={};if(e===null||typeof e!="object"||Array.isArray(e))return t;for(let[n,r]of Object.entries(e)){let i=n.trim();i.length===0||!Ie(r)||(t[i]=Math.floor(r))}return t}import{stat as jn}from"node:fs/promises";var me=new Map;function Ct(e){return[...new Set(e.map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}async function Nn(e){try{let t=await jn(e);return{path:e,mtime_ms:t.mtimeMs,size:t.size}}catch{return{path:e,mtime_ms:null,size:null}}}async function L(e){let t=Ct(e),n=await Promise.all(t.map(r=>Nn(r)));return n.sort((r,i)=>r.path.localeCompare(i.path)),n}function ae(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n+=1){let r=e[n],i=t[n];if(r.path!==i.path||r.mtime_ms!==i.mtime_ms||r.size!==i.size)return!1}return!0}function At(e){return me.get(e)}function pe(e,t){let n=Ct(t.tracked_paths),r=[...t.signatures].map(i=>({path:i.path,mtime_ms:i.mtime_ms,size:i.size})).sort((i,a)=>i.path.localeCompare(a.path));me.set(e,{tracked_paths:n,signatures:r,value:t.value})}function H(e){if(e){me.delete(e);return}me.clear()}var Me=new In;async function jo(e,t,n=()=>!0){let r=new Set([qt.resolve(e)]);try{r.add(await Lt(e))}catch{}let i=!1,a=[r,()=>!i&&n()];try{return await Me.run([...Me.getStore()??[],a],t)}finally{i=!0}}function Ln(e){let t=qt.resolve(e);return Me.getStore()?.some(([n,r])=>n.has(t)&&r())??!1}var qn="settings:write",zt=Symbol("pm.settings.persist_source"),Mt=Symbol("pm.settings.fallback_origin"),Dt=Symbol("pm.settings.fallback_baseline"),zn=128,Mn=new Set(["off","advisory","strict"]);function Pt(e){return structuredClone(Xe[e])}function Dn(e){return e==="minimal"||e==="default"||e==="strict"||e==="custom"?e:u.governance.preset}var Fn=new Set(it);function Ft(e){return Fn.has(e)}function jt(e,t){let n=typeof t.create_default_type=="string"?t.create_default_type.trim():void 0;return n&&n.length>0&&(e.create_default_type=n),(t.workflow_enforcement==="off"||t.workflow_enforcement==="warn"||t.workflow_enforcement==="strict")&&(e.workflow_enforcement=t.workflow_enforcement),Ft(t.start_blocker_enforcement)&&(e.start_blocker_enforcement=t.start_blocker_enforcement),t.require_close_reason===!1&&(e.require_close_reason=!1),e.duplicate_detection_mode=t.duplicate_detection_mode,e.duplicate_detection_threshold=t.duplicate_detection_threshold,e.duplicate_detection_limit=t.duplicate_detection_limit,e}function Vn(e){return e.preset==="custom"?jt({preset:"custom",ownership_enforcement:e.ownership_enforcement,create_mode_default:e.create_mode_default,close_validation_default:e.close_validation_default,parent_reference:e.parent_reference,metadata_profile:e.metadata_profile,force_required_for_stale_lock:e.force_required_for_stale_lock},e):jt({preset:e.preset},e)}function Wn(e){let t=typeof e.create_default_type=="string"?e.create_default_type.trim():void 0,n={};t&&t.length>0&&(n.create_default_type=t),(e.workflow_enforcement==="off"||e.workflow_enforcement==="warn"||e.workflow_enforcement==="strict")&&(n.workflow_enforcement=e.workflow_enforcement),Ft(e.start_blocker_enforcement)&&(n.start_blocker_enforcement=e.start_blocker_enforcement),typeof e.require_close_reason=="boolean"&&(n.require_close_reason=e.require_close_reason),Mn.has(String(e.duplicate_detection_mode))&&(n.duplicate_detection_mode=e.duplicate_detection_mode);let r=e.duplicate_detection_threshold;[typeof r=="number",Number.isFinite(r),Number(r)>=0,Number(r)<=1].every(Boolean)&&(n.duplicate_detection_threshold=r);let i=e.duplicate_detection_limit;return[typeof i=="number",Number.isSafeInteger(i),Number(i)>=0,Number(i)<=20].every(Boolean)&&(n.duplicate_detection_limit=i),n}function Vt(e){let t=e.governance??{},n=Dn(t.preset),r=Wn(t);if(n==="custom"){let s=Pt("default"),l=r.require_close_reason??s.require_close_reason;return{preset:n,ownership_enforcement:t.ownership_enforcement??s.ownership_enforcement,create_mode_default:t.create_mode_default??s.create_mode_default,close_validation_default:t.close_validation_default??s.close_validation_default,parent_reference:t.parent_reference??s.parent_reference,metadata_profile:t.metadata_profile??s.metadata_profile,force_required_for_stale_lock:t.force_required_for_stale_lock??s.force_required_for_stale_lock,...r,require_close_reason:l,duplicate_detection_mode:r.duplicate_detection_mode??s.duplicate_detection_mode,duplicate_detection_threshold:r.duplicate_detection_threshold??s.duplicate_detection_threshold,duplicate_detection_limit:r.duplicate_detection_limit??s.duplicate_detection_limit}}let i=Pt(n),a=r.require_close_reason??i.require_close_reason;return{preset:n,...i,...r,require_close_reason:a}}function Ve(){return structuredClone(u)}function Wt(e){return e==="cache_only"||e==="semantic_configured"||e==="semantic_auto"?e:u.search.mutation_refresh_policy}function Ut(e){return e==="auto"||e==="keyword"||e==="semantic"||e==="hybrid"?e:"auto"}function $t(e){return typeof e=="boolean"?e:u.search.query_expansion.enabled}function Ht(e){return typeof e!="string"?u.search.query_expansion.provider:e.trim()}function Bt(e){return typeof e=="boolean"?e:u.search.rerank.enabled}function Gt(e){return typeof e!="string"?u.search.rerank.model:e.trim()}function Kt(e){return typeof e=="number"&&Number.isFinite(e)&&Number.isInteger(e)&&e>0?e:u.search.rerank.top_k}function Jt(e){if(typeof e!="string")return u.vector_store.collection_name;let n=e.trim().replaceAll(/[^a-zA-Z0-9_-]/g,"_").slice(0,zn);return n.length>0?n:u.vector_store.collection_name}function Le(e){return{present:Array.isArray(e),values:Array.isArray(e)?structuredClone(e):[]}}function Yt(e,t){let n=e.schema,r=Le(n?.statuses),i=Le(n?.fields),a=Le(n?.type_workflows);return{persisted_settings:structuredClone(e),source_settings:structuredClone(e),has_source_item_type_definitions:Array.isArray(e.item_types?.definitions),source_item_type_definitions:Y(e.item_types?.definitions),has_source_schema_statuses:r.present,source_schema_statuses:r.values,has_source_schema_fields:i.present,source_schema_fields:i.values,has_source_schema_type_workflows:a.present,source_schema_type_workflows:a.values,runtime_item_type_definitions:Y(t.item_types?.definitions),runtime_schema_statuses:structuredClone(t.schema.statuses),runtime_schema_fields:structuredClone(t.schema.fields),runtime_schema_type_workflows:structuredClone(t.schema.type_workflows??[])}}function ke(e,t){Object.defineProperty(e,zt,{value:t,writable:!0,configurable:!0,enumerable:!1})}function We(e){let t=e[zt];if(!(!t||typeof t!="object"))return t}function No(e){let t=We(e);if(t){let n=structuredClone(t);n.source_settings.item_format=e.item_format,ke(e,n)}}function he(e){let t=structuredClone(e.settings),n=We(e.settings);n&&ke(t,n);let r=Ue(e.settings);return r!==void 0&&Xt(t,r),{settings:t,metadata:{has_explicit_item_format:e.metadata.has_explicit_item_format},warnings:[...e.warnings]}}function Un(e,t,n){let r=ne(t);return[n,re(e,r.files.types,te.types),re(e,r.files.statuses,te.statuses),re(e,r.files.fields,te.fields),re(e,r.files.workflows,te.workflows)]}async function $n(e,t,n){let r=await L(t);pe(e,{tracked_paths:t,signatures:r,value:he(n)})}async function Hn(e,t,n){try{await $n(e,t,n)}catch{H(e)}}function Nt(e,t){return e.find(n=>n.path===t)}function Bn(e,t,n){for(let r of n){let i=Nt(e,r),a=Nt(t,r);if(!i||!a||!ae([i],[a]))return!1}return!0}async function qe(e,t,n,r,i){try{let a=await L(t);if(!Bn(r,a,i)){H(e);return}pe(e,{tracked_paths:t,signatures:a,value:he(n)})}catch{H(e)}}function Gn(e,t){let n=ne(e.schema),r=Y(e.item_types?.definitions);if(!t)return{item_type_definitions:r,schema_statuses:n.statuses,schema_fields:n.fields,schema_type_workflows:n.type_workflows};let i=n.type_workflows??[],a=P(r,t.runtime_item_type_definitions),s=P(n.statuses,t.runtime_schema_statuses),l=P(n.fields,t.runtime_schema_fields),_=P(i,t.runtime_schema_type_workflows);return{item_type_definitions:a?t.has_source_item_type_definitions?Y(t.source_item_type_definitions):[]:r,schema_statuses:s?t.has_source_schema_statuses?structuredClone(t.source_schema_statuses):[]:n.statuses,schema_fields:l?t.has_source_schema_fields?structuredClone(t.source_schema_fields):[]:n.fields,schema_type_workflows:_?t.has_source_schema_type_workflows?structuredClone(t.source_schema_type_workflows):void 0:n.type_workflows}}function Xt(e,t){Object.defineProperty(e,Mt,{value:t,writable:!0,configurable:!0,enumerable:!1})}function Io(e){return Ue(e)!==void 0}function Ue(e){let t=e[Mt];return typeof t=="string"?t:void 0}function Kn(e){return e[Dt]}function Jn(e,t){Object.defineProperty(e,Dt,{value:t,writable:!0,configurable:!0,enumerable:!1})}function j(e){let t=Ve();return e!==void 0&&Xt(t,e),{settings:t,metadata:{has_explicit_item_format:!1},warnings:e?[e]:[]}}function Qt(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=e.item_format;return t==="toon"||t==="json_markdown"}function De(e){return[...new Set((e??[]).map(t=>t.trim()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Zt(e){let t=u.agent_guidance,n=e?.template_version;return{prompt_completed:e?.prompt_completed===!0,declined:e?.declined===!0,declined_at:typeof e?.declined_at=="string"?e.declined_at:t.declined_at,template_version:typeof n=="number"&&Number.isInteger(n)&&n>0?n:t.template_version,last_checked_files:De(e?.last_checked_files??t.last_checked_files)}}function A(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Yn(e){return e==="off"||e==="warn"||e==="enforce"?e:u.extensions.policy.mode}function Xn(e){return e==="off"||e==="warn"||e==="enforce"?e:u.extensions.policy.trust_mode}function en(e){return e==="none"||e==="restricted"||e==="strict"?e:u.extensions.policy.default_sandbox_profile}function Qn(e){let t=e.name.trim().toLowerCase();if(t.length===0)return null;let n={name:t};e.disabled===!0&&(n.disabled=!0),e.require_trusted===!0&&(n.require_trusted=!0),e.require_provenance===!0&&(n.require_provenance=!0),e.sandbox_profile!==void 0&&(n.sandbox_profile=en(e.sandbox_profile));let r=A(e.allowed_capabilities),i=A(e.blocked_capabilities),a=A(e.allowed_surfaces),s=A(e.blocked_surfaces),l=A(e.allowed_commands),_=A(e.blocked_commands),f=A(e.allowed_actions),w=A(e.blocked_actions),g=A(e.allowed_services),S=A(e.blocked_services);return r.length>0&&(n.allowed_capabilities=r),i.length>0&&(n.blocked_capabilities=i),a.length>0&&(n.allowed_surfaces=a),s.length>0&&(n.blocked_surfaces=s),l.length>0&&(n.allowed_commands=l),_.length>0&&(n.blocked_commands=_),f.length>0&&(n.allowed_actions=f),w.length>0&&(n.blocked_actions=w),g.length>0&&(n.allowed_services=g),S.length>0&&(n.blocked_services=S),n}function Zn(e){let t=new Map;for(let n of e??[]){let r=Qn(n);r&&t.set(r.name,r)}return[...t.values()].sort((n,r)=>n.name.localeCompare(r.name))}function ze(e){return e==="block"||e==="warn"?e:void 0}function er(e){if(typeof e=="string")return ze(e);if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=ze(e.global),n=ze(e.project);return t===void 0&&n===void 0?void 0:{...t!==void 0?{global:t}:{},...n!==void 0?{project:n}:{}}}}function T(e,t){return A(e?.[t]??u.extensions.policy[t])}function tn(e){let t=er(e?.pm_max_version_exceeded_mode);return{mode:Yn(e?.mode),trust_mode:Xn(e?.trust_mode),...t!==void 0?{pm_max_version_exceeded_mode:t}:{},require_provenance:e?.require_provenance===!0,trusted_extensions:T(e,"trusted_extensions"),default_sandbox_profile:en(e?.default_sandbox_profile),allowed_extensions:T(e,"allowed_extensions"),blocked_extensions:T(e,"blocked_extensions"),allowed_capabilities:T(e,"allowed_capabilities"),blocked_capabilities:T(e,"blocked_capabilities"),allowed_surfaces:T(e,"allowed_surfaces"),blocked_surfaces:T(e,"blocked_surfaces"),allowed_commands:T(e,"allowed_commands"),blocked_commands:T(e,"blocked_commands"),allowed_actions:T(e,"allowed_actions"),blocked_actions:T(e,"blocked_actions"),allowed_services:T(e,"allowed_services"),blocked_services:T(e,"blocked_services"),extension_overrides:Zn(e?.extension_overrides??u.extensions.policy.extension_overrides)}}function nn(e){return[...new Set((e??[]).map(n=>n.trim().toLowerCase().replaceAll("-","_")))].filter(n=>n.length>0).sort((n,r)=>n.localeCompare(r)).filter(n=>["author","acceptance_criteria","estimated_minutes","close_reason","reviewer","risk","confidence","sprint","release"].includes(n))}function q(e){return[...new Set((e??[]).map(t=>t.trim().toLowerCase()).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function b(e,t){return e===void 0?t:e}function C(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:{}}function Fe(e){return Array.isArray(e)?e:[]}function tr(e,t,n){return{...t.validation,...e.validation,parent_reference:n.parent_reference,metadata_profile:n.metadata_profile,metadata_required_fields:nn(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:q(e.validation?.lifecycle_stale_blocker_reason_patterns??t.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:q(e.validation?.lifecycle_closure_like_blocked_reason_patterns??t.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:q(e.validation?.lifecycle_closure_like_resolution_patterns??t.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:q(e.validation?.lifecycle_closure_like_actual_result_patterns??t.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:Re(e.validation?.estimate_defaults_by_type)}}function nr(e,t){return{enabled:e.telemetry?.enabled??t.telemetry.enabled,first_run_prompt_completed:e.telemetry?.first_run_prompt_completed??t.telemetry.first_run_prompt_completed,capture_level:e.telemetry?.capture_level??t.telemetry.capture_level,endpoint:e.telemetry?.endpoint??t.telemetry.endpoint,installation_id:e.telemetry?.installation_id??t.telemetry.installation_id,retention_days:e.telemetry?.retention_days??t.telemetry.retention_days}}function rr(e,t){return{...t.search,...e.search,default_mode:Ut(e.search?.default_mode),mutation_refresh_policy:Wt(e.search?.mutation_refresh_policy),query_expansion:{...t.search.query_expansion,...e.search?.query_expansion,enabled:$t(e.search?.query_expansion?.enabled),provider:Ht(e.search?.query_expansion?.provider)},rerank:{...t.search.rerank,...e.search?.rerank,enabled:Bt(e.search?.rerank?.enabled),model:Gt(e.search?.rerank?.model),top_k:Kt(e.search?.rerank?.top_k)}}}function or(e,t){return{adapter:e.vector_store.adapter??t.vector_store.adapter,collection_name:Jt(e.vector_store.collection_name),qdrant:{...t.vector_store.qdrant,...e.vector_store.qdrant},lancedb:{...t.vector_store.lancedb,...e.vector_store.lancedb}}}function ir(e,t){return e.item_format==="json_markdown"?"toon":e.item_format??t.item_format}function ar(e,t){return{default_depth:e.context?.default_depth??t.context.default_depth,activity_limit:e.context?.activity_limit??t.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??t.context.stale_threshold_days,next_ranking_policy:e.context?.next_ranking_policy??t.context.next_ranking_policy,sections:{...t.context.sections,...e.context?.sections}}}function sr(e,t){return{openai:{...t.providers.openai,...e.providers.openai},ollama:{...t.providers.ollama,...e.providers.ollama}}}function Y(e){let t=(e??[]).map(r=>st(r)).filter(r=>r!==null),n=new Map;for(let r of t)n.set(r.name.toLowerCase(),r);return[...n.values()].sort((r,i)=>r.name.localeCompare(i.name))}function ye(e){let t=Ve(),n=Vt({governance:e.governance??{preset:"default"}});return{...t,...e,item_format:ir(e,t),locks:{...t.locks,...e.locks},ids:{...t.ids,...e.ids},agent_identity:structuredClone(e.agent_identity??t.agent_identity),mutation_guard:{...t.mutation_guard,...e.mutation_guard},checkpoints:{...t.checkpoints,...e.checkpoints},output:{...t.output,...e.output},ux:{...t.ux,...e.ux},history:{...t.history,...e.history,compact_policy:{...t.history.compact_policy,...e.history?.compact_policy}},validation:tr(e,t,n),governance:n,workflow:{definition_of_done:[...e.workflow?.definition_of_done??t.workflow.definition_of_done]},testing:{record_results_to_items:e.testing?.record_results_to_items??t.testing.record_results_to_items,allow_untrusted_linked_tests:e.testing?.allow_untrusted_linked_tests??t.testing.allow_untrusted_linked_tests},telemetry:nr(e,t),agent_guidance:Zt(e.agent_guidance??t.agent_guidance),item_types:{definitions:Y(e.item_types?.definitions)},schema:ne(e.schema??t.schema),context:ar(e,t),extensions:{enabled:[...e.extensions.enabled],disabled:[...e.extensions.disabled],policy:tn(e.extensions.policy??t.extensions.policy)},search:rr(e,t),providers:sr(e,t),vector_store:or(e,t)}}function cr(e){e.agent_identity=p(e.agent_identity,["probes_enabled","identity_vocabulary","harness_signals"]);let t=e.agent_identity;Object.hasOwn(t,"identity_vocabulary")&&(t.identity_vocabulary=p(C(t.identity_vocabulary),["version","aliases"])),e.agent_identity.harness_signals=Fe(e.agent_identity.harness_signals).map(n=>p(C(n),["harness","environment_keys","model_environment_keys","session_environment_keys","provenance_environment_keys","provenance_resolvers","provenance_unavailable_dimensions","argv_markers","client_names"])),e.locks=p(e.locks,["ttl_seconds","wait_ms"]),e.ids=p(e.ids,["token_length"]),e.mutation_guard=p(e.mutation_guard,["require_attributed_author","secret_guard","stale_in_progress_hours"]),e.checkpoints=p(e.checkpoints,["retention_days"]),e.output=p(e.output,["default_format"]),e.ux=p(e.ux,["deprecation_hints"]),e.history=p(e.history,["missing_stream","compact_policy"]),e.validation=p(e.validation,["sprint_release_format","parent_reference","metadata_profile","metadata_required_fields","lifecycle_stale_blocker_reason_patterns","lifecycle_closure_like_blocked_reason_patterns","lifecycle_closure_like_resolution_patterns","lifecycle_closure_like_actual_result_patterns","estimate_defaults_by_type"]),e.governance=p(e.governance,["preset","ownership_enforcement","create_mode_default","close_validation_default","require_close_reason","parent_reference","metadata_profile","force_required_for_stale_lock","create_default_type","workflow_enforcement","duplicate_detection_mode","duplicate_detection_threshold","duplicate_detection_limit"]),e.workflow=p(e.workflow,["definition_of_done"]),e.testing=p(e.testing,["record_results_to_items","allow_untrusted_linked_tests"]),e.telemetry=p(e.telemetry,["enabled","first_run_prompt_completed","capture_level","endpoint","installation_id","retention_days"]),e.agent_guidance=p(e.agent_guidance,["prompt_completed","declined","declined_at","template_version","last_checked_files"]),e.item_types=p(e.item_types,["definitions"]),e.schema=p(e.schema,["version","files","statuses","fields","workflow","type_workflows","unknown_field_policy"]),e.schema.files=p(C(e.schema.files),["types","statuses","fields","workflows"]),e.schema.workflow=p(C(e.schema.workflow),["draft_status","open_status","in_progress_status","blocked_status","close_status","canceled_status"]),e.context=p(e.context,["default_depth","activity_limit","stale_threshold_days","next_ranking_policy","sections"]),e.context.sections=p(C(e.context.sections),["hierarchy","activity","progress","blockers","files","workload","staleness","tests"]),e.extensions=p(e.extensions,["enabled","disabled","policy"]),e.extensions.policy=p(C(e.extensions.policy),["mode","trust_mode","pm_max_version_exceeded_mode","require_provenance","trusted_extensions","default_sandbox_profile","allowed_extensions","blocked_extensions","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services","extension_overrides"]),e.extensions.policy.extension_overrides=Fe(e.extensions.policy.extension_overrides).map(n=>p(C(n),["name","disabled","require_trusted","require_provenance","sandbox_profile","allowed_capabilities","blocked_capabilities","allowed_surfaces","blocked_surfaces","allowed_commands","blocked_commands","allowed_actions","blocked_actions","allowed_services","blocked_services"])),e.search=p(e.search,["score_threshold","hybrid_semantic_weight","max_results","embedding_model","embedding_corpus_max_characters","embedding_batch_size","embedding_timeout_ms","scanner_max_batch_retries","provider","default_mode","mutation_refresh_policy","query_expansion","rerank"]),e.search.query_expansion=p(C(e.search.query_expansion),["enabled","provider"]),e.search.rerank=p(C(e.search.rerank),["enabled","model","top_k"]),e.providers=p(e.providers,["openai","ollama"]),e.providers.openai=p(C(e.providers.openai),["base_url","api_key","model"]),e.providers.ollama=p(C(e.providers.ollama),["base_url","model"]),e.vector_store=p(e.vector_store,["adapter","collection_name","qdrant","lancedb"]),e.vector_store.qdrant=p(C(e.vector_store.qdrant),["url","api_key"]),e.vector_store.lancedb=p(C(e.vector_store.lancedb),["path"])}function lr(e){return{...e,locks:b(e.locks,u.locks),ids:b(e.ids,u.ids),agent_identity:b(e.agent_identity,u.agent_identity),mutation_guard:b(e.mutation_guard,u.mutation_guard),checkpoints:b(e.checkpoints,u.checkpoints),output:b(e.output,u.output),ux:b(e.ux,u.ux),history:b(e.history,u.history),validation:b(e.validation,u.validation),workflow:b(e.workflow,u.workflow),testing:b(e.testing,u.testing),telemetry:b(e.telemetry,u.telemetry),agent_guidance:b(e.agent_guidance,u.agent_guidance),item_types:b(e.item_types,u.item_types),schema:b(e.schema,u.schema),context:b(e.context,u.context),extensions:b(e.extensions,u.extensions),search:b(e.search,u.search),providers:b(e.providers,u.providers),vector_store:b(e.vector_store,u.vector_store)}}function dr(e,t){return{...e.validation,parent_reference:t.parent_reference,metadata_profile:t.metadata_profile,metadata_required_fields:nn(e.validation?.metadata_required_fields),lifecycle_stale_blocker_reason_patterns:q(e.validation?.lifecycle_stale_blocker_reason_patterns??u.validation.lifecycle_stale_blocker_reason_patterns),lifecycle_closure_like_blocked_reason_patterns:q(e.validation?.lifecycle_closure_like_blocked_reason_patterns??u.validation.lifecycle_closure_like_blocked_reason_patterns),lifecycle_closure_like_resolution_patterns:q(e.validation?.lifecycle_closure_like_resolution_patterns??u.validation.lifecycle_closure_like_resolution_patterns),lifecycle_closure_like_actual_result_patterns:q(e.validation?.lifecycle_closure_like_actual_result_patterns??u.validation.lifecycle_closure_like_actual_result_patterns),estimate_defaults_by_type:Re(e.validation?.estimate_defaults_by_type)}}function ur(e){return{...u.search,...e.search,default_mode:Ut(e.search?.default_mode),mutation_refresh_policy:Wt(e.search?.mutation_refresh_policy),query_expansion:{...u.search.query_expansion,...e.search?.query_expansion,enabled:$t(e.search?.query_expansion?.enabled),provider:Ht(e.search?.query_expansion?.provider)},rerank:{...u.search.rerank,...e.search?.rerank,enabled:Bt(e.search?.rerank?.enabled),model:Gt(e.search?.rerank?.model),top_k:Kt(e.search?.rerank?.top_k)}}}function _r(e){return{default_depth:e.context?.default_depth??u.context.default_depth,activity_limit:e.context?.activity_limit??u.context.activity_limit,stale_threshold_days:e.context?.stale_threshold_days??u.context.stale_threshold_days,next_ranking_policy:e.context?.next_ranking_policy??u.context.next_ranking_policy,sections:{...u.context.sections,...e.context?.sections}}}function fr(e){return{...e.vector_store,adapter:e.vector_store?.adapter??u.vector_store.adapter,collection_name:Jt(e.vector_store?.collection_name),qdrant:{...e.vector_store?.qdrant},lancedb:{...e.vector_store?.lancedb}}}function mr(e,t,n,r){return{...e,item_format:"toon",validation:dr(e,t),governance:t,agent_guidance:Zt(e.agent_guidance),item_types:{definitions:r.item_type_definitions},schema:{...n,statuses:r.schema_statuses,fields:r.schema_fields,type_workflows:r.schema_type_workflows},search:ur(e),context:_r(e),extensions:{enabled:De(e.extensions?.enabled),disabled:De(e.extensions?.disabled),policy:tn(e.extensions?.policy)},vector_store:fr(e)}}function rn(e,t){for(let n of Object.keys(t)){let r=Reflect.get(t,n),i=e[n];typeof r=="object"&&r!==null&&!Array.isArray(r)&&typeof i=="object"&&i!==null&&!Array.isArray(i)?rn(i,r):e[n]=structuredClone(r)}}function $e(e,t,n){let r=new Set([...Object.keys(t),...Object.keys(n)]);for(let i of r){let a=t[i],s=n[i];if(!P(a,s)){if(s===void 0){delete e[i];continue}if(typeof a=="object"&&a!==null&&!Array.isArray(a)&&typeof s=="object"&&s!==null&&!Array.isArray(s)){let l=e[i],_=typeof l=="object"&&l!==null&&!Array.isArray(l)?l:{};$e(_,a,s),Object.keys(_).length>0?e[i]=_:delete e[i];continue}e[i]=structuredClone(s)}}}var we=["version","id_prefix","ids","author_default","agent_identity","mutation_guard","item_format","locks","checkpoints","output","ux","history","validation","governance","workflow","testing","telemetry","agent_guidance","item_types","schema","context","extensions","search","providers","vector_store"];function It(e,t){let n=lr(e),r=Vt(n),i=ne(n.schema),a=Gn(n,t),s=mr(n,r,i,a),l=p({...s,governance:Vn(r)},we);return cr(l),l}function on(e,t={}){let n=t.source===void 0?t.persist_source:Yt(t.source.validated,ye(t.source.validated)),r=It(e,n);if(n){let i=ye(n.source_settings);i.item_types={definitions:structuredClone(n.runtime_item_type_definitions)},i.schema={...i.schema,statuses:structuredClone(n.runtime_schema_statuses),fields:structuredClone(n.runtime_schema_fields),type_workflows:structuredClone(n.runtime_schema_type_workflows)};let a=It(i,n);t.source!==void 0&&rn(a,t.source.validated);let s=structuredClone(t.source===void 0?n.source_settings:t.source.raw);return $e(s,a,r),`${JSON.stringify(p(s,we),null,2)}
3
- `}return`${JSON.stringify(r,null,2)}
4
- `}async function pr(e){let t;try{t=await Lt(e)}catch(l){if(le(l))return j();throw l}let n=B(t),r;try{r=await Rn(n)}catch(l){if(le(l))return j();throw l}if(!r.isFile())throw Te("settings.json");let i;try{i=await Ze(n,Te("settings.json"))}catch(l){if(le(l))return j();throw l}let a;try{a=JSON.parse(i)}catch{return j("settings_read_invalid_json")}let s=_e(a);return s.success?{settings:ye(s.data),metadata:{has_explicit_item_format:Qt(a)},warnings:s.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[]}:j("settings_read_invalid_schema")}async function an(e){if(Ln(e))return pr(e);let t=B(e),n=[t];await kt({path:t,scope:"project"});let r=At(e);if(r){let f=await L(r.tracked_paths);if(ae(f,r.signatures))return he(r.value)}let i=await L([t]),a;try{a=await I(t)}catch{return j("settings_read_fs_error")}if(a===null){let f=j();return await qe(e,[t],f,i,[t]),f}let s=await L([t]);if(!ae(i,s))return H(e),an(e);let l;try{l=JSON.parse(a)}catch{let f=j("settings_read_invalid_json");return await qe(e,[t],f,s,[t]),f}let _=_e(l);if(!_.success){let f=j("settings_read_invalid_schema");return await qe(e,[t],f,s,[t]),f}try{let f=ye(_.data),w=Un(e,f.schema,t);n=w;let g=await L(w),S=await dt(e,f.schema),X=await L(w),Oe={...f,item_types:{definitions:Y([...f.item_types.definitions,...Fe(S.type_definitions_from_file)])},schema:S.schema};ke(Oe,Yt(_.data,Oe));let Ye={settings:Oe,metadata:{has_explicit_item_format:Qt(l)},warnings:[..._.data.item_format==="json_markdown"?["settings_item_format_legacy_json_markdown_coerced_to_toon"]:[],...S.warnings]};return ae(g,X)?pe(e,{tracked_paths:w,signatures:X,value:he(Ye)}):H(e),Ye}catch{let f=j("settings_read_merge_failed");return await Hn(e,n,f),f}}function hr(e,t=[],n=null){let r=He(n)??{},i=t.filter(s=>!Object.hasOwn(r,s));if(i.length===0)return e;let a=JSON.parse(e);for(let s of i)Reflect.deleteProperty(a,s);return`${JSON.stringify(a,null,2)}
5
- `}var yr=/^[A-Za-z0-9_-]+$/u,kr=new Set(["__proto__","constructor","prototype"]);function He(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)?e:void 0}function wr(e){for(let t of e)if(t.split(".").find(i=>!yr.test(i)||kr.has(i))!==void 0)throw new x(`Settings write assignedPaths entry "${t}" is not a dotted settings path.`,v.USAGE,{code:"settings_write_assigned_path_invalid",reason:"assigned_path_segment_invalid",field:t,why:"Assigned paths name settings keys; an empty, reserved or non-identifier segment cannot address one safely.",nextSteps:["Pass dotted settings keys such as context.next_ranking_policy in assignedPaths."]})}function sn(e,t){return He(Object.hasOwn(e,t)?e[t]:void 0)}function Rt(e,t){let n=e;for(let r of t)if(n=sn(n,r),n===void 0)return;return n}function gr(e,t){let n=e;for(let r of t){let i=sn(n,r);i===void 0&&(i={},n[r]=i),n=i}return n}function br(e,t,n){for(let r of n){let i=r.split("."),a=i.pop(),s=Rt(t,i);if(s===void 0)continue;if(Object.hasOwn(s,a)){gr(e,i)[a]=structuredClone(s[a]);continue}if(!St.includes(i[0]??a))continue;let l=Rt(e,i);l!==void 0&&delete l[a]}}function vr(e,t,n,r,i){let a=i??JSON.parse(on(Ve())),s=structuredClone(He(e)??{});$e(s,a,t),br(s,t,r);let l=_e(s);if(!l.success){let _=l.path;throw new x(`Existing settings.json fails validation at ${_}; the settings write was refused and nothing was changed.`,v.USAGE,{code:"settings_write_invalid_existing_schema",reason:"existing_settings_schema_invalid",field:_,original_code:n,why:"The stored settings could not be read, so writing would either keep an invalid document or replace intended project configuration with defaults.",nextSteps:[`Fix or remove ${_} in settings.json, then retry the original command.`,"A configurable setting can also be repaired explicitly, even to its default value, with pm config <scope> set <dotted.key> <value>.","Run pm health to confirm the settings warning has cleared."]})}return`${JSON.stringify(p(s,we),null,2)}
6
- `}function xr(e){try{return JSON.parse(e)}catch{throw new x("Existing settings.json is malformed; the settings write was refused.",v.USAGE,{code:"settings_write_invalid_existing_json",reason:"existing_settings_json_malformed",why:"Writing defaults over malformed settings could destroy intended project configuration.",nextSteps:["Repair the syntax in .agents/pm/settings.json, then retry the original command.","Run pm health to confirm the settings warning has cleared."]})}}async function Ro(e){return(await an(e)).settings}async function Lo(e,t,n=qn,r={}){let i=r.assignedPaths??[];wr(i);let a=B(e),s=We(t),l=s?void 0:Ue(t),_=on(t,{persist_source:s}),f=JSON.parse(_),w=!1;try{if(await vt({pmRoot:e,filePath:a,mutate:g=>{let S=g===null?null:xr(g);return g!==null&&r.skipIfStored?.(S)===!0?(w=!0,{raw:g,result:void 0}):l!==void 0&&g!==null?{raw:vr(S,f,l,i,Kn(t)),result:void 0}:{raw:s?`${JSON.stringify(p(Ne(s.persisted_settings,f,S),we),null,2)}
7
- `:hr(_,r.omitSections,S),result:void 0}},op:n,author:ft(void 0,t.author_default),lockTtlSeconds:t.locks.ttl_seconds,lockWaitMs:t.locks.wait_ms,recordCreation:!1}),w)return;s?ke(t,{...s,persisted_settings:structuredClone(f)}):l!==void 0&&Jn(t,structuredClone(f)),await yt({path:a,scope:"project",op:n})}finally{H(e)}}import cn from"node:fs";import se from"node:path";import{createRequire as Sr}from"node:module";var ce="@unbrained/pm-cli",Er=new Set(["append","claim","changelog","close","close-many","close-task","comments","config","copy","create","dedupe-merge","delete","deps","docs","extension","event","events","files","focus","gc","history-author-acknowledge","history-compact","history-redact","history-repair","init","install","item","learnings","meet","merge","normalize","notes","package","packages","pause-task","plan","profile","reindex","release","remind","restore","schema","start-task","test","test-all","test-runs","test-runs-worker","telemetry","templates","twin","update","update-many","upgrade","vcs","workspace"]),ln=new Set(["--author","--expect-hash","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),Ge=/\b(\d{4})\.(\d{1,2})\.(\d{1,2})(?:-(\d+))?\b/u,xe="2026.8.31";function E(e,t){return e.some(n=>t.includes(n.split("=",1)[0]))}function Be(e,t){return["activate","adopt","adopt-all","deactivate","init","install","migrate","reload","uninstall"].includes(t[0]??"")||E(e,["--activate","--adopt","--adopt-all","--deactivate","--fix-managed-state","--init","--install","--output","--reload","--scaffold","--uninstall"])}var Or={changelog:(e,t)=>{if(t[0]==="generate")return!E(e,["--check"]);let n=e.indexOf("export");return t[0]==="export"&&(E(e,["--output"])||n>=0&&e[n+1]!==void 0&&!e[n+1].startsWith("-"))},comments:e=>E(e,["--add","--delete","--edit","--file","--stdin"]),config:(e,t)=>(t[0]==="project"||t[0]==="global"?t[1]:t[0])==="set",deps:()=>!1,docs:e=>E(e,["--add","--add-glob","--migrate","--remove"]),duplicates:()=>!1,events:()=>!1,extension:Be,files:(e,t)=>E(e,["--add","--add-glob","--migrate","--remove"])||t[0]==="discover"&&E(e,["--apply"]),health:e=>!E(e,["--check-only","--no-refresh","--skip-vectors"]),learnings:e=>E(e,["--add","--delete","--edit","--file","--stdin"]),merge:(e,t)=>t[0]!=="report",notes:e=>E(e,["--add","--delete","--edit","--file","--stdin"]),package:Be,packages:Be,profile:(e,t)=>t[0]==="apply",schema:(e,t)=>["add-field","add-status","add-type","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type"].includes(t[0]??"")&&!(E(e,["--infer"])&&!E(e,["--apply"])),telemetry:(e,t)=>t.slice(0,2).some(n=>["clear","flush"].includes(n)),templates:(e,t)=>t[0]==="save",test:e=>E(e,["--update","--update-index","--add","--add-json","--background","--measure","--remove","--resume","--run","--stop"]),validate:e=>E(e,["--auto-fix","--prune-missing"]),vcs:(e,t)=>["abandon","create","merge","propose","ref-create"].includes(t[0]??""),workspace:(e,t)=>t[0]==="snapshot"&&["create","delete","restore"].includes(t[1]??"")};function be(e){let t=e.match(Ge);return t?[Number(t[1]),Number(t[2]),Number(t[3]),Number(t[4]??0)]:null}function z(e,t){let n=be(e),r=be(t);if(!n||!r)return null;for(let i=0;i<n.length;i+=1){let a=n[i]-r[i];if(a!==0)return Math.sign(a)}return 0}function ge(e){return z(e,xe)!==-1?3:2}function Tr(e,t){if(t===3)return e.filter(n=>n.history_epoch_compatible===!1).map(n=>({...n,declaration:n.declaration??n.version})).sort((n,r)=>z(n.version,r.version))[0]}function ve(e){try{let t=JSON.parse(cn.readFileSync(e,"utf8"));return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:null}catch{return null}}function Cr(e){let t=[...e.matchAll(/(<=|<)\s*v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/gu)].map(r=>({inclusive:r[1]==="<=",version:r[2]})),n=e.match(/\b\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?\s+-\s+v?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/u);return n?[...t,{inclusive:!0,version:n[1]}]:t}function Ar(e){let t=e.split("||").map(n=>Cr(n));return{bounded:t.some(n=>n.length>0),compatible:t.some(n=>n.every(r=>{let i=z(xe,r.version);return i!==null&&(r.inclusive?i!==1:i===-1)}))}}function dn(e){return["dependencies","devDependencies","optionalDependencies","peerDependencies"].flatMap(t=>{let n=e[t];if(typeof n!="object"||n===null)return[];let r=n[ce];return typeof r=="string"?[r.trim()]:[]})}function Pr(e){return dn(e).flatMap(t=>{let n=/^[<!]/u.test(t)?void 0:t.match(Ge)?.[0];if(!n)return[];let r=/^(?:=|v)?\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?$/u.test(t),i=Ar(t);return[{version:n,constraint:r?"exact":i.bounded?"range":"minimum",...r?{}:{declaration:t},history_epoch_compatible:r?z(n,xe)!==-1:i.compatible}]})}function jr(e){let n=ve(se.join(e,"package-lock.json"))?.packages;if(typeof n!="object"||n===null)return;let r=n["node_modules/@unbrained/pm-cli"];if(typeof r!="object"||r===null)return;let i=r.version;return typeof i=="string"?i:void 0}function Nr(e,t){try{let n=cn.readFileSync(se.join(e,t),"utf8").split(/\r?\n/u),r=n.findIndex(_=>_.includes(ce));if(r<0)return;let i=n[r].match(/^\s*/u)[0].length,a=[n[r]];for(let _=r+1;_<n.length;_+=1){let f=n[_],w=f.trim(),g=f.match(/^\s*/u)[0].length;if(w.length>0&&g<=i)break;a.push(f)}return a.join(`
8
- `).match(/^\s*version(?::\s*|\s+)["']?(\d{4}\.\d{1,2}\.\d{1,2}(?:-\d+)?)/mu)?.[1]??a[0].match(Ge)?.[0]}catch{return}}function un(e){let t=[],n=ve(se.join(e,"package.json"));n&&t.push(...Pr(n).map(s=>({...s,source:"package.json"})));let i=ve(se.join(e,"node_modules","@unbrained","pm-cli","package.json"))?.version;typeof i=="string"&&be(i)&&t.push({version:i,source:"installed-package",constraint:"exact",history_epoch_compatible:ge(i)===3});let a=jr(e);a&&be(a)&&t.push({version:a,source:"package-lock.json",constraint:"exact",history_epoch_compatible:ge(a)===3});for(let s of["pnpm-lock.yaml","yarn.lock"]){let l=Nr(e,s);l&&t.push({version:l,source:s,constraint:"exact",history_epoch_compatible:ge(l)===3})}return t}function Ir(e,t){if(t<=1)return;let{minVersion:n,lt:r}=Sr(import.meta.url)("semver"),i=dn(ve(se.join(e,"package.json"))??{}).find(s=>{try{let l=n(s);return l!==null&&r(l,"2026.10.10")}catch{return!1}}),a=i===void 0?un(e).find(s=>z(s.version,"2026.10.10")===-1):{version:i,source:"package.json"};if(a)throw new x(`The project selects pm ${a.version}, which cannot safely refuse item format ${t}.`,v.CONFLICT,{code:"project_runtime_item_format_incompatible",reason:a.source,required:"Upgrade project pins, installed SDKs, CI hosts and Git merge drivers before writing guarded item formats.",nextSteps:["Use a pm runtime supporting the required item format throughout the project; preserve original item and history bytes, and never re-anchor history to satisfy an older host."]})}function $o(e,t){let n=_t(e);n<=1||(Ir(ct(t),n),e.pm_format_version=n)}function _n(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(ln.has(n)){t+=1;continue}if(!n.startsWith("-"))return{command:n.toLowerCase(),index:t}}}function Rr(e){let t=_n(e);if(!t||E(e,["--help","-h","--dry-run"]))return!1;let{command:n,index:r}=t,i=[];for(let s=r+1;s<e.length;s+=1){let l=e[s];if(ln.has(l)){s+=1;continue}l.startsWith("-")||i.push(l.toLowerCase())}let a=Or[n];return a?a(e,i):Er.has(n)}function Lr(e){let t=_n(e.argv)?.command,n=Rr(e.argv),r=un(e.projectRoot).filter(w=>z(w.version,e.executingVersion)!==null).sort((w,g)=>z(g.version,w.version)),i=r[0],a=i!==void 0&&z(e.executingVersion,i.version)===-1,s=ge(e.executingVersion),l=Tr(r,s),_=n&&l!==void 0,f=a&&!n?{code:"project_runtime_stale_read",executing_version:e.executingVersion,project_version:i.version,source:i.source,message:"This read is using an older pm runtime than the project requires.",next_steps:[`Run the command through the project's installed ${ce} ${i.version}.`,"Install the project dependencies with its declared package manager if the local executable is missing."]}:void 0;return{compatible:!n||!a&&!_||e.allowStale===!0,executing_version:e.executingVersion,...i?{project_version:i.version,source:i.source}:{},...t?{command:t}:{},mutating:n,stale:a,history_epoch_incompatible:_,writer_item_hash_version:s,...l?{incompatible_project_version:l.declaration,incompatible_source:l.source}:{},...f?{warning:f}:{},override_applied:n&&(a||_)&&e.allowStale===!0}}function Ho(e){let t=Lr(e);if(t.compatible)return t;throw t.history_epoch_incompatible?new x(`pm ${t.executing_version} cannot write item-hash epoch ${t.writer_item_hash_version} into a project pinned to pm ${t.incompatible_project_version}.`,v.CONFLICT,{code:"project_runtime_history_epoch_incompatible",reason:t.incompatible_source,why:`The pinned runtime cannot read item_hash_version ${t.writer_item_hash_version}; allowing the write would break its health and validation gates.`,nextSteps:[`Upgrade the project's ${ce} pin to ${xe} or newer before mutating tracker history.`,"For an intentional coordinated migration only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]}):new x(`pm ${t.executing_version} cannot mutate a project pinned to newer pm ${t.project_version}.`,v.CONFLICT,{code:"project_runtime_stale_mutation",reason:t.source,why:"An older runtime can write storage, history, and merge contracts it does not understand.",nextSteps:[`Run this command through the project's installed ${ce} ${t.project_version}.`,"For an intentional recovery only, set PM_ALLOW_STALE_CLI=1 for this invocation and record why.","Read-only commands remain available without an override."]})}import Je from"node:fs/promises";import Se from"node:path";function M(e,t){return typeof e=="object"&&e!==null&&"code"in e&&e.code===t}function fn(e){let t=["--pm-path",e,"init","--defaults","--agent-guidance","skip"];return{suggested_retry:lt(t),suggested_retry_args:t}}function Ee(e){return new x(`Tracker root is not a directory at ${e}.`,v.USAGE,{code:"tracker_root_not_directory",reason:"not_a_directory",resolved_path:e,nextSteps:["Pass a tracker directory, usually <workspace>/.agents/pm, rather than a file path."]})}function Ke(e){return new x(`Tracker root is not readable at ${e}.`,v.GENERIC_FAILURE,{code:"tracker_root_unreadable",reason:"unreadable",resolved_path:e,nextSteps:["Grant read and directory-search permission to the tracker root, then retry."]})}async function qr(e){let t=Se.resolve(e),n=Se.parse(t).root,r=Se.dirname(t);for(;r!==n;){let i;try{i=await Je.stat(r)}catch(a){if(M(a,"ENOTDIR"))throw Ee(e);if(!M(a,"ENOENT"))throw a;r=Se.dirname(r);continue}if(!i.isDirectory())throw Ee(e);return}}async function zr(e){let t;try{t=await Je.stat(e)}catch(n){throw M(n,"ENOENT")?(await qr(e),new x(`Tracker is not initialized at ${e}. Tracker root does not exist. Run pm init first.`,v.NOT_FOUND,{code:"tracker_root_missing",reason:"missing",resolved_path:e,nextSteps:["Confirm the tracker root path or initialize it with the emitted retry."],recovery:fn(e)})):M(n,"ENOTDIR")?Ee(e):M(n,"EACCES")||M(n,"EPERM")?Ke(e):n}if(!t.isDirectory())throw Ee(e);if(process.platform!=="win32"&&((t.mode&292)===0||(t.mode&73)===0))throw Ke(e);try{await(await Je.opendir(e)).close()}catch(n){throw M(n,"EACCES")||M(n,"EPERM")?Ke(e):n}}async function ei(e){if(await zr(e),!await Qe(B(e)))throw new x(`Tracker is not initialized at ${e}. Run pm init first.`,v.NOT_FOUND,{code:"tracker_not_initialized",reason:"settings_missing",resolved_path:e,nextSteps:["Initialize the selected tracker root with the emitted retry."],recovery:fn(e)})}export{R as a,W as b,Jr as c,Yr as d,Xr as e,vt as f,Qr as g,Zr as h,eo as i,St as j,_e as k,co as l,H as m,jo as n,Ln as o,Vt as p,No as q,Io as r,ye as s,on as t,an as u,Ro as v,Lo as w,xe as x,z as y,ge as z,un as A,Ir as B,$o as C,Rr as D,Lr as E,Ho as F,fn as G,zr as H,ei as I};
9
- //# sourceMappingURL=chunk-XRCE4QNL.js.map
@@ -1,2 +0,0 @@
1
- import{f as a,g as b,h as c,i as d,j as e,k as f,l as g,m as h,n as i}from"./chunk-IGW3RVJC.js";import"./chunk-B2GM6KOM.js";import"./chunk-DUJSME77.js";import"./chunk-SX76UGEY.js";import"./chunk-6OIHST4I.js";import"./chunk-XAWE4EAK.js";export{i as assertFieldDefinitionOptionsAvailable,h as assertFieldOptionsAvailable,e as describeFieldFlagSpellingDefectLine,f as describeFieldOptionCollision,d as resolveAddFieldFlagSpellingDefects,b as resolveAddFieldOptionCollisions,c as resolveFieldFlagSpellingDefects,a as resolveFieldOptionCollisions,g as scanFieldOptionCollisions};
2
- //# sourceMappingURL=field-option-collisions-CGRJEAPQ.js.map
@@ -1,2 +0,0 @@
1
- import{A as u,B as v,C as w,D as x,E as y,k as e,l as f,m as g,n as h,o as i,p as j,q as k,r as l,s as m,t as n,u as o,v as p,w as q,x as r,y as s,z as t}from"./chunk-KES4VHU4.js";import"./chunk-NDS4MXZX.js";import"./chunk-PZA7QECY.js";import"./chunk-KCRRTJ4X.js";import"./chunk-XRCE4QNL.js";import{Wf as a,Xf as b,Yf as c,Zf as d}from"./chunk-WZOJSHJT.js";import"./chunk-DUJSME77.js";import"./chunk-SX76UGEY.js";import"./chunk-6OIHST4I.js";import"./chunk-XAWE4EAK.js";export{f as ITEM_REVISION_CONFLICT_CHANGE_LIMIT,e as ITEM_REVISION_CONFLICT_CODE,w as assertExpectHashAdmissible,t as bindExpectedItemRevisions,c as bindItemRevisionScope,a as createItemRevisionScope,k as describeItemRevisionChanges,y as dispatchWithExpectedItemRevisions,q as enrichItemRevisionConflict,o as expectHashInvocationRewrittenError,x as expectHashRequiresMutationError,m as isItemRevisionConflict,u as isTrackerRevisionGuarded,l as itemRevisionConflictRowFields,d as itemRevisionScopeReceipt,v as itemRevisionUncheckedWarning,g as normalizeExpectedItemHash,h as parseExpectHashSpecs,i as readItemRevision,j as resolveExpectedItemRevisions,r as runWithBoundItemRevisionScope,b as runWithItemRevisionScope,p as scopeItemRevisionConflict,n as throwFirstItemRevisionConflict,s as withExpectedItemRevisions};
2
- //# sourceMappingURL=item-revision-FGDR5NSF.js.map
@@ -1,2 +0,0 @@
1
- import{i as a,j as b,k as c,l as d,m as e,n as f,o as g,p as h,q as i,r as j}from"./chunk-7F3UFYZA.js";import"./chunk-PQSEEVOA.js";import"./chunk-GQXK4KKH.js";import"./chunk-MGJMQSN4.js";import"./chunk-CBBKXTJG.js";import"./chunk-HTGN24XM.js";import"./chunk-T3GJPXIZ.js";import"./chunk-LNZKNVMT.js";import"./chunk-KHFUHGL3.js";import"./chunk-AA52P34H.js";import"./chunk-5AAIRHNE.js";import"./chunk-MNFCJNQA.js";import"./chunk-6H36ZHMI.js";import"./chunk-QMM46SJM.js";import"./chunk-5FY2VHRF.js";import"./chunk-KES4VHU4.js";import"./chunk-NDS4MXZX.js";import"./chunk-PZA7QECY.js";import"./chunk-KCRRTJ4X.js";import"./chunk-XRCE4QNL.js";import"./chunk-WZOJSHJT.js";import"./chunk-IGW3RVJC.js";import"./chunk-B2GM6KOM.js";import"./chunk-DUJSME77.js";import"./chunk-SX76UGEY.js";import"./chunk-6OIHST4I.js";import"./chunk-XAWE4EAK.js";export{h as _testOnlyItemTransaction,j as abandonItemTransaction,f as buildItemCompletionMutations,g as commitItemCompletion,e as commitItemMutations,b as listUpsertKeyCandidates,c as loadGuardedRuntimeSchema,d as previewItemMutations,i as readItemTransaction,a as resolveTransactionSchema};
2
- //# sourceMappingURL=item-transaction-C3KAMEYO.js.map
@@ -1,2 +0,0 @@
1
- import{P as y,s as _,x as f}from"./chunk-CBBKXTJG.js";import{a as A,j as L,m as M}from"./chunk-5FY2VHRF.js";import"./chunk-KCRRTJ4X.js";import{v as E}from"./chunk-XRCE4QNL.js";import{Qa as S,ba as w}from"./chunk-WZOJSHJT.js";import{G as R,Qa as N,Wa as b}from"./chunk-B2GM6KOM.js";import{da as C}from"./chunk-DUJSME77.js";import{Q as T,R as g}from"./chunk-SX76UGEY.js";import{C as m}from"./chunk-6OIHST4I.js";import"./chunk-XAWE4EAK.js";function l(e,t,n,i=!1){let s=[...n].map(o=>({candidate:o,distance:S(t,o,3)})).filter(o=>o.distance!==null).sort((o,d)=>o.distance-d.distance||o.candidate.localeCompare(d.candidate))[0]?.candidate,a=i?`Put mutation fields under options (options.${t}).`:s?`Did you mean "${s}"?`:"Use the declared command options or the field option for registered item fields.";throw new m(`Unknown ${e} ${i?"argument":"option"} "${t}". ${a} No changes were made.`,2,{code:"invalid_argument_value",reason:"unknown_mutation_option",changed:!1,field:t,required:a,nextSteps:[a]})}var p=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function $(e){let t=e==="create"?L:M,i=(e==="create"?N:b).map(({flag:s})=>s.slice(2).replace(/-([a-z])/gu,(a,o)=>o.toUpperCase()));return new Set([...t.flatMap(s=>[s.target,...s.keys]),...i,"author","message","force","fullChangedFields","idOnly",...p])}function F(e){if(e!==void 0&&!f(e))throw new m("Mutation options must be an object. No changes were made.",2,{code:"invalid_argument_value",changed:!1})}async function v(e,t){let i=T((await E(w(process.cwd(),t))).schema).command_to_fields.get(e)??[];return{targets:i.map(s=>g(s)),reads:s=>i.some(a=>C({[s]:!0},a)===!0)}}async function h(e,t,n,i,s,a=(o,d)=>l(e,o,d)){let o=[...n].filter(r=>!i.has(r));if(o.length===0)return;let d=await v(t,s);for(let r of d.targets)i.add(r);for(let r of o)d.reads(r)||a(r,i)}async function ee(e,t,n,i,s){if(_(t))return;let a=$(e),o=new Set(["action","options","path","cwd","author","force","noExtensions","no_extensions","fullChangedFields","idOnly",...p,...s,...e==="update"?["id"]:[]]);for(let r of Object.keys(t))o.has(r)||l(e,r,a,a.has(r));let d=t.options;F(d),await h(e,e,new Set([...Object.keys(d??{}),...Object.keys(n)]),a,i)}var I=new Set([...y].filter(e=>e!=="filterStatus"&&(e.startsWith("filter")||e==="ids"||e==="limit"||e==="offset"))),k=e=>e.replace(/_([a-z])/gu,(t,n)=>n.toUpperCase()),O=new Map([["for","Bound the selection with list.limit."],["tokenBudget","Bound the selection with list.limit."],["token_budget","Bound the selection with list.limit."],["all",'State the status selection as filterStatus: "all" beside the list record.'],["status","State the status selection as filterStatus beside the list record."]]),K=["compact","brief","fields","includeBody","full"];async function U(e,t){let n=K.filter(s=>Object.hasOwn(e,s));if(n.length===0)return;let i=await v("list",t);for(let s of n)i.reads(s)&&c(`update-many "list.${s}" is not read beside this selection.`,`list.${s}`,"The bulk selection clears this list option, so the schema field's filter under that name is not applied; select the rows another way.")}var j=["excludeTerminal","lifecycleBucket","dependencyBlocked"];function P(){let e=R.map(({flag:n})=>n.replace(/^--(?:no-)?/u,"").replace(/-([a-z])/gu,(i,s)=>s.toUpperCase())),t=new Set([...e,...A.flatMap(n=>n.keys),"filterEstimateMissing",...j]);for(let n of O.keys())t.delete(n);return t}function c(e,t,n,i="unknown_mutation_option"){throw new m(`${e} ${n} No changes were made.`,2,{code:"invalid_argument_value",reason:i,changed:!1,field:t,required:n,nextSteps:[n]})}function D(){let e=$("update");e.delete("id");for(let t of e)/File$|^stdin/u.test(t)&&e.delete(t);return e.add("documentAnnotationSnapshot"),e}function B(e){for(let t of["list","update"]){let n=e[t];n!=null&&!f(n)&&c(`update-many "${t}" must be an object.`,t,`Pass ${t} as an object, or omit it.`,"invalid_mutation_option_value")}}async function x(e,t,n){Object.hasOwn(e,"id")&&l("update-many list","id",new Set(["ids"])),Object.hasOwn(e,"status")&&c('update-many "list.status" is not read beside this selection.',"list.status",O.get("status"));let i=[...t].find(s=>I.has(s));i!==void 0&&c(`update-many "${i}" is not read beside this selection.`,i,`Put the selection inside list, or drop the list record; a flat "${i}" beside it is not read.`),await U(e,n),await h("update-many list","list",Object.keys(e),P(),n,(s,a)=>{let o=O.get(s);o===void 0&&l("update-many list",s,a),c(`update-many "list.${s}" is not read beside this selection.`,`list.${s}`,o)})}function Y(e,t,n){for(let i of e)t.has(i)||(n.has(i)&&c(`Unknown update-many option "${i}".`,i,`Put update fields inside update (update.${i}); beside a nested update record an outer key selects rows or controls the run.`),l("update-many",i,t))}async function te(e,t,n){if(_(e))return;let i=e.options;F(i);let s=D(),a=new Set([...y,"author","message","force","fullChangedFields","idOnly",...p]),o=new Set([...s,...a]),d=new Set(["action","options","path","cwd","author","noExtensions","no_extensions","fullChangedFields","idOnly",...p]);for(let u of Object.keys(e))d.has(u)||l("update-many",u,o,o.has(u));let r=new Set([...Object.keys(i??{}),...Object.keys(t)].map(u=>p.includes(k(u))?k(u):u));if(B(t),f(t.list)&&await x(t.list,r,n),!f(t.update)){await h("update-many","update_many",r,o,n);return}Y(r,a,s),await h("update-many","update_many",Object.keys(t.update),s,n)}export{ee as assertNativeMutationOptions,te as assertNativeUpdateManyOptions};
2
- //# sourceMappingURL=mutation-admission-LLHIRY6O.js.map
@@ -1,2 +0,0 @@
1
- import{a as se}from"./chunk-RFK3ERYX.js";import"./chunk-SLFRSZK6.js";import{$d as re,Ga as P,Ob as F,Pd as te,Sd as ae,Ud as ne,_d as oe,ae as B,ec as V,ed as J,fd as U,gd as $,ge as ie,hd as H,id as W,jd as j,kc as N,kd as G,md as S,nc as q,nd as z,od as Y,pb as M,pd as K,qd as X,rd as Q,td as Z,ud as ee}from"./chunk-GQXK4KKH.js";import"./chunk-MGJMQSN4.js";import"./chunk-CBBKXTJG.js";import"./chunk-T3GJPXIZ.js";import"./chunk-LNZKNVMT.js";import"./chunk-KHFUHGL3.js";import"./chunk-AA52P34H.js";import"./chunk-MNFCJNQA.js";import"./chunk-6H36ZHMI.js";import"./chunk-QMM46SJM.js";import{Ka as h,ja as D,ka as T,la as L,pa as c,sa as f,ta as i,ua as y}from"./chunk-5FY2VHRF.js";import"./chunk-KES4VHU4.js";import"./chunk-NDS4MXZX.js";import"./chunk-PZA7QECY.js";import{R as b}from"./chunk-KCRRTJ4X.js";import{v as C}from"./chunk-XRCE4QNL.js";import{Af as d,Ih as A,ba as x,nc as O,zf as l}from"./chunk-WZOJSHJT.js";import"./chunk-IGW3RVJC.js";import"./chunk-B2GM6KOM.js";import{o as I,p as E}from"./chunk-DUJSME77.js";import"./chunk-SX76UGEY.js";import{A as u,C as p}from"./chunk-6OIHST4I.js";import"./chunk-XAWE4EAK.js";var le=new Map([["measurements","boolean"],["metric","string"],["measurementLimit","number"],["observe","string_array"],["direction","direction"],["measurementSource","string"],["measurementItem","string"],["measurementRevision","string"],["author","string"],["message","string"],["provenanceCoverage","boolean"],["fleetAttribution","boolean"],["since","string"],["eventLimit","number"],["minimumSample","number"]]),ve=new Set(["higher","lower","target"]),xe=[...le.keys()].sort((e,t)=>e.localeCompare(t)).join(", ");function be(e,t){return e==="boolean"?typeof t=="boolean":e==="string"?typeof t=="string":e==="number"?typeof t=="number":e==="string_array"?Array.isArray(t)&&t.every(a=>typeof a=="string"):e==="direction"&&ve.has(t)}function ce(e){if(e===void 0)return{};let t;try{t=JSON.parse(e)}catch(a){throw new p(`--analytics must be valid JSON: ${String(a)}`,u.USAGE)}if(t===null||typeof t!="object"||Array.isArray(t))throw new p("--analytics must be a JSON object.",u.USAGE);for(let[a,n]of Object.entries(t)){let o=le.get(a);if(!be(o,n))throw new p(o===void 0?`Unknown --analytics field "${a}". Accepted fields: ${xe}.`:`--analytics field "${a}" must be ${o.replace("_"," ")}.`,u.USAGE)}return t}var de=(e,t)=>V(e,t,{runUpdate:(a,n,o)=>se(a,n,o)});async function Ae(e,t,a,n,o){let r=c(o),s=e==="run",m=e==="verdicts",g=e==="presets"||e==="apply",v=e==="promote",k=await N({action:e,...s||m||g||v?{}:{kind:t},id:s||m||v?a??t:a,preset:g?a??t:void 0,definition:i(n,"definition"),trigger:i(n,"trigger"),tree:i(n,"tree"),gate:i(n,"gate"),limit:i(n,"limit"),dry_run:n.dryRun===!0,fullChangedFields:r.fullChangedFields,idOnly:r.idOnly,author:i(n,"author"),message:i(n,"message"),owner:i(n,"owner"),apply:n.apply===!0,enforcement:i(n,"enforcement")},r);l(k,r),typeof k=="object"&&k!==null&&"exit_code"in k&&k.exit_code===1&&(process.exitCode=1)}function ue(e){e.command("assurance").argument("<action>","Action; inspect `pm contracts --command assurance`").argument("[kind]","Declaration kind or run gate id").argument("[id]","Declaration/gate id").description("Manage SDK-owned assurance contracts.").option("--definition <json>","Put declaration JSON").option("--trigger <value>","Gate trigger").option("--tree <value>","Revision identity").option("--gate <id>","Verdict gate filter").option("--limit <number>","Verdict limit").option("--dry-run","Evaluate without recording").option("--author <value>","Mutation author").option("--message <value>","Mutation rationale").option("--owner <item-id>","Preset/derivation owner").option("--apply","Persist derived proposals").option("--enforcement <level>","Promote to warn or block").action(Ae)}function Ce(e,t){let a=e?.trim().toLowerCase(),n=t?.trim().toLowerCase();if(a===void 0||a.length===0)return n;if(a==="local-analytics")return n&&n.length>0?n:"status";if(n!==void 0&&n.length>0)throw b({command_path:"telemetry",token:`${e} ${t}`,allowed:["status","flush","stats","clear","local-analytics"],token_kind:"path",examples:["pm telemetry stats --limit 10","pm telemetry local-analytics status --json"]});return a}function Se(e){return{addValues:Array.isArray(e.add)?e.add:[],addJsonValues:Array.isArray(e.addJson)?e.addJson:[],removeValues:Array.isArray(e.remove)?e.remove:[],removeIndexValues:Array.isArray(e.removeIndex)?e.removeIndex:[]}}function fe(e,t){if(e.background===!0){if(e.run!==!0)throw new p("--background requires --run",u.USAGE);if(e.acknowledgeLinkedTests===!0)throw new p("--background cannot be combined with --acknowledge-linked-tests; acknowledgement is a non-executing foreground operation",u.USAGE);if(e.update!==void 0||e.updateIndex!==void 0||e.setJson!==void 0||t.addValues.length>0||t.addJsonValues.length>0||t.removeValues.length>0||t.removeIndexValues.length>0)throw new p("--background does not support --add/--add-json/--remove/--remove-index or metadata edits; update linked tests first, then run in background",u.USAGE)}}async function Be(e,t,a,n){let o=await B({kind:"test",commandArgs:D(e,{...t,add:n.addValues,addJson:n.addJsonValues,remove:n.removeValues,removeIndex:n.removeIndexValues}),targetId:e,author:typeof t.author=="string"?t.author:void 0,noExtensions:a.noExtensions===!0},a);l(o,a)}function _e(e){return{update:typeof e.update=="string"?e.update:void 0,updateIndex:typeof e.updateIndex=="string"||typeof e.updateIndex=="number"?e.updateIndex:void 0,setJson:typeof e.setJson=="string"?e.setJson:void 0}}function _(e,t){return{add:t.addValues,addJson:t.addJsonValues,remove:t.removeValues,removeIndex:t.removeIndexValues,..._e(e),list:!!e.list,fullHistory:e.fullHistory===!0,run:!!e.run,match:typeof e.match=="string"?e.match:void 0,onlyIndex:typeof e.onlyIndex=="string"||typeof e.onlyIndex=="number"?e.onlyIndex:void 0,onlyLast:!!e.onlyLast,timeout:typeof e.timeout=="string"?e.timeout:void 0,progress:!!e.progress,envSet:Array.isArray(e.envSet)?e.envSet:[],envClear:Array.isArray(e.envClear)?e.envClear:[],sharedHostSafe:!!e.sharedHostSafe,pmContext:typeof e.pmContext=="string"?e.pmContext:void 0,overrideLinkedPmContext:!!e.overrideLinkedPmContext,workspaceContext:typeof e.workspaceContext=="string"?e.workspaceContext:void 0,overrideLinkedWorkspaceContext:!!e.overrideLinkedWorkspaceContext,allowUntrustedLinkedTests:!!e.allowUntrustedLinkedTests,acknowledgeLinkedTests:!!e.acknowledgeLinkedTests,failOnContextMismatch:!!e.failOnContextMismatch,failOnSkipped:!!e.failOnSkipped,failOnEmptyTestRun:!!e.failOnEmptyTestRun,requireAssertionsForPm:!!e.requireAssertionsForPm,checkContext:!!e.checkContext,fullOutput:!!e.fullOutput,autoPmContext:!!e.autoPmContext,author:typeof e.author=="string"?e.author:void 0,message:typeof e.message=="string"?e.message:void 0,force:!!e.force,measure:Array.isArray(e.measure)?e.measure:[],metricBelow:typeof e.metricBelow=="string"?e.metricBelow:void 0,metricDiff:typeof e.metricDiff=="string"?e.metricDiff:void 0}}var Nt={buildRunTestOptions:_,buildRunTestAllOptions:pe,runWorkspacePositionAction:he,validateBackgroundTestOptions:fe};async function Re(e,t,a,n){let o=await oe(e,_(t,n),a);(t.update!==void 0||t.updateIndex!==void 0||t.setJson!==void 0||n.addValues.length>0||n.addJsonValues.length>0||n.removeValues.length>0||t.run===!0||n.removeIndexValues.length>0)&&await h(a,o),l(o,a),(o.run_results.some(r=>r.status==="failed"||r.status==="refused")||o.fail_on_skipped_triggered===!0)&&(process.exitCode=u.DEPENDENCY_FAILED)}async function Ie(e,t,a){let n=c(a),o=Date.now(),r=Se(t);t.background===!0&&ne(e,_(t,r),n,x(process.cwd(),n.path),!0),fe(t,r),t.background===!0?await Be(e,t,n,r):await Re(e,t,n,r),n.profile&&d(`profile:command=test took_ms=${Date.now()-o}`)}function w(e){let t=i(e,"author"),a=i(e,"assignee");if(t!==void 0&&a!==void 0&&t!==a)throw new p("Lifecycle ownership received conflicting --author and --assignee values; use one actor value for both aliases.",u.USAGE,{code:"conflicting_lifecycle_owner",examples:["pm claim pm-123","pm claim pm-123 --start","pm release pm-123"]});return{author:t??a,message:i(e,"message")}}async function Ee(e,t){let a=c(t),n=Date.now();if(e.background===!0){let s=await B({kind:"test-all",commandArgs:T(e),statusFilter:i(e,"status"),noExtensions:a.noExtensions===!0},a);l(s,a),a.profile&&d(`profile:command=test-all took_ms=${Date.now()-n}`);return}let r=await re(pe(e),a);await h(a,{ids:r.results.map(s=>s.id)}),l(r,a),(r.failed>0||r.fail_on_skipped_triggered===!0)&&(process.exitCode=u.DEPENDENCY_FAILED),a.profile&&d(`profile:command=test-all took_ms=${Date.now()-n}`)}function pe(e){return{status:i(e,"status"),limit:i(e,"limit"),offset:i(e,"offset"),timeout:i(e,"timeout"),progress:!!e.progress,envSet:Array.isArray(e.envSet)?e.envSet:[],envClear:Array.isArray(e.envClear)?e.envClear:[],sharedHostSafe:!!e.sharedHostSafe,pmContext:i(e,"pmContext"),overrideLinkedPmContext:!!e.overrideLinkedPmContext,workspaceContext:i(e,"workspaceContext"),overrideLinkedWorkspaceContext:!!e.overrideLinkedWorkspaceContext,allowUntrustedLinkedTests:!!e.allowUntrustedLinkedTests,failOnContextMismatch:!!e.failOnContextMismatch,failOnSkipped:!!e.failOnSkipped,failOnEmptyTestRun:!!e.failOnEmptyTestRun,requireAssertionsForPm:!!e.requireAssertionsForPm,checkContext:!!e.checkContext,fullOutput:!!e.fullOutput,autoPmContext:!!e.autoPmContext}}async function Oe(e,t,a,n){let o=c(n),r=Date.now(),s=await ae({subcommand:Ce(e,t),limit:i(a,"limit")},o);l(s,o),o.profile&&d(`profile:command=telemetry took_ms=${Date.now()-r}`)}async function De(e,t){let a=c(t),n=Date.now(),o=ce(i(e,"analytics")),r=await te(a,{includeEmpty:e.includeEmpty===!0,storage:e.storage===!0,metadataCoverage:e.metadataCoverage===!0,byAssignee:e.byAssignee===!0,byTag:e.byTag===!0,byPriority:e.byPriority===!0,tagPrefix:i(e,"tagPrefix"),fieldUtilization:e.fieldUtilization===!0,...o});r.recorded_observations?.some(s=>s.changed)===!0&&await h(a,{ids:r.recorded_observations?.flatMap(s=>s.observation.item_id?[s.observation.item_id]:[])}),l(r,a),a.profile&&d(`profile:command=stats took_ms=${Date.now()-n}`)}async function Te(e,t){let a=c(t),n=Date.now(),o=i(e,"threshold"),r=i(e,"limit"),s=await M(a,{...e.exhaustive===!0?{exhaustive:!0}:{},status:Array.isArray(e.status)&&e.status.length>0?e.status:void 0,since:i(e,"since"),...o===void 0?{}:{threshold:Number(o)},...r===void 0?{}:{limit:Number(r)}});l(s,a),a.profile&&d(`profile:command=duplicates took_ms=${Date.now()-n}`)}async function Le(e,t){let a=c(t),n=Date.now(),o=!!e.strictExit||!!e.failOnWarn,r=await F(a,{strictExit:o,strictDirectories:!!e.strictDirectories,requireMergeDrivers:!!e.requireMergeDrivers,checkOnly:!!e.checkOnly,checkTelemetry:!!e.checkTelemetry,noRefresh:!!e.noRefresh,refreshVectors:!!e.refreshVectors,verboseStaleItems:!!e.verboseStaleItems,verboseAuthorEvents:!!e.verboseAuthorEvents,brief:!!e.brief,summary:!!e.summary||o&&e.full!==!0,skipVectors:!!e.skipVectors,skipIntegrity:!!e.skipIntegrity,skipDrift:!!e.skipDrift,full:!!e.full});l(r,a),o&&!r.ok&&(A({...r,exit_code:u.GENERIC_FAILURE,error_code:"health_findings",error_category:"validation",command_resolution:"health_findings",resolution_stage:"execute"}),process.exitCode=u.GENERIC_FAILURE),a.profile&&d(`profile:command=health took_ms=${Date.now()-n}`)}async function Pe(e,t){let a=c(t),n=Date.now(),o=await de({checkMetadata:!!e.checkMetadata,metadataProfile:i(e,"metadataProfile"),checkResolution:!!e.checkResolution,checkCompleteness:!!e.checkCompleteness,checkLifecycle:!!e.checkLifecycle,checkStaleBlockers:!!e.checkStaleBlockers,dependencyCycleSeverity:i(e,"dependencyCycleSeverity"),parentCycleSeverity:i(e,"parentCycleSeverity"),checkFiles:!!e.checkFiles,checkCommandReferences:!!e.checkCommandReferences,scanMode:i(e,"scanMode"),includePmInternals:!!e.includePmInternals,verboseFileLists:!!e.verboseFileLists,verboseDiagnostics:!!e.verboseDiagnostics,allAffectedIds:!!e.allAffectedIds,checkHistoryDrift:!!e.checkHistoryDrift,checkStorageIntegrity:!!e.checkStorageIntegrity,fixHints:!!e.fixHints,autoFix:!!e.autoFix,dryRun:!!e.dryRun,fixScope:Array.isArray(e.fixScope)?e.fixScope:void 0,pruneMissing:!!e.pruneMissing,counts:!!e.counts,full:!!e.full},a);l(o,a),(e.strictExit||e.failOnWarn)&&(o.has_warnings||!o.ok)&&(A({...o,exit_code:u.GENERIC_FAILURE,error_code:"validation_findings",error_category:"validation",command_resolution:"validation_findings",resolution_stage:"execute"}),process.exitCode=u.GENERIC_FAILURE),a.profile&&d(`profile:command=validate took_ms=${Date.now()-n}`)}async function Me(e,t){let a=c(t),n=Date.now(),o=await q(a,{dryRun:e.dryRun===!0,scope:Array.isArray(e.scope)?e.scope:[]});l(o,a),a.profile&&d(`profile:command=gc took_ms=${Date.now()-n}`)}async function Fe(e,t,a,n){let o=c(n),r=x(process.cwd(),o.path),s=e.trim().toLowerCase();if(!S.some(m=>m===s))throw b({command_path:"workspace snapshot",token:e,allowed:S,display_name:"workspace snapshot",token_kind:"action",examples:["pm workspace snapshot create before-migration","pm workspace snapshot restore before-migration"]});if(s==="list"){l(await K(r),o);return}if(s==="create"){l(await z(r,t===void 0?{}:{name:t}),o);return}if(t===void 0)throw new p(`pm workspace snapshot ${s} requires a snapshot name or fingerprint`,u.USAGE);if(s==="inspect"){l(await Y(r,t),o);return}if(s==="restore"){if(a.dryRun===!0){l(await X(r,t),o);return}let m=await C(r);l(await Q(r,t,{force:a.force===!0,author:O(i(a,"author"),m.author_default),message:i(a,"message"),lockTtlSeconds:m.locks.ttl_seconds,lockWaitMs:m.locks.wait_ms}),o);return}l(await Z(r,t),o)}async function he(e,t){let a=c(t);l(await ee(a),a)}async function Ve(e,t){let a=c(t),n=Date.now(),o=await P({action:i(e,"action"),command:i(e,"command"),summary:!!e.summary,schemaOnly:!!e.schemaOnly,flagsOnly:!!e.flagsOnly,availabilityOnly:!!e.availabilityOnly,runtimeOnly:!!e.runtimeOnly||!!e.activeOnly,full:!!e.full},a);l(o,a),a.profile&&d(`profile:command=contracts took_ms=${Date.now()-n}`)}async function Ne(e,t,a){let n=t.next===!0,o=t.start===!0;if(o&&e){await ye(e,t,a);return}U(e,n,o);let r=c(a),s=Date.now(),m={...w(t),ifAvailable:t.ifAvailable===!0,...t.takeoverStale===!0?{takeoverStale:!0}:{},maxAttempts:t.maxAttempts,...o?{start:!0}:{}},g=n?await $(!!t.force,r,m,qe(t)):await J(e,!!t.force,r,m);await h(r,g),l(g,r),r.profile&&d(`profile:command=claim took_ms=${Date.now()-s}`)}function qe(e){return{type:i(e,"type"),tag:i(e,"tag"),priority:e.priority,assigneeFilter:i(e,"assigneeFilter"),parent:i(e,"parent"),sprint:i(e,"sprint"),release:i(e,"release"),includeDecisions:e.includeDecisions===!0,includeGates:e.includeGates===!0,includeContainers:e.includeContainers===!0,tokenBudget:e.tokenBudget??e.token_budget,explainRanking:e.explainRanking===!0||e.explain_ranking===!0}}async function Je(e,t,a){if(t.pause===!0){await ge(e,t,a);return}let n=c(a),o=Date.now(),r=await H(e,!!t.force,n,{...w(t),ownershipReleaseBypass:t.ownershipReleaseBypass===!0,handoff:t.handoff});await h(n,r),l(await L("release",[e],t,n,r),n),n.profile&&d(`profile:command=release took_ms=${Date.now()-o}`)}async function R(e){let t=c(e),a=I(e.name());if(!a||t.json||t.quiet)return;(await C(x(process.cwd(),t.path))).ux?.deprecation_hints&&d(E(a))}async function ye(e,t,a){await R(a);let n=c(a),o=Date.now(),r=await W(e,{...w(t),force:!!t.force,next:t.next===!0,ifAvailable:t.ifAvailable===!0,...t.takeoverStale===!0?{takeoverStale:!0}:{}},n);await h(n,r.update),l(r,n),n.profile&&d(`profile:command=start-task took_ms=${Date.now()-o}`)}async function ge(e,t,a){await R(a);let n=c(a),o=Date.now(),r=await j(e,{...w(t),handoff:i(t,"handoff"),force:!!t.force},n);await h(n,r.release),l(r,n),n.profile&&d(`profile:command=pause-task took_ms=${Date.now()-o}`)}async function Ue(e,t,a,n){await R(n);let o=c(n),r=Date.now(),s=await G(e,t,{...w(a),validateClose:i(a,"validateClose"),force:!!a.force},o);await h(o,s.release),l(s,o),o.profile&&d(`profile:command=close-task took_ms=${Date.now()-r}`)}function me(e){return e.option("--background","Run linked tests in managed background mode").option("--timeout <seconds>","Default run timeout in seconds (requires --run)").option("--progress","Emit stderr run progress (requires --run; automatic in TTY)").option("--env-set <value>","Set run environment (KEY=VALUE, repeatable)",f).option("--env-clear <value>","Clear run environment (NAME, repeatable)",f).option("--shared-host-safe","Apply additive shared-host-safe run defaults").option("--pm-context <mode>","PM test context: schema|tracker|auto|none (default: schema)").option("--override-linked-pm-context","Override stored context with --pm-context").option("--workspace-context <mode>","Source-workspace mode: source|isolated|snapshot (default: source)").option("--override-linked-workspace-context","Override stored context with --workspace-context").option("--allow-untrusted-linked-tests","Execute untrusted linked commands when project policy also permits it").option("--fail-on-context-mismatch","Fail linked PM commands when context item counts differ").option("--fail-on-skipped","Treat skipped linked tests as dependency failures").option("--fail-on-empty-test-run","Fail successful commands reporting zero executed tests").option("--require-assertions-for-pm","Require assertion metadata for linked PM command tests").option("--check-context","Check PM context before execution and report the full execution context").option("--full-output","Report full stdout/stderr of passing rows").option("--auto-pm-context","Route mismatched PM tracker reads through tracker context")}function qt(e){ue(e);let t=e.command("test").argument("<id>","Item id").option("--add <value>","Link isolated test; runs only with --run (CSV/markdown or stdin)",f).option("--add-json <value>","Link isolated test; runs only with --run (JSON object/array or stdin)",f).option("--remove <value>","Remove exact command/path (command=<value>, path=<value>, or stdin -)",f).option("--remove-index <n>","Remove 1-based --list position (repeatable)",f).option("--list","List linked tests without mutating").option("--update <value>","Edit exact command or path=<value>").option("--update-index <n>","Edit current 1-based --list position").option("--set-json <value>","Metadata patch; null clears optional fields").option("--run","Run linked test commands").option("--match <value>","Run matching command/path substring").option("--only-index <n>","Run 1-based --list position").option("--only-last","Run most recently added test").option("--full-history","Return all linked tests after a write");t.option("--acknowledge-linked-tests","Trust current commands in this clone without execution"),me(t).option("--measure <value>","Record name=value[,unit=...][,threshold=...]; requires --run",f).option("--metric-below <value>","Return evidence below name=value").option("--metric-diff <name>","Diff the latest two values").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override").description("Manage tests linked to an item and optionally run them.").action(Ie);let a=e.command("test-all").description("Run linked tests across matching items.").option("--status <value>","Filter items by status before running tests").option("--limit <n>","Limit matching items before running linked tests").option("--offset <n>","Skip matching items before running linked tests");me(a).action(Ee),e.command("test-runs-worker",{hidden:!0}).argument("<runId>","Background run id").description("Internal background worker command.").action(async(v,k,ke)=>{let we=c(ke);await ie(v,we)}),e.command("telemetry").argument("[namespace-or-subcommand]","Telemetry subcommand: status, flush, stats, clear (default: status)").argument("[subcommand]","Compatibility alias target for local-analytics: status, flush, stats, clear").option("--limit <n>","Maximum command groups returned by telemetry stats").description("Inspect and manage local telemetry queue/runtime state.").action(Oe),e.command("duplicates").description("Find duplicate clusters across all statuses.").option("--status <value>","Statuses (repeatable or comma-separated)",f,[]).option("--since <value>","Created at or after this time").option("--threshold <value>","Minimum similarity (0-1)").option("--limit <n>","Maximum clusters").option("--exhaustive","Score all pairs within the safety bound").action(Te),e.command("stats").description("Show project tracker statistics.").option("--include-empty","Restore zero-count registered item-type and lifecycle-status buckets").option("--storage","Include aggregate history-stream storage metrics (total streams/lines/bytes, largest + deepest streams, oldest/newest entries)").option("--metadata-coverage","Include metadata coverage % (acceptance_criteria, estimated_minutes, resolution, tags, parent) overall and by type").option("--by-assignee","Include a lifecycle-bucketed item breakdown grouped by assignee").option("--by-tag","Include a lifecycle-bucketed item breakdown grouped by tag").option("--by-priority","Include a lifecycle-bucketed item breakdown grouped by priority").option("--tag-prefix <value>","With --by-tag: only count tags starting with this prefix (e.g. domain:)").option("--field-utilization","Report content-field utilization rates (notes/learnings/files/docs/tests/comments/deps/body) for governance analysis").option("--analytics <json>","Improvement ledger/history analytics JSON").action(De),e.command("health").description("Show project tracker health checks.").option("--strict-directories","Treat optional item-type directories as required failures").option("--require-merge-drivers","Treat absent clone-local merge drivers as a required health failure").option("--check-only","Run read-only health diagnostics without refreshing vectors").option("--check-telemetry","Probe telemetry endpoint health and include network diagnostics").option("--no-refresh","Disable automatic vector refresh attempts during health checks").option("--refresh-vectors","Explicitly enable vector refresh attempts during health checks").option("--verbose-stale-items","Include full stale vectorization ID lists in health output").option("--verbose-author-events","Include every actionable unknown-author event coordinate for review or disposition").option("--brief","Emit compact health details for low-token agent checks").option("--summary","Emit one-line-style status and warning count, also with --full").option("--skip-vectors","Skip vectorization check for a faster run").option("--skip-integrity","Skip item/history file integrity check for a faster run").option("--skip-drift","Skip history drift hash check for a faster run").option("--full","Run every check (slow integrity, drift, vectors too); keeps --summary/--brief").option("--strict-exit","Return non-zero exit when health is not ok and default to actionable summary output; use --full for complete details").option("--fail-on-warn","Alias for --strict-exit").action(Le),e.command("validate").description("Validate metadata, lifecycle policies, files, command references, and history.").option("--check-metadata","Run metadata completeness checks").option("--metadata-profile <value>","Metadata profile (core|strict|custom)").option("--check-resolution","Run closed-item resolution metadata checks").option("--check-completeness","Check declarative lifecycle field requirements").option("--check-lifecycle","Run active-item lifecycle governance drift checks").option("--check-stale-blockers","Include stale blocker-pattern diagnostics in lifecycle checks").option("--dependency-cycle-severity <value>","Set dependency-cycle warning policy for lifecycle checks (off|warn|error)").option("--parent-cycle-severity <value>","Set parent-hierarchy cycle warning policy for lifecycle checks (off|warn|error)").option("--check-files","Run linked-file and orphaned-file checks").option("--check-command-references","Run linked-command PM-ID reference checks").option("--scan-mode <value>","Select file candidate scan mode for --check-files (default|tracked-all|tracked-all-strict)").option("--include-pm-internals","Include PM storage internals in tracked-all candidate scans").option("--verbose-file-lists","Include full file-path lists for validate --check-files details").option("--verbose-diagnostics","Include full diagnostic ID lists").option("--all-affected-ids","Emit complete missing_* affected-ID lists with no truncation (implied by --json)").option("--strict-exit","Return non-zero exit when validation warnings are present").option("--fail-on-warn","Alias for --strict-exit").option("--fix-hints","Add a machine-executable fix_hints[] of pm commands to each failing check's details").option("--auto-fix","Apply safe, deterministic field backfills").option("--dry-run","Preview planned --auto-fix/--prune-missing fixes without applying them").option("--fix-scope <scope>","Grant --auto-fix scopes (metadata, resolution, estimates, timestamps, lifecycle; comma-separated or repeatable). Default: metadata, resolution; other scopes require explicit opt-in",f).option("--prune-missing","Remove deleted-path file/doc links; preserves real files").option("--check-history-drift","Run item/history hash drift checks").option("--check-storage-integrity","Run the post-merge storage-integrity check (unreadable items, history conflict markers, resurrected deletes, unparseable config/schema)").option("--counts","Keep validation counts and totals while omitting per-item diagnostic arrays").option("--full","Return the complete validation diagnostic projection").action(Pe),e.command("gc").option("--dry-run","Preview cleanup targets without deleting files; without this flag, pm gc deletes matched artifacts").option("--scope <value>","Limit cleanup to one or more scopes (comma-separated or repeatable): index, embeddings, runtime, locks, checkpoints, transactions",f).description("Delete optional cache artifacts by default (including expired lock debris) and show a summary.").action(Me);let n=e.command("workspace").description("Inspect workspace state and snapshots.");n.command("position").description("Show merge and history readiness.").action(he),n.command("snapshot").argument("<action>","Action: create, list, inspect, restore, delete").argument("[target]","Optional name for create; name or fingerprint otherwise").description("Manage content-addressed tracker snapshots.").option("--dry-run","Preview restore file, item, stream, and history-entry impact without mutating state").option("--force","Explicitly confirm a whole-workspace snapshot restore").option("--author <value>","Actor recorded on the restore audit event").option("--message <value>","Human-readable restore rationale").action(Fe),e.command("contracts").description("Show machine-readable command and schema contracts for agents.").option("--action <value>","Filter tool schema branches to a specific action").option("--command <value>","Scope contracts output to one CLI command (narrow-by-default)").option("--summary","Return one command+intent row per top-level command for cheap agent bootstrap").option("--schema-only","Return schema-focused output only").option("--flags-only","Return command flag contracts only").option("--availability-only","Return action availability surface only").option("--runtime-only","Include only actions invocable in the current runtime").option("--active-only","Alias for --runtime-only").option("--full","Include full schema and command-flag surfaces (large; default brief output omits heavy sections for unfiltered queries)").action(Ve);let o=e.command("claim").option("--start","Claim and start (id or --next)").argument("[id]","Item id (omit with --next)").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force claim override").option("--if-available","Skip another author's claim (skipped=true)").option("--takeover-stale","Take over an idle claim (stale-work policy)").option("--next","Atomically claim the next caller-available actionable item").option("--type <value>","Filter --next candidates by type").option("--tag <value>","Filter --next candidates by tag").option("--priority <value>","Filter --next candidates by priority").option("--assignee-filter <value>","Filter --next candidates: assigned|unassigned").option("--parent <id>","Scope --next candidates to a subtree").option("--sprint <value>","Filter --next candidates by sprint").option("--release <value>","Filter --next candidates by release").option("--max-attempts <n>","Bound the --next candidate walk (default 10; maximum 100)").option("--include-decisions","Allow --next to claim human-gated Decision items").option("--include-gates","Allow --next to claim outcome gates").option("--include-containers","Allow --next to claim containers with unfinished descendants").option("--token-budget <n>","Bound the estimated tokens used to rank --next candidates").option("--explain-ranking","Include ranking provenance for --next selection").description("Claim an item for active work.").action(Ne);y(o,"--assignee <value>","Alias for --author on lifecycle ownership commands"),y(o,"--token_budget <n>","Alias for --token-budget"),y(o,"--explain_ranking","Alias for --explain-ranking");let r=e.command("release").option("--pause","Use open status").option("--handoff <status>","Needs --message").argument("<id>","Item id").option("--author <value>","Author").option("--message <value>","Message").option("--force","Override ownership").description("Release ownership.").action(Je);y(r,"--assignee <value>","Alias for --author on lifecycle ownership commands");let s=e.command("start-task",{hidden:!0}).argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership or terminal override when required").option("--takeover-stale","Take over an idle claim (stale-work policy)").description("Lifecycle alias: claim an item and move it to in_progress.").action(ye);y(s,"--assignee <value>","Alias for --author on lifecycle ownership commands");let m=e.command("pause-task",{hidden:!0}).argument("<id>","Item id").option("--author <value>","Mutation author").option("--message <value>","History message").option("--force","Force ownership override when required").description("Lifecycle alias: move an item to open and release its claim.").action(ge);y(m,"--assignee <value>","Alias for --author on lifecycle ownership commands");let g=e.command("close-task",{hidden:!0}).argument("<id>","Item id").argument("[reason]","Close reason text").option("--author <value>","Mutation author").option("--message <value>","History message").option("--validate-close <value>","Close-time validation mode: off|warn|strict").option("--force","Force ownership or terminal override when required").description("Lifecycle alias: close an item and release assignment metadata.").action(Ue);y(g,"--assignee <value>","Alias for --author on lifecycle ownership commands")}export{Nt as _testOnlyRegisterOperations,qt as registerOperationCommands,U as requireClaimTarget};
2
- //# sourceMappingURL=register-operations-ECVBZ5FM.js.map
@@ -1,2 +0,0 @@
1
- import"./chunk-SLFRSZK6.js";import{a as N,b as z,c as q,d as K,e as $,f as B}from"./chunk-5BPDT7G2.js";import{g as T,i as M}from"./chunk-HTGN24XM.js";import{Ca as W,Ea as H,ha as j,ia as D,ka as F,na as P,xa as G}from"./chunk-T3GJPXIZ.js";import"./chunk-LNZKNVMT.js";import"./chunk-KHFUHGL3.js";import"./chunk-AA52P34H.js";import"./chunk-QMM46SJM.js";import{pa as w,sa as x}from"./chunk-5FY2VHRF.js";import"./chunk-NDS4MXZX.js";import"./chunk-PZA7QECY.js";import{X as U}from"./chunk-KCRRTJ4X.js";import{v as L}from"./chunk-XRCE4QNL.js";import{Af as h,ba as I,uf as O,zf as y}from"./chunk-WZOJSHJT.js";import"./chunk-IGW3RVJC.js";import"./chunk-B2GM6KOM.js";import{o as C,p as A}from"./chunk-DUJSME77.js";import"./chunk-SX76UGEY.js";import{A as d,C as m}from"./chunk-6OIHST4I.js";import"./chunk-XAWE4EAK.js";import S from"node:fs/promises";import V from"node:path";async function ae(t,e,o){let a=w(e),i=e.optsWithGlobals(),r=I(process.cwd(),a.path);o==="extension"&&await K(r)&&h(A(C("extension")));let c=a.json===!0||i.outputFormat!==void 0?a:{...a,defaultOutputFormat:await q(r)};if(i.global===!0&&(i.project===!0||i.local===!0))throw new m("--global and --project/--local are mutually exclusive.",d.USAGE);N(i),z({...c,outputFormat:i.outputFormat});let s=j(i.fields,$,"list"),n=await B({pmRoot:r,scope:i.global===!0?"global":"project",name:t});y(s===void 0?n:{...n,extensions:D(n.extensions,s)},c),n.complete||(process.exitCode=d.GENERIC_FAILURE)}var X={extension:"extension",package:void 0};async function _(t,e){if(!t)return;let o=C(t),a=w(e);await L(I(process.cwd(),a.path)).then(r=>r.ux.deprecation_hints)&&h(A(o))}var ie={init:"init",install:"install",uninstall:"uninstall",explore:"explore",manage:"manage",describe:"describe",reload:"reload",doctor:"doctor",catalog:"catalog",adopt:"adopt","adopt-all":"adoptAll",activate:"activate",deactivate:"deactivate",migrate:"migrate"};function ne(t){let e=t.capability,o=typeof e=="string"?[e]:Array.isArray(e)?e.filter(i=>typeof i=="string"):[],a=[...new Set(o.map(i=>i.trim().toLowerCase()).filter(i=>i.length>0))];if(a.length>1)throw new m(`Multiple scaffold capabilities cannot be combined yet: ${a.join(", ")}. Choose one capability per scaffold.`,d.USAGE);return a[0]}function R(t,e,o="extension"){let a={...t};e!==void 0&&(a[ie[e]]=!0);let i=(...c)=>c.some(s=>a[s]===!0),r=(...c)=>{for(let s of c)if(typeof a[s]=="string")return a[s]};return{init:i("init"),scaffold:i("scaffold"),install:i("install"),uninstall:i("uninstall"),explore:i("explore","list"),manage:i("manage"),describe:i("describe"),markdown:i("markdown"),reload:i("reload"),doctor:i("doctor"),catalog:i("catalog"),adopt:i("adopt"),adoptAll:i("adoptAll","adopt_all","adopt-all"),activate:i("activate"),deactivate:i("deactivate"),migrate:i("migrate"),project:i("project"),local:i("local"),global:i("global"),gh:r("gh"),github:r("github"),ref:r("ref"),capability:ne(t),declarative:i("declarative"),fields:r("fields"),detail:r("detail"),output:r("output"),trace:i("trace"),watch:i("watch"),runtimeProbe:i("runtimeProbe","runtime_probe","runtime-probe"),offline:i("offline"),fixManagedState:i("fixManagedState","fix_managed_state","fix-managed-state"),isolated:i("isolated"),ignoreGlobal:i("ignoreGlobal","ignore_global","ignore-global"),strictExit:i("strictExit","strict_exit","strict-exit"),failOnWarn:i("failOnWarn","fail_on_warn","fail-on-warn"),dryRun:i("dryRun","dry_run","dry-run"),vocabulary:o}}async function re(t){let e=(await S.readdir(process.cwd())).filter(a=>!a.startsWith(".")).sort((a,i)=>a.localeCompare(i)),o=[...t].sort((a,i)=>a.localeCompare(i));return e.length===o.length&&e.every((a,i)=>a===o[i])}async function se(t){let e=(t??[]).map(o=>o.trim()).filter(o=>o.length>0);return e.length<=1?e.length===0?void 0:e:await re(e)?["*"]:e}function J(t,e,o){let a=t.markdown===!0;if(o!==void 0&&o==="")throw new m("--output requires a non-empty file path.",d.USAGE);if(o!==void 0&&!a)throw new m("--output is only supported with --markdown describe output.",d.USAGE);if(a){if(e.json)throw new m("Cannot combine --json with --markdown.",d.USAGE);if(t.describe!==!0)throw new m("--markdown is only supported by the describe action.",d.USAGE)}}async function le(t){let e=P(t.result.details,t.vocabulary);if(t.outputPath!==void 0){let o=V.resolve(t.outputPath);await S.mkdir(V.dirname(o),{recursive:!0}),await S.writeFile(o,e,"utf8")}if(!t.globalOptions.quiet){for(let o of t.result.warnings)h(`warning: ${o}`);t.outputPath===void 0&&O(e)}}function ce(t,e){let o=!!e.strictExit||!!e.failOnWarn;if(t.action!=="doctor"||!o)return;let a=t.details!==null&&typeof t.details=="object"?t.details:{},i=a.summary!==null&&typeof a.summary=="object"?a.summary:null,r=i&&typeof i.status=="string"?i.status:void 0;(t.warnings.length>0||r!==void 0&&r!=="ok")&&(process.exitCode=d.GENERIC_FAILURE)}async function u(t,e,o,a,i="extension"){let r=w(o),c=Date.now(),s=i==="extension"?"package":i;await _(X[i],o);let n=R(e,a,s),f=(typeof n.output=="string"?n.output:void 0)?.trim();J(n,r,f);let g=await G(t,n,r);n.markdown===!0?await le({result:g,vocabulary:s,outputPath:f,globalOptions:r}):y(g,r),ce(g,n),g.ok===!1&&(process.exitCode=d.GENERIC_FAILURE),r.profile&&h(`profile:command=extension took_ms=${Date.now()-c}`)}function de(t){return t.details!==null&&typeof t.details=="object"?t.details:{}}function pe(t){return t instanceof m?{message:t.message,exit_code:t.exitCode,...t.context}:{message:t instanceof Error?t.message:String(t),exit_code:d.GENERIC_FAILURE}}async function ue(t,e,o){let a=[],i=[],r=d.GENERIC_FAILURE;for(let c of t)try{let s=await G(c,e,o),n=de(s),l=Array.isArray(s.warnings)?s.warnings:[];i.push(...l);let f=s.ok===!0;a.push({target:c,ok:f,extension:n.extension,source:n.source,install_plan:n.install_plan,dry_run:n.dry_run,destination_path:n.destination_path,activated:n.activated,settings_changed:n.settings_changed,previous_state_preserved:n.previous_state_preserved,rollback:n.rollback,command_paths:n.command_paths,action_paths:n.action_paths,runtime_activation_status:n.runtime_activation_status,activation_diagnostics:n.activation_diagnostics,command_discovery:n.command_discovery,verification:n.verification,warnings:l,...f?{}:{error:{message:"Extension install returned ok=false without throwing an error.",exit_code:d.GENERIC_FAILURE,code:"extension_install_soft_failed"}}})}catch(s){let n=pe(s),l=n.exit_code;typeof l=="number"&&r===d.GENERIC_FAILURE&&l!==d.GENERIC_FAILURE&&(r=l),a.push({target:c,ok:!1,error:n})}return{rows:a,warnings:i,failureExitCode:r}}async function Q(t,e,o,a){let i=a==="extension"?"package":a;await _(X[a],o);let r=await se(t);if(r===void 0||r.length<=1){await u(r?.[0],e,o,"install",i);return}let c=w(o),s=Date.now(),n=R(e,"install",i);if(J(n,c,void 0),[n.gh,n.github].some(b=>typeof b=="string"&&b.trim().length>0))throw new m("Multiple install targets cannot be combined with --gh/--github. Install one GitHub source per command, or pass multiple explicit local, bundled, or npm: targets.",d.USAGE,{code:"multi_target_github_install_ambiguous",required:"Use exactly one positional target with --gh/--github, or omit --gh/--github when installing multiple targets.",examples:["pm package install --gh owner/repo","pm package install npm:pm-guide-shell pm-todos"]});let{rows:f,warnings:g,failureExitCode:E}=await ue(r,n,c),k=f.filter(b=>b.ok!==!0).length,te={ok:k===0,action:"install",scope:n.global===!0?"global":"project",installed_count:n.dryRun===!0?0:f.length-k,...n.dryRun===!0?{dry_run:!0,planned_count:f.length-k}:{},failed_count:k,targets:f,warnings:[...new Set(g)].sort((b,oe)=>b.localeCompare(oe))};y(te,c),k>0&&(process.exitCode=E),c.profile&&h(`profile:command=extension took_ms=${Date.now()-s}`)}function fe(t){return t.option("--project","Use project extension scope (default)").option("--local","Alias for --project").option("--global","Use global extension scope")}function v(t){return t.option("--project","Use project package scope (default)").option("--local","Alias for --project").option("--global","Use global package scope")}function p(t,e){return e==="package"?v(t):fe(t)}function Z(t){return t.option("--dry-run","Plan CLI/package upgrades without running npm or reinstalling packages").option("--cli-only","Upgrade only the pm CLI/SDK npm package").option("--packages-only","Upgrade only managed pm packages").option("--repair","Force npm global reinstall when upgrading the pm CLI/SDK").option("--tag <value>","npm dist-tag/version for CLI and registry package upgrades").option("--package-name <value>","Override the CLI package name for self-upgrade testing")}async function ee(t,e,o){let a=w(e),i=Date.now();o&&await _("upgrade",e);let r=await M(t,e.optsWithGlobals(),a);y(r,a),r.ok||(process.exitCode=d.GENERIC_FAILURE),a.profile&&h(`profile:command=package-upgrade took_ms=${Date.now()-i}`)}function Y(t,e){let o=e==="package"?"package":"extension",a=e==="package"?"packages":"extensions",i=e,r=t.command(i,{hidden:e==="extension"}).argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} source, name, or scaffold path`).option("--init",`Generate a starter ${o} scaffold at target path`).option("--scaffold","Alias for --init").option("--capability <kind>","Starter capability for --init (default: commands)",x).option("--install",`Install a ${o} source`).option("--dry-run","Preview install without writes or activation").option("--uninstall",`Uninstall an installed ${o}`).option("--explore",`List discovered ${a} in selected scope`).option("--list","Alias for --explore").option("--manage",`List managed ${a} and updates`).option("--offline","Skip remote freshness checks during manage").option("--describe",`Show surfaces registered by a loaded ${o}`).option("--markdown","Render describe as Markdown").option("--output <path>","Write Markdown to a file").option("--reload",`Reload ${a} without import cache`).option("--watch","Use watch mode with --reload").option("--doctor",`Run ${o} diagnostics`).option("--catalog",`List bundled first-party ${o} catalog metadata`).option("--adopt",`Adopt unmanaged ${o}`).option("--adopt-all",`Adopt all unmanaged ${a}`).option("--activate",`Activate a ${o} in selected scope settings`).option("--deactivate",`Deactivate a ${o} in selected scope settings`).option("--project",`Use project ${o} scope (default)`).option("--local","Alias for --project").option("--global",`Use global ${o} scope`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").option("--detail <mode>",`${o[0].toUpperCase()}${o.slice(1)} diagnostics detail mode (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${a} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(e==="package"?"Manage package lifecycle in project or global scope.":"Manage extension lifecycle in project or global scope.").action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,void 0,e)});e==="package"&&(r.alias("packages"),r.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"));let c=r.command("init").alias("scaffold").argument("<target>","Scaffold target directory path").option("--capability <kind>",`Capability the starter targets (${F.join("|")}; default commands)`,x).description(e==="package"?"Generate a starter package scaffold with package metadata, manifest, and entrypoint.":"Generate a starter extension scaffold with manifest and entrypoint.");e==="package"&&c.option("--declarative","Scaffold the composeExtension blueprint starter (any capability)"),p(c,e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"init",e)}),p(r.command("install").option("--dry-run","Resolve sources and estimate copying without destination writes or activation").argument("[targets...]",`${o[0].toUpperCase()}${o.slice(1)} source (local path, bundled alias, npm: source, wildcard, or GitHub source)`).option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description(`Install ${o} from local path, bundled alias, npm: source, wildcard, or GitHub source.`),e).action(async(s,n,l)=>{await Q(s,l.optsWithGlobals(),l,e)}),p(r.command("uninstall").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Uninstall an installed ${o}.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"uninstall",e)}),p(r.command("explore").option("--fields <value>","Render compact comma-separated row fields, for example: name,version,activation_status").description(`List discovered ${a} in selected scope.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"explore",e)}),p(r.command("inventory").alias("list").argument("[name]",`${o[0].toUpperCase()}${o.slice(1)} name or directory to inspect`).option("--fields <value>",`Render compact comma-separated row fields, for example: ${$.slice(0,3).join(",")},update`).description(`List installed ${a} in the selected scope, with the last observed update, without activating extension code.`),e).action(async(s,n,l)=>{await ae(s,l,e)}),p(r.command("manage").option("--offline","Skip remote freshness checks and report unknown update availability").option("--fields <value>","Render compact comma-separated row fields, for example: name,version,update_available,last_update_remote_version").option("--runtime-probe","Opt-in runtime activation probe for manage output parity").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).description(`List managed ${a} with update-check metadata.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"manage",e)}),p(r.command("describe").argument("[target]",`${o[0].toUpperCase()}${o.slice(1)} name to describe (omit for every loaded ${o})`).option("--markdown","Render the surface map as a Markdown reference document instead of toon/json").option("--output <path>","Write Markdown output to a file (requires --markdown)").description(`Map every surface a loaded ${o} registers (commands, hooks, item types, providers, overrides, ...).`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"describe",e)}),p(r.command("reload").option("--watch","Use watch mode for repeated reload checks").description(`Reload ${a} with cache-busted module imports.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"reload",e)}),p(r.command("doctor").option("--detail <mode>",`Detail mode for ${o} diagnostics (summary|deep)`).option("--trace","Include actionable registration traces in doctor deep diagnostics").option("--fix-managed-state",`Adopt unmanaged ${a} before diagnostics/update checks`).option("--isolated",`Run doctor against project-scope ${a} only, ignoring global registrations`).option("--ignore-global","Alias for --isolated").option("--strict-exit","Return non-zero exit when doctor warnings are present (ok=false)").option("--fail-on-warn","Alias for --strict-exit (doctor)").description(`Run consolidated ${o} diagnostics (summary/deep modes).`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"doctor",e)}),p(r.command("catalog").option("--fields <value>","Render compact comma-separated catalog fields, for example: alias,installed,install_command").description(`List bundled first-party ${o} catalog metadata.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"catalog",e)}),p(r.command("adopt").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).option("--gh <owner/repo[/path]>",`GitHub provenance shorthand for adopted ${o}`).option("--github <owner/repo[/path]>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub shorthand source").description(`Adopt an existing unmanaged ${o} into managed metadata.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"adopt",e)}),p(r.command("adopt-all").description(`Adopt all unmanaged ${a} into managed metadata.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"adopt-all",e)}),p(r.command("migrate").option("--dry-run","Plan active migrations without invoking extension code").description(`Plan or apply active ${o} migrations with durable receipts.`),e).action(async(s,n)=>{await u(void 0,n.optsWithGlobals(),n,"migrate",e)}),p(r.command("activate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Activate a ${o} in selected scope settings.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"activate",e)}),p(r.command("deactivate").argument("<target>",`${o[0].toUpperCase()}${o.slice(1)} name`).description(`Deactivate a ${o} in selected scope settings.`),e).action(async(s,n,l)=>{await u(s,l.optsWithGlobals(),l,"deactivate",e)}),e==="package"&&Z(v(r.command("upgrade").argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(s,n,l)=>{await ee(s,l,!1)})}async function ge(t,e,o){let a=w(o),i=Date.now(),r=await H(t,a,{idPrefix:typeof e.idPrefix=="string"?e.idPrefix:void 0,preset:typeof e.preset=="string"?e.preset:void 0,defaults:e.defaults===!0||e.yes===!0,author:typeof e.author=="string"?e.author:void 0,agentGuidance:typeof e.agentGuidance=="string"?e.agentGuidance:void 0,typePreset:typeof e.typePreset=="string"?e.typePreset:void 0,withPackages:e.withPackages===!0,mergeFence:e.mergeFence!==!1,force:e.force===!0,workspace:typeof e.workspace=="string"?e.workspace:void 0}),s=e.verbose===!0||a.json===!0;y(s?r:W(r,!0),a),a.profile&&h(`profile:command=init took_ms=${Date.now()-i}`)}function me(t,e,o,a){let r=t!==void 0&&new Set(["get","set","list","export"]).has(t);return{resolvedScope:r?U(e):t??"project",resolvedAction:r?t:e??"list",resolvedKey:r?e:o,resolvedValue:r?o:a}}function he(t){return{criterion:Array.isArray(t.criterion)?t.criterion:[],format:typeof t.format=="string"?t.format:void 0,policy:typeof t.policy=="string"?t.policy:void 0,value:typeof t.value=="string"?t.value:void 0,clearCriteria:t.clearCriteria===!0,defaultDepth:typeof t.defaultDepth=="string"?t.defaultDepth:void 0,activityLimit:typeof t.activityLimit=="string"?t.activityLimit:void 0,staleThresholdDays:typeof t.staleThresholdDays=="string"?t.staleThresholdDays:void 0,sectionHierarchy:typeof t.sectionHierarchy=="string"?t.sectionHierarchy:void 0,sectionActivity:typeof t.sectionActivity=="string"?t.sectionActivity:void 0,sectionProgress:typeof t.sectionProgress=="string"?t.sectionProgress:void 0,sectionBlockers:typeof t.sectionBlockers=="string"?t.sectionBlockers:void 0,sectionFiles:typeof t.sectionFiles=="string"?t.sectionFiles:void 0,sectionWorkload:typeof t.sectionWorkload=="string"?t.sectionWorkload:void 0,sectionStaleness:typeof t.sectionStaleness=="string"?t.sectionStaleness:void 0,sectionTests:typeof t.sectionTests=="string"?t.sectionTests:void 0}}async function we(t,e,o,a,i,r){let c=w(r),s=Date.now(),{resolvedScope:n,resolvedAction:l,resolvedKey:f,resolvedValue:g}=me(t,e,o,a),E=await T(n,l,f,he(i),c,typeof g=="string"?g:void 0);y(E,c),c.profile&&h(`profile:command=config took_ms=${Date.now()-s}`)}var Me={normalizeExtensionOptions:R};function Ne(t){t.command("init").argument("[prefix-or-path]","Optional id prefix, or path-like tracker target such as ./pm-sandbox").option("--prefix, --id-prefix <value>","Set the item ID prefix (alias for the positional prefix)").option("--preset <value>","Governance preset for new setups: minimal|default|strict").option("--defaults","Use non-interactive setup defaults without opening the wizard").option("-y, --yes","Alias for --defaults (non-interactive setup)").option("--author <value>","Set the default mutation author for this project").option("--agent-guidance <mode>","Agent guidance mode: ask|add|skip|status").option("--type-preset <name>","Register domain item types during init: agile|ops|research").option("--with-packages","Install all bundled first-party packages during initialization").option("--no-merge-fence","Skip automatic merge-driver installation for a fresh Git-backed tracker").option("--workspace <dir>","Initialize repository-local tracker storage at <dir>/.agents/pm").option("--force","Allow initializing tracker files directly in a directory that looks like a workspace root").option("--verbose","Include the full resolved settings tree in the output (default output is a concise summary)").description("Initialize pm storage and defaults for the current workspace or a path-like tracker target.").action(async(e,o,a)=>{await ge(e,o,a)}),t.command("config").argument("[scope]","Config scope: project|global, or action shorthand list|export|get|set for project scope").argument("[action]","Config action: get|set|list|export").argument("[key]","Config key for get|set; use `pm config project list` for the complete typed inventory, including mutation-guard-* policies").argument("[value]","Value for set, validated by key. Dotted leaves accept values (e.g. context.default_depth deep); the context group takes --default-depth/--section-* flags.").option("--criterion <text>","Criteria value for definition-of-done, metadata-required-fields, or lifecycle pattern keys (repeatable for set)",x).option("--clear-criteria","Clear criteria-list keys for config set operations").option("--format <value>","Item format for item-format key: toon").option("--policy <value>","Policy key values: history-missing-stream-policy=auto_create|strict_error; sprint-release-format-policy=warn|strict_error; parent-reference-policy=warn|strict_error; governance-preset=minimal|default|strict|custom; governance-ownership-enforcement=none|warn|strict; governance-create-mode-default=progressive|strict; governance-close-validation-default=off|warn|strict; governance-require-close-reason=enabled|disabled; governance-parent-reference-policy=warn|strict_error; governance-metadata-validation-profile=core|strict|custom; governance-force-required-for-stale-lock=enabled|disabled; governance-duplicate-detection-mode=off|advisory|strict; test-result-tracking=enabled|disabled; untrusted-linked-test-execution=enabled|disabled; telemetry-tracking=enabled|disabled").option("--value <value>","Typed nested setting value. Mutation guards: require-attributed-author=true|false, secret-guard=off|advise|block, stale-in-progress-hours=integer>=1. Kebab-case is preferred; underscore aliases remain accepted.").option("--default-depth <value>","Context default depth: brief|standard|deep|full").option("--activity-limit <n>","Context default activity limit").option("--stale-threshold-days <n>","Context staleness cutoff in days").option("--section-hierarchy <value>","Enable/disable context hierarchy section (true|false)").option("--section-activity <value>","Enable/disable context activity section (true|false)").option("--section-progress <value>","Enable/disable context progress section (true|false)").option("--section-blockers <value>","Enable/disable context blockers section (true|false)").option("--section-files <value>","Enable/disable context files section (true|false)").option("--section-workload <value>","Enable/disable context workload section (true|false)").option("--section-staleness <value>","Enable/disable context staleness section (true|false)").option("--section-tests <value>","Enable/disable context tests section (true|false)").description("Read or update pm settings for the current workspace or global profile.").action(async(e,o,a,i,r,c)=>{await we(e,o,a,i,r,c)}),Y(t,"extension"),Y(t,"package"),v(t.command("install",{hidden:!0}).option("--dry-run","Resolve sources and estimate copying without destination writes or activation").argument("[targets...]","Package source (local path, bundled alias, npm: source, wildcard, or GitHub source)").option("--gh <github-source>","Install from GitHub shorthand source (owner/repo[/path])").option("--github <github-source>","Alias for --gh").option("--ref <ref>","Git ref/branch/tag for GitHub install sources").description("Install a pm package into the project package scope by default.")).action(async(e,o,a)=>{await _("install",a),await Q(e,a.optsWithGlobals(),a,"package")}),Z(v(t.command("upgrade",{hidden:!0}).argument("[target]","Optional managed package name/source to upgrade; omit to upgrade pm CLI and all managed packages").description("Upgrade the pm CLI/SDK and refresh managed installable pm packages."))).action(async(e,o,a)=>{await ee(e,a,!0)})}export{Me as _testOnlyRegisterSetup,Ne as registerSetupCommands};
2
- //# sourceMappingURL=register-setup-3QYD5H4H.js.map
@@ -1,2 +0,0 @@
1
- import{F as a,G as b,H as c,I as d,J as e,K as f,L as g,M as h,N as i,O as j,P as k,Q as l,R as m,S as n}from"./chunk-SX76UGEY.js";import"./chunk-6OIHST4I.js";import"./chunk-XAWE4EAK.js";export{a as DEFAULT_RUNTIME_SCHEMA_FILE_PATHS,c as DEFAULT_RUNTIME_STATUS_DEFINITIONS,b as DEFAULT_RUNTIME_WORKFLOW,h as ensureRuntimeSchemaFileScaffold,f as filePathForSchemaSection,i as loadRuntimeSchemaFromOptionalFiles,d as normalizeCliToken,e as normalizeRuntimeSchemaSettings,k as normalizeStatusInputWithRegistry,g as resolveItemTypesFilePath,l as resolveRuntimeFieldRegistry,j as resolveRuntimeStatusRegistry,m as runtimeFieldOptionTarget,n as statusIsTerminal};
2
- //# sourceMappingURL=runtime-schema-Y4SHTEXL.js.map
@@ -1,2 +0,0 @@
1
- import{a as y}from"./chunk-MGJMQSN4.js";import{i as w}from"./chunk-LNZKNVMT.js";import{d as u}from"./chunk-KHFUHGL3.js";import{c as g}from"./chunk-AA52P34H.js";import"./chunk-PZA7QECY.js";import"./chunk-XRCE4QNL.js";import{ba as h}from"./chunk-WZOJSHJT.js";import"./chunk-DUJSME77.js";import"./chunk-SX76UGEY.js";import{A as d,C as f}from"./chunk-6OIHST4I.js";import"./chunk-XAWE4EAK.js";import{execFile as x}from"node:child_process";import{realpath as R}from"node:fs/promises";import p from"node:path";import{promisify as $}from"node:util";var b=$(x);function c(t){return new f(`Automatic merge settlement refused: ${t}`,d.CONFLICT,{code:"merge_settlement_review_required",recovery:{suggested_retry:"pm merge reconcile --dry-run"},nextSteps:["Inspect receipts, repair streams and Git changes. Resolve competing values or unrelated drift explicitly, then run pm merge reconcile and stage the reviewed artifacts manually."]})}async function G(t){let e=process.env.GIT_INDEX_FILE;if(e===void 0)return;let s=(await t(["rev-parse","--path-format=absolute","--git-path","index"])).stdout.trim();if(p.resolve(e)!==p.resolve(s))throw c("an alternate Git index requires explicit manual settlement")}async function k(t,e){if(e.length===0)return[];let s=e.map(n=>`:(literal)${n}`),a=new Set((await t(["ls-files","--cached","-z","--",...s])).stdout.split("\0")),i=e.filter(n=>!a.has(n)).map(n=>`:(literal)${n}`);if(i.length>0&&(await t(["diff","--cached","--name-only","--diff-filter=D","-z","--",...i])).stdout.length>0)throw c("a receipt has a staged deletion that requires explicit review");return i}async function I(t){let{git:e,preview:s,paths:a,newReceiptPathspecs:i}=t,n=!1;try{i.length>0&&(n=!0,await e(["add","--",...i]));let o=await t.apply();if(!o.ok||JSON.stringify(o.receipts.summaries)!==JSON.stringify(s.receipts.summaries)||o.repair.streams.some(m=>!s.repair.streams.some(l=>l.id===m.id)))throw c("reconciliation changed or did not finish; inspect the audit artifacts before staging");return a.length>0&&await e(["add","--",...a.map(m=>`:(literal)${m}`)]),{...o,staged_paths:a,guidance:["Lossless reconciliation artifacts are staged for the merge commit. Review git diff --cached before committing."]}}catch(o){throw n&&await e(["reset","--quiet","--",...i]),o}}function S(t){if(t.repair.totals.failed>0||t.receipts.missing_history_references_after>0||t.receipts.summaries.some(e=>e.conflict_fields.length>0)||t.repair.streams.some(e=>e.merge_receipt_proof?.trusted!==!0)||t.validation.checks.some(e=>e.name!=="history_drift"&&e.status!=="ok"))throw c("only fully authenticated receipt-backed repairs without discarded values can be staged")}async function q(t){try{return{...t,path:await R(h(process.cwd(),t.path))}}catch{throw c("the tracker root cannot be resolved")}}async function z(t){let{preview:e}=t;S(e);let{path:s}=await q(t.global),a=await w(s);if(a===null)throw c("a Git workspace is required");let i=r=>b("git",r,{cwd:a,env:g(),timeout:1e4});if(await G(i),(await i(["ls-files","--unmerged","-z"])).stdout.length>0)throw c("Git still has unresolved paths");let o=[...new Set([...[...new Set([...e.repair.streams.map(r=>r.id),...e.receipts.summaries.map(r=>r.item_id)])].map(r=>p.join(s,"history",`${r}.jsonl`)),...e.receipts.summaries.map(r=>p.join(s,"merge-receipts",`${r.receipt_id}.json`))])].map(r=>p.relative(a,r).replaceAll("\\","/"));if(o.some(u))throw c("reconciliation artifacts must belong to this Git workspace");let m=await y(a,o);if(m.length>0)throw new f(`Automatic merge settlement refused: required artifacts are ignored by Git: ${m.map(r=>`${r.path} (${r.source}:${r.line}: ${r.pattern})`).join(", ")}. Remove or narrow the owning ignore rules because merge receipts must travel with the commit.`,d.CONFLICT,{code:"merge_settlement_review_required",reason:"ignored_merge_artifacts",paths:m.map(r=>r.path),nextSteps:["Remove or narrow the named ignore rules, preserve receipt and history files, then retry pm merge reconcile --stage --dry-run before applying pm merge reconcile --stage. Do not force-add ignored proof as a substitute for fixing the shared policy."]});let l=o.map(r=>`:(literal)${r}`),v=e.receipts.summaries.map(r=>p.relative(a,p.join(s,"merge-receipts",`${r.receipt_id}.json`)).replaceAll("\\","/"));if(l.length>0)try{await i(["diff","--quiet","--",...l])}catch{throw c("reconciliation paths have unstaged edits or Git cannot verify their index state")}let _=await k(i,v);return t.dryRun?{...e,staged_paths:[]}:I({...t,git:i,paths:o,newReceiptPathspecs:_})}export{q as resolveMergeSettlementGlobal,z as stageLosslessMergeReconciliation};
2
- //# sourceMappingURL=stage-RSCSUYEJ.js.map
@@ -1,2 +0,0 @@
1
- import{a as B,b as v}from"./chunk-X6CXWWNB.js";import{Fb as I,Gb as h,K as T,S as A,s as m}from"./chunk-NSFS3VWP.js";function E(e,n){return(n===void 0?void 0:A(e,n))?.execution_role??T[e.trim().toLowerCase()]??"agent"}var g="blocked_by",L="blocks",G=Object.freeze([g,L]),x="no-active-blocker";function l(e){return e.trim().toLowerCase()}function b(e,n){return n?`external:${e}`:`local:${l(e)}`}function k(e){let n=new Map,t=typeof e.blocked_by=="string"?e.blocked_by.trim():"";if(t.length>0&&l(t)!==x){let o=B(t);n.set(b(t,o),o?t:l(t))}for(let o of e.dependencies??[]){let c=typeof o.id=="string"?o.id.trim():"";if(m(o.kind)===g&&c.length>0&&l(c)!==x){let s=B(c)||v(o.source_kind);n.set(b(c,s),s?c:l(c))}}return[...n.values()].sort((o,c)=>o.localeCompare(c))}function _(e){let n=new Map;for(let t of e){let o=l(t.id);o.length!==0&&n.set(o,new Set(k(t)))}for(let t of e){let o=l(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=m(c.kind)===L&&typeof c.id=="string"?l(c.id):"";if(s.length===0||s===x)continue;let i=n.get(s)??new Set;i.add(o),n.set(s,i)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function M(e,n){let t=l(e.id);return t.length>0?_(n).get(t)??k(e):k(e)}function S(e,n,t,o){let c=e,s=typeof c.id=="string"?o?.get(l(c.id))??M(c,[...n.values()]):k(e),i=new Set((e.dependencies??[]).filter(r=>m(r.kind)===g&&v(r.source_kind)&&typeof r.id=="string"&&r.id.trim().length>0).map(r=>b(r.id.trim(),!0)));return s.map(r=>{if(B(r)||i.has(b(r,!0)))return{id:r,title:null,status:null,resolved:!1,external:!0,...typeof e.updated_at=="string"?{blocked_since:e.updated_at}:{},resolver:null};let d=n.get(l(r));return d?{id:r,title:d.title,status:d.status,resolved:h(d.status,t)}:{id:r,title:null,status:null,resolved:!1}})}function R(e,n,t){return S(e,n,t)}function U(e,n){let t=new Map(e.map(i=>[l(i.id),i])),o=_(e),c=new Set([...z(n),...n.blocked_statuses]),s=new Set;for(let i of e){let r=I(i.status,n);if(!c.has(r))continue;(n.blocked_statuses.has(r)||S(i,t,n,o).some(f=>!f.resolved))&&s.add(l(i.id))}return s}function W(e,n,t={},o){let c=[...e.ready,...e.decisions,...e.gates];t.includeContainers===!0&&c.push(...e.containers.filter(i=>i.open_blockers.length===0&&!n.blocked_statuses.has(I(i.item.status,n))));let s={ready:[],decisions:[],gates:[]};for(let i of c){let r=E(i.item.type,o);r==="human"&&t.includeDecisions!==!0?s.decisions.push(i):r==="gate"&&t.includeGates!==!0?s.gates.push(i):s.ready.push(i)}return s}function z(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function $(e,n,t){let o=[l(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let i of n.get(s)??[]){if(!h(i.status,t))return!0;o.push(l(i.id))}}}return!1}function j(e){let n=new Map,t=new Map,o=new Map,c=_(e);for(let s of e){n.set(l(s.id),s);let i=typeof s.parent=="string"?s.parent.trim():"";if(i.length>0){let r=l(i),d=t.get(r)??[];d.push(s),t.set(r,d)}for(let r of c.get(l(s.id))){let d=l(r),f=o.get(d)??[];f.push(s.id),o.set(d,f)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function V(e,n,t,o){let{itemsById:c,childrenByParent:s,blockedByReverse:i,blockerIdsByItem:r}=j(n),d=new Set([...z(t),...t.blocked_statuses]),f=new Set(n.filter(a=>!h(a.status,t)).map(a=>l(a.id))),C=[],w=[],y=[],D=[],N=[],K=0;for(let a of e){if(!d.has(I(a.status,t)))continue;K+=1;let O=S(a,c,t,r).filter(u=>!u.resolved),Y=(i.get(l(a.id))??[]).filter(u=>f.has(l(u))).sort((u,F)=>u.localeCompare(F)),p={item:a,open_blockers:O,unblocks:Y};if($(a.id,s,t)){y.push(p);continue}let P=t.blocked_statuses.has(I(a.status,t));if(O.length===0&&!P){let u=E(a.type,o);u==="human"?D.push(p):u==="gate"?N.push(p):C.push(p)}else w.push(p)}return{ready:C,blocked:w,containers:y,decisions:D,gates:N,active_count:K,container_count:y.length}}export{E as a,G as b,k as c,_ as d,M as e,R as f,U as g,W as h,V as i};
2
- //# sourceMappingURL=chunk-3BR5NWQI.js.map