@unbrained/pm-cli 2026.8.26 → 2026.8.27

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 (161) hide show
  1. package/.agents/skills/HARNESS_COMPATIBILITY.md +32 -0
  2. package/.agents/skills/README.md +47 -0
  3. package/.agents/skills/pm-developer/SKILL.md +117 -0
  4. package/.agents/skills/pm-developer/references/COMMAND_PLAYBOOK.md +49 -0
  5. package/.agents/skills/pm-developer/references/GRAPH_AND_RELATIONSHIPS.md +91 -0
  6. package/.agents/skills/pm-developer/references/MULTI_AGENT_MERGE.md +72 -0
  7. package/.agents/skills/pm-developer/references/PROMPTS.md +17 -0
  8. package/.agents/skills/pm-developer/references/SCRIPTING_COMPOSITION.md +82 -0
  9. package/.agents/skills/pm-developer/references/TOKEN_BUDGETS.md +85 -0
  10. package/.agents/skills/pm-extensions/SKILL.md +106 -0
  11. package/.agents/skills/pm-extensions/references/AUTHORING.md +95 -0
  12. package/.agents/skills/pm-extensions/references/LIFECYCLE.md +40 -0
  13. package/.agents/skills/pm-extensions/references/TROUBLESHOOTING.md +25 -0
  14. package/.agents/skills/pm-sdk/SKILL.md +107 -0
  15. package/.agents/skills/pm-sdk/references/DOMAIN_MODELING.md +78 -0
  16. package/.agents/skills/pm-sdk/references/INTEGRATION_CHECKLIST.md +31 -0
  17. package/.agents/skills/pm-sdk/references/PROMPTS.md +13 -0
  18. package/.agents/skills/pm-sdk/references/SURFACE_MAP.md +82 -0
  19. package/.agents/skills/pm-user/SKILL.md +111 -0
  20. package/.agents/skills/pm-user/references/BACKLOG_SHAPING.md +105 -0
  21. package/.agents/skills/pm-user/references/PROMPTS.md +17 -0
  22. package/.agents/skills/pm-user/references/WORKFLOWS.md +35 -0
  23. package/.claude-plugin/marketplace.json +2 -2
  24. package/CHANGELOG.md +25 -3
  25. package/README.md +8 -5
  26. package/dist/cli/commander-usage.js +11 -7
  27. package/dist/cli/error-guidance.js +3 -3
  28. package/dist/cli/help-content.d.ts +2 -0
  29. package/dist/cli/help-content.js +53 -17
  30. package/dist/cli/help-json-payload.d.ts +8 -2
  31. package/dist/cli/help-json-payload.js +46 -12
  32. package/dist/cli/main.js +52 -74
  33. package/dist/cli/register-annotations.js +27 -21
  34. package/dist/cli/register-setup.js +98 -57
  35. package/dist/cli-bundle/bundle-manifest.json +152 -152
  36. package/dist/cli-bundle/chunks/chunk-3OO3W6FW.js +202 -0
  37. package/dist/cli-bundle/chunks/chunk-52EKTW6V.js +3 -0
  38. package/dist/cli-bundle/chunks/{chunk-KBFP3E4E.js → chunk-CVBBGWW5.js} +62 -44
  39. package/dist/cli-bundle/chunks/chunk-MFNTKMTI.js +13 -0
  40. package/dist/cli-bundle/chunks/{chunk-E2GCFJSU.js → chunk-OS27HHBN.js} +31 -31
  41. package/dist/cli-bundle/chunks/chunk-QTO7USTH.js +2 -0
  42. package/dist/cli-bundle/chunks/{chunk-S4U76VZF.js → chunk-R4ETAOJC.js} +2 -2
  43. package/dist/cli-bundle/chunks/{chunk-UKBCRPA2.js → chunk-SH6P7FXI.js} +2 -2
  44. package/dist/cli-bundle/chunks/{chunk-WRHJ3MB6.js → chunk-SHMDY36D.js} +2 -2
  45. package/dist/cli-bundle/chunks/{chunk-ZNRLJ54C.js → chunk-SKXLJIEK.js} +2 -2
  46. package/dist/cli-bundle/chunks/chunk-TNX6HC54.js +3 -0
  47. package/dist/cli-bundle/chunks/{register-list-query-EMCPMICY.js → register-list-query-EUWM6VII.js} +2 -2
  48. package/dist/cli-bundle/chunks/{register-mutation-OJ67ABCB.js → register-mutation-FD4HSAVU.js} +4 -4
  49. package/dist/cli-bundle/chunks/{register-operations-H2GLP7LT.js → register-operations-HRMNFEC3.js} +2 -2
  50. package/dist/cli-bundle/chunks/register-setup-33GNICLX.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/{chunk-4XNH2HM7.js → chunk-2AGZ5BRT.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-72T6JGAE.js → chunk-4BR5UU52.js} +45 -45
  53. package/dist/cli-bundle/focused-chunks/{chunk-OHIHZ7HS.js → chunk-6GCRSLPG.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-UYBA57GY.js → chunk-AD6ULRAF.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-7YCDTCBC.js → chunk-AQ5IYEZZ.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-YO3ZF3FI.js → chunk-EKX37ZHA.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{chunk-LV5N3LK5.js → chunk-FC2AXLB5.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{chunk-IBHXMFE7.js → chunk-HC7ODMH3.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{chunk-4K2II4TV.js → chunk-HVQ22RC4.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-A644DUFQ.js → chunk-MEASX544.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-FXDLT6FL.js → chunk-MXTYGECH.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-MMXUPDDJ.js → chunk-SUBSWYW3.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-57XY346D.js → chunk-XDPYBQCF.js} +9 -9
  64. package/dist/cli-bundle/focused-chunks/{chunk-TMJDFHVD.js → chunk-Y3JJXRVK.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-66VGB23P.js → chunk-Y5A7SJJ7.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/chunk-YHWHX6YY.js +2 -0
  67. package/dist/cli-bundle/focused-chunks/{chunk-P2E6LDAE.js → chunk-YVVZ3LQ6.js} +3 -3
  68. package/dist/cli-bundle/focused-chunks/chunk-Z2USIBR2.js +5 -0
  69. package/dist/cli-bundle/main.js +15 -14
  70. package/dist/cli-bundle/sdk-authoring.js +1 -1
  71. package/dist/cli-bundle/sdk-contracts.js +2 -2
  72. package/dist/cli-bundle/sdk-core.js +31 -31
  73. package/dist/cli-bundle/sdk-governance.js +1 -1
  74. package/dist/cli-bundle/sdk-graph.js +1 -1
  75. package/dist/cli-bundle/sdk-merge.js +31 -31
  76. package/dist/cli-bundle/sdk-query.js +1 -1
  77. package/dist/cli-bundle/sdk-runtime.js +1 -1
  78. package/dist/cli-bundle/sdk-testing.js +1 -1
  79. package/dist/cli-bundle/sdk.js +32 -7
  80. package/dist/core/governance/issue-codes.d.ts +11 -2
  81. package/dist/core/governance/issue-codes.js +29 -10
  82. package/dist/core/item/item-format.js +3 -3
  83. package/dist/core/store/item-store.js +12 -5
  84. package/dist/mcp/server.js +123 -9
  85. package/dist/mcp/tool-definitions.d.ts +2 -0
  86. package/dist/mcp/tool-definitions.js +2 -2
  87. package/dist/sdk/agent/closed-domain-contracts.d.ts +1 -1
  88. package/dist/sdk/agent/closed-domain-contracts.js +24 -2
  89. package/dist/sdk/agent-capability-contracts.js +6 -2
  90. package/dist/sdk/cli-bootstrap.js +3 -2
  91. package/dist/sdk/cli-contracts/command-aliases.js +15 -2
  92. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -1
  93. package/dist/sdk/cli-contracts/enum-contracts.js +7 -2
  94. package/dist/sdk/cli-contracts/flag-contracts.js +9 -5
  95. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +3 -3
  96. package/dist/sdk/cli-contracts/grammar-contracts.js +24 -17
  97. package/dist/sdk/cli-contracts/runtime-contracts.js +13 -11
  98. package/dist/sdk/cli-contracts/tool-schema.js +18 -15
  99. package/dist/sdk/cli-contracts.d.ts +1 -1
  100. package/dist/sdk/cli-contracts.js +3 -3
  101. package/dist/sdk/cli-program.js +3 -2
  102. package/dist/sdk/completion.js +40 -13
  103. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +14 -2
  104. package/dist/sdk/governance/upgrade.d.ts +2 -0
  105. package/dist/sdk/governance/upgrade.js +30 -8
  106. package/dist/sdk/governance/validate.js +8 -6
  107. package/dist/sdk/guide-topics.js +6 -6
  108. package/dist/sdk/index.d.ts +4 -2
  109. package/dist/sdk/index.js +5 -3
  110. package/dist/sdk/mcp/apps.d.ts +70 -0
  111. package/dist/sdk/mcp/apps.js +154 -0
  112. package/dist/sdk/mcp/skills.d.ts +127 -0
  113. package/dist/sdk/mcp/skills.js +390 -0
  114. package/dist/sdk/read-output-contracts.js +16 -3
  115. package/dist/sdk/runtime-action-aliases.js +7 -3
  116. package/dist/sdk/runtime-input.js +12 -4
  117. package/dist/sdk/runtime-primitives.d.ts +1 -1
  118. package/dist/sdk/runtime-primitives.js +3 -3
  119. package/docs/CLI_GRAMMAR.md +7 -1
  120. package/docs/COMMANDS.md +2 -2
  121. package/docs/EXTENSIONS.md +33 -32
  122. package/docs/MCP_2026_07_28.md +24 -2
  123. package/docs/MCP_2026_07_28_CONFORMANCE.md +4 -4
  124. package/docs/MCP_SKILLS_AND_APPS.md +107 -0
  125. package/docs/QUICKSTART.md +15 -15
  126. package/docs/README.md +1 -0
  127. package/docs/RELEASING.md +11 -3
  128. package/docs/SDK_CONTEXT_INTEGRITY.md +6 -0
  129. package/docs/SDK_EVIDENCE_TRACEABILITY.md +9 -1
  130. package/docs/generated/AGENT_CAPABILITY_ROUTING.md +1 -1
  131. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +7 -6
  132. package/marketplace.json +2 -2
  133. package/package.json +9 -7
  134. package/packages/pm-beads/README.md +12 -6
  135. package/packages/pm-beads/docs/MIGRATION.md +53 -0
  136. package/packages/pm-beads/extensions/beads/index.ts +8 -0
  137. package/packages/pm-beads/extensions/beads/runtime.ts +671 -112
  138. package/packages/pm-beads/package.json +1 -1
  139. package/packages/pm-calendar/package.json +1 -1
  140. package/packages/pm-command-kit/package.json +1 -1
  141. package/packages/pm-digital-twin/package.json +1 -1
  142. package/packages/pm-governance-audit/package.json +1 -1
  143. package/packages/pm-guide-shell/package.json +1 -1
  144. package/packages/pm-kanban/package.json +1 -1
  145. package/packages/pm-lifecycle-hooks/package.json +1 -1
  146. package/packages/pm-linked-test-adapters/package.json +1 -1
  147. package/packages/pm-search-advanced/package.json +1 -1
  148. package/packages/pm-templates/package.json +1 -1
  149. package/packages/pm-todos/package.json +1 -1
  150. package/packages/pm-vcs/package.json +1 -1
  151. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  152. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  153. package/sdk/public-surface.json +235 -13
  154. package/dist/cli-bundle/chunks/chunk-ES25LX3D.js +0 -202
  155. package/dist/cli-bundle/chunks/chunk-FRDWWB6R.js +0 -3
  156. package/dist/cli-bundle/chunks/chunk-ICQ3RVIY.js +0 -2
  157. package/dist/cli-bundle/chunks/chunk-IV64RJVE.js +0 -13
  158. package/dist/cli-bundle/chunks/chunk-MVYLQ67M.js +0 -3
  159. package/dist/cli-bundle/chunks/register-setup-GLZAHLVI.js +0 -2
  160. package/dist/cli-bundle/focused-chunks/chunk-7I23XGWO.js +0 -2
  161. package/dist/cli-bundle/focused-chunks/chunk-LMKG3DFE.js +0 -5
@@ -1,6 +1,6 @@
1
- import{c as x}from"./chunk-4K2II4TV.js";import{La as a,Na as w,r as m,y as T}from"./chunk-UYBA57GY.js";import{L as v,Y as f,Z as u,o as _,p as b,q as E}from"./chunk-LMKG3DFE.js";import C from"node:fs/promises";import p from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6fc24a7c-a359-51fd-a432-4c8037d10e9e")}catch{}})();var z=["extensions","docs","examples","assets","prompts"],R=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function q(e){return z.includes(e)}function G(e,t){if(t==null)return[];let r=Array.isArray(t)?t:[t],n=[];for(let i of r){if(typeof i!="string"||i.trim().length===0)throw new u(`Package manifest field pm.${e} must contain string paths.`,f.USAGE);n.push(i.trim())}return[...new Set(n)].sort((i,o)=>i.localeCompare(o))}function J(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new u("Package manifest field pm must be an object.",f.USAGE);let t={},r=e;for(let[n,i]of Object.entries(r)){if(!q(n))continue;let o=G(n,i);o.length>0&&(t[n]=o)}return t}function c(e,t){let r=e[t];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}function S(e){if(!Array.isArray(e))return;let t=e.map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0);return t.length>0?[...new Set(t)].sort((r,n)=>r.localeCompare(n)):void 0}function I(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function K(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={docs:c(t,"docs"),npm:c(t,"npm"),repository:c(t,"repository"),report:c(t,"report")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={image:c(t,"image"),video:c(t,"video")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function Y(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={display_name:c(t,"display_name")??c(t,"displayName"),category:c(t,"category"),summary:c(t,"summary"),links:K(t.links),media:V(t.media),tags:S(t.tags)};return Object.values(r).some(n=>n!==void 0)?r:void 0}async function B(e){let t=p.join(e,"package.json");if(!await m(t))return{source:"convention",resources:{}};let r;try{r=JSON.parse(await C.readFile(t,"utf8"))}catch(d){throw new u(`Failed to parse package manifest at "${t}": ${String(d)}`,f.USAGE)}if(typeof r!="object"||r===null||Array.isArray(r))throw new u(`Package manifest at "${t}" must be a JSON object.`,f.USAGE);let n=r,i=n.pm,o=i!=null,s=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:{};return{source:o?"pm":"convention",package_json_path:t,package_name:typeof n.name=="string"?n.name:void 0,package_version:typeof n.version=="string"?n.version:void 0,package_private:n.private===!0,package_description:typeof n.description=="string"?n.description:void 0,package_keywords:S(n.keywords),package_homepage:typeof n.homepage=="string"?n.homepage:void 0,package_repository_url:I(n.repository),package_bugs_url:I(n.bugs),aliases:S(s.aliases),resources:J(i),catalog:Y(s.catalog)}}async function j(e){if(!await m(e))return[];let t=await C.readdir(e,{withFileTypes:!0}),r=[];for(let n of t){if(!n.isDirectory())continue;let i=p.join(e,n.name);await m(p.join(i,"manifest.json"))&&r.push(i)}return r.sort((n,i)=>n.localeCompare(i))}async function _e(e){if(await m(p.join(e,"manifest.json")))return[e];let r=(await B(e)).resources.extensions??[],n=new Set;for(let i of r){if(i.includes("*")||i.startsWith("!"))throw new u(`Package extension entry "${i}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,f.USAGE);let o=p.resolve(e,i);if(!T(e,o))throw new u(`Package extension entry "${i}" resolves outside package root.`,f.USAGE);if(await m(p.join(o,"manifest.json"))){n.add(o);continue}for(let s of await j(o))n.add(s)}if(r.length===0)for(let i of R.extensions)for(let o of await j(p.join(e,i)))n.add(o);return[...n].sort((i,o)=>i.localeCompare(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]="48c3e62a-8085-5215-a692-4c03792022ce")}catch{}})();var D=1,A=6,$=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["assurance_providers","Assurance measurement providers"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function k(e){return"#".repeat(e)}function F(e){if(!e.includes("`"))return`\`${e}\``;let t=0,r=0;for(let o of e)r=o==="`"?r+1:0,t=Math.max(t,r);let n="`".repeat(t+1),i=e.startsWith("`")||e.endsWith("`")?" ":"";return`${n}${i}${e}${i}${n}`}function W(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(F).join(", ")}`}function H(e,t,r){let n=[`${k(t)} ${e}`,""];return r.length===0?(n.push("_None._",""),n):(n.push(...r.map(i=>`- ${F(i)}`),""),n)}function X(e,t,r){return e===0&&!r?[]:[`${k(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function Ee(e,t={}){let r=t.headingLevel??2;if(!Number.isInteger(r)||r<D||r>A)throw new RangeError(`headingLevel must be an integer in [${D}, ${A}], received ${String(t.headingLevel)}`);let n=Math.min(r+1,A),i=t.includeEmpty===!0,o=t.title??"Extension surfaces",s=[`${k(r)} ${o}`,""];(i||e.capabilities.length>0)&&s.push(W(e.capabilities),"");for(let[l,y]of $){let g=e[l]??[];g.length===0&&!i||s.push(...H(y,n,g))}return s.push(...X(e.preflight_overrides,n,i)),!(e.preflight_overrides>0||$.some(([l])=>(e[l]?.length??0)>0))&&!i&&s.push("_This extension registers no surfaces._",""),`${s.join(`
1
+ import{c as x}from"./chunk-HVQ22RC4.js";import{La as a,Na as w,r as m,y as T}from"./chunk-AD6ULRAF.js";import{L as v,Y as f,Z as u,o as _,p as b,q as E}from"./chunk-Z2USIBR2.js";import C from"node:fs/promises";import p from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="6fc24a7c-a359-51fd-a432-4c8037d10e9e")}catch{}})();var z=["extensions","docs","examples","assets","prompts"],R=Object.freeze({extensions:Object.freeze([".agents/pm/extensions","extensions",".custom/pm-extensions",".custom/pm-extension"]),docs:Object.freeze(["docs","documentation"]),examples:Object.freeze(["examples","docs/examples"]),assets:Object.freeze(["assets",".agents/pm/assets"]),prompts:Object.freeze(["prompts",".agents/pm/prompts"])});function q(e){return z.includes(e)}function G(e,t){if(t==null)return[];let r=Array.isArray(t)?t:[t],n=[];for(let i of r){if(typeof i!="string"||i.trim().length===0)throw new u(`Package manifest field pm.${e} must contain string paths.`,f.USAGE);n.push(i.trim())}return[...new Set(n)].sort((i,o)=>i.localeCompare(o))}function J(e){if(e==null)return{};if(typeof e!="object"||Array.isArray(e))throw new u("Package manifest field pm must be an object.",f.USAGE);let t={},r=e;for(let[n,i]of Object.entries(r)){if(!q(n))continue;let o=G(n,i);o.length>0&&(t[n]=o)}return t}function c(e,t){let r=e[t];return typeof r=="string"&&r.trim().length>0?r.trim():void 0}function S(e){if(!Array.isArray(e))return;let t=e.map(r=>typeof r=="string"?r.trim():"").filter(r=>r.length>0);return t.length>0?[...new Set(t)].sort((r,n)=>r.localeCompare(n)):void 0}function I(e){if(typeof e=="string"&&e.trim().length>0)return e.trim();if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let t=e.url;return typeof t=="string"&&t.trim().length>0?t.trim():void 0}}function K(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={docs:c(t,"docs"),npm:c(t,"npm"),repository:c(t,"repository"),report:c(t,"report")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function V(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={image:c(t,"image"),video:c(t,"video")};return Object.values(r).some(n=>typeof n=="string")?r:void 0}function Y(e){if(typeof e!="object"||e===null||Array.isArray(e))return;let t=e,r={display_name:c(t,"display_name")??c(t,"displayName"),category:c(t,"category"),summary:c(t,"summary"),links:K(t.links),media:V(t.media),tags:S(t.tags)};return Object.values(r).some(n=>n!==void 0)?r:void 0}async function B(e){let t=p.join(e,"package.json");if(!await m(t))return{source:"convention",resources:{}};let r;try{r=JSON.parse(await C.readFile(t,"utf8"))}catch(d){throw new u(`Failed to parse package manifest at "${t}": ${String(d)}`,f.USAGE)}if(typeof r!="object"||r===null||Array.isArray(r))throw new u(`Package manifest at "${t}" must be a JSON object.`,f.USAGE);let n=r,i=n.pm,o=i!=null,s=typeof i=="object"&&i!==null&&!Array.isArray(i)?i:{};return{source:o?"pm":"convention",package_json_path:t,package_name:typeof n.name=="string"?n.name:void 0,package_version:typeof n.version=="string"?n.version:void 0,package_private:n.private===!0,package_description:typeof n.description=="string"?n.description:void 0,package_keywords:S(n.keywords),package_homepage:typeof n.homepage=="string"?n.homepage:void 0,package_repository_url:I(n.repository),package_bugs_url:I(n.bugs),aliases:S(s.aliases),resources:J(i),catalog:Y(s.catalog)}}async function j(e){if(!await m(e))return[];let t=await C.readdir(e,{withFileTypes:!0}),r=[];for(let n of t){if(!n.isDirectory())continue;let i=p.join(e,n.name);await m(p.join(i,"manifest.json"))&&r.push(i)}return r.sort((n,i)=>n.localeCompare(i))}async function _e(e){if(await m(p.join(e,"manifest.json")))return[e];let r=(await B(e)).resources.extensions??[],n=new Set;for(let i of r){if(i.includes("*")||i.startsWith("!"))throw new u(`Package extension entry "${i}" uses a glob/exclusion pattern. pm package installs currently require concrete extension paths or directories.`,f.USAGE);let o=p.resolve(e,i);if(!T(e,o))throw new u(`Package extension entry "${i}" resolves outside package root.`,f.USAGE);if(await m(p.join(o,"manifest.json"))){n.add(o);continue}for(let s of await j(o))n.add(s)}if(r.length===0)for(let i of R.extensions)for(let o of await j(p.join(e,i)))n.add(o);return[...n].sort((i,o)=>i.localeCompare(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]="48c3e62a-8085-5215-a692-4c03792022ce")}catch{}})();var D=1,A=6,$=[["commands","Commands"],["command_overrides","Command overrides"],["flag_commands","Flag commands"],["item_types","Item types"],["item_fields","Item fields"],["migrations","Migrations"],["profiles","Profiles"],["importers","Importers"],["exporters","Exporters"],["search_providers","Search providers"],["vector_store_adapters","Vector store adapters"],["assurance_providers","Assurance measurement providers"],["hooks","Lifecycle hooks"],["parser_overrides","Parser overrides"],["service_overrides","Service overrides"],["renderer_overrides","Renderer overrides"]];function k(e){return"#".repeat(e)}function F(e){if(!e.includes("`"))return`\`${e}\``;let t=0,r=0;for(let o of e)r=o==="`"?r+1:0,t=Math.max(t,r);let n="`".repeat(t+1),i=e.startsWith("`")||e.endsWith("`")?" ":"";return`${n}${i}${e}${i}${n}`}function W(e){return e.length===0?"Capabilities: _none registered_":`Capabilities: ${e.map(F).join(", ")}`}function H(e,t,r){let n=[`${k(t)} ${e}`,""];return r.length===0?(n.push("_None._",""),n):(n.push(...r.map(i=>`- ${F(i)}`),""),n)}function X(e,t,r){return e===0&&!r?[]:[`${k(t)} Preflight overrides`,"",e>0?`- ${e} registered (this surface carries no per-entry identifier)`:"_None._",""]}function Ee(e,t={}){let r=t.headingLevel??2;if(!Number.isInteger(r)||r<D||r>A)throw new RangeError(`headingLevel must be an integer in [${D}, ${A}], received ${String(t.headingLevel)}`);let n=Math.min(r+1,A),i=t.includeEmpty===!0,o=t.title??"Extension surfaces",s=[`${k(r)} ${o}`,""];(i||e.capabilities.length>0)&&s.push(W(e.capabilities),"");for(let[l,y]of $){let g=e[l]??[];g.length===0&&!i||s.push(...H(y,n,g))}return s.push(...X(e.preflight_overrides,n,i)),!(e.preflight_overrides>0||$.some(([l])=>(e[l]?.length??0)>0))&&!i&&s.push("_This extension registers no surfaces._",""),`${s.join(`
2
2
  `).trimEnd()}
3
3
  `}(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]="e3f016bb-8add-5765-bb1a-a7b22423f8d1")}catch{}})();var Q=["agile","ops","research"],Z={agile:[{name:"Story",description:"User-facing outcome or capability slice expressed from a stakeholder perspective.",defaultStatus:"open",folder:"stories",aliases:["user-story"]},{name:"Spike",description:"Time-boxed investigation used to reduce uncertainty before implementation.",defaultStatus:"open",folder:"spikes",aliases:["research-spike"]}],ops:[{name:"Incident",description:"Operational disruption, degradation, or support escalation with recovery tracking.",defaultStatus:"open",folder:"incidents",aliases:["outage"]},{name:"Runbook",description:"Repeatable operational procedure, diagnostic path, or response playbook.",defaultStatus:"open",folder:"runbooks",aliases:["playbook"]}],research:[{name:"Experiment",description:"Validated-learning activity with hypothesis, method, and outcome tracking.",defaultStatus:"open",folder:"experiments",aliases:["study"]},{name:"Hypothesis",description:"Testable claim or assumption that should be supported, rejected, or refined.",defaultStatus:"open",folder:"hypotheses",aliases:["assumption"]}]};function ke(e){if(e===void 0)return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length===0)throw new Error("Type preset name must not be empty.");if(t==="agile"||t==="ops"||t==="research")return t;throw new Error(`Invalid type preset "${e}". Allowed: ${Q.join(", ")}.`)}function ve(e){return Z[e].map(t=>x(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]="2b5a573e-1e36-58b9-b93b-4a4088f71e9a")}catch{}})();var ee=new Set(b),te=new Set(E),N=new Set([...v.filter(e=>e!=="severity"),"id","title","type","status","priority","tags","assignee","parent","description","body","created_at","updated_at","closed_at","completed_at","author","deadline","estimate","sprint","release","risk","confidence","reviewer","resolution","expected","actual"]),ne=["create","update"];function P(e){if(typeof e!="string")return"";let t=e.trim().toLowerCase().replaceAll(/[\s_]+/g,"-");return t.startsWith("--")?t.slice(2):t}function O(e){return e.replaceAll("_","-")}function re(e,t){let r=new Set;for(let n of e){let i=P(n);i.length>0&&i!==t&&r.add(i)}return[...r].sort((n,i)=>n.localeCompare(i))}function ie(e){let t=new Set;for(let r of e??[]){let n=r.trim();n.length>0&&t.add(n)}return[...t].sort((r,n)=>r.localeCompare(n))}function oe(e){let t=new Set,r=[];for(let n of e??[]){let i=n.trim().toLowerCase();if(i.length!==0){if(!te.has(i))throw new Error(`Invalid field command "${n}". Allowed: ${E.join(", ")}.`);t.has(i)||(t.add(i),r.push(i))}}return e===void 0||r.length===0?[...ne]:r}function je(e){let t=a(e.key);if(t.length===0)throw new Error("Field key must not be empty.");if(N.has(t))throw new Error(`Cannot define custom field "${t}": custom schema field "${t}" collides with built-in item metadata "${t}". Rename the custom field with a project-specific prefix. Reserved fields: ${[...N].sort((g,U)=>g.localeCompare(U)).join(", ")}.`);let r=typeof e.type=="string"&&e.type.trim().length>0?e.type.trim().toLowerCase():"string";if(!ee.has(r))throw new Error(`Invalid field type "${e.type}". Allowed: ${b.join(", ")}.`);let n=r,i=oe(e.commands),o=P(e.cliFlag),s=o.length>0&&o!==O(t)?o:void 0,d=s??O(t),l=re(e.aliases??[],d),y=e.description?.trim();return{key:t,type:n,commands:i,description:y&&y.length>0?y:void 0,cliFlag:s,cliAliases:l,required:e.required===!0,requiredOnCreate:e.requiredOnCreate===!0,allowUnset:e.allowUnset!==!1,requiredTypes:ie(e.requiredTypes)}}function se(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.fields))return t.fields;if(Array.isArray(t.definitions))return t.definitions}function ae(e){let t=se(e);if(!t)return[];let r=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.key!="string"||i.key.trim().length===0||r.push(i)}return r}function Ce(e){if(e==null||e.trim().length===0)return{fields:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/fields.json contains invalid JSON.")}return{fields:ae(t)}}function De(e){return`${JSON.stringify({fields:e.fields},null,2)}
4
4
  `}function $e(e,t){let r=e.fields.find(s=>a(s.key)===t.key),n=r!==void 0,i=e.fields.filter(s=>a(s.key)!==t.key),o={...r,key:t.key,type:t.type,commands:[...t.commands]};return L(o,"description",t.description),L(o,"cli_flag",t.cliFlag),t.cliAliases.length>0?o.cli_aliases=[...t.cliAliases]:delete o.cli_aliases,M(o,"required",t.required),M(o,"required_on_create",t.requiredOnCreate),t.allowUnset===!1?o.allow_unset=!1:delete o.allow_unset,t.requiredTypes.length>0?o.required_types=[...t.requiredTypes]:delete o.required_types,i.push(o),i.sort((s,d)=>a(s.key).localeCompare(a(d.key))),{file:{fields:i},definition:o,replaced:n}}function Fe(e,t){let r=a(t);if(r.length===0)throw new Error("Field key must not be empty.");let n=[],i=e.fields.filter(o=>a(o.key)===r?(n.push(o),!1):!0);return n.length===0?{file:{fields:i},removed:!1}:{file:{fields:i},removed:!0,definition:n[0]}}function L(e,t,r){let n=e;r!==void 0&&r.length>0?n[t]=r:delete n[t]}function M(e,t,r){let n=e;r?n[t]=!0:delete n[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]="3eac0218-43c9-5bd2-8eaf-589d02d2c8ad")}catch{}})();var de=new Set(_),h=new Set(w.map(e=>a(e.id)).filter(e=>e.length>0));function le(e){let t=new Set;for(let r of e){let n=a(r);n.length>0&&t.add(n)}return[...t].sort((r,n)=>r.localeCompare(n))}function Ue(e){let t=a(e.id);if(t.length===0)throw new Error("Status id must not be empty.");if(h.has(t))throw new Error(`Cannot add-status the built-in status "${t}". Built-in statuses are reserved: ${[...h].join(", ")}.`);let r;if(e.roles!==void 0){r=[];let s=new Set;for(let d of e.roles){let l=typeof d=="string"?d.trim().toLowerCase():"";if(l.length!==0){if(!de.has(l))throw new Error(`Invalid status role "${d}". Allowed roles: ${_.join(", ")}.`);s.has(l)||(s.add(l),r.push(l))}}}let n=e.aliases===void 0?void 0:le(e.aliases).filter(s=>s!==t),i=e.description?.trim(),o=typeof e.order=="number"&&Number.isFinite(e.order)?Math.trunc(e.order):void 0;return{id:t,roles:r,aliases:n,description:i&&i.length>0?i:void 0,order:o}}function ce(e){if(Array.isArray(e))return e;if(typeof e!="object"||e===null)return;let t=e;if(Array.isArray(t.statuses))return t.statuses;if(Array.isArray(t.definitions))return t.definitions}function fe(e){let t=ce(e);if(!t)return[];let r=[];for(let n of t){if(typeof n!="object"||n===null||Array.isArray(n))continue;let i=n;typeof i.id!="string"||i.id.trim().length===0||r.push(i)}return r}function ze(e){if(e==null||e.trim().length===0)return{statuses:[]};let t;try{t=JSON.parse(e)}catch{throw new Error("schema/statuses.json contains invalid JSON.")}return{statuses:fe(t)}}function Re(e){return`${JSON.stringify({statuses:e.statuses},null,2)}
5
5
  `}function qe(e,t,r){let n=e.statuses.slice(),i=n.findIndex(d=>a(d.id)===t.id),o=i>=0?n[i]:r,s={...o,id:t.id};return t.roles!==void 0&&(t.roles.length>0?s.roles=[...t.roles]:s.roles!==void 0&&delete s.roles),t.aliases!==void 0&&(t.aliases.length>0?s.aliases=[...t.aliases]:s.aliases!==void 0&&delete s.aliases),t.description!==void 0&&(s.description=t.description),t.order!==void 0&&(s.order=t.order),i>=0?n[i]=s:n.push(s),{file:{statuses:n},definition:s,replaced:o!==void 0}}function Ge(e,t){let r=a(t);if(r.length===0)throw new Error("Status id must not be empty.");if(h.has(r))throw new Error(`Cannot remove built-in status "${r}". Built-in statuses are reserved: ${[...h].join(", ")}.`);let n=e.statuses.slice(),i=n.findIndex(s=>a(s.id)===r);if(i<0)return{file:{statuses:n},removed:!1};let[o]=n.splice(i,1);return{file:{statuses:n},removed:!0,definition:o}}function Je(e,t){let r=[e.id,...e.aliases??[]];for(let n of r){let i=a(n);if(i.length===0)continue;let o=t.get(i);if(o!==void 0&&o!==e.id)throw new Error(`Status token "${i}" already belongs to status "${o}". Choose a different id/alias to avoid shadowing it.`)}}export{z as a,R as b,B as c,_e as d,Q as e,Z as f,ke as g,ve as h,je as i,Ce as j,De as k,$e as l,Fe as m,h as n,Ue as o,ze as p,Re as q,qe as r,Ge as s,Je as t,Ee as u};
6
- //# sourceMappingURL=chunk-TMJDFHVD.js.map
6
+ //# sourceMappingURL=chunk-Y3JJXRVK.js.map
@@ -1,2 +1,2 @@
1
- import{pa as I,qa as b}from"./chunk-57XY346D.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="de8a82e1-0b02-5d5a-9086-686529a1ccab")}catch{}})();var v="blocked_by",D="blocks",T=Object.freeze([v,D]),y="no-active-blocker";function l(e){return e.trim().toLowerCase()}function p(e){let n=new Set,t=typeof e.blocked_by=="string"?l(e.blocked_by):"";t.length>0&&t!==y&&n.add(t);for(let o of e.dependencies??[]){let c=typeof o.id=="string"?l(o.id):"";o.kind===v&&c.length>0&&c!==y&&n.add(c)}return[...n].sort((o,c)=>o.localeCompare(c))}function k(e){let n=new Map;for(let t of e){let o=l(t.id);o.length!==0&&n.set(o,new Set(p(t)))}for(let t of e){let o=l(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=c.kind===D&&typeof c.id=="string"?l(c.id):"";if(s.length===0||s===y)continue;let d=n.get(s)??new Set;d.add(o),n.set(s,d)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function S(e,n){let t=l(e.id);return t.length>0?k(n).get(t)??p(e):p(e)}function B(e,n,t,o){let c=e;return(typeof c.id=="string"?o?.get(l(c.id))??S(c,[...n.values()]):p(e)).map(d=>{let r=n.get(l(d));return r?{id:d,title:r.title,status:r.status,resolved:b(r.status,t)}:{id:d,title:null,status:null,resolved:!1}})}function O(e,n,t){return B(e,n,t)}function K(e,n){let t=new Map(e.map(d=>[l(d.id),d])),o=k(e),c=new Set([...C(n),...n.blocked_statuses]),s=new Set;for(let d of e){let r=I(d.status,n);if(!c.has(r))continue;(n.blocked_statuses.has(r)||B(d,t,n,o).some(f=>!f.resolved))&&s.add(l(d.id))}return s}function C(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function A(e,n,t){let o=[l(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let d of n.get(s)??[]){if(!b(d.status,t))return!0;o.push(l(d.id))}}}return!1}function L(e){let n=new Map,t=new Map,o=new Map,c=k(e);for(let s of e){n.set(l(s.id),s);let d=typeof s.parent=="string"?s.parent.trim():"";if(d.length>0){let r=l(d),a=t.get(r)??[];a.push(s),t.set(r,a)}for(let r of c.get(l(s.id))){let a=l(r),f=o.get(a)??[];f.push(s.id),o.set(a,f)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function M(e,n,t){let{itemsById:o,childrenByParent:c,blockedByReverse:s,blockerIdsByItem:d}=L(n),r=new Set([...C(t),...t.blocked_statuses]),a=new Set(n.filter(i=>!b(i.status,t)).map(i=>l(i.id))),f=[],h=[],m=0,_=0;for(let i of e){if(!r.has(I(i.status,t)))continue;if(m+=1,A(i.id,c,t)){_+=1;continue}let g=B(i,o,t,d).filter(u=>!u.resolved),E=(s.get(l(i.id))??[]).filter(u=>a.has(l(u))).sort((u,x)=>u.localeCompare(x)),w={item:i,open_blockers:g,unblocks:E},N=t.blocked_statuses.has(I(i.status,t));g.length===0&&!N?f.push(w):h.push(w)}return{ready:f,blocked:h,active_count:m,container_count:_}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cc271a73-9767-54bb-a142-d4d4569e3c6a")}catch{}})();export{T as a,p as b,k as c,S as d,O as e,K as f,M as g};
2
- //# sourceMappingURL=chunk-66VGB23P.js.map
1
+ import{pa as I,qa as b}from"./chunk-XDPYBQCF.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="de8a82e1-0b02-5d5a-9086-686529a1ccab")}catch{}})();var v="blocked_by",D="blocks",T=Object.freeze([v,D]),y="no-active-blocker";function l(e){return e.trim().toLowerCase()}function p(e){let n=new Set,t=typeof e.blocked_by=="string"?l(e.blocked_by):"";t.length>0&&t!==y&&n.add(t);for(let o of e.dependencies??[]){let c=typeof o.id=="string"?l(o.id):"";o.kind===v&&c.length>0&&c!==y&&n.add(c)}return[...n].sort((o,c)=>o.localeCompare(c))}function k(e){let n=new Map;for(let t of e){let o=l(t.id);o.length!==0&&n.set(o,new Set(p(t)))}for(let t of e){let o=l(t.id);if(o.length!==0)for(let c of t.dependencies??[]){let s=c.kind===D&&typeof c.id=="string"?l(c.id):"";if(s.length===0||s===y)continue;let d=n.get(s)??new Set;d.add(o),n.set(s,d)}}return new Map([...n].map(([t,o])=>[t,[...o].sort((c,s)=>c.localeCompare(s))]))}function S(e,n){let t=l(e.id);return t.length>0?k(n).get(t)??p(e):p(e)}function B(e,n,t,o){let c=e;return(typeof c.id=="string"?o?.get(l(c.id))??S(c,[...n.values()]):p(e)).map(d=>{let r=n.get(l(d));return r?{id:d,title:r.title,status:r.status,resolved:b(r.status,t)}:{id:d,title:null,status:null,resolved:!1}})}function O(e,n,t){return B(e,n,t)}function K(e,n){let t=new Map(e.map(d=>[l(d.id),d])),o=k(e),c=new Set([...C(n),...n.blocked_statuses]),s=new Set;for(let d of e){let r=I(d.status,n);if(!c.has(r))continue;(n.blocked_statuses.has(r)||B(d,t,n,o).some(f=>!f.resolved))&&s.add(l(d.id))}return s}function C(e){return e.active_statuses.size>0?e.active_statuses:new Set([e.open_status])}function A(e,n,t){let o=[l(e)],c=new Set;for(;o.length>0;){let s=o.pop();if(!c.has(s)){c.add(s);for(let d of n.get(s)??[]){if(!b(d.status,t))return!0;o.push(l(d.id))}}}return!1}function L(e){let n=new Map,t=new Map,o=new Map,c=k(e);for(let s of e){n.set(l(s.id),s);let d=typeof s.parent=="string"?s.parent.trim():"";if(d.length>0){let r=l(d),a=t.get(r)??[];a.push(s),t.set(r,a)}for(let r of c.get(l(s.id))){let a=l(r),f=o.get(a)??[];f.push(s.id),o.set(a,f)}}return{itemsById:n,childrenByParent:t,blockedByReverse:o,blockerIdsByItem:c}}function M(e,n,t){let{itemsById:o,childrenByParent:c,blockedByReverse:s,blockerIdsByItem:d}=L(n),r=new Set([...C(t),...t.blocked_statuses]),a=new Set(n.filter(i=>!b(i.status,t)).map(i=>l(i.id))),f=[],h=[],m=0,_=0;for(let i of e){if(!r.has(I(i.status,t)))continue;if(m+=1,A(i.id,c,t)){_+=1;continue}let g=B(i,o,t,d).filter(u=>!u.resolved),E=(s.get(l(i.id))??[]).filter(u=>a.has(l(u))).sort((u,x)=>u.localeCompare(x)),w={item:i,open_blockers:g,unblocks:E},N=t.blocked_statuses.has(I(i.status,t));g.length===0&&!N?f.push(w):h.push(w)}return{ready:f,blocked:h,active_count:m,container_count:_}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="cc271a73-9767-54bb-a142-d4d4569e3c6a")}catch{}})();export{T as a,p as b,k as c,S as d,O as e,K as f,M as g};
2
+ //# sourceMappingURL=chunk-Y5A7SJJ7.js.map
@@ -0,0 +1,2 @@
1
+ import{_ as I,ga as P}from"./chunk-Z2USIBR2.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="d0f4c030-0028-5acb-a438-210666118074")}catch{}})();var X=["item","list","context","search","graph","history","workspace","package","ops","plan","contracts","help"],ge=["activate","add","adopt","adopt-all","catalog","compact","complete","create","deactivate","delete","describe","doctor","edit","explore","import","init","inspect","install","list","manage","migrate","mutate","read","redact","reload","remove","reopen","repair","restore","run","show","uninstall","upgrade","verify"];function s(e,a,t,l={}){return{name:e,required:t,variadic:l.variadic===!0,value_kind:a,polymorphic:l.polymorphic===!0}}function M(e){let a=e.replaceAll("-"," ");return`${a.charAt(0).toUpperCase()}${a.slice(1)}`}var g=s("id","item_id",!0),T=s("id","item_id",!1),A=s("text","string",!1),C=s("plan-id","item_id",!0),D=s("step","string",!0),fe=["--acceptance-criteria","--actual-result","--affected-version","--assignee","--blocked-by","--blocked-reason","--blocks","--body","--claim","--comment","--component","--confidence","--create-mode","--customer-impact","--deadline","--definition-of-ready","--description","--doc","--environment","--estimate","--event","--expected-result","--fixed-version","--file","--from-search","--goal","--harness","--impact","--learning","--message","--mode","--note","--objective","--order","--outcome","--parent","--priority","--rank","--related","--release","--reminder","--reporter","--repro-steps","--resolution","--resume-context","--reviewer","--risk","--scope","--severity","--sprint","--status","--step","--step-blocked-reason","--step-body","--step-evidence","--step-owner","--step-replacement","--step-status","--step-title","--tags","--template","--test","--title","--type-option","--unblock-note","--value","--why-now"],O=["--allow-multiple-active","--depends-on","--file","--force","--message","--step-blocked-reason","--step-body","--step-evidence","--step-owner","--step-status","--step-title","--test"],ce={"update-step":"Update one declared Plan step.","complete-step":"Complete one declared Plan step.","block-step":"Block one declared Plan step.","remove-step":"Remove one declared Plan step.",link:"Link one dependency to a declared Plan step.",unlink:"Unlink one dependency from a declared Plan step."},v=[{command:"plan create",parent:"plan",action:"create",slots:[s("title","string",!1,{polymorphic:!0})],accepted_flags:fe,description:"Create a Plan item and optionally seed its ordered steps.",example:'pm plan create --title "Refactor lock retry"'},{command:"plan show",parent:"plan",action:"show",slots:[C],accepted_flags:["--depth","--fields"],description:"Read one Plan item with a bounded plan projection.",example:"pm plan show pm-a1b2 --depth standard"},{command:"plan add-step",parent:"plan",action:"add-step",slots:[C],accepted_flags:O,description:"Append one ordered step to a Plan item.",example:'pm plan add-step pm-a1b2 --step-title "Run tests"'},...Object.entries(ce).map(([e,a])=>({command:`plan ${e}`,parent:"plan",action:e,slots:[C,D],accepted_flags:O,description:a,example:`pm plan ${e} pm-a1b2 plan-step-001`})),{command:"plan reorder-step",parent:"plan",action:"reorder-step",slots:[C,D,s("new-order","integer",!0)],accepted_flags:["--force","--message"],description:"Move one Plan step to a declared integer order.",example:"pm plan reorder-step pm-a1b2 plan-step-001 2"},...["decision","discovery","validation","resume","approve","materialize"].map(e=>({command:`plan ${e}`,parent:"plan",action:e,slots:[C],accepted_flags:O,description:`${M(e)} for one Plan item.`,example:`pm plan ${e} pm-a1b2`})),...["list","show","put","remove"].map(e=>({command:`assurance ${e}`,parent:"assurance",action:e,slots:[s("kind","string",!0),...e==="list"?[]:[s("id","string",!0)]],accepted_flags:e==="put"?["--author","--definition","--message"]:e==="remove"?["--author","--message"]:[],description:`${M(e)} assurance declarations by kind.`,example:e==="list"?"pm assurance list measurement":`pm assurance ${e} measurement example-id`})),{command:"assurance run",parent:"assurance",action:"run",slots:[s("gate-id","string",!0)],accepted_flags:["--dry-run","--trigger","--tree"],description:"Evaluate one assurance gate for a lifecycle trigger.",example:"pm assurance run tracker-context-quality --trigger ci --dry-run"},{command:"assurance verdicts",parent:"assurance",action:"verdicts",slots:[s("gate-id","string",!1)],accepted_flags:["--gate","--limit"],description:"List bounded assurance verdict history.",example:"pm assurance verdicts --limit 20"},...["presets","apply"].map(e=>({command:`assurance ${e}`,parent:"assurance",action:e,slots:[s("preset","string",e==="apply")],accepted_flags:["--author","--message","--owner"],description:e==="apply"?"Apply one assurance adoption preset.":"List available assurance adoption presets.",example:e==="apply"?"pm assurance apply software-delivery --owner <pm-item-id>":"pm assurance presets"})),{command:"assurance derive",parent:"assurance",action:"derive",slots:[],accepted_flags:["--apply","--author","--message","--owner"],description:"Derive assurance proposals from current project context.",example:"pm assurance derive --owner pm-a1b2"},{command:"assurance promote",parent:"assurance",action:"promote",slots:[s("assertion-id","string",!0)],accepted_flags:["--author","--enforcement","--message"],description:"Promote one assertion into a warning or blocking gate.",example:"pm assurance promote assertion-id --enforcement warn"},{command:"assurance risk",parent:"assurance",action:"risk",slots:[],accepted_flags:["--definition"],description:"Analyze bounded defect-recurrence risk for a proposed change.",example:`pm assurance risk --definition '{"change":{"files":[]}}'`},{command:"workspace snapshot create",parent:"workspace snapshot",action:"create",slots:[s("name","string",!1)],accepted_flags:[],description:"Capture authoritative tracker state as an immutable snapshot.",example:"pm workspace snapshot create before-migration"},{command:"workspace snapshot list",parent:"workspace snapshot",action:"list",slots:[],accepted_flags:[],description:"List immutable workspace snapshots and named references.",example:"pm workspace snapshot list"},{command:"workspace snapshot inspect",parent:"workspace snapshot",action:"inspect",slots:[s("target","string",!0)],accepted_flags:[],description:"Inspect one workspace snapshot target.",example:"pm workspace snapshot inspect before-migration"},{command:"workspace snapshot restore",parent:"workspace snapshot",action:"restore",slots:[s("target","string",!0)],accepted_flags:["--author","--dry-run","--force","--message"],description:"Restore an immutable workspace snapshot with explicit recovery controls.",example:"pm workspace snapshot restore before-migration --dry-run"},{command:"workspace snapshot delete",parent:"workspace snapshot",action:"delete",slots:[s("target","string",!0)],accepted_flags:[],description:"Delete one workspace snapshot target.",example:"pm workspace snapshot delete before-migration"}],pe=[...v].sort((e,a)=>a.command.length-e.command.length),z=new Map([["append",[g,A]],["assurance",[s("action","action",!0),s("kind","string",!1),s("id","string",!1)]],["beads import",[s("file","string",!1)]],["changelog export",[s("file","string",!1)]],["claim",[T]],["close",[g,A]],["close-task",[g,s("reason","string",!1)]],["comments",[g,A]],["completion",[s("shell","string",!1)]],["config",[s("scope","string",!1,{polymorphic:!0}),s("action","action",!1),s("key","string",!1),s("value","string",!1,{polymorphic:!0})]],["copy",[g]],["create",[s("type-or-title","string",!1,{polymorphic:!0}),s("title","string",!1)]],["delete",[g]],["deps",[g]],["docs",[g]],["event",[s("title","string",!0)]],["files",[g]],["files discover",[g]],["files lookup",[s("paths","string",!0,{variadic:!0})]],["focus",[T]],["get",[g]],["graph",[s("subcommand","action",!0),T,s("target","item_id",!1)]],["guide",[s("topic","string",!1)]],["history",[g]],["history-compact",[T]],["history-redact",[g]],["history-repair",[T]],["init",[s("prefix-or-path","string",!1,{polymorphic:!0})]],["item complete",[g,s("reason","string",!1)]],["item reopen",[g,s("reason","string",!0)]],["learnings",[g,A]],["meet",[s("title","string",!0)]],["merge",[s("subcommand","action",!0),s("artifact","string",!1),s("base","string",!1),s("ours","string",!1),s("theirs","string",!1)]],["notes",[g,A]],["package",[s("target","string",!1,{polymorphic:!0})]],["package list",[]],["package scaffold",[s("target","string",!0)]],["package upgrade",[s("target","string",!1)]],["packages",[s("target","string",!1,{polymorphic:!0})]],["packages list",[]],["packages scaffold",[s("target","string",!0)]],["packages upgrade",[s("target","string",!1)]],["pause-task",[g]],["plan",[s("subcommand","action",!0),s("id","item_id",!1,{polymorphic:!0}),s("step","string",!1),s("new-order","integer",!1)]],["profile",[s("subcommand","action",!0),s("name","string",!1)]],["release",[g]],["remind",[s("title","string",!0)]],["restore",[g,s("target","string",!0)]],["schema",[s("subcommand","action",!0),s("name","string",!1)]],["search-advanced",[s("keywords","string",!0,{variadic:!0})]],["search",[s("keywords","string",!0,{variadic:!0})]],["start-task",[g]],["telemetry",[s("namespace-or-subcommand","action",!1,{polymorphic:!0}),s("subcommand","action",!1)]],["test",[g]],["update",[g]],["workspace snapshot",[s("action","action",!0),s("target","string",!1)]],...["activate","adopt","deactivate","init","uninstall"].flatMap(e=>["extension","package","packages"].map(a=>[`${a} ${e}`,[s("target","string",!0)]])),...["describe"].flatMap(e=>["extension","package","packages"].map(a=>[`${a} ${e}`,[s("target","string",!1)]])),...["install"].flatMap(e=>["extension","package","packages"].map(a=>[`${a} ${e}`,[s("targets","string",!1,{variadic:!0})]])),["vcs abandon",[g]],["vcs create",[s("title","string",!0)]],["vcs merge",[g]],["vcs propose",[g]],["vcs ref-create",[s("name","string",!0)]],["vcs show",[g]]]);function _(e){return e.trim().toLowerCase().replace(/\s+/gu," ")}function ja(e){let a=_(e),t=w.find(r=>r.command===a);if(t)return t;let l=P(a)?.canonical;if(l)return w.find(r=>r.command===l)}function de(e){let a=_(e);return pe.find(t=>t.command===a||a.startsWith(`${t.command} `))}function qa(e){return`Applicable flags: ${e.length>0?e.join(", "):"none"}.`}function i(e,a,t,l,r){return r.map(n=>({command:n,noun:e,target:a,disposition:t,owner:l}))}var x=[...i("item","item","target_noun","pm-pbyu",["item","item complete","item mutate","item reopen"]),...i("item","item","consolidation","pm-yql1",["append","claim","close","close-many","close-task","comments","copy","create","delete","docs","files","get","learnings","notes","pause-task","release","start-task","test","update","update-many"]),...i("item","item files","consolidation","pm-ya7x55",["files discover","files lookup"]),...i("list","list","target_noun","pm-pfqi",["list"]),...i("list","list --group-by","consolidation","pm-xkgq",["aggregate"]),...i("context","context","target_noun","pm-pbyu",["context"]),...i("context","context","consolidation","pm-kcs4",["ctx","focus","next"]),...i("search","search","target_noun","pm-pbyu",["search"]),...i("search","search","package_owned","package:search-advanced",["reindex","search-advanced"]),...i("search","search duplicates","consolidation","pm-3i9q8g",["duplicates"]),...i("graph","graph","target_noun","pm-pbyu",["graph"]),...i("graph","graph show","consolidation","pm-yql1",["deps"]),...i("history","history","target_noun","pm-pbyu",["history"]),...i("history","history","consolidation","pm-tqel",["activity","events","history-author-acknowledge","history-compact","history-redact","history-repair","merge","restore"]),...i("history","history","package_owned","package:builtin-vcs-exemplar",["vcs abandon","vcs create","vcs log","vcs merge","vcs propose","vcs ref-create","vcs show"]),...i("workspace","workspace","target_noun","pm-pbyu",["workspace","workspace snapshot","workspace snapshot create","workspace snapshot delete","workspace snapshot inspect","workspace snapshot list","workspace snapshot restore"]),...i("workspace","workspace init","consolidation","pm-n7rr",["init"]),...i("package","package","target_noun","pm-pbyu",["package","package activate","package adopt","package adopt-all","package catalog","package deactivate","package describe","package doctor","package explore","package init","package install","package list","package manage","package migrate","package reload","package scaffold","package uninstall","package upgrade"]),...i("package","package","consolidation","pm-tnud",["extension activate","extension adopt","extension adopt-all","extension catalog","extension deactivate","extension describe","extension doctor","extension explore","extension init","extension install","extension manage","extension migrate","extension reload","extension uninstall","packages","packages activate","packages adopt","packages adopt-all","packages catalog","packages deactivate","packages describe","packages doctor","packages explore","packages init","packages install","packages list","packages manage","packages migrate","packages reload","packages scaffold","packages uninstall","packages upgrade"]),...i("package","package","package_owned","package:beads",["beads import"]),...i("package","package","package_owned","package:pm-changelog",["changelog export","changelog generate"]),...i("package","package calendar","package_owned","pm-o3fh",["event","meet","remind"]),...i("ops","ops","consolidation","pm-6apl",["assurance","config","eval","gc","health","profile","schema","stats","telemetry","test-all","validate"]),...i("ops","ops assurance","consolidation","pm-2tan",v.filter(({parent:e})=>e==="assurance").map(({command:e})=>e)),...i("plan","plan","target_noun","pm-pbyu",["plan"]),...i("plan","plan","target_noun","pm-2tan",v.filter(({parent:e})=>e==="plan").map(({command:e})=>e)),...i("contracts","contracts","target_noun","pm-pbyu",["contracts"]),...i("help","help","target_noun","pm-pbyu",["help"]),...i("help","help","package_owned","package:builtin-guide-shell",["completion","completion-statuses","completion-tags","completion-types","guide"])],w=[...new Set(x.map(({command:e})=>e))].map(e=>({command:e,slots:de(e)?.slots??z.get(e)??[]})),b={nouns:X,shared_verbs:ge,scope_before_verb:!0,visible_top_level_ceiling:69,ceiling_raise_requires_pm_item:!0,positional_shape_budget:21};function $(e,a){let t=new Set(a);return[...new Set(e)].filter(l=>!t.has(l)).map(l=>({code:"positional_signature_mismatch",command:l,detail:`Positional signature ${l} has no destination declaration.`}))}function me(e){return e.map(({required:a,variadic:t,value_kind:l,polymorphic:r})=>`${a?"r":"o"}:${t?"v":"s"}:${l}:${r?"p":"m"}`).join("|")}function k(e){return e.map(({name:a,required:t,variadic:l,value_kind:r,polymorphic:n})=>`${a}:${t?"r":"o"}:${l?"v":"s"}:${r}:${n?"p":"m"}`).join("|")}function U(e,a){let t=new Map;for(let{command:l}of e){let r=_(l);t.set(r,(t.get(r)??0)+1)}return[...t.entries()].filter(([,l])=>l>1).map(([l,r])=>({code:"positional_signature_mismatch",command:l,detail:`${r} ${a} positional signatures exist for ${l}; exactly one is required.`}))}function Ba(e,a={}){let t=a.declared??w,l=a.positionalShapeBudget??b.positional_shape_budget,r=new Map(t.map(o=>[_(o.command),o])),n=new Map(e.map(o=>[_(o.command),o])),c=[...U(t,"declared"),...U(e,"observed"),...a.declared===void 0?[...$(z.keys(),x.map(({command:o})=>o)),...$(v.map(({command:o})=>o),x.map(({command:o})=>o))]:[]];for(let o of r.values()){let d=_(o.command),f=n.get(d);f?k(f.slots)!==k(o.slots)&&c.push({code:"positional_signature_mismatch",command:o.command,detail:`Observed positional signature for ${o.command} differs from its declared SDK contract: observed=${k(f.slots)||"<none>"}; declared=${k(o.slots)||"<none>"}.`}):c.push({code:"missing_observed_signature",command:o.command,detail:`No observed positional signature exists for ${o.command}.`})}for(let o of n.values())r.has(_(o.command))||c.push({code:"stale_observed_signature",command:o.command,detail:`Observed positional signature ${o.command} has no declaration.`});let p=new Set(t.map(({slots:o})=>me(o))).size;return p>l&&c.push({code:"positional_shape_budget_exceeded",command:"*",detail:`Distinct positional shape count ${p} exceeds budget ${l}.`}),c.sort((o,d)=>o.command!==d.command?o.command.localeCompare(d.command):o.code.localeCompare(d.code)),{ok:c.length===0,declared_command_count:t.length,observed_command_count:e.length,positional_shape_count:p,positional_shape_budget:l,findings:c}}function ue(e,a,t){return e.flatMap(l=>{let r=a.get(l)??[];if(r.length===0){let c=l.indexOf(" "),p=c===-1?l:l.slice(0,c);return[{code:"missing_destination",spelling:l,message:`Command \`${l}\` has no destination census row.`,nearest_target:t.has(p)?p:`ops ${l}`}]}let n=r.length>1?[{code:"duplicate_destination",spelling:l,message:`Command \`${l}\` has ${r.length} destination rows.`,nearest_target:r[0].target}]:[];return r.reduce((c,p)=>(p.disposition==="keep_as_is"&&(p.reason?.trim().length??0)===0&&c.push({code:"missing_destination",spelling:l,message:`Command \`${l}\` is kept as-is without a documented reason.`,nearest_target:p.target}),t.has(p.noun)||c.push({code:"unknown_noun",spelling:l,message:`Command \`${l}\` names undeclared noun \`${p.noun}\`.`,nearest_target:p.target}),c),n)})}function _e(e,a){return a.filter(t=>t.disposition!=="package_owned"&&!e.has(t.command)).map(t=>({code:"stale_destination",spelling:t.command,message:`Destination row \`${t.command}\` is absent from live contracts.`,nearest_target:t.target}))}function he(e,a){return e.filter(t=>!a.has(t.canonical)).map(t=>({code:"alias_target_missing",spelling:t.alias,message:`Alias \`${t.alias}\` targets missing canonical command \`${t.canonical}\`.`,nearest_target:t.canonical_argv.join(" ")}))}function Ya(e,a=[],t=x){let l=[...new Set(e.map(f=>f.trim()))].filter(f=>f.length>0).sort((f,h)=>f.localeCompare(h)),r=new Set(l),n=new Set(X),c=new Map;for(let f of t){let h=c.get(f.command)??[];h.push(f),c.set(f.command,h)}let p=[...ue(l,c,n),..._e(r,t),...he(a,r)],o=new Set(a.filter(f=>f.hidden).map(f=>f.alias)),d=new Set(l.filter(f=>!f.includes(" ")&&!o.has(f)&&!(c.get(f)??[]).some(h=>h.disposition==="package_owned"))).size;return d>b.visible_top_level_ceiling&&p.push({code:"visible_surface_ceiling_exceeded",spelling:String(d),message:`Visible non-package top-level command count ${d} exceeds ceiling ${b.visible_top_level_ceiling}.`,nearest_target:"Declare the noun placement and tracked waiver before raising the ceiling."}),{ok:p.length===0,command_count:l.length,destination_count:t.length,hidden_alias_count:a.filter(f=>f.hidden).length,visible_top_level_count:d,visible_top_level_ceiling:b.visible_top_level_ceiling,findings:p}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="f73e79d8-2a65-5a25-8c6f-ec9b06651634")}catch{}})();function y(e){return[...new Set(Array.from(e,a=>a.trim()).filter(a=>a.length>0))]}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="76fe6260-2386-52c5-8f94-aad48dec33f9")}catch{}})();function N(e){return e.startsWith("--")?`--${e.slice(2).replaceAll("_","-")}`:e}function L(e){let a=new Map;for(let t of e){let l=N(t.flag),r=a.get(l)??new Set;t.flag!==l&&r.add(t.flag);for(let n of t.aliases??[])n!==l&&r.add(n);a.set(l,r)}return e.map(t=>{let l=N(t.flag);if(t.flag!==l)return t;let r=y([...t.aliases??[],...a.get(l)]).filter(n=>n!==l);return r.length===0?t:{...t,aliases:r}})}function Qa(e){let a=L(e),t=new Set(a.map(l=>l.flag));return a.filter(l=>{let r=N(l.flag);return l.flag===r||!t.has(r)})}var E=I.map(e=>({flag:e.flag,...e.aliases?{aliases:[...e.aliases]}:{},...e.value_name?{value_name:e.value_name}:{}})),Za=[...E,{flag:"--version"}],V=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--has-notes"},{flag:"--no-notes"},{flag:"--has-learnings"},{flag:"--no-learnings"},{flag:"--has-files"},{flag:"--no-files"},{flag:"--filter-files-missing"},{flag:"--has-docs"},{flag:"--no-docs"},{flag:"--filter-docs-missing"},{flag:"--has-tests"},{flag:"--no-tests"},{flag:"--has-comments"},{flag:"--no-comments"},{flag:"--has-deps"},{flag:"--no-deps"},{flag:"--has-body"},{flag:"--empty-body"},{flag:"--has-linked-command"},{flag:"--no-linked-command"}],K=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--filter-has-notes"},{flag:"--filter-no-notes"},{flag:"--filter-has-learnings"},{flag:"--filter-no-learnings"},{flag:"--filter-has-files"},{flag:"--filter-no-files"},{flag:"--filter-has-docs"},{flag:"--filter-no-docs"},{flag:"--filter-has-tests"},{flag:"--filter-no-tests"},{flag:"--filter-has-comments"},{flag:"--filter-no-comments"},{flag:"--filter-has-deps"},{flag:"--filter-no-deps"},{flag:"--filter-has-body"},{flag:"--filter-empty-body"},{flag:"--filter-has-linked-command"},{flag:"--filter-no-linked-command"},{flag:"--ids",list:!0},{flag:"--limit"},{flag:"--offset"}],R=F([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--status",list:!0},{flag:"--all",value_type:"boolean"},{flag:"--type",list:!0},{flag:"--tag",aliases:["--tags"],list:!0},{flag:"--priority",list:!0},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--today"},{flag:"--recent"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--ids",list:!0},{flag:"--assignee",list:!0},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:!0},{flag:"--release",list:!0},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...V,{flag:"--limit"},{flag:"--offset"},{flag:"--after"},{flag:"--no-truncate"},{flag:"--compact"},{flag:"--brief"},{flag:"--full"},{flag:"--fields",list:!0},{flag:"--sort"},{flag:"--order"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--include-body"},{flag:"--strict-read"},{flag:"--format"},{flag:"--stream"}],new Set(["--limit","--token-budget","--offset","--after","--no-truncate","--compact","--brief","--full","--fields","--include-body","--strict-read"])),ve=[{flag:"--group-by",list:!0},{flag:"--count"},{flag:"--completion"},{flag:"--sum"},{flag:"--avg"},{flag:"--include-unparented"},{flag:"--include_unparented"},{flag:"--status",list:!0},{flag:"--type",list:!0},{flag:"--tag",list:!0},{flag:"--priority",list:!0},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--assignee",list:!0},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:!0},{flag:"--release",list:!0}],Te=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--comment","--body","--text"]},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--full-history"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];function F(e,a){return e.map(t=>a.has(t.flag)?{...t,cursor_semantics:"presentation"}:t)}var Ae=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--note","--text"]},{flag:"--add-json"},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--since"},{flag:"--event-type"},{flag:"--include-meta"},{flag:"--full-history"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Ce=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--learning","--text"]},{flag:"--limit"},{flag:"--full-history"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],ye=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--append-stable"},{flag:"--validate-paths"},{flag:"--scope"},{flag:"--limit"},{flag:"--offset"},{flag:"--no-truncate"},{flag:"--strict-read"},{flag:"--explain"},{flag:"--lines",value_name:"start:end"},{flag:"--decision-depth",value_name:"n",value_type:"number"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],ke=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--validate-paths"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],be=[{flag:"--id",value_name:"item-id"},{flag:"--limit"},{flag:"--compact"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:!0},{flag:"--agent-instance",repeatable:!0},{flag:"--provenance-filter",repeatable:!0},{flag:"--diff"},{flag:"--field"},{flag:"--verify"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--format"}],xe=[{flag:"--dry-run"},{flag:"--output"},{flag:"--item-path"},{flag:"--prefer"}],Se=[{flag:"--id",value_name:"item-id"},{flag:"--literal"},{flag:"--regex"},{flag:"--replacement"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Ne=[{flag:"--id",value_name:"item-id"},{flag:"--all"},{flag:"--dry-run"},{flag:"--normalize-provenance"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Oe=[{flag:"--event",repeatable:!0},{flag:"--all-actionable"},{flag:"--dry-run"},{flag:"--plan-fingerprint"},{flag:"--limit",value_type:"number"},{flag:"--attributed-author",aliases:["--attributed_author"]},{flag:"--reviewer"},{flag:"--reason"}],we=[{flag:"--id",value_name:"item-id"},{flag:"--before"},{flag:"--ids",list:!0},{flag:"--all-over",value_type:"number"},{flag:"--closed"},{flag:"--all-streams"},{flag:"--min-entries",value_type:"number"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Le=[{flag:"--description"},{flag:"--default-status",aliases:["--default_status"]},{flag:"--folder"},{flag:"--alias"},{flag:"--role"},{flag:"--order"},{flag:"--type"},{flag:"--commands"},{flag:"--cli-flag"},{flag:"--required"},{flag:"--required-on-create"},{flag:"--no-allow-unset"},{flag:"--required-types"},{flag:"--infer"},{flag:"--min-count"},{flag:"--apply",value_type:"boolean"},{flag:"--to"},{flag:"--migration-id",aliases:["--migration_id"]},{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}],Ee=[{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}],W=[{flag:"--title"},{flag:"--description"},{flag:"--scope"},{flag:"--parent"},{flag:"--related"},{flag:"--blocks"},{flag:"--blocked-by",aliases:["--blocked_by"]},{flag:"--harness"},{flag:"--mode"},{flag:"--resume-context",aliases:["--resume_context"]},{flag:"--tags",aliases:["--tag"],list:!0},{flag:"--priority"},{flag:"--status",short:"-s"},{flag:"--create-mode",aliases:["--create_mode"]},{flag:"--deadline"},{flag:"--estimate",aliases:["--estimated-minutes","--estimated_minutes"]},{flag:"--acceptance-criteria",aliases:["--acceptance_criteria","--ac"],repeatable:!0},{flag:"--definition-of-ready",aliases:["--definition_of_ready"]},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now",aliases:["--why_now"]},{flag:"--assignee"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-reason",aliases:["--blocked_reason"]},{flag:"--unblock-note",aliases:["--unblock_note"]},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps",aliases:["--repro_steps"]},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--affected-version",aliases:["--affected_version"]},{flag:"--fixed-version",aliases:["--fixed_version"]},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact",aliases:["--customer_impact"]},{flag:"--comment",repeatable:!0},{flag:"--note",repeatable:!0},{flag:"--learning",repeatable:!0},{flag:"--reminder",repeatable:!0},{flag:"--event",repeatable:!0},{flag:"--type-option",aliases:["--type_option"],repeatable:!0},{flag:"--body"},{flag:"--claim"},{flag:"--from-search",aliases:["--from_search"]},{flag:"--template"},{flag:"--step-title",aliases:["--step_title"]},{flag:"--step"},{flag:"--step-body",aliases:["--step_body"]},{flag:"--step-owner",aliases:["--step_owner"]},{flag:"--step-status",aliases:["--step_status"]},{flag:"--step-evidence",aliases:["--step_evidence"]},{flag:"--step-blocked-reason",aliases:["--step_blocked_reason"]},{flag:"--step-replacement",aliases:["--step_replacement"]},{flag:"--depends-on",aliases:["--depends_on"]},{flag:"--link"},{flag:"--link-kind",aliases:["--link_kind"]},{flag:"--link-note",aliases:["--link_note"]},{flag:"--promote-to-item-dep",aliases:["--promote_to_item_dep"]},{flag:"--allow-multiple-active",aliases:["--allow_multiple_active"]},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--decision-text",aliases:["--decision_text","--decision"]},{flag:"--decision-rationale",aliases:["--decision_rationale"]},{flag:"--decision-evidence",aliases:["--decision_evidence"]},{flag:"--discovery-text",aliases:["--discovery_text","--discovery"]},{flag:"--validation-text",aliases:["--validation_text","--validation"]},{flag:"--validation-command",aliases:["--validation_command"]},{flag:"--validation-expected",aliases:["--validation_expected"]},{flag:"--depth"},{flag:"--field"},{flag:"--fields",list:!0},{flag:"--steps"},{flag:"--materialize-type",aliases:["--materialize_type"]},{flag:"--materialize-parent",aliases:["--materialize_parent"]},{flag:"--materialize-tags",aliases:["--materialize_tags"]},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Re=[{flag:"--id-prefix",aliases:["--prefix"]},{flag:"--preset"},{flag:"--type-preset"},{flag:"--defaults",short:"-y",aliases:["--yes"]},{flag:"--author"},{flag:"--agent-guidance"},{flag:"--with-packages"},{flag:"--no-merge-fence"},{flag:"--workspace"},{flag:"--force"},{flag:"--verbose"}],Fe=[{flag:"--criterion"},{flag:"--clear-criteria"},{flag:"--format"},{flag:"--policy"},{flag:"--default-depth"},{flag:"--activity-limit"},{flag:"--stale-threshold-days"},{flag:"--section-hierarchy"},{flag:"--section-activity"},{flag:"--section-progress"},{flag:"--section-blockers"},{flag:"--section-files"},{flag:"--section-workload"},{flag:"--section-staleness"},{flag:"--section-tests"}],J=[{flag:"--init"},{flag:"--scaffold"},{flag:"--capability"},{flag:"--install"},{flag:"--uninstall"},{flag:"--explore"},{flag:"--list"},{flag:"--manage"},{flag:"--describe"},{flag:"--markdown"},{flag:"--output"},{flag:"--reload"},{flag:"--watch"},{flag:"--doctor"},{flag:"--catalog"},{flag:"--adopt"},{flag:"--adopt-all"},{flag:"--activate"},{flag:"--deactivate"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"},{flag:"--detail"},{flag:"--trace"},{flag:"--runtime-probe"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}],m=[{flag:"--project"},{flag:"--local"},{flag:"--global"}],Q=[...m,{flag:"--capability"}],j=[...J,{flag:"--declarative"}],Ge=[...Q,{flag:"--declarative"}],Ie=[{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],Pe=m,Me=m,De=[...m,{flag:"--markdown"},{flag:"--output"}],$e=m,Ue=m,Xe=m,ze=[...m,{flag:"--dry-run"}],je=[...m,{flag:"--runtime-probe"},{flag:"--fix-managed-state"}],qe=[...m,{flag:"--watch"}],Be=[...m,{flag:"--detail"},{flag:"--trace"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}],q=[...m,{flag:"--fields",list:!0}],Ye=[...m,{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],He=[{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],Z=[{flag:"--dry-run"},{flag:"--cli-only"},{flag:"--packages-only"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--repair"},{flag:"--tag"},{flag:"--package-name"}],et=[{flag:"--mode"},{flag:"--progress"}],Ve=[{flag:"--id",value_name:"item-id"},{flag:"--reason",value_name:"value"},{flag:"--close-reason",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--duplicate-of",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",aliases:["--expected_result","--expected"],value_name:"value"},{flag:"--actual-result",aliases:["--actual_result","--actual"],value_name:"value"},{flag:"--force",value_type:"boolean"}],Ke=[{flag:"--filter-status",list:!0},{flag:"--filter-type"},{flag:"--filter-tag"},{flag:"--filter-priority"},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee"},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint"},{flag:"--filter-release"},...K,{flag:"--reason"},{flag:"--completed-at"},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--validate-close"},{flag:"--author"},{flag:"--message"},{flag:"--force"},{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"}],We=[{flag:"--id",value_name:"item-id"},{flag:"--body",short:"-b"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Je=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"},{flag:"--if-available"},{flag:"--next"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee-filter"},{flag:"--parent"},{flag:"--sprint"},{flag:"--release"},{flag:"--max-attempts"},{flag:"--include-decisions"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--explain-ranking",aliases:["--explain_ranking"]}],Qe=[{flag:"--id",value_name:"item-id"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Ze=[{flag:"--id",value_name:"item-id"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],ea=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}],aa=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}],ta=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}],la=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--force"}],ee=[{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--tags"},{flag:"--priority"},{flag:"--body"},{flag:"--description"},{flag:"--author"},{flag:"--message"}],ae=[{flag:"--start"},{flag:"--duration"},{flag:"--end"},{flag:"--location"},{flag:"--timezone"},{flag:"--all-day"},...ee],sa=ae,ra=[{flag:"--at"},{flag:"--text"},...ee],na=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-json"},{flag:"--remove"},{flag:"--remove-index",repeatable:!0},{flag:"--run"},{flag:"--match"},{flag:"--only-index"},{flag:"--only-last"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--acknowledge-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"},{flag:"--measure",list:!0},{flag:"--metric-below"},{flag:"--metric-diff"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],oa=[{flag:"--status"},{flag:"--limit"},{flag:"--offset"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"}],ia=[{flag:"--limit"}],ga=[{flag:"--status"},{flag:"--limit"},{flag:"--stream"},{flag:"--tail"},{flag:"--force"},{flag:"--author"}],fa=[{flag:"--dry-run"},{flag:"--scope"}],ca=[{flag:"--include-empty"},{flag:"--storage"},{flag:"--metadata-coverage"},{flag:"--field-utilization"},{flag:"--by-assignee"},{flag:"--by-tag"},{flag:"--by-priority"},{flag:"--tag-prefix"},{flag:"--analytics"}],pa=[{flag:"--status",repeatable:!0,list:!0},{flag:"--since"},{flag:"--threshold"},{flag:"--limit"}],da=[{flag:"--strict-directories"},{flag:"--require-merge-drivers"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--check-only"},{flag:"--check-telemetry"},{flag:"--no-refresh"},{flag:"--refresh-vectors"},{flag:"--verbose-stale-items"},{flag:"--verbose-author-events"},{flag:"--brief"},{flag:"--summary"},{flag:"--skip-vectors"},{flag:"--skip-integrity"},{flag:"--skip-drift"},{flag:"--full"}],ma=[{flag:"--check-metadata"},{flag:"--metadata-profile"},{flag:"--check-resolution"},{flag:"--check-lifecycle"},{flag:"--check-stale-blockers"},{flag:"--dependency-cycle-severity"},{flag:"--parent-cycle-severity"},{flag:"--check-files"},{flag:"--scan-mode"},{flag:"--include-pm-internals"},{flag:"--verbose-file-lists"},{flag:"--verbose-diagnostics"},{flag:"--all-affected-ids"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--fix-hints"},{flag:"--auto-fix"},{flag:"--dry-run"},{flag:"--fix-scope"},{flag:"--prune-missing"},{flag:"--check-history-drift"},{flag:"--check-command-references"},{flag:"--check-storage-integrity"},{flag:"--counts"},{flag:"--full"}],te=[{flag:"--definition",value_name:"json"},{flag:"--trigger",value_name:"value"},{flag:"--tree",value_name:"value"},{flag:"--gate",value_name:"id"},{flag:"--limit",value_name:"number"},{flag:"--dry-run"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--owner",value_name:"item-id"},{flag:"--apply",value_type:"boolean"},{flag:"--enforcement",value_name:"level"}],le=[{flag:"--assignee"},{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--allow-unresolved-deps"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-by"},{flag:"--blocked-reason"},{flag:"--unblock-note"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--actual-result"},{flag:"--affected-version"},{flag:"--fixed-version"}],se=[{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"}],re=[{short:"-p",flag:"--priority"},{flag:"--type"},{flag:"--tags",aliases:["--tag"],list:!0},{flag:"--add-tags",aliases:["--add_tags"]},{flag:"--remove-tags",aliases:["--remove_tags"]},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--add-ac",aliases:["--add_ac"]},{flag:"--remove-ac",aliases:["--remove_ac"]}],B=[{flag:"--stdin-json"},{short:"-t",flag:"--title"},{flag:"--id"},{short:"-d",flag:"--description"},{flag:"--type"},{flag:"--template"},{flag:"--create-mode"},{flag:"--create_mode"},{flag:"--schedule-preset"},{flag:"--schedule_preset"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},{flag:"--completed_at"},{short:"-p",flag:"--priority"},{flag:"--tags",aliases:["--tag"],list:!0},{flag:"--add-tags",aliases:["--add_tags"]},{short:"-b",flag:"--body"},{flag:"--body-file"},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--author"},{flag:"--message"},...le,...se,{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--fixed_version"},{flag:"--dep"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--reminder"},{flag:"--event"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--allow-duplicate",value_type:"boolean"}],ua=[{flag:"--transaction-id",value_name:"value"},{flag:"--stdin-json"},{flag:"--dry-run"},{flag:"--create-compensation",value_name:"mode"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--author",value_name:"value"}],_a=[{flag:"--id",value_name:"item-id"},{flag:"--transaction-id",value_name:"value",required:!0},{flag:"--reason",value_name:"value"},{flag:"--file",value_name:"value",repeatable:!0},{flag:"--doc",value_name:"value",repeatable:!0},{flag:"--test",value_name:"value",repeatable:!0},{flag:"--comment",value_name:"value",repeatable:!0},{flag:"--note",value_name:"value",repeatable:!0},{flag:"--learning",value_name:"value",repeatable:!0},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",value_name:"value"},{flag:"--actual-result",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--dry-run"},{flag:"--force"},{flag:"--author",value_name:"value"}],ha=[{flag:"--id",value_name:"item-id"},{flag:"--status",value_name:"open|in_progress"},{flag:"--message",value_name:"value"},{flag:"--force"},{flag:"--author",value_name:"value"}],va=[{flag:"--id",value_name:"item-id"},{flag:"--title",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--allow-duplicate",value_type:"boolean"}],Ta=[{flag:"--id",value_name:"item-id"},{flag:"--clear"}],Aa=[{flag:"--id",value_name:"item-id"},{flag:"--stdin-json"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},{flag:"--body-file"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},...re,...le,{flag:"--fixed_version"},...se,{flag:"--author"},{flag:"--message"},{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--force"}],Ca=[{flag:"--filter-status",list:!0},{flag:"--filter-type",list:!0},{flag:"--filter-tag",list:!0},{flag:"--filter-priority",list:!0},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee",list:!0},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint",list:!0},{flag:"--filter-release",list:!0},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...K,{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},...re,{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--repro_steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--expected_result"},{flag:"--expected"},{flag:"--actual-result"},{flag:"--actual_result"},{flag:"--actual"},{flag:"--affected-version"},{flag:"--affected_version"},{flag:"--fixed-version"},{flag:"--fixed_version"},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--allow-unresolved-deps"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Y=[{flag:"--view"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--full-period"},{flag:"--full_period"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--status"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--include"},{flag:"--recurrence-lookahead-days"},{flag:"--recurrence-lookback-days"},{flag:"--occurrence-limit"},{flag:"--limit"},{flag:"--format"}],ya=[{flag:"--id"},{flag:"--op"},{flag:"--author"},{flag:"--from"},{flag:"--to"},{flag:"--limit"},{flag:"--unbounded"},{flag:"--compact"},{flag:"--raw"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:!0},{flag:"--agent-instance",repeatable:!0},{flag:"--provenance-filter",repeatable:!0},{flag:"--stream"}],ka=[{flag:"--since"},{flag:"--type",repeatable:!0},{flag:"--author",repeatable:!0},{flag:"--item",repeatable:!0},{flag:"--limit",value_type:"number"},{flag:"--cursor-mode",value_name:"batch|row"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:!0},{flag:"--agent-instance",repeatable:!0},{flag:"--provenance-filter",repeatable:!0},{flag:"--follow"},{flag:"--interval-ms",value_type:"number"}],H=F([{flag:"--for",value_name:"intent"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit",aliases:["--max-items"]},{flag:"--after"},{flag:"--format"},{flag:"--depth"},{flag:"--fields",list:!0},{flag:"--section"},{flag:"--activity-limit"},{flag:"--stale-threshold"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--no-extension-health"},{flag:"--no-tags"}],new Set(["--limit","--after","--format","--fields","--section","--activity-limit","--stale-threshold","--explain-ranking","--explain_ranking","--no-extension-health","--no-tags"])),ba=[{flag:"--id",value_name:"item-id"},{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--depth"},{flag:"--full",value_type:"boolean"},{flag:"--fields",list:!0},{flag:"--at"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--format"}],xa=[{flag:"--list"},{flag:"--format"},{flag:"--depth"}],Sa=[{flag:"--id",value_name:"item-id"},{flag:"--format"},{flag:"--max-depth"},{flag:"--collapse"},{flag:"--summary"},{flag:"--full"},{flag:"--node-limit"},{flag:"--edge-limit"},{flag:"--token-budget"},{flag:"--cursor"},{flag:"--direction"},{flag:"--kind",list:!0}],Na=[{flag:"--kind",list:!0},{flag:"--max-depth"},{flag:"--limit"},{flag:"--after"},{flag:"--direction"},{flag:"--max-paths"},{flag:"--sample"},{flag:"--exempt-isolate",list:!0},{flag:"--exempt-isolate-type",list:!0},{flag:"--save-baseline"},{flag:"--rebuild"},{flag:"--clear"},{flag:"--summary"},{flag:"--full"}],Oa=[{flag:"--mode"},{flag:"--k"},{flag:"--fail-under"},{flag:"--queries"},{flag:"--format"}],u=[{flag:"--dry-run"},{flag:"--force"},{flag:"--author"},{flag:"--message"}],wa=[{flag:"--for",value_name:"intent"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit"},{flag:"--blocked-limit"},{flag:"--blocked_limit"},{flag:"--ready-only"},{flag:"--ready_only"},{flag:"--format"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]}],La=F([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--mode"},{flag:"--semantic"},{flag:"--hybrid"},{flag:"--match-mode"},{flag:"--min-score"},{flag:"--count"},{flag:"--semantic-weight"},{flag:"--include-linked"},{flag:"--title-exact"},{flag:"--phrase-exact"},{flag:"--highlight"},{flag:"--compact"},{flag:"--full"},{flag:"--fields",list:!0},{flag:"--format"},{flag:"--limit"},{flag:"--after"},{flag:"--status",list:!0},{flag:"--type",list:!0},{flag:"--tag",aliases:["--tags"],list:!0},{flag:"--priority",list:!0},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--assignee",list:!0},{flag:"--sprint",list:!0},{flag:"--release",list:!0},{flag:"--parent"},...V],new Set(["--highlight","--compact","--full","--fields","--format","--limit","--token-budget","--after"])),Ea=[{flag:"--action"},{flag:"--command"},{flag:"--summary"},{flag:"--schema-only"},{flag:"--flags-only"},{flag:"--availability-only"},{flag:"--runtime-only"},{flag:"--active-only"},{flag:"--full"}],Ra=[{flag:"--eager-tags"}];function at(e){let a=new Set,t=[];for(let l of e){let r=(l.aliases??[]).join(","),n=`${l.flag}|${l.short??""}|${r}`;a.has(n)||(a.add(n),t.push(l))}return t}function S(e){let a=new Map;for(let t of[...E,...e]){let l=N(t.flag),r=a.get(l),{aliases:n,...c}=t,p=y([...n??[],...t.flag===l?[]:[t.flag]]).filter(f=>f!==l),o={...c,flag:l,...p.length>0?{aliases:p}:{}},d=y([...r?.aliases??[],...o.aliases??[]]);a.set(l,r===void 0?o:{...r,...o,...d.length>0?{aliases:d}:{}})}return L([...a.values()])}var Fa=["list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled"],Ga=R.filter(e=>e.flag!=="--status"&&e.flag!=="--all"),Ia=R.filter(e=>e.flag!=="--status");function G(e){let a=new Map;for(let t of e)for(let l of[t.flag,...t.aliases??[]]){let r=a.get(l)??[];r.push(t),a.set(l,r)}return a}var Pa=G(W),Ma=G(te),Da=new Map([["assurance",Ma],["plan",Pa],["workspace snapshot",G(u)]]);function $a(e=v){return e.map(({command:a,parent:t,accepted_flags:l})=>{let r=Da.get(t);if(!r)throw new Error(`Positional action ${a} has no flag-contract index for ${t}.`);let n=l.map(c=>{let p=r.get(c)??[];if(p.length!==1)throw new Error(`Positional action ${a} accepted flag ${c} does not resolve to exactly one ${t} flag contract.`);return p[0]});return[a,n]})}var Ua=$a(),ne=new Map([["list",R],["list-all",Ia],...Fa.map(e=>[e,Ga]),["templates",B],["cal",Y],["ctx",H],["test-runs-worker",ga],["init",Re],["config",Fe],["extension",J],["package",j],["packages",j],["install",He],["upgrade",Z],["create",B],["item mutate",ua],["item complete",_a],["item reopen",ha],["copy",va],["focus",Ta],["aggregate",ve],["calendar",Y],["context",H],["get",ba],["guide",xa],["search",La],["next",wa],["eval",Oa],["workspace",u],["workspace snapshot",u],["workspace snapshot create",u],["workspace snapshot list",u],["workspace snapshot inspect",u],["workspace snapshot restore",u],["workspace snapshot delete",u],["history",be],["history-redact",Se],["history-repair",Ne],["history-author-acknowledge",Oe],["history-compact",we],["merge",xe],["schema",Le],["profile",Ee],["plan",W],["activity",ya],["events",ka],["restore",Qe],["update",Aa],["update-many",Ca],["close",Ve],["close-many",Ke],["delete",Ze],["append",We],["comments",Te],["notes",Ae],["learnings",Ce],["files",ye],["docs",ke],["deps",Sa],["graph",Na],["test",na],["test-all",oa],["telemetry",ia],["health",da],["assurance",te],...Ua,["validate",ma],["gc",fa],["stats",ca],["duplicates",pa],["contracts",Ea],["completion",Ra],["claim",Je],["release",ea],["start-task",aa],["pause-task",ta],["close-task",la],["meet",ae],["event",sa],["remind",ra]]),oe=new Map([["install",Ie],["uninstall",Pe],["explore",Me],["manage",je],["describe",De],["reload",qe],["doctor",Be],["catalog",q],["list",q],["adopt",Ye],["adopt-all",$e],["activate",Ue],["deactivate",Xe],["migrate",ze]]);function ie(e){return typeof e!="string"?"":e.trim().toLowerCase()}function tt(e){let a=ie(e);if(ne.has(a))return!0;let[t,l,...r]=a.split(/\s+/);return(t==="extension"||t==="package"||t==="packages")&&l!==void 0&&r.length===0&&(l==="init"||l==="scaffold"||oe.has(l))}function Xa(e,a){return a==="init"||a==="scaffold"?e==="extension"?Q:Ge:oe.get(a)??[]}function lt(e){let a=ie(e);if(a.length===0)return S([]);let[t,l,...r]=a.split(/\s+/);if((t==="extension"||t==="package"||t==="packages")&&l!==void 0&&r.length===0)return S((t==="package"||t==="packages")&&l==="upgrade"?Z:Xa(t,l));let n=ne.get(a)??[];return S(n)}function st(e,a=!0){let l=L(e).flatMap(n=>[n.short,n.flag,...n.aliases??[]]).filter(n=>!!n),r=a?[...l,...E.flatMap(n=>[n.short,n.flag,...n.aliases??[]]).filter(n=>!!n)]:l;return y(r).join(" ")}export{y as a,X as b,ge as c,v as d,ja as e,de as f,qa as g,x as h,w as i,b as j,$ as k,me as l,k as m,Ba as n,Ya as o,L as p,Qa as q,E as r,Za as s,R as t,ve as u,Te as v,Ae as w,Ce as x,ye as y,ke as z,be as A,xe as B,Se as C,Ne as D,Oe as E,we as F,Le as G,Ee as H,W as I,Re as J,Fe as K,J as L,m as M,Q as N,j as O,Ge as P,Ie as Q,Pe as R,Me as S,De as T,$e as U,Ue as V,Xe as W,ze as X,je as Y,qe as Z,Be as _,q as $,Ye as aa,He as ba,Z as ca,et as da,Ve as ea,Ke as fa,We as ga,Je as ha,Qe as ia,Ze as ja,ea as ka,aa as la,ta as ma,la as na,ae as oa,sa as pa,ra as qa,na as ra,oa as sa,ia as ta,ga as ua,fa as va,ca as wa,pa as xa,da as ya,ma as za,te as Aa,B as Ba,ua as Ca,_a as Da,ha as Ea,va as Fa,Ta as Ga,Aa as Ha,Ca as Ia,Y as Ja,ya as Ka,ka as La,H as Ma,ba as Na,xa as Oa,Sa as Pa,Na as Qa,Oa as Ra,u as Sa,wa as Ta,La as Ua,Ea as Va,Ra as Wa,at as Xa,$a as Ya,Ua as Za,tt as _a,lt as $a,st as ab};
2
+ //# sourceMappingURL=chunk-YHWHX6YY.js.map
@@ -1,4 +1,4 @@
1
- import{Bb as ke,Da as te,Ia as at,Ka as fe,La as Zt,Ma as z,Na as Ae,Ra as ve,Ta as ct,Wa as er,Y as Ie,Z as v,da as xe,db as tr,ea as Qt,eb as Ce,fa as Jt,fb as C,gb as Re,kb as dt,l as ce,lb as re,o as q,oa as de,pb as lt,qa as ot,sb as ut,ta as it,tb as ft,ua as le,ub as mt,va as st,wa as ue,xb as rr,yb as B,zb as G}from"./chunk-57XY346D.js";import{H as F,N as H,P as tt,Q as rt,R as se,S as Kt,T as Se,Ta as Te,W as w,Y as ae,Z as ee,_ as b,a as Ze,aa as Xt,r as P,t as Z,u as T,v as S,x as be}from"./chunk-UYBA57GY.js";import{S as et,Y as u,Z as f,ba as nt}from"./chunk-LMKG3DFE.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]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function Ln(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new f(`${t} must be a non-negative number`,u.USAGE);return Math.floor(r)}(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]="7775a1f2-5167-5853-a2c5-a44d46f8e80e")}catch{}})();var Mn=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,Nn=/\bnpm_[A-Za-z0-9]{36}\b/,On=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,Pn=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,$n=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,nr=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,Fn=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],ht=new Map(Fn.map(e=>[e.action,e]));function zn(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let r=0;for(let n of t.values()){let o=n/e.length;r-=o*Math.log2(o)}return r}function pt(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>pt(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>pt(o,`${t}.${n}`,r)))}function or(e){let t=[];for(let r of pt(e)){Mn.test(r.value)&&t.push({rule:"github_token",path:r.path}),Nn.test(r.value)&&t.push({rule:"npm_token",path:r.path}),On.test(r.value)&&t.push({rule:"slack_token",path:r.path}),Pn.test(r.value)&&t.push({rule:"private_key",path:r.path}),$n.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),nr.lastIndex=0;for(let n of r.value.matchAll(nr)){let o=n[1];if(zn(o)>=3.5){t.push({rule:"high_entropy_assignment",path:r.path});break}}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function Un(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new f("Mutation author is required by workspace policy.",u.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let r;try{r=or(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new f(`Mutation blocked by secret guard (${n}). No detected value was logged.`,u.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function Vn(e){return ht.has(e.trim().toLowerCase())}function jn(){return[...ht.keys()].sort((e,t)=>e.localeCompare(t))}function mc(e){return ht.get(e.trim().toLowerCase())}(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]="3ad30a32-0f83-5473-b0a3-349e271d8378")}catch{}})();function Hn(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function hc(e){return Hn(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function me(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(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]="dff9b113-2b29-5154-afbf-f191f2f556a6")}catch{}})();var qn=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function De(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function he(e){return[...new Set(De(e).match(/[\p{L}\p{N}]+/gu)??[])]}function pe(e){let t=De(e);return{normalized:t,tokens:he(t),issueCodes:[...new Set(t.match(qn)?.map(r=>r.toLowerCase())??[])]}}function Le(e,t){return Me(pe(e),pe(t))}function Me(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:me(e.tokens,t.tokens),reason:"title_token_jaccard"}}import Bn from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="376bb9d2-e202-57e7-86c8-d70a7d3fa7ab")}catch{}})();function Ne(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Gn(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,o)=>o.time-n.time)[0]?.value??e.updated_at}function ir(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=Ne(t.in_progress_status),i=[];for(let s of e){if(Ne(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=Gn(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function Yn(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>Ne(String(o.status))===Ne(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await ue(Bn.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),ir(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as Wn,readFile as Kn}from"node:fs/promises";import sr from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function Xn(e){let t=e.trim();if(!t)throw new f("--rollback requires a non-empty checkpoint ID",u.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new f("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",u.USAGE);return t}function Qn(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function ar(e,t){return sr.join(e,"checkpoints",t)}function cr(e,t,r){return sr.join(ar(e,t),`${r}.json`)}async function Jn(e,t,r,n){let o=ar(e,t);await Wn(o,{recursive:!0});let i=cr(e,t,r);return await S(i,`${JSON.stringify(n,null,2)}
1
+ import{Bb as ke,Da as te,Ia as at,Ka as fe,La as Zt,Ma as z,Na as Ae,Ra as ve,Ta as ct,Wa as er,Y as Ie,Z as v,da as xe,db as tr,ea as Qt,eb as Ce,fa as Jt,fb as C,gb as Re,kb as dt,l as ce,lb as re,o as q,oa as de,pb as lt,qa as ot,sb as ut,ta as it,tb as ft,ua as le,ub as mt,va as st,wa as ue,xb as rr,yb as B,zb as G}from"./chunk-XDPYBQCF.js";import{H as F,N as H,P as tt,Q as rt,R as se,S as Kt,T as Se,Ta as Te,W as w,Y as ae,Z as ee,_ as b,a as Ze,aa as Xt,r as P,t as Z,u as T,v as S,x as be}from"./chunk-AD6ULRAF.js";import{S as et,Y as u,Z as f,ba as nt}from"./chunk-Z2USIBR2.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]="b9581c92-5e8a-589d-9681-d4d014e6902b")}catch{}})();function Ln(e,t="--limit"){if(e===void 0)return;let r=Number(e);if(!Number.isFinite(r)||r<0)throw new f(`${t} must be a non-negative number`,u.USAGE);return Math.floor(r)}(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]="7775a1f2-5167-5853-a2c5-a44d46f8e80e")}catch{}})();var Mn=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,Nn=/\bnpm_[A-Za-z0-9]{36}\b/,On=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,Pn=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,$n=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,nr=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,Fn=[{action:"append",history_scope:"item"},{action:"claim",history_scope:"item"},{action:"close",history_scope:"item"},{action:"close-many",history_scope:"item"},{action:"close-task",history_scope:"item"},{action:"comments",history_scope:"conditional"},{action:"config",history_scope:"conditional"},{action:"copy",history_scope:"item"},{action:"create",history_scope:"item"},{action:"delete",history_scope:"item"},{action:"deps",history_scope:"conditional"},{action:"discover",history_scope:"item"},{action:"docs",history_scope:"conditional"},{action:"files",history_scope:"conditional"},{action:"focus",history_scope:"conditional"},{action:"gc",history_scope:"conditional"},{action:"history-compact",history_scope:"history"},{action:"history-author-acknowledge",history_scope:"workspace"},{action:"history-redact",history_scope:"history"},{action:"history-repair",history_scope:"history"},{action:"init",history_scope:"workspace"},{action:"install",history_scope:"conditional"},{action:"learnings",history_scope:"conditional"},{action:"notes",history_scope:"conditional"},{action:"package",history_scope:"conditional"},{action:"pause-task",history_scope:"item"},{action:"plan",history_scope:"conditional"},{action:"profile",history_scope:"conditional"},{action:"release",history_scope:"item"},{action:"restore",history_scope:"item"},{action:"schema",history_scope:"conditional"},{action:"start-task",history_scope:"item"},{action:"templates",history_scope:"conditional"},{action:"test",history_scope:"conditional"},{action:"test-all",history_scope:"conditional"},{action:"update",history_scope:"item"},{action:"update-many",history_scope:"item"},{action:"upgrade",history_scope:"conditional"}],ht=new Map(Fn.map(e=>[e.action,e]));function zn(e){let t=new Map;for(let n of e)t.set(n,(t.get(n)??0)+1);let r=0;for(let n of t.values()){let o=n/e.length;r-=o*Math.log2(o)}return r}function pt(e,t="$",r=new WeakSet){return typeof e=="string"?[{path:t,value:e}]:typeof e!="object"||e===null?[]:r.has(e)?[]:(r.add(e),Array.isArray(e)?e.flatMap((n,o)=>pt(n,`${t}[${o}]`,r)):Object.entries(e).flatMap(([n,o])=>pt(o,`${t}.${n}`,r)))}function or(e){let t=[];for(let r of pt(e)){Mn.test(r.value)&&t.push({rule:"github_token",path:r.path}),Nn.test(r.value)&&t.push({rule:"npm_token",path:r.path}),On.test(r.value)&&t.push({rule:"slack_token",path:r.path}),Pn.test(r.value)&&t.push({rule:"private_key",path:r.path}),$n.test(r.value)&&t.push({rule:"aws_access_key",path:r.path}),nr.lastIndex=0;for(let n of r.value.matchAll(nr)){let o=n[1];if(zn(o)>=3.5){t.push({rule:"high_entropy_assignment",path:r.path});break}}}return t.filter((r,n,o)=>o.findIndex(i=>i.rule===r.rule&&i.path===r.path)===n)}function Un(e){let t=e.author.trim()||"unknown";if(e.settings.require_attributed_author&&t.toLowerCase()==="unknown")throw new f("Mutation author is required by workspace policy.",u.USAGE,{code:"mutation_author_required",required:"Pass --author <id>, set PM_AUTHOR, or configure author_default.",nextSteps:["Retry with --author <stable-agent-id>.","Set PM_AUTHOR for this agent session."]});if(e.settings.secret_guard==="off")return{author:t,findings:[],warnings:[],override_applied:!1};let r;try{r=or(e.payload)}catch{return{author:t,findings:[],warnings:["secret_guard_scan_failed_open"],override_applied:!1}}if(r.length===0)return{author:t,findings:r,warnings:[],override_applied:!1};let n=[...new Set(r.map(o=>o.rule))].sort().join(",");if(e.settings.secret_guard==="block"&&e.force!==!0)throw new f(`Mutation blocked by secret guard (${n}). No detected value was logged.`,u.CONFLICT,{code:"mutation_secret_guard_blocked",required:"Remove the credential-shaped content or retry with --force after explicit review.",nextSteps:["Replace the value with a secret-manager reference.","Use pm history-redact if equivalent content already entered history."],recovery:{recovery_mode:"compact",attempted_command:"pm <mutation> [REDACTED]",normalized_args:["[REDACTED]"],suggested_retry:"Remove credential-shaped content, then retry the mutation."}});return{author:t,findings:r,warnings:[`secret_guard_detected:${r.length}:rules=${n}`,...e.settings.secret_guard==="block"&&e.force===!0?["secret_guard_force_override"]:[]],override_applied:e.settings.secret_guard==="block"&&e.force===!0}}function Vn(e){return ht.has(e.trim().toLowerCase())}function jn(){return[...ht.keys()].sort((e,t)=>e.localeCompare(t))}function mc(e){return ht.get(e.trim().toLowerCase())}(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]="3ad30a32-0f83-5473-b0a3-349e271d8378")}catch{}})();function Hn(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function hc(e){return Hn(e).split(/[^a-z0-9]+/).filter(t=>t.length>0)}function me(e,t){if(e.length===0&&t.length===0)return 1;if(e.length===0||t.length===0)return 0;let r=new Set(e),n=new Set(t),o=0;for(let s of r)n.has(s)&&(o+=1);let i=new Set([...r,...n]).size;return o/i}(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]="dff9b113-2b29-5154-afbf-f191f2f556a6")}catch{}})();var qn=/\b[a-z][a-z0-9]*-\d+(?:-[a-z0-9]+)*\b/giu;function De(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function he(e){return[...new Set(De(e).match(/[\p{L}\p{N}]+/gu)??[])]}function pe(e){let t=De(e);return{normalized:t,tokens:he(t),issueCodes:[...new Set(t.match(qn)?.map(r=>r.toLowerCase())??[])]}}function Le(e,t){return Me(pe(e),pe(t))}function Me(e,t){if(e.normalized===t.normalized)return{score:1,reason:"exact_title"};let r=new Set(e.issueCodes);return t.issueCodes.some(n=>r.has(n))?{score:.99,reason:"issue_code"}:{score:me(e.tokens,t.tokens),reason:"title_token_jaccard"}}import Bn from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="376bb9d2-e202-57e7-86c8-d70a7d3fa7ab")}catch{}})();function Ne(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Gn(e,t){return[e.updated_at,t].map(n=>({value:n,time:Date.parse(n??"")})).filter(n=>typeof n.value=="string"&&Number.isFinite(n.time)).sort((n,o)=>o.time-n.time)[0]?.value??e.updated_at}function ir(e,t){let r=Math.max(1,Math.trunc(t.threshold_hours)),n=(t.now??new Date).getTime(),o=Ne(t.in_progress_status),i=[];for(let s of e){if(Ne(String(s.status))!==o||(s.assignee?.trim().length??0)>0)continue;let a=Gn(s,t.last_history_activity?.(s)),c=Date.parse(a);if(!Number.isFinite(c))continue;let d=Math.max(0,Math.floor((n-c)/36e5));d>=r&&i.push({id:s.id,last_activity_at:a,age_hours:d})}return i.sort((s,a)=>a.age_hours-s.age_hours||s.id.localeCompare(a.id)),{threshold_hours:r,count:i.length,items:i,remediation:"Claim active work with `pm claim <id>` or return abandoned work to open with `pm update <id> --status open`."}}async function Yn(e,t,r){let n=new Map;return await Promise.all(t.filter(o=>Ne(String(o.status))===Ne(r.in_progress_status)&&(o.assignee?.trim().length??0)===0).map(async o=>{let i;try{i=await ue(Bn.join(e,"history",`${o.id}.jsonl`),o.id)}catch{return}let s=i.map(a=>a.ts).filter(a=>Number.isFinite(Date.parse(a))).sort((a,c)=>Date.parse(c)-Date.parse(a))[0];s&&n.set(o.id,s)})),ir(t,{...r,last_history_activity:o=>n.get(o.id)})}import{mkdir as Wn,readFile as Kn}from"node:fs/promises";import sr from"node:path";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="71a8cd89-54fc-5f8a-b93b-9e4a79bb34b6")}catch{}})();function Xn(e){let t=e.trim();if(!t)throw new f("--rollback requires a non-empty checkpoint ID",u.USAGE);if(!/^[a-zA-Z0-9._-]+$/.test(t))throw new f("--rollback checkpoint ID must match [a-zA-Z0-9._-]+",u.USAGE);return t}function Qn(e,t){let r=t.replace(/[-:.TZ]/g,"").slice(0,14),n=Math.random().toString(36).slice(2,8);return`${e}-${r}-${n}`}function ar(e,t){return sr.join(e,"checkpoints",t)}function cr(e,t,r){return sr.join(ar(e,t),`${r}.json`)}async function Jn(e,t,r,n){let o=ar(e,t);await Wn(o,{recursive:!0});let i=cr(e,t,r);return await S(i,`${JSON.stringify(n,null,2)}
2
2
  `),i}function Zn(e,t){if(!Array.isArray(e.items))throw new f(`Checkpoint ${t} is missing items`,u.GENERIC_FAILURE);return e.items.map(r=>{if(!r||typeof r!="object")throw new f(`Checkpoint ${t} contains an invalid item entry`,u.GENERIC_FAILURE);let n=r;if(typeof n.id!="string"||n.id.trim().length===0)throw new f(`Checkpoint ${t} contains an item entry without ID`,u.GENERIC_FAILURE);if(typeof n.target_updated_at!="string"||n.target_updated_at.trim().length===0)throw new f(`Checkpoint ${t} contains an item entry without target_updated_at`,u.GENERIC_FAILURE);return{id:n.id.trim(),target_updated_at:n.target_updated_at.trim()}})}async function eo(e,t,r,n){let o=Xn(r),i=cr(e,t,o);if(!await P(i))throw new f(`Checkpoint ${o} not found`,u.NOT_FOUND);let s=await Kn(i,"utf8"),a;try{a=JSON.parse(s)}catch(l){throw new f(`Checkpoint ${o} contains invalid JSON: ${b(l)}`,u.GENERIC_FAILURE)}if(!a||typeof a!="object")throw new f(`Checkpoint ${o} is invalid`,u.GENERIC_FAILURE);let c=a;if(c.schema_version!==n)throw new f(`Checkpoint ${o} has unsupported schema version`,u.GENERIC_FAILURE);let d=Zn(c,o);return{record:c,items:d,path:i,id:typeof c.id=="string"?c.id:o,created_at:typeof c.created_at=="string"?c.created_at:v(),author:typeof c.author=="string"?c.author:"unknown"}}async function to(e,t){let r=[],n=[];for(let o of e)try{let i=await t(o.id,o.target_updated_at);r.push({id:o.id,status:"restored",changed_fields:i.changed_fields,warnings:i.warnings}),n.push(o.id)}catch(i){r.push({id:o.id,status:"failed",error:b(i)})}return{rows:r,restored_ids:n,failed_count:r.filter(o=>o.status==="failed").length}}(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]="ab276268-7a98-5f97-b3f5-300dfd1b5ed5")}catch{}})();function U(e){if(typeof e!="string")return null;let t=e.trim().toLowerCase();return t.length>0?t:null}function Dc(e,t){let r=U(t);return!e||!r?null:[...e.assurance_providers??[]].reverse().find(n=>U(n.definition.id)===r)??null}function ro(e,t){let r=U(t);return!e||!r?null:[...e.search_providers].reverse().find(o=>(U(o.runtime_definition?.name)??U(o.definition?.name))===r)??null}function no(e,t){let r=U(t);return!e||!r?null:[...e.vector_store_adapters].reverse().find(o=>(U(o.runtime_definition?.name)??U(o.definition?.name))===r)??null}(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]="2252cfb9-37ea-57f1-b7ea-2b0c0f87ecb2")}catch{}})();var $="-",dr=new Set(["actual_result","body","cmd","command","customer_impact","description","environment","expected_result","impact","location","message","note","outcome","repro_steps","resolution","text","title","unblock_note","value","why_now"]);function lr(e){let t=e.trim();if(t==="")return[];let n=(co(t)??t.split(",")).map(o=>o.trim()).filter(Boolean).map(o=>o.toLowerCase());return Array.from(new Set(n)).sort((o,i)=>o.localeCompare(i))}function ur(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let r of e)if(typeof r=="string")for(let n of lr(r))t.push(n);return Array.from(new Set(t)).sort((r,n)=>r.localeCompare(n))}function fr(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function oo(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function io(e,t,r){let n=e.map(s=>s.trim()).filter(Boolean);for(let s of t??[]){let a=s.trim();if(a.includes(";"))throw new f('Acceptance criteria added with --add-ac cannot contain ";" because semicolons delimit stored criteria',u.USAGE,{code:"acceptance_criteria_semicolon_forbidden",required:"Pass one semicolon-free criterion per --add-ac value",why:"A semicolon inside one criterion would be re-read as multiple criteria",nextSteps:["Split the text into repeated --add-ac values, or replace the semicolon with punctuation that is not the storage delimiter"]});a.length>0&&!n.includes(a)&&n.push(a)}let o=[],i=n;for(let s of r??[]){let a=s.trim();if(a.length!==0){if(!i.includes(a)){o.push(a);continue}i=i.filter(c=>c!==a)}}return{criteria:i,unmatchedRemovals:o}}function so(e,t){let r=fr(e);if(!t||t.length===0)return Array.from(new Set(r)).sort((o,i)=>o.localeCompare(i));let n=new Set(r);for(let o of ur(t))n.add(o);return Array.from(n).sort((o,i)=>o.localeCompare(i))}function ao(e,t){let r=Array.from(new Set(fr(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return r;let n=new Set(ur(t));return n.size===0?r:r.filter(o=>!n.has(o))}function co(e){if(!e.startsWith("["))return null;let t;try{t=JSON.parse(e)}catch{return null}return t.map(n=>typeof n=="string"||typeof n=="number"||typeof n=="boolean"?String(n):"").filter(n=>n.length>0)}function _t(e){return e.replace(/\r\n/g,`
3
3
  `)}function mr(e){let t=_t(e).trim();if(!t.startsWith("```"))return e;let r=t.split(`
4
4
  `);return r.length<2||r.at(-1)?.trim()!=="```"?e:r.slice(1,-1).join(`
@@ -15,5 +15,5 @@ ${i}`;continue}return null}return r}function ho(e,t){let r=mr(e).trim();if(!r)th
15
15
  `:"";for(let o=0;;o+=1)try{await S(Xe(e),n);return}catch(i){let s=tn[o];if(s===void 0||!yn(i))throw i;await gn(s)}}function yn(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return t==="EACCES"||t==="EBUSY"||t==="EPERM"}function gn(e){return new Promise(t=>{setTimeout(t,e)})}function ya(e){let t=JSON.stringify([e.endpoint,e.enqueued_at,e.payload]);return Vt.createHash("sha256").update(t).digest("hex").slice(0,32)}function wn(e){let t=[];for(let r of e.split(`
16
16
  `)){let n=r.trim();if(n.length!==0)try{let o=JSON.parse(n);o&&typeof o=="object"&&typeof o.endpoint=="string"&&o.endpoint.trim().length>0&&"payload"in o&&typeof o.attempts=="number"&&Number.isFinite(o.attempts)&&((typeof o.id!="string"||o.id.length===0)&&(o.id=ya(o)),t.push(o))}catch{}}return t}function ga(e,t){if(typeof e.enqueued_at!="string"||e.enqueued_at.trim().length===0)return!1;let r=Date.parse(e.enqueued_at);return Number.isNaN(r)?!1:r<t}function En(e,t){let r=_n(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>Zr||ga(i,r)||i.attempts>=en){o+=1;continue}n.push(i)}if(n.length>Gr){let i=n.length-Gr;return o+=i,{entries:n.slice(i),prunedCount:o}}return{entries:n,prunedCount:o}}async function wa(e,t){let r=t.map(o=>JSON.stringify(o)).join(`
17
17
  `),n=r.length>0?`${r}
18
- `:"";for(let o=0;;o+=1)try{await S(Ht(e),n);return}catch(i){let s=tn[o];if(s===void 0||!yn(i))throw i;await gn(s)}}async function Qr(e,t,r,n){return Bt(async()=>{let o=await T(Ht(e)),i=o===null?[]:wn(o),s=[];for(let c of i){if(r.has(c.id))continue;let d=n.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=En(s,t);return await wa(e,a),a.length})}async function Ea(e,t){let r=await T(Ht(e));if(r===null||r.trim().length===0){await N(e,{pending_otel_spans:0});return}let n=wn(r),{entries:o,prunedCount:i}=En(n,t),s=o.filter(_=>hn(_.next_attempt_after)).slice(0,Us);if(s.length===0){let _=i>0?await Qr(e,t,new Set,new Map):o.length;await N(e,{pending_otel_spans:_});return}let a=v(),c=new Set,d=new Map,l=0,m;await Promise.all(s.map(async _=>{try{let y=await fn(_.endpoint,{"content-type":"application/json"},JSON.stringify(_.payload));if(y<200||y>=300)throw new Error(`local_otel_export_http_${y}`);c.add(_.id),l+=1}catch(y){m=y instanceof Error?Ut(y.message,"redacted"):"local_otel_export_failed";let g=_.attempts+1;d.set(_.id,{attempts:g,next_attempt_after:pn(g)})}}));let h=await Qr(e,t,c,d),p={pending_otel_spans:h,last_otel_attempt_at:a};l>0&&(p.last_otel_success_at=a),m!==void 0?(p.last_otel_failure_at=a,p.last_otel_failure_error=m):h===0&&(p.last_otel_failure_at=void 0,p.last_otel_failure_error=void 0),await N(e,p)}async function ba(e,t,r){try{await xa(e,t,r)}catch{}try{await Ea(e,r)}catch{}}async function Sa(e,t=Ws){try{let r=sa(e),n=await Ns(r,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(n.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=k.join(r,i.name);(await Jr(s)).mtimeMs<o&&await jt(s,{force:!0})}))}catch{}}async function Bt(e){let t=Kr.catch(()=>{}).then(e);return Kr=t.catch(()=>{}),t}async function Gt(e){let t=await T(Xe(e));return t===null||t.trim().length===0?[]:mn(t)}async function Ta(e,t,r){return Bt(async()=>{let n=await Gt(e),{entries:o}=qt(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await Ke(e,i),i})}async function Ia(e,t,r,n){return Bt(async()=>{let o=await Gt(e),{entries:i}=qt(o,n),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:r,next_attempt_after:pn(c)}});return await Ke(e,s),s})}async function xa(e,t,r){await Sa(e);let n=t.trim();if(n.length===0)return;let o=await T(Xe(e));if(o===null||o.trim().length===0){await N(e,{endpoint:n,queue_entries:0});return}let i=mn(o);if(i.length===0){await N(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=qt(i,r);if(s.length===0){await Ke(e,[]),await N(e,{endpoint:n,queue_entries:0});return}let c=s.filter(p=>ha(p)).slice(0,js);if(c.length===0){a>0&&await Ke(e,s),await N(e,{endpoint:n,queue_entries:s.length});return}let d=new Set(c.map(p=>p.event.event_id)),l=v(),m={"content-type":"application/json"},h=process.env.PM_TELEMETRY_INGEST_KEY?.trim();h&&(m["x-pm-telemetry-key"]=h);try{let p=await fn(n,m,JSON.stringify({schema_version:Vs,events:c.map(_=>_.event)}));if(p<200||p>=300)throw new Error(`telemetry_flush_http_${p}`)}catch(p){let _=await Ia(e,d,l,r),y=p instanceof Error?Ut(p.message,"redacted"):"telemetry_flush_failed";await N(e,{endpoint:n,queue_entries:_.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:y});return}try{let p=await Ta(e,d,r);await N(e,{endpoint:n,queue_entries:p.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(p){let _=p instanceof Error?Ut(p.message,"redacted"):"telemetry_flush_failed",y=await Gt(e).catch(()=>s);await N(e,{endpoint:n,queue_entries:y.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:_})}}async function Aa(e){let t=on(e);await zt(k.dirname(t),{recursive:!0});try{return await zt(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await Jr(t);return Date.now()-r.mtimeMs<Ks?!1:(await jt(t,{recursive:!0,force:!0}),await zt(t),!0)}catch{return!1}}function va(e){try{Ms(e,{recursive:!0,force:!0})}catch{}}function Ca(e){va(aa(e))}async function Ra(e,t,r){let n=await Aa(e);if(Ca(e),!!n)try{await ba(e,t,r)}finally{try{await jt(on(e),{recursive:!0,force:!0})}catch{}}}async function _u(e=tt(process.cwd())){if(!ma())try{if(!(await C(e)).telemetry.enabled)return;let{endpoint:r,retentionDays:n}=await pa(e);await Ra(e,r,n)}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]="4be36c51-a9fc-507d-8f13-d764b5668ab9")}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]="13c02696-29a7-598e-888a-3502fd88bfbe")}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]="33a43890-abcf-58fc-bf9d-bf2619d4cf35")}catch{}})();var ka=3,bn=20,Da=.8,La=100,Sn=1e3,Tn=1e6;function Dh(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`,`likely_duplicate_recovery:${e.recovery.action}:${e.recovery.item_id}`]}async function Ma(e,t){let r=e.items[0],n=H(t.cwd??process.cwd(),t.pmRoot),o=Te((await C(n)).schema);return ot(r.status,o)?{action:"reopen",item_id:r.id,command:`pm item reopen ${r.id} "<recurrence reason>"`,args:["item","reopen",r.id,"<recurrence reason>"]}:{action:"reuse",item_id:r.id,command:`pm get ${r.id} --full`,args:["get",r.id,"--full"]}}function In(e){let t=e.limit??ka,r=e.threshold??Da;if(!Number.isSafeInteger(t)||t<0||t>bn)throw new f(`Similarity limit must be an integer from 0 to ${bn}.`,u.USAGE);if(!Number.isFinite(r)||r<0||r>1)throw new f("Similarity threshold must be a number from 0 to 1.",u.USAGE);return{limit:t,threshold:r}}function Na(e){let t=e.limit??La;if(!Number.isSafeInteger(t)||t<0||t>Sn)throw new f(`Duplicate cluster limit must be an integer from 0 to ${Sn}.`,u.USAGE);let r=e.since===void 0?void 0:new Date(e.since);if(r&&Number.isNaN(r.getTime()))throw new f("Duplicate cluster --since must be a valid ISO timestamp.",u.USAGE);return{limit:t,since:r}}async function Oa(e,t){let r=H(e.cwd??process.cwd(),e.pmRoot),n=await C(r),o=F(n),i=e.statuses?.map(m=>m.trim().toLowerCase()).filter(Boolean);if(e.statuses!==void 0&&i?.length===0)throw new f("Duplicate cluster statuses must include at least one lifecycle status or all.",u.USAGE);let s=Te(n.schema),a=i?.map(m=>{if(m==="all")return m;let h=de(m,s);if(!h)throw new f(`Unknown duplicate-cluster status "${m}". Allowed: all, ${s.definitions.map(p=>p.id).join(", ")}.`,u.USAGE);return h}),c=a?.includes("all")===!0;if(c&&a?.some(m=>m!=="all"))throw new f('The "all" status cannot be combined with other statuses.',u.USAGE);let d=c?void 0:a,l=d?new Set(d):void 0;return{items:(await ke(r,n.item_format,o.type_to_folder,void 0,n.schema)).filter(m=>(!l||l.has(m.status))&&(!t||new Date(m.created_at).getTime()>=t.getTime())).sort((m,h)=>m.id.localeCompare(h.id)).map(m=>({item:m,prepared:pe(m.title)})),statuses:d}}function xn(e,t=Tn){let r=new Set,n=[new Map,new Map,new Map];for(let[o,i]of e.entries()){let s=[[i.prepared.normalized],i.prepared.issueCodes,i.prepared.tokens];for(let[a,c]of s.entries())for(let d of c){let l=n[a].get(d)??[];for(let m of l)r.add(`${m}:${o}`);if(r.size>t)throw new f(`Duplicate sweep exceeded ${Tn} candidate pairs; narrow it with statuses or since.`,u.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the batch duplicate query until its deterministic candidate set fits the disclosed safety bound."});l.push(o),n[a].set(d,l)}}return r}var Lh={buildDuplicateClusters:vn,collectDuplicateCandidatePairs:xn,createDuplicateUnionFind:An};function An(e){let t=Array.from({length:e},(n,o)=>o);return{parent:t,findRoot:n=>{let o=n;for(;t[o]!==o;)o=t[o];for(;t[n]!==n;){let i=t[n];t[n]=o,n=i}return o}}}function Pa(e,t,r,n){let o=[];for(let i of t){let[s,a]=i.split(":").map(m=>Number.parseInt(m,10)),c=Me(e[s].prepared,e[a].prepared);if(c.score<r)continue;let d=n.findRoot(s),l=n.findRoot(a);d!==l&&(n.parent[l]=d),o.push({left_id:e[s].item.id,right_id:e[a].item.id,...c})}return o}function vn(e,t,r,n){let o=new Map;for(let i of e.keys()){let s=r.findRoot(i),a=o.get(s)??[];a.push(i),o.set(s,a)}return[...o.values()].filter(i=>i.length>1).map(i=>{let s=new Set(i.map(c=>e[c].item.id)),a=t.filter(c=>s.has(c.left_id)&&s.has(c.right_id)).sort((c,d)=>d.score-c.score||c.left_id.localeCompare(d.left_id)||c.right_id.localeCompare(d.right_id));return{id:e[i[0]].item.id,items:i.map(c=>{let d=e[c].item;return{id:d.id,title:d.title,status:d.status,type:d.type}}),matches:a,max_score:a[0]?.score??0}}).sort((i,s)=>s.max_score-i.max_score||i.id.localeCompare(s.id)).slice(0,n)}function $a(e,t,r,n,o){return t.filter(i=>!r.has(i.id)).map(i=>({id:i.id,title:i.title,status:i.status,type:i.type,...Le(e,i.title)})).filter(i=>i.score>=n).sort((i,s)=>s.score-i.score||i.id.localeCompare(s.id)).slice(0,o)}async function Fa(e,t={}){let r=e.title.trim();if(r.length===0)throw new f("Similarity candidate title must not be empty.",u.USAGE);let{limit:n,threshold:o}=In(t),i=H(t.cwd??process.cwd(),t.pmRoot),s=await C(i),a=F(s),c=await ft(i,Object.values(a.type_to_folder)),d=he(r),l=c&&d.length>0?await lt({pmRoot:i,expectedSourceCursor:c.source_cursor,query:d.map(p=>`"${p.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(n*10,50)}):null,m=l===null?await ke(i,s.item_format,a.type_to_folder,void 0,s.schema):l.items,h=$a(r,m,new Set(e.excludeIds??[]),o,n);return{items:h,count:h.length,threshold:o,source:l?"persistent_index":"metadata_fallback"}}async function Mh(e={}){let{threshold:t}=In({...e,limit:void 0}),{limit:r,since:n}=Na(e),{items:o,statuses:i}=await Oa(e,n),s=xn(o),a=An(o.length),c=Pa(o,s,t,a),d=vn(o,c,a,r);return{clusters:d,count:d.length,threshold:t,source:"metadata_scan",filters:{statuses:i??null,since:e.since??null},cost:{item_count:o.length,candidate_pairs:s.size,scored_pairs:s.size}}}async function Nh(e,t){if(t.mode==="off")return;let r=await Fa(e,t);if(r.count===0)return;let n=await Ma(r,t),o=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!o){let i=r.items.map(a=>`${a.id} (${a.status}): ${a.title}`).join("; "),s=n.action==="reopen"?"Reopen the canonical item":"Reuse the canonical item";throw new f(`Likely duplicate item(s) found: ${i}. ${s} or pass --allow-duplicate with explicit intent.`,u.CONFLICT,{code:"likely_duplicate",required:`${s}, or explicitly acknowledge the duplicate with --allow-duplicate.`,recovery:{suggested_flags:["--allow-duplicate"],suggested_retry:n.command,suggested_retry_args:n.args}})}return{mode:t.mode,bypassed:o,result:r,recovery: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]="47c087c2-124a-58b7-a5c9-09403235f4a2")}catch{}})();function za(e,t){let r=-1;return e.forEach((n,o)=>{let i=Date.parse(n.ts);if(!Number.isFinite(i))throw new f(`History for this item contains invalid timestamp at entry ${o+1}.`,u.GENERIC_FAILURE);i<=t&&(r=o)}),r}function Ua(e){let t=e[0]?.ts??null,r=e.at(-1)?.ts??null,n={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:t,last_timestamp:r}};return r!==null&&(n.examples=["1",String(e.length),r],n.valid_range.first_version=1,n.valid_range.last_version=e.length),{guidance:n,lastTimestamp:r}}function Va(e,t){let r={};if(t instanceof Error&&t.message.trim().length>0&&(r.reason=t.message.trim()),typeof t!="object"||t===null)return r;let n=t;if(typeof n.index=="number"&&Number.isInteger(n.index)&&n.index>=0&&(r.patchIndex=n.index),typeof n.operation=="object"&&n.operation!==null){let o=n.operation;Object.assign(r,Object.fromEntries(["op","path","from"].flatMap(i=>{let s=o[i];return typeof s=="string"?[[i,s]]:[]})))}if(r.patchIndex!==void 0){let o=e[r.patchIndex];o&&(r.op??=o.op,r.path??=o.path,r.from??=o.from)}return r}function Uh(e,t,r={}){let n=e.trim(),o=r.errorSubject??"history",i=o==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=Ua(t);if(!n)throw new f(`Missing ${o} target. Use a timestamp or version number.`,u.USAGE,s);if(/^\d+$/.test(n)){let l=Number(n);if(!Number.isSafeInteger(l)||l<1||l>t.length)throw new f(`${i} version must be between 1 and ${t.length} for this item.`,u.USAGE,s);return{kind:"version",raw:n,historyIndex:l-1}}let c=Date.parse(n);if(!Number.isFinite(c))throw new f(`Invalid ${o} target "${e}". Use a positive version number or ISO timestamp.`,u.USAGE,s);let d=za(t,c);if(d<0||r.allowFutureTimestamp!==!0&&c>Date.parse(a))throw new f(o==="restore"?`No history entries exist at or before timestamp ${n}.`:`No history entry exists at timestamp ${n}.`,u.USAGE,s);return{kind:"timestamp",raw:n,historyIndex:d}}function Qe(e,t,r,n){let o=ve(e,t);if(o.ok)return o.document;let i=Va(t,o.error),s=[`history_op=${n}`,i.patchIndex===void 0?null:`patch_index=${i.patchIndex}`,i.op?`op=${i.op}`:null,i.path?`path=${i.path}`:null,i.from?`from=${i.from}`:null].filter(a=>a!==null);throw new f(`Failed to apply history patch at entry ${r} (${s.join(", ")}). ${i.reason??String(o.error)}`,u.GENERIC_FAILURE)}function Vh(e,t){let r=structuredClone(fe);for(let n=0;n<=t;n+=1){let o=e[n];if(!o)throw new f(`History target entry ${n+1} does not exist.`,u.USAGE);if(z(r)!==o.before_hash)throw new f(`History hash mismatch before replay at entry ${n+1}.`,u.GENERIC_FAILURE);if(r=Qe(r,o.patch,n+1,o.op),z(r)!==o.after_hash)throw new f(`History hash mismatch after replay at entry ${n+1}.`,u.GENERIC_FAILURE)}return r}function jh(e,t){if(Object.keys(e.metadata).length>0)return e;throw new f(`History target ${t.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,u.USAGE)}import Yt from"node:fs/promises";import ja from"node:fs/promises";(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]="a2ec9f1a-aae2-59d5-8c9a-7acd8bf5a7a2")}catch{}})();function Ha(e){if(!e.itemDocument)return[];let t=e.itemDocument.metadata?.assignee?.trim();if(!t||t===e.author||e.force)return[];let r=tr(e.settings);if(r.ownership_enforcement==="strict")throw new f(`Item ${e.subjectId} is assigned to ${t}. Use --force to override.`,u.CONFLICT);return r.ownership_enforcement==="warn"?[`ownership_warning:assignee_conflict:${e.subjectId}:${t}`]:[]}async function qa(e){let t=await T(e.subject.historyPath);if(t!==e.historyRawBeforeLock)throw new f(`History for ${e.subject.id} changed while waiting for lock; retry ${e.operation}.`,u.CONFLICT);let r=await B(e.pmRoot,e.subject.id,e.settings.id_prefix,e.settings.item_format,e.typeRegistry.type_to_folder),n=r?await G(r,{schema:e.settings.schema}):null;if((n?.raw??null)!==(e.currentItemRawBeforeLock??null))throw new f(`Item ${e.subject.id} changed while waiting for lock; retry ${e.operation}.`,u.CONFLICT);return{historyRawUnderLock:t,locatedUnderLock:r,loadedItemUnderLock:n}}async function Jh(e){let t=e.writeHistoryRaw??S;try{await t(e.historyPath,e.nextHistoryRaw),await te(e.historyPath)}catch(r){try{e.historyRawUnderLock===null?await ja.rm(e.historyPath,{force:!0}):await t(e.historyPath,e.historyRawUnderLock),await te(e.historyPath)}catch(n){throw new AggregateError([r,n],`History rewrite failed and rollback also failed: ${String(r)}`)}throw r}}async function Cn(e){let t=[...Ha({itemDocument:e.itemDocument,subjectId:e.subject.id,author:e.author,force:e.force,settings:e.settings})],r=await xe(e.pmRoot,e.subject.id,e.settings.locks.ttl_seconds,e.author,!!e.force,e.settings.governance.force_required_for_stale_lock,e.settings.locks.wait_ms);try{let n=await qa({pmRoot:e.pmRoot,subject:e.subject,settings:e.settings,typeRegistry:e.typeRegistry,historyRawBeforeLock:e.historyRawBeforeLock,currentItemRawBeforeLock:e.currentItemRawBeforeLock,operation:e.operation});return await e.applyRewrite(n),e.applyPostRewrite&&t.push(...await e.applyPostRewrite(n)),t}finally{await r()}}(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]="05b945f2-4f96-5f88-98ff-84cc856d0d57")}catch{}})();function Rn(e){return Array.isArray(e)?e:typeof e=="string"?[e]:[]}function Ba(e){let t=[];for(let r of e)t.includes(r)||t.push(r);return t.includes("g")||t.push("g"),t.join("")}function Ga(e){let t=e.trim();if(t.length===0)throw new f("history-redact --regex requires a non-empty pattern.",u.USAGE);let r=t,n="g";if(t.startsWith("/")&&t.length>1){let o=t.lastIndexOf("/");o>0&&(r=t.slice(1,o),n=Ba(t.slice(o+1)))}if(r.length===0)throw new f("history-redact --regex cannot use an empty pattern.",u.USAGE);try{new RegExp(r,n)}catch{throw new f("Invalid --regex value; provide a valid JavaScript regular expression.",u.USAGE)}return{kind:"regex",source:r,flags:n}}function Ya(e,t){let r=[...new Set(Rn(e).map(i=>i.trim()))].filter(i=>i.length>0).map(i=>({kind:"literal",value:i})),n=[...new Set(Rn(t).map(i=>i.trim()))].filter(i=>i.length>0).map(Ga),o=[...r,...n];if(o.length===0)throw new f("history-redact requires at least one matcher via --literal or --regex.",u.USAGE,{code:"missing_required_argument",required:"Provide --literal <value> and/or --regex <pattern>.",examples:['pm history-redact pm-a1b2 --literal "[redacted_path_prefix]/private"','pm history-redact pm-a1b2 --regex "/192\\\\.168\\\\.[0-9.]+/g" --replacement "[scrubbed_ip]"']});return o}function Wa(e,t,r){if(t.length===0)return{value:e,replacements:0};let n=0,o=0;for(;n<=e.length;){let i=e.indexOf(t,n);if(i===-1)break;o+=1,n=i+Math.max(1,t.length)}return o===0?{value:e,replacements:0}:{value:e.split(t).join(r),replacements:o}}function Ka(e,t,r){let n=new RegExp(t.source,t.flags),o=[...e.matchAll(n)];return o.length===0?{value:e,replacements:0}:{value:e.replace(n,r),replacements:o.length}}function kn(e,t,r){let n=e,o=0;for(let i of t){let s=i.kind==="literal"?Wa(n,i.value,r):Ka(n,i,r);n=s.value,o+=s.replacements}return{value:n,replacements:o}}function Wt(e,t,r){if(typeof e=="string")return kn(e,t,r);if(Array.isArray(e)){let n=0;return{value:e.map(i=>{let s=Wt(i,t,r);return n+=s.replacements,s.value}),replacements:n}}if(typeof e=="object"&&e!==null){let n=0,o={};for(let[i,s]of Object.entries(e)){let a=Wt(s,t,r);n+=a.replacements,o[i]=a.value}return{value:o,replacements:n}}return{value:e,replacements:0}}function Xa(e){let t=structuredClone(fe),r=0,n=0;for(let o=0;o<e.length;o+=1){let i=e[o];z(t)!==i.before_hash&&(r+=1),t=Qe(t,i.patch,o+1,i.op),z(t)!==i.after_hash&&(n+=1)}return{hashMismatchesBefore:r,hashMismatchesAfter:n,finalDocument:t}}function Qa(e,t,r){let n=0,o=!1,i=e.message;if(typeof e.message=="string"){let a=kn(e.message,t,r);i=a.value,n+=a.replacements,a.replacements>0&&(o=!0)}let s=e.patch.map(a=>{if(!Object.prototype.hasOwnProperty.call(a,"value"))return a;let c=Wt(a.value,t,r);return n+=c.replacements,c.replacements>0?(o=!0,{...a,value:c.value}):a});return{entry:{...e,message:i,patch:s},replacements:n,changed:o}}function Ja(e,t,r){let n=structuredClone(fe),o=0,i=0,s=[];for(let a=0;a<e.length;a+=1){let c=Qa(e[a],t,r);i+=c.replacements,c.changed&&(o+=1);let d=z(n);n=Qe(n,c.entry.patch,a+1,c.entry.op);let l=z(n);s.push({...c.entry,before_hash:d,after_hash:l})}return{entries:s,finalDocument:n,entriesChanged:o,replacements:i}}function Za(e){return Object.keys(e.metadata).length>0}async function ec(e,t){let r=e.located?.itemPath??null;if(!e.located)return{raw:null,path:r,document:null};let n=await G(e.located,{schema:t.schema});return{raw:n.raw,path:r,document:n.document}}function tc(e){if(!Za(e.finalDocument))return{raw:null,path:null,document:null};let t=st(Ae(e.finalDocument),{schema:e.settings.schema});if(t.metadata.id!==e.subject.id)throw new f("history-redact would change the item id; narrow your patterns.",u.USAGE);return{document:t,path:se(e.pmRoot,t.metadata.type,e.subject.id,"toon",e.typeToFolder),raw:le(t,{format:"toon",schema:e.settings.schema})}}function rc(e,t){return typeof e.message=="string"&&e.message.trim().length>0?e.message:`history-redact replaced ${t.replacements} match(es) across ${t.entriesChanged} entr${t.entriesChanged===1?"y":"ies"}.`}function nc(e){let t=[...e.rewritten.entries];if(e.dryRun||!e.changed)return{rewrittenEntries:t,auditEntryAdded:!1};let r=e.nextItemDocument??Ae(e.rewritten.finalDocument);return t.push(at({nowIso:v(),author:e.author,op:"history_redact",before:r,after:r,message:e.message})),{rewrittenEntries:t,auditEntryAdded:!0}}async function oc(e){let t=[];return Cn({pmRoot:e.pmRoot,subject:e.subject,settings:e.settings,typeRegistry:e.typeRegistry,historyRawBeforeLock:e.historyRawBeforeLock,currentItemRawBeforeLock:e.currentItem.raw,operation:"history-redact",author:e.author,force:e.force,itemDocument:e.currentItem.document,applyRewrite:async({historyRawUnderLock:r})=>{let n=await ut(e.pmRoot,e.author),o=new Set;e.currentItem.path&&o.add(e.currentItem.path),e.nextItem.path&&o.add(e.nextItem.path);let i=new Map;e.currentItem.path&&e.currentItem.raw!==null&&i.set(e.currentItem.path,e.currentItem.raw);let s=()=>{};try{try{e.nextItem.path&&e.nextItem.raw!==null&&e.nextItem.raw!==e.currentItem.raw&&await S(e.nextItem.path,e.nextItem.raw),e.currentItem.path&&(!e.nextItem.path||e.nextItem.path!==e.currentItem.path)&&await Yt.rm(e.currentItem.path,{force:!0}),await S(e.subject.historyPath,er(e.rewrittenEntries))}catch(c){try{await ic(e.subject.historyPath,r,o,i)}finally{await te(e.subject.historyPath)}throw c}await te(e.subject.historyPath);let a=e.nextItem.path??e.currentItem.path;a&&(t=await mt({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:e.typeRegistry.type_to_folder,schema:e.settings.schema,itemPath:a,...e.currentItem.path?{previousItemPath:e.currentItem.path}:{},document:e.nextItem.document}))}finally{await n().catch(a=>{s=()=>{throw a}})}s()},applyPostRewrite:async()=>[...t,...await sc(e.subject.historyPath,[e.nextItem.path,e.currentItem.path])]})}async function ic(e,t,r,n){t===null?await Yt.rm(e,{force:!0}):await S(e,t);for(let o of r){let i=n.get(o);i===void 0?await Yt.rm(o,{force:!0}):await S(o,i)}}async function sc(e,t){let r=[],n=new Set(t.filter(o=>o!==null));for(let o of n)r.push(...await q({path:o,scope:"project",op:"history_redact"}));return r.push(...await q({path:e,scope:"project",op:"history_redact:history"})),r}async function ac(e,t,r,n){let o=await B(e,t,r.id_prefix,r.item_format,n);if(o)return{id:o.id,historyPath:Se(e,o.id),located:o};let i=re(t,r.id_prefix),s=dt(t),a=i===s?[i]:[i,s];for(let c of a){let d=Se(e,c);if(await P(d))return{id:c,historyPath:d,located:null}}throw new f(`Item ${t} not found`,u.NOT_FOUND)}async function b_(e,t,r){let n=H(process.cwd(),r.path);await rr(n);let o=await C(n),i=F(o,ce()),s=t.replacement??"",a=s.length===0,c=a?"[redacted]":s,d=Ya(t.literal,t.regex),l=await ac(n,e,o,i.type_to_folder);if(!await P(l.historyPath))throw new f(`No history stream exists for ${l.id}.`,u.NOT_FOUND);let m=await T(l.historyPath),h=await ue(l.historyPath,l.id);if(h.length===0)throw new f(`No history entries exist for ${l.id}; nothing to redact.`,u.USAGE);let p=Xa(h),_=Ja(h,d,c),y=p.hashMismatchesBefore+p.hashMismatchesAfter,g=!!t.dryRun,E=_.replacements>0,x=[];y>0&&x.push(`history_redact_preexisting_hash_mismatches:${y}`),E||x.push("history_redact_no_matches");let I=await ec(l,o),A=tc({pmRoot:n,subject:l,settings:o,typeToFolder:i.type_to_folder,finalDocument:_.finalDocument}),V=(I.path??null)!==(A.path??null)||(I.raw??null)!==(A.raw??null),O=Ie(t.author,o.author_default),Je=rc(t,_),{rewrittenEntries:J,auditEntryAdded:Ee}=nc({rewritten:_,dryRun:g,changed:E,nextItemDocument:A.document,author:O,message:Je}),ie=ct(J);if(!ie.ok)throw new f(`history-redact produced an invalid rewritten chain (${ie.errors.join(", ")}).`,u.GENERIC_FAILURE);return!g&&E&&x.push(...await oc({pmRoot:n,subject:l,settings:o,typeRegistry:i,historyRawBeforeLock:m,currentItem:I,nextItem:A,author:O,force:t.force,rewrittenEntries:J})),{id:l.id,dry_run:g,changed:E,patterns:{literal_count:d.filter(j=>j.kind==="literal").length,regex_count:d.filter(j=>j.kind==="regex").length,total_count:d.length,replacement_is_default:a},history:{path:l.historyPath,entries_scanned:h.length,entries_changed:_.entriesChanged,replacements:_.replacements,hash_mismatches_before:p.hashMismatchesBefore,hash_mismatches_after:p.hashMismatchesAfter,preexisting_hash_mismatches:y,audit_entry_added:Ee,verify_ok:ie.ok,verify_errors:ie.errors},item:{existed_before:I.path!==null,exists_after:A.path!==null,path_before:I.path,path_after:A.path,changed:V},warnings:[...new Set(x)].sort((j,Dn)=>j.localeCompare(Dn)),generated_at:v()}}(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]="412fc2d2-daee-5d87-82ab-5411a1503087")}catch{}})();function T_(e,t){let r=t??{};return e.filter(n=>r[n.id]!==n.updated_at).map(n=>n.id).sort((n,o)=>n.localeCompare(o))}export{Uh as a,Qe as b,Vh as c,jh as d,Jh as e,Cn as f,ac as g,b_ as h,Qn as i,Jn as j,eo as k,to as l,Dc as m,ro as n,no as o,lr as p,oo as q,io as r,so as s,ao as t,ho as u,go as v,wo as w,hr as x,bo as y,So as z,Oc as A,To as B,Oe as C,Pc as D,Pe as E,xo as F,Ao as G,yt as H,Co as I,gt as J,Ro as K,Qc as L,Do as M,yr as N,Lo as O,Mo as P,Po as Q,od as R,zo as S,ld as T,Ho as U,Bo as V,Ln as W,Go as X,Yo as Y,ze as Z,hi as _,Ld as $,Et as aa,vr as ba,bt as ca,vi as da,Ci as ea,Od as fa,Cr as ga,ne as ha,Tt as ia,xt as ja,Mt as ka,Gd as la,Nt as ma,Ge as na,Or as oa,Ye as pa,Ot as qa,Pt as ra,$t as sa,Ft as ta,Vr as ua,jr as va,ml as wa,Fn as xa,or as ya,Un as za,Vn as Aa,jn as Ba,mc as Ca,hc as Da,me as Ea,De as Fa,he as Ga,pe as Ha,Le as Ia,Me as Ja,ir as Ka,Yn as La,Is as Ma,vs as Na,Rs as Oa,ks as Pa,Vs as Qa,en as Ra,ea as Sa,_u as Ta,T_ as Ua,Dh as Va,Lh as Wa,Fa as Xa,Mh as Ya,Nh as Za};
19
- //# sourceMappingURL=chunk-P2E6LDAE.js.map
18
+ `:"";for(let o=0;;o+=1)try{await S(Ht(e),n);return}catch(i){let s=tn[o];if(s===void 0||!yn(i))throw i;await gn(s)}}async function Qr(e,t,r,n){return Bt(async()=>{let o=await T(Ht(e)),i=o===null?[]:wn(o),s=[];for(let c of i){if(r.has(c.id))continue;let d=n.get(c.id);s.push(d?{...c,attempts:d.attempts,next_attempt_after:d.next_attempt_after}:c)}let{entries:a}=En(s,t);return await wa(e,a),a.length})}async function Ea(e,t){let r=await T(Ht(e));if(r===null||r.trim().length===0){await N(e,{pending_otel_spans:0});return}let n=wn(r),{entries:o,prunedCount:i}=En(n,t),s=o.filter(_=>hn(_.next_attempt_after)).slice(0,Us);if(s.length===0){let _=i>0?await Qr(e,t,new Set,new Map):o.length;await N(e,{pending_otel_spans:_});return}let a=v(),c=new Set,d=new Map,l=0,m;await Promise.all(s.map(async _=>{try{let y=await fn(_.endpoint,{"content-type":"application/json"},JSON.stringify(_.payload));if(y<200||y>=300)throw new Error(`local_otel_export_http_${y}`);c.add(_.id),l+=1}catch(y){m=y instanceof Error?Ut(y.message,"redacted"):"local_otel_export_failed";let g=_.attempts+1;d.set(_.id,{attempts:g,next_attempt_after:pn(g)})}}));let h=await Qr(e,t,c,d),p={pending_otel_spans:h,last_otel_attempt_at:a};l>0&&(p.last_otel_success_at=a),m!==void 0?(p.last_otel_failure_at=a,p.last_otel_failure_error=m):h===0&&(p.last_otel_failure_at=void 0,p.last_otel_failure_error=void 0),await N(e,p)}async function ba(e,t,r){try{await xa(e,t,r)}catch{}try{await Ea(e,r)}catch{}}async function Sa(e,t=Ws){try{let r=sa(e),n=await Ns(r,{withFileTypes:!0}),o=Date.now()-Math.max(0,t);await Promise.all(n.filter(i=>i.isFile()&&/^\.events\.jsonl\.\d+\.\d+\.[a-f0-9]+\.tmp$/.test(i.name)).map(async i=>{let s=k.join(r,i.name);(await Jr(s)).mtimeMs<o&&await jt(s,{force:!0})}))}catch{}}async function Bt(e){let t=Kr.catch(()=>{}).then(e);return Kr=t.catch(()=>{}),t}async function Gt(e){let t=await T(Xe(e));return t===null||t.trim().length===0?[]:mn(t)}async function Ta(e,t,r){return Bt(async()=>{let n=await Gt(e),{entries:o}=qt(n,r),i=o.filter(s=>!t.has(s.event.event_id));return await Ke(e,i),i})}async function Ia(e,t,r,n){return Bt(async()=>{let o=await Gt(e),{entries:i}=qt(o,n),s=i.map(a=>{if(!t.has(a.event.event_id))return a;let c=a.attempts+1;return{...a,attempts:c,last_attempt_at:r,next_attempt_after:pn(c)}});return await Ke(e,s),s})}async function xa(e,t,r){await Sa(e);let n=t.trim();if(n.length===0)return;let o=await T(Xe(e));if(o===null||o.trim().length===0){await N(e,{endpoint:n,queue_entries:0});return}let i=mn(o);if(i.length===0){await N(e,{endpoint:n,queue_entries:0});return}let{entries:s,prunedCount:a}=qt(i,r);if(s.length===0){await Ke(e,[]),await N(e,{endpoint:n,queue_entries:0});return}let c=s.filter(p=>ha(p)).slice(0,js);if(c.length===0){a>0&&await Ke(e,s),await N(e,{endpoint:n,queue_entries:s.length});return}let d=new Set(c.map(p=>p.event.event_id)),l=v(),m={"content-type":"application/json"},h=process.env.PM_TELEMETRY_INGEST_KEY?.trim();h&&(m["x-pm-telemetry-key"]=h);try{let p=await fn(n,m,JSON.stringify({schema_version:Vs,events:c.map(_=>_.event)}));if(p<200||p>=300)throw new Error(`telemetry_flush_http_${p}`)}catch(p){let _=await Ia(e,d,l,r),y=p instanceof Error?Ut(p.message,"redacted"):"telemetry_flush_failed";await N(e,{endpoint:n,queue_entries:_.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:y});return}try{let p=await Ta(e,d,r);await N(e,{endpoint:n,queue_entries:p.length,last_attempted_flush_at:l,last_successful_flush_at:l,last_failed_flush_at:void 0,last_failed_flush_error:void 0})}catch(p){let _=p instanceof Error?Ut(p.message,"redacted"):"telemetry_flush_failed",y=await Gt(e).catch(()=>s);await N(e,{endpoint:n,queue_entries:y.length,last_attempted_flush_at:l,last_failed_flush_at:l,last_failed_flush_error:_})}}async function Aa(e){let t=on(e);await zt(k.dirname(t),{recursive:!0});try{return await zt(t),!0}catch(r){if(typeof r!="object"||r===null||!("code"in r)||r.code!=="EEXIST")throw r}try{let r=await Jr(t);return Date.now()-r.mtimeMs<Ks?!1:(await jt(t,{recursive:!0,force:!0}),await zt(t),!0)}catch{return!1}}function va(e){try{Ms(e,{recursive:!0,force:!0})}catch{}}function Ca(e){va(aa(e))}async function Ra(e,t,r){let n=await Aa(e);if(Ca(e),!!n)try{await ba(e,t,r)}finally{try{await jt(on(e),{recursive:!0,force:!0})}catch{}}}async function _u(e=tt(process.cwd())){if(!ma())try{if(!(await C(e)).telemetry.enabled)return;let{endpoint:r,retentionDays:n}=await pa(e);await Ra(e,r,n)}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]="d45775e5-6826-521b-80b3-429ed22947d9")}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]="13c02696-29a7-598e-888a-3502fd88bfbe")}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]="33a43890-abcf-58fc-bf9d-bf2619d4cf35")}catch{}})();var ka=3,bn=20,Da=.8,La=100,Sn=1e3,Tn=1e6;function Lh(e){return e===void 0?[]:[`likely_duplicates:${e.result.items.map(t=>t.id).join(",")}`,`likely_duplicate_recovery:${e.recovery.action}:${e.recovery.item_id}`]}async function Ma(e,t){let r=e.items[0],n=H(t.cwd??process.cwd(),t.pmRoot),o=Te((await C(n)).schema);return ot(r.status,o)?{action:"reopen",item_id:r.id,command:`pm item reopen ${r.id} "<recurrence reason>"`,args:["item","reopen",r.id,"<recurrence reason>"]}:{action:"reuse",item_id:r.id,command:`pm get ${r.id} --full`,args:["get",r.id,"--full"]}}function In(e){let t=e.limit??ka,r=e.threshold??Da;if(!Number.isSafeInteger(t)||t<0||t>bn)throw new f(`Similarity limit must be an integer from 0 to ${bn}.`,u.USAGE);if(!Number.isFinite(r)||r<0||r>1)throw new f("Similarity threshold must be a number from 0 to 1.",u.USAGE);return{limit:t,threshold:r}}function Na(e){let t=e.limit??La;if(!Number.isSafeInteger(t)||t<0||t>Sn)throw new f(`Duplicate cluster limit must be an integer from 0 to ${Sn}.`,u.USAGE);let r=e.since===void 0?void 0:new Date(e.since);if(r&&Number.isNaN(r.getTime()))throw new f("Duplicate cluster --since must be a valid ISO timestamp.",u.USAGE);return{limit:t,since:r}}async function Oa(e,t){let r=H(e.cwd??process.cwd(),e.pmRoot),n=await C(r),o=F(n),i=e.statuses?.map(m=>m.trim().toLowerCase()).filter(Boolean);if(e.statuses!==void 0&&i?.length===0)throw new f("Duplicate cluster statuses must include at least one lifecycle status or all.",u.USAGE);let s=Te(n.schema),a=i?.map(m=>{if(m==="all")return m;let h=de(m,s);if(!h)throw new f(`Unknown duplicate-cluster status "${m}". Allowed: all, ${s.definitions.map(p=>p.id).join(", ")}.`,u.USAGE);return h}),c=a?.includes("all")===!0;if(c&&a?.some(m=>m!=="all"))throw new f('The "all" status cannot be combined with other statuses.',u.USAGE);let d=c?void 0:a,l=d?new Set(d):void 0;return{items:(await ke(r,n.item_format,o.type_to_folder,void 0,n.schema)).filter(m=>(!l||l.has(m.status))&&(!t||new Date(m.created_at).getTime()>=t.getTime())).sort((m,h)=>m.id.localeCompare(h.id)).map(m=>({item:m,prepared:pe(m.title)})),statuses:d}}function xn(e,t=Tn){let r=new Set,n=[new Map,new Map,new Map];for(let[o,i]of e.entries()){let s=[[i.prepared.normalized],i.prepared.issueCodes,i.prepared.tokens];for(let[a,c]of s.entries())for(let d of c){let l=n[a].get(d)??[];for(let m of l)r.add(`${m}:${o}`);if(r.size>t)throw new f(`Duplicate sweep exceeded ${Tn} candidate pairs; narrow it with statuses or since.`,u.CONFLICT,{code:"duplicate_sweep_cost_limit",required:"Narrow the batch duplicate query until its deterministic candidate set fits the disclosed safety bound."});l.push(o),n[a].set(d,l)}}return r}var Mh={buildDuplicateClusters:vn,collectDuplicateCandidatePairs:xn,createDuplicateUnionFind:An};function An(e){let t=Array.from({length:e},(n,o)=>o);return{parent:t,findRoot:n=>{let o=n;for(;t[o]!==o;)o=t[o];for(;t[n]!==n;){let i=t[n];t[n]=o,n=i}return o}}}function Pa(e,t,r,n){let o=[];for(let i of t){let[s,a]=i.split(":").map(m=>Number.parseInt(m,10)),c=Me(e[s].prepared,e[a].prepared);if(c.score<r)continue;let d=n.findRoot(s),l=n.findRoot(a);d!==l&&(n.parent[l]=d),o.push({left_id:e[s].item.id,right_id:e[a].item.id,...c})}return o}function vn(e,t,r,n){let o=new Map;for(let i of e.keys()){let s=r.findRoot(i),a=o.get(s)??[];a.push(i),o.set(s,a)}return[...o.values()].filter(i=>i.length>1).map(i=>{let s=new Set(i.map(c=>e[c].item.id)),a=t.filter(c=>s.has(c.left_id)&&s.has(c.right_id)).sort((c,d)=>d.score-c.score||c.left_id.localeCompare(d.left_id)||c.right_id.localeCompare(d.right_id));return{id:e[i[0]].item.id,items:i.map(c=>{let d=e[c].item;return{id:d.id,title:d.title,status:d.status,type:d.type}}),matches:a,max_score:a[0]?.score??0}}).sort((i,s)=>s.max_score-i.max_score||i.id.localeCompare(s.id)).slice(0,n)}function $a(e,t,r,n,o){return t.filter(i=>!r.has(i.id)).map(i=>({id:i.id,title:i.title,status:i.status,type:i.type,...Le(e,i.title)})).filter(i=>i.score>=n).sort((i,s)=>s.score-i.score||i.id.localeCompare(s.id)).slice(0,o)}async function Fa(e,t={}){let r=e.title.trim();if(r.length===0)throw new f("Similarity candidate title must not be empty.",u.USAGE);let{limit:n,threshold:o}=In(t),i=H(t.cwd??process.cwd(),t.pmRoot),s=await C(i),a=F(s),c=await ft(i,Object.values(a.type_to_folder)),d=he(r),l=c&&d.length>0?await lt({pmRoot:i,expectedSourceCursor:c.source_cursor,query:d.map(p=>`"${p.replaceAll('"','""')}"`).join(" OR "),limit:Math.max(n*10,50)}):null,m=l===null?await ke(i,s.item_format,a.type_to_folder,void 0,s.schema):l.items,h=$a(r,m,new Set(e.excludeIds??[]),o,n);return{items:h,count:h.length,threshold:o,source:l?"persistent_index":"metadata_fallback"}}async function Nh(e={}){let{threshold:t}=In({...e,limit:void 0}),{limit:r,since:n}=Na(e),{items:o,statuses:i}=await Oa(e,n),s=xn(o),a=An(o.length),c=Pa(o,s,t,a),d=vn(o,c,a,r);return{clusters:d,count:d.length,threshold:t,source:"metadata_scan",filters:{statuses:i??null,since:e.since??null},cost:{item_count:o.length,candidate_pairs:s.size,scored_pairs:s.size}}}async function Oh(e,t){if(t.mode==="off")return;let r=await Fa(e,t);if(r.count===0)return;let n=await Ma(r,t),o=t.mode==="strict"&&t.allowDuplicate===!0;if(t.mode==="strict"&&!o){let i=r.items.map(a=>`${a.id} (${a.status}): ${a.title}`).join("; "),s=n.action==="reopen"?"Reopen the canonical item":"Reuse the canonical item";throw new f(`Likely duplicate item(s) found: ${i}. ${s} or pass --allow-duplicate with explicit intent.`,u.CONFLICT,{code:"likely_duplicate",required:`${s}, or explicitly acknowledge the duplicate with --allow-duplicate.`,recovery:{suggested_flags:["--allow-duplicate"],suggested_retry:n.command,suggested_retry_args:n.args}})}return{mode:t.mode,bypassed:o,result:r,recovery: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]="47c087c2-124a-58b7-a5c9-09403235f4a2")}catch{}})();function za(e,t){let r=-1;return e.forEach((n,o)=>{let i=Date.parse(n.ts);if(!Number.isFinite(i))throw new f(`History for this item contains invalid timestamp at entry ${o+1}.`,u.GENERIC_FAILURE);i<=t&&(r=o)}),r}function Ua(e){let t=e[0]?.ts??null,r=e.at(-1)?.ts??null,n={code:"history_target_out_of_range",required:"Choose a target within the available item history.",why:"Point-in-time reads and restores can only reconstruct recorded versions.",examples:[],nextSteps:["Run pm history <id> to inspect available versions and timestamps."],valid_range:{first_version:null,last_version:null,first_timestamp:t,last_timestamp:r}};return r!==null&&(n.examples=["1",String(e.length),r],n.valid_range.first_version=1,n.valid_range.last_version=e.length),{guidance:n,lastTimestamp:r}}function Va(e,t){let r={};if(t instanceof Error&&t.message.trim().length>0&&(r.reason=t.message.trim()),typeof t!="object"||t===null)return r;let n=t;if(typeof n.index=="number"&&Number.isInteger(n.index)&&n.index>=0&&(r.patchIndex=n.index),typeof n.operation=="object"&&n.operation!==null){let o=n.operation;Object.assign(r,Object.fromEntries(["op","path","from"].flatMap(i=>{let s=o[i];return typeof s=="string"?[[i,s]]:[]})))}if(r.patchIndex!==void 0){let o=e[r.patchIndex];o&&(r.op??=o.op,r.path??=o.path,r.from??=o.from)}return r}function Vh(e,t,r={}){let n=e.trim(),o=r.errorSubject??"history",i=o==="restore"?"Restore":"History",{guidance:s,lastTimestamp:a}=Ua(t);if(!n)throw new f(`Missing ${o} target. Use a timestamp or version number.`,u.USAGE,s);if(/^\d+$/.test(n)){let l=Number(n);if(!Number.isSafeInteger(l)||l<1||l>t.length)throw new f(`${i} version must be between 1 and ${t.length} for this item.`,u.USAGE,s);return{kind:"version",raw:n,historyIndex:l-1}}let c=Date.parse(n);if(!Number.isFinite(c))throw new f(`Invalid ${o} target "${e}". Use a positive version number or ISO timestamp.`,u.USAGE,s);let d=za(t,c);if(d<0||r.allowFutureTimestamp!==!0&&c>Date.parse(a))throw new f(o==="restore"?`No history entries exist at or before timestamp ${n}.`:`No history entry exists at timestamp ${n}.`,u.USAGE,s);return{kind:"timestamp",raw:n,historyIndex:d}}function Qe(e,t,r,n){let o=ve(e,t);if(o.ok)return o.document;let i=Va(t,o.error),s=[`history_op=${n}`,i.patchIndex===void 0?null:`patch_index=${i.patchIndex}`,i.op?`op=${i.op}`:null,i.path?`path=${i.path}`:null,i.from?`from=${i.from}`:null].filter(a=>a!==null);throw new f(`Failed to apply history patch at entry ${r} (${s.join(", ")}). ${i.reason??String(o.error)}`,u.GENERIC_FAILURE)}function jh(e,t){let r=structuredClone(fe);for(let n=0;n<=t;n+=1){let o=e[n];if(!o)throw new f(`History target entry ${n+1} does not exist.`,u.USAGE);if(z(r)!==o.before_hash)throw new f(`History hash mismatch before replay at entry ${n+1}.`,u.GENERIC_FAILURE);if(r=Qe(r,o.patch,n+1,o.op),z(r)!==o.after_hash)throw new f(`History hash mismatch after replay at entry ${n+1}.`,u.GENERIC_FAILURE)}return r}function Hh(e,t){if(Object.keys(e.metadata).length>0)return e;throw new f(`History target ${t.raw} resolves to a deleted state; choose a version or timestamp where the item exists.`,u.USAGE)}import Yt from"node:fs/promises";import ja from"node:fs/promises";(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]="a2ec9f1a-aae2-59d5-8c9a-7acd8bf5a7a2")}catch{}})();function Ha(e){if(!e.itemDocument)return[];let t=e.itemDocument.metadata?.assignee?.trim();if(!t||t===e.author||e.force)return[];let r=tr(e.settings);if(r.ownership_enforcement==="strict")throw new f(`Item ${e.subjectId} is assigned to ${t}. Use --force to override.`,u.CONFLICT);return r.ownership_enforcement==="warn"?[`ownership_warning:assignee_conflict:${e.subjectId}:${t}`]:[]}async function qa(e){let t=await T(e.subject.historyPath);if(t!==e.historyRawBeforeLock)throw new f(`History for ${e.subject.id} changed while waiting for lock; retry ${e.operation}.`,u.CONFLICT);let r=await B(e.pmRoot,e.subject.id,e.settings.id_prefix,e.settings.item_format,e.typeRegistry.type_to_folder),n=r?await G(r,{schema:e.settings.schema}):null;if((n?.raw??null)!==(e.currentItemRawBeforeLock??null))throw new f(`Item ${e.subject.id} changed while waiting for lock; retry ${e.operation}.`,u.CONFLICT);return{historyRawUnderLock:t,locatedUnderLock:r,loadedItemUnderLock:n}}async function Zh(e){let t=e.writeHistoryRaw??S;try{await t(e.historyPath,e.nextHistoryRaw),await te(e.historyPath)}catch(r){try{e.historyRawUnderLock===null?await ja.rm(e.historyPath,{force:!0}):await t(e.historyPath,e.historyRawUnderLock),await te(e.historyPath)}catch(n){throw new AggregateError([r,n],`History rewrite failed and rollback also failed: ${String(r)}`)}throw r}}async function Cn(e){let t=[...Ha({itemDocument:e.itemDocument,subjectId:e.subject.id,author:e.author,force:e.force,settings:e.settings})],r=await xe(e.pmRoot,e.subject.id,e.settings.locks.ttl_seconds,e.author,!!e.force,e.settings.governance.force_required_for_stale_lock,e.settings.locks.wait_ms);try{let n=await qa({pmRoot:e.pmRoot,subject:e.subject,settings:e.settings,typeRegistry:e.typeRegistry,historyRawBeforeLock:e.historyRawBeforeLock,currentItemRawBeforeLock:e.currentItemRawBeforeLock,operation:e.operation});return await e.applyRewrite(n),e.applyPostRewrite&&t.push(...await e.applyPostRewrite(n)),t}finally{await r()}}(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]="05b945f2-4f96-5f88-98ff-84cc856d0d57")}catch{}})();function Rn(e){return Array.isArray(e)?e:typeof e=="string"?[e]:[]}function Ba(e){let t=[];for(let r of e)t.includes(r)||t.push(r);return t.includes("g")||t.push("g"),t.join("")}function Ga(e){let t=e.trim();if(t.length===0)throw new f("history-redact --regex requires a non-empty pattern.",u.USAGE);let r=t,n="g";if(t.startsWith("/")&&t.length>1){let o=t.lastIndexOf("/");o>0&&(r=t.slice(1,o),n=Ba(t.slice(o+1)))}if(r.length===0)throw new f("history-redact --regex cannot use an empty pattern.",u.USAGE);try{new RegExp(r,n)}catch{throw new f("Invalid --regex value; provide a valid JavaScript regular expression.",u.USAGE)}return{kind:"regex",source:r,flags:n}}function Ya(e,t){let r=[...new Set(Rn(e).map(i=>i.trim()))].filter(i=>i.length>0).map(i=>({kind:"literal",value:i})),n=[...new Set(Rn(t).map(i=>i.trim()))].filter(i=>i.length>0).map(Ga),o=[...r,...n];if(o.length===0)throw new f("history-redact requires at least one matcher via --literal or --regex.",u.USAGE,{code:"missing_required_argument",required:"Provide --literal <value> and/or --regex <pattern>.",examples:['pm history-redact pm-a1b2 --literal "[redacted_path_prefix]/private"','pm history-redact pm-a1b2 --regex "/192\\\\.168\\\\.[0-9.]+/g" --replacement "[scrubbed_ip]"']});return o}function Wa(e,t,r){if(t.length===0)return{value:e,replacements:0};let n=0,o=0;for(;n<=e.length;){let i=e.indexOf(t,n);if(i===-1)break;o+=1,n=i+Math.max(1,t.length)}return o===0?{value:e,replacements:0}:{value:e.split(t).join(r),replacements:o}}function Ka(e,t,r){let n=new RegExp(t.source,t.flags),o=[...e.matchAll(n)];return o.length===0?{value:e,replacements:0}:{value:e.replace(n,r),replacements:o.length}}function kn(e,t,r){let n=e,o=0;for(let i of t){let s=i.kind==="literal"?Wa(n,i.value,r):Ka(n,i,r);n=s.value,o+=s.replacements}return{value:n,replacements:o}}function Wt(e,t,r){if(typeof e=="string")return kn(e,t,r);if(Array.isArray(e)){let n=0;return{value:e.map(i=>{let s=Wt(i,t,r);return n+=s.replacements,s.value}),replacements:n}}if(typeof e=="object"&&e!==null){let n=0,o={};for(let[i,s]of Object.entries(e)){let a=Wt(s,t,r);n+=a.replacements,o[i]=a.value}return{value:o,replacements:n}}return{value:e,replacements:0}}function Xa(e){let t=structuredClone(fe),r=0,n=0;for(let o=0;o<e.length;o+=1){let i=e[o];z(t)!==i.before_hash&&(r+=1),t=Qe(t,i.patch,o+1,i.op),z(t)!==i.after_hash&&(n+=1)}return{hashMismatchesBefore:r,hashMismatchesAfter:n,finalDocument:t}}function Qa(e,t,r){let n=0,o=!1,i=e.message;if(typeof e.message=="string"){let a=kn(e.message,t,r);i=a.value,n+=a.replacements,a.replacements>0&&(o=!0)}let s=e.patch.map(a=>{if(!Object.prototype.hasOwnProperty.call(a,"value"))return a;let c=Wt(a.value,t,r);return n+=c.replacements,c.replacements>0?(o=!0,{...a,value:c.value}):a});return{entry:{...e,message:i,patch:s},replacements:n,changed:o}}function Ja(e,t,r){let n=structuredClone(fe),o=0,i=0,s=[];for(let a=0;a<e.length;a+=1){let c=Qa(e[a],t,r);i+=c.replacements,c.changed&&(o+=1);let d=z(n);n=Qe(n,c.entry.patch,a+1,c.entry.op);let l=z(n);s.push({...c.entry,before_hash:d,after_hash:l})}return{entries:s,finalDocument:n,entriesChanged:o,replacements:i}}function Za(e){return Object.keys(e.metadata).length>0}async function ec(e,t){let r=e.located?.itemPath??null;if(!e.located)return{raw:null,path:r,document:null};let n=await G(e.located,{schema:t.schema});return{raw:n.raw,path:r,document:n.document}}function tc(e){if(!Za(e.finalDocument))return{raw:null,path:null,document:null};let t=st(Ae(e.finalDocument),{schema:e.settings.schema});if(t.metadata.id!==e.subject.id)throw new f("history-redact would change the item id; narrow your patterns.",u.USAGE);return{document:t,path:se(e.pmRoot,t.metadata.type,e.subject.id,"toon",e.typeToFolder),raw:le(t,{format:"toon",schema:e.settings.schema})}}function rc(e,t){return typeof e.message=="string"&&e.message.trim().length>0?e.message:`history-redact replaced ${t.replacements} match(es) across ${t.entriesChanged} entr${t.entriesChanged===1?"y":"ies"}.`}function nc(e){let t=[...e.rewritten.entries];if(e.dryRun||!e.changed)return{rewrittenEntries:t,auditEntryAdded:!1};let r=e.nextItemDocument??Ae(e.rewritten.finalDocument);return t.push(at({nowIso:v(),author:e.author,op:"history_redact",before:r,after:r,message:e.message})),{rewrittenEntries:t,auditEntryAdded:!0}}async function oc(e){let t=[];return Cn({pmRoot:e.pmRoot,subject:e.subject,settings:e.settings,typeRegistry:e.typeRegistry,historyRawBeforeLock:e.historyRawBeforeLock,currentItemRawBeforeLock:e.currentItem.raw,operation:"history-redact",author:e.author,force:e.force,itemDocument:e.currentItem.document,applyRewrite:async({historyRawUnderLock:r})=>{let n=await ut(e.pmRoot,e.author),o=new Set;e.currentItem.path&&o.add(e.currentItem.path),e.nextItem.path&&o.add(e.nextItem.path);let i=new Map;e.currentItem.path&&e.currentItem.raw!==null&&i.set(e.currentItem.path,e.currentItem.raw);let s=()=>{};try{try{e.nextItem.path&&e.nextItem.raw!==null&&e.nextItem.raw!==e.currentItem.raw&&await S(e.nextItem.path,e.nextItem.raw),e.currentItem.path&&(!e.nextItem.path||e.nextItem.path!==e.currentItem.path)&&await Yt.rm(e.currentItem.path,{force:!0}),await S(e.subject.historyPath,er(e.rewrittenEntries))}catch(c){try{await ic(e.subject.historyPath,r,o,i)}finally{await te(e.subject.historyPath)}throw c}await te(e.subject.historyPath);let a=e.nextItem.path??e.currentItem.path;a&&(t=await mt({pmRoot:e.pmRoot,preferredFormat:e.settings.item_format,typeToFolder:e.typeRegistry.type_to_folder,schema:e.settings.schema,itemPath:a,...e.currentItem.path?{previousItemPath:e.currentItem.path}:{},document:e.nextItem.document}))}finally{await n().catch(a=>{s=()=>{throw a}})}s()},applyPostRewrite:async()=>[...t,...await sc(e.subject.historyPath,[e.nextItem.path,e.currentItem.path])]})}async function ic(e,t,r,n){t===null?await Yt.rm(e,{force:!0}):await S(e,t);for(let o of r){let i=n.get(o);i===void 0?await Yt.rm(o,{force:!0}):await S(o,i)}}async function sc(e,t){let r=[],n=new Set(t.filter(o=>o!==null));for(let o of n)r.push(...await q({path:o,scope:"project",op:"history_redact"}));return r.push(...await q({path:e,scope:"project",op:"history_redact:history"})),r}async function ac(e,t,r,n){let o=await B(e,t,r.id_prefix,r.item_format,n);if(o)return{id:o.id,historyPath:Se(e,o.id),located:o};let i=re(t,r.id_prefix),s=dt(t),a=i===s?[i]:[i,s];for(let c of a){let d=Se(e,c);if(await P(d))return{id:c,historyPath:d,located:null}}throw new f(`Item ${t} not found`,u.NOT_FOUND)}async function S_(e,t,r){let n=H(process.cwd(),r.path);await rr(n);let o=await C(n),i=F(o,ce()),s=t.replacement??"",a=s.length===0,c=a?"[redacted]":s,d=Ya(t.literal,t.regex),l=await ac(n,e,o,i.type_to_folder);if(!await P(l.historyPath))throw new f(`No history stream exists for ${l.id}.`,u.NOT_FOUND);let m=await T(l.historyPath),h=await ue(l.historyPath,l.id);if(h.length===0)throw new f(`No history entries exist for ${l.id}; nothing to redact.`,u.USAGE);let p=Xa(h),_=Ja(h,d,c),y=p.hashMismatchesBefore+p.hashMismatchesAfter,g=!!t.dryRun,E=_.replacements>0,x=[];y>0&&x.push(`history_redact_preexisting_hash_mismatches:${y}`),E||x.push("history_redact_no_matches");let I=await ec(l,o),A=tc({pmRoot:n,subject:l,settings:o,typeToFolder:i.type_to_folder,finalDocument:_.finalDocument}),V=(I.path??null)!==(A.path??null)||(I.raw??null)!==(A.raw??null),O=Ie(t.author,o.author_default),Je=rc(t,_),{rewrittenEntries:J,auditEntryAdded:Ee}=nc({rewritten:_,dryRun:g,changed:E,nextItemDocument:A.document,author:O,message:Je}),ie=ct(J);if(!ie.ok)throw new f(`history-redact produced an invalid rewritten chain (${ie.errors.join(", ")}).`,u.GENERIC_FAILURE);return!g&&E&&x.push(...await oc({pmRoot:n,subject:l,settings:o,typeRegistry:i,historyRawBeforeLock:m,currentItem:I,nextItem:A,author:O,force:t.force,rewrittenEntries:J})),{id:l.id,dry_run:g,changed:E,patterns:{literal_count:d.filter(j=>j.kind==="literal").length,regex_count:d.filter(j=>j.kind==="regex").length,total_count:d.length,replacement_is_default:a},history:{path:l.historyPath,entries_scanned:h.length,entries_changed:_.entriesChanged,replacements:_.replacements,hash_mismatches_before:p.hashMismatchesBefore,hash_mismatches_after:p.hashMismatchesAfter,preexisting_hash_mismatches:y,audit_entry_added:Ee,verify_ok:ie.ok,verify_errors:ie.errors},item:{existed_before:I.path!==null,exists_after:A.path!==null,path_before:I.path,path_after:A.path,changed:V},warnings:[...new Set(x)].sort((j,Dn)=>j.localeCompare(Dn)),generated_at:v()}}(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]="412fc2d2-daee-5d87-82ab-5411a1503087")}catch{}})();function I_(e,t){let r=t??{};return e.filter(n=>r[n.id]!==n.updated_at).map(n=>n.id).sort((n,o)=>n.localeCompare(o))}export{Vh as a,Qe as b,jh as c,Hh as d,Zh as e,Cn as f,ac as g,S_ as h,Qn as i,Jn as j,eo as k,to as l,Dc as m,ro as n,no as o,lr as p,oo as q,io as r,so as s,ao as t,ho as u,go as v,wo as w,hr as x,bo as y,So as z,Oc as A,To as B,Oe as C,Pc as D,Pe as E,xo as F,Ao as G,yt as H,Co as I,gt as J,Ro as K,Qc as L,Do as M,yr as N,Lo as O,Mo as P,Po as Q,od as R,zo as S,ld as T,Ho as U,Bo as V,Ln as W,Go as X,Yo as Y,ze as Z,hi as _,Ld as $,Et as aa,vr as ba,bt as ca,vi as da,Ci as ea,Od as fa,Cr as ga,ne as ha,Tt as ia,xt as ja,Mt as ka,Gd as la,Nt as ma,Ge as na,Or as oa,Ye as pa,Ot as qa,Pt as ra,$t as sa,Ft as ta,Vr as ua,jr as va,ml as wa,Fn as xa,or as ya,Un as za,Vn as Aa,jn as Ba,mc as Ca,hc as Da,me as Ea,De as Fa,he as Ga,pe as Ha,Le as Ia,Me as Ja,ir as Ka,Yn as La,Is as Ma,vs as Na,Rs as Oa,ks as Pa,Vs as Qa,en as Ra,ea as Sa,_u as Ta,I_ as Ua,Lh as Va,Mh as Wa,Fa as Xa,Nh as Ya,Oh as Za};
19
+ //# sourceMappingURL=chunk-YVVZ3LQ6.js.map