@unbrained/pm-cli 2026.8.14 → 2026.8.16

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 (160) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +51 -11
  3. package/dist/cli/commander-usage.js +17 -4
  4. package/dist/cli/error-guidance.d.ts +7 -0
  5. package/dist/cli/error-guidance.js +65 -25
  6. package/dist/cli/main.js +3 -2
  7. package/dist/cli/register-history-author.js +16 -11
  8. package/dist/cli/register-mutation.js +4 -2
  9. package/dist/cli/register-operations.js +5 -5
  10. package/dist/cli-bundle/bundle-manifest.json +148 -148
  11. package/dist/cli-bundle/chunks/chunk-47OQEOQB.js +2 -0
  12. package/dist/cli-bundle/chunks/{chunk-XAVMOK6B.js → chunk-73UGEBRS.js} +2 -2
  13. package/dist/cli-bundle/chunks/chunk-HCIYWD6M.js +35 -0
  14. package/dist/cli-bundle/chunks/{chunk-FIW4P64F.js → chunk-I2LUWWR5.js} +2 -2
  15. package/dist/cli-bundle/chunks/{chunk-SBRKH6OR.js → chunk-IC5W2T34.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-TMJ7URWS.js → chunk-PANOOBIS.js} +9 -9
  17. package/dist/cli-bundle/chunks/{chunk-BFALV3YP.js → chunk-RIS565OA.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-TXMEUUUY.js → chunk-TK6N7HGM.js} +2 -2
  19. package/dist/cli-bundle/chunks/chunk-TOFG2URD.js +197 -0
  20. package/dist/cli-bundle/chunks/{chunk-G5JUB66K.js → chunk-URW4QRMI.js} +65 -59
  21. package/dist/cli-bundle/chunks/{register-list-query-T3EHHNNV.js → register-list-query-EYCXHZAG.js} +2 -2
  22. package/dist/cli-bundle/chunks/register-mutation-7YVIG54J.js +20 -0
  23. package/dist/cli-bundle/chunks/register-operations-KGDNRMCL.js +2 -0
  24. package/dist/cli-bundle/chunks/{register-setup-3YXZ444E.js → register-setup-NVXBOD5I.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-PPFGQDSI.js → chunk-4JPEBFFC.js} +2 -2
  26. package/dist/cli-bundle/focused-chunks/chunk-5NMFSX26.js +155 -0
  27. package/dist/cli-bundle/focused-chunks/{chunk-YOOI3UZX.js → chunk-6ROKKT4X.js} +2 -2
  28. package/dist/cli-bundle/focused-chunks/chunk-725JSCMP.js +2 -0
  29. package/dist/cli-bundle/focused-chunks/{chunk-XDNAW5OI.js → chunk-C7JUBRFP.js} +2 -2
  30. package/dist/cli-bundle/focused-chunks/{chunk-4DQ2YERC.js → chunk-CODV5LUT.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-DQ6SMTBF.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/chunk-HAACPSUW.js +2 -0
  33. package/dist/cli-bundle/focused-chunks/{chunk-WCVE2NIG.js → chunk-J4UFYHOD.js} +2 -2
  34. package/dist/cli-bundle/focused-chunks/chunk-JX5Z344Q.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-L4RDYBIQ.js +2 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-KSEDUWVZ.js → chunk-NJ5RLEFD.js} +2 -2
  37. package/dist/cli-bundle/focused-chunks/{chunk-K7RWWOAG.js → chunk-QYZERYR5.js} +2 -2
  38. package/dist/cli-bundle/focused-chunks/chunk-SSNDYZTM.js +8 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-T46KLOIB.js +50 -0
  40. package/dist/cli-bundle/focused-chunks/{chunk-KFSZ3BP6.js → chunk-TZATVC4G.js} +6 -6
  41. package/dist/cli-bundle/focused-chunks/chunk-WY3WRPVN.js +2 -0
  42. package/dist/cli-bundle/main.js +13 -13
  43. package/dist/cli-bundle/sdk-authoring.js +1 -1
  44. package/dist/cli-bundle/sdk-contracts.js +1 -1
  45. package/dist/cli-bundle/sdk-core.js +32 -35
  46. package/dist/cli-bundle/sdk-governance.js +1 -1
  47. package/dist/cli-bundle/sdk-graph.js +1 -1
  48. package/dist/cli-bundle/sdk-merge.js +32 -31
  49. package/dist/cli-bundle/sdk-query.js +1 -1
  50. package/dist/cli-bundle/sdk-runtime.js +1 -1
  51. package/dist/cli-bundle/sdk-testing.js +1 -1
  52. package/dist/cli-bundle/sdk.js +2 -2
  53. package/dist/core/diagnostics/remediation.js +7 -2
  54. package/dist/core/extensions/reserved-host-flags.js +3 -2
  55. package/dist/core/history/replay.d.ts +14 -1
  56. package/dist/core/history/replay.js +45 -8
  57. package/dist/core/history/workspace-history.js +32 -10
  58. package/dist/core/output/output.d.ts +2 -0
  59. package/dist/core/output/output.js +7 -3
  60. package/dist/core/shared/command-types.d.ts +2 -0
  61. package/dist/core/shared/command-types.js +2 -2
  62. package/dist/core/shared/errors.d.ts +14 -0
  63. package/dist/core/shared/errors.js +2 -2
  64. package/dist/core/store/item-store.js +28 -2
  65. package/dist/mcp/tool-definitions.js +9 -5
  66. package/dist/sdk/agent/refusal-reachability.d.ts +69 -0
  67. package/dist/sdk/agent/refusal-reachability.js +159 -3
  68. package/dist/sdk/author-attribution.d.ts +56 -11
  69. package/dist/sdk/author-attribution.js +174 -50
  70. package/dist/sdk/cli-bootstrap.d.ts +2 -0
  71. package/dist/sdk/cli-bootstrap.js +7 -2
  72. package/dist/sdk/cli-contracts/completeness.js +3 -2
  73. package/dist/sdk/cli-contracts/flag-contracts.js +6 -2
  74. package/dist/sdk/cli-contracts/registration-helpers.js +3 -2
  75. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +5 -0
  76. package/dist/sdk/cli-contracts/runtime-contracts.js +23 -7
  77. package/dist/sdk/cli-contracts/tool-parameter-tables.js +22 -5
  78. package/dist/sdk/cli-contracts/tool-schema.js +20 -5
  79. package/dist/sdk/cli-program.js +3 -2
  80. package/dist/sdk/completion.js +11 -4
  81. package/dist/sdk/core.d.ts +2 -2
  82. package/dist/sdk/core.js +3 -3
  83. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +50 -2
  84. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +74 -14
  85. package/dist/sdk/governance/assurance-action.d.ts +7 -1
  86. package/dist/sdk/governance/assurance-action.js +7 -6
  87. package/dist/sdk/governance/assurance-mutation-error.d.ts +42 -1
  88. package/dist/sdk/governance/assurance-mutation-error.js +27 -3
  89. package/dist/sdk/governance/assurance-runtime.js +12 -11
  90. package/dist/sdk/governance/assurance.d.ts +9 -0
  91. package/dist/sdk/governance/assurance.js +80 -14
  92. package/dist/sdk/governance/coverage-assurance.d.ts +24 -0
  93. package/dist/sdk/governance/coverage-assurance.js +61 -0
  94. package/dist/sdk/governance/extension-host-version.d.ts +25 -0
  95. package/dist/sdk/governance/extension-host-version.js +116 -0
  96. package/dist/sdk/governance/health.d.ts +32 -1
  97. package/dist/sdk/governance/health.js +119 -27
  98. package/dist/sdk/governance/provenance-health.d.ts +27 -0
  99. package/dist/sdk/governance/provenance-health.js +95 -3
  100. package/dist/sdk/governance/validate.js +7 -8
  101. package/dist/sdk/governance.d.ts +6 -0
  102. package/dist/sdk/governance.js +8 -2
  103. package/dist/sdk/history-repair.d.ts +13 -1
  104. package/dist/sdk/history-repair.js +62 -18
  105. package/dist/sdk/index.d.ts +2 -1
  106. package/dist/sdk/index.js +4 -3
  107. package/dist/sdk/linked-artifacts.js +16 -5
  108. package/dist/sdk/pagination.d.ts +15 -0
  109. package/dist/sdk/pagination.js +9 -5
  110. package/dist/sdk/query/context.d.ts +5 -1
  111. package/dist/sdk/query/context.js +14 -5
  112. package/dist/sdk/read-output/continuation.d.ts +11 -0
  113. package/dist/sdk/read-output/continuation.js +132 -0
  114. package/dist/sdk/read-output-budget.d.ts +1 -1
  115. package/dist/sdk/read-output-budget.js +14 -10
  116. package/dist/sdk/read-output-contracts.d.ts +66 -2
  117. package/dist/sdk/read-output-contracts.js +185 -19
  118. package/dist/sdk/read-output-rows.d.ts +2 -0
  119. package/dist/sdk/read-output-rows.js +15 -2
  120. package/dist/sdk/runtime-input.js +4 -2
  121. package/dist/sdk/runtime.d.ts +2 -5
  122. package/dist/sdk/runtime.js +3 -2
  123. package/docs/ASSURANCE.md +59 -2
  124. package/docs/COMMANDS.md +8 -2
  125. package/docs/READ_OUTPUT_CONTRACTS.md +55 -8
  126. package/docs/RELEASING.md +54 -11
  127. package/docs/SDK_CONTEXT_INTEGRITY.md +94 -4
  128. package/docs/SDK_CONTEXT_TRUTH_CONTRACTS.md +13 -5
  129. package/marketplace.json +2 -2
  130. package/package.json +3 -3
  131. package/packages/pm-beads/package.json +1 -1
  132. package/packages/pm-calendar/package.json +1 -1
  133. package/packages/pm-command-kit/package.json +1 -1
  134. package/packages/pm-digital-twin/package.json +1 -1
  135. package/packages/pm-governance-audit/package.json +1 -1
  136. package/packages/pm-guide-shell/package.json +1 -1
  137. package/packages/pm-kanban/package.json +1 -1
  138. package/packages/pm-lifecycle-hooks/package.json +1 -1
  139. package/packages/pm-linked-test-adapters/package.json +1 -1
  140. package/packages/pm-search-advanced/package.json +1 -1
  141. package/packages/pm-templates/package.json +1 -1
  142. package/packages/pm-todos/package.json +1 -1
  143. package/packages/pm-vcs/package.json +1 -1
  144. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  145. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  146. package/sdk/public-surface.json +1241 -180
  147. package/dist/cli-bundle/chunks/chunk-BBOFSVAK.js +0 -197
  148. package/dist/cli-bundle/chunks/chunk-YAMTJL6Y.js +0 -34
  149. package/dist/cli-bundle/chunks/chunk-YSVSMJ2B.js +0 -2
  150. package/dist/cli-bundle/chunks/register-mutation-E27WCLSZ.js +0 -20
  151. package/dist/cli-bundle/chunks/register-operations-4R6I7CPY.js +0 -2
  152. package/dist/cli-bundle/focused-chunks/chunk-F43TT2QQ.js +0 -8
  153. package/dist/cli-bundle/focused-chunks/chunk-KYUQGTSB.js +0 -2
  154. package/dist/cli-bundle/focused-chunks/chunk-LZ4MV3RH.js +0 -2
  155. package/dist/cli-bundle/focused-chunks/chunk-PGXJQLCT.js +0 -155
  156. package/dist/cli-bundle/focused-chunks/chunk-Q4YY3XNF.js +0 -2
  157. package/dist/cli-bundle/focused-chunks/chunk-QK753U3U.js +0 -46
  158. package/dist/cli-bundle/focused-chunks/chunk-QUMB2J27.js +0 -2
  159. package/dist/cli-bundle/focused-chunks/chunk-SM7MTG27.js +0 -2
  160. package/dist/cli-bundle/focused-chunks/chunk-ZM6TZVHC.js +0 -2
@@ -1,4 +1,4 @@
1
- import{$ as ro,$b as ke,$c as bt,B as Ht,Bc as q,C as g,Ci as Co,De as ko,Dh as Qt,E as h,Fb as uo,Gb as mo,H as oo,Ha as ao,Ia as so,Ja as J,Nd as bo,Oi as Ro,Pg as xo,Q as A,Qg as et,Ra as j,Rg as tt,Sc as $,Sd as H,Sg as So,Ta as co,Tc as K,Tg as Eo,Ua as be,Uc as wo,Ug as oe,Vc as W,Vg as Ue,Wb as Xt,Wc as ee,Wg as $o,Xb as fo,Xg as de,Yb as ho,Yc as vo,Zb as wt,Zc as Qe,ba as io,bc as xe,bg as Y,c as x,ca as Q,cl as kt,d as Qn,da as ce,e as ne,ec as go,eh as re,f as z,fg as Zt,g as he,gc as vt,hc as yo,hh as O,i as eo,ic as _o,ig as Me,ih as Ee,ja as Kt,ka as Vt,l as _t,la as Yt,mg as Se,nh as Ao,sc as B,th as To,u as Wt,wb as lo,wh as Io,x as to,xb as po,xh as Oo,y as no,zh as Ce}from"./chunk-BBOFSVAK.js";import{mkdir as es,readFile as ts}from"node:fs/promises";import Lo from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6ed4a26f-2ae2-556a-87db-56844108757f")}catch{}})();var en=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},ns="sdk-workspace-transaction",os=/^[a-zA-Z0-9._-]+$/,rs=30,is=3e3;function Po(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!os.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function No(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n)throw new TypeError(`${t} must be non-empty`);return n}function Do(e,t,n){let o=e??t;if(!Number.isInteger(o)||o<=0)throw new TypeError(`${n} must be a positive integer`);return o}function Mo(e,t){return Lo.join(e,"transactions","sdk",`${t}.json`)}async function $e(e,t){t.updatedAt=A();let n=Mo(e,t.transactionId);await es(Lo.dirname(n),{recursive:!0}),await he(n,`${JSON.stringify(t,null,2)}
1
+ import{$ as ro,$b as ke,$c as bt,$g as $o,B as Ht,Bc as q,Bh as Io,C as g,Ch as Oo,E as h,Eh as Ce,Fb as uo,Fe as ko,Gb as mo,H as oo,Ha as ao,Hi as Co,Ia as so,Ih as Qt,Ja as J,Nd as bo,Q as A,Ra as j,Sc as $,Sd as H,Ta as co,Tc as K,Ti as Ro,Ua as be,Uc as wo,Ug as xo,Vc as W,Vg as et,Wb as Xt,Wc as ee,Wg as tt,Xb as fo,Xg as So,Yb as ho,Yc as vo,Yg as Eo,Zb as wt,Zc as Qe,Zg as oe,_g as Ue,ah as de,ba as io,bc as xe,c as x,ca as Q,d as Qn,da as ce,e as ne,ec as go,f as z,g as he,gc as vt,gg as Y,hc as yo,hl as kt,i as eo,ic as _o,ja as Kt,jh as re,ka as Vt,kg as Zt,l as _t,la as Yt,mh as O,ng as Me,nh as Ee,rg as Se,sc as B,sh as Ao,u as Wt,wb as lo,x as to,xb as po,y as no,yh as To}from"./chunk-TOFG2URD.js";import{mkdir as es,readFile as ts}from"node:fs/promises";import Lo from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6ed4a26f-2ae2-556a-87db-56844108757f")}catch{}})();var en=class extends Error{constructor(t="Workspace transaction interrupted"){super(t),this.name="WorkspaceTransactionInterruptedError"}},ns="sdk-workspace-transaction",os=/^[a-zA-Z0-9._-]+$/,rs=30,is=3e3;function Po(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n||!os.test(n))throw new TypeError(`${t} must match [a-zA-Z0-9._-]+`);return n}function No(e,t){if(typeof e!="string")throw new TypeError(`${t} must be a string`);let n=e.trim();if(!n)throw new TypeError(`${t} must be non-empty`);return n}function Do(e,t,n){let o=e??t;if(!Number.isInteger(o)||o<=0)throw new TypeError(`${n} must be a positive integer`);return o}function Mo(e,t){return Lo.join(e,"transactions","sdk",`${t}.json`)}async function $e(e,t){t.updatedAt=A();let n=Mo(e,t.transactionId);await es(Lo.dirname(n),{recursive:!0}),await he(n,`${JSON.stringify(t,null,2)}
2
2
  `)}function as(e){return Number.isInteger(e.attempt)&&typeof e.author=="string"&&typeof e.createdAt=="string"&&typeof e.updatedAt=="string"}function Re(e){return Object.assign(Object.create(null),e)}function ss(e,t){try{let n=JSON.stringify(e,(o,r)=>{if(typeof r=="number"&&!Number.isFinite(r))throw new TypeError(`${t} contains a non-finite number`);if(r===void 0||typeof r=="function"||typeof r=="symbol")throw new TypeError(`${t} contains a non-JSON value`);return r});return JSON.parse(n)}catch(n){throw new TypeError(`${t} must be JSON serializable`,{cause:n})}}function tn(e,t){return e===void 0?void 0:ss(e,t)}function nn(e,t,n,o){let r=tn(n,o);r===void 0?delete e[t]:e[t]=r}function jo(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Fo(e,t){return Array.isArray(e)&&new Set(e).size===e.length&&e.every(n=>typeof n=="string"&&t.includes(n))}function cs(e,t){if(!Fo(e.startedStepIds,t)||!Fo(e.completedStepIds,t)||!jo(e.results)||!jo(e.compensationData))return!1;let n=e.startedStepIds,o=new Set(n),r=e.completedStepIds,i=new Set(r);return Object.keys(e.compensationData).some(a=>!o.has(a))||Object.keys(e.results).some(a=>!i.has(a))?!1:e.status==="committed"?t.every(a=>i.has(a)):e.status!=="compensated"||i.size===0&&o.size===0}function ds(e,t,n){let o;try{o=JSON.parse(e)}catch{throw new TypeError(`Workspace transaction ${t} journal is invalid JSON`)}if(!o||typeof o!="object"||Array.isArray(o))throw new TypeError(`Workspace transaction ${t} journal is invalid`);let r=o,i=r.schemaVersion===1&&r.transactionId===t,a=Array.isArray(r.stepIds)&&r.stepIds.length===n.length&&r.stepIds.every((l,p)=>l===n[p]),s=cs(r,n),c=as(r),d=["applying","compensating","compensated","committed"].includes(String(r.status));if(!i||!a||!s||!c||!d)throw new TypeError(`Workspace transaction ${t} journal does not match the supplied plan`);return{...r,results:Re(r.results),compensationData:Re(r.compensationData)}}async function ls(e,t,n,o,r){let i=r,a=i!==void 0;if(i?.status==="compensating"&&await Uo(e,i),i===void 0||i.status==="compensated"){let s=A();i={schemaVersion:1,transactionId:t,author:n,status:"applying",attempt:(i?.attempt??0)+1,createdAt:i?.createdAt??s,updatedAt:s,stepIds:o,startedStepIds:[],completedStepIds:[],results:Re(),compensationData:Re()},await $e(e.pmRoot,i),await ge(e,i,"prepared")}return{journal:i,recovered:a}}async function ps(e,t,n){try{await ms(t,e.steps),await $e(e.pmRoot,t);let o=new Set(t.completedStepIds),r=new Set(t.startedStepIds);for(let i of e.steps){if(o.has(i.id))continue;let a=await i.inspect(),s=tn(a.result,`Step ${i.id} result`);if(a.state!=="applied"){let c=await i.prepareCompensation?.();nn(t.compensationData,i.id,c,`Step ${i.id} compensation data`),r.add(i.id),t.startedStepIds=e.steps.map(l=>l.id).filter(l=>r.has(l)),await $e(e.pmRoot,t);let d=await i.apply();s=tn(d,`Step ${i.id} result`)}await ge(e,t,"step_applied",i.id),o.add(i.id),t.completedStepIds=e.steps.map(c=>c.id).filter(c=>o.has(c)),nn(t.results,i.id,s,`Step ${i.id} result`),await $e(e.pmRoot,t),await ge(e,t,"step_recorded",i.id)}return await ge(e,t,"committing"),t.status="committed",await $e(e.pmRoot,t),await ge(e,t,"committed"),{transactionId:t.transactionId,status:"committed",recovered:n,results:Re(t.results)}}catch(o){if(o instanceof en||t.status==="committed")throw o;try{await Uo(e,t)}catch(r){throw new AggregateError([o,r],`Workspace transaction failed and compensation failed: ${String(r)}`,{cause:r})}throw o}}async function us(e,t,n){try{return ds(await ts(Mo(e,t),"utf8"),t,n)}catch(o){if(o!==null&&typeof o=="object"&&"code"in o&&ne(o))return;throw o}}async function ge(e,t,n,o){await e.onTransition?.({transactionId:t.transactionId,attempt:t.attempt,transition:n,...o===void 0?{}:{stepId:o}})}async function ms(e,t){let n=new Set,o=Re();for(let r of t){let i=await r.inspect();i.state==="applied"&&(n.add(r.id),nn(o,r.id,i.result,`Step ${r.id} result`))}e.results=o,e.completedStepIds=t.map(r=>r.id).filter(r=>n.has(r))}async function Uo(e,t){t.status="compensating",await $e(e.pmRoot,t),await ge(e,t,"compensating");let n=new Set(t.completedStepIds),o=new Set(t.startedStepIds);for(let r of[...e.steps].reverse()){if(!o.has(r.id)&&!n.has(r.id))continue;let i;try{i=o.has(r.id)&&(await r.inspect()).state==="applied"}catch{i=o.has(r.id)}i&&(await ge(e,t,"step_compensating",r.id),await r.compensate(t.compensationData[r.id])),n.delete(r.id),o.delete(r.id),t.completedStepIds=e.steps.map(a=>a.id).filter(a=>n.has(a)),t.startedStepIds=e.steps.map(a=>a.id).filter(a=>o.has(a)),delete t.results[r.id],delete t.compensationData[r.id],await $e(e.pmRoot,t),await ge(e,t,"step_compensated",r.id)}t.status="compensated",await $e(e.pmRoot,t),await ge(e,t,"compensated")}async function Go(e){let t=No(e.pmRoot,"Transaction pmRoot"),n=Po(e.transactionId,"Transaction id"),o=No(e.author,"Transaction author"),r=Do(e.lockTtlSeconds,rs,"Transaction lock TTL"),i=Do(e.lockWaitMs,is,"Transaction lock wait"),a=[...e.steps];if(a.length===0)throw new TypeError("Workspace transaction requires at least one step");let s=a.map(l=>{let p=Po(l.id,"Transaction step id");if(p!==l.id)throw new TypeError("Transaction step id must not contain surrounding whitespace");return p});if(new Set(s).size!==s.length)throw new TypeError("Workspace transaction step ids must be unique");let c={...e,pmRoot:t,transactionId:n,author:o,steps:a,lockTtlSeconds:r,lockWaitMs:i},d=await Y(t,ns,r,o,!1,!1,i);try{let l=await us(t,n,s),p=l!==void 0;if(l?.status==="committed")return{transactionId:n,status:"committed",recovered:!0,results:Re(l.results)};let u=await ls(c,n,o,s,l);return await ps(c,u.journal,p||u.recovered)}finally{await d()}}import{readFile as fs,writeFile as hs}from"node:fs/promises";import nt from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="89261a49-97e5-5ffc-a81c-2409f0b529cf")}catch{}})();var Jo="# pm-cli:runtime-cache:start",on="# pm-cli:runtime-cache:end",qo=".agents/pm",gs=["runtime/","search/","locks/","transactions/","checkpoints/"],ys=["search/eval-queries.json"];async function zo(e){try{return await e()}catch(t){throw t instanceof Error&&"code"in t&&typeof t.code=="string"&&["EACCES","EPERM","EROFS"].includes(t.code)?new h("The workspace .gitignore is not writable.",g.GENERIC_FAILURE,{code:"init_gitignore_unwritable",reason:t.code.toLowerCase(),required:"Grant the current user read and write access to the workspace .gitignore before initialization.",why:"pm init must publish its managed runtime-cache ignore fence without replacing unrelated entries.",nextSteps:["Grant read and write access to the workspace .gitignore and rerun pm init.","If the workspace is intentionally read-only, initialize pm in a writable workspace or clone."]}):t}}function Bo(e){return e.replaceAll("\\","/").replace(/^\.\/+/,"").replace(/\/+$/,"")}function rn(e){let t=e.replaceAll("\\","/");return nt.isAbsolute(e)||t===".."||t.startsWith("../")}function _s(e=qo){let t=Bo(e);return[Jo,...gs.map(n=>n==="search/"?`${t}/${n}*`:`${t}/${n}`),...ys.map(n=>`!${t}/${n}`),on].join(`
3
3
  `)}async function Wo(e,t={}){let n=nt.join(e,".gitignore"),o=qo;if(t.pmRoot!==void 0){let l=Bo(nt.relative(nt.resolve(e),nt.resolve(t.pmRoot)));if(rn(l))return{path:n,changed:!1};l.length>0&&(o=l)}let r="";try{r=await zo(()=>fs(n,"utf8"))}catch(l){if(!(l instanceof Error&&"code"in l&&ne(l)))throw l}let i=r.indexOf(Jo),a=r.indexOf(on),c=(i>=0&&a>=i?`${r.slice(0,i)}${r.slice(a+on.length)}`:r).trimEnd(),d=`${c.length>0?`${c}
4
4
 
@@ -74,4 +74,4 @@ Agent guidance check
74
74
  `),V.write(`Telemetry helps improve reliability and can be disabled anytime via pm config.
75
75
  `);let c=t?"Y/n":"y/N",d=await n.question(`Enable telemetry for this project? [${c}] `),l=Ua(d,t);return V.write(`
76
76
  `),{prefix:r,preset:s,telemetry_enabled:l}}finally{n.close()}}function xu(e){return{presetFromOption:Vn(e.preset),useDefaults:e.defaults===!0,authorFromOption:ja(e.author),installBundledPackages:e.withPackages===!0,agentGuidanceMode:Ma(e.agentGuidance),typePreset:Da(e.typePreset)}}function Su(e){let t=[];return e.prefixArg!==void 0&&e.settings.id_prefix!==e.normalizedPrefix&&t.push("id_prefix"),e.presetFromOption!==void 0&&e.settings.governance.preset!==e.presetFromOption&&t.push("governance_preset"),e.authorFromOption!==void 0&&e.settings.author_default!==e.authorFromOption&&t.push("author_default"),t}function Eu(e,t,n,o){if(t.length===0||n)return;let r=o.discovery==="ancestor";throw new h(`${r?`No tracker exists in ${o.requested_cwd}; pm init found an ancestor tracker at ${o.tracker_root}. `:""}Refusing to update existing tracker settings at ${e} without --force.`,g.USAGE,{code:"init_existing_settings_requires_force",type:"urn:pm-cli:error:init_existing_settings_requires_force",required:`--force for ${t.join(", ")}`,why:r?"Ancestor discovery is useful for normal commands, but init must make the selected existing workspace explicit before changing its identity or policy settings.":"pm init is safe to rerun, but changing id prefix, governance preset, or default author on an existing tracker can corrupt long-lived project context when an agent meant to initialize a sandbox path.",resolved_path:o.tracker_root,requested_path:o.requested_cwd,suggested_path:o.suggested_current_tracker_root,examples:["pm init --yes","pm init ./sandbox-pm --yes",...r?['pm init <name> --yes --pm-path "$PWD/.agents/pm"']:[],"pm init acme --yes --force"],nextSteps:[...r?['To create a new tracker in the current directory, rerun with --pm-path "$PWD/.agents/pm".']:[],"If you meant to initialize a sandbox tracker, pass a path-like positional such as ./sandbox-pm or /tmp/pm-test.","If you intentionally want to rewrite this existing tracker's init-managed settings, rerun with --force."]})}function $u(e){let t=!1;return e.prefixArg!==void 0&&e.settings.id_prefix!==e.normalizedPrefix&&(e.settings.id_prefix=e.normalizedPrefix,e.warnings.push(`updated:id_prefix:${e.normalizedPrefix}`),t=!0),e.presetFromOption!==void 0&&e.settings.governance.preset!==e.presetFromOption&&(Yn(e.settings,e.presetFromOption),e.warnings.push(`updated:governance_preset:${e.presetFromOption}`),t=!0),e.authorFromOption!==void 0&&e.settings.author_default!==e.authorFromOption&&(e.settings.author_default=e.authorFromOption,e.warnings.push(`updated:author_default:${e.authorFromOption}`),t=!0),t}async function Au(e){let t=await O(e.pmRoot);e.warnings.push(`already_exists:${e.settingsPath}`);let n=Su({settings:t,normalizedPrefix:e.normalizedPrefix,prefixArg:e.prefixArg,presetFromOption:e.normalizedOptions.presetFromOption,authorFromOption:e.normalizedOptions.authorFromOption});return Eu(e.settingsPath,n,e.options.force===!0,e.target),$u({settings:t,normalizedPrefix:e.normalizedPrefix,prefixArg:e.prefixArg,presetFromOption:e.normalizedOptions.presetFromOption,authorFromOption:e.normalizedOptions.authorFromOption,warnings:e.warnings})&&await Ee(e.pmRoot,t),{settings:t,normalizedPrefix:e.normalizedPrefix,chosenPreset:e.normalizedOptions.presetFromOption,wizardUsed:!1}}async function Tu(e){let t=e.normalizedPrefix,n=e.normalizedOptions.presetFromOption,o,r=!1;if(e.normalizedOptions.presetFromOption===void 0&&!e.normalizedOptions.useDefaults&&process.stdin.isTTY===!0&&process.stdout.isTTY===!0){let c=await Wa(t,Ht.telemetry.enabled);t=c.prefix,n=c.preset,o=c.telemetry_enabled,r=!0}let i=n??"minimal",a=vu();a.id_prefix=t,Yn(a,i);let s=bo()?.trim()||void 0;return a.author_default=e.normalizedOptions.authorFromOption??s??"",o!==void 0&&(a.telemetry.enabled=o,a.telemetry.first_run_prompt_completed=!0),await Ee(e.pmRoot,a),{settings:a,normalizedPrefix:t,chosenPreset:n,wizardUsed:r}}async function Ca(e){return e.settingsExists?await Au(e):await Tu({pmRoot:e.pmRoot,normalizedPrefix:e.normalizedPrefix,normalizedOptions:e.normalizedOptions})}async function Iu(e){let t=await Oa({pm_root:e.pmRoot,cwd:e.cwd,mode:e.agentGuidanceMode,interactive:process.stdin.isTTY===!0&&process.stdout.isTTY===!0,settings:e.settings});return e.warnings.push(...t.warnings),t.settings_changed&&await Ee(e.pmRoot,e.settings),{...t.summary,next_steps:t.next_steps}}async function Ou(e,t){let n=[],o=[],r=await vo(e,t.schema);for(let i of r.created_paths)n.push(i),o.push(...await q({path:i,scope:"project",op:"init:runtime_schema_file"}));return{createdDirs:n,warnings:o}}async function Cu(e){if(e.typePreset===void 0)return;let t=await za(e.pmRoot,e.settings,e.typePreset);return e.warnings.push(`registered_type_preset:${e.typePreset}`),e.warnings.push(...await q({path:t.file,scope:"project",op:"init:type_preset"})),t}async function Ru(e){let n=J(e.settings,B()).folders.filter(r=>!Wt.includes(r)),o=await Ba(e.pmRoot,n);e.createdDirs.push(...o.createdDirs),e.warnings.push(...o.warnings)}function Pu(e){let t=F.resolve(e.tracker_root),n=F.dirname(t);return F.basename(t)==="pm"&&F.basename(n)===".agents"?F.dirname(n):e.workspace_root}async function Nu(e,t,n,o){if(!e)return;let r=await Jn("all",{install:!0,project:!0},{...t,path:n});o.push(...r.warnings);let i=Ga(r),a=i.packages.filter(s=>!s.ok).map(s=>s.alias);if(!i.installed_all||a.length>0)throw new h(`pm init --with-packages did not install all bundled packages successfully${a.length>0?`: ${a.join(", ")}`:"."}`,g.GENERIC_FAILURE);return i}function Ha(e){let t=o=>xt([...e.target.mode==="workspace-discovery"?[]:["--pm-path",e.target.tracker_root],...o]),n=[`Create your first item: ${t(["create","--type","Task","--title","<title>"])}`,`List active items: ${t(["list"])}`,`Get agent-friendly project context: ${t(["context"])}`];e.installBundledPackages?n.push(`Explore newly-available commands: ${t(["cal"])}, ${t(["templates"])}, ${t(["guide"])}`):(n.push(`Add optional packages for richer workflows: ${t(["install","calendar","--project"])}, ${t(["install","templates","--project"])}, ${t(["install","guide-shell","--project"])}`),n.push(`Or install everything bundled: ${t(["init","--with-packages"])} (idempotent on re-run)`)),e.registeredTypePreset&&n.push(`Inspect registered preset types: ${t(["schema","list"])}, ${t(["schema","show",e.registeredTypePreset.registered[0]??e.registeredTypePreset.updated[0]])}`),n.push("Supported agent harnesses are attributed automatically; use --author or PM_AUTHOR only when an explicit identity override is required.");for(let o of e.agentGuidanceNextSteps){let r=e.target.mode==="workspace-discovery"?o:o.replace(/\bpm (?=[a-z])/g,()=>`${t([])} `);n.includes(r)||n.push(r)}return n}async function Ka(e,t,n,o=mn){if(t===null){n.push("merge_fence_skipped:not_git_repository:run pm merge install after moving the tracker into a Git repository");return}try{let r=await o({pmRoot:e,workspaceRoot:t});r.gitattributes.changed&&n.push(`updated:merge_fence:${r.gitattributes.path}`)}catch(r){if(!(r instanceof h))throw r;n.push(`merge_fence_skipped:install_failed:${r.context.code??"pm_error"}:${r.message}:run pm merge install after resolving the Git repository error`)}}async function y_(e,t,n={}){let o=process.cwd(),r=Fa(o,t,e,n.workspace),i=r.pmRoot;e=La(r.prefixArg,n.idPrefix);let a=xu(n);await qa(i,r.target.mode==="tracker-path",n.force===!0);let s=[],c=[],d=F.join(i,"settings.json"),l=await x(d),p;l&&(p=await Ca({pmRoot:i,settingsPath:d,settingsExists:l,normalizedPrefix:Se(e),prefixArg:e,options:n,normalizedOptions:a,warnings:c,target:r.target}));let u=await Ba(i,Wt);s.push(...u.createdDirs),c.push(...u.warnings),p??=await Ca({pmRoot:i,settingsPath:d,settingsExists:l,normalizedPrefix:Se(e),prefixArg:e,options:n,normalizedOptions:a,warnings:c,target:r.target});let{settings:m}=p,y=Pu(r.target),w=await ln(y??F.dirname(i)),f=y??w,_=await Iu({pmRoot:i,cwd:f??o,agentGuidanceMode:a.agentGuidanceMode,settings:m,warnings:c}),v=await Ou(i,m);s.push(...v.createdDirs),c.push(...v.warnings);let k=await Cu({pmRoot:i,settings:m,typePreset:a.typePreset,warnings:c});if(k&&(m=await O(i)),await Ru({pmRoot:i,settings:m,createdDirs:s,warnings:c}),f&&a.agentGuidanceMode!=="status"){let C=await Wo(f,{pmRoot:i});C.changed&&c.push(`updated:gitignore:${C.path}`)}!l&&n.mergeFence!==!1&&a.agentGuidanceMode!=="status"&&await Ka(i,w,c);let T=await Nu(a.installBundledPackages,t,i,c),R=Ha({installBundledPackages:a.installBundledPackages,registeredTypePreset:k,agentGuidanceNextSteps:_.next_steps,target:r.target});return{ok:!0,path:i,target:r.target,settings:m,created_dirs:s,warnings:c,governance_preset:m.governance.preset,wizard_used:p.wizardUsed,...k?{registered_type_preset:k}:{},...T?{installed_packages:T}:{},next_steps:R,agent_guidance:_}}export{en as a,Go as b,Jo as c,on as d,gs as e,_s as f,Wo as g,Ge as h,vs as i,an as j,xt as k,Yu as l,ks as m,xs as n,Ko as o,St as p,Zo as q,ze as r,cn as s,Ts as t,ln as u,un as v,or as w,gm as x,ym as y,rr as z,_m as A,mn as B,mr as C,Be as D,We as E,fr as F,lr as G,Je as H,qe as I,pr as J,mc as K,vr as L,Sr as M,pc as N,uc as O,$f as P,Af as Q,Tf as R,it as S,If as T,Of as U,Cf as V,Rf as W,Pf as X,Nf as Y,Df as Z,jf as _,Ff as $,Lf as aa,Mf as ba,Uf as ca,Gf as da,zf as ea,Jf as fa,qf as ga,Bf as ha,Wf as ia,Hf as ja,Kf as ka,Vf as la,Yf as ma,Xf as na,Zf as oa,Qf as pa,b as qa,we as ra,Ot as sa,Oc as ta,st as ua,Ct as va,Wr as wa,ni as xa,Nn as ya,gi as za,fg as Aa,xl as Ba,Ci as Ca,Ri as Da,Dn as Ea,hl as Fa,gl as Ga,yl as Ha,wi as Ia,vi as Ja,Jn as Ka,ya as La,By as Ma,Oa as Na,h_ as Oa,g_ as Pa,y_ as Qa};
77
- //# sourceMappingURL=chunk-XAVMOK6B.js.map
77
+ //# sourceMappingURL=chunk-73UGEBRS.js.map