@unbrained/pm-cli 2026.10.11 → 2026.10.12
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 +18 -0
- package/dist/cli/commander-usage.d.ts +5 -5
- package/dist/cli/commander-usage.js +3 -3
- package/dist/cli/error-guidance.d.ts +2 -0
- package/dist/cli/error-guidance.js +2 -2
- package/dist/cli/help-json-payload.js +1 -1
- package/dist/cli/main.d.ts +1 -0
- package/dist/cli/main.js +4 -4
- package/dist/cli/register-operations.d.ts +9 -4
- package/dist/cli/register-operations.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-2JYTSTQP.js → chunk-3LQTJN4J.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YMLF6QT7.js → chunk-6PZPUJW3.js} +28 -28
- package/dist/cli-bundle/chunks/{chunk-RUT3CCAG.js → chunk-B465HPS5.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ESRACL6K.js → chunk-DT3KUUKY.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-SSY4OSJR.js → chunk-GUVKPOY6.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-ILQEZ4Y6.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-RBPOO46D.js → chunk-JRRXWH5B.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-MEWBSWE3.js → chunk-LH5QDBMN.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-KNW3RSLS.js → chunk-M5NDSW6E.js} +30 -30
- package/dist/cli-bundle/chunks/{chunk-K2UTE75T.js → chunk-MHPU2LDF.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OBLO45UM.js → chunk-QM3M7GB5.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-S445XEYT.js → chunk-UABZJXIS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-ZWRLAOA4.js → chunk-X2I2EEAS.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-T6BOR67M.js → register-list-query-OR33UEML.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-6NXR7SAJ.js → register-mutation-R34EJ3NH.js} +2 -2
- package/dist/cli-bundle/chunks/register-operations-UHSMEHSF.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-MAYFPKBX.js → register-setup-5E3PT22L.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SIEGIPNT.js → chunk-7QIZB2F2.js} +7 -7
- package/dist/cli-bundle/focused-chunks/{chunk-PLTTMQAW.js → chunk-AJG3DBXR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-AXBO53EQ.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-W5AE7GKZ.js → chunk-CYEZLKLL.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PBCYGO7X.js → chunk-FXRWJEQ5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-GVGFUD52.js → chunk-IKJFAU32.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-DMSADMEU.js → chunk-OGOLIS5R.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-PPH5N26M.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-WAOXID5J.js → chunk-RNAWRTQV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-B3YW6H2I.js → chunk-RZVNGUT7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-52UJEHEV.js → chunk-SV6YYZLR.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-EIOQNLBQ.js → chunk-TS46OZD5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KNJR2WUO.js → chunk-VBTLX5SN.js} +62 -62
- package/dist/cli-bundle/focused-chunks/{chunk-JGFSSR3G.js → chunk-YCOJLIDI.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-YDJT33JU.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-AU6VJGTY.js → chunk-Z4T3637Y.js} +2 -2
- package/dist/cli-bundle/main.js +22 -22
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +31 -31
- 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 +24 -24
- 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 +8 -8
- package/dist/core/history/event-classification.d.ts +1 -1
- package/dist/core/history/event-classification.js +1 -1
- package/dist/core/item/item-format.d.ts +2 -0
- package/dist/core/item/item-format.js +2 -2
- package/dist/core/telemetry/runtime.d.ts +1 -1
- package/dist/core/telemetry/runtime.js +2 -2
- package/dist/core/test/background-runs.d.ts +1 -0
- package/dist/core/test/background-runs.js +2 -2
- package/dist/sdk/agent/command-suggestions.d.ts +2 -0
- package/dist/sdk/agent/command-suggestions.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/registration-helpers.d.ts +1 -4
- package/dist/sdk/cli-contracts/registration-helpers.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/core.d.ts +1 -0
- package/dist/sdk/core.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/governance/artifact-ledgers.js +1 -1
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/test/batch.js +1 -1
- package/dist/sdk/test/command-args.d.ts +4 -0
- package/dist/sdk/test/command-args.js +2 -0
- package/dist/sdk/test/entry.d.ts +3 -0
- package/dist/sdk/test/entry.js +1 -1
- package/dist/sdk/test/execution.d.ts +15 -4
- package/dist/sdk/test/execution.js +2 -2
- package/dist/sdk/test/prerequisites.d.ts +6 -0
- package/dist/sdk/test/prerequisites.js +2 -0
- package/dist/sdk/test/trust.js +1 -1
- package/dist/sdk/test/update.d.ts +55 -0
- package/dist/sdk/test/update.js +2 -0
- package/dist/types.d.ts +4 -0
- package/dist/types.js +1 -1
- package/docs/LINKED_TEST_EDITS.md +79 -0
- package/docs/RELEASING.md +19 -8
- package/docs/SDK.md +178 -636
- package/docs/SDK_EVIDENCE_TRACEABILITY.md +4 -0
- package/docs/TESTING.md +13 -0
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +8 -3
- package/docs/performance/runner-qualification.md +36 -0
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- 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-BXSXT5Z6.js +0 -2
- package/dist/cli-bundle/chunks/register-operations-PDOBQZUJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2CJWTLQG.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-MJQ253F3.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-WOEZJUA2.js +0 -2
package/dist/cli-bundle/main.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{B as
|
|
2
|
-
`)}function
|
|
3
|
-
`)}function ci(e,t){return t==="detailed"?ss(e):rs(e)}function M(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var ls={cal:"calendar",ctx:"context"};function cs(e,t){return e.commands.find(n=>n.name()===t)??null}function ds(e,t){let n=e;for(let o of t){let a=cs(n,o);if(!a)return null;n=a}return n}function bn(e,t,n,o){let a=ds(e,t.split(" ").filter(i=>i.length>0));a&&a.addHelpText("after",ci(n,o))}function Cn(e){return e.includes("--explain")?"detailed":"compact"}function oe(e){return e.includes("--all")||e.includes("--explain")}var fe={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 install ./my-package --project","pm 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 extension explore --project","pm extension manage --global","pm extension describe sample-ext --project","pm extension 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 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 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 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 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 extension init ./my-extension","pm extension init ./my-hook-extension --capability hooks","pm extension init ./my-search-extension --capability search","pm extension init ./my-sync-extension --capability importers","pm extension init ./my-domain-extension --capability schema","pm extension init ./my-output-extension --capability renderers","pm extension --install --project ./my-sync-extension","pm extension --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 extension install ./my-extension --project","pm extension --install --project ./my-extension","pm extension 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 extension doctor --project --detail summary","pm extension doctor --project --detail deep --trace","pm extension 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 extension catalog --project","pm extension 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 install '*' --project","pm install ./packages/pm-todos --project","pm install npm:@scope/pm-package --global","pm 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 upgrade --dry-run","pm upgrade --packages-only --project","pm upgrade todos --dry-run","pm upgrade --cli-only --repair","pm 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."]},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-open --priority 0 --limit 10"]},"list-in-progress":{why:"Tracks active execution and owner progress.",examples:["pm list-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-closed --limit 20 --type Task"]},"list-canceled":{why:"Audits intentionally discontinued work.",examples:["pm list-canceled --limit 20"]},"list-draft":{why:"Finds incompletely defined items that need refinement before execution.",examples:["pm list-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 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:"Inspects item mutation timeline and audit trail.",examples:["pm history pm-a1b2 --limit 20","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" --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 takeover for non-terminal items does not require --force; --force is reserved for terminal/lock overrides.","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"]},"start-task":{why:"Lifecycle alias that claims an item and sets status to in_progress.",examples:['pm start-task pm-a1b2 --message "Start implementation"']},"pause-task":{why:"Lifecycle alias that sets status to open and releases active assignment.",examples:['pm pause-task pm-a1b2 --message "Pause for dependency unblock"']},"close-task":{why:"Lifecycle alias that closes with reason text and clears assignment metadata.",examples:['pm close-task 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 I){let n=fe[e];n&&(fe[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var Ee={why:"Provides deterministic project management workflows for humans and coding agents.",examples:["pm init","pm install guide-shell --project","pm list-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."]},di=B.filter(e=>e.lifecycle==="deprecated");for(let e of di){let t=fe[e.alias];fe[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[Ee,...Object.values(fe)])e.examples=e.examples.map(t=>{for(let n of di){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function ms(e){let t=M(e??"");return t?ls[t]??t:""}function xn(e){let t=ms(e);return t?fe[t]??Ee:Ee}function mi(e,t){let n=xn(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:li(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function ps(){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(" ")} (${qo(n)})`)].join(`
|
|
4
|
-
`)}function
|
|
5
|
-
`,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),
|
|
6
|
-
`)}function _i(e,t){return t.transactionOperation!==void 0&&(e.transaction_operation=t.transactionOperation),t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),hs(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 Cs(e,t){if(e.flag)return e.flag;let n=o=>{let a=o.split("=",1)[0];return D([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 xs(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 ks(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=D(e.recovery?.normalized_args??[]),o=W(n),a=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,i=Cs(e,a),r=xs(e,a,i);return{surface:i??e.recovery?.missing?.[0]??wn(a)??"command",...r!==void 0?{rejected_value:r}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function Es(e,t){return _i({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:ks(e,t)},e)}function Tn(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 ma(Es(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function Rn(e){return _i({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required},e)}function Rt(e){return e.replace(/\(outputHelp\)/g,"").trim()}function Ss(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 gi(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function As(e){return wn(e?.normalized_args)}function Os(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 Ts(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,k(s)}}}function Rs(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 Is(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=Rt(t),a=Ot(n.code,e.code),i=Ot(n.type,yi(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?Rs(o):void 0,d=Ae(n.recovery),m=d&&e.recovery?Ae({...e.recovery,...d}):d??e.recovery;return{...e,code:a,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:Is(n,m)??e.flag,value:n.value??e.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,transactionOperation:n.transaction_operation,tombstone:n.tombstone,availableDependencies:n.available_dependencies,recovery:m}}function $s(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=Vo(process.cwd(),a);return ae(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 Ps(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(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 Ns(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:ae(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 Ds(e,t,n){return t.includes("is locked")?ae(C({code:"lock_conflict",title:"Lock conflict",happened:t,required:"Wait for lock release, or use --force where supported if lock is stale and safe to override.",why:"Locking protects item files from concurrent write races.",examples:["pm update pm-a1b2 --status in_progress --force"]}),e,n):null}function Ms(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(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 Fs(e,t,n){return t.startsWith("No update flags provided")?ae(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 Ls(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=Ae(n?.recovery),a=As(o),i=a?`pm ${a} --help`:"pm <command> --help",r=Os(t),s=Ae({...o,allowed_values:o?.allowed_values??r}),l=Ts(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(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 In(e,t){let n=Rt(e);return($s(e,n,t)??Ps(e,n,t)??Ns(e,n,t)??Ds(e,n,t)??Ms(e,n,t)??Fs(e,n,t)??Ls(e,n,t))||ae(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 js(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 Us(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function qs(e){if(!(!Array.isArray(e)||e.length===0))return k(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 z(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:qs(o),i=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return Ae({attempted_command:a,normalized_args:o,provided_fields:n,suggested_retry:i,...t})}function On(e,t){return!t||e.includes(t)?e:[...e,t]}var Hs=new Set(["--add","--add-json","--remove"]),zs=new Set(["command","cmd","path"]);function Gs(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(Hs.has(o))return o}}function Ws(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"||!zs.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 k(l)}}function Vs(e,t,n,o){let a=e.match(/required option '([^']+)' not specified/);if(!a)return null;let i=Us(a[1]),r=i.startsWith("--type"),s=o?.suggestedRetryCommand,l=$n(o?.providedOptionFlags),c=[i],d=js(t,i,n),m=s?On(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?On(p,`Replay with preserved arguments: ${s}`):p,g=l&&l.length>0?On(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:g,recovery:z(o,{missing:c})})}function Bs(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:z(n,{missing:[a]})})}function Ks(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:z(t,{suggested_flags:n})})}var Js={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 Ys(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 Xs(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 Zs(e,t){if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};let n=e.normalizedInvocationArgs;if(n===void 0)return{};if(n.filter(i=>i===t||i.startsWith(`${t}=`)).length!==1)return{};let o=n.findIndex(i=>i===t||i.startsWith(`${t}=`));if(o<0||n.includes("--")||!n[o]?.includes("=")&&o!==n.length-1&&n[o+1]?.startsWith("-")!==!0)return{};let a=D(n.filter((i,r)=>r!==o));return{retryCommand:k(a),suggestedRetryArgs:a}}function Qs(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}=Zs(a,i);if(t==="update"&&(i==="--file"||i==="--doc"))return Ks(i,n,r);let c=Ys(a),d=Xs(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 ${V(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:Js[c.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:i,value:i,examples:m,nextSteps:d,recovery:z(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 el(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:gi([t.installCommand,...n]),nextSteps:gi([i,...r]),recovery:z(a)})}function tl(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=ws(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))?el(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:z(t)})}function nl(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 ${V(t)?.canonical??t} --help`],nextSteps:a?[`Retry with the declared hyphenated action: ${a}`]:["Choose one value from recovery.allowed_values."],recovery:z(e,{allowed_values:o,suggested_retry:a})})}function ol(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,a=Gs(o);if(!a)return null;let i=Ws(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:z(n,i?{suggested_retry:i}:{})})}var al=new Set(["comments","docs","files","learnings","notes","test"]);function il(e,t,n){if(!/too many arguments/i.test(e)||!al.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:z(n,{parsed_positionals:[{role:"transposed_subcommand",value:i},{role:"item_id",value:s}],suggested_retry:l})})}var rl=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"]),hi=new Set(["context","ctx"]);function sl(e,t,n){if(!/too many arguments/i.test(e)||!hi.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],a=o.findIndex(c=>hi.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(rl.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:z(n,{suggested_retry:l})})}function Pn(e,t,n,o){let a=Rt(e);return(Vs(a,t,n,o)??Bs(a,t,o)??Qs(a,t,o)??tl(a,o)??nl(o)??il(a,t,o)??ol(a,t,o)??sl(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:z(o)})}function vi(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: ${k(n.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
|
|
7
|
-
`):
|
|
1
|
+
import{B as ai,C as ii,E as ri,F as vn,a as sn,b as me,c as ln,d as cn,e as dn,f as mn,i as F,j as D,k as A,l as Y,m as k,n as Pa,s as He,t as $a,u as Fa,y as La,z as _n}from"./chunks/chunk-ILQEZ4Y6.js";import{Ta as oi,f as xa,i as Ta}from"./chunks/chunk-DT3KUUKY.js";import"./chunks/chunk-MHPU2LDF.js";import"./chunks/chunk-3LQTJN4J.js";import{F as Xa,Id as ni,Nc as ti,b as Ba,d as Ct,g as Ka,h as Ja,i as X,j as Ya}from"./chunks/chunk-M5NDSW6E.js";import{Ga as Za,g as Ra}from"./chunks/chunk-GUVKPOY6.js";import"./chunks/chunk-JRRXWH5B.js";import"./chunks/chunk-DEZPZOQ7.js";import{$a as tn,$o as wn,Ac as sa,Bc as ne,Cc as la,Dc as ca,De as fa,Ec as le,Ee as an,Fc as da,Fj as qe,Gc as ut,Hb as Xo,Hc as be,Ic as ce,Jf as de,Kn as We,Lc as ma,Mc as ft,Mf as Ca,Nf as Ce,Nn as za,Pf as rn,Qb as Zo,Qf as _,Qn as Ga,R as g,Rb as Qo,S as mt,Sa as en,Sc as on,T as b,Tc as gt,Uc as pa,Ue as ga,V as K,Va as se,Vc as ua,Ve as ha,Vn as hn,Vo as xt,We as ya,Wn as Wa,Wo as kt,Xa as Ko,Xb as ea,Xe as wa,Xn as Va,Xo as yn,Ya as pt,Ye as _a,Yo as Ve,Zb as ta,Zo as E,_o as Qa,ab as Jo,bb as S,be as je,bj as wt,cj as Oa,db as Yo,dd as x,dp as q,e as I,eb as J,ed as Le,eh as ka,fa as Wo,fh as Ea,g as W,ga as Vo,h as P,j as B,ja as De,k as Zt,kc as na,l as V,lc as Me,ll as Ia,m as Go,ml as oe,mn as ja,na as Qt,nc as Fe,nh as ht,nn as bt,oc as oa,ol as Na,on as un,pg as pn,pi as yt,pl as Da,pn as fn,qj as _t,qn as ze,ra as Bo,ri as Sa,rl as Ma,rn as gn,rp as ei,sj as Ue,sn as Ua,tf as va,tj as vt,tn as Ge,ui as xe,vi as N,wb as nn,wi as Aa,wn as qa,xc as aa,xf as ba,xn as Ha,yc as ia,zc as ra}from"./chunks/chunk-6PZPUJW3.js";import{Command as Do,CommanderError as Or}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 bn=new Set(["--fields","--output-include","--depth","--for","--token-budget"]),Et=new Set(["--full","--brief","--compact"]);function rs(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 ss(e){let t=oe(k([...e])),n=new Set([...Na,...Da,...Ma].flatMap(r=>r.keys.map(s=>`--${s.replace(/[A-Z]/g,l=>`-${l.toLowerCase()}`)}`))),o=new Map([...qe,...t].flatMap(r=>[r.flag,...r.aliases??[]].map(s=>[s,r.flag]))),a=new Map([...qe,...t].flatMap(r=>[r.flag,...r.aliases??[]].map(s=>[s,rs(r,n)])));for(let r of bn)a.set(r,!0);for(let r of Et)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 si(e,t,n){let o=new Set;for(let[a,i]of t)n.has(i)&&(o.add(a),bn.has(i)&&!e[a].includes("=")&&o.add(a+1));return e.filter((a,i)=>!o.has(i))}function ls(e,t){let n=t.find(a=>Et.has(a));if(n===void 0)return;let o=[...new Set(e.values())].filter(a=>Et.has(a));return o.length===1?o[0]:n}function li(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=ss(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=si(e,i,new Set(["--fields"])),r.splice(l,0,"--fields",o[s+1])}else{let s=ls(i,o);if(s===void 0||![...i.values()].includes(s))return a;let l=new Set([...bn,...Et].filter(c=>c!==s));r=si(e,i,l)}return{...n,suggested_retry:x(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 ci(e,t){await Wa(e,{ok:t.ok,error:t.error,result:ce(),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 di(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await va({pmRoot:e.pmRoot,result:ce()})}catch(o){t=o}let n=await N(e.pmRoot);if(await ba({pmRoot:e.pmRoot,author:ht(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]="6ec548d1-a26d-5e72-9a7b-0fbd74a86601")}catch{}})();var mi=new WeakMap;function St(e,t){mi.set(e,t)}function ue(e){return mi.get(e)}function pi(e){return e.length>0?[e[0]]:[]}function cs(e){let t=["","Intent:",` ${e.why}`],n=pi(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(`
|
|
2
|
+
`)}function ds(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(`
|
|
3
|
+
`)}function ui(e,t){return t==="detailed"?ds(e):cs(e)}function M(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var ms={cal:"calendar",ctx:"context"};function ps(e,t){return e.commands.find(n=>n.name()===t)??null}function us(e,t){let n=e;for(let o of t){let a=ps(n,o);if(!a)return null;n=a}return n}function Cn(e,t,n,o){let a=us(e,t.split(" ").filter(i=>i.length>0));a&&a.addHelpText("after",ui(n,o))}function xn(e){return e.includes("--explain")?"detailed":"compact"}function ae(e){return e.includes("--all")||e.includes("--explain")}var fe={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 install ./my-package --project","pm 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 extension explore --project","pm extension manage --global","pm extension describe sample-ext --project","pm extension 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 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 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 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 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 extension init ./my-extension","pm extension init ./my-hook-extension --capability hooks","pm extension init ./my-search-extension --capability search","pm extension init ./my-sync-extension --capability importers","pm extension init ./my-domain-extension --capability schema","pm extension init ./my-output-extension --capability renderers","pm extension --install --project ./my-sync-extension","pm extension --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 extension install ./my-extension --project","pm extension --install --project ./my-extension","pm extension 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 extension doctor --project --detail summary","pm extension doctor --project --detail deep --trace","pm extension 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 extension catalog --project","pm extension 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 install '*' --project","pm install ./packages/pm-todos --project","pm install npm:@scope/pm-package --global","pm 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 upgrade --dry-run","pm upgrade --packages-only --project","pm upgrade todos --dry-run","pm upgrade --cli-only --repair","pm 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."]},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-open --priority 0 --limit 10"]},"list-in-progress":{why:"Tracks active execution and owner progress.",examples:["pm list-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-closed --limit 20 --type Task"]},"list-canceled":{why:"Audits intentionally discontinued work.",examples:["pm list-canceled --limit 20"]},"list-draft":{why:"Finds incompletely defined items that need refinement before execution.",examples:["pm list-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 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:"Inspects item mutation timeline and audit trail.",examples:["pm history pm-a1b2 --limit 20","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" --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 takeover for non-terminal items does not require --force; --force is reserved for terminal/lock overrides.","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"]},"start-task":{why:"Lifecycle alias that claims an item and sets status to in_progress.",examples:['pm start-task pm-a1b2 --message "Start implementation"']},"pause-task":{why:"Lifecycle alias that sets status to open and releases active assignment.",examples:['pm pause-task pm-a1b2 --message "Pause for dependency unblock"']},"close-task":{why:"Lifecycle alias that closes with reason text and clears assignment metadata.",examples:['pm close-task 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 I){let n=fe[e];n&&(fe[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var ke={why:"Provides deterministic project management workflows for humans and coding agents.",examples:["pm init","pm install guide-shell --project","pm list-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."]},fi=B.filter(e=>e.lifecycle==="deprecated");for(let e of fi){let t=fe[e.alias];fe[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[ke,...Object.values(fe)])e.examples=e.examples.map(t=>{for(let n of fi){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function fs(e){let t=M(e??"");return t?ms[t]??t:""}function kn(e){let t=fs(e);return t?fe[t]??ke:ke}function gi(e,t){let n=kn(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:pi(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function gs(){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(" ")} (${Go(n)})`)].join(`
|
|
4
|
+
`)}function hs(e,t,n,o){let a=new Set(Ka);e.configureHelp({visibleCommands(i){let r=t.visibleCommands(i);return n?r.filter(s=>(ue(s)??X(s.name()))!=="internal"):i!==e?r:r.filter(s=>o.has(s))},visibleOptions(i){let r=t.visibleOptions(i);return i!==e||n?r:r.filter(s=>a.has(s.flags))}})}function ys(e,t,n,o){let a=new Set(Ya("core")),i=e.createHelp();i.prepareContext({error:!1,helpWidth:80,outputHasColors:!1});let r=()=>`${i.formatHelp(e,i)}${o}
|
|
5
|
+
`,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),Ja(r()).within_budget||n.delete(l))}function hi(e,t=process.argv.slice(2)){let n=e.createHelp(),o=ae(t),a=new Set;hs(e,n,o,a);let i=xn(t),r=ui(ke,i);e.addHelpText("after",r),o&&e.addHelpText("after",gs()),ys(e,n,a,r);for(let[d,m]of Object.entries(fe))Cn(e,d,m,i);let s=M(A(t).commandPathTokens.join(" ")),l=Ue(s);if(l){Cn(e,l.parent,{why:l.description,examples:[l.example],tips:[`Action path: pm ${l.command}`,vt(l.accepted_flags)]},i);return}let c=_t.filter(({parent:d})=>d===s);c.length>0&&Cn(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 En(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 I){if(t&&!I.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),St(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]="990ef8ec-9869-5902-b702-9db69230fd69")}catch{}})();function Tt(e){let{why:t,title:n,...o}=e;return o}var ws=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function _s(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!ws.has(e.code)}function bi(e){return`urn:pm-cli:error:${e}`}function C(e){return{...e,type:bi(e.code)}}var Ee={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},yi={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},wi={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},At={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},vs={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:yi,cal:yi,reindex:wi,"search-advanced":wi,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":At,"dedupe-audit":At,"dedupe-merge":At,normalize:At};function bs(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return vs[t]}function Sn(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function Cs(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 xs(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 An(e,t,n){typeof n=="string"&&n.trim().length>0&&(e[t]=n.trim())}function Q(e,t,n){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=Cs(n);o&&(e[t]=o)}function Se(e){if(!e||typeof e!="object")return;let t={};e.recovery_mode==="compact"&&(t.recovery_mode="compact"),An(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),An(t,"suggested_retry",e.suggested_retry),Q(t,"suggested_retry_args",e.suggested_retry_args),typeof e.retry_after_ms=="number"&&Number.isSafeInteger(e.retry_after_ms)&&e.retry_after_ms>=0&&(t.retry_after_ms=e.retry_after_ms);let n=xs(e.fallback_candidates);return n&&(t.fallback_candidates=n),An(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function On(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 ks(e){let t=Se(e);if(!t)return[];let n=["Recovery bundle:"];if(On(n,"suggested_retry",t.suggested_retry),On(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}`),typeof t.retry_after_ms=="number"&&n.push(` retry_after_ms: ${t.retry_after_ms}`),On(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 Ci(e){let t=[`Error: ${e.title}`,"","What is required:",` ${e.required}`];e.nextSteps&&e.nextSteps.length>0&&(t.push(""),t.push(...Sn("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(...Sn("Examples:",e.examples))),e.verificationErrors&&e.verificationErrors.length>0&&(t.push(""),t.push(...Sn("Verification errors:",e.verificationErrors)));let n=ks(e.recovery);return n.length>0&&(t.push(""),t.push(...n)),t.join(`
|
|
6
|
+
`)}function xi(e,t){return t.transactionOperation!==void 0&&(e.transaction_operation=t.transactionOperation),t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),_s(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 Es(e,t){if(e.flag)return e.flag;let n=o=>{let a=o.split("=",1)[0];return D([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 Ss(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 As(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=D(e.recovery?.normalized_args??[]),o=W(n),a=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,i=Es(e,a),r=Ss(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 Os(e,t){return xi({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:As(e,t)},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 fa(Os(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function In(e){return xi({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required},e)}function Rt(e){return e.replace(/\(outputHelp\)/g,"").trim()}function Ts(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 _i(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function Rs(e){return _n(e?.normalized_args)}function Is(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 Ps(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,x(s)}}}function $s(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 Ns(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 ie(e,t,n){if(!n)return e;let o=Rt(t),a=Ot(n.code,e.code),i=Ot(n.type,bi(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?$s(o):void 0,d=Se(n.recovery),m=d&&e.recovery?Se({...e.recovery,...d}):d??e.recovery;return{...e,code:a,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:Ns(n,m)??e.flag,value:n.value??e.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,transactionOperation:n.transaction_operation,tombstone:n.tombstone,availableDependencies:n.available_dependencies,recovery:m}}function Ds(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=Jo(process.cwd(),a);return ie(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 Ms(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 ie(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 Fs(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:ie(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 Ls(e,t,n){return t.includes("is locked")?ie(C({code:"lock_conflict",title:"Lock conflict",happened:t,required:"Wait for lock release, or use --force where supported if lock is stale and safe to override.",why:"Locking protects item files from concurrent write races.",examples:["pm update pm-a1b2 --status in_progress --force"]}),e,n):null}function js(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 ie(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 Us(e,t,n){return t.startsWith("No update flags provided")?ie(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 qs(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=Se(n?.recovery),a=Rs(o),i=a?`pm ${a} --help`:"pm <command> --help",r=Is(t),s=Se({...o,allowed_values:o?.allowed_values??r}),l=Ps(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 ie(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 Pn(e,t){let n=Rt(e);return(Ds(e,n,t)??Ms(e,n,t)??Fs(e,n,t)??Ls(e,n,t)??js(e,n,t)??Us(e,n,t)??qs(e,n,t))||ie(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 Hs(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 zs(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function Gs(e){if(!(!Array.isArray(e)||e.length===0))return x(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 z(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:Gs(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 Ws=new Set(["--add","--add-json","--remove"]),Vs=new Set(["command","cmd","path"]);function Bs(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(Ws.has(o))return o}}function Ks(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"||!Vs.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 x(l)}}function Js(e,t,n,o){let a=e.match(/required option '([^']+)' not specified/);if(!a)return null;let i=zs(a[1]),r=i.startsWith("--type"),s=o?.suggestedRetryCommand,l=$n(o?.providedOptionFlags),c=[i],d=Hs(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 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:z(o,{missing:c})})}function Ys(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:z(n,{missing:[a]})})}function Xs(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:z(t,{suggested_flags:n})})}var Zs={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 Qs(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 el(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 tl(e,t){if(["--dry-run","--check","--check-only","--plan","--preview"].includes(t.split("=",1)[0]))return{};if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};let n=e.normalizedInvocationArgs;if(n===void 0)return{};if(n.filter(i=>i===t||i.startsWith(`${t}=`)).length!==1)return{};let o=n.findIndex(i=>i===t||i.startsWith(`${t}=`));if(o<0||n.includes("--")||!n[o]?.includes("=")&&o!==n.length-1&&n[o+1]?.startsWith("-")!==!0)return{};let a=D(n.filter((i,r)=>r!==o));return{retryCommand:x(a),suggestedRetryArgs:a}}function nl(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}=tl(a,i);if(t==="update"&&(i==="--file"||i==="--doc"))return Xs(i,n,r);let c=Qs(a),d=el(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 ${V(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:Zs[c.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:i,value:i,examples:m,nextSteps:d,recovery:z(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 ol(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:_i([t.installCommand,...n]),nextSteps:_i([i,...r]),recovery:z(a)})}function al(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=bs(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))?ol(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:z(t)})}function il(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 ${V(t)?.canonical??t} --help`],nextSteps:a?[`Retry with the declared hyphenated action: ${a}`]:["Choose one value from recovery.allowed_values."],recovery:z(e,{allowed_values:o,suggested_retry:a})})}function rl(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,a=Bs(o);if(!a)return null;let i=Ks(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:z(n,i?{suggested_retry:i}:{})})}var sl=new Set(["comments","docs","files","learnings","notes","test"]);function ll(e,t,n){if(!/too many arguments/i.test(e)||!sl.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:z(n,{parsed_positionals:[{role:"transposed_subcommand",value:i},{role:"item_id",value:s}],suggested_retry:l})})}var cl=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"]),vi=new Set(["context","ctx"]);function dl(e,t,n){if(!/too many arguments/i.test(e)||!vi.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],a=o.findIndex(c=>vi.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(cl.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:z(n,{suggested_retry:l})})}function Nn(e,t,n,o){let a=Rt(e);return(Js(a,t,n,o)??Ys(a,t,o)??nl(a,t,o)??al(a,o)??il(o)??ll(a,t,o)??rl(a,t,o)??dl(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:z(o)})}function ki(e,t){let n=Pn(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: ${x(n.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
|
|
7
|
+
`):an(Ci(n),n.required).output}function Ei(e,t){return In(Pn(e,t))}function Dn(e,t,n){return Rn(Pn(e,n),t)}function Si(e,t,n,o){let a=Nn(e,t,n,o);return an(Ci(a),a.required).output}function Mn(e,t,n,o){return In(Nn(e,t,n,o))}function It(e,t,n,o,a){return Rn(Nn(e,t,n,a),o)}function Ai(e,t){let n=Oi(e);return Rn(n,t)}function Oi(e){let t=Rt(e);return Ts(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 Ti(e){return In(Oi(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]="b4a71f6d-b74c-557f-979d-973c26664e84")}catch{}})();var Be=Bo.join("|"),ml={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"},pl={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"]}},Ri=["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 ul(e,t){let n=pl[e];if(!n)return[];let o=H(t);for(let[a,i]of Object.entries(n))if(H(a)===o)return i;return[]}function Fn(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:de(c,d=>`${JSON.stringify(d,null,2)}
|
|
8
8
|
`),null,2)}let o=n.map(r=>`- ${r.layer}:${r.name}: ${r.error}`).join(`
|
|
9
9
|
`),a=n.find(r=>r.declared_command_match===!0);if(!a)return`${e}
|
|
10
10
|
Extension activation failures:
|
|
@@ -16,23 +16,23 @@ ${i}`:""}
|
|
|
16
16
|
|
|
17
17
|
${e}
|
|
18
18
|
Extension activation failures:
|
|
19
|
-
${o}`}function
|
|
20
|
-
`||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function
|
|
21
|
-
`):
|
|
19
|
+
${o}`}function Ln(e){return A(e).commandPathTokens[0]??k(e)??"<command>"}function Ni(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let a=o.shift();if(!a)continue;let i=M(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=M(a),r=i.split(" ").some(s=>s.startsWith("_"));i.length>0&&!r&&n.add(i)}return[...n].sort((a,i)=>a.localeCompare(i))}function Ii(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=nn(s,o,i);l!==null&&(r=Math.min(r,l))}return Number.isFinite(r)?4+r:Number.POSITIVE_INFINITY}function Pi(e){return H(e).slice(2).replace(/-/g,"")}function jn(e){return x(e)}function fl(e){let t=V(e)?.canonical??Zt[e]??e,n=t.split(" ")[0]?.trim().toLowerCase();if(!n)return null;let o=ml[n];return o?{packageAlias:o,canonicalPath:t,installCommand:`pm package install ${o} --project`}:null}function $i(e){let t=Za(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function gl(e,t){let n=$i(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=$i(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 Ke(e,t){let n=new Set,o=t??oe(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 hl(e,t){if(!e.startsWith("--"))return[];let n=Pi(e);if(n.length===0)return[];let o=n.length>=8?2:1,a=[];for(let i of t){let r=Pi(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=nn(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 Pt,yl=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 wl(){if(Pt)return Pt;let e=new Map;for(let t of je)if(!yl.has(t))for(let n of Ke(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return Pt=e,Pt}function _l(e,t){if(!e.startsWith("--"))return[];let n=wl().get(H(e));if(!n)return[];let o=t?.trim().toLowerCase(),a=new Set(Ke(o));return[...new Set(n.filter(i=>i!==o).map(i=>({command:i,sharedFlagCount:Ke(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})=>V(i)?.canonical??i))]}function vl(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 bl(e){let t=new Set(e.commandPaths),n=i=>Math.min(Ii(i,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?Ii(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(Zt))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 Cl(e){let t=V(e.normalizedUnknown),n=ri(e.commandPaths,e.primaryToken),o=bl(e),a=gl(e.primaryToken,e.extensionDescriptors).filter(i=>e.commandPaths.includes(i));return vn([...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 xl(e){return[...new Set(e.map(t=>t.split(" ")[0]).filter(t=>t.length>0))].sort((t,n)=>t.localeCompare(n))}function kl(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 El(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 Sl(e,t){if(!e)return;let n=F([...t]);return[...n.path?["--pm-path",S(process.cwd(),n.path)]:[],...n.noExtensions?["--no-extensions"]:[],...e.split(" "),"--help"]}function Un(e,t,n,o=[]){let a=e.match(/unknown command '([^']+)'/i);if(!a||typeof a[1]!="string")return;let i=Ni(t,n),r=El(a[1],o,i),s=M(r);if(s.length===0||i.length===0)return;let l=fl(s);if(l&&!i.includes(l.canonicalPath.split(" ")[0]))return{unknownCommandExamples:[l.installCommand,`pm ${l.canonicalPath} --help`,"pm --help --all"],unknownCommandNextSteps:[`"${s}" is provided by the "${l.packageAlias}" package. Install it with: ${l.installCommand}. Command after installation: pm ${l.canonicalPath}.`],suggestedRetryCommand:l.installCommand};let c=s.split(" ")[0],d=Cl({commandPaths:i,normalizedUnknown:s,primaryToken:c,extensionDescriptors:n}),m=xl(i),p=ii(s,i),u=Sl(p,o),f=[...new Set([...p?[p]:[],...d.length>0?d:vn(m,i)])].slice(0,3),h=kl(f,d.length>0),w=d.length>0?`Did you mean: ${f.join(", ")}?`:null;return{...u?{suggestedRetryCommand:x(u),suggestedRetryArgs:u}:{},unknownCommandExamples:u?[x(u),...h.slice(1)]:h,unknownCommandNextSteps:[...w?[w]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',...w?["Use one of the suggested command paths above with --help to inspect valid flags and usage."]:[]]}}function Al(e){return Array.from(new Set(e))}function Ol(e){let t="";for(let n of e){if(n===" "||n===" "||n===`
|
|
20
|
+
`||n==="\r"||n==="\f"||n==="\v")break;t+=n}return t}function Tl(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 Rl(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 Ae(e,t){if(t.length===0)return!0;let n=e;for(let[o,a]of t.entries()){let i=Rl(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 Il(e,t,n,o){try{let a=S(process.cwd(),e.path);if(!await K(J(a)))return{allowedTypes:Be};let i=await N(a),r=e.noExtensions?void 0:le(),s=se(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("|"):Be,pmRoot:a,settings:i,typeToFolder:s.type_to_folder,verifiedCollectionItemId:l}}catch{return{allowedTypes:Be}}}function Pl(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?Al([...ul(t,n[1]),...hl(n[1],Ke(t))]):void 0,a=n?_l(n[1],t):[],i=n!==null&&Ke(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 $l(e,t,n){if(!t||!n||n.length===0)return;let o=vl(e,t[1],n[0]);return o?jn(o):void 0}function Nl(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?Tl(Ol(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let a=k(t);if(a)return ai(t,a,[o])}function Dl(e,t){if(!/too many arguments/i.test(e))return;let n=Y(t),o=W(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(!Ri.includes(s))return;let l=[...t.slice(0,a+1),s,...t.slice(a+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${i} ${r}`,unknownSubcommandAllowedValues:[...Ri],suggestedRetryCommand:jn(l)}}function Ml(e,t,n,o){let a=Y(t),i=W(t.slice(a))?.alias??k(t);if(!/unknown option /i.test(e)||i===void 0)return i;let r=V(i)?.canonical??i;return je.some(s=>s===i)||Ni(n,o).includes(r)?i:void 0}async function Je(e,t,n,o={},a=process.argv.slice(2)){let i=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",r=He([...a]).argv,s=F(r),l=Ml(i,r,t,n),c=jn(r),d=Z(r),m=await Il(s,i,r,l),p=m.allowedTypes,u=Un(i,t,n,r),f=Pl(i,l),h=Dl(i,r),w=h?.suggestedRetryCommand??$l(r,f.match,f.suggestions)??Nl(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:w,verifiedCollectionItemId:m.verifiedCollectionItemId,...h,...u,...o}}async function qn(e,t,n,o={},a=process.argv.slice(2)){let i=await Je(e,t,n,o,a),{message:r,commandName:s,allowedTypes:l,unknownCommandExamples:c,unknownCommandNextSteps:d,attemptedCommand:m,normalizedInvocationArgs:p,providedOptionFlags:u,unknownOptionSuggestions:f,unknownOptionOtherCommands:h,unknownOptionOtherCommandsTotal:w,unknownOptionOtherCommandsTruncated:O,unknownOptionScope:j,unknownSubcommandPath:G,unknownSubcommandToken:U,unknownSubcommandAllowedValues:ve,suggestedRetryCommand:Yt,suggestedRetryArgs:lt,verifiedCollectionItemId:ct,failedExtensions:dt}=i,zo=Si(r,s,l,{unknownCommandExamples:c,unknownCommandNextSteps:d,attemptedCommand:m,normalizedInvocationArgs:p,providedOptionFlags:u,unknownOptionSuggestions:f,unknownOptionOtherCommands:h,unknownOptionOtherCommandsTotal:w,unknownOptionOtherCommandsTruncated:O,unknownOptionScope:j,unknownSubcommandPath:G,unknownSubcommandToken:U,unknownSubcommandAllowedValues:ve,suggestedRetryCommand:Yt,suggestedRetryArgs:lt,verifiedCollectionItemId:ct,failedExtensions:dt}),Xt=await ua("help_format",{message:zo,command:s,allowed_types:l});return Xt.handled&&typeof Xt.result=="string"?Xt.result:zo}async function Hn(e,t,n,o=!1,a={},i=process.argv.slice(2)){let r=await Je(e,t,n,a,i),s=It(r.message,r.commandName,r.allowedTypes,g.USAGE,{unknownCommandExamples:r.unknownCommandExamples,unknownCommandNextSteps:r.unknownCommandNextSteps,attemptedCommand:r.attemptedCommand,normalizedInvocationArgs:r.normalizedInvocationArgs,providedOptionFlags:r.providedOptionFlags,unknownOptionSuggestions:r.unknownOptionSuggestions,unknownOptionOtherCommands:r.unknownOptionOtherCommands,unknownOptionOtherCommandsTotal:r.unknownOptionOtherCommandsTotal,unknownOptionOtherCommandsTruncated:r.unknownOptionOtherCommandsTruncated,unknownOptionScope:r.unknownOptionScope,unknownSubcommandPath:r.unknownSubcommandPath,unknownSubcommandToken:r.unknownSubcommandToken,unknownSubcommandAllowedValues:r.unknownSubcommandAllowedValues,suggestedRetryCommand:r.suggestedRetryCommand,suggestedRetryArgs:r.suggestedRetryArgs,verifiedCollectionItemId:r.verifiedCollectionItemId,failedExtensions:r.failedExtensions}),l=o?Tt(s):s,c=F(r.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(c?de(l,d=>`${JSON.stringify(d,null,2)}
|
|
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 Di(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 Fl}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]="1f0aec6a-0db1-5a10-b61f-e3b2eb0d9518")}catch{}})();function v(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function Fi(e,t){let n=new Map;for(let o of e){let a=v(o.command);for(let i of t){if(i.layer!==o.layer||i.name!==o.name)continue;let r=v(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 zn(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 $t(r).takesValue}function $(e){if(typeof e!="string")return null;let t=e.trim();return t.length>0?t:null}function ee(e){return typeof e=="boolean"?e:void 0}function $t(e){let t=$(e.value_type)??$(e.type),n=$(e.value_name),o=t!=="boolean"&&(n!==null||t!==null||ee(e.required)===!0||ee(e.list)===!0);return{takesValue:o,valueName:o?n??"value":null}}function Ll(e){if(ee(e.visible)===!1)return null;let t=$(e.long);if(!t||!t.startsWith("--")||t.length<3)return null;let n=$(e.short),o=n&&n.startsWith("-")&&!n.startsWith("--")?`${n}, `:"",a=$(e.value_name),i=a?` <${a}>`:"",r=$(e.description)??"Extension-provided option.",s=[];ee(e.required)===!0&&s.push("required"),ee(e.enabled)===!1&&s.push("disabled");let l=s.length>0?` [${s.join(", ")}]`:"";return`${o}${t}${i} ${r}${l}`}function Li(e){let t=[...new Set(e.map(Ll).filter(n=>n!==null))].sort((n,o)=>n.localeCompare(o));return t.length===0?null:`
|
|
22
22
|
Extension-provided flags:
|
|
23
23
|
${t.join(`
|
|
24
|
-
`)}`}function
|
|
24
|
+
`)}`}function ji(e){let t=new Map;for(let a of e){let i=v(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=Li(i);r&&o.set(a,r)}return o}function Ui(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function Mi(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 jl(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 Ul(e){let t=new Map;for(let n of e){let o=v(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:Ui(o,n.action),description:a,intent:i,examples:Mi(n.examples),failure_hints:Mi(n.failure_hints),arguments:jl(n.arguments),flags:[],tier:n.tier??"standard",family:n.family??"extensions",source:{layer:n.layer,name:n.name,package:n.source_package}})}return t}function ql(e){let t=new Map;for(let n of e){let o=v(n.target_command);if(o.length===0)continue;let a=t.get(o)??[];a.push(...n.flags),t.set(o,a)}return t}function Hl(e,t,n){let o=new Set;for(let a of e){let i=v(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 zl(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function qi(e,t,n,o=new Map){let a=Ul(t),i=ql(n),r=Hl(e,a,i),s=new Map,l=[...r].sort((c,d)=>c.localeCompare(d));for(let c of l){let d=zl(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:Ui(c,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function Gl(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function Hi(e,t){for(let n of t.arguments)e.argument(Gl(n),n.description??"Extension argument.")}function zi(e){if(ee(e.visible)===!1)return null;let t=$(e.long),n=$(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 Wl(e){let t=zi(e);if(!t)return null;let{valueName:n}=$t(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Vl(e){let t=zi(e);if(!t)return null;let{valueName:n}=$t(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Gi(e){let t=$(e.description)??"Extension-provided option.",n=[];ee(e.required)===!0&&n.push("required"),ee(e.enabled)===!1&&n.push("disabled");let o=n.length>0?` [${n.join(", ")}]`:"";return`${t}${o}`}function Wi(e,t){let n=$(t.long),o=$(t.short);return e.options.some(a=>{let i=a;return n!==null&&i.long===n||o!==null&&i.short===o})}function Gn(e,t){for(let n of t){if(Wi(e,n))continue;let o=Vl(n);if(!o)continue;let a=Gi(n),i=new Fl(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 Wn(e,t){return Li(t.filter(n=>!Wi(e,n)))}function Bl(e){let t=Wl(e);if(!t)return null;let n=$(e.long),o=$(e.short),a=n&&n.startsWith("--")&&n.length>2?n:null,i=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,{takesValue:r,valueName:s}=$t(e),l=ee(e.required)===!0;return{flags:t,long:a,short:i,description:Gi(e),takes_value:r,value_required:r,value_name:s,variadic:!1,required:l,aliases:[],alias_for:null}}function Vi(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let a=Bl(o);!a||n.has(a.flags)||(n.add(a.flags),t.push(a))}return t}function Bi(e,t){if(t.length===0)return e;let n=[...e],o=new Set(e.map(a=>a.flags));for(let a of t)o.has(a.flags)||(o.add(a.flags),n.push(a));return n}function Ki(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
25
|
Extension command metadata:
|
|
26
26
|
${t.join(`
|
|
27
|
-
`)}`}function Wn(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 Ze(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:Wn(o).includes(n))??null}function ee(e,t){let n=e;for(let o of t){let a=Ze(n,o);if(!a)return null;n=a}return n}var Vn=new WeakSet;function Wi(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&&I.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let i=Ze(n,a);if(i){n=i;continue}let r=n.command(a);Vn.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 zl(e,t){let n=t.join(" "),o=I.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=Ze(a,r);if(!s)return null;i.push(r);let l=s.commands.length>0||I.some(c=>c.canonical.startsWith(`${i.join(" ")} `));if(!Vn.has(s)&&(i.length===t.length||!l))return{core_path:i.join(" "),extension_path:t.join(" ")};a=s}return null}function Gl(e,t,n,o,a=!1){let i=t.split(" ").filter(d=>d.length>0),r=zl(e,i),s=ee(e,i),l=I.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||Vn.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 Vi(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=Gl(e,i,o,n.get(i),t.includes(i));return r?(a(r),!o.has(i)&&ee(e,i.split(" "))!==null):!0})}function Bi(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]="c4cd4b1c-7043-53a0-8823-d47339372420")}catch{}})();var Wl=new Set(["__proto__","prototype","constructor"]),Ki=Symbol("looseOptionOccurrences");function Qe(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,n)=>n.toUpperCase())}function Vl(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 Bn(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)};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)};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 Wl.has(e)}function Ji(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Jo(t)}function et(e){let t=[],n=typeof e.long=="string"?e.long.trim():"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let a=Qe(n.slice(2));a.length>0&&!Nt(a)&&t.push(a)}if(o.startsWith("-")&&!o.startsWith("--")){let a=Qe(o.slice(1));a.length>0&&!Nt(a)&&t.push(a)}return[...new Set(t)]}function Yi(e){let t=new Set;for(let n of e)for(let o of et(n))t.add(o);return t}function Bl(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")){let n=Qe(t.slice(2));if(n.length>0&&!Nt(n))return n}return et(e)[0]??null}function Kl(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 Kn(e,t,n){if(t.length===0)return;let o=new Set,a=new Map,i=[],r=[];for(let s of t){let l=et(s),c=Kl(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 b(`Unknown option '--${s}' for extension command '${n}'.${c}`,f.USAGE)}let l=a.get(s);if(l)throw new b(`Option '${l}' is disabled for extension command '${n}'.`,f.USAGE)}for(let s of i)if(!s.keys.some(l=>Object.hasOwn(e,l)))throw new b(`Missing required option '${s.label}' for extension command '${n}'.`,f.USAGE)}function Jl(e){return typeof e=="string"||e==null?e:String(e)}function Yl(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 Xl(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 Zl={string:Jl,number:Yl,boolean:Xl};function Dt(e,t){return Array.isArray(e)?e.map(n=>Dt(n,t)):Zl[t](e)}function Xi(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(a=>a!=null&&a!==""):Yo(e);return t?o.map(a=>Dt(a,t)):o}function Ql(e,t,n,o){return n?Xi(e,t,o):t?Dt(e,t):e}function ec(e,t,n){let o=e[Ki];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 Zi(e,t,n=e){if(t.length===0)return e;let o=Object.create(null);for(let[a,i]of Object.entries(e))o[a]=i;for(let a of t){let i=Bl(a);if(!i)continue;let r=a.list===!0,s=et(a);for(let d of s)if(!(d===i||!Object.hasOwn(o,d))){if(Object.hasOwn(o,i)){if(!r){delete o[d];continue}let m=o[i],p=o[d];o[i]=[...Array.isArray(m)?m:[m],...Array.isArray(p)?p:[p]].filter(u=>u!=null),delete o[d];continue}o[i]=o[d],delete o[d]}let l=Ji(a),c=a.repeatable===!0;if(!Object.hasOwn(o,i)){a.default!==void 0&&(o[i]=Ql(a.default,l,r,c));continue}if(r){o[i]=Xi(ec(n,s,o[i]),l,c);continue}l&&(o[i]=Dt(o[i],l))}return o}function Qi(e){let t=Object.create(null),n=[];Object.defineProperty(t,Ki,{value:n});let o=0;for(;o<e.length;){let a=Bn(e,o);if(!a){o+=1;continue}let i=Qe(a.key);if(i.length===0||Nt(i)){o+=a.consumed;continue}Vl(t,i,a.value),n.push({...a,key:i}),o+=a.consumed}return t}function er(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=Bn(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function Jn(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let r of t){let s=Ji(r);for(let l of et(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=Bn(e,i);if(r){let s=Qe(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 Oe 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 Yn(e,t={},n=[]){let o={readSettings:N,loadExtensions:Fe,activateExtensions:Le,resolveImplicitPmRoot:en,...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(M).filter((p,u,g)=>p.length>0&&g.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),d=n.map(M),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 tr(e,t,n={},o=[]){if(e!=="unknown_command")return[];let a=await Yn(t,n,o),i={readSettings:N,loadExtensions:Fe,activateExtensions:Le,resolveImplicitPmRoot:en,...n};try{let r=i.resolveImplicitPmRoot(process.cwd());if(Oe.resolve(r)===Oe.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,g)=>u.localeCompare(g));if(p.length===0)return a;a.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${Oe.resolve(t)} extension_discovery_root=${c.roots.project}; cwd_storage_root=${Oe.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 ${Oe.resolve(r)}, or install the extension into the selected tracker with "pm --pm-path ${Oe.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]="6bca8bb8-c8f8-5bf5-bd3a-1e3089571238")}catch{}})();var nr={core:0,standard:1,full:2,internal:3};function or(e,t,n=!0){let o=t.get(O(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)=>nr[l.tier]<nr[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 ar(e,t){if(t.length===0)return e;let n=ee(e,t);if(n)return n;let o=t.join(" ");if(O(o)!==o||!Ue.some(a=>a===o)&&!Oa(o)&&!qe(o)&&!Ye(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 tc(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function ir(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 nc(e){let t=new Map;for(let n of e){let o=n,a=ir(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 oc(e){return k(e)}function ac(e){let t=e.options??[],n=nc(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=ir(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("["),g={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:tc(i),variadic:a.variadic===!0,required:m,aliases:l,alias_for:d};return a.defaultValue!==void 0&&(g.default_value=a.defaultValue),g})}function ic(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 rc(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 sc(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)??Y(a.name()))!=="internal").map(a=>{let i=M(E(a)),r=i,s=ue(a),l=or(i,t,s!==void 0),c=B.find(({alias:d})=>d===i);return{name:a.name().trim(),aliases:Wn(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 lc(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 cc(e,t,n,o,a){let i=e!==void 0&&xn(e)===Ee,r=i?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:mi(e,n),s=a?"positional_action":o?.intent||o?.description?"extension":i?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:lc(n,r,o),intentSource:s}}function dc(e,t){return e===void 0?null:t?.tier??Y(e)}function mc(e,t){return e===void 0?null:t?.family??Ct(e)}function pc(e,t,n){if(!(t!==e||!n))return B.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:ar(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function uc(e,t,n,o,a=new Map,i=!1){if(!e){let s=rc(t),l=sc(t,a,i),c=new Set(l.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...l,..._t.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 fc(e,t,n,o,a){let i=Cn(n),r=oe(n),s=M(E(t)),l=M(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,g=p?a.get(O(p)):void 0,h=p?or(p,a,ue(t)!==void 0):void 0,{narrative:v,intentSource:A}=cc(p,t.description().trim(),i,g,d!==void 0),L=ic(zi(ac(t),Hi(g))),G=uc(d,t,m,L,a,r),j=pc(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:dc(u,h),capability_family:mc(u,h),description:d?.description??t.description(),usage:G.usage,intent:d?.description??v.intent,intent_source:A,examples:d?[d.example]:v.examples,tips:d?[vt(d.accepted_flags)]:v.tips,arguments:G.arguments,options:G.options,subcommands:G.subcommands,has_subcommands:G.subcommands.length>0,...j===void 0?{}:{command_aliases:j}}}async function rr(e,t,n,o=t){let a=U(t);if(!a.json)return!1;let i=S(t);if(!i.requested)return!1;let r=ar(e,i.commandPathTokens);if(!r){if(!a.quiet){let s=`unknown command '${O(i.commandPathTokens.join(" "))}'`,l=jn(s,e,n),c=It(s,"help",Ke,f.USAGE,{...l,attemptedCommand:oc(t),normalizedInvocationArgs:[...t],providedOptionFlags:X(t)}),d=a.tokenAccounting?ce(c,m=>`${JSON.stringify(m,null,2)}
|
|
28
|
-
`):c;
|
|
29
|
-
`)}return process.exitCode=
|
|
30
|
-
`)}return process.exitCode=
|
|
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 sr(e,t,n){let o=x(n);if(o!=="create"&&o!=="update")return;let a=Ze(e,o);a&&a.addHelpText("after",_c(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 vc(e,t){return Me(e.id)||`migration-${String(t+1).padStart(3,"0")}`}function bc(e){return Me(e.status)?.toLowerCase()??"pending"}function Cc(e){return e.mandatory===!0}function xc(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 dr(e){let t=[];return e.forEach((n,o)=>{if(!Cc(n.definition))return;let a=bc(n.definition);a!=="applied"&&t.push({layer:n.layer,name:n.name,id:vc(n.definition,o),status:a})}),t.sort(xc),t}function lr(e){return Array.isArray(e)&&e.length>0}var kc=new Set(["create","beads import","todos import"]),Ec=new Set(["restore","update","close","delete","append","claim","release"]),Sc=new Set(["comments","notes","learnings"]),Ac=new Set(["files","docs","test"]),Oc=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 Xn(e,t){let n=t.force===!0;return kc.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:Ec.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:Sc.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:Ac.has(e)?{isMutation:lr(t.add)||lr(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function Tc(e,t,n){if(Xn(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return ja(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(a=>Oc.has(a.trim().toLowerCase())):!1}function cr(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Rc(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(Me(t[1])||a.push("source"),Me(n.to)||a.push("--to"),a.length!==0)throw new b(`Schema migration requires ${a.join(", ")}.`,f.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 Ic(e,t,n,o,a){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||cr(n.status)!==cr(a.schema.workflow.in_progress_status))return;let i=t[0];if(!i)return;let r=re(a,se()),s=await wt(o,i,a.id_prefix,a.item_format,r.type_to_folder);if(!s)return;let l=await Ea(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)||w(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function Zn(e,t,n,o,a){if(!Tc(e,t,n)||(Rc(e,t,n),!await K(J(a))))return;let i=await ke(a);o.json!==!0&&await Ic(e,t,n,a,i.settings);let r=La({author:ht(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)w(`warning:${s}`)}function mr(e,t,n){if(n.length===0)return;let o=Xn(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 b(`Write command "${e}" blocked by unresolved mandatory extension migrations (${a.join(",")}). ${i}`,f.CONFLICT)}async function Qn(e,t,n,o){if(!Xn(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await K(J(n)))return;let{settings:a,metadata:i,warnings:r}=await ke(n);for(let s of r)w(`warning:${s}`);if(o.enforce_item_format_gate&&!i.has_explicit_item_format&&(xa(a),await ka(n,a,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let s=re(a,se());await Ua(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 eo(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=_(n);o.length!==0&&t.push(o)}return t}function Re(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 eo(e.commandArgs))o.push(...a.split(" ").filter(i=>i.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(a=>[a,O(a)]))]}function to(e,t){let n=_(e);if(n.length===0)return!1;let o=Re(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),...pr(n.preflight_ownership),...pr(n.renderer_ownership)]:[]}function R(e){return e??[]}function pr(e){return R(e).flatMap(t=>t.commands)}function tt(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var ur=new Set(["hooks","parser","preflight","renderers"]),fr=new Set(["commands","schema","services","importers"]),$c=new Set(["reindex","search","search-advanced"]),Pc=new Set(["--template"]);function Te(e,t){for(let n of t)if(e.has(n))return!0;return!1}function no(e){let t=_(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return $c.has(n??t)}function oo(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 Lt(e){return _(e.commandPath??"")==="create"&&oo(e,Pc)}function ao(e){return e.some(t=>{let n=_(t);return n==="templates"||n.startsWith("templates ")})}function Mt(e,t){return e.some(n=>to(n,t))||Lt(t)&&ao(e)}function io(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 ro(e,t){let n=e.activation?.commands??[];if(n.length>0)return Mt(n,t);let o=Ft(e);if(Mt(o,t)||tt(e).has("search")&&no(t.commandPath))return!0;if(e.contributions)return io(e.contributions)}function jt(e,t){let n=ro(e,t);if(n!==void 0)return n;let o=tt(e);return!!(Te(o,ur)||Te(o,fr))}function nt(e,t){return e.effective.length===0?!1:ot(t)!=="all"?e.effective.some(n=>jt(n,t)):e.effective.some(n=>{let o=tt(n);return Ft(n).length>0||Te(o,ur)||Te(o,fr)||o.has("search")})}function ot(e){if(_(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Re(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=Lt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function so(e){return ot(e)==="all"?void 0:t=>jt(t,e)}function Ie(e){let t=S(e);if(t.requested&&t.commandPathTokens.length>0){let[a,...i]=t.commandPathTokens;return{commandPath:a,commandArgs:i,allowCommandPrefixMatch:!0}}let n=D(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 lo(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]="2fe1a4e5-3c55-5ec3-a729-2216a298c081")}catch{}})();var Ut=Symbol.for("pm.readOutputInvocationProvenance");function ie(e,t){let n=Reflect.get(e,Ut);n!==void 0&&Reflect.set(t,Ut,n)}function co(e,t,n){let o=ua(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=pa.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,Ut);Reflect.set(n,Ut,{canonical_include_modes:c?.canonical_include_modes??[],explicit_legacy_aliases:l,cli_invocation_observed:!0}),ie(n,e)}function Nc(e){let t=e.optsWithGlobals(),n=E(e);if(O(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 b(`Unknown option '${i.long}' for ${n}`,f.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 mo(e,t,n,o){co(e,t,o);let a=n.outputInclude;if(a===void 0)return;let{selectors:i,modes:r}=ha(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=ga(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 $e(e,t,n=[]){let o={...Nc(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=Qi(t);for(let[i,r]of Object.entries(a))o[i]===void 0&&(o[i]=r);if(n.length>0){let i=Yi(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]);Kn(s,[...r,...n],E(e));let l=Zi(o,n,a);return ie(o,l),l}return o}function qt(e,t){let n=_(t);return n.length===0?[]:e.flags.filter(o=>O(_(o.target_command))===O(n)).flatMap(o=>o.flags)}function at(e,t,n){let o=qt(e,t),a=[t],i=[];for(let r of n){if(r.startsWith("-"))break;a.push(r);let s=qt(e,a.join(" "));s.length>0&&(i=s)}return i.length>0?i:o}function Ht(e){return e.arguments??[]}function gr(e){let t=Ht(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function po(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 uo(e,t){let n=Ht(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 b(`Missing required argument for extension command '${e.command}'. Usage: ${gr(e)}${r}`,f.USAGE);if(t.length>a){let s=t.slice(a).join(" ");throw new b(`Too many arguments for extension command '${e.command}': ${s}. Usage: ${gr(e)}${r}`,f.USAGE)}}function Dc(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function Mc(e,t,n){if(n.length>0){Kn(t,n,e.command);return}let o=Object.keys(t).filter(a=>t[a]!==void 0).sort();if(o.length!==0)throw new b(`Unknown option '${o.map(Dc).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,f.USAGE)}function fo(e,t,n,o){e&&(uo(e,t),Mc(e,n,o))}import{Command as hr}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 Fc=new Set(["--version","-V"]);function it(e){let t=D(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function yr(e){if(D(e)[0]!=="item"||!e.includes("--dry-run"))return;let t=new hr().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 Lc=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),go=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"]),wr=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"]),jc=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),Uc=new Set(["claim","close-task","pause-task","release","start-task","test"]),ye={setup:!0,listQuery:!0,mutation:!0,operation:!0},qc=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 rt(e){return e.some(t=>Fc.has(t))}function Hc(e,t){if(!I.some(o=>o.canonical_argv[0]===t))return;let n=new hr().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of Ga(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 ye;let a=W([t,...o.operands])?.alias;if(I.some(i=>i.alias===a))return{...ye,targetCommandName:a}}catch{return ye}}function ho(e){if(rt(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||S(e).requested)return ye;let t=x(e);if(!t)return ye;let n=t.trim().toLowerCase(),o=D(e),a=W(o)?.alias;return I.some(i=>i.alias===a)?{...ye,targetCommandName:a}:Hc(o,n==="ctx"?"context":n)||(Lc.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:go.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:wr.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:jc.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:ye)}function yo(e){return e.length===0||S(e).requested||e.includes("--explain")&&x(e)===void 0}function wo(e,t){return it(t)||rt(t)?!1:oe(t)||S(t).requested?!0:!!x(t)}function _o(e){if(rt(e))return!1;let t=x(e);return t?qc.has(t):!1}function zc(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 vo(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=wr.has(t)||Uc.has(t),r=i?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=i?"mutating option":"option",l=zc({argv:e.argv,normalizedDisplay:a,normalizedTokens:o,rawFrom:n.from});throw new b(`Refusing to auto-correct ${s} ${l.sourceDisplay} to ${l.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,f.USAGE,{code:r,examples:[k(l.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:l.argv,suggested_retry:k(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 Gc=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"]),Wc=new Set(["parse","preflight","execute","unknown"]),Vc=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 bo(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function zt(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 Co(e){if(!e)return;let t=e.trim().toLowerCase();if(Gc.has(t))return t}function xo(e){if(!e)return;let t=e.trim().toLowerCase();if(Wc.has(t))return t}function ko(e){if(!e)return;let t=e.trim().toLowerCase();if(Vc.has(t))return t}function Eo(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(bo(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let o=zt(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=>Zt(r)?.status==="failed").length;if(i>0)return`failed_runs:${i}`}}function So(e,t){if(!e)return t===f.USAGE?"invalid_command_usage":t===f.NOT_FOUND?"item_not_found":t===f.CONFLICT?"lock_conflict":t===f.DEPENDENCY_FAILED?"dependency_failed":"command_failed"}function Ao(){let e=Zt(le()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=zt(e,"exit_code","exitCode"),o=t??n??f.SUCCESS,a=Ka(o),i=we(e,"error_code","errorCode")??So(a,o),r=ko(we(e,"error_category","errorCategory"))??(a?void 0:mt(i)),s=a?void 0:Eo(e)??`command_exit_${o}`,l=Co(we(e,"command_resolution","commandResolution"))??bt({ok:a,errorCode:i,errorCategory:r}),c=xo(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]="2309d6a4-a061-51d8-be5e-5e1dd62e9b3e")}catch{}})();var Oo="PM_CLI_PACKAGE_ROOT",Er=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 Bc(){return Ho(import.meta.url,["../.."])}(typeof process.env[Oo]!="string"||process.env[Oo]?.trim().length===0)&&(process.env[Oo]=Bc());var Pe=null,F=null;function Kc(e){Pe=e}function Jc(e){P=e}var st=null,_e=null,P=new Map,Do=250,Yc=new Set([f.USAGE,f.NOT_FOUND,f.CONFLICT]),Xc=new Set(["1","true","yes","on"]),Zc=Ve(()=>import("./chunks/register-setup-MAYFPKBX.js")),Qc=Ve(()=>import("./chunks/register-list-query-T6BOR67M.js")),ed=Ve(()=>import("./chunks/register-mutation-6NXR7SAJ.js")),td=Ve(()=>import("./chunks/register-operations-PDOBQZUJ.js"));function Wt(e){return k(e)}function Sr(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 nd(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=>pe(d)??d)),i=Sr(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)||Hn(t,r,m,P)!==void 0});return c&&c.length>0?c:void 0}function od(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=Hn(e,r,i,P),d=i?l?.isBoolean()===!0||c===!1?[i]:[i,"<value>"]:[],m=i?Wt([...e,...d]):t;return m===t?void 0:m}function ad(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 id(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,...ad(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Ar(e,t,n){let o=je(t),a=D(o),i=me(a),[r,s]=i===void 0?[]:a.slice(i,i+2),l=o.includes("--explain"),c=ai(o,e?.code,e?.recovery),d=c&&(r==="history-redact"||r==="history"&&s==="redact")?{...c,...c.attempted_command?{attempted_command:Wt(o)}:{},...c.normalized_args?{normalized_args:[...o]}:{},...c.suggested_retry?{suggested_retry:Wt(o)}:{},...c.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:c;if(d?.recovery_mode==="compact"&&!l)return{...e,recovery:d};let m=Wt(o),p=X(o),u=nd(n,o,d),g=od(o,m,u,d),h=id({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:g,existingRecovery:d});return{...e,recovery:h}}async function ct(e){let t=F;F=null,await ii(t,e);let n=Pe;if(Pe=null,!n){ft();return}let o=[],a=la();try{await ri({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 Zo(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{ft()}!n.globalOptions.json&&o.length>0&&w(`[pm] warning: afterCommand hook_warnings=${q(o)}`),n.profileEnabled&&o.length>0&&w(`profile:extensions hook_warnings=${q(o)}`)}async function Or(){await Ma()}function Tr(e){return Xc.has((process.env[e]??"").trim().toLowerCase())}function Rr(e){return Tr("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Yc.has(Math.trunc(e))}async function Bt(e){return Rr(e.exit_code)?(await Or(),Fa(e),!0):!1}async function Ir(e){let t=de(e.error),n=Ei(t);e.bootstrapGlobal.json?w(JSON.stringify(xi(t,f.GENERIC_FAILURE),null,2)):w(t),process.exitCode=f.GENERIC_FAILURE;let o="runtime",a="runtime_failed";try{await Or(),fn(e.error);let i=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:n.code,errorMessage:n.detail,exitCode:f.GENERIC_FAILURE,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"});o=i.errorCategory,a=i.commandResolution,Ge(!1,t,{error_code:n.code,error_category:o,exit_code:f.GENERIC_FAILURE,command_resolution:a,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||w(`Failed to report error: ${de(i)}`)}try{await ct({ok:!1,error:t,exit_code:f.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:a,resolution_stage:"execute"})}catch(i){e.bootstrapGlobal.json||w(`Failed to run error hooks: ${de(i)}`)}try{await We()}catch(i){e.bootstrapGlobal.json||w(`Failed to flush error reporting: ${de(i)}`)}}var rd={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"},To=new Map;function Ro(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function $r(e,t){return e.options.some(n=>n.long===t)}function Pr(e,t){return e.options.some(n=>n.short===t)}function Io(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(Pr(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(!$r(e,r)){if(o){e.option(`${r} <value>`,`${i} (repeatable)`,yn);return}e.option(`${r} <value>`,i)}}async function Nr(e,t){let n=rd[e];if(!n)return[];let o=`${t}:${n}`,a=To.get(o);if(a)return a;if(!await K(J(t)))return To.set(o,[]),[];let i=await N(t),r=(mn(i.schema).command_to_fields.get(n)??[]).flatMap(s=>[s.cli_flag,...s.cli_aliases].map(l=>({long:`--${l}`,type:Ro(s.type),value_type:Ro(s.type)})));return To.set(o,r),r}async function Dr(e,t){let n=U(t),o=T(process.cwd(),n.path);if(!await K(J(o)))return;let a=_e?.key===Lo(o)?_e.snapshot:null,i=a===null?await N(o):a.settings,r=mn(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??"";Io(c,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)Io(c,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function Mo(e,t,n,o,a){let i=x(n);if(!(i!=="create"&&i!=="update"))try{let r=a??await N(t),s=re(r,o);sr(e,s,n)}catch{}}function $o(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function Mr(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function Fo(e){return e.some(t=>t==="--profile")}function Lo(e){return`pm-root:${e}`}function Po(e){for(let t of e)t.startsWith("settings_read_")&&w(`[pm] warning: ${t} \u2014 settings.json could not be loaded and pm fell back to defaults; run pm health for remediation.`)}function Fr(e,t){e.profile&&(w(`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&&w(`profile:extensions activation_warnings=${q(t.activationWarnings)}`))}function Kt(e,t,n){if(!e)return;let o=_(n.commandPath??"")||"<none>";w(`profile:extensions activation=skipped command=${o} effective=${t.discovery.effective.length} warnings=${t.discovery.warnings.length} discovery_ms=${t.discoveryMs}`)}async function Jt(e,t=ke){let n=Lo(e);if(_e?.key===n)return _e.snapshot;try{let o=Date.now(),{settings:a,warnings:i}=await t(e),r=await Qo({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 Ne(e,t,n=N){let o=t?ot(t):"all",a=Mr(e,o);if(st?.key===a)return st.snapshot;try{let i=await n(e),r=await Fe({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?so(t):void 0}),s=await Le({...r,loaded:r.loaded}),l=[...new Set(s.commands.handlers.map(u=>_(u.command)))].filter(u=>u.length>0).sort((u,g)=>u.localeCompare(g)),c=Di(s.registrations.flags),d=Pi(s.commands.handlers,s.registrations.commands),m=Fi(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:g})=>({name:u,module:g}))};return st={key:a,snapshot:p},p}catch{return st={key:a,snapshot:null},null}}async function Lr(e){let t=Be(e);if(t.noExtensions){let r=T(process.cwd(),t.path);return await K(J(r))&&Po((await ke(r)).warnings),null}let n=T(process.cwd(),t.path),o=await Jt(n);if(!o)return null;Po(o.settingsReadWarnings);let a={commandPath:E(e),commandArgs:lo(e)};if(!nt(o.discovery,a))return Kt(t.profile,o,a),null;let i=await Ne(n,a);return i?(Fr(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 jr(e){let t=await Ne(e);return t?new Map(t.commandDescriptors):P}async function Ur(e,t){return(await Aa({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 qr(e,t,n){let o=typeof t.author=="string"&&t.author.trim()?t.author.trim():"pm-extension";return Sa(e,ei.forActiveExtensionHost({pmRoot:e,author:o}),o,_(n))}async function Hr(e,t,n,o=[]){let a=E(e),i=Jn(e.args.map(String),o),r={...t},s={...n},l=T(process.cwd(),n.path),c=await gt({command:a,args:i,options:r,global:s,pm_root:l});n.profile&&c.warnings.length>0&&w(`profile:extensions parser_warnings=${q(c.warnings)}`),i=c.context.args,r=c.context.options,s=c.context.global,fo(P.get(_(a)),i,r,o),Ce(void 0),ut({command:a,args:i,options:{...r},global:{...s},pm_root:l});let d=await nn({command:a,args:i,options:r,global:s,pm_root:l,sdk:qr(l,s,a)});if(s.profile&&d.warnings.length>0&&w(`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 b(`Command "${a}" failed in extension handler (${m}).${u}`,f.GENERIC_FAILURE,{code:d.errorCode??"command_failed",nextSteps:d.remediation?[d.remediation]:void 0})}throw new b(`Command "${a}" is provided by extensions and is not currently available.`,f.NOT_FOUND)}return d.exitCode!==void 0&&(process.exitCode=d.exitCode),Ce(d.result),d.result}var _r=Symbol("pm.wrappedActionHandler");function sd(e,t){let n=e[e.length-1];return n instanceof No?n:t}function vr(e,t,n){e&&n.length>0&&w(`profile:extensions ${t}=${q(n)}`)}function ld(e){let t=P.get(_(e.commandPath));if(!t||!po(e.activeRegistrations,e.commandPath))return;let n=Ht(t).length===0?er(e.commandArgs):Jn(e.commandArgs,e.extensionFlagDefinitions);uo(t,n)}function cd(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 zr(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[_r]!==!0){let a=o._actionHandler;o._actionHandler=async function(...i){let r=sd(i,n),s=Date.now();hn(r);let l=Be(r),c=O(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?at(p,c,m):[],g=await Nr(c,d),h=$e(r,m,[...u,...g]),v=await gt({command:c,args:m,options:h,global:l,pm_root:d});vr(l.profile,"parser_warnings",v.warnings),m=v.context.args,h=v.context.options,ie(r,h),l=v.context.global,ld({activeRegistrations:p,commandPath:c,commandArgs:m,extensionFlagDefinitions:u}),l=await Ya(l),kt(r,l),cd(r,i,m),xt(r,h),Ce(void 0),ut({command:c,args:m,options:{...h},global:{...l},pm_root:d});let A=await nn({command:c,args:m,options:h,global:l,pm_root:d,sdk:qr(d,l,c)});if(vr(l.profile,"command_handler_warnings",A.warnings),A.handled){Ce(A.result),an(A.result,{...l,command:c,commandArgs:m,commandOptions:h,pmRoot:d}),l.profile&&w(`profile:command=${c} took_ms=${Date.now()-s}`);return}return await a.apply(this,i)},o[_r]=!0}for(let a of n.commands)t(a)};t(e)}async function Gt(e){P=new Map,te({overrides:[]}),e&&await Mo(e.rootProgram,e.pmRoot,e.invocationArgv,Ko(),e.settings)}function dd(e,t,n,o){if(t?.flags&&t.flags.length>0){zn(e,t.flags);let a=Gn(e,t.flags);a&&e.addHelpText("after",a)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function Gr(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");St(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 Wr(e,t){let n=U(t),o=T(process.cwd(),n.path);if(n.noExtensions){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let a=await Jt(o),i=Ie(t);if(!a){await Gt();return}if(!nt(a.discovery,i)){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings}),Kt(Fo(t),a,i);return}let r=await Ne(o,i);if(!r){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings});return}te(r.services),P=new Map(r.commandDescriptors),await Mo(e,o,t,r.registrations,r.settings);let s=Vi(e,r.commandHandlers,r.commandDescriptors,r.commandAliases,d=>Bi(r.activationWarnings,w,d)),l=new Set(e.commands.map(d=>d.name())),c=d=>{let m=d.split(" ").filter(L=>L.length>0),p=r.commandDescriptors.get(d),u=ee(e,m),g=r.commandFlagHelp.get(d),h=p?Gi(p):null;if(u){dd(u,p,g,h);return}let v=Wi(e,m);p?.description&&v.description(p.description);let A=g;p&&(Li(v,p),p.flags.length>0&&(zn(v,p.flags),A=Gn(v,p.flags)??void 0)),A&&v.addHelpText("after",A),h&&v.addHelpText("after",h),v.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...L)=>{let G=L[L.length-1],j=G instanceof No?G:v,ve=Be(j),Yt=Date.now(),dt=at(r.registrations,d,j.args.map(String)),De=$e(j,j.args.map(String),dt),be=await Hr(j,De,ve,dt);await Xa(ve,be),an(be,{...ve,command:d,commandArgs:j.args.map(String),commandOptions:De,pmRoot:o}),ve.profile&&w(`profile:command=${d} took_ms=${Date.now()-Yt}`)})};for(let d of s)c(d);Gr(e,l,r.commandDescriptors)}var lt=zo(import.meta.url,["../.."])??"0.0.0",y=rn(lt);async function br(e){if(!F)return;let t=Reflect.get(e,Er);typeof t=="string"&&await Qa(t)}async function Cr(e,t,n){let o=E(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}function Vr(e,t){t&&it(t)||(e.hook("preAction",async(n,o)=>{Pe=null,F=null,ft(),hn(o);let a=o.optsWithGlobals(),i=Be(o),r=O(E(o)),s=o.args.map(String),l=$e(o,s),c={...i};fa(r,{...l,outputInclude:a.outputInclude,outputLimit:a.outputLimit,outputBudget:a.outputBudget,outputFormat:a.outputFormat,outputSession:a.outputSession,outputCursor:a.outputCursor}),mo(o,r,c,l),await Cr(o,void 0,()=>qa(r,c));let d=T(process.cwd(),i.path),m=await Lr(o);if(!m){Pe=ea({commandName:r,commandArgs:s,commandOptions:l,globalOptions:c,pmRoot:d}),F=await gn({command:r,pm_version:lt,args:s,options:l,global:c,pm_root:d}),await br(e),pn(r,s,l,{source_context:F?.source_context,source_context_source:F?.source_context_source}),un(r),await Qn(r,l,d,$o()),await Zn(r,s,l,c,d);return}ta(m.hooks),na(m.commands),oa(m.parsers),aa(m.preflight),te(m.services),ia(m.renderers),ra(m.registrations);let p=at(m.registrations,r,s);l=$e(o,s,p),mo(o,r,c,l);let u=await gt({command:r,args:s,options:l,global:c,pm_root:m.pmRoot});c.profile&&u.warnings.length>0&&w(`profile:extensions parser_warnings=${q(u.warnings)}`),s=u.context.args,l=u.context.options,ie(o,l),c=u.context.global,xt(o,l);let g=await ca({command:r,args:s,options:l,global:c,pm_root:m.pmRoot,decision:$o()});c.profile&&g.warnings.length>0&&w(`profile:extensions preflight_warnings=${q(g.warnings)}`),s=g.context.args,l=g.context.options,ie(o,l),c=g.context.global,xt(o,l);let h=g.decision;await Qn(r,l,m.pmRoot,h),await Zn(r,s,l,c,m.pmRoot);let v=h.run_extension_migrations?await Cr(o,[],()=>Ur(m.registrations.migrations,m.pmRoot)):[];c.profile&&v.length>0&&w(`profile:extensions migration_warnings=${q(v)}`);let A=dr(m.registrations.migrations);Pe={hooks:m.hooks,commandName:r,commandArgs:s,commandOptions:{...l},globalOptions:{...c},pmRoot:m.pmRoot,profileEnabled:!!c.profile,migrationBlockers:A},Ce(void 0),ut({command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot}),F=await gn({command:r,pm_version:lt,args:s,options:l,global:c,pm_root:m.pmRoot}),await br(e),pn(r,s,l,{source_context:F?.source_context,source_context_source:F?.source_context_source}),un(r);let L=await Xo(m.hooks,{command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot});c.profile&&L.length>0&&w(`profile:extensions hook_warnings=${q(L)}`),h.enforce_mandatory_migration_gate&&mr(r,l,A)}),e.hook("postAction",async()=>{let n=Ao();Ge(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)}))}Vr(y);var xr=Symbol("pmCliIdempotentTopLevelRegistration");function Br(e){let t=e;if(t[xr])return;t[xr]=!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 No(i):n(o,...a)})}async function md(e,t){if(Br(e),t.setup){let{registerSetupCommands:n}=await Zc();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Qc(),o=typeof t.targetCommandName=="string"&&go.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await ed();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await td();n(e)}}function pd(e){return async t=>{let n=mt(t.errorCode),o=bt({ok:!1,errorCode:t.errorCode,errorCategory:n});return await za({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:lt,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 Kr(e){if(e.bootstrapGlobal.noExtensions||it(e.invocationArgv))return;let t=Ie(e.invocationArgv),n=await Jt(e.bootstrapPmRoot);if(n&&nt(n.discovery,t)){let o=await Ne(e.bootstrapPmRoot,t);Jr(o);return}n&&Kt(Fo(e.invocationArgv),n,t),te({overrides:[]})}function Jr(e){if(!e){te({overrides:[]});return}te(e.services)}async function jo(e){Ge(!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 Yr(){Ge(!0,void 0,{exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await ct({ok:!0,exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=f.SUCCESS}async function Xr(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof b)&&(cn(e.error)||!n))return!1;let o=de(e.error),a=e.error instanceof b?e.error.exitCode:ln(t),i=e.error instanceof b?e.error.context:void 0,r=Ar(i,e.invocationArgv,o),s=bi(o,r),l=e.bootstrapGlobal.lean?Tt(Nn(o,a,r)):Nn(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
|
-
`):
|
|
27
|
+
`)}`}function Vn(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 Ye(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:Vn(o).includes(n))??null}function te(e,t){let n=e;for(let o of t){let a=Ye(n,o);if(!a)return null;n=a}return n}var Bn=new WeakSet;function Ji(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&&I.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let i=Ye(n,a);if(i){n=i;continue}let r=n.command(a);Bn.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 Kl(e,t){let n=t.join(" "),o=I.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=Ye(a,r);if(!s)return null;i.push(r);let l=s.commands.length>0||I.some(c=>c.canonical.startsWith(`${i.join(" ")} `));if(!Bn.has(s)&&(i.length===t.length||!l))return{core_path:i.join(" "),extension_path:t.join(" ")};a=s}return null}function Jl(e,t,n,o,a=!1){let i=t.split(" ").filter(d=>d.length>0),r=Kl(e,i),s=te(e,i),l=I.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||Bn.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 Yi(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=Jl(e,i,o,n.get(i),t.includes(i));return r?(a(r),!o.has(i)&&te(e,i.split(" "))!==null):!0})}function Xi(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]="c4cd4b1c-7043-53a0-8823-d47339372420")}catch{}})();var Yl=new Set(["__proto__","prototype","constructor"]),Zi=Symbol("looseOptionOccurrences");function Xe(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(t,n)=>n.toUpperCase())}function Xl(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 Kn(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)};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)};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 Yl.has(e)}function Qi(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Zo(t)}function Ze(e){let t=[],n=typeof e.long=="string"?e.long.trim():"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let a=Xe(n.slice(2));a.length>0&&!Nt(a)&&t.push(a)}if(o.startsWith("-")&&!o.startsWith("--")){let a=Xe(o.slice(1));a.length>0&&!Nt(a)&&t.push(a)}return[...new Set(t)]}function er(e){let t=new Set;for(let n of e)for(let o of Ze(n))t.add(o);return t}function Zl(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")){let n=Xe(t.slice(2));if(n.length>0&&!Nt(n))return n}return Ze(e)[0]??null}function Ql(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 Jn(e,t,n){if(t.length===0)return;let o=new Set,a=new Map,i=[],r=[];for(let s of t){let l=Ze(s),c=Ql(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 b(`Unknown option '--${s}' for extension command '${n}'.${c}`,g.USAGE)}let l=a.get(s);if(l)throw new b(`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 b(`Missing required option '${s.label}' for extension command '${n}'.`,g.USAGE)}function ec(e){return typeof e=="string"||e==null?e:String(e)}function tc(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 nc(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 oc={string:ec,number:tc,boolean:nc};function Dt(e,t){return Array.isArray(e)?e.map(n=>Dt(n,t)):oc[t](e)}function tr(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(a=>a!=null&&a!==""):Qo(e);return t?o.map(a=>Dt(a,t)):o}function ac(e,t,n,o){return n?tr(e,t,o):t?Dt(e,t):e}function ic(e,t,n){let o=e[Zi];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 nr(e,t,n=e){if(t.length===0)return e;let o=Object.create(null);for(let[a,i]of Object.entries(e))o[a]=i;for(let a of t){let i=Zl(a);if(!i)continue;let r=a.list===!0,s=Ze(a);for(let d of s)if(!(d===i||!Object.hasOwn(o,d))){if(Object.hasOwn(o,i)){if(!r){delete o[d];continue}let m=o[i],p=o[d];o[i]=[...Array.isArray(m)?m:[m],...Array.isArray(p)?p:[p]].filter(u=>u!=null),delete o[d];continue}o[i]=o[d],delete o[d]}let l=Qi(a),c=a.repeatable===!0;if(!Object.hasOwn(o,i)){a.default!==void 0&&(o[i]=ac(a.default,l,r,c));continue}if(r){o[i]=tr(ic(n,s,o[i]),l,c);continue}l&&(o[i]=Dt(o[i],l))}return o}function or(e){let t=Object.create(null),n=[];Object.defineProperty(t,Zi,{value:n});let o=0;for(;o<e.length;){let a=Kn(e,o);if(!a){o+=1;continue}let i=Xe(a.key);if(i.length===0||Nt(i)){o+=a.consumed;continue}Xl(t,i,a.value),n.push({...a,key:i}),o+=a.consumed}return t}function ar(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=Kn(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function Yn(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let r of t){let s=Qi(r);for(let l of Ze(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=Kn(e,i);if(r){let s=Xe(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 Oe 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 Xn(e,t={},n=[]){let o={readSettings:N,loadExtensions:Me,activateExtensions:Fe,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(M).filter((p,u,f)=>p.length>0&&f.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),d=n.map(M),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 ir(e,t,n={},o=[]){if(e!=="unknown_command")return[];let a=await Xn(t,n,o),i={readSettings:N,loadExtensions:Me,activateExtensions:Fe,resolveImplicitPmRoot:tn,...n};try{let r=i.resolveImplicitPmRoot(process.cwd());if(Oe.resolve(r)===Oe.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=${Oe.resolve(t)} extension_discovery_root=${c.roots.project}; cwd_storage_root=${Oe.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 ${Oe.resolve(r)}, or install the extension into the selected tracker with "pm --pm-path ${Oe.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 rr={core:0,standard:1,full:2,internal:3};function sr(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)=>rr[l.tier]<rr[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 lr(e,t){if(t.length===0)return e;let n=te(e,t);if(n)return n;let o=t.join(" ");if(P(o)!==o||!je.some(a=>a===o)&&!Ia(o)&&!Ue(o)&&!Ae(e,t))return null;for(let a=t.length-1;a>0;a-=1){let i=te(e,t.slice(0,a));if(i)return i}return t.length===1?e:null}function rc(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function cr(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 sc(e){let t=new Map;for(let n of e){let o=n,a=cr(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 lc(e){return x(e)}function cc(e){let t=e.options??[],n=sc(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=cr(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:rc(i),variadic:a.variadic===!0,required:m,aliases:l,alias_for:d};return a.defaultValue!==void 0&&(f.default_value=a.defaultValue),f})}function dc(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 mc(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 pc(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=M(E(a)),r=i,s=ue(a),l=sr(i,t,s!==void 0),c=B.find(({alias:d})=>d===i);return{name:a.name().trim(),aliases:Vn(a),description:a.description().trim(),tier:l?.tier??s??X(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 uc(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 fc(e,t,n,o,a){let i=e!==void 0&&kn(e)===ke,r=i?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:gi(e,n),s=a?"positional_action":o?.intent||o?.description?"extension":i?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:uc(n,r,o),intentSource:s}}function gc(e,t){return e===void 0?null:t?.tier??X(e)}function hc(e,t){return e===void 0?null:t?.family??Ct(e)}function yc(e,t,n){if(!(t!==e||!n))return B.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:lr(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function wc(e,t,n,o,a=new Map,i=!1){if(!e){let s=mc(t),l=pc(t,a,i),c=new Set(l.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...l,..._t.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: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 _c(e,t,n,o,a){let i=xn(n),r=ae(n),s=M(E(t)),l=M(o.join(" ")),c=l.length>s.length?l:s,d=Ue(c),m=d?.command??s,p=m.length>0?m:void 0,u=p,f=p?a.get(P(p)):void 0,h=p?sr(p,a,ue(t)!==void 0):void 0,{narrative:w,intentSource:O}=fc(p,t.description().trim(),i,f,d!==void 0),j=dc(Bi(cc(t),Vi(f))),G=wc(d,t,m,j,a,r),U=yc(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:gc(u,h),capability_family:hc(u,h),description:d?.description??t.description(),usage:G.usage,intent:d?.description??w.intent,intent_source:O,examples:d?[d.example]:w.examples,tips:d?[vt(d.accepted_flags)]:w.tips,arguments:G.arguments,options:G.options,subcommands:G.subcommands,has_subcommands:G.subcommands.length>0,...U===void 0?{}:{command_aliases:U}}}async function dr(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=lr(e,i.commandPathTokens);if(!r){if(!a.quiet){let s=`unknown command '${i.commandPathTokens.join(" ")}'`,l=Un(s,e,n,t),c=It(s,"help",Be,g.USAGE,{...l,attemptedCommand:lc(t),normalizedInvocationArgs:[...t],providedOptionFlags:Z(t)}),d=a.tokenAccounting?de(c,m=>`${JSON.stringify(m,null,2)}
|
|
28
|
+
`):c;Ce(`${JSON.stringify(d,null,2)}
|
|
29
|
+
`)}return process.exitCode=g.USAGE,!0}if(!a.quiet){let s=_c(e,r,t,i.commandPathTokens,n),l=A(o).commandPathTokens;s.requested_path=l;let c=V(l.join(" "));c&&(s.resolved_path=c.canonical),r===e&&!ae(t)&&(s.omission_receipt={has_omissions:!0,omitted_field_group_count:1,omitted_field_groups:[{name:"command_aliases",restore_with:"--all"}]}),Ca(`${JSON.stringify(s,null,2)}
|
|
30
|
+
`)}return process.exitCode=g.SUCCESS,!0}function vc(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(`
|
|
31
|
+
`)}function bc(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 Cc(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 xc(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(ti).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 kc(e,t,n){let o=$a(n);if(!o)return vc(e,t);let a=Ko(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(`
|
|
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=Cc(e,a),m=pt(a,e,d.progressive),p=pt(a,e,c?d.strict:d.progressive),u=h=>h.length>0?h.map(w=>en(e,w)).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);xc(f,a,m.required,h.required)}return bc(f,a),p.errors.length>0&&f.push(` config errors: ${p.errors.join("; ")}`),f.join(`
|
|
33
|
+
`)}function mr(e,t,n){let o=k(n);if(o!=="create"&&o!=="update")return;let a=Ye(e,o);a&&a.addHelpText("after",kc(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 Ec(e,t){return De(e.id)||`migration-${String(t+1).padStart(3,"0")}`}function Sc(e){return De(e.status)?.toLowerCase()??"pending"}function Ac(e){return e.mandatory===!0}function Oc(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 fr(e){let t=[];return e.forEach((n,o)=>{if(!Ac(n.definition))return;let a=Sc(n.definition);a!=="applied"&&t.push({layer:n.layer,name:n.name,id:Ec(n.definition,o),status:a})}),t.sort(Oc),t}function pr(e){return Array.isArray(e)&&e.length>0}var Tc=new Set(["create","beads import","todos import"]),Rc=new Set(["restore","update","close","delete","append","claim","release"]),Ic=new Set(["comments","notes","learnings"]),Pc=new Set(["files","docs","test"]),$c=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 Zn(e,t){let n=t.force===!0;return Tc.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:Rc.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:Ic.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:Pc.has(e)?{isMutation:pr(t.add)||pr(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function Nc(e,t,n){if(Zn(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return Ha(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(a=>$c.has(a.trim().toLowerCase())):!1}function ur(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function Dc(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(De(t[1])||a.push("source"),De(n.to)||a.push("--to"),a.length!==0)throw new b(`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 Mc(e,t,n,o,a){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||ur(n.status)!==ur(a.schema.workflow.in_progress_status))return;let i=t[0];if(!i)return;let r=se(a,le()),s=await wt(o,i,a.id_prefix,a.item_format,r.type_to_folder);if(!s)return;let l=await Oa(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 Qn(e,t,n,o,a){if(!Nc(e,t,n)||(Dc(e,t,n),!await K(J(a))))return;let i=await xe(a);o.json!==!0&&await Mc(e,t,n,a,i.settings);let r=qa({author:ht(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 gr(e,t,n){if(n.length===0)return;let o=Zn(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 b(`Write command "${e}" blocked by unresolved mandatory extension migrations (${a.join(",")}). ${i}`,g.CONFLICT)}async function eo(e,t,n,o){if(!Zn(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await K(J(n)))return;let{settings:a,metadata:i,warnings:r}=await xe(n);for(let s of r)_(`warning:${s}`);if(o.enforce_item_format_gate&&!i.has_explicit_item_format&&(Sa(a),await Aa(n,a,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let s=se(a,le());await za(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 to(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=v(n);o.length!==0&&t.push(o)}return t}function Re(e){let t=v(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(a=>a.length>0);for(let a of to(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 no(e,t){let n=v(e);if(n.length===0)return!1;let o=Re(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?[...T(n.commands),...T(n.command_handlers),...T(n.command_overrides),...T(n.flag_commands),...T(n.parser_overrides),...hr(n.preflight_ownership),...hr(n.renderer_ownership)]:[]}function T(e){return e??[]}function hr(e){return T(e).flatMap(t=>t.commands)}function Qe(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var yr=new Set(["hooks","parser","preflight","renderers"]),wr=new Set(["commands","schema","services","importers"]),Fc=new Set(["reindex","search","search-advanced"]),Lc=new Set(["--template"]);function Te(e,t){for(let n of t)if(e.has(n))return!0;return!1}function oo(e){let t=v(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return Fc.has(n??t)}function ao(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 Lt(e){return v(e.commandPath??"")==="create"&&ao(e,Lc)}function io(e){return e.some(t=>{let n=v(t);return n==="templates"||n.startsWith("templates ")})}function Mt(e,t){return e.some(n=>no(n,t))||Lt(t)&&io(e)}function ro(e){return[T(e.hooks).length,(e.preflight_overrides??0)-T(e.preflight_ownership).length,T(e.item_types).length,T(e.item_fields).length,T(e.relationship_kinds).length,T(e.service_overrides).length,T(e.assurance_providers).length,T(e.renderer_overrides).length-T(e.renderer_ownership).length].some(t=>t>0)}function so(e,t){let n=e.activation?.commands??[];if(n.length>0)return Mt(n,t);let o=Ft(e);if(Mt(o,t)||Qe(e).has("search")&&oo(t.commandPath))return!0;if(e.contributions)return ro(e.contributions)}function jt(e,t){let n=so(e,t);if(n!==void 0)return n;let o=Qe(e);return!!(Te(o,yr)||Te(o,wr))}function et(e,t){return e.effective.length===0?!1:tt(t)!=="all"?e.effective.some(n=>jt(n,t)):e.effective.some(n=>{let o=Qe(n);return Ft(n).length>0||Te(o,yr)||Te(o,wr)||o.has("search")})}function tt(e){if(v(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Re(e).filter(o=>o.split(" ").every(a=>!a.startsWith("-"))).sort((o,a)=>a.length-o.length)[0]??v(e.commandPath??"");if(t.length===0)return"all";let n=Lt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function lo(e){return tt(e)==="all"?void 0:t=>jt(t,e)}function Ie(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=D(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 co(e){let t=e.args.map(String);if(v(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]="2fe1a4e5-3c55-5ec3-a729-2216a298c081")}catch{}})();var Ut=Symbol.for("pm.readOutputInvocationProvenance");function re(e,t){let n=Reflect.get(e,Ut);n!==void 0&&Reflect.set(t,Ut,n)}function mo(e,t,n){let o=ha(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=ga.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,Ut);Reflect.set(n,Ut,{canonical_include_modes:c?.canonical_include_modes??[],explicit_legacy_aliases:l,cli_invocation_observed:!0}),re(n,e)}function jc(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 b(`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 po(e,t,n,o){mo(e,t,o);let a=n.outputInclude;if(a===void 0)return;let{selectors:i,modes:r}=_a(t,a,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),r.length===0)return;re(o,e);let s=wa(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 Pe(e,t,n=[]){let o={...jc(e)};re(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=or(t);for(let[i,r]of Object.entries(a))o[i]===void 0&&(o[i]=r);if(n.length>0){let i=er(n),r=oe(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]);Jn(s,[...r,...n],E(e));let l=nr(o,n,a);return re(o,l),l}return o}function qt(e,t){let n=v(t);return n.length===0?[]:e.flags.filter(o=>P(v(o.target_command))===P(n)).flatMap(o=>o.flags)}function nt(e,t,n){let o=qt(e,t),a=[t],i=[];for(let r of n){if(r.startsWith("-"))break;a.push(r);let s=qt(e,a.join(" "));s.length>0&&(i=s)}return i.length>0?i:o}function Ht(e){return e.arguments??[]}function _r(e){let t=Ht(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function uo(e,t){if(!e)return!1;let n=v(t);return e.importers.some(o=>v(`${o.importer} import`)===n)||e.exporters.some(o=>v(`${o.exporter} export`)===n)}function fo(e,t){let n=Ht(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 b(`Missing required argument for extension command '${e.command}'. Usage: ${_r(e)}${r}`,g.USAGE);if(t.length>a){let s=t.slice(a).join(" ");throw new b(`Too many arguments for extension command '${e.command}': ${s}. Usage: ${_r(e)}${r}`,g.USAGE)}}function Uc(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function qc(e,t,n){if(n.length>0){Jn(t,n,e.command);return}let o=Object.keys(t).filter(a=>t[a]!==void 0).sort();if(o.length!==0)throw new b(`Unknown option '${o.map(Uc).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,g.USAGE)}function go(e,t,n,o){e&&(fo(e,t),qc(e,n,o))}import{Command as vr}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 Hc=new Set(["--version","-V"]);function ot(e){let t=D(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}function br(e){if(D(e)[0]!=="item"||!e.includes("--dry-run"))return;let t=new vr().configureOutput({writeErr:()=>{}}).exitOverride(),n=new Set;for(let a of qe)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 zc=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),ho=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"]),Cr=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"]),Gc=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),Wc=new Set(["claim","close-task","pause-task","release","start-task","test"]),ye={setup:!0,listQuery:!0,mutation:!0,operation:!0},Vc=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 at(e){return e.some(t=>Hc.has(t))}function Bc(e,t){if(!I.some(o=>o.canonical_argv[0]===t))return;let n=new vr().configureOutput({writeErr:()=>{}}).exitOverride();for(let o of Ba(t,oe(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 ye;let a=W([t,...o.operands])?.alias;if(I.some(i=>i.alias===a))return{...ye,targetCommandName:a}}catch{return ye}}function yo(e){if(at(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||A(e).requested)return ye;let t=k(e);if(!t)return ye;let n=t.trim().toLowerCase(),o=D(e),a=W(o)?.alias;return I.some(i=>i.alias===a)?{...ye,targetCommandName:a}:Bc(o,n==="ctx"?"context":n)||(zc.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:ho.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:Cr.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:Gc.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:ye)}function wo(e){return e.length===0||A(e).requested||e.includes("--explain")&&k(e)===void 0}function _o(e,t){return ot(t)||at(t)?!1:ae(t)||A(t).requested?!0:!!k(t)}function vo(e){if(at(e))return!1;let t=k(e);return t?Vc.has(t):!1}function Kc(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=Le(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 bo(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=Cr.has(t)||Wc.has(t),r=i?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=i?"mutating option":"option",l=Kc({argv:e.argv,normalizedDisplay:a,normalizedTokens:o,rawFrom:n.from});throw new b(`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:[x(l.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:l.argv,suggested_retry:x(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 Jc=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"]),Yc=new Set(["parse","preflight","execute","unknown"]),Xc=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 Co(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function zt(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 xo(e){if(!e)return;let t=e.trim().toLowerCase();if(Jc.has(t))return t}function ko(e){if(!e)return;let t=e.trim().toLowerCase();if(Yc.has(t))return t}function Eo(e){if(!e)return;let t=e.trim().toLowerCase();if(Xc.has(t))return t}function So(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(Co(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let o=zt(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=>Qt(r)?.status==="failed").length;if(i>0)return`failed_runs:${i}`}}function Ao(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 Oo(){let e=Qt(ce()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=zt(e,"exit_code","exitCode"),o=t??n??g.SUCCESS,a=Xa(o),i=we(e,"error_code","errorCode")??Ao(a,o),r=Eo(we(e,"error_category","errorCategory"))??(a?void 0:mt(i)),s=a?void 0:So(e)??`command_exit_${o}`,l=xo(we(e,"command_resolution","commandResolution"))??bt({ok:a,errorCode:i,errorCategory:r}),c=ko(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]="19f4cc1d-7f76-5759-878d-bfdf83194eca")}catch{}})();var To="PM_CLI_PACKAGE_ROOT",Tr=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 Zc(){return Wo(import.meta.url,["../.."])}(typeof process.env[To]!="string"||process.env[To]?.trim().length===0)&&(process.env[To]=Zc());var $e=null,L=null;function Qc(e){$e=e}function ed(e){R=e}var it=null,_e=null,R=new Map,Mo=250,td=new Set([g.USAGE,g.NOT_FOUND,g.CONFLICT]),nd=new Set(["1","true","yes","on"]),od=We(()=>import("./chunks/register-setup-5E3PT22L.js")),ad=We(()=>import("./chunks/register-list-query-OR33UEML.js")),id=We(()=>import("./chunks/register-mutation-R34EJ3NH.js")),rd=We(()=>import("./chunks/register-operations-UHSMEHSF.js"));function Wt(e){return x(e)}function Rr(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 sd(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=Rr(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)||zn(t,r,m,R)!==void 0});return c&&c.length>0?c:void 0}function ld(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=zn(e,r,i,R),d=i?l?.isBoolean()===!0||c===!1?[i]:[i,"<value>"]:[],m=i?Wt([...e,...d]):t;return m===t?void 0:m}function cd(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 dd(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,...cd(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function Ir(e,t,n){let o=Le(t),a=D(o),i=Y(a),[r,s]=i===void 0?[]:a.slice(i,i+2),l=o.includes("--explain"),c=li(o,e?.code,e?.recovery),d=c&&(r==="history-redact"||r==="history"&&s==="redact")?{...c,...c.attempted_command?{attempted_command:Wt(o)}:{},...c.normalized_args?{normalized_args:[...o]}:{},...c.suggested_retry?{suggested_retry:Wt(o)}:{},...c.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:c;if(d?.recovery_mode==="compact"&&!l)return{...e,recovery:d};let m=Wt(o),p=Z(o),u=sd(n,o,d),f=ld(o,m,u,d),h=dd({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:f,existingRecovery:d});return{...e,recovery:h}}async function st(e){let t=L;L=null,await ci(t,e);let n=$e;if($e=null,!n){ft();return}let o=[],a=ma();try{await di({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 ta(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:ce(),affected:a}))}catch(i){o=[`afterCommand hooks failed: ${i instanceof Error?i.message:String(i)}`]}finally{ft()}!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 Pr(){await ja()}function $r(e){return nd.has((process.env[e]??"").trim().toLowerCase())}function Nr(e){return $r("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!td.has(Math.trunc(e))}async function Bt(e){return Nr(e.exit_code)?(await Pr(),Ua(e),!0):!1}async function Dr(e){let t=me(e.error),n=Ti(t);e.bootstrapGlobal.json?_(JSON.stringify(Ai(t,g.GENERIC_FAILURE),null,2)):_(t),process.exitCode=g.GENERIC_FAILURE;let o="runtime",a="runtime_failed";try{await Pr(),gn(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,ze(!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: ${me(i)}`)}try{await st({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: ${me(i)}`)}try{await Ge()}catch(i){e.bootstrapGlobal.json||_(`Failed to flush error reporting: ${me(i)}`)}}var md={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"},Ro=new Map;function Io(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function Mr(e,t){return e.options.some(n=>n.long===t)}function Fr(e,t){return e.options.some(n=>n.short===t)}function Po(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(Fr(e,a))return;if(o){e.option(`${a} <value>`,`${i} (repeatable)`,wn);return}e.option(`${a} <value>`,i);return}let r=a.startsWith("--")?a:`--${a}`;if(!Mr(e,r)){if(o){e.option(`${r} <value>`,`${i} (repeatable)`,wn);return}e.option(`${r} <value>`,i)}}async function Lr(e,t){let n=md[e];if(!n)return[];let o=`${t}:${n}`,a=Ro.get(o);if(a)return a;if(!await K(J(t)))return Ro.set(o,[]),[];let i=await N(t),r=(pn(i.schema).command_to_fields.get(n)??[]).flatMap(s=>[s.cli_flag,...s.cli_aliases].map(l=>({long:`--${l}`,type:Io(s.type),value_type:Io(s.type)})));return Ro.set(o,r),r}async function jr(e,t){let n=F(t),o=S(process.cwd(),n.path);if(!await K(J(o)))return;let a=_e?.key===jo(o)?_e.snapshot:null,i=a===null?await N(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=te(e,l.path.split(" "));if(c)for(let d of r.command_to_fields.get(l.command)??[]){let m=d.description??"";Po(c,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)Po(c,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function Fo(e,t,n,o,a){let i=k(n);if(!(i!=="create"&&i!=="update"))try{let r=a??await N(t),s=se(r,o);mr(e,s,n)}catch{}}function $o(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function Ur(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function Lo(e){return e.some(t=>t==="--profile")}function jo(e){return`pm-root:${e}`}function No(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 qr(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 Kt(e,t,n){if(!e)return;let o=v(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 Jt(e,t=xe){let n=jo(e);if(_e?.key===n)return _e.snapshot;try{let o=Date.now(),{settings:a,warnings:i}=await t(e),r=await na({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 Ne(e,t,n=N){let o=t?tt(t):"all",a=Ur(e,o);if(it?.key===a)return it.snapshot;try{let i=await n(e),r=await Me({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?lo(t):void 0}),s=await Fe({...r,loaded:r.loaded}),l=[...new Set(s.commands.handlers.map(u=>v(u.command)))].filter(u=>u.length>0).sort((u,f)=>u.localeCompare(f)),c=ji(s.registrations.flags),d=Fi(s.commands.handlers,s.registrations.commands),m=qi(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 it={key:a,snapshot:p},p}catch{return it={key:a,snapshot:null},null}}async function Hr(e){let t=Ve(e);if(t.noExtensions){let r=S(process.cwd(),t.path);return await K(J(r))&&No((await xe(r)).warnings),null}let n=S(process.cwd(),t.path),o=await Jt(n);if(!o)return null;No(o.settingsReadWarnings);let a={commandPath:E(e),commandArgs:co(e)};if(!et(o.discovery,a))return Kt(t.profile,o,a),null;let i=await Ne(n,a);return i?(qr(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 Uo(e){let t=await Ne(e);return t?new Map(t.commandDescriptors):R}async function pd(e,t){return!e.requested||t.noExtensions||Ae(y,e.commandPathTokens)?R:Uo(S(process.cwd(),t.path))}async function zr(e,t){return(await Ra({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 Gr(e,t,n){let o=typeof t.author=="string"&&t.author.trim()?t.author.trim():"pm-extension";return Ta(e,oi.forActiveExtensionHost({pmRoot:e,author:o}),o,v(n))}async function Wr(e,t,n,o=[]){let a=E(e),i=Yn(e.args.map(String),o),r={...t},s={...n},l=S(process.cwd(),n.path),c=await gt({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,go(R.get(v(a)),i,r,o),be(void 0),ut({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:Gr(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 b(`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 b(`Command "${a}" is provided by extensions and is not currently available.`,g.NOT_FOUND)}return d.exitCode!==void 0&&(process.exitCode=d.exitCode),be(d.result),d.result}var xr=Symbol("pm.wrappedActionHandler");function ud(e,t){let n=e[e.length-1];return n instanceof Do?n:t}function kr(e,t,n){e&&n.length>0&&_(`profile:extensions ${t}=${q(n)}`)}function fd(e){let t=R.get(v(e.commandPath));if(!t||!uo(e.activeRegistrations,e.commandPath))return;let n=Ht(t).length===0?ar(e.commandArgs):Yn(e.commandArgs,e.extensionFlagDefinitions);fo(t,n)}function gd(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 Vr(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[xr]!==!0){let a=o._actionHandler;o._actionHandler=async function(...i){let r=ud(i,n),s=Date.now();yn(r);let l=Ve(r),c=P(E(r));if(["package inventory","packages inventory","extension inventory"].includes(c))return await a.apply(this,i);let d=S(process.cwd(),l.path),m=r.args.map(String),p=le(),u=p?nt(p,c,m):[],f=await Lr(c,d),h=Pe(r,m,[...u,...f]),w=await gt({command:c,args:m,options:h,global:l,pm_root:d});kr(l.profile,"parser_warnings",w.warnings),m=w.context.args,h=w.context.options,re(r,h),l=w.context.global,fd({activeRegistrations:p,commandPath:c,commandArgs:m,extensionFlagDefinitions:u}),l=await Qa(l),kt(r,l),gd(r,i,m),xt(r,h),be(void 0),ut({command:c,args:m,options:{...h},global:{...l},pm_root:d});let O=await on({command:c,args:m,options:h,global:l,pm_root:d,sdk:Gr(d,l,c)});if(kr(l.profile,"command_handler_warnings",O.warnings),O.handled){be(O.result),rn(O.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[xr]=!0}for(let a of n.commands)t(a)};t(e)}async function Gt(e){R=new Map,ne({overrides:[]}),e&&await Fo(e.rootProgram,e.pmRoot,e.invocationArgv,Xo(),e.settings)}function hd(e,t,n,o){if(t?.flags&&t.flags.length>0){Gn(e,t.flags);let a=Wn(e,t.flags);a&&e.addHelpText("after",a)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function Br(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");St(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 Kr(e,t){let n=F(t),o=S(process.cwd(),n.path);if(n.noExtensions){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let a=await Jt(o),i=Ie(t);if(!a){await Gt();return}if(!et(a.discovery,i)){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings}),Kt(Lo(t),a,i);return}let r=await Ne(o,i);if(!r){await Gt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:a.settings});return}ne(r.services),R=new Map(r.commandDescriptors),await Fo(e,o,t,r.registrations,r.settings);let s=Yi(e,r.commandHandlers,r.commandDescriptors,r.commandAliases,d=>Xi(r.activationWarnings,_,d)),l=new Set(e.commands.map(d=>d.name())),c=d=>{let m=d.split(" ").filter(j=>j.length>0),p=r.commandDescriptors.get(d),u=te(e,m),f=r.commandFlagHelp.get(d),h=p?Ki(p):null;if(u){hd(u,p,f,h);return}let w=Ji(e,m);p?.description&&w.description(p.description);let O=f;p&&(Hi(w,p),p.flags.length>0&&(Gn(w,p.flags),O=Wn(w,p.flags)??void 0)),O&&w.addHelpText("after",O),h&&w.addHelpText("after",h),w.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...j)=>{let G=j[j.length-1],U=G instanceof Do?G:w,ve=Ve(U),Yt=Date.now(),lt=nt(r.registrations,d,U.args.map(String)),ct=Pe(U,U.args.map(String),lt),dt=await Wr(U,ct,ve,lt);await ei(ve,dt),rn(dt,{...ve,command:d,commandArgs:U.args.map(String),commandOptions:ct,pmRoot:o}),ve.profile&&_(`profile:command=${d} took_ms=${Date.now()-Yt}`)})};for(let d of s)c(d);Br(e,l,r.commandDescriptors)}var rt=Vo(import.meta.url,["../.."])??"0.0.0",y=sn(rt);async function Er(e){if(!L)return;let t=Reflect.get(e,Tr);typeof t=="string"&&await ni(t)}async function Sr(e,t,n){let o=E(e);return["item mutate","item complete"].includes(o)&&e.optsWithGlobals().dryRun===!0?t:n()}function Jr(e,t){t&&ot(t)||(e.hook("preAction",async(n,o)=>{$e=null,L=null,ft(),yn(o);let a=o.optsWithGlobals(),i=Ve(o),r=P(E(o)),s=o.args.map(String),l=Pe(o,s),c={...i};ya(r,{...l,outputInclude:a.outputInclude,outputLimit:a.outputLimit,outputBudget:a.outputBudget,outputFormat:a.outputFormat,outputSession:a.outputSession,outputCursor:a.outputCursor}),po(o,r,c,l),await Sr(o,void 0,()=>Ga(r,c));let d=S(process.cwd(),i.path),m=await Hr(o);if(!m){$e=oa({commandName:r,commandArgs:s,commandOptions:l,globalOptions:c,pmRoot:d}),L=await hn({command:r,pm_version:rt,args:s,options:l,global:c,pm_root:d}),await Er(e),un(r,s,l,{source_context:L?.source_context,source_context_source:L?.source_context_source}),fn(r),await eo(r,l,d,$o()),await Qn(r,s,l,c,d);return}aa(m.hooks),ia(m.commands),ra(m.parsers),sa(m.preflight),ne(m.services),la(m.renderers),ca(m.registrations);let p=nt(m.registrations,r,s);l=Pe(o,s,p),po(o,r,c,l);let u=await gt({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,re(o,l),c=u.context.global,xt(o,l);let f=await pa({command:r,args:s,options:l,global:c,pm_root:m.pmRoot,decision:$o()});c.profile&&f.warnings.length>0&&_(`profile:extensions preflight_warnings=${q(f.warnings)}`),s=f.context.args,l=f.context.options,re(o,l),c=f.context.global,xt(o,l);let h=f.decision;await eo(r,l,m.pmRoot,h),await Qn(r,s,l,c,m.pmRoot);let w=h.run_extension_migrations?await Sr(o,[],()=>zr(m.registrations.migrations,m.pmRoot)):[];c.profile&&w.length>0&&_(`profile:extensions migration_warnings=${q(w)}`);let O=fr(m.registrations.migrations);$e={hooks:m.hooks,commandName:r,commandArgs:s,commandOptions:{...l},globalOptions:{...c},pmRoot:m.pmRoot,profileEnabled:!!c.profile,migrationBlockers:O},be(void 0),ut({command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot}),L=await hn({command:r,pm_version:rt,args:s,options:l,global:c,pm_root:m.pmRoot}),await Er(e),un(r,s,l,{source_context:L?.source_context,source_context_source:L?.source_context_source}),fn(r);let j=await ea(m.hooks,{command:r,args:s,options:{...l},global:{...c},pm_root:m.pmRoot});c.profile&&j.length>0&&_(`profile:extensions hook_warnings=${q(j)}`),h.enforce_mandatory_migration_gate&&gr(r,l,O)}),e.hook("postAction",async()=>{let n=Oo();ze(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 st(n)}))}Jr(y);var Ar=Symbol("pmCliIdempotentTopLevelRegistration");function Yr(e){let t=e;if(t[Ar])return;t[Ar]=!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 Do(i):n(o,...a)})}async function yd(e,t){if(Yr(e),t.setup){let{registerSetupCommands:n}=await od();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await ad(),o=typeof t.targetCommandName=="string"&&ho.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await id();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await rd();n(e)}}function wd(e){return async t=>{let n=mt(t.errorCode),o=bt({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Va({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:rt,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 Xr(e){if(e.bootstrapGlobal.noExtensions||ot(e.invocationArgv))return;let t=Ie(e.invocationArgv),n=await Jt(e.bootstrapPmRoot);if(n&&et(n.discovery,t)){let o=await Ne(e.bootstrapPmRoot,t);Zr(o);return}n&&Kt(Lo(e.invocationArgv),n,t),ne({overrides:[]})}function Zr(e){if(!e){ne({overrides:[]});return}ne(e.services)}async function qo(e){ze(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await st({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 Qr(){ze(!0,void 0,{exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await st({ok:!0,exit_code:g.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=g.SUCCESS}async function es(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof b)&&(dn(e.error)||!n))return!1;let o=me(e.error),a=e.error instanceof b?e.error.exitCode:cn(t),i=e.error instanceof b?e.error.context:void 0,r=Ir(i,e.invocationArgv,o),s=Ei(o,r),l=e.bootstrapGlobal.lean?Tt(Dn(o,a,r)):Dn(o,a,r),c=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?de(l,u=>`${JSON.stringify(u,null,2)}
|
|
34
|
+
`):l,null,2):ki(o,r);e.jsonErrors?Ce(`${c}
|
|
35
|
+
`):_(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 Bt({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:L?.source_context});return await qo({errorMessage:o,exitCode:a,classificationCode:s.code,errorCategory:d,commandResolution:m,resolutionStage:"execute"}),p&&(gn(mn(e.error,o)),await Ge(Mo)),process.exitCode=a,!0}async function ts(e,t){let n=A(e.invocationArgv).commandPathTokens.join(" ")||Ln(e.invocationArgv),o=P(n),a=`unknown command '${n}'`,i=S(process.cwd(),e.bootstrapGlobal.path),r=e.bootstrapGlobal.noExtensions?R:await Uo(i),s=Ie(e.invocationArgv),l=e.bootstrapGlobal.noExtensions?[]:await Xn(i,{},Re(s)),c=await Je({message:a},y,r,{failedExtensions:l},e.invocationArgv),d=Mn(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 Bt({command:o,error_code:d.code,error_category:m,exit_code:g.USAGE,error_message:d.detail,command_resolution:p,resolution_stage:"parse"}),f=e.jsonErrors?await Hn({message:a},y,r,e.bootstrapGlobal.lean===!0,{failedExtensions:l},e.invocationArgv):await qn({message:a},y,r,{failedExtensions:l},e.invocationArgv),h=Fn(f,e.jsonErrors,l);await qo({errorMessage:a,exitCode:g.USAGE,classificationCode:d.code,errorCategory:m,commandResolution:p,resolutionStage:"parse"}),e.jsonErrors?Ce(`${h}
|
|
36
|
+
`):_(h),u&&await Ge(Mo),process.exitCode=g.USAGE}async function ns(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&&!Ae(y,o.commandPathTokens)?(await ts(e,t),!0):(await Qr(),!0)}async function os(e,t){let n=await Je(e.error,y,R,{},e.invocationArgv),o=Mn(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 Bt({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:L?.source_context}),s=e.jsonErrors?await Hn(e.error,y,R,e.bootstrapGlobal.lean===!0,{},e.invocationArgv):await qn(e.error,y,R,{},e.invocationArgv),l=await ir(o.code,e.bootstrapPmRoot,{},Re(Ie(e.invocationArgv))),c=Fn(s,e.jsonErrors,l);await qo({errorMessage:n.message,exitCode:g.USAGE,classificationCode:o.code,errorCategory:a,commandResolution:i,resolutionStage:"parse"}),e.jsonErrors?Ce(`${c}
|
|
37
|
+
`):_(c),r&&await Ge(Mo),process.exitCode=g.USAGE}function as(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 is(e){let t=e.error.code,n=String(e.error.message??"");if(!await ns(e,t,n)){if(t==="commander.version"){await Qr();return}await os(e,t)}}async function Ho(e){let t=F(e.invocationArgv),n=S(process.cwd(),t.path),o={error:e.error,invocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:k(e.invocationArgv)??"<unknown>",emitTelemetryCommandError:wd({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await Xr({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await es(o,ln(e.error))){if(as(e.error)){await is(o);return}await Dr({error:e.error,attemptedCommand:o.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:o.emitTelemetryCommandError})}}function _d(e,t,n){let o=n.requested?n.commandPathTokens:D(t),a=W(o);if(a&&!te(e,[...a.canonical_argv]))throw new Or(g.USAGE,"commander.unknownCommand",`unknown command '${a.alias}'`)}function vd(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,Tr,i.alias)}async function bd(e,t){y=sn(rt),y.hook("preAction",(i,r)=>{t.configurationOnly=["item mutate","item complete"].includes(E(r))&&r.optsWithGlobals().dryRun===!0}),Jr(y,e),it=null,_e=null,R=new Map,da();let n=[...e],o,a;try{let i=He(e);n=i.argv,vd(y,e);let r=[process.argv[0],process.argv[1],...n],s=n.length===0,l=F(n);if(l.authorMissingValue)throw new b("--author requires a non-empty value.",g.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});o=Fa(l.author),bo(i),a=Pa(n);let c=yo(n);await yd(y,c),En(y,!0),_o(y,n)?await Kr(y,n):(R=new Map,ne({overrides:[]})),vo(n)&&await jr(y,n),En(y);let d=A(n);_d(y,n,d),wo(n)&&hi(y,n),Vr(y);let m=await pd(d,l);if(await dr(y,n,m,e))return;if(d.requested&&!Ae(y,d.commandPathTokens))throw new Or(g.USAGE,"commander.helpDisplayed","(outputHelp)");if(s||ae(n)&&k(n)===void 0){y.outputHelp();return}if(ot(n)){await y.parseAsync(r);return}let p=S(process.cwd(),l.path),u=await N(p),f=await Di(n,p,l.noExtensions,Ne);await xa({pmRoot:p,packages:f?.contextIntentPackages},()=>ka({env:{...process.env,PM_PATH:p},argv:r,cwd:process.cwd()},()=>Ea(u.agent_identity.harness_signals,()=>y.parseAsync(r),{probesEnabled:u.agent_identity?.probes_enabled})))}catch(i){await Ho({error:i,invocationArgv:n})}finally{a?.(),o?.()}}async function Wp(e=process.argv.slice(2)){let t=e;try{t=He(e).argv}catch{}let n=br(t),o={configurationOnly:n!==void 0},a=()=>o.configurationOnly,i=async()=>{try{await La(process.env,()=>bd(e,o))}catch(r){await Ho({error:r,invocationArgv:[...e]})}};if(n!==void 0){let r=S(process.cwd(),F(t).path),s=S(process.cwd(),n.path),l=Yo(process.cwd());await yt(r,()=>yt(s,()=>yt(l,i,a),a),a)}else await i()}var Vp={activationCommandMatchesProbe:no,applyDynamicExtensionRootHelpVisibility:Br,bootstrapProfileEnabled:Lo,buildBootstrapActivationProbe:Ie,buildPostActionTelemetryOutcome:Oo,buildPmCliRecoveryContext:Ir,buildRuntimeExtensionDiscoverySnapshotCacheKey:jo,buildRuntimeExtensionActivationScope:tt,buildRuntimeExtensionSnapshotCacheKey:Ur,buildRuntimeExtensionFilterForProbe:lo,addRuntimeFieldOption:Po,collectActivationCommandCandidates:Re,collectExtensionFlagDefinitionsForCommand:qt,collectExtensionFlagDefinitionsForInvocation:nt,collectLeadingCommandArgs:to,collectParsedActivationCommandArgs:co,collectRuntimeFieldLooseFlagDefinitionsForCommand:Lr,commandHasLongOption:Mr,commandHasShortOption:Fr,commandPathNeedsSearchExtensions:oo,commandPathNeedsTemplateExtensions:Lt,describeUnknownError:me,defaultPreflightDecision:$o,discoveryNeedsActivationForProbe:et,emitExtensionProfile:qr,emitExtensionSkippedProfile:Kt,emitSettingsReadWarnings:No,ensureIdempotentTopLevelCommandRegistration:Yr,enforceExplicitRetryForFlagTypos:bo,envFlagEnabled:$r,executeRegisteredRuntimeMigrations:zr,extractCommandScopedOptions:Pe,extensionActivationCommands:Ft,extensionCapabilities:Qe,extensionNeedsActivationForProbe:jt,extensionProvidesTemplatesRuntime:io,hasAnyCapability:Te,hasGlobalExtensionContributions:ro,handleGenericRunPmCliError:Dr,handleRunPmCliCommanderError:is,handleRunPmCliError:Ho,handleRunPmCliHelpDisplayError:ns,handleRunPmCliKnownError:es,handleRunPmCliCommanderUsageError:os,handleUnknownHelpCommandError:ts,inferMissingFieldsFromErrorMessage:Rr,inferPostActionErrorCode:Ao,inferPostActionFailureMessage:So,invocationRequestsVersion:at,isCommanderError:dn,loadRuntimeExtensionCommandDescriptorsForRecovery:Uo,loadRuntimeExtensionDiscoverySnapshot:Jt,loadRuntimeExtensionSnapshot:Ne,maybeLoadRuntimeExtensions:Hr,maybeAttachCreateUpdatePolicyHelpText:Fo,maybeLogHandledCliErrorToSentry:Bt,matchesStaticExtensionCommand:Mt,normalizeTelemetryCommandResolution:xo,normalizeTelemetryErrorCategory:Eo,normalizeTelemetryResolutionStage:ko,normalizeThrownExitCode:cn,probeUsesAnyFlag:ao,prepareExtensionServicesForRunPmCliError:Xr,readRecordBoolean:Co,readRecordNumber:zt,readRecordString:we,recordCliReadOutputInvocationProvenance:mo,registerDynamicExtensionCommandPaths:Kr,registerRuntimeSchemaFieldFlags:jr,resolveCoreCommandRegistrationSelection:yo,resolveStaticExtensionActivationDecision:so,resolveUnknownHelpToken:Ln,readThrownExitCode:ln,runAndClearAfterCommandHooks:st,runRequiredExtensionCommand:Wr,shouldAttachRichHelpTextForInvocation:wo,shouldLogHandledErrorToSentry:Nr,shouldRegisterDynamicExtensionPaths:_o,shouldRegisterRuntimeSchemaFlags:vo,shouldHandleRunPmCliCommanderError:as,setActiveExtensionHookContextForTest:Qc,setActiveRuntimeExtensionCommandDescriptorsForTest:ed,setRecoveredExtensionServices:Zr,toLooseFieldDefinitionType:Io,isImporterOrExporterCommandPath:uo,validateDynamicExtensionCommandInvocation:go,wrapProgramActionsForExtensionHandlers:Vr,wrapThrownErrorForSentry:mn};export{Vp as _testOnly,Wp as runPmCli};
|
|
38
38
|
//# sourceMappingURL=main.js.map
|