@unbrained/pm-cli 2026.11.17 → 2026.11.19

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 (124) 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-2UTJ5QIE.js +71 -0
  4. package/dist/cli-bundle/chunks/{chunk-VLKCFZY6.js → chunk-4FNMPZ7Y.js} +2 -2
  5. package/dist/cli-bundle/chunks/chunk-723PMYNX.js +125 -0
  6. package/dist/cli-bundle/chunks/{chunk-77MGDTK4.js → chunk-AGPFANRX.js} +3 -3
  7. package/dist/cli-bundle/chunks/{chunk-RXNBNF6O.js → chunk-AMHD7WIV.js} +2 -2
  8. package/dist/cli-bundle/chunks/{chunk-7K2RUKMK.js → chunk-AOV5HG3Y.js} +2 -2
  9. package/dist/cli-bundle/chunks/{chunk-36R3JTAD.js → chunk-CNMGGAZO.js} +2 -2
  10. package/dist/cli-bundle/chunks/{chunk-XPBADEUK.js → chunk-CTOE26W4.js} +2 -2
  11. package/dist/cli-bundle/chunks/{chunk-FXSLODOK.js → chunk-GQCMICAL.js} +2 -2
  12. package/dist/cli-bundle/chunks/{chunk-ABFHWRLE.js → chunk-IQKCRLQP.js} +2 -2
  13. package/dist/cli-bundle/chunks/{chunk-QANUQMDL.js → chunk-IUTN67EB.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-M76BEWTT.js +31 -0
  15. package/dist/cli-bundle/chunks/{chunk-ADKDFCVT.js → chunk-N2CPCFSN.js} +2 -2
  16. package/dist/cli-bundle/chunks/{chunk-KIQNEOKJ.js → chunk-NMVPQTZI.js} +2 -2
  17. package/dist/cli-bundle/chunks/{chunk-XP35IEHT.js → chunk-O7IFAJ76.js} +2 -2
  18. package/dist/cli-bundle/chunks/{chunk-X5TFNFTS.js → chunk-OESI2ETD.js} +2 -2
  19. package/dist/cli-bundle/chunks/{chunk-ACLBUVQG.js → chunk-P4A5RFLX.js} +2 -2
  20. package/dist/cli-bundle/chunks/{chunk-QZNL5XDT.js → chunk-PRVT7ITI.js} +2 -2
  21. package/dist/cli-bundle/chunks/{chunk-O4ZSIMNC.js → chunk-Q32Q3LRH.js} +2 -2
  22. package/dist/cli-bundle/chunks/{chunk-DXSZL3T6.js → chunk-XPBPGDFW.js} +2 -2
  23. package/dist/cli-bundle/chunks/{chunk-4FIN2XWC.js → chunk-Z5LHCEXG.js} +2 -2
  24. package/dist/cli-bundle/chunks/{item-revision-7RVMVXTE.js → item-revision-YJKGOYBR.js} +2 -2
  25. package/dist/cli-bundle/chunks/item-transaction-K4YZ7GWR.js +2 -0
  26. package/dist/cli-bundle/chunks/{mutation-admission-3PKQOAYK.js → mutation-admission-JLMQJ2M5.js} +2 -2
  27. package/dist/cli-bundle/chunks/{register-list-query-TPZLHFHQ.js → register-list-query-4AXLLXK7.js} +2 -2
  28. package/dist/cli-bundle/chunks/{register-mutation-JG5AEBRJ.js → register-mutation-FJIXGGF4.js} +2 -2
  29. package/dist/cli-bundle/chunks/{register-operations-3CNXP46P.js → register-operations-W4E2KEMA.js} +2 -2
  30. package/dist/cli-bundle/chunks/{register-setup-4N56VL2P.js → register-setup-RYRIBNSN.js} +2 -2
  31. package/dist/cli-bundle/focused-chunks/{chunk-VBA4BIHN.js → chunk-2XULTI5B.js} +2 -2
  32. package/dist/cli-bundle/focused-chunks/{chunk-2MQNIDKG.js → chunk-4S7I342K.js} +2 -2
  33. package/dist/cli-bundle/focused-chunks/{chunk-GD2YWUAD.js → chunk-77CDWGBW.js} +55 -54
  34. package/dist/cli-bundle/focused-chunks/{chunk-BNLLST32.js → chunk-7A4VIRIU.js} +2 -2
  35. package/dist/cli-bundle/focused-chunks/{chunk-SESMRMEE.js → chunk-D72EQN7Z.js} +2 -2
  36. package/dist/cli-bundle/focused-chunks/{chunk-YWPLBFPC.js → chunk-GAOWBALE.js} +23 -23
  37. package/dist/cli-bundle/focused-chunks/chunk-N64BUB63.js +27 -0
  38. package/dist/cli-bundle/focused-chunks/{chunk-XJS4COL2.js → chunk-OF4UM5B6.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-6JQXDGHM.js → chunk-P4TG4VMJ.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{item-revision-U7GDVAH7.js → item-revision-32HFGFYG.js} +2 -2
  41. package/dist/cli-bundle/focused-chunks/{item-transaction-7C4BH47O.js → item-transaction-C4VW3SHX.js} +2 -2
  42. package/dist/cli-bundle/focused-chunks/{mutation-admission-SKXVITP5.js → mutation-admission-PNK6ORZR.js} +2 -2
  43. package/dist/cli-bundle/main.js +2 -2
  44. package/dist/cli-bundle/sdk-authoring.js +1 -1
  45. package/dist/cli-bundle/sdk-core.js +1 -1
  46. package/dist/cli-bundle/sdk-governance.js +1 -1
  47. package/dist/cli-bundle/sdk-merge.js +58 -58
  48. package/dist/cli-bundle/sdk-query.js +1 -1
  49. package/dist/cli-bundle/sdk-runtime.js +1 -1
  50. package/dist/cli-bundle/sdk-testing.js +1 -1
  51. package/dist/cli-bundle/sdk.js +11 -11
  52. package/dist/core/fs/file-glob.js +2 -0
  53. package/dist/core/shared/process-tree.js +3 -0
  54. package/dist/core/shared/secret-rules.d.ts +94 -4
  55. package/dist/core/shared/secret-rules.js +5 -4
  56. package/dist/sdk/extension/managed-state.d.ts +3 -1
  57. package/dist/sdk/extension/managed-state.js +1 -1
  58. package/dist/sdk/extension/managed-update-status.js +1 -1
  59. package/dist/sdk/extension/update-check.d.ts +42 -6
  60. package/dist/sdk/extension/update-check.js +1 -1
  61. package/dist/sdk/extension.d.ts +3 -1
  62. package/dist/sdk/extension.js +1 -1
  63. package/dist/sdk/index.d.ts +1 -1
  64. package/dist/sdk/index.js +1 -1
  65. package/dist/sdk/linked-artifacts.js +2 -2
  66. package/dist/sdk/mutation-guard.d.ts +146 -5
  67. package/dist/sdk/mutation-guard.js +1 -1
  68. package/dist/sdk/public-surface.json +1 -1
  69. package/dist/sdk/test/execution.js +2 -2
  70. package/docs/COMMANDS.md +33 -0
  71. package/docs/CONFIGURATION.md +1 -0
  72. package/docs/DEFECT_RECURRENCE.md +3 -2
  73. package/docs/MUTATION_INTEGRITY.md +259 -7
  74. package/docs/PACKAGE_EVIDENCE.md +66 -0
  75. package/marketplace.json +1 -1
  76. package/package.json +1 -3
  77. package/packages/pm-beads/package.json +1 -1
  78. package/packages/pm-calendar/package.json +1 -1
  79. package/packages/pm-command-kit/package.json +1 -1
  80. package/packages/pm-digital-twin/package.json +1 -1
  81. package/packages/pm-governance-audit/package.json +1 -1
  82. package/packages/pm-guide-shell/package.json +1 -1
  83. package/packages/pm-kanban/package.json +1 -1
  84. package/packages/pm-lifecycle-hooks/package.json +1 -1
  85. package/packages/pm-linked-test-adapters/package.json +1 -1
  86. package/packages/pm-search-advanced/package.json +1 -1
  87. package/packages/pm-templates/package.json +1 -1
  88. package/packages/pm-todos/package.json +1 -1
  89. package/packages/pm-vcs/package.json +1 -1
  90. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  91. package/plugins/pm-claude/package.json +1 -1
  92. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  93. package/plugins/pm-codex/package.json +1 -1
  94. package/plugins/pm-codex/plugin.json +1 -1
  95. package/runtime-dependencies.json +1 -1
  96. package/dist/cli-bundle/chunks/chunk-2WHXFKMY.js +0 -31
  97. package/dist/cli-bundle/chunks/chunk-3IU2S5UQ.js +0 -70
  98. package/dist/cli-bundle/chunks/chunk-AM26RAG7.js +0 -124
  99. package/dist/cli-bundle/chunks/item-transaction-NVX6P3FK.js +0 -2
  100. package/dist/cli-bundle/focused-chunks/chunk-ZDY5L2C2.js +0 -26
  101. package/node_modules/fdir/LICENSE +0 -7
  102. package/node_modules/fdir/README.md +0 -91
  103. package/node_modules/fdir/dist/index.cjs +0 -588
  104. package/node_modules/fdir/dist/index.d.cts +0 -155
  105. package/node_modules/fdir/dist/index.d.mts +0 -155
  106. package/node_modules/fdir/dist/index.mjs +0 -570
  107. package/node_modules/fdir/package.json +0 -106
  108. package/node_modules/picomatch/LICENSE +0 -21
  109. package/node_modules/picomatch/README.md +0 -743
  110. package/node_modules/picomatch/index.js +0 -17
  111. package/node_modules/picomatch/lib/constants.js +0 -184
  112. package/node_modules/picomatch/lib/parse.js +0 -1425
  113. package/node_modules/picomatch/lib/picomatch.js +0 -361
  114. package/node_modules/picomatch/lib/scan.js +0 -403
  115. package/node_modules/picomatch/lib/utils.js +0 -72
  116. package/node_modules/picomatch/package.json +0 -83
  117. package/node_modules/picomatch/posix.js +0 -3
  118. package/node_modules/tinyglobby/LICENSE +0 -21
  119. package/node_modules/tinyglobby/README.md +0 -25
  120. package/node_modules/tinyglobby/dist/index.cjs +0 -335
  121. package/node_modules/tinyglobby/dist/index.d.cts +0 -148
  122. package/node_modules/tinyglobby/dist/index.d.mts +0 -148
  123. package/node_modules/tinyglobby/dist/index.mjs +0 -307
  124. package/node_modules/tinyglobby/package.json +0 -70
@@ -1,2 +1,2 @@
1
- import{Ab as Z,Bb as Q,Hb as A,Jb as w,Kc as ee,Lb as k,Lc as te,Nc as ne,jc as O,oc as S,wb as K,xb as X,yb as J,zb as I}from"./chunk-7K2RUKMK.js";import{L as R,b as E,ba as x,c as L,s as H,t as Y,ta as W,v as C,w as q}from"./chunk-AM26RAG7.js";import{Rb as m}from"./chunk-7UUPLMCU.js";import{A as u,C as f}from"./chunk-5OFMWP3Q.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]="202cbe4e-7d36-5b12-be9d-d35608a6b36d")}catch{}})();var Oe=new Set(["none","null"]);function it(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function g(e){return e===void 0?!1:Oe.has(e.trim().toLowerCase())}function st(e,t,n){if(!g(e))return;let a=n?` ${n}`:"";throw new f(`${t} no longer accepts "none" or "null".${a}`.trim(),u.USAGE)}function lt(e,t,n){if(!e||e.length===0||L(e)||!e.some(i=>g(i)))return;let a=n?` ${n}`:"";throw new f(`${t} no longer accepts "none" or "null".${a}`.trim(),u.USAGE)}function ct(e,t){for(let n of t){let a=e[n.optionKey];if(!Array.isArray(a)||a.length===0)continue;if(!a.every(r=>typeof r=="string"))throw new f(`${n.valueFlag} entries must be strings.`,u.USAGE);if(L(a))continue;let i=a;if(i.some(r=>g(r))){if(i.filter(r=>!g(r)).length>0)throw new f(`Cannot mix legacy clear token "none"/"null" with concrete ${n.valueFlag} entries. Use ${n.clearFlag} to clear or provide explicit entries.`,u.USAGE);e[n.optionKey]=void 0,e[n.clearFlagKey]=!0,n.disableFlagKey&&(e[n.disableFlagKey]=!1)}}return e}(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]="5146346c-df7b-5011-9d55-c59a7ff88f29")}catch{}})();var ge=["close_reason","close-reason"],ae=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],oe=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],Te=[...ae,...oe],re=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}],B=[...Te,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...re],he=[...ae,{canonical:"close-reason",aliases:ge,optionKey:"closeReason",metadataKey:"close_reason"},...oe,...re],ve=new Set(["none","null","-"]);function ie(e){return e==="create"?B:he}function F(e,t){let n=t.unset;if(n!==void 0&&typeof n!="string"&&!Array.isArray(n))return;let a=[];for(let i of ie(e))i.optionKey==="author"||!Object.hasOwn(t,i.optionKey)||t[i.optionKey]!==null||(Reflect.deleteProperty(t,i.optionKey),a.push(i.canonical));a.length!==0&&(t.unset=[...n===void 0?[]:typeof n=="string"?[n]:n,...a])}function U(e){return typeof e=="string"&&ve.has(e.trim().toLowerCase())}function pt(e,t,n,a){return n?ie(e).flatMap(i=>{let r=t[i.optionKey],o=a[i.metadataKey];return U(r)&&(U(o)||Array.isArray(o)&&o.some(U))?[`literal_sentinel_stored:${i.canonical}:${r.trim()}`]:[]}):[]}function Ee(e,t){return e.flatMap(n=>n.includes(",")&&t(n)?[n]:n.split(","))}function Ce(e){let t=new Set,n=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:n};let a=Ee(e.raw,i=>e.resolveDefinition(i.trim().toLowerCase())!==void 0);for(let i of a){let r=i.trim().toLowerCase();if(!r)throw new f("--unset values must not be empty; name each field once, for example --unset parent,release",u.USAGE);if(g(r))throw new f('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',u.USAGE);let o=e.resolveDefinition(r);if(!o)throw new f(`Unsupported --unset field "${i}". Supported fields: ${e.supportedFields}`,u.USAGE);t.add(o.metadataKey),n.add(o.optionKey)}return{metadataKeys:t,optionKeys:n}}function Se(e,t,n){let a=e.trim().toLowerCase();if(!n)return;let i=n.command_to_fields?.get(t)??[];for(let r of i){if(r.allow_unset===!1)continue;let o=new Set;if(typeof r.key=="string"&&r.key.length>0&&o.add(r.key.toLowerCase()),typeof r.metadata_key=="string"&&r.metadata_key.length>0&&o.add(r.metadata_key.toLowerCase()),typeof r.cli_flag=="string"&&r.cli_flag.length>0&&(o.add(r.cli_flag.replaceAll("-","_").toLowerCase()),o.add(r.cli_flag.toLowerCase())),Array.isArray(r.cli_aliases))for(let s of r.cli_aliases)typeof s!="string"||s.length===0||(o.add(s.replaceAll("-","_").toLowerCase()),o.add(s.toLowerCase()));if(o.has(a))return{optionKey:r.key,metadataKey:r.metadata_key}}}var Ne=(()=>{let e=new Map;for(let t of B)for(let n of t.aliases)e.set(n,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),be=B.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function yt(e,t){return Ce({raw:e,supportedFields:be,resolveDefinition:n=>Ne.get(n)??Se(n,"create",t)})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="837a5c2d-6447-5696-b0de-32641cde14cd")}catch{}})();var Re={create:'client.create({ type: "Task", title: "Example", createMode: "progressive" })',update:'client.update(id, { estimatedMinutes: "45", force: false })',append:'client.append(id, "Body text")',reopen:'client.reopen(id, "The work recurred", { expectedResult: "Verified recovery" })'};function T(e,t,n){let a=`${e} ${t} must be ${n}.`;throw new f(a,u.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",field:t,changed:!1,required:a,examples:[Re[e]]})}function N(e,t,n){typeof e!="string"&&T(t,n,"a string")}function $(e,t){(e===null||typeof e!="object"||Array.isArray(e))&&T(t,"options","an object")}function se(e,t){(e==="append"||e==="update")&&t.id!==void 0&&N(t.id,e,"id"),e==="item-reopen"&&(t.id!==void 0&&N(t.id,"reopen","id"),t.reason!==void 0&&N(t.reason,"reopen","reason"),t.options!==void 0&&Ke(t.options))}function Nt(e){$(e,"append");for(let t of["body","author","message"])e[t]!==void 0&&N(e[t],"append",t);e.force!==void 0&&typeof e.force!="boolean"&&T("append","force","a boolean")}function Ke(e){$(e,"reopen");for(let t of S["item-reopen"].optional){let n=e[t];n!==void 0&&(m(Reflect.get(O,t)).type==="boolean"?typeof n!="boolean"&&T("reopen",t,"a boolean"):N(n,"reopen",t))}}function Ie(e,t){return e?t?"a string or string array":"a string array":"a string"}function we(e,t,n,a,i,r){n===void 0||typeof n=="string"&&(!i||r)||a==="priority"&&typeof n=="number"&&Number.isFinite(n)||i&&Array.isArray(n)&&Array.from(n).every(o=>typeof o=="string")||T(e,t,Ie(i,r))}function ke(e,t,n){let a=e==="create"?w:k;for(let{param:i}of[...a,...A,{param:"force"}]){if(m(Reflect.get(O,i)).type!=="boolean")continue;let r=n.find(o=>o.keys.includes(i))?.keys??[i];for(let o of r)t[o]!==void 0&&typeof t[o]!="boolean"&&T(e,o,"a boolean")}}function G(e,t,n=!0,a=!1){let i=e==="create"?K:I;for(let{target:r,keys:o,repeatable:s}of i)if(m(Reflect.get(O,r)).type!=="boolean")for(let d of o){let _=a&&d!==r,y=s===!0&&(r!=="acceptanceCriteria"||_);we(e,d,t[d],r,y,n||_)}ke(e,t,i)}function bt(e,t){$(t,e);let n=H(t),a=E(n);return a||F(e,n),G(e,n,!1,a),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]="63a51994-4328-5a65-938c-d0de377ac338")}catch{}})();var Fe=Symbol("pm.mcp-mutation-transport"),Me=new Set(["create","update","append"]),P={create:{parameters:w,aliases:K,strings:X,repeatables:J},update:{parameters:k,aliases:I,strings:Z,repeatables:Q}},De=new Set(["activity","aggregate","context","contracts","deps","files-discover","files-lookup","get","graph","health","history","history-attest","list","next","search","stats","telemetry","validate"]);function b(e){return Fe in e}function D(e,t){return b(e)?Y(t):C(e,t)}function Vt(e,t,n=[]){let a=C(e,{...e,...t});for(let i of n)Reflect.deleteProperty(a,i);return a}function l(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n:void 0}function c(e,t){let n=e[t];return typeof n=="string"?n.trim().length>0?n:void 0:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function zt(e,t){let n=e[t];return typeof n=="string"?n:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function p(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ht(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new f(`${t} must be a finite integer.`,u.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let n=Number(e);if(!Number.isInteger(n))throw new f(`${t} must be a finite integer.`,u.USAGE);return n}}function Yt(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:l(e,"limit")??l(t,"limit")}function qt(e){let t=l(e,"outputFormat");return{json:!0,quiet:!0,author:l(e,"author"),path:l(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:l(e,"outputInclude"),outputLimit:c(e,"outputLimit"),outputBudget:c(e,"outputBudget"),outputSession:l(e,"outputSession"),outputCursor:l(e,"outputCursor"),outputFormat:t==="json"||t==="toon"?t:void 0}}var de=new Set(["tags","blockedBy","blocked_by","skills","fields"]),ue=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),Pe=new Set([...ue].filter(e=>e!=="file")),Le=new Set(["files","files-discover","docs","test","test-all"]),z=new Set(["comments","notes","learnings"]);function xe(e,t){if(!(!z.has(e)||!Object.prototype.hasOwnProperty.call(t,"file")))throw new f(`MCP ${e} does not accept options.file. Pass annotation text in options.add instead.`,u.USAGE,{code:"mcp_annotation_file_unavailable",required:"Pass annotation text as JSON data; MCP annotation actions cannot read server-local files."})}var Ue=new Set(["claim","release","start-task","pause-task","close-task"]),fe={history:["order"],"history-attest":["verify","output","hashAlgorithm"],list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate","inheritFocus"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt","releaseAssignment"],claim:["start","next","ifAvailable","takeoverStale"],"start-task":["takeoverStale"],release:["pause","handoff"],comments:["ifAbsent"],notes:["ifAbsent"],learnings:["ifAbsent"],extension:["dryRun","offline"],package:["dryRun","offline"],install:["dryRun"],upgrade:["scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"],append:["body"]},Be=new Set(["context","get","list","next","search","comments","notes","learnings","files","docs","test"]),$e=new Set(["query","keywords","id","text"]);function Ge(e){return Be.has(e)?S[e].optional.filter(t=>!$e.has(t)):[]}var je=new Set(["claim","start-task","comments","notes","learnings","files","docs","test"]);function Ve(e,t){if(!je.has(e??""))return t;let n={...t};for(let a of S[e].optional){let i=a.replace(/[A-Z]/gu,r=>`_${r.toLowerCase()}`);i===a||n[i]===void 0||(n[a]??=n[i],delete n[i])}return n}function ze(e,t,n){if(!z.has(e??""))return n;let a=n,i=a.text??t.text;if(i===void 0)return a;if(a.add!==void 0&&a.add!==i){let o=e.replace(/s$/u,"");throw new f(`Specify ${o} text either as text or with add, not both.`,u.USAGE,{code:"annotation_text_source_conflict",field:"text",required:`Pass the ${o} text once: text and add are the same source.`})}let r={...a,add:i};return delete r.text,r}function He(e,t){let n=t.replace(/[A-Z]/gu,a=>`_${a.toLowerCase()}`);return e[t]!==void 0||e[n]!==void 0}function Ye(e){return[...fe[e]??[],...Ge(e),...pe]}var pe=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function ye(e,t=""){let n={},a=Le.has(t),i=t==="files"||t==="files-discover"||t==="docs",r=z.has(t)?Pe:ue;for(let[o,s]of Object.entries(e)){if(Array.isArray(s)&&de.has(o)){n[o]=s.join(",");continue}if(o==="note"&&i){n[o]=s;continue}if(typeof s=="string"&&r.has(o)){n[o]=[s];continue}if(typeof s=="string"&&a&&(o==="add"||o==="remove")){n[o]=[s];continue}n[o]=s}return Object.assign(n,Object.fromEntries(Object.getOwnPropertySymbols(e).map(o=>[o,Reflect.get(e,o)]))),n}function qe(e,t,n){let a=l(e,"author");return a!==void 0?a:n!==void 0&&Ue.has(n)?l(e,"assignee")??l(t,"assignee"):void 0}function We(e,t){return t!==void 0&&e.author===void 0?{...e,author:t}:e}function Xe(e,t,n){let a={},i=P[e],r=new Set([...i.parameters.map(({param:o})=>o),...A.map(({param:o})=>o),...fe[e],...pe,"force"]);for(let o of r){let s=i.aliases.find(d=>d.keys.includes(o))?.keys??[o];t[o]===void 0||s.some(d=>n[d]!==void 0)||(a[o]=t[o])}return a}function h(e,t){throw new f(`Invalid MCP ${e} value for "${t}". No changes were made.`,u.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:t,required:`Provide valid ${e} field values and an options object; inspect the pm_${e} input schema for supported types.`})}function Je(e,t,n){let a=P[e],i=[...a.parameters,...A,{param:"force"}];for(let{param:r}of i){if(m(O[r]).type!=="boolean")continue;let o=(a.aliases.find(s=>s.keys.includes(r))?.keys??[r]).find(s=>n[s]!==void 0&&typeof n[s]!="boolean");o!==void 0&&h(e,o)}for(let r of["idOnly","fullChangedFields"])t[r]!==void 0&&typeof t[r]!="boolean"&&h(e,r)}function Ze(e,t,n){t.options!==void 0&&!p(t.options)&&h(e,"options"),Je(e,t,n);for(let o of de){let s=n[o];Array.isArray(s)&&s.some(d=>typeof d!="string")&&h(e,o)}let a=Ae(n,e),i=P[e];for(let{keys:o,target:s}of i.strings)o.some(d=>n[d]!==void 0)&&a[s]===void 0&&h(e,s);let r=i.repeatables.flatMap(({keys:o})=>o).find(o=>{let s=n[o];return s!==void 0&&typeof s!="string"&&(!Array.isArray(s)||s.some(d=>typeof d!="string"))});return r!==void 0&&h(e,r),a}function Qe(e,t,n,a,i){let r=(t==="create"||t==="update")&&b(e),o={...r?Xe(t,e,a):n,...a};if((t==="create"||t==="update")&&!r){let s=p(e.options)&&E(e.options);s||F(t,o),G(t,o,!0,s)}return r?Ze(t,e,o):i?ye(o,t):o}function et(e,t){return!Me.has(e??"")||E(t)?t:W(t)}function Wt(e,t,{nativeAction:n=!0}={}){se(t,e);let a=p(e.options)?e.options:void 0,i=m(e.options),r={},o=y=>{He(i,y)||e[y]===void 0||(r[y]=e[y])};for(let y of Ye(t??""))o(y);t!==void 0&&b(e)&&xe(t,i);let s=ze(t,e,Ve(t,Qe(e,t,r,i,n)));if(t==="history-attest"&&b(e)&&(s.output!==void 0||typeof s.verify=="string"))throw new f("MCP history attest does not accept server-local proof paths. Export the returned JSON bundle and pass that JSON object as verify.",u.USAGE);let d=b(e)?e:a??e,_=D(d,We(s,qe(e,s,t)));return et(t,_)}function Xt(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function Jt(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function tt(e){let t=[],n=!0;for(let a of e.trim().toLowerCase()){if(a>="a"&&a<="z"||a>="0"&&a<="9"){t.push(a),n=!1;continue}n||(t.push("-"),n=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function Zt(e){return!De.has(tt(e))}function Qt(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function nt(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function en(e,t){let n=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),a={};for(let[r,o]of Object.entries(e))n.has(r)||(a[r]=o);let i={...a,...t};return delete i.args,delete i.author,i}function tn(e,t){let n=D(t??{},{...t});return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:n}}function V(e){return{type:c(e,"filterType"),tag:c(e,"filterTag"),priority:c(e,"filterPriority"),deadlineBefore:c(e,"filterDeadlineBefore"),deadlineAfter:c(e,"filterDeadlineAfter"),updatedAfter:c(e,"filterUpdatedAfter"),updatedBefore:c(e,"filterUpdatedBefore"),createdAfter:c(e,"filterCreatedAfter"),createdBefore:c(e,"filterCreatedBefore"),ids:x(e.ids),assignee:c(e,"filterAssignee"),assigneeFilter:c(e,"filterAssigneeFilter")??c(e,"filterAssignee_filter"),parent:c(e,"filterParent"),sprint:c(e,"filterSprint"),release:c(e,"filterRelease"),limit:c(e,"limit"),offset:c(e,"offset")}}function j(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return nt(e)}function M(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function nn(e){let t=j(e.kind),n=j(e.exemptIsolate),a=j(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:M(e.maxDepth),limit:M(e.limit),after:l(e,"after"),direction:l(e,"direction"),maxPaths:M(e.maxPaths),sample:M(e.sample),...n===void 0?{}:{exemptIsolate:n},...a===void 0?{}:{exemptIsolateType:a},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function me(e){let t=ne(e);return e.ids!==void 0&&(t.ids=x(e.ids)),t}function an(e){return{status:l(e,"filterStatus"),list:p(e.list)?me(e.list):V(e),reason:l(e,"reason"),completedAt:l(e,"completedAt")??l(e,"completed_at"),resolution:l(e,"resolution"),expectedResult:l(e,"expectedResult")??l(e,"expected_result")??l(e,"expected"),actualResult:l(e,"actualResult")??l(e,"actual_result")??l(e,"actual"),validateClose:l(e,"validateClose")??l(e,"validate_close"),author:l(e,"author"),message:l(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var at=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function le(e){let t={};for(let[n,a]of Object.entries(e))at.has(n)||(t[n]=a);return _e(t)}function _e(e){return Ae(e,"update")}function Ae(e,t){let n=ye(e,t),a=P[t],i=new Set([...a.parameters,...A].filter(({booleanish:r})=>r===!0).map(({param:r})=>r));for(let{keys:r}of a.repeatables)for(let o of r)typeof n[o]=="string"&&(n[o]=[n[o]]);for(let r of a.strings)for(let o of r.keys){let s=n[o];(typeof s=="number"&&Number.isFinite(s)||s===!1&&i.has(o))&&(n[o]=String(s))}return t==="create"?{...ee(n,{requireType:!1})}:te(n)}function on(e){if(p(e.list)||p(e.update)){let t=p(e.update)?e.update:le(e),n=D(e,_e(t));return{status:c(e,"filterStatus"),list:p(e.list)?me(e.list):V(e),update:q(t,n),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}return{status:c(e,"filterStatus"),list:V(e),update:D(e,le(e)),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}function ce(e){return"expectHash"in e||"expect_hash"in e}function rn(e){if(!ce(e)&&!(p(e.options)&&ce(e.options)))return{expectHash:void 0,dispatchArgs:e};let{expectHash:t,expect_hash:n,...a}=e,i=p(a.options)?a.options:{},{expectHash:r,expect_hash:o,...s}=i,d=[t,n,r,o].filter(v=>v!==void 0),_=d.length>1?d.flatMap(v=>Array.isArray(v)?v:[v]):d[0],y=C(e,"options"in a?{...a,options:p(a.options)?C(a.options,s):a.options}:a);return{expectHash:_,dispatchArgs:y}}export{it as a,g as b,st as c,lt as d,ct as e,ge as f,B as g,he as h,pt as i,Ee as j,Ce as k,Se as l,yt as m,N as n,$ as o,Nt as p,Ke as q,bt as r,b as s,Vt as t,l as u,c as v,zt as w,p as x,Ht as y,Yt as z,qt as A,fe as B,ye as C,Wt as D,Xt as E,Jt as F,tt as G,Zt as H,Qt as I,nt as J,en as K,tn as L,V as M,nn as N,an as O,_e as P,on as Q,rn as R};
2
- //# sourceMappingURL=chunk-36R3JTAD.js.map
1
+ import{Ab as Z,Bb as Q,Hb as A,Jb as w,Kc as ee,Lb as k,Lc as te,Nc as ne,jc as O,oc as S,wb as K,xb as X,yb as J,zb as I}from"./chunk-AOV5HG3Y.js";import{L as R,b as E,ba as x,c as L,s as H,t as Y,ta as W,v as C,w as q}from"./chunk-723PMYNX.js";import{Rb as m}from"./chunk-7UUPLMCU.js";import{A as u,C as f}from"./chunk-5OFMWP3Q.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]="202cbe4e-7d36-5b12-be9d-d35608a6b36d")}catch{}})();var Oe=new Set(["none","null"]);function it(e={}){return[{optionKey:"dep",clearFlagKey:"clearDeps",valueFlag:"--dep",clearFlag:"--clear-deps",...e.depDisableFlagKey===void 0?{}:{disableFlagKey:e.depDisableFlagKey}},{optionKey:"comment",clearFlagKey:"clearComments",valueFlag:"--comment",clearFlag:"--clear-comments"},{optionKey:"note",clearFlagKey:"clearNotes",valueFlag:"--note",clearFlag:"--clear-notes"},{optionKey:"learning",clearFlagKey:"clearLearnings",valueFlag:"--learning",clearFlag:"--clear-learnings"},{optionKey:"file",clearFlagKey:"clearFiles",valueFlag:"--file",clearFlag:"--clear-files",...e.fileDisableFlagKey===void 0?{}:{disableFlagKey:e.fileDisableFlagKey}},{optionKey:"test",clearFlagKey:"clearTests",valueFlag:"--test",clearFlag:"--clear-tests",...e.testDisableFlagKey===void 0?{}:{disableFlagKey:e.testDisableFlagKey}},{optionKey:"doc",clearFlagKey:"clearDocs",valueFlag:"--doc",clearFlag:"--clear-docs",...e.docDisableFlagKey===void 0?{}:{disableFlagKey:e.docDisableFlagKey}},{optionKey:"reminder",clearFlagKey:"clearReminders",valueFlag:"--reminder",clearFlag:"--clear-reminders"},{optionKey:"event",clearFlagKey:"clearEvents",valueFlag:"--event",clearFlag:"--clear-events"},{optionKey:"typeOption",clearFlagKey:"clearTypeOptions",valueFlag:"--type-option",clearFlag:"--clear-type-options"}]}function g(e){return e===void 0?!1:Oe.has(e.trim().toLowerCase())}function st(e,t,n){if(!g(e))return;let a=n?` ${n}`:"";throw new f(`${t} no longer accepts "none" or "null".${a}`.trim(),u.USAGE)}function lt(e,t,n){if(!e||e.length===0||L(e)||!e.some(i=>g(i)))return;let a=n?` ${n}`:"";throw new f(`${t} no longer accepts "none" or "null".${a}`.trim(),u.USAGE)}function ct(e,t){for(let n of t){let a=e[n.optionKey];if(!Array.isArray(a)||a.length===0)continue;if(!a.every(r=>typeof r=="string"))throw new f(`${n.valueFlag} entries must be strings.`,u.USAGE);if(L(a))continue;let i=a;if(i.some(r=>g(r))){if(i.filter(r=>!g(r)).length>0)throw new f(`Cannot mix legacy clear token "none"/"null" with concrete ${n.valueFlag} entries. Use ${n.clearFlag} to clear or provide explicit entries.`,u.USAGE);e[n.optionKey]=void 0,e[n.clearFlagKey]=!0,n.disableFlagKey&&(e[n.disableFlagKey]=!1)}}return e}(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]="5146346c-df7b-5011-9d55-c59a7ff88f29")}catch{}})();var ge=["close_reason","close-reason"],ae=[{canonical:"tags",aliases:["tags"],optionKey:"tags",metadataKey:"tags"}],oe=[{canonical:"deadline",aliases:["deadline"],optionKey:"deadline",metadataKey:"deadline"},{canonical:"estimate",aliases:["estimate","estimated_minutes","estimated-minutes"],optionKey:"estimatedMinutes",metadataKey:"estimated_minutes"},{canonical:"acceptance-criteria",aliases:["acceptance_criteria","acceptance-criteria","ac"],optionKey:"acceptanceCriteria",metadataKey:"acceptance_criteria"},{canonical:"definition-of-ready",aliases:["definition_of_ready","definition-of-ready"],optionKey:"definitionOfReady",metadataKey:"definition_of_ready"},{canonical:"order",aliases:["order","rank"],optionKey:"order",metadataKey:"order"},{canonical:"goal",aliases:["goal"],optionKey:"goal",metadataKey:"goal"},{canonical:"objective",aliases:["objective"],optionKey:"objective",metadataKey:"objective"},{canonical:"value",aliases:["value"],optionKey:"value",metadataKey:"value"},{canonical:"impact",aliases:["impact"],optionKey:"impact",metadataKey:"impact"},{canonical:"outcome",aliases:["outcome"],optionKey:"outcome",metadataKey:"outcome"},{canonical:"why-now",aliases:["why_now","why-now"],optionKey:"whyNow",metadataKey:"why_now"}],Te=[...ae,...oe],re=[{canonical:"assignee",aliases:["assignee"],optionKey:"assignee",metadataKey:"assignee"},{canonical:"parent",aliases:["parent"],optionKey:"parent",metadataKey:"parent"},{canonical:"reviewer",aliases:["reviewer"],optionKey:"reviewer",metadataKey:"reviewer"},{canonical:"risk",aliases:["risk"],optionKey:"risk",metadataKey:"risk"},{canonical:"confidence",aliases:["confidence"],optionKey:"confidence",metadataKey:"confidence"},{canonical:"sprint",aliases:["sprint"],optionKey:"sprint",metadataKey:"sprint"},{canonical:"release",aliases:["release"],optionKey:"release",metadataKey:"release"},{canonical:"blocked-by",aliases:["blocked_by","blocked-by"],optionKey:"blockedBy",metadataKey:"blocked_by"},{canonical:"blocked-reason",aliases:["blocked_reason","blocked-reason"],optionKey:"blockedReason",metadataKey:"blocked_reason"},{canonical:"unblock-note",aliases:["unblock_note","unblock-note"],optionKey:"unblockNote",metadataKey:"unblock_note"},{canonical:"reporter",aliases:["reporter"],optionKey:"reporter",metadataKey:"reporter"},{canonical:"severity",aliases:["severity"],optionKey:"severity",metadataKey:"severity"},{canonical:"environment",aliases:["environment"],optionKey:"environment",metadataKey:"environment"},{canonical:"repro-steps",aliases:["repro_steps","repro-steps"],optionKey:"reproSteps",metadataKey:"repro_steps"},{canonical:"resolution",aliases:["resolution"],optionKey:"resolution",metadataKey:"resolution"},{canonical:"expected-result",aliases:["expected_result","expected-result"],optionKey:"expectedResult",metadataKey:"expected_result"},{canonical:"actual-result",aliases:["actual_result","actual-result"],optionKey:"actualResult",metadataKey:"actual_result"},{canonical:"affected-version",aliases:["affected_version","affected-version"],optionKey:"affectedVersion",metadataKey:"affected_version"},{canonical:"fixed-version",aliases:["fixed_version","fixed-version"],optionKey:"fixedVersion",metadataKey:"fixed_version"},{canonical:"component",aliases:["component"],optionKey:"component",metadataKey:"component"},{canonical:"regression",aliases:["regression"],optionKey:"regression",metadataKey:"regression"},{canonical:"customer-impact",aliases:["customer_impact","customer-impact"],optionKey:"customerImpact",metadataKey:"customer_impact"}],B=[...Te,{canonical:"author",aliases:["author"],optionKey:"author",metadataKey:"author"},...re],he=[...ae,{canonical:"close-reason",aliases:ge,optionKey:"closeReason",metadataKey:"close_reason"},...oe,...re],ve=new Set(["none","null","-"]);function ie(e){return e==="create"?B:he}function F(e,t){let n=t.unset;if(n!==void 0&&typeof n!="string"&&!Array.isArray(n))return;let a=[];for(let i of ie(e))i.optionKey==="author"||!Object.hasOwn(t,i.optionKey)||t[i.optionKey]!==null||(Reflect.deleteProperty(t,i.optionKey),a.push(i.canonical));a.length!==0&&(t.unset=[...n===void 0?[]:typeof n=="string"?[n]:n,...a])}function U(e){return typeof e=="string"&&ve.has(e.trim().toLowerCase())}function pt(e,t,n,a){return n?ie(e).flatMap(i=>{let r=t[i.optionKey],o=a[i.metadataKey];return U(r)&&(U(o)||Array.isArray(o)&&o.some(U))?[`literal_sentinel_stored:${i.canonical}:${r.trim()}`]:[]}):[]}function Ee(e,t){return e.flatMap(n=>n.includes(",")&&t(n)?[n]:n.split(","))}function Ce(e){let t=new Set,n=new Set;if(!e.raw||e.raw.length===0)return{metadataKeys:t,optionKeys:n};let a=Ee(e.raw,i=>e.resolveDefinition(i.trim().toLowerCase())!==void 0);for(let i of a){let r=i.trim().toLowerCase();if(!r)throw new f("--unset values must not be empty; name each field once, for example --unset parent,release",u.USAGE);if(g(r))throw new f('--unset no longer accepts "none" or "null". Specify concrete field names such as --unset deadline',u.USAGE);let o=e.resolveDefinition(r);if(!o)throw new f(`Unsupported --unset field "${i}". Supported fields: ${e.supportedFields}`,u.USAGE);t.add(o.metadataKey),n.add(o.optionKey)}return{metadataKeys:t,optionKeys:n}}function Se(e,t,n){let a=e.trim().toLowerCase();if(!n)return;let i=n.command_to_fields?.get(t)??[];for(let r of i){if(r.allow_unset===!1)continue;let o=new Set;if(typeof r.key=="string"&&r.key.length>0&&o.add(r.key.toLowerCase()),typeof r.metadata_key=="string"&&r.metadata_key.length>0&&o.add(r.metadata_key.toLowerCase()),typeof r.cli_flag=="string"&&r.cli_flag.length>0&&(o.add(r.cli_flag.replaceAll("-","_").toLowerCase()),o.add(r.cli_flag.toLowerCase())),Array.isArray(r.cli_aliases))for(let s of r.cli_aliases)typeof s!="string"||s.length===0||(o.add(s.replaceAll("-","_").toLowerCase()),o.add(s.toLowerCase()));if(o.has(a))return{optionKey:r.key,metadataKey:r.metadata_key}}}var Ne=(()=>{let e=new Map;for(let t of B)for(let n of t.aliases)e.set(n,{optionKey:t.optionKey,metadataKey:t.metadataKey});return e})(),be=B.map(e=>e.canonical).sort((e,t)=>e.localeCompare(t)).join(", ");function yt(e,t){return Ce({raw:e,supportedFields:be,resolveDefinition:n=>Ne.get(n)??Se(n,"create",t)})}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="837a5c2d-6447-5696-b0de-32641cde14cd")}catch{}})();var Re={create:'client.create({ type: "Task", title: "Example", createMode: "progressive" })',update:'client.update(id, { estimatedMinutes: "45", force: false })',append:'client.append(id, "Body text")',reopen:'client.reopen(id, "The work recurred", { expectedResult: "Verified recovery" })'};function T(e,t,n){let a=`${e} ${t} must be ${n}.`;throw new f(a,u.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",field:t,changed:!1,required:a,examples:[Re[e]]})}function N(e,t,n){typeof e!="string"&&T(t,n,"a string")}function $(e,t){(e===null||typeof e!="object"||Array.isArray(e))&&T(t,"options","an object")}function se(e,t){(e==="append"||e==="update")&&t.id!==void 0&&N(t.id,e,"id"),e==="item-reopen"&&(t.id!==void 0&&N(t.id,"reopen","id"),t.reason!==void 0&&N(t.reason,"reopen","reason"),t.options!==void 0&&Ke(t.options))}function Nt(e){$(e,"append");for(let t of["body","author","message"])e[t]!==void 0&&N(e[t],"append",t);e.force!==void 0&&typeof e.force!="boolean"&&T("append","force","a boolean")}function Ke(e){$(e,"reopen");for(let t of S["item-reopen"].optional){let n=e[t];n!==void 0&&(m(Reflect.get(O,t)).type==="boolean"?typeof n!="boolean"&&T("reopen",t,"a boolean"):N(n,"reopen",t))}}function Ie(e,t){return e?t?"a string or string array":"a string array":"a string"}function we(e,t,n,a,i,r){n===void 0||typeof n=="string"&&(!i||r)||a==="priority"&&typeof n=="number"&&Number.isFinite(n)||i&&Array.isArray(n)&&Array.from(n).every(o=>typeof o=="string")||T(e,t,Ie(i,r))}function ke(e,t,n){let a=e==="create"?w:k;for(let{param:i}of[...a,...A,{param:"force"}]){if(m(Reflect.get(O,i)).type!=="boolean")continue;let r=n.find(o=>o.keys.includes(i))?.keys??[i];for(let o of r)t[o]!==void 0&&typeof t[o]!="boolean"&&T(e,o,"a boolean")}}function G(e,t,n=!0,a=!1){let i=e==="create"?K:I;for(let{target:r,keys:o,repeatable:s}of i)if(m(Reflect.get(O,r)).type!=="boolean")for(let d of o){let _=a&&d!==r,y=s===!0&&(r!=="acceptanceCriteria"||_);we(e,d,t[d],r,y,n||_)}ke(e,t,i)}function bt(e,t){$(t,e);let n=H(t),a=E(n);return a||F(e,n),G(e,n,!1,a),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]="63a51994-4328-5a65-938c-d0de377ac338")}catch{}})();var Fe=Symbol("pm.mcp-mutation-transport"),Me=new Set(["create","update","append"]),P={create:{parameters:w,aliases:K,strings:X,repeatables:J},update:{parameters:k,aliases:I,strings:Z,repeatables:Q}},De=new Set(["activity","aggregate","context","contracts","deps","files-discover","files-lookup","get","graph","health","history","history-attest","list","next","search","stats","telemetry","validate"]);function b(e){return Fe in e}function D(e,t){return b(e)?Y(t):C(e,t)}function Vt(e,t,n=[]){let a=C(e,{...e,...t});for(let i of n)Reflect.deleteProperty(a,i);return a}function l(e,t){let n=e[t];return typeof n=="string"&&n.trim().length>0?n:void 0}function c(e,t){let n=e[t];return typeof n=="string"?n.trim().length>0?n:void 0:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function zt(e,t){let n=e[t];return typeof n=="string"?n:typeof n=="number"&&Number.isFinite(n)?String(n):void 0}function p(e){return e!==null&&typeof e=="object"&&!Array.isArray(e)}function Ht(e,t){if(typeof e=="number"){if(!Number.isInteger(e))throw new f(`${t} must be a finite integer.`,u.USAGE);return e}if(typeof e=="string"&&e.trim().length>0){let n=Number(e);if(!Number.isInteger(n))throw new f(`${t} must be a finite integer.`,u.USAGE);return n}}function Yt(e,t){return typeof e.limit=="number"&&Number.isFinite(e.limit)?e.limit:typeof t.limit=="number"&&Number.isFinite(t.limit)?t.limit:l(e,"limit")??l(t,"limit")}function qt(e){let t=l(e,"outputFormat");return{json:!0,quiet:!0,author:l(e,"author"),path:l(e,"path"),noExtensions:e.noExtensions===!0||e.no_extensions===!0,noPager:!0,outputInclude:l(e,"outputInclude"),outputLimit:c(e,"outputLimit"),outputBudget:c(e,"outputBudget"),outputSession:l(e,"outputSession"),outputCursor:l(e,"outputCursor"),outputFormat:t==="json"||t==="toon"?t:void 0}}var de=new Set(["tags","blockedBy","blocked_by","skills","fields"]),ue=new Set(["comment","note","learning","reminder","event","dep","depRemove","dep_remove","file","doc","test","unset","addGlob","add_glob","migrate","envSet","env_set","envClear","env_clear"]),Pe=new Set([...ue].filter(e=>e!=="file")),Le=new Set(["files","files-discover","docs","test","test-all"]),z=new Set(["comments","notes","learnings"]);function xe(e,t){if(!(!z.has(e)||!Object.prototype.hasOwnProperty.call(t,"file")))throw new f(`MCP ${e} does not accept options.file. Pass annotation text in options.add instead.`,u.USAGE,{code:"mcp_annotation_file_unavailable",required:"Pass annotation text as JSON data; MCP annotation actions cannot read server-local files."})}var Ue=new Set(["claim","release","start-task","pause-task","close-task"]),fe={history:["order"],"history-attest":["verify","output","hashAlgorithm"],list:["status","type","tag","priority","limit","offset"],search:["mode","status","type","tag","priority","limit"],create:["title","type","status","description","body","priority","tags","parent","createMode","create_mode","allowMissingParent","allowDuplicate","inheritFocus"],update:["parent","allowMissingParent","completedAt"],copy:["allowDuplicate"],close:["duplicateOf","completedAt","releaseAssignment"],claim:["start","next","ifAvailable","takeoverStale"],"start-task":["takeoverStale"],release:["pause","handoff"],comments:["ifAbsent"],notes:["ifAbsent"],learnings:["ifAbsent"],extension:["dryRun","offline"],package:["dryRun","offline"],install:["dryRun"],upgrade:["scope","dryRun","cliOnly","packagesOnly","repair","tag","packageName"],append:["body"]},Be=new Set(["context","get","list","next","search","comments","notes","learnings","files","docs","test"]),$e=new Set(["query","keywords","id","text"]);function Ge(e){return Be.has(e)?S[e].optional.filter(t=>!$e.has(t)):[]}var je=new Set(["claim","start-task","comments","notes","learnings","files","docs","test"]);function Ve(e,t){if(!je.has(e??""))return t;let n={...t};for(let a of S[e].optional){let i=a.replace(/[A-Z]/gu,r=>`_${r.toLowerCase()}`);i===a||n[i]===void 0||(n[a]??=n[i],delete n[i])}return n}function ze(e,t,n){if(!z.has(e??""))return n;let a=n,i=a.text??t.text;if(i===void 0)return a;if(a.add!==void 0&&a.add!==i){let o=e.replace(/s$/u,"");throw new f(`Specify ${o} text either as text or with add, not both.`,u.USAGE,{code:"annotation_text_source_conflict",field:"text",required:`Pass the ${o} text once: text and add are the same source.`})}let r={...a,add:i};return delete r.text,r}function He(e,t){let n=t.replace(/[A-Z]/gu,a=>`_${a.toLowerCase()}`);return e[t]!==void 0||e[n]!==void 0}function Ye(e){return[...fe[e]??[],...Ge(e),...pe]}var pe=["outputInclude","outputLimit","outputBudget","outputFormat","outputSession","outputCursor"];function ye(e,t=""){let n={},a=Le.has(t),i=t==="files"||t==="files-discover"||t==="docs",r=z.has(t)?Pe:ue;for(let[o,s]of Object.entries(e)){if(Array.isArray(s)&&de.has(o)){n[o]=s.join(",");continue}if(o==="note"&&i){n[o]=s;continue}if(typeof s=="string"&&r.has(o)){n[o]=[s];continue}if(typeof s=="string"&&a&&(o==="add"||o==="remove")){n[o]=[s];continue}n[o]=s}return Object.assign(n,Object.fromEntries(Object.getOwnPropertySymbols(e).map(o=>[o,Reflect.get(e,o)]))),n}function qe(e,t,n){let a=l(e,"author");return a!==void 0?a:n!==void 0&&Ue.has(n)?l(e,"assignee")??l(t,"assignee"):void 0}function We(e,t){return t!==void 0&&e.author===void 0?{...e,author:t}:e}function Xe(e,t,n){let a={},i=P[e],r=new Set([...i.parameters.map(({param:o})=>o),...A.map(({param:o})=>o),...fe[e],...pe,"force"]);for(let o of r){let s=i.aliases.find(d=>d.keys.includes(o))?.keys??[o];t[o]===void 0||s.some(d=>n[d]!==void 0)||(a[o]=t[o])}return a}function h(e,t){throw new f(`Invalid MCP ${e} value for "${t}". No changes were made.`,u.USAGE,{code:"invalid_argument_value",reason:"invalid_mutation_option_value",changed:!1,field:t,required:`Provide valid ${e} field values and an options object; inspect the pm_${e} input schema for supported types.`})}function Je(e,t,n){let a=P[e],i=[...a.parameters,...A,{param:"force"}];for(let{param:r}of i){if(m(O[r]).type!=="boolean")continue;let o=(a.aliases.find(s=>s.keys.includes(r))?.keys??[r]).find(s=>n[s]!==void 0&&typeof n[s]!="boolean");o!==void 0&&h(e,o)}for(let r of["idOnly","fullChangedFields"])t[r]!==void 0&&typeof t[r]!="boolean"&&h(e,r)}function Ze(e,t,n){t.options!==void 0&&!p(t.options)&&h(e,"options"),Je(e,t,n);for(let o of de){let s=n[o];Array.isArray(s)&&s.some(d=>typeof d!="string")&&h(e,o)}let a=Ae(n,e),i=P[e];for(let{keys:o,target:s}of i.strings)o.some(d=>n[d]!==void 0)&&a[s]===void 0&&h(e,s);let r=i.repeatables.flatMap(({keys:o})=>o).find(o=>{let s=n[o];return s!==void 0&&typeof s!="string"&&(!Array.isArray(s)||s.some(d=>typeof d!="string"))});return r!==void 0&&h(e,r),a}function Qe(e,t,n,a,i){let r=(t==="create"||t==="update")&&b(e),o={...r?Xe(t,e,a):n,...a};if((t==="create"||t==="update")&&!r){let s=p(e.options)&&E(e.options);s||F(t,o),G(t,o,!0,s)}return r?Ze(t,e,o):i?ye(o,t):o}function et(e,t){return!Me.has(e??"")||E(t)?t:W(t)}function Wt(e,t,{nativeAction:n=!0}={}){se(t,e);let a=p(e.options)?e.options:void 0,i=m(e.options),r={},o=y=>{He(i,y)||e[y]===void 0||(r[y]=e[y])};for(let y of Ye(t??""))o(y);t!==void 0&&b(e)&&xe(t,i);let s=ze(t,e,Ve(t,Qe(e,t,r,i,n)));if(t==="history-attest"&&b(e)&&(s.output!==void 0||typeof s.verify=="string"))throw new f("MCP history attest does not accept server-local proof paths. Export the returned JSON bundle and pass that JSON object as verify.",u.USAGE);let d=b(e)?e:a??e,_=D(d,We(s,qe(e,s,t)));return et(t,_)}function Xt(e){if(e.addNote===void 0)return e;let t={...e};return t.note===void 0&&typeof t.addNote=="string"&&(t.note=t.addNote),delete t.addNote,t}function Jt(e){let t={...e};return t.discoveryNote!==void 0&&t.note===void 0&&typeof t.discoveryNote=="string"&&(t.note=t.discoveryNote),delete t.discover,delete t.discoveryNote,t}function tt(e){let t=[],n=!0;for(let a of e.trim().toLowerCase()){if(a>="a"&&a<="z"||a>="0"&&a<="9"){t.push(a),n=!1;continue}n||(t.push("-"),n=!0)}return t.at(-1)==="-"&&t.pop(),t.join("")}function Zt(e){return!De.has(tt(e))}function Qt(e){return e.trim().toLowerCase().split(/\s+/).filter(Boolean).join(" ")}function nt(e){return Array.isArray(e)?e.map(t=>String(t)).filter(t=>t.length>0):[]}function en(e,t){let n=new Set(["action","args","author","cwd","fullChangedFields","id","options","path","query","reason","target"]),a={};for(let[r,o]of Object.entries(e))n.has(r)||(a[r]=o);let i={...a,...t};return delete i.args,delete i.author,i}function tn(e,t){let n=D(t??{},{...t});return{changedFields:e.fullChangedFields===!0?"full":"compact",idOnly:e.idOnly===!0,runnerOptions:n}}function V(e){return{type:c(e,"filterType"),tag:c(e,"filterTag"),priority:c(e,"filterPriority"),deadlineBefore:c(e,"filterDeadlineBefore"),deadlineAfter:c(e,"filterDeadlineAfter"),updatedAfter:c(e,"filterUpdatedAfter"),updatedBefore:c(e,"filterUpdatedBefore"),createdAfter:c(e,"filterCreatedAfter"),createdBefore:c(e,"filterCreatedBefore"),ids:x(e.ids),assignee:c(e,"filterAssignee"),assigneeFilter:c(e,"filterAssigneeFilter")??c(e,"filterAssignee_filter"),parent:c(e,"filterParent"),sprint:c(e,"filterSprint"),release:c(e,"filterRelease"),limit:c(e,"limit"),offset:c(e,"offset")}}function j(e){if(typeof e=="string"&&e.trim().length>0)return e;if(Array.isArray(e))return nt(e)}function M(e){if(typeof e=="number"&&Number.isFinite(e)||typeof e=="string"&&e.trim().length>0)return e}function nn(e){let t=j(e.kind),n=j(e.exemptIsolate),a=j(e.exemptIsolateType);return{...t===void 0?{}:{kind:t},maxDepth:M(e.maxDepth),limit:M(e.limit),after:l(e,"after"),direction:l(e,"direction"),maxPaths:M(e.maxPaths),sample:M(e.sample),...n===void 0?{}:{exemptIsolate:n},...a===void 0?{}:{exemptIsolateType:a},saveBaseline:e.saveBaseline===!0,rebuild:e.rebuild===!0,clear:e.clear===!0,summary:e.summary===!0,...e.full===!0?{full:!0}:{}}}function me(e){let t=ne(e);return e.ids!==void 0&&(t.ids=x(e.ids)),t}function an(e){return{status:l(e,"filterStatus"),list:p(e.list)?me(e.list):V(e),reason:l(e,"reason"),completedAt:l(e,"completedAt")??l(e,"completed_at"),resolution:l(e,"resolution"),expectedResult:l(e,"expectedResult")??l(e,"expected_result")??l(e,"expected"),actualResult:l(e,"actualResult")??l(e,"actual_result")??l(e,"actual"),validateClose:l(e,"validateClose")??l(e,"validate_close"),author:l(e,"author"),message:l(e,"message"),force:e.force===!0?!0:void 0,dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}var at=new Set(["filterStatus","filterType","filterTag","filterPriority","filterDeadlineBefore","filterDeadlineAfter","filterUpdatedAfter","filterUpdatedBefore","filterCreatedAfter","filterCreatedBefore","filterAssignee","filterAssigneeFilter","filterAssignee_filter","filterParent","filterSprint","filterRelease","ids","list","update","limit","offset","dryRun","dry_run","rollback","checkpoint","noCheckpoint","no_checkpoint"]);function le(e){let t={};for(let[n,a]of Object.entries(e))at.has(n)||(t[n]=a);return _e(t)}function _e(e){return Ae(e,"update")}function Ae(e,t){let n=ye(e,t),a=P[t],i=new Set([...a.parameters,...A].filter(({booleanish:r})=>r===!0).map(({param:r})=>r));for(let{keys:r}of a.repeatables)for(let o of r)typeof n[o]=="string"&&(n[o]=[n[o]]);for(let r of a.strings)for(let o of r.keys){let s=n[o];(typeof s=="number"&&Number.isFinite(s)||s===!1&&i.has(o))&&(n[o]=String(s))}return t==="create"?{...ee(n,{requireType:!1})}:te(n)}function on(e){if(p(e.list)||p(e.update)){let t=p(e.update)?e.update:le(e),n=D(e,_e(t));return{status:c(e,"filterStatus"),list:p(e.list)?me(e.list):V(e),update:q(t,n),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}return{status:c(e,"filterStatus"),list:V(e),update:D(e,le(e)),dryRun:e.dryRun===!0||e.dry_run===!0?!0:void 0,rollback:R(e.rollback),checkpoint:e.checkpoint===!1||e.noCheckpoint===!0||e.no_checkpoint===!0?!1:void 0}}function ce(e){return"expectHash"in e||"expect_hash"in e}function rn(e){if(!ce(e)&&!(p(e.options)&&ce(e.options)))return{expectHash:void 0,dispatchArgs:e};let{expectHash:t,expect_hash:n,...a}=e,i=p(a.options)?a.options:{},{expectHash:r,expect_hash:o,...s}=i,d=[t,n,r,o].filter(v=>v!==void 0),_=d.length>1?d.flatMap(v=>Array.isArray(v)?v:[v]):d[0],y=C(e,"options"in a?{...a,options:p(a.options)?C(a.options,s):a.options}:a);return{expectHash:_,dispatchArgs:y}}export{it as a,g as b,st as c,lt as d,ct as e,ge as f,B as g,he as h,pt as i,Ee as j,Ce as k,Se as l,yt as m,N as n,$ as o,Nt as p,Ke as q,bt as r,b as s,Vt as t,l as u,c as v,zt as w,p as x,Ht as y,Yt as z,qt as A,fe as B,ye as C,Wt as D,Xt as E,Jt as F,tt as G,Zt as H,Qt as I,nt as J,en as K,tn as L,V as M,nn as N,an as O,_e as P,on as Q,rn as R};
2
+ //# sourceMappingURL=chunk-CNMGGAZO.js.map
@@ -1,2 +1,2 @@
1
- import{$a as te,Ub as et,Vb as tt,Xb as ne,_b as nt,a as Je,ac as rt,bc as it,xc as ot}from"./chunk-77MGDTK4.js";import{u as Qe}from"./chunk-QANUQMDL.js";import{wc as Ze}from"./chunk-2WHXFKMY.js";import{m as Xe}from"./chunk-36R3JTAD.js";import{a as ze,c as U,d as Q,e as Be,f as ee,g as Ve}from"./chunk-3IU2S5UQ.js";import{ra as He,wb as j,xa as Ye,zb as D}from"./chunk-7K2RUKMK.js";import{Va as Z,d as Ee,ia as Ge,ka as N,t as Oe,u as Ae,ub as Le,uc as We,v as z}from"./chunk-AM26RAG7.js";import{k as xe,o as qe,v as Ke}from"./chunk-CR5GC3VO.js";import{$c as Ce,Bc as Ie,Bd as Ne,Fc as E,Ka as V,Mc as Y,Ta as ke,a as be,be as Ue,bj as De,ce as R,cj as X,gc as $e,jh as I,oh as je,oj as Fe,pj as Pe,uh as C,vc as Me,xc as H,yc as Re}from"./chunk-7UUPLMCU.js";import{A as p,C as u,G as B,I as Te,J as $,l as ve,q as k,t as _e,y as Se}from"./chunk-5OFMWP3Q.js";import ue from"node:crypto";import{constants as se,readFileSync as Tn}from"node:fs";import{cp as kn,lstat as kt,mkdir as $n,mkdtemp as $t,open as Mn,readdir as Rn,realpath as Mt,rm as Rt,stat as pe,writeFile as It}from"node:fs/promises";import{tmpdir as Ct}from"node:os";import m from"node:path";import yt 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]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var O=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...ve,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);function at(e){if(e===void 0)return;let t=e.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return O.has(t)?t:e}(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]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function F(e,t,n){let r=e?.estimatedMinutes;if(!(r===void 0||typeof r=="string"))throw new u(`Mutation ${n+1} ${t} option "estimatedMinutes" must be a string.`,p.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(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]="37abb7b8-a5c3-5bdd-ad3a-9dc5189e834f")}catch{}})();var re=["op","id","reason","options","unique","match"],Lt=[...re,"ref"],st=[...Lt,"item"],Wt="mutate-",ct="row-",dt=["schema_version","mutations"],wt="[a-z][a-z0-9._-]{0,63}",ut=new RegExp(`^${wt}$`,"u"),gt=new RegExp(`(^|,)id=@(${wt})(?=,|$)`,"gu"),pt=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),P=["item","item_hash","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],vt=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count","pm_format_version","claim_principal","test_runs","deferred_fields"]),Jt=new Set([...vt,"completed_at","id"]),_t={create:j.map(e=>e.target),update:D.map(e=>e.target),close:He.map(e=>pt(e.flag)).filter(e=>e!=="reason"),release:Ye.map(e=>pt(e.flag))};function gr(e){let t=yt.createHash("sha256").update(e).digest("hex");return`${Wt}${t.slice(0,24)}`}function vr(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new u("createCompensation must be close or delete.",p.USAGE);t.createCompensation=n}for(let r of["lockTtlSeconds","lockWaitMs"]){let i=e[r];if(i===void 0)continue;let o=typeof i=="number"||typeof i=="string"&&i.trim().length>0?Number(i):Number.NaN;if(!Number.isSafeInteger(o)||o<=0)throw new u(`${r} must be a positive safe integer.`,p.USAGE);t[r]=o}return t}function w(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 i of t){let o=$e(e,i,n);o!==null&&(r===void 0||o<r.distance)&&(r={key:i,distance:o})}return r?.key}function A(e,t,n){let r=G(t,n);return new u(r===void 0?`${e} does not recognize key "${t}". Allowed keys: ${n.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${r}"?`,p.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 ae(e,t){try{return JSON.parse(e)}catch(n){let r=n instanceof Error?n.message:String(n);throw new u(`${t} must be valid JSON: ${r}`,p.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 zt(e,t){if(!w(e))throw new u(`Mutation ${t+1} must be an object.`,p.USAGE);for(let n of Object.keys(e))if(!re.includes(n))throw A(`mutation ${t+1}`,n,re);return e}function Bt(e,t,n,r){if(e===void 0)return;if(!w(e))throw new u(`Mutation ${n+1} options must be an object.`,p.USAGE);let i=[..._t[t],...Et(t,r)];for(let o of Object.keys(e))if(!i.includes(o))throw A(`mutation ${n+1} ${t} options`,o,i);return F(e,t,n),e}function lt(e,t,n,r){if(e===void 0)return;let i=r==="unique"?"create":"update";if(t!==i)throw new u(`Mutation ${n+1} ${r} is only valid for ${i} operations.`,p.USAGE);let o=w(e)&&typeof e.key=="string"?e.key.trim():"";if(!w(e)||o.length===0||e.value===void 0||e.value===null)throw new u(`Mutation ${n+1} ${r} must be an object with a non-empty key and a value.`,p.USAGE);return{key:o,value:e.value}}function Vt(e,t,n){let r=zt(e,t),{op:i,id:o,reason:a}=r;if(i!=="create"&&i!=="update"&&i!=="close"&&i!=="release")throw new u(`Mutation ${t+1} op must be create, update, close, or release.`,p.USAGE);let s=Bt(r.options,i,t,n),d=lt(r.unique,i,t,"unique"),c=lt(r.match,i,t,"match");if(typeof o!="string"||o.trim().length===0)throw new u(`Mutation ${t+1} requires a non-empty id.`,p.USAGE);let l=o.trim();if(i==="close"){if(typeof a!="string"||a.trim().length===0)throw new u(`Mutation ${t+1} close requires a non-empty reason.`,p.USAGE);return{op:i,id:l,reason:a.trim(),...s===void 0?{}:{options:s}}}if(i==="release")return{op:i,id:l,...s===void 0?{}:{options:s}};if(!w(s))throw new u(`Mutation ${t+1} ${i} requires an options object.`,p.USAGE);return{op:i,id:l,options:s,...d===void 0?{}:{unique:d},...c===void 0?{}:{match:c}}}function St(e,t={}){let n=ae(e,"Mutation batch"),r=Array.isArray(n)?n:w(n)&&Array.isArray(n.mutations)?n.mutations:void 0;if(r===void 0||r.length===0)throw new u("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",p.USAGE);let i=t.runtimeFields??[];return r.map((o,a)=>{let s=Vt(o,a,i);return s.options!==void 0&&Oe(s.options),s})}function Ht(e,t,n){let r=yt.createHash("sha256").update(e).update("\0").update(t).digest("hex"),i=BigInt(`0x${r.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${Ge(n)}${i}`}function mt(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let n=e.slice(1),r=t[n];if(r===void 0)throw new u(`Unknown mutation reference "${e}".`,p.USAGE);return r}function ft(e,t){if(typeof e!="string")return e;let n=e.replace(gt,(r,i,o)=>{let a=t[o];if(a===void 0)throw new u(`Unknown mutation reference "@${o}".`,p.USAGE);return`${i}id=${a}`});if(/(^|,)id=@/u.test(n))throw new u(`Malformed mutation reference in dependency "${e}".`,p.USAGE);return n}function Yt(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(gt)].map(t=>t[1]).filter(t=>t!==void 0)}function Xt(e,t){let n=new Map;for(let[a,s]of e.entries()){let d=t[a];if(d===void 0)continue;let c=w(s.options)?s.options:{},l=Array.isArray(c.dep)?c.dep:c.dep===void 0?[]:[c.dep];n.set(d,[c.parent,c.blockedBy,...l].flatMap(Yt))}let r=new Set,i=new Set,o=a=>{if(r.has(a))throw new u(`Mutation reference cycle includes "@${a}".`,p.USAGE);if(!i.has(a)){r.add(a);for(let s of n.get(a))n.has(s)&&o(s);r.delete(a),i.add(a)}};for(let a of n.keys())o(a)}function Zt(e){let t=e.split(/\r?\n/u).map((o,a)=>({line:o.trim(),number:a+1})).filter(o=>o.line.length>0);if(t.length<2)return null;let n=t.map(o=>{try{return{...o,ok:!0,value:JSON.parse(o.line)}}catch(a){return{...o,ok:!1,error:a}}}),r=n[0];if(!r.ok&&(r.line.startsWith("[")||r.line==="{"||n.at(-1).line==="}")||!n.some(o=>o.ok&&w(o.value)))return null;let i=[];for(let o of n){if(!o.ok)throw new u(`Mutation document line ${o.number} must be one valid JSON object: ${We(o.error)}`,p.USAGE,{code:"stdin_json_invalid",required:"Provide one JSON object per line (JSON Lines), a JSON array, or a {schema_version, mutations} document.",why:"Structured mutation input must parse deterministically before any tracker write begins."});if(!w(o.value))throw new u(`Mutation document line ${o.number} must be a JSON object.`,p.USAGE);i.push(o.value)}return i}function Qt(e){return Object.hasOwn(e,"mutations")||Object.hasOwn(e,"schema_version")}function en(e){let t;try{t=ae(e,"Mutation document")}catch(n){let r=Zt(e);if(r===null)throw n;return{schema_version:1,mutations:r}}return Array.isArray(t)?{schema_version:1,mutations:t}:w(t)&&!Qt(t)?{schema_version:1,mutations:[t]}:t}function tn(e,t){let n=Object.hasOwn(e,"op")?nn(e,t):rn(e,t);if(n.op==="create"&&n.id===void 0&&w(n.item)&&n.item.id!==void 0){if(typeof n.item.id!="string")throw new u(`Mutation ${t+1} item id must be a string.`,p.USAGE);n.id=n.item.id}return n}function nn(e,t){for(let n of Object.keys(e))if(!st.includes(n))throw A(`mutation ${t+1}`,n,st);if(e.item!==void 0&&e.op!=="create")throw new u(`Mutation ${t+1} item documents are only valid for create operations.`,p.USAGE);if(e.item!==void 0&&e.options!==void 0)throw new u(`Mutation ${t+1} must declare either item or options, not both.`,p.USAGE);return{...e}}function rn(e,t){let{ref:n,id:r,item:i,...o}=e,a=i!==void 0?i:o;if(i!==void 0&&Object.keys(o).length>0)throw new u(`Mutation ${t+1} must not mix item document keys with top-level fields.`,p.USAGE);if(!w(a))throw new u(`Mutation ${t+1} item document must be an object.`,p.USAGE);return{op:"create",...n===void 0?{}:{ref:n},...r===void 0?{}:{id:r},item:a}}function on(e){let t=en(e);if(!w(t))throw new u("Mutation document must be a JSON array or object.",p.USAGE);for(let n of Object.keys(t))if(!dt.includes(n))throw A("mutation document",n,dt);if(t.schema_version!==void 0&&t.schema_version!==1)throw new u("Mutation document schema_version must be 1.",p.USAGE);if(!Array.isArray(t.mutations)||t.mutations.length===0)throw new u("Mutation document requires a non-empty mutations array.",p.USAGE);return t.mutations.map((n,r)=>{if(!w(n))throw new u(`Mutation ${r+1} must be an object.`,p.USAGE);return tn(n,r)})}function an(e,t,n){let r=new Set(Object.values(At(t,n,Object.create(null))));for(let i of t)i.op==="create"&&typeof i.id=="string"&&i.id.trim().length>0&&r.add(N(i.id,n.idPrefix));return{...e,existing:e.existing.filter(i=>!r.has(i.id))}}function sn(e){let t=new Set(e.map(n=>n.ref).filter(n=>typeof n=="string"));for(let[n,r]of e.entries()){if(r.op!=="create"||r.ref!==void 0||typeof r.id=="string"&&r.id.trim().length>0)continue;let i=`${ct}${n+1}`;if(t.has(i))throw new u(`Mutation ${n+1} receives the synthesized ref "${i}", but another row declares that ref. Rename it or give mutation ${n+1} its own ref; ${ct}<n> aliases are reserved for rows without one.`,p.USAGE);r.ref=i}}function bt(e,t,n){let r=An(JSON.stringify(e),t,{},n);return delete r.stdinJson,delete r.documentAnnotationSnapshot,r}function Et(e,t){return e!=="create"&&e!=="update"?[]:t.filter(n=>n.commands.includes(e)).map(n=>E(n))}function cn(e,t){for(let n of e)w(n.item)&&(n.options=bt(n.item,"create",t),delete n.item)}function Ot(e,t){return t.some(n=>n.metadata_key===e)?e:at(e)}function ie(e,t,n){let r=t.replaceAll(/_([a-z])/gu,(a,s)=>s.toUpperCase());if(w(e.item)){if(e.item[t]!==void 0)return e.item[t];if(Ot(r,n)===t&&e.item[r]!==void 0)return e.item[r]}let i=w(e.options)?e.options:{},o=n.find(a=>a.metadata_key===t);return o!==void 0&&i[E(o)]!==void 0?i[E(o)]:i[t]!==void 0?i[t]:i[r]!==void 0?i[r]:(Array.isArray(i.field)?i.field:[]).map(String).find(a=>a.startsWith(`${t}=`))?.slice(t.length+1)}function dn(e,t){return e<t?-1:+(e!==t)}function oe(e){return Array.isArray(e)?e.map(oe):w(e)?Object.fromEntries(Object.entries(e).sort(([t],[n])=>dn(t,n)).map(([t,n])=>[t,oe(n)])):e}function _(e){return typeof e=="string"?e.trim():JSON.stringify(oe(e))}function un(e,t,n,r,i){let o=t.key.trim();if(o.length===0)throw new u("Upsert key must be a non-empty field name.",p.USAGE);let a=pn(t.existing),s=new Map,d=new Set;for(let[c,l]of e.entries()){if(l.op!=="create")continue;let f=ln(l,o,c,s,r),y=mn(a.get(f)??[],o,f);if(y===void 0){l.unique={key:o,value:ie(l,o,r)};continue}let h=N(y,n);typeof l.ref=="string"&&(i[l.ref]=h),fn(l,h,r,{key:o,value:ie(l,o,r)}),d.add(c)}return d}function pn(e){let t=new Map;for(let n of e){if(n.value===void 0||n.value===null)continue;let r=_(n.value);t.set(r,[...t.get(r)??[],n.id])}return t}function ln(e,t,n,r,i){let o=ie(e,t,i);if(o==null||o==="")throw new u(`Mutation ${n+1} is missing the upsert key "${t}".`,p.USAGE,{code:"upsert_key_missing",required:`Every create record must carry a non-empty "${t}" value when --upsert-key ${t} is set.`,why:"Keyed upsert identifies existing items by that field; a record without it cannot be matched or safely created."});let a=_(o),s=r.get(a);if(s!==void 0)throw new u(`Mutations ${s+1} and ${n+1} share the upsert key value ${JSON.stringify(a)} for "${t}".`,p.USAGE,{code:"upsert_key_duplicate",required:"Each record must carry a distinct upsert key value within one batch.",why:"Two records with the same key would race for the same existing item."});return r.set(a,n),a}function mn(e,t,n){if(e.length>1)throw new u(`Upsert key "${t}" value ${JSON.stringify(n)} matches ${e.length} existing items: ${e.join(", ")}.`,p.CONFLICT,{code:"upsert_key_ambiguous",required:"Resolve the duplicate existing items or choose a key that is unique per item.",why:"An ambiguous key cannot select one item to update without guessing."});return e[0]}function fn(e,t,n,r){let i=new Set([..._t.update,...Et("update",n)]),o=w(e.item)?bt(e.item,"update",n):Object.fromEntries(Object.entries(e.options).filter(([a])=>i.has(a)));delete e.item,delete e.ref,e.op="update",e.id=t,e.options=o,e.match=r}function At(e,t,n){for(let[r,i]of e.entries())if(i.ref!==void 0){if(i.op!=="create")throw new u(`Mutation ${r+1} ref is only valid for create operations.`,p.USAGE);if(typeof i.ref!="string"||!ut.test(i.ref))throw new u(`Mutation ${r+1} ref must match ${ut.source}.`,p.USAGE);if(n[i.ref]!==void 0)throw new u(`Duplicate mutation ref "${i.ref}".`,p.USAGE);n[i.ref]=typeof i.id=="string"&&i.id.trim().length>0?N(i.id,t.idPrefix):Ht(t.transactionId,i.ref,t.idPrefix)}return n}function _r(e,t){let n=on(e);sn(n);let r=n.map(l=>typeof l.ref=="string"?l.ref:void 0),i=Object.create(null),o=t.upsert===void 0?new Set:un(n,an(t.upsert,n,t),t.idPrefix,t.runtimeFields??[],i);cn(n,t.runtimeFields??[]),At(n,t,i),Xt(n,r);let a=n.map(l=>{let f={...l},y=typeof f.ref=="string"?f.ref:void 0;if(delete f.ref,y!==void 0?f.id=i[y]:f.id=mt(f.id,i),w(f.options)){let h={...f.options};for(let g of["parent","blockedBy"])h[g]!==void 0&&(h[g]=mt(h[g],i));Array.isArray(h.dep)?h.dep=h.dep.map(g=>ft(g,i)):h.dep!==void 0&&(h.dep=ft(h.dep,i)),f.options=h}return f}),s=St(JSON.stringify(a),{runtimeFields:t.runtimeFields??[]}),d=s.filter(l=>l.op==="create").map(l=>l.id);if(new Set(d).size!==d.length)throw new u("Duplicate resolved create id in mutation document.",p.USAGE);let c=s.map((l,f)=>{let y=r[f];return{index:f,...typeof y=="string"?{ref:y}:{},id:l.id,op:l.op,...o.has(f)?{upserted:!0}:{}}});return{schema_version:1,mutations:s,references:i,rows:c}}function hn(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 yn(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(w))throw new u(`${n} must be an array of objects.`,p.USAGE);return e.map(r=>hn(r,t))}}function wn(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 ht(e,t,n=!1){for(let[r,i,o]of Ze){let a=t[r],s=yn(n&&["comments","notes","learnings"].includes(r)&&Array.isArray(a)?a.filter(d=>!w(d)||d.created_at===void 0):a,o,r);s!==void 0&&s.length>0&&(e[i]=s)}}function gn(e,t){for(let n of Object.keys(e)){if(t){if(!P.includes(n))throw A("item envelope",n,P);continue}if(!O.has(n)&&G(n,[...O])===void 0&&G(n,P)==="item")throw A("item envelope",n,P)}}function vn(e){let t=Object.hasOwn(e,"item");gn(e,t);let n=t?e.item:e;if(!w(n))throw new u("Item document item must be an object.",p.USAGE);return{item:n,...t&&w(e.linked)?{linked:e.linked}:{}}}function _n(e,t,n,r,i,o){if((r==="update"?Jt:vt).has(t))return;let a=i.find(s=>s.metadata_key===t&&s.commands.includes(r));if(a!==void 0){let s=Y(o,a);e[E(a)]=s!==void 0?s:a.type==="array"||a.type==="object"?JSON.stringify(n):n;return}if(!O.has(t)){if(G(t,[...O])!==void 0)throw A("item document",t,[...O]);let s=Array.isArray(e.field)?e.field:[];s.push(`${t}=${typeof n=="string"?n:JSON.stringify(n)}`),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(s,d)=>d.toUpperCase())]=wn(t,n))}function Sn(e){return{command_to_fields:new Map([["create",e.filter(t=>t.commands.includes("create"))]])}}function bn(e,t,n,r){let i=r.filter(c=>c.commands.includes("create")),o=new Set([...Ce.filter(c=>t.has(c.option)).map(c=>c.field),...i.filter(c=>t.has(E(c))).map(c=>c.metadata_key),...Xe(Array.isArray(n)?n.map(String):[],Sn(i)).metadataKeys]),a=(Array.isArray(e)?e:[]).filter(w).filter(c=>typeof c.field=="string"&&!o.has(c.field));if(a.length===0)return{};let s=a.map(c=>typeof c.reason=="string"?c.reason.trim():""),d=a.map(c=>c.field);return t.has("deferReason")?{defer:d}:s.every(c=>c.length>0)?{defer:d,deferReason:[...new Set(s)].join("; ")}:{defer:d}}function En(e,t,n){let r=new Set(Object.entries(e).filter(([,o])=>o!==void 0).map(([o])=>o)),i=t==="create"?j:D;for(let{target:o,keys:a}of i)a.some(s=>r.has(s))&&r.add(o);for(let o of n.filter(a=>a.commands.includes(t)))Y(e,o)!==void 0&&r.add(E(o));return r}function On(e,t,n){let r=t==="create"?j:D;for(let{target:i}of r)i!=="field"&&n.has(i)&&delete e[i]}function An(e,t,n={},r=[]){let i=ae(e,"Item document");if(!w(i))throw new u("Item document must be a JSON object.",p.USAGE);let{item:o,linked:a}=vn(i),s={};for(let[f,y]of Object.entries(o)){let h=Ot(f,r);h!==f&&Object.hasOwn(o,h)||_n(s,h,y,t,r,n)}ht(s,o,t==="update"),a!==void 0&&ht(s,a);let d=En(n,t,r);if(On(s,t,d),t==="create"&&!d.has("defer")&&Object.assign(s,bn(o.deferred_fields,d,n.unset,r)),t==="update"){let f=Object.fromEntries(["comments","notes","learnings"].filter(y=>Object.hasOwn(o,y)&&!d.has(y.slice(0,-1))).map(y=>[y,o[y].filter(h=>w(h)&&h.created_at!==void 0)]));Object.keys(f).length>0&&(s.documentAnnotationSnapshot=f)}let c={...s,...Object.fromEntries(Object.entries(n).filter(([,f])=>f!==void 0)),...Array.isArray(s.field)&&Array.isArray(n.field)?{field:[...s.field,...n.field]}:{},stdinJson:void 0},l=Object.keys(s).filter(f=>!d.has(f));return Ae(Ee(c,l),l)}function Sr(e){return St(JSON.stringify(e))}(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]="359a47e6-c7e8-5713-bd07-1e19fb81674a")}catch{}})();async function In(e,t){if(!qe(e))return{schema:H(t.schema),typeDefinitionsFromFile:[]};let n=await Wn(e,t.schema);return{schema:n.schema,typeDefinitionsFromFile:n.type_definitions_from_file??[]}}async function Cn(e,t,n,r){let i=V({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...n.typeDefinitionsFromFile]}},X());return(await Le(e,t.item_format,i.type_to_folder,void 0,n.schema)).flatMap(o=>{let a=o[r];return a==null?[]:[{id:o.id,value:a}]})}function le(e){let t=new Map,n=async r=>{let i=await Ke(e),o=await In(e,i),a=new Map;for(let s of await Cn(e,i,o,r)){let d=_(s.value);a.set(d,[...a.get(d)??[],s.id])}return a};return{lookup(r){let i=t.get(r)??n(r);return t.set(r,i),i},async recordCreate(r){for(let[i,o]of t){let a=r[i];if(a==null)continue;let s=await o,d=_(a);s.set(d,[...s.get(d)??[],String(r.id)])}},invalidate(){t.clear()}}}async function Nn(e,t){let n=_(t.value),r=(await e.lookup(t.key)).get(n)??[];if(r.length!==0)throw new u(`Upsert key "${t.key}" value ${JSON.stringify(n)} now matches existing item ${r.join(", ")}; the plan was resolved before it existed.`,p.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function Un(e,t,n){let r=e.metadata[n.key],i=_(n.value);if(_(r)!==i)throw new u(`Item ${t} no longer carries upsert key "${n.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,p.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function Tt(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function L(e,t){let n={...e,...t};return e===void 0?n:z(e,n)}async function b(e,t){try{let n=(await te(t,{},{pmRoot:e})).item;return{id:n.id,closedAt:n.closed_at,updatedAt:n.updated_at,assignee:n.assignee,claimPrincipal:n.claim_principal}}catch(n){if(n instanceof u&&n.exitCode===p.NOT_FOUND)return;throw n}}function me(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=ue.createHash("sha256").update(be(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function jn(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function v(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}function fe(e,t){return e===t||(e?.startsWith(`${t} | `)??!1)}async function M(e,t,n,r){let i=await R(m.join(e,"history",`${t}.jsonl`),t),o=v(n,r,"apply"),a=v(n,r,"compensate");for(let s=i.length-1;s>=0;s-=1){let d=i[s].message;if(fe(d,o))return!0;if(d===a)return!1}return!1}async function he(e,t){let n=await b(e,t.id);if(n?.updatedAt===void 0)throw new u(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,p.NOT_FOUND);let r=await R(m.join(e,"history",`${n.id}.jsonl`),n.id);if(r.length===0)throw new u(`Bulk ${t.op} target ${t.id} has no restorable history`,p.NOT_FOUND);return{target_updated_at:n.updatedAt,target_version:String(Z(r)+r.length),target_history_hash:I(r),target_history_length:r.length}}function T(e,t,n){return new u(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${n}; review item ${t} history before recovery.`,p.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function Nt(e,t){let n=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(r=>typeof r=="string"&&r.startsWith(n))}function Dn(e,t,n){let{expectedHistory:r,length:i,version:o}=t;if(I(e)===r)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||I(e.slice(0,i))!==r||o!==String(Z(e)+i))throw T(n,n.itemId,n.stepId);let a=v(n.transactionId,n.stepId,"apply"),s=e.slice(i),d=y=>fe(y.message,a)||y.context?.item_transaction_step===a,c=v(n.transactionId,n.stepId,"compensate");if(s.filter(y=>d(y)||y.message===c).at(-1)?.message===c)return!1;let l=s.filter(d);if(l.length===0)return!1;let f=e.at(-1).after_hash===l.at(-1).after_hash&&s.every(y=>Nt(y,n.transactionId));if(l.length!==s.length&&!f)throw T(n,n.itemId,n.stepId);return!0}async function Ut(e,t){let n=m.join(e,"history",`${t}.jsonl`),r=await Ue(n,t);return{history:r.entries,assertOwnedUnderLock:(i,o)=>{let a;try{a=Tn(n).equals(r.raw_bytes)&&je(i)===r.entries.at(-1).after_hash}catch(s){throw Object.assign(o(),{cause:s})}if(!a)throw o()}}}async function W(e,t,n,r){let i=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let o=i.target_updated_at,a=await b(e.pmRoot,t);if(a===void 0)return;let{history:s,assertOwnedUnderLock:d}=await Ut(e.pmRoot,a.id),c=i.target_history_hash,l=typeof c=="string";if(typeof c=="string"){if(!Dn(s,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:a.id,stepId:n}))return}else{if(a.updatedAt===o)return;if(!await M(e.pmRoot,a.id,e.transactionId,n))throw T(e,a.id,n)}let f=()=>it(t,typeof i.target_version=="string"?i.target_version:o,{force:!0,author:e.author,message:v(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot});await C({pmRoot:e.pmRoot,id:a.id,validate:y=>{d(y,()=>T(e,a.id,n))},compensation:Dt(e,t,n,"restore",l)},f)}var jt=new WeakMap;function Dt(e,t,n,r,i){let o=i?ze(e.pmRoot,e.transactionId):void 0,a=o===void 0?void 0:jt.get(o);if(!(a?.stepId!==n||a.itemId!==t||a.operation!==r))return{transaction_id:e.transactionId,step_id:n,operations:[r],overrides:[]}}function Ft(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);if(r===void 0)return{state:"pending"};if(r.closedAt!==void 0){let i=await R(m.join(e.pmRoot,"history",`${r.id}.jsonl`),r.id),o=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(a=>a.op==="close").at(-1)?.patch.some(a=>a.op==="add"||a.op==="replace"?a.path==="/metadata/close_reason"&&a.value===o:!1)??!1)throw new u(`Created item ${r.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,p.CONFLICT,{code:"transaction_create_compensated",item_id:r.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${r.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:r.id,op:"create"}}},async apply(){t.unique!==void 0&&await Nn(e.uniqueIndex,t.unique);let r=await et(L(t.options,{author:e.author,id:t.id,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=r.item;return e.onCreateWarnings?.(String(i.id),r.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await Fn(e,t.id,n)}}}async function Fn(e,t,n){let r=await b(e.pmRoot,t);if(r===void 0||e.createCompensation==="close"&&r.closedAt!==void 0)return;let{history:i,assertOwnedUnderLock:o}=await Ut(e.pmRoot,r.id),a=v(e.transactionId,n,"apply"),s=v(e.transactionId,n,"compensate"),d=i.filter(c=>fe(c.message,a)||c.message===s).at(-1);if(d?.message!==s){if(d===void 0||!i.every(c=>Nt(c,e.transactionId)))throw T(e,r.id,n);await C({pmRoot:e.pmRoot,id:r.id,validate:c=>{o(c,()=>T(e,r.id,n))},compensation:Dt(e,t,n,e.createCompensation==="delete"?"delete":"close",!0)},async()=>{let c={force:!0,author:e.author,message:s};e.createCompensation==="delete"?await rt(t,c,{pmRoot:e.pmRoot}):await ne(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,{...c,validateClose:"off"},{pmRoot:e.pmRoot})})}}function Pn(e,t,n){return{id:n,compensatePending:!0,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return he(e.pmRoot,t)},async apply(){let r=()=>tt(t.id,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=t.match,o=i,a=(await C({pmRoot:e.pmRoot,id:String((await te(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:s=>{o!==void 0&&Un(s,t.id,o)},committed:s=>{i!==void 0&&(o={key:i.key,value:structuredClone(s.metadata[i.key])})},historyContext:{item_transaction_step:v(e.transactionId,n,"apply")}},r)).item;return e.uniqueIndex.invalidate(),{id:String(a.id),op:"update"}},async compensate(r){await W(e,t.id,n,r)}}}function Gn(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(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 he(e.pmRoot,t)},async apply(){let r=(await ne(t.id,t.reason,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"close"}},async compensate(r){await W(e,t.id,n,r)}}}function xn(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(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 he(e.pmRoot,t)},async apply(){let r=(await nt(t.id,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"release"}},async compensate(r){await W(e,t.id,n,r)}}}function ye(e,t,n){let r=me(t,n),i=qn(e,t,r);return jt.set(i,{transactionId:e.transactionId,stepId:r,itemId:t.id,operation:t.op!=="create"?"restore":e.createCompensation==="delete"?"delete":"close"}),i}function qn(e,t,n){switch(t.op){case"create":return Ft(e,t,n);case"update":return Pn(e,t,n);case"close":return Gn(e,t,n);case"release":return xn(e,t,n)}}function Kn(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`);if(e.op==="create"&&e.unique!==void 0&&!Tt(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!Tt(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);F(e.options,e.op,t)}function Pt(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[n,r]of e.entries()){if(Kn(r,n),r.op!=="create"||r.unique===void 0)continue;let{key:i,value:o}=r.unique,a=t.get(i)??new Map,s=_(o),d=a.get(s);if(d!==void 0)throw new u(`Bulk create mutations ${d+1} and ${n+1} share the upsert key value ${JSON.stringify(s)} for "${i}".`,p.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});a.set(s,n),t.set(i,a)}}function Gt(e){let t=[...e];return Pt(t),t.map(n=>{let r=structuredClone(n);return n.options!==void 0&&r.options!==void 0&&z(n.options,r.options),r})}function xt(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([n,r])=>{let i=`${t}/${n.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(n)?[i]:xt(r,i)})}async function ce(e,t,n){try{return await n()}catch(r){throw r instanceof u?new u(r.message,r.exitCode,{...r.context,transaction_operation:{index:t,op:e.op,id:e.id}}):r}}function qt(e,t,n,r){let i=m.relative(e,t),o=i.split(m.sep);return o[0]==="extensions"&&o[2]==="node_modules"&&!r.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`))?!1:["locks","runtime","search"].includes(i.split(m.sep)[0])?r.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`)):i===""||n===void 0||n.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`))}async function q(e,t){let n=await kt(t);if(n.isSymbolicLink())await pe(t);else if(n.isDirectory()||n.isFile())return n;throw $(m.relative(e,t))}async function Ln(e,t){let n=await Mn(t,se.O_RDONLY|se.O_NOFOLLOW|se.O_NONBLOCK);try{let r=await n.stat();if(!r.isFile())throw $(m.relative(e,t));let i=ue.createHash("sha256");if(r.size>0)for await(let o of n.createReadStream({highWaterMark:64*1024,end:r.size-1,autoClose:!1}))i.update(o);return i.digest()}finally{await n.close()}}async function de(e,t,n){let r=ue.createHash("sha256");async function i(o){for(let a of(await Rn(o)).sort()){let s=m.join(o,a);qt(e,s,t,n)&&((await q(e,s)).isDirectory()?await i(s):(r.update(JSON.stringify(m.relative(e,s))),r.update(await Ln(e,s))))}}return await i(e),r.digest("hex")}function x(){return new u("Tracker changed while preparing the transaction preview; retry against stable state.",p.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function we(e){if(!B(e))return!1;let t=e.path;if(typeof t!="string")return!1;let n=m.resolve(t),r=n;for(;;)try{let i=await kt(r);return r!==n&&i.isDirectory()}catch(i){if(!B(i))return!1;let o=m.dirname(r);if(o===r)return!1;r=o}}async function K(e,t){let n=m.join(e,t);try{let r=e;for(let i of t.split(m.sep).slice(0,-1))r=m.join(r,i),await q(e,r);if(!(await q(e,n)).isFile())throw $(t);return await Te(n,$(t))}catch(r){if(await we(r))return;throw r}}async function Kt(e,t,n,r){let i=H(n);for(let[o,a]of Object.entries(i.files)){let s=m.relative(e,Re(e,a,Me[o]));if(s===""||!m.resolve(e,s).startsWith(m.join(e,m.sep)))throw new u("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",p.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${o}`});i.files[o]=s;let d=await K(e,s);if(r?.set(s,d),d!==void 0){let c=m.join(t,s);await $n(m.dirname(c),{recursive:!0}),await It(c,d)}}return Ie(t,i)}async function Wn(e,t){await pe(e);let n=await $t(m.join(Ct(),"pm-schema-plan-"));try{let r=await Mt(e);return await Kt(r,m.join(n,"configuration"),t)}catch(r){throw await we(r)?x():r}finally{await Rt(n,{recursive:!0,force:!0})}}async function Jn(e,t,n){let r=new Map,i=await K(e,k);r.set(k,i);let o;try{o=JSON.parse(i??"null")}catch{o=null}let a=xe(o),s=a.success?a.data:void 0,d=await Kt(e,t,s?.schema,r),c=d.schema,l=m.relative(e,Ne(e));r.set(l,await K(e,l));let f=V({...Se,item_types:{definitions:[...s?.item_types?.definitions??[],...d.type_definitions_from_file??[]]}},n),y=ke(e)===e?[..._e.filter(Boolean),k,Je,"transactions",...f.folders,...r.keys()].map(g=>m.normalize(g)):void 0,h=s===void 0?void 0:JSON.stringify({...o,schema:{...s.schema,files:c.files}});return{configuration:r,ownedPaths:y,stagedSettings:h,registryFolders:f.folders}}async function zn(e,t,n){await pe(e);try{let r=await Mt(e),i=await Jn(r,m.join(m.dirname(t),"configuration"),n),o=[...i.configuration.keys(),...i.registryFolders].map(c=>m.normalize(c)),a=await de(r,i.ownedPaths,o);await kn(r,t,{recursive:!0,dereference:!1,filter:async c=>qt(r,c,i.ownedPaths,o)?(await q(r,c),!0):!1});let[s,d]=await Promise.all([de(r,i.ownedPaths,o),de(t,i.ownedPaths,o)]);if(a!==s||a!==d)throw x();for(let[c,l]of i.configuration)if(await K(t,c)!==l)throw x();i.stagedSettings!==void 0&&await It(m.join(t,k),i.stagedSettings)}catch(r){throw await we(r)?x():r}}async function Qr(e){let t=U(e),n=Gt(e.mutations),r=X(),i=Pe(),o=await $t(m.join(Ct(),"pm-transaction-preview-")),a=m.join(o,"tracker");try{await zn(t.pmRoot,a,r);let s=!1,d=[],c=[],l=new Set;return await Fe(i,()=>ot({path:a,noExtensions:!0},async()=>{De(r);let f={...t,pmRoot:a,createCompensation:"close",uniqueIndex:le(a)},y=n.map((h,g)=>{let S=ye({...f,onCreateWarnings:(J,ge)=>{ge.length>0&&d.push({index:g,id:J,op:"create",warnings:ge})}},h,g);return{...S,inspect:()=>ce(h,g,()=>S.inspect()),prepareCompensation:()=>ce(h,g,async()=>S.prepareCompensation?.()),apply:()=>ce(h,g,async()=>{let J=await S.apply();return l.add(g),J})}});if(await Q({...t,pmRoot:a,steps:y,onTransition:({transition:h})=>{h==="committed"&&(s=!0)}}),s)for(let[h,g]of n.entries()){let S=(await Qe(g.id,{path:a},{full:!0})).item;c.push({index:h,id:String(S.id),op:g.op,execution:l.has(h)?"applied":"adopted",item:S,commit_time_fields:xt(S)})}})),{records:c,validated:s,state:s?"staged_snapshot":"replayed_committed_plan",warnings:d,unresolved_commit_constraints:["concurrent_tracker_changes","extension_write_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await Rt(o,{recursive:!0,force:!0})}}async function Bn(e){let t=U(e),n=Gt(e.mutations),r=e.createCompensation??"close";if(!["close","delete"].includes(r))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:r,uniqueIndex:le(t.pmRoot)},o=await Q({...t,steps:n.map((s,d)=>ye(i,s,d)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:n,createCompensation:r})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),a={};for(let[s,d]of n.entries()){let c=me(d,s),l=o.results[c];a[jn(d,s)]=l}return{transactionId:o.transactionId,status:"committed",recovered:o.recovered,results:a}}function Vn(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 ei(e){return Bn({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:Vn(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var ti={buildCreateStep:Ft,bulkHistoryMarker:v,compensateByRestore:W,deriveStepId:me,isUpdateMarkerApplied:M,readItemSnapshot:b};async function ni(e,t){let n=await Be(e,t);return n===void 0?void 0:{journal:n,planDigest:ee(n)}}function Hn(e,t){let n=t.recoveryData;if(n===null||typeof n!="object"||Array.isArray(n)||n.kind!=="item-mutations-v1"||!Array.isArray(n.mutations)||!["close","delete"].includes(String(n.createCompensation)))throw new u("Transaction has no supported item recovery plan",p.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let r=n.mutations;Pt(r);let i={...e,createCompensation:n.createCompensation,uniqueIndex:le(e.pmRoot)};return r.map((o,a)=>ye(i,o,a))}async function ri(e){let t=U(e),n=await Ve({...e,...t,resolveSteps:r=>Hn({...e,...t},r)});return{journal:n,planDigest:ee(n)}}export{at as a,gr as b,vr as c,St as d,_ as e,_r as f,An as g,Sr as h,In as i,Cn as j,Wn as k,Qr as l,Bn as m,Vn as n,ei as o,ti as p,ni as q,ri as r};
2
- //# sourceMappingURL=chunk-XPBADEUK.js.map
1
+ import{$a as te,Ub as et,Vb as tt,Xb as ne,_b as nt,a as Je,ac as rt,bc as it,xc as ot}from"./chunk-AGPFANRX.js";import{u as Qe}from"./chunk-IUTN67EB.js";import{wc as Ze}from"./chunk-M76BEWTT.js";import{m as Xe}from"./chunk-CNMGGAZO.js";import{a as ze,c as U,d as Q,e as Be,f as ee,g as Ve}from"./chunk-2UTJ5QIE.js";import{ra as He,wb as j,xa as Ye,zb as D}from"./chunk-AOV5HG3Y.js";import{Va as Z,d as Ee,ia as Ge,ka as N,t as Oe,u as Ae,ub as Le,uc as We,v as z}from"./chunk-723PMYNX.js";import{k as xe,o as qe,v as Ke}from"./chunk-CR5GC3VO.js";import{$c as Ce,Bc as Ie,Bd as Ne,Fc as E,Ka as V,Mc as Y,Ta as ke,a as be,be as Ue,bj as De,ce as R,cj as X,gc as $e,jh as I,oh as je,oj as Fe,pj as Pe,uh as C,vc as Me,xc as H,yc as Re}from"./chunk-7UUPLMCU.js";import{A as p,C as u,G as B,I as Te,J as $,l as ve,q as k,t as _e,y as Se}from"./chunk-5OFMWP3Q.js";import ue from"node:crypto";import{constants as se,readFileSync as Tn}from"node:fs";import{cp as kn,lstat as kt,mkdir as $n,mkdtemp as $t,open as Mn,readdir as Rn,realpath as Mt,rm as Rt,stat as pe,writeFile as It}from"node:fs/promises";import{tmpdir as Ct}from"node:os";import m from"node:path";import yt 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]="01728cbc-2037-50d2-8318-5f106714b8da")}catch{}})();var O=new Set(["id","title","description","type","status","priority","tags","body","deadline","estimated_minutes","acceptance_criteria","definition_of_ready","order","rank","assignee",...ve,"affected_version","fixed_version","component","regression","customer_impact","close_reason","completed_at","dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"]);function at(e){if(e===void 0)return;let t=e.replace(/[A-Z]/gu,n=>`_${n.toLowerCase()}`);return O.has(t)?t:e}(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]="6456f85b-e076-5048-9c21-03d477267259")}catch{}})();function F(e,t,n){let r=e?.estimatedMinutes;if(!(r===void 0||typeof r=="string"))throw new u(`Mutation ${n+1} ${t} option "estimatedMinutes" must be a string.`,p.USAGE,{code:"mutation_option_value_invalid",required:'Pass estimatedMinutes as a string, for example "45", in raw mutation options.',why:"Raw options use the create/update command option types; item documents accept numeric estimated_minutes instead.",nextSteps:["Quote the estimatedMinutes value or use an item document with numeric estimated_minutes, then retry the transaction."]})}(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]="37abb7b8-a5c3-5bdd-ad3a-9dc5189e834f")}catch{}})();var re=["op","id","reason","options","unique","match"],Lt=[...re,"ref"],st=[...Lt,"item"],Wt="mutate-",ct="row-",dt=["schema_version","mutations"],wt="[a-z][a-z0-9._-]{0,63}",ut=new RegExp(`^${wt}$`,"u"),gt=new RegExp(`(^|,)id=@(${wt})(?=,|$)`,"gu"),pt=e=>e.slice(2).replaceAll(/-([a-z])/gu,(t,n)=>n.toUpperCase()),P=["item","item_hash","linked","schedule","claim_state","children","omission_receipt","row_contract","context_intent"],vt=new Set(["created_at","updated_at","closed_at","version","format_version","path","author","collection_counts","notes_count","tests_count","pm_format_version","claim_principal","test_runs","deferred_fields"]),Jt=new Set([...vt,"completed_at","id"]),_t={create:j.map(e=>e.target),update:D.map(e=>e.target),close:He.map(e=>pt(e.flag)).filter(e=>e!=="reason"),release:Ye.map(e=>pt(e.flag))};function gr(e){let t=yt.createHash("sha256").update(e).digest("hex");return`${Wt}${t.slice(0,24)}`}function vr(e){let t={},n=e.createCompensation;if(n!==void 0){if(n!=="close"&&n!=="delete")throw new u("createCompensation must be close or delete.",p.USAGE);t.createCompensation=n}for(let r of["lockTtlSeconds","lockWaitMs"]){let i=e[r];if(i===void 0)continue;let o=typeof i=="number"||typeof i=="string"&&i.trim().length>0?Number(i):Number.NaN;if(!Number.isSafeInteger(o)||o<=0)throw new u(`${r} must be a positive safe integer.`,p.USAGE);t[r]=o}return t}function w(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 i of t){let o=$e(e,i,n);o!==null&&(r===void 0||o<r.distance)&&(r={key:i,distance:o})}return r?.key}function A(e,t,n){let r=G(t,n);return new u(r===void 0?`${e} does not recognize key "${t}". Allowed keys: ${n.join(", ")}.`:`${e} does not recognize key "${t}". Did you mean "${r}"?`,p.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 ae(e,t){try{return JSON.parse(e)}catch(n){let r=n instanceof Error?n.message:String(n);throw new u(`${t} must be valid JSON: ${r}`,p.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 zt(e,t){if(!w(e))throw new u(`Mutation ${t+1} must be an object.`,p.USAGE);for(let n of Object.keys(e))if(!re.includes(n))throw A(`mutation ${t+1}`,n,re);return e}function Bt(e,t,n,r){if(e===void 0)return;if(!w(e))throw new u(`Mutation ${n+1} options must be an object.`,p.USAGE);let i=[..._t[t],...Et(t,r)];for(let o of Object.keys(e))if(!i.includes(o))throw A(`mutation ${n+1} ${t} options`,o,i);return F(e,t,n),e}function lt(e,t,n,r){if(e===void 0)return;let i=r==="unique"?"create":"update";if(t!==i)throw new u(`Mutation ${n+1} ${r} is only valid for ${i} operations.`,p.USAGE);let o=w(e)&&typeof e.key=="string"?e.key.trim():"";if(!w(e)||o.length===0||e.value===void 0||e.value===null)throw new u(`Mutation ${n+1} ${r} must be an object with a non-empty key and a value.`,p.USAGE);return{key:o,value:e.value}}function Vt(e,t,n){let r=zt(e,t),{op:i,id:o,reason:a}=r;if(i!=="create"&&i!=="update"&&i!=="close"&&i!=="release")throw new u(`Mutation ${t+1} op must be create, update, close, or release.`,p.USAGE);let s=Bt(r.options,i,t,n),d=lt(r.unique,i,t,"unique"),c=lt(r.match,i,t,"match");if(typeof o!="string"||o.trim().length===0)throw new u(`Mutation ${t+1} requires a non-empty id.`,p.USAGE);let l=o.trim();if(i==="close"){if(typeof a!="string"||a.trim().length===0)throw new u(`Mutation ${t+1} close requires a non-empty reason.`,p.USAGE);return{op:i,id:l,reason:a.trim(),...s===void 0?{}:{options:s}}}if(i==="release")return{op:i,id:l,...s===void 0?{}:{options:s}};if(!w(s))throw new u(`Mutation ${t+1} ${i} requires an options object.`,p.USAGE);return{op:i,id:l,options:s,...d===void 0?{}:{unique:d},...c===void 0?{}:{match:c}}}function St(e,t={}){let n=ae(e,"Mutation batch"),r=Array.isArray(n)?n:w(n)&&Array.isArray(n.mutations)?n.mutations:void 0;if(r===void 0||r.length===0)throw new u("Mutation batch must be a non-empty JSON array or an object with a non-empty mutations array.",p.USAGE);let i=t.runtimeFields??[];return r.map((o,a)=>{let s=Vt(o,a,i);return s.options!==void 0&&Oe(s.options),s})}function Ht(e,t,n){let r=yt.createHash("sha256").update(e).update("\0").update(t).digest("hex"),i=BigInt(`0x${r.slice(0,16)}`).toString(36).padStart(13,"0").slice(-12);return`${Ge(n)}${i}`}function mt(e,t){if(typeof e!="string"||!e.startsWith("@"))return e;let n=e.slice(1),r=t[n];if(r===void 0)throw new u(`Unknown mutation reference "${e}".`,p.USAGE);return r}function ft(e,t){if(typeof e!="string")return e;let n=e.replace(gt,(r,i,o)=>{let a=t[o];if(a===void 0)throw new u(`Unknown mutation reference "@${o}".`,p.USAGE);return`${i}id=${a}`});if(/(^|,)id=@/u.test(n))throw new u(`Malformed mutation reference in dependency "${e}".`,p.USAGE);return n}function Yt(e){return typeof e!="string"?[]:e.startsWith("@")?[e.slice(1)]:[...e.matchAll(gt)].map(t=>t[1]).filter(t=>t!==void 0)}function Xt(e,t){let n=new Map;for(let[a,s]of e.entries()){let d=t[a];if(d===void 0)continue;let c=w(s.options)?s.options:{},l=Array.isArray(c.dep)?c.dep:c.dep===void 0?[]:[c.dep];n.set(d,[c.parent,c.blockedBy,...l].flatMap(Yt))}let r=new Set,i=new Set,o=a=>{if(r.has(a))throw new u(`Mutation reference cycle includes "@${a}".`,p.USAGE);if(!i.has(a)){r.add(a);for(let s of n.get(a))n.has(s)&&o(s);r.delete(a),i.add(a)}};for(let a of n.keys())o(a)}function Zt(e){let t=e.split(/\r?\n/u).map((o,a)=>({line:o.trim(),number:a+1})).filter(o=>o.line.length>0);if(t.length<2)return null;let n=t.map(o=>{try{return{...o,ok:!0,value:JSON.parse(o.line)}}catch(a){return{...o,ok:!1,error:a}}}),r=n[0];if(!r.ok&&(r.line.startsWith("[")||r.line==="{"||n.at(-1).line==="}")||!n.some(o=>o.ok&&w(o.value)))return null;let i=[];for(let o of n){if(!o.ok)throw new u(`Mutation document line ${o.number} must be one valid JSON object: ${We(o.error)}`,p.USAGE,{code:"stdin_json_invalid",required:"Provide one JSON object per line (JSON Lines), a JSON array, or a {schema_version, mutations} document.",why:"Structured mutation input must parse deterministically before any tracker write begins."});if(!w(o.value))throw new u(`Mutation document line ${o.number} must be a JSON object.`,p.USAGE);i.push(o.value)}return i}function Qt(e){return Object.hasOwn(e,"mutations")||Object.hasOwn(e,"schema_version")}function en(e){let t;try{t=ae(e,"Mutation document")}catch(n){let r=Zt(e);if(r===null)throw n;return{schema_version:1,mutations:r}}return Array.isArray(t)?{schema_version:1,mutations:t}:w(t)&&!Qt(t)?{schema_version:1,mutations:[t]}:t}function tn(e,t){let n=Object.hasOwn(e,"op")?nn(e,t):rn(e,t);if(n.op==="create"&&n.id===void 0&&w(n.item)&&n.item.id!==void 0){if(typeof n.item.id!="string")throw new u(`Mutation ${t+1} item id must be a string.`,p.USAGE);n.id=n.item.id}return n}function nn(e,t){for(let n of Object.keys(e))if(!st.includes(n))throw A(`mutation ${t+1}`,n,st);if(e.item!==void 0&&e.op!=="create")throw new u(`Mutation ${t+1} item documents are only valid for create operations.`,p.USAGE);if(e.item!==void 0&&e.options!==void 0)throw new u(`Mutation ${t+1} must declare either item or options, not both.`,p.USAGE);return{...e}}function rn(e,t){let{ref:n,id:r,item:i,...o}=e,a=i!==void 0?i:o;if(i!==void 0&&Object.keys(o).length>0)throw new u(`Mutation ${t+1} must not mix item document keys with top-level fields.`,p.USAGE);if(!w(a))throw new u(`Mutation ${t+1} item document must be an object.`,p.USAGE);return{op:"create",...n===void 0?{}:{ref:n},...r===void 0?{}:{id:r},item:a}}function on(e){let t=en(e);if(!w(t))throw new u("Mutation document must be a JSON array or object.",p.USAGE);for(let n of Object.keys(t))if(!dt.includes(n))throw A("mutation document",n,dt);if(t.schema_version!==void 0&&t.schema_version!==1)throw new u("Mutation document schema_version must be 1.",p.USAGE);if(!Array.isArray(t.mutations)||t.mutations.length===0)throw new u("Mutation document requires a non-empty mutations array.",p.USAGE);return t.mutations.map((n,r)=>{if(!w(n))throw new u(`Mutation ${r+1} must be an object.`,p.USAGE);return tn(n,r)})}function an(e,t,n){let r=new Set(Object.values(At(t,n,Object.create(null))));for(let i of t)i.op==="create"&&typeof i.id=="string"&&i.id.trim().length>0&&r.add(N(i.id,n.idPrefix));return{...e,existing:e.existing.filter(i=>!r.has(i.id))}}function sn(e){let t=new Set(e.map(n=>n.ref).filter(n=>typeof n=="string"));for(let[n,r]of e.entries()){if(r.op!=="create"||r.ref!==void 0||typeof r.id=="string"&&r.id.trim().length>0)continue;let i=`${ct}${n+1}`;if(t.has(i))throw new u(`Mutation ${n+1} receives the synthesized ref "${i}", but another row declares that ref. Rename it or give mutation ${n+1} its own ref; ${ct}<n> aliases are reserved for rows without one.`,p.USAGE);r.ref=i}}function bt(e,t,n){let r=An(JSON.stringify(e),t,{},n);return delete r.stdinJson,delete r.documentAnnotationSnapshot,r}function Et(e,t){return e!=="create"&&e!=="update"?[]:t.filter(n=>n.commands.includes(e)).map(n=>E(n))}function cn(e,t){for(let n of e)w(n.item)&&(n.options=bt(n.item,"create",t),delete n.item)}function Ot(e,t){return t.some(n=>n.metadata_key===e)?e:at(e)}function ie(e,t,n){let r=t.replaceAll(/_([a-z])/gu,(a,s)=>s.toUpperCase());if(w(e.item)){if(e.item[t]!==void 0)return e.item[t];if(Ot(r,n)===t&&e.item[r]!==void 0)return e.item[r]}let i=w(e.options)?e.options:{},o=n.find(a=>a.metadata_key===t);return o!==void 0&&i[E(o)]!==void 0?i[E(o)]:i[t]!==void 0?i[t]:i[r]!==void 0?i[r]:(Array.isArray(i.field)?i.field:[]).map(String).find(a=>a.startsWith(`${t}=`))?.slice(t.length+1)}function dn(e,t){return e<t?-1:+(e!==t)}function oe(e){return Array.isArray(e)?e.map(oe):w(e)?Object.fromEntries(Object.entries(e).sort(([t],[n])=>dn(t,n)).map(([t,n])=>[t,oe(n)])):e}function _(e){return typeof e=="string"?e.trim():JSON.stringify(oe(e))}function un(e,t,n,r,i){let o=t.key.trim();if(o.length===0)throw new u("Upsert key must be a non-empty field name.",p.USAGE);let a=pn(t.existing),s=new Map,d=new Set;for(let[c,l]of e.entries()){if(l.op!=="create")continue;let f=ln(l,o,c,s,r),y=mn(a.get(f)??[],o,f);if(y===void 0){l.unique={key:o,value:ie(l,o,r)};continue}let h=N(y,n);typeof l.ref=="string"&&(i[l.ref]=h),fn(l,h,r,{key:o,value:ie(l,o,r)}),d.add(c)}return d}function pn(e){let t=new Map;for(let n of e){if(n.value===void 0||n.value===null)continue;let r=_(n.value);t.set(r,[...t.get(r)??[],n.id])}return t}function ln(e,t,n,r,i){let o=ie(e,t,i);if(o==null||o==="")throw new u(`Mutation ${n+1} is missing the upsert key "${t}".`,p.USAGE,{code:"upsert_key_missing",required:`Every create record must carry a non-empty "${t}" value when --upsert-key ${t} is set.`,why:"Keyed upsert identifies existing items by that field; a record without it cannot be matched or safely created."});let a=_(o),s=r.get(a);if(s!==void 0)throw new u(`Mutations ${s+1} and ${n+1} share the upsert key value ${JSON.stringify(a)} for "${t}".`,p.USAGE,{code:"upsert_key_duplicate",required:"Each record must carry a distinct upsert key value within one batch.",why:"Two records with the same key would race for the same existing item."});return r.set(a,n),a}function mn(e,t,n){if(e.length>1)throw new u(`Upsert key "${t}" value ${JSON.stringify(n)} matches ${e.length} existing items: ${e.join(", ")}.`,p.CONFLICT,{code:"upsert_key_ambiguous",required:"Resolve the duplicate existing items or choose a key that is unique per item.",why:"An ambiguous key cannot select one item to update without guessing."});return e[0]}function fn(e,t,n,r){let i=new Set([..._t.update,...Et("update",n)]),o=w(e.item)?bt(e.item,"update",n):Object.fromEntries(Object.entries(e.options).filter(([a])=>i.has(a)));delete e.item,delete e.ref,e.op="update",e.id=t,e.options=o,e.match=r}function At(e,t,n){for(let[r,i]of e.entries())if(i.ref!==void 0){if(i.op!=="create")throw new u(`Mutation ${r+1} ref is only valid for create operations.`,p.USAGE);if(typeof i.ref!="string"||!ut.test(i.ref))throw new u(`Mutation ${r+1} ref must match ${ut.source}.`,p.USAGE);if(n[i.ref]!==void 0)throw new u(`Duplicate mutation ref "${i.ref}".`,p.USAGE);n[i.ref]=typeof i.id=="string"&&i.id.trim().length>0?N(i.id,t.idPrefix):Ht(t.transactionId,i.ref,t.idPrefix)}return n}function _r(e,t){let n=on(e);sn(n);let r=n.map(l=>typeof l.ref=="string"?l.ref:void 0),i=Object.create(null),o=t.upsert===void 0?new Set:un(n,an(t.upsert,n,t),t.idPrefix,t.runtimeFields??[],i);cn(n,t.runtimeFields??[]),At(n,t,i),Xt(n,r);let a=n.map(l=>{let f={...l},y=typeof f.ref=="string"?f.ref:void 0;if(delete f.ref,y!==void 0?f.id=i[y]:f.id=mt(f.id,i),w(f.options)){let h={...f.options};for(let g of["parent","blockedBy"])h[g]!==void 0&&(h[g]=mt(h[g],i));Array.isArray(h.dep)?h.dep=h.dep.map(g=>ft(g,i)):h.dep!==void 0&&(h.dep=ft(h.dep,i)),f.options=h}return f}),s=St(JSON.stringify(a),{runtimeFields:t.runtimeFields??[]}),d=s.filter(l=>l.op==="create").map(l=>l.id);if(new Set(d).size!==d.length)throw new u("Duplicate resolved create id in mutation document.",p.USAGE);let c=s.map((l,f)=>{let y=r[f];return{index:f,...typeof y=="string"?{ref:y}:{},id:l.id,op:l.op,...o.has(f)?{upserted:!0}:{}}});return{schema_version:1,mutations:s,references:i,rows:c}}function hn(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 yn(e,t,n){if(e!==void 0){if(!Array.isArray(e)||!e.every(w))throw new u(`${n} must be an array of objects.`,p.USAGE);return e.map(r=>hn(r,t))}}function wn(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 ht(e,t,n=!1){for(let[r,i,o]of Ze){let a=t[r],s=yn(n&&["comments","notes","learnings"].includes(r)&&Array.isArray(a)?a.filter(d=>!w(d)||d.created_at===void 0):a,o,r);s!==void 0&&s.length>0&&(e[i]=s)}}function gn(e,t){for(let n of Object.keys(e)){if(t){if(!P.includes(n))throw A("item envelope",n,P);continue}if(!O.has(n)&&G(n,[...O])===void 0&&G(n,P)==="item")throw A("item envelope",n,P)}}function vn(e){let t=Object.hasOwn(e,"item");gn(e,t);let n=t?e.item:e;if(!w(n))throw new u("Item document item must be an object.",p.USAGE);return{item:n,...t&&w(e.linked)?{linked:e.linked}:{}}}function _n(e,t,n,r,i,o){if((r==="update"?Jt:vt).has(t))return;let a=i.find(s=>s.metadata_key===t&&s.commands.includes(r));if(a!==void 0){let s=Y(o,a);e[E(a)]=s!==void 0?s:a.type==="array"||a.type==="object"?JSON.stringify(n):n;return}if(!O.has(t)){if(G(t,[...O])!==void 0)throw A("item document",t,[...O]);let s=Array.isArray(e.field)?e.field:[];s.push(`${t}=${typeof n=="string"?n:JSON.stringify(n)}`),e.field=s;return}["dependencies","comments","notes","learnings","files","tests","docs","reminders","events","type_options"].includes(t)||(e[t.replaceAll(/_([a-z])/gu,(s,d)=>d.toUpperCase())]=wn(t,n))}function Sn(e){return{command_to_fields:new Map([["create",e.filter(t=>t.commands.includes("create"))]])}}function bn(e,t,n,r){let i=r.filter(c=>c.commands.includes("create")),o=new Set([...Ce.filter(c=>t.has(c.option)).map(c=>c.field),...i.filter(c=>t.has(E(c))).map(c=>c.metadata_key),...Xe(Array.isArray(n)?n.map(String):[],Sn(i)).metadataKeys]),a=(Array.isArray(e)?e:[]).filter(w).filter(c=>typeof c.field=="string"&&!o.has(c.field));if(a.length===0)return{};let s=a.map(c=>typeof c.reason=="string"?c.reason.trim():""),d=a.map(c=>c.field);return t.has("deferReason")?{defer:d}:s.every(c=>c.length>0)?{defer:d,deferReason:[...new Set(s)].join("; ")}:{defer:d}}function En(e,t,n){let r=new Set(Object.entries(e).filter(([,o])=>o!==void 0).map(([o])=>o)),i=t==="create"?j:D;for(let{target:o,keys:a}of i)a.some(s=>r.has(s))&&r.add(o);for(let o of n.filter(a=>a.commands.includes(t)))Y(e,o)!==void 0&&r.add(E(o));return r}function On(e,t,n){let r=t==="create"?j:D;for(let{target:i}of r)i!=="field"&&n.has(i)&&delete e[i]}function An(e,t,n={},r=[]){let i=ae(e,"Item document");if(!w(i))throw new u("Item document must be a JSON object.",p.USAGE);let{item:o,linked:a}=vn(i),s={};for(let[f,y]of Object.entries(o)){let h=Ot(f,r);h!==f&&Object.hasOwn(o,h)||_n(s,h,y,t,r,n)}ht(s,o,t==="update"),a!==void 0&&ht(s,a);let d=En(n,t,r);if(On(s,t,d),t==="create"&&!d.has("defer")&&Object.assign(s,bn(o.deferred_fields,d,n.unset,r)),t==="update"){let f=Object.fromEntries(["comments","notes","learnings"].filter(y=>Object.hasOwn(o,y)&&!d.has(y.slice(0,-1))).map(y=>[y,o[y].filter(h=>w(h)&&h.created_at!==void 0)]));Object.keys(f).length>0&&(s.documentAnnotationSnapshot=f)}let c={...s,...Object.fromEntries(Object.entries(n).filter(([,f])=>f!==void 0)),...Array.isArray(s.field)&&Array.isArray(n.field)?{field:[...s.field,...n.field]}:{},stdinJson:void 0},l=Object.keys(s).filter(f=>!d.has(f));return Ae(Ee(c,l),l)}function Sr(e){return St(JSON.stringify(e))}(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]="359a47e6-c7e8-5713-bd07-1e19fb81674a")}catch{}})();async function In(e,t){if(!qe(e))return{schema:H(t.schema),typeDefinitionsFromFile:[]};let n=await Wn(e,t.schema);return{schema:n.schema,typeDefinitionsFromFile:n.type_definitions_from_file??[]}}async function Cn(e,t,n,r){let i=V({...t,item_types:{...t.item_types,definitions:[...t.item_types?.definitions??[],...n.typeDefinitionsFromFile]}},X());return(await Le(e,t.item_format,i.type_to_folder,void 0,n.schema)).flatMap(o=>{let a=o[r];return a==null?[]:[{id:o.id,value:a}]})}function le(e){let t=new Map,n=async r=>{let i=await Ke(e),o=await In(e,i),a=new Map;for(let s of await Cn(e,i,o,r)){let d=_(s.value);a.set(d,[...a.get(d)??[],s.id])}return a};return{lookup(r){let i=t.get(r)??n(r);return t.set(r,i),i},async recordCreate(r){for(let[i,o]of t){let a=r[i];if(a==null)continue;let s=await o,d=_(a);s.set(d,[...s.get(d)??[],String(r.id)])}},invalidate(){t.clear()}}}async function Nn(e,t){let n=_(t.value),r=(await e.lookup(t.key)).get(n)??[];if(r.length!==0)throw new u(`Upsert key "${t.key}" value ${JSON.stringify(n)} now matches existing item ${r.join(", ")}; the plan was resolved before it existed.`,p.CONFLICT,{code:"upsert_key_conflict",required:"Re-plan the document so the row updates the existing item instead of creating a duplicate.",why:"Keyed upsert is resolved before the writer lock, so every remaining create is re-checked under the lock; concurrent imports therefore cannot create two items for one key value.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan turns the row into an update of the existing item.","Inspect the existing item first when its content should win over the document row."]})}function Un(e,t,n){let r=e.metadata[n.key],i=_(n.value);if(_(r)!==i)throw new u(`Item ${t} no longer carries upsert key "${n.key}" value ${JSON.stringify(i)}; the plan selected it before the key changed.`,p.CONFLICT,{code:"upsert_match_changed",required:"Re-plan the document so the row is resolved against the current key values.",why:"Keyed upsert selects its target before the writer lock, so the update re-reads the key under the lock instead of updating a mismatched item blindly.",nextSteps:["Re-run pm item mutate with the same document and --upsert-key; the re-plan creates or re-targets the row from the current key values."]})}function Tt(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;let t=e;return typeof t.key=="string"&&t.key.trim().length>0&&t.value!==void 0&&t.value!==null}function L(e,t){let n={...e,...t};return e===void 0?n:z(e,n)}async function b(e,t){try{let n=(await te(t,{},{pmRoot:e})).item;return{id:n.id,closedAt:n.closed_at,updatedAt:n.updated_at,assignee:n.assignee,claimPrincipal:n.claim_principal}}catch(n){if(n instanceof u&&n.exitCode===p.NOT_FOUND)return;throw n}}function me(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_"),r=ue.createHash("sha256").update(be(e)).digest("hex").slice(0,12);return`${t+1}-${e.op}-${n}-${r}`}function jn(e,t){let n=e.id.replaceAll(/[^a-zA-Z0-9._-]/gu,"_");return`${t+1}-${e.op}-${n}`}function v(e,t,n){return`bulk-item-transaction ${e} ${t} ${n}`}function fe(e,t){return e===t||(e?.startsWith(`${t} | `)??!1)}async function M(e,t,n,r){let i=await R(m.join(e,"history",`${t}.jsonl`),t),o=v(n,r,"apply"),a=v(n,r,"compensate");for(let s=i.length-1;s>=0;s-=1){let d=i[s].message;if(fe(d,o))return!0;if(d===a)return!1}return!1}async function he(e,t){let n=await b(e,t.id);if(n?.updatedAt===void 0)throw new u(`Bulk ${t.op} target ${t.id} does not exist or has no restorable version`,p.NOT_FOUND);let r=await R(m.join(e,"history",`${n.id}.jsonl`),n.id);if(r.length===0)throw new u(`Bulk ${t.op} target ${t.id} has no restorable history`,p.NOT_FOUND);return{target_updated_at:n.updatedAt,target_version:String(Z(r)+r.length),target_history_hash:I(r),target_history_length:r.length}}function T(e,t,n){return new u(`Transaction ${e.transactionId} cannot safely compensate incomplete step ${n}; review item ${t} history before recovery.`,p.CONFLICT,{code:"transaction_partial_mutation",item_id:t,required:"Reconcile the item's partial or intervening changes before resuming this transaction.",why:"The retained history does not prove exclusive ownership of the changes to undo. The journal remains compensating instead of claiming a rollback or overwriting another writer.",nextSteps:[`Run pm history ${t} and inspect this transaction's retained compensation data before explicitly restoring or reconciling the item.`]})}function Nt(e,t){let n=`bulk-item-transaction ${t} `;return[e.message,e.context?.item_transaction_step].some(r=>typeof r=="string"&&r.startsWith(n))}function Dn(e,t,n){let{expectedHistory:r,length:i,version:o}=t;if(I(e)===r)return!1;if(typeof i!="number"||!Number.isSafeInteger(i)||i<1||I(e.slice(0,i))!==r||o!==String(Z(e)+i))throw T(n,n.itemId,n.stepId);let a=v(n.transactionId,n.stepId,"apply"),s=e.slice(i),d=y=>fe(y.message,a)||y.context?.item_transaction_step===a,c=v(n.transactionId,n.stepId,"compensate");if(s.filter(y=>d(y)||y.message===c).at(-1)?.message===c)return!1;let l=s.filter(d);if(l.length===0)return!1;let f=e.at(-1).after_hash===l.at(-1).after_hash&&s.every(y=>Nt(y,n.transactionId));if(l.length!==s.length&&!f)throw T(n,n.itemId,n.stepId);return!0}async function Ut(e,t){let n=m.join(e,"history",`${t}.jsonl`),r=await Ue(n,t);return{history:r.entries,assertOwnedUnderLock:(i,o)=>{let a;try{a=Tn(n).equals(r.raw_bytes)&&je(i)===r.entries.at(-1).after_hash}catch(s){throw Object.assign(o(),{cause:s})}if(!a)throw o()}}}async function W(e,t,n,r){let i=r!==null&&typeof r=="object"&&!Array.isArray(r)?r:void 0;if(i===void 0||typeof i.target_updated_at!="string")return;let o=i.target_updated_at,a=await b(e.pmRoot,t);if(a===void 0)return;let{history:s,assertOwnedUnderLock:d}=await Ut(e.pmRoot,a.id),c=i.target_history_hash,l=typeof c=="string";if(typeof c=="string"){if(!Dn(s,{expectedHistory:c,length:i.target_history_length,version:i.target_version},{...e,itemId:a.id,stepId:n}))return}else{if(a.updatedAt===o)return;if(!await M(e.pmRoot,a.id,e.transactionId,n))throw T(e,a.id,n)}let f=()=>it(t,typeof i.target_version=="string"?i.target_version:o,{force:!0,author:e.author,message:v(e.transactionId,n,"compensate")},{pmRoot:e.pmRoot});await C({pmRoot:e.pmRoot,id:a.id,validate:y=>{d(y,()=>T(e,a.id,n))},compensation:Dt(e,t,n,"restore",l)},f)}var jt=new WeakMap;function Dt(e,t,n,r,i){let o=i?ze(e.pmRoot,e.transactionId):void 0,a=o===void 0?void 0:jt.get(o);if(!(a?.stepId!==n||a.itemId!==t||a.operation!==r))return{transaction_id:e.transactionId,step_id:n,operations:[r],overrides:[]}}function Ft(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);if(r===void 0)return{state:"pending"};if(r.closedAt!==void 0){let i=await R(m.join(e.pmRoot,"history",`${r.id}.jsonl`),r.id),o=`Compensated: interrupted bulk transaction ${e.transactionId}`;if(i.filter(a=>a.op==="close").at(-1)?.patch.some(a=>a.op==="add"||a.op==="replace"?a.path==="/metadata/close_reason"&&a.value===o:!1)??!1)throw new u(`Created item ${r.id} remains closed by transaction compensation; explicitly reopen or reconcile it before retrying.`,p.CONFLICT,{code:"transaction_create_compensated",item_id:r.id,required:"Review the compensated item and explicitly reopen it before retrying the same document.",why:"This item's latest closure belongs to transaction compensation. Automatically reopening it could overwrite later lifecycle decisions.",nextSteps:[`Run pm item reopen ${r.id} "Retry compensated creation" after reviewing its history, then retry the transaction.`]})}return{state:"applied",result:{id:r.id,op:"create"}}},async apply(){t.unique!==void 0&&await Nn(e.uniqueIndex,t.unique);let r=await et(L(t.options,{author:e.author,id:t.id,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=r.item;return e.onCreateWarnings?.(String(i.id),r.warnings),await e.uniqueIndex.recordCreate(i),{id:String(i.id),op:"create"}},async compensate(){await Fn(e,t.id,n)}}}async function Fn(e,t,n){let r=await b(e.pmRoot,t);if(r===void 0||e.createCompensation==="close"&&r.closedAt!==void 0)return;let{history:i,assertOwnedUnderLock:o}=await Ut(e.pmRoot,r.id),a=v(e.transactionId,n,"apply"),s=v(e.transactionId,n,"compensate"),d=i.filter(c=>fe(c.message,a)||c.message===s).at(-1);if(d?.message!==s){if(d===void 0||!i.every(c=>Nt(c,e.transactionId)))throw T(e,r.id,n);await C({pmRoot:e.pmRoot,id:r.id,validate:c=>{o(c,()=>T(e,r.id,n))},compensation:Dt(e,t,n,e.createCompensation==="delete"?"delete":"close",!0)},async()=>{let c={force:!0,author:e.author,message:s};e.createCompensation==="delete"?await rt(t,c,{pmRoot:e.pmRoot}):await ne(t,`Compensated: interrupted bulk transaction ${e.transactionId}`,{...c,validateClose:"off"},{pmRoot:e.pmRoot})})}}function Pn(e,t,n){return{id:n,compensatePending:!0,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(e.pmRoot,r.id,e.transactionId,n)?{state:"applied",result:{id:r.id,op:"update"}}:{state:"pending"}},async prepareCompensation(){return he(e.pmRoot,t)},async apply(){let r=()=>tt(t.id,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot}),i=t.match,o=i,a=(await C({pmRoot:e.pmRoot,id:String((await te(t.id,{},{pmRoot:e.pmRoot})).item.id),validate:s=>{o!==void 0&&Un(s,t.id,o)},committed:s=>{i!==void 0&&(o={key:i.key,value:structuredClone(s.metadata[i.key])})},historyContext:{item_transaction_step:v(e.transactionId,n,"apply")}},r)).item;return e.uniqueIndex.invalidate(),{id:String(a.id),op:"update"}},async compensate(r){await W(e,t.id,n,r)}}}function Gn(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(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 he(e.pmRoot,t)},async apply(){let r=(await ne(t.id,t.reason,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"close"}},async compensate(r){await W(e,t.id,n,r)}}}function xn(e,t,n){return{id:n,async inspect(){let r=await b(e.pmRoot,t.id);return r===void 0?{state:"pending"}:await M(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 he(e.pmRoot,t)},async apply(){let r=(await nt(t.id,L(t.options,{author:e.author,message:v(e.transactionId,n,"apply")}),{pmRoot:e.pmRoot})).item;return e.uniqueIndex.invalidate(),{id:String(r.id),op:"release"}},async compensate(r){await W(e,t.id,n,r)}}}function ye(e,t,n){let r=me(t,n),i=qn(e,t,r);return jt.set(i,{transactionId:e.transactionId,stepId:r,itemId:t.id,operation:t.op!=="create"?"restore":e.createCompensation==="delete"?"delete":"close"}),i}function qn(e,t,n){switch(t.op){case"create":return Ft(e,t,n);case"update":return Pn(e,t,n);case"close":return Gn(e,t,n);case"release":return xn(e,t,n)}}function Kn(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`);if(e.op==="create"&&e.unique!==void 0&&!Tt(e.unique))throw new TypeError(`Bulk create mutation ${t+1} unique must be an object with a non-empty key and a value`);if(e.op==="update"&&e.match!==void 0&&!Tt(e.match))throw new TypeError(`Bulk update mutation ${t+1} match must be an object with a non-empty key and a value`);F(e.options,e.op,t)}function Pt(e){if(e.length===0)throw new TypeError("Bulk item transaction requires at least one mutation");let t=new Map;for(let[n,r]of e.entries()){if(Kn(r,n),r.op!=="create"||r.unique===void 0)continue;let{key:i,value:o}=r.unique,a=t.get(i)??new Map,s=_(o),d=a.get(s);if(d!==void 0)throw new u(`Bulk create mutations ${d+1} and ${n+1} share the upsert key value ${JSON.stringify(s)} for "${i}".`,p.USAGE,{code:"upsert_key_duplicate",required:"Each create must carry a distinct unique key value within one batch.",why:"Direct SDK batches must preserve the same uniqueness invariant as planned document rows."});a.set(s,n),t.set(i,a)}}function Gt(e){let t=[...e];return Pt(t),t.map(n=>{let r=structuredClone(n);return n.options!==void 0&&r.options!==void 0&&z(n.options,r.options),r})}function xt(e,t=""){return e===null||typeof e!="object"?[]:Object.entries(e).flatMap(([n,r])=>{let i=`${t}/${n.replaceAll("~","~0").replaceAll("/","~1")}`;return/^(created_at|updated_at|closed_at|completed_at|timestamp)$/u.test(n)?[i]:xt(r,i)})}async function ce(e,t,n){try{return await n()}catch(r){throw r instanceof u?new u(r.message,r.exitCode,{...r.context,transaction_operation:{index:t,op:e.op,id:e.id}}):r}}function qt(e,t,n,r){let i=m.relative(e,t),o=i.split(m.sep);return o[0]==="extensions"&&o[2]==="node_modules"&&!r.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`))?!1:["locks","runtime","search"].includes(i.split(m.sep)[0])?r.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`)):i===""||n===void 0||n.some(a=>i===a||i.startsWith(`${a}${m.sep}`)||a.startsWith(`${i}${m.sep}`))}async function q(e,t){let n=await kt(t);if(n.isSymbolicLink())await pe(t);else if(n.isDirectory()||n.isFile())return n;throw $(m.relative(e,t))}async function Ln(e,t){let n=await Mn(t,se.O_RDONLY|se.O_NOFOLLOW|se.O_NONBLOCK);try{let r=await n.stat();if(!r.isFile())throw $(m.relative(e,t));let i=ue.createHash("sha256");if(r.size>0)for await(let o of n.createReadStream({highWaterMark:64*1024,end:r.size-1,autoClose:!1}))i.update(o);return i.digest()}finally{await n.close()}}async function de(e,t,n){let r=ue.createHash("sha256");async function i(o){for(let a of(await Rn(o)).sort()){let s=m.join(o,a);qt(e,s,t,n)&&((await q(e,s)).isDirectory()?await i(s):(r.update(JSON.stringify(m.relative(e,s))),r.update(await Ln(e,s))))}}return await i(e),r.digest("hex")}function x(){return new u("Tracker changed while preparing the transaction preview; retry against stable state.",p.CONFLICT,{code:"transaction_preview_snapshot_changed"})}async function we(e){if(!B(e))return!1;let t=e.path;if(typeof t!="string")return!1;let n=m.resolve(t),r=n;for(;;)try{let i=await kt(r);return r!==n&&i.isDirectory()}catch(i){if(!B(i))return!1;let o=m.dirname(r);if(o===r)return!1;r=o}}async function K(e,t){let n=m.join(e,t);try{let r=e;for(let i of t.split(m.sep).slice(0,-1))r=m.join(r,i),await q(e,r);if(!(await q(e,n)).isFile())throw $(t);return await Te(n,$(t))}catch(r){if(await we(r))return;throw r}}async function Kt(e,t,n,r){let i=H(n);for(let[o,a]of Object.entries(i.files)){let s=m.relative(e,Re(e,a,Me[o]));if(s===""||!m.resolve(e,s).startsWith(m.join(e,m.sep)))throw new u("Transaction preview requires schema files inside the selected tracker root; relocate the configured schema file before retrying.",p.USAGE,{code:"transaction_preview_external_schema",field:`schema.files.${o}`});i.files[o]=s;let d=await K(e,s);if(r?.set(s,d),d!==void 0){let c=m.join(t,s);await $n(m.dirname(c),{recursive:!0}),await It(c,d)}}return Ie(t,i)}async function Wn(e,t){await pe(e);let n=await $t(m.join(Ct(),"pm-schema-plan-"));try{let r=await Mt(e);return await Kt(r,m.join(n,"configuration"),t)}catch(r){throw await we(r)?x():r}finally{await Rt(n,{recursive:!0,force:!0})}}async function Jn(e,t,n){let r=new Map,i=await K(e,k);r.set(k,i);let o;try{o=JSON.parse(i??"null")}catch{o=null}let a=xe(o),s=a.success?a.data:void 0,d=await Kt(e,t,s?.schema,r),c=d.schema,l=m.relative(e,Ne(e));r.set(l,await K(e,l));let f=V({...Se,item_types:{definitions:[...s?.item_types?.definitions??[],...d.type_definitions_from_file??[]]}},n),y=ke(e)===e?[..._e.filter(Boolean),k,Je,"transactions",...f.folders,...r.keys()].map(g=>m.normalize(g)):void 0,h=s===void 0?void 0:JSON.stringify({...o,schema:{...s.schema,files:c.files}});return{configuration:r,ownedPaths:y,stagedSettings:h,registryFolders:f.folders}}async function zn(e,t,n){await pe(e);try{let r=await Mt(e),i=await Jn(r,m.join(m.dirname(t),"configuration"),n),o=[...i.configuration.keys(),...i.registryFolders].map(c=>m.normalize(c)),a=await de(r,i.ownedPaths,o);await kn(r,t,{recursive:!0,dereference:!1,filter:async c=>qt(r,c,i.ownedPaths,o)?(await q(r,c),!0):!1});let[s,d]=await Promise.all([de(r,i.ownedPaths,o),de(t,i.ownedPaths,o)]);if(a!==s||a!==d)throw x();for(let[c,l]of i.configuration)if(await K(t,c)!==l)throw x();i.stagedSettings!==void 0&&await It(m.join(t,k),i.stagedSettings)}catch(r){throw await we(r)?x():r}}async function Qr(e){let t=U(e),n=Gt(e.mutations),r=X(),i=Pe(),o=await $t(m.join(Ct(),"pm-transaction-preview-")),a=m.join(o,"tracker");try{await zn(t.pmRoot,a,r);let s=!1,d=[],c=[],l=new Set;return await Fe(i,()=>ot({path:a,noExtensions:!0},async()=>{De(r);let f={...t,pmRoot:a,createCompensation:"close",uniqueIndex:le(a)},y=n.map((h,g)=>{let S=ye({...f,onCreateWarnings:(J,ge)=>{ge.length>0&&d.push({index:g,id:J,op:"create",warnings:ge})}},h,g);return{...S,inspect:()=>ce(h,g,()=>S.inspect()),prepareCompensation:()=>ce(h,g,async()=>S.prepareCompensation?.()),apply:()=>ce(h,g,async()=>{let J=await S.apply();return l.add(g),J})}});if(await Q({...t,pmRoot:a,steps:y,onTransition:({transition:h})=>{h==="committed"&&(s=!0)}}),s)for(let[h,g]of n.entries()){let S=(await Qe(g.id,{path:a},{full:!0})).item;c.push({index:h,id:String(S.id),op:g.op,execution:l.has(h)?"applied":"adopted",item:S,commit_time_fields:xt(S)})}})),{records:c,validated:s,state:s?"staged_snapshot":"replayed_committed_plan",warnings:d,unresolved_commit_constraints:["concurrent_tracker_changes","extension_write_hooks","derived_extension_dependencies_excluded","generated_timestamps_and_provenance"]}}finally{await Rt(o,{recursive:!0,force:!0})}}async function Bn(e){let t=U(e),n=Gt(e.mutations),r=e.createCompensation??"close";if(!["close","delete"].includes(r))throw new TypeError("Bulk item transaction createCompensation must be close or delete");let i={...t,createCompensation:r,uniqueIndex:le(t.pmRoot)},o=await Q({...t,steps:n.map((s,d)=>ye(i,s,d)),recoveryData:JSON.parse(JSON.stringify({kind:"item-mutations-v1",mutations:n,createCompensation:r})),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}}),a={};for(let[s,d]of n.entries()){let c=me(d,s),l=o.results[c];a[jn(d,s)]=l}return{transactionId:o.transactionId,status:"committed",recovered:o.recovered,results:a}}function Vn(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 ei(e){return Bn({pmRoot:e.pmRoot,transactionId:e.transactionId,author:e.author,mutations:Vn(e),...e.lockTtlSeconds===void 0?{}:{lockTtlSeconds:e.lockTtlSeconds},...e.lockWaitMs===void 0?{}:{lockWaitMs:e.lockWaitMs},...e.onTransition===void 0?{}:{onTransition:e.onTransition}})}var ti={buildCreateStep:Ft,bulkHistoryMarker:v,compensateByRestore:W,deriveStepId:me,isUpdateMarkerApplied:M,readItemSnapshot:b};async function ni(e,t){let n=await Be(e,t);return n===void 0?void 0:{journal:n,planDigest:ee(n)}}function Hn(e,t){let n=t.recoveryData;if(n===null||typeof n!="object"||Array.isArray(n)||n.kind!=="item-mutations-v1"||!Array.isArray(n.mutations)||!["close","delete"].includes(String(n.createCompensation)))throw new u("Transaction has no supported item recovery plan",p.CONFLICT,{code:"transaction_recovery_plan_missing",required:"Resume with the original plan and its original adapter.",why:"Legacy or foreign journals cannot safely reconstruct item compensation."});let r=n.mutations;Pt(r);let i={...e,createCompensation:n.createCompensation,uniqueIndex:le(e.pmRoot)};return r.map((o,a)=>ye(i,o,a))}async function ri(e){let t=U(e),n=await Ve({...e,...t,resolveSteps:r=>Hn({...e,...t},r)});return{journal:n,planDigest:ee(n)}}export{at as a,gr as b,vr as c,St as d,_ as e,_r as f,An as g,Sr as h,In as i,Cn as j,Wn as k,Qr as l,Bn as m,Vn as n,ei as o,ti as p,ni as q,ri as r};
2
+ //# sourceMappingURL=chunk-CTOE26W4.js.map
@@ -1,2 +1,2 @@
1
- import{lb as h}from"./chunk-7K2RUKMK.js";import{$ as A,Je as z,Ke as G,Tb as $,Ub as R,Vd as B,Wd as S,Wg as U,Xe as L,Y as w,Ye as W,Z as k,Zb as V,_ as F,aa as g,ba as C,gc as v,lb as D,u as N,v as p,x as E,y as M,z as I}from"./chunk-7UUPLMCU.js";import{A as y,C as _}from"./chunk-5OFMWP3Q.js";import{Command as ae}from"commander";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a851f5ac-99a5-5061-a0c3-a08d898ea20b")}catch{}})();function nt(e){return new ae().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(e).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:t=>{U(t)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the result encoding for reads and mutations").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume continuation_kind=output_cursor").option("--output-row-contract","Include row selectors, encoding metadata, and read-output receipts").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--all","Reveal every public command and compatibility alias").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").option("--expect-hash <revision>","Refuse writes to the named item unless it is still at this item_hash from pm get (a bare hash names the command's <id>; guard each other item with <id>=<item_hash>, repeatable)",(t,n)=>[...n??[],t]).exitOverride()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8efedca0-725e-520f-ad06-825a0cccddaa")}catch{}})();var j=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),q=new Map([["files","discover"],["item","complete"]]),le=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function K(e){let t=p(e?.trim().toLowerCase()??"");return j.has(t)||q.has(t)}function ce(e,t,n){let o=j.has(n)?t+1:void 0,s=g(e.slice(t+1));if(s===void 0)return o;let r=t+1+s,a=`${n} ${e[r]}`,i=p(a);return i===a?n==="item"&&e[r]==="complete"?r+1:o:K(i)?P(e,r,i):void 0}function P(e,t,n){if(["history","context","ctx","update","close","item"].includes(n))return ce(e,t,n);let o=q.get(n);if(o===void 0)return t+1;let s=e[t+1]?.toLowerCase()===o;return t+(s?2:1)}function ue(e){let t=new Map;for(let n of h(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function de(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function fe(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let o=n.get(e);return o!==void 0&&o.value_type!=="boolean"}function pe(e,t,n,o,s){let r=0;for(let a=t;a<e.length;a+=1){let i=e[a];if(i==="--")break;if(i==="--id"){a+=1;continue}if(!i.startsWith("--id=")){if(!i.startsWith("-")){if(a<o)return!0;r+=1;continue}fe(i,e[a+1],s)&&(a+=1)}}return r>(le.get(p(n))??0)}function Y(e){let t=g(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(n!=="context"&&n!=="ctx"&&!K(n))return{argv:[...e],changed:!1,conflict:!1};let o=P(e,t,n);if(o===void 0)return{argv:[...e],changed:!1,conflict:!1};let s=o>t+1?`${p(e.slice(t,o-1).join(" "))} ${e[o-1]}`:n,r=ue(s),a=de(e),i=a[0];if(!i||!i.value?.trim())return{argv:[...e],changed:!1,conflict:!1};if(a.length>1||pe(e,o,s,i.index,r))return{argv:[...e],changed:!1,conflict:!0,itemId:i.value};let l=[...e.slice(0,i.index),...e.slice(i.index+i.consumed)],c=g(l),u=P(l,c,n);return l.splice(u,0,i.value),{argv:l,changed:!0,conflict:!1,itemId:i.value}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="10f173af-3f3d-5678-85a1-267469d22069")}catch{}})();var me=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),he=new Set(["toon","json"]);function ge(e,t,n){let o=e[t];if(k.has(o))return n.booleanFlags.add(o),1;let s=o.indexOf("="),r=s>0?o.slice(0,s):o;if(!w.has(r))return 1;let a=s>0?o.slice(s+1):void 0,i=a===void 0&&A(r,e[t+1]),l=a??(i?e[t+1]:void 0);return r==="--author"?n.author=l??"":typeof l=="string"&&l.length>0&&(me.has(r)?n.outputValues:n.pathValues).set(r,l),i?2:1}function be(e){return e.outputValues.get("--output-format")!=="toon"&&(e.booleanFlags.has("--json")||e.outputValues.get("--output-format")==="json"||e.pathValues.get("--format")?.trim().toLowerCase()==="json")}function ye(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=ge(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions")||["history attest","history-attest"].includes(ee(e)??""),noPager:t.booleanFlags.has("--no-pager"),json:be(t),quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...he.has(t.outputValues.get("--output-format"))?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function Z(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(k.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(w.has(o)){n+=A(o,e[n+1])?2:1;continue}if(F(o)){n+=1;continue}t.push(o),n+=1}return t}function _e(e){let t=Z(e);if(t[0]?.trim().toLowerCase()==="help"){let o=[];for(let s=1;s<t.length;s+=1){let r=t[s];if(r.startsWith("-"))break;o.push(r.trim().toLowerCase())}return{requested:!0,commandPathTokens:o}}if(t.findIndex(o=>o==="--help"||o==="-h")<0)return{requested:!1,commandPathTokens:[]};let n=[];for(let o of t){if(o.startsWith("-"))break;n.push(o.trim().toLowerCase())}return{requested:!0,commandPathTokens:n}}function T(e){return g(e)}function we(e){return C(e)}function Ie(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:_e(e).requested}function bt(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(r=>process.env[r]),o=()=>{for(let[r,a]of t.entries()){let i=n[r];i===void 0?delete process.env[a]:process.env[a]=i}},s=ye(e);return Ie(e,s)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var ke=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function Ce(e){let t=T(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!ke.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var ve=new Set(["pm","pm-cli"]);function Se(e,t){let n=T(e);if(n===void 0)return e;let o=e[n];return ve.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function Te(e,t){let n=T(e);if(n!==void 0&&e[n]==="help"){let i=T(e.slice(n+1));n=i===void 0?void 0:n+1+i}if(n===void 0)return e;let o=e[n],s=M[o.trim().toLowerCase()];if(!s)return e;let r=s.split(" "),a=[...e.slice(0,n),...r,...e.slice(n+1)];return t.push({from:o,to:r,reason:"command_alias",confidence:"high"}),a}function x(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function X(e){return x(e).replace(/-/g,"")}function J(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function xe(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function Oe(e,t){let n=t??h(e),o=new Map,s=new Map,r=new Map,a=new Set;for(let i of n){let l=xe(i);if(l.length===0)continue;let c=`--${x(l[0])}`;for(let d of l)J(o,x(d),c),J(s,X(d),c);let u=X(c);r.has(c)||r.set(c,u),i.list===!0&&a.add(c)}return{canonicalByNormalized:o,canonicalByCompact:s,canonicalComparables:[...r.entries()].map(([i,l])=>({canonicalFlag:i,comparable:l})),listCanonicalFlags:a}}function H(e,t){let n=x(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let s=n.replace(/-/g,""),r=t.canonicalByCompact.get(s);if(typeof r=="string")return{flag:r,reason:"flag_alias",confidence:"high"};let a=s.length>=8?2:1,i=Number.POSITIVE_INFINITY,l,c=!1;for(let u of t.canonicalComparables){let d=v(s,u.comparable,a);if(d!==null){if(d<i){i=d,l=u.canonicalFlag,c=!1;continue}d===i&&l!==u.canonicalFlag&&(c=!0)}}return!l||c||!Number.isFinite(i)||i<=0?null:{flag:l,reason:"flag_typo",confidence:i>=2?"medium":"high"}}function yt(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function Ee(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],s=n[3];return s.length===0||n[2]===":"&&/\s/u.test(e)?null:{key:o,value:s}}function Ae(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),s=o>=0?e.slice(0,o):e,r=o>=0?e.slice(o+1):void 0,a=H(s,t);if(!a)return{tokens:[e]};let i=r===void 0?a.flag:`${a.flag}=${r}`;return i===e?{tokens:[e]}:{tokens:[i],event:{from:e,to:[i],reason:a.reason,confidence:a.confidence}}}function Le(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let s=e[o];n=s==="--path"||s==="--pm-path"}return t}function Pe(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function Ne(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function Me(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let s=[],r=t+1;for(;r<e.length&&e[r]!=="--"&&!e[r].startsWith("-")&&(s.length===0||o.has(n.flag));)s.push(e[r]),r+=1;let a=s.length===0?1:1+s.length;return{originalTokens:e.slice(t,t+a),value:s.length===0?void 0:s.join(","),consumed:a}}function Fe(e,t,n,o){let s=e.get(n);if(s){s.values.push(o.value),s.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function De(e,t){let n=[],o=[];for(let[s,r]of e){if(!(r.occurrences>=2||t.has(s)&&r.originalTokens.length>2)){o.push({outputIndex:r.outputIndex,tokens:r.originalTokens});continue}let a=`${s}=${r.values.join(",")}`;o.push({outputIndex:r.outputIndex,tokens:[a]}),n.push({from:`${s} (x${r.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function $e(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function Re(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let s=[],r=new Map,a=0;for(;a<e.length;){let c=e[a];if(c==="--"){s.push(...e.slice(a));break}if(n.has(c)){a=Ne(e,a,s);continue}let u=Pe(c);if(!u||!t.has(u.flag)){s.push(c),a+=1;continue}let d=Me(e,a,u,o);if(d.value===void 0){s.push(c),a+=d.consumed;continue}Fe(r,s,u.flag,{originalTokens:d.originalTokens,value:d.value}),a+=d.consumed}let{events:i,splices:l}=De(r,o);return $e(s,l),{argv:s,events:i}}var Q=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function Ve(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],s=Q.get(o);return s!==void 0&&s.has(n)}function Be(e,t,n){if(t!=="test")return e;let o=[],s=0;for(;s<e.length;){let r=e[s];if(r==="--")return o.push(...e.slice(s)),o;let a=Q.get(r),i=a?e[s+1]:void 0;if(!a||typeof i!="string"||!a.has(i)){o.push(r),s+=1;continue}let l=s+2;for(;l<e.length&&!e[l].startsWith("-");)l+=1;if(l-(s+2)!==1){o.push(r),s+=1;continue}let c=e[s+2],u=`${i}=${c}`;o.push(r,u),n.push({from:`${r} ${i} ${c}`,to:[r,u],reason:"bare_key_value",confidence:"high"}),s+=3}return o}function ze(e,t,n,o){let s=[],r=Le(e);for(let a=0;a<e.length;a+=1){let i=e[a];if(i==="--"){s.push(...e.slice(a));break}let l=r.has(a),c=s[s.length-1];if(i.startsWith("--")){let b=Ae(i,t,l);s.push(...b.tokens),b.event&&o.push(b.event);continue}let u=Ee(i,l);if(!u||typeof c=="string"&&c.startsWith("-")&&!c.includes("=")||["search","comments","notes","learnings"].includes(n)||Ve(n,s)){s.push(i);continue}let d=H(u.key,t);if(!d){s.push(i);continue}let m=u.value.startsWith("-")?[`${d.flag}=${u.value}`]:[d.flag,u.value];s.push(...m),o.push({from:i,to:m,reason:"bare_key_value",confidence:d.confidence})}return s}function Ge(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--verify"){let o=e[t+1];if(o===void 0||o==="--")throw new _("history attest --verify requires a bundle file.",y.USAGE);e.splice(t,2,`--verify=${o}`)}else(w.has(n)||n==="--output"||n==="--hash-algorithm")&&(t+=1)}}function We(e,t){if(!e.some(o=>o==="--help"||o==="-h"))return;let n=new Set(h(t).flatMap(o=>[o.flag,...o.aliases??[],...o.short===void 0?[]:[o.short]]));for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="--")break;s!=="--help"&&s!=="-h"||n.has(e[o-1])&&!k.has(e[o-1])&&(e[o-1]=s)}}function _t(e){let t=[],n=Se(e,t),o=Ce(n);(o.length!==n.length||o.some((b,re)=>b!==n[re]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let s=Te(o,t),r=Y(s);if(r.conflict)throw new _("Provide the item id either positionally or with --id, not both.",y.USAGE);r.changed&&t.push({from:`--id ${r.itemId}`,to:[r.itemId],reason:"item_id_alias",confidence:"high"});let a=we(r.argv),i=ee(r.argv),l=p(i??a??""),c=Oe(i??a),u=ze(r.argv,c,l,t),d=Be(u,l,t),m=Re(d,c.listCanonicalFlags,w,a==="create"?new Set(["--tags"]):new Set);for(let b of m.events)t.push(b);return We(m.argv,i??a),i==="history attest"&&Ge(m.argv),{argv:m.argv,commandName:a,trace:t}}function ee(e){let t=Z(e),n=t[0]?.trim().toLowerCase(),o=t[1]?.trim().toLowerCase(),s=N(t);return s?s.canonical:(n==="extension"||n==="package"||n==="packages")&&typeof o=="string"&&o.length>0&&!o.startsWith("-")?`${n} ${o}`:n}function wt(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return o}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fb625cd9-f8a8-56cf-88ab-abef64051497")}catch{}})();function St(e){if(e===void 0)return()=>{};let t=e.trim();if(t.length===0)throw new _("--author requires a non-empty value.",y.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let n=B();S(t);let o=!1;return()=>{o||(o=!0,n===void 0?S(void 0):S(n))}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d0e60f7e-e0a8-5ef4-9af7-4a1f102ccb7d")}catch{}})();var f=Object.freeze({clock:"PM_CLOCK",tickMs:"PM_CLOCK_TICK_MS",seed:"PM_SEED"});function O(e,t,n,o){return new _(e,y.USAGE,{code:"invalid_reproducible_process_environment",reason:t,field:n,required:`${f.clock} and ${f.seed}; ${f.tickMs} is optional`,nextSteps:[`Set ${f.clock} to an ISO-8601 instant with Z or a numeric UTC offset and ${f.seed} to a non-empty reproducibility seed.`,`Optionally set ${f.tickMs} to a non-negative integer; it defaults to 1.`,"Unset all three variables to retain normal wall-clock and cryptographic-random behavior."],recovery:{recovery_mode:"compact",provided_fields:o,missing_required_fields:t==="incomplete"?[f.clock,f.seed].filter(s=>!o.includes(s)):void 0}})}function Ue(e){let t=e[f.clock],n=e[f.tickMs],o=e[f.seed],s=[[f.clock,t],[f.tickMs,n],[f.seed,o]].filter(a=>a[1]!==void 0).map(([a])=>a);if(s.length===0)return;if(t===void 0||o===void 0)throw O("Reproducible process execution requires PM_CLOCK and PM_SEED together.","incomplete",t===void 0?f.clock:f.seed,s);if(o.trim().length===0)throw O(`${f.seed} must not be empty.`,"invalid_value",f.seed,s);if(!V(t))throw O(`${f.clock} must be a valid ISO-8601 instant with Z or a numeric UTC offset.`,"invalid_value",f.clock,s);let r=n===void 0?1:Number(n);if(n?.trim().length===0||!Number.isSafeInteger(r)||r<0)throw O(`${f.tickMs} must be a non-negative integer.`,"invalid_value",f.tickMs,s);return $({clock:t,seed:o,tickMs:r})}function je(e){let t=Ue(e);return t===void 0?n=>n():R(t)}async function Lt(e,t){return je(e)(t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="94bdb20f-d193-5767-91f2-8207169b82d1")}catch{}})();var te=new Set([...Object.values(z),...G,"--full","--brief","--compact","--summary","--fields","--section","--token-budget"]),ne=new Set(["--full-changed-fields","--no-changed-fields","--id-only"]);function zt(e,t){if(!["block","unblock"].includes(e)||t.includes(e)||!t.includes("update"))return;let n=new Set(h("update").map(o=>o.flag));if((e==="block"?["--blocked-by","--blocked-reason"]:["--unset","--unblock-note"]).every(o=>n.has(o)))return e==="block"?{examples:[["update","<item-id>","--blocked-by","<blocker-id>","--blocked-reason","<reason>"]],nextSteps:["Choose the actual item and blocker identifiers before running update. --blocked-by records the blocker field and its blocked_by relationship."]}:{examples:[["update","<item-id>","--unset","blocked-by","--unset","blocked-reason","--unblock-note","<note>"]],nextSteps:[`Inspect the item's blockers before running update. --unset blocked-by removes the blocker field and the blocked_by rows naming it; other blocked_by relationships stay, so remove one with --dep-remove "id=<id>,kind=blocked_by" or all with --dep-remove kind=blocked_by. --unset blocked-reason clears the stale reason. --unblock-note alone records a note and does not unblock the item.`,"If your project also uses a blocked lifecycle status, choose its appropriate next status separately with update --status."]}}function qe(e,t){let n=e.includes("="),o=n?e.slice(e.indexOf("=")+1):t;if(!(!o||o.startsWith("--")))return{consumed:n?1:2,replacement:["--from",o],conflicts:["--from"]}}var Ke=["--depth","--output-include","--fields","--section","--for"];function Ye(e){let t=L(p(e.trim().toLowerCase()));if(t===void 0)return;let n=h(t),o=n.flatMap(a=>[a.flag,...a.aliases??[]]),s=[...W(t).keys()].filter(a=>o.includes(`--${a}`)),r=[...n.find(a=>a.flag==="--depth")?.values??[]];if(!(s.length===0&&r.length===0))return{command:t,modes:s,depth_values:r,declared_flags:o}}function Gt(e){return[...e.depth_values.length>0?[`--depth ${e.depth_values.join("|")}`]:[],...e.modes.map(t=>`--${t}`)].join(", ")}function Xe(e,t,n,o){let s=Ye(e);if(s===void 0||s.declared_flags.includes(t))return;let r=[...Ke,...s.modes.map(i=>`--${i}`)].filter(i=>i!==t);if(t==="--depth"){let i=n.includes("="),l=(i?n.slice(n.indexOf("=")+1):o)?.trim().toLowerCase();if(!l)return;let c=i?1:2;return s.modes.includes(l)?{consumed:c,replacement:[`--${l}`],conflicts:r}:l==="standard"?{consumed:c,replacement:[],conflicts:r}:void 0}let a=t.slice(2);return n===t&&s.depth_values.includes(a)?{consumed:1,replacement:["--depth",a],conflicts:r}:void 0}function Je(e,t,n,o){return t==="--since"&&e==="activity"?qe(n,o):t==="--toon"&&n===t?{consumed:1,replacement:["--output-format","toon"],conflicts:["--json","--format","--output-format","--stream"]}:Xe(e,t,n,o)}function Ze(e){let t=g(e);if(t===void 0)return;let n=e[t].trim().toLowerCase(),o=`${n} ${e[t+1]?.trim().toLowerCase()??""}`,s=p(o);return s!==o.trim()?s:n==="ctx"?"context":p(n)}function Wt(e,t,n){let o=e==="ctx"?"context":p(e);if(L(o)===void 0||t.includes("--")||Ze(t)!==o)return;let s=n.split("=",1)[0],r=t.flatMap((d,m)=>d===s||d.startsWith(`${s}=`)?[m]:[]);if(r.length!==1)return;let a=r[0],i=Je(o,s,t[a],t[a+1]);if(!i)return;let{replacement:l,consumed:c,conflicts:u}=i;if(!t.some(d=>u.includes(d.split("=",1)[0])))return[...t.slice(0,a),...l,...t.slice(a+c)]}function oe(e){let t=e.split("=",1)[0].replaceAll("_","-");return te.has(t)||t.length>=5&&[...te].some(n=>n.startsWith(t))}function Ut(e,t){let n=e.split("=",1)[0].replaceAll("_","-");return oe(n)?!ne.has(t):ne.has(n)?!oe(t):!0}function se(e){return e.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function jt(e){if(!(!Array.isArray(e)||e.length===0))return C(e)}function He(e,t){let n=se(t);if(!n)return;let o=h(e).find(s=>s.flag===n||s.aliases?.includes(n));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function qt(e,t,n){let o=[...e],s=o.indexOf("--"),r=s<0?o.length:s;for(let a of n){let i=se(a);if(!i||o.slice(0,r).some(u=>u===i||u.startsWith(`${i}=`)))continue;let l=He(t,i),c=l?[i,l]:[i];o.splice(r,0,...c),r+=c.length}return o.length===e.length?void 0:D(o)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bd9a8d3b-bc6f-5309-a3fb-7e5f41ef9dab")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="12066389-daef-5fce-b7a6-0ecffa926d66")}catch{}})();function Qt(e,t){let n=e.trim().split(/\s+/u);if(!(n.length<2||t.includes(n.join(" "))))for(let o=1;o<n.length;o+=1){if(!t.includes(n.slice(0,o).join(" ")))return;let s=n.slice(o).join(" "),r=I(s),a=new Set(t.filter(i=>i===s||i.endsWith(` ${s}`)||i===r?.canonical).map(i=>I(i)?.canonical??i).filter(i=>t.includes(i)));if(a.size>0)return a.size===1?[...a][0]:void 0}}var Qe={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"],start:["start-task"]};function ie(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let s=n.split(" "),r=Qe[o]?.indexOf(p(n));if(r!==void 0&&r>=0)return r;if(n===o)return 10;if(s.includes(o))return 11;if(s.some(l=>l.startsWith(o)))return 12;let a=o.length>=5?2:1,i=Number.POSITIVE_INFINITY;for(let l of s){let c=v(l,o,a);c!==null&&(i=Math.min(i,c))}return Number.isFinite(i)?20+i:n.includes(o)?30:Number.POSITIVE_INFINITY}function en(e,t){return e.map(n=>({path:n,score:ie(n,t)})).filter(n=>Number.isFinite(n.score)).sort((n,o)=>n.score!==o.score?n.score-o.score:n.path===o.path?0:n.path<o.path?-1:1).map(n=>n.path)}function tn(e,t,n){let o=new Set(t),s=E.filter(i=>i.lifecycle==="deprecated").slice().sort((i,l)=>l.alias.length-i.alias.length),r=[],a=e.flatMap(i=>{let l=s.find(u=>i===u.alias||i.startsWith(`${u.alias} `)),c=i;if(l){let u=i.slice(l.alias.length);if(!o.has(`${l.canonical}${u}`))return[];c=`${l.canonical_argv.join(" ")}${u}`}return n!==void 0&&ie(i,n)<10&&r.push(c),[c]});return[...new Set(r.length>0?r:a)]}export{nt as a,K as b,Y as c,ye as d,Z as e,_e as f,T as g,we as h,bt as i,Ce as j,yt as k,Re as l,Be as m,_t as n,wt as o,St as p,f as q,Ue as r,je as s,Lt as t,zt as u,Ye as v,Gt as w,Wt as x,oe as y,Ut as z,jt as A,He as B,qt as C,Qt as D,ie as E,en as F,tn as G};
2
- //# sourceMappingURL=chunk-FXSLODOK.js.map
1
+ import{lb as h}from"./chunk-AOV5HG3Y.js";import{$ as A,Je as z,Ke as G,Tb as $,Ub as R,Vd as B,Wd as S,Wg as U,Xe as L,Y as w,Ye as W,Z as k,Zb as V,_ as F,aa as g,ba as C,gc as v,lb as D,u as N,v as p,x as E,y as M,z as I}from"./chunk-7UUPLMCU.js";import{A as y,C as _}from"./chunk-5OFMWP3Q.js";import{Command as ae}from"commander";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="a851f5ac-99a5-5061-a0c3-a08d898ea20b")}catch{}})();function nt(e){return new ae().name("pm").description("Universal, flexible, extensible, agent-optimized project management CLI for any project or programming language.").version(e).showHelpAfterError(!1).allowExcessArguments(!1).allowUnknownOption(!1).configureOutput({writeOut:t=>{U(t)},writeErr:()=>{}}).option("--json","Output JSON instead of TOON; mutations emit a flat receipt with top-level id/status/changed_field_count while reads use documented entity or collection envelopes").option("--lean","Omit null and empty containers from JSON output").option("--token-accounting","Attach a bounded per-section token-cost receipt to command output").option("--output-include <fields>","Retain comma-separated fields or sections in read output").option("--output-limit <count>","Bound rows in read output").option("--output-budget <tokens|unbounded>","Bound estimated tokens in read output or explicitly disable the default ceiling").option("--output-format <toon|json>","Select the result encoding for reads and mutations").option("--output-session <state>","Carry a JSON session budget and served-item ledger across read calls").option("--output-cursor <cursor>","Resume continuation_kind=output_cursor").option("--output-row-contract","Include row selectors, encoding metadata, and read-output receipts").option("--quiet","Suppress stdout output").option("--no-changed-fields","Omit the changed_fields array from mutation output (keeps changed_field_count)").option("--full-changed-fields","Restore the legacy full mutation envelope and changed_fields array").option("--id-only","Print only id and status for single-item mutation output").option("--pm-path <dir>","Explicit tracker storage path for this command (preferred over --path)").option("--path <dir>","Backward-compatible alias for --pm-path; this is the tracker storage path, not a workspace cwd").option("--no-extensions","Disable extension loading").option("--no-pager","Disable pager integration for help and long output").option("--explain","Render extended rationale and examples in help output").option("--all","Reveal every public command and compatibility alias").option("--profile","Print deterministic timing diagnostics").option("--author <id>","Override mutation author for this invocation").option("--expect-hash <revision>","Refuse writes to the named item unless it is still at this item_hash from pm get (a bare hash names the command's <id>; guard each other item with <id>=<item_hash>, repeatable)",(t,n)=>[...n??[],t]).exitOverride()}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="8efedca0-725e-520f-ad06-825a0cccddaa")}catch{}})();var j=new Set(["append","claim","close","close-task","comments","copy","delete","deps","docs","files","focus","get","history","history-compact","history-redact","history-repair","learnings","notes","pause-task","release","restore","start-task","test","update"]),q=new Map([["files","discover"],["item","complete"]]),le=new Map([["append",1],["close",1],["close-task",1],["comments",1],["item complete",1],["learnings",1],["notes",1],["restore",1]]);function K(e){let t=p(e?.trim().toLowerCase()??"");return j.has(t)||q.has(t)}function ce(e,t,n){let o=j.has(n)?t+1:void 0,s=g(e.slice(t+1));if(s===void 0)return o;let r=t+1+s,a=`${n} ${e[r]}`,i=p(a);return i===a?n==="item"&&e[r]==="complete"?r+1:o:K(i)?P(e,r,i):void 0}function P(e,t,n){if(["history","context","ctx","update","close","item"].includes(n))return ce(e,t,n);let o=q.get(n);if(o===void 0)return t+1;let s=e[t+1]?.toLowerCase()===o;return t+(s?2:1)}function ue(e){let t=new Map;for(let n of h(e))for(let o of[n.flag,n.short,...n.aliases??[]])o&&t.set(o,n);return t}function de(e){let t=[];for(let n=0;n<e.length;n+=1){let o=e[n];if(o==="--")break;o==="--id"?(t.push({index:n,consumed:2,value:e[n+1]}),n+=1):o.startsWith("--id=")&&t.push({index:n,consumed:1,value:o.slice(5)})}return t}function fe(e,t,n){if(e.indexOf("=")>=0||t===void 0||t.startsWith("-"))return!1;let o=n.get(e);return o!==void 0&&o.value_type!=="boolean"}function pe(e,t,n,o,s){let r=0;for(let a=t;a<e.length;a+=1){let i=e[a];if(i==="--")break;if(i==="--id"){a+=1;continue}if(!i.startsWith("--id=")){if(!i.startsWith("-")){if(a<o)return!0;r+=1;continue}fe(i,e[a+1],s)&&(a+=1)}}return r>(le.get(p(n))??0)}function Y(e){let t=g(e),n=t===void 0?void 0:e[t]?.toLowerCase();if(n!=="context"&&n!=="ctx"&&!K(n))return{argv:[...e],changed:!1,conflict:!1};let o=P(e,t,n);if(o===void 0)return{argv:[...e],changed:!1,conflict:!1};let s=o>t+1?`${p(e.slice(t,o-1).join(" "))} ${e[o-1]}`:n,r=ue(s),a=de(e),i=a[0];if(!i||!i.value?.trim())return{argv:[...e],changed:!1,conflict:!1};if(a.length>1||pe(e,o,s,i.index,r))return{argv:[...e],changed:!1,conflict:!0,itemId:i.value};let l=[...e.slice(0,i.index),...e.slice(i.index+i.consumed)],c=g(l),u=P(l,c,n);return l.splice(u,0,i.value),{argv:l,changed:!0,conflict:!1,itemId:i.value}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="10f173af-3f3d-5678-85a1-267469d22069")}catch{}})();var me=new Set(["--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),he=new Set(["toon","json"]);function ge(e,t,n){let o=e[t];if(k.has(o))return n.booleanFlags.add(o),1;let s=o.indexOf("="),r=s>0?o.slice(0,s):o;if(!w.has(r))return 1;let a=s>0?o.slice(s+1):void 0,i=a===void 0&&A(r,e[t+1]),l=a??(i?e[t+1]:void 0);return r==="--author"?n.author=l??"":typeof l=="string"&&l.length>0&&(me.has(r)?n.outputValues:n.pathValues).set(r,l),i?2:1}function be(e){return e.outputValues.get("--output-format")!=="toon"&&(e.booleanFlags.has("--json")||e.outputValues.get("--output-format")==="json"||e.pathValues.get("--format")?.trim().toLowerCase()==="json")}function ye(e){let t={booleanFlags:new Set,outputValues:new Map,pathValues:new Map},n=0;for(;n<e.length&&e[n]!=="--";)n+=ge(e,n,t);return{path:t.pathValues.get("--pm-path")??t.pathValues.get("--path"),noExtensions:t.booleanFlags.has("--no-extensions")||["history attest","history-attest"].includes(ee(e)??""),noPager:t.booleanFlags.has("--no-pager"),json:be(t),quiet:t.booleanFlags.has("--quiet"),lean:t.booleanFlags.has("--lean"),tokenAccounting:t.booleanFlags.has("--token-accounting"),...t.booleanFlags.has("--output-row-contract")?{outputRowContract:!0}:{},...t.outputValues.get("--output-include")===void 0?{}:{outputInclude:t.outputValues.get("--output-include")},...t.outputValues.get("--output-limit")===void 0?{}:{outputLimit:t.outputValues.get("--output-limit")},...t.outputValues.get("--output-budget")===void 0?{}:{outputBudget:t.outputValues.get("--output-budget")},...he.has(t.outputValues.get("--output-format"))?{outputFormat:t.outputValues.get("--output-format")}:{},...t.outputValues.get("--output-session")===void 0?{}:{outputSession:t.outputValues.get("--output-session")},...t.outputValues.get("--output-cursor")===void 0?{}:{outputCursor:t.outputValues.get("--output-cursor")},...t.author===""?{authorMissingValue:!0}:t.author!==void 0?{author:t.author}:{}}}function Z(e){let t=[],n=0;for(;n<e.length;){let o=e[n];if(o==="--")break;if(k.has(o)||o==="--profile"||o==="--id-only"||o==="--full-changed-fields"||o==="--explain"){n+=1;continue}if(w.has(o)){n+=A(o,e[n+1])?2:1;continue}if(F(o)){n+=1;continue}t.push(o),n+=1}return t}function _e(e){let t=Z(e);if(t[0]?.trim().toLowerCase()==="help"){let o=[];for(let s=1;s<t.length;s+=1){let r=t[s];if(r.startsWith("-"))break;o.push(r.trim().toLowerCase())}return{requested:!0,commandPathTokens:o}}if(t.findIndex(o=>o==="--help"||o==="-h")<0)return{requested:!1,commandPathTokens:[]};let n=[];for(let o of t){if(o.startsWith("-"))break;n.push(o.trim().toLowerCase())}return{requested:!0,commandPathTokens:n}}function T(e){return g(e)}function we(e){return C(e)}function Ie(e,t){return t.noPager?!0:process.stdout.isTTY===!0?!1:_e(e).requested}function bt(e){let t=["PAGER","MANPAGER","GIT_PAGER","LESS"],n=t.map(r=>process.env[r]),o=()=>{for(let[r,a]of t.entries()){let i=n[r];i===void 0?delete process.env[a]:process.env[a]=i}},s=ye(e);return Ie(e,s)&&(process.env.PAGER="cat",process.env.MANPAGER="cat",process.env.GIT_PAGER="cat",(typeof process.env.LESS!="string"||process.env.LESS.trim().length===0)&&(process.env.LESS="FRX")),o}var ke=new Set(["install","uninstall","explore","manage","doctor","adopt","adopt-all","activate","deactivate"]);function Ce(e){let t=T(e);if(t===void 0||e[t]!=="extension")return[...e];let n=e[t+1];if(!n||n.startsWith("-"))return[...e];if(!ke.has(n))return[...e];if(e.includes("--help")||e.includes("-h"))return[...e];let o=`--${n}`;return e.includes(o)?[...e]:[...e.slice(0,t+1),o,...e.slice(t+2)]}var ve=new Set(["pm","pm-cli"]);function Se(e,t){let n=T(e);if(n===void 0)return e;let o=e[n];return ve.has(o.trim().toLowerCase())?(t.push({from:o,to:[],reason:"executable_alias",confidence:"high"}),[...e.slice(0,n),...e.slice(n+1)]):e}function Te(e,t){let n=T(e);if(n!==void 0&&e[n]==="help"){let i=T(e.slice(n+1));n=i===void 0?void 0:n+1+i}if(n===void 0)return e;let o=e[n],s=M[o.trim().toLowerCase()];if(!s)return e;let r=s.split(" "),a=[...e.slice(0,n),...r,...e.slice(n+1)];return t.push({from:o,to:r,reason:"command_alias",confidence:"high"}),a}function x(e){return e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}function X(e){return x(e).replace(/-/g,"")}function J(e,t,n){let o=e.get(t);if(o===void 0){e.set(t,n);return}o!==n&&e.set(t,null)}function xe(e){let t=[],n=o=>{typeof o=="string"&&o.startsWith("--")&&t.push(o)};n(e.flag);for(let o of e.aliases??[])n(o);return t}function Oe(e,t){let n=t??h(e),o=new Map,s=new Map,r=new Map,a=new Set;for(let i of n){let l=xe(i);if(l.length===0)continue;let c=`--${x(l[0])}`;for(let d of l)J(o,x(d),c),J(s,X(d),c);let u=X(c);r.has(c)||r.set(c,u),i.list===!0&&a.add(c)}return{canonicalByNormalized:o,canonicalByCompact:s,canonicalComparables:[...r.entries()].map(([i,l])=>({canonicalFlag:i,comparable:l})),listCanonicalFlags:a}}function H(e,t){let n=x(e),o=t.canonicalByNormalized.get(n);if(typeof o=="string")return{flag:o,reason:"flag_alias",confidence:"high"};let s=n.replace(/-/g,""),r=t.canonicalByCompact.get(s);if(typeof r=="string")return{flag:r,reason:"flag_alias",confidence:"high"};let a=s.length>=8?2:1,i=Number.POSITIVE_INFINITY,l,c=!1;for(let u of t.canonicalComparables){let d=v(s,u.comparable,a);if(d!==null){if(d<i){i=d,l=u.canonicalFlag,c=!1;continue}d===i&&l!==u.canonicalFlag&&(c=!0)}}return!l||c||!Number.isFinite(i)||i<=0?null:{flag:l,reason:"flag_typo",confidence:i>=2?"medium":"high"}}function yt(e){let t=[`${e}s`];return e.endsWith("y")&&e.length>1&&t.push(`${e.slice(0,-1)}ies`),t}function Ee(e,t=!1){if(t||e.includes("://"))return null;let n=e.match(/^([A-Za-z][A-Za-z0-9_-]{1,63})([:=])(.*)$/);if(!n)return null;let o=n[1],s=n[3];return s.length===0||n[2]===":"&&/\s/u.test(e)?null:{key:o,value:s}}function Ae(e,t,n=!1){if(n||!e.startsWith("--"))return{tokens:[e]};let o=e.indexOf("="),s=o>=0?e.slice(0,o):e,r=o>=0?e.slice(o+1):void 0,a=H(s,t);if(!a)return{tokens:[e]};let i=r===void 0?a.flag:`${a.flag}=${r}`;return i===e?{tokens:[e]}:{tokens:[i],event:{from:e,to:[i],reason:a.reason,confidence:a.confidence}}}function Le(e){let t=new Set,n=!1;for(let o=0;o<e.length;o+=1){if(n){t.add(o),n=!1;continue}let s=e[o];n=s==="--path"||s==="--pm-path"}return t}function Pe(e){if(!e.startsWith("--"))return null;let t=e.indexOf("=");return t<0?{flag:e}:{flag:e.slice(0,t),inlineValue:e.slice(t+1)}}function Ne(e,t,n){n.push(e[t]);let o=e[t+1];return typeof o=="string"&&o!=="--"?(n.push(o),t+2):t+1}function Me(e,t,n,o){if(n.inlineValue!==void 0)return{originalTokens:[e[t]],value:n.inlineValue,consumed:1};let s=[],r=t+1;for(;r<e.length&&e[r]!=="--"&&!e[r].startsWith("-")&&(s.length===0||o.has(n.flag));)s.push(e[r]),r+=1;let a=s.length===0?1:1+s.length;return{originalTokens:e.slice(t,t+a),value:s.length===0?void 0:s.join(","),consumed:a}}function Fe(e,t,n,o){let s=e.get(n);if(s){s.values.push(o.value),s.occurrences+=1;return}e.set(n,{outputIndex:t.length,originalTokens:o.originalTokens,values:[o.value],occurrences:1}),t.push(null)}function De(e,t){let n=[],o=[];for(let[s,r]of e){if(!(r.occurrences>=2||t.has(s)&&r.originalTokens.length>2)){o.push({outputIndex:r.outputIndex,tokens:r.originalTokens});continue}let a=`${s}=${r.values.join(",")}`;o.push({outputIndex:r.outputIndex,tokens:[a]}),n.push({from:`${s} (x${r.occurrences})`,to:[a],reason:"list_merge",confidence:"high"})}return{events:n,splices:o}}function $e(e,t){t.sort((n,o)=>o.outputIndex-n.outputIndex);for(let n of t)e.splice(n.outputIndex,1,...n.tokens)}function Re(e,t,n=new Set,o=new Set){if(t.size===0)return{argv:[...e],events:[]};let s=[],r=new Map,a=0;for(;a<e.length;){let c=e[a];if(c==="--"){s.push(...e.slice(a));break}if(n.has(c)){a=Ne(e,a,s);continue}let u=Pe(c);if(!u||!t.has(u.flag)){s.push(c),a+=1;continue}let d=Me(e,a,u,o);if(d.value===void 0){s.push(c),a+=d.consumed;continue}Fe(r,s,u.flag,{originalTokens:d.originalTokens,value:d.value}),a+=d.consumed}let{events:i,splices:l}=De(r,o);return $e(s,l),{argv:s,events:i}}var Q=new Map([["--add",new Set(["command","cmd","path"])],["--remove",new Set(["command","path"])]]);function Ve(e,t){if(e!=="test"||t.length<2)return!1;let n=t[t.length-1],o=t[t.length-2],s=Q.get(o);return s!==void 0&&s.has(n)}function Be(e,t,n){if(t!=="test")return e;let o=[],s=0;for(;s<e.length;){let r=e[s];if(r==="--")return o.push(...e.slice(s)),o;let a=Q.get(r),i=a?e[s+1]:void 0;if(!a||typeof i!="string"||!a.has(i)){o.push(r),s+=1;continue}let l=s+2;for(;l<e.length&&!e[l].startsWith("-");)l+=1;if(l-(s+2)!==1){o.push(r),s+=1;continue}let c=e[s+2],u=`${i}=${c}`;o.push(r,u),n.push({from:`${r} ${i} ${c}`,to:[r,u],reason:"bare_key_value",confidence:"high"}),s+=3}return o}function ze(e,t,n,o){let s=[],r=Le(e);for(let a=0;a<e.length;a+=1){let i=e[a];if(i==="--"){s.push(...e.slice(a));break}let l=r.has(a),c=s[s.length-1];if(i.startsWith("--")){let b=Ae(i,t,l);s.push(...b.tokens),b.event&&o.push(b.event);continue}let u=Ee(i,l);if(!u||typeof c=="string"&&c.startsWith("-")&&!c.includes("=")||["search","comments","notes","learnings"].includes(n)||Ve(n,s)){s.push(i);continue}let d=H(u.key,t);if(!d){s.push(i);continue}let m=u.value.startsWith("-")?[`${d.flag}=${u.value}`]:[d.flag,u.value];s.push(...m),o.push({from:i,to:m,reason:"bare_key_value",confidence:d.confidence})}return s}function Ge(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--verify"){let o=e[t+1];if(o===void 0||o==="--")throw new _("history attest --verify requires a bundle file.",y.USAGE);e.splice(t,2,`--verify=${o}`)}else(w.has(n)||n==="--output"||n==="--hash-algorithm")&&(t+=1)}}function We(e,t){if(!e.some(o=>o==="--help"||o==="-h"))return;let n=new Set(h(t).flatMap(o=>[o.flag,...o.aliases??[],...o.short===void 0?[]:[o.short]]));for(let o=0;o<e.length;o+=1){let s=e[o];if(s==="--")break;s!=="--help"&&s!=="-h"||n.has(e[o-1])&&!k.has(e[o-1])&&(e[o-1]=s)}}function _t(e){let t=[],n=Se(e,t),o=Ce(n);(o.length!==n.length||o.some((b,re)=>b!==n[re]))&&t.push({from:n.join(" "),to:[...o],reason:"legacy_extension_action",confidence:"high"});let s=Te(o,t),r=Y(s);if(r.conflict)throw new _("Provide the item id either positionally or with --id, not both.",y.USAGE);r.changed&&t.push({from:`--id ${r.itemId}`,to:[r.itemId],reason:"item_id_alias",confidence:"high"});let a=we(r.argv),i=ee(r.argv),l=p(i??a??""),c=Oe(i??a),u=ze(r.argv,c,l,t),d=Be(u,l,t),m=Re(d,c.listCanonicalFlags,w,a==="create"?new Set(["--tags"]):new Set);for(let b of m.events)t.push(b);return We(m.argv,i??a),i==="history attest"&&Ge(m.argv),{argv:m.argv,commandName:a,trace:t}}function ee(e){let t=Z(e),n=t[0]?.trim().toLowerCase(),o=t[1]?.trim().toLowerCase(),s=N(t);return s?s.canonical:(n==="extension"||n==="package"||n==="packages")&&typeof o=="string"&&o.length>0&&!o.startsWith("-")?`${n} ${o}`:n}function wt(e){for(let t=0;t<e.length;t+=1){let n=e[t];if(n==="--")break;if(n==="--type"){let o=e[t+1];if(typeof o=="string"&&o.trim().length>0)return o.trim();continue}if(n.startsWith("--type=")){let o=n.slice(7).trim();if(o.length>0)return o}}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="fb625cd9-f8a8-56cf-88ab-abef64051497")}catch{}})();function St(e){if(e===void 0)return()=>{};let t=e.trim();if(t.length===0)throw new _("--author requires a non-empty value.",y.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});let n=B();S(t);let o=!1;return()=>{o||(o=!0,n===void 0?S(void 0):S(n))}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d0e60f7e-e0a8-5ef4-9af7-4a1f102ccb7d")}catch{}})();var f=Object.freeze({clock:"PM_CLOCK",tickMs:"PM_CLOCK_TICK_MS",seed:"PM_SEED"});function O(e,t,n,o){return new _(e,y.USAGE,{code:"invalid_reproducible_process_environment",reason:t,field:n,required:`${f.clock} and ${f.seed}; ${f.tickMs} is optional`,nextSteps:[`Set ${f.clock} to an ISO-8601 instant with Z or a numeric UTC offset and ${f.seed} to a non-empty reproducibility seed.`,`Optionally set ${f.tickMs} to a non-negative integer; it defaults to 1.`,"Unset all three variables to retain normal wall-clock and cryptographic-random behavior."],recovery:{recovery_mode:"compact",provided_fields:o,missing_required_fields:t==="incomplete"?[f.clock,f.seed].filter(s=>!o.includes(s)):void 0}})}function Ue(e){let t=e[f.clock],n=e[f.tickMs],o=e[f.seed],s=[[f.clock,t],[f.tickMs,n],[f.seed,o]].filter(a=>a[1]!==void 0).map(([a])=>a);if(s.length===0)return;if(t===void 0||o===void 0)throw O("Reproducible process execution requires PM_CLOCK and PM_SEED together.","incomplete",t===void 0?f.clock:f.seed,s);if(o.trim().length===0)throw O(`${f.seed} must not be empty.`,"invalid_value",f.seed,s);if(!V(t))throw O(`${f.clock} must be a valid ISO-8601 instant with Z or a numeric UTC offset.`,"invalid_value",f.clock,s);let r=n===void 0?1:Number(n);if(n?.trim().length===0||!Number.isSafeInteger(r)||r<0)throw O(`${f.tickMs} must be a non-negative integer.`,"invalid_value",f.tickMs,s);return $({clock:t,seed:o,tickMs:r})}function je(e){let t=Ue(e);return t===void 0?n=>n():R(t)}async function Lt(e,t){return je(e)(t)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="94bdb20f-d193-5767-91f2-8207169b82d1")}catch{}})();var te=new Set([...Object.values(z),...G,"--full","--brief","--compact","--summary","--fields","--section","--token-budget"]),ne=new Set(["--full-changed-fields","--no-changed-fields","--id-only"]);function zt(e,t){if(!["block","unblock"].includes(e)||t.includes(e)||!t.includes("update"))return;let n=new Set(h("update").map(o=>o.flag));if((e==="block"?["--blocked-by","--blocked-reason"]:["--unset","--unblock-note"]).every(o=>n.has(o)))return e==="block"?{examples:[["update","<item-id>","--blocked-by","<blocker-id>","--blocked-reason","<reason>"]],nextSteps:["Choose the actual item and blocker identifiers before running update. --blocked-by records the blocker field and its blocked_by relationship."]}:{examples:[["update","<item-id>","--unset","blocked-by","--unset","blocked-reason","--unblock-note","<note>"]],nextSteps:[`Inspect the item's blockers before running update. --unset blocked-by removes the blocker field and the blocked_by rows naming it; other blocked_by relationships stay, so remove one with --dep-remove "id=<id>,kind=blocked_by" or all with --dep-remove kind=blocked_by. --unset blocked-reason clears the stale reason. --unblock-note alone records a note and does not unblock the item.`,"If your project also uses a blocked lifecycle status, choose its appropriate next status separately with update --status."]}}function qe(e,t){let n=e.includes("="),o=n?e.slice(e.indexOf("=")+1):t;if(!(!o||o.startsWith("--")))return{consumed:n?1:2,replacement:["--from",o],conflicts:["--from"]}}var Ke=["--depth","--output-include","--fields","--section","--for"];function Ye(e){let t=L(p(e.trim().toLowerCase()));if(t===void 0)return;let n=h(t),o=n.flatMap(a=>[a.flag,...a.aliases??[]]),s=[...W(t).keys()].filter(a=>o.includes(`--${a}`)),r=[...n.find(a=>a.flag==="--depth")?.values??[]];if(!(s.length===0&&r.length===0))return{command:t,modes:s,depth_values:r,declared_flags:o}}function Gt(e){return[...e.depth_values.length>0?[`--depth ${e.depth_values.join("|")}`]:[],...e.modes.map(t=>`--${t}`)].join(", ")}function Xe(e,t,n,o){let s=Ye(e);if(s===void 0||s.declared_flags.includes(t))return;let r=[...Ke,...s.modes.map(i=>`--${i}`)].filter(i=>i!==t);if(t==="--depth"){let i=n.includes("="),l=(i?n.slice(n.indexOf("=")+1):o)?.trim().toLowerCase();if(!l)return;let c=i?1:2;return s.modes.includes(l)?{consumed:c,replacement:[`--${l}`],conflicts:r}:l==="standard"?{consumed:c,replacement:[],conflicts:r}:void 0}let a=t.slice(2);return n===t&&s.depth_values.includes(a)?{consumed:1,replacement:["--depth",a],conflicts:r}:void 0}function Je(e,t,n,o){return t==="--since"&&e==="activity"?qe(n,o):t==="--toon"&&n===t?{consumed:1,replacement:["--output-format","toon"],conflicts:["--json","--format","--output-format","--stream"]}:Xe(e,t,n,o)}function Ze(e){let t=g(e);if(t===void 0)return;let n=e[t].trim().toLowerCase(),o=`${n} ${e[t+1]?.trim().toLowerCase()??""}`,s=p(o);return s!==o.trim()?s:n==="ctx"?"context":p(n)}function Wt(e,t,n){let o=e==="ctx"?"context":p(e);if(L(o)===void 0||t.includes("--")||Ze(t)!==o)return;let s=n.split("=",1)[0],r=t.flatMap((d,m)=>d===s||d.startsWith(`${s}=`)?[m]:[]);if(r.length!==1)return;let a=r[0],i=Je(o,s,t[a],t[a+1]);if(!i)return;let{replacement:l,consumed:c,conflicts:u}=i;if(!t.some(d=>u.includes(d.split("=",1)[0])))return[...t.slice(0,a),...l,...t.slice(a+c)]}function oe(e){let t=e.split("=",1)[0].replaceAll("_","-");return te.has(t)||t.length>=5&&[...te].some(n=>n.startsWith(t))}function Ut(e,t){let n=e.split("=",1)[0].replaceAll("_","-");return oe(n)?!ne.has(t):ne.has(n)?!oe(t):!0}function se(e){return e.trim().match(/--[a-z0-9][a-z0-9_-]*/i)?.[0]?.replaceAll("_","-").toLowerCase()}function jt(e){if(!(!Array.isArray(e)||e.length===0))return C(e)}function He(e,t){let n=se(t);if(!n)return;let o=h(e).find(s=>s.flag===n||s.aliases?.includes(n));return o?o.value_type==="boolean"?null:`<${o.value_name??"value"}>`:"<value>"}function qt(e,t,n){let o=[...e],s=o.indexOf("--"),r=s<0?o.length:s;for(let a of n){let i=se(a);if(!i||o.slice(0,r).some(u=>u===i||u.startsWith(`${i}=`)))continue;let l=He(t,i),c=l?[i,l]:[i];o.splice(r,0,...c),r+=c.length}return o.length===e.length?void 0:D(o)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="bd9a8d3b-bc6f-5309-a3fb-7e5f41ef9dab")}catch{}})();(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="12066389-daef-5fce-b7a6-0ecffa926d66")}catch{}})();function Qt(e,t){let n=e.trim().split(/\s+/u);if(!(n.length<2||t.includes(n.join(" "))))for(let o=1;o<n.length;o+=1){if(!t.includes(n.slice(0,o).join(" ")))return;let s=n.slice(o).join(" "),r=I(s),a=new Set(t.filter(i=>i===s||i.endsWith(` ${s}`)||i===r?.canonical).map(i=>I(i)?.canonical??i).filter(i=>t.includes(i)));if(a.size>0)return a.size===1?[...a][0]:void 0}}var Qe={add:["create","append"],fetch:["get"],inspect:["get","health"],log:["history","comments","notes"],ls:["list"],pause:["release"],read:["get"],remove:["delete"],rm:["delete"],show:["get"],start:["start-task"]};function ie(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let s=n.split(" "),r=Qe[o]?.indexOf(p(n));if(r!==void 0&&r>=0)return r;if(n===o)return 10;if(s.includes(o))return 11;if(s.some(l=>l.startsWith(o)))return 12;let a=o.length>=5?2:1,i=Number.POSITIVE_INFINITY;for(let l of s){let c=v(l,o,a);c!==null&&(i=Math.min(i,c))}return Number.isFinite(i)?20+i:n.includes(o)?30:Number.POSITIVE_INFINITY}function en(e,t){return e.map(n=>({path:n,score:ie(n,t)})).filter(n=>Number.isFinite(n.score)).sort((n,o)=>n.score!==o.score?n.score-o.score:n.path===o.path?0:n.path<o.path?-1:1).map(n=>n.path)}function tn(e,t,n){let o=new Set(t),s=E.filter(i=>i.lifecycle==="deprecated").slice().sort((i,l)=>l.alias.length-i.alias.length),r=[],a=e.flatMap(i=>{let l=s.find(u=>i===u.alias||i.startsWith(`${u.alias} `)),c=i;if(l){let u=i.slice(l.alias.length);if(!o.has(`${l.canonical}${u}`))return[];c=`${l.canonical_argv.join(" ")}${u}`}return n!==void 0&&ie(i,n)<10&&r.push(c),[c]});return[...new Set(r.length>0?r:a)]}export{nt as a,K as b,Y as c,ye as d,Z as e,_e as f,T as g,we as h,bt as i,Ce as j,yt as k,Re as l,Be as m,_t as n,wt as o,St as p,f as q,Ue as r,je as s,Lt as t,zt as u,Ye as v,Gt as w,Wt as x,oe as y,Ut as z,jt as A,He as B,qt as C,Qt as D,ie as E,en as F,tn as G};
2
+ //# sourceMappingURL=chunk-GQCMICAL.js.map
@@ -1,2 +1,2 @@
1
- import{a as f,b as I,f as T,i as _,j as M,l as y}from"./chunk-XPBADEUK.js";import{v as g}from"./chunk-CR5GC3VO.js";import{Ec as l,Fc as p}from"./chunk-7UUPLMCU.js";import{A as c,C as u}from"./chunk-5OFMWP3Q.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]="4175f7f5-a689-5d05-982a-f92e21bc83e7")}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]="3041c268-69c8-58e5-8a68-eaaa3c0dbd3b")}catch{}})();async function ce(e){let{plan:t}=e,r=await y({pmRoot:e.pmRoot,author:e.author,transactionId:t.transaction_id,mutations:t.mutations}),o=new Map(r.warnings.map(i=>[i.index,i.warnings])),s=t.rows.map(i=>{let n={...i};delete n.warnings;let a=o.get(i.index);return a!==void 0&&(n.warnings=a),n});return{validation:r,rows:s}}async function ue(e){let t=e.upsertKey?.trim();if(t!==void 0&&t.length===0)throw new u("Upsert key must be a non-empty field name.",c.USAGE);let r=e.settings??await g(e.pmRoot),o=e.transactionId?.trim()??"",s=o.length>0?o:I(e.input),i=await _(e.pmRoot,r),n=l(i.schema).definitions,a=(n.find(m=>m.metadata_key===t)??n.find(m=>m.key===t||p(m)===t))?.metadata_key??f(t),d=a===void 0?void 0:{key:a,existing:await M(e.pmRoot,r,i,a)};return{...T(e.input,{transactionId:s,idPrefix:r.id_prefix,runtimeFields:n,...d===void 0?{}:{upsert:d}}),transaction_id:s,transaction_id_source:o.length>0?"explicit":"derived",...d===void 0?{}:{upsert_key:d.key}}}export{ce as a,ue as b};
2
- //# sourceMappingURL=chunk-ABFHWRLE.js.map
1
+ import{a as f,b as I,f as T,i as _,j as M,l as y}from"./chunk-CTOE26W4.js";import{v as g}from"./chunk-CR5GC3VO.js";import{Ec as l,Fc as p}from"./chunk-7UUPLMCU.js";import{A as c,C as u}from"./chunk-5OFMWP3Q.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]="4175f7f5-a689-5d05-982a-f92e21bc83e7")}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]="3041c268-69c8-58e5-8a68-eaaa3c0dbd3b")}catch{}})();async function ce(e){let{plan:t}=e,r=await y({pmRoot:e.pmRoot,author:e.author,transactionId:t.transaction_id,mutations:t.mutations}),o=new Map(r.warnings.map(i=>[i.index,i.warnings])),s=t.rows.map(i=>{let n={...i};delete n.warnings;let a=o.get(i.index);return a!==void 0&&(n.warnings=a),n});return{validation:r,rows:s}}async function ue(e){let t=e.upsertKey?.trim();if(t!==void 0&&t.length===0)throw new u("Upsert key must be a non-empty field name.",c.USAGE);let r=e.settings??await g(e.pmRoot),o=e.transactionId?.trim()??"",s=o.length>0?o:I(e.input),i=await _(e.pmRoot,r),n=l(i.schema).definitions,a=(n.find(m=>m.metadata_key===t)??n.find(m=>m.key===t||p(m)===t))?.metadata_key??f(t),d=a===void 0?void 0:{key:a,existing:await M(e.pmRoot,r,i,a)};return{...T(e.input,{transactionId:s,idPrefix:r.id_prefix,runtimeFields:n,...d===void 0?{}:{upsert:d}}),transaction_id:s,transaction_id_source:o.length>0?"explicit":"derived",...d===void 0?{}:{upsert_key:d.key}}}export{ce as a,ue as b};
2
+ //# sourceMappingURL=chunk-IQKCRLQP.js.map