@unbrained/pm-cli 2026.10.30 → 2026.10.31
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.
- package/.claude-plugin/marketplace.json +1 -1
- package/CHANGELOG.md +32 -0
- package/dist/cli/commander-usage.js +2 -2
- package/dist/cli/error-guidance.d.ts +45 -5
- package/dist/cli/error-guidance.js +5 -3
- package/dist/cli/extension-command-help.d.ts +1 -0
- package/dist/cli/extension-command-help.js +2 -2
- package/dist/cli/main.d.ts +1 -5
- package/dist/cli/main.js +5 -5
- package/dist/cli/migration-gates.d.ts +1 -1
- package/dist/cli/migration-gates.js +1 -1
- package/dist/cli/preflight-warnings.d.ts +11 -0
- package/dist/cli/preflight-warnings.js +4 -0
- package/dist/cli/register-mutation.js +2 -2
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/chunk-24J6TNYE.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-EHBGHX55.js → chunk-2AHSPMKJ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MVL27TAH.js → chunk-35Q2B2GJ.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-43R7UTWV.js +2 -0
- package/dist/cli-bundle/chunks/chunk-6PSDQ7T7.js +8 -0
- package/dist/cli-bundle/chunks/{chunk-UUQX3PFD.js → chunk-BS2KXT24.js} +70 -70
- package/dist/cli-bundle/chunks/{chunk-Y6NC3X3E.js → chunk-GMBDZID5.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-HSBTITO4.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-LWW4F4G2.js → chunk-MRUA2Z43.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-P3LNMWL2.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-S2U7ECUJ.js → chunk-PT7TS6E7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-TH5KPAN4.js → chunk-SBVX5CMV.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-4BQD5SW2.js → chunk-TL3O5GZA.js} +30 -30
- package/dist/cli-bundle/chunks/chunk-U7JXZMU5.js +6 -0
- package/dist/cli-bundle/chunks/{chunk-GRABKNFL.js → chunk-V6EWBTNH.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-VC7TA67O.js +20 -0
- package/dist/cli-bundle/chunks/chunk-WNF6FOL7.js +31 -0
- package/dist/cli-bundle/chunks/chunk-WRXQAW7Q.js +114 -0
- package/dist/cli-bundle/chunks/{chunk-RZQNFHXO.js → chunk-WX25MU4N.js} +3 -3
- package/dist/cli-bundle/chunks/chunk-XDDPSWIW.js +2 -0
- package/dist/cli-bundle/chunks/chunk-YT5D5HNG.js +2 -0
- package/dist/cli-bundle/chunks/chunk-ZTJVOBDU.js +128 -0
- package/dist/cli-bundle/chunks/{indexed-receipt-blobs-LHLE7PSG.js → indexed-receipt-blobs-KGMJVFH2.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-UWV6UNSV.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-admission-TRGAVS7N.js → mutation-admission-I4RHIT3Q.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-BH4F6M7Z.js → register-list-query-MVDL5EXG.js} +3 -3
- package/dist/cli-bundle/chunks/register-mutation-GAF7LXRB.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-JLFRL36Q.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-QPWSVHFZ.js → register-setup-MZN6ONB3.js} +2 -2
- package/dist/cli-bundle/chunks/{settlement-hook-MN3Y7LVX.js → settlement-hook-YWSWFOZY.js} +2 -2
- package/dist/cli-bundle/chunks/{stage-RTB6RAAO.js → stage-2ZORTOF6.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-S23ZUASN.js → chunk-2J7T2UCH.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-4QPGJO2G.js +26 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YU7QOYYV.js → chunk-57HPXGOQ.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-5MCGYBOQ.js +91 -0
- package/dist/cli-bundle/focused-chunks/chunk-6F6APBCX.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-AFVN2KCP.js +44 -0
- package/dist/cli-bundle/focused-chunks/{chunk-RKPUQDWF.js → chunk-DFUTCKUF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-EA65HVBO.js +12 -0
- package/dist/cli-bundle/focused-chunks/chunk-GP2WU43K.js +26 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YQUZL2CK.js → chunk-HPWT3RBG.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-HSAEEWSI.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-BPE6JTKL.js → chunk-JLXGRDTG.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-FRFNGMAK.js → chunk-JNKRUCVZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BCIUAEWX.js → chunk-KH5QJXY7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-KKRIFBSL.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-RGQEJFXO.js → chunk-MW77Q3AQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-NOKG4RFN.js +22 -0
- package/dist/cli-bundle/focused-chunks/{chunk-POJPJX64.js → chunk-NRBUMDLF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-3SRX77ES.js → chunk-PC3R5CJV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-RYEZSZJ7.js → chunk-PFBQOZPK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SAT7IAEB.js → chunk-QFMJGQGO.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-VFWCSQAG.js → chunk-SFQKCA5K.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-WHIE2C6Q.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-Y6UYRMVG.js +6 -0
- package/dist/cli-bundle/focused-chunks/{indexed-receipt-blobs-VK2363JB.js → indexed-receipt-blobs-KHWT44EK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-LU75EG7D.js +2 -0
- package/dist/cli-bundle/focused-chunks/{mutation-admission-7VUODEPJ.js → mutation-admission-KDJ7SCPA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{settlement-hook-OK6A7PG2.js → settlement-hook-SJV52ZTV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-S5RP5SZH.js → stage-R4KEBO37.js} +2 -2
- package/dist/cli-bundle/main.js +26 -22
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +4 -4
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +57 -57
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/config/nested-settings.js +1 -1
- package/dist/core/extensions/extension-hook-runtime.js +1 -1
- package/dist/core/extensions/extension-types.d.ts +4 -0
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/core/extensions/loader.js +1 -1
- package/dist/core/lock/lock.js +4 -4
- package/dist/core/output/output.js +2 -2
- package/dist/core/schema/fields-file.js +1 -1
- package/dist/core/sentry/helpers.d.ts +6 -0
- package/dist/core/sentry/helpers.js +1 -1
- package/dist/core/sentry/instrument.d.ts +1 -1
- package/dist/core/sentry/instrument.js +1 -1
- package/dist/core/shared/constants.js +1 -1
- package/dist/core/shared/errors.d.ts +6 -0
- package/dist/core/shared/errors.js +1 -1
- package/dist/core/shared/output-unicode.d.ts +10 -0
- package/dist/core/shared/output-unicode.js +2 -0
- package/dist/core/store/settings-validator.d.ts +1 -0
- package/dist/core/store/settings-validator.js +1 -1
- package/dist/core/store/settings.js +1 -1
- package/dist/core/telemetry/policy.d.ts +8 -0
- package/dist/core/telemetry/policy.js +1 -1
- package/dist/core/telemetry/runtime.js +3 -3
- package/dist/sdk/agent/command-recovery.d.ts +15 -0
- package/dist/sdk/agent/command-recovery.js +1 -1
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/agent-output-contracts.d.ts +28 -0
- package/dist/sdk/cli-contracts/agent-output-contracts.js +2 -2
- package/dist/sdk/cli-contracts/commander-mutation-options.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/completion/fish.js +4 -4
- package/dist/sdk/completion/zsh.js +3 -3
- package/dist/sdk/config.d.ts +1 -0
- package/dist/sdk/config.js +1 -1
- package/dist/sdk/core.d.ts +1 -0
- package/dist/sdk/core.js +1 -1
- package/dist/sdk/error-runtime.d.ts +9 -0
- package/dist/sdk/error-runtime.js +1 -1
- package/dist/sdk/errors.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/index.d.ts +2 -2
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/lifecycle/claim.js +1 -1
- package/dist/sdk/lifecycle/close.js +1 -1
- package/dist/sdk/lifecycle/create.js +1 -1
- package/dist/sdk/lifecycle/plan.d.ts +2 -3
- package/dist/sdk/lifecycle/plan.js +1 -1
- package/dist/sdk/lifecycle/repeated-terminal-state.d.ts +45 -0
- package/dist/sdk/lifecycle/repeated-terminal-state.js +2 -0
- package/dist/sdk/lifecycle/shared-unset-fields.d.ts +9 -0
- package/dist/sdk/lifecycle/shared-unset-fields.js +1 -1
- package/dist/sdk/lifecycle/update-many.d.ts +0 -1
- package/dist/sdk/lifecycle/update-many.js +1 -1
- package/dist/sdk/lifecycle/update.d.ts +29 -1
- package/dist/sdk/lifecycle/update.js +2 -2
- package/dist/sdk/output/table-rows.d.ts +7 -1
- package/dist/sdk/output/table-rows.js +1 -1
- package/dist/sdk/output.d.ts +1 -0
- package/dist/sdk/output.js +2 -2
- package/dist/sdk/ownership-source.d.ts +18 -0
- package/dist/sdk/ownership-source.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/get.d.ts +1 -1
- package/dist/sdk/query/get.js +1 -1
- package/dist/sdk/query/next-ranking-policy.d.ts +35 -0
- package/dist/sdk/query/next-ranking-policy.js +2 -0
- package/dist/sdk/query/next.d.ts +12 -2
- package/dist/sdk/query/next.js +2 -2
- package/dist/sdk/query/projection-contracts.d.ts +4 -0
- package/dist/sdk/query/projection-contracts.js +1 -1
- package/dist/sdk/read-output/surfaces.d.ts +27 -0
- package/dist/sdk/read-output/surfaces.js +2 -0
- package/dist/sdk/read-output-contracts.js +1 -1
- package/dist/sdk/runtime-primitives.d.ts +1 -0
- package/dist/sdk/runtime-primitives.js +1 -1
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/test/execution-receipts.d.ts +25 -0
- package/dist/sdk/test/execution-receipts.js +2 -2
- package/dist/sdk/test/execution.d.ts +5 -0
- package/dist/sdk/test/execution.js +2 -2
- package/dist/types.d.ts +2 -0
- package/dist/types.js +1 -1
- package/docs/AGENT_GUIDE.md +1 -1
- package/docs/AGENT_OUTPUT_ENCODINGS.md +12 -0
- package/docs/AGENT_UX_CONTRACTS.md +2 -1
- package/docs/COMMANDS.md +58 -5
- package/docs/CONFIGURATION.md +48 -1
- package/docs/DEVELOPMENT_DEPENDENCY_SECURITY.md +26 -0
- package/docs/PACKED_FIRST_RUN.md +2 -1
- package/docs/READ_OUTPUT_CONTRACTS.md +24 -6
- package/docs/SDK.md +73 -2
- package/docs/TESTING.md +38 -2
- package/docs/agent-task-token-baseline.json +1 -1
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/extensions/calendar/index.ts +1 -0
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-34MP7WKK.js +0 -6
- package/dist/cli-bundle/chunks/chunk-3KMYHYJV.js +0 -2
- package/dist/cli-bundle/chunks/chunk-42BHHNTL.js +0 -128
- package/dist/cli-bundle/chunks/chunk-I5O3XZOA.js +0 -2
- package/dist/cli-bundle/chunks/chunk-LEIVUGDH.js +0 -8
- package/dist/cli-bundle/chunks/chunk-OH7WPD42.js +0 -114
- package/dist/cli-bundle/chunks/chunk-OOD2A7AF.js +0 -20
- package/dist/cli-bundle/chunks/chunk-Q5V7P6NM.js +0 -2
- package/dist/cli-bundle/chunks/chunk-QLPFYBXN.js +0 -2
- package/dist/cli-bundle/chunks/chunk-SA5NYLPE.js +0 -8
- package/dist/cli-bundle/chunks/chunk-VHLAVTJN.js +0 -31
- package/dist/cli-bundle/chunks/chunk-XAOVJG52.js +0 -3
- package/dist/cli-bundle/chunks/chunk-XPQ4RTSF.js +0 -2
- package/dist/cli-bundle/chunks/item-transaction-WIOBZW4E.js +0 -2
- package/dist/cli-bundle/chunks/register-mutation-5V2NANIS.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-XSFRMUFX.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2V6NMNYN.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-ASHGXMX4.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-CKBN2D42.js +0 -12
- package/dist/cli-bundle/focused-chunks/chunk-I642DXOT.js +0 -22
- package/dist/cli-bundle/focused-chunks/chunk-K7DKG5HM.js +0 -91
- package/dist/cli-bundle/focused-chunks/chunk-NMQBXU7N.js +0 -44
- package/dist/cli-bundle/focused-chunks/chunk-PGM3ENGZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-QFNV4JTA.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-QVJCQMZY.js +0 -26
- package/dist/cli-bundle/focused-chunks/chunk-R2TPPPVU.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VJVJ2ZX2.js +0 -2
- package/dist/cli-bundle/focused-chunks/item-transaction-ZFDKJIP7.js +0 -2
package/dist/cli-bundle/main.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import"./chunks/chunk-DEZPZOQ7.js";import{A as
|
|
2
|
-
`)}function
|
|
3
|
-
`)}function Ri(e,t){return t==="detailed"?Os(e):Rs(e)}function N(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var Is={cal:"calendar",ctx:"context"};function $s(e,t){return e.commands.find(n=>n.name()===t)??null}function Ps(e,t){let n=e;for(let o of t){let a=$s(n,o);if(!a)return null;n=a}return n}function bn(e,t,n,o){let a=Ps(e,t.split(" ").filter(i=>i.length>0));a&&a.addHelpText("after",Ri(n,o))}function Cn(e){return e.includes("--explain")?"detailed":"compact"}function oe(e){return e.includes("--all")||e.includes("--explain")}var ue={"item reopen":{why:"Reopens recurring work while archiving earlier closure evidence and declaring its current planning outcome.",examples:['pm item reopen pm-a1b2 "The failure recurred" --expected-result "The recurrence regression passes"'],tips:["Without --expected-result, follow recovery.suggested_retry_args to restore current planning before claiming the item."]},ops:{why:"Groups workspace diagnostics, quality checks, and maintenance under one discoverable command.",examples:["pm ops health --summary","pm ops validate --check-history-drift","pm ops --help"]},init:{why:"Bootstraps tracker storage and settings so all other commands can run safely.",examples:["pm init","pm init acme","pm init ./pm-sandbox --defaults","pm init --preset minimal","pm init --agent-guidance add","pm init --defaults --with-packages"],tips:["Run this once per repository before create/list/update commands.","A path-like positional (`./dir`, `/tmp/dir`) initializes that tracker path; a plain word remains an id prefix.","Rewriting id prefix, governance preset, or default author on an existing tracker requires --force.","Use --preset for non-interactive automation; omit it in a TTY to use the setup wizard.","Use --agent-guidance add to inject compact AGENTS/CLAUDE workflow guidance, or --agent-guidance status to inspect missing guidance without modifying files.","Use --with-packages when agents need bundled commands such as calendar and templates available immediately."]},config:{why:"Reads or updates project/global settings such as definition-of-done, item format, telemetry, and policy toggles.",examples:["pm config project get definition-of-done",'pm config project set definition-of-done --criterion "tests pass"',"pm config project set item-format --format toon","pm config project set sprint-release-format-policy --policy strict_error","pm config project set governance-preset --policy minimal","pm config project set governance-ownership-enforcement --policy none","pm config project set test-result-tracking --policy enabled","pm config global set telemetry-tracking --policy disabled"]},extension:{why:"Compatibility command for package-backed runtime extension lifecycle operations across project or global scope.",examples:["pm package install ./my-package --project","pm package install '*' --project","pm package doctor --project --detail summary","pm package manage --global","pm package activate sample-ext --project","pm package deactivate sample-ext --project","pm package uninstall sample-ext --global","pm package explore --project","pm package manage --global","pm package describe sample-ext --project","pm package doctor --detail deep"],tips:["Prefer pm install and pm package in new user-facing automation.","Use pm extension when maintaining existing extension-specific scripts or debugging the compatibility runtime directly.","Bundled aliases beads and todos resolve to package-shipped extension sources.","Use --gh/--github shorthand for GitHub sources and --ref to pin a branch, tag, or ref.","Install updates settings activation state automatically unless extension allowlist mode is unchanged.","Use --adopt for single-extension adoption and --adopt-all to bulk-register unmanaged installs as managed without reinstalling.","Use --manage for concise triage summaries and remediation-oriented diagnostics alongside full extension details.","Use --describe to map exactly what each loaded extension registers (commands, hooks, item types, providers, overrides) in one call.","Use --doctor for consolidated diagnostics with warning codes, remediation hints, and optional deep detail payloads."]},package:{why:"Installs, explores, manages, diagnoses, adopts, activates, deactivates, and refreshes package-backed pm runtime extensions.",examples:["pm package install npm:@scope/pm-package --project","pm package install ./my-package --project","pm package doctor --project --detail deep","pm package manage --project --runtime-probe","pm package describe --project","pm package activate sample-ext --project","pm package upgrade --packages-only --dry-run"],tips:["Prefer package vocabulary for user-facing workflows; extension vocabulary remains available for compatibility.","Use pm package describe [name] to map every surface a package registers without reading its manifest or running diagnostics.","Use pm upgrade to refresh the CLI/SDK and managed packages from their recorded sources.","Use --dry-run before upgrade when automation needs a deterministic plan."]},"package init":{why:"Generates an installable starter pm package with package metadata and a root extension entrypoint.",examples:["pm package init ./my-package","pm package init ./my-hook-package --capability hooks","pm package init ./my-search-package --capability search","pm package init ./my-sync-package --capability importers","pm package init ./my-domain-package --capability schema","pm package init ./my-output-package --capability renderers","pm package install ./my-sync-package --project","pm package doctor --project --detail summary"],tips:["Use --capability hooks for a starter after_command lifecycle reactor with runnable SDK testing coverage.","Use --capability search for a starter search provider/vector-store adapter with runnable SDK testing coverage.","Use --capability importers for paired import/export commands that move project context across systems.","Use --capability schema for a starter custom item type, field, and migration so pm models your project domain.","Use --capability renderers/parser/preflight/services for starter override surfaces (output renderer, parsed-option rewrite, pre-run gate decision, built-in service) \u2014 one runnable starter per SDK capability.","The generated package is local-install safe; add SDK runtime imports only after declaring dependencies and validating with package doctor.","Use package doctor after changes to verify activation, policy, and collision diagnostics."]},"package install":{why:"Installs pm packages from local paths, npm sources, GitHub sources, bundled aliases, or wildcard/all aliases.",examples:["pm package install ./my-package --project","pm package install npm:pm-changelog --project","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Prefer the top-level pm install alias in scripts when only installation is needed.","Run pm package manage or pm package doctor after installing external packages."]},"package doctor":{why:"Diagnoses package activation, policy, collision, and managed-state health for project or global package scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed package registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global package state: PM_GLOBAL_PATH=$(mktemp -d) pm package doctor --project --detail deep --trace.","Non-isolated project diagnostics include global registrations and emit remediation when global package state can affect the result."]},"package catalog":{why:"Lists bundled first-party package catalog metadata and compact field projections.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command","pm package list --project --fields alias,package_name,category"],tips:["Use --fields for low-token package discovery in agent loops.","External npm package discovery still belongs to npm search."]},"extension init":{why:"Generates an installable starter runtime extension with manifest and entrypoint files.",examples:["pm package init ./my-extension","pm package init ./my-hook-extension --capability hooks","pm package init ./my-search-extension --capability search","pm package init ./my-sync-extension --capability importers","pm package init ./my-domain-extension --capability schema","pm package init ./my-output-extension --capability renderers","pm package --install --project ./my-sync-extension","pm package --doctor --project --detail summary"],tips:["Use --capability hooks when the extension should react to command lifecycle events.","Use --capability search when the extension should register retrieval primitives.","Use --capability importers when the extension should register project-context import/export commands.","Use --capability schema when the extension should register custom item types, fields, and migrations.","Use --capability renderers/parser/preflight/services to override pm's output rendering, parsed options, pre-run gate, or a built-in service.","Use package init for new distributable package workflows; extension init is the compatibility-level runtime scaffold."]},"extension install":{why:"Installs a compatibility runtime extension from local, npm, GitHub, bundled alias, or wildcard sources.",examples:["pm package install ./my-extension --project","pm package --install --project ./my-extension","pm package doctor --project --detail summary"],tips:["Prefer pm install or pm package install for new package-first automation."]},"extension doctor":{why:"Diagnoses compatibility extension activation, policy, collision, and managed-state health for project or global extension scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed extension registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global extension state: PM_GLOBAL_PATH=$(mktemp -d) pm extension doctor --project --detail deep --trace.","Prefer pm package doctor in new package-first workflows."]},"extension catalog":{why:"Compatibility view of bundled package catalog metadata.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command"],tips:["Prefer pm package catalog in new user-facing workflows."]},install:{why:"Installs a pm package into project scope by default, using local, npm, GitHub, or bundled alias sources.",examples:["pm package install '*' --project","pm package install ./packages/pm-todos --project","pm package install npm:@scope/pm-package --global","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Installed packages are recorded in managed state and can be inspected with pm package manage."]},upgrade:{why:"Updates the global pm CLI/SDK and refreshes managed pm packages from recorded install sources.",examples:["pm package upgrade --dry-run","pm package upgrade --packages-only --project","pm package upgrade todos --dry-run","pm package upgrade --cli-only --repair","pm package upgrade --tag next --dry-run"],tips:["Omit target to include the CLI/SDK plus all managed packages in the selected scope.","Pass a target to refresh one managed package by name, directory, package name, or source.","Use --packages-only in repository automation when the global CLI should not be changed."]},create:{why:"Creates a new planning item with deterministic metadata and history.",examples:['pm create --title "Harden lock flow" --description "Improve stale lock handling" --type Task --status open --priority 1 --message "Create lock hardening task" --create-mode progressive','pm create --title "Weekly planning sync" --description "Recurring coordination meeting" --type Meeting --schedule-preset lightweight','pm create --title "Asset: Hero model" --description "Track playable model asset" --type Asset --status open --priority 1 --message "Create asset item" --type-option category=Character --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this asset item exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/assets/hero.glb,note=tracked asset" --test "command=node scripts/run-tests.mjs test,timeout_seconds=240" --doc "path=README.md,note=asset docs"'],tips:["Use --schedule-preset lightweight for Reminder/Meeting/Event when you want minimal required create inputs.","Use --type <value> to load type-aware policy guidance in --help output.","Bulk creation is pm item mutate --from items.jsonl (JSON Lines, array, or envelope; --upsert-key <field> makes re-runs idempotent)."]},focus:{why:"Sets a session focused item so new pm create items default their --parent to it (project management = context management).",examples:["pm focus pm-epic1","pm focus","pm focus --clear"],tips:["Focus is session-local (stored in .agents/pm/runtime/session.json, gitignored) \u2014 it never affects teammates.",'An explicit --parent on pm create always overrides the focused item; use --parent "" to create with no parent.',"A stale focused item produces the same missing-parent validation as an explicit stale --parent."]},update:{why:"Mutates existing item fields while preserving history and lock safety.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --unset close-reason --message "Clear stale close reason after reopen"','pm update pm-a1b2 --unset assignee --deadline +2d --message "Replan ownership and deadline"','pm update pm-a1b2 --body "Backfilled body text for legacy item" --message "Normalize missing body"'],tips:['Use "pm close <ID> <TEXT>" to close items instead of --status closed.',"When reopening from closed to a non-terminal status, update clears stale close_reason unless explicitly set via --close-reason.",'Use "pm append <ID> --body <text>" for additive notes; use update --body to replace body content.']},"update-many":{why:"Bulk-updates matched item sets with dry-run previews and rollback checkpoints for safe large-scale metadata changes.",examples:["pm update-many --filter-status open --status in_progress --dry-run",'pm update-many --filter-tag wave:7 --replace-tests --test "command=node scripts/run-tests.mjs test -- tests/core/history.spec.ts,timeout_seconds=240"','pm update-many --filter-tag governance --reviewer maintainer-review --message "Normalize reviewer metadata"',"pm update-many --rollback ckpt-abc123"],tips:["Use --dry-run first to inspect proposed changes before apply mode.","Linked-array mutation flags mirror pm update semantics (for example --replace-tests, --clear-files, and repeatable --doc/--note seeds).","Checkpoints are enabled by default for apply mode and can be restored with --rollback."]},"close-many":{why:"Bulk-closes matched items with a shared reason routed through full pm close semantics (close validation, active-child orphan checks, blocked-edge cleanup) plus dry-run previews and rollback checkpoints \u2014 unlike update-many --status closed, which bypasses close validation.",examples:['pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met" --dry-run','pm close-many --filter-tag wave:7 --reason "Superseded by redesign" --validate-close warn','pm close-many --ids pm-a,pm-b,pm-c --reason "Closed in batch" --resolution "Verified by integration suite"',"pm close-many --rollback close-many-20260604-abc123"],tips:["At least one filter (--filter-* or --ids) is required so close-many never matches every item.","Already-terminal matches are skipped by default; pass --force to re-close them.","Use --dry-run to preview matches plus per-item skip reasons and active-child orphan warnings before applying.","Checkpoints are enabled by default for apply mode; restore with --rollback <checkpoint-id>."]},templates:{why:"Saves, lists, and inspects reusable create option bundles for repeatable workflows.",examples:['pm templates save triage-default --title "Triage item" --description "..." --type Task --status open --priority 2 --message "Seed triage template"',"pm templates list","pm templates show triage-default"],tips:["Template names are positional arguments (`pm templates save <name>` and `pm templates show <name>`), not --name flags.","Combine templates with explicit create flags; explicit flags always override template defaults."]},deps:{why:"Inspects an item dependency graph as a tree or graph payload to understand blockers and hierarchy links.",examples:["pm deps pm-a1b2","pm deps pm-a1b2 --format graph","pm deps pm-a1b2 --max-depth 2 --collapse repeated --summary"],tips:["Use --summary for lightweight counts when full graph payloads are unnecessary."]},list:{why:"Lists active items with deterministic filtering and ordering.",examples:["pm list --limit 20","pm list --type Task --priority 0 --tag release --status in_progress","pm list --compact --sort deadline --order asc","pm list --fields id,title,parent,type --sort parent --order asc"]},"list-all":{why:"Lists all item states (including terminal states) when you need full visibility.",examples:["pm list --all --limit 50","pm list --all --type Issue --include-body"]},"list-open":{why:"Shows work that is ready to claim and start.",examples:["pm list --status open --priority 0 --limit 10"]},"list-in-progress":{why:"Tracks active execution and owner progress.",examples:["pm list --status in_progress --priority 0 --limit 20"]},"list-blocked":{why:"Surfaces blocked work that needs intervention.",examples:["pm list --blocked --limit 20"]},"list-closed":{why:"Reviews completed work and closure outcomes.",examples:["pm list --status closed --limit 20 --type Task"]},"list-canceled":{why:"Audits intentionally discontinued work.",examples:["pm list --status canceled --limit 20"]},"list-draft":{why:"Finds incompletely defined items that need refinement before execution.",examples:["pm list --status draft --limit 20"]},aggregate:{why:"Runs grouped aggregation queries for governance checks such as decomposition by parent/type or triage by status/priority.",examples:["pm aggregate --group-by parent,type --count","pm aggregate --group-by type,status --count","pm aggregate --group-by parent,type --count --status open --parent pm-feature01"],tips:["Current aggregate mode is grouped counts only, so pass --count explicitly."]},guide:{why:"Routes local progressive-disclosure documentation so agents can fetch only the context they need.",examples:["pm package install guide-shell --project","pm guide","pm guide quickstart","pm guide commands --depth standard","pm guide skills --depth deep --format markdown","pm guide release --json"],tips:["Use brief depth for minimal token footprint, standard for excerpted docs, and deep for full local document rendering.","Use --list to force topic index output even when topic parsing is ambiguous."]},calendar:{why:"Provides deadline/reminder/event scheduling views for planning and coordination.",examples:["pm calendar","pm calendar --view agenda --from +0d --to +7d --tag release","pm calendar --view week --date 2026-04-06 --full-period --include deadlines,events","pm calendar --view month --tag release --format json"],tips:["Day/week/month views are anchored period windows; default mode clips the start to now unless --past or --full-period is set.","--full-period applies only to day/week/month views; use --from/--to to bound agenda windows."]},context:{why:"Builds an agent-optimized snapshot of critical active work plus near-term agenda context with progressive depth levels.",examples:["pm context","pm ctx --depth standard --limit 10","pm ctx --depth deep --tag release","pm ctx --section hierarchy --section progress --section blockers","pm context --depth standard --activity-limit 20 --stale-threshold 14d","pm context --from +0d --to +7d --format markdown --depth deep"],tips:["High-level focus contains Epics/Features and low-level focus contains Tasks/Issues/Chores/Decisions/Event/Reminder/Milestone/Meeting/Plan.","When no open or in-progress work exists, blocked items are shown as fallback context.","--depth brief (default) shows focus+agenda; standard adds hierarchy/activity/progress/workload; deep adds blockers/files/staleness/tests.","--section overrides --depth and selects specific sections: hierarchy, activity, progress, blockers, files, workload, staleness, tests.","Configure defaults via pm config project set context --default-depth standard --activity-limit 15."]},next:{why:"Answers 'what should I work on now?' with the highest-priority ready item, rationale, and ranked ready and blocked queues.",examples:["pm next","pm next --json","pm next --limit 3 --ready-only","pm next --parent pm-mpbb","pm next --tag release --format markdown"],tips:["Ready = active status, no open blockers, and no open children (a concrete leaf); the recommendation resumes in-progress work before starting new work.","An item is blocked when its scalar blocked_by or a blocked_by dependency points at a non-terminal item; the blocked list names the blockers to clear.","Containers (Epics/Features with open children) are never recommended directly \u2014 the actionable leaf beneath them is.","Use --parent to scope to one epic's subtree, or --ready-only to drop the blocked companion list for the tightest output."]},search:{why:"Finds relevant items by keyword, semantic, or hybrid retrieval modes.",examples:['pm search "lock stale retry" --mode keyword --limit 10','pm search "extension migration blockers" --mode hybrid --type Task --priority 0','pm search "Cross-Epic Realism Dependency Council" --mode keyword --title-exact'],tips:["Use --title-exact to require exact normalized title parity, or --phrase-exact to require full-phrase matches in item text fields.","Use --include-linked when linked docs/files/tests should influence scoring."]},eval:{why:"Measures search relevance against a curated golden-query set so retrieval regressions are caught, not guessed.",examples:["pm eval --json","pm eval --mode hybrid --k 10","pm eval --fail-under 0.6 --json","pm eval --queries ./my-eval.json --mode semantic"],tips:["Curate ground truth in <pmRoot>/search/eval-queries.json as an array of {query, relevant_ids, mode?} objects.","Wire --fail-under into CI to fail the build when aggregate nDCG@k drops below your baseline."]},reindex:{why:"Rebuilds search artifacts after large changes to item corpus or provider/vector config.",examples:["pm reindex --mode keyword","pm reindex --mode hybrid --progress --json"],tips:["Use --progress for non-interactive visibility during local embedding runs.","JSON output includes semantic stale/unchanged/embed/upsert counts so agents can gate long reindex work without parsing stderr."]},get:{why:"Shows details for one item by ID, with optional lower-token projections for agent loops.",examples:["pm get pm-a1b2","pm get pm-a1b2 --depth brief --json","pm get pm-a1b2 --fields id,title,status,parent,type --json","pm get pm-a1b2 --at 7 --fields id,title,status,body --json"],tips:["Default depth is standard for body plus linked artifacts without append-only logs; use brief for metadata-only checks or --full for complete history-heavy metadata.","Use --fields for the smallest deterministic item metadata payload when an agent only needs specific fields.","Schedule metadata is normalized under schedule; request schedule.start_at or schedule.location for narrow calendar reads.","Children are type-agnostic and include bounded deterministic samples plus continuation metadata when a parent has direct children.","Use --at <version|timestamp> for a verified read-only historical projection; reconstructed/as_of fields distinguish it from current state.","JSON output shape is { item, linked, claim_state, schedule, children }; body is nested at item.body (parity with list --include-body)."]},history:{why:"Inspect recorded mutations.",examples:["pm history pm-a1b2 --order oldest_first","pm history pm-a1b2 --full --verify"]},"history-compact":{why:"Compacts long history streams into a synthetic checkpoint while preserving replay integrity. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to sweep many.",examples:["pm history-compact pm-a1b2 --dry-run",'pm history-compact pm-a1b2 --before 25 --message "Compact early history"',"pm history-compact --all-over 500 --dry-run","pm history-compact --closed","pm history-compact --ids pm-a1b2,pm-c3d4 --dry-run"]},activity:{why:"Reviews recent tracker-wide activity across items.",examples:["pm activity --limit 50","pm activity --full --id pm-a1b2 --limit 50","pm activity --id pm-a1b2 --op update --from -7d --to now","pm activity --json --stream rows --limit 200"],tips:["Use --stream with --json for line-delimited automation output; --from is inclusive and --to is exclusive."]},restore:{why:"Restores an item to a prior timestamp/version with history replay safety.",examples:['pm restore pm-a1b2 2026-04-01T00:00:00.000Z --message "Rollback to known-good state"']},close:{why:"Transitions work to terminal closed state with explicit rationale.",examples:['pm close pm-a1b2 "Done" --resolution "Delivered" --expected "Required outcome" --actual "Verified outcome" --release-assignment --validate-close warn','pm close pm-a1b2 "Done" --validate-close','pm close pm-a1b2 "Done" --validate-close off','pm close pm-a1b2 "Done" --validate-close strict']},delete:{why:"Removes an item while preserving history evidence and lock/ownership checks.",examples:['pm delete pm-a1b2 --message "Remove duplicate item"']},append:{why:"Adds implementation notes to body without replacing existing content.",examples:['pm append pm-a1b2 --body "Implemented retry with bounded backoff." --message "Record implementation detail"']},comments:{why:"Adds or reviews lightweight status updates linked to an item.",examples:['pm comments pm-a1b2 "Verified fix on Linux and macOS"','pm comments pm-a1b2 --add "Verified fix on Linux and macOS"','printf "%s\\n" "## Verification" "- linux pass" "- mac pass" | pm comments pm-a1b2 --stdin',"pm comments pm-a1b2 --file docs/release-evidence.md",'pm comments pm-a1b2 --add "text: verification note with commas, key-like words, and parser details"','pm comments pm-a1b2 --add "Follow-up needed after review" --force',"pm comments pm-a1b2 --limit 10"],tips:["Use exactly one comment source at a time: positional [text], --add, --stdin, or --file.","Use --force when adding comments to items currently assigned to a different owner.","When --add payload resembles CSV-like key fragments (for example text=hello,scope:project), plain-text fallback is intentional; use explicit text=..., markdown text: ..., or stdin token - for structured intent."]},notes:{why:"Adds or reviews durable implementation notes linked to an item.",examples:['pm notes pm-a1b2 --add "Investigated parser edge case and documented fallback logic."','pm notes pm-a1b2 --add "text: parser rationale with commas, colons, and key-like wording"','pm notes pm-a1b2 --edit 1 --add "Corrected durable note"',"pm notes pm-a1b2 --delete 2","pm notes pm-a1b2 --limit 10"],tips:["CSV-like add payloads with extra key fragments are treated as plain text by design; use explicit text keys (text= or text:) when structured parsing is required."]},learnings:{why:"Adds or reviews post-implementation learnings for future work.",examples:['pm learnings pm-a1b2 --add "Avoid direct test-runner commands in linked tests; use sandbox runner."','pm learnings pm-a1b2 --add "text: lesson with commas, key-like words, and punctuation-safe context"',"pm learnings pm-a1b2 --edit 1 --file docs/corrected-learning.md","pm learnings pm-a1b2 --delete 2","pm learnings pm-a1b2 --limit 10"],tips:["If you intended structured parsing for a key-like payload, prefer explicit text=..., markdown text: ..., or stdin token -; ambiguous CSV-like forms intentionally remain plain text."]},files:{why:"Associates changed source files with tracker items for reproducibility.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,note=help orchestration"','pm files pm-a1b2 --add src/cli/main.ts --note "help orchestration"',"pm files discover pm-a1b2",'pm files discover pm-a1b2 --apply --note "discovered from item text"']},docs:{why:"Associates relevant documentation paths with tracker items.",examples:['pm docs pm-a1b2 --add "path=README.md,note=user-facing command guidance"','pm docs pm-a1b2 --add README.md --note "user-facing command guidance"']},test:{why:"Links test commands/paths and optionally executes them for one item.",examples:['pm test pm-a1b2 --add "command=node scripts/run-tests.mjs test -- tests/unit/output.spec.ts,timeout_seconds=2400"','pm test pm-a1b2 --add "command=pm list --all --type Task --limit 200,assert_stdout_contains=count:,assert_stdout_regex=count:\\s+\\d+"','pm test pm-a1b2 --add "command=pm list --all --type Task --limit 200,pm_context_mode=auto"',"pm test pm-a1b2 --run --timeout 2400 --env-set PORT=0 --env-clear PLAYWRIGHT_BASE_URL --shared-host-safe --pm-context tracker --fail-on-context-mismatch --fail-on-skipped","pm test pm-a1b2 --run --timeout 2400 --pm-context auto","pm test pm-a1b2 --run --background --timeout 2400 --progress"]},"test-all":{why:"Runs linked tests in bulk for release/readiness sweeps.",examples:["pm test-all --status in_progress --limit 5 --offset 10 --timeout 2400","pm test-all --status closed --timeout 3600 --progress --env-set PORT=0 --shared-host-safe --fail-on-skipped","pm test-all --status in_progress --pm-context tracker --fail-on-context-mismatch --require-assertions-for-pm","pm test-all --status in_progress --pm-context auto --fail-on-context-mismatch","pm test-all --status in_progress --background --timeout 3600"]},"test-runs":{why:"Manages background linked-test runs with lifecycle controls and log/status inspection.",examples:["pm test-runs list --status running --limit 20","pm test-runs status tr-abc123","pm test-runs logs tr-abc123 --stream stderr --tail 200","pm test-runs stop tr-abc123","pm test-runs resume tr-abc123"]},stats:{why:"Reports tracker-level totals and distribution by type/status.",examples:["pm stats","pm stats --json"]},telemetry:{why:"Inspects and manages local telemetry queue/runtime state for observability diagnostics.",examples:["pm telemetry status","pm telemetry stats --limit 10","pm telemetry flush","pm telemetry clear"]},health:{why:"Validates tracker/runtime health including extension triage, migration, and integrity diagnostics.",examples:["pm health","pm health --check-only --summary --json","pm health --brief --json","pm health --no-refresh","pm health --refresh-vectors"]},validate:{why:"Runs standalone metadata, resolution, lifecycle (including dependency-cycle diagnostics), linked-file, linked-command reference, and history drift checks with default remediation hints for resolution gaps.",examples:["pm validate","pm validate --check-resolution --json","pm validate --check-lifecycle --dependency-cycle-severity error","pm validate --check-lifecycle --parent-cycle-severity error","pm validate --check-files --scan-mode tracked-all","pm validate --check-files --scan-mode tracked-all-strict --include-pm-internals","pm validate --check-command-references","pm validate --check-resolution --fail-on-warn --json"],tips:["Resolution-gap warnings include default `pm update <id> ...` remediation hint templates in check details."]},gc:{why:"Deletes optional cache artifacts by default to keep local tracker state tidy; use --dry-run to preview targets without deleting files.",examples:["pm gc --dry-run","pm gc"]},claim:{why:"Claims an item to signal active ownership and reduce conflicts.",examples:["pm claim pm-a1b2 --start",'pm claim pm-a1b2 --force --message "Take over terminal item"','pm claim pm-a1b2 --author "release-service" --message "Explicit non-agent identity override"'],tips:["Claim is an atomic test-and-set: a non-terminal item held by another principal refuses with already_claimed_by. Use --if-available to skip that item without failing. Terminal items still require --force, even when --if-available is set. Use --force for coordinated takeovers; stale locks require --force only when governance.force_required_for_stale_lock is enabled.","Harness identity is automatic; use --author only to assert an intentional external principal."]},release:{why:"Releases an active claim when paused, handed off, or completed.",examples:["pm release pm-a1b2 --pause",'pm release pm-a1b2 --handoff review --message "Implemented; run linked verification"'],tips:["Register the project queue with pm schema add-status review --role active before using --handoff."]},"start-task":{why:"Lifecycle alias that claims an item and sets status to in_progress.",examples:['pm claim --start pm-a1b2 --message "Start implementation"']},"pause-task":{why:"Lifecycle alias that sets status to open and releases active assignment.",examples:['pm release --pause pm-a1b2 --message "Pause for dependency unblock"']},"close-task":{why:"Lifecycle alias that closes with reason text and clears assignment metadata.",examples:['pm close --release-assignment pm-a1b2 "All acceptance criteria met" --message "Close and handoff"']},meet:{why:"Shortcut to create a Meeting from friendly time flags (start/duration) without structured --event CSV.",examples:['pm meet "Sprint Planning" --start +1h --duration 1h','pm meet "1:1" --start 2026-07-01T15:00:00Z --end 2026-07-01T15:30:00Z --location "Room A"'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},event:{why:"Shortcut to create an Event from friendly time flags (start/duration) without structured --event CSV.",examples:['pm event "Release v2" --start 2026-07-01T10:00:00Z --duration 2h','pm event "Conference" --start 2026-08-01 --all-day'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},remind:{why:"Shortcut to create a Reminder from a single point in time without structured --reminder CSV.",examples:['pm remind "Review PR" --at +2d','pm remind "Follow up" --at 2026-07-01T09:00:00Z --text "Ping the team"'],tips:["The reminder time defaults to +1d and the reminder text defaults to the title."]},completion:{why:"Generates shell completion scripts for faster and more reliable command entry.",examples:["pm completion bash","pm completion zsh","pm completion fish","pm completion bash --eager-tags"],tips:["Default scripts resolve tag suggestions lazily at completion time; use --eager-tags to embed current tags directly."]},contracts:{why:"Exposes machine-readable CLI command and tool schema contracts for agent integrations.",examples:["pm contracts","pm contracts --command list --runtime-only","pm contracts --command update --flags-only","pm contracts --availability-only --runtime-only","pm contracts --action create","pm contracts --schema-only"],tips:["Use --command to narrow actions/schema to one CLI surface; combine with --flags-only or --availability-only for lighter payloads."]}};for(let{alias:e,canonical:t}of $){let n=ue[e];n&&(ue[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var xe={why:"Provides deterministic project management workflows for humans and coding agents.",examples:["pm init","pm package install guide-shell --project","pm list --status open --limit 10",'pm create --title "..." --description "..." --type Task --status open --priority 1 --message "..." --create-mode progressive'],tips:["Use <command> --help for command-specific guidance and examples.","Install guide-shell before using pm guide for local docs and skills routing.","Use --json for machine parsing and integration flows.","Use --no-pager to force direct help output in CI and other non-interactive shells."]},Oi=V.filter(e=>e.lifecycle==="deprecated");for(let e of Oi){let t=ue[e.alias];ue[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[xe,...Object.values(ue)])e.examples=e.examples.map(t=>{for(let n of Oi){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function Ds(e){let t=N(e??"");return t?Is[t]??t:""}function kn(e){let t=Ds(e);return t?ue[t]??xe:xe}function Ii(e,t){let n=kn(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:Ti(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function Ms(){let e=V.filter(({lifecycle:n})=>n==="permanent"),t=V.filter(({lifecycle:n})=>n==="deprecated");return["","Command aliases:",...e.map(({alias:n,canonical_argv:o})=>` ${n} -> pm ${o.join(" ")}`),"","Deprecated aliases:",...t.map(n=>` ${n.alias} -> pm ${n.canonical_argv.join(" ")} (${Xo(n)})`)].join(`
|
|
4
|
-
`)}function
|
|
5
|
-
`,s=t.visibleCommands(e);for(let l of s)pe(l)===void 0&&(l.name()==="help"||a.has(l.name()))&&n.add(l);for(let l of s)pe(l)==="core"&&(n.add(l),ci(r()).within_budget||n.delete(l))}function $i(e,t=process.argv.slice(2)){let n=e.createHelp(),o=oe(t),a=new Set;Ns(e,n,o,a);let i=Cn(t),r=Ri(xe,i);e.addHelpText("after",r),o&&e.addHelpText("after",Ms()),Fs(e,n,a,r);for(let[d,m]of Object.entries(ue))bn(e,d,m,i);let s=N(A(t).commandPathTokens.join(" ")),l=qe(s);if(l){bn(e,l.parent,{why:l.description,examples:[l.example],tips:[`Action path: pm ${l.command}`,_t(l.accepted_flags)]},i);return}let c=yt.filter(({parent:d})=>d===s);c.length>0&&bn(e,s,{why:`Dispatches one declared positional action: ${c.map(({action:d})=>d).join("|")}.`,examples:c.map(({example:d})=>d),tips:[`Inspect one action directly with pm ${s} <action> --help --json.`]},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]="2efeb172-b440-5df6-ad48-4c54087835e0")}catch{}})();function xn(e,t=!1){e.commands.some(n=>n.name()==="ops")||e.command("ops").description("Discover workspace diagnostics and maintenance operations.");for(let{alias:n,canonical:o,canonical_argv:a}of $){if(t&&!$.some(c=>c.canonical.startsWith(`${o} `)))continue;let i=e.commands.findIndex(c=>c.name()===n);if(i<0)continue;let r=e.commands[i],s=e;for(let c of a.slice(0,-1))s!==e&&s.enablePositionalOptions(),s=s.commands.find(d=>d.name()===c)??s.command(c).description(`Discover ${c} operations.`);let l=a[a.length-1];if(s.commands.some(c=>c.name()===l))throw new Error(`Cannot install canonical command ${o}: destination already exists.`);e.commands.splice(i,1),r.name(l),xt(r,Y(o)),s.enablePositionalOptions(),s.addCommand(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]="2302a550-7046-5865-93ed-93771ac4b787")}catch{}})();function At(e){let{why:t,title:n,...o}=e;return o}var Ls=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function js(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!Ls.has(e.code)}function Fi(e){return`urn:pm-cli:error:${e}`}function k(e){return{...e,type:Fi(e.code)}}var Ee={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},Pi={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},Di={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},Et={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},Us={guide:Ee,shell:Ee,completion:Ee,"completion-statuses":Ee,"completion-tags":Ee,"completion-types":Ee,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:Pi,cal:Pi,reindex:Di,"search-advanced":Di,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":Et,"dedupe-audit":Et,"dedupe-merge":Et,normalize:Et};function qs(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return Us[t]}function En(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function Hs(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function zs(e){if(!Array.isArray(e))return;let t=e.map(n=>({source:typeof n?.source=="string"?n.source.trim():"",command:typeof n?.command=="string"?n.command.trim():"",reason:typeof n?.reason=="string"?n.reason.trim():""})).filter(n=>n.source.length>0&&n.command.length>0&&n.reason.length>0);return t.length>0?t:void 0}function Sn(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function Li(e){return Array.isArray(e)&&e.length>0&&e.every(t=>typeof t=="string")?[...e]:void 0}function Z(e,t,n){if(t==="normalized_args"||t==="suggested_retry_args"){let a=Li(n);a&&(e[t]=a);return}if(t==="parsed_positionals"){if(!Array.isArray(n))return;let a=n.map(i=>({role:typeof i?.role=="string"?i.role.trim():"",value:typeof i?.value=="string"?i.value.trim():""})).filter(i=>i.role.length>0&&i.value.length>0);a.length>0&&(e.parsed_positionals=a);return}let o=Hs(n);o&&(e[t]=o)}function Gs(e,t){if(!Da(t))return;let{requested_tokens:n,feasible_tokens:o,minimum_feasible_tokens:a,minimum_status:i,basis:r,reason:s}=t;e.token_budget={requested_tokens:n,feasible_tokens:o,minimum_feasible_tokens:a,minimum_status:i,basis:r,reason:s}}var ji=["retry_after_ms","waited_ms","owner_handoffs"];function Ws(e,t){for(let n of ji)typeof t[n]=="number"&&e.push(` ${n}: ${t[n]}`)}function Vs(e,t){for(let n of ji){let o=t[n];typeof o=="number"&&Number.isSafeInteger(o)&&o>=0&&(e[n]=o)}}function Se(e){if(!e||typeof e!="object")return;let t={};Gs(t,e.token_budget),e.recovery_mode==="compact"&&(t.recovery_mode="compact"),Sn(t,"attempted_command",e.attempted_command),Z(t,"normalized_args",e.normalized_args),Z(t,"parsed_positionals",e.parsed_positionals),Z(t,"provided_fields",e.provided_fields),Z(t,"missing",e.missing),Z(t,"missing_required_fields",e.missing_required_fields),Z(t,"suggested_flags",e.suggested_flags),Z(t,"allowed_values",e.allowed_values),Z(t,"candidate_commands",e.candidate_commands),typeof e.candidate_commands_total=="number"&&Number.isSafeInteger(e.candidate_commands_total)&&e.candidate_commands_total>=0&&(t.candidate_commands_total=e.candidate_commands_total),e.candidate_commands_truncated===!0&&(t.candidate_commands_truncated=!0),(e.option_scope==="declared_on_path"||e.option_scope==="declared_elsewhere"||e.option_scope==="declared_nowhere")&&(t.option_scope=e.option_scope),Sn(t,"suggested_retry",e.suggested_retry),Z(t,"suggested_retry_args",e.suggested_retry_args),Vs(t,e);let n=zs(e.fallback_candidates);return n&&(t.fallback_candidates=n),Sn(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function An(e,t,n){n&&e.push(` ${t}: ${n}`)}function fe(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function Bs(e){let t=Se(e);if(!t)return[];let n=["Recovery bundle:"];if(t.token_budget){let o=t.token_budget;n.push(` requested_token_budget: ${o.requested_tokens}`,` feasible_token_budget: ${o.feasible_tokens??"unavailable"}`,` minimum_token_budget: ${o.minimum_feasible_tokens??"not established"}`)}if(An(n,"suggested_retry",t.suggested_retry),An(n,"attempted_command",t.attempted_command),fe(n,"normalized_args",t.attempted_command?void 0:t.normalized_args," "),t.parsed_positionals&&t.parsed_positionals.length>0){n.push(" parsed_positionals:");for(let o of t.parsed_positionals)n.push(` - ${o.role}: ${o.value}`)}if(fe(n,"provided_fields",t.provided_fields,", "),fe(n,"missing",t.missing,", "),fe(n,"missing_required_fields",t.missing_required_fields,", "),fe(n,"suggested_flags",t.suggested_flags,", "),fe(n,"allowed_values",t.allowed_values,", "),fe(n,"candidate_commands",t.candidate_commands,", "),typeof t.candidate_commands_total=="number"&&n.push(` candidate_commands_total: ${String(t.candidate_commands_total)}`),t.candidate_commands_truncated===!0&&n.push(" candidate_commands_truncated: true"),t.option_scope!==void 0&&n.push(` option_scope: ${t.option_scope}`),Ws(n,t),An(n,"next_best_command",t.next_best_command),t.fallback_candidates&&t.fallback_candidates.length>0){n.push(" fallback_candidates:");for(let o of t.fallback_candidates)n.push(` - ${o.source}: ${o.command} (${o.reason})`)}return n}function Ui(e){let t=[`Error: ${e.title}`,"","What is required:",` ${e.required}`];e.nextSteps&&e.nextSteps.length>0&&(t.push(""),t.push(...En("Next steps:",e.nextSteps))),t.push("","What happened:",` ${e.happened}`),e.why&&(t.push("","Why:"),t.push(` ${e.why}`)),e.examples&&e.examples.length>0&&(t.push(""),t.push(...En("Examples:",e.examples))),e.verificationErrors&&e.verificationErrors.length>0&&(t.push(""),t.push(...En("Verification errors:",e.verificationErrors)));let n=Bs(e.recovery);return n.length>0&&(t.push(""),t.push(...n)),t.join(`
|
|
6
|
-
`)}function Ks(e,t){t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),t.lease!==void 0&&(e.lease=t.lease,e.current_owner=t.currentOwner??null,e.item_id=t.itemId)}function qi(e,t){return t.sideEffects!==void 0&&(e.side_effects=t.sideEffects),t.previewStorage!==void 0&&(e.preview_storage=t.previewStorage),t.transactionOperation!==void 0&&(e.transaction_operation=t.transactionOperation),Ks(e,t),js(t)&&(e.why=t.why),t.examples&&t.examples.length>0&&(e.examples=t.examples),t.nextSteps&&t.nextSteps.length>0&&(e.next_steps=t.nextSteps),t.verificationErrors&&t.verificationErrors.length>0&&(e.verification_errors=t.verificationErrors),t.flag!==void 0&&(e.flag=t.flag),t.value!==void 0&&(e.value=t.value),t.unmatchedSelectors!==void 0&&(e.unmatched_selectors=t.unmatchedSelectors),t.availableDependencies!==void 0&&(e.available_dependencies=t.availableDependencies),t.recovery&&(e.recovery=t.recovery),e}function Js(e,t){if(e.flag)return e.flag;let n=o=>{let a=o.split("=",1)[0];return M([a]).length>0&&!["--help","--no-changed-fields","--version"].includes(a)&&t.some(i=>i===a||i.startsWith(`${a}=`))};return[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(o=>o[0]).find(o=>n(o))}function Ys(e,t,n){if(e.value!==void 0)return e.value;if(e.flag===void 0&&n){let o=t.find(i=>i===n||i.startsWith(`${n}=`));if(o?.startsWith(`${n}=`))return o.slice(n.length+1);let a=t.indexOf(n);return t[a+1]}}function Xs(e,t){if(e.policyViolations?.length)return{surface:`policy:${e.policyViolations.map(s=>s.policy_id).join(",")}`,policies:e.policyViolations,policy_violation_count:e.policyViolationCount,missing_fields:[...new Set(e.policyViolations.flatMap(s=>s.missing_fields))],exit_code:t};let n=M(e.recovery?.normalized_args??[]),o=G(n),a=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,i=Js(e,a),r=Ys(e,a,i);return{surface:i??e.recovery?.missing?.[0]??_n(a)??"command",...r!==void 0?{rejected_value:r}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function Zs(e,t){return qi({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:Xs(e,t),...e.changed===!1?{changed:!1}:{}},e)}function Rn(e,t){let n=e.recovery,o=!!n?.suggested_retry||!!n?.suggested_retry_args?.length||!!n?.allowed_values?.length||!!n?.candidate_commands?.length||!!e.nextSteps?.length;return va(Zs(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function On(e){return qi({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,...e.changed===!1?{changed:!1}:{}},e)}function Tt(e){return e.replace(/\(outputHelp\)/g,"").trim()}function Qs(e){let t=e.toLowerCase();return t.includes("cannot find module")||t.includes("cannot find package")||t.includes("err_module_not_found")||t.includes("module_not_found")}function ge(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function Mi(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function el(e){return _n(e?.normalized_args)}function tl(e){let t=e.match(/\bmust be one of:?\s+([A-Za-z0-9_.|,\- ]+)/i);return t?t[1].split(/[|,]/).map(n=>n.trim()).filter(n=>/^[A-Za-z0-9_.-]+$/.test(n)):[]}function nl(e,t){let n=e?.normalized_args,o=e?.provided_fields,a=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!a))for(let i of o){let r=n.findIndex(s=>s===i);if(r>=0&&r<n.length-1&&!n[r+1]?.startsWith("-")){let s=[...n];return s[r+1]=a,b(s)}}}function ol(e){let t=e.split(/\r?\n/)[0].trim();if(t.length!==0)return t.length<=120?t:`${t.slice(0,117)}...`}function St(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function al(e,t){if(e.flag!==void 0)return e.flag;if(e.field===void 0)return;let n=e.field.startsWith("--")?e.field:`--${e.field.replaceAll(/([A-Z])([A-Z][a-z])/gu,"$1-$2").replaceAll(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`;return t?.normalized_args?.some(o=>o===n||o.startsWith(`${n}=`))?n:void 0}function ae(e,t,n){if(!n)return e;let o=Tt(t),a=St(n.code,e.code),i=St(n.type,Fi(a)),r=ge(n.examples)??e.examples,s=ge(n.nextSteps)??e.nextSteps,l=ge(n.verification_errors)??e.verificationErrors,c=e.code==="command_failed"&&n.code?ol(o):void 0,d=Se(n.recovery),m=d&&e.recovery?Se({...e.recovery,...d}):d??e.recovery;return{...e,code:a,changed:n.changed,sideEffects:n.side_effects,type:i,title:c??e.title,happened:o.length>0?o:e.happened,required:St(n.required,e.required),why:St(n.why,e.why),examples:r,nextSteps:s,verificationErrors:l,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:al(n,m)??e.flag,value:n.value??e.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,transactionOperation:n.transaction_operation,previewStorage:n.preview_storage,tombstone:n.tombstone,lease:n.lease,currentOwner:n.current_owner,availableDependencies:n.available_dependencies,recovery:m}}function il(e,t,n){let o=t.match(/^Tracker is not initialized at (.+)\. (?:Run pm init first|Tracker root does not exist\. Run pm init first)\.$/);if(!o)return null;let a=o[1],i=na(process.cwd(),a);return ae(k(i?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${a}, but found a tracker at ${i}.`,required:"Select the existing tracker root explicitly.",why:"Implicit discovery checks the default .agents/pm layout and ancestor root-layout trackers, while custom nested roots require an explicit path.",examples:[`pm --pm-path ${i} <command>`,`PM_PATH=${i} pm <command>`],nextSteps:[`Re-run with "--pm-path ${i}" or export PM_PATH=${i}.`]}:{code:"tracker_not_initialized",title:"Tracker is not initialized",happened:`pm data path does not contain initialized tracker metadata (${o[1]}).`,required:"Select an existing tracker with --pm-path/PM_PATH, or initialize the default .agents/pm storage.",why:"Most commands require settings in an explicitly selected root, an ancestor root-layout tracker, or the default .agents/pm directory.",examples:["pm init","pm init acme"],nextSteps:['Run "pm init", then rerun your original command.']}),e,n)}function rl(e,t,n){let o=t.match(/^Item ([^ ]+) not found$/);if(!o)return null;let a=o[1],i=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(a),r=i?`The item ID "${a}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${a}" exists in the active tracker scope.`;return ae(k({code:"item_not_found",title:"Item ID not found",flag:"id",value:a,happened:r,required:"Use an existing item ID from current tracker data.",why:"Mutation and read commands operate only on known IDs.",examples:["pm list --status open --limit 20",'pm search "<keyword>" --limit 10'],nextSteps:i?["Check that the variable holding the item ID is defined before passing it to pm.",'Use "pm list --status open --limit 20" to find valid IDs.']:["Confirm the active --path/PM_PATH scope, then retry with a valid id."]}),e,n)}function sl(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:ae(k({code:"ownership_conflict",title:"Ownership conflict",happened:t,required:"Run as the assigned owner, claim the item when appropriate, or use --force only for an approved override.",why:"Ownership checks prevent accidental concurrent mutations on claimed items and protect against conflicting writes.",examples:["pm claim pm-a1b2","pm update pm-a1b2 --status in_progress --force"],nextSteps:["Use --force for approved systematic metadata updates performed by leads or maintainers.","Use --force when correcting known stale metadata after coordinating ownership changes.",'For non-terminal reassignment, prefer "pm claim <ID>" before running other mutations.']}),e,n)}function ll(e,t,n){if(!t.includes("is locked"))return null;let o=Li(n?.recovery?.normalized_args),a=o?b(o):void 0,i=ae(k({code:"lock_conflict",title:"Lock conflict",happened:t,required:"Wait for lock release, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget for expected contention.",why:"Locking protects item files from concurrent write races.",examples:a?[a]:["pm gc --scope locks --dry-run"]}),e,n);return o&&(i.recovery={...i.recovery,suggested_retry:a,suggested_retry_args:[...o]}),i}function cl(e,t,n){let o=t.match(/^Missing required option /),a=t.match(/^Missing required options /);if(!o&&!a)return null;let i=!!a,r=i?null:t.replace(/^Missing required option\s+/,"").trim(),s=r??"",l=r?`Pass ${r} with a valid value before running the command.`:"Provide the required option for this command invocation.";return ae(k({code:"missing_required_option",title:i?"Missing required options":`Missing required option ${s}`,happened:t,required:i?"Provide every required option for this command invocation.":l,why:"Required options define command intent and enforce deterministic write contracts.",examples:['pm create --title "Task title" --description "Task details" --type Task --create-mode progressive','pm create --title "Task title" --description "Task details" --type Task --status open --priority 1 --message "Create task" --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this task exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/example.ts,scope=project" --test "command=node scripts/run-tests.mjs test,scope=project,timeout_seconds=240" --doc "path=README.md,scope=project"'],nextSteps:['Run "pm <command> --help" to view required and recommended flags.',"For staged triage without placeholder linkage values, use --create-mode progressive."]}),e,n)}function dl(e,t,n){return t.startsWith("No update flags provided")?ae(k({code:"no_update_fields",title:"No update fields supplied",happened:"The update command was called without any field-changing flags.",required:"Provide at least one field-changing flag such as --status, --priority, --title, --tags, --description, or --body. Use --message only to label a real mutation.",why:"pm update mutates existing item fields; no-op invocations are rejected to avoid ambiguous history.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --description "Clarified implementation scope" --message "Clarify task intent"','pm append pm-a1b2 --body "Detailed progress notes" --message "Append progress notes"'],nextSteps:["Choose the item field you intend to change, then pair that change with --message for history context.","Use pm comments, pm notes, pm learnings, or pm append when you only need to add narrative context."]}),e,n):null}function ml(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=Se(n?.recovery),a=el(o),i=a?`pm ${a} --help`:"pm <command> --help",r=n?.allowed??tl(t),s=Se({...o,allowed_values:o?.allowed_values??r}),l=nl(o,r),c=l?[l,i]:[i,"pm contracts --command <command> --flags-only --json"],d=r.length>0?[`Allowed values: ${r.join("|")}`,`Run "${i}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return ae(k({code:"invalid_argument_value",title:"Invalid argument value",happened:t,required:"Use values that match documented command constraints.",why:"Validation protects data consistency and deterministic behavior across commands.",examples:c,nextSteps:d,recovery:s}),e,n)}function In(e,t){let n=Tt(e);return(il(e,n,t)??rl(e,n,t)??sl(e,n,t)??ll(e,n,t)??cl(e,n,t)??dl(e,n,t)??ml(e,n,t))||ae(k({code:"command_failed",title:"Command failed",happened:n,required:"Adjust command input or tracker state and retry.",why:"pm enforces explicit, deterministic contracts for data and command semantics.",examples:["pm --help","pm <command> --help"]}),e,t)}function pl(e,t,n){return e==="create"&&t.startsWith("--type")?[`pm create --title "Example title" --description "Example description" --type ${n.split("|")[0]||"Task"} --status open --priority 1 --message "Create item" --create-mode progressive`]:e==="update"?['pm update pm-a1b2 --status in_progress --message "Start implementation"']:[`pm ${e??"<command>"} --help`]}function ul(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function fl(e){if(!(!Array.isArray(e)||e.length===0))return b(e)}function $n(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function L(e,t={}){let n=$n(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,a=typeof e?.attemptedCommand=="string"?e.attemptedCommand:fl(o),i=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return Se({attempted_command:a,normalized_args:o,provided_fields:n,suggested_retry:i,suggested_retry_args:e?.suggestedRetryArgs,...t})}function Tn(e,t){return!t||e.includes(t)?e:[...e,t]}var gl=new Set(["--add","--add-json","--remove"]),hl=new Set(["command","cmd","path"]);function yl(e){if(Array.isArray(e))for(let t of e){if(!t.startsWith("--"))continue;let n=t.indexOf("="),o=n>=0?t.slice(0,n):t;if(gl.has(o))return o}}function _l(e){if(!Array.isArray(e))return;let t=e.indexOf("test");if(t<0)return;let n=e[t+1];if(!(typeof n!="string"||n.startsWith("-")))for(let o=t+2;o<e.length;o+=1){let a=e[o];if(a!=="--add"&&a!=="--remove")continue;let i=e[o+1];if(typeof i!="string"||!hl.has(i))return;let r=[];for(let c=o+2;c<e.length;c+=1){let d=e[c];if(d.startsWith("--")&&d.length>2)break;r.push(d)}if(r.length<2)return;let s=`${i}=${r.join(" ")}`,l=[...e.slice(0,o+1),s,...e.slice(o+2+r.length)];return b(l)}}function wl(e,t,n,o){let a=e.match(/required option '([^']+)' not specified/);if(!a)return null;let i=ul(a[1]),r=i.startsWith("--type"),s=o?.suggestedRetryCommand,l=$n(o?.providedOptionFlags),c=[i],d=pl(t,i,n),m=s?Tn(d,s):d,p=r?[`Allowed type values: ${n}`,`Run "pm ${t??"create"} --help --type <value>" for type-aware policy details.`]:[`Run "pm ${t??"<command>"} --help" for required option guidance.`],u=s?Tn(p,`Replay with preserved arguments: ${s}`):p,f=l&&l.length>0?Tn(u,`Already provided options: ${l.join(", ")}`):u;return k({code:"missing_required_option",title:`Missing required option ${i}`,happened:`Commander rejected the command because ${i} was not provided.`,required:`Pass ${i} with a valid value before running the command.`,why:r?"--type selects item contract and policy routing, including required/disabled option rules.":"Required flags define mandatory command intent and prevent ambiguous execution.",examples:m,nextSteps:f,recovery:L(o,{missing:c})})}function vl(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let a=o[1];return k({code:"missing_required_argument",title:`Missing required argument ${a}`,happened:`Command invocation omitted positional argument ${a}.`,required:`Provide ${a} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:L(n,{missing:[a]})})}function bl(e,t,n){return k({code:"unsupported_update_option",title:`Unsupported option ${e} for update`,happened:`pm update does not accept ${e} for linked artifact mutations.`,required:"Use dedicated linked-artifact commands instead of pm update for files/docs changes.",why:"pm update manages scalar item metadata, while linked files/docs are managed by pm files and pm docs.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,scope=project,note=implementation surface"','pm docs pm-a1b2 --add "path=README.md,scope=project,note=user-facing contract"'],nextSteps:['Run "pm files --help" and "pm docs --help" for add/remove payload formats.'],recovery:L(t,{suggested_flags:n})})}var Cl={declared_elsewhere:"Use an option declared on this path, or move the declared option to one of its accepting command paths.",declared_on_path:"Use the option with the value and syntax declared by this command path.",declared_nowhere:"Use a declared option on this command path; this spelling exists nowhere in the command lexicon."};function kl(e){let t=ge(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function xl(e,t,n,o,a){let i=o.otherCommands.slice(0,3),r=o.candidateTotal-i.length,s=r>0?` and ${String(r)} more command path(s)`:"";return["Run command help to confirm the exact option contracts for this command path.",n.length?`Nearest supported options: ${n.join(", ")}`:void 0,i.length?`${e} is accepted by ${i.join(", ")}${s}. Inspect those command contracts only if you intended a different operation.`:void 0,o.optionScope==="declared_nowhere"?`${e} is not declared on any command path. Use a nearest supported option on ${t??"the attempted command"}, or inspect that command's help.`:void 0,a?`Replay with suggested correction: ${a}`:void 0].filter(l=>typeof l=="string")}function El(e,t,n){let o=yi(n??"",e.normalizedInvocationArgs??[],t);return o?{retryCommand:b(o),suggestedRetryArgs:o}:["--full","--depth","--toon",...n==="activity"?["--since"]:[]].includes(t.split("=",1)[0])?{}:void 0}function Sl(e,t,n){if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};let o=El(e,t,n);if(o)return o;if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};if(_i(t))return{};let a=e.normalizedInvocationArgs;if(a===void 0)return{};if(a.filter(s=>s===t||s.startsWith(`${t}=`)).length!==1)return{};let i=a.findIndex(s=>s===t||s.startsWith(`${t}=`));if(i<0||a.includes("--")||!a[i]?.includes("=")&&i!==a.length-1&&a[i+1]?.startsWith("-")!==!0)return{};let r=M(a.filter((s,l)=>l!==i));return{retryCommand:b(r),suggestedRetryArgs:r}}function Al(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let a=n??{},i=o[1],r=$n(a.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:l}=Sl(a,i,t);if(t==="update"&&(i==="--file"||i==="--doc"))return bl(i,n,r);let c=kl(a),d=xl(i,t,r,c,s);["--dry-run","--check","--check-only","--plan","--preview"].includes(i.split("=",1)[0])&&d.push("The requested preview is unavailable on this path. Inspect the item with a read-only command or use a command that declares this option; do not replay this mutation without preview intent.");let m=[s,t?`pm ${W(t)?.canonical??t} --help`:"pm --help --all"].filter(p=>typeof p=="string");return k({code:"unknown_option",title:`Unknown option ${i}`,happened:`Commander does not recognize option ${i} for this command path.`,required:Cl[c.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:i,value:i,examples:m,nextSteps:d,recovery:L(n,{suggested_flags:r.length>0?r:void 0,suggested_retry:s,suggested_retry_args:l,candidate_commands:c.otherCommands,candidate_commands_total:c.candidateTotal||void 0,candidate_commands_truncated:a.unknownOptionOtherCommandsTruncated,option_scope:c.optionScope})})}function Tl(e,t,n,o,a){let i=`"${e}" is provided by the ${t.packageName} package. Install it with: ${t.installCommand}`,r=o.filter(s=>!s.endsWith(`: ${t.installCommand}`));return k({code:"unknown_command",title:`Unknown command ${e}`,happened:`pm does not expose command path "${e}" in current runtime configuration. It is shipped by the optional ${t.packageName} package.`,required:`Install the ${t.packageName} package, or use a valid command name or subcommand path.`,why:"Command registry includes core commands plus active extension command handlers; package-provided commands appear only after the package is installed.",examples:Mi([t.installCommand,...n]),nextSteps:Mi([i,...r]),recovery:L(a)})}function Rl(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],a=ge(t?.unknownCommandExamples),i=ge(t?.unknownCommandNextSteps),r=qs(o),s=a??["pm --help"],l=i??["Verify spelling and active extensions, then rerun."],c=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),d=r?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return r&&(!d||!c.has(d))?Tl(o,r,s,l,t):k({code:"unknown_command",title:`Unknown command ${o}`,happened:`pm does not expose command path "${o}" in current runtime configuration.`,required:"Use a valid command name or subcommand path.",why:"Command registry includes core commands plus active extension command handlers.",examples:s,nextSteps:l,recovery:L(t)})}function Ol(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=ge(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let a=e?.suggestedRetryCommand;return k({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${n}`,value:n,happened:`The positional token sequence "${n}" is not a declared ${t} subcommand.`,required:`Use one of: ${o.join(", ")}.`,why:"Subcommands are single positional tokens; multi-word action names use hyphens.",examples:[...a?[a]:[],`pm ${W(t)?.canonical??t} --help`],nextSteps:a?[`Retry with the declared hyphenated action: ${a}`]:["Choose one value from recovery.allowed_values."],recovery:L(e,{allowed_values:o,suggested_retry:a})})}function Il(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,a=yl(o);if(!a)return null;let i=_l(o);return k({code:"linked_test_value_not_quoted",title:`Linked-test ${a} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${a} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${a} value as a single argument. Accepted forms: --add "command=npm test -- parser", --add command "npm test -- parser" (two-token form with the value quoted), or --add-json for complex commands.`,why:"The shell splits unquoted values before pm can see them, so pm cannot reassemble the intended command unambiguously.",examples:[...i?[i]:[],'pm test pm-a1b2 --add "command=npm test -- parser"','pm test pm-a1b2 --add command "npm test -- parser"',`pm test pm-a1b2 --add-json '{"command":"npm test -- parser"}'`],nextSteps:[...i?[`Replay with the value re-joined into one argument: ${i}`]:[],"Prefer --add-json for commands containing commas, equals signs, or quotes.",'Run "pm test --help" for linked-test entry contracts.'],recovery:L(n,i?{suggested_retry:i}:{})})}var $l=new Set(["comments","docs","files","learnings","notes","test"]);function Pl(e,t,n){if(!/too many arguments/i.test(e))return null;let o=Va(t,n?.normalizedInvocationArgs??[]);if(!o)return null;let a=o.retryArgs?b(o.retryArgs):void 0,i=b(o.templateArgs??["test",o.itemId,"--add",`command=<actual command>,${o.value}`]);return k({code:"linked_resource_positional_value",title:"Linked-resource values require an explicit --add option",happened:`The value after the item id is not a positional argument of ${t}.`,required:a?`Retry the explicit collection mutation: ${a}`:`Supply the actual command and its metadata together, for example ${i}.`,examples:[a??i],recovery:L(n,{suggested_retry:a,suggested_retry_args:o.retryArgs})})}function Dl(e,t,n){if(!/too many arguments/i.test(e)||!$l.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],a=o.findIndex(c=>c===t),i=o[a+1],r=o[a+2],s=n?.verifiedCollectionItemId?.trim();if(i?.toLowerCase()!=="add"||!r||r.startsWith("-")||!s||s.toLowerCase()!==r.toLowerCase())return null;let l=`pm ${t} ${s} --add <value>`;return k({code:"collection_transposed_subcommand",title:`Transposed ${t} add syntax`,happened:`The positional token "add" occupied the item-id role and "${s}" occupied the next positional role. pm ${t} does not use an add subcommand.`,required:`Place the item id immediately after ${t}, then use --add for the value.`,why:"Collection mutations use object-first grammar: pm <collection> <item-id> --add <value>.",examples:[l,`pm ${t} --help`],recovery:L(n,{parsed_positionals:[{role:"transposed_subcommand",value:i},{role:"item_id",value:s}],suggested_retry:l})})}var Ml=new Set(["--activity-limit","--assignee","--assignee-filter","--date","--depth","--fields","--format","--from","--limit","--parent","--path","--pm-path","--priority","--release","--section","--sprint","--stale-threshold","--tag","--to","--type"]),Ni=new Set(["context","ctx"]);function Nl(e,t,n){if(!/too many arguments/i.test(e)||!Ni.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],a=o.findIndex(c=>Ni.has(c)),i=a===-1?1:a+1,r=e.match(/got \d+:\s*(\S+)/i),s=r?r[1].replace(/\.$/,""):void 0;if(s===void 0){let c=!1;for(let d of o.slice(i)){if(c){c=!1;continue}let m=d.split("=")[0];if(Ml.has(m)){c=!d.includes("=");continue}if(!d.startsWith("-")){s=d;break}}}if(!s)return null;let l=`pm get ${s}`;return k({code:"context_takes_no_item_argument",title:"pm context takes no item argument",happened:`pm context renders a workspace-level snapshot and received the positional argument "${s}".`,required:`Use ${l} for one item's full details, or pm context --parent ${s} to scope the snapshot to that item's subtree.`,why:"Item-level detail (pm get) and workspace-level context (pm context) are separate projections.",examples:[l,`pm context --parent ${s}`],recovery:L(n,{suggested_retry:l})})}function Pn(e,t,n,o){let a=Tt(e);return(wl(a,t,n,o)??vl(a,t,o)??Al(a,t,o)??Rl(a,o)??Ol(o)??Dl(a,t,o)??Il(a,t,o)??Pl(a,t,o)??Nl(a,t,o))||k({code:"invalid_command_usage",title:"Invalid command usage",happened:a,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:L(o)})}function Hi(e,t){let n=In(e,t);return(t?.code==="tracker_root_missing"||t?.code==="tracker_not_initialized")&&n.title==="Tracker is not initialized"&&n.recovery?.suggested_retry_args?[`Error: ${n.title}`,`Run: ${b(n.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
|
|
7
|
-
|
|
1
|
+
import"./chunks/chunk-DEZPZOQ7.js";import{A as Sn,C as Mi,D as Ni,F as Li,G as An,a as xn,d as M,e as N,f as A,g as Y,h as k,i as mi,n as Be,o as pi,p as hi,t as yi,u as Oi,v as Ri,w as Ii,x as Pi,y as $i,z as Di}from"./chunks/chunk-43R7UTWV.js";import{Ua as Ti,f as si,k as li}from"./chunks/chunk-BS2KXT24.js";import"./chunks/chunk-HSBTITO4.js";import"./chunks/chunk-U7JXZMU5.js";import{F as ki,b as vi,d as Et,g as bi,h as Ci,i as X,j as xi,od as Ai,rc as Si}from"./chunks/chunk-WNF6FOL7.js";import"./chunks/chunk-YT5D5HNG.js";import{ha as Ei,j as ci}from"./chunks/chunk-TL3O5GZA.js";import"./chunks/chunk-VC7TA67O.js";import"./chunks/chunk-P3LNMWL2.js";import{$c as Ct,Ag as wi,F as pa,Hc as ze,Kc as oi,Nc as ai,Sc as Cn,Tc as ii,Te as di,Uc as ri,Ue as ae,We as ui,Xb as fn,Xe as fi,Yc as bt,Zb as Va,Ze as gi,_c as Ge,bc as Ka,cc as Ja,cg as xt,dc as gn,dg as kt,eg as kn,fc as Ya,fg as Ve,gc as me,gg as E,hc as hn,hg as _i,ic as yn,ig as En,jc as _n,kc as wn,lb as wt,lc as vt,ld as We,mb as Ba,mc as vn,mg as q,nc as Xa,oc as Za,pc as Qa,qc as bn,rc as ei,sc as Ee,vc as ti,wc as ni}from"./chunks/chunk-ZTJVOBDU.js";import"./chunks/chunk-SPPHDVZE.js";import"./chunks/chunk-MRUA2Z43.js";import"./chunks/chunk-6PSDQ7T7.js";import"./chunks/chunk-IB7UB5TE.js";import{$e as Ia,Ag as Na,Ba as en,Bd as sn,Bg as La,Cd as ht,Cg as Fa,Dd as Ta,Dg as ja,Di as _t,Ea as le,Ec as ya,Ed as Oa,Eg as Ua,G as Fe,Ga as la,Gc as _a,Gi as Ga,Ha as pt,Hh as za,Ih as oe,Ji as ke,Ka as tn,Kh as un,Ki as D,La as ca,Lh as v,Li as Wa,Ma as O,Mb as ua,Nb as Ce,Oa as da,Ob as on,Pa as K,Pb as ut,Qb as an,Tc as wa,Uc as qe,Vd as ln,Wc as He,Xc as va,_e as Ra,aa as sa,bc as fa,bh as qa,cc as ga,ed as ba,eg as Pa,fb as w,fd as Ca,fg as $a,fh as Ha,gd as xa,gg as Da,hb as ma,hd as ka,hf as yt,hg as Ma,ib as je,id as ne,jd as Ea,jg as cn,kd as rn,kg as dn,lb as te,ld as ce,lg as mn,md as Sa,nd as ft,ng as pn,qb as Ue,qd as xe,r as P,rd as de,rh as J,t as G,u as $,uc as ha,ud as Aa,vd as gt,w as B,wb as nn,x as Qt,y as W,z as ra}from"./chunks/chunk-WRXQAW7Q.js";import"./chunks/chunk-SBVX5CMV.js";import"./chunks/chunk-VS565KBX.js";import{A as g,B as mt,C as x,E as V}from"./chunks/chunk-WX25MU4N.js";import"./chunks/chunk-XAWE4EAK.js";import{AsyncLocalStorage as Ks}from"node:async_hooks";(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]="0e47421c-706d-5e31-a466-6152cdeba30f")}catch{}})();var Se=new Ks;function Fi(e){let t=Se.getStore();return t===void 0?e:t!==null}function Ke(e,t=`warning:${e}`){let n=Se.getStore();n?(!n.has(e)||t!==`warning:${e}`)&&n.set(e,t):v(t)}function Je(e){let t=Se.getStore();if(!t?.size)return e;let n=Reflect.get(e,"warnings"),o=[...t].filter(([r,s])=>s!==`warning:${r}`).map(([r,s])=>({code:r,message:s})),a=Reflect.get(e,"warning_details"),i={...e,warnings:[...Array.isArray(n)?n:[],...t.keys()],...o.length>0?{warning_details:[...Array.isArray(a)?a:[],...o]}:{}};return t.clear(),i}function Tn(e){if(!Se.getStore()?.size)return e;let{token_accounting:t,...n}=Je(JSON.parse(e));return JSON.stringify(t===void 0?n:J(n,o=>`${JSON.stringify(o,null,2)}
|
|
2
|
+
`),null,2)}async function ji(e,t){if(!e){await Se.run(null,t);return}let n=new Map;await Se.run(n,async()=>{await t(),n.size>0&&oe(`${JSON.stringify(Je({type:"warning"}))}
|
|
3
|
+
`)})}import{Command as Jo,CommanderError as gs}from"commander";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="50318c14-8c1c-50f3-95d0-fd9ea3f0bb69")}catch{}})();function H(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function pe(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return H(t)}function Z(e){let t=new Set,n=[];for(let o of e){let a=pe(o);a&&(t.has(a)||n.push(a),t.add(a))}return 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]="0b95b409-ef2c-59da-a628-16a2cb4f0ea6")}catch{}})();var On=new Set(["--fields","--output-include","--depth","--for","--token-budget"]),St=new Set(["--full","--brief","--compact"]);function Js(e,t){return!!(e.flag==="--pm-path"||e.value_name||e.list||e.value_type==="number"||e.value_type==="string"||t.has(e.flag))}function Ys(e){let t=ae(k([...e])),n=new Set([...ui,...fi,...gi].flatMap(r=>r.keys.map(s=>`--${s.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`))),o=new Map([...We,...t].flatMap(r=>[r.flag,...r.aliases??[]].map(s=>[s,r.flag]))),a=new Map([...We,...t].flatMap(r=>[r.flag,...r.aliases??[]].map(s=>[s,Js(r,n)])));for(let r of On)a.set(r,!0);for(let r of St)a.set(r,!1);let i=new Map;for(let r=0;r<e.length;r+=1){let s=e[r];if(s==="--")break;if(!s.startsWith("-"))continue;let l=s.split("=")[0];if(!a.has(l)&&!s.includes("="))return;i.set(r,o.get(l)??l),a.get(l)&&!s.includes("=")&&(r+=1)}return i}function Ui(e,t,n){let o=new Set;for(let[a,i]of t)n.has(i)&&(o.add(a),On.has(i)&&!e[a].includes("=")&&o.add(a+1));return e.filter((a,i)=>!o.has(i))}function Xs(e,t){let n=t.find(a=>St.has(a));if(n===void 0)return;let o=[...new Set(e.values())].filter(a=>St.has(a));return o.length===1?o[0]:n}function qi(e,t,n){if(!n||!["unknown_field_projection","projection_options_mutually_exclusive"].includes(t??""))return n;let o=n.suggested_retry_args,a={...n,suggested_retry:void 0,suggested_retry_args:void 0};if(!o)return a;let i=Ys(e);if(!i)return a;let r;if(t==="unknown_field_projection"){let s=o.indexOf("--fields");if(s<0||o[s+1]===void 0)return a;let l=[...i].find(([c,d])=>d==="--fields")?.[0]??-1;if(l<0)return a;r=Ui(e,i,new Set(["--fields"])),r.splice(l,0,"--fields",o[s+1])}else{let s=Xs(i,o);if(s===void 0||![...i.values()].includes(s))return a;let l=new Set([...On,...St].filter(c=>c!==s));r=Ui(e,i,l)}return{...n,suggested_retry:w(r),suggested_retry_args: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]="afa4a7a0-d9de-529d-92dd-3e9704ea00d2")}catch{}})();async function Hi(e,t){await ii(e,{ok:t.ok,error:t.error,result:de(),exit_code:t.exit_code,error_code:t.error_code,error_category:t.error_category,command_resolution:t.command_resolution,resolution_stage:t.resolution_stage})}async function zi(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await qa({pmRoot:e.pmRoot,result:de()})}catch(o){t=o}let n=await D(e.pmRoot);if(await Ha({pmRoot:e.pmRoot,author:yt(e.author,n.author_default),itemIds:e.itemIds,intent:e.intent}),t!==void 0)throw 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]="dacf3952-3ae1-57fa-840a-c8a43cf855a5")}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]="9490326e-507d-5b3e-9958-08c12afbc5ff")}catch{}})();var Gi=new WeakMap;function At(e,t){Gi.set(e,t)}function ue(e){return Gi.get(e)}function Wi(e){return e.length>0?[e[0]]:[]}function Zs(e){let t=["","Intent:",` ${e.why}`],n=Wi(e.examples);return n.length>0&&(t.push("","Example:"),t.push(` ${n[0]}`)),t.push("","Need deeper rationale and more examples?"),t.push(" Re-run with --explain."),t.join(`
|
|
4
|
+
`)}function Qs(e){let t=["","Why use this command:",` ${e.why}`,"","Examples:",...e.examples.map(n=>` ${n}`)];return e.tips&&e.tips.length>0&&(t.push("","Tips:"),t.push(...e.tips.map(n=>` - ${n}`))),t.join(`
|
|
5
|
+
`)}function Bi(e,t){return t==="detailed"?Qs(e):Zs(e)}function L(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var el={cal:"calendar",ctx:"context"};function tl(e,t){return e.commands.find(n=>n.name()===t)??null}function nl(e,t){let n=e;for(let o of t){let a=tl(n,o);if(!a)return null;n=a}return n}function Rn(e,t,n,o){let a=nl(e,t.split(" ").filter(i=>i.length>0));a&&a.addHelpText("after",Bi(n,o))}function In(e){return e.includes("--explain")?"detailed":"compact"}function ie(e){return e.includes("--all")||e.includes("--explain")}var fe={"item reopen":{why:"Reopens recurring work while archiving earlier closure evidence and declaring its current planning outcome.",examples:['pm item reopen pm-a1b2 "The failure recurred" --expected-result "The recurrence regression passes"'],tips:["Without --expected-result, follow recovery.suggested_retry_args to restore current planning before claiming the item."]},ops:{why:"Groups workspace diagnostics, quality checks, and maintenance under one discoverable command.",examples:["pm ops health --summary","pm ops validate --check-history-drift","pm ops --help"]},init:{why:"Bootstraps tracker storage and settings so all other commands can run safely.",examples:["pm init","pm init acme","pm init ./pm-sandbox --defaults","pm init --preset minimal","pm init --agent-guidance add","pm init --defaults --with-packages"],tips:["Run this once per repository before create/list/update commands.","A path-like positional (`./dir`, `/tmp/dir`) initializes that tracker path; a plain word remains an id prefix.","Rewriting id prefix, governance preset, or default author on an existing tracker requires --force.","Use --preset for non-interactive automation; omit it in a TTY to use the setup wizard.","Use --agent-guidance add to inject compact AGENTS/CLAUDE workflow guidance, or --agent-guidance status to inspect missing guidance without modifying files.","Use --with-packages when agents need bundled commands such as calendar and templates available immediately."]},config:{why:"Reads or updates project/global settings such as definition-of-done, item format, telemetry, and policy toggles.",examples:["pm config project get definition-of-done",'pm config project set definition-of-done --criterion "tests pass"',"pm config project set item-format --format toon","pm config project set sprint-release-format-policy --policy strict_error","pm config project set governance-preset --policy minimal","pm config project set governance-ownership-enforcement --policy none","pm config project set test-result-tracking --policy enabled","pm config global set telemetry-tracking --policy disabled"]},extension:{why:"Compatibility command for package-backed runtime extension lifecycle operations across project or global scope.",examples:["pm package install ./my-package --project","pm package install '*' --project","pm package doctor --project --detail summary","pm package manage --global","pm package activate sample-ext --project","pm package deactivate sample-ext --project","pm package uninstall sample-ext --global","pm package explore --project","pm package manage --global","pm package describe sample-ext --project","pm package doctor --detail deep"],tips:["Prefer pm install and pm package in new user-facing automation.","Use pm extension when maintaining existing extension-specific scripts or debugging the compatibility runtime directly.","Bundled aliases beads and todos resolve to package-shipped extension sources.","Use --gh/--github shorthand for GitHub sources and --ref to pin a branch, tag, or ref.","Install updates settings activation state automatically unless extension allowlist mode is unchanged.","Use --adopt for single-extension adoption and --adopt-all to bulk-register unmanaged installs as managed without reinstalling.","Use --manage for concise triage summaries and remediation-oriented diagnostics alongside full extension details.","Use --describe to map exactly what each loaded extension registers (commands, hooks, item types, providers, overrides) in one call.","Use --doctor for consolidated diagnostics with warning codes, remediation hints, and optional deep detail payloads."]},package:{why:"Installs, explores, manages, diagnoses, adopts, activates, deactivates, and refreshes package-backed pm runtime extensions.",examples:["pm package install npm:@scope/pm-package --project","pm package install ./my-package --project","pm package doctor --project --detail deep","pm package manage --project --runtime-probe","pm package describe --project","pm package activate sample-ext --project","pm package upgrade --packages-only --dry-run"],tips:["Prefer package vocabulary for user-facing workflows; extension vocabulary remains available for compatibility.","Use pm package describe [name] to map every surface a package registers without reading its manifest or running diagnostics.","Use pm upgrade to refresh the CLI/SDK and managed packages from their recorded sources.","Use --dry-run before upgrade when automation needs a deterministic plan."]},"package init":{why:"Generates an installable starter pm package with package metadata and a root extension entrypoint.",examples:["pm package init ./my-package","pm package init ./my-hook-package --capability hooks","pm package init ./my-search-package --capability search","pm package init ./my-sync-package --capability importers","pm package init ./my-domain-package --capability schema","pm package init ./my-output-package --capability renderers","pm package install ./my-sync-package --project","pm package doctor --project --detail summary"],tips:["Use --capability hooks for a starter after_command lifecycle reactor with runnable SDK testing coverage.","Use --capability search for a starter search provider/vector-store adapter with runnable SDK testing coverage.","Use --capability importers for paired import/export commands that move project context across systems.","Use --capability schema for a starter custom item type, field, and migration so pm models your project domain.","Use --capability renderers/parser/preflight/services for starter override surfaces (output renderer, parsed-option rewrite, pre-run gate decision, built-in service) \u2014 one runnable starter per SDK capability.","The generated package is local-install safe; add SDK runtime imports only after declaring dependencies and validating with package doctor.","Use package doctor after changes to verify activation, policy, and collision diagnostics."]},"package install":{why:"Installs pm packages from local paths, npm sources, GitHub sources, bundled aliases, or wildcard/all aliases.",examples:["pm package install ./my-package --project","pm package install npm:pm-changelog --project","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Prefer the top-level pm install alias in scripts when only installation is needed.","Run pm package manage or pm package doctor after installing external packages."]},"package doctor":{why:"Diagnoses package activation, policy, collision, and managed-state health for project or global package scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed package registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global package state: PM_GLOBAL_PATH=$(mktemp -d) pm package doctor --project --detail deep --trace.","Non-isolated project diagnostics include global registrations and emit remediation when global package state can affect the result."]},"package catalog":{why:"Lists bundled first-party package catalog metadata and compact field projections.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command","pm package list --project --fields alias,package_name,category"],tips:["Use --fields for low-token package discovery in agent loops.","External npm package discovery still belongs to npm search."]},"extension init":{why:"Generates an installable starter runtime extension with manifest and entrypoint files.",examples:["pm package init ./my-extension","pm package init ./my-hook-extension --capability hooks","pm package init ./my-search-extension --capability search","pm package init ./my-sync-extension --capability importers","pm package init ./my-domain-extension --capability schema","pm package init ./my-output-extension --capability renderers","pm package --install --project ./my-sync-extension","pm package --doctor --project --detail summary"],tips:["Use --capability hooks when the extension should react to command lifecycle events.","Use --capability search when the extension should register retrieval primitives.","Use --capability importers when the extension should register project-context import/export commands.","Use --capability schema when the extension should register custom item types, fields, and migrations.","Use --capability renderers/parser/preflight/services to override pm's output rendering, parsed options, pre-run gate, or a built-in service.","Use package init for new distributable package workflows; extension init is the compatibility-level runtime scaffold."]},"extension install":{why:"Installs a compatibility runtime extension from local, npm, GitHub, bundled alias, or wildcard sources.",examples:["pm package install ./my-extension --project","pm package --install --project ./my-extension","pm package doctor --project --detail summary"],tips:["Prefer pm install or pm package install for new package-first automation."]},"extension doctor":{why:"Diagnoses compatibility extension activation, policy, collision, and managed-state health for project or global extension scopes.",examples:["pm package doctor --project --detail summary","pm package doctor --project --detail deep --trace","pm package doctor --project --isolated --detail deep --trace"],tips:["Use --isolated (alias --ignore-global) for hermetic project smoke tests that must ignore globally installed extension registrations.","Set PM_GLOBAL_PATH for a whole subprocess suite when every pm invocation must avoid machine-local global extension state: PM_GLOBAL_PATH=$(mktemp -d) pm extension doctor --project --detail deep --trace.","Prefer pm package doctor in new package-first workflows."]},"extension catalog":{why:"Compatibility view of bundled package catalog metadata.",examples:["pm package catalog --project","pm package catalog --project --fields alias,installed,install_command"],tips:["Prefer pm package catalog in new user-facing workflows."]},install:{why:"Installs a pm package into project scope by default, using local, npm, GitHub, or bundled alias sources.",examples:["pm package install '*' --project","pm package install ./packages/pm-todos --project","pm package install npm:@scope/pm-package --global","pm package install --github org/repo/packages/my-pm-package --ref main"],tips:["Installed packages are recorded in managed state and can be inspected with pm package manage."]},upgrade:{why:"Updates the global pm CLI/SDK and refreshes managed pm packages from recorded install sources.",examples:["pm package upgrade --dry-run","pm package upgrade --packages-only --project","pm package upgrade todos --dry-run","pm package upgrade --cli-only --repair","pm package upgrade --tag next --dry-run"],tips:["Omit target to include the CLI/SDK plus all managed packages in the selected scope.","Pass a target to refresh one managed package by name, directory, package name, or source.","Use --packages-only in repository automation when the global CLI should not be changed."]},create:{why:"Creates a new planning item with deterministic metadata and history.",examples:['pm create --title "Harden lock flow" --description "Improve stale lock handling" --type Task --status open --priority 1 --message "Create lock hardening task" --create-mode progressive','pm create --title "Weekly planning sync" --description "Recurring coordination meeting" --type Meeting --schedule-preset lightweight','pm create --title "Asset: Hero model" --description "Track playable model asset" --type Asset --status open --priority 1 --message "Create asset item" --type-option category=Character --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this asset item exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/assets/hero.glb,note=tracked asset" --test "command=node scripts/run-tests.mjs test,timeout_seconds=240" --doc "path=README.md,note=asset docs"'],tips:["Use --schedule-preset lightweight for Reminder/Meeting/Event when you want minimal required create inputs.","Use --type <value> to load type-aware policy guidance in --help output.","Bulk creation is pm item mutate --from items.jsonl (JSON Lines, array, or envelope; --upsert-key <field> makes re-runs idempotent)."]},focus:{why:"Sets a session focused item so new pm create items default their --parent to it (project management = context management).",examples:["pm focus pm-epic1","pm focus","pm focus --clear"],tips:["Focus is session-local (stored in .agents/pm/runtime/session.json, gitignored) \u2014 it never affects teammates.",'An explicit --parent on pm create always overrides the focused item; use --parent "" to create with no parent.',"A stale focused item produces the same missing-parent validation as an explicit stale --parent."]},update:{why:"Mutates existing item fields while preserving history and lock safety.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --unset close-reason --message "Clear stale close reason after reopen"','pm update pm-a1b2 --unset assignee --deadline +2d --message "Replan ownership and deadline"','pm update pm-a1b2 --body "Backfilled body text for legacy item" --message "Normalize missing body"'],tips:['Use "pm close <ID> <TEXT>" to close items instead of --status closed.',"When reopening from closed to a non-terminal status, update clears stale close_reason unless explicitly set via --close-reason.",'Use "pm append <ID> --body <text>" for additive notes; use update --body to replace body content.']},"update-many":{why:"Bulk-updates matched item sets with dry-run previews and rollback checkpoints for safe large-scale metadata changes.",examples:["pm update-many --filter-status open --status in_progress --dry-run",'pm update-many --filter-tag wave:7 --replace-tests --test "command=node scripts/run-tests.mjs test -- tests/core/history.spec.ts,timeout_seconds=240"','pm update-many --filter-tag governance --reviewer maintainer-review --message "Normalize reviewer metadata"',"pm update-many --rollback ckpt-abc123"],tips:["Use --dry-run first to inspect proposed changes before apply mode.","Linked-array mutation flags mirror pm update semantics (for example --replace-tests, --clear-files, and repeatable --doc/--note seeds).","Checkpoints are enabled by default for apply mode and can be restored with --rollback."]},"close-many":{why:"Bulk-closes matched items with a shared reason routed through full pm close semantics (close validation, active-child orphan checks, blocked-edge cleanup) plus dry-run previews and rollback checkpoints \u2014 unlike update-many --status closed, which bypasses close validation.",examples:['pm close-many --filter-sprint S-12 --reason "Sprint S-12 acceptance criteria met" --dry-run','pm close-many --filter-tag wave:7 --reason "Superseded by redesign" --validate-close warn','pm close-many --ids pm-a,pm-b,pm-c --reason "Closed in batch" --resolution "Verified by integration suite"',"pm close-many --rollback close-many-20260604-abc123"],tips:["At least one filter (--filter-* or --ids) is required so close-many never matches every item.","Already-terminal matches are skipped by default; pass --force to re-close them.","Use --dry-run to preview matches plus per-item skip reasons and active-child orphan warnings before applying.","Checkpoints are enabled by default for apply mode; restore with --rollback <checkpoint-id>."]},templates:{why:"Saves, lists, and inspects reusable create option bundles for repeatable workflows.",examples:['pm templates save triage-default --title "Triage item" --description "..." --type Task --status open --priority 2 --message "Seed triage template"',"pm templates list","pm templates show triage-default"],tips:["Template names are positional arguments (`pm templates save <name>` and `pm templates show <name>`), not --name flags.","Combine templates with explicit create flags; explicit flags always override template defaults."]},deps:{why:"Inspects an item dependency graph as a tree or graph payload to understand blockers and hierarchy links.",examples:["pm deps pm-a1b2","pm deps pm-a1b2 --format graph","pm deps pm-a1b2 --max-depth 2 --collapse repeated --summary"],tips:["Use --summary for lightweight counts when full graph payloads are unnecessary."]},list:{why:"Lists active items with deterministic filtering and ordering.",examples:["pm list --limit 20","pm list --type Task --priority 0 --tag release --status in_progress","pm list --compact --sort deadline --order asc","pm list --fields id,title,parent,type --sort parent --order asc"]},"list-all":{why:"Lists all item states (including terminal states) when you need full visibility.",examples:["pm list --all --limit 50","pm list --all --type Issue --include-body"]},"list-open":{why:"Shows work that is ready to claim and start.",examples:["pm list --status open --priority 0 --limit 10"]},"list-in-progress":{why:"Tracks active execution and owner progress.",examples:["pm list --status in_progress --priority 0 --limit 20"]},"list-blocked":{why:"Surfaces blocked work that needs intervention.",examples:["pm list --blocked --limit 20"]},"list-closed":{why:"Reviews completed work and closure outcomes.",examples:["pm list --status closed --limit 20 --type Task"]},"list-canceled":{why:"Audits intentionally discontinued work.",examples:["pm list --status canceled --limit 20"]},"list-draft":{why:"Finds incompletely defined items that need refinement before execution.",examples:["pm list --status draft --limit 20"]},aggregate:{why:"Runs grouped aggregation queries for governance checks such as decomposition by parent/type or triage by status/priority.",examples:["pm aggregate --group-by parent,type --count","pm aggregate --group-by type,status --count","pm aggregate --group-by parent,type --count --status open --parent pm-feature01"],tips:["Current aggregate mode is grouped counts only, so pass --count explicitly."]},guide:{why:"Routes local progressive-disclosure documentation so agents can fetch only the context they need.",examples:["pm package install guide-shell --project","pm guide","pm guide quickstart","pm guide commands --depth standard","pm guide skills --depth deep --format markdown","pm guide release --json"],tips:["Use brief depth for minimal token footprint, standard for excerpted docs, and deep for full local document rendering.","Use --list to force topic index output even when topic parsing is ambiguous."]},calendar:{why:"Provides deadline/reminder/event scheduling views for planning and coordination.",examples:["pm calendar","pm calendar --view agenda --from +0d --to +7d --tag release","pm calendar --view week --date 2026-04-06 --full-period --include deadlines,events","pm calendar --view month --tag release --format json"],tips:["Day/week/month views are anchored period windows; default mode clips the start to now unless --past or --full-period is set.","--full-period applies only to day/week/month views; use --from/--to to bound agenda windows."]},context:{why:"Builds an agent-optimized snapshot of critical active work plus near-term agenda context with progressive depth levels.",examples:["pm context","pm ctx --depth standard --limit 10","pm ctx --depth deep --tag release","pm ctx --section hierarchy --section progress --section blockers","pm context --depth standard --activity-limit 20 --stale-threshold 14d","pm context --from +0d --to +7d --format markdown --depth deep"],tips:["High-level focus contains Epics/Features and low-level focus contains Tasks/Issues/Chores/Decisions/Event/Reminder/Milestone/Meeting/Plan.","When no open or in-progress work exists, blocked items are shown as fallback context.","--depth brief (default) shows focus+agenda; standard adds hierarchy/activity/progress/workload; deep adds blockers/files/staleness/tests.","--section overrides --depth and selects specific sections: hierarchy, activity, progress, blockers, files, workload, staleness, tests.","Configure defaults via pm config project set context --default-depth standard --activity-limit 15."]},next:{why:"Answers 'what should I work on now?' with the highest-priority ready item, rationale, and ranked ready and blocked queues.",examples:["pm next","pm next --json","pm next --limit 3 --ready-only","pm next --parent pm-mpbb","pm next --tag release --format markdown"],tips:["Ready = active status, no open blockers, and no open children (a concrete leaf); the recommendation resumes in-progress work before starting new work.","An item is blocked when its scalar blocked_by or a blocked_by dependency points at a non-terminal item; the blocked list names the blockers to clear.","Containers (Epics/Features with open children) are never recommended directly \u2014 the actionable leaf beneath them is.","Use --parent to scope to one epic's subtree, or --ready-only to drop the blocked companion list for the tightest output."]},search:{why:"Finds relevant items by keyword, semantic, or hybrid retrieval modes.",examples:['pm search "lock stale retry" --mode keyword --limit 10','pm search "extension migration blockers" --mode hybrid --type Task --priority 0','pm search "Cross-Epic Realism Dependency Council" --mode keyword --title-exact'],tips:["Use --title-exact to require exact normalized title parity, or --phrase-exact to require full-phrase matches in item text fields.","Use --include-linked when linked docs/files/tests should influence scoring."]},eval:{why:"Measures search relevance against a curated golden-query set so retrieval regressions are caught, not guessed.",examples:["pm eval --json","pm eval --mode hybrid --k 10","pm eval --fail-under 0.6 --json","pm eval --queries ./my-eval.json --mode semantic"],tips:["Curate ground truth in <pmRoot>/search/eval-queries.json as an array of {query, relevant_ids, mode?} objects.","Wire --fail-under into CI to fail the build when aggregate nDCG@k drops below your baseline."]},reindex:{why:"Rebuilds search artifacts after large changes to item corpus or provider/vector config.",examples:["pm reindex --mode keyword","pm reindex --mode hybrid --progress --json"],tips:["Use --progress for non-interactive visibility during local embedding runs.","JSON output includes semantic stale/unchanged/embed/upsert counts so agents can gate long reindex work without parsing stderr."]},get:{why:"Shows details for one item by ID, with optional lower-token projections for agent loops.",examples:["pm get pm-a1b2","pm get pm-a1b2 --depth brief --json","pm get pm-a1b2 --fields id,title,status,parent,type --json","pm get pm-a1b2 --at 7 --fields id,title,status,body --json"],tips:["Default depth is standard for body plus linked artifacts without append-only logs; use brief for metadata-only checks or --full for complete history-heavy metadata.","Use --fields for the smallest deterministic item metadata payload when an agent only needs specific fields.","Schedule metadata is normalized under schedule; request schedule.start_at or schedule.location for narrow calendar reads.","Children are type-agnostic and include bounded deterministic samples plus continuation metadata when a parent has direct children.","Use --at <version|timestamp> for a verified read-only historical projection; reconstructed/as_of fields distinguish it from current state.","JSON output shape is { item, linked, claim_state, schedule, children }; body is nested at item.body (parity with list --include-body)."]},history:{why:"Inspect recorded mutations.",examples:["pm history pm-a1b2 --order oldest_first","pm history pm-a1b2 --full --verify"]},"history-compact":{why:"Compacts long history streams into a synthetic checkpoint while preserving replay integrity. Pass an item id for one stream, or a bulk selector (--ids/--all-over/--closed/--all-streams) to sweep many.",examples:["pm history-compact pm-a1b2 --dry-run",'pm history-compact pm-a1b2 --before 25 --message "Compact early history"',"pm history-compact --all-over 500 --dry-run","pm history-compact --closed","pm history-compact --ids pm-a1b2,pm-c3d4 --dry-run"]},activity:{why:"Reviews recent tracker-wide activity across items.",examples:["pm activity --limit 50","pm activity --full --id pm-a1b2 --limit 50","pm activity --id pm-a1b2 --op update --from -7d --to now","pm activity --json --stream rows --limit 200"],tips:["Use --stream with --json for line-delimited automation output; --from is inclusive and --to is exclusive."]},restore:{why:"Restores an item to a prior timestamp/version with history replay safety.",examples:['pm restore pm-a1b2 2026-04-01T00:00:00.000Z --message "Rollback to known-good state"']},close:{why:"Transitions work to terminal closed state with explicit rationale.",examples:['pm close pm-a1b2 "Done" --resolution "Delivered" --expected "Required outcome" --actual "Verified outcome" --release-assignment --validate-close warn','pm close pm-a1b2 "Done" --validate-close','pm close pm-a1b2 "Done" --validate-close off','pm close pm-a1b2 "Done" --validate-close strict']},delete:{why:"Removes an item while preserving history evidence and lock/ownership checks.",examples:['pm delete pm-a1b2 --message "Remove duplicate item"']},append:{why:"Adds implementation notes to body without replacing existing content.",examples:['pm append pm-a1b2 --body "Implemented retry with bounded backoff." --message "Record implementation detail"']},comments:{why:"Adds or reviews lightweight status updates linked to an item.",examples:['pm comments pm-a1b2 "Verified fix on Linux and macOS"','pm comments pm-a1b2 --add "Verified fix on Linux and macOS"','printf "%s\\n" "## Verification" "- linux pass" "- mac pass" | pm comments pm-a1b2 --stdin',"pm comments pm-a1b2 --file docs/release-evidence.md",'pm comments pm-a1b2 --add "text: verification note with commas, key-like words, and parser details"','pm comments pm-a1b2 --add "Follow-up needed after review" --force',"pm comments pm-a1b2 --limit 10"],tips:["Use exactly one comment source at a time: positional [text], --add, --stdin, or --file.","Use --force when adding comments to items currently assigned to a different owner.","When --add payload resembles CSV-like key fragments (for example text=hello,scope:project), plain-text fallback is intentional; use explicit text=..., markdown text: ..., or stdin token - for structured intent."]},notes:{why:"Adds or reviews durable implementation notes linked to an item.",examples:['pm notes pm-a1b2 --add "Investigated parser edge case and documented fallback logic."','pm notes pm-a1b2 --add "text: parser rationale with commas, colons, and key-like wording"','pm notes pm-a1b2 --edit 1 --add "Corrected durable note"',"pm notes pm-a1b2 --delete 2","pm notes pm-a1b2 --limit 10"],tips:["CSV-like add payloads with extra key fragments are treated as plain text by design; use explicit text keys (text= or text:) when structured parsing is required."]},learnings:{why:"Adds or reviews post-implementation learnings for future work.",examples:['pm learnings pm-a1b2 --add "Avoid direct test-runner commands in linked tests; use sandbox runner."','pm learnings pm-a1b2 --add "text: lesson with commas, key-like words, and punctuation-safe context"',"pm learnings pm-a1b2 --edit 1 --file docs/corrected-learning.md","pm learnings pm-a1b2 --delete 2","pm learnings pm-a1b2 --limit 10"],tips:["If you intended structured parsing for a key-like payload, prefer explicit text=..., markdown text: ..., or stdin token -; ambiguous CSV-like forms intentionally remain plain text."]},files:{why:"Associates changed source files with tracker items for reproducibility.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,note=help orchestration"','pm files pm-a1b2 --add src/cli/main.ts --note "help orchestration"',"pm files discover pm-a1b2",'pm files discover pm-a1b2 --apply --note "discovered from item text"']},docs:{why:"Associates relevant documentation paths with tracker items.",examples:['pm docs pm-a1b2 --add "path=README.md,note=user-facing command guidance"','pm docs pm-a1b2 --add README.md --note "user-facing command guidance"']},test:{why:"Links test commands/paths and optionally executes them for one item.",examples:['pm test pm-a1b2 --add "command=node scripts/run-tests.mjs test -- tests/unit/output.spec.ts,timeout_seconds=2400"','pm test pm-a1b2 --add "command=pm list --all --type Task --limit 200,assert_stdout_contains=count:,assert_stdout_regex=count:\\s+\\d+"','pm test pm-a1b2 --add "command=pm list --all --type Task --limit 200,pm_context_mode=auto"',"pm test pm-a1b2 --run --timeout 2400 --env-set PORT=0 --env-clear PLAYWRIGHT_BASE_URL --shared-host-safe --pm-context tracker --fail-on-context-mismatch --fail-on-skipped","pm test pm-a1b2 --run --timeout 2400 --pm-context auto","pm test pm-a1b2 --run --background --timeout 2400 --progress"]},"test-all":{why:"Runs linked tests in bulk for release/readiness sweeps.",examples:["pm test-all --status in_progress --limit 5 --offset 10 --timeout 2400","pm test-all --status closed --timeout 3600 --progress --env-set PORT=0 --shared-host-safe --fail-on-skipped","pm test-all --status in_progress --pm-context tracker --fail-on-context-mismatch --require-assertions-for-pm","pm test-all --status in_progress --pm-context auto --fail-on-context-mismatch","pm test-all --status in_progress --background --timeout 3600"]},"test-runs":{why:"Manages background linked-test runs with lifecycle controls and log/status inspection.",examples:["pm test-runs list --status running --limit 20","pm test-runs status tr-abc123","pm test-runs logs tr-abc123 --stream stderr --tail 200","pm test-runs stop tr-abc123","pm test-runs resume tr-abc123"]},stats:{why:"Reports tracker-level totals and distribution by type/status.",examples:["pm stats","pm stats --json"]},telemetry:{why:"Inspects and manages local telemetry queue/runtime state for observability diagnostics.",examples:["pm telemetry status","pm telemetry stats --limit 10","pm telemetry flush","pm telemetry clear"]},health:{why:"Validates tracker/runtime health including extension triage, migration, and integrity diagnostics.",examples:["pm health","pm health --check-only --summary --json","pm health --brief --json","pm health --no-refresh","pm health --refresh-vectors"]},validate:{why:"Runs standalone metadata, resolution, lifecycle (including dependency-cycle diagnostics), linked-file, linked-command reference, and history drift checks with default remediation hints for resolution gaps.",examples:["pm validate","pm validate --check-resolution --json","pm validate --check-lifecycle --dependency-cycle-severity error","pm validate --check-lifecycle --parent-cycle-severity error","pm validate --check-files --scan-mode tracked-all","pm validate --check-files --scan-mode tracked-all-strict --include-pm-internals","pm validate --check-command-references","pm validate --check-resolution --fail-on-warn --json"],tips:["Resolution-gap warnings include default `pm update <id> ...` remediation hint templates in check details."]},gc:{why:"Deletes optional cache artifacts by default to keep local tracker state tidy; use --dry-run to preview targets without deleting files.",examples:["pm gc --dry-run","pm gc"]},claim:{why:"Claims an item to signal active ownership and reduce conflicts.",examples:["pm claim pm-a1b2 --start",'pm claim pm-a1b2 --force --message "Take over terminal item"','pm claim pm-a1b2 --author "release-service" --message "Explicit non-agent identity override"'],tips:["Claim is an atomic test-and-set: a non-terminal item held by another principal refuses with already_claimed_by. Use --if-available to skip that item without failing. Terminal items still require --force, even when --if-available is set. Use --force for coordinated takeovers; stale locks require --force only when governance.force_required_for_stale_lock is enabled.","Harness identity is automatic; use --author only to assert an intentional external principal."]},release:{why:"Releases an active claim when paused, handed off, or completed.",examples:["pm release pm-a1b2 --pause",'pm release pm-a1b2 --handoff review --message "Implemented; run linked verification"'],tips:["Register the project queue with pm schema add-status review --role active before using --handoff."]},"start-task":{why:"Lifecycle alias that claims an item and sets status to in_progress.",examples:['pm claim --start pm-a1b2 --message "Start implementation"']},"pause-task":{why:"Lifecycle alias that sets status to open and releases active assignment.",examples:['pm release --pause pm-a1b2 --message "Pause for dependency unblock"']},"close-task":{why:"Lifecycle alias that closes with reason text and clears assignment metadata.",examples:['pm close --release-assignment pm-a1b2 "All acceptance criteria met" --message "Close and handoff"']},meet:{why:"Shortcut to create a Meeting from friendly time flags (start/duration) without structured --event CSV.",examples:['pm meet "Sprint Planning" --start +1h --duration 1h','pm meet "1:1" --start 2026-07-01T15:00:00Z --end 2026-07-01T15:30:00Z --location "Room A"'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},event:{why:"Shortcut to create an Event from friendly time flags (start/duration) without structured --event CSV.",examples:['pm event "Release v2" --start 2026-07-01T10:00:00Z --duration 2h','pm event "Conference" --start 2026-08-01 --all-day'],tips:["Start defaults to now and duration to 1h; pass --end to set an explicit end instead of --duration.","--duration accepts relative tokens (h/d/w/m where m is months) plus sub-hour forms like 30min or PT30M."]},remind:{why:"Shortcut to create a Reminder from a single point in time without structured --reminder CSV.",examples:['pm remind "Review PR" --at +2d','pm remind "Follow up" --at 2026-07-01T09:00:00Z --text "Ping the team"'],tips:["The reminder time defaults to +1d and the reminder text defaults to the title."]},completion:{why:"Generates shell completion scripts for faster and more reliable command entry.",examples:["pm completion bash","pm completion zsh","pm completion fish","pm completion bash --eager-tags"],tips:["Default scripts resolve tag suggestions lazily at completion time; use --eager-tags to embed current tags directly."]},contracts:{why:"Exposes machine-readable CLI command and tool schema contracts for agent integrations.",examples:["pm contracts","pm contracts --command list --runtime-only","pm contracts --command update --flags-only","pm contracts --availability-only --runtime-only","pm contracts --action create","pm contracts --schema-only"],tips:["Use --command to narrow actions/schema to one CLI surface; combine with --flags-only or --availability-only for lighter payloads."]}};for(let{alias:e,canonical:t}of P){let n=fe[e];n&&(fe[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var Ae={why:"Provides deterministic project management workflows for humans and coding agents.",examples:["pm init","pm package install guide-shell --project","pm list --status open --limit 10",'pm create --title "..." --description "..." --type Task --status open --priority 1 --message "..." --create-mode progressive'],tips:["Use <command> --help for command-specific guidance and examples.","Install guide-shell before using pm guide for local docs and skills routing.","Use --json for machine parsing and integration flows.","Use --no-pager to force direct help output in CI and other non-interactive shells."]},Vi=B.filter(e=>e.lifecycle==="deprecated");for(let e of Vi){let t=fe[e.alias];fe[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[Ae,...Object.values(fe)])e.examples=e.examples.map(t=>{for(let n of Vi){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function ol(e){let t=L(e??"");return t?el[t]??t:""}function Pn(e){let t=ol(e);return t?fe[t]??Ae:Ae}function Ki(e,t){let n=Pn(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:Wi(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function al(){let e=B.filter(({lifecycle:n})=>n==="permanent"),t=B.filter(({lifecycle:n})=>n==="deprecated");return["","Command aliases:",...e.map(({alias:n,canonical_argv:o})=>` ${n} -> pm ${o.join(" ")}`),"","Deprecated aliases:",...t.map(n=>` ${n.alias} -> pm ${n.canonical_argv.join(" ")} (${ra(n)})`)].join(`
|
|
6
|
+
`)}function il(e,t,n,o){let a=new Set(bi);e.configureHelp({visibleCommands(r){let s=t.visibleCommands(r);return n?s.filter(l=>(ue(l)??X(l.name()))!=="internal"):r!==e?s:s.filter(l=>o.has(l))},visibleOptions(r){let s=t.visibleOptions(r);return r!==e||n?s:s.filter(l=>a.has(l.flags))}});let i=e.options.filter(r=>r.long==="--output-cursor");for(let r of e.commands.flatMap(s=>[s,...s.commands]))["list","search","context"].includes(r.name())&&r.configureHelp({visibleOptions:s=>[...t.visibleOptions(s),...i]})}function rl(e,t,n,o){let a=new Set(xi("core")),i=e.createHelp();i.prepareContext({error:!1,helpWidth:80,outputHasColors:!1});let r=()=>`${i.formatHelp(e,i)}${o}
|
|
7
|
+
`,s=t.visibleCommands(e);for(let l of s)ue(l)===void 0&&(l.name()==="help"||a.has(l.name()))&&n.add(l);for(let l of s)ue(l)==="core"&&(n.add(l),Ci(r()).within_budget||n.delete(l))}function Ji(e,t=process.argv.slice(2)){let n=e.createHelp(),o=ie(t),a=new Set;il(e,n,o,a);let i=In(t),r=Bi(Ae,i);e.addHelpText("after",r),o&&e.addHelpText("after",al()),rl(e,n,a,r);for(let[d,m]of Object.entries(fe))Rn(e,d,m,i);let s=L(A(t).commandPathTokens.join(" ")),l=Ge(s);if(l){Rn(e,l.parent,{why:l.description,examples:[l.example],tips:[`Action path: pm ${l.command}`,Ct(l.accepted_flags)]},i);return}let c=bt.filter(({parent:d})=>d===s);c.length>0&&Rn(e,s,{why:`Dispatches one declared positional action: ${c.map(({action:d})=>d).join("|")}.`,examples:c.map(({example:d})=>d),tips:[`Inspect one action directly with pm ${s} <action> --help --json.`]},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]="2efeb172-b440-5df6-ad48-4c54087835e0")}catch{}})();function $n(e,t=!1){e.commands.some(n=>n.name()==="ops")||e.command("ops").description("Discover workspace diagnostics and maintenance operations.");for(let{alias:n,canonical:o,canonical_argv:a}of P){if(t&&!P.some(c=>c.canonical.startsWith(`${o} `)))continue;let i=e.commands.findIndex(c=>c.name()===n);if(i<0)continue;let r=e.commands[i],s=e;for(let c of a.slice(0,-1))s!==e&&s.enablePositionalOptions(),s=s.commands.find(d=>d.name()===c)??s.command(c).description(`Discover ${c} operations.`);let l=a[a.length-1];if(s.commands.some(c=>c.name()===l))throw new Error(`Cannot install canonical command ${o}: destination already exists.`);e.commands.splice(i,1),r.name(l),At(r,X(o)),s.enablePositionalOptions(),s.addCommand(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]="df89d031-f8e3-5d3b-bfe8-a1d8c00f18fd")}catch{}})();function Rt(e){let{title:t,...n}=e;dn(n.why)&&delete n.why,cn(n.required)&&delete n.required;let o=mn(n.examples);o.length>0?n.examples=o:delete n.examples;let a=pn(n.recovery);return a===void 0?delete n.recovery:n.recovery=a,n}var sl=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function ll(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!sl.has(e.code)}function or(e){return`urn:pm-cli:error:${e}`}function C(e){return{...e,type:or(e.code)}}var Te={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},Yi={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},Xi={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},Tt={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},cl={guide:Te,shell:Te,completion:Te,"completion-statuses":Te,"completion-tags":Te,"completion-types":Te,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:Yi,cal:Yi,reindex:Xi,"search-advanced":Xi,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":Tt,"dedupe-audit":Tt,"dedupe-merge":Tt,normalize:Tt};function dl(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return cl[t]}function Ln(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function ml(e){if(!Array.isArray(e))return;let t=e.filter(n=>typeof n=="string").map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function pl(e){if(!Array.isArray(e))return;let t=e.map(n=>({source:typeof n?.source=="string"?n.source.trim():"",command:typeof n?.command=="string"?n.command.trim():"",reason:typeof n?.reason=="string"?n.reason.trim():""})).filter(n=>n.source.length>0&&n.command.length>0&&n.reason.length>0);return t.length>0?t:void 0}function Dn(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function ar(e){return Array.isArray(e)&&e.length>0&&e.every(t=>typeof t=="string")?[...e]:void 0}function Q(e,t,n){if(t==="normalized_args"||t==="suggested_retry_args"){let a=ar(n);a&&(e[t]=a);return}if(t==="parsed_positionals"){if(!Array.isArray(n))return;let a=n.map(i=>({role:typeof i?.role=="string"?i.role.trim():"",value:typeof i?.value=="string"?i.value.trim():""})).filter(i=>i.role.length>0&&i.value.length>0);a.length>0&&(e.parsed_positionals=a);return}let o=ml(n);o&&(e[t]=o)}function ul(e,t){if(!Va(t))return;let{requested_tokens:n,feasible_tokens:o,minimum_feasible_tokens:a,minimum_status:i,basis:r,reason:s}=t;e.token_budget={requested_tokens:n,feasible_tokens:o,minimum_feasible_tokens:a,minimum_status:i,basis:r,reason:s}}var ir=["retry_after_ms","waited_ms","owner_handoffs"];function fl(e,t){for(let n of ir)typeof t[n]=="number"&&e.push(` ${n}: ${t[n]}`)}function gl(e,t){for(let n of ir){let o=t[n];typeof o=="number"&&Number.isSafeInteger(o)&&o>=0&&(e[n]=o)}}function ye(e){if(!e||typeof e!="object")return;let t={};ul(t,e.token_budget),e.recovery_mode==="compact"&&(t.recovery_mode="compact"),Dn(t,"attempted_command",e.attempted_command),Q(t,"normalized_args",e.normalized_args),Q(t,"parsed_positionals",e.parsed_positionals),Q(t,"provided_fields",e.provided_fields),Q(t,"missing",e.missing),Q(t,"missing_required_fields",e.missing_required_fields),Q(t,"suggested_flags",e.suggested_flags),Q(t,"allowed_values",e.allowed_values),Q(t,"candidate_commands",e.candidate_commands),typeof e.candidate_commands_total=="number"&&Number.isSafeInteger(e.candidate_commands_total)&&e.candidate_commands_total>=0&&(t.candidate_commands_total=e.candidate_commands_total),e.candidate_commands_truncated===!0&&(t.candidate_commands_truncated=!0),(e.option_scope==="declared_on_path"||e.option_scope==="declared_elsewhere"||e.option_scope==="declared_nowhere")&&(t.option_scope=e.option_scope),Dn(t,"suggested_retry",e.suggested_retry),Q(t,"suggested_retry_args",e.suggested_retry_args),gl(t,e);let n=pl(e.fallback_candidates);return n&&(t.fallback_candidates=n),Dn(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function Mn(e,t,n){n&&e.push(` ${t}: ${n}`)}function ge(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function hl(e){let t=ye(e);if(!t)return[];let n=["Recovery bundle:"];if(t.token_budget){let o=t.token_budget;n.push(` requested_token_budget: ${o.requested_tokens}`,` feasible_token_budget: ${o.feasible_tokens??"unavailable"}`,` minimum_token_budget: ${o.minimum_feasible_tokens??"not established"}`)}if(Mn(n,"suggested_retry",t.suggested_retry),Mn(n,"attempted_command",t.attempted_command),ge(n,"normalized_args",t.attempted_command?void 0:t.normalized_args," "),t.parsed_positionals&&t.parsed_positionals.length>0){n.push(" parsed_positionals:");for(let o of t.parsed_positionals)n.push(` - ${o.role}: ${o.value}`)}if(ge(n,"provided_fields",t.provided_fields,", "),ge(n,"missing",t.missing,", "),ge(n,"missing_required_fields",t.missing_required_fields,", "),ge(n,"suggested_flags",t.suggested_flags,", "),ge(n,"allowed_values",t.allowed_values,", "),ge(n,"candidate_commands",t.candidate_commands,", "),typeof t.candidate_commands_total=="number"&&n.push(` candidate_commands_total: ${String(t.candidate_commands_total)}`),t.candidate_commands_truncated===!0&&n.push(" candidate_commands_truncated: true"),t.option_scope!==void 0&&n.push(` option_scope: ${t.option_scope}`),fl(n,t),Mn(n,"next_best_command",t.next_best_command),t.fallback_candidates&&t.fallback_candidates.length>0){n.push(" fallback_candidates:");for(let o of t.fallback_candidates)n.push(` - ${o.source}: ${o.command} (${o.reason})`)}return n}var Zi=120;function yl(e){if(e.claimedBy===void 0)return;let t=e.claimedAt?` since ${e.claimedAt}`:"",n=Array.from(e.claimedBy);return`Held by: ${n.length>Zi?`${n.slice(0,Zi).join("")}...`:e.claimedBy} (${e.claimSource??"unknown"}${t})`}function _l(e,t){let n=[`Error: ${e.title}`];(!t||!cn(e.required))&&n.push("","What is required:",` ${e.required}`),e.nextSteps&&e.nextSteps.length>0&&(n.push(""),n.push(...Ln("Next steps:",e.nextSteps))),e.happened!==e.title&&n.push("","What happened:",` ${e.happened}`);let o=yl(e);return o!==void 0&&n.push("",o),n}function wl(e,t){let n=[];e.why&&!(t&&dn(e.why))&&n.push("","Why:",` ${e.why}`);let o=t?mn(e.examples):e.examples??[];o.length>0&&n.push("",...Ln("Examples:",o));let a=e.verificationErrors??[];return a.length>0&&n.push("",...Ln("Verification errors:",a)),n}function Qi(e,t={}){let n=t.lean===!0,o=[..._l(e,n),...wl(e,n)],a=hl(n?pn(e.recovery):e.recovery);return a.length>0&&(o.push(""),o.push(...a)),o.join(`
|
|
8
|
+
`)}var vl="Some guidance was omitted to fit the diagnostic token ceiling; rerun with --json for the full recovery envelope.",bl=400,er=320;function Cl(e){let t=ye(e);if(!t)return;let n={};t.suggested_retry&&Buffer.byteLength(t.suggested_retry,"utf8")<=bl&&(n.suggested_retry=t.suggested_retry);for(let o of["missing","missing_required_fields","allowed_values"]){let a=t[o];a&&a.length>0&&(n[o]=a.slice(0,3))}return t.next_best_command&&(n.next_best_command=t.next_best_command),Object.keys(n).length>0?n:void 0}function xl(e,t={}){let n=Qi(e,t),o=$a("error").default_max_estimated_tokens_by_format.text,a=d=>Pa(Buffer.byteLength(d,"utf8"))<=o;if(a(n))return n;let i={...e,why:void 0},r={...i,examples:e.examples?.slice(0,1),nextSteps:e.nextSteps?.slice(0,1),verificationErrors:e.verificationErrors?.slice(0,3)},s={...r,recovery:Cl(e.recovery)},l=Array.from(e.happened),c={...s,examples:void 0,happened:l.length>er?`${l.slice(0,er).join("")}...`:e.happened};for(let d of[i,r,s,c]){let m=`${Qi(d,t)}
|
|
9
|
+
|
|
10
|
+
${vl}`;if(a(m))return m}return n}function kl(e,t){t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),t.lease!==void 0&&(e.lease=t.lease,e.current_owner=t.currentOwner??null,e.item_id=t.itemId),t.claimedBy!==void 0&&(e.claimed_by=t.claimedBy,e.claimed_at=t.claimedAt??null,e.claim_source=t.claimSource??"unknown",e.item_id=t.itemId)}function rr(e,t){return t.sideEffects!==void 0&&(e.side_effects=t.sideEffects),t.previewStorage!==void 0&&(e.preview_storage=t.previewStorage),t.transactionOperation!==void 0&&(e.transaction_operation=t.transactionOperation),kl(e,t),ll(t)&&(e.why=t.why),t.examples&&t.examples.length>0&&(e.examples=t.examples),t.nextSteps&&t.nextSteps.length>0&&(e.next_steps=t.nextSteps),t.verificationErrors&&t.verificationErrors.length>0&&(e.verification_errors=t.verificationErrors),t.flag!==void 0&&(e.flag=t.flag),t.value!==void 0&&(e.value=t.value),t.unmatchedSelectors!==void 0&&(e.unmatched_selectors=t.unmatchedSelectors),t.availableDependencies!==void 0&&(e.available_dependencies=t.availableDependencies),t.recovery&&(e.recovery=t.recovery),e}function El(e,t){if(e.flag)return e.flag;let n=o=>{let a=o.split("=",1)[0];return N([a]).length>0&&!["--help","--no-changed-fields","--version"].includes(a)&&t.some(i=>i===a||i.startsWith(`${a}=`))};return[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(o=>o[0]).find(o=>n(o))}function Sl(e,t,n){if(e.value!==void 0)return e.value;if(e.flag===void 0&&n){let o=t.find(i=>i===n||i.startsWith(`${n}=`));if(o?.startsWith(`${n}=`))return o.slice(n.length+1);let a=t.indexOf(n);return t[a+1]}}function Al(e,t){if(e.policyViolations?.length)return{surface:`policy:${e.policyViolations.map(s=>s.policy_id).join(",")}`,policies:e.policyViolations,policy_violation_count:e.policyViolationCount,missing_fields:[...new Set(e.policyViolations.flatMap(s=>s.missing_fields))],exit_code:t};let n=N(e.recovery?.normalized_args??[]),o=G(n),a=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,i=El(e,a),r=Sl(e,a,i);return{surface:i??e.recovery?.missing?.[0]??Sn(a)??"command",...r!==void 0?{rejected_value:r}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function Tl(e,t){return rr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:Al(e,t),...e.changed===!1?{changed:!1}:{}},e)}function Fn(e,t){let n=e.recovery,o=!!n?.suggested_retry||!!n?.suggested_retry_args?.length||!!n?.allowed_values?.length||!!n?.candidate_commands?.length||!!e.nextSteps?.length;return Da(Tl(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function jn(e){return rr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,...e.changed===!1?{changed:!1}:{}},e)}function It(e){return e.replace(/\(outputHelp\)/g,"").trim()}function Ol(e){let t=e.toLowerCase();return t.includes("cannot find module")||t.includes("cannot find package")||t.includes("err_module_not_found")||t.includes("module_not_found")}function he(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function tr(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function Rl(e){return Sn(e?.normalized_args)}function Il(e){let t=e.match(/\bmust be one of:?\s+([A-Za-z0-9_.|,\- ]+)/i);return t?t[1].split(/[|,]/).map(n=>n.trim()).filter(n=>/^[A-Za-z0-9_.-]+$/.test(n)):[]}function Pl(e,t){let n=e?.normalized_args,o=e?.provided_fields,a=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!a))for(let i of o){let r=n.findIndex(s=>s===i);if(r>=0&&r<n.length-1&&!n[r+1]?.startsWith("-")){let s=[...n];return s[r+1]=a,w(s)}}}function $l(e){let t=e.split(/\r?\n/)[0].trim();if(t.length!==0)return t.length<=120?t:`${t.slice(0,117)}...`}function Ot(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function Dl(e,t){if(e.flag!==void 0)return e.flag;if(e.field===void 0)return;let n=e.field.startsWith("--")?e.field:`--${e.field.replaceAll(/([A-Z])([A-Z][a-z])/gu,"$1-$2").replaceAll(/([a-z0-9])([A-Z])/gu,"$1-$2").replaceAll("_","-").toLowerCase()}`;return t?.normalized_args?.some(o=>o===n||o.startsWith(`${n}=`))?n:void 0}function re(e,t,n){if(!n)return e;let o=It(t),a=Ot(n.code,e.code),i=Ot(n.type,or(a)),r=he(n.examples)??e.examples,s=he(n.nextSteps)??e.nextSteps,l=he(n.verification_errors)??e.verificationErrors,c=e.code==="command_failed"&&n.code?$l(o):void 0,d=ye(n.recovery),m=d&&e.recovery?ye({...e.recovery,...d}):d??e.recovery;return{...e,code:a,changed:n.changed,sideEffects:n.side_effects,type:i,title:c??e.title,happened:o.length>0?o:e.happened,required:Ot(n.required,e.required),why:Ot(n.why,e.why),examples:r,nextSteps:s,verificationErrors:l,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:Dl(n,m)??e.flag,value:n.value??e.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,transactionOperation:n.transaction_operation,previewStorage:n.preview_storage,tombstone:n.tombstone,lease:n.lease,currentOwner:n.current_owner,claimedBy:n.claimed_by,claimedAt:n.claimed_at,claimSource:n.claim_source,availableDependencies:n.available_dependencies,recovery:m}}function Ml(e,t,n){let o=t.match(/^Tracker is not initialized at (.+)\. (?:Run pm init first|Tracker root does not exist\. Run pm init first)\.$/);if(!o)return null;let a=o[1],i=ca(process.cwd(),a);return re(C(i?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${a}, but found a tracker at ${i}.`,required:"Select the existing tracker root explicitly.",why:"Implicit discovery checks the default .agents/pm layout and ancestor root-layout trackers, while custom nested roots require an explicit path.",examples:[`pm --pm-path ${i} <command>`,`PM_PATH=${i} pm <command>`],nextSteps:[`Re-run with "--pm-path ${i}" or export PM_PATH=${i}.`]}:{code:"tracker_not_initialized",title:"Tracker is not initialized",happened:`pm data path does not contain initialized tracker metadata (${o[1]}).`,required:"Select an existing tracker with --pm-path/PM_PATH, or initialize the default .agents/pm storage.",why:"Most commands require settings in an explicitly selected root, an ancestor root-layout tracker, or the default .agents/pm directory.",examples:["pm init","pm init acme"],nextSteps:['Run "pm init", then rerun your original command.']}),e,n)}function Nl(e,t,n){let o=t.match(/^Item ([^ ]+) not found$/);if(!o)return null;let a=o[1],i=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(a),r=i?`The item ID "${a}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${a}" exists in the active tracker scope.`;return re(C({code:"item_not_found",title:"Item ID not found",flag:"id",value:a,happened:r,required:"Use an existing item ID from current tracker data.",why:"Mutation and read commands operate only on known IDs.",examples:["pm list --status open --limit 20",'pm search "<keyword>" --limit 10'],nextSteps:i?["Check that the variable holding the item ID is defined before passing it to pm.",'Use "pm list --status open --limit 20" to find valid IDs.']:["Confirm the active --path/PM_PATH scope, then retry with a valid id."]}),e,n)}function Ll(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:re(C({code:"ownership_conflict",title:"Ownership conflict",happened:t,required:"Run as the assigned owner, claim the item when appropriate, or use --force only for an approved override.",why:"Ownership checks prevent accidental concurrent mutations on claimed items and protect against conflicting writes.",examples:["pm claim pm-a1b2","pm update pm-a1b2 --status in_progress --force"],nextSteps:["Use --force for approved systematic metadata updates performed by leads or maintainers.","Use --force when correcting known stale metadata after coordinating ownership changes.",'For non-terminal reassignment, prefer "pm claim <ID>" before running other mutations.']}),e,n)}function Fl(e,t,n){if(!t.includes("is locked"))return null;let o=ar(n?.recovery?.normalized_args),a=o?w(o):void 0,i=re(C({code:"lock_conflict",title:"Lock conflict",happened:t,required:"Wait for lock release, then retry the same operation. Set PM_LOCK_WAIT_MS to a larger bounded millisecond budget for expected contention.",why:"Locking protects item files from concurrent write races.",examples:a?[a]:["pm gc --scope locks --dry-run"]}),e,n);return o&&(i.recovery={...i.recovery,suggested_retry:a,suggested_retry_args:[...o]}),i}function jl(e,t,n){let o=t.match(/^Missing required option /),a=t.match(/^Missing required options /);if(!o&&!a)return null;let i=!!a,r=i?null:t.replace(/^Missing required option\s+/,"").trim(),s=r??"",l=r?`Pass ${r} with a valid value before running the command.`:"Provide the required option for this command invocation.";return re(C({code:"missing_required_option",title:i?"Missing required options":`Missing required option ${s}`,happened:t,required:i?"Provide every required option for this command invocation.":l,why:"Required options define command intent and enforce deterministic write contracts.",examples:['pm create --title "Task title" --description "Task details" --type Task --create-mode progressive','pm create --title "Task title" --description "Task details" --type Task --status open --priority 1 --message "Create task" --dep "id=pm-epic01,kind=parent,created_at=now" --comment "created_at=now,text=Why this task exists." --note "created_at=now,text=Initial implementation note." --learning "created_at=now,text=Durable lesson placeholder." --file "path=src/example.ts,scope=project" --test "command=node scripts/run-tests.mjs test,scope=project,timeout_seconds=240" --doc "path=README.md,scope=project"'],nextSteps:['Run "pm <command> --help" to view required and recommended flags.',"For staged triage without placeholder linkage values, use --create-mode progressive."]}),e,n)}function Ul(e,t,n){return t.startsWith("No update flags provided")?re(C({code:"no_update_fields",title:"No update fields supplied",happened:"The update command was called without any field-changing flags.",required:"Provide at least one field-changing flag such as --status, --priority, --title, --tags, --description, or --body. Use --message only to label a real mutation.",why:"pm update mutates existing item fields; no-op invocations are rejected to avoid ambiguous history.",examples:['pm update pm-a1b2 --status in_progress --message "Start implementation"','pm update pm-a1b2 --description "Clarified implementation scope" --message "Clarify task intent"','pm append pm-a1b2 --body "Detailed progress notes" --message "Append progress notes"'],nextSteps:["Choose the item field you intend to change, then pair that change with --message for history context.","Use pm comments, pm notes, pm learnings, or pm append when you only need to add narrative context."]}),e,n):null}function ql(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=ye(n?.recovery),a=Rl(o),i=a?`pm ${a} --help`:"pm <command> --help",r=n?.allowed??Il(t),s=ye({...o,allowed_values:o?.allowed_values??r}),l=Pl(o,r),c=l?[l,i]:[i,"pm contracts --command <command> --flags-only --json"],d=r.length>0?[`Allowed values: ${r.join("|")}`,`Run "${i}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return re(C({code:"invalid_argument_value",title:"Invalid argument value",happened:t,required:"Use values that match documented command constraints.",why:"Validation protects data consistency and deterministic behavior across commands.",examples:c,nextSteps:d,recovery:s}),e,n)}function Un(e,t){let n=It(e);return(Ml(e,n,t)??Nl(e,n,t)??Ll(e,n,t)??Fl(e,n,t)??jl(e,n,t)??Ul(e,n,t)??ql(e,n,t))||re(C({code:"command_failed",title:"Command failed",happened:n,required:"Adjust command input or tracker state and retry.",why:"pm enforces explicit, deterministic contracts for data and command semantics.",examples:["pm --help","pm <command> --help"]}),e,t)}function Hl(e,t,n){return e==="create"&&t.startsWith("--type")?[`pm create --title "Example title" --description "Example description" --type ${n.split("|")[0]||"Task"} --status open --priority 1 --message "Create item" --create-mode progressive`]:e==="update"?['pm update pm-a1b2 --status in_progress --message "Start implementation"']:[`pm ${e??"<command>"} --help`]}function zl(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function Gl(e){if(!(!Array.isArray(e)||e.length===0))return w(e)}function qn(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function j(e,t={}){let n=qn(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,a=typeof e?.attemptedCommand=="string"?e.attemptedCommand:Gl(o),i=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return ye({attempted_command:a,normalized_args:o,provided_fields:n,suggested_retry:i,suggested_retry_args:e?.suggestedRetryArgs,...t})}function Nn(e,t){return!t||e.includes(t)?e:[...e,t]}var Wl=new Set(["--add","--add-json","--remove"]),Bl=new Set(["command","cmd","path"]);function Vl(e){if(Array.isArray(e))for(let t of e){if(!t.startsWith("--"))continue;let n=t.indexOf("="),o=n>=0?t.slice(0,n):t;if(Wl.has(o))return o}}function Kl(e){if(!Array.isArray(e))return;let t=e.indexOf("test");if(t<0)return;let n=e[t+1];if(!(typeof n!="string"||n.startsWith("-")))for(let o=t+2;o<e.length;o+=1){let a=e[o];if(a!=="--add"&&a!=="--remove")continue;let i=e[o+1];if(typeof i!="string"||!Bl.has(i))return;let r=[];for(let c=o+2;c<e.length;c+=1){let d=e[c];if(d.startsWith("--")&&d.length>2)break;r.push(d)}if(r.length<2)return;let s=`${i}=${r.join(" ")}`,l=[...e.slice(0,o+1),s,...e.slice(o+2+r.length)];return w(l)}}function Jl(e,t,n,o){let a=e.match(/required option '([^']+)' not specified/);if(!a)return null;let i=zl(a[1]),r=i.startsWith("--type"),s=o?.suggestedRetryCommand,l=qn(o?.providedOptionFlags),c=[i],d=Hl(t,i,n),m=s?Nn(d,s):d,p=r?[`Allowed type values: ${n}`,`Run "pm ${t??"create"} --help --type <value>" for type-aware policy details.`]:[`Run "pm ${t??"<command>"} --help" for required option guidance.`],u=s?Nn(p,`Replay with preserved arguments: ${s}`):p,f=l&&l.length>0?Nn(u,`Already provided options: ${l.join(", ")}`):u;return C({code:"missing_required_option",title:`Missing required option ${i}`,happened:`Commander rejected the command because ${i} was not provided.`,required:`Pass ${i} with a valid value before running the command.`,why:r?"--type selects item contract and policy routing, including required/disabled option rules.":"Required flags define mandatory command intent and prevent ambiguous execution.",examples:m,nextSteps:f,recovery:j(o,{missing:c})})}function Yl(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let a=o[1];return C({code:"missing_required_argument",title:`Missing required argument ${a}`,happened:`Command invocation omitted positional argument ${a}.`,required:`Provide ${a} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:j(n,{missing:[a]})})}function Xl(e,t,n){return C({code:"unsupported_update_option",title:`Unsupported option ${e} for update`,happened:`pm update does not accept ${e} for linked artifact mutations.`,required:"Use dedicated linked-artifact commands instead of pm update for files/docs changes.",why:"pm update manages scalar item metadata, while linked files/docs are managed by pm files and pm docs.",examples:['pm files pm-a1b2 --add "path=src/cli/main.ts,scope=project,note=implementation surface"','pm docs pm-a1b2 --add "path=README.md,scope=project,note=user-facing contract"'],nextSteps:['Run "pm files --help" and "pm docs --help" for add/remove payload formats.'],recovery:j(t,{suggested_flags:n})})}var Zl={declared_elsewhere:"Use an option declared on this path, or move the declared option to one of its accepting command paths.",declared_on_path:"Use the option with the value and syntax declared by this command path.",declared_nowhere:"Use a declared option on this command path; this spelling exists nowhere in the command lexicon."};function Ql(e){let t=he(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function ec(e,t,n,o,a){let i=o.otherCommands.slice(0,3),r=o.candidateTotal-i.length,s=r>0?` and ${String(r)} more command path(s)`:"";return["Run command help to confirm the exact option contracts for this command path.",n.length?`Nearest supported options: ${n.join(", ")}`:void 0,a?void 0:tc(e,t),i.length?`${e} is accepted by ${i.join(", ")}${s}. Inspect those command contracts only if you intended a different operation.`:void 0,lr(e)?`"${e}" contains spaces, so it is a value that starts with --, not an option. Pass it after a -- separator at the end of the command, or through the command's named value flag.`:o.optionScope==="declared_nowhere"?`${e} is not declared on any command path. Use a nearest supported option on ${t??"the attempted command"}, or inspect that command's help.`:void 0,a?`Replay with suggested correction: ${a}`:void 0].filter(l=>typeof l=="string")}var sr=["--brief","--compact","--standard","--deep","--full","--summary","--depth"];function tc(e,t){if(t===void 0||!sr.includes(e.split("=",1)[0]))return;let n=Ri(t);return n===void 0?void 0:`Completeness controls accepted by pm ${n.command}: ${Ii(n)}.`}function nc(e,t,n){let o=Pi(n??"",e.normalizedInvocationArgs??[],t);return o?{retryCommand:w(o),suggestedRetryArgs:o}:[...sr,"--toon",...n==="activity"?["--since"]:[]].includes(t.split("=",1)[0])?{}:void 0}function lr(e){return/\s/u.test(e)}function oc(e,t){let n=e?.indexOf(t)??-1;if(e===void 0||n<0||e.includes("--")||e.lastIndexOf(t)!==n)return{};if(e.slice(n+1).some(a=>!a.startsWith("-")))return{};let o=[...N(e.filter((a,i)=>i!==n)),"--",t];return{retryCommand:w(o),suggestedRetryArgs:o}}function ac(e,t,n){if(lr(t))return oc(e.normalizedInvocationArgs,t);if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};let o=nc(e,t,n);if(o)return o;if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};if($i(t))return{};let a=e.normalizedInvocationArgs;if(a===void 0)return{};if(a.filter(s=>s===t||s.startsWith(`${t}=`)).length!==1)return{};let i=a.findIndex(s=>s===t||s.startsWith(`${t}=`));if(i<0||a.includes("--")||!a[i]?.includes("=")&&i!==a.length-1&&a[i+1]?.startsWith("-")!==!0)return{};let r=N(a.filter((s,l)=>l!==i));return{retryCommand:w(r),suggestedRetryArgs:r}}function ic(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let a=n??{},i=o[1],r=qn(a.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:l}=ac(a,i,t);if(t==="update"&&(i==="--file"||i==="--doc"))return Xl(i,n,r);let c=Ql(a),d=ec(i,t,r,c,s);["--dry-run","--check","--check-only","--plan","--preview"].includes(i.split("=",1)[0])&&d.push("The requested preview is unavailable on this path. Inspect the item with a read-only command or use a command that declares this option; do not replay this mutation without preview intent.");let m=[s,t?`pm ${W(t)?.canonical??t} --help`:"pm --help --all"].filter(p=>typeof p=="string");return C({code:"unknown_option",title:`Unknown option ${i}`,happened:`Commander does not recognize option ${i} for this command path.`,required:Zl[c.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:i,value:i,examples:m,nextSteps:d,recovery:j(n,{suggested_flags:r.length>0?r:void 0,suggested_retry:s,suggested_retry_args:l,candidate_commands:c.otherCommands,candidate_commands_total:c.candidateTotal||void 0,candidate_commands_truncated:a.unknownOptionOtherCommandsTruncated,option_scope:c.optionScope})})}function rc(e,t,n,o,a){let i=`"${e}" is provided by the ${t.packageName} package. Install it with: ${t.installCommand}`,r=o.filter(s=>!s.endsWith(`: ${t.installCommand}`));return C({code:"unknown_command",title:`Unknown command ${e}`,happened:`pm does not expose command path "${e}" in current runtime configuration. It is shipped by the optional ${t.packageName} package.`,required:`Install the ${t.packageName} package, or use a valid command name or subcommand path.`,why:"Command registry includes core commands plus active extension command handlers; package-provided commands appear only after the package is installed.",examples:tr([t.installCommand,...n]),nextSteps:tr([i,...r]),recovery:j(a)})}function sc(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],a=he(t?.unknownCommandExamples),i=he(t?.unknownCommandNextSteps),r=dl(o),s=a??["pm --help"],l=i??["Verify spelling and active extensions, then rerun."],c=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),d=r?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return r&&(!d||!c.has(d))?rc(o,r,s,l,t):C({code:"unknown_command",title:`Unknown command ${o}`,happened:`pm does not expose command path "${o}" in current runtime configuration.`,required:"Use a valid command name or subcommand path.",why:"Command registry includes core commands plus active extension command handlers.",examples:s,nextSteps:l,recovery:j(t)})}function lc(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=he(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let a=e?.suggestedRetryCommand;return C({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${n}`,value:n,happened:`The positional token sequence "${n}" is not a declared ${t} subcommand.`,required:`Use one of: ${o.join(", ")}.`,why:"Subcommands are single positional tokens; multi-word action names use hyphens.",examples:[...a?[a]:[],`pm ${W(t)?.canonical??t} --help`],nextSteps:a?[`Retry with the declared hyphenated action: ${a}`]:["Choose one value from recovery.allowed_values."],recovery:j(e,{allowed_values:o,suggested_retry:a})})}function cc(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,a=Vl(o);if(!a)return null;let i=Kl(o);return C({code:"linked_test_value_not_quoted",title:`Linked-test ${a} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${a} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${a} value as a single argument. Accepted forms: --add "command=npm test -- parser", --add command "npm test -- parser" (two-token form with the value quoted), or --add-json for complex commands.`,why:"The shell splits unquoted values before pm can see them, so pm cannot reassemble the intended command unambiguously.",examples:[...i?[i]:[],'pm test pm-a1b2 --add "command=npm test -- parser"','pm test pm-a1b2 --add command "npm test -- parser"',`pm test pm-a1b2 --add-json '{"command":"npm test -- parser"}'`],nextSteps:[...i?[`Replay with the value re-joined into one argument: ${i}`]:[],"Prefer --add-json for commands containing commas, equals signs, or quotes.",'Run "pm test --help" for linked-test entry contracts.'],recovery:j(n,i?{suggested_retry:i}:{})})}var dc=new Set(["comments","docs","files","learnings","notes","test"]);function mc(e,t,n){if(!/too many arguments/i.test(e))return null;let o=pa(t,n?.normalizedInvocationArgs??[]);if(!o)return null;let a=o.retryArgs?w(o.retryArgs):void 0,i=w(o.templateArgs??["test",o.itemId,"--add",`command=<actual command>,${o.value}`]);return C({code:"linked_resource_positional_value",title:"Linked-resource values require an explicit --add option",happened:`The value after the item id is not a positional argument of ${t}.`,required:a?`Retry the explicit collection mutation: ${a}`:`Supply the actual command and its metadata together, for example ${i}.`,examples:[a??i],recovery:j(n,{suggested_retry:a,suggested_retry_args:o.retryArgs})})}function pc(e,t,n){if(!/too many arguments/i.test(e)||!dc.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],a=o.findIndex(c=>c===t),i=o[a+1],r=o[a+2],s=n?.verifiedCollectionItemId?.trim();if(i?.toLowerCase()!=="add"||!r||r.startsWith("-")||!s||s.toLowerCase()!==r.toLowerCase())return null;let l=`pm ${t} ${s} --add <value>`;return C({code:"collection_transposed_subcommand",title:`Transposed ${t} add syntax`,happened:`The positional token "add" occupied the item-id role and "${s}" occupied the next positional role. pm ${t} does not use an add subcommand.`,required:`Place the item id immediately after ${t}, then use --add for the value.`,why:"Collection mutations use object-first grammar: pm <collection> <item-id> --add <value>.",examples:[l,`pm ${t} --help`],recovery:j(n,{parsed_positionals:[{role:"transposed_subcommand",value:i},{role:"item_id",value:s}],suggested_retry:l})})}var uc=new Set(["--activity-limit","--assignee","--assignee-filter","--date","--depth","--fields","--format","--from","--limit","--parent","--path","--pm-path","--priority","--release","--section","--sprint","--stale-threshold","--tag","--to","--type"]),nr=new Set(["context","ctx"]);function fc(e,t,n){if(!/too many arguments/i.test(e)||!nr.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],a=o.findIndex(c=>nr.has(c)),i=a===-1?1:a+1,r=e.match(/got \d+:\s*(\S+)/i),s=r?r[1].replace(/\.$/,""):void 0;if(s===void 0){let c=!1;for(let d of o.slice(i)){if(c){c=!1;continue}let m=d.split("=")[0];if(uc.has(m)){c=!d.includes("=");continue}if(!d.startsWith("-")){s=d;break}}}if(!s)return null;let l=`pm get ${s}`;return C({code:"context_takes_no_item_argument",title:"pm context takes no item argument",happened:`pm context renders a workspace-level snapshot and received the positional argument "${s}".`,required:`Use ${l} for one item's full details, or pm context --parent ${s} to scope the snapshot to that item's subtree.`,why:"Item-level detail (pm get) and workspace-level context (pm context) are separate projections.",examples:[l,`pm context --parent ${s}`],recovery:j(n,{suggested_retry:l})})}function Hn(e,t,n,o){let a=It(e);return(Jl(a,t,n,o)??Yl(a,t,o)??ic(a,t,o)??sc(a,o)??lc(o)??pc(a,t,o)??cc(a,t,o)??mc(a,t,o)??fc(a,t,o))||C({code:"invalid_command_usage",title:"Invalid command usage",happened:a,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:j(o)})}function cr(e,t,n={}){let o=Un(e,t);return(t?.code==="tracker_root_missing"||t?.code==="tracker_not_initialized")&&o.title==="Tracker is not initialized"&&o.recovery?.suggested_retry_args?[`Error: ${o.title}`,`Run: ${w(o.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
|
|
11
|
+
`):dr(o,n)}function dr(e,t){let n=i=>Ma(xl(e,i),e.required).output,o=n(t);if(t.lean!==!0)return o;let a=n({});return Buffer.byteLength(a,"utf8")<Buffer.byteLength(o,"utf8")?a:o}function mr(e,t){return jn(Un(e,t))}function zn(e,t,n){return Fn(Un(e,n),t)}function pr(e,t,n,o,a={}){let i=Hn(e,t,n,o);return dr(i,a)}function Gn(e,t,n,o){return jn(Hn(e,t,n,o))}function Pt(e,t,n,o,a){return Fn(Hn(e,t,n,a),o)}function ur(e,t){let n=fr(e);return Fn(n,t)}function fr(e){let t=It(e);return Ol(t)?C({code:"module_import_failed",title:"Module import failed",happened:t,required:"Ensure the active checkout is built and any package or extension entry file exists before retrying.",why:"Node could not resolve an imported module. In pm this usually means an extension/package entrypoint, build artifact, or dependency is missing from the active runtime.",examples:["pnpm build","pm package manage --doctor --project","pm health --check-only --json"],nextSteps:["Rebuild the checkout or package that provides the missing module.","Run package doctor for installed extensions when the failure follows package installation or activation.","Rerun the original pm command after the runtime files are present."]}):C({code:"unknown_error",title:"Unhandled error",happened:t,required:"Inspect command input and runtime state, then retry.",why:"Unexpected runtime failures can occur from environment or extension-level issues.",examples:["pm --help","pm health --json"]})}function gr(e){return jn(fr(e))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4647d40c-70a2-5ffe-a91f-d43e9c522114")}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]="e860a827-39e1-5d6c-b76e-0d77365ba202")}catch{}})();var Ye=sa.join("|"),gc={calendar:"calendar",cal:"calendar",reindex:"search-advanced","search-advanced":"search-advanced",guide:"guide-shell",completion:"guide-shell",templates:"templates","test-runs":"linked-test-adapters",beads:"beads",todos:"todos"},hc={comments:{"--body":["--add"],"--text":["--add"],"--comment":["--add"]},notes:{"--body":["--add"],"--text":["--add"],"--note":["--add"]},learnings:{"--body":["--add"],"--text":["--add"],"--learning":["--add"]},update:{"--add-tag":["--add-tags"],"--remove-tag":["--remove-tags"],"--tag":["--tags"]},create:{"--add-tag":["--add-tags"],"--tag":["--tags"]}},hr=["add-field","add-status","add-type","apply-preset","list","list-fields","remap-status","remove-field","remove-status","remove-type","rename-field","rename-type","show","show-field","show-status"];function yc(e,t){let n=hc[e];if(!n)return[];let o=H(t);for(let[a,i]of Object.entries(n))if(H(a)===o)return i;return[]}function Wn(e,t,n){if(n.length===0)return e;if(t){let r=n.find(d=>d.declared_command_match===!0),{token_accounting:s,...l}=JSON.parse(e),c={...l,...r?{extension_command_failure:{code:"extension_command_activation_failed",extension:r.name,layer:r.layer,error:r.error,recovery_commands:r.recovery_commands??[]}}:{},failed_extensions:n};return JSON.stringify(s===void 0?c:J(c,d=>`${JSON.stringify(d,null,2)}
|
|
8
12
|
`),null,2)}let o=n.map(r=>`- ${r.layer}:${r.name}: ${r.error}`).join(`
|
|
9
13
|
`),a=n.find(r=>r.declared_command_match===!0);if(!a)return`${e}
|
|
10
14
|
Extension activation failures:
|
|
@@ -16,23 +20,23 @@ ${i}`:""}
|
|
|
16
20
|
|
|
17
21
|
${e}
|
|
18
22
|
Extension activation failures:
|
|
19
|
-
${o}`}function
|
|
20
|
-
`||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function
|
|
21
|
-
`):l,null,2)}(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]="e57ce782-5c73-5c74-a929-0971a990a355")}catch{}})();async function
|
|
23
|
+
${o}`}function Bn(e){return A(e).commandPathTokens[0]??k(e)??"<command>"}function br(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let a=o.shift();if(!a)continue;let i=L(E(a)),r=i.split(" ").some(s=>s.startsWith("_"));i.length>0&&!r&&n.add(i),o.push(...a.commands)}for(let a of t.keys()){let i=L(a),r=i.split(" ").some(s=>s.startsWith("_"));i.length>0&&!r&&n.add(i)}return[...n].sort((a,i)=>a.localeCompare(i))}function yr(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let a=n.split(" ");if(n===o)return 0;if(a.includes(o))return 1;if(a.some(s=>s.startsWith(o)))return 2;if(n.includes(o))return 3;let i=o.length>=5?2:1,r=Number.POSITIVE_INFINITY;for(let s of a){let l=an(s,o,i);l!==null&&(r=Math.min(r,l))}return Number.isFinite(r)?4+r:Number.POSITIVE_INFINITY}function _r(e){return H(e).slice(2).replace(/-/g,"")}function Vn(e){return w(e)}function _c(e){let t=W(e)?.canonical??Qt[e]??e,n=t.split(" ")[0]?.trim().toLowerCase();if(!n)return null;let o=gc[n];return o?{packageAlias:o,canonicalPath:t,installCommand:`pm package install ${o} --project`}:null}function wr(e){let t=Ei(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function wc(e,t){let n=wr(e);if(n.length===0)return[];let o=[];for(let a of t.values()){let i=new Set,r=a.source;if(r)for(let s of[r.name,r.package]){let l=wr(s??"");l.length>0&&i.add(l)}i.size!==0&&[...i].some(s=>s===n||s.includes(n)||n.includes(s))&&o.push(a.command)}return[...new Set(o)].sort((a,i)=>a.localeCompare(i))}function Xe(e,t){let n=new Set,o=t??ae(e);for(let a of o){a.flag.startsWith("--")&&n.add(H(a.flag));for(let i of a.aliases??[])i.startsWith("--")&&n.add(H(i))}return[...n].sort((a,i)=>a.localeCompare(i))}function vc(e,t){if(!e.startsWith("--"))return[];let n=_r(e);if(n.length===0)return[];let o=n.length>=8?2:1,a=[];for(let i of t){let r=_r(i);if(r===n)continue;if(n.length>=3&&r.startsWith(n)){a.push({flag:i,rank:0,distance:r.length-n.length});continue}let s=an(n,r,o);s===null||s<=0||a.push({flag:i,rank:1,distance:s})}return a.sort((i,r)=>i.rank!==r.rank?i.rank-r.rank:i.distance!==r.distance?i.distance-r.distance:i.flag.localeCompare(r.flag)).map(i=>i.flag).slice(0,3)}var $t,bc=new Set(["ctx","packages","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","start-task","pause-task","close-task","help"]);function Cc(){if($t)return $t;let e=new Map;for(let t of Fe)if(!bc.has(t))for(let n of Xe(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return $t=e,$t}function xc(e,t){if(!e.startsWith("--"))return[];let n=Cc().get(H(e));if(!n)return[];let o=t?.trim().toLowerCase(),a=new Set(Xe(o));return[...new Set(n.filter(i=>i!==o).map(i=>({command:i,sharedFlagCount:Xe(i).filter(r=>a.has(r)).length})).sort((i,r)=>i.sharedFlagCount!==r.sharedFlagCount?r.sharedFlagCount-i.sharedFlagCount:i.command.localeCompare(r.command)).map(({command:i})=>W(i)?.canonical??i))]}function kc(e,t,n){for(let o=0;o<e.length;o+=1){let a=e[o];if(!a.startsWith("--"))continue;let i=a.indexOf("="),r=i>=0?a.slice(0,i):a;if(H(r)!==H(t))continue;let s=[...e];return s[o]=i>=0?`${n}${a.slice(i)}`:n,s}}function Ec(e){let t=new Set(e.commandPaths),n=i=>Math.min(yr(i,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?yr(i,e.primaryToken):Number.POSITIVE_INFINITY),o=new Map,a=(i,r)=>{if(!Number.isFinite(r)||!t.has(i))return;let s=o.get(i);(s===void 0||r<s)&&o.set(i,r)};for(let i of e.commandPaths)a(i,n(i));for(let[i,r]of Object.entries(Qt))i!=="read"&&a(r,n(i));return[...o.entries()].sort(([i,r],[s,l])=>r!==l?r-l:i.localeCompare(s)).map(([i])=>i)}function Sc(e){let t=W(e.normalizedUnknown),n=Li(e.commandPaths,e.primaryToken),o=Ec(e),a=wc(e.primaryToken,e.extensionDescriptors).filter(i=>e.commandPaths.includes(i));return An([...t&&e.commandPaths.includes(t.canonical)?[t.canonical_argv.join(" ")]:[],...n,...o,...a],e.commandPaths,e.primaryToken).filter(i=>!e.normalizedUnknown.includes(" ")||i!==e.normalizedUnknown)}function Ac(e){return[...new Set(e.map(t=>t.split(" ")[0]).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function Tc(e,t){let n=e.map(o=>`pm ${o} --help`);return t?[...new Set([...n,"pm --help --all"])]:[...new Set(["pm --help --all",...n])]}function Oc(e,t,n){let o=Y([...t]),a=[];for(;o!==void 0;){if(a.push(t[o]),t[o]===e)return a.join(" ");if(!n.includes(a.join(" ")))return e;let i=Y(t.slice(o+1));o=i===void 0?void 0:o+1+i}return e}function vr(e,t){if(!e)return;let n=M([...t]);return[...ma(n),...e.split(" "),"--help"]}function Kn(e,t,n,o=[]){let a=e.match(/unknown command '([^']+)'/i);if(!a||typeof a[1]!="string")return;let i=br(t,n),r=Oc(a[1],o,i),s=L(r);if(s.length===0||i.length===0)return;let l=Oi(s,i);if(l){let I=vr("update",o),z=I.slice(0,-2);return{suggestedRetryCommand:w(I),suggestedRetryArgs:I,unknownCommandExamples:[w(I),...l.examples.map(U=>w([...z,...U]))],unknownCommandNextSteps:l.nextSteps}}let c=_c(s);if(c&&!i.includes(c.canonicalPath.split(" ")[0]))return{unknownCommandExamples:[c.installCommand,`pm ${c.canonicalPath} --help`,"pm --help --all"],unknownCommandNextSteps:[`"${s}" is provided by the "${c.packageAlias}" package. Install it with: ${c.installCommand}. Command after installation: pm ${c.canonicalPath}.`],suggestedRetryCommand:c.installCommand};let d=s.split(" ")[0],m=Sc({commandPaths:i,normalizedUnknown:s,primaryToken:d,extensionDescriptors:n}),p=Ac(i),u=Ni(s,i),f=vr(u,o),h=[...new Set([...u?[u]:[],...m.length>0?m:An(p,i)])].slice(0,3),b=Tc(h,m.length>0),S=m.length>0?`Did you mean: ${h.join(", ")}?`:null;return{...f?{suggestedRetryCommand:w(f),suggestedRetryArgs:f}:{},unknownCommandExamples:f?[w(f),...b.slice(1)]:b,unknownCommandNextSteps:[...S?[S]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',...S?["Use one of the suggested command paths above with --help to inspect valid flags and usage."]:[]]}}function Rc(e){return Array.from(new Set(e))}function Ic(e){let t="";for(let n of e){if(n===" "||n===" "||n===`
|
|
24
|
+
`||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function Pc(e){let t=e.length;for(;t>0;){let n=e[t-1];if(n!==","&&n!==":"&&n!==";")break;t-=1}return e.slice(0,t)}function $c(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:(typeof o.aliases=="function"?o.aliases():[]).some(a=>a.trim().toLowerCase()===n))}function Oe(e,t){if(t.length===0)return!0;let n=e;for(let[o,a]of t.entries()){let i=$c(n,a);if(!i){let r=n.registeredArguments;return r.length>0&&(n.commands.length===0||r[0]?.required===!0)&&(r.at(-1)?.variadic===!0||t.length-o<=r.length)}n=i}return!0}async function Dc(e,t,n,o){try{let a=O(process.cwd(),e.path);if(!await V(K(a)))return{allowedTypes:Ye};let i=await D(a),r=e.noExtensions?void 0:ce(),s=le(i,r),l;if(/too many arguments/i.test(t)&&["comments","docs","files","learnings","notes","test"].includes(o??"")){let c=n.findIndex(m=>m===o),d=n[c+2];if(n[c+1]?.toLowerCase()==="add"&&d!==void 0&&!d.startsWith("-"))try{l=(await wt(a,d,i.id_prefix,i.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):Ye,pmRoot:a,settings:i,typeToFolder:s.type_to_folder,verifiedCollectionItemId:l}}catch{return{allowedTypes:Ye}}}function Mc(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?Rc([...yc(t,n[1]),...vc(n[1],Xe(t))]).filter(r=>Di(n[1],r)):void 0,a=n?xc(n[1],t):[],i=n!==null&&Xe(t).includes(H(n[1]));return{match:n,suggestions:o,otherCommands:a,scope:i?"declared_on_path":a.length>0?"declared_elsewhere":"declared_nowhere"}}function Nc(e,t,n){if(!t||!n||n.length===0)return;let o=kc(e,t[1],n[0]);return o?Vn(o):void 0}function Lc(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?Pc(Ic(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let a=k(t);if(a)return Mi(t,a,[o])}function Fc(e,t){if(!/too many arguments/i.test(e))return;let n=Y(t),o=G(t.slice(n));if(o?.alias!=="schema")return;let a=n+o.canonical_argv.length-1,i=t[a+1]?.trim().toLowerCase(),r=t[a+2]?.trim().toLowerCase();if(!i||!r)return;let s=`${i}-${r}`;if(!hr.includes(s))return;let l=[...t.slice(0,a+1),s,...t.slice(a+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${i} ${r}`,unknownSubcommandAllowedValues:[...hr],suggestedRetryCommand:Vn(l)}}function jc(e,t,n,o){let a=Y(t),i=G(t.slice(a))?.alias??k(t);if(!/unknown option /i.test(e)||i===void 0)return i;let r=W(i)?.canonical??i;return Fe.some(s=>s===i)||br(n,o).includes(r)?i:void 0}async function Ze(e,t,n,o={},a=process.argv.slice(2)){let i=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",r=Be([...a]).argv,s=M(r),l=jc(i,r,t,n),c=Vn(r),d=Z(r),m=await Dc(s,i,r,l),p=m.allowedTypes,u=Kn(i,t,n,r),f=Mc(i,l),h=Fc(i,r),b=h?.suggestedRetryCommand??Nc(r,f.match,f.suggestions)??Lc(i,r);return{message:i,commandName:l,allowedTypes:p,attemptedCommand:c,normalizedInvocationArgs:[...r],providedOptionFlags:d,unknownOptionSuggestions:f.suggestions,unknownOptionOtherCommands:f.otherCommands.length>0?f.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:f.otherCommands.length>0?f.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:f.otherCommands.length>12||void 0,unknownOptionScope:f.scope,suggestedRetryCommand:b,verifiedCollectionItemId:m.verifiedCollectionItemId,...h,...u,...o}}async function Jn(e,t,n,o={},a=process.argv.slice(2)){let i=await Ze(e,t,n,o,a),{message:r,commandName:s,allowedTypes:l,...c}=i,d=M(i.normalizedInvocationArgs).lean,m=pr(r,s,l,c,{lean:d}),p=await Oa("help_format",{message:m,command:s,allowed_types:l});return p.handled&&typeof p.result=="string"?p.result:m}async function Yn(e,t,n,o=!1,a={},i=process.argv.slice(2)){let r=await Ze(e,t,n,a,i),s=Pt(r.message,r.commandName,r.allowedTypes,g.USAGE,r),l=o?Rt(s):s,c=M(r.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(c?J(l,d=>`${JSON.stringify(d,null,2)}
|
|
25
|
+
`):l,null,2)}(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]="e57ce782-5c73-5c74-a929-0971a990a355")}catch{}})();async function Cr(e,t,n,o){if(n)return null;let a=e.some(r=>r==="--for"||r.startsWith("--for=")),i=k(e)==="contracts"&&e.includes("--full");return a||i?await o(t):null}import{Option as Uc}from"commander";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="dd8f1dc7-7987-56d4-8521-f8383b1cc5ae")}catch{}})();function _(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function kr(e,t){let n=new Map;for(let o of e){let a=_(o.command);for(let i of t){if(i.layer!==o.layer||i.name!==o.name)continue;let r=_(i.command),s=r.split(" "),l=s.at(-1),c=s.slice(1).join(" "),d=c?`${s[0]}-${l} ${c}`:`${s[0]}-${l}`;if(l&&a===d){n.set(a,r);break}}}return n}function Xn(e,t,n,o){if(!t||!n)return;let a,i=0;for(let[s,l]of e.entries()){if(l!==t)continue;let c=e.slice(s);for(let[d,m]of o.entries()){let p=d.split(" ");p.length>i&&p.every((u,f)=>c[f]===u)&&(a=m,i=p.length)}}let r=a?.flags.find(s=>s.long===n||s.short===n);if(r)return qc(r).takesValue}function Mt(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function Dt(e){return typeof e=="boolean"?e:void 0}function qc(e){let t=Ce(e);return{takesValue:t.value_arity!=="none",valueName:t.value_name}}function Hc(e){let t=te(e.long);if(!t||!t.startsWith("--")||t.length<3)return null;let n=Zn(e);return n?`${n} ${Qn(e)}`:null}function Er(e){let t=[...new Set(e.map(Hc).filter(n=>n!==null))].sort((n,o)=>n.localeCompare(o));return t.length===0?null:`
|
|
22
26
|
Extension-provided flags:
|
|
23
27
|
${t.join(`
|
|
24
|
-
`)}`}function
|
|
28
|
+
`)}`}function Sr(e){let t=new Map;for(let a of e){let i=_(a.target_command);if(i.length===0)continue;let r=t.get(i)??[];r.push(...a.flags),t.set(i,r)}let n=[...t.entries()].sort(([a],[i])=>a.localeCompare(i)),o=new Map;for(let[a,i]of n){let r=Er(i);r&&o.set(a,r)}return o}function Ar(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function xr(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let o of e){if(typeof o!="string")continue;let a=o.trim();a.length===0||n.has(a)||(n.add(a),t.push(a))}return t}function zc(e){return Array.isArray(e)?e.map(t=>{let n=typeof t.name=="string"?t.name.trim():"";if(n.length===0)return null;let o={name:n,required:t.required===!0,variadic:t.variadic===!0};return typeof t.description=="string"&&t.description.trim().length>0&&(o.description=t.description.trim()),o}).filter(t=>t!==null):[]}function Gc(e){let t=new Map;for(let n of e){let o=_(n.command);if(o.length===0)continue;let a=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():void 0,i=typeof n.intent=="string"&&n.intent.trim().length>0?n.intent.trim():void 0;t.set(o,{command:o,action:Ar(o,n.action),description:a,intent:i,examples:xr(n.examples),failure_hints:xr(n.failure_hints),arguments:zc(n.arguments),flags:[],tier:n.tier??"standard",family:n.family??"extensions",source:{layer:n.layer,name:n.name,package:n.source_package,version:n.source_version}})}return t}function Wc(e){let t=new Map;for(let n of e){let o=_(n.target_command);if(o.length===0)continue;let a=t.get(o)??[];a.push(...n.flags),t.set(o,a)}return t}function Bc(e,t,n){let o=new Set;for(let a of e){let i=_(a);i.length>0&&o.add(i)}for(let a of t.keys())o.add(a);for(let a of n.keys())o.add(a);return o}function Vc(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function Tr(e,t,n,o=new Map){let a=Gc(t),i=Wc(n),r=Bc(e,a,i),s=new Map,l=[...r].sort((c,d)=>c.localeCompare(d));for(let c of l){let d=Vc(c,a,o)??a.get(c),m=i.get(c)??(d?i.get(d.command):void 0)??[];if(d){s.set(c,{...d,command:c,flags:m});continue}s.set(c,{command:c,action:Ar(c,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function Kc(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function Or(e,t){for(let n of t.arguments)e.argument(Kc(n),n.description??"Extension argument.")}function Jc(e){if(Dt(e.visible)===!1)return null;let t=te(e.long),n=Mt(e.short),o=n&&n.startsWith("-")&&!n.startsWith("--")?n:null,a=t&&t.startsWith("--")&&t.length>2?t:null,i=[o,a].filter(r=>r!==null);return i.length>0?i:null}function Zn(e){let t=Jc(e);if(!t)return null;let{value_name:n,value_arity:o}=Ce(e),a=n?o==="optional"?` [${n}]`:` <${n}>`:"";return`${t.join(", ")}${a}`}function Yc(e){return Zn(e)}function Qn(e){let t=Mt(e.description)??"Extension-provided option.",n=[];Dt(e.required)===!0&&n.push("required"),Dt(e.enabled)===!1&&n.push("disabled");let o=n.length>0?` [${n.join(", ")}]`:"",a=e.default!==void 0?` (default: ${JSON.stringify(e.default)})`:"";return`${t}${o}${a}`}function Rr(e,t){let n=te(t.long),o=Mt(t.short);return e.options.some(a=>{let i=a;return n!==null&&i.long===n||o!==null&&i.short===o})}function eo(e,t){for(let n of t){if(Rr(e,n))continue;let o=Yc(n);if(!o)continue;let a=Qn(n),i=new Uc(o,a);if(i.negate=!1,n.list!==!0){e.addOption(i);continue}e.addOption(i.argParser((r,s=[])=>[...Array.isArray(s)?s:[s],r]))}}function to(e,t){return Er(t.filter(n=>!Rr(e,n)))}function Xc(e){let t=Zn(e);if(!t)return null;let n=te(e.long),o=Mt(e.short),a=n&&n.startsWith("--")&&n.length>2?n:null,i=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,r=Ce(e),s=Dt(e.required)===!0;return{flags:t,long:a,short:i,description:Qn(e),takes_value:r.value_arity!=="none",value_required:r.value_arity==="required",value_name:r.value_name,variadic:!1,required:s,aliases:[],alias_for:null,...e.default!==void 0?{default_value:e.default}:{}}}function Ir(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let a=Xc(o);!a||n.has(a.flags)||(n.add(a.flags),t.push(a))}return t}function Pr(e,t){if(t.length===0)return e;let n=new Map(e.map(o=>[o.flags,o]));for(let o of t){let a=n.get(o.flags);n.set(o.flags,a?{...a,...o.default_value!==void 0?{default_value:o.default_value}:{}}:o)}return[...n.values()]}function $r(e){let t=[];if(e.intent&&t.push(`Intent: ${e.intent}`),e.action&&t.push(`Action contract: ${e.action}`),e.examples.length>0){t.push("Examples:");for(let n of e.examples)t.push(` - ${n}`)}if(e.failure_hints.length>0){t.push("Common failure hints:");for(let n of e.failure_hints)t.push(` - ${n}`)}return t.length===0?null:`
|
|
25
29
|
Extension command metadata:
|
|
26
30
|
${t.join(`
|
|
27
|
-
`)}`}function Bn(e){let t=e;if(typeof t.aliases=="function")return t.aliases().map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);if(typeof t.alias=="function"){let n=t.alias();if(typeof n=="string"&&n.trim().length>0)return[n.trim().toLowerCase()]}return Array.isArray(t._aliases)?t._aliases.map(n=>n.trim().toLowerCase()).filter(n=>n.length>0):[]}function Je(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:Bn(o).includes(n))??null}function Q(e,t){let n=e;for(let o of t){let a=Je(n,o);if(!a)return null;n=a}return n}var Kn=new WeakSet;function pr(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let a=t[o];o>0&&$.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let i=Je(n,a);if(i){n=i;continue}let r=n.command(a);Kn.add(r),o<t.length-1?(r.description("Extension-provided command group."),r.action(()=>{r.help()})):r.description("Extension-provided command path."),n=r}return n}function vc(e,t){let n=t.join(" "),o=$.find(r=>n===r.canonical||n.startsWith(`${r.canonical} `));if(o)return{core_path:o.canonical,extension_path:n};let a=e,i=[];for(let r of t){let s=Je(a,r);if(!s)return null;i.push(r);let l=s.commands.length>0||$.some(c=>c.canonical.startsWith(`${i.join(" ")} `));if(!Kn.has(s)&&(i.length===t.length||!l))return{core_path:i.join(" "),extension_path:t.join(" ")};a=s}return null}function bc(e,t,n,o,a=!1){let i=t.split(" ").filter(d=>d.length>0),r=vc(e,i),s=Q(e,i),l=$.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||Kn.has(s)));if(!r||r.core_path===t&&s!==null&&!n.has(t)&&!a||l&&!n.has(t))return null;let c=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${r.extension_path}:core_owner=pm-cli:${r.core_path}:extension_owner=${c}`}function ur(e,t,n,o,a){return[...new Set([...t,...n.keys()])].filter(i=>i.trim().length>0).sort((i,r)=>i.localeCompare(r)).filter(i=>{let r=bc(e,i,o,n.get(i),t.includes(i));return r?(a(r),!o.has(i)&&Q(e,i.split(" "))!==null):!0})}function fr(e,t,n){e.push(n),t(`[pm] warning: ${n}; core command preserved. Rename or namespace the extension command alias.`)}(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]="c6ed71d0-b878-575e-b990-356afdc45688")}catch{}})();var Cc=new Set(["__proto__","prototype","constructor"]),Jn=Symbol("looseOptionOccurrences");function Ye(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,n)=>n.toUpperCase())}function kc(e,t,n){let o=e[t];if(o===void 0){e[t]=n;return}if(Array.isArray(o)){o.push(n),e[t]=o;return}e[t]=[o,n]}function Yn(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let r=n.indexOf("=");if(r>=0)return{consumed:1,key:n.slice(1,r).trim(),value:n.slice(r+1),attached:!0};let s=n.slice(1).trim(),l=e[t+1];return typeof l=="string"&&!l.startsWith("-")?{consumed:2,key:s,value:l}:{consumed:1,key:s,value:!0}}let o=n.indexOf("=");if(o>=0)return{consumed:1,key:n.slice(2,o).trim(),value:n.slice(o+1),attached:!0};if(n.startsWith("--no-"))return{consumed:1,key:n.slice(5).trim(),value:!1};let a=n.slice(2).trim(),i=e[t+1];return typeof i=="string"&&!i.startsWith("-")?{consumed:2,key:a,value:i}:{consumed:1,key:a,value:!0}}function Pt(e){return Cc.has(e)}function gr(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return ia(t)}function Xe(e){let t=[],n=ee(e.long)??"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let a=Ye(n.slice(2));a.length>0&&!Pt(a)&&t.push(a)}if(o.startsWith("-")&&!o.startsWith("--")){let a=Ye(o.slice(1));a.length>0&&!Pt(a)&&t.push(a)}return[...new Set(t)]}function hr(e){let t=new Set;for(let n of e)for(let o of Xe(n))t.add(o);return t}function xc(e){let t=ee(e.long)??"";if(t.startsWith("--")){let n=Ye(t.slice(2));if(n.length>0&&!Pt(n))return n}return Xe(e)[0]??null}function yr(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function Xn(e,t,n){if(t.length===0)return;let o=new Set,a=new Map,i=[],r=[];for(let s of t){let l=Xe(s),c=yr(s);c!==null&&r.push(c);for(let d of l)o.add(d),s.enabled===!1&&a.set(d,c);s.required===!0&&s.enabled!==!1&&l.length>0&&i.push({keys:l,label:c})}for(let s of Object.keys(e)){if(!o.has(s)){let c=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new C(`Unknown option '--${s}' for extension command '${n}'.${c}`,g.USAGE)}let l=a.get(s);if(l)throw new C(`Option '${l}' is disabled for extension command '${n}'.`,g.USAGE)}for(let s of i)if(!s.keys.some(l=>Object.hasOwn(e,l)))throw new C(`Missing required option '${s.label}' for extension command '${n}'.`,g.USAGE)}function Ec(e){return typeof e=="string"||e==null?e:String(e)}function Sc(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function Ac(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var Tc={string:Ec,number:Sc,boolean:Ac};function Te(e,t){return Array.isArray(e)?e.map(n=>Te(n,t)):Tc[t](e)}function _r(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(a=>a!=null&&a!==""):tn(e);return t?o.map(a=>Te(a,t)):o}function Rc(e,t,n,o){return n?_r(e,t,o):t?Te(e,t):e}function Oc(e,t,n){let o=e[Jn];if(!o||o.length===0)return n;let a=new Set(t);return o.filter(i=>a.has(i.key)).map(i=>i.value)}function wr(e){return we(e).value_arity==="none"}function Zn(e,t,n,o,a){let i=yr(e),r=a?` for extension command '${a}'`:"",s=n===!0?"no value":JSON.stringify(n);throw new C(`Option '${i}'${r} expects ${o}; received ${s}.`,g.USAGE,{code:"extension_flag_value_invalid",required:`Pass ${i} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${i}.`,`Run pm ${a??"<command>"} --help to review the declared flag contract.`]})}function Qn(e,t){return e.value_validation==="strict"&&t!=="string"}function Ic(e,t){let n=e[Jn];if(!n)return[];let o=new Set(t);return n.filter(a=>o.has(a.key))}function $c(e,t,n,o){if(wr(e))for(let a of Ic(n,t)){if(a.attached!==!0)continue;let i=e.list===!0&&e.repeatable!==!0?tn(a.value):[a.value];for(let r of i){let s=dt(Te(r,"boolean"),"boolean");s!==null&&Zn(e,"boolean",r,s.expected,o)}}}function Pc(e,t,n,o,a){let i=Array.isArray(n)?n.flat(1/0):[n],r=o?i:i.flatMap(s=>typeof s=="string"?s.split(","):[s]);for(let s of r)if(typeof s=="string"&&s.trim().length===0){let l=dt(s,t);Zn(e,t,s,l.expected,a)}}function eo(e,t,n,o){if(!Qn(e,n))return t;let a=n==="boolean"&&wr(e),i=r=>{let s=dt(r,n);return s===null?r:a&&typeof r=="string"?!0:Zn(e,n,r,s.expected,o)};return Array.isArray(t)?t.map(i):i(t)}function Dc(e,t,n,o){for(let a of n)if(!(a===t||!Object.hasOwn(e,a))){if(Object.hasOwn(e,t)){if(o){let i=e[t],r=e[a];e[t]=[...Array.isArray(i)?i:[i],...Array.isArray(r)?r:[r]].filter(s=>s!=null)}delete e[a];continue}e[t]=e[a],delete e[a]}}function vr(e,t,n=e,o){if(t.length===0)return e;let a=Object.create(null);for(let[i,r]of Object.entries(e))a[i]=r;for(let i of t){let r=xc(i);r&&Mc(a,i,r,n,o)}return a}function Mc(e,t,n,o,a){let i=t.list===!0,r=Xe(t),s=gr(t);s&&!i&&Nc(e,t,n,r,s,a),Dc(e,n,r,i);let l=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=Rc(t.default,s,i,l));return}if(s==="boolean"&&Qn(t,s)&&$c(t,r,o,a),i){e[n]=Fc(t,r,o,e[n],s,l,a);return}s&&(e[n]=eo(t,Te(e[n],s),s,a))}function Nc(e,t,n,o,a,i){for(let r of o)r!==n&&Object.hasOwn(e,r)&&eo(t,Te(e[r],a),a,i)}function Fc(e,t,n,o,a,i,r){let s=Oc(n,t,o);a&&Qn(e,a)&&Pc(e,a,s,i,r);let l=_r(s,a,i);return a?eo(e,l,a,r):l}function br(e){let t=Object.create(null),n=[];Object.defineProperty(t,Jn,{value:n});let o=0;for(;o<e.length;){let a=Yn(e,o);if(!a){o+=1;continue}let i=Ye(a.key);if(i.length===0||Pt(i)){o+=a.consumed;continue}kc(t,i,a.value),n.push({...a,key:i}),o+=a.consumed}return t}function Cr(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=Yn(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function to(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let r of t){let s=gr(r);for(let l of Xe(r))n.add(l),s==="boolean"&&o.add(l)}if(n.size===0)return[...e];let a=[],i=0;for(;i<e.length;){if(e[i]==="--"){a.push(...e.slice(i+1));break}let r=Yn(e,i);if(r){let s=Ye(r.key);if(n.has(s)){let l=e[i],c=o.has(s)&&!l.includes("=")?1:r.consumed;i+=c;continue}}a.push(e[i]),i+=1}return a}import Re 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]="4a2291ff-7618-518c-8bff-e9aa0e2f8af2")}catch{}})();async function no(e,t={},n=[]){let o={readSettings:D,loadExtensions:Le,activateExtensions:je,resolveImplicitPmRoot:Qt,...t};try{let a=await o.readSettings(e),i=await o.loadExtensions({pmRoot:e,settings:a,cwd:process.cwd(),noExtensions:!1}),r=await o.activateExtensions(i);return[...i.failed,...r.failed].map(s=>{let l=(i.effective??[]).find(p=>p.layer===s.layer&&p.name===s.name),c=[...l?.contributions?.commands??[],...l?.contributions?.command_handlers??[],...l?.activation?.commands??[]].map(N).filter((p,u,f)=>p.length>0&&f.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),d=n.map(N),m=c.some(p=>d.some(u=>u===p||u.startsWith(`${p} `)));return{layer:s.layer,name:s.name,error:s.error,...c.length>0?{declared_commands:c}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(a){return[{layer:"runtime",name:"extension-loader",error:a instanceof Error?a.message:String(a)}]}}async function kr(e,t,n={},o=[]){if(e!=="unknown_command")return[];let a=await no(t,n,o),i={readSettings:D,loadExtensions:Le,activateExtensions:je,resolveImplicitPmRoot:Qt,...n};try{let r=i.resolveImplicitPmRoot(process.cwd());if(Re.resolve(r)===Re.resolve(t))return a;let[s,l]=await Promise.all([i.readSettings(t),i.readSettings(r)]),[c,d]=await Promise.all([i.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),i.loadExtensions({pmRoot:r,settings:l,cwd:process.cwd(),noExtensions:!1})]),m=new Set(c.loaded.flatMap(u=>u.activation?.commands??[])),p=[...new Set(d.loaded.flatMap(u=>u.activation?.commands??[]))].filter(u=>!m.has(u)).sort((u,f)=>u.localeCompare(f));if(p.length===0)return a;a.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${Re.resolve(t)} extension_discovery_root=${c.roots.project}; cwd_storage_root=${Re.resolve(r)} cwd_extension_discovery_root=${d.roots.project}; the selected --pm-path runtime is missing ${p.length} workspace command path(s): ${p.slice(0,8).join(", ")}${p.length>8?", ...":""}. --pm-path selects extension discovery as well as item storage; omit it, point --pm-path at ${Re.resolve(r)}, or install the extension into the selected tracker with "pm --pm-path ${Re.resolve(t)} install <package> --project".`})}catch{}return a}(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]="3f896a8d-2c03-5f9c-9909-4684a187870d")}catch{}})();var xr={core:0,standard:1,full:2,internal:3};function Er(e,t,n=!0){let o=t.get(P(e));if(o)return o;if(!n)return;let a=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(a.length===0)return;let i=a.reduce((s,l)=>xr[l.tier]<xr[s]?l.tier:s,"internal"),r=new Set(a.map(({family:s})=>s));return{tier:i,family:r.size===1?a[0].family:"extensions"}}function Sr(e,t){if(t.length===0)return e;let n=Q(e,t);if(n)return n;let o=t.join(" ");if(P(o)!==o||!Fe.some(a=>a===o)&&!La(o)&&!qe(o)&&!Ae(e,t))return null;for(let a=t.length-1;a>0;a-=1){let i=Q(e,t.slice(0,a));if(i)return i}return t.length===1?e:null}function Lc(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function Ar(e){let t=e;if(typeof t.attributeName=="function"){let n=t.attributeName();return typeof n=="string"&&n.trim().length>0?n.trim():null}return typeof t.attributeName=="string"&&t.attributeName.trim().length>0?t.attributeName.trim():null}function jc(e){let t=new Map;for(let n of e){let o=n,a=Ar(n);if(!a||typeof o.long!="string"||o.long.trim().length===0)continue;let i=t.get(a)??[];i.push(o.long.trim()),t.set(a,i)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(a=>a.trim()).filter(a=>a.length>0))].sort((a,i)=>a.localeCompare(i)));return t}function Uc(e){return b(e)}function qc(e){let t=e.options??[],n=jc(t);return t.map(o=>{let a=o,i=typeof a.flags=="string"?a.flags.trim():"",r=typeof a.description=="string"?a.description.trim():"",s=Ar(o),l=(s?n.get(s)??[]:[]).filter(h=>h!==a.long).map(h=>h.trim()).filter(h=>h.length>0),c=r.match(/^Alias for ([^ ]+)/i),d=c&&c[1]?c[1].trim():null,m=a.mandatory===!0||r.includes("[required]")||r.toLowerCase().includes("required;"),p=i.includes("<"),u=p||i.includes("["),f={flags:i,long:typeof a.long=="string"?a.long:null,short:typeof a.short=="string"?a.short:null,description:r,takes_value:u,value_required:p,value_name:Lc(i),variadic:a.variadic===!0,required:m,aliases:l,alias_for:d};return a.defaultValue!==void 0&&(f.default_value=a.defaultValue),f})}function Hc(e){let t=new Map,n=[];for(let o of e){if(o.alias_for&&o.long){n.push(o);continue}o.long&&t.set(o.long,o)}for(let o of n){let a=o.alias_for,i=t.get(a);if(!i)continue;let r=o.long,s=new Set([...i.aliases??[],r]);i.aliases=[...s].sort((l,c)=>l.localeCompare(c))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function zc(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(n=>{let o=typeof n.name=="function"?n.name():typeof n.name=="string"?n.name:"argument",a=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():null;return{name:o.trim(),required:n.required===!0||a?.toLowerCase().startsWith("required;")===!0,variadic:n.variadic===!0,description:a}})}function Gc(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(a=>a.name()!=="help"||e.parent===null).filter(a=>!n||(pe(a)??Y(a.name()))!=="internal").map(a=>{let i=N(E(a)),r=i,s=pe(a),l=Er(i,t,s!==void 0),c=V.find(({alias:d})=>d===i);return{name:a.name().trim(),aliases:Bn(a),description:a.description().trim(),tier:l?.tier??s??Y(r),family:l?.family??Ct(r),...c?{alias_for:c.canonical,alias_lifecycle:c.lifecycle,...c.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((a,i)=>a.name.localeCompare(i.name))}function Wc(e,t,n){if(!n)return t;let o=n.examples??[],a=n.failure_hints??[];return{intent:n.intent??n.description??t.intent,examples:e==="detailed"?o.length>0?[...o]:[...t.examples]:o.length>0?[o[0]]:[...t.examples],tips:e==="detailed"?a.length>0?[...a]:[...t.tips]:[],detail_mode:e}}function Vc(e,t,n,o,a){let i=e!==void 0&&kn(e)===xe,r=i?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:Ii(e,n),s=a?"positional_action":o?.intent||o?.description?"extension":i?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:Wc(n,r,o),intentSource:s}}function Bc(e,t){return e===void 0?null:t?.tier??Y(e)}function Kc(e,t){return e===void 0?null:t?.family??Ct(e)}function Jc(e,t,n){if(!(t!==e||!n))return V.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:Sr(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function Yc(e,t,n,o,a=new Map,i=!1){if(!e){let s=zc(t),l=Gc(t,a,i),c=new Set(l.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...l,...yt.filter(({parent:d,action:m})=>d===n&&!c.has(m)).map(({action:d,description:m})=>({name:d,aliases:[],description:m,tier:Y(n.split(" ")[0]),family:Ct(n.split(" ")[0])}))].sort((d,m)=>d.name.localeCompare(m.name)),usage:[n,s.reduce((d,m)=>m.required?d.replace(`[${m.name}${m.variadic?"...":""}]`,`<${m.name}${m.variadic?"...":""}>`):d,t.usage())].filter(d=>d.length>0).join(" ")}}let r=new Set(e.accepted_flags);return{arguments:e.slots.map(({name:s,required:l,variadic:c,value_kind:d,polymorphic:m})=>({name:s,required:l,variadic:c,description:m?`Polymorphic ${d} value; inspect the action contract before mutation.`:`${d.replaceAll("_"," ")} value.`})),options:o.filter(({long:s,aliases:l})=>s!==null&&r.has(s)||l.some(c=>r.has(c))),subcommands:[],usage:[e.command,...e.slots.map(({name:s,required:l,variadic:c})=>{let d=c?`${s}...`:s;return l?`<${d}>`:`[${d}]`})].join(" ")}}function Xc(e,t,n,o,a){let i=Cn(n),r=oe(n),s=N(E(t)),l=N(o.join(" ")),c=l.length>s.length?l:s,d=qe(c),m=d?.command??s,p=m.length>0?m:void 0,u=p,f=p?a.get(P(p)):void 0,h=p?Er(p,a,pe(t)!==void 0):void 0,{narrative:v,intentSource:S}=Vc(p,t.description().trim(),i,f,d!==void 0),I=Hc(dr(qc(t),cr(f))),z=Yc(d,t,m,I,a,r),U=Jc(e,t,r);return{format:"pm_help_v1",detail_mode:i,root_command:e.name(),requested_path:o,resolved_path:m.length>0?m:e.name(),visibility_tier:Bc(u,h),capability_family:Kc(u,h),description:d?.description??t.description(),usage:z.usage,intent:d?.description??v.intent,intent_source:S,examples:d?[d.example]:v.examples,tips:d?[_t(d.accepted_flags)]:v.tips,arguments:z.arguments,options:z.options,subcommands:z.subcommands,has_subcommands:z.subcommands.length>0,...U===void 0?{}:{command_aliases:U}}}async function Tr(e,t,n,o=t){let a=F(t);if(!a.json)return!1;let i=A(t);if(!i.requested)return!1;let r=Sr(e,i.commandPathTokens);if(!r){if(!a.quiet){let s=`unknown command '${i.commandPathTokens.join(" ")}'`,l=jn(s,e,n,t),c=Rt(s,"help",Ve,g.USAGE,{...l,attemptedCommand:Uc(t),normalizedInvocationArgs:[...t],providedOptionFlags:X(t)}),d=a.tokenAccounting?ce(c,m=>`${JSON.stringify(m,null,2)}
|
|
28
|
-
`):c;
|
|
29
|
-
`)}return process.exitCode=g.USAGE,!0}if(!a.quiet){let s=
|
|
30
|
-
`)}return process.exitCode=g.SUCCESS,!0}function
|
|
31
|
-
`)}function
|
|
32
|
-
`)}let i=n.indexOf("--"),r=i<0?n:n.slice(0,i),s=r.findIndex(h=>h==="--create-mode"||h.startsWith("--create-mode=")),l=s<0?void 0:r[s]?.startsWith("--create-mode=")?r[s]?.slice(14):r[s+1],c=e==="create"&&l?.toLowerCase()==="strict",d=
|
|
33
|
-
`)}function Rr(e,t,n){let o=x(n);if(o!=="create"&&o!=="update")return;let a=Je(e,o);a&&a.addHelpText("after",nd(o,t,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]="714821f9-dd8f-5958-a751-29e8dfc06471")}catch{}})();function od(e,t){return Ne(e.id)||`migration-${String(t+1).padStart(3,"0")}`}function ad(e){return Ne(e.status)?.toLowerCase()??"pending"}function id(e){return e.mandatory===!0}function rd(e,t){let n=e.layer.localeCompare(t.layer);if(n!==0)return n;let o=e.name.localeCompare(t.name);return o!==0?o:e.id.localeCompare(t.id)}function $r(e){let t=[];return e.forEach((n,o)=>{if(!id(n.definition))return;let a=ad(n.definition);a!=="applied"&&t.push({layer:n.layer,name:n.name,id:od(n.definition,o),status:a})}),t.sort(rd),t}function Or(e){return Array.isArray(e)&&e.length>0}var sd=new Set(["create","beads import","todos import"]),ld=new Set(["restore","update","close","delete","append","claim","release"]),cd=new Set(["comments","notes","learnings"]),dd=new Set(["files","docs","test"]),md=new Set(["activate","add","add-field","add-status","add-type","apply","compact","create","deactivate","delete","disable","edit","enable","import","infer","install","materialize","migrate","redact","remove","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type","repair","run","save","set","unset","update","upgrade"]);function oo(e,t){let n=t.force===!0;return sd.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:ld.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:cd.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:dd.has(e)?{isMutation:Or(t.add)||Or(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function pd(e,t,n){if(oo(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return ei(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(a=>md.has(a.trim().toLowerCase())):!1}function Ir(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function ud(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let a=[];if(Ne(t[1])||a.push("source"),Ne(n.to)||a.push("--to"),a.length!==0)throw new C(`Schema migration requires ${a.join(", ")}.`,g.USAGE,{code:"schema_migration_input_required",required:a.join(","),why:"Schema migrations require a source and target. A workspace-bound stable migration id is derived automatically when --migration-id is omitted.",recovery:{recovery_mode:"compact",missing_required_fields:a,suggested_flags:a.filter(i=>i.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function fd(e,t,n,o,a){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||Ir(n.status)!==Ir(a.schema.workflow.in_progress_status))return;let i=t[0];if(!i)return;let r=re(a,se()),s=await ht(o,i,a.id_prefix,a.item_format,r.type_to_folder);if(!s)return;let l=await Ma(s,{schema:a.schema}),c=typeof n.assignee=="string"?n.assignee.trim():void 0;(c===void 0?l.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(c.toLowerCase())&&c)||_(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function ao(e,t,n,o,a){if(!pd(e,t,n)||(ud(e,t,n),!await B(K(a))))return;let i=await Ce(a);o.json!==!0&&await fd(e,t,n,a,i.settings);let r=Qa({author:ft(o.author,i.settings.author_default),payload:{command:e,args:t,options:n},settings:i.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of r.warnings)_(`warning:${s}`)}function Pr(e,t,n){if(n.length===0)return;let o=oo(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let a=n.map(r=>`extension_migration_blocking:${r.layer}:${r.name}:${r.id}:${r.status}`),i=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new C(`Write command "${e}" blocked by unresolved mandatory extension migrations (${a.join(",")}). ${i}`,g.CONFLICT)}async function io(e,t,n,o){if(!oo(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await B(K(n)))return;let{settings:a,metadata:i,warnings:r}=await Ce(n);for(let s of r)_(`warning:${s}`);if(o.enforce_item_format_gate&&!i.has_explicit_item_format&&($a(a),await Pa(n,a,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let s=re(a,se());await ti(n,a.item_format,"item_format:pre_mutation_sync",s.type_to_folder,a.schema)}}(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]="c0826cb1-5181-51b3-9ad9-0cd7a3d2c4b3")}catch{}})();function ro(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=w(n);o.length!==0&&t.push(o)}return t}function Ie(e){let t=w(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(a=>a.length>0);for(let a of ro(e.commandArgs))o.push(...a.split(" ").filter(i=>i.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(a=>[a,P(a)]))]}function so(e,t){let n=w(e);if(n.length===0)return!1;let o=Ie(t);for(let a of o)if(a===n||a.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(a=>n.startsWith(`${a} `)):!1}function Mt(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...O(n.commands),...O(n.command_handlers),...O(n.command_overrides),...O(n.flag_commands),...O(n.parser_overrides),...Dr(n.preflight_ownership),...Dr(n.renderer_ownership)]:[]}function O(e){return e??[]}function Dr(e){return O(e).flatMap(t=>t.commands)}function Ze(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Mr=new Set(["hooks","parser","preflight","renderers"]),Nr=new Set(["commands","schema","services","importers"]),gd=new Set(["reindex","search","search-advanced"]),hd=new Set(["--template"]);function Oe(e,t){for(let n of t)if(e.has(n))return!0;return!1}function lo(e){let t=w(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return gd.has(n??t)}function co(e,t){for(let n of e.commandArgs??[]){if(!n.startsWith("--"))continue;let[o]=n.split("=",1);if(t.has(o))return!0}return!1}function Nt(e){return w(e.commandPath??"")==="create"&&co(e,hd)}function mo(e){return e.some(t=>{let n=w(t);return n==="templates"||n.startsWith("templates ")})}function Dt(e,t){return e.some(n=>so(n,t))||Nt(t)&&mo(e)}function po(e){return[O(e.hooks).length,(e.preflight_overrides??0)-O(e.preflight_ownership).length,O(e.item_types).length,O(e.item_fields).length,O(e.relationship_kinds).length,O(e.service_overrides).length,O(e.assurance_providers).length,O(e.renderer_overrides).length-O(e.renderer_ownership).length].some(t=>t>0)}function uo(e,t){let n=e.activation?.commands??[];if(n.length>0)return Dt(n,t);let o=Mt(e);if(Dt(o,t)||Ze(e).has("search")&&lo(t.commandPath))return!0;if(e.contributions)return po(e.contributions)}function Ft(e,t){let n=uo(e,t);if(n!==void 0)return n;let o=Ze(e);return!!(Oe(o,Mr)||Oe(o,Nr))}function Qe(e,t){return e.effective.length===0?!1:et(t)!=="all"?e.effective.some(n=>Ft(n,t)):e.effective.some(n=>{let o=Ze(n);return Mt(n).length>0||Oe(o,Mr)||Oe(o,Nr)||o.has("search")})}function et(e){if(w(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Ie(e).filter(o=>o.split(" ").every(a=>!a.startsWith("-"))).sort((o,a)=>a.length-o.length)[0]??w(e.commandPath??"");if(t.length===0)return"all";let n=Nt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function fo(e){return et(e)==="all"?void 0:t=>Ft(t,e)}function $e(e){let t=A(e);if(t.requested&&t.commandPathTokens.length>0){let[a,...i]=t.commandPathTokens;return{commandPath:a,commandArgs:i,allowCommandPrefixMatch:!0}}let n=M(e),o=n.findIndex(a=>a.trim().length>0&&!a.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function go(e){let t=e.args.map(String);if(w(E(e))==="create"){let n=e.optsWithGlobals();typeof n.template=="string"&&n.template.trim().length>0&&t.push("--template")}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]="298624a5-da1b-53ca-aefb-19fbc3fa0401")}catch{}})();var Lt=Symbol.for("pm.readOutputInvocationProvenance");function ie(e,t){let n=Reflect.get(e,Lt);n!==void 0&&Reflect.set(t,Lt,n)}function ho(e,t,n){let o=Ca(t,n);if(!o)return;let a=e;for(;a.parent;)a=a.parent;let i=a.rawArgs,r=new Set(X(i.slice(2))),s=ba.find(d=>d.command===o),l=Object.values(s?.dimensions??{}).flatMap(d=>d.legacy_aliases.flatMap(m=>r.has(m.flag)?[m.flag]:[])),c=Reflect.get(n,Lt);Reflect.set(n,Lt,{canonical_include_modes:c?.canonical_include_modes??[],explicit_legacy_aliases:l,cli_invocation_observed:!0}),ie(n,e)}function yd(e){let t=e.optsWithGlobals(),n=E(e);if(P(n)===n)return t;let o=e.opts();for(let a=e.parent;a?.parent;a=a.parent)for(let i of a.options){let r=i.attributeName(),s=a.getOptionValueSource(r)==="cli";if(s&&!e.options.some(l=>l.long===i.long))throw new C(`Unknown option '${i.long}' for ${n}`,g.USAGE,{code:"unknown_option",flag:i.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(r)!=="cli"){let l=a.getOptionValue(r);e.setOptionValueWithSource(r,l,"cli")}r in o?t[r]=o[r]:delete t[r]}return t}function yo(e,t,n,o){ho(e,t,o);let a=n.outputInclude;if(a===void 0)return;let{selectors:i,modes:r}=Ea(t,a,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),r.length===0)return;ie(o,e);let s=xa(t);for(let c of r){let d=s.get(c),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let l=i.length>0?i.join(","):void 0;l===void 0?delete n.outputInclude:n.outputInclude=l;for(let c=e;c;c=c.parent)c.setOptionValueWithSource("outputInclude",l,"cli");bt(e,n)}function Pe(e,t,n=[]){let o={...yd(e)};ie(e,o),delete o.json,delete o.quiet,delete o.path,delete o.pmPath,delete o.noExtensions,delete o.extensions,delete o.profile,delete o.pager,delete o.changedFields,delete o.fullChangedFields,delete o.idOnly,delete o.lean,delete o.tokenAccounting,delete o.outputInclude,delete o.outputLimit,delete o.outputBudget,delete o.outputFormat,delete o.outputSession;let a=br(t);for(let[i,r]of Object.entries(a))o[i]===void 0&&(o[i]=r);if(n.length>0){let i=hr(n),r=ne(E(e)).map(c=>({long:c.flag,short:c.short,aliases:c.aliases})),s={...a};for(let c of i)o[c]!==void 0&&(s[c]=o[c]);Xn(s,[...r,...n],E(e));let l=vr(o,n,a,E(e));return ie(o,l),l}return o}function jt(e,t){let n=w(t);return n.length===0?[]:e.flags.filter(o=>P(w(o.target_command))===P(n)).flatMap(o=>o.flags)}function tt(e,t,n){let o=jt(e,t),a=[t],i=[];for(let r of n){if(r.startsWith("-"))break;a.push(r);let s=jt(e,a.join(" "));s.length>0&&(i=s)}return i.length>0?i:o}function Ut(e){return e.arguments??[]}function Fr(e){let t=Ut(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function _o(e,t){if(!e)return!1;let n=w(t);return e.importers.some(o=>w(`${o.importer} import`)===n)||e.exporters.some(o=>w(`${o.exporter} export`)===n)}function wo(e,t){let n=Ut(e),o=n.filter(s=>s.required).length,a=n.some(s=>s.variadic)?Number.POSITIVE_INFINITY:n.length,i=e.failure_hints??[],r=i.length>0?` ${i.join(" ")}`:"";if(t.length<o)throw new C(`Missing required argument for extension command '${e.command}'. Usage: ${Fr(e)}${r}`,g.USAGE);if(t.length>a){let s=t.slice(a).join(" ");throw new C(`Too many arguments for extension command '${e.command}': ${s}. Usage: ${Fr(e)}${r}`,g.USAGE)}}function _d(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function wd(e,t,n){if(n.length>0){Xn(t,n,e.command);return}let o=Object.keys(t).filter(a=>t[a]!==void 0).sort();if(o.length!==0)throw new C(`Unknown option '${o.map(_d).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,g.USAGE)}function vo(e,t,n,o){e&&(wo(e,t),wd(e,n,o))}import{Command as Lr}from"commander";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0503f6e5-36d9-5afb-a17f-feef2241f984")}catch{}})();var vd=new Set(["--version","-V"]);function nt(e){let t=M(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function jr(e){if(M(e)[0]!=="item"||!e.includes("--dry-run"))return;let t=new Lr().configureOutput({writeErr:()=>{}}).exitOverride(),n=new Set;for(let a of He)for(let i of[a.flag,a.short,...a.aliases??[]]){if(i===void 0||n.has(i))continue;n.add(i);let r=a.value_name!==void 0||a.flag==="--pm-path";t.option(`${i}${r?" <value>":""}`)}try{t.parseOptions(e)}catch{}let o=t.opts();return{path:o.pmPath??o.path}}var bd=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),bo=new Set(["activity","aggregate","context","ctx","events","get","graph","history","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","search"]),Ur=new Set(["append","close","close-many","comments","delete","deps","discover","docs","files","history-repair","history-redact","history-compact","learnings","notes","plan","restore","update","update-many","create"]),Cd=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),kd=new Set(["claim","close-task","pause-task","release","start-task","test"]),he={setup:!0,listQuery:!0,mutation:!0,operation:!0},xd=new Set(["create","update","update-many","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","search","calendar","context","templates"]);function ot(e){return e.some(t=>vd.has(t))}function Ed(e,t){if(!$.some(o=>o.canonical_argv[0]===t))return;let n=new Lr().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of si(t,ne(t))){let a=o.takes_value?o.value_required?" <value>":" [value]":"";for(let i of[o.flag,o.short,...o.aliases??[]])i!==void 0&&n.option(`${i}${a}`)}try{let o=n.parseOptions(e.slice(1));if(o.unknown.length>0)return he;let a=G([t,...o.operands])?.alias;if($.some(i=>i.alias===a))return{...he,targetCommandName:a}}catch{return he}}function Co(e){if(ot(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||A(e).requested)return he;let t=x(e);if(!t)return he;let n=t.trim().toLowerCase(),o=M(e),a=G(o)?.alias;return $.some(i=>i.alias===a)?{...he,targetCommandName:a}:Ed(o,n==="ctx"?"context":n)||(bd.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:bo.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:Ur.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:Cd.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:he)}function ko(e){return e.length===0||A(e).requested||e.includes("--explain")&&x(e)===void 0}function xo(e,t){return nt(t)||ot(t)?!1:oe(t)||A(t).requested?!0:!!x(t)}function Eo(e){if(ot(e))return!1;let t=x(e);return t?xd.has(t):!1}function Sd(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,a=e.normalizedTokens.map(c=>{let d=c.indexOf("=");return d>=0?c.slice(0,d):c}).find(c=>c==="--literal"||c==="--regex"||c==="--replacement"),i=a?e.argv.map(c=>{let d=c.indexOf("=");return(d>=0?c.slice(0,d):c)===o?d>=0?`${a}${c.slice(d)}`:a:c}):e.argv,r=Ue(i),s=a&&n>=0?`${o}=[redacted]`:t,l=a&&e.normalizedDisplay.includes("=")?`${a}=[redacted]`:e.normalizedDisplay;return{argv:r,normalizedDisplay:l,sourceDisplay:s}}function So(e){let t=e.commandName;if(!t)return;let n=e.trace.find(c=>c.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(c=>c.length>0),a=o.length>0?o.join(" "):"the canonical flag",i=Ur.has(t)||kd.has(t),r=i?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=i?"mutating option":"option",l=Sd({argv:e.argv,normalizedDisplay:a,normalizedTokens:o,rawFrom:n.from});throw new C(`Refusing to auto-correct ${s} ${l.sourceDisplay} to ${l.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,g.USAGE,{code:r,examples:[b(l.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:l.argv,suggested_retry:b(l.argv)}})}(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]="6d83c356-db56-5116-9fe7-e0c27973b36f")}catch{}})();var Ad=new Set(["success","nonexistent_command","invalid_option","missing_required_option","missing_required_argument","invalid_usage","validation_failed","health_findings","validation_findings","conflict","runtime_failed","unknown_failed"]),Td=new Set(["parse","preflight","execute","unknown"]),Rd=new Set(["usage","validation","conflict","runtime","unknown"]);function ye(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let a=o.trim();if(a.length>0)return a}}}function Ao(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function qt(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="number"&&Number.isFinite(o))return Math.max(0,Math.trunc(o))}}function To(e){if(!e)return;let t=e.trim().toLowerCase();if(Ad.has(t))return t}function Ro(e){if(!e)return;let t=e.trim().toLowerCase();if(Td.has(t))return t}function Oo(e){if(!e)return;let t=e.trim().toLowerCase();if(Rd.has(t))return t}function Io(e){let t=ye(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let i=n.find(r=>typeof r=="string"&&r.trim().length>0);if(typeof i=="string")return i.trim()}if(Ao(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let o=qt(e,"failed");if(typeof o=="number"&&o>0)return`failed_runs:${o}`;let a=e?.run_results;if(Array.isArray(a)){let i=a.filter(r=>Xt(r)?.status==="failed").length;if(i>0)return`failed_runs:${i}`}}function $o(e,t){if(!e)return t===g.USAGE?"invalid_command_usage":t===g.NOT_FOUND?"item_not_found":t===g.CONFLICT?"lock_conflict":t===g.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function Po(){let e=Xt(le()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=qt(e,"exit_code","exitCode"),o=t??n??g.SUCCESS,a=mi(o),i=ye(e,"error_code","errorCode")??$o(a,o),r=Oo(ye(e,"error_category","errorCategory"))??(a?void 0:lt(i)),s=a?void 0:Io(e)??`command_exit_${o}`,l=To(ye(e,"command_resolution","commandResolution"))??wt({ok:a,errorCode:i,errorCategory:r}),c=Ro(ye(e,"resolution_stage","resolutionStage"))??"execute";return{ok:a,error:s,exit_code:o,error_code:i,error_category:r,command_resolution:l,resolution_stage:c}}(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]="3e4a18e9-6c97-5b44-95bc-678c3e7bdbcc")}catch{}})();var Do="PM_CLI_PACKAGE_ROOT",Kr=Symbol("pm.deprecatedAliasInvocation"),Gt=new Map;for(let e of V){let t=e.alias.split(" ")[0],n=Gt.get(t)??[];n.push(e),Gt.set(t,n)}for(let e of Gt.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function Od(){return Zo(import.meta.url,["../.."])}(typeof process.env[Do]!="string"||process.env[Do]?.trim().length===0)&&(process.env[Do]=Od());var De=null,j=null,Wt=null;function Id(e){De=e}function $d(e){R=e}var at=null,_e=null,R=new Map,qo=250,Pd=new Set([g.USAGE,g.NOT_FOUND,g.CONFLICT]),Dd=new Set(["1","true","yes","on"]),Md=Ge(()=>import("./chunks/register-setup-QPWSVHFZ.js")),Nd=Ge(()=>import("./chunks/register-list-query-BH4F6M7Z.js")),Fd=Ge(()=>import("./chunks/register-mutation-5V2NANIS.js")),Ld=Ge(()=>import("./chunks/register-operations-XSFRMUFX.js"));function zt(e){return b(e)}function Jr(e){let t=e.match(/--[a-zA-Z0-9][a-zA-Z0-9_-]*/g);if(!t||t.length===0)return;let n=[...new Set(t.map(o=>me(o)??o))];return n.length>0?n:void 0}function jd(e,t,n){if(n?.suggested_retry||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let o=X(t),a=new Set(o.map(d=>me(d)??d)),i=Jr(e),r=t.find(d=>y.commands.some(m=>m.name()===d)),s=r?y.commands.find(d=>d.name()===r):void 0,l=new Set([...y.options,...s?.options??[]].flatMap(d=>d.flags.split(/[ ,|]+/).map(m=>me(m)).filter(m=>m!==void 0))),c=i?.filter(d=>{let m=me(d)??d;return a.has(m)?!1:l.has(m)||Hn(t,r,m,R)!==void 0});return c&&c.length>0?c:void 0}function Ud(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let a=n?.[0],i=a?me(a):void 0,r=e.find(p=>y.commands.some(u=>u.name()===p)),s=r?y.commands.find(p=>p.name()===r):void 0,l=i?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(i)):void 0,c=Hn(e,r,i,R),d=i?l?.isBoolean()===!0||c===!1?[i]:[i,"<value>"]:[],m=i?zt([...e,...d]):t;return m===t?void 0:m}function qd(e){if(!e)return{};let t=["recovery_mode","missing_required_fields","suggested_flags","suggested_retry_args","allowed_values","candidate_commands","candidate_commands_total","candidate_commands_truncated","fallback_candidates","next_best_command"],n={};for(let o of t){let a=e[o];a!=null&&(n[o]=a)}return n}function Hd(e){let t=e.existingRecovery;return{attempted_command:t?.attempted_command??e.attemptedCommand,normalized_args:t?.normalized_args??[...e.invocationArgv],provided_fields:t?.provided_fields??(e.providedFields.length>0?e.providedFields:void 0),missing:t?.missing??e.inferredMissing,...qd(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Yr(e,t,n){let o=Ue(t),a=M(o),i=J(a),[r,s]=i===void 0?[]:a.slice(i,i+2),l=o.includes("--explain"),c=xi(o,e?.code,e?.recovery),d=c&&(r==="history-redact"||r==="history"&&s==="redact")?{...c,...c.attempted_command?{attempted_command:zt(o)}:{},...c.normalized_args?{normalized_args:[...o]}:{},...c.suggested_retry?{suggested_retry:zt(o)}:{},...c.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:c;if(d?.recovery_mode==="compact"&&!l)return{...e,recovery:d};let m=zt(o),p=X(o),u=jd(n,o,d),f=Ud(o,m,u,d),h=Hd({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:f,existingRecovery:d});return{...e,recovery:h}}async function rt(e){let t=j;j=null,await Ei(t,e);let n=De;if(De=null,!n){pt();return}let o=[],a=ha();try{await Si({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?a?.map(i=>i.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await sa(n.hooks,{command:n.commandName,args:n.commandArgs,options:{...n.commandOptions},global:{...n.globalOptions},pm_root:n.pmRoot,ok:e.ok,error:e.error,result:le(),affected:a}))}catch(i){o=[`afterCommand hooks failed: ${i instanceof Error?i.message:String(i)}`]}finally{pt()}!n.globalOptions.json&&o.length>0&&_(`[pm] warning: afterCommand hook_warnings=${q(o)}`),n.profileEnabled&&o.length>0&&_(`profile:extensions hook_warnings=${q(o)}`)}async function Xr(){await Ba()}function Zr(e){return Dd.has((process.env[e]??"").trim().toLowerCase())}function Qr(e){return Zr("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Pd.has(Math.trunc(e))}async function Vt(e){return Qr(e.exit_code)?(await Xr(),Za(e),!0):!1}async function es(e){let t=de(e.error),n=Bi(t);e.bootstrapGlobal.json?_(JSON.stringify(Wi(t,g.GENERIC_FAILURE),null,2)):_(t),process.exitCode=g.GENERIC_FAILURE;let o="runtime",a="runtime_failed";try{await Xr(),fn(e.error);let i=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:g.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=i.errorCategory,a=i.commandResolution,await Jt(!1,t,{error_code:n.code,error_category:o,exit_code:g.GENERIC_FAILURE,command_resolution:a,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||_(`Failed to report error: ${de(i)}`)}try{await rt({ok:!1,error:t,exit_code:g.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:a,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||_(`Failed to run error hooks: ${de(i)}`)}try{await ke()}catch(i){e.bootstrapGlobal.json||_(`Failed to flush error reporting: ${de(i)}`)}}var zd={create:"create",update:"update","update-many":"update_many",list:"list","list-all":"list","list-draft":"list","list-open":"list","list-in-progress":"list","list-blocked":"list","list-closed":"list","list-canceled":"list",search:"search",calendar:"calendar",context:"context","templates save":"create"},Mo=new Map;function No(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function ts(e,t){return e.options.some(n=>n.long===t)}function ns(e,t){return e.options.some(n=>n.short===t)}function Fo(e,t,n,o){let a=t.trim();if(!a)return;let i=n.length>0?n:`Runtime schema field (${t})`;if(a.startsWith("-")&&!a.startsWith("--")){if(ns(e,a))return;if(o){e.option(`${a} <value>`,`${i} (repeatable)`,yn);return}e.option(`${a} <value>`,i);return}let r=a.startsWith("--")?a:`--${a}`;if(!ts(e,r)){if(o){e.option(`${r} <value>`,`${i} (repeatable)`,yn);return}e.option(`${r} <value>`,i)}}async function os(e,t){let n=zd[e];if(!n)return[];let o=`${t}:${n}`,a=Mo.get(o);if(a)return a;if(!await B(K(t)))return Mo.set(o,[]),[];let i=await D(t),r=(pn(i.schema).command_to_fields.get(n)??[]).flatMap(s=>[s.cli_flag,...s.cli_aliases].map(l=>({long:`--${l}`,type:No(s.type),value_type:No(s.type)})));return Mo.set(o,r),r}async function as(e,t){let n=F(t),o=T(process.cwd(),n.path);if(!await B(K(o)))return;let a=_e?.key===Go(o)?_e.snapshot:null,i=a===null?await D(o):a.settings,r=pn(i.schema),s=[{path:"create",command:"create"},{path:"update",command:"update"},{path:"update-many",command:"update_many"},{path:"list",command:"list"},{path:"list-all",command:"list"},{path:"list-draft",command:"list"},{path:"list-open",command:"list"},{path:"list-in-progress",command:"list"},{path:"list-blocked",command:"list"},{path:"list-closed",command:"list"},{path:"list-canceled",command:"list"},{path:"search",command:"search"},{path:"calendar",command:"calendar"},{path:"context",command:"context"},{path:"templates save",command:"create"}];for(let l of s){let c=Q(e,l.path.split(" "));if(c)for(let d of r.command_to_fields.get(l.command)??[]){let m=d.description??"";Fo(c,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)Fo(c,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function Ho(e,t,n,o,a){let i=x(n);if(!(i!=="create"&&i!=="update"))try{let r=a??await D(t),s=re(r,o);Rr(e,s,n)}catch{}}function Lo(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function is(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function zo(e){return e.some(t=>t==="--profile")}function Go(e){return`pm-root:${e}`}function jo(e){for(let t of e)t.startsWith("settings_read_")&&_(`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function rs(e,t){e.profile&&(_(`profile:extensions loaded=${t.loadedCount} failed=${t.loadFailedCount} warnings=${t.loadWarnings.length} activation_failed=${t.activationFailedCount} hook_counts=before:${t.hooks.beforeCommand.length}|after:${t.hooks.afterCommand.length}|write:${t.hooks.onWrite.length}|read:${t.hooks.onRead.length}|index:${t.hooks.onIndex.length} command_overrides=${t.commands.overrides.length} command_handlers=${t.commands.handlers.length} parser_overrides=${t.parsers.overrides.length} preflight_overrides=${t.preflight.overrides.length} service_overrides=${t.services.overrides.length} renderer_overrides=${t.renderers.overrides.length}`),t.activationWarnings.length>0&&_(`profile:extensions activation_warnings=${q(t.activationWarnings)}`))}function Bt(e,t,n){if(!e)return;let o=w(n.commandPath??"")||"<none>";_(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function Kt(e,t=Ce){let n=Go(e);if(_e?.key===n)return _e.snapshot;try{let o=Date.now(),{settings:a,warnings:i}=await t(e),r=await la({pmRoot:e,settings:a,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:a,discovery:r,discoveryMs:Date.now()-o,settingsReadWarnings:[...i]};return _e={key:n,snapshot:s},s}catch{return _e={key:n,snapshot:null},null}}async function Me(e,t,n=D){let o=t?et(t):"all",a=is(e,o);if(at?.key===a)return at.snapshot;try{let i=await n(e),r=await Le({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?fo(t):void 0}),s=await je({...r,loaded:r.loaded}),l=[...new Set(s.commands.handlers.map(u=>w(u.command)))].filter(u=>u.length>0).sort((u,f)=>u.localeCompare(f)),c=ar(s.registrations.flags),d=nr(s.commands.handlers,s.registrations.commands),m=rr(l,s.registrations.commands,s.registrations.flags,d),p={hooks:s.hooks,commands:s.commands,parsers:s.parsers,preflight:s.preflight,services:s.services,renderers:s.renderers,registrations:s.registrations,pmRoot:e,settings:i,commandHandlers:l,commandFlagHelp:c,commandDescriptors:m,commandAliases:d,loadWarnings:[...r.warnings],activationWarnings:[...s.warnings],loadedCount:r.loaded.length,loadFailedCount:r.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:r.loaded.map(({name:u,module:f})=>({name:u,module:f}))};return at={key:a,snapshot:p},p}catch{return at={key:a,snapshot:null},null}}async function ss(e){let t=We(e);if(t.noExtensions){let r=T(process.cwd(),t.path);return await B(K(r))&&jo((await Ce(r)).warnings),null}let n=T(process.cwd(),t.path),o=await Kt(n);if(!o)return null;jo(o.settingsReadWarnings);let a={commandPath:E(e),commandArgs:go(e)};if(!Qe(o.discovery,a))return Bt(t.profile,o,a),null;let i=await Me(n,a);return i?(rs(t,i),{hooks:i.hooks,commands:i.commands,parsers:i.parsers,preflight:i.preflight,services:i.services,renderers:i.renderers,registrations:i.registrations,pmRoot:n}):null}async function Wo(e){let t=await Me(e);return t?new Map(t.commandDescriptors):R}async function Gd(e,t){return!e.requested||t.noExtensions||Ae(y,e.commandPathTokens)?R:Wo(T(process.cwd(),t.path))}async function ls(e,t){return(await Fa({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(n=>n.outcome==="failed").map(n=>`extension_migration_failed:${n.layer}:${n.extension}:${n.id}`)}function cs(e,t,n){let o=t.author;return Na(e,gi.forActiveExtensionHost({pmRoot:e,author:o}),o,w(n))}async function ds(e,t,n,o=[]){let a=E(e),i=to(e.args.map(String),o),r={...t};delete r.author;let s={...n},l=T(process.cwd(),n.path),c=await ut({command:a,args:i,options:r,global:s,pm_root:l});n.profile&&c.warnings.length>0&&_(`profile:extensions parser_warnings=${q(c.warnings)}`),i=c.context.args,r=c.context.options,s=c.context.global,vo(R.get(w(a)),i,r,o),ve(void 0),mt({command:a,args:i,options:{...r},global:{...s},pm_root:l});let d=await on({command:a,args:i,options:r,global:s,pm_root:l,sdk:cs(l,s,a)});if(s.profile&&d.warnings.length>0&&_(`profile:extensions command_handler_warnings=${q(d.warnings)}`),!d.handled){if(d.warnings.length>0){let m=d.warnings[0],p=d.errorMessage?.trim(),u=p?` ${p}`:"";throw new C(`Command "${a}" failed in extension handler (${m}).${u}`,g.GENERIC_FAILURE,{code:d.errorCode??"command_failed",nextSteps:d.remediation?[d.remediation]:void 0})}throw new C(`Command "${a}" is provided by extensions and is not currently available.`,g.NOT_FOUND)}return d.exitCode!==void 0&&(process.exitCode=d.exitCode),ve(d.result),d.result}var qr=Symbol("pm.wrappedActionHandler");function Wd(e,t){let n=e[e.length-1];return n instanceof Uo?n:t}function Hr(e,t,n){e&&n.length>0&&_(`profile:extensions ${t}=${q(n)}`)}function Vd(e){let t=R.get(w(e.commandPath));if(!t||!_o(e.activeRegistrations,e.commandPath))return;let n=Ut(t).length===0?Cr(e.commandArgs):to(e.commandArgs,e.extensionFlagDefinitions);wo(t,n)}function Bd(e,t,n){e.args=[...n],"_processArguments"in e&&typeof e._processArguments=="function"&&e._processArguments(),t.length>0&&Array.isArray(t[0])&&(t[0]=[...e.processedArgs])}function ms(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[qr]!==!0){let a=o._actionHandler;o._actionHandler=async function(...i){let r=Wd(i,n),s=Date.now();hn(r);let l=We(r),c=P(E(r));if(["package inventory","packages inventory","extension inventory"].includes(c))return await a.apply(this,i);let d=T(process.cwd(),l.path),m=r.args.map(String),p=se(),u=p?tt(p,c,m):[],f=await os(c,d),h=Pe(r,m,[...u,...f]);R.has(w(c))&&delete h.author;let v=await ut({command:c,args:m,options:h,global:l,pm_root:d});Hr(l.profile,"parser_warnings",v.warnings),m=v.context.args,h=v.context.options,ie(r,h),l=v.context.global,Vd({activeRegistrations:p,commandPath:c,commandArgs:m,extensionFlagDefinitions:u}),l=await ii(l),bt(r,l),Bd(r,i,m),vt(r,h),ve(void 0),mt({command:c,args:m,options:{...h},global:{...l},pm_root:d});let S=await on({command:c,args:m,options:h,global:l,pm_root:d,sdk:cs(d,l,c)});if(Hr(l.profile,"command_handler_warnings",S.warnings),S.handled){ve(S.result),rn(S.result,{...l,command:c,commandArgs:m,commandOptions:h,pmRoot:d}),l.profile&&_(`profile:command=${c} took_ms=${Date.now()-s}`);return}return await a.apply(this,i)},o[qr]=!0}for(let a of n.commands)t(a)};t(e)}async function Ht(e){R=new Map,te({overrides:[]}),e&&await Ho(e.rootProgram,e.pmRoot,e.invocationArgv,aa(),e.settings)}function Kd(e,t,n,o){if(t?.flags&&t.flags.length>0){Wn(e,t.flags);let a=Vn(e,t.flags);a&&e.addHelpText("after",a)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function ps(e,t,n){let o={core:0,standard:1,full:2,internal:3},a=(i,r)=>{let s=r.join(" "),l=[...n.entries()].filter(([d])=>d===s||d.startsWith(`${s} `)).map(([,d])=>d),c=l.length===0?"standard":l.reduce((d,m)=>o[m.tier]<o[d]?m.tier:d,"internal");xt(i,c);for(let d of i.commands)a(d,[...r,d.name()])};for(let i of e.commands)t.has(i.name())||a(i,[i.name()])}async function us(e,t){let n=F(t),o=T(process.cwd(),n.path);if(n.noExtensions){await Ht({rootProgram:e,pmRoot:o,invocationArgv:t});return}let a=await Kt(o),i=$e(t);if(!a){await Ht();return}if(!Qe(a.discovery,i)){await Ht({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings}),Bt(zo(t),a,i);return}let r=await Me(o,i);if(!r){await Ht({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings});return}te(r.services),R=new Map(r.commandDescriptors),await Ho(e,o,t,r.registrations,r.settings);let s=ur(e,r.commandHandlers,r.commandDescriptors,r.commandAliases,d=>fr(r.activationWarnings,_,d)),l=new Set(e.commands.map(d=>d.name())),c=d=>{let m=d.split(" ").filter(I=>I.length>0),p=r.commandDescriptors.get(d),u=Q(e,m),f=r.commandFlagHelp.get(d),h=p?mr(p):null;if(u){Kd(u,p,f,h);return}let v=pr(e,m);p?.description&&v.description(p.description);let S=f;p&&(sr(v,p),p.flags.length>0&&(Wn(v,p.flags),S=Vn(v,p.flags)??void 0)),S&&v.addHelpText("after",S),h&&v.addHelpText("after",h),v.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...I)=>{let z=I[I.length-1],U=z instanceof Uo?z:v,st=We(U),Es=Date.now(),Ko=tt(r.registrations,d,U.args.map(String)),Jo=Pe(U,U.args.map(String),Ko),Yo=await ds(U,Jo,st,Ko);await ri(st,Yo),rn(Yo,{...st,command:d,commandArgs:U.args.map(String),commandOptions:Jo,pmRoot:o}),st.profile&&_(`profile:command=${d} took_ms=${Date.now()-Es}`)})};for(let d of s)c(d);ps(e,l,r.commandDescriptors)}var it=Qo(import.meta.url,["../.."])??"0.0.0",y=sn(it);async function zr(e){if(!j)return;let t=Reflect.get(e,Kr);typeof t=="string"&&await fi(t)}async function Gr(e,t,n){let o=E(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}async function Wr(e,t,n){!j||!await un(!0)||(Ka(e,t,n,{source_context:j.source_context,source_context_source:j.source_context_source}),Ja(e),Wt=j)}async function Jt(e,t,n){let o=Wt;if(!o)return;Wt=null;let a=!1;try{let i=await D(o.global_pm_root);a=i.telemetry.enabled&&i.telemetry.installation_id===o.installation_id}catch{}await un(a)?Xa(e,t,n):Ya()}async function Jd(e){let t=await ss(e);return nn(t?.registrations??null),t}function fs(e,t){t&&nt(t)||(e.hook("preAction",async(n,o)=>{De=null,j=null,Wt=null,pt(),hn(o);let a=o.optsWithGlobals(),i=We(o),r=P(E(o)),s=o.args.map(String),l=Pe(o,s),c={...i},d=T(process.cwd(),i.path),m=await Jd(o);if(ka(r,{...l,outputInclude:a.outputInclude,outputLimit:a.outputLimit,outputBudget:a.outputBudget,outputFormat:a.outputFormat,outputSession:a.outputSession,outputCursor:a.outputCursor}),yo(o,r,c,l),await Gr(o,void 0,()=>ni(r,c)),!m){De=ca({commandName:r,commandArgs:s,commandOptions:l,globalOptions:c,pmRoot:d}),j=await gn({command:r,pm_version:it,args:s,options:l,global:c,pm_root:d}),await zr(e),await Wr(r,s,l),await io(r,l,d,Lo()),await ao(r,s,l,c,d);return}da(m.hooks),ma(m.commands),pa(m.parsers),ua(m.preflight),te(m.services),fa(m.renderers),nn(m.registrations);let p=tt(m.registrations,r,s);l=Pe(o,s,p),yo(o,r,c,l);let u=await ut({command:r,args:s,options:l,global:c,pm_root:m.pmRoot});c.profile&&u.warnings.length>0&&_(`profile:extensions parser_warnings=${q(u.warnings)}`),s=u.context.args,l=u.context.options,ie(o,l),c=u.context.global,vt(o,l);let f=await ya({command:r,args:s,options:l,global:c,pm_root:m.pmRoot,decision:Lo()});c.profile&&f.warnings.length>0&&_(`profile:extensions preflight_warnings=${q(f.warnings)}`),s=f.context.args,l=f.context.options,ie(o,l),c=f.context.global,vt(o,l);let h=f.decision;await io(r,l,m.pmRoot,h),await ao(r,s,l,c,m.pmRoot);let v=h.run_extension_migrations?await Gr(o,[],()=>ls(m.registrations.migrations,m.pmRoot)):[];c.profile&&v.length>0&&_(`profile:extensions migration_warnings=${q(v)}`);let S=$r(m.registrations.migrations);De={hooks:m.hooks,commandName:r,commandArgs:s,commandOptions:{...l},globalOptions:{...c},pmRoot:m.pmRoot,profileEnabled:!!c.profile,migrationBlockers:S},ve(void 0),mt({command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot}),j=await gn({command:r,pm_version:it,args:s,options:l,global:c,pm_root:m.pmRoot}),await zr(e),await Wr(r,s,l);let I=await ra(m.hooks,{command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot});c.profile&&I.length>0&&_(`profile:extensions hook_warnings=${q(I)}`),h.enforce_mandatory_migration_gate&&Pr(r,l,S)}),e.hook("postAction",async()=>{let n=Po();await Jt(n.ok,n.error,{error_code:n.error_code,error_category:n.error_category,exit_code:n.exit_code,command_resolution:n.command_resolution,resolution_stage:n.resolution_stage}),await rt(n),await ke()}))}fs(y);var Vr=Symbol("pmCliIdempotentTopLevelRegistration");function gs(e){let t=e;if(t[Vr])return;t[Vr]=!0;let n=e.command.bind(e);e.command=((o,...a)=>{let i=o.split(/\s+/u)[0];return e.commands.some(r=>r.name()===i||r.aliases().includes(i))?new Uo(i):n(o,...a)})}async function Yd(e,t){if(gs(e),t.setup){let{registerSetupCommands:n}=await Md();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Nd(),o=typeof t.targetCommandName=="string"&&bo.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await Fd();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await Ld();n(e)}}function Xd(e){return async t=>{let n=lt(t.errorCode),o=wt({ok:!1,errorCode:t.errorCode,errorCategory:n});return await ai({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:it,pm_root:e.bootstrapPmRoot,error_code:t.errorCode,error_message:t.errorMessage,exit_code:t.exitCode,error_category:n,command_resolution:o,resolution_stage:t.resolutionStage}),{errorCategory:n,commandResolution:o}}}async function hs(e){if(e.bootstrapGlobal.noExtensions||nt(e.invocationArgv))return;let t=$e(e.invocationArgv),n=await Kt(e.bootstrapPmRoot);if(n&&Qe(n.discovery,t)){let o=await Me(e.bootstrapPmRoot,t);ys(o);return}n&&Bt(zo(e.invocationArgv),n,t),te({overrides:[]})}function ys(e){if(!e){te({overrides:[]});return}te(e.services)}async function Vo(e){await Jt(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await rt({ok:!1,error:e.errorMessage,exit_code:e.exitCode,error_code:e.classificationCode,error_category:e.errorCategory,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage})}async function _s(){await Jt(!0,void 0,{exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await rt({ok:!0,exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=g.SUCCESS}async function ws(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof C)&&(dn(e.error)||!n))return!1;let o=de(e.error),a=e.error instanceof C?e.error.exitCode:cn(t),i=e.error instanceof C?e.error.context:void 0,r=Yr(i,e.invocationArgv,o),s=zi(o,r),l=e.bootstrapGlobal.lean?At(Dn(o,a,r)):Dn(o,a,r),c=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?ce(l,u=>`${JSON.stringify(u,null,2)}
|
|
34
|
-
`):l,null,2):
|
|
35
|
-
`):
|
|
36
|
-
`):
|
|
37
|
-
`):
|
|
31
|
+
`)}`}function no(e){let t=e;if(typeof t.aliases=="function")return t.aliases().map(n=>n.trim().toLowerCase()).filter(n=>n.length>0);if(typeof t.alias=="function"){let n=t.alias();if(typeof n=="string"&&n.trim().length>0)return[n.trim().toLowerCase()]}return Array.isArray(t._aliases)?t._aliases.map(n=>n.trim().toLowerCase()).filter(n=>n.length>0):[]}function Qe(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:no(o).includes(n))??null}function ee(e,t){let n=e;for(let o of t){let a=Qe(n,o);if(!a)return null;n=a}return n}var oo=new WeakSet;function Dr(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let a=t[o];o>0&&P.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let i=Qe(n,a);if(i){n=i;continue}let r=n.command(a);oo.add(r),o<t.length-1?(r.description("Extension-provided command group."),r.action(()=>{r.help()})):r.description("Extension-provided command path."),n=r}return n}function Zc(e,t){let n=t.join(" "),o=P.find(r=>n===r.canonical||n.startsWith(`${r.canonical} `));if(o)return{core_path:o.canonical,extension_path:n};let a=e,i=[];for(let r of t){let s=Qe(a,r);if(!s)return null;i.push(r);let l=s.commands.length>0||P.some(c=>c.canonical.startsWith(`${i.join(" ")} `));if(!oo.has(s)&&(i.length===t.length||!l))return{core_path:i.join(" "),extension_path:t.join(" ")};a=s}return null}function Qc(e,t,n,o,a=!1){let i=t.split(" ").filter(d=>d.length>0),r=Zc(e,i),s=ee(e,i),l=P.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||oo.has(s)));if(!r||r.core_path===t&&s!==null&&!n.has(t)&&!a||l&&!n.has(t))return null;let c=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${r.extension_path}:core_owner=pm-cli:${r.core_path}:extension_owner=${c}`}function Mr(e,t,n,o,a){return[...new Set([...t,...n.keys()])].filter(i=>i.trim().length>0).sort((i,r)=>i.localeCompare(r)).filter(i=>{let r=Qc(e,i,o,n.get(i),t.includes(i));return r?(a(r),!o.has(i)&&ee(e,i.split(" "))!==null):!0})}function Nr(e,t,n){e.push(n),t(`[pm] warning: ${n}; core command preserved. Rename or namespace the extension command alias.`)}(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]="c6ed71d0-b878-575e-b990-356afdc45688")}catch{}})();var ed=new Set(["__proto__","prototype","constructor"]),ao=Symbol("looseOptionOccurrences");function et(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,n)=>n.toUpperCase())}function td(e,t,n){let o=e[t];if(o===void 0){e[t]=n;return}if(Array.isArray(o)){o.push(n),e[t]=o;return}e[t]=[o,n]}function io(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let r=n.indexOf("=");if(r>=0)return{consumed:1,key:n.slice(1,r).trim(),value:n.slice(r+1),attached:!0};let s=n.slice(1).trim(),l=e[t+1];return typeof l=="string"&&!l.startsWith("-")?{consumed:2,key:s,value:l}:{consumed:1,key:s,value:!0}}let o=n.indexOf("=");if(o>=0)return{consumed:1,key:n.slice(2,o).trim(),value:n.slice(o+1),attached:!0};if(n.startsWith("--no-"))return{consumed:1,key:n.slice(5).trim(),value:!1};let a=n.slice(2).trim(),i=e[t+1];return typeof i=="string"&&!i.startsWith("-")?{consumed:2,key:a,value:i}:{consumed:1,key:a,value:!0}}function Nt(e){return ed.has(e)}function Lr(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return ua(t)}function tt(e){let t=[],n=te(e.long)??"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let a=et(n.slice(2));a.length>0&&!Nt(a)&&t.push(a)}if(o.startsWith("-")&&!o.startsWith("--")){let a=et(o.slice(1));a.length>0&&!Nt(a)&&t.push(a)}return[...new Set(t)]}function Fr(e){let t=new Set;for(let n of e)for(let o of tt(n))t.add(o);return t}function nd(e){let t=te(e.long)??"";if(t.startsWith("--")){let n=et(t.slice(2));if(n.length>0&&!Nt(n))return n}return tt(e)[0]??null}function jr(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")&&t.length>2)return t;let n=typeof e.short=="string"?e.short.trim():"";return n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function ro(e,t,n){if(t.length===0)return;let o=new Set,a=new Map,i=[],r=[];for(let s of t){let l=tt(s),c=jr(s);c!==null&&r.push(c);for(let d of l)o.add(d),s.enabled===!1&&a.set(d,c);s.required===!0&&s.enabled!==!1&&l.length>0&&i.push({keys:l,label:c})}for(let s of Object.keys(e)){if(!o.has(s)){let c=r.length>0?` Expected one of: ${[...new Set(r)].join(", ")}.`:"";throw new x(`Unknown option '--${s}' for extension command '${n}'.${c}`,g.USAGE)}let l=a.get(s);if(l)throw new x(`Option '${l}' is disabled for extension command '${n}'.`,g.USAGE)}for(let s of i)if(!s.keys.some(l=>Object.hasOwn(e,l)))throw new x(`Missing required option '${s.label}' for extension command '${n}'.`,g.USAGE)}function od(e){return typeof e=="string"||e==null?e:String(e)}function ad(e){if(typeof e=="number")return e;if(typeof e=="string"&&e.trim().length>0){let t=Number(e);return Number.isFinite(t)?t:e}return e}function id(e){if(typeof e=="boolean")return e;if(typeof e=="string"){let t=e.trim().toLowerCase();if(t==="true"||t==="1")return!0;if(t==="false"||t==="0")return!1}return e}var rd={string:od,number:ad,boolean:id};function Re(e,t){return Array.isArray(e)?e.map(n=>Re(n,t)):rd[t](e)}function Ur(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(a=>a!=null&&a!==""):on(e);return t?o.map(a=>Re(a,t)):o}function sd(e,t,n,o){return n?Ur(e,t,o):t?Re(e,t):e}function ld(e,t,n){let o=e[ao];if(!o||o.length===0)return n;let a=new Set(t);return o.filter(i=>a.has(i.key)).map(i=>i.value)}function qr(e){return Ce(e).value_arity==="none"}function so(e,t,n,o,a){let i=jr(e),r=a?` for extension command '${a}'`:"",s=n===!0?"no value":JSON.stringify(n);throw new x(`Option '${i}'${r} expects ${o}; received ${s}.`,g.USAGE,{code:"extension_flag_value_invalid",required:`Pass ${i} ${t==="number"?"<number>":"<true|false|1|0>"}.`,why:`The flag declares value_type ${t} with value_validation strict, so a malformed token is refused before the extension handler runs.`,nextSteps:[`Re-run with a valid ${t} value for ${i}.`,`Run pm ${a??"<command>"} --help to review the declared flag contract.`]})}function lo(e,t){return e.value_validation==="strict"&&t!=="string"}function cd(e,t){let n=e[ao];if(!n)return[];let o=new Set(t);return n.filter(a=>o.has(a.key))}function dd(e,t,n,o){if(qr(e))for(let a of cd(n,t)){if(a.attached!==!0)continue;let i=e.list===!0&&e.repeatable!==!0?on(a.value):[a.value];for(let r of i){let s=ut(Re(r,"boolean"),"boolean");s!==null&&so(e,"boolean",r,s.expected,o)}}}function md(e,t,n,o,a){let i=Array.isArray(n)?n.flat(1/0):[n],r=o?i:i.flatMap(s=>typeof s=="string"?s.split(","):[s]);for(let s of r)if(typeof s=="string"&&s.trim().length===0){let l=ut(s,t);so(e,t,s,l.expected,a)}}function co(e,t,n,o){if(!lo(e,n))return t;let a=n==="boolean"&&qr(e),i=r=>{let s=ut(r,n);return s===null?r:a&&typeof r=="string"?!0:so(e,n,r,s.expected,o)};return Array.isArray(t)?t.map(i):i(t)}function pd(e,t,n,o){for(let a of n)if(!(a===t||!Object.hasOwn(e,a))){if(Object.hasOwn(e,t)){if(o){let i=e[t],r=e[a];e[t]=[...Array.isArray(i)?i:[i],...Array.isArray(r)?r:[r]].filter(s=>s!=null)}delete e[a];continue}e[t]=e[a],delete e[a]}}function Hr(e,t,n=e,o){if(t.length===0)return e;let a=Object.create(null);for(let[i,r]of Object.entries(e))a[i]=r;for(let i of t){let r=nd(i);r&&ud(a,i,r,n,o)}return a}function ud(e,t,n,o,a){let i=t.list===!0,r=tt(t),s=Lr(t);s&&!i&&fd(e,t,n,r,s,a),pd(e,n,r,i);let l=t.repeatable===!0;if(!Object.hasOwn(e,n)){t.default!==void 0&&(e[n]=sd(t.default,s,i,l));return}if(s==="boolean"&&lo(t,s)&&dd(t,r,o,a),i){e[n]=gd(t,r,o,e[n],s,l,a);return}s&&(e[n]=co(t,Re(e[n],s),s,a))}function fd(e,t,n,o,a,i){for(let r of o)r!==n&&Object.hasOwn(e,r)&&co(t,Re(e[r],a),a,i)}function gd(e,t,n,o,a,i,r){let s=ld(n,t,o);a&&lo(e,a)&&md(e,a,s,i,r);let l=Ur(s,a,i);return a?co(e,l,a,r):l}function zr(e){let t=Object.create(null),n=[];Object.defineProperty(t,ao,{value:n});let o=0;for(;o<e.length;){let a=io(e,o);if(!a){o+=1;continue}let i=et(a.key);if(i.length===0||Nt(i)){o+=a.consumed;continue}td(t,i,a.value),n.push({...a,key:i}),o+=a.consumed}return t}function Gr(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=io(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function mo(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let r of t){let s=Lr(r);for(let l of tt(r))n.add(l),s==="boolean"&&o.add(l)}if(n.size===0)return[...e];let a=[],i=0;for(;i<e.length;){if(e[i]==="--"){a.push(...e.slice(i+1));break}let r=io(e,i);if(r){let s=et(r.key);if(n.has(s)){let l=e[i],c=o.has(s)&&!l.includes("=")?1:r.consumed;i+=c;continue}}a.push(e[i]),i+=1}return a}import Ie 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]="4a2291ff-7618-518c-8bff-e9aa0e2f8af2")}catch{}})();async function po(e,t={},n=[]){let o={readSettings:D,loadExtensions:qe,activateExtensions:He,resolveImplicitPmRoot:tn,...t};try{let a=await o.readSettings(e),i=await o.loadExtensions({pmRoot:e,settings:a,cwd:process.cwd(),noExtensions:!1}),r=await o.activateExtensions(i);return[...i.failed,...r.failed].map(s=>{let l=(i.effective??[]).find(p=>p.layer===s.layer&&p.name===s.name),c=[...l?.contributions?.commands??[],...l?.contributions?.command_handlers??[],...l?.activation?.commands??[]].map(L).filter((p,u,f)=>p.length>0&&f.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),d=n.map(L),m=c.some(p=>d.some(u=>u===p||u.startsWith(`${p} `)));return{layer:s.layer,name:s.name,error:s.error,...c.length>0?{declared_commands:c}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(a){return[{layer:"runtime",name:"extension-loader",error:a instanceof Error?a.message:String(a)}]}}async function Wr(e,t,n={},o=[]){if(e!=="unknown_command")return[];let a=await po(t,n,o),i={readSettings:D,loadExtensions:qe,activateExtensions:He,resolveImplicitPmRoot:tn,...n};try{let r=i.resolveImplicitPmRoot(process.cwd());if(Ie.resolve(r)===Ie.resolve(t))return a;let[s,l]=await Promise.all([i.readSettings(t),i.readSettings(r)]),[c,d]=await Promise.all([i.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),i.loadExtensions({pmRoot:r,settings:l,cwd:process.cwd(),noExtensions:!1})]),m=new Set(c.loaded.flatMap(u=>u.activation?.commands??[])),p=[...new Set(d.loaded.flatMap(u=>u.activation?.commands??[]))].filter(u=>!m.has(u)).sort((u,f)=>u.localeCompare(f));if(p.length===0)return a;a.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${Ie.resolve(t)} extension_discovery_root=${c.roots.project}; cwd_storage_root=${Ie.resolve(r)} cwd_extension_discovery_root=${d.roots.project}; the selected --pm-path runtime is missing ${p.length} workspace command path(s): ${p.slice(0,8).join(", ")}${p.length>8?", ...":""}. --pm-path selects extension discovery as well as item storage; omit it, point --pm-path at ${Ie.resolve(r)}, or install the extension into the selected tracker with "pm --pm-path ${Ie.resolve(t)} install <package> --project".`})}catch{}return a}(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]="3f896a8d-2c03-5f9c-9909-4684a187870d")}catch{}})();var Br={core:0,standard:1,full:2,internal:3};function Vr(e,t,n=!0){let o=t.get($(e));if(o)return o;if(!n)return;let a=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(a.length===0)return;let i=a.reduce((s,l)=>Br[l.tier]<Br[s]?l.tier:s,"internal"),r=new Set(a.map(({family:s})=>s));return{tier:i,family:r.size===1?a[0].family:"extensions"}}function Kr(e,t){if(t.length===0)return e;let n=ee(e,t);if(n)return n;let o=t.join(" ");if($(o)!==o||!Fe.some(a=>a===o)&&!di(o)&&!Ge(o)&&!Oe(e,t))return null;for(let a=t.length-1;a>0;a-=1){let i=ee(e,t.slice(0,a));if(i)return i}return t.length===1?e:null}function hd(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function Jr(e){let t=e;if(typeof t.attributeName=="function"){let n=t.attributeName();return typeof n=="string"&&n.trim().length>0?n.trim():null}return typeof t.attributeName=="string"&&t.attributeName.trim().length>0?t.attributeName.trim():null}function yd(e){let t=new Map;for(let n of e){let o=n,a=Jr(n);if(!a||typeof o.long!="string"||o.long.trim().length===0)continue;let i=t.get(a)??[];i.push(o.long.trim()),t.set(a,i)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(a=>a.trim()).filter(a=>a.length>0))].sort((a,i)=>a.localeCompare(i)));return t}function _d(e){return w(e)}function wd(e){let t=e.options??[],n=yd(t);return t.map(o=>{let a=o,i=typeof a.flags=="string"?a.flags.trim():"",r=typeof a.description=="string"?a.description.trim():"",s=Jr(o),l=(s?n.get(s)??[]:[]).filter(h=>h!==a.long).map(h=>h.trim()).filter(h=>h.length>0),c=r.match(/^Alias for ([^ ]+)/i),d=c&&c[1]?c[1].trim():null,m=a.mandatory===!0||r.includes("[required]")||r.toLowerCase().includes("required;"),p=i.includes("<"),u=p||i.includes("["),f={flags:i,long:typeof a.long=="string"?a.long:null,short:typeof a.short=="string"?a.short:null,description:r,takes_value:u,value_required:p,value_name:hd(i),variadic:a.variadic===!0,required:m,aliases:l,alias_for:d};return a.defaultValue!==void 0&&(f.default_value=a.defaultValue),f})}function vd(e){let t=new Map,n=[];for(let o of e){if(o.alias_for&&o.long){n.push(o);continue}o.long&&t.set(o.long,o)}for(let o of n){let a=o.alias_for,i=t.get(a);if(!i)continue;let r=o.long,s=new Set([...i.aliases??[],r]);i.aliases=[...s].sort((l,c)=>l.localeCompare(c))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function bd(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(n=>{let o=typeof n.name=="function"?n.name():typeof n.name=="string"?n.name:"argument",a=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():null;return{name:o.trim(),required:n.required===!0||a?.toLowerCase().startsWith("required;")===!0,variadic:n.variadic===!0,description:a}})}function Cd(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(a=>a.name()!=="help"||e.parent===null).filter(a=>!n||(ue(a)??X(a.name()))!=="internal").map(a=>{let i=L(E(a)),r=i,s=ue(a),l=Vr(i,t,s!==void 0),c=B.find(({alias:d})=>d===i);return{name:a.name().trim(),aliases:no(a),description:a.description().trim(),tier:l?.tier??s??X(r),family:l?.family??Et(r),...c?{alias_for:c.canonical,alias_lifecycle:c.lifecycle,...c.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((a,i)=>a.name.localeCompare(i.name))}function xd(e,t,n){if(!n)return t;let o=n.examples??[],a=n.failure_hints??[];return{intent:n.intent??n.description??t.intent,examples:e==="detailed"?o.length>0?[...o]:[...t.examples]:o.length>0?[o[0]]:[...t.examples],tips:e==="detailed"?a.length>0?[...a]:[...t.tips]:[],detail_mode:e}}function kd(e,t,n,o,a){let i=e!==void 0&&Pn(e)===Ae,r=i?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:Ki(e,n),s=a?"positional_action":o?.intent||o?.description?"extension":i?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:xd(n,r,o),intentSource:s}}function Ed(e,t){return e===void 0?null:t?.tier??X(e)}function Sd(e,t){return e===void 0?null:t?.family??Et(e)}function Ad(e,t,n){if(!(t!==e||!n))return B.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:Kr(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function Td(e,t,n,o,a=new Map,i=!1){if(!e){let s=bd(t),l=Cd(t,a,i),c=new Set(l.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...l,...bt.filter(({parent:d,action:m})=>d===n&&!c.has(m)).map(({action:d,description:m})=>({name:d,aliases:[],description:m,tier:X(n.split(" ")[0]),family:Et(n.split(" ")[0])}))].sort((d,m)=>d.name.localeCompare(m.name)),usage:[n,s.reduce((d,m)=>m.required?d.replace(`[${m.name}${m.variadic?"...":""}]`,`<${m.name}${m.variadic?"...":""}>`):d,t.usage())].filter(d=>d.length>0).join(" ")}}let r=new Set(e.accepted_flags);return{arguments:e.slots.map(({name:s,required:l,variadic:c,value_kind:d,polymorphic:m})=>({name:s,required:l,variadic:c,description:m?`Polymorphic ${d} value; inspect the action contract before mutation.`:`${d.replaceAll("_"," ")} value.`})),options:o.filter(({long:s,aliases:l})=>s!==null&&r.has(s)||l.some(c=>r.has(c))),subcommands:[],usage:[e.command,...e.slots.map(({name:s,required:l,variadic:c})=>{let d=c?`${s}...`:s;return l?`<${d}>`:`[${d}]`})].join(" ")}}function Od(e,t,n,o,a){let i=In(n),r=ie(n),s=L(E(t)),l=L(o.join(" ")),c=l.length>s.length?l:s,d=Ge(c),m=d?.command??s,p=m.length>0?m:void 0,u=p,f=p?a.get($(p)):void 0,h=p?Vr(p,a,ue(t)!==void 0):void 0,{narrative:b,intentSource:S}=kd(p,t.description().trim(),i,f,d!==void 0),I=vd(Pr(wd(t),Ir(f))),z=Td(d,t,m,I,a,r),U=Ad(e,t,r);return{format:"pm_help_v1",detail_mode:i,root_command:e.name(),requested_path:o,resolved_path:m.length>0?m:e.name(),visibility_tier:Ed(u,h),capability_family:Sd(u,h),description:d?.description??t.description(),usage:z.usage,intent:d?.description??b.intent,intent_source:S,examples:d?[d.example]:b.examples,tips:d?[Ct(d.accepted_flags)]:b.tips,arguments:z.arguments,options:z.options,subcommands:z.subcommands,has_subcommands:z.subcommands.length>0,...U===void 0?{}:{command_aliases:U}}}async function Yr(e,t,n,o=t){let a=M(t);if(!a.json)return!1;let i=A(t);if(!i.requested)return!1;let r=Kr(e,i.commandPathTokens);if(!r){if(!a.quiet){let s=`unknown command '${i.commandPathTokens.join(" ")}'`,l=Kn(s,e,n,t),c=Pt(s,"help",Ye,g.USAGE,{...l,attemptedCommand:_d(t),normalizedInvocationArgs:[...t],providedOptionFlags:Z(t)}),d=a.tokenAccounting?J(c,m=>`${JSON.stringify(m,null,2)}
|
|
32
|
+
`):c;oe(`${JSON.stringify(d,null,2)}
|
|
33
|
+
`)}return process.exitCode=g.USAGE,!0}if(!a.quiet){let s=Od(e,r,t,i.commandPathTokens,n),l=A(o).commandPathTokens;s.requested_path=l;let c=W(l.join(" "));c&&(s.resolved_path=c.canonical),r===e&&!ie(t)&&(s.omission_receipt={has_omissions:!0,omitted_field_group_count:1,omitted_field_groups:[{name:"command_aliases",restore_with:"--all"}]}),za(`${JSON.stringify(s,null,2)}
|
|
34
|
+
`)}return process.exitCode=g.SUCCESS,!0}function Rd(e,t){let n=["","Type-aware option policies:"," pass --type <value> with --help to render required/disabled/hidden option policy details for that type.",` active type values: ${t.types.join("|")}`];return e==="create"&&n.push(" scheduling shortcut: use --schedule-preset lightweight for Reminder/Meeting/Event minimal create flows."),n.join(`
|
|
35
|
+
`)}function Id(e,t){if(t.options.length===0){e.push(" type options: none");return}e.push(" type options:");for(let n of t.options){let o=n.required?" (required)":"",a=n.aliases??[];e.push(` - ${n.key}${o}`),e.push(` values: ${n.values.length>0?n.values.join("|"):"any non-empty string"}`),e.push(` aliases: ${a.length>0?a.join("|"):"none"}`),n.description&&n.description.trim().length>0&&e.push(` description: ${n.description.trim()}`)}}function Pd(e,t){let n=e==="create"?new Set(["title","type"]):new Set,o=new Set(n);if(e==="create")for(let a of[...t.required_create_fields,...t.required_create_repeatables])o.add(a);return{progressive:n,strict:o}}function $d(e,t,n,o){let a=new Set(n),i=o.filter(l=>!a.has(l)),r=l=>l.length>0?l.map(c=>en("create",c)).join(", "):"none";e.push(` required in strict mode: ${r(i)}`);let s=i.map(Si).filter(l=>l!==void 0);e.push(` explicit empty assertion: ${s.length>0?s.join(", "):"none"}`),["Reminder","Meeting","Event"].includes(t.name)&&(e.push(" schedule preset: --schedule-preset lightweight switches schedule artifacts to progressive required-option policy."),e.push(" strict parity remains available via --create-mode strict."))}function Dd(e,t,n){let o=pi(n);if(!o)return Rd(e,t);let a=la(o,t);if(!a){let h=t.types.join("|");return["",`Type-aware option policies: type "${o}" is not in the active registry.`,` active type values: ${h}`].join(`
|
|
36
|
+
`)}let i=n.indexOf("--"),r=i<0?n:n.slice(0,i),s=r.findIndex(h=>h==="--create-mode"||h.startsWith("--create-mode=")),l=s<0?void 0:r[s]?.startsWith("--create-mode=")?r[s]?.slice(14):r[s+1],c=e==="create"&&l?.toLowerCase()==="strict",d=Pd(e,a),m=pt(a,e,d.progressive),p=pt(a,e,c?d.strict:d.progressive),u=h=>h.length>0?h.map(b=>en(e,b)).join(", "):"none",f=["",`Type-aware option policies for ${a.name}:`,` required: ${u(p.required)}`,` disabled: ${u(p.disabled)}`,` hidden: ${u(p.hidden)}`];if(e==="create"){let h=pt(a,e,d.strict);$d(f,a,m.required,h.required)}return Id(f,a),p.errors.length>0&&f.push(` config errors: ${p.errors.join("; ")}`),f.join(`
|
|
37
|
+
`)}function Xr(e,t,n){let o=k(n);if(o!=="create"&&o!=="update")return;let a=Qe(e,o);a&&a.addHelpText("after",Dd(o,t,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]="75ebde30-dc8a-5541-b8ba-649906912b78")}catch{}})();function Md(e,t){return Ue(e.id)||`migration-${String(t+1).padStart(3,"0")}`}function Nd(e){return Ue(e.status)?.toLowerCase()??"pending"}function Ld(e){return e.mandatory===!0}function Fd(e,t){let n=e.layer.localeCompare(t.layer);if(n!==0)return n;let o=e.name.localeCompare(t.name);return o!==0?o:e.id.localeCompare(t.id)}function es(e){let t=[];return e.forEach((n,o)=>{if(!Ld(n.definition))return;let a=Nd(n.definition);a!=="applied"&&t.push({layer:n.layer,name:n.name,id:Md(n.definition,o),status:a})}),t.sort(Fd),t}function Zr(e){return Array.isArray(e)&&e.length>0}var jd=new Set(["create","beads import","todos import"]),Ud=new Set(["restore","update","close","delete","append","claim","release"]),qd=new Set(["comments","notes","learnings"]),Hd=new Set(["files","docs","test"]),zd=new Set(["activate","add","add-field","add-status","add-type","apply","compact","create","deactivate","delete","disable","edit","enable","import","infer","install","materialize","migrate","redact","remove","remove-field","remove-status","remove-type","remap-status","rename-field","rename-type","repair","run","save","set","unset","update","upgrade"]);function uo(e,t){let n=t.force===!0;return jd.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:Ud.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:qd.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:Hd.has(e)?{isMutation:Zr(t.add)||Zr(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function Gd(e,t,n){if(uo(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return ni(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(a=>zd.has(a.trim().toLowerCase())):!1}function Qr(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Wd(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let a=[];if(Ue(t[1])||a.push("source"),Ue(n.to)||a.push("--to"),a.length!==0)throw new x(`Schema migration requires ${a.join(", ")}.`,g.USAGE,{code:"schema_migration_input_required",required:a.join(","),why:"Schema migrations require a source and target. A workspace-bound stable migration id is derived automatically when --migration-id is omitted.",recovery:{recovery_mode:"compact",missing_required_fields:a,suggested_flags:a.filter(i=>i.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function Bd(e,t,n,o,a){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||Qr(n.status)!==Qr(a.schema.workflow.in_progress_status))return;let i=t[0];if(!i)return;let r=le(a,ce()),s=await wt(o,i,a.id_prefix,a.item_format,r.type_to_folder);if(!s)return;let l=await Ba(s,{schema:a.schema}),c=typeof n.assignee=="string"?n.assignee.trim():void 0;(c===void 0?l.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(c.toLowerCase())&&c)||v(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function fo(e,t,n,o,a){if(!Gd(e,t,n)||(Wd(e,t,n),!await V(K(a))))return;let i=await ke(a);Fi(o.json===!0)||await Bd(e,t,n,a,i.settings);let r=ti({author:yt(o.author,i.settings.author_default),payload:{command:e,args:t,options:n},settings:i.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of r.warnings)Ke(s)}function ts(e,t,n){if(n.length===0)return;let o=uo(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let a=n.map(r=>`extension_migration_blocking:${r.layer}:${r.name}:${r.id}:${r.status}`),i=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new x(`Write command "${e}" blocked by unresolved mandatory extension migrations (${a.join(",")}). ${i}`,g.CONFLICT)}async function go(e,t,n,o){if(!uo(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await V(K(n)))return;let{settings:a,metadata:i,warnings:r}=await ke(n);for(let s of r)Ke(s);if(o.enforce_item_format_gate&&!i.has_explicit_item_format&&(Ga(a),await Wa(n,a,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let s=le(a,ce());await oi(n,a.item_format,"item_format:pre_mutation_sync",s.type_to_folder,a.schema)}}(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]="c0826cb1-5181-51b3-9ad9-0cd7a3d2c4b3")}catch{}})();function ho(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=_(n);o.length!==0&&t.push(o)}return t}function $e(e){let t=_(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(a=>a.length>0);for(let a of ho(e.commandArgs))o.push(...a.split(" ").filter(i=>i.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(a=>[a,$(a)]))]}function yo(e,t){let n=_(e);if(n.length===0)return!1;let o=$e(t);for(let a of o)if(a===n||a.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(a=>n.startsWith(`${a} `)):!1}function Ft(e){let t=e.activation?.commands;if(t)return t;let n=e.contributions;return n?[...R(n.commands),...R(n.command_handlers),...R(n.command_overrides),...R(n.flag_commands),...R(n.parser_overrides),...ns(n.preflight_ownership),...ns(n.renderer_ownership)]:[]}function R(e){return e??[]}function ns(e){return R(e).flatMap(t=>t.commands)}function nt(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var os=new Set(["hooks","parser","preflight","renderers"]),as=new Set(["commands","schema","services","importers"]),Vd=new Set(["reindex","search","search-advanced"]),Kd=new Set(["--template"]);function Pe(e,t){for(let n of t)if(e.has(n))return!0;return!1}function _o(e){let t=_(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return Vd.has(n??t)}function wo(e,t){for(let n of e.commandArgs??[]){if(!n.startsWith("--"))continue;let[o]=n.split("=",1);if(t.has(o))return!0}return!1}function jt(e){return _(e.commandPath??"")==="create"&&wo(e,Kd)}function vo(e){return e.some(t=>{let n=_(t);return n==="templates"||n.startsWith("templates ")})}function Lt(e,t){return e.some(n=>yo(n,t))||jt(t)&&vo(e)}function bo(e){return[R(e.hooks).length,(e.preflight_overrides??0)-R(e.preflight_ownership).length,R(e.item_types).length,R(e.item_fields).length,R(e.relationship_kinds).length,R(e.service_overrides).length,R(e.assurance_providers).length,R(e.renderer_overrides).length-R(e.renderer_ownership).length].some(t=>t>0)}function Co(e,t){let n=e.activation?.commands??[];if(n.length>0)return Lt(n,t);let o=Ft(e);if(Lt(o,t)||nt(e).has("search")&&_o(t.commandPath))return!0;if(e.contributions)return bo(e.contributions)}function Ut(e,t){let n=Co(e,t);if(n!==void 0)return n;let o=nt(e);return!!(Pe(o,os)||Pe(o,as))}function ot(e,t){return e.effective.length===0?!1:at(t)!=="all"?e.effective.some(n=>Ut(n,t)):e.effective.some(n=>{let o=nt(n);return Ft(n).length>0||Pe(o,os)||Pe(o,as)||o.has("search")})}function at(e){if(_(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=$e(e).filter(o=>o.split(" ").every(a=>!a.startsWith("-"))).sort((o,a)=>a.length-o.length)[0]??_(e.commandPath??"");if(t.length===0)return"all";let n=jt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function xo(e){return at(e)==="all"?void 0:t=>Ut(t,e)}function De(e){let t=A(e);if(t.requested&&t.commandPathTokens.length>0){let[a,...i]=t.commandPathTokens;return{commandPath:a,commandArgs:i,allowCommandPrefixMatch:!0}}let n=N(e),o=n.findIndex(a=>a.trim().length>0&&!a.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function ko(e){let t=e.args.map(String);if(_(E(e))==="create"){let n=e.optsWithGlobals();typeof n.template=="string"&&n.template.trim().length>0&&t.push("--template")}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]="298624a5-da1b-53ca-aefb-19fbc3fa0401")}catch{}})();var qt=Symbol.for("pm.readOutputInvocationProvenance");function se(e,t){let n=Reflect.get(e,qt);n!==void 0&&Reflect.set(t,qt,n)}function Eo(e,t,n){let o=La(t,n);if(!o)return;let a=e;for(;a.parent;)a=a.parent;let i=a.rawArgs,r=new Set(Z(i.slice(2))),s=Na.find(d=>d.command===o),l=Object.values(s?.dimensions??{}).flatMap(d=>d.legacy_aliases.flatMap(m=>r.has(m.flag)?[m.flag]:[])),c=Reflect.get(n,qt);Reflect.set(n,qt,{canonical_include_modes:c?.canonical_include_modes??[],explicit_legacy_aliases:l,cli_invocation_observed:!0}),se(n,e)}function Jd(e){let t=e.optsWithGlobals(),n=E(e);if($(n)===n)return t;let o=e.opts();for(let a=e.parent;a?.parent;a=a.parent)for(let i of a.options){let r=i.attributeName(),s=a.getOptionValueSource(r)==="cli";if(s&&!e.options.some(l=>l.long===i.long))throw new x(`Unknown option '${i.long}' for ${n}`,g.USAGE,{code:"unknown_option",flag:i.long,required:`Use options declared by pm ${n} --help.`});if(s&&e.getOptionValueSource(r)!=="cli"){let l=a.getOptionValue(r);e.setOptionValueWithSource(r,l,"cli")}r in o?t[r]=o[r]:delete t[r]}return t}function So(e,t,n,o){Eo(e,t,o);let a=n.outputInclude;if(a===void 0)return;let{selectors:i,modes:r}=Ua(t,a,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),r.length===0)return;se(o,e);let s=ja(t);for(let c of r){let d=s.get(c),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let l=i.length>0?i.join(","):void 0;l===void 0?delete n.outputInclude:n.outputInclude=l;for(let c=e;c;c=c.parent)c.setOptionValueWithSource("outputInclude",l,"cli");kt(e,n)}function Me(e,t,n=[]){let o={...Jd(e)};se(e,o),delete o.json,delete o.quiet,delete o.path,delete o.pmPath,delete o.noExtensions,delete o.extensions,delete o.profile,delete o.pager,delete o.changedFields,delete o.fullChangedFields,delete o.idOnly,delete o.lean,delete o.tokenAccounting,delete o.outputInclude,delete o.outputLimit,delete o.outputBudget,delete o.outputFormat,delete o.outputSession;let a=zr(t);for(let[i,r]of Object.entries(a))o[i]===void 0&&(o[i]=r);if(n.length>0){let i=Fr(n),r=ae(E(e)).map(c=>({long:c.flag,short:c.short,aliases:c.aliases})),s={...a};for(let c of i)o[c]!==void 0&&(s[c]=o[c]);ro(s,[...r,...n],E(e));let l=Hr(o,n,a,E(e));return se(o,l),l}return o}function Ht(e,t){let n=_(t);return n.length===0?[]:e.flags.filter(o=>$(_(o.target_command))===$(n)).flatMap(o=>o.flags)}function it(e,t,n){let o=Ht(e,t),a=[t],i=[];for(let r of n){if(r.startsWith("-"))break;a.push(r);let s=Ht(e,a.join(" "));s.length>0&&(i=s)}return i.length>0?i:o}function zt(e){return e.arguments??[]}function is(e){let t=zt(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function Ao(e,t){if(!e)return!1;let n=_(t);return e.importers.some(o=>_(`${o.importer} import`)===n)||e.exporters.some(o=>_(`${o.exporter} export`)===n)}function To(e,t){let n=zt(e),o=n.filter(s=>s.required).length,a=n.some(s=>s.variadic)?Number.POSITIVE_INFINITY:n.length,i=e.failure_hints??[],r=i.length>0?` ${i.join(" ")}`:"";if(t.length<o)throw new x(`Missing required argument for extension command '${e.command}'. Usage: ${is(e)}${r}`,g.USAGE);if(t.length>a){let s=t.slice(a).join(" ");throw new x(`Too many arguments for extension command '${e.command}': ${s}. Usage: ${is(e)}${r}`,g.USAGE)}}function Yd(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function Xd(e,t,n){if(n.length>0){ro(t,n,e.command);return}let o=Object.keys(t).filter(a=>t[a]!==void 0).sort();if(o.length!==0)throw new x(`Unknown option '${o.map(Yd).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,g.USAGE)}function Oo(e,t,n,o){e&&(To(e,t),Xd(e,n,o))}import{Command as rs}from"commander";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="0503f6e5-36d9-5afb-a17f-feef2241f984")}catch{}})();var Zd=new Set(["--version","-V"]);function rt(e){let t=N(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function ss(e){if(N(e)[0]!=="item"||!e.includes("--dry-run"))return;let t=new rs().configureOutput({writeErr:()=>{}}).exitOverride(),n=new Set;for(let a of We)for(let i of[a.flag,a.short,...a.aliases??[]]){if(i===void 0||n.has(i))continue;n.add(i);let r=a.value_name!==void 0||a.flag==="--pm-path";t.option(`${i}${r?" <value>":""}`)}try{t.parseOptions(e)}catch{}let o=t.opts();return{path:o.pmPath??o.path}}var Qd=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),Ro=new Set(["activity","aggregate","context","ctx","events","get","graph","history","list","list-all","list-blocked","list-canceled","list-closed","list-draft","list-in-progress","list-open","search"]),ls=new Set(["append","close","close-many","comments","delete","deps","discover","docs","files","history-repair","history-redact","history-compact","learnings","notes","plan","restore","update","update-many","create"]),em=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),tm=new Set(["claim","close-task","pause-task","release","start-task","test"]),_e={setup:!0,listQuery:!0,mutation:!0,operation:!0},nm=new Set(["create","update","update-many","list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled","search","calendar","context","templates"]);function st(e){return e.some(t=>Zd.has(t))}function om(e,t){if(!P.some(o=>o.canonical_argv[0]===t))return;let n=new rs().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of vi(t,ae(t))){let a=o.takes_value?o.value_required?" <value>":" [value]":"";for(let i of[o.flag,o.short,...o.aliases??[]])i!==void 0&&n.option(`${i}${a}`)}try{let o=n.parseOptions(e.slice(1));if(o.unknown.length>0)return _e;let a=G([t,...o.operands])?.alias;if(P.some(i=>i.alias===a))return{..._e,targetCommandName:a}}catch{return _e}}function Io(e){if(st(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||A(e).requested)return _e;let t=k(e);if(!t)return _e;let n=t.trim().toLowerCase(),o=N(e),a=G(o)?.alias;return P.some(i=>i.alias===a)?{..._e,targetCommandName:a}:om(o,n==="ctx"?"context":n)||(Qd.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:Ro.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:ls.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:em.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:_e)}function Po(e){return e.length===0||A(e).requested||e.includes("--explain")&&k(e)===void 0}function $o(e,t){return rt(t)||st(t)?!1:ie(t)||A(t).requested?!0:!!k(t)}function Do(e){if(st(e))return!1;let t=k(e);return t?nm.has(t):!1}function am(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,a=e.normalizedTokens.map(c=>{let d=c.indexOf("=");return d>=0?c.slice(0,d):c}).find(c=>c==="--literal"||c==="--regex"||c==="--replacement"),i=a?e.argv.map(c=>{let d=c.indexOf("=");return(d>=0?c.slice(0,d):c)===o?d>=0?`${a}${c.slice(d)}`:a:c}):e.argv,r=je(i),s=a&&n>=0?`${o}=[redacted]`:t,l=a&&e.normalizedDisplay.includes("=")?`${a}=[redacted]`:e.normalizedDisplay;return{argv:r,normalizedDisplay:l,sourceDisplay:s}}function Mo(e){let t=e.commandName;if(!t)return;let n=e.trace.find(c=>c.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(c=>c.length>0),a=o.length>0?o.join(" "):"the canonical flag",i=ls.has(t)||tm.has(t),r=i?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=i?"mutating option":"option",l=am({argv:e.argv,normalizedDisplay:a,normalizedTokens:o,rawFrom:n.from});throw new x(`Refusing to auto-correct ${s} ${l.sourceDisplay} to ${l.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,g.USAGE,{code:r,examples:[w(l.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:l.argv,suggested_retry:w(l.argv)}})}(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]="6d83c356-db56-5116-9fe7-e0c27973b36f")}catch{}})();var im=new Set(["success","nonexistent_command","invalid_option","missing_required_option","missing_required_argument","invalid_usage","validation_failed","health_findings","validation_findings","conflict","runtime_failed","unknown_failed"]),rm=new Set(["parse","preflight","execute","unknown"]),sm=new Set(["usage","validation","conflict","runtime","unknown"]);function we(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let a=o.trim();if(a.length>0)return a}}}function No(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function Gt(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="number"&&Number.isFinite(o))return Math.max(0,Math.trunc(o))}}function Lo(e){if(!e)return;let t=e.trim().toLowerCase();if(im.has(t))return t}function Fo(e){if(!e)return;let t=e.trim().toLowerCase();if(rm.has(t))return t}function jo(e){if(!e)return;let t=e.trim().toLowerCase();if(sm.has(t))return t}function Uo(e){let t=we(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let i=n.find(r=>typeof r=="string"&&r.trim().length>0);if(typeof i=="string")return i.trim()}if(No(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let o=Gt(e,"failed");if(typeof o=="number"&&o>0)return`failed_runs:${o}`;let a=e?.run_results;if(Array.isArray(a)){let i=a.filter(r=>nn(r)?.status==="failed").length;if(i>0)return`failed_runs:${i}`}}function qo(e,t){if(!e)return t===g.USAGE?"invalid_command_usage":t===g.NOT_FOUND?"item_not_found":t===g.CONFLICT?"lock_conflict":t===g.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function Ho(){let e=nn(de()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=Gt(e,"exit_code","exitCode"),o=t??n??g.SUCCESS,a=ki(o),i=we(e,"error_code","errorCode")??qo(a,o),r=jo(we(e,"error_category","errorCategory"))??(a?void 0:mt(i)),s=a?void 0:Uo(e)??`command_exit_${o}`,l=Lo(we(e,"command_resolution","commandResolution"))??vt({ok:a,errorCode:i,errorCategory:r}),c=Fo(we(e,"resolution_stage","resolutionStage"))??"execute";return{ok:a,error:s,exit_code:o,error_code:i,error_category:r,command_resolution:l,resolution_stage:c}}(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]="b14d6057-de6b-5844-aee9-201364902f93")}catch{}})();var zo="PM_CLI_PACKAGE_ROOT",hs=Symbol("pm.deprecatedAliasInvocation"),Vt=new Map;for(let e of B){let t=e.alias.split(" ")[0],n=Vt.get(t)??[];n.push(e),Vt.set(t,n)}for(let e of Vt.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function lm(){return fa(import.meta.url,["../.."])}(typeof process.env[zo]!="string"||process.env[zo]?.trim().length===0)&&(process.env[zo]=lm());var be=null,F=null,Kt=null;function cm(e){be=e}function dm(e){T=e}var lt=null,ve=null,T=new Map,Yo=250,mm=new Set([g.USAGE,g.NOT_FOUND,g.CONFLICT]),pm=new Set(["1","true","yes","on"]),um=ze(()=>import("./chunks/register-setup-MZN6ONB3.js")),fm=ze(()=>import("./chunks/register-list-query-MVDL5EXG.js")),gm=ze(()=>import("./chunks/register-mutation-GAF7LXRB.js")),hm=ze(()=>import("./chunks/register-operations-JLFRL36Q.js"));function Bt(e){return w(e)}function ys(e){let t=e.match(/--[a-zA-Z0-9][a-zA-Z0-9_-]*/g);if(!t||t.length===0)return;let n=[...new Set(t.map(o=>pe(o)??o))];return n.length>0?n:void 0}function ym(e,t,n){if(n?.suggested_retry||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let o=Z(t),a=new Set(o.map(d=>pe(d)??d)),i=ys(e),r=t.find(d=>y.commands.some(m=>m.name()===d)),s=r?y.commands.find(d=>d.name()===r):void 0,l=new Set([...y.options,...s?.options??[]].flatMap(d=>d.flags.split(/[ ,|]+/).map(m=>pe(m)).filter(m=>m!==void 0))),c=i?.filter(d=>{let m=pe(d)??d;return a.has(m)?!1:l.has(m)||Xn(t,r,m,T)!==void 0});return c&&c.length>0?c:void 0}function _m(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let a=n?.[0],i=a?pe(a):void 0,r=e.find(p=>y.commands.some(u=>u.name()===p)),s=r?y.commands.find(p=>p.name()===r):void 0,l=i?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(i)):void 0,c=Xn(e,r,i,T),d=i?l?.isBoolean()===!0||c===!1?[i]:[i,"<value>"]:[],m=i?Bt([...e,...d]):t;return m===t?void 0:m}function wm(e){if(!e)return{};let t=["recovery_mode","missing_required_fields","suggested_flags","suggested_retry_args","allowed_values","candidate_commands","candidate_commands_total","candidate_commands_truncated","fallback_candidates","next_best_command"],n={};for(let o of t){let a=e[o];a!=null&&(n[o]=a)}return n}function vm(e){let t=e.existingRecovery;return{attempted_command:t?.attempted_command??e.attemptedCommand,normalized_args:t?.normalized_args??[...e.invocationArgv],provided_fields:t?.provided_fields??(e.providedFields.length>0?e.providedFields:void 0),missing:t?.missing??e.inferredMissing,...wm(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function _s(e,t,n){let o=je(t),a=N(o),i=Y(a),[r,s]=i===void 0?[]:a.slice(i,i+2),l=o.includes("--explain"),c=qi(o,e?.code,e?.recovery),d=c&&(r==="history-redact"||r==="history"&&s==="redact")?{...c,...c.attempted_command?{attempted_command:Bt(o)}:{},...c.normalized_args?{normalized_args:[...o]}:{},...c.suggested_retry?{suggested_retry:Bt(o)}:{},...c.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:c;if(d?.recovery_mode==="compact"&&!l)return{...e,recovery:d};let m=Bt(o),p=Z(o),u=ym(n,o,d),f=_m(o,m,u,d),h=vm({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:f,existingRecovery:d});return{...e,recovery:h}}async function ct(e){let t=F;F=null,await Hi(t,e);let n=be;if(be=null,!n){gt();return}let o=[],a=Aa();try{await zi({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?a?.map(i=>i.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await _a(n.hooks,{command:n.commandName,args:n.commandArgs,options:{...n.commandOptions},global:{...n.globalOptions},pm_root:n.pmRoot,ok:e.ok,error:e.error,result:de(),affected:a}))}catch(i){o=[`afterCommand hooks failed: ${i instanceof Error?i.message:String(i)}`]}finally{gt()}!n.globalOptions.json&&o.length>0&&v(`[pm] warning: afterCommand hook_warnings=${q(o)}`),n.profileEnabled&&o.length>0&&v(`profile:extensions hook_warnings=${q(o)}`)}async function ws(e,t){await Ja();let n=F,o=be,a=n?.command??o?.commandName??e,i=n??fn(o?.globalOptions??t),r=T.get(_(a))?.source;vn(a,o?.commandArgs??[],{...o?.commandOptions,...o?.globalOptions},{source_context:i.source_context,source_context_source:i.source_context_source,pm_version:n?.pm_version??Ne,extension:r})}function vs(e){return pm.has((process.env[e]??"").trim().toLowerCase())}function bs(e){return vs("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!mm.has(Math.trunc(e))}async function Jt(e,t){return bs(e.exit_code)?(await ws(e.command,t),ei({...e,source_context:e.source_context??fn(t).source_context}),!0):!1}async function Cs(e){let t=me(e.error),n=gr(t);e.bootstrapGlobal.json?v(JSON.stringify(Je(ur(t,g.GENERIC_FAILURE)),null,2)):v(t),process.exitCode=g.GENERIC_FAILURE;let o="runtime",a="runtime_failed";try{await ws(e.attemptedCommand,e.bootstrapGlobal),bn(e.error);let i=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:g.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=i.errorCategory,a=i.commandResolution,await Zt(!1,t,{error_code:n.code,error_category:o,exit_code:g.GENERIC_FAILURE,command_resolution:a,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||v(`Failed to report error: ${me(i)}`)}try{await ct({ok:!1,error:t,exit_code:g.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:a,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||v(`Failed to run error hooks: ${me(i)}`)}try{await Ee()}catch(i){e.bootstrapGlobal.json||v(`Failed to flush error reporting: ${me(i)}`)}}var bm={create:"create",update:"update","update-many":"update_many",list:"list","list-all":"list","list-draft":"list","list-open":"list","list-in-progress":"list","list-blocked":"list","list-closed":"list","list-canceled":"list",search:"search",calendar:"calendar",context:"context","templates save":"create"},Go=new Map;function Wo(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function xs(e,t){return e.options.some(n=>n.long===t)}function ks(e,t){return e.options.some(n=>n.short===t)}function Bo(e,t,n,o){let a=t.trim();if(!a)return;let i=n.length>0?n:`Runtime schema field (${t})`;if(a.startsWith("-")&&!a.startsWith("--")){if(ks(e,a))return;if(o){e.option(`${a} <value>`,`${i} (repeatable)`,En);return}e.option(`${a} <value>`,i);return}let r=a.startsWith("--")?a:`--${a}`;if(!xs(e,r)){if(o){e.option(`${r} <value>`,`${i} (repeatable)`,En);return}e.option(`${r} <value>`,i)}}async function Es(e,t){let n=bm[e];if(!n)return[];let o=`${t}:${n}`,a=Go.get(o);if(a)return a;if(!await V(K(t)))return Go.set(o,[]),[];let i=await D(t),r=(ln(i.schema).command_to_fields.get(n)??[]).flatMap(s=>[s.cli_flag,...s.cli_aliases].map(l=>({long:`--${l}`,type:Wo(s.type),value_type:Wo(s.type)})));return Go.set(o,r),r}async function Ss(e,t){let n=M(t),o=O(process.cwd(),n.path);if(!await V(K(o)))return;let a=ve?.key===Qo(o)?ve.snapshot:null,i=a===null?await D(o):a.settings,r=ln(i.schema),s=[{path:"create",command:"create"},{path:"update",command:"update"},{path:"update-many",command:"update_many"},{path:"list",command:"list"},{path:"list-all",command:"list"},{path:"list-draft",command:"list"},{path:"list-open",command:"list"},{path:"list-in-progress",command:"list"},{path:"list-blocked",command:"list"},{path:"list-closed",command:"list"},{path:"list-canceled",command:"list"},{path:"search",command:"search"},{path:"calendar",command:"calendar"},{path:"context",command:"context"},{path:"templates save",command:"create"}];for(let l of s){let c=ee(e,l.path.split(" "));if(c)for(let d of r.command_to_fields.get(l.command)??[]){let m=d.description??"";Bo(c,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)Bo(c,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function Xo(e,t,n,o,a){let i=k(n);if(!(i!=="create"&&i!=="update"))try{let r=a??await D(t),s=le(r,o);Xr(e,s,n)}catch{}}function Vo(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function As(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function Zo(e){return e.some(t=>t==="--profile")}function Qo(e){return`pm-root:${e}`}function Ko(e){for(let t of e)t.startsWith("settings_read_")&&Ke(t,`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function Ts(e,t){e.profile&&(v(`profile:extensions loaded=${t.loadedCount} failed=${t.loadFailedCount} warnings=${t.loadWarnings.length} activation_failed=${t.activationFailedCount} hook_counts=before:${t.hooks.beforeCommand.length}|after:${t.hooks.afterCommand.length}|write:${t.hooks.onWrite.length}|read:${t.hooks.onRead.length}|index:${t.hooks.onIndex.length} command_overrides=${t.commands.overrides.length} command_handlers=${t.commands.handlers.length} parser_overrides=${t.parsers.overrides.length} preflight_overrides=${t.preflight.overrides.length} service_overrides=${t.services.overrides.length} renderer_overrides=${t.renderers.overrides.length}`),t.activationWarnings.length>0&&v(`profile:extensions activation_warnings=${q(t.activationWarnings)}`))}function Yt(e,t,n){if(!e)return;let o=_(n.commandPath??"")||"<none>";v(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function Xt(e,t=ke){let n=Qo(e);if(ve?.key===n)return ve.snapshot;try{let o=Date.now(),{settings:a,warnings:i}=await t(e),r=await wa({pmRoot:e,settings:a,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:a,discovery:r,discoveryMs:Date.now()-o,settingsReadWarnings:[...i]};return ve={key:n,snapshot:s},s}catch{return ve={key:n,snapshot:null},null}}async function Le(e,t,n=D){let o=t?at(t):"all",a=As(e,o);if(lt?.key===a)return lt.snapshot;try{let i=await n(e),r=await qe({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?xo(t):void 0}),s=await He({...r,loaded:r.loaded}),l=[...new Set(s.commands.handlers.map(u=>_(u.command)))].filter(u=>u.length>0).sort((u,f)=>u.localeCompare(f)),c=Sr(s.registrations.flags),d=kr(s.commands.handlers,s.registrations.commands),m=Tr(l,s.registrations.commands,s.registrations.flags,d),p={hooks:s.hooks,commands:s.commands,parsers:s.parsers,preflight:s.preflight,services:s.services,renderers:s.renderers,registrations:s.registrations,pmRoot:e,settings:i,commandHandlers:l,commandFlagHelp:c,commandDescriptors:m,commandAliases:d,loadWarnings:[...r.warnings],activationWarnings:[...s.warnings],loadedCount:r.loaded.length,loadFailedCount:r.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:r.loaded.map(({name:u,module:f})=>({name:u,module:f}))};return lt={key:a,snapshot:p},p}catch{return lt={key:a,snapshot:null},null}}async function Os(e){let t=Ve(e);if(t.noExtensions){let r=O(process.cwd(),t.path);return await V(K(r))&&Ko((await ke(r)).warnings),null}let n=O(process.cwd(),t.path),o=await Xt(n);if(!o)return null;Ko(o.settingsReadWarnings);let a={commandPath:E(e),commandArgs:ko(e)};if(!ot(o.discovery,a))return Yt(t.profile,o,a),null;let i=await Le(n,a);return i?(Ts(t,i),{hooks:i.hooks,commands:i.commands,parsers:i.parsers,preflight:i.preflight,services:i.services,renderers:i.renderers,registrations:i.registrations,pmRoot:n}):null}async function ea(e){let t=await Le(e);return t?new Map(t.commandDescriptors):T}async function Cm(e,t){return!e.requested||t.noExtensions||Oe(y,e.commandPathTokens)?T:ea(O(process.cwd(),t.path))}async function Rs(e,t){return(await ci({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(n=>n.outcome==="failed").map(n=>`extension_migration_failed:${n.layer}:${n.extension}:${n.id}`)}function Is(e,t,n){let o=t.author;return li(e,Ti.forActiveExtensionHost({pmRoot:e,author:o}),o,_(n))}async function Ps(e,t,n,o=[]){let a=E(e),i=mo(e.args.map(String),o),r={...t};delete r.author;let s={...n},l=O(process.cwd(),n.path),c=await ht({command:a,args:i,options:r,global:s,pm_root:l});n.profile&&c.warnings.length>0&&v(`profile:extensions parser_warnings=${q(c.warnings)}`),i=c.context.args,r=c.context.options,s=c.context.global,Oo(T.get(_(a)),i,r,o),xe(void 0),ft({command:a,args:i,options:{...r},global:{...s},pm_root:l});let d=await sn({command:a,args:i,options:r,global:s,pm_root:l,sdk:Is(l,s,a)});if(s.profile&&d.warnings.length>0&&v(`profile:extensions command_handler_warnings=${q(d.warnings)}`),!d.handled)throw d.warnings.length>0?Ya(a,d):new x(`Command "${a}" is provided by extensions and is not currently available.`,g.NOT_FOUND);return d.exitCode!==void 0&&(process.exitCode=d.exitCode),xe(d.result),d.result}var cs=Symbol("pm.wrappedActionHandler");function xm(e,t){let n=e[e.length-1];return n instanceof Jo?n:t}function ds(e,t,n){e&&n.length>0&&v(`profile:extensions ${t}=${q(n)}`)}function km(e){let t=T.get(_(e.commandPath));if(!t||!Ao(e.activeRegistrations,e.commandPath))return;let n=zt(t).length===0?Gr(e.commandArgs):mo(e.commandArgs,e.extensionFlagDefinitions);To(t,n)}function Em(e,t,n){e.args=[...n],"_processArguments"in e&&typeof e._processArguments=="function"&&e._processArguments(),t.length>0&&Array.isArray(t[0])&&(t[0]=[...e.processedArgs])}function $s(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[cs]!==!0){let a=o._actionHandler;o._actionHandler=async function(...i){let r=xm(i,n),s=Date.now();kn(r);let l=Ve(r),c=$(E(r));if(["package inventory","packages inventory","extension inventory"].includes(c))return await a.apply(this,i);let d=O(process.cwd(),l.path),m=r.args.map(String),p=ce(),u=p?it(p,c,m):[],f=await Es(c,d),h=Me(r,m,[...u,...f]);T.has(_(c))&&delete h.author;let b=await ht({command:c,args:m,options:h,global:l,pm_root:d});ds(l.profile,"parser_warnings",b.warnings),m=b.context.args,h=b.context.options,se(r,h),l=b.context.global,km({activeRegistrations:p,commandPath:c,commandArgs:m,extensionFlagDefinitions:u}),l=await _i(l),kt(r,l),Em(r,i,m),xt(r,h),xe(void 0),ft({command:c,args:m,options:{...h},global:{...l},pm_root:d});let S=await sn({command:c,args:m,options:h,global:l,pm_root:d,sdk:Is(d,l,c)});if(ds(l.profile,"command_handler_warnings",S.warnings),S.handled){xe(S.result),un(S.result,{...l,command:c,commandArgs:m,commandOptions:h,pmRoot:d}),l.profile&&v(`profile:command=${c} took_ms=${Date.now()-s}`);return}return await a.apply(this,i)},o[cs]=!0}for(let a of n.commands)t(a)};t(e)}async function Wt(e){T=new Map,ne({overrides:[]}),e&&await Xo(e.rootProgram,e.pmRoot,e.invocationArgv,ha(),e.settings)}function Sm(e,t,n,o){if(t?.flags&&t.flags.length>0){eo(e,t.flags);let a=to(e,t.flags);a&&e.addHelpText("after",a)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function Ds(e,t,n){let o={core:0,standard:1,full:2,internal:3},a=(i,r)=>{let s=r.join(" "),l=[...n.entries()].filter(([d])=>d===s||d.startsWith(`${s} `)).map(([,d])=>d),c=l.length===0?"standard":l.reduce((d,m)=>o[m.tier]<o[d]?m.tier:d,"internal");At(i,c);for(let d of i.commands)a(d,[...r,d.name()])};for(let i of e.commands)t.has(i.name())||a(i,[i.name()])}async function Ms(e,t){let n=M(t),o=O(process.cwd(),n.path);if(n.noExtensions){await Wt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let a=await Xt(o),i=De(t);if(!a){await Wt();return}if(!ot(a.discovery,i)){await Wt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings}),Yt(Zo(t),a,i);return}let r=await Le(o,i);if(!r){await Wt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings});return}ne(r.services),T=new Map(r.commandDescriptors),await Xo(e,o,t,r.registrations,r.settings);let s=Mr(e,r.commandHandlers,r.commandDescriptors,r.commandAliases,d=>Nr(r.activationWarnings,v,d)),l=new Set(e.commands.map(d=>d.name())),c=d=>{let m=d.split(" ").filter(I=>I.length>0),p=r.commandDescriptors.get(d),u=ee(e,m),f=r.commandFlagHelp.get(d),h=p?$r(p):null;if(u){Sm(u,p,f,h);return}let b=Dr(e,m);p?.description&&b.description(p.description);let S=f;p&&(Or(b,p),p.flags.length>0&&(eo(b,p.flags),S=to(b,p.flags)??void 0)),S&&b.addHelpText("after",S),h&&b.addHelpText("after",h),b.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...I)=>{let z=I[I.length-1],U=z instanceof Jo?z:b,dt=Ve(U),Vs=Date.now(),oa=it(r.registrations,d,U.args.map(String)),aa=Me(U,U.args.map(String),oa),ia=await Ps(U,aa,dt,oa);await wi(dt,ia),un(ia,{...dt,command:d,commandArgs:U.args.map(String),commandOptions:aa,pmRoot:o}),dt.profile&&v(`profile:command=${d} took_ms=${Date.now()-Vs}`)})};for(let d of s)c(d);Ds(e,l,r.commandDescriptors)}var Ne=ga(import.meta.url,["../.."])??"0.0.0",y=xn(Ne);async function ms(e){if(!F)return;let t=Reflect.get(e,hs);typeof t=="string"&&await Ai(t)}async function ps(e,t,n){let o=E(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}async function us(e,t,n){!F||!await gn(!0)||(vn(e,t,n,{source_context:F.source_context,source_context_source:F.source_context_source}),Xa(e),Kt=F)}async function Zt(e,t,n){let o=Kt;if(!o)return;Kt=null;let a=!1;try{let i=await D(o.global_pm_root);a=i.telemetry.enabled&&i.telemetry.installation_id===o.installation_id}catch{}await gn(a)?Qa(e,t,n):Za()}async function Am(e){let t=await Os(e);return rn(t?.registrations??null),t}function Ns(e,t){t&&rt(t)||(e.hook("preAction",async(n,o)=>{be=null,F=null,Kt=null,gt(),kn(o);let a=o.optsWithGlobals(),i=Ve(o),r=$(E(o)),s=o.args.map(String),l=Me(o,s),c={...i},d=O(process.cwd(),i.path),m=await Am(o);if(Fa(r,{...l,outputInclude:a.outputInclude,outputLimit:a.outputLimit,outputBudget:a.outputBudget,outputFormat:a.outputFormat,outputSession:a.outputSession,outputCursor:a.outputCursor}),So(o,r,c,l),await ps(o,void 0,()=>ai(r,c)),!m){be=va({commandName:r,commandArgs:s,commandOptions:l,globalOptions:c,pmRoot:d}),F=await Cn({command:r,pm_version:Ne,args:s,options:l,global:c,pm_root:d}),await ms(e),await us(r,s,l),await go(r,l,d,Vo()),await fo(r,s,l,c,d);return}ba(m.hooks),Ca(m.commands),xa(m.parsers),ka(m.preflight),ne(m.services),Ea(m.renderers),rn(m.registrations);let p=it(m.registrations,r,s);l=Me(o,s,p),So(o,r,c,l);let u=await ht({command:r,args:s,options:l,global:c,pm_root:m.pmRoot});c.profile&&u.warnings.length>0&&v(`profile:extensions parser_warnings=${q(u.warnings)}`),s=u.context.args,l=u.context.options,se(o,l),c=u.context.global,xt(o,l);let f=await Ta({command:r,args:s,options:l,global:c,pm_root:m.pmRoot,decision:Vo()});c.profile&&f.warnings.length>0&&v(`profile:extensions preflight_warnings=${q(f.warnings)}`),s=f.context.args,l=f.context.options,se(o,l),c=f.context.global,xt(o,l);let h=f.decision;await go(r,l,m.pmRoot,h),await fo(r,s,l,c,m.pmRoot);let b=h.run_extension_migrations?await ps(o,[],()=>Rs(m.registrations.migrations,m.pmRoot)):[];c.profile&&b.length>0&&v(`profile:extensions migration_warnings=${q(b)}`);let S=es(m.registrations.migrations);be={hooks:m.hooks,commandName:r,commandArgs:s,commandOptions:{...l},globalOptions:{...c},pmRoot:m.pmRoot,profileEnabled:!!c.profile,migrationBlockers:S},xe(void 0),ft({command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot}),F=await Cn({command:r,pm_version:Ne,args:s,options:l,global:c,pm_root:m.pmRoot}),await ms(e),await us(r,s,l);let I=await ya(m.hooks,{command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot});c.profile&&I.length>0&&v(`profile:extensions hook_warnings=${q(I)}`),h.enforce_mandatory_migration_gate&&ts(r,l,S)}),e.hook("postAction",async()=>{let n=Ho();await Zt(n.ok,n.error,{error_code:n.error_code,error_category:n.error_category,exit_code:n.exit_code,command_resolution:n.command_resolution,resolution_stage:n.resolution_stage}),await ct(n),await Ee()}))}Ns(y);var fs=Symbol("pmCliIdempotentTopLevelRegistration");function Ls(e){let t=e;if(t[fs])return;t[fs]=!0;let n=e.command.bind(e);e.command=((o,...a)=>{let i=o.split(/\s+/u)[0];return e.commands.some(r=>r.name()===i||r.aliases().includes(i))?new Jo(i):n(o,...a)})}async function Tm(e,t){if(Ls(e),t.setup){let{registerSetupCommands:n}=await um();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await fm(),o=typeof t.targetCommandName=="string"&&Ro.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await gm();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await hm();n(e)}}function Om(e){return async t=>{let n=mt(t.errorCode),o=vt({ok:!1,errorCode:t.errorCode,errorCategory:n});return await ri({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:Ne,pm_root:e.bootstrapPmRoot,error_code:t.errorCode,error_message:t.errorMessage,exit_code:t.exitCode,error_category:n,command_resolution:o,resolution_stage:t.resolutionStage}),{errorCategory:n,commandResolution:o}}}async function Fs(e){if(e.bootstrapGlobal.noExtensions||rt(e.invocationArgv))return;let t=De(e.invocationArgv),n=await Xt(e.bootstrapPmRoot);if(n&&ot(n.discovery,t)){let o=await Le(e.bootstrapPmRoot,t);js(o);return}n&&Yt(Zo(e.invocationArgv),n,t),ne({overrides:[]})}function js(e){if(!e){ne({overrides:[]});return}ne(e.services)}async function ta(e){await Zt(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await ct({ok:!1,error:e.errorMessage,exit_code:e.exitCode,error_code:e.classificationCode,error_category:e.errorCategory,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage})}async function Us(){await Zt(!0,void 0,{exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await ct({ok:!0,exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=g.SUCCESS}async function qs(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof x)&&(_n(e.error)||!n))return!1;let o=me(e.error),a=e.error instanceof x?e.error.exitCode:yn(t),i=e.error instanceof x||Ka(e.error)?e.error.context:void 0,r=_s(i,e.invocationArgv,o),s=mr(o,r),l=Je(e.bootstrapGlobal.lean?Rt(zn(o,a,r)):zn(o,a,r)),c=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?J(l,u=>`${JSON.stringify(u,null,2)}
|
|
38
|
+
`):l,null,2):cr(o,r,{lean:e.bootstrapGlobal.lean===!0});e.jsonErrors?oe(`${c}
|
|
39
|
+
`):v(c);let{errorCategory:d,commandResolution:m}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:s.code,errorMessage:s.detail,exitCode:a,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"}),p=await Jt({command:e.attemptedCommand,error_code:s.code,error_category:d,exit_code:a,error_message:s.detail,command_resolution:m,resolution_stage:"execute",source_context:F?.source_context},e.bootstrapGlobal);return await ta({errorMessage:o,exitCode:a,classificationCode:s.code,errorCategory:d,commandResolution:m,resolutionStage:"execute"}),p&&(bn(wn(e.error,o)),await Ee(Yo)),process.exitCode=a,!0}async function Hs(e,t){let n=A(e.invocationArgv).commandPathTokens.join(" ")||Bn(e.invocationArgv),o=$(n),a=`unknown command '${n}'`,i=O(process.cwd(),e.bootstrapGlobal.path),r=e.bootstrapGlobal.noExtensions?T:await ea(i),s=De(e.invocationArgv),l=e.bootstrapGlobal.noExtensions?[]:await po(i,{},$e(s)),c=await Ze({message:a},y,r,{failedExtensions:l},e.invocationArgv),d=Gn(c.message,c.commandName,c.allowedTypes,{unknownCommandExamples:c.unknownCommandExamples,unknownCommandNextSteps:c.unknownCommandNextSteps,attemptedCommand:c.attemptedCommand,normalizedInvocationArgs:c.normalizedInvocationArgs,providedOptionFlags:c.providedOptionFlags,unknownOptionSuggestions:c.unknownOptionSuggestions,suggestedRetryCommand:c.suggestedRetryCommand,failedExtensions:l}),{errorCategory:m,commandResolution:p}=await e.emitTelemetryCommandError({command:o,errorCode:d.code,errorMessage:d.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),u=await Jt({command:o,error_code:d.code,error_category:m,exit_code:g.USAGE,error_message:d.detail,command_resolution:p,resolution_stage:"parse"},e.bootstrapGlobal),f=e.jsonErrors?await Yn({message:a},y,r,e.bootstrapGlobal.lean===!0,{failedExtensions:l},e.invocationArgv):await Jn({message:a},y,r,{failedExtensions:l},e.invocationArgv),h=Wn(f,e.jsonErrors,l);await ta({errorMessage:a,exitCode:g.USAGE,classificationCode:d.code,errorCategory:m,commandResolution:p,resolutionStage:"parse"}),e.jsonErrors?oe(`${Tn(h)}
|
|
40
|
+
`):v(h),u&&await Ee(Yo),process.exitCode=g.USAGE}async function zs(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let o=A(e.invocationArgv);return o.requested&&!Oe(y,o.commandPathTokens)?(await Hs(e,t),!0):(await Us(),!0)}async function Gs(e,t){let n=await Ze(e.error,y,T,{},e.invocationArgv),o=Gn(n.message,n.commandName,n.allowedTypes,{unknownCommandExamples:n.unknownCommandExamples,unknownCommandNextSteps:n.unknownCommandNextSteps,attemptedCommand:n.attemptedCommand,normalizedInvocationArgs:n.normalizedInvocationArgs,providedOptionFlags:n.providedOptionFlags,unknownOptionSuggestions:n.unknownOptionSuggestions,suggestedRetryCommand:n.suggestedRetryCommand}),{errorCategory:a,commandResolution:i}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:o.code,errorMessage:o.detail,exitCode:g.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),r=await Jt({command:e.attemptedCommand,error_code:o.code,error_category:a,exit_code:g.USAGE,error_message:o.detail,command_resolution:i,resolution_stage:"parse",source_context:F?.source_context},e.bootstrapGlobal),s=e.jsonErrors?await Yn(e.error,y,T,e.bootstrapGlobal.lean===!0,{},e.invocationArgv):await Jn(e.error,y,T,{},e.invocationArgv),l=await Wr(o.code,e.bootstrapPmRoot,{},$e(De(e.invocationArgv))),c=Wn(s,e.jsonErrors,l);await ta({errorMessage:n.message,exitCode:g.USAGE,classificationCode:o.code,errorCategory:a,commandResolution:i,resolutionStage:"parse"}),e.jsonErrors?oe(`${Tn(c)}
|
|
41
|
+
`):v(c),r&&await Ee(Yo),process.exitCode=g.USAGE}function Ws(e){if(typeof e!="object"||e===null||!("code"in e))return!1;let t=e.code;return typeof t=="string"&&(t==="commander.version"||t.startsWith("commander."))?!0:String(e.message??"").includes("(outputHelp)")}async function Bs(e){let t=e.error.code,n=String(e.error.message??"");if(!await zs(e,t,n)){if(t==="commander.version"){await Us();return}await Gs(e,t)}}async function na(e){let t=M(e.invocationArgv),n=O(process.cwd(),t.path),o={error:e.error,invocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:k(e.invocationArgv)??"<unknown>",emitTelemetryCommandError:Om({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await Fs({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await qs(o,hn(e.error))){if(Ws(e.error)){await Bs(o);return}await Cs({error:e.error,attemptedCommand:o.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:o.emitTelemetryCommandError})}}function Rm(e,t,n){let o=n.requested?n.commandPathTokens:N(t),a=G(o);if(a&&!ee(e,[...a.canonical_argv]))throw new gs(g.USAGE,"commander.unknownCommand",`unknown command '${a.alias}'`)}function Im(e,t){let n=Y(t);if(n===void 0)return;if(["pm","pm-cli"].includes(t[n]?.trim().toLowerCase())){let r=Y(t.slice(n+1));if(r===void 0)return;n+=r+1}let o=Vt.get(t[n]),a=t.slice(n).filter(r=>!["--global","--project","--local"].includes(r)),i=o?.find(r=>r.alias.split(" ").every((s,l)=>a[l]===s));i?.lifecycle==="deprecated"&&Reflect.set(e,hs,i.alias)}function Pm(e){return[process.argv[0],process.argv[1]??"pm",...e]}async function $m(e,t){y=xn(Ne),y.hook("preAction",(i,r)=>{t.configurationOnly=["item mutate","item complete"].includes(E(r))&&r.optsWithGlobals().dryRun===!0}),Ns(y,e),lt=null,ve=null,T=new Map,Sa();let n=[...e],o,a;try{let i=Be(e);n=i.argv,Im(y,e);let r=Pm(n),s=n.length===0,l=M(n);if(l.authorMissingValue)throw new x("--author requires a non-empty value.",g.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});o=hi(l.author),Mo(i),a=mi(n);let c=Io(n);await Tm(y,c),$n(y,!0),$o(y,n)?await Ms(y,n):(T=new Map,ne({overrides:[]})),Do(n)&&await Ss(y,n),$n(y);let d=A(n);Rm(y,n,d),Po(n)&&Ji(y,n),$s(y);let m=await Cm(d,l);if(await Yr(y,n,m,e))return;if(d.requested&&!Oe(y,d.commandPathTokens))throw new gs(g.USAGE,"commander.helpDisplayed","(outputHelp)");if(s||ie(n)&&k(n)===void 0){y.outputHelp();return}if(rt(n)){await y.parseAsync(r);return}let p=O(process.cwd(),l.path),u=await D(p),f=await Cr(n,p,l.noExtensions,Le);await si({pmRoot:p,packages:f?.contextIntentPackages},()=>Ra({env:{...process.env,PM_PATH:p},argv:r,cwd:process.cwd()},()=>Ia(u.agent_identity.harness_signals,()=>y.parseAsync(r),{probesEnabled:u.agent_identity?.probes_enabled})))}catch(i){await na({error:i,invocationArgv:n})}finally{a?.(),o?.()}}async function gf(e=process.argv.slice(2)){let t=e;try{t=Be(e).argv}catch{}let n=ss(t),o={configurationOnly:n!==void 0},a=()=>o.configurationOnly,i=()=>ji(M(t).json,async()=>{try{await yi(process.env,()=>$m(e,o))}catch(r){await na({error:r,invocationArgv:[...e]})}});if(n!==void 0){let r=O(process.cwd(),M(t).path),s=O(process.cwd(),n.path),l=da(process.cwd());await _t(r,()=>_t(s,()=>_t(l,i,a),a),a)}else await i()}var hf={activationCommandMatchesProbe:yo,applyDynamicExtensionRootHelpVisibility:Ds,bootstrapProfileEnabled:Zo,buildBootstrapActivationProbe:De,buildPostActionTelemetryOutcome:Ho,buildPmCliRecoveryContext:_s,buildRuntimeExtensionDiscoverySnapshotCacheKey:Qo,buildRuntimeExtensionActivationScope:at,buildRuntimeExtensionSnapshotCacheKey:As,buildRuntimeExtensionFilterForProbe:xo,addRuntimeFieldOption:Bo,collectActivationCommandCandidates:$e,collectExtensionFlagDefinitionsForCommand:Ht,collectExtensionFlagDefinitionsForInvocation:it,collectLeadingCommandArgs:ho,collectParsedActivationCommandArgs:ko,collectRuntimeFieldLooseFlagDefinitionsForCommand:Es,commandHasLongOption:xs,commandHasShortOption:ks,commandPathNeedsSearchExtensions:_o,commandPathNeedsTemplateExtensions:jt,describeUnknownError:me,defaultPreflightDecision:Vo,discoveryNeedsActivationForProbe:ot,emitExtensionProfile:Ts,emitExtensionSkippedProfile:Yt,emitSettingsReadWarnings:Ko,ensureIdempotentTopLevelCommandRegistration:Ls,enforceExplicitRetryForFlagTypos:Mo,envFlagEnabled:vs,executeRegisteredRuntimeMigrations:Rs,extractCommandScopedOptions:Me,extensionActivationCommands:Ft,extensionCapabilities:nt,extensionNeedsActivationForProbe:Ut,extensionProvidesTemplatesRuntime:vo,hasAnyCapability:Pe,hasGlobalExtensionContributions:bo,handleGenericRunPmCliError:Cs,handleRunPmCliCommanderError:Bs,handleRunPmCliError:na,handleRunPmCliHelpDisplayError:zs,handleRunPmCliKnownError:qs,handleRunPmCliCommanderUsageError:Gs,handleUnknownHelpCommandError:Hs,inferMissingFieldsFromErrorMessage:ys,inferPostActionErrorCode:qo,inferPostActionFailureMessage:Uo,invocationRequestsVersion:st,isCommanderError:_n,loadRuntimeExtensionCommandDescriptorsForRecovery:ea,loadRuntimeExtensionDiscoverySnapshot:Xt,loadRuntimeExtensionSnapshot:Le,maybeLoadRuntimeExtensions:Os,maybeAttachCreateUpdatePolicyHelpText:Xo,maybeLogHandledCliErrorToSentry:Jt,matchesStaticExtensionCommand:Lt,normalizeTelemetryCommandResolution:Lo,normalizeTelemetryErrorCategory:jo,normalizeTelemetryResolutionStage:Fo,normalizeThrownExitCode:yn,probeUsesAnyFlag:wo,prepareExtensionServicesForRunPmCliError:Fs,readRecordBoolean:No,readRecordNumber:Gt,readRecordString:we,recordCliReadOutputInvocationProvenance:Eo,registerDynamicExtensionCommandPaths:Ms,registerRuntimeSchemaFieldFlags:Ss,resolveCoreCommandRegistrationSelection:Io,resolveStaticExtensionActivationDecision:Co,resolveUnknownHelpToken:Bn,readThrownExitCode:hn,runAndClearAfterCommandHooks:ct,runRequiredExtensionCommand:Ps,shouldAttachRichHelpTextForInvocation:Po,shouldLogHandledErrorToSentry:bs,shouldRegisterDynamicExtensionPaths:$o,shouldRegisterRuntimeSchemaFlags:Do,shouldHandleRunPmCliCommanderError:Ws,setActiveExtensionHookContextForTest:cm,setActiveRuntimeExtensionCommandDescriptorsForTest:dm,setRecoveredExtensionServices:js,toLooseFieldDefinitionType:Wo,isImporterOrExporterCommandPath:Ao,validateDynamicExtensionCommandInvocation:Oo,wrapProgramActionsForExtensionHandlers:$s,wrapThrownErrorForSentry:wn};export{hf as _testOnly,gf as runPmCli};
|
|
38
42
|
//# sourceMappingURL=main.js.map
|