@unbrained/pm-cli 2026.8.15 → 2026.8.17

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 (176) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/CHANGELOG.md +56 -12
  3. package/README.md +13 -13
  4. package/dist/cli/error-guidance.d.ts +5 -0
  5. package/dist/cli/error-guidance.js +15 -2
  6. package/dist/cli/public.d.ts +2 -0
  7. package/dist/cli/public.js +21 -0
  8. package/dist/cli/register-history-author.js +16 -11
  9. package/dist/cli/register-mutation.js +4 -4
  10. package/dist/cli-bundle/bundle-manifest.json +143 -143
  11. package/dist/cli-bundle/chunks/{chunk-J42EGKDK.js → chunk-2QLOXC3V.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-LJHOAVGI.js → chunk-3UEGXBMR.js} +49 -43
  13. package/dist/cli-bundle/chunks/chunk-4JPYF536.js +35 -0
  14. package/dist/cli-bundle/chunks/chunk-6VDLG2FC.js +13 -0
  15. package/dist/cli-bundle/chunks/chunk-7IBRGCHX.js +2 -0
  16. package/dist/cli-bundle/chunks/chunk-HBJAS566.js +8 -0
  17. package/dist/cli-bundle/chunks/chunk-ION3E43Q.js +197 -0
  18. package/dist/cli-bundle/chunks/{chunk-WLPDLNEZ.js → chunk-JOKATURE.js} +4 -4
  19. package/dist/cli-bundle/chunks/{chunk-MEM2ZS3O.js → chunk-TPXZIBIV.js} +5 -5
  20. package/dist/cli-bundle/chunks/chunk-YM2YAMF7.js +2 -0
  21. package/dist/cli-bundle/chunks/{register-list-query-CT3LFDDN.js → register-list-query-Q7KII4G5.js} +2 -2
  22. package/dist/cli-bundle/chunks/{register-mutation-NWEVA5YS.js → register-mutation-4WBRPXLV.js} +3 -3
  23. package/dist/cli-bundle/chunks/{register-operations-AHIAG5KM.js → register-operations-SSENDH5B.js} +2 -2
  24. package/dist/cli-bundle/chunks/{register-setup-ZJZFVAKE.js → register-setup-DOSFBGKE.js} +2 -2
  25. package/dist/cli-bundle/focused-chunks/{chunk-WTSER4WJ.js → chunk-267MUUS6.js} +11 -11
  26. package/dist/cli-bundle/focused-chunks/chunk-2NNFLLNG.js +2 -0
  27. package/dist/cli-bundle/focused-chunks/chunk-2QSAKMIH.js +2 -0
  28. package/dist/cli-bundle/focused-chunks/{chunk-ZMFXQ7VF.js → chunk-ATEY76SX.js} +2 -2
  29. package/dist/cli-bundle/focused-chunks/chunk-BUCG4ZI2.js +2 -0
  30. package/dist/cli-bundle/focused-chunks/{chunk-M67F5AIN.js → chunk-CYFK5UPB.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/chunk-EHXIKD6K.js +2 -0
  32. package/dist/cli-bundle/focused-chunks/{chunk-EXZA4257.js → chunk-KGEXTMPG.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/chunk-KP2VQQVQ.js +2 -0
  34. package/dist/cli-bundle/focused-chunks/chunk-MHPIL773.js +2 -0
  35. package/dist/cli-bundle/focused-chunks/chunk-POEEAD2V.js +4 -0
  36. package/dist/cli-bundle/focused-chunks/{chunk-ITAUHSO6.js → chunk-SALH6B6K.js} +47 -47
  37. package/dist/cli-bundle/focused-chunks/{chunk-KLVUMNXJ.js → chunk-SYZENPIT.js} +3 -3
  38. package/dist/cli-bundle/focused-chunks/{chunk-KTKH4IMG.js → chunk-XKAMP5OU.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-NSPYTG6G.js → chunk-XPIC53VA.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-6XKF3PGV.js → chunk-ZQPGZZWQ.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/chunk-ZT2DJS27.js +155 -0
  42. package/dist/cli-bundle/main.js +10 -10
  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 +31 -31
  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 -32
  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 +4 -2
  53. package/dist/core/extensions/loader.js +10 -6
  54. package/dist/core/extensions/manifest-schema.d.ts +20 -0
  55. package/dist/core/extensions/manifest-schema.js +52 -0
  56. package/dist/core/history/replay.js +32 -14
  57. package/dist/core/history/workspace-history.js +32 -10
  58. package/dist/core/output/output.js +6 -3
  59. package/dist/core/schema/fields-file.d.ts +1 -1
  60. package/dist/core/schema/fields-file.js +2 -2
  61. package/dist/core/schema/runtime-field-values.js +115 -9
  62. package/dist/core/schema/runtime-schema.d.ts +3 -1
  63. package/dist/core/schema/runtime-schema.js +124 -3
  64. package/dist/core/shared/errors.d.ts +12 -0
  65. package/dist/core/shared/errors.js +2 -2
  66. package/dist/core/shared/time.d.ts +2 -0
  67. package/dist/core/shared/time.js +27 -2
  68. package/dist/core/store/item-store.js +28 -2
  69. package/dist/sdk/agent/refusal-reachability.d.ts +56 -8
  70. package/dist/sdk/agent/refusal-reachability.js +414 -4
  71. package/dist/sdk/author-attribution.d.ts +56 -11
  72. package/dist/sdk/author-attribution.js +174 -50
  73. package/dist/sdk/cli-contracts/flag-contracts.js +5 -2
  74. package/dist/sdk/cli-contracts/tool-parameter-tables.js +12 -4
  75. package/dist/sdk/cli-contracts/tool-schema.js +12 -4
  76. package/dist/sdk/completion.js +11 -4
  77. package/dist/sdk/compose.d.ts +6 -2
  78. package/dist/sdk/compose.js +33 -3
  79. package/dist/sdk/context-intent-contracts.d.ts +8 -4
  80. package/dist/sdk/context-intent-contracts.js +76 -31
  81. package/dist/sdk/dependency-flag-validation.d.ts +9 -2
  82. package/dist/sdk/dependency-flag-validation.js +101 -35
  83. package/dist/sdk/environment/host-environment-errors.js +25 -7
  84. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +62 -14
  85. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +50 -2
  86. package/dist/sdk/governance/assurance-action.d.ts +3 -7
  87. package/dist/sdk/governance/assurance-action.js +97 -2
  88. package/dist/sdk/governance/boundary-fixtures.d.ts +86 -0
  89. package/dist/sdk/governance/boundary-fixtures.js +201 -0
  90. package/dist/sdk/governance/coverage-assurance.d.ts +24 -0
  91. package/dist/sdk/governance/coverage-assurance.js +61 -0
  92. package/dist/sdk/governance/defect-recurrence-signals.d.ts +10 -0
  93. package/dist/sdk/governance/defect-recurrence-signals.js +25 -0
  94. package/dist/sdk/governance/defect-recurrence.d.ts +242 -0
  95. package/dist/sdk/governance/defect-recurrence.js +523 -0
  96. package/dist/sdk/governance/extension-host-version.js +20 -9
  97. package/dist/sdk/governance.d.ts +2 -0
  98. package/dist/sdk/governance.js +4 -2
  99. package/dist/sdk/graph/governance.js +3 -2
  100. package/dist/sdk/guide-topics.js +191 -2
  101. package/dist/sdk/index.d.ts +5 -1
  102. package/dist/sdk/index.js +6 -3
  103. package/dist/sdk/lifecycle/create.js +4 -2
  104. package/dist/sdk/lifecycle/update-many.js +15 -2
  105. package/dist/sdk/lifecycle/update.js +5 -2
  106. package/dist/sdk/linked-artifacts.js +63 -14
  107. package/dist/sdk/query/get.d.ts +2 -0
  108. package/dist/sdk/query/get.js +32 -7
  109. package/dist/sdk/read-output-contracts.js +5 -3
  110. package/dist/sdk/relationship-analytics.js +90 -14
  111. package/dist/sdk/relationship-kinds/contract.d.ts +4 -0
  112. package/dist/sdk/relationship-kinds/contract.js +3 -2
  113. package/dist/sdk/relationships.d.ts +1 -1
  114. package/dist/sdk/relationships.js +11 -2
  115. package/dist/sdk/runtime.d.ts +2 -5
  116. package/dist/sdk/runtime.js +3 -2
  117. package/dist/sdk/schema.d.ts +1 -0
  118. package/dist/sdk/schema.js +2 -2
  119. package/dist/sdk/test/execution.d.ts +6 -2
  120. package/dist/sdk/test/execution.js +39 -13
  121. package/dist/types.d.ts +29 -2
  122. package/dist/types.js +4 -2
  123. package/docs/CONFIGURATION.md +58 -1
  124. package/docs/CONTEXT_INTEGRITY_CONTRACTS.md +58 -0
  125. package/docs/DEFECT_RECURRENCE.md +134 -0
  126. package/docs/DEPENDENCY_KIND_CONTRACT.md +12 -2
  127. package/docs/README.md +2 -0
  128. package/docs/READ_OUTPUT_CONTRACTS.md +7 -1
  129. package/docs/RELATIONSHIP_GRAPH.md +16 -2
  130. package/docs/RELEASING.md +13 -7
  131. package/docs/SDK.md +38 -5
  132. package/docs/SDK_CONTEXT_INTEGRITY.md +33 -5
  133. package/docs/SDK_CONTEXT_TRUTH_CONTRACTS.md +13 -5
  134. package/docs/SDK_RUNTIME_BOUNDARIES.md +9 -1
  135. package/docs/TESTING.md +18 -1
  136. package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +1 -1
  137. package/marketplace.json +2 -2
  138. package/package.json +6 -4
  139. package/packages/pm-beads/package.json +1 -1
  140. package/packages/pm-calendar/package.json +1 -1
  141. package/packages/pm-command-kit/package.json +1 -1
  142. package/packages/pm-digital-twin/package.json +1 -1
  143. package/packages/pm-governance-audit/package.json +1 -1
  144. package/packages/pm-guide-shell/package.json +1 -1
  145. package/packages/pm-kanban/package.json +1 -1
  146. package/packages/pm-lifecycle-hooks/package.json +1 -1
  147. package/packages/pm-linked-test-adapters/package.json +1 -1
  148. package/packages/pm-search-advanced/package.json +1 -1
  149. package/packages/pm-templates/package.json +1 -1
  150. package/packages/pm-todos/package.json +1 -1
  151. package/packages/pm-vcs/package.json +1 -1
  152. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  153. package/plugins/pm-claude/skills/pm-audit/SKILL.md +26 -0
  154. package/plugins/pm-claude/skills/pm-developer/SKILL.md +26 -0
  155. package/plugins/pm-claude/skills/pm-planner/SKILL.md +26 -0
  156. package/plugins/pm-claude/skills/pm-release/SKILL.md +26 -0
  157. package/plugins/pm-claude/skills/pm-workflow/SKILL.md +26 -0
  158. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  159. package/plugins/pm-codex/skills/pm-auditor/SKILL.md +26 -0
  160. package/plugins/pm-codex/skills/pm-native/SKILL.md +26 -0
  161. package/plugins/pm-codex/skills/pm-release/SKILL.md +26 -0
  162. package/sdk/public-surface.json +716 -33
  163. package/dist/cli-bundle/chunks/chunk-24GAV7XL.js +0 -8
  164. package/dist/cli-bundle/chunks/chunk-AIM6VT2N.js +0 -13
  165. package/dist/cli-bundle/chunks/chunk-DSWDLTDR.js +0 -197
  166. package/dist/cli-bundle/chunks/chunk-KIEGUBYQ.js +0 -2
  167. package/dist/cli-bundle/chunks/chunk-KLKYLSDX.js +0 -2
  168. package/dist/cli-bundle/chunks/chunk-QHPCJWEJ.js +0 -35
  169. package/dist/cli-bundle/focused-chunks/chunk-4X57RE4U.js +0 -2
  170. package/dist/cli-bundle/focused-chunks/chunk-7NJ4QYQ2.js +0 -2
  171. package/dist/cli-bundle/focused-chunks/chunk-KT5XMYSX.js +0 -4
  172. package/dist/cli-bundle/focused-chunks/chunk-OKA6ELTL.js +0 -2
  173. package/dist/cli-bundle/focused-chunks/chunk-PUISBOPP.js +0 -2
  174. package/dist/cli-bundle/focused-chunks/chunk-QLNMCESQ.js +0 -155
  175. package/dist/cli-bundle/focused-chunks/chunk-SLKC6QLJ.js +0 -2
  176. package/dist/cli-bundle/focused-chunks/chunk-U65UC4G3.js +0 -2
@@ -1,2 +0,0 @@
1
- import{k as A}from"./chunk-WLPDLNEZ.js";import{$ as b,C as f,E as h,Ef as E,Nd as k,Od as y,Ti as S,el as m}from"./chunk-DSWDLTDR.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="271cf7c1-f84b-5f59-aa13-ed8cb4ee232f")}catch{}})();var F=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),x=new Map([["files","discover"],["item","complete"]]),G=new Set(["--author","--output-budget","--output-format","--output-include","--output-limit","--output-session","--path","--pm-path"]),$=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function R(e){let t=e?.trim().toLowerCase()??"";return F.has(t)||x.has(t)}function L(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(G.has(n)){t+=1;continue}if(!n.startsWith("-"))return t}}function O(e,t,n){let o=x.get(n);if(o===void 0)return t+1;let s=e[t+1]?.toLowerCase()===o;if(!(!s&&!F.has(n)))return t+(s?2:1)}function U(e){let t=new Map;for(let n of m(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function q(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function j(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let s=n.get(e);return s!==void 0&&s.value_type!=="boolean"}function K(e,t,n,o,s){let i=0;for(let r=t;r<e.length;r+=1){let a=e[r];if(a==="--")break;if(a==="--id"){r+=1;continue}if(!a.startsWith("--id=")){if(!a.startsWith("-")){if(r<o)return!0;i+=1;continue}j(a,e[r+1],s)&&(r+=1)}}return i>($.get(n)??0)}function N(e){let t=L(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(!R(n))return{argv:[...e],changed:!1,conflict:!1};let o=x.get(n)===e[t+1]?.toLowerCase()?`${n} ${e[t+1]?.toLowerCase()}`:n,s=U(o),i=q(e),r=i[0];if(!r||!r.value?.trim())return{argv:[...e],changed:!1,conflict:!1};let a=O(e,t,n);if(a===void 0)return{argv:[...e],changed:!1,conflict:!1};if(i.length>1||K(e,a,o,r.index,s))return{argv:[...e],changed:!1,conflict:!0,itemId:r.value};let u=[...e.slice(0,r.index),...e.slice(r.index+r.consumed)],c=L(u),l=O(u,c,n);return u.splice(l,0,r.value),{argv:u,changed:!0,conflict:!1,itemId:r.value}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="eccdb2d2-da6f-555b-ba1b-8339f9b64f1a")}catch{}})();var g=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),Y=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),D=e=>{let t=e.indexOf("=");return t>0&&g.has(e.slice(0,t))},_=(e,t)=>typeof t!="string"?!1:e==="--path"||e==="--pm-path"||!t.startsWith("-"),T=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract"]);function X(e,t,n){let o=e[t];if(T.has(o))return n.booleanFlags.add(o),1;let s=o.indexOf("="),i=s>0?o.slice(0,s):o;if(!g.has(i))return 1;let r=s>0?o.slice(s+1):void 0,a=r===void 0&&_(i,e[t+1]),u=r??(a?e[t+1]:void 0);return i==="--author"?n.author=u??"":typeof u=="string"&&u.length>0&&(Y.has(i)?n.outputValues:n.pathValues).set(i,u),a?2:1}function J(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=X(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions"),noPager:t.booleanFlags.has("--no-pager"),json:t.booleanFlags.has("--json"),quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...t.outputValues.get("--output-format")==="toon"||t.outputValues.get("--output-format")==="json"?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function M(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(T.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(g.has(o)){n+=_(o,e[n+1])?2:1;continue}if(D(o)){n+=1;continue}t.push(o),n+=1}return t}function Z(e){let t=M(e);if(t[0]?.trim().toLowerCase()==="help"){let i=[];for(let r=1;r<t.length;r+=1){let a=t[r];if(a.startsWith("-"))break;i.push(a.trim().toLowerCase())}return{requested:!0,commandPathTokens:i}}if(t.findIndex(i=>i==="--help"||i==="-h")<0)return{requested:!1,commandPathTokens:[]};let s=[];for(let i of t){if(i.startsWith("-"))break;s.push(i.trim().toLowerCase())}return{requested:!0,commandPathTokens:s}}function I(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")return;if(g.has(n)){t+=_(n,e[t+1])?1:0;continue}if(!(D(n)||T.has(n)||n==="--profile"||n==="--id-only"||n==="--explain")&&!n.startsWith("-"))return t}}function C(e){let t=I(e);return t===void 0?void 0:e[t].trim().toLowerCase()}function H(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:Z(e).requested}function Ve(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(i=>process.env[i]),o=()=>{for(let[i,r]of t.entries()){let a=n[i];a===void 0?delete process.env[r]:process.env[r]=a}},s=J(e);return H(e,s)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var Q=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function ee(e){let t=I(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!Q.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var te=new Set(["pm","pm-cli"]);function ne(e,t){let n=I(e);if(n===void 0)return e;let o=e[n];return te.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function oe(e,t){let n=I(e);if(n===void 0)return e;let o=e[n],s=S[o.trim().toLowerCase()];if(!s)return e;let i=[...e];return i[n]=s,t.push({from:o,to:[s],reason:"command_alias",confidence:"high"}),i}function w(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function P(e){return w(e).replace(/-/g,"")}function V(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function se(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function ie(e,t){let n=t??m(e),o=new Map,s=new Map,i=new Map,r=new Set;for(let a of n){let u=se(a);if(u.length===0)continue;let c=`--${w(u[0])}`;for(let d of u)V(o,w(d),c),V(s,P(d),c);let l=P(c);i.has(c)||i.set(c,l),a.list===!0&&r.add(c)}return{canonicalByNormalized:o,canonicalByCompact:s,canonicalComparables:[...i.entries()].map(([a,u])=>({canonicalFlag:a,comparable:u})),listCanonicalFlags:r}}function B(e,t){let n=w(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let s=n.replace(/-/g,""),i=t.canonicalByCompact.get(s);if(typeof i=="string")return{flag:i,reason:"flag_alias",confidence:"high"};let r=s.length>=8?2:1,a=Number.POSITIVE_INFINITY,u,c=!1;for(let l of t.canonicalComparables){let d=b(s,l.comparable,r);if(d!==null){if(d<a){a=d,u=l.canonicalFlag,c=!1;continue}d===a&&u!==l.canonicalFlag&&(c=!0)}}return!u||c||!Number.isFinite(a)||a<=0?null:{flag:u,reason:"flag_typo",confidence:a>=2?"medium":"high"}}function De(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function re(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],s=n[3];return s.length===0?null:{key:o,value:s}}function ae(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),s=o>=0?e.slice(0,o):e,i=o>=0?e.slice(o+1):void 0,r=B(s,t);if(!r)return{tokens:[e]};let a=i===void 0?r.flag:`${r.flag}=${i}`;return a===e?{tokens:[e]}:{tokens:[a],event:{from:e,to:[a],reason:r.reason,confidence:r.confidence}}}function ue(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let s=e[o];n=s==="--path"||s==="--pm-path"}return t}function ce(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function le(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function de(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let s=[],i=t+1;for(;i<e.length&&e[i]!=="--"&&!e[i].startsWith("-")&&(s.length===0||o.has(n.flag));)s.push(e[i]),i+=1;let r=s.length===0?1:1+s.length;return{originalTokens:e.slice(t,t+r),value:s.length===0?void 0:s.join(","),consumed:r}}function fe(e,t,n,o){let s=e.get(n);if(s){s.values.push(o.value),s.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function pe(e,t){let n=[],o=[];for(let[s,i]of e){if(!(i.occurrences>=2||t.has(s)&&i.originalTokens.length>2)){o.push({outputIndex:i.outputIndex,tokens:i.originalTokens});continue}let a=`${s}=${i.values.join(",")}`;o.push({outputIndex:i.outputIndex,tokens:[a]}),n.push({from:`${s} (x${i.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function he(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function me(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let s=[],i=new Map,r=0;for(;r<e.length;){let c=e[r];if(c==="--"){s.push(...e.slice(r));break}if(n.has(c)){r=le(e,r,s);continue}let l=ce(c);if(!l||!t.has(l.flag)){s.push(c),r+=1;continue}let d=de(e,r,l,o);if(d.value===void 0){s.push(c),r+=d.consumed;continue}fe(i,s,l.flag,{originalTokens:d.originalTokens,value:d.value}),r+=d.consumed}let{events:a,splices:u}=pe(i,o);return he(s,u),{argv:s,events:a}}var v=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function ge(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],s=v.get(o);return s!==void 0&&s.has(n)}function be(e,t){return e==="search"||ge(e,t)}function ye(e,t,n){if(t!=="test")return e;let o=[],s=0;for(;s<e.length;){let i=e[s];if(i==="--")return o.push(...e.slice(s)),o;let r=v.get(i),a=r?e[s+1]:void 0;if(!r||typeof a!="string"||!r.has(a)){o.push(i),s+=1;continue}let u=s+2;for(;u<e.length&&!e[u].startsWith("-");)u+=1;if(u-(s+2)!==1){o.push(i),s+=1;continue}let c=e[s+2],l=`${a}=${c}`;o.push(i,l),n.push({from:`${i} ${a} ${c}`,to:[i,l],reason:"bare_key_value",confidence:"high"}),s+=3}return o}function we(e,t,n,o){let s=[],i=ue(e);for(let r=0;r<e.length;r+=1){let a=e[r];if(a==="--"){s.push(...e.slice(r));break}let u=i.has(r),c=s[s.length-1];if(a.startsWith("--")){let d=ae(a,t,u);s.push(...d.tokens),d.event&&o.push(d.event);continue}let l=re(a,u);if(l&&!(typeof c=="string"&&c.startsWith("-"))&&!be(n,s)){let d=B(l.key,t);if(d){let p=[d.flag,l.value];s.push(...p),o.push({from:a,to:p,reason:"bare_key_value",confidence:d.confidence});continue}}s.push(a)}return s}function Me(e){let t=[],n=ne(e,t),o=ee(n);(o.length!==n.length||o.some((p,W)=>p!==n[W]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let s=oe(o,t),i=N(s);if(i.conflict)throw new h("Provide the item id either positionally or with --id, not both.",f.USAGE);i.changed&&t.push({from:`--id ${i.itemId}`,to:[i.itemId],reason:"item_id_alias",confidence:"high"});let r=C(i.argv),a=Ie(i.argv),u=ie(a??r),c=we(i.argv,u,r,t),l=ye(c,r,t),d=me(l,u.listCanonicalFlags,g,r==="create"?new Set(["--tags"]):new Set);for(let p of d.events)t.push(p);return{argv:d.argv,commandName:r,trace:t}}function Ie(e){let t=M(e),n=t[0]?.trim().toLowerCase(),o=t[1]?.trim().toLowerCase();return(n==="extension"||n==="package"||n==="packages")&&typeof o=="string"&&o.length>0&&!o.startsWith("-")?`${n} ${o}`:n}function Be(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return o}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4973a995-60f0-5990-9927-371dc6716063")}catch{}})();function z(e){return e.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function $e(e){if(!(!Array.isArray(e)||e.length===0))return C(e)}function xe(e,t){let n=z(t);if(!n)return;let o=m(e).find(s=>s.flag===n||s.aliases?.includes(n));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function Re(e,t,n){let o=[...e],s=o.indexOf("--"),i=s<0?o.length:s;for(let r of n){let a=z(r);if(!a||o.slice(0,i).some(l=>l===a||l.startsWith(`${a}=`)))continue;let u=xe(t,a),c=u?[a,u]:[a];o.splice(i,0,...c),i+=c.length}return o.length===e.length?void 0:A(o)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d82065d1-488d-523e-9df2-a30056f29603")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="5810cf1d-fc9a-597b-a47e-a914009fadfa")}catch{}})();function Je(e){return e instanceof h||e instanceof Error?e.message:"Unknown failure"}function _e(e){if(typeof e!="object"||e===null||!("exitCode"in e))return;let t=e.exitCode;return typeof t=="number"&&Number.isFinite(t)?t:void 0}function Te(e){let t=Math.trunc(e);return t>f.SUCCESS?t:f.GENERIC_FAILURE}function Ze(e){return typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string"&&e.code.startsWith("commander.")}function He(e,t){if(e instanceof Error)return e;let n=new Error(t),o=_e(e);return o!==void 0&&(n.exitCode=Te(o)),n}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8f7cca3d-9b19-53b4-a510-5290aaf75e12")}catch{}})();function ot(e){if(e===void 0)return()=>{};let t=e.trim();if(t.length===0)throw new h("--author requires a non-empty value.",f.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let n=k();y(t);let o=!1;return()=>{o||(o=!0,n===void 0?y(void 0):y(n))}}import{Command as Ce}from"commander";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="03d46cbf-73bc-50c9-b4e6-e7329ee53076")}catch{}})();function at(e){return new Ce().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(e).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:t=>{E(t)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the read-output encoding").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume a budget-compacted declared row collection").option("--output-row-contract","Include the machine-readable row selector and TOON encoding contract").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").exitOverride()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71e5a870-f62f-5252-b4e9-e1a42e36009f")}catch{}})();var ke={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"]};function Ee(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let s=n.split(" "),i=ke[o]?.indexOf(n);if(i!==void 0&&i>=0)return i;if(n===o)return 10;if(s.includes(o))return 11;if(s.some(u=>u.startsWith(o)))return 12;let r=o.length>=5?2:1,a=Number.POSITIVE_INFINITY;for(let u of s){let c=b(u,o,r);c!==null&&(a=Math.min(a,c))}return Number.isFinite(a)?20+a:n.includes(o)?30:Number.POSITIVE_INFINITY}function lt(e,t){return e.map(n=>({path:n,score:Ee(n,t)})).filter(n=>Number.isFinite(n.score)).sort((n,o)=>n.score!==o.score?n.score-o.score:n.path===o.path?0:n.path<o.path?-1:1).map(n=>n.path)}export{R as a,N as b,J as c,M as d,Z as e,I as f,C as g,Ve as h,ee as i,De as j,me as k,ye as l,Me as m,Be as n,$e as o,xe as p,Re as q,Je as r,_e as s,Te as t,Ze as u,He as v,ot as w,at as x,Ee as y,lt as z};
2
- //# sourceMappingURL=chunk-KIEGUBYQ.js.map
@@ -1,2 +0,0 @@
1
- import{$b as B,Wb as z,Xb as K,Yb as S,bb as P,bc as F,cc as L}from"./chunk-LJHOAVGI.js";import{b as x}from"./chunk-WLPDLNEZ.js";import{$,C as c,E as d,Hb as k,Td as N,bj as D,ej as G,nk as j,rg as C,tg as U,tk as v,w as O}from"./chunk-DSWDLTDR.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="687855bf-7432-5691-a809-1f0406b5d8a8")}catch{}})();import ie from"node:crypto";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="07876c03-63a8-5c69-9c6c-c3446076a382")}catch{}})();var b=["op","id","reason","options"],J=[...b,"ref"],W=["schema_version","mutations"],Q="[a-z][a-z0-9._-]{0,63}",Y=new RegExp(`^${Q}$`,"u"),ee=new RegExp(`(^|,)id=@(${Q})(?=,|$)`,"gu"),q=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),E=["item","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],te=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count"]),se=new Set([...te,"completed_at","id"]),_=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...O,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]),V={create:D.map(e=>e.target),update:G.map(e=>e.target),close:j.map(e=>q(e.flag)).filter(e=>e!=="reason"),release:v.map(e=>q(e.flag))};function lt(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new d("createCompensation must be close or delete.",c.USAGE);t.createCompensation=n}for(let r of["lockTtlSeconds","lockWaitMs"]){let o=e[r];if(o===void 0)continue;let i=typeof o=="number"||typeof o=="string"&&o.trim().length>0?Number(o):Number.NaN;if(!Number.isSafeInteger(i)||i<=0)throw new d(`${r} must be a positive safe integer.`,c.USAGE);t[r]=i}return t}function p(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function g(e,t){let n=Math.max(1,Math.min(3,Math.floor(e.length/4)+1)),r;for(let o of t){let i=$(e,o,n);i!==null&&(r===void 0||i<r.distance)&&(r={key:o,distance:i})}return r?.key}function y(e,t,n){let r=g(t,n);return new d(r===void 0?`${e} does not recognize key "${t}". Allowed keys: ${n.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${r}"?`,c.USAGE,{code:"stdin_json_unknown_key",required:`Use documented ${e} keys only.`,why:"Strict structured input prevents silent typos from creating incomplete or unintended mutations.",nextSteps:[r===void 0?`Remove or correct "${t}".`:`Replace "${t}" with "${r}".`]})}function R(e,t){try{return JSON.parse(e)}catch(n){let r=n instanceof Error?n.message:String(n);throw new d(`${t} must be valid JSON: ${r}`,c.USAGE,{code:"stdin_json_invalid",required:`Pipe one valid JSON ${t.toLowerCase()} into stdin.`,why:"Structured mutation input must parse deterministically before any tracker write begins."})}}function ae(e,t){if(!p(e))throw new d(`Mutation ${t+1} must be an object.`,c.USAGE);for(let n of Object.keys(e))if(!b.includes(n))throw y(`mutation ${t+1}`,n,b);return e}function ce(e,t,n){if(e!==void 0){if(!p(e))throw new d(`Mutation ${n+1} options must be an object.`,c.USAGE);for(let r of Object.keys(e))if(!V[t].includes(r))throw y(`mutation ${n+1} ${t} options`,r,V[t]);return e}}function de(e,t){let n=ae(e,t),{op:r,id:o,reason:i}=n;if(r!=="create"&&r!=="update"&&r!=="close"&&r!=="release")throw new d(`Mutation ${t+1} op must be create, update, close, or release.`,c.USAGE);let s=ce(n.options,r,t);if(typeof o!="string"||o.trim().length===0)throw new d(`Mutation ${t+1} requires a non-empty id.`,c.USAGE);let a=o.trim();if(r==="close"){if(typeof i!="string"||i.trim().length===0)throw new d(`Mutation ${t+1} close requires a non-empty reason.`,c.USAGE);return{op:r,id:a,reason:i.trim(),...s===void 0?{}:{options:s}}}if(r==="release")return{op:r,id:a,...s===void 0?{}:{options:s}};if(!p(s))throw new d(`Mutation ${t+1} ${r} requires an options object.`,c.USAGE);return{op:r,id:a,options:s}}function ne(e){let t=R(e,"Mutation batch"),n=Array.isArray(t)?t:p(t)&&Array.isArray(t.mutations)?t.mutations:void 0;if(n===void 0||n.length===0)throw new d("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",c.USAGE);return n.map((r,o)=>de(r,o))}function ue(e,t,n){let r=ie.createHash("sha256").update(e).update("\0").update(t).digest("hex"),o=BigInt(`0x${r.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${C(n)}${o}`}function H(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let n=e.slice(1),r=t[n];if(r===void 0)throw new d(`Unknown mutation reference "${e}".`,c.USAGE);return r}function X(e,t){if(typeof e!="string")return e;let n=e.replace(ee,(r,o,i)=>{let s=t[i];if(s===void 0)throw new d(`Unknown mutation reference "@${i}".`,c.USAGE);return`${o}id=${s}`});if(/(^|,)id=@/u.test(n))throw new d(`Malformed mutation reference in dependency "${e}".`,c.USAGE);return n}function pe(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(ee)].map(t=>t[1]).filter(t=>t!==void 0)}function fe(e){let t=new Map;for(let i of e){if(i.op!=="create"||typeof i.ref!="string")continue;let s=p(i.options)?i.options:{},a=Array.isArray(s.dep)?s.dep:s.dep===void 0?[]:[s.dep];t.set(i.ref,[s.parent,s.blockedBy,...a].flatMap(pe))}let n=new Set,r=new Set,o=i=>{if(n.has(i))throw new d(`Mutation reference cycle includes "@${i}".`,c.USAGE);if(!r.has(i)){n.add(i);for(let s of t.get(i))t.has(s)&&o(s);n.delete(i),r.add(i)}};for(let i of t.keys())o(i)}function le(e){let t=R(e,"Mutation document"),n=Array.isArray(t)?{schema_version:1,mutations:t}:t;if(!p(n))throw new d("Mutation document must be a JSON array or object.",c.USAGE);for(let r of Object.keys(n))if(!W.includes(r))throw y("mutation document",r,W);if(n.schema_version!==void 0&&n.schema_version!==1)throw new d("Mutation document schema_version must be 1.",c.USAGE);if(!Array.isArray(n.mutations)||n.mutations.length===0)throw new d("Mutation document requires a non-empty mutations array.",c.USAGE);return n.mutations.map((r,o)=>{if(!p(r))throw new d(`Mutation ${o+1} must be an object.`,c.USAGE);for(let i of Object.keys(r))if(!J.includes(i))throw y(`mutation ${o+1}`,i,J);return{...r}})}function me(e,t){let n=Object.create(null);for(let[r,o]of e.entries())if(o.ref!==void 0){if(o.op!=="create")throw new d(`Mutation ${r+1} ref is only valid for create operations.`,c.USAGE);if(typeof o.ref!="string"||!Y.test(o.ref))throw new d(`Mutation ${r+1} ref must match ${Y.source}.`,c.USAGE);if(n[o.ref]!==void 0)throw new d(`Duplicate mutation ref "${o.ref}".`,c.USAGE);n[o.ref]=typeof o.id=="string"&&o.id.trim().length>0?U(o.id,t.idPrefix):ue(t.transactionId,o.ref,t.idPrefix)}return n}function mt(e,t){let n=le(e),r=me(n,t);fe(n);let o=n.map(a=>{let u={...a},m=typeof u.ref=="string"?u.ref:void 0;if(delete u.ref,m!==void 0?u.id=r[m]:u.id=H(u.id,r),p(u.options)){let f={...u.options};for(let w of["parent","blockedBy"])f[w]!==void 0&&(f[w]=H(f[w],r));Array.isArray(f.dep)?f.dep=f.dep.map(w=>X(w,r)):f.dep!==void 0&&(f.dep=X(f.dep,r)),u.options=f}return u}),i=ne(JSON.stringify(o)),s=i.filter(a=>a.op==="create").map(a=>a.id);if(new Set(s).size!==s.length)throw new d("Duplicate resolved create id in mutation document.",c.USAGE);return{schema_version:1,mutations:i,references:r}}function re(e,t){return t.filter(n=>e[n]!==void 0&&e[n]!==null).map(n=>{let r=String(e[n]);return`${n}=${/[",\n\r\\]/u.test(r)?JSON.stringify(r):r}`}).join(",")}function ye(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(p))throw new d(`${n} must be an array of objects.`,c.USAGE);return e.map(r=>re(r,t))}}function he(e,t){return e==="tags"&&Array.isArray(t)&&t.every(n=>typeof n=="string")?JSON.stringify(t):typeof t=="number"||typeof t=="boolean"?String(t):t}function Z(e,t,n=!1){let r=[["dependencies","dep",["id","kind","created_at","author","source_kind"]],["comments","comment",["text","created_at","author"]],["notes","note",["text","created_at","author"]],["learnings","learning",["text","created_at","author"]],["files","file",["path","scope","note"]],["tests","test",["command","scope","timeout_seconds"]],["docs","doc",["path","scope","note"]],["reminders","reminder",["at","text","created_at"]],["events","event",["start_at","end_at","title","location"]],["type_options","typeOption",["key","value"]]];for(let[o,i,s]of r){let a=t[o],u=ye(n&&["comments","notes","learnings"].includes(o)&&Array.isArray(a)?a.filter(m=>!p(m)||m.created_at===void 0):a,s,o);u!==void 0&&u.length>0&&(e[i]=u)}}function we(e,t){for(let n of Object.keys(e)){if(t){if(!E.includes(n))throw y("item envelope",n,E);continue}if(!_.has(n)&&g(n,[..._])===void 0&&g(n,E)==="item")throw y("item envelope",n,E)}}function _e(e){let t=Object.hasOwn(e,"item");we(e,t);let n=t?e.item:e;if(!p(n))throw new d("Item document item must be an object.",c.USAGE);return{item:n,...t&&p(e.linked)?{linked:e.linked}:{}}}function Ee(e,t,n,r){if(!(r==="update"?se:te).has(t)){if(!_.has(t)){if(g(t,[..._])!==void 0)throw y("item document",t,[..._]);let s=Array.isArray(e.field)?e.field:[];s.push(re({key:t,value:typeof n=="string"?n:JSON.stringify(n)},["key","value"])),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(i,s)=>s.toUpperCase())]=he(t,n))}}function yt(e,t,n={}){let r=R(e,"Item document");if(!p(r))throw new d("Item document must be a JSON object.",c.USAGE);let{item:o,linked:i}=_e(r),s={};for(let[a,u]of Object.entries(o))Ee(s,a,u,t);return Z(s,o,t==="update"),i!==void 0&&Z(s,i),{...s,...Object.fromEntries(Object.entries(n).filter(([,a])=>a!==void 0)),stdinJson:void 0}}function ht(e){return ne(JSON.stringify(e))}import ge from"node:crypto";import Ae 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]="ed638747-7a72-5332-87fc-c82088457b91")}catch{}})();async function l(e,t){try{let r=(await P(t,{},{pmRoot:e})).item;return{id:r.id,closedAt:r.closed_at,updatedAt:r.updated_at,assignee:r.assignee,claimPrincipal:r.claim_principal}}catch(n){if(n instanceof d&&n.exitCode===c.NOT_FOUND)return;throw n}}function I(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=ge.createHash("sha256").update(k(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function Te(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function h(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}async function A(e,t,n,r){let o=await N(Ae.join(e,"history",`${t}.jsonl`),t),i=h(n,r,"apply"),s=h(n,r,"compensate");for(let a=o.length-1;a>=0;a-=1){let u=o[a].message;if(u===i)return!0;if(u===s)return!1}return!1}async function M(e,t){let n=await l(e,t.id);if(n?.updatedAt===void 0)throw new d(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,c.NOT_FOUND);return{target_updated_at:n.updatedAt}}async function T(e,t,n,r){let o=r!==null&&typeof r=="object"&&!Array.isArray(r)?r.target_updated_at:void 0;typeof o=="string"&&await l(e.pmRoot,t)!==void 0&&await L(t,o,{force:!0,author:e.author,message:h(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot})}function oe(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"create"}}},async apply(){let o=(await z({...t.options,author:e.author,id:t.id},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"create"}},async compensate(){let r=await l(e.pmRoot,t.id);if(r!==void 0){if(e.createCompensation==="delete"){await F(t.id,{force:!0,author:e.author,message:`Compensate interrupted bulk transaction ${e.transactionId}`},{pmRoot:e.pmRoot});return}r.closedAt===void 0&&await S(t.id,`Compensated: interrupted bulk transaction ${e.transactionId}`,{force:!0,author:e.author},{pmRoot:e.pmRoot})}}}}function Se(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await A(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let o=(await K(t.id,{...t.options,author:e.author,message:h(e.transactionId,n,"apply")},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"update"}},async compensate(r){await T(e,t.id,n,r)}}}function be(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await A(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"close"}}:r.closedAt===void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"close"}}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let o=(await S(t.id,t.reason,{...t.options,author:e.author,message:h(e.transactionId,n,"apply")},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"close"}},async compensate(r){await T(e,t.id,n,r)}}}function Re(e,t,n){return{id:n,async inspect(){let r=await l(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await A(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"release"}}:r.assignee!==void 0||r.claimPrincipal!==void 0?{state:"pending"}:{state:"applied",result:{id:r.id,op:"release"}}},async prepareCompensation(){return M(e.pmRoot,t)},async apply(){let o=(await B(t.id,{...t.options,author:e.author,message:h(e.transactionId,n,"apply")},{pmRoot:e.pmRoot})).item;return{id:String(o.id),op:"release"}},async compensate(r){await T(e,t.id,n,r)}}}function Ie(e,t,n){let r=I(t,n);switch(t.op){case"create":return oe(e,t,r);case"update":return Se(e,t,r);case"close":return be(e,t,r);case"release":return Re(e,t,r)}}function Me(e,t){if(e===null||typeof e!="object"||Array.isArray(e))throw new TypeError(`Bulk mutation ${t+1} must be an object`);if(!["create","update","close","release"].includes(e.op))throw new TypeError(`Bulk mutation ${t+1} op must be create, update, close, or release`);if(typeof e.id!="string"||e.id.trim().length===0)throw new TypeError(`Bulk mutation ${t+1} requires a non-empty id`);if(e.op==="close"&&(typeof e.reason!="string"||e.reason.trim().length===0))throw new TypeError(`Bulk close mutation ${t+1} requires a non-empty reason`)}async function Oe(e){let t=[...e.mutations];if(t.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");for(let[s,a]of t.entries())Me(a,s);let n=e.createCompensation??"close";if(!["close","delete"].includes(n))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let r={pmRoot:e.pmRoot,author:e.author,transactionId:e.transactionId,createCompensation:n},o=await x({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,steps:t.map((s,a)=>Ie(r,s,a)),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),i={};for(let[s,a]of t.entries()){let u=I(a,s),m=o.results[u];i[Te(a,s)]=m}return{transactionId:o.transactionId,status:"committed",recovered:o.recovered,results:i}}function $e(e){let t=[];return e.evidence!==void 0&&Object.keys(e.evidence).length>0&&t.push({op:"update",id:e.id,options:e.evidence}),t.push({op:"close",id:e.id,reason:e.reason,...e.closeOptions===void 0?{}:{options:e.closeOptions}},{op:"release",id:e.id,...e.releaseOptions===void 0?{}:{options:e.releaseOptions}}),t}function It(e){return Oe({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:$e(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var Mt={buildCreateStep:oe,bulkHistoryMarker:h,compensateByRestore:T,deriveStepId:I,isUpdateMarkerApplied:A,readItemSnapshot:l};export{lt as a,ne as b,mt as c,yt as d,ht as e,Oe as f,$e as g,It as h,Mt as i};
2
- //# sourceMappingURL=chunk-KLKYLSDX.js.map