@unbrained/pm-cli 2026.8.30 → 2026.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (176) hide show
  1. package/.agents/skills/HARNESS_COMPATIBILITY.md +1 -1
  2. package/.agents/skills/README.md +1 -1
  3. package/.agents/skills/pm-developer/SKILL.md +1 -1
  4. package/.agents/skills/pm-developer/references/COMMAND_PLAYBOOK.md +2 -2
  5. package/.agents/skills/pm-developer/references/MULTI_AGENT_MERGE.md +1 -1
  6. package/.agents/skills/pm-developer/references/TOKEN_BUDGETS.md +1 -1
  7. package/.agents/skills/pm-extensions/SKILL.md +2 -2
  8. package/.agents/skills/pm-extensions/references/AUTHORING.md +1 -1
  9. package/.agents/skills/pm-extensions/references/LIFECYCLE.md +1 -1
  10. package/.agents/skills/pm-sdk/SKILL.md +1 -1
  11. package/.agents/skills/pm-user/SKILL.md +2 -2
  12. package/.agents/skills/pm-user/references/WORKFLOWS.md +2 -2
  13. package/.claude-plugin/marketplace.json +2 -2
  14. package/AGENTS.md +16 -14
  15. package/CHANGELOG.md +41 -6
  16. package/README.md +3 -3
  17. package/dist/cli/commands/merge.d.ts +1 -1
  18. package/dist/cli/commands/merge.js +3 -3
  19. package/dist/cli/register-list-query.js +32 -17
  20. package/dist/cli/register-mutation.js +8 -5
  21. package/dist/cli/register-operations.d.ts +2 -0
  22. package/dist/cli/register-operations.js +20 -9
  23. package/dist/cli-bundle/bundle-manifest.json +144 -144
  24. package/dist/cli-bundle/chunks/{chunk-CMIEDWAY.js → chunk-2MC2LCXZ.js} +41 -41
  25. package/dist/cli-bundle/chunks/{chunk-WS2GJQVG.js → chunk-3WICXLVT.js} +2 -2
  26. package/dist/cli-bundle/chunks/{chunk-7SKMLSMX.js → chunk-6XIIGE7U.js} +2 -2
  27. package/dist/cli-bundle/chunks/chunk-ALKKAUFN.js +35 -0
  28. package/dist/cli-bundle/chunks/{chunk-MTTKAUBX.js → chunk-DTGWEL23.js} +2 -2
  29. package/dist/cli-bundle/chunks/chunk-GOACULJW.js +13 -0
  30. package/dist/cli-bundle/chunks/chunk-NOPL37X4.js +205 -0
  31. package/dist/cli-bundle/chunks/{chunk-2UETTHY6.js → chunk-TAG4VC22.js} +30 -30
  32. package/dist/cli-bundle/chunks/{chunk-3TEF3HM5.js → chunk-U45JXJCC.js} +2 -2
  33. package/dist/cli-bundle/chunks/{chunk-TGNAA66W.js → chunk-X4RCGLTX.js} +2 -2
  34. package/dist/cli-bundle/chunks/{chunk-2MKLQL2E.js → chunk-Y7VOMSZT.js} +2 -2
  35. package/dist/cli-bundle/chunks/{register-list-query-OMKJ5ONN.js → register-list-query-XYNX4ASQ.js} +11 -11
  36. package/dist/cli-bundle/chunks/register-mutation-2MVLRS3J.js +20 -0
  37. package/dist/cli-bundle/chunks/register-operations-WCIDXBU3.js +2 -0
  38. package/dist/cli-bundle/chunks/{register-setup-GLQ5SYV3.js → register-setup-KVNC5KPL.js} +2 -2
  39. package/dist/cli-bundle/focused-chunks/{chunk-HVQ22RC4.js → chunk-2FEZ5SKM.js} +2 -2
  40. package/dist/cli-bundle/focused-chunks/{chunk-Y3JJXRVK.js → chunk-4O4CJAR6.js} +5 -5
  41. package/dist/cli-bundle/focused-chunks/chunk-7VATS5QY.js +16 -0
  42. package/dist/cli-bundle/focused-chunks/{chunk-LYFWQMVC.js → chunk-BEVHCEWG.js} +2 -2
  43. package/dist/cli-bundle/focused-chunks/{chunk-TDK3OCX3.js → chunk-FWPLDEXF.js} +2 -2
  44. package/dist/cli-bundle/focused-chunks/chunk-JEFKLWMM.js +2 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-JZYPPMXF.js → chunk-KB5OFSFD.js} +2 -2
  46. package/dist/cli-bundle/focused-chunks/{chunk-73EDXGYE.js → chunk-MKHG3T76.js} +2 -2
  47. package/dist/cli-bundle/focused-chunks/{chunk-3AVAWVZA.js → chunk-PF3E6Q36.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/{chunk-AD6ULRAF.js → chunk-QDFJIRKN.js} +4 -4
  49. package/dist/cli-bundle/focused-chunks/{chunk-RKOKG43G.js → chunk-RMRCQPWU.js} +2 -2
  50. package/dist/cli-bundle/focused-chunks/{chunk-XXOWRJZ5.js → chunk-S4U5CN5Q.js} +2 -2
  51. package/dist/cli-bundle/focused-chunks/{chunk-THEPQMLX.js → chunk-SVXJYD6G.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/chunk-T2LXXSOD.js +158 -0
  53. package/dist/cli-bundle/focused-chunks/chunk-Y6JJIX6I.js +51 -0
  54. package/dist/cli-bundle/main.js +2 -2
  55. package/dist/cli-bundle/sdk-authoring.js +1 -1
  56. package/dist/cli-bundle/sdk-contracts.js +1 -1
  57. package/dist/cli-bundle/sdk-core.js +27 -27
  58. package/dist/cli-bundle/sdk-governance.js +1 -1
  59. package/dist/cli-bundle/sdk-graph.js +1 -1
  60. package/dist/cli-bundle/sdk-merge.js +33 -33
  61. package/dist/cli-bundle/sdk-query.js +1 -1
  62. package/dist/cli-bundle/sdk-runtime.js +1 -1
  63. package/dist/cli-bundle/sdk-testing.js +1 -1
  64. package/dist/cli-bundle/sdk.js +10 -10
  65. package/dist/core/history/drift-scan.js +6 -6
  66. package/dist/core/history/history.d.ts +6 -0
  67. package/dist/core/history/history.js +47 -5
  68. package/dist/core/history/replay.d.ts +12 -1
  69. package/dist/core/history/replay.js +60 -39
  70. package/dist/core/schema/runtime-schema.d.ts +4 -0
  71. package/dist/core/schema/runtime-schema.js +60 -48
  72. package/dist/core/schema/status-defs-file.js +5 -2
  73. package/dist/mcp/legacy-adapter.d.ts +11 -2
  74. package/dist/mcp/legacy-adapter.js +26 -12
  75. package/dist/mcp/server.d.ts +2 -2
  76. package/dist/mcp/server.js +78 -15
  77. package/dist/mcp/tool-definitions.js +56 -2
  78. package/dist/sdk/agent-capability-contracts.js +4 -2
  79. package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
  80. package/dist/sdk/cli-contracts/flag-contracts.js +6 -2
  81. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +1 -1
  82. package/dist/sdk/cli-contracts/grammar-contracts.js +12 -2
  83. package/dist/sdk/cli-contracts/runtime-contracts.js +3 -2
  84. package/dist/sdk/cli-contracts/tool-schema.js +11 -3
  85. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +14 -2
  86. package/dist/sdk/governance/health.js +17 -6
  87. package/dist/sdk/governance/status-role-diagnostics.d.ts +27 -0
  88. package/dist/sdk/governance/status-role-diagnostics.js +36 -0
  89. package/dist/sdk/governance/validate-normalization.d.ts +6 -0
  90. package/dist/sdk/governance/validate-normalization.js +37 -0
  91. package/dist/sdk/governance/validate.d.ts +1 -1
  92. package/dist/sdk/governance/validate.js +20 -35
  93. package/dist/sdk/governance/workspace-position.d.ts +69 -0
  94. package/dist/sdk/governance/workspace-position.js +164 -0
  95. package/dist/sdk/governance.d.ts +2 -0
  96. package/dist/sdk/governance.js +4 -2
  97. package/dist/sdk/history-read.js +14 -6
  98. package/dist/sdk/history-repair.js +17 -10
  99. package/dist/sdk/index.d.ts +2 -1
  100. package/dist/sdk/index.js +4 -3
  101. package/dist/sdk/init-agent-guidance.js +4 -4
  102. package/dist/sdk/lifecycle/update.js +23 -10
  103. package/dist/sdk/mcp/discovery.d.ts +152 -0
  104. package/dist/sdk/mcp/discovery.js +495 -0
  105. package/dist/sdk/mcp/protocol.d.ts +10 -2
  106. package/dist/sdk/mcp/protocol.js +15 -4
  107. package/dist/sdk/merge/index.d.ts +1 -1
  108. package/dist/sdk/merge/index.js +3 -3
  109. package/dist/sdk/merge/receipts.d.ts +27 -1
  110. package/dist/sdk/merge/receipts.js +27 -8
  111. package/dist/sdk/merge/three-way.d.ts +3 -1
  112. package/dist/sdk/merge/three-way.js +9 -7
  113. package/dist/sdk/query/context.js +11 -14
  114. package/dist/sdk/query/list.d.ts +2 -0
  115. package/dist/sdk/query/list.js +33 -12
  116. package/dist/sdk/runtime-extended-actions.js +10 -6
  117. package/dist/sdk/schema.js +12 -2
  118. package/dist/sdk/test/execution.d.ts +15 -0
  119. package/dist/sdk/test/execution.js +35 -27
  120. package/docs/AGENT_GUIDE.md +12 -4
  121. package/docs/AGENT_PROVENANCE_ADR.md +1 -1
  122. package/docs/AGENT_RUNTIME_PRIMITIVES.md +2 -2
  123. package/docs/ARCHITECTURE.md +5 -0
  124. package/docs/CLAUDE_CODE_PLUGIN.md +5 -5
  125. package/docs/COMMANDS.md +12 -12
  126. package/docs/CONFIGURATION.md +1 -1
  127. package/docs/CONTEXT_RECOVERY_PRIMITIVES.md +14 -5
  128. package/docs/DEFECT_RECURRENCE.md +2 -0
  129. package/docs/MCP_2026_07_28.md +33 -9
  130. package/docs/MCP_2026_07_28_CONFORMANCE.md +1 -0
  131. package/docs/MCP_CAPABILITY_SURFACES.md +7 -1
  132. package/docs/MCP_REMOTE_TRANSPORT_SECURITY.md +15 -3
  133. package/docs/MERGE_SAFETY.md +30 -2
  134. package/docs/ONBOARDING.md +1 -1
  135. package/docs/OUTPUT_TOKEN_ACCOUNTING.md +5 -3
  136. package/docs/PROGRESSIVE_TOOL_DISCOVERY.md +42 -0
  137. package/docs/README.md +3 -1
  138. package/docs/READ_OUTPUT_CONTRACTS.md +1 -1
  139. package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +1 -1
  140. package/docs/SDK.md +3 -3
  141. package/docs/TESTING.md +23 -14
  142. package/docs/WORKSPACE_POSITION_AND_LIFECYCLE.md +113 -0
  143. package/docs/agent-task-token-baseline.json +157 -3
  144. package/docs/agent-task-transcripts.json +143 -0
  145. package/docs/examples/policy-restricted-extension/README.md +2 -2
  146. package/docs/examples/starter-extension/README.md +1 -1
  147. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
  148. package/docs/performance/cli-transport-overhead.md +8 -6
  149. package/marketplace.json +2 -2
  150. package/package.json +4 -4
  151. package/packages/pm-beads/package.json +1 -1
  152. package/packages/pm-calendar/package.json +1 -1
  153. package/packages/pm-command-kit/package.json +1 -1
  154. package/packages/pm-digital-twin/package.json +1 -1
  155. package/packages/pm-governance-audit/package.json +1 -1
  156. package/packages/pm-guide-shell/package.json +1 -1
  157. package/packages/pm-kanban/package.json +1 -1
  158. package/packages/pm-lifecycle-hooks/package.json +1 -1
  159. package/packages/pm-linked-test-adapters/package.json +1 -1
  160. package/packages/pm-search-advanced/package.json +1 -1
  161. package/packages/pm-templates/package.json +1 -1
  162. package/packages/pm-todos/package.json +1 -1
  163. package/packages/pm-vcs/package.json +1 -1
  164. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  165. package/plugins/pm-claude/README.md +4 -3
  166. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  167. package/sdk/public-surface.json +314 -10
  168. package/dist/cli-bundle/chunks/chunk-7X6OZEIV.js +0 -34
  169. package/dist/cli-bundle/chunks/chunk-GNWPTEBW.js +0 -205
  170. package/dist/cli-bundle/chunks/chunk-N6OR6FAR.js +0 -13
  171. package/dist/cli-bundle/chunks/register-mutation-QBSNCOY3.js +0 -20
  172. package/dist/cli-bundle/chunks/register-operations-UC77FQZC.js +0 -2
  173. package/dist/cli-bundle/focused-chunks/chunk-3UMBF26I.js +0 -158
  174. package/dist/cli-bundle/focused-chunks/chunk-AXZ5AJAF.js +0 -50
  175. package/dist/cli-bundle/focused-chunks/chunk-G6PATS5E.js +0 -16
  176. package/dist/cli-bundle/focused-chunks/chunk-LLNTHF5X.js +0 -2
@@ -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]="4efc5934-7d1b-517b-8b5e-eb2fe14379f2")}catch{}})();var X=["item","list","context","search","graph","history","workspace","package","ops","plan","contracts","help"],fe=["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),ce=["--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"],w=["--allow-multiple-active","--depends-on","--file","--force","--message","--step-blocked-reason","--step-body","--step-evidence","--step-owner","--step-status","--step-title","--test"],pe={"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:ce,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:w,description:"Append one ordered step to a Plan item.",example:'pm plan add-step pm-a1b2 --step-title "Run tests"'},...Object.entries(pe).map(([e,a])=>({command:`plan ${e}`,parent:"plan",action:e,slots:[C,D],accepted_flags:w,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:w,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 position",parent:"workspace",action:"position",slots:[],accepted_flags:[],description:"Read bounded merge-fence, receipt, history-drift, and next-action readiness.",example:"pm workspace position"},{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"}],de=[...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 qa(e){let a=_(e),t=L.find(r=>r.command===a);if(t)return t;let l=P(a)?.canonical;if(l)return L.find(r=>r.command===l)}function me(e){let a=_(e);return de.find(t=>t.command===a||a.startsWith(`${t.command} `))}function Ba(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 position","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"])],L=[...new Set(x.map(({command:e})=>e))].map(e=>({command:e,slots:me(e)?.slots??z.get(e)??[]})),b={nouns:X,shared_verbs:fe,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 ue(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 Ya(e,a={}){let t=a.declared??L,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})=>ue(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 _e(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 he(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 ve(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 Ha(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=[..._e(l,c,n),...he(r,t),...ve(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]="789faf62-dfbf-56ff-9412-55adc5c12d3d")}catch{}})();function N(e){return e.startsWith("--")?`--${e.slice(2).replaceAll("_","-")}`:e}function E(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 Za(e){let a=E(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 R=I.map(e=>({flag:e.flag,...e.aliases?{aliases:[...e.aliases]}:{},...e.value_name?{value_name:e.value_name}:{}})),et=[...R,{flag:"--version"}],K=[{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"}],V=[{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"}],F=G([{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"},...K,{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"])),Te=[{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}],Ae=[{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:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];function G(e,a){return e.map(t=>a.has(t.flag)?{...t,cursor_semantics:"presentation"}:t)}var Ce=[{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:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],ye=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--learning","--text"]},{flag:"--limit"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{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:"--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"}],be=[{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"}],xe=[{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"}],Se=[{flag:"--dry-run"},{flag:"--output"},{flag:"--item-path"},{flag:"--prefer"}],Ne=[{flag:"--id",value_name:"item-id"},{flag:"--literal"},{flag:"--regex"},{flag:"--replacement"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Oe=[{flag:"--id",value_name:"item-id"},{flag:"--all"},{flag:"--dry-run"},{flag:"--normalize-provenance"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],we=[{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"}],Le=[{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"}],Ee=[{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"}],Re=[{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"}],Fe=[{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"}],Ge=[{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"}],Ie=[...Q,{flag:"--declarative"}],Pe=[{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],Me=m,De=m,$e=[...m,{flag:"--markdown"},{flag:"--output"}],Ue=m,Xe=m,ze=m,je=[...m,{flag:"--dry-run"}],qe=[...m,{flag:"--runtime-probe"},{flag:"--fix-managed-state"}],Be=[...m,{flag:"--watch"}],Ye=[...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}],He=[...m,{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],Ke=[{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"}],at=[{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"}],We=[{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"},...V,{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"}],Je=[{flag:"--id",value_name:"item-id"},{flag:"--body",short:"-b"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],Qe=[{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"]}],Ze=[{flag:"--id",value_name:"item-id"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],ea=[{flag:"--id",value_name:"item-id"},{flag:"--dry-run"},{flag:"--author"},{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:"--force"}],sa=[{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],ra=ae,na=[{flag:"--at"},{flag:"--text"},...ee],oa=[{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"}],ia=[{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"}],ga=[{flag:"--limit"}],fa=[{flag:"--status"},{flag:"--limit"},{flag:"--stream"},{flag:"--tail"},{flag:"--force"},{flag:"--author"}],ca=[{flag:"--dry-run"},{flag:"--scope"}],pa=[{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"}],da=[{flag:"--status",repeatable:!0,list:!0},{flag:"--since"},{flag:"--threshold"},{flag:"--limit"}],ma=[{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"}],ua=[{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"}],_a=[{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"}],ha=[{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"}],va=[{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"}],Ta=[{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"}],Aa=[{flag:"--id",value_name:"item-id"},{flag:"--clear"}],Ca=[{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"}],ya=[{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"},...V,{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"}],ka=[{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"}],ba=[{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=G([{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"])),xa=[{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"}],Sa=[{flag:"--list"},{flag:"--format"},{flag:"--depth"}],Na=[{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}],Oa=[{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"}],wa=[{flag:"--mode"},{flag:"--k"},{flag:"--fail-under"},{flag:"--queries"},{flag:"--format"}],u=[{flag:"--dry-run"},{flag:"--force"},{flag:"--author"},{flag:"--message"}],ne=[],La=[{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"]}],Ea=G([{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"},...K],new Set(["--highlight","--compact","--full","--fields","--format","--limit","--token-budget","--after"])),Ra=[{flag:"--action"},{flag:"--command"},{flag:"--summary"},{flag:"--schema-only"},{flag:"--flags-only"},{flag:"--availability-only"},{flag:"--runtime-only"},{flag:"--active-only"},{flag:"--full"}],Fa=[{flag:"--eager-tags"}];function tt(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[...R,...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 E([...a.values()])}var Ga=["list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled"],Ia=F.filter(e=>e.flag!=="--status"&&e.flag!=="--all"),Pa=F.filter(e=>e.flag!=="--status");function O(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 Ma=O(W),Da=O(te),$a=new Map([["assurance",Da],["plan",Ma],["workspace",O(ne)],["workspace snapshot",O(u)]]);function Ua(e=v){return e.map(({command:a,parent:t,accepted_flags:l})=>{let r=$a.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 Xa=Ua(),oe=new Map([["list",F],["list-all",Pa],...Ga.map(e=>[e,Ia]),["templates",B],["cal",Y],["ctx",H],["test-runs-worker",fa],["init",Fe],["config",Ge],["extension",J],["package",j],["packages",j],["install",Ke],["upgrade",Z],["create",B],["item mutate",_a],["item complete",ha],["item reopen",va],["copy",Ta],["focus",Aa],["aggregate",Te],["calendar",Y],["context",H],["get",xa],["guide",Sa],["search",Ea],["next",La],["eval",wa],["workspace",u],["workspace position",ne],["workspace snapshot",u],["workspace snapshot create",u],["workspace snapshot list",u],["workspace snapshot inspect",u],["workspace snapshot restore",u],["workspace snapshot delete",u],["history",xe],["history-redact",Ne],["history-repair",Oe],["history-author-acknowledge",we],["history-compact",Le],["merge",Se],["schema",Ee],["profile",Re],["plan",W],["activity",ka],["events",ba],["restore",Ze],["update",Ca],["update-many",ya],["close",Ve],["close-many",We],["delete",ea],["append",Je],["comments",Ae],["notes",Ce],["learnings",ye],["files",ke],["docs",be],["deps",Na],["graph",Oa],["test",oa],["test-all",ia],["telemetry",ga],["health",ma],["assurance",te],...Xa,["validate",ua],["gc",ca],["stats",pa],["duplicates",da],["contracts",Ra],["completion",Fa],["claim",Qe],["release",aa],["start-task",ta],["pause-task",la],["close-task",sa],["meet",ae],["event",ra],["remind",na]]),ie=new Map([["install",Pe],["uninstall",Me],["explore",De],["manage",qe],["describe",$e],["reload",Be],["doctor",Ye],["catalog",q],["list",q],["adopt",He],["adopt-all",Ue],["activate",Xe],["deactivate",ze],["migrate",je]]);function ge(e){return typeof e!="string"?"":e.trim().toLowerCase()}function lt(e){let a=ge(e);if(oe.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"||ie.has(l))}function za(e,a){return a==="init"||a==="scaffold"?e==="extension"?Q:Ie:ie.get(a)??[]}function st(e){let a=ge(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:za(t,l));let n=oe.get(a)??[];return S(n)}function rt(e,a=!0){let l=E(e).flatMap(n=>[n.short,n.flag,...n.aliases??[]]).filter(n=>!!n),r=a?[...l,...R.flatMap(n=>[n.short,n.flag,...n.aliases??[]]).filter(n=>!!n)]:l;return y(r).join(" ")}export{y as a,X as b,fe as c,v as d,qa as e,me as f,Ba as g,x as h,L as i,b as j,$ as k,ue as l,k as m,Ya as n,Ha as o,E as p,Za as q,R as r,et as s,F as t,Te as u,Ae as v,Ce as w,ye as x,ke as y,be as z,xe as A,Se as B,Ne as C,Oe as D,we as E,Le as F,Ee as G,Re as H,W as I,Fe as J,Ge as K,J as L,m as M,Q as N,j as O,Ie as P,Pe as Q,Me as R,De as S,$e as T,Ue as U,Xe as V,ze as W,je as X,qe as Y,Be as Z,Ye as _,q as $,He as aa,Ke as ba,Z as ca,at as da,Ve as ea,We as fa,Je as ga,Qe as ha,Ze as ia,ea as ja,aa as ka,ta as la,la as ma,sa as na,ae as oa,ra as pa,na as qa,oa as ra,ia as sa,ga as ta,fa as ua,ca as va,pa as wa,da as xa,ma as ya,ua as za,te as Aa,B as Ba,_a as Ca,ha as Da,va as Ea,Ta as Fa,Aa as Ga,Ca as Ha,ya as Ia,Y as Ja,ka as Ka,ba as La,H as Ma,xa as Na,Sa as Oa,Na as Pa,Oa as Qa,wa as Ra,u as Sa,La as Ta,Ea as Ua,Ra as Va,Fa as Wa,tt as Xa,Ua as Ya,Xa as Za,lt as _a,st as $a,rt as ab};
2
+ //# sourceMappingURL=chunk-JEFKLWMM.js.map
@@ -1,4 +1,4 @@
1
- import{f as w,i as f,j as B,k as j,l as U,o as y,p as X,q as W,r as Y}from"./chunk-Y3JJXRVK.js";import{C as H,a as P,b as D}from"./chunk-LYFWQMVC.js";import{c as u,f as M,g as z,i as q}from"./chunk-HVQ22RC4.js";import{Ua as F,q as L,t as R}from"./chunk-LLNTHF5X.js";import{La as g,Na as K,_ as k}from"./chunk-AD6ULRAF.js";import{a as N,e as x,f as O,g as A,i as C,l as $}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]="bb16b445-3bd4-520d-becf-c55621bfa186")}catch{}})();var Ce=N,$e=x,Pe=C,De=O,Le=A;function G(e,t,n,s){let r=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),o=n.has(r);return{long:t,...s?{short:s}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:o?"string":"boolean",...o?{value_name:e.value_name??"value"}:{}}}function Q(e,t=[]){let n=new Set(t.flatMap(r=>r.keys)),s=[];for(let r of L(e.map(o=>({...o})))){s.push(G(r,r.flag,n,r.short));for(let o of r.aliases??[])s.push(G(r,o,n))}return s}var Re=Q(R,P),Fe=Q(F,D);(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]="bed1d1d4-0c1d-59e5-8267-fbe800dfd83b")}catch{}})();var _=["agile","ops","research"],I={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:w.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
1
+ import{f as w,i as f,j as B,k as j,l as U,o as y,p as X,q as W,r as Y}from"./chunk-4O4CJAR6.js";import{C as H,a as P,b as D}from"./chunk-BEVHCEWG.js";import{c as u,f as M,g as z,i as q}from"./chunk-2FEZ5SKM.js";import{Ua as F,q as L,t as R}from"./chunk-JEFKLWMM.js";import{La as g,Na as K,_ as k}from"./chunk-QDFJIRKN.js";import{a as N,e as x,f as O,g as A,i as C,l as $}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]="bb16b445-3bd4-520d-becf-c55621bfa186")}catch{}})();var Ce=N,$e=x,Pe=C,De=O,Le=A;function G(e,t,n,s){let r=e.flag.slice(2).replace(/[-_]([a-z])/gu,(i,a)=>a.toUpperCase()),o=n.has(r);return{long:t,...s?{short:s}:{},description:e.description??`Standard pm ${e.flag} option.`,...e.required===!0?{required:!0}:{},...e.list===!0?{list:!0}:{},...e.repeatable===!0?{repeatable:!0}:{},value_type:o?"string":"boolean",...o?{value_name:e.value_name??"value"}:{}}}function Q(e,t=[]){let n=new Set(t.flatMap(r=>r.keys)),s=[];for(let r of L(e.map(o=>({...o})))){s.push(G(r,r.flag,n,r.short));for(let o of r.aliases??[])s.push(G(r,o,n))}return s}var Re=Q(R,P),Fe=Q(F,D);(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]="bed1d1d4-0c1d-59e5-8267-fbe800dfd83b")}catch{}})();var _=["agile","ops","research"],I={agile:{name:"agile",title:"Agile delivery",summary:"Story/Spike delivery with a review stage, story points, and acceptance ownership.",types:w.agile,statuses:[{id:"review",roles:["active"],aliases:["in-review"],description:"Work is implementation-complete and awaiting peer review."}],fields:[{key:"story_points",type:"number",commands:["create","update","list"],description:"Relative estimation size for a story or spike.",aliases:["points"]},{key:"acceptance_owner",type:"string",commands:["create","update","list"],description:"Stakeholder accountable for accepting the delivered story.",aliases:["acceptor"]}],workflows:[{type:"Story",allowed_transitions:[["open","in_progress"],["in_progress","review"],["review","in_progress"],["review","closed"],["in_progress","blocked"],["blocked","in_progress"]]}],config:[{key:"search_provider",value:"bm25",summary:"Offline BM25 lexical search works without an embedding service."},{key:"search_max_results",value:"20",summary:"Sprint-sized result cap for quick triage."}],templates:[{name:"story",options:{type:"Story",priority:"2",tags:"story",acceptanceCriteria:"Story delivers the stated user outcome with tests and docs updated.",body:`## As a
2
2
 
3
3
  ## I want
4
4
 
@@ -23,4 +23,4 @@ import{f as w,i as f,j as B,k as j,l as U,o as y,p as X,q as W,r as Y}from"./chu
23
23
 
24
24
  ## Conclusion
25
25
  `}}],packages:[{spec:"search-advanced",reason:"Semantic retrieval over experiments and findings."},{spec:"templates",reason:"Consistent experiment and hypothesis scaffolds."},{spec:"beads",reason:"Import structured prior work into the tracker."}]}};function ne(e){if(e===void 0)return;let t=p(e);if(t.length===0)throw new Error("Profile name must not be empty.");if(_.includes(t))return t;throw new Error(`Invalid profile "${e}". Allowed: ${_.join(", ")}.`)}function qe(e){let t=ne(e);if(t===void 0)throw new Error(`Profile name is required. Allowed: ${_.join(", ")}.`);return I[t]}function Be(){return _.map(e=>I[e])}function p(e){return e.trim().toLowerCase().replaceAll("-","_")}function J(e){return e.map(t=>t.definition.name).join(", ")}function se(e=[]){let t=_.map(o=>({definition:I[o],source:"builtin"})),n=new Set(_.map(o=>p(o))),s=new Set(n),r=[];for(let o of e){let i=p(o.profile.name);if(n.has(i)){r.push(`Extension "${o.name}" profile "${o.profile.name}" uses a name reserved by a built-in archetype and was ignored.`);continue}if(s.has(i)){r.push(`Profile "${o.profile.name}" from extension "${o.name}" duplicates an already-registered profile and was ignored.`);continue}s.add(i),t.push({definition:o.profile,source:"extension",package:o.name})}return{profiles:t,warnings:r}}function je(e,t=[]){let{profiles:n,warnings:s}=se(t);if(typeof e!="string"||e.trim().length===0)throw new Error(`Profile name is required. Allowed: ${J(n)}.`);let r=p(e),o=n.find(i=>p(i.definition.name)===r);if(o===void 0)throw new Error(`Invalid profile "${e}". Allowed: ${J(n)}.`);return{resolved:o,warnings:s}}(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]="933d8f74-c4aa-58d0-bd3b-8932a35d3702")}catch{}})();function re(e){return{types:e.types.length,statuses:e.statuses.length,fields:e.fields.length,workflows:e.workflows.length,config:e.config.length,templates:e.templates.length,packages:e.packages.length}}function Ye(e){return{name:e.name,title:e.title,summary:e.summary,composition:re(e),types:e.types.map(t=>S(()=>u(t).name,()=>String(t.name??""))),statuses:e.statuses.map(t=>S(()=>y(t).id,()=>String(t.id??""))),fields:e.fields.map(t=>S(()=>f(t).key,()=>String(t.key??""))),workflows:e.workflows.map(t=>t.type),config:e.config.map(t=>`${t.key}=${t.value}`),templates:e.templates.map(t=>t.name),packages:e.packages.map(t=>({spec:t.spec,reason:t.reason}))}}function S(e,t){try{return e()}catch{return 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]="4e50d57b-4502-5ce5-a6dd-0bdc8eba5af4")}catch{}})();var oe=[{key:"search_provider",path:"search.provider",kind:"string",summary:"Search embedding provider name (e.g. openai, ollama, or an extension provider)."},{key:"search_mutation_refresh_policy",path:"search.mutation_refresh_policy",kind:"string",choices:["cache_only","semantic_configured","semantic_auto"],summary:"Mutation-time search refresh policy: cache_only, semantic_configured, or semantic_auto."},{key:"search_query_expansion_enabled",path:"search.query_expansion.enabled",kind:"boolean",summary:"Enable or disable query expansion for semantic/hybrid search."},{key:"search_query_expansion_provider",path:"search.query_expansion.provider",kind:"string",summary:"Query expansion provider name (built-in openai/ollama or extension provider)."},{key:"search_rerank_enabled",path:"search.rerank.enabled",kind:"boolean",summary:"Enable or disable post-retrieval reranking for hybrid search."},{key:"search_rerank_model",path:"search.rerank.model",kind:"string",summary:"Rerank model name override used by built-in providers."},{key:"search_rerank_top_k",path:"search.rerank.top_k",kind:"integer",min:1,summary:"Number of top hybrid candidates to rerank when rerank is enabled."},{key:"search_embedding_model",path:"search.embedding_model",kind:"string",summary:"Default embedding model name (overrides provider-specific model when set)."},{key:"search_embedding_corpus_max_characters",path:"search.embedding_corpus_max_characters",kind:"integer",min:1,summary:"Maximum semantic corpus characters per item before truncation."},{key:"search_embedding_batch_size",path:"search.embedding_batch_size",kind:"integer",min:1,summary:"Number of items embedded per request batch."},{key:"search_embedding_timeout_ms",path:"search.embedding_timeout_ms",kind:"integer",min:1,summary:"Per-request embedding timeout in milliseconds."},{key:"search_score_threshold",path:"search.score_threshold",kind:"number",summary:"Minimum score for a hit to be returned (0 keeps all matches)."},{key:"search_hybrid_semantic_weight",path:"search.hybrid_semantic_weight",kind:"ratio",summary:"Hybrid mode semantic weight in [0, 1] (1-weight goes to keyword)."},{key:"search_max_results",path:"search.max_results",kind:"integer",min:1,summary:"Default upper bound on search hits when --limit is not supplied."},{key:"search_bm25_k1",path:"search.bm25.k1",kind:"number",min:0,summary:"Offline BM25 term-frequency saturation (k1); higher saturates repeated terms slower (default 1.2)."},{key:"search_bm25_b",path:"search.bm25.b",kind:"ratio",summary:"Offline BM25 document-length normalization (b) in [0, 1]; 0 disables, 1 fully normalizes (default 0.75)."},{key:"openai_base_url",path:"providers.openai.base_url",kind:"string",summary:"OpenAI-compatible API base URL (LM Studio/vLLM also use this)."},{key:"openai_api_key",path:"providers.openai.api_key",kind:"string",summary:"OpenAI-compatible API key."},{key:"openai_model",path:"providers.openai.model",kind:"string",summary:"OpenAI-compatible embedding model name."},{key:"ollama_base_url",path:"providers.ollama.base_url",kind:"string",summary:"Ollama API base URL (typically http://localhost:11434)."},{key:"ollama_model",path:"providers.ollama.model",kind:"string",summary:"Ollama embedding model name (e.g. nomic-embed-text)."},{key:"vector_store_adapter",path:"vector_store.adapter",kind:"string",summary:"Vector store adapter name (lancedb, qdrant, or an extension adapter)."},{key:"vector_store_collection_name",path:"vector_store.collection_name",kind:"string",non_empty:!0,summary:"Vector collection/table name shared by Qdrant and LanceDB adapters."},{key:"qdrant_url",path:"vector_store.qdrant.url",kind:"string",summary:"Qdrant HTTP API URL."},{key:"qdrant_api_key",path:"vector_store.qdrant.api_key",kind:"string",summary:"Qdrant API key (empty if running unauthenticated)."},{key:"lancedb_path",path:"vector_store.lancedb.path",kind:"string",summary:"LanceDB storage path (relative to pm root or absolute)."},{key:"id_prefix",path:"id_prefix",kind:"string",non_empty:!0,summary:'Prefix for generated item IDs (e.g. "pm" produces pm-xxxx).'},{key:"author_default",path:"author_default",kind:"string",non_empty:!0,summary:"Default author recorded on mutations when --author is not supplied."},{key:"agent_identity_probes_enabled",path:"agent_identity.probes_enabled",kind:"boolean",summary:"Allow privacy-bounded local harness provenance probes; no network or subprocess access is permitted."},{key:"mutation_guard_require_attributed_author",path:"mutation_guard.require_attributed_author",kind:"boolean",summary:"Reject mutations whose effective author resolves to unknown."},{key:"mutation_guard_secret_guard",path:"mutation_guard.secret_guard",kind:"string",choices:["off","advise","block"],summary:"Detect credential-shaped mutation content: off, advise, or block."},{key:"mutation_guard_stale_in_progress_hours",path:"mutation_guard.stale_in_progress_hours",kind:"integer",min:1,summary:"Age threshold for unclaimed in-progress work surfaced by health."},{key:"governance_duplicate_detection_mode",path:"governance.duplicate_detection_mode",kind:"string",choices:["off","advisory","strict"],summary:"Create/copy duplicate governance: off, advisory, or strict explicit-bypass enforcement."},{key:"governance_duplicate_detection_threshold",path:"governance.duplicate_detection_threshold",kind:"ratio",summary:"Minimum shared similarity score in [0, 1] for create/copy duplicate governance."},{key:"governance_duplicate_detection_limit",path:"governance.duplicate_detection_limit",kind:"integer",min:0,max:20,summary:"Maximum likely duplicates returned by create/copy governance (0-20)."},{key:"output_default_format",path:"output.default_format",kind:"string",choices:["toon","json"],summary:"Default output format for commands that support it: toon or json."},{key:"ux_deprecation_hints",path:"ux.deprecation_hints",kind:"boolean",summary:"Emit one stderr migration hint for deprecated command aliases."},{key:"locks_ttl_seconds",path:"locks.ttl_seconds",kind:"integer",min:1,summary:"Claim/lock time-to-live in seconds before a stale lock can be reclaimed."},{key:"locks_wait_ms",path:"locks.wait_ms",kind:"integer",min:0,summary:"Bounded jittered wait in milliseconds before a contended item mutation fails with lock_conflict; 0 fails fast. PM_LOCK_WAIT_MS overrides per invocation."},{key:"ids_token_length",path:"ids.token_length",kind:"integer",min:4,max:12,summary:"Random base36 token length for newly minted item ids (4-12, default 4). Raise it to shrink cross-branch id collision odds in concurrent multi-agent workflows (pm-pibw)."},{key:"checkpoints_retention_days",path:"checkpoints.retention_days",kind:"integer",min:1,summary:"Age in days above which pm gc --scope checkpoints prunes bulk-mutation rollback checkpoints."},{key:"schema_unknown_field_policy",path:"schema.unknown_field_policy",kind:"string",choices:["allow","warn","reject"],summary:"How item I/O handles metadata keys not in the field registry: allow, warn, or reject."},{key:"history_compact_policy_enabled",path:"history.compact_policy.enabled",kind:"boolean",summary:"Enable the history-compaction advisory: pm health warns on over-threshold streams."},{key:"history_compact_policy_max_entries",path:"history.compact_policy.max_entries",kind:"integer",min:1,summary:"Entry count above which a history stream is flagged (and the default pm history-compact --all-over threshold)."},{key:"history_compact_policy_trigger",path:"history.compact_policy.trigger",kind:"string",choices:["health_warn","auto"],summary:"History-compaction policy intent: health_warn (advisory only) or auto (scheduled sweeps expected)."}],ie=new Map(oe.flatMap(e=>[[e.key,e],[e.path.toLowerCase().replaceAll("-","_"),e]]));function b(e){if(typeof e!="string")return;let t=e.trim().toLowerCase().replaceAll("-","_");if(t.length!==0)return ie.get(t)}function ae(e,t){let n=t.trim().toLowerCase();return n==="true"||n==="1"||n==="yes"||n==="on"?{ok:!0,parsed:{descriptor:e,value:!0}}:n==="false"||n==="0"||n==="no"||n==="off"?{ok:!0,parsed:{descriptor:e,value:!1}}:{ok:!1,error:{message:`Config set ${e.key} requires a boolean value (true|false), got "${t}"`}}}function le(e,t,n){return e.non_empty===!0&&n.length===0?{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}}:e.choices&&!e.choices.includes(n)?{ok:!1,error:{message:`Config set ${e.key} must be one of ${e.choices.join("|")}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function de(e,t,n){if(n.length===0)return{ok:!1,error:{message:`Config set ${e.key} requires a non-empty value`}};let s=Number(n);return Number.isFinite(s)?{ok:!0,value:s}:{ok:!1,error:{message:`Config set ${e.key} requires a finite number, got "${t}"`}}}function ce(e,t,n){return!Number.isInteger(n)||n<0?{ok:!1,error:{message:`Config set ${e.key} requires a non-negative integer, got "${t}"`}}:e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires an integer >= ${e.min}, got "${t}" (the runtime silently ignores 0 here and falls back to the default)`}}:e.max!==void 0&&n>e.max?{ok:!1,error:{message:`Config set ${e.key} requires an integer <= ${e.max}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function me(e,t,n){return n<0||n>1?{ok:!1,error:{message:`Config set ${e.key} requires a number in [0, 1], got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function pe(e,t,n){return e.min!==void 0&&n<e.min?{ok:!1,error:{message:`Config set ${e.key} requires a number >= ${e.min}, got "${t}"`}}:{ok:!0,parsed:{descriptor:e,value:n}}}function v(e,t){if(typeof t!="string")return{ok:!1,error:{message:`Config set ${e.key} requires a string value`}};let n=t.trim();if(e.kind==="boolean")return ae(e,t);if(e.kind==="string")return le(e,t,n);let s=de(e,t,n);return s.ok?e.kind==="integer"?ce(e,t,s.value):e.kind==="ratio"?me(e,t,s.value):pe(e,t,s.value):{ok:!1,error:s.error}}function V(e,t){let n=t.path.split("."),s=e;for(let r of n){if(typeof s!="object"||s===null)return null;s=s[r]}return typeof s=="string"||typeof s=="number"||typeof s=="boolean"?s:null}function Ge(e,t,n){let s=t.path.split("."),r=e;for(let a=0;a<s.length-1;a+=1){let c=s[a],d=r[c];if(typeof d!="object"||d===null||Array.isArray(d)){let l={};r[c]=l,r=l}else r=d}let o=s[s.length-1];return r[o]===n?!1:(r[o]=n,!0)}(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]="f9b22df0-7ec2-5d72-bc88-3eb7201a6051")}catch{}})();var at=["profile","types","statuses","fields","workflows","config","templates","packages"],lt=["profile_name_empty","profile_name_not_normalized","profile_title_empty","profile_summary_empty","type_invalid","type_duplicate","status_invalid","status_duplicate","field_invalid","field_duplicate","field_mcp_input_collision","workflow_type_empty","workflow_type_unknown","workflow_duplicate_type","workflow_transition_malformed","workflow_status_unknown","config_key_unknown","config_value_invalid","config_duplicate","template_type_unknown","package_spec_empty"],ue=new Set(K.flatMap(e=>[g(e.id),...(e.aliases??[]).map(t=>g(t))]).filter(e=>e.length>0)),Z=new Set($.map(e=>e.toLowerCase()));function fe(e,t){e.name.trim().length===0?t.push({severity:"error",code:"profile_name_empty",dimension:"profile",message:"Profile name must not be empty; profile resolution requires a non-blank name."}):e.name!==p(e.name)&&t.push({severity:"warning",code:"profile_name_not_normalized",dimension:"profile",target:e.name,message:`Profile name "${e.name}" is not in canonical form; resolution folds it to "${p(e.name)}" (lowercase, hyphens as underscores).`}),e.title.trim().length===0&&t.push({severity:"warning",code:"profile_title_empty",dimension:"profile",message:"Profile title is empty; list and show surfaces will render a blank title."}),e.summary.trim().length===0&&t.push({severity:"warning",code:"profile_summary_empty",dimension:"profile",message:"Profile summary is empty; list and show surfaces will render a blank archetype description."})}function ye(e,t){let n=new Set,s=new Set;for(let[r,o]of e.types.entries()){let i;try{i=u(o).name}catch(c){t.push({severity:"error",code:"type_invalid",dimension:"types",target:typeof o.name=="string"?o.name:`#${r}`,message:k(c)});continue}let a=i.toLowerCase();if(s.has(a)){t.push({severity:"error",code:"type_duplicate",dimension:"types",target:i,message:`Item type "${i}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}s.add(a),n.add(a)}return n}function he(e,t){let n=new Set,s=new Set;for(let[r,o]of e.statuses.entries()){let i;try{i=y(o)}catch(a){t.push({severity:"error",code:"status_invalid",dimension:"statuses",target:typeof o.id=="string"?o.id:`#${r}`,message:k(a)});continue}if(s.has(i.id)){t.push({severity:"error",code:"status_duplicate",dimension:"statuses",target:i.id,message:`Status "${i.id}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}s.add(i.id),n.add(i.id);for(let a of i.aliases??[])n.add(g(a))}return n}function ge(e,t){let n=new Set;for(let[s,r]of e.fields.entries()){let o;try{o=f(r).key}catch(a){t.push({severity:"error",code:"field_invalid",dimension:"fields",target:typeof r.key=="string"?r.key:`#${s}`,message:k(a)});continue}if(n.has(o)){t.push({severity:"error",code:"field_duplicate",dimension:"fields",target:o,message:`Field "${o}" is declared more than once; the later definition silently overwrites the earlier upsert.`});continue}n.add(o);let i=H(o);i&&t.push({severity:"warning",code:"field_mcp_input_collision",dimension:"fields",target:o,message:`Field "${o}" collides with canonical MCP property "${i.property}" owned by ${i.owner}; callers must pass the custom value through ${i.nested_path}.`})}}function _e(e,t,n,s){let r=new Set;for(let[o,i]of e.workflows.entries()){let a=i.type.trim().toLowerCase();if(a.length===0){s.push({severity:"error",code:"workflow_type_empty",dimension:"workflows",target:`#${o}`,message:"Workflow has an empty type; the workflow resolver drops entries without a type."});continue}let c=r.has(a);r.add(a),c?s.push({severity:"warning",code:"workflow_duplicate_type",dimension:"workflows",target:i.type,message:`Workflow type "${i.type}" is declared more than once; the later transition set wins.`}):!Z.has(a)&&!t.has(a)&&s.push({severity:"warning",code:"workflow_type_unknown",dimension:"workflows",target:i.type,message:`Workflow governs type "${i.type}" which is neither a built-in type nor declared by this profile; it has no effect unless that type already exists.`});let d=new Set;for(let l of i.allowed_transitions){let m=g(l[0]),T=g(l[1]);if(m.length===0||T.length===0){s.push({severity:"error",code:"workflow_transition_malformed",dimension:"workflows",target:i.type,message:`Workflow "${i.type}" has a transition with an empty status; the workflow resolver silently drops it.`});continue}for(let h of[m,T])ue.has(h)||n.has(h)||d.has(h)||(d.add(h),s.push({severity:"warning",code:"workflow_status_unknown",dimension:"workflows",target:h,message:`Workflow "${i.type}" references status "${h}" which is neither a built-in status nor declared by this profile; transitions to or from it are unreachable.`}))}}}function ke(e,t){let n=new Set;for(let s of e.config){let r=b(s.key);if(r===void 0){t.push({severity:"error",code:"config_key_unknown",dimension:"config",target:s.key,message:`Config knob "${s.key}" is not a recognized setting; apply rejects it with a usage error.`});continue}n.has(r.key)?t.push({severity:"error",code:"config_duplicate",dimension:"config",target:r.key,message:`Config knob "${r.key}" is set more than once; the later value silently overwrites the earlier one.`}):n.add(r.key);let o=v(r,s.value);o.ok||t.push({severity:"error",code:"config_value_invalid",dimension:"config",target:s.key,message:o.error.message})}}function we(e,t,n){for(let s of e.templates){let r=s.options.type;if(typeof r!="string"||r.trim().length===0)continue;let o=r.trim().toLowerCase();!Z.has(o)&&!t.has(o)&&n.push({severity:"warning",code:"template_type_unknown",dimension:"templates",target:s.name,message:`Template "${s.name}" creates type "${r}" which is neither a built-in type nor declared by this profile.`})}}function be(e,t){for(let[n,s]of e.packages.entries())s.spec.trim().length===0&&t.push({severity:"warning",code:"package_spec_empty",dimension:"packages",target:`#${n}`,message:"Package recommendation has an empty spec; it cannot be surfaced as an install hint."})}function dt(e){let t=[];fe(e,t);let n=ye(e,t),s=he(e,t);ge(e,t),_e(e,n,s,t),ke(e,t),we(e,n,t),be(e,t);let r=t.filter(i=>i.severity==="error").length,o=t.length-r;return{profile:e.name,ok:r===0,findings:t,errorCount:r,warningCount: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]="ead1caea-8e8b-5208-9fba-23fb114044b5")}catch{}})();function E(e,t,n,s,r){let o=e,i=[];for(let a of t){let c=s(o),d=r(o,a),l=s(d.file);o=d.file;let m=c===l?"unchanged":d.replaced?"update":"add";i.push({key:n(a),status:m})}return{file:o,changes:i,changed:i.some(a=>a.status!=="unchanged")}}function ee(e){return JSON.stringify(e.map(t=>t.join("\0")).sort())}function ve(e,t){let n=e.map(r=>({...r})),s=[];for(let r of t){let o=n.findIndex(a=>a.type===r.type),i={type:r.type,allowed_transitions:r.allowed_transitions};o<0?(n.push(i),s.push({type:r.type,status:"add"})):ee(n[o].allowed_transitions)===ee(r.allowed_transitions)?s.push({type:r.type,status:"unchanged"}):(n[o]=i,s.push({type:r.type,status:"update"}))}return{changes:s,result:n,changed:s.some(r=>r.status!=="unchanged")}}function Ie(e,t){let n=[];for(let s of e.config){let r=b(s.key);if(r===void 0)throw new Error(`Profile "${e.name}" references unknown config key "${s.key}".`);let o=v(r,s.value);if(!o.ok)throw new Error(`Profile "${e.name}" config ${s.key}: ${o.error.message}`);let i=V(t,r),a=i===null?"add":i===o.parsed.value?"unchanged":"update";n.push({key:r.key,path:r.path,value:o.parsed.value,status:a})}return{changes:n,changed:n.some(s=>s.status!=="unchanged")}}function te(e){let t=Object.entries(e).sort(([n],[s])=>n.localeCompare(s));return JSON.stringify(t)}function Se(e,t){let n=[];for(let s of e.templates){let r=t.get(s.name),o;r===void 0?o="add":te(r)===te(s.options)?o="unchanged":o="update",n.push({name:s.name,options:s.options,status:o})}return{changes:n,changed:n.some(s=>s.status!=="unchanged")}}function yt(e,t){let n=E(M(t.typesRaw),e.types,l=>u(l).name,q,(l,m)=>z(l,u(m))),s=E(X(t.statusesRaw),e.statuses,l=>y(l).id,W,(l,m)=>Y(l,y(m))),r=E(B(t.fieldsRaw),e.fields,l=>f(l).key,j,(l,m)=>U(l,f(m))),o=ve(t.workflows,e.workflows),i=Ie(e,t.settings),a=Se(e,t.templates),c=e.packages.map(l=>({spec:l.spec,reason:l.reason,status:t.installedPackages.has(l.spec)?"installed":"recommended"})),d=n.changed||s.changed||r.changed||o.changed||i.changed||a.changed;return{profile:{name:e.name,title:e.title,summary:e.summary},types:n,statuses:s,fields:r,workflows:o,config:i,templates:a,packages:c,changed:d}}export{Ce as a,$e as b,Pe as c,De as d,Le as e,Q as f,Re as g,Fe as h,_ as i,I as j,ne as k,qe as l,Be as m,se as n,je as o,re as p,Ye as q,oe as r,b as s,v as t,V as u,Ge as v,at as w,lt as x,dt as y,yt as z};
26
- //# sourceMappingURL=chunk-JZYPPMXF.js.map
26
+ //# sourceMappingURL=chunk-KB5OFSFD.js.map
@@ -1,4 +1,4 @@
1
- import{Ab as G,Cb as ke,Da as te,Ja as at,La as fe,Ma as Zt,Na as z,Oa as Ae,Sa as ve,Ua as ct,Xa as er,Y as Ie,Z as v,da as xe,ea as Qt,eb as tr,fa as Jt,fb as Ce,gb as C,hb as Re,l as ce,lb as dt,mb as re,o as q,oa as de,qa as ot,qb as lt,ta as it,tb as ut,ua as le,ub as ft,va as st,vb as mt,wa as ue,yb as rr,zb as B}from"./chunk-3UMBF26I.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 Mn(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 Nn=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,On=/\bnpm_[A-Za-z0-9]{36}\b/,Pn=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,$n=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,Fn=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,nr=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,zn=[{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(zn.map(e=>[e.action,e]));function Un(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)){Nn.test(r.value)&&t.push({rule:"github_token",path:r.path}),On.test(r.value)&&t.push({rule:"npm_token",path:r.path}),Pn.test(r.value)&&t.push({rule:"slack_token",path:r.path}),$n.test(r.value)&&t.push({rule:"private_key",path:r.path}),Fn.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(Un(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 Vn(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 jn(e){return ht.has(e.trim().toLowerCase())}function Hn(){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 qn(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function hc(e){return qn(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 Bn=/\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(Bn)?.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 Gn 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 Yn(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=Yn(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 Wn(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(Gn.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 Kn,readFile as Xn}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 Qn(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 Jn(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 Zn(e,t,r,n){let o=ar(e,t);await Kn(o,{recursive:!0});let i=cr(e,t,r);return await S(i,`${JSON.stringify(n,null,2)}
1
+ import{Ab as B,Bb as G,Da as te,Db as ke,Ja as at,La as fe,Ma as Zt,Na as z,Pa as Ae,Ta as ve,Va as ct,Y as Ie,Ya as er,Z as v,da as xe,ea as Qt,fa as Jt,fb as tr,gb as Ce,hb as C,ib as Re,l as ce,mb as dt,nb as re,o as q,oa as de,qa as ot,rb as lt,ta as it,ua as le,ub as ut,va as st,vb as ft,wa as ue,wb as mt,zb as rr}from"./chunk-T2LXXSOD.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-QDFJIRKN.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 Mn(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 Nn=/\b(?:gh[pousr]_[A-Za-z0-9]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/,On=/\bnpm_[A-Za-z0-9]{36}\b/,Pn=/\bxox[baprs]-(?=[A-Za-z0-9-]{20,80}\b)(?=[A-Za-z0-9-]*\d)[A-Za-z0-9-]{20,80}\b/,$n=/-----BEGIN (?:[A-Z0-9]+ )?PRIVATE KEY-----/,Fn=/\b(?:AKIA|ASIA)[A-Z0-9]{16}\b/,nr=/\b(?:token|secret|password|passwd|api[_-]?key)\s*[:=]\s*["']?([A-Za-z0-9+/=_-]{24,})/gi,zn=[{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(zn.map(e=>[e.action,e]));function Un(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)){Nn.test(r.value)&&t.push({rule:"github_token",path:r.path}),On.test(r.value)&&t.push({rule:"npm_token",path:r.path}),Pn.test(r.value)&&t.push({rule:"slack_token",path:r.path}),$n.test(r.value)&&t.push({rule:"private_key",path:r.path}),Fn.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(Un(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 Vn(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 jn(e){return ht.has(e.trim().toLowerCase())}function Hn(){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 qn(e){return e.trim().toLowerCase().replace(/\s+/g," ")}function hc(e){return qn(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 Bn=/\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(Bn)?.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 Gn 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 Yn(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=Yn(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 Wn(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(Gn.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 Kn,readFile as Xn}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 Qn(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 Jn(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 Zn(e,t,r,n){let o=ar(e,t);await Kn(o,{recursive:!0});let i=cr(e,t,r);return await S(i,`${JSON.stringify(n,null,2)}
2
2
  `),i}function eo(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 to(e,t,r,n){let o=Qn(r),i=cr(e,t,o);if(!await P(i))throw new f(`Checkpoint ${o} not found`,u.NOT_FOUND);let s=await Xn(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=eo(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 ro(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 no(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 oo(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]="80965b57-856c-5fef-a372-0c9f3766ada5")}catch{}})();var $="-",lr=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 Oc(e,t){if(e.startsWith("```")||e.includes(`
3
3
  `))return!0;let r=t.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");return new RegExp(`^(?:[-*+]\\s+)?(?:${r})\\s*[:=]`,"i").test(e)}function ur(e){let t=e.trim();if(t==="")return[];let n=(lo(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 fr(e){if(!Array.isArray(e)||e.length===0)return[];let t=[];for(let r of e)if(typeof r=="string")for(let n of ur(r))t.push(n);return Array.from(new Set(t)).sort((r,n)=>r.localeCompare(n))}function mr(e){return Array.isArray(e)?e.filter(t=>typeof t=="string").map(t=>t.trim().toLowerCase()).filter(Boolean):[]}function io(e){return typeof e!="string"?[]:e.split(";").map(t=>t.trim()).filter(Boolean)}function so(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 ao(e,t){let r=mr(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 fr(t))n.add(o);return Array.from(n).sort((o,i)=>o.localeCompare(i))}function co(e,t){let r=Array.from(new Set(mr(e))).sort((o,i)=>o.localeCompare(i));if(!t||t.length===0)return r;let n=new Set(fr(t));return n.size===0?r:r.filter(o=>!n.has(o))}function lo(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,`
4
4
  `)}function pr(e){let t=_t(e).trim();if(!t.startsWith("```"))return e;let r=t.split(`
@@ -17,4 +17,4 @@ ${i}`;continue}return null}return r}function ho(e,t){let r=pr(e).trim();if(!r)th
17
17
  `)){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 bn(e,t){let r=yn(t),n=[],o=0;for(let i of e){if(JSON.stringify(i).length>en||ga(i,r)||i.attempts>=tn){o+=1;continue}n.push(i)}if(n.length>Yr){let i=n.length-Yr;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(`
18
18
  `),n=r.length>0?`${r}
19
19
  `:"";for(let o=0;;o+=1)try{await S(Ht(e),n);return}catch(i){let s=rn[o];if(s===void 0||!gn(i))throw i;await wn(s)}}async function Jr(e,t,r,n){return Bt(async()=>{let o=await T(Ht(e)),i=o===null?[]:En(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}=bn(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=En(r),{entries:o,prunedCount:i}=bn(n,t),s=o.filter(_=>_n(_.next_attempt_after)).slice(0,Us);if(s.length===0){let _=i>0?await Jr(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 mn(_.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:hn(g)})}}));let h=await Jr(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 Zr(s)).mtimeMs<o&&await jt(s,{force:!0})}))}catch{}}async function Bt(e){let t=Xr.catch(()=>{}).then(e);return Xr=t.catch(()=>{}),t}async function Gt(e){let t=await T(Xe(e));return t===null||t.trim().length===0?[]:pn(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:hn(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=pn(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 mn(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=sn(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 Zr(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(sn(e),{recursive:!0,force:!0})}catch{}}}async function gu(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,Sn=20,Da=.8,La=100,Tn=1e3,In=1e6;function Nh(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 xn(e){let t=e.limit??ka,r=e.threshold??Da;if(!Number.isSafeInteger(t)||t<0||t>Sn)throw new f(`Similarity limit must be an integer from 0 to ${Sn}.`,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>Tn)throw new f(`Duplicate cluster limit must be an integer from 0 to ${Tn}.`,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 An(e,t=In){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 ${In} 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 Oh={buildDuplicateClusters:Cn,collectDuplicateCandidatePairs:An,createDuplicateUnionFind:vn};function vn(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 Cn(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}=xn(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 Ph(e={}){let{threshold:t}=xn({...e,limit:void 0}),{limit:r,since:n}=Na(e),{items:o,statuses:i}=await Oa(e,n),s=An(o),a=vn(o.length),c=Pa(o,s,t,a),d=Cn(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 $h(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 Hh(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 qh(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 Bh(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 t_(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 Rn(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 kn(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(kn(e).map(i=>i.trim()))].filter(i=>i.length>0).map(i=>({kind:"literal",value:i})),n=[...new Set(kn(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 Dn(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 Dn(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=Dn(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 Rn({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 I_(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,Ln)=>j.localeCompare(Ln)),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 A_(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{Hh as a,Qe as b,qh as c,Bh as d,t_ as e,Rn as f,ac as g,I_ as h,Jn as i,Zn as j,to as k,ro as l,Dc as m,no as n,oo as o,Oc as p,ur as q,io as r,so as s,ao as t,co as u,ho as v,go as w,Pc as x,wo as y,_r as z,bo as A,So as B,$c as C,To as D,Oe as E,Fc as F,Pe as G,xo as H,Ao as I,yt as J,Co as K,gt as L,Ro as M,Zc as N,Do as O,gr as P,Lo as Q,Mo as R,Po as S,sd as T,zo as U,fd as V,Ho as W,Bo as X,Mn as Y,Go as Z,Yo as _,ze as $,hi as aa,Nd as ba,Et as ca,Cr as da,bt as ea,vi as fa,Ci as ga,$d as ha,Rr as ia,ne as ja,Tt as ka,xt as la,Mt as ma,Wd as na,Nt as oa,Ge as pa,Pr as qa,Ye as ra,Ot as sa,Pt as ta,$t as ua,Ft as va,jr as wa,Hr as xa,hl as ya,zn as za,or as Aa,Vn as Ba,jn as Ca,Hn as Da,mc as Ea,hc as Fa,me as Ga,De as Ha,he as Ia,pe as Ja,Le as Ka,Me as La,ir as Ma,Wn as Na,Is as Oa,vs as Pa,Rs as Qa,ks as Ra,Vs as Sa,tn as Ta,ea as Ua,gu as Va,A_ as Wa,Nh as Xa,Oh as Ya,Fa as Za,Ph as _a,$h as $a};
20
- //# sourceMappingURL=chunk-73EDXGYE.js.map
20
+ //# sourceMappingURL=chunk-MKHG3T76.js.map
@@ -1,8 +1,8 @@
1
- import{w as D,x as q}from"./chunk-XXOWRJZ5.js";import{Ob as N,Ub as z,Wb as O,da as j}from"./chunk-3UMBF26I.js";import{fa as S,ka as m,t as b,v as k}from"./chunk-AD6ULRAF.js";import{aa as _,bb as x,eb as C,hb as L}from"./chunk-Z2USIBR2.js";import{constants as u}from"node:fs";import{lstat as M,mkdir as $,open as F}from"node:fs/promises";import h from"node:path";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="bb5dfa6f-b60f-55f2-ae17-3dbcaaff1b47")}catch{}})();function E(i,e){if(typeof i!="string"||i.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return i.trim()}function I(i,e){let t=e.require(i.kind),n=t.direction==="undirected"?[i.source,i.target].sort().join("\0"):`${i.source}\0${i.target}`;return`${t.kind}\0${n}`}function H(i){return Object.freeze({...i,...i.payload===void 0?{}:{payload:Object.freeze(structuredClone(i.payload))}})}function J(i,e,t,n){let r=t.require(i.kind),o=n.outgoingOne.get(`${r.kind}\0${i.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let s=n.incomingOne.get(`${r.kind}\0${i.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let c=I(i,t),d=n.identities.get(c);if(d!==void 0&&d!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function K(i){let e=new Map;for(let t of i)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function G(i,e,t){if(i.expectedVersion!==void 0&&i.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${i.expectedVersion}, current ${e}`);let n=E(i.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(i.action!=="add"&&i.action!=="remove"&&i.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${i.action}`);if(!Number.isFinite(Date.parse(i.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(i.relationshipId,"relationshipId"),author:E(i.author,"author"),timestamp:new Date(i.timestamp).toISOString()}}function Q(i,e,t,n,r,o){let s=t.has(e);if(i.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(i.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(i.action==="remove")return;if(!i.edge)throw new TypeError(`Relationship ${i.action} event requires an edge`);let c=typeof i.edge.source=="string"?i.edge.source.trim():"",d=typeof i.edge.target=="string"?i.edge.target.trim():"";if(!n.has(c)||!n.has(d))throw new TypeError(`Relationship endpoint not found: ${c} -> ${d}`);let a=new m([c,d],[i.edge],r).edges()[0];return J(a,e,r,o),H(a)}var T=class{#t;#n;#i=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#n=t.registry??S()}get version(){return this.#i.length}events(){return Object.freeze([...this.#i])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,r=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=r)yield Object.freeze(this.#i.slice(o,Math.min(o+r,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let r=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let d of c)r=t(r,d),o+=1,s=d;return Object.freeze({state:r,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#n.require(t.kind);this.#r.identities.set(I(t,this.#n),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#n.require(e.kind);this.#r.identities.delete(I(e,this.#n)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=G(e,this.version,this.#o),n=this.#e.get(t.relationshipId),r=Q(e,t.relationshipId,this.#e,this.#t,this.#n,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...r===void 0?{}:{edge:r},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#i.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,r),this.#s(t.relationshipId,r)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#i.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#i.slice(0,o)}let n=K(t),r=new m(this.#t,n.values(),this.#n);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=x("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(C(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=L(this.#i.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},Y="relationship-event-store",A=u.O_NOFOLLOW;function g(i){return j(i,Y,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function l(i,e="relationships/events.jsonl"){let t=h.resolve(i),n=h.resolve(t,e),r=h.relative(t,n);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${h.sep}`)||h.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await $(t,{recursive:!0}),(await M(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let s=t;for(let c of r.split(h.sep)){s=h.join(s,c);try{if((await M(s)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(d){if(b(d))break;throw d}}return n}async function w(i,e,t){let n=new T(e,{registry:t}),r,o;try{o=await F(i,u.O_RDONLY|A),r=await o.readFile("utf8")}catch(c){if(b(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=r.split(`
1
+ import{w as D,x as q}from"./chunk-S4U5CN5Q.js";import{Pb as N,Vb as z,Xb as O,da as j}from"./chunk-T2LXXSOD.js";import{fa as S,ka as m,t as b,v as k}from"./chunk-QDFJIRKN.js";import{aa as _,bb as x,eb as C,hb as L}from"./chunk-Z2USIBR2.js";import{constants as u}from"node:fs";import{lstat as M,mkdir as $,open as F}from"node:fs/promises";import h from"node:path";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="bb5dfa6f-b60f-55f2-ae17-3dbcaaff1b47")}catch{}})();function E(i,e){if(typeof i!="string"||i.trim().length===0)throw new TypeError(`Relationship event ${e} must be non-empty`);return i.trim()}function I(i,e){let t=e.require(i.kind),n=t.direction==="undirected"?[i.source,i.target].sort().join("\0"):`${i.source}\0${i.target}`;return`${t.kind}\0${n}`}function H(i){return Object.freeze({...i,...i.payload===void 0?{}:{payload:Object.freeze(structuredClone(i.payload))}})}function J(i,e,t,n){let r=t.require(i.kind),o=n.outgoingOne.get(`${r.kind}\0${i.source}`);if(o!==void 0&&o!==e)throw new TypeError(`Relationship outgoing cardinality exceeded for ${r.kind}`);let s=n.incomingOne.get(`${r.kind}\0${i.target}`);if(s!==void 0&&s!==e)throw new TypeError(`Relationship incoming cardinality exceeded for ${r.kind}`);let c=I(i,t),d=n.identities.get(c);if(d!==void 0&&d!==e)throw new TypeError(`Relationship edge already active: ${c}`)}function K(i){let e=new Map;for(let t of i)t.action==="remove"?e.delete(t.relationshipId):e.set(t.relationshipId,t.edge);return e}function G(i,e,t){if(i.expectedVersion!==void 0&&i.expectedVersion!==e)throw new TypeError(`Relationship event version conflict: expected ${i.expectedVersion}, current ${e}`);let n=E(i.eventId,"eventId");if(t.has(n))throw new TypeError(`Relationship event already exists: ${n}`);if(i.action!=="add"&&i.action!=="remove"&&i.action!=="supersede")throw new TypeError(`Unknown relationship event action: ${i.action}`);if(!Number.isFinite(Date.parse(i.timestamp)))throw new TypeError("Relationship event timestamp must be valid");return{eventId:n,relationshipId:E(i.relationshipId,"relationshipId"),author:E(i.author,"author"),timestamp:new Date(i.timestamp).toISOString()}}function Q(i,e,t,n,r,o){let s=t.has(e);if(i.action==="add"&&s)throw new TypeError(`Relationship is already active: ${e}`);if(i.action!=="add"&&!s)throw new TypeError(`Relationship is not active: ${e}`);if(i.action==="remove")return;if(!i.edge)throw new TypeError(`Relationship ${i.action} event requires an edge`);let c=typeof i.edge.source=="string"?i.edge.source.trim():"",d=typeof i.edge.target=="string"?i.edge.target.trim():"";if(!n.has(c)||!n.has(d))throw new TypeError(`Relationship endpoint not found: ${c} -> ${d}`);let a=new m([c,d],[i.edge],r).edges()[0];return J(a,e,r,o),H(a)}var T=class{#t;#n;#i=[];#o=new Set;#e=new Map;#r={identities:new Map,outgoingOne:new Map,incomingOne:new Map};constructor(e,t={}){this.#t=new Set([...e].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean)),this.#n=t.registry??S()}get version(){return this.#i.length}events(){return Object.freeze([...this.#i])}*stream(e={}){let t=e.fromVersion??1,n=e.toVersion??this.version,r=e.batchSize??100;if(!Number.isInteger(t)||t<1)throw new TypeError("Relationship event stream fromVersion must be positive");if(!Number.isInteger(n)||n<0||n>this.version)throw new TypeError(`Relationship event stream toVersion out of range: ${n}`);if(!Number.isInteger(r)||r<1)throw new TypeError("Relationship event stream batchSize must be positive");if(t>n+1)throw new TypeError("Relationship event stream fromVersion exceeds the selected prefix");for(let o=t-1;o<n;o+=r)yield Object.freeze(this.#i.slice(o,Math.min(o+r,n)))}project(e,t,n={}){if(typeof t!="function")throw new TypeError("Relationship event projection requires a reducer");let r=e,o=0,s;for(let c of this.stream({...n,batchSize:256}))for(let d of c)r=t(r,d),o+=1,s=d;return Object.freeze({state:r,version:s?.sequence??Math.max(0,(n.fromVersion??1)-1),processed:o,...s===void 0?{}:{asOf:s.timestamp}})}#s(e,t){let n=this.#n.require(t.kind);this.#r.identities.set(I(t,this.#n),e),n.outgoing==="one"&&this.#r.outgoingOne.set(`${n.kind}\0${t.source}`,e),n.incoming==="one"&&this.#r.incomingOne.set(`${n.kind}\0${t.target}`,e)}#a(e){let t=this.#n.require(e.kind);this.#r.identities.delete(I(e,this.#n)),t.outgoing==="one"&&this.#r.outgoingOne.delete(`${t.kind}\0${e.source}`),t.incoming==="one"&&this.#r.incomingOne.delete(`${t.kind}\0${e.target}`)}append(e){let t=G(e,this.version,this.#o),n=this.#e.get(t.relationshipId),r=Q(e,t.relationshipId,this.#e,this.#t,this.#n,this.#r),o=Object.freeze({eventId:t.eventId,relationshipId:t.relationshipId,action:e.action,...r===void 0?{}:{edge:r},author:t.author,timestamp:t.timestamp,...e.reason?.trim()?{reason:e.reason.trim()}:{},sequence:this.version+1});return this.#i.push(o),this.#o.add(t.eventId),n&&this.#a(n),e.action==="remove"?this.#e.delete(t.relationshipId):(this.#e.set(t.relationshipId,r),this.#s(t.relationshipId,r)),o}snapshot(e={}){if(e.atVersion!==void 0&&e.atTimestamp!==void 0)throw new TypeError("Relationship snapshot accepts one target");let t;if(e.atTimestamp!==void 0){let o=Date.parse(e.atTimestamp);if(!Number.isFinite(o))throw new TypeError("Relationship snapshot timestamp must be valid");t=this.#i.filter(s=>Date.parse(s.timestamp)<=o)}else{let o=e.atVersion??this.version;if(!Number.isInteger(o)||o<0||o>this.version)throw new TypeError(`Relationship snapshot version out of range: ${o}`);t=this.#i.slice(0,o)}let n=K(t),r=new m(this.#t,n.values(),this.#n);return Object.freeze({version:t.at(-1)?.sequence??0,...t.at(-1)?{asOf:t.at(-1).timestamp}:{},edges:r.edges(),graph:r})}page(e){if(!Number.isInteger(e.limit)||e.limit<1)throw new TypeError("Relationship event page limit must be positive");let t=x("relationship-events",{order:"append-sequence"}),n=e.cursor===void 0?this.version:Number(C(e.cursor,t).snapshot);if(!Number.isSafeInteger(n)||n<0||n>this.version)throw new TypeError("Relationship event cursor snapshot version is invalid");let r=L(this.#i.slice(0,n),{cursor:e.cursor,fingerprint:t,limit:e.limit,readId:o=>o.eventId,snapshot:String(n)});return{version:n,events:r.rows,hasMore:r.has_more,...r.next_cursor?{nextCursor:r.next_cursor}:{}}}},Y="relationship-event-store",A=u.O_NOFOLLOW;function g(i){return j(i,Y,30,`relationship-store:${process.pid}`,!1,!1,3e3)}async function l(i,e="relationships/events.jsonl"){let t=h.resolve(i),n=h.resolve(t,e),r=h.relative(t,n);if(r.length===0)throw new TypeError("Relationship event path must name a file within the tracker root");if(r===".."||r.startsWith(`..${h.sep}`)||h.isAbsolute(r))throw new TypeError("Relationship event path must stay within the tracker root");if(await $(t,{recursive:!0}),(await M(t)).isSymbolicLink())throw new TypeError("Relationship event tracker root must not be a symbolic link");let s=t;for(let c of r.split(h.sep)){s=h.join(s,c);try{if((await M(s)).isSymbolicLink())throw new TypeError("Relationship event path must not contain symbolic links")}catch(d){if(b(d))break;throw d}}return n}async function w(i,e,t){let n=new T(e,{registry:t}),r,o;try{o=await F(i,u.O_RDONLY|A),r=await o.readFile("utf8")}catch(c){if(b(c))return{log:n,raw:""};throw c}finally{await o?.close()}let s=r.split(`
2
2
  `);for(let c=0;c<s.length;c+=1){let d=s[c].trim();if(!d)continue;let a;try{a=JSON.parse(d)}catch{throw new TypeError(`Invalid relationship event JSONL at line ${c+1}`)}if(a.sequence!==n.version+1)throw new TypeError(`Invalid relationship event sequence at line ${c+1}`);n.append({eventId:a.eventId,relationshipId:a.relationshipId,action:a.action,...a.edge===void 0?{}:{edge:a.edge},author:a.author,timestamp:a.timestamp,...a.reason===void 0?{}:{reason:a.reason},expectedVersion:n.version})}return{log:n,raw:r}}function U(i,e,t,n){let r=Date.parse(e.timestamp),o;return e.action!=="remove"&&e.edge!==void 0&&(o=new m(t,[e.edge],n).edges()[0]),i.eventId===e.eventId.trim()&&i.relationshipId===e.relationshipId.trim()&&i.action===e.action&&i.author===e.author.trim()&&Number.isFinite(r)&&i.timestamp===new Date(r).toISOString()&&i.reason===(e.reason?.trim()||void 0)&&_(i.edge)===_(o)}var V=class i{#t;#n;#i;#o;#e;constructor(e,t,n,r){this.#t=e.pmRoot,this.#n=t,this.#i=e.registry,this.#o=n,this.#e=r}static async open(e){let t=Object.freeze([...e.nodes]),n=await l(e.pmRoot,e.relativePath),r=await g(e.pmRoot);try{await l(e.pmRoot,n);let{log:o}=await w(n,t,e.registry);return new i(e,t,n,o)}finally{await r()}}get path(){return this.#o}async currentVersion(){return this.#e=await this.#r(),this.#e.version}async append(e){let t=await g(this.#t);try{let n=await l(this.#t,this.#o),{log:r}=await w(n,this.#n,this.#i),o=r.append(e);await $(h.dirname(n),{recursive:!0}),await l(this.#t,n);let s=await F(n,u.O_APPEND|u.O_CREAT|u.O_WRONLY|A);try{await s.appendFile(`${JSON.stringify(o)}
3
3
  `,"utf8")}finally{await s.close()}return this.#e=r,o}finally{await t()}}async appendBatch(e,t={}){let n=await g(this.#t);try{let r=await l(this.#t,this.#o),{log:o,raw:s}=await w(r,this.#n,this.#i),c=o.version,d=new Map(o.events().map(f=>[f.eventId,f])),a=[],R=[];for(let f of e){let p=f.eventId.trim(),y=d.get(p);if(y!==void 0){if(t.existingEventPolicy==="skip_identical"&&U(y,f,this.#n,this.#i)){R.push(y.eventId);continue}if(t.existingEventPolicy==="skip_identical")throw new TypeError(`Relationship event id collision with different content: ${p}`)}let v=o.append(f);d.set(v.eventId,v),a.push(v)}if(a.length>0){let f=s.length===0||s.endsWith(`
4
4
  `)?s:`${s}
5
5
  `;await $(h.dirname(r),{recursive:!0}),await l(this.#t,r),await k(r,`${f}${a.map(p=>JSON.stringify(p)).join(`
6
6
  `)}
7
7
  `)}return this.#e=o,Object.freeze({version_before:c,version_after:o.version,appended:Object.freeze(a),skipped_event_ids:Object.freeze(R)})}finally{await n()}}async snapshot(e={}){return this.#e=await this.#r(),this.#e.snapshot(e)}async page(e){return this.#e=await this.#r(),this.#e.page(e)}async*stream(e={}){this.#e=await this.#r(),yield*this.#e.stream(e)}async project(e,t,n={}){return this.#e=await this.#r(),this.#e.project(e,t,n)}async#r(){let e=await g(this.#t);try{let t=await l(this.#t,this.#o);return(await w(t,this.#n,this.#i)).log}finally{await e()}}};(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new i.Error().stack;e&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[e]="94e8b95b-35fa-5fc7-843a-481497e09b54")}catch{}})();function P(i){return[...i].sort().join("\0")}function X(i,e,t){let n=i.successors.get(e);n?n.push(t):i.successors.set(e,[t]);let r=i.predecessors.get(t);r?r.push(e):i.predecessors.set(t,[e])}function W(i,e,t,n,r){let o=e.resolve(r);if(o?.ordering!==!0)return;let s=z(n),c=s===void 0?void 0:i.canonicalIds.get(s.toLowerCase());if(c===void 0)return;let d=(o.precedence??"source_before_target")==="source_before_target";X(i,d?t:c,d?c:t)}function Z(i,e){let t={successors:new Map,predecessors:new Map,canonicalIds:new Map},n=i.filter(r=>typeof r?.id=="string"&&r.id.trim().length>0);for(let r of n){let o=r.id.trim();t.canonicalIds.set(o.toLowerCase(),o)}for(let r of n){let o=r.id.trim();W(t,e,o,r.blocked_by,"blocked_by");for(let s of r.dependencies??[])typeof s!="object"||s===null||W(t,e,o,s.id,typeof s.kind=="string"?s.kind:"related")}for(let r of[t.successors,t.predecessors])for(let o of r.values())o.sort();return t}function ee(i,e){let t=new Set([e]),n=[e];for(;n.length>0;){let r=n.pop();for(let o of[i.successors,i.predecessors])for(let s of o.get(r)??[])t.has(s)||(t.add(s),n.push(s))}return t}function te(i,e){let t=new Map;for(let n of e){let r=(i.successors.get(n)??[]).filter(o=>e.has(o));r.length>0&&t.set(n,r)}return t}function B(i,e,t){let n=Z(i,e),r=n.canonicalIds.get(t.trim().toLowerCase());if(r===void 0)return{cycles:[],successors:new Map,canonical:t};let o=te(n,ee(n,r));return{cycles:D(o).filter(s=>s.includes(r)),successors:o,canonical:r}}function ne(i,e,t){let n=new Set(e),r=n.has(t)?t:e[0];if(i.get(r)?.includes(r))return[r,r];for(let o of i.get(r)??[]){if(!n.has(o))continue;let s=ie(i,n,r,o);if(s)return s}return[...e,e[0]]}function ie(i,e,t,n){let r=[[n]],o=new Set([t,n]);for(;r.length>0;){let s=r.shift(),c=s.at(-1);for(let d of i.get(c)??[]){if(d===t)return[t,...s,t];!e.has(d)||o.has(d)||(o.add(d),r.push([...s,d]))}}}function me(i,e,t){let n=N(),r=B(i,n,t),o=B(e,n,t),s=new Set(r.cycles.map(P)),c=new Set(O(i,void 0,n).map(a=>`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`));return[...O(e,void 0,n).filter(a=>a.holder_id.toLowerCase()===t.trim().toLowerCase()&&!c.has(`${a.holder_id.toLowerCase()}\0${a.target_id.toLowerCase()}\0${a.dependency_kind}`)).map(a=>`ordering_storage_contradiction_created:${q(a)}:remove_contradicting_dependency_row:run_pm_graph_audit`),...o.cycles.filter(a=>!s.has(P(a))).map(a=>`ordering_cycle_created:${ne(o.successors,a,o.canonical).join(" -> ")}:items_will_not_be_ready:run_pm_graph_audit`)]}export{T as a,V as b,me as c};
8
- //# sourceMappingURL=chunk-3AVAWVZA.js.map
8
+ //# sourceMappingURL=chunk-PF3E6Q36.js.map