@unbrained/pm-cli 2026.9.28 → 2026.9.30
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/.agents/skills/pm-developer/references/GRAPH_AND_RELATIONSHIPS.md +7 -6
- package/.agents/skills/pm-user/references/BACKLOG_SHAPING.md +1 -1
- package/.agents/skills/pm-user/references/ECOSYSTEM_PLANNING.md +26 -3
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +26 -0
- package/dist/cli/error-guidance.js +1 -1
- package/dist/cli/help-json-payload.js +2 -2
- package/dist/cli/main.js +2 -2
- package/dist/cli/runtime/invocation-options.d.ts +3 -1
- package/dist/cli/runtime/invocation-options.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +152 -152
- package/dist/cli-bundle/chunks/{chunk-UT7GRGHY.js → chunk-6XTJLOKW.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-VMJLM7P2.js → chunk-6YEET7XI.js} +22 -22
- package/dist/cli-bundle/chunks/{chunk-NEUIVBFO.js → chunk-A6NDNRCK.js} +3 -3
- package/dist/cli-bundle/chunks/{chunk-GLH2LNRH.js → chunk-BNAT4EYR.js} +9 -9
- package/dist/cli-bundle/chunks/{chunk-CPOWTIIS.js → chunk-BTCE36JS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-35DME35A.js → chunk-BX4LEJX4.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-A2G5OG6W.js → chunk-EGAIIWI3.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-FYTXVVZG.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-ZFHJP7YD.js → chunk-O23CQ5T4.js} +31 -29
- package/dist/cli-bundle/chunks/{chunk-NBDB3SRC.js → chunk-UIAH7UFK.js} +67 -67
- package/dist/cli-bundle/chunks/{chunk-OYCCWPBM.js → chunk-USTAFHIM.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-PR4UAMI5.js → chunk-XRN3JYNN.js} +85 -85
- package/dist/cli-bundle/chunks/{chunk-PLNNUAFZ.js → chunk-YM342ELM.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-N6RP6PSP.js → register-list-query-SYNBVMNG.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-CY7JGQE6.js → register-mutation-4GSUK23D.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-53HAD3QP.js → register-operations-7FCJUC4Z.js} +2 -2
- package/dist/cli-bundle/chunks/{register-setup-NVX6374E.js → register-setup-YTWW2KL5.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BRLXKRI2.js → chunk-3CAZ7Z4R.js} +4 -4
- package/dist/cli-bundle/focused-chunks/{chunk-K7GSZ7YZ.js → chunk-4AORVUT4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-AZA4AEOR.js → chunk-AKB3JN57.js} +33 -33
- package/dist/cli-bundle/focused-chunks/{chunk-OVVCXTIE.js → chunk-EFD4ATS7.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-IJXZQE3D.js → chunk-EVMH4SKN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-IWLMQLBO.js → chunk-IDB6E3ZV.js} +28 -28
- package/dist/cli-bundle/focused-chunks/{chunk-YZB7IPR6.js → chunk-IQBFYQF2.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BGWF6CMP.js → chunk-KZULQIAG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ZMQTIS3L.js → chunk-MOUCTR72.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6IVQPNYN.js → chunk-OMBDUJWZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-DTLRXY77.js → chunk-RIJQQOEZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-A5O3VYWV.js → chunk-T4PZJQG4.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-V7OPZRL6.js → chunk-UPOMLSW7.js} +14 -14
- package/dist/cli-bundle/focused-chunks/{chunk-5KJXX2TZ.js → chunk-XB5Q2P7Z.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-ONDNR3VU.js → chunk-XUCXRZZZ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-Y5Z3XNGY.js → chunk-ZJ3CLTV4.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 +22 -21
- 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 +38 -38
- 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 +2 -2
- package/dist/core/extensions/extension-types.d.ts +13 -0
- package/dist/core/extensions/extension-types.js +1 -1
- package/dist/core/history/replay.js +1 -1
- package/dist/core/history/workspace-history.d.ts +17 -0
- package/dist/core/history/workspace-history.js +1 -1
- package/dist/core/output/mutation-projection.js +1 -1
- package/dist/core/telemetry/runtime.js +2 -2
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/extension-command-context.d.ts +1 -7
- package/dist/sdk/extension-command-context.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/index.d.ts +1 -0
- package/dist/sdk/index.js +1 -1
- package/dist/sdk/lifecycle/plan-mutation-receipt.d.ts +53 -0
- package/dist/sdk/lifecycle/plan-mutation-receipt.js +2 -0
- package/dist/sdk/lifecycle/plan.d.ts +3 -0
- package/dist/sdk/lifecycle/plan.js +1 -1
- package/dist/sdk/lifecycle/update.d.ts +2 -0
- package/dist/sdk/lifecycle/update.js +1 -1
- package/dist/sdk/linked-artifacts.js +1 -1
- package/dist/sdk/merge/install.js +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/runtime/actions.js +1 -1
- package/dist/sdk/runtime-input.d.ts +2 -0
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/runtime.js +1 -1
- package/dist/sdk/similarity-scoring.js +1 -1
- package/dist/sdk/structured-mutations.js +1 -1
- package/dist/sdk/telemetry.d.ts +2 -0
- package/dist/sdk/telemetry.js +3 -1
- package/dist/sdk/testing.js +1 -1
- package/docs/CLI_GRAMMAR.md +18 -1
- package/docs/ECOSYSTEM_PLANNING_REVIEW.md +270 -0
- package/docs/MERGE_SAFETY.md +11 -6
- package/docs/README.md +2 -0
- package/docs/RELEASE_RELIABILITY.md +26 -4
- package/docs/SDK_AUDITED_MUTATIONS.md +52 -0
- package/docs/SDK_EVIDENCE_TRACEABILITY.md +34 -0
- package/docs/agent-task-token-baseline.json +28 -2
- package/docs/agent-task-transcripts.json +137 -14
- package/docs/ecosystem-review-2026-09-28.json +3159 -0
- package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +4 -3
- package/marketplace.json +2 -2
- 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 +2 -2
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +2 -2
- package/plugins/pm-codex/plugin.json +1 -1
- package/dist/cli-bundle/chunks/chunk-YERBAGQD.js +0 -2
package/dist/cli-bundle/main.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{B as
|
|
2
|
-
`)}function
|
|
3
|
-
`)}function Yi(e,t){return t==="detailed"?La(e):Fa(e)}function N(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var ja={cal:"calendar",ctx:"context"};function Ua(e,t){return e.commands.find(n=>n.name()===t)??null}function qa(e,t){let n=e;for(let o of t){let i=Ua(n,o);if(!i)return null;n=i}return n}function gn(e,t,n,o){let i=qa(e,t.split(" ").filter(r=>r.length>0));i&&i.addHelpText("after",Yi(n,o))}function hn(e){return e.includes("--explain")?"detailed":"compact"}function me(e){return e.includes("--all")||e.includes("--explain")}var de={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 M){let n=de[e];n&&(de[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var be={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."]},Xi=te.filter(e=>e.lifecycle==="deprecated");for(let e of Xi){let t=de[e.alias];de[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[be,...Object.values(de)])e.examples=e.examples.map(t=>{for(let n of Xi){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function Ha(e){let t=N(e??"");return t?ja[t]??t:""}function yn(e){let t=Ha(e);return t?de[t]??be:be}function Qi(e,t){let n=yn(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:Ji(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function za(){let e=te.filter(({lifecycle:n})=>n==="permanent"),t=te.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(" ")} (${Mo(n)})`)].join(`
|
|
4
|
-
`)}function
|
|
5
|
-
`,s=t.visibleCommands(e);for(let l of s)
|
|
6
|
-
`)}function ar(e,t){return t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),Ba(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 Za(e,t){if(e.flag)return e.flag;let n=i=>{let r=i.split("=",1)[0];return F([r]).length>0&&!["--help","--no-changed-fields","--version"].includes(r)&&t.some(a=>a===r||a.startsWith(`${r}=`))},o=[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(i=>i[0]).find(i=>n(i));return o||e.recovery?.provided_fields?.map(i=>i.split("=",1)[0]).find(i=>n(i))}function es(e,t,n){if(e.value!==void 0)return e.value;if(n){let i=t.find(a=>a===n||a.startsWith(`${n}=`));if(i?.startsWith(`${n}=`))return i.slice(n.length+1);let r=t.indexOf(n);return r>=0?t[r+1]:void 0}let o=e.recovery?.allowed_values;if(o?.length)return t.find((i,r)=>r>0&&!i.startsWith("-")&&!o.includes(i))}function ts(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=F(e.recovery?.normalized_args??[]),o=W(n),i=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,r=Za(e,i),a=es(e,i,r);return{surface:r??e.recovery?.missing?.[0]??un(i)??"command",...a!==void 0?{rejected_value:a}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function ns(e,t){return ar({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:ts(e,t)},e)}function xn(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 ri(ns(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function kn(e){return ar({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required},e)}function Et(e){return e.replace(/\(outputHelp\)/g,"").trim()}function os(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 ue(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 nr(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function is(e){return un(e?.normalized_args)}function rs(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 as(e,t){let n=e?.normalized_args,o=e?.provided_fields,i=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!i))for(let r of o){let a=n.findIndex(s=>s===r);if(a>=0&&a<n.length-1&&!n[a+1]?.startsWith("-")){let s=[...n];return s[a+1]=i,A(s)}}}function ss(e){let t=e.split(/\r?\n/)[0].trim();if(t.length!==0)return t.length<=120?t:`${t.slice(0,117)}...`}function xt(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function X(e,t,n){if(!n)return e;let o=Et(t),i=xt(n.code,e.code),r=xt(n.type,ir(i)),a=ue(n.examples)??e.examples,s=ue(n.nextSteps)??e.nextSteps,l=ue(n.verification_errors)??e.verificationErrors,c=e.code==="command_failed"&&n.code?ss(o):void 0,d=xe(n.recovery),m=d&&e.recovery?xe({...e.recovery,...d}):d??e.recovery;return{...e,code:i,type:r,title:c??e.title,happened:o.length>0?o:e.happened,required:xt(n.required,e.required),why:xt(n.why,e.why),examples:a,nextSteps:s,verificationErrors:l,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:n.flag,value:n.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,tombstone:n.tombstone,availableDependencies:n.available_dependencies,recovery:m}}function ls(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 i=o[1],r=qo(process.cwd(),i);return X(b(r?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${i}, but found a tracker at ${r}.`,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 ${r} <command>`,`PM_PATH=${r} pm <command>`],nextSteps:[`Re-run with "--pm-path ${r}" or export PM_PATH=${r}.`]}:{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 cs(e,t,n){let o=t.match(/^Item ([^ ]+) not found$/);if(!o)return null;let i=o[1],r=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(i),a=r?`The item ID "${i}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${i}" exists in the active tracker scope.`;return X(b({code:"item_not_found",title:"Item ID not found",happened:a,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:r?["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 ds(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:X(b({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 ms(e,t,n){return t.includes("is locked")?X(b({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 ps(e,t,n){let o=t.match(/^Missing required option /),i=t.match(/^Missing required options /);if(!o&&!i)return null;let r=!!i,a=r?null:t.replace(/^Missing required option\s+/,"").trim(),s=a??"",l=a?`Pass ${a} with a valid value before running the command.`:"Provide the required option for this command invocation.";return X(b({code:"missing_required_option",title:r?"Missing required options":`Missing required option ${s}`,happened:t,required:r?"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")?X(b({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 fs(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=xe(n?.recovery),i=is(o),r=i?`pm ${i} --help`:"pm <command> --help",a=rs(t),s=xe({...o,allowed_values:o?.allowed_values??a}),l=as(o,a),c=l?[l,r]:[r,"pm contracts --command <command> --flags-only --json"],d=a.length>0?[`Allowed values: ${a.join("|")}`,`Run "${r}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return X(b({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 En(e,t){let n=Et(e),o=ls(e,n,t)??cs(e,n,t)??ds(e,n,t)??ms(e,n,t)??ps(e,n,t)??us(e,n,t)??fs(e,n,t);return o||X(b({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 gs(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 hs(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function ys(e){if(!(!Array.isArray(e)||e.length===0))return A(e)}function Sn(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 q(e,t={}){let n=Sn(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,i=typeof e?.attemptedCommand=="string"?e.attemptedCommand:ys(o),r=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return xe({attempted_command:i,normalized_args:o,provided_fields:n,suggested_retry:r,...t})}function Cn(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 _s(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 bs(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 i=e[o];if(i!=="--add"&&i!=="--remove")continue;let r=e[o+1];if(typeof r!="string"||!vs.has(r))return;let a=[];for(let c=o+2;c<e.length;c+=1){let d=e[c];if(d.startsWith("--")&&d.length>2)break;a.push(d)}if(a.length<2)return;let s=`${r}=${a.join(" ")}`,l=[...e.slice(0,o+1),s,...e.slice(o+2+a.length)];return A(l)}}function Cs(e,t,n,o){let i=e.match(/required option '([^']+)' not specified/);if(!i)return null;let r=hs(i[1]),a=r.startsWith("--type"),s=o?.suggestedRetryCommand,l=Sn(o?.providedOptionFlags),c=[r],d=gs(t,r,n),m=s?Cn(d,s):d,p=a?[`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?Cn(p,`Replay with preserved arguments: ${s}`):p,g=l&&l.length>0?Cn(u,`Already provided options: ${l.join(", ")}`):u;return b({code:"missing_required_option",title:`Missing required option ${r}`,happened:`Commander rejected the command because ${r} was not provided.`,required:`Pass ${r} with a valid value before running the command.`,why:a?"--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:q(o,{missing:c})})}function xs(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let i=o[1];return b({code:"missing_required_argument",title:`Missing required argument ${i}`,happened:`Command invocation omitted positional argument ${i}.`,required:`Provide ${i} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:q(n,{missing:[i]})})}function ks(e,t,n){return b({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:q(t,{suggested_flags:n})})}var Es={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 Ss(e){let t=ue(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function As(e,t,n,o,i){let r=o.otherCommands.slice(0,3),a=o.candidateTotal-r.length,s=a>0?` and ${String(a)} 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,r.length?`${e} is accepted by ${r.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,i?`Replay with suggested correction: ${i}`:void 0].filter(l=>typeof l=="string")}function Ts(e,t){if(e.suggestedRetryCommand!==void 0)return{retryCommand:e.suggestedRetryCommand};let n=e.normalizedInvocationArgs;if(n===void 0)return{};if(n.filter(r=>r===t||r.startsWith(`${t}=`)).length!==1)return{};let o=n.findIndex(r=>r===t||r.startsWith(`${t}=`));if(o<0||n.includes("--")||!n[o]?.includes("=")&&o!==n.length-1&&n[o+1]?.startsWith("-")!==!0)return{};let i=F(n.filter((r,a)=>a!==o));return{retryCommand:A(i),suggestedRetryArgs:i}}function Os(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let i=n??{},r=o[1],a=Sn(i.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:l}=Ts(i,r);if(t==="update"&&(r==="--file"||r==="--doc"))return ks(r,n,a);let c=Ss(i),d=As(r,t,a,c,s),m=[s,`pm ${t?ne(t)?.canonical??t:"<command>"} --help`].filter(p=>typeof p=="string");return b({code:"unknown_option",title:`Unknown option ${r}`,happened:`Commander does not recognize option ${r} for this command path.`,required:Es[c.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:r,value:r,examples:m,nextSteps:d,recovery:q(n,{suggested_flags:a.length>0?a:void 0,suggested_retry:s,suggested_retry_args:l,candidate_commands:c.otherCommands,candidate_commands_total:c.candidateTotal||void 0,candidate_commands_truncated:i.unknownOptionOtherCommandsTruncated,option_scope:c.optionScope})})}function Rs(e,t,n,o,i){let r=`"${e}" is provided by the ${t.packageName} package. Install it with: ${t.installCommand}`,a=o.filter(s=>!s.endsWith(`: ${t.installCommand}`));return b({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:nr([t.installCommand,...n]),nextSteps:nr([r,...a]),recovery:q(i)})}function Is(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],i=ue(t?.unknownCommandExamples),r=ue(t?.unknownCommandNextSteps),a=Ja(o),s=i??["pm --help"],l=r??["Verify spelling and active extensions, then rerun."],c=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),d=a?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return a&&(!d||!c.has(d))?Rs(o,a,s,l,t):b({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:q(t)})}function Ps(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=ue(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let i=e?.suggestedRetryCommand;return b({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${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:[...i?[i]:[],`pm ${ne(t)?.canonical??t} --help`],nextSteps:i?[`Retry with the declared hyphenated action: ${i}`]:["Choose one value from recovery.allowed_values."],recovery:q(e,{allowed_values:o,suggested_retry:i})})}function $s(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,i=_s(o);if(!i)return null;let r=bs(o);return b({code:"linked_test_value_not_quoted",title:`Linked-test ${i} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${i} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${i} 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:[...r?[r]:[],'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:[...r?[`Replay with the value re-joined into one argument: ${r}`]:[],"Prefer --add-json for commands containing commas, equals signs, or quotes.",'Run "pm test --help" for linked-test entry contracts.'],recovery:q(n,r?{suggested_retry:r}:{})})}var Ds=new Set(["comments","docs","files","learnings","notes","test"]);function Ns(e,t,n){if(!/too many arguments/i.test(e)||!Ds.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(c=>c===t),r=o[i+1],a=o[i+2],s=n?.verifiedCollectionItemId?.trim();if(r?.toLowerCase()!=="add"||!a||a.startsWith("-")||!s||s.toLowerCase()!==a.toLowerCase())return null;let l=`pm ${t} ${s} --add <value>`;return b({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:q(n,{parsed_positionals:[{role:"transposed_subcommand",value:r},{role:"item_id",value:s}],suggested_retry:l})})}var Ms=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"]),or=new Set(["context","ctx"]);function Fs(e,t,n){if(!/too many arguments/i.test(e)||!or.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(c=>or.has(c)),r=i===-1?1:i+1,a=e.match(/got \d+:\s*(\S+)/i),s=a?a[1].replace(/\.$/,""):void 0;if(s===void 0){let c=!1;for(let d of o.slice(r)){if(c){c=!1;continue}let m=d.split("=")[0];if(Ms.has(m)){c=!d.includes("=");continue}if(!d.startsWith("-")){s=d;break}}}if(!s)return null;let l=`pm get ${s}`;return b({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:q(n,{suggested_retry:l})})}function An(e,t,n,o){let i=Et(e),r=Cs(i,t,n,o)??xs(i,t,o)??Os(i,t,o)??Is(i,o)??Ps(o)??Ns(i,t,o)??$s(i,t,o)??Fs(i,t,o);return r||b({code:"invalid_command_usage",title:"Invalid command usage",happened:i,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:q(o)})}function sr(e,t){let n=En(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: ${A(n.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
|
|
7
|
-
`):
|
|
1
|
+
import{B as Vi,D as Bi,E as hn,a as nn,b as ce,c as on,d as rn,e as an,f as sn,g as xi,k as ki,n as G,o as F,p as k,q as de,r as E,s as Gi,x as bt,y as Wi,z as gn}from"./chunks/chunk-USTAFHIM.js";import{Wa as zi,f as gi,l as bi}from"./chunks/chunk-XRN3JYNN.js";import"./chunks/chunk-6XTJLOKW.js";import"./chunks/chunk-A6NDNRCK.js";import{F as Fi,Id as Hi,Nc as qi,d as wt,g as Di,h as Ni,i as Y,j as Mi}from"./chunks/chunk-O23CQ5T4.js";import{Fa as Li,f as Ci}from"./chunks/chunk-6YEET7XI.js";import"./chunks/chunk-BNAT4EYR.js";import"./chunks/chunk-DEZPZOQ7.js";import{$k as Ai,Ac as ti,Al as Pi,Bc as ae,Cc as ni,Dc as lt,Eb as zo,Ec as ve,Ef as le,Fc as se,Ff as fi,Gf as be,Go as _t,H as Lo,Ho as vt,I as jo,Ic as oi,If as tn,Io as un,Jc as ct,Jf as _,Jo as He,Ko as T,L as De,Lo as ji,Mo as fn,Nb as Go,Ob as Wo,P as Jt,Pa as Yt,Pc as Zt,Pe as si,Qc as dt,Qe as li,Qi as ut,Rc as ii,Re as ci,Ri as vi,Rk as Ei,Sa as re,Sc as ri,Se as di,Sk as ft,So as U,Te as mi,Tk as cn,Ua as qo,Ub as Vo,Uk as dn,Va as st,Vg as hi,Vk as Le,Wb as Bo,Wg as yi,Wk as mn,Xk as Si,Ya as Xt,Yd as mt,Yk as je,Za as Ho,_a as $,ad as A,al as Ti,bb as J,bd as Fe,bo as $i,ch as pt,co as yt,e as M,ep as Ui,fi as wi,g as W,gm as gt,h as O,hc as Ko,hg as ln,hi as Ce,ic as Ne,ii as D,im as qe,j as V,ji as _i,jm as ht,k as Kt,kc as Me,l as B,la as f,lc as Jo,m as Fo,ma as at,na as C,nl as Ue,oa as Uo,of as pi,ql as Oi,sf as ui,tb as Qt,tl as Ri,uc as Yo,vc as Xo,wc as Qo,x as K,xc as Zo,yc as ne,ye as ai,yl as pn,zc as ei,ze as en,zl as Ii}from"./chunks/chunk-UIAH7UFK.js";import{Command as Ro,CommanderError as ca}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]="1c4a4bc4-d26a-5f51-bac0-2a132dad1f56")}catch{}})();async function Ki(e,t){await Ii(e,{ok:t.ok,error:t.error,result:se(),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 Ji(e){if(process.env.PM_CONTEXT_USAGE_DISABLED==="1")return;let t;try{await pi({pmRoot:e.pmRoot,result:se()})}catch(o){t=o}let n=await D(e.pmRoot);if(await ui({pmRoot:e.pmRoot,author:pt(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]="0429ff6a-ec0d-5c20-9fa7-0ed05b154523")}catch{}})();function q(e){return`--${e.replace(/^--?/,"").replace(/_/g,"-").replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase()}`}function me(e){if(!e.startsWith("--"))return;let t=e.includes("=")?e.slice(0,e.indexOf("=")):e;return q(t)}function X(e){let t=new Set,n=[];for(let o of e){let i=me(o);i&&(t.has(i)||n.push(i),t.add(i))}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]="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]="63db65f1-fdbe-513d-b71a-87490ec9b69e")}catch{}})();var Yi=new WeakMap;function Ct(e,t){Yi.set(e,t)}function pe(e){return Yi.get(e)}function Xi(e){return e.length>0?[e[0]]:[]}function Ha(e){let t=["","Intent:",` ${e.why}`],n=Xi(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 za(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 Qi(e,t){return t==="detailed"?za(e):Ha(e)}function N(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}var Ga={cal:"calendar",ctx:"context"};function Wa(e,t){return e.commands.find(n=>n.name()===t)??null}function Va(e,t){let n=e;for(let o of t){let i=Wa(n,o);if(!i)return null;n=i}return n}function yn(e,t,n,o){let i=Va(e,t.split(" ").filter(r=>r.length>0));i&&i.addHelpText("after",Qi(n,o))}function wn(e){return e.includes("--explain")?"detailed":"compact"}function oe(e){return e.includes("--all")||e.includes("--explain")}var ue={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 M){let n=ue[e];n&&(ue[t]={...n,examples:n.examples.map(o=>o.replace(`pm ${e}`,`pm ${t}`))})}var xe={why:"Provides deterministic project management workflows for humans and coding agents.",examples:["pm init","pm 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."]},Zi=V.filter(e=>e.lifecycle==="deprecated");for(let e of Zi){let t=ue[e.alias];ue[e.alias]={...t,why:`Deprecated: use pm ${e.canonical_argv.join(" ")}. ${t.why}`}}for(let e of[xe,...Object.values(ue)])e.examples=e.examples.map(t=>{for(let n of Zi){let o=n.alias.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");t=t.replaceAll(new RegExp(`\\bpm ${o}(?![\\w-])`,"g"),`pm ${n.canonical_argv.join(" ")}`)}return t});function Ba(e){let t=N(e??"");return t?Ga[t]??t:""}function _n(e){let t=Ba(e);return t?ue[t]??xe:xe}function er(e,t){let n=_n(e);return{intent:n.why,examples:t==="detailed"?[...n.examples]:Xi(n.examples),tips:t==="detailed"?[...n.tips??[]]:[],detail_mode:t}}function Ka(){let e=V.filter(({lifecycle:n})=>n==="permanent"),t=V.filter(({lifecycle:n})=>n==="deprecated");return["","Command aliases:",...e.map(({alias:n,canonical_argv:o})=>` ${n} -> pm ${o.join(" ")}`),"","Deprecated aliases:",...t.map(n=>` ${n.alias} -> pm ${n.canonical_argv.join(" ")} (${Fo(n)})`)].join(`
|
|
4
|
+
`)}function Ja(e,t,n,o){let i=new Set(Di);e.configureHelp({visibleCommands(r){let a=t.visibleCommands(r);return n?a.filter(s=>(pe(s)??Y(s.name()))!=="internal"):r!==e?a:a.filter(s=>o.has(s))},visibleOptions(r){let a=t.visibleOptions(r);return r!==e||n?a:a.filter(s=>i.has(s.flags))}})}function Ya(e,t,n,o){let i=new Set(Mi("core")),r=e.createHelp();r.prepareContext({error:!1,helpWidth:80,outputHasColors:!1});let a=()=>`${r.formatHelp(e,r)}${o}
|
|
5
|
+
`,s=t.visibleCommands(e);for(let l of s)pe(l)===void 0&&(l.name()==="help"||i.has(l.name()))&&n.add(l);for(let l of s)pe(l)==="core"&&(n.add(l),Ni(a()).within_budget||n.delete(l))}function tr(e,t=process.argv.slice(2)){let n=e.createHelp(),o=oe(t),i=new Set;Ja(e,n,o,i);let r=wn(t),a=Qi(xe,r);e.addHelpText("after",a),o&&e.addHelpText("after",Ka()),Ya(e,n,i,a);for(let[c,m]of Object.entries(ue))yn(e,c,m,r);let s=N(k(t).commandPathTokens.join(" ")),l=qe(s);if(l){yn(e,l.parent,{why:l.description,examples:[l.example],tips:[`Action path: pm ${l.command}`,ht(l.accepted_flags)]},r);return}let d=gt.filter(({parent:c})=>c===s);d.length>0&&yn(e,s,{why:`Dispatches one declared positional action: ${d.map(({action:c})=>c).join("|")}.`,examples:d.map(({example:c})=>c),tips:[`Inspect one action directly with pm ${s} <action> --help --json.`]},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]="b70452a1-26dc-5f66-bb87-67a5bde7bd30")}catch{}})();function vn(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:i}of M){if(t&&!M.some(d=>d.canonical.startsWith(`${o} `)))continue;let r=e.commands.findIndex(d=>d.name()===n);if(r<0)continue;let a=e.commands[r],s=e;for(let d of i.slice(0,-1))s!==e&&s.enablePositionalOptions(),s=s.commands.find(c=>c.name()===d)??s.command(d).description(`Discover ${d} operations.`);let l=i[i.length-1];if(s.commands.some(d=>d.name()===l))throw new Error(`Cannot install canonical command ${o}: destination already exists.`);e.commands.splice(r,1),a.name(l),Ct(a,Y(o)),s.enablePositionalOptions(),s.addCommand(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]="2e3d63ed-ae76-5027-af01-066f60e8070a")}catch{}})();function Et(e){let{why:t,title:n,...o}=e;return o}var Xa=new Set(["unknown_command","unknown_option","missing_required_option","missing_required_argument","invalid_argument_value","invalid_command_usage","command_failed"]);function Qa(e){return!e.why||e.recovery?.recovery_mode==="compact"?!1:!Xa.has(e.code)}function ar(e){return`urn:pm-cli:error:${e}`}function b(e){return{...e,type:ar(e.code)}}var ke={packageName:"@unbrained/pm-guide-shell",installCommand:"pm install guide-shell"},nr={packageName:"@unbrained/pm-calendar",installCommand:"pm install calendar"},or={packageName:"@unbrained/pm-search-advanced",installCommand:"pm install search-advanced"},xt={packageName:"@unbrained/pm-governance-audit",installCommand:"pm install audit"},Za={guide:ke,shell:ke,completion:ke,"completion-statuses":ke,"completion-tags":ke,"completion-types":ke,templates:{packageName:"@unbrained/pm-templates",installCommand:"pm install templates"},calendar:nr,cal:nr,reindex:or,"search-advanced":or,"test-runs":{packageName:"@unbrained/pm-linked-test-adapters",installCommand:"pm install linked-test-adapters"},"comments-audit":xt,"dedupe-audit":xt,"dedupe-merge":xt,normalize:xt};function es(e){let t=e.trim().split(/\s+/)[0]?.toLowerCase();if(t)return Za[t]}function bn(e,t){return t.length===0?[]:[e,...t.map(n=>` - ${n}`)]}function ts(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 ns(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 Cn(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 i=n.map(r=>({role:typeof r?.role=="string"?r.role.trim():"",value:typeof r?.value=="string"?r.value.trim():""})).filter(r=>r.role.length>0&&r.value.length>0);i.length>0&&(e.parsed_positionals=i);return}let o=ts(n);o&&(e[t]=o)}function Ee(e){if(!e||typeof e!="object")return;let t={};e.recovery_mode==="compact"&&(t.recovery_mode="compact"),Cn(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),Cn(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=ns(e.fallback_candidates);return n&&(t.fallback_candidates=n),Cn(t,"next_best_command",e.next_best_command),Object.keys(t).length>0?t:void 0}function xn(e,t,n){n&&e.push(` ${t}: ${n}`)}function fe(e,t,n,o){n&&n.length>0&&e.push(` ${t}: ${n.join(o)}`)}function os(e){let t=Ee(e);if(!t)return[];let n=["Recovery bundle:"];if(xn(n,"suggested_retry",t.suggested_retry),xn(n,"attempted_command",t.attempted_command),fe(n,"normalized_args",t.attempted_command?void 0:t.normalized_args," "),t.parsed_positionals&&t.parsed_positionals.length>0){n.push(" parsed_positionals:");for(let o of t.parsed_positionals)n.push(` - ${o.role}: ${o.value}`)}if(fe(n,"provided_fields",t.provided_fields,", "),fe(n,"missing",t.missing,", "),fe(n,"missing_required_fields",t.missing_required_fields,", "),fe(n,"suggested_flags",t.suggested_flags,", "),fe(n,"allowed_values",t.allowed_values,", "),fe(n,"candidate_commands",t.candidate_commands,", "),typeof t.candidate_commands_total=="number"&&n.push(` candidate_commands_total: ${String(t.candidate_commands_total)}`),t.candidate_commands_truncated===!0&&n.push(" candidate_commands_truncated: true"),t.option_scope!==void 0&&n.push(` option_scope: ${t.option_scope}`),typeof t.retry_after_ms=="number"&&n.push(` retry_after_ms: ${t.retry_after_ms}`),xn(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 sr(e){let t=[`Error: ${e.title}`,"","What is required:",` ${e.required}`];e.nextSteps&&e.nextSteps.length>0&&(t.push(""),t.push(...bn("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(...bn("Examples:",e.examples))),e.verificationErrors&&e.verificationErrors.length>0&&(t.push(""),t.push(...bn("Verification errors:",e.verificationErrors)));let n=os(e.recovery);return n.length>0&&(t.push(""),t.push(...n)),t.join(`
|
|
6
|
+
`)}function lr(e,t){return t.tombstone!==void 0&&(e.tombstone=t.tombstone,e.item_id=t.itemId),Qa(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 is(e,t){if(e.flag)return e.flag;let n=i=>{let r=i.split("=",1)[0];return F([r]).length>0&&!["--help","--no-changed-fields","--version"].includes(r)&&t.some(a=>a===r||a.startsWith(`${r}=`))},o=[...`${e.title} ${e.happened}`.matchAll(/--[A-Za-z0-9][A-Za-z0-9_-]*/gu)].map(i=>i[0]).find(i=>n(i));return o||e.recovery?.provided_fields?.map(i=>i.split("=",1)[0]).find(i=>n(i))}function rs(e,t,n){if(e.value!==void 0)return e.value;if(n){let i=t.find(a=>a===n||a.startsWith(`${n}=`));if(i?.startsWith(`${n}=`))return i.slice(n.length+1);let r=t.indexOf(n);return r>=0?t[r+1]:void 0}let o=e.recovery?.allowed_values;if(o?.length)return t.find((i,r)=>r>0&&!i.startsWith("-")&&!o.includes(i))}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=F(e.recovery?.normalized_args??[]),o=W(n),i=o?[o.alias,...n.slice(o.canonical_argv.length)]:n,r=is(e,i),a=rs(e,i,r);return{surface:r??e.recovery?.missing?.[0]??gn(i)??"command",...a!==void 0?{rejected_value:a}:{},...e.recovery?.allowed_values?.length?{legal_domain:e.recovery.allowed_values}:{},exit_code:t}}function ss(e,t){return lr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required,exit_code:t,refusal:as(e,t)},e)}function En(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 ai(ss(e,t),{diagnosticClass:o?"recovery_bundle":"error"})}function Sn(e){return lr({type:e.type,code:e.code,title:e.title,detail:e.happened,required:e.required},e)}function St(e){return e.replace(/\(outputHelp\)/g,"").trim()}function ls(e){let t=e.toLowerCase();return t.includes("cannot find module")||t.includes("cannot find package")||t.includes("err_module_not_found")||t.includes("module_not_found")}function ge(e){if(!Array.isArray(e))return;let t=e.map(n=>n.trim()).filter(n=>n.length>0);return t.length>0?t:void 0}function ir(e){let t=new Set,n=[];for(let o of e)t.has(o)||(t.add(o),n.push(o));return n}function cs(e){return gn(e?.normalized_args)}function ds(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 ms(e,t){let n=e?.normalized_args,o=e?.provided_fields,i=t[0];if(!(!Array.isArray(n)||!Array.isArray(o)||!i))for(let r of o){let a=n.findIndex(s=>s===r);if(a>=0&&a<n.length-1&&!n[a+1]?.startsWith("-")){let s=[...n];return s[a+1]=i,A(s)}}}function ps(e){let t=e.split(/\r?\n/)[0].trim();if(t.length!==0)return t.length<=120?t:`${t.slice(0,117)}...`}function kt(e,t){return typeof e=="string"&&e.trim().length>0?e.trim():t}function Z(e,t,n){if(!n)return e;let o=St(t),i=kt(n.code,e.code),r=kt(n.type,ar(i)),a=ge(n.examples)??e.examples,s=ge(n.nextSteps)??e.nextSteps,l=ge(n.verification_errors)??e.verificationErrors,d=e.code==="command_failed"&&n.code?ps(o):void 0,c=Ee(n.recovery),m=c&&e.recovery?Ee({...e.recovery,...c}):c??e.recovery;return{...e,code:i,type:r,title:d??e.title,happened:o.length>0?o:e.happened,required:kt(n.required,e.required),why:kt(n.why,e.why),examples:a,nextSteps:s,verificationErrors:l,policyViolations:n.policy_violations,policyViolationCount:n.policy_violation_count,flag:n.flag,value:n.value,unmatchedSelectors:n.unmatched_selectors,itemId:n.item_id,tombstone:n.tombstone,availableDependencies:n.available_dependencies,recovery:m}}function us(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 i=o[1],r=Ho(process.cwd(),i);return Z(b(r?{code:"tracker_not_initialized",title:"Tracker exists at a custom path",happened:`pm did not find initialized metadata at ${i}, but found a tracker at ${r}.`,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 ${r} <command>`,`PM_PATH=${r} pm <command>`],nextSteps:[`Re-run with "--pm-path ${r}" or export PM_PATH=${r}.`]}:{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 fs(e,t,n){let o=t.match(/^Item ([^ ]+) not found$/);if(!o)return null;let i=o[1],r=/^(undefined|null|<.*>|\[.*\]|{.*}|)$/.test(i),a=r?`The item ID "${i}" looks like a placeholder or unresolved variable. Ensure the ID argument is resolved before calling pm.`:`No item with id "${i}" exists in the active tracker scope.`;return Z(b({code:"item_not_found",title:"Item ID not found",happened:a,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:r?["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 gs(e,t,n){return!t.includes("is assigned to")||!t.includes("Use --force to override")?null:Z(b({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 hs(e,t,n){return t.includes("is locked")?Z(b({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 ys(e,t,n){let o=t.match(/^Missing required option /),i=t.match(/^Missing required options /);if(!o&&!i)return null;let r=!!i,a=r?null:t.replace(/^Missing required option\s+/,"").trim(),s=a??"",l=a?`Pass ${a} with a valid value before running the command.`:"Provide the required option for this command invocation.";return Z(b({code:"missing_required_option",title:r?"Missing required options":`Missing required option ${s}`,happened:t,required:r?"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 ws(e,t,n){return t.startsWith("No update flags provided")?Z(b({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 _s(e,t,n){if(!t.startsWith("Invalid ")&&!t.includes(" must be ")&&!t.includes(" requires "))return null;let o=Ee(n?.recovery),i=cs(o),r=i?`pm ${i} --help`:"pm <command> --help",a=ds(t),s=Ee({...o,allowed_values:o?.allowed_values??a}),l=ms(o,a),d=l?[l,r]:[r,"pm contracts --command <command> --flags-only --json"],c=a.length>0?[`Allowed values: ${a.join("|")}`,`Run "${r}" to confirm command-specific constraints.`]:["Check allowed values in command help, then rerun with corrected input."];return Z(b({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:d,nextSteps:c,recovery:s}),e,n)}function An(e,t){let n=St(e),o=us(e,n,t)??fs(e,n,t)??gs(e,n,t)??hs(e,n,t)??ys(e,n,t)??ws(e,n,t)??_s(e,n,t);return o||Z(b({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 vs(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 bs(e){let t=e.trim();return t.match(/--[A-Za-z0-9][A-Za-z0-9_-]*/)?.[0]??t}function Cs(e){if(!(!Array.isArray(e)||e.length===0))return A(e)}function Tn(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 H(e,t={}){let n=Tn(e?.providedOptionFlags),o=Array.isArray(e?.normalizedInvocationArgs)&&e?.normalizedInvocationArgs.length>0?e.normalizedInvocationArgs:void 0,i=typeof e?.attemptedCommand=="string"?e.attemptedCommand:Cs(o),r=typeof e?.suggestedRetryCommand=="string"?e.suggestedRetryCommand:void 0;return Ee({attempted_command:i,normalized_args:o,provided_fields:n,suggested_retry:r,...t})}function kn(e,t){return!t||e.includes(t)?e:[...e,t]}var xs=new Set(["--add","--add-json","--remove"]),ks=new Set(["command","cmd","path"]);function Es(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(xs.has(o))return o}}function Ss(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 i=e[o];if(i!=="--add"&&i!=="--remove")continue;let r=e[o+1];if(typeof r!="string"||!ks.has(r))return;let a=[];for(let d=o+2;d<e.length;d+=1){let c=e[d];if(c.startsWith("--")&&c.length>2)break;a.push(c)}if(a.length<2)return;let s=`${r}=${a.join(" ")}`,l=[...e.slice(0,o+1),s,...e.slice(o+2+a.length)];return A(l)}}function As(e,t,n,o){let i=e.match(/required option '([^']+)' not specified/);if(!i)return null;let r=bs(i[1]),a=r.startsWith("--type"),s=o?.suggestedRetryCommand,l=Tn(o?.providedOptionFlags),d=[r],c=vs(t,r,n),m=s?kn(c,s):c,p=a?[`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?kn(p,`Replay with preserved arguments: ${s}`):p,g=l&&l.length>0?kn(u,`Already provided options: ${l.join(", ")}`):u;return b({code:"missing_required_option",title:`Missing required option ${r}`,happened:`Commander rejected the command because ${r} was not provided.`,required:`Pass ${r} with a valid value before running the command.`,why:a?"--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:H(o,{missing:d})})}function Ts(e,t,n){let o=e.match(/missing required argument '([^']+)'/);if(!o)return null;let i=o[1];return b({code:"missing_required_argument",title:`Missing required argument ${i}`,happened:`Command invocation omitted positional argument ${i}.`,required:`Provide ${i} in the expected command position.`,why:"Positional arguments identify the target entity or action context for the command.",examples:[`pm ${t??"<command>"} --help`],recovery:H(n,{missing:[i]})})}function Os(e,t,n){return b({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:H(t,{suggested_flags:n})})}var Rs={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 Is(e){let t=ge(e.unknownOptionOtherCommands)??[];return{otherCommands:t,optionScope:e.unknownOptionScope??(t.length>0?"declared_elsewhere":"declared_nowhere"),candidateTotal:e.unknownOptionOtherCommandsTotal??t.length}}function Ps(e,t,n,o,i){let r=o.otherCommands.slice(0,3),a=o.candidateTotal-r.length,s=a>0?` and ${String(a)} 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,r.length?`${e} is accepted by ${r.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,i?`Replay with suggested correction: ${i}`:void 0].filter(l=>typeof l=="string")}function $s(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(r=>r===t||r.startsWith(`${t}=`)).length!==1)return{};let o=n.findIndex(r=>r===t||r.startsWith(`${t}=`));if(o<0||n.includes("--")||!n[o]?.includes("=")&&o!==n.length-1&&n[o+1]?.startsWith("-")!==!0)return{};let i=F(n.filter((r,a)=>a!==o));return{retryCommand:A(i),suggestedRetryArgs:i}}function Ds(e,t,n){let o=e.match(/unknown option '([^']+)'/);if(!o)return null;let i=n??{},r=o[1],a=Tn(i.unknownOptionSuggestions)??[],{retryCommand:s,suggestedRetryArgs:l}=$s(i,r);if(t==="update"&&(r==="--file"||r==="--doc"))return Os(r,n,a);let d=Is(i),c=Ps(r,t,a,d,s);["--dry-run","--check","--check-only","--plan","--preview"].includes(r.split("=",1)[0])&&c.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,`pm ${t?B(t)?.canonical??t:"<command>"} --help`].filter(p=>typeof p=="string");return b({code:"unknown_option",title:`Unknown option ${r}`,happened:`Commander does not recognize option ${r} for this command path.`,required:Rs[d.optionScope],why:"Option contracts are command-specific and intentionally validated.",flag:r,value:r,examples:m,nextSteps:c,recovery:H(n,{suggested_flags:a.length>0?a:void 0,suggested_retry:s,suggested_retry_args:l,candidate_commands:d.otherCommands,candidate_commands_total:d.candidateTotal||void 0,candidate_commands_truncated:i.unknownOptionOtherCommandsTruncated,option_scope:d.optionScope})})}function Ns(e,t,n,o,i){let r=`"${e}" is provided by the ${t.packageName} package. Install it with: ${t.installCommand}`,a=o.filter(s=>!s.endsWith(`: ${t.installCommand}`));return b({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:ir([t.installCommand,...n]),nextSteps:ir([r,...a]),recovery:H(i)})}function Ms(e,t){let n=e.match(/unknown command '([^']+)'/);if(!n)return null;let o=n[1],i=ge(t?.unknownCommandExamples),r=ge(t?.unknownCommandNextSteps),a=es(o),s=i??["pm --help"],l=r??["Verify spelling and active extensions, then rerun."],d=new Set(t?.failedExtensions?.map(m=>m.name.trim().toLowerCase())),c=a?.packageName.replace(/^@unbrained\/pm-/,"").toLowerCase();return a&&(!c||!d.has(c))?Ns(o,a,s,l,t):b({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:H(t)})}function Fs(e){let t=e?.unknownSubcommandPath?.trim(),n=e?.unknownSubcommandToken?.trim(),o=ge(e?.unknownSubcommandAllowedValues);if(!t||!n||!o)return null;let i=e?.suggestedRetryCommand;return b({code:"unknown_subcommand",title:`Unknown ${t} subcommand ${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:[...i?[i]:[],`pm ${B(t)?.canonical??t} --help`],nextSteps:i?[`Retry with the declared hyphenated action: ${i}`]:["Choose one value from recovery.allowed_values."],recovery:H(e,{allowed_values:o,suggested_retry:i})})}function Ls(e,t,n){if(!/too many arguments/i.test(e)||t!=="test")return null;let o=n?.normalizedInvocationArgs,i=Es(o);if(!i)return null;let r=Ss(o);return b({code:"linked_test_value_not_quoted",title:`Linked-test ${i} value must be one argument`,happened:`Commander saw extra positional tokens after the item id \u2014 usually a ${i} value containing spaces (for example a command with " -- ") that the shell split into multiple tokens.`,required:`Quote the whole ${i} 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:[...r?[r]:[],'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:[...r?[`Replay with the value re-joined into one argument: ${r}`]:[],"Prefer --add-json for commands containing commas, equals signs, or quotes.",'Run "pm test --help" for linked-test entry contracts.'],recovery:H(n,r?{suggested_retry:r}:{})})}var js=new Set(["comments","docs","files","learnings","notes","test"]);function Us(e,t,n){if(!/too many arguments/i.test(e)||!js.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(d=>d===t),r=o[i+1],a=o[i+2],s=n?.verifiedCollectionItemId?.trim();if(r?.toLowerCase()!=="add"||!a||a.startsWith("-")||!s||s.toLowerCase()!==a.toLowerCase())return null;let l=`pm ${t} ${s} --add <value>`;return b({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:H(n,{parsed_positionals:[{role:"transposed_subcommand",value:r},{role:"item_id",value:s}],suggested_retry:l})})}var qs=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"]),rr=new Set(["context","ctx"]);function Hs(e,t,n){if(!/too many arguments/i.test(e)||!rr.has(t??""))return null;let o=n?.normalizedInvocationArgs??[],i=o.findIndex(d=>rr.has(d)),r=i===-1?1:i+1,a=e.match(/got \d+:\s*(\S+)/i),s=a?a[1].replace(/\.$/,""):void 0;if(s===void 0){let d=!1;for(let c of o.slice(r)){if(d){d=!1;continue}let m=c.split("=")[0];if(qs.has(m)){d=!c.includes("=");continue}if(!c.startsWith("-")){s=c;break}}}if(!s)return null;let l=`pm get ${s}`;return b({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:H(n,{suggested_retry:l})})}function On(e,t,n,o){let i=St(e),r=As(i,t,n,o)??Ts(i,t,o)??Ds(i,t,o)??Ms(i,o)??Fs(o)??Us(i,t,o)??Ls(i,t,o)??Hs(i,t,o);return r||b({code:"invalid_command_usage",title:"Invalid command usage",happened:i,required:"Use the command with valid arguments and options.",why:"Commander validates CLI contracts before execution.",examples:["pm --help",`pm ${t??"<command>"} --help`],recovery:H(o)})}function cr(e,t){let n=An(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: ${A(n.recovery.suggested_retry_args)}`,"Use --json for full recovery details."].join(`
|
|
7
|
+
`):en(sr(n),n.required).output}function dr(e,t){return Sn(An(e,t))}function Rn(e,t,n){return En(An(e,n),t)}function mr(e,t,n,o){let i=On(e,t,n,o);return en(sr(i),i.required).output}function In(e,t,n,o){return Sn(On(e,t,n,o))}function At(e,t,n,o,i){return En(On(e,t,n,i),o)}function pr(e,t){let n=ur(e);return En(n,t)}function ur(e){let t=St(e);return ls(t)?b({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."]}):b({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 fr(e){return Sn(ur(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]="667ad638-d21d-5a49-a00e-1335cb3f10be")}catch{}})();var ze=Uo.join("|"),zs={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"},Gs={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"]}},gr=["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 Ws(e,t){let n=Gs[e];if(!n)return[];let o=q(t);for(let[i,r]of Object.entries(n))if(q(i)===o)return r;return[]}function Pn(e,t,n){if(n.length===0)return e;if(t){let a=n.find(c=>c.declared_command_match===!0),{token_accounting:s,...l}=JSON.parse(e),d={...l,...a?{extension_command_failure:{code:"extension_command_activation_failed",extension:a.name,layer:a.layer,error:a.error,recovery_commands:a.recovery_commands??[]}}:{},failed_extensions:n};return JSON.stringify(s===void 0?d:le(d,c=>`${JSON.stringify(c,null,2)}
|
|
8
8
|
`),null,2)}let o=n.map(a=>`- ${a.layer}:${a.name}: ${a.error}`).join(`
|
|
9
9
|
`),i=n.find(a=>a.declared_command_match===!0);if(!i)return`${e}
|
|
10
10
|
Extension activation failures:
|
|
@@ -16,23 +16,23 @@ ${r}`:""}
|
|
|
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
|
-
`):s,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]="939abfaf-7563-5490-bd76-90d188aa0940")}catch{}})();async function
|
|
19
|
+
${o}`}function $n(e){return k(e).commandPathTokens[0]??E(e)??"<command>"}function Vs(e,t){let n=new Set,o=[...e.commands];for(;o.length>0;){let i=o.shift();if(!i)continue;let r=N(T(i)),a=r.split(" ").some(s=>s.startsWith("_"));r.length>0&&!a&&n.add(r),o.push(...i.commands)}for(let i of t.keys()){let r=N(i),a=r.split(" ").some(s=>s.startsWith("_"));r.length>0&&!a&&n.add(r)}return[...n].sort((i,r)=>i.localeCompare(r))}function hr(e,t){let n=e.trim().toLowerCase(),o=t.trim().toLowerCase();if(o.length===0)return Number.POSITIVE_INFINITY;let i=n.split(" ");if(n===o)return 0;if(i.includes(o))return 1;if(i.some(s=>s.startsWith(o)))return 2;if(n.includes(o))return 3;let r=o.length>=5?2:1,a=Number.POSITIVE_INFINITY;for(let s of i){let l=Qt(s,o,r);l!==null&&(a=Math.min(a,l))}return Number.isFinite(a)?4+a:Number.POSITIVE_INFINITY}function yr(e){return q(e).slice(2).replace(/-/g,"")}function Dn(e){return A(e)}function Bs(e){let t=B(e)?.canonical??Kt[e]??e,n=t.split(" ")[0]?.trim().toLowerCase();if(!n)return null;let o=zs[n];return o?{packageAlias:o,canonicalPath:t,installCommand:`pm package install ${o} --project`}:null}function wr(e){let t=Li(e);for(let n of["@unbrained/","builtin-","pm-"])t.startsWith(n)&&(t=t.slice(n.length));return t}function Ks(e,t){let n=wr(e);if(n.length===0)return[];let o=[];for(let i of t.values()){let r=new Set,a=i.source;if(a)for(let l of[a.name,a.package]){let d=wr(l??"");d.length>0&&r.add(d)}if(r.size===0)continue;[...r].some(l=>l===n||l.includes(n)||n.includes(l))&&o.push(i.command)}return[...new Set(o)].sort((i,r)=>i.localeCompare(r))}function Ge(e,t){let n=new Set,o=t??yt(e);for(let i of o){i.flag.startsWith("--")&&n.add(q(i.flag));for(let r of i.aliases??[])r.startsWith("--")&&n.add(q(r))}return[...n].sort((i,r)=>i.localeCompare(r))}function Js(e,t){if(!e.startsWith("--"))return[];let n=yr(e);if(n.length===0)return[];let o=n.length>=8?2:1,i=[];for(let r of t){let a=yr(r);if(a===n)continue;if(n.length>=3&&a.startsWith(n)){i.push({flag:r,rank:0,distance:a.length-n.length});continue}let s=Qt(n,a,o);s===null||s<=0||i.push({flag:r,rank:1,distance:s})}return i.sort((r,a)=>r.rank!==a.rank?r.rank-a.rank:r.distance!==a.distance?r.distance-a.distance:r.flag.localeCompare(a.flag)).map(r=>r.flag).slice(0,3)}var Tt,Ys=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 Xs(){if(Tt)return Tt;let e=new Map;for(let t of mt)if(!Ys.has(t))for(let n of Ge(t)){let o=e.get(n)??[];o.push(t),e.set(n,o)}return Tt=e,Tt}function Qs(e,t){if(!e.startsWith("--"))return[];let n=Xs().get(q(e));if(!n)return[];let o=t?.trim().toLowerCase(),i=new Set(Ge(o));return[...new Set(n.filter(r=>r!==o).map(r=>({command:r,sharedFlagCount:Ge(r).filter(a=>i.has(a)).length})).sort((r,a)=>r.sharedFlagCount!==a.sharedFlagCount?a.sharedFlagCount-r.sharedFlagCount:r.command.localeCompare(a.command)).map(({command:r})=>B(r)?.canonical??r))]}function Zs(e,t,n){for(let o=0;o<e.length;o+=1){let i=e[o];if(!i.startsWith("--"))continue;let r=i.indexOf("="),a=r>=0?i.slice(0,r):i;if(q(a)!==q(t))continue;let s=[...e];return s[o]=r>=0?`${n}${i.slice(r)}`:n,s}}function el(e){let t=new Set(e.commandPaths),n=r=>Math.min(hr(r,e.normalizedUnknown),e.primaryToken!==e.normalizedUnknown?hr(r,e.primaryToken):Number.POSITIVE_INFINITY),o=new Map,i=(r,a)=>{if(!Number.isFinite(a)||!t.has(r))return;let s=o.get(r);(s===void 0||a<s)&&o.set(r,a)};for(let r of e.commandPaths)i(r,n(r));for(let[r,a]of Object.entries(Kt))r!=="read"&&i(a,n(r));return[...o.entries()].sort(([r,a],[s,l])=>a!==l?a-l:r.localeCompare(s)).map(([r])=>r)}function tl(e){let t=B(e.normalizedUnknown),n=Bi(e.commandPaths,e.primaryToken),o=el(e),i=Ks(e.primaryToken,e.extensionDescriptors).filter(r=>e.commandPaths.includes(r));return hn([...t&&e.commandPaths.includes(t.canonical)?[t.canonical_argv.join(" ")]:[],...n,...o,...i],e.commandPaths,e.primaryToken).filter(r=>!e.normalizedUnknown.includes(" ")||r!==e.normalizedUnknown)}function nl(e){return[...new Set(e.map(n=>n.split(" ")[0]).filter(n=>n.length>0))].sort((n,o)=>n.localeCompare(o))}function ol(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 Nn(e,t,n){let o=e.match(/unknown command '([^']+)'/i);if(!o||typeof o[1]!="string")return;let i=N(o[1]);if(i.length===0)return;let r=Vs(t,n);if(r.length===0)return;let a=Bs(i);if(a&&!r.includes(a.canonicalPath.split(" ")[0]))return{unknownCommandExamples:[a.installCommand,`pm ${a.canonicalPath} --help`,"pm --help --all"],unknownCommandNextSteps:[`"${i}" is provided by the "${a.packageAlias}" package. Install it with: ${a.installCommand}. Command after installation: pm ${a.canonicalPath}.`],suggestedRetryCommand:a.installCommand};let s=i.split(" ")[0],l=tl({commandPaths:r,normalizedUnknown:i,primaryToken:s,extensionDescriptors:n}),d=nl(r),c=(l.length>0?l:hn(d,r)).slice(0,3),m=ol(c,l.length>0),p=l.length>0?`Did you mean: ${c.join(", ")}?`:null;return{unknownCommandExamples:m,unknownCommandNextSteps:[...p?[p]:[],'Run "pm --help --all" to list every command available in this runtime, including active extensions.',...p?["Use one of the suggested command paths above with --help to inspect valid flags and usage."]:[]]}}function il(e){return Array.from(new Set(e))}function rl(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 al(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 sl(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(r=>r.trim().toLowerCase()===n))}function We(e,t){if(t.length===0)return!0;let n=e;for(let[o,i]of t.entries()){let r=sl(n,i);if(!r){let a=n.registeredArguments;return a.length>0&&(n.commands.length===0||a[0]?.required===!0)&&(a.at(-1)?.variadic===!0||t.length-o<=a.length)}n=r}return!0}async function ll(e,t,n,o){try{let i=$(process.cwd(),e.path);if(!await K(J(i)))return{allowedTypes:ze};let r=await D(i),a=e.noExtensions?void 0:ae(),s=re(r,a),l;if(/too many arguments/i.test(t)&&["comments","docs","files","learnings","notes","test"].includes(o??"")){let d=n.findIndex(m=>m===o),c=n[d+2];if(n[d+1]?.toLowerCase()==="add"&&c!==void 0&&!c.startsWith("-"))try{l=(await ut(i,c,r.id_prefix,r.item_format,s.type_to_folder))?.id}catch{}}return{allowedTypes:s.types.length>0?s.types.join("|"):ze,pmRoot:i,settings:r,typeToFolder:s.type_to_folder,verifiedCollectionItemId:l}}catch{return{allowedTypes:ze}}}function cl(e,t){let n=e.match(/unknown option '([^']+)'/i),o=n&&t?il([...Ws(t,n[1]),...Js(n[1],Ge(t))]):void 0,i=n?Qs(n[1],t):[],r=n!==null&&Ge(t).includes(q(n[1]));return{match:n,suggestions:o,otherCommands:i,scope:r?"declared_on_path":i.length>0?"declared_elsewhere":"declared_nowhere"}}function dl(e,t,n){if(!t||!n||n.length===0)return;let o=Zs(e,t[1],n[0]);return o?Dn(o):void 0}function ml(e,t){let n=e.match(/required option '([^']+)' not specified/i),o=n?.[1]?al(rl(n[1].trim())):void 0;if(!o?.startsWith("--"))return;let i=E(t);if(i)return Vi(t,i,[o])}function pl(e,t){if(!/too many arguments/i.test(e))return;let n=de(t),o=W(t.slice(n));if(o?.alias!=="schema")return;let i=n+o.canonical_argv.length-1,r=t[i+1]?.trim().toLowerCase(),a=t[i+2]?.trim().toLowerCase();if(!r||!a)return;let s=`${r}-${a}`;if(!gr.includes(s))return;let l=[...t.slice(0,i+1),s,...t.slice(i+3)];return{unknownSubcommandPath:"schema",unknownSubcommandToken:`${r} ${a}`,unknownSubcommandAllowedValues:[...gr],suggestedRetryCommand:Dn(l)}}async function Ve(e,t,n,o={}){let r=(typeof e=="object"&&e!==null?e.message:void 0)??"Invalid command usage",a=bt(process.argv.slice(2)).argv,s=G(a),l=de(a),d=W(a.slice(l))?.alias??E(a),c=Dn(a),m=X(a),p=await ll(s,r,a,d),u=p.allowedTypes,g=Nn(r,t,n),h=cl(r,d),y=pl(r,a),x=y?.suggestedRetryCommand??dl(a,h.match,h.suggestions)??ml(r,a);return{message:r,commandName:d,allowedTypes:u,attemptedCommand:c,normalizedInvocationArgs:[...a],providedOptionFlags:m,unknownOptionSuggestions:h.suggestions,unknownOptionOtherCommands:h.otherCommands.length>0?h.otherCommands.slice(0,12):void 0,unknownOptionOtherCommandsTotal:h.otherCommands.length>0?h.otherCommands.length:void 0,unknownOptionOtherCommandsTruncated:h.otherCommands.length>12||void 0,unknownOptionScope:h.scope,suggestedRetryCommand:x,verifiedCollectionItemId:p.verifiedCollectionItemId,...y,...g,...o}}async function Mn(e,t,n,o={}){let i=await Ve(e,t,n,o),{message:r,commandName:a,allowedTypes:s,unknownCommandExamples:l,unknownCommandNextSteps:d,attemptedCommand:c,normalizedInvocationArgs:m,providedOptionFlags:p,unknownOptionSuggestions:u,unknownOptionOtherCommands:g,unknownOptionOtherCommandsTotal:h,unknownOptionOtherCommandsTruncated:y,unknownOptionScope:x,unknownSubcommandPath:S,unknownSubcommandToken:z,unknownSubcommandAllowedValues:j,suggestedRetryCommand:we,verifiedCollectionItemId:Bt,failedExtensions:rt}=i,$e=mr(r,a,s,{unknownCommandExamples:l,unknownCommandNextSteps:d,attemptedCommand:c,normalizedInvocationArgs:m,providedOptionFlags:p,unknownOptionSuggestions:u,unknownOptionOtherCommands:g,unknownOptionOtherCommandsTotal:h,unknownOptionOtherCommandsTruncated:y,unknownOptionScope:x,unknownSubcommandPath:S,unknownSubcommandToken:z,unknownSubcommandAllowedValues:j,suggestedRetryCommand:we,verifiedCollectionItemId:Bt,failedExtensions:rt}),_e=await ri("help_format",{message:$e,command:a,allowed_types:s});return _e.handled&&typeof _e.result=="string"?_e.result:$e}async function Fn(e,t,n,o=!1,i={}){let r=await Ve(e,t,n,i),a=At(r.message,r.commandName,r.allowedTypes,f.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,verifiedCollectionItemId:r.verifiedCollectionItemId,failedExtensions:r.failedExtensions}),s=o?Et(a):a,l=G(r.normalizedInvocationArgs).tokenAccounting===!0;return JSON.stringify(l?le(s,d=>`${JSON.stringify(d,null,2)}
|
|
21
|
+
`):s,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]="939abfaf-7563-5490-bd76-90d188aa0940")}catch{}})();async function _r(e,t,n,o){if(n)return null;let i=e.some(a=>a==="--for"||a.startsWith("--for=")),r=E(e)==="contracts"&&e.includes("--full");return i||r?await o(t):null}import{Option as ul}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]="2f731313-580e-5554-bf61-f160121a298b")}catch{}})();function v(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function br(e,t){let n=new Map;for(let o of e){let i=v(o.command);for(let r of t){if(r.layer!==o.layer||r.name!==o.name)continue;let a=v(r.command),s=a.split(" "),l=s.at(-1),d=s.slice(1).join(" "),c=d?`${s[0]}-${l} ${d}`:`${s[0]}-${l}`;if(l&&i===c){n.set(i,a);break}}}return n}function Ln(e,t,n,o){if(!t||!n)return;let i,r=0;for(let[s,l]of e.entries()){if(l!==t)continue;let d=e.slice(s);for(let[c,m]of o.entries()){let p=c.split(" ");p.length>r&&p.every((u,g)=>d[g]===u)&&(i=m,r=p.length)}}let a=i?.flags.find(s=>s.long===n||s.short===n);if(a)return Ot(a).takesValue}function I(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 Ot(e){let t=I(e.value_type)??I(e.type),n=I(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 fl(e){if(ee(e.visible)===!1)return null;let n=I(e.long);if(!n||!n.startsWith("--")||n.length<3)return null;let o=I(e.short),i=o&&o.startsWith("-")&&!o.startsWith("--")?`${o}, `:"",r=I(e.value_name),a=r?` <${r}>`:"",s=I(e.description)??"Extension-provided option.",l=[];ee(e.required)===!0&&l.push("required"),ee(e.enabled)===!1&&l.push("disabled");let d=l.length>0?` [${l.join(", ")}]`:"";return`${i}${n}${a} ${s}${d}`}function Cr(e){let t=[...new Set(e.map(fl).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 xr(e){let t=new Map;for(let i of e){let r=v(i.target_command);if(r.length===0)continue;let a=t.get(r)??[];a.push(...i.flags),t.set(r,a)}let n=[...t.entries()].sort(([i],[r])=>i.localeCompare(r)),o=new Map;for(let[i,r]of n){let a=Cr(r);a&&o.set(i,a)}return o}function kr(e,t){return typeof t!="string"||t.trim().length===0?e.replace(/\s+/g,"-"):t.trim().toLowerCase()}function vr(e){if(!Array.isArray(e))return[];let t=[],n=new Set;for(let o of e){if(typeof o!="string")continue;let i=o.trim();i.length===0||n.has(i)||(n.add(i),t.push(i))}return t}function gl(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 hl(e){let t=new Map;for(let n of e){let o=v(n.command);if(o.length===0)continue;let i=typeof n.description=="string"&&n.description.trim().length>0?n.description.trim():void 0,r=typeof n.intent=="string"&&n.intent.trim().length>0?n.intent.trim():void 0;t.set(o,{command:o,action:kr(o,n.action),description:i,intent:r,examples:vr(n.examples),failure_hints:vr(n.failure_hints),arguments:gl(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 yl(e){let t=new Map;for(let n of e){let o=v(n.target_command);if(o.length===0)continue;let i=t.get(o)??[];i.push(...n.flags),t.set(o,i)}return t}function wl(e,t,n){let o=new Set;for(let i of e){let r=v(i);r.length>0&&o.add(r)}for(let i of t.keys())o.add(i);for(let i of n.keys())o.add(i);return o}function _l(e,t,n){let o=n.get(e);return o?t.get(o):void 0}function Er(e,t,n,o=new Map){let i=hl(t),r=yl(n),a=wl(e,i,r),s=new Map,l=[...a].sort((d,c)=>d.localeCompare(c));for(let d of l){let c=_l(d,i,o)??i.get(d),m=r.get(d)??(c?r.get(c.command):void 0)??[];if(c){s.set(d,{...c,command:d,flags:m});continue}s.set(d,{command:d,action:kr(d,void 0),examples:[],failure_hints:[],arguments:[],flags:m,tier:"standard",family:"extensions"})}return s}function vl(e){let t=e.variadic?"...":"";return e.required?`<${e.name}${t}>`:`[${e.name}${t}]`}function Sr(e,t){for(let n of t.arguments)e.argument(vl(n),n.description??"Extension argument.")}function Ar(e){if(ee(e.visible)===!1)return null;let n=I(e.long),o=I(e.short),i=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,r=n&&n.startsWith("--")&&n.length>2?n:null,a=[i,r].filter(s=>s!==null);return a.length>0?a:null}function bl(e){let t=Ar(e);if(!t)return null;let{valueName:n}=Ot(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Cl(e){let t=Ar(e);if(!t)return null;let{valueName:n}=Ot(e),o=n?` <${n}>`:"";return`${t.join(", ")}${o}`}function Tr(e){let t=I(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 Or(e,t){let n=I(t.long),o=I(t.short);return e.options.some(i=>{let r=i;return n!==null&&r.long===n||o!==null&&r.short===o})}function jn(e,t){for(let n of t){if(Or(e,n))continue;let o=Cl(n);if(!o)continue;let i=Tr(n),r=new ul(o,i);if(r.negate=!1,n.list!==!0){e.addOption(r);continue}e.addOption(r.argParser((a,s=[])=>[...Array.isArray(s)?s:[s],a]))}}function Un(e,t){return Cr(t.filter(n=>!Or(e,n)))}function xl(e){let t=bl(e);if(!t)return null;let n=I(e.long),o=I(e.short),i=n&&n.startsWith("--")&&n.length>2?n:null,r=o&&o.startsWith("-")&&!o.startsWith("--")?o:null,{takesValue:a,valueName:s}=Ot(e),l=ee(e.required)===!0;return{flags:t,long:i,short:r,description:Tr(e),takes_value:a,value_required:a,value_name:s,variadic:!1,required:l,aliases:[],alias_for:null}}function Rr(e){if(!e)return[];let t=[],n=new Set;for(let o of e.flags){let i=xl(o);!i||n.has(i.flags)||(n.add(i.flags),t.push(i))}return t}function Ir(e,t){if(t.length===0)return e;let n=[...e],o=new Set(e.map(i=>i.flags));for(let i of t)o.has(i.flags)||(o.add(i.flags),n.push(i));return n}function Pr(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 jn(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 Ve(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:jn(o).includes(n))??null}function Z(e,t){let n=e;for(let o of t){let i=Ve(n,o);if(!i)return null;n=i}return n}var Un=new WeakSet;function Ir(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let i=t[o];o>0&&M.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let r=Ve(n,i);if(r){n=r;continue}let a=n.command(i);Un.add(a),o<t.length-1?(a.description("Extension-provided command group."),a.action(()=>{a.help()})):a.description("Extension-provided command path."),n=a}return n}function vl(e,t){let n=t.join(" "),o=M.find(a=>n===a.canonical||n.startsWith(`${a.canonical} `));if(o)return{core_path:o.canonical,extension_path:n};let i=e,r=[];for(let a of t){let s=Ve(i,a);if(!s)return null;r.push(a);let l=s.commands.length>0||M.some(c=>c.canonical.startsWith(`${r.join(" ")} `));if(!Un.has(s)&&(r.length===t.length||!l))return{core_path:r.join(" "),extension_path:t.join(" ")};i=s}return null}function _l(e,t,n,o,i=!1){let r=t.split(" ").filter(d=>d.length>0),a=vl(e,r),s=Z(e,r),l=M.some(d=>d.canonical===t&&d.alias===o?.action&&!e.commands.some(m=>m.name()===d.alias)&&(s===null||Un.has(s)));if(!a||a.core_path===t&&s!==null&&!n.has(t)&&!i||l&&!n.has(t))return null;let c=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${a.extension_path}:core_owner=pm-cli:${a.core_path}:extension_owner=${c}`}function Pr(e,t,n,o,i){return[...new Set([...t,...n.keys()])].filter(r=>r.trim().length>0).sort((r,a)=>r.localeCompare(a)).filter(r=>{let a=_l(e,r,o,n.get(r),t.includes(r));return a?(i(a),!o.has(r)&&Z(e,r.split(" "))!==null):!0})}function $r(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]="93ca07c1-857b-57ae-8530-a315a24d0fe5")}catch{}})();var bl=new Set(["__proto__","prototype","constructor"]),Dr=Symbol("looseOptionOccurrences");function Be(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,o)=>o.toUpperCase())}function Cl(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 qn(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let a=n.indexOf("=");if(a>=0)return{consumed:1,key:n.slice(1,a).trim(),value:n.slice(a+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 i=n.slice(2).trim(),r=e[t+1];return typeof r=="string"&&!r.startsWith("-")?{consumed:2,key:i,value:r}:{consumed:1,key:i,value:!0}}function Ot(e){return bl.has(e)}function Nr(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 Ke(e){let t=[],n=typeof e.long=="string"?e.long.trim():"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let i=Be(n.slice(2));i.length>0&&!Ot(i)&&t.push(i)}if(o.startsWith("-")&&!o.startsWith("--")){let i=Be(o.slice(1));i.length>0&&!Ot(i)&&t.push(i)}return[...new Set(t)]}function Mr(e){let t=new Set;for(let n of e)for(let o of Ke(n))t.add(o);return t}function xl(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")){let n=Be(t.slice(2));if(n.length>0&&!Ot(n))return n}return Ke(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 Hn(e,t,n){if(t.length===0)return;let o=new Set,i=new Map,r=[],a=[];for(let s of t){let l=Ke(s),c=kl(s);c!==null&&a.push(c);for(let d of l)o.add(d),s.enabled===!1&&i.set(d,c);s.required===!0&&s.enabled!==!1&&l.length>0&&r.push({keys:l,label:c})}for(let s of Object.keys(e)){if(!o.has(s)){let c=a.length>0?` Expected one of: ${[...new Set(a)].join(", ")}.`:"";throw new C(`Unknown option '--${s}' for extension command '${n}'.${c}`,f.USAGE)}let l=i.get(s);if(l)throw new C(`Option '${l}' is disabled for extension command '${n}'.`,f.USAGE)}for(let s of r)if(!s.keys.some(l=>Object.hasOwn(e,l)))throw new C(`Missing required option '${s.label}' for extension command '${n}'.`,f.USAGE)}function El(e){return typeof e=="string"||e==null?e:String(e)}function Sl(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 Al(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 Tl={string:El,number:Sl,boolean:Al};function Rt(e,t){return Array.isArray(e)?e.map(n=>Rt(n,t)):Tl[t](e)}function Fr(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(i=>i!=null&&i!==""):Go(e);return t?o.map(i=>Rt(i,t)):o}function Ol(e,t,n,o){return n?Fr(e,t,o):t?Rt(e,t):e}function Rl(e,t,n){let o=e[Dr];if(!o||o.length===0)return n;let i=new Set(t);return o.filter(r=>i.has(r.key)).map(r=>r.value)}function Lr(e,t,n=e){if(t.length===0)return e;let o=Object.create(null);for(let[i,r]of Object.entries(e))o[i]=r;for(let i of t){let r=xl(i);if(!r)continue;let a=i.list===!0,s=Ke(i);for(let d of s)if(!(d===r||!Object.hasOwn(o,d))){if(Object.hasOwn(o,r)){if(!a){delete o[d];continue}let m=o[r],p=o[d];o[r]=[...Array.isArray(m)?m:[m],...Array.isArray(p)?p:[p]].filter(u=>u!=null),delete o[d];continue}o[r]=o[d],delete o[d]}let l=Nr(i),c=i.repeatable===!0;if(!Object.hasOwn(o,r)){i.default!==void 0&&(o[r]=Ol(i.default,l,a,c));continue}if(a){o[r]=Fr(Rl(n,s,o[r]),l,c);continue}l&&(o[r]=Rt(o[r],l))}return o}function jr(e){let t=Object.create(null),n=[];Object.defineProperty(t,Dr,{value:n});let o=0;for(;o<e.length;){let i=qn(e,o);if(!i){o+=1;continue}let r=Be(i.key);if(r.length===0||Ot(r)){o+=i.consumed;continue}Cl(t,r,i.value),n.push({...i,key:r}),o+=i.consumed}return t}function Ur(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=qn(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function zn(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let a of t){let s=Nr(a);for(let l of Ke(a))n.add(l),s==="boolean"&&o.add(l)}if(n.size===0)return[...e];let i=[],r=0;for(;r<e.length;){if(e[r]==="--"){i.push(...e.slice(r+1));break}let a=qn(e,r);if(a){let s=Be(a.key);if(n.has(s)){let l=e[r],c=o.has(s)&&!l.includes("=")?1:a.consumed;r+=c;continue}}i.push(e[r]),r+=1}return i}import ke 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]="989fc265-7deb-5456-8a83-0f1fa8d2d9b2")}catch{}})();async function Gn(e,t={},n=[]){let o={readSettings:D,loadExtensions:$e,activateExtensions:De,resolveImplicitPmRoot:Jt,...t};try{let i=await o.readSettings(e),r=await o.loadExtensions({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),a=await o.activateExtensions(r);return[...r.failed,...a.failed].map(s=>{let l=(r.effective??[]).find(p=>p.layer===s.layer&&p.name===s.name),c=[...l?.contributions?.commands??[],...l?.contributions?.command_handlers??[],...l?.activation?.commands??[]].map(N).filter((p,u,g)=>p.length>0&&g.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),d=n.map(N),m=c.some(p=>d.some(u=>u===p||u.startsWith(`${p} `)));return{layer:s.layer,name:s.name,error:s.error,...c.length>0?{declared_commands:c}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(i){return[{layer:"runtime",name:"extension-loader",error:i instanceof Error?i.message:String(i)}]}}async function qr(e,t,n={},o=[]){if(e!=="unknown_command")return[];let i=await Gn(t,n,o),r={readSettings:D,loadExtensions:$e,activateExtensions:De,resolveImplicitPmRoot:Jt,...n};try{let a=r.resolveImplicitPmRoot(process.cwd());if(ke.resolve(a)===ke.resolve(t))return i;let[s,l]=await Promise.all([r.readSettings(t),r.readSettings(a)]),[c,d]=await Promise.all([r.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),r.loadExtensions({pmRoot:a,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 i;i.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${ke.resolve(t)} extension_discovery_root=${c.roots.project}; cwd_storage_root=${ke.resolve(a)} 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 ${ke.resolve(a)}, or install the extension into the selected tracker with "pm --pm-path ${ke.resolve(t)} install <package> --project".`})}catch{}return 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]="a0e4b3f7-ace2-5190-8e60-83d67109e95d")}catch{}})();var Hr={core:0,standard:1,full:2,internal:3};function zr(e,t,n=!0){let o=t.get(O(e));if(o)return o;if(!n)return;let i=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(i.length===0)return;let r=i.reduce((s,l)=>Hr[l.tier]<Hr[s]?l.tier:s,"internal"),a=new Set(i.map(({family:s})=>s));return{tier:r,family:a.size===1?i[0].family:"extensions"}}function Il(e,t){if(t.length===0)return e;let n=Z(e,t);if(n)return n;let o=t.join(" ");if(O(o)!==o||!dt.some(i=>i===o)&&!Pi(o)&&!je(o)&&!Ge(e,t))return null;for(let i=t.length-1;i>0;i-=1){let r=Z(e,t.slice(0,i));if(r)return r}return t.length===1?e:null}function Pl(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function Gr(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 $l(e){let t=new Map;for(let n of e){let o=n,i=Gr(n);if(!i||typeof o.long!="string"||o.long.trim().length===0)continue;let r=t.get(i)??[];r.push(o.long.trim()),t.set(i,r)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(i=>i.trim()).filter(i=>i.length>0))].sort((i,r)=>i.localeCompare(r)));return t}function Dl(e){return A(e)}function Nl(e){let t=e.options??[],n=$l(t);return t.map(o=>{let i=o,r=typeof i.flags=="string"?i.flags.trim():"",a=typeof i.description=="string"?i.description.trim():"",s=Gr(o),c=(s?n.get(s)??[]:[]).filter(y=>y!==i.long).map(y=>y.trim()).filter(y=>y.length>0),d=a.match(/^Alias for ([^ ]+)/i),m=d&&d[1]?d[1].trim():null,p=i.mandatory===!0||a.includes("[required]")||a.toLowerCase().includes("required;"),u=r.includes("<"),g=u||r.includes("["),h={flags:r,long:typeof i.long=="string"?i.long:null,short:typeof i.short=="string"?i.short:null,description:a,takes_value:g,value_required:u,value_name:Pl(r),variadic:i.variadic===!0,required:p,aliases:c,alias_for:m};return i.defaultValue!==void 0&&(h.default_value=i.defaultValue),h})}function Ml(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 i=o.alias_for,r=t.get(i);if(!r)continue;let a=o.long,s=new Set([...r.aliases??[],a]);r.aliases=[...s].sort((l,c)=>l.localeCompare(c))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function Fl(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(o=>{let i=typeof o.name=="function"?o.name():typeof o.name=="string"?o.name:"argument",r=typeof o.description=="string"&&o.description.trim().length>0?o.description.trim():null;return{name:i.trim(),required:o.required===!0||r?.toLowerCase().startsWith("required;")===!0,variadic:o.variadic===!0,description:r}})}function Ll(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(r=>r.name()!=="help"||e.parent===null).filter(r=>!n||(ce(r)??K(r.name()))!=="internal").map(r=>{let a=N(T(r)),s=a,l=ce(r),c=zr(a,t,l!==void 0),d=te.find(({alias:m})=>m===a);return{name:r.name().trim(),aliases:jn(r),description:r.description().trim(),tier:c?.tier??l??K(s),family:c?.family??yt(s),...d?{alias_for:d.canonical,alias_lifecycle:d.lifecycle,...d.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((r,a)=>r.name.localeCompare(a.name))}function jl(e,t,n){if(!n)return t;let o=n.examples??[],i=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"?i.length>0?[...i]:[...t.tips]:[],detail_mode:e}}function Ul(e,t,n,o,i){let r=e!==void 0&&yn(e)===be,a=r?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:Qi(e,n),s=i?"positional_action":o?.intent||o?.description?"extension":r?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:jl(n,a,o),intentSource:s}}function ql(e,t){return e===void 0?null:t?.tier??K(e)}function Hl(e,t){return e===void 0?null:t?.family??yt(e)}function zl(e,t,n){if(!(t!==e||!n))return te.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function Gl(e,t,n,o,i=new Map,r=!1){if(!e){let s=Fl(t),l=Ll(t,i,r),c=new Set(l.map(({name:d})=>d));return{arguments:s,options:o,subcommands:[...l,...ft.filter(({parent:d,action:m})=>d===n&&!c.has(m)).map(({action:d,description:m})=>({name:d,aliases:[],description:m,tier:K(n.split(" ")[0]),family:yt(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 a=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&&a.has(s)||l.some(c=>a.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 Wl(e,t,n,o,i){let r=hn(n),a=me(n),s=N(T(t)),l=N(o.join(" ")),c=l.length>s.length?l:s,d=je(c),m=d?.command??s,p=m.length>0?m:void 0,u=p,g=p?i.get(O(p)):void 0,h=p?zr(p,i,ce(t)!==void 0):void 0,{narrative:y,intentSource:x}=Ul(p,t.description().trim(),r,g,d!==void 0),S=Ml(Or(Nl(t),Tr(g))),z=Gl(d,t,m,S,i,a),L=zl(e,t,a);return{format:"pm_help_v1",detail_mode:r,root_command:e.name(),requested_path:o,resolved_path:m.length>0?m:e.name(),visibility_tier:ql(u,h),capability_family:Hl(u,h),description:d?.description??t.description(),usage:z.usage,intent:d?.description??y.intent,intent_source:x,examples:d?[d.example]:y.examples,tips:d?[gt(d.accepted_flags)]:y.tips,arguments:z.arguments,options:z.options,subcommands:z.subcommands,has_subcommands:z.subcommands.length>0,...L===void 0?{}:{command_aliases:L}}}async function Wr(e,t,n,o=t){let i=G(t);if(!i.json)return!1;let r=k(t);if(!r.requested)return!1;let a=Il(e,r.commandPathTokens);if(!a){if(!i.quiet){let s=`unknown command '${O(r.commandPathTokens.join(" "))}'`,l=$n(s,e,n),c=St(s,"help",He,f.USAGE,{...l,attemptedCommand:Dl(t),normalizedInvocationArgs:[...t],providedOptionFlags:J(t)}),d=i.tokenAccounting?ae(c,m=>`${JSON.stringify(m,null,2)}
|
|
28
|
-
`):
|
|
29
|
-
`)}return process.exitCode=f.USAGE,!0}if(!i.quiet){let s=
|
|
30
|
-
`)}return process.exitCode=f.SUCCESS,!0}function
|
|
31
|
-
`)}function
|
|
32
|
-
`)}let r=n.indexOf("--"),a=r<0?n:n.slice(0,r),s=a.findIndex(h=>h==="--create-mode"||h.startsWith("--create-mode=")),l=s<0?void 0:a[s]?.startsWith("--create-mode=")?a[s]?.slice(14):a[s+1],
|
|
33
|
-
`)}function Vr(e,t,n){let o=E(n);if(o!=="create"&&o!=="update")return;let i=Ve(e,o);i&&i.addHelpText("after",Yl(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]="840b471e-c996-57e2-b97c-3a84bd68f050")}catch{}})();function Xl(e,t){let n=Pe(e.id);return n||`migration-${String(t+1).padStart(3,"0")}`}function Ql(e){return Pe(e.status)?.toLowerCase()??"pending"}function Zl(e){return e.mandatory===!0}function ec(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 Jr(e){let t=[];return e.forEach((n,o)=>{if(!Zl(n.definition))return;let i=Ql(n.definition);i!=="applied"&&t.push({layer:n.layer,name:n.name,id:Xl(n.definition,o),status:i})}),t.sort(ec),t}function Br(e){return Array.isArray(e)&&e.length>0}var tc=new Set(["create","beads import","todos import"]),nc=new Set(["restore","update","close","delete","append","claim","release"]),oc=new Set(["comments","notes","learnings"]),ic=new Set(["files","docs","test"]),rc=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 Wn(e,t){let n=t.force===!0;return tc.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:nc.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:oc.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:ic.has(e)?{isMutation:Br(t.add)||Br(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function ac(e,t,n){if(Wn(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return Ai(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(i=>rc.has(i.trim().toLowerCase())):!1}function Kr(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function sc(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let i=[];if(Pe(t[1])||i.push("source"),Pe(n.to)||i.push("--to"),i.length!==0)throw new C(`Schema migration requires ${i.join(", ")}.`,f.USAGE,{code:"schema_migration_input_required",required:i.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:i,suggested_flags:i.filter(r=>r.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function lc(e,t,n,o,i){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||Kr(n.status)!==Kr(i.schema.workflow.in_progress_status))return;let r=t[0];if(!r)return;let a=oe(i,ie()),s=await pt(o,r,i.id_prefix,i.item_format,a.type_to_folder);if(!s)return;let l=await vi(s,{schema:i.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 Vn(e,t,n,o,i){if(!ac(e,t,n)||(sc(e,t,n),!await V(B(i))))return;let r=await _e(i);o.json!==!0&&await lc(e,t,n,i,r.settings);let a=Si({author:mt(o.author,r.settings.author_default),payload:{command:e,args:t,options:n},settings:r.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of a.warnings)w(`warning:${s}`)}function Yr(e,t,n){if(n.length===0)return;let o=Wn(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let i=n.map(a=>`extension_migration_blocking:${a.layer}:${a.name}:${a.id}:${a.status}`),r=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new C(`Write command "${e}" blocked by unresolved mandatory extension migrations (${i.join(",")}). ${r}`,f.CONFLICT)}async function Bn(e,t,n,o){if(!Wn(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await V(B(n)))return;let{settings:r,metadata:a,warnings:s}=await _e(n);for(let l of s)w(`warning:${l}`);if(o.enforce_item_format_gate&&!a.has_explicit_item_format&&(yi(r),await wi(n,r,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let l=oe(r,ie());await Ti(n,r.item_format,"item_format:pre_mutation_sync",l.type_to_folder,r.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]="697f96fe-38a0-5530-b54b-22cb442c130f")}catch{}})();function Kn(e){let t=[];for(let n of e??[]){if(n.startsWith("-"))break;let o=_(n);o.length!==0&&t.push(o)}return t}function Se(e){let t=_(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(i=>i.length>0);for(let i of Kn(e.commandArgs))o.push(...i.split(" ").filter(r=>r.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(i=>[i,O(i)]))]}function Jn(e,t){let n=_(e);if(n.length===0)return!1;let o=Se(t);for(let i of o)if(i===n||i.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(i=>n.startsWith(`${i} `)):!1}function Pt(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),...Xr(n.preflight_ownership),...Xr(n.renderer_ownership)]:[]}function R(e){return e??[]}function Xr(e){return R(e).flatMap(t=>t.commands)}function Je(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var Qr=new Set(["hooks","parser","preflight","renderers"]),Zr=new Set(["commands","schema","services","importers"]),cc=new Set(["reindex","search","search-advanced"]),dc=new Set(["--template"]);function Ee(e,t){for(let n of t)if(e.has(n))return!0;return!1}function Yn(e){let t=_(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return cc.has(n??t)}function Xn(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 $t(e){return _(e.commandPath??"")==="create"&&Xn(e,dc)}function Qn(e){return e.some(t=>{let n=_(t);return n==="templates"||n.startsWith("templates ")})}function It(e,t){return e.some(n=>Jn(n,t))||$t(t)&&Qn(e)}function Zn(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(n=>n>0)}function eo(e,t){let n=e.activation?.commands??[];if(n.length>0)return It(n,t);let o=Pt(e);if(It(o,t)||Je(e).has("search")&&Yn(t.commandPath))return!0;if(e.contributions)return Zn(e.contributions)}function Dt(e,t){let n=eo(e,t);if(n!==void 0)return n;let o=Je(e);return!!(Ee(o,Qr)||Ee(o,Zr))}function Ye(e,t){return e.effective.length===0?!1:Xe(t)!=="all"?e.effective.some(o=>Dt(o,t)):e.effective.some(o=>{let i=Je(o);return Pt(o).length>0||Ee(i,Qr)||Ee(i,Zr)||i.has("search")})}function Xe(e){if(_(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Se(e).filter(i=>i.split(" ").every(r=>!r.startsWith("-"))).sort((i,r)=>r.length-i.length)[0]??_(e.commandPath??"");if(t.length===0)return"all";let n=$t(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function to(e){return Xe(e)==="all"?void 0:t=>Dt(t,e)}function Ae(e){let t=k(e);if(t.requested&&t.commandPathTokens.length>0){let[i,...r]=t.commandPathTokens;return{commandPath:i,commandArgs:r,allowCommandPrefixMatch:!0}}let n=F(e),o=n.findIndex(i=>i.trim().length>0&&!i.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function no(e){let t=e.args.map(String);if(_(T(e))==="create"){let o=e.optsWithGlobals();typeof o.template=="string"&&o.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]="4584c97a-4e3c-551e-95a4-2f63a7fc152e")}catch{}})();var Nt=Symbol.for("pm.readOutputInvocationProvenance");function oo(e,t){let n=Reflect.get(e,Nt);n!==void 0&&Reflect.set(t,Nt,n)}function io(e,t,n){let o=si(t,n);if(!o)return;let i=e;for(;i.parent;)i=i.parent;let r=i.rawArgs,a=new Set(J(r.slice(2))),s=ai.find(d=>d.command===o),l=Object.values(s.dimensions).flatMap(d=>d.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),c=Reflect.get(n,Nt);Reflect.set(n,Nt,{canonical_include_modes:c?.canonical_include_modes??[],explicit_legacy_aliases:l,cli_invocation_observed:!0}),oo(n,e)}function ro(e,t,n,o){io(e,t,o);let i=n.outputInclude;if(i===void 0)return;let{selectors:r,modes:a}=di(t,i,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),a.length===0)return;oo(o,e);let s=ci(t);for(let c of a){let d=s.get(c),m=o[d];e.setOptionValueWithSource(d,m,"cli")}let l=r.length>0?r.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");vt(e,n)}function mc(e){let t=e.optsWithGlobals(),n=T(e);if(O(n)===n)return t;let o=e.opts();for(let i=e.parent;i?.parent;i=i.parent)for(let r of Object.keys(i.opts()))!(r in o)&&i.getOptionValueSource(r)==="default"&&delete t[r];return t}function Te(e,t,n=[]){let i={...mc(e)};oo(e,i),delete i.json,delete i.quiet,delete i.path,delete i.pmPath,delete i.noExtensions,delete i.extensions,delete i.profile,delete i.pager,delete i.changedFields,delete i.fullChangedFields,delete i.idOnly,delete i.lean,delete i.tokenAccounting,delete i.outputInclude,delete i.outputLimit,delete i.outputBudget,delete i.outputFormat,delete i.outputSession;let r=jr(t);for(let[a,s]of Object.entries(r))i[a]===void 0&&(i[a]=s);if(n.length>0){let a=Mr(n),s=ht(T(e)).map(c=>({long:c.flag,short:c.short,aliases:c.aliases})),l={...r};for(let c of a)i[c]!==void 0&&(l[c]=i[c]);return Hn(l,[...s,...n],T(e)),Lr(i,n,r)}return i}function Mt(e,t){let n=_(t);return n.length===0?[]:e.flags.filter(o=>O(_(o.target_command))===O(n)).flatMap(o=>o.flags)}function Qe(e,t,n){let o=Mt(e,t),i=[t],r=[];for(let a of n){if(a.startsWith("-"))break;i.push(a);let s=Mt(e,i.join(" "));s.length>0&&(r=s)}return r.length>0?r:o}function Ft(e){return e.arguments??[]}function ea(e){let t=Ft(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function ao(e,t){if(!e)return!1;let n=_(t);return e.importers.some(o=>_(`${o.importer} import`)===n)||e.exporters.some(o=>_(`${o.exporter} export`)===n)}function so(e,t){let n=Ft(e),o=n.filter(l=>l.required).length,r=n.some(l=>l.variadic)?Number.POSITIVE_INFINITY:n.length,a=e.failure_hints??[],s=a.length>0?` ${a.join(" ")}`:"";if(t.length<o)throw new C(`Missing required argument for extension command '${e.command}'. Usage: ${ea(e)}${s}`,f.USAGE);if(t.length>r){let l=t.slice(r).join(" ");throw new C(`Too many arguments for extension command '${e.command}': ${l}. Usage: ${ea(e)}${s}`,f.USAGE)}}function pc(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function uc(e,t,n){if(n.length>0){Hn(t,n,e.command);return}let o=Object.keys(t).filter(i=>t[i]!==void 0).sort();if(o.length!==0)throw new C(`Unknown option '${o.map(pc).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,f.USAGE)}function lo(e,t,n,o){e&&(so(e,t),uc(e,n,o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="48c16121-f941-50e9-9945-3a14ceddb08f")}catch{}})();var fc=new Set(["--version","-V"]);function Ze(e){let t=F(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}var gc=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),co=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"]),ta=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"]),hc=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),yc=new Set(["claim","close-task","pause-task","release","start-task","test"]),Lt={setup:!0,listQuery:!0,mutation:!0,operation:!0},wc=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 et(e){return e.some(t=>fc.has(t))}function mo(e){if(et(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||k(e).requested)return Lt;let t=E(e);if(!t)return Lt;let n=t.trim().toLowerCase(),o=F(e),i=W(o)?.alias;return M.some(r=>r.alias===i)?{...Lt,targetCommandName:i}:gc.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:co.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:ta.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:hc.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:Lt}function po(e){return e.length===0||k(e).requested||e.includes("--explain")&&E(e)===void 0}function uo(e,t){return Ze(t)||et(t)?!1:me(t)||k(t).requested?!0:!!E(t)}function fo(e){if(et(e))return!1;let t=E(e);return t?wc.has(t):!1}function vc(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,i=e.normalizedTokens.map(c=>{let d=c.indexOf("=");return d>=0?c.slice(0,d):c}).find(c=>c==="--literal"||c==="--regex"||c==="--replacement"),r=i?e.argv.map(c=>{let d=c.indexOf("=");return(d>=0?c.slice(0,d):c)===o?d>=0?`${i}${c.slice(d)}`:i:c}):e.argv,a=Ne(r),s=i&&n>=0?`${o}=[redacted]`:t,l=i&&e.normalizedDisplay.includes("=")?`${i}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:l,sourceDisplay:s}}function go(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),i=o.length>0?o.join(" "):"the canonical flag",r=ta.has(t)||yc.has(t),a=r?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=r?"mutating option":"option",l=vc({argv:e.argv,normalizedDisplay:i,normalizedTokens:o,rawFrom:n.from});throw new C(`Refusing to auto-correct ${s} ${l.sourceDisplay} to ${l.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,f.USAGE,{code:a,examples:[A(l.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:l.argv,suggested_retry:A(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]="afcf2608-3360-5030-b5ea-b101df5829e7")}catch{}})();var _c=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"]),bc=new Set(["parse","preflight","execute","unknown"]),Cc=new Set(["usage","validation","conflict","runtime","unknown"]);function fe(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let i=o.trim();if(i.length>0)return i}}}function ho(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function jt(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 yo(e){if(!e)return;let t=e.trim().toLowerCase();if(_c.has(t))return t}function wo(e){if(!e)return;let t=e.trim().toLowerCase();if(bc.has(t))return t}function vo(e){if(!e)return;let t=e.trim().toLowerCase();if(Cc.has(t))return t}function _o(e){let t=fe(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let a=n.find(s=>typeof s=="string"&&s.trim().length>0);if(typeof a=="string")return a.trim()}if(ho(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let i=jt(e,"failed");if(typeof i=="number"&&i>0)return`failed_runs:${i}`;let r=e?.run_results;if(Array.isArray(r)){let a=r.filter(s=>Bt(s)?.status==="failed").length;if(a>0)return`failed_runs:${a}`}}function bo(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 Co(){let e=Bt(re()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=jt(e,"exit_code","exitCode"),o=t??n??f.SUCCESS,i=Mi(o),r=fe(e,"error_code","errorCode")??bo(i,o),a=vo(fe(e,"error_category","errorCategory"))??(i?void 0:rt(r)),s=i?void 0:_o(e)??`command_exit_${o}`,l=yo(fe(e,"command_resolution","commandResolution"))??ut({ok:i,errorCode:r,errorCategory:a}),c=wo(fe(e,"resolution_stage","resolutionStage"))??"execute";return{ok:i,error:s,exit_code:o,error_code:r,error_category:a,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]="2a6936ec-d28f-5fba-9585-8cb5bcba103b")}catch{}})();var xo="PM_CLI_PACKAGE_ROOT";function xc(){return Fo(import.meta.url,["../.."])}(typeof process.env[xo]!="string"||process.env[xo]?.trim().length===0)&&(process.env[xo]=xc());var Oe=null,H=null;function kc(e){Oe=e}function Ec(e){P=e}var tt=null,ge=null,P=new Map,Ro=250,Sc=new Set([f.USAGE,f.NOT_FOUND,f.CONFLICT]),Ac=new Set(["1","true","yes","on"]),Tc=Le(()=>import("./chunks/register-setup-NVX6374E.js")),Oc=Le(()=>import("./chunks/register-list-query-N6RP6PSP.js")),Rc=Le(()=>import("./chunks/register-mutation-CY7JGQE6.js")),Ic=Le(()=>import("./chunks/register-operations-53HAD3QP.js"));function qt(e){return A(e)}function aa(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=>le(o)??o))];return n.length>0?n:void 0}function Pc(e,t,n){if(n?.suggested_retry||e.includes("failed in extension handler (")||!/\b(?:missing|required|requires)\b/i.test(e))return;let o=J(t),i=new Set(o.map(d=>le(d)??d)),r=aa(e),a=t.find(d=>v.commands.some(m=>m.name()===d)),s=a?v.commands.find(d=>d.name()===a):void 0,l=new Set([...v.options,...s?.options??[]].flatMap(d=>d.flags.split(/[ ,|]+/).map(m=>le(m)).filter(m=>m!==void 0))),c=r?.filter(d=>{let m=le(d)??d;return i.has(m)?!1:l.has(m)||Mn(t,a,m,P)!==void 0});return c&&c.length>0?c:void 0}function $c(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let i=n?.[0],r=i?le(i):void 0,a=e.find(p=>v.commands.some(u=>u.name()===p)),s=a?v.commands.find(p=>p.name()===a):void 0,l=r?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(r)):void 0,c=Mn(e,a,r,P),d=r?l?.isBoolean()===!0||c===!1?[r]:[r,"<value>"]:[],m=r?qt([...e,...d]):t;return m===t?void 0:m}function Dc(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 i=e[o];i!=null&&(n[o]=i)}return n}function Nc(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,...Dc(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function sa(e,t,n){let o=Ne(t),i=F(o),r=qe(i),[a,s]=r===void 0?[]:i.slice(r,r+2),l=o.includes("--explain"),c=e?.recovery,d=c&&(a==="history-redact"||a==="history"&&s==="redact")?{...c,...c.attempted_command?{attempted_command:qt(o)}:{},...c.normalized_args?{normalized_args:[...o]}:{},...c.suggested_retry?{suggested_retry:qt(o)}:{},...c.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:c;if(d?.recovery_mode==="compact"&&!l)return{...e,recovery:d};let m=qt(o),p=J(o),u=Pc(n,o,d),g=$c(o,m,u,d),h=Nc({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:g,existingRecovery:d});return{...e,recovery:h}}async function ot(e){let t=H;H=null,await Vi(t,e);let n=Oe;if(Oe=null,!n){lt();return}let o=[],i=ni();try{await Bi({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?i?.map(r=>r.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await Vo(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:re(),affected:i}))}catch(r){o=[`afterCommand hooks failed: ${r instanceof Error?r.message:String(r)}`]}finally{lt()}!n.globalOptions.json&&o.length>0&&w(`[pm] warning: afterCommand hook_warnings=${j(o)}`),n.profileEnabled&&o.length>0&&w(`profile:extensions hook_warnings=${j(o)}`)}async function la(){await ki()}function ca(e){return Ac.has((process.env[e]??"").trim().toLowerCase())}function da(e){return ca("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Sc.has(Math.trunc(e))}async function Ht(e){return da(e.exit_code)?(await la(),Ei(e),!0):!1}async function ma(e){let t=se(e.error),n=pr(t);e.bootstrapGlobal.json?w(JSON.stringify(dr(t,f.GENERIC_FAILURE),null,2)):w(t),process.exitCode=f.GENERIC_FAILURE;let o="runtime",i="runtime_failed";try{await la(),cn(e.error);let r=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=r.errorCategory,i=r.commandResolution,Me(!1,t,{error_code:n.code,error_category:o,exit_code:f.GENERIC_FAILURE,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||w(`Failed to report error: ${se(r)}`)}try{await ot({ok:!1,error:t,exit_code:f.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||w(`Failed to run error hooks: ${se(r)}`)}try{await Fe()}catch(r){e.bootstrapGlobal.json||w(`Failed to flush error reporting: ${se(r)}`)}}var Mc={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"},ko=new Map;function Eo(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function pa(e,t){return e.options.some(n=>n.long===t)}function ua(e,t){return e.options.some(n=>n.short===t)}function So(e,t,n,o){let i=t.trim();if(!i)return;let r=n.length>0?n:`Runtime schema field (${t})`;if(i.startsWith("-")&&!i.startsWith("--")){if(ua(e,i))return;if(o){e.option(`${i} <value>`,`${r} (repeatable)`,pn);return}e.option(`${i} <value>`,r);return}let a=i.startsWith("--")?i:`--${i}`;if(!pa(e,a)){if(o){e.option(`${a} <value>`,`${r} (repeatable)`,pn);return}e.option(`${a} <value>`,r)}}async function fa(e,t){let n=Mc[e];if(!n)return[];let o=`${t}:${n}`,i=ko.get(o);if(i)return i;if(!await V(B(t)))return ko.set(o,[]),[];let r=await D(t),s=(an(r.schema).command_to_fields.get(n)??[]).flatMap(l=>[l.cli_flag,...l.cli_aliases].map(d=>({long:`--${d}`,type:Eo(l.type),value_type:Eo(l.type)})));return ko.set(o,s),s}async function ga(e,t){let n=G(t),o=$(process.cwd(),n.path);if(!await V(B(o)))return;let i=ge?.key===$o(o)?ge.snapshot:null,r=i===null?await D(o):i.settings,a=an(r.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=Z(e,l.path.split(" "));if(c)for(let d of a.command_to_fields.get(l.command)??[]){let m=d.description??"";So(c,d.cli_flag,m,d.repeatable);for(let p of d.cli_aliases)So(c,p,`Alias for --${d.cli_flag}`,d.repeatable)}}}async function Io(e,t,n,o,i){let r=E(n);if(!(r!=="create"&&r!=="update"))try{let a=i??await D(t),s=oe(a,o);Vr(e,s,n)}catch{}}function Ao(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function ha(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function Po(e){return e.some(t=>t==="--profile")}function $o(e){return`pm-root:${e}`}function To(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 ya(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=${j(t.activationWarnings)}`))}function zt(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 Gt(e,t=_e){let n=$o(e);if(ge?.key===n)return ge.snapshot;try{let o=Date.now(),{settings:i,warnings:r}=await t(e),a=await Bo({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:i,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...r]};return ge={key:n,snapshot:s},s}catch{return ge={key:n,snapshot:null},null}}async function Re(e,t,n=D){let o=t?Xe(t):"all",i=ha(e,o);if(tt?.key===i)return tt.snapshot;try{let r=await n(e),a=await $e({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?to(t):void 0}),s=await De({...a,loaded:a.loaded}),l=[...new Set(s.commands.handlers.map(u=>_(u.command)))].filter(u=>u.length>0).sort((u,g)=>u.localeCompare(g)),c=br(s.registrations.flags),d=vr(s.commands.handlers,s.registrations.commands),m=xr(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:r,commandHandlers:l,commandFlagHelp:c,commandDescriptors:m,commandAliases:d,loadWarnings:[...a.warnings],activationWarnings:[...s.warnings],loadedCount:a.loaded.length,loadFailedCount:a.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:a.loaded.map(({name:u,module:g})=>({name:u,module:g}))};return tt={key:i,snapshot:p},p}catch{return tt={key:i,snapshot:null},null}}async function wa(e){let t=Ue(e);if(t.noExtensions){let a=$(process.cwd(),t.path);return await V(B(a))&&To((await _e(a)).warnings),null}let n=$(process.cwd(),t.path),o=await Gt(n);if(!o)return null;To(o.settingsReadWarnings);let i={commandPath:T(e),commandArgs:no(e)};if(!Ye(o.discovery,i))return zt(t.profile,o,i),null;let r=await Re(n,i);return r?(ya(t,r),{hooks:r.hooks,commands:r.commands,parsers:r.parsers,preflight:r.preflight,services:r.services,renderers:r.renderers,registrations:r.registrations,pmRoot:n}):null}async function va(e){let t=await Re(e);return t?new Map(t.commandDescriptors):P}async function _a(e,t){return(await bi({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(o=>o.outcome==="failed").map(o=>`extension_migration_failed:${o.layer}:${o.extension}:${o.id}`)}function ba(e,t){let n=typeof t.author=="string"&&t.author.trim()?t.author.trim():"pm-extension";return _i(e,qi.forActiveExtensionHost({pmRoot:e,author:n}))}async function Ca(e,t,n,o=[]){let i=T(e),r=zn(e.args.map(String),o),a={...t},s={...n},l=$(process.cwd(),n.path),c=await ct({command:i,args:r,options:a,global:s,pm_root:l});n.profile&&c.warnings.length>0&&w(`profile:extensions parser_warnings=${j(c.warnings)}`),r=c.context.args,a=c.context.options,s=c.context.global,lo(P.get(_(i)),r,a,o),we(void 0),st({command:i,args:r,options:{...a},global:{...s},pm_root:l});let d=await Xt({command:i,args:r,options:a,global:s,pm_root:l,sdk:ba(l,s)});if(s.profile&&d.warnings.length>0&&w(`profile:extensions command_handler_warnings=${j(d.warnings)}`),!d.handled){if(d.warnings.length>0){let m=d.warnings[0],p=d.errorMessage?.trim(),u=p?` ${p}`:"";throw new C(`Command "${i}" failed in extension handler (${m}).${u}`,f.GENERIC_FAILURE,{code:d.errorCode??"command_failed",nextSteps:d.remediation?[d.remediation]:void 0})}throw new C(`Command "${i}" is provided by extensions and is not currently available.`,f.NOT_FOUND)}return d.exitCode!==void 0&&(process.exitCode=d.exitCode),we(d.result),d.result}var na=Symbol("pm.wrappedActionHandler");function Fc(e,t){let n=e[e.length-1];return n instanceof Oo?n:t}function oa(e,t,n){e&&n.length>0&&w(`profile:extensions ${t}=${j(n)}`)}function Lc(e){let t=P.get(_(e.commandPath));if(!t||!ao(e.activeRegistrations,e.commandPath))return;let n=Ft(t).length===0?Ur(e.commandArgs):zn(e.commandArgs,e.extensionFlagDefinitions);so(t,n)}function jc(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 xa(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[na]!==!0){let i=o._actionHandler;o._actionHandler=async function(...a){let s=Fc(a,n),l=Date.now();mn(s);let c=Ue(s),d=O(T(s));if(["package inventory","packages inventory","extension inventory"].includes(d))return await i.apply(this,a);let m=$(process.cwd(),c.path),p=s.args.map(String),u=ie(),g=u?Qe(u,d,p):[],h=await fa(d,m),y=Te(s,p,[...g,...h]),x=await ct({command:d,args:p,options:y,global:c,pm_root:m});oa(c.profile,"parser_warnings",x.warnings),p=x.context.args,y=x.context.options,c=x.context.global,Lc({activeRegistrations:u,commandPath:d,commandArgs:p,extensionFlagDefinitions:g}),c=await Li(c),vt(s,c),jc(s,a,p),wt(s,y),we(void 0),st({command:d,args:p,options:{...y},global:{...c},pm_root:m});let S=await Xt({command:d,args:p,options:y,global:c,pm_root:m,sdk:ba(m,c)});if(oa(c.profile,"command_handler_warnings",S.warnings),S.handled){we(S.result),Zt(S.result,{...c,command:d,commandArgs:p,commandOptions:y,pmRoot:m}),c.profile&&w(`profile:command=${d} took_ms=${Date.now()-l}`);return}return await i.apply(this,a)},o[na]=!0}for(let i of n.commands)t(i)};t(e)}async function Ut(e){P=new Map,ee({overrides:[]}),e&&await Io(e.rootProgram,e.pmRoot,e.invocationArgv,Ho(),e.settings)}function Uc(e,t,n,o){if(t?.flags&&t.flags.length>0){Fn(e,t.flags);let i=Ln(e,t.flags);i&&e.addHelpText("after",i)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function ka(e,t,n){let o={core:0,standard:1,full:2,internal:3},i=(r,a)=>{let s=a.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");bt(r,c);for(let d of r.commands)i(d,[...a,d.name()])};for(let r of e.commands)t.has(r.name())||i(r,[r.name()])}async function Ea(e,t){let n=G(t),o=$(process.cwd(),n.path);if(n.noExtensions){await Ut({rootProgram:e,pmRoot:o,invocationArgv:t});return}let i=await Gt(o),r=Ae(t);if(!i){await Ut();return}if(!Ye(i.discovery,r)){await Ut({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings}),zt(Po(t),i,r);return}let a=await Re(o,r);if(!a){await Ut({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings});return}ee(a.services),P=new Map(a.commandDescriptors),await Io(e,o,t,a.registrations,a.settings);let s=Pr(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,d=>$r(a.activationWarnings,w,d)),l=new Set(e.commands.map(d=>d.name())),c=d=>{let m=d.split(" ").filter(S=>S.length>0),p=a.commandDescriptors.get(d),u=Z(e,m),g=a.commandFlagHelp.get(d),h=p?Rr(p):null;if(u){Uc(u,p,g,h);return}let y=Ir(e,m);p?.description&&y.description(p.description);let x=g;p&&(kr(y,p),p.flags.length>0&&(Fn(y,p.flags),x=Ln(y,p.flags)??void 0)),x&&y.addHelpText("after",x),h&&y.addHelpText("after",h),y.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...S)=>{let z=S[S.length-1],L=z instanceof Oo?z:y,he=Ue(L),Wt=Date.now(),it=Qe(a.registrations,d,L.args.map(String)),Ie=Te(L,L.args.map(String),it),ye=await Ca(L,Ie,he,it);await ji(he,ye),Zt(ye,{...he,command:d,commandArgs:L.args.map(String),commandOptions:Ie,pmRoot:o}),he.profile&&w(`profile:command=${d} took_ms=${Date.now()-Wt}`)})};for(let d of s)c(d);ka(e,l,a.commandDescriptors)}var nt=Lo(import.meta.url,["../.."])??"0.0.0",v=en(nt);function Sa(e,t){t&&Ze(t)||(e.hook("preAction",async(n,o)=>{Oe=null,H=null,lt(),mn(o);let i=o.optsWithGlobals(),r=Ue(o),a=O(T(o)),s=o.args.map(String),l=Te(o,s),c={...r};li(a,{...l,outputInclude:i.outputInclude,outputLimit:i.outputLimit,outputBudget:i.outputBudget,outputFormat:i.outputFormat,outputSession:i.outputSession,outputCursor:i.outputCursor}),ro(o,a,c,l),await Oi(a,c);let d=$(process.cwd(),r.path),m=await wa(o);if(!m){Oe=Ko({commandName:a,commandArgs:s,commandOptions:l,globalOptions:c,pmRoot:d}),H=await dn({command:a,pm_version:nt,args:s,options:l,global:c,pm_root:d}),sn(a,s,l,{source_context:H?.source_context,source_context_source:H?.source_context_source}),ln(a),await Bn(a,l,d,Ao()),await Vn(a,s,l,c,d);return}Jo(m.hooks),Yo(m.commands),Xo(m.parsers),Qo(m.preflight),ee(m.services),Zo(m.renderers),ei(m.registrations);let p=Qe(m.registrations,a,s);l=Te(o,s,p),ro(o,a,c,l);let u=await ct({command:a,args:s,options:l,global:c,pm_root:m.pmRoot});c.profile&&u.warnings.length>0&&w(`profile:extensions parser_warnings=${j(u.warnings)}`),s=u.context.args,l=u.context.options,c=u.context.global,wt(o,l);let g=await oi({command:a,args:s,options:l,global:c,pm_root:m.pmRoot,decision:Ao()});c.profile&&g.warnings.length>0&&w(`profile:extensions preflight_warnings=${j(g.warnings)}`),s=g.context.args,l=g.context.options,c=g.context.global,wt(o,l);let h=g.decision;await Bn(a,l,m.pmRoot,h),await Vn(a,s,l,c,m.pmRoot);let y=h.run_extension_migrations?await _a(m.registrations.migrations,m.pmRoot):[];c.profile&&y.length>0&&w(`profile:extensions migration_warnings=${j(y)}`);let x=Jr(m.registrations.migrations);Oe={hooks:m.hooks,commandName:a,commandArgs:s,commandOptions:{...l},globalOptions:{...c},pmRoot:m.pmRoot,profileEnabled:!!c.profile,migrationBlockers:x},we(void 0),st({command:a,args:s,options:{...l},global:{...c},pm_root:m.pmRoot}),H=await dn({command:a,pm_version:nt,args:s,options:l,global:c,pm_root:m.pmRoot}),sn(a,s,l,{source_context:H?.source_context,source_context_source:H?.source_context_source}),ln(a);let S=await Wo(m.hooks,{command:a,args:s,options:{...l},global:{...c},pm_root:m.pmRoot});c.profile&&S.length>0&&w(`profile:extensions hook_warnings=${j(S)}`),h.enforce_mandatory_migration_gate&&Yr(a,l,x)}),e.hook("postAction",async()=>{let n=Co();Me(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 ot(n)}))}Sa(v);var ia=Symbol("pmCliIdempotentTopLevelRegistration");function Aa(e){let t=e;if(t[ia])return;t[ia]=!0;let n=e.command.bind(e);e.command=((o,...i)=>{let r=o.split(/\s+/u)[0];return e.commands.some(a=>a.name()===r||a.aliases().includes(r))?new Oo(r):n(o,...i)})}async function qc(e,t){if(Aa(e),t.setup){let{registerSetupCommands:n}=await Tc();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await Oc(),o=typeof t.targetCommandName=="string"&&co.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await Rc();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await Ic();n(e)}}function Hc(e){return async t=>{let n=rt(t.errorCode),o=ut({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Ii({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:nt,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 Ta(e){if(e.bootstrapGlobal.noExtensions||Ze(e.invocationArgv))return;let t=Ae(e.invocationArgv),n=await Gt(e.bootstrapPmRoot);if(n&&Ye(n.discovery,t)){let o=await Re(e.bootstrapPmRoot,t);Oa(o);return}n&&zt(Po(e.invocationArgv),n,t),ee({overrides:[]})}function Oa(e){if(!e){ee({overrides:[]});return}ee(e.services)}async function Do(e){Me(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await ot({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 Ra(){Me(!0,void 0,{exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await ot({ok:!0,exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=f.SUCCESS}async function Ia(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof C)&&(on(e.error)||!n))return!1;let o=se(e.error),i=e.error instanceof C?e.error.exitCode:nn(t),r=e.error instanceof C?e.error.context:void 0,a=sa(r,e.invocationArgv,o),s=lr(o,a),l=e.bootstrapGlobal.lean?kt(Tn(o,i,a)):Tn(o,i,a),c=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?ae(l,u=>`${JSON.stringify(u,null,2)}
|
|
34
|
-
`):l,null,2):
|
|
35
|
-
`):
|
|
36
|
-
`):
|
|
37
|
-
`):
|
|
27
|
+
`)}`}function qn(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 Be(e,t){let n=t.trim().toLowerCase();return e.commands.find(o=>o.name().trim().toLowerCase()===n?!0:qn(o).includes(n))??null}function te(e,t){let n=e;for(let o of t){let i=Be(n,o);if(!i)return null;n=i}return n}var Hn=new WeakSet;function $r(e,t){if(t.length===0)return null;let n=e;for(let o=0;o<t.length;o+=1){let i=t[o];o>0&&M.some(s=>s.canonical===t.join(" "))&&n.enablePositionalOptions();let r=Be(n,i);if(r){n=r;continue}let a=n.command(i);Hn.add(a),o<t.length-1?(a.description("Extension-provided command group."),a.action(()=>{a.help()})):a.description("Extension-provided command path."),n=a}return n}function kl(e,t){let n=t.join(" "),o=M.find(a=>n===a.canonical||n.startsWith(`${a.canonical} `));if(o)return{core_path:o.canonical,extension_path:n};let i=e,r=[];for(let a of t){let s=Be(i,a);if(!s)return null;r.push(a);let l=s.commands.length>0||M.some(d=>d.canonical.startsWith(`${r.join(" ")} `));if(!Hn.has(s)&&(r.length===t.length||!l))return{core_path:r.join(" "),extension_path:t.join(" ")};i=s}return null}function El(e,t,n,o,i=!1){let r=t.split(" ").filter(c=>c.length>0),a=kl(e,r),s=te(e,r),l=M.some(c=>c.canonical===t&&c.alias===o?.action&&!e.commands.some(m=>m.name()===c.alias)&&(s===null||Hn.has(s)));if(!a||a.core_path===t&&s!==null&&!n.has(t)&&!i||l&&!n.has(t))return null;let d=o?.source?.package??o?.source?.name??"unknown-extension";return`extension_command_collision:${a.extension_path}:core_owner=pm-cli:${a.core_path}:extension_owner=${d}`}function Dr(e,t,n,o,i){return[...new Set([...t,...n.keys()])].filter(r=>r.trim().length>0).sort((r,a)=>r.localeCompare(a)).filter(r=>{let a=El(e,r,o,n.get(r),t.includes(r));return a?(i(a),!o.has(r)&&te(e,r.split(" "))!==null):!0})}function Nr(e,t,n){e.push(n),t(`[pm] warning: ${n}; core command preserved. Rename or namespace the extension command alias.`)}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="93ca07c1-857b-57ae-8530-a315a24d0fe5")}catch{}})();var Sl=new Set(["__proto__","prototype","constructor"]),Mr=Symbol("looseOptionOccurrences");function Ke(e){return e.trim().toLowerCase().replaceAll(/-([a-z0-9])/g,(n,o)=>o.toUpperCase())}function Al(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 zn(e,t){let n=e[t];if(!n.startsWith("-")||n==="-"||n==="--")return null;if(!n.startsWith("--")){let a=n.indexOf("=");if(a>=0)return{consumed:1,key:n.slice(1,a).trim(),value:n.slice(a+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 i=n.slice(2).trim(),r=e[t+1];return typeof r=="string"&&!r.startsWith("-")?{consumed:2,key:i,value:r}:{consumed:1,key:i,value:!0}}function Rt(e){return Sl.has(e)}function Fr(e){let t=(typeof e.value_type=="string"?e.value_type:void 0)??(typeof e.type=="string"?e.type:void 0);return Go(t)}function Je(e){let t=[],n=typeof e.long=="string"?e.long.trim():"",o=typeof e.short=="string"?e.short.trim():"";if(n.startsWith("--")){let i=Ke(n.slice(2));i.length>0&&!Rt(i)&&t.push(i)}if(o.startsWith("-")&&!o.startsWith("--")){let i=Ke(o.slice(1));i.length>0&&!Rt(i)&&t.push(i)}return[...new Set(t)]}function Lr(e){let t=new Set;for(let n of e)for(let o of Je(n))t.add(o);return t}function Tl(e){let t=typeof e.long=="string"?e.long.trim():"";if(t.startsWith("--")){let n=Ke(t.slice(2));if(n.length>0&&!Rt(n))return n}return Je(e)[0]??null}function Ol(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 Gn(e,t,n){if(t.length===0)return;let o=new Set,i=new Map,r=[],a=[];for(let s of t){let l=Je(s),d=Ol(s);d!==null&&a.push(d);for(let c of l)o.add(c),s.enabled===!1&&i.set(c,d);s.required===!0&&s.enabled!==!1&&l.length>0&&r.push({keys:l,label:d})}for(let s of Object.keys(e)){if(!o.has(s)){let d=a.length>0?` Expected one of: ${[...new Set(a)].join(", ")}.`:"";throw new C(`Unknown option '--${s}' for extension command '${n}'.${d}`,f.USAGE)}let l=i.get(s);if(l)throw new C(`Option '${l}' is disabled for extension command '${n}'.`,f.USAGE)}for(let s of r)if(!s.keys.some(l=>Object.hasOwn(e,l)))throw new C(`Missing required option '${s.label}' for extension command '${n}'.`,f.USAGE)}function Rl(e){return typeof e=="string"||e==null?e:String(e)}function Il(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 Pl(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 $l={string:Rl,number:Il,boolean:Pl};function It(e,t){return Array.isArray(e)?e.map(n=>It(n,t)):$l[t](e)}function jr(e,t,n){let o=n?(Array.isArray(e)?e.flat(1/0):[e]).filter(i=>i!=null&&i!==""):Wo(e);return t?o.map(i=>It(i,t)):o}function Dl(e,t,n,o){return n?jr(e,t,o):t?It(e,t):e}function Nl(e,t,n){let o=e[Mr];if(!o||o.length===0)return n;let i=new Set(t);return o.filter(r=>i.has(r.key)).map(r=>r.value)}function Ur(e,t,n=e){if(t.length===0)return e;let o=Object.create(null);for(let[i,r]of Object.entries(e))o[i]=r;for(let i of t){let r=Tl(i);if(!r)continue;let a=i.list===!0,s=Je(i);for(let c of s)if(!(c===r||!Object.hasOwn(o,c))){if(Object.hasOwn(o,r)){if(!a){delete o[c];continue}let m=o[r],p=o[c];o[r]=[...Array.isArray(m)?m:[m],...Array.isArray(p)?p:[p]].filter(u=>u!=null),delete o[c];continue}o[r]=o[c],delete o[c]}let l=Fr(i),d=i.repeatable===!0;if(!Object.hasOwn(o,r)){i.default!==void 0&&(o[r]=Dl(i.default,l,a,d));continue}if(a){o[r]=jr(Nl(n,s,o[r]),l,d);continue}l&&(o[r]=It(o[r],l))}return o}function qr(e){let t=Object.create(null),n=[];Object.defineProperty(t,Mr,{value:n});let o=0;for(;o<e.length;){let i=zn(e,o);if(!i){o+=1;continue}let r=Ke(i.key);if(r.length===0||Rt(r)){o+=i.consumed;continue}Al(t,r,i.value),n.push({...i,key:r}),o+=i.consumed}return t}function Hr(e){let t=[],n=0;for(;n<e.length;){if(e[n]==="--"){t.push(...e.slice(n+1));break}let o=zn(e,n);if(o){n+=Math.max(1,o.consumed);continue}t.push(e[n]),n+=1}return t}function Wn(e,t){if(t.length===0)return[...e];let n=new Set,o=new Set;for(let a of t){let s=Fr(a);for(let l of Je(a))n.add(l),s==="boolean"&&o.add(l)}if(n.size===0)return[...e];let i=[],r=0;for(;r<e.length;){if(e[r]==="--"){i.push(...e.slice(r+1));break}let a=zn(e,r);if(a){let s=Ke(a.key);if(n.has(s)){let l=e[r],d=o.has(s)&&!l.includes("=")?1:a.consumed;r+=d;continue}}i.push(e[r]),r+=1}return i}import Se 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]="989fc265-7deb-5456-8a83-0f1fa8d2d9b2")}catch{}})();async function Vn(e,t={},n=[]){let o={readSettings:D,loadExtensions:Ne,activateExtensions:Me,resolveImplicitPmRoot:Xt,...t};try{let i=await o.readSettings(e),r=await o.loadExtensions({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),a=await o.activateExtensions(r);return[...r.failed,...a.failed].map(s=>{let l=(r.effective??[]).find(p=>p.layer===s.layer&&p.name===s.name),d=[...l?.contributions?.commands??[],...l?.contributions?.command_handlers??[],...l?.activation?.commands??[]].map(N).filter((p,u,g)=>p.length>0&&g.indexOf(p)===u).sort((p,u)=>p.localeCompare(u)),c=n.map(N),m=d.some(p=>c.some(u=>u===p||u.startsWith(`${p} `)));return{layer:s.layer,name:s.name,error:s.error,...d.length>0?{declared_commands:d}:{},...m?{declared_command_match:!0,recovery_commands:["pm package doctor --project --detail deep","pm package install <package-or-path> --project"]}:{}}})}catch(i){return[{layer:"runtime",name:"extension-loader",error:i instanceof Error?i.message:String(i)}]}}async function zr(e,t,n={},o=[]){if(e!=="unknown_command")return[];let i=await Vn(t,n,o),r={readSettings:D,loadExtensions:Ne,activateExtensions:Me,resolveImplicitPmRoot:Xt,...n};try{let a=r.resolveImplicitPmRoot(process.cwd());if(Se.resolve(a)===Se.resolve(t))return i;let[s,l]=await Promise.all([r.readSettings(t),r.readSettings(a)]),[d,c]=await Promise.all([r.loadExtensions({pmRoot:t,settings:s,cwd:process.cwd(),noExtensions:!1}),r.loadExtensions({pmRoot:a,settings:l,cwd:process.cwd(),noExtensions:!1})]),m=new Set(d.loaded.flatMap(u=>u.activation?.commands??[])),p=[...new Set(c.loaded.flatMap(u=>u.activation?.commands??[]))].filter(u=>!m.has(u)).sort((u,g)=>u.localeCompare(g));if(p.length===0)return i;i.push({layer:"runtime",name:"extension-root-relocation",error:`storage_root=${Se.resolve(t)} extension_discovery_root=${d.roots.project}; cwd_storage_root=${Se.resolve(a)} cwd_extension_discovery_root=${c.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 ${Se.resolve(a)}, or install the extension into the selected tracker with "pm --pm-path ${Se.resolve(t)} install <package> --project".`})}catch{}return 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]="6fa59b21-fcd4-5056-ae4c-379d57bb7757")}catch{}})();var Gr={core:0,standard:1,full:2,internal:3};function Wr(e,t,n=!0){let o=t.get(O(e));if(o)return o;if(!n)return;let i=[...t.entries()].filter(([s])=>s.startsWith(`${e} `)).map(([,s])=>s);if(i.length===0)return;let r=i.reduce((s,l)=>Gr[l.tier]<Gr[s]?l.tier:s,"internal"),a=new Set(i.map(({family:s})=>s));return{tier:r,family:a.size===1?i[0].family:"extensions"}}function Vr(e,t){if(t.length===0)return e;let n=te(e,t);if(n)return n;let o=t.join(" ");if(O(o)!==o||!mt.some(i=>i===o)&&!$i(o)&&!qe(o)&&!We(e,t))return null;for(let i=t.length-1;i>0;i-=1){let r=te(e,t.slice(0,i));if(r)return r}return t.length===1?e:null}function Ml(e){let t=e.match(/[<[]([^>\]]+)[>\]]/);if(!t)return null;let n=t[1]?.trim();return n&&n.length>0?n:null}function Br(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 Fl(e){let t=new Map;for(let n of e){let o=n,i=Br(n);if(!i||typeof o.long!="string"||o.long.trim().length===0)continue;let r=t.get(i)??[];r.push(o.long.trim()),t.set(i,r)}for(let[n,o]of t.entries())t.set(n,[...new Set(o.map(i=>i.trim()).filter(i=>i.length>0))].sort((i,r)=>i.localeCompare(r)));return t}function Ll(e){return A(e)}function jl(e){let t=e.options??[],n=Fl(t);return t.map(o=>{let i=o,r=typeof i.flags=="string"?i.flags.trim():"",a=typeof i.description=="string"?i.description.trim():"",s=Br(o),d=(s?n.get(s)??[]:[]).filter(y=>y!==i.long).map(y=>y.trim()).filter(y=>y.length>0),c=a.match(/^Alias for ([^ ]+)/i),m=c&&c[1]?c[1].trim():null,p=i.mandatory===!0||a.includes("[required]")||a.toLowerCase().includes("required;"),u=r.includes("<"),g=u||r.includes("["),h={flags:r,long:typeof i.long=="string"?i.long:null,short:typeof i.short=="string"?i.short:null,description:a,takes_value:g,value_required:u,value_name:Ml(r),variadic:i.variadic===!0,required:p,aliases:d,alias_for:m};return i.defaultValue!==void 0&&(h.default_value=i.defaultValue),h})}function Ul(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 i=o.alias_for,r=t.get(i);if(!r)continue;let a=o.long,s=new Set([...r.aliases??[],a]);r.aliases=[...s].sort((l,d)=>l.localeCompare(d))}return e.filter(o=>!o.alias_for||!o.long?!0:!t.has(o.alias_for))}function ql(e){let t=e;return(Array.isArray(t.registeredArguments)?t.registeredArguments:Array.isArray(t._args)?t._args:[]).map(o=>{let i=typeof o.name=="function"?o.name():typeof o.name=="string"?o.name:"argument",r=typeof o.description=="string"&&o.description.trim().length>0?o.description.trim():null;return{name:i.trim(),required:o.required===!0||r?.toLowerCase().startsWith("required;")===!0,variadic:o.variadic===!0,description:r}})}function Hl(e,t=new Map,n=!1){let o=e.createHelp().visibleCommands(e);return(n?[...new Set([...o,...e.commands])]:o).filter(r=>r.name()!=="help"||e.parent===null).filter(r=>!n||(pe(r)??Y(r.name()))!=="internal").map(r=>{let a=N(T(r)),s=a,l=pe(r),d=Wr(a,t,l!==void 0),c=V.find(({alias:m})=>m===a);return{name:r.name().trim(),aliases:qn(r),description:r.description().trim(),tier:d?.tier??l??Y(s),family:d?.family??wt(s),...c?{alias_for:c.canonical,alias_lifecycle:c.lifecycle,...c.lifecycle==="deprecated"?{deprecated:!0}:{}}:{}}}).sort((r,a)=>r.name.localeCompare(a.name))}function zl(e,t,n){if(!n)return t;let o=n.examples??[],i=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"?i.length>0?[...i]:[...t.tips]:[],detail_mode:e}}function Gl(e,t,n,o,i){let r=e!==void 0&&_n(e)===xe,a=r?{intent:t,examples:[`pm ${e} --help`],tips:[],detail_mode:n}:er(e,n),s=i?"positional_action":o?.intent||o?.description?"extension":r?t?"command_description":"unavailable":e?"help_bundle":"root_help_bundle";return{narrative:zl(n,a,o),intentSource:s}}function Wl(e,t){return e===void 0?null:t?.tier??Y(e)}function Vl(e,t){return e===void 0?null:t?.family??wt(e)}function Bl(e,t,n){if(!(t!==e||!n))return V.map(o=>({alias:o.alias,canonical:o.canonical,canonical_argv:[...o.canonical_argv],available:Vr(e,o.canonical.split(" "))!==null,lifecycle:o.lifecycle,hidden:o.hidden,deprecated:o.lifecycle==="deprecated"}))}function Kl(e,t,n,o,i=new Map,r=!1){if(!e){let s=ql(t),l=Hl(t,i,r),d=new Set(l.map(({name:c})=>c));return{arguments:s,options:o,subcommands:[...l,...gt.filter(({parent:c,action:m})=>c===n&&!d.has(m)).map(({action:c,description:m})=>({name:c,aliases:[],description:m,tier:Y(n.split(" ")[0]),family:wt(n.split(" ")[0])}))].sort((c,m)=>c.name.localeCompare(m.name)),usage:[n,s.reduce((c,m)=>m.required?c.replace(`[${m.name}${m.variadic?"...":""}]`,`<${m.name}${m.variadic?"...":""}>`):c,t.usage())].filter(c=>c.length>0).join(" ")}}let a=new Set(e.accepted_flags);return{arguments:e.slots.map(({name:s,required:l,variadic:d,value_kind:c,polymorphic:m})=>({name:s,required:l,variadic:d,description:m?`Polymorphic ${c} value; inspect the action contract before mutation.`:`${c.replaceAll("_"," ")} value.`})),options:o.filter(({long:s,aliases:l})=>s!==null&&a.has(s)||l.some(d=>a.has(d))),subcommands:[],usage:[e.command,...e.slots.map(({name:s,required:l,variadic:d})=>{let c=d?`${s}...`:s;return l?`<${c}>`:`[${c}]`})].join(" ")}}function Jl(e,t,n,o,i){let r=wn(n),a=oe(n),s=N(T(t)),l=N(o.join(" ")),d=l.length>s.length?l:s,c=qe(d),m=c?.command??s,p=m.length>0?m:void 0,u=p,g=p?i.get(O(p)):void 0,h=p?Wr(p,i,pe(t)!==void 0):void 0,{narrative:y,intentSource:x}=Gl(p,t.description().trim(),r,g,c!==void 0),S=Ul(Ir(jl(t),Rr(g))),z=Kl(c,t,m,S,i,a),j=Bl(e,t,a);return{format:"pm_help_v1",detail_mode:r,root_command:e.name(),requested_path:o,resolved_path:m.length>0?m:e.name(),visibility_tier:Wl(u,h),capability_family:Vl(u,h),description:c?.description??t.description(),usage:z.usage,intent:c?.description??y.intent,intent_source:x,examples:c?[c.example]:y.examples,tips:c?[ht(c.accepted_flags)]:y.tips,arguments:z.arguments,options:z.options,subcommands:z.subcommands,has_subcommands:z.subcommands.length>0,...j===void 0?{}:{command_aliases:j}}}async function Kr(e,t,n,o=t){let i=G(t);if(!i.json)return!1;let r=k(t);if(!r.requested)return!1;let a=Vr(e,r.commandPathTokens);if(!a){if(!i.quiet){let s=`unknown command '${O(r.commandPathTokens.join(" "))}'`,l=Nn(s,e,n),d=At(s,"help",ze,f.USAGE,{...l,attemptedCommand:Ll(t),normalizedInvocationArgs:[...t],providedOptionFlags:X(t)}),c=i.tokenAccounting?le(d,m=>`${JSON.stringify(m,null,2)}
|
|
28
|
+
`):d;be(`${JSON.stringify(c,null,2)}
|
|
29
|
+
`)}return process.exitCode=f.USAGE,!0}if(!i.quiet){let s=Jl(e,a,t,r.commandPathTokens,n),l=k(o).commandPathTokens;s.requested_path=l;let d=B(l.join(" "));d&&(s.resolved_path=d.canonical),a===e&&!oe(t)&&(s.omission_receipt={has_omissions:!0,omitted_field_group_count:1,omitted_field_groups:[{name:"command_aliases",restore_with:"--all"}]}),fi(`${JSON.stringify(s,null,2)}
|
|
30
|
+
`)}return process.exitCode=f.SUCCESS,!0}function Yl(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 Xl(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)":"",i=n.aliases??[];e.push(` - ${n.key}${o}`),e.push(` values: ${n.values.length>0?n.values.join("|"):"any non-empty string"}`),e.push(` aliases: ${i.length>0?i.join("|"):"none"}`),n.description&&n.description.trim().length>0&&e.push(` description: ${n.description.trim()}`)}}function Ql(e,t){let n=e==="create"?new Set(["title","type"]):new Set,o=new Set(n);if(e==="create")for(let i of[...t.required_create_fields,...t.required_create_repeatables])o.add(i);return{progressive:n,strict:o}}function Zl(e,t,n,o){let i=new Set(n),r=o.filter(l=>!i.has(l)),a=l=>l.length>0?l.map(d=>Yt("create",d)).join(", "):"none";e.push(` required in strict mode: ${a(r)}`);let s=r.map(qi).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 ec(e,t,n){let o=Wi(n);if(!o)return Yl(e,t);let i=qo(o,t);if(!i){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 r=n.indexOf("--"),a=r<0?n:n.slice(0,r),s=a.findIndex(h=>h==="--create-mode"||h.startsWith("--create-mode=")),l=s<0?void 0:a[s]?.startsWith("--create-mode=")?a[s]?.slice(14):a[s+1],d=e==="create"&&l?.toLowerCase()==="strict",c=Ql(e,i),m=st(i,e,c.progressive),p=st(i,e,d?c.strict:c.progressive),u=h=>h.length>0?h.map(y=>Yt(e,y)).join(", "):"none",g=["",`Type-aware option policies for ${i.name}:`,` required: ${u(p.required)}`,` disabled: ${u(p.disabled)}`,` hidden: ${u(p.hidden)}`];if(e==="create"){let h=st(i,e,c.strict);Zl(g,i,m.required,h.required)}return Xl(g,i),p.errors.length>0&&g.push(` config errors: ${p.errors.join("; ")}`),g.join(`
|
|
33
|
+
`)}function Jr(e,t,n){let o=E(n);if(o!=="create"&&o!=="update")return;let i=Be(e,o);i&&i.addHelpText("after",ec(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]="840b471e-c996-57e2-b97c-3a84bd68f050")}catch{}})();function tc(e,t){let n=De(e.id);return n||`migration-${String(t+1).padStart(3,"0")}`}function nc(e){return De(e.status)?.toLowerCase()??"pending"}function oc(e){return e.mandatory===!0}function ic(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 Qr(e){let t=[];return e.forEach((n,o)=>{if(!oc(n.definition))return;let i=nc(n.definition);i!=="applied"&&t.push({layer:n.layer,name:n.name,id:tc(n.definition,o),status:i})}),t.sort(ic),t}function Yr(e){return Array.isArray(e)&&e.length>0}var rc=new Set(["create","beads import","todos import"]),ac=new Set(["restore","update","close","delete","append","claim","release"]),sc=new Set(["comments","notes","learnings"]),lc=new Set(["files","docs","test"]),cc=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 Bn(e,t){let n=t.force===!0;return rc.has(e)?{isMutation:!0,forceCapable:!1,forceRequested:!1}:ac.has(e)?{isMutation:!0,forceCapable:!0,forceRequested:n}:sc.has(e)?{isMutation:typeof t.add=="string",forceCapable:!0,forceRequested:n}:lc.has(e)?{isMutation:Yr(t.add)||Yr(t.remove),forceCapable:!0,forceRequested:n}:{isMutation:!1,forceCapable:!1,forceRequested:!1}}function dc(e,t,n){if(Bn(e,n).isMutation)return!0;let o=e.trim().toLowerCase();return Ti(o)?["close-many","close-task","copy","delete","discover","focus","pause-task","start-task","update-many"].includes(o)?!0:t.some(i=>cc.has(i.trim().toLowerCase())):!1}function Xr(e){return(e??"in_progress").trim().toLowerCase().replaceAll("-","_")}function mc(e,t,n){let o=t[0]?.trim().toLowerCase()??"";if(e.trim().toLowerCase()!=="schema"||!["rename-type","rename-field","remap-status"].includes(o))return;let i=[];if(De(t[1])||i.push("source"),De(n.to)||i.push("--to"),i.length!==0)throw new C(`Schema migration requires ${i.join(", ")}.`,f.USAGE,{code:"schema_migration_input_required",required:i.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:i,suggested_flags:i.filter(r=>r.startsWith("--")),suggested_retry:`pm schema ${o} <source> --to <target>`}})}async function pc(e,t,n,o,i){if(e.trim().toLowerCase()!=="update"||typeof n.status!="string"||Xr(n.status)!==Xr(i.schema.workflow.in_progress_status))return;let r=t[0];if(!r)return;let a=re(i,ae()),s=await ut(o,r,i.id_prefix,i.item_format,a.type_to_folder);if(!s)return;let l=await vi(s,{schema:i.schema}),d=typeof n.assignee=="string"?n.assignee.trim():void 0;(d===void 0?l.document.metadata.assignee?.trim():!["","none","null","undefined"].includes(d.toLowerCase())&&d)||_(`warning:in_progress_item_unclaimed:${s.id}:claim_with=pm claim ${s.id}`)}async function Kn(e,t,n,o,i){if(!dc(e,t,n)||(mc(e,t,n),!await K(J(i))))return;let r=await Ce(i);o.json!==!0&&await pc(e,t,n,i,r.settings);let a=Ai({author:pt(o.author,r.settings.author_default),payload:{command:e,args:t,options:n},settings:r.settings.mutation_guard,force:o.force===!0||n.force===!0});for(let s of a.warnings)_(`warning:${s}`)}function Zr(e,t,n){if(n.length===0)return;let o=Bn(e,t);if(!o.isMutation||o.forceCapable&&o.forceRequested)return;let i=n.map(a=>`extension_migration_blocking:${a.layer}:${a.name}:${a.id}:${a.status}`),r=o.forceCapable?"Re-run this command with --force to bypass.":"This command path does not support --force bypass.";throw new C(`Write command "${e}" blocked by unresolved mandatory extension migrations (${i.join(",")}). ${r}`,f.CONFLICT)}async function Jn(e,t,n,o){if(!Bn(e,t).isMutation||!o.enforce_item_format_gate&&!o.run_preflight_item_format_sync||!await K(J(n)))return;let{settings:r,metadata:a,warnings:s}=await Ce(n);for(let l of s)_(`warning:${l}`);if(o.enforce_item_format_gate&&!a.has_explicit_item_format&&(wi(r),await _i(n,r,"item_format:auto_select_default")),o.run_preflight_item_format_sync){let l=re(r,ae());await Oi(n,r.item_format,"item_format:pre_mutation_sync",l.type_to_folder,r.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]="697f96fe-38a0-5530-b54b-22cb442c130f")}catch{}})();function Yn(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 Te(e){let t=v(e.commandPath??"");if(t.length===0)return[];let n=[t],o=t.split(" ").filter(i=>i.length>0);for(let i of Yn(e.commandArgs))o.push(...i.split(" ").filter(r=>r.length>0)),n.push(o.join(" "));return[...new Set(n.flatMap(i=>[i,O(i)]))]}function Xn(e,t){let n=v(e);if(n.length===0)return!1;let o=Te(t);for(let i of o)if(i===n||i.startsWith(`${n} `))return!0;return t.allowCommandPrefixMatch===!0?o.some(i=>n.startsWith(`${i} `)):!1}function $t(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),...ea(n.preflight_ownership),...ea(n.renderer_ownership)]:[]}function R(e){return e??[]}function ea(e){return R(e).flatMap(t=>t.commands)}function Ye(e){return new Set((e.capabilities??[]).map(t=>t.trim().toLowerCase()))}var ta=new Set(["hooks","parser","preflight","renderers"]),na=new Set(["commands","schema","services","importers"]),uc=new Set(["reindex","search","search-advanced"]),fc=new Set(["--template"]);function Ae(e,t){for(let n of t)if(e.has(n))return!0;return!1}function Qn(e){let t=v(e??"");if(t.length===0)return!1;let[n]=t.split(" ");return uc.has(n??t)}function Zn(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 Dt(e){return v(e.commandPath??"")==="create"&&Zn(e,fc)}function eo(e){return e.some(t=>{let n=v(t);return n==="templates"||n.startsWith("templates ")})}function Pt(e,t){return e.some(n=>Xn(n,t))||Dt(t)&&eo(e)}function to(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(n=>n>0)}function no(e,t){let n=e.activation?.commands??[];if(n.length>0)return Pt(n,t);let o=$t(e);if(Pt(o,t)||Ye(e).has("search")&&Qn(t.commandPath))return!0;if(e.contributions)return to(e.contributions)}function Nt(e,t){let n=no(e,t);if(n!==void 0)return n;let o=Ye(e);return!!(Ae(o,ta)||Ae(o,na))}function Xe(e,t){return e.effective.length===0?!1:Qe(t)!=="all"?e.effective.some(o=>Nt(o,t)):e.effective.some(o=>{let i=Ye(o);return $t(o).length>0||Ae(i,ta)||Ae(i,na)||i.has("search")})}function Qe(e){if(v(e.commandPath??"").split(" ")[0]==="completion")return"all";let t=Te(e).filter(i=>i.split(" ").every(r=>!r.startsWith("-"))).sort((i,r)=>r.length-i.length)[0]??v(e.commandPath??"");if(t.length===0)return"all";let n=Dt(e)?"--template":"";return`${e.allowCommandPrefixMatch===!0?"prefix":"exact"}:${t}:${n}`}function oo(e){return Qe(e)==="all"?void 0:t=>Nt(t,e)}function Oe(e){let t=k(e);if(t.requested&&t.commandPathTokens.length>0){let[i,...r]=t.commandPathTokens;return{commandPath:i,commandArgs:r,allowCommandPrefixMatch:!0}}let n=F(e),o=n.findIndex(i=>i.trim().length>0&&!i.startsWith("-"));return o<0?{}:{commandPath:n[o],commandArgs:n.slice(o+1),allowCommandPrefixMatch:t.requested}}function io(e){let t=e.args.map(String);if(v(T(e))==="create"){let o=e.optsWithGlobals();typeof o.template=="string"&&o.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]="2b424635-df90-55ee-beb0-d39a79d242f3")}catch{}})();var Mt=Symbol.for("pm.readOutputInvocationProvenance");function ie(e,t){let n=Reflect.get(e,Mt);n!==void 0&&Reflect.set(t,Mt,n)}function ro(e,t,n){let o=li(t,n);if(!o)return;let i=e;for(;i.parent;)i=i.parent;let r=i.rawArgs,a=new Set(X(r.slice(2))),s=si.find(c=>c.command===o),l=Object.values(s.dimensions).flatMap(c=>c.legacy_aliases.flatMap(m=>a.has(m.flag)?[m.flag]:[])),d=Reflect.get(n,Mt);Reflect.set(n,Mt,{canonical_include_modes:d?.canonical_include_modes??[],explicit_legacy_aliases:l,cli_invocation_observed:!0}),ie(n,e)}function ao(e,t,n,o){ro(e,t,o);let i=n.outputInclude;if(i===void 0)return;let{selectors:r,modes:a}=mi(t,i,o);if(t==="get"&&typeof o.fields=="string"&&e.setOptionValueWithSource("fields",o.fields,"cli"),a.length===0)return;ie(o,e);let s=di(t);for(let d of a){let c=s.get(d),m=o[c];e.setOptionValueWithSource(c,m,"cli")}let l=r.length>0?r.join(","):void 0;l===void 0?delete n.outputInclude:n.outputInclude=l;for(let d=e;d;d=d.parent)d.setOptionValueWithSource("outputInclude",l,"cli");vt(e,n)}function gc(e){let t=e.optsWithGlobals(),n=T(e);if(O(n)===n)return t;let o=e.opts();for(let i=e.parent;i?.parent;i=i.parent)for(let r of Object.keys(i.opts()))!(r in o)&&i.getOptionValueSource(r)==="default"&&delete t[r];return t}function Re(e,t,n=[]){let i={...gc(e)};ie(e,i),delete i.json,delete i.quiet,delete i.path,delete i.pmPath,delete i.noExtensions,delete i.extensions,delete i.profile,delete i.pager,delete i.changedFields,delete i.fullChangedFields,delete i.idOnly,delete i.lean,delete i.tokenAccounting,delete i.outputInclude,delete i.outputLimit,delete i.outputBudget,delete i.outputFormat,delete i.outputSession;let r=qr(t);for(let[a,s]of Object.entries(r))i[a]===void 0&&(i[a]=s);if(n.length>0){let a=Lr(n),s=yt(T(e)).map(c=>({long:c.flag,short:c.short,aliases:c.aliases})),l={...r};for(let c of a)i[c]!==void 0&&(l[c]=i[c]);Gn(l,[...s,...n],T(e));let d=Ur(i,n,r);return ie(i,d),d}return i}function Ft(e,t){let n=v(t);return n.length===0?[]:e.flags.filter(o=>O(v(o.target_command))===O(n)).flatMap(o=>o.flags)}function Ze(e,t,n){let o=Ft(e,t),i=[t],r=[];for(let a of n){if(a.startsWith("-"))break;i.push(a);let s=Ft(e,i.join(" "));s.length>0&&(r=s)}return r.length>0?r:o}function Lt(e){return e.arguments??[]}function oa(e){let t=Lt(e).map(n=>{let o=n.variadic?`${n.name}...`:n.name;return n.required?`<${o}>`:`[${o}]`}).join(" ");return`pm ${e.command}${t?` ${t}`:""}`}function so(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 lo(e,t){let n=Lt(e),o=n.filter(l=>l.required).length,r=n.some(l=>l.variadic)?Number.POSITIVE_INFINITY:n.length,a=e.failure_hints??[],s=a.length>0?` ${a.join(" ")}`:"";if(t.length<o)throw new C(`Missing required argument for extension command '${e.command}'. Usage: ${oa(e)}${s}`,f.USAGE);if(t.length>r){let l=t.slice(r).join(" ");throw new C(`Too many arguments for extension command '${e.command}': ${l}. Usage: ${oa(e)}${s}`,f.USAGE)}}function hc(e){return`--${e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").replace(/_/g,"-").toLowerCase()}`}function yc(e,t,n){if(n.length>0){Gn(t,n,e.command);return}let o=Object.keys(t).filter(i=>t[i]!==void 0).sort();if(o.length!==0)throw new C(`Unknown option '${o.map(hc).join(", ")}' for extension command '${e.command}'. This command does not define extension flags.`,f.USAGE)}function co(e,t,n,o){e&&(lo(e,t),yc(e,n,o))}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="48c16121-f941-50e9-9945-3a14ceddb08f")}catch{}})();var wc=new Set(["--version","-V"]);function et(e){let t=F(e);return["package","packages","extension"].includes(t[0]??"")&&t[1]==="inventory"}var _c=new Set(["config","extension","init","install","package","packages","templates","upgrade"]),mo=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"]),ia=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"]),vc=new Set(["claim","close-task","contracts","duplicates","gc","health","pause-task","release","start-task","stats","test","test-all","test-runs","test-runs-worker","validate"]),bc=new Set(["claim","close-task","pause-task","release","start-task","test"]),jt={setup:!0,listQuery:!0,mutation:!0,operation:!0},Cc=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 tt(e){return e.some(t=>wc.has(t))}function po(e){if(tt(e))return{setup:!1,listQuery:!1,mutation:!1,operation:!1};if(e.length===0||k(e).requested)return jt;let t=E(e);if(!t)return jt;let n=t.trim().toLowerCase(),o=F(e),i=W(o)?.alias;return M.some(r=>r.alias===i)?{...jt,targetCommandName:i}:_c.has(n)?{setup:!0,listQuery:!1,mutation:!1,operation:!1,targetCommandName:n}:mo.has(n)?{setup:!1,listQuery:!0,mutation:!1,operation:!1,targetCommandName:n}:ia.has(n)?{setup:!1,listQuery:!1,mutation:!0,operation:!1,targetCommandName:n}:vc.has(n)?{setup:!1,listQuery:!1,mutation:!1,operation:!0,targetCommandName:n}:jt}function uo(e){return e.length===0||k(e).requested||e.includes("--explain")&&E(e)===void 0}function fo(e,t){return et(t)||tt(t)?!1:oe(t)||k(t).requested?!0:!!E(t)}function go(e){if(tt(e))return!1;let t=E(e);return t?Cc.has(t):!1}function xc(e){let t=String(e.rawFrom??""),n=t.indexOf("="),o=n>=0?t.slice(0,n):t,i=e.normalizedTokens.map(d=>{let c=d.indexOf("=");return c>=0?d.slice(0,c):d}).find(d=>d==="--literal"||d==="--regex"||d==="--replacement"),r=i?e.argv.map(d=>{let c=d.indexOf("=");return(c>=0?d.slice(0,c):d)===o?c>=0?`${i}${d.slice(c)}`:i:d}):e.argv,a=Fe(r),s=i&&n>=0?`${o}=[redacted]`:t,l=i&&e.normalizedDisplay.includes("=")?`${i}=[redacted]`:e.normalizedDisplay;return{argv:a,normalizedDisplay:l,sourceDisplay:s}}function ho(e){let t=e.commandName;if(!t)return;let n=e.trace.find(d=>d.reason==="flag_typo");if(!n)return;let o=Array.isArray(n.to)?n.to:[String(n.to??"")].filter(d=>d.length>0),i=o.length>0?o.join(" "):"the canonical flag",r=ia.has(t)||bc.has(t),a=r?"mutating_flag_typo_requires_retry":"flag_typo_requires_retry",s=r?"mutating option":"option",l=xc({argv:e.argv,normalizedDisplay:i,normalizedTokens:o,rawFrom:n.from});throw new C(`Refusing to auto-correct ${s} ${l.sourceDisplay} to ${l.normalizedDisplay}. Retry with the canonical flag so the command is explicit.`,f.USAGE,{code:a,examples:[A(l.argv)],nextSteps:["Retry the command with the canonical flag shown in examples."],recovery:{normalized_args:l.argv,suggested_retry:A(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]="afcf2608-3360-5030-b5ea-b101df5829e7")}catch{}})();var kc=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"]),Ec=new Set(["parse","preflight","execute","unknown"]),Sc=new Set(["usage","validation","conflict","runtime","unknown"]);function he(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="string"){let i=o.trim();if(i.length>0)return i}}}function yo(e,...t){if(e)for(let n of t){let o=e[n];if(typeof o=="boolean")return o}}function Ut(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 wo(e){if(!e)return;let t=e.trim().toLowerCase();if(kc.has(t))return t}function _o(e){if(!e)return;let t=e.trim().toLowerCase();if(Ec.has(t))return t}function vo(e){if(!e)return;let t=e.trim().toLowerCase();if(Sc.has(t))return t}function bo(e){let t=he(e,"error","message");if(t)return t;let n=e?.warnings;if(Array.isArray(n)){let a=n.find(s=>typeof s=="string"&&s.trim().length>0);if(typeof a=="string")return a.trim()}if(yo(e,"fail_on_skipped_triggered","failOnSkippedTriggered"))return"linked_test_fail_on_skipped_triggered";let i=Ut(e,"failed");if(typeof i=="number"&&i>0)return`failed_runs:${i}`;let r=e?.run_results;if(Array.isArray(r)){let a=r.filter(s=>Jt(s)?.status==="failed").length;if(a>0)return`failed_runs:${a}`}}function Co(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 xo(){let e=Jt(se()),t=typeof process.exitCode=="number"&&Number.isFinite(process.exitCode)?Math.max(0,Math.trunc(process.exitCode)):void 0,n=Ut(e,"exit_code","exitCode"),o=t??n??f.SUCCESS,i=Fi(o),r=he(e,"error_code","errorCode")??Co(i,o),a=vo(he(e,"error_category","errorCategory"))??(i?void 0:at(r)),s=i?void 0:bo(e)??`command_exit_${o}`,l=wo(he(e,"command_resolution","commandResolution"))??ft({ok:i,errorCode:r,errorCategory:a}),d=_o(he(e,"resolution_stage","resolutionStage"))??"execute";return{ok:i,error:s,exit_code:o,error_code:r,error_category:a,command_resolution:l,resolution_stage:d}}(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="4cfcafe6-c6d5-579b-9b12-4b47c89f2355")}catch{}})();var ko="PM_CLI_PACKAGE_ROOT",da=Symbol("pm.deprecatedAliasInvocation"),zt=new Map;for(let e of V){let t=e.alias.split(" ")[0],n=zt.get(t)??[];n.push(e),zt.set(t,n)}for(let e of zt.values())e.sort((t,n)=>n.alias.split(" ").length-t.alias.split(" ").length);function Ac(){return Lo(import.meta.url,["../.."])}(typeof process.env[ko]!="string"||process.env[ko]?.trim().length===0)&&(process.env[ko]=Ac());var Ie=null,L=null;function Tc(e){Ie=e}function Oc(e){P=e}var nt=null,ye=null,P=new Map,Io=250,Rc=new Set([f.USAGE,f.NOT_FOUND,f.CONFLICT]),Ic=new Set(["1","true","yes","on"]),Pc=Ue(()=>import("./chunks/register-setup-YTWW2KL5.js")),$c=Ue(()=>import("./chunks/register-list-query-SYNBVMNG.js")),Dc=Ue(()=>import("./chunks/register-mutation-4GSUK23D.js")),Nc=Ue(()=>import("./chunks/register-operations-7FCJUC4Z.js"));function Ht(e){return A(e)}function ma(e){let t=e.match(/--[a-zA-Z0-9][a-zA-Z0-9_-]*/g);if(!t||t.length===0)return;let n=[...new Set(t.map(o=>me(o)??o))];return n.length>0?n:void 0}function Mc(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),i=new Set(o.map(c=>me(c)??c)),r=ma(e),a=t.find(c=>w.commands.some(m=>m.name()===c)),s=a?w.commands.find(c=>c.name()===a):void 0,l=new Set([...w.options,...s?.options??[]].flatMap(c=>c.flags.split(/[ ,|]+/).map(m=>me(m)).filter(m=>m!==void 0))),d=r?.filter(c=>{let m=me(c)??c;return i.has(m)?!1:l.has(m)||Ln(t,a,m,P)!==void 0});return d&&d.length>0?d:void 0}function Fc(e,t,n,o){if(o?.suggested_retry)return o.suggested_retry;let i=n?.[0],r=i?me(i):void 0,a=e.find(p=>w.commands.some(u=>u.name()===p)),s=a?w.commands.find(p=>p.name()===a):void 0,l=r?s?.options.find(p=>p.flags.split(/[ ,|]+/).includes(r)):void 0,d=Ln(e,a,r,P),c=r?l?.isBoolean()===!0||d===!1?[r]:[r,"<value>"]:[],m=r?Ht([...e,...c]):t;return m===t?void 0:m}function Lc(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 i=e[o];i!=null&&(n[o]=i)}return n}function jc(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,...Lc(t),...e.suggestedRetry?{suggested_retry:e.suggestedRetry}:{}}}function pa(e,t,n){let o=Fe(t),i=F(o),r=de(i),[a,s]=r===void 0?[]:i.slice(r,r+2),l=o.includes("--explain"),d=e?.recovery,c=d&&(a==="history-redact"||a==="history"&&s==="redact")?{...d,...d.attempted_command?{attempted_command:Ht(o)}:{},...d.normalized_args?{normalized_args:[...o]}:{},...d.suggested_retry?{suggested_retry:Ht(o)}:{},...d.suggested_retry_args?{suggested_retry_args:[...o]}:{}}:d;if(c?.recovery_mode==="compact"&&!l)return{...e,recovery:c};let m=Ht(o),p=X(o),u=Mc(n,o,c),g=Fc(o,m,u,c),h=jc({invocationArgv:o,attemptedCommand:m,providedFields:p,inferredMissing:u,suggestedRetry:g,existingRecovery:c});return{...e,recovery:h}}async function it(e){let t=L;L=null,await Ki(t,e);let n=Ie;if(Ie=null,!n){ct();return}let o=[],i=oi();try{await Ji({pmRoot:n.pmRoot,author:n.globalOptions.author,itemIds:e.ok?i?.map(r=>r.id)??[]:[],intent:n.commandName})}catch{o.push("context_usage_feedback_write_failed")}try{o.push(...await Bo(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:se(),affected:i}))}catch(r){o=[`afterCommand hooks failed: ${r instanceof Error?r.message:String(r)}`]}finally{ct()}!n.globalOptions.json&&o.length>0&&_(`[pm] warning: afterCommand hook_warnings=${U(o)}`),n.profileEnabled&&o.length>0&&_(`profile:extensions hook_warnings=${U(o)}`)}async function ua(){await Ei()}function fa(e){return Ic.has((process.env[e]??"").trim().toLowerCase())}function ga(e){return fa("PM_SENTRY_CAPTURE_EXPECTED_ERRORS")?!0:!Rc.has(Math.trunc(e))}async function Gt(e){return ga(e.exit_code)?(await ua(),Si(e),!0):!1}async function ha(e){let t=ce(e.error),n=fr(t);e.bootstrapGlobal.json?_(JSON.stringify(pr(t,f.GENERIC_FAILURE),null,2)):_(t),process.exitCode=f.GENERIC_FAILURE;let o="runtime",i="runtime_failed";try{await ua(),mn(e.error);let r=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=r.errorCategory,i=r.commandResolution,Le(!1,t,{error_code:n.code,error_category:o,exit_code:f.GENERIC_FAILURE,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||_(`Failed to report error: ${ce(r)}`)}try{await it({ok:!1,error:t,exit_code:f.GENERIC_FAILURE,error_code:n.code,error_category:o,command_resolution:i,resolution_stage:"execute"})}catch(r){e.bootstrapGlobal.json||_(`Failed to run error hooks: ${ce(r)}`)}try{await je()}catch(r){e.bootstrapGlobal.json||_(`Failed to flush error reporting: ${ce(r)}`)}}var Uc={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"},Eo=new Map;function So(e){return e==="number"?"number":e==="boolean"?"boolean":"string"}function ya(e,t){return e.options.some(n=>n.long===t)}function wa(e,t){return e.options.some(n=>n.short===t)}function Ao(e,t,n,o){let i=t.trim();if(!i)return;let r=n.length>0?n:`Runtime schema field (${t})`;if(i.startsWith("-")&&!i.startsWith("--")){if(wa(e,i))return;if(o){e.option(`${i} <value>`,`${r} (repeatable)`,fn);return}e.option(`${i} <value>`,r);return}let a=i.startsWith("--")?i:`--${i}`;if(!ya(e,a)){if(o){e.option(`${a} <value>`,`${r} (repeatable)`,fn);return}e.option(`${a} <value>`,r)}}async function _a(e,t){let n=Uc[e];if(!n)return[];let o=`${t}:${n}`,i=Eo.get(o);if(i)return i;if(!await K(J(t)))return Eo.set(o,[]),[];let r=await D(t),s=(ln(r.schema).command_to_fields.get(n)??[]).flatMap(l=>[l.cli_flag,...l.cli_aliases].map(c=>({long:`--${c}`,type:So(l.type),value_type:So(l.type)})));return Eo.set(o,s),s}async function va(e,t){let n=G(t),o=$(process.cwd(),n.path);if(!await K(J(o)))return;let i=ye?.key===Do(o)?ye.snapshot:null,r=i===null?await D(o):i.settings,a=ln(r.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 d=te(e,l.path.split(" "));if(d)for(let c of a.command_to_fields.get(l.command)??[]){let m=c.description??"";Ao(d,c.cli_flag,m,c.repeatable);for(let p of c.cli_aliases)Ao(d,p,`Alias for --${c.cli_flag}`,c.repeatable)}}}async function Po(e,t,n,o,i){let r=E(n);if(!(r!=="create"&&r!=="update"))try{let a=i??await D(t),s=re(a,o);Jr(e,s,n)}catch{}}function To(){return{enforce_item_format_gate:!0,run_preflight_item_format_sync:!0,run_extension_migrations:!0,enforce_mandatory_migration_gate:!0}}function ba(e,t="all"){return t==="all"?`pm-root:${e}`:`pm-root:${e}:activation:${t}`}function $o(e){return e.some(t=>t==="--profile")}function Do(e){return`pm-root:${e}`}function Oo(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 Ca(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=${U(t.activationWarnings)}`))}function Wt(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 Vt(e,t=Ce){let n=Do(e);if(ye?.key===n)return ye.snapshot;try{let o=Date.now(),{settings:i,warnings:r}=await t(e),a=await Ko({pmRoot:e,settings:i,cwd:process.cwd(),noExtensions:!1}),s={pmRoot:e,settings:i,discovery:a,discoveryMs:Date.now()-o,settingsReadWarnings:[...r]};return ye={key:n,snapshot:s},s}catch{return ye={key:n,snapshot:null},null}}async function Pe(e,t,n=D){let o=t?Qe(t):"all",i=ba(e,o);if(nt?.key===i)return nt.snapshot;try{let r=await n(e),a=await Ne({pmRoot:e,settings:r,cwd:process.cwd(),noExtensions:!1,extensionFilter:t?oo(t):void 0}),s=await Me({...a,loaded:a.loaded}),l=[...new Set(s.commands.handlers.map(u=>v(u.command)))].filter(u=>u.length>0).sort((u,g)=>u.localeCompare(g)),d=xr(s.registrations.flags),c=br(s.commands.handlers,s.registrations.commands),m=Er(l,s.registrations.commands,s.registrations.flags,c),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:r,commandHandlers:l,commandFlagHelp:d,commandDescriptors:m,commandAliases:c,loadWarnings:[...a.warnings],activationWarnings:[...s.warnings],loadedCount:a.loaded.length,loadFailedCount:a.failed.length,activationFailedCount:s.failed.length,contextIntentPackages:a.loaded.map(({name:u,module:g})=>({name:u,module:g}))};return nt={key:i,snapshot:p},p}catch{return nt={key:i,snapshot:null},null}}async function xa(e){let t=He(e);if(t.noExtensions){let a=$(process.cwd(),t.path);return await K(J(a))&&Oo((await Ce(a)).warnings),null}let n=$(process.cwd(),t.path),o=await Vt(n);if(!o)return null;Oo(o.settingsReadWarnings);let i={commandPath:T(e),commandArgs:io(e)};if(!Xe(o.discovery,i))return Wt(t.profile,o,i),null;let r=await Pe(n,i);return r?(Ca(t,r),{hooks:r.hooks,commands:r.commands,parsers:r.parsers,preflight:r.preflight,services:r.services,renderers:r.renderers,registrations:r.registrations,pmRoot:n}):null}async function ka(e){let t=await Pe(e);return t?new Map(t.commandDescriptors):P}async function Ea(e,t){return(await Ci({pmRoot:t,migrations:e,author:"pm-extension-migration"})).migrations.filter(o=>o.outcome==="failed").map(o=>`extension_migration_failed:${o.layer}:${o.extension}:${o.id}`)}function Sa(e,t,n){let o=typeof t.author=="string"&&t.author.trim()?t.author.trim():"pm-extension";return bi(e,zi.forActiveExtensionHost({pmRoot:e,author:o}),o,v(n))}async function Aa(e,t,n,o=[]){let i=T(e),r=Wn(e.args.map(String),o),a={...t},s={...n},l=$(process.cwd(),n.path),d=await dt({command:i,args:r,options:a,global:s,pm_root:l});n.profile&&d.warnings.length>0&&_(`profile:extensions parser_warnings=${U(d.warnings)}`),r=d.context.args,a=d.context.options,s=d.context.global,co(P.get(v(i)),r,a,o),ve(void 0),lt({command:i,args:r,options:{...a},global:{...s},pm_root:l});let c=await Zt({command:i,args:r,options:a,global:s,pm_root:l,sdk:Sa(l,s,i)});if(s.profile&&c.warnings.length>0&&_(`profile:extensions command_handler_warnings=${U(c.warnings)}`),!c.handled){if(c.warnings.length>0){let m=c.warnings[0],p=c.errorMessage?.trim(),u=p?` ${p}`:"";throw new C(`Command "${i}" failed in extension handler (${m}).${u}`,f.GENERIC_FAILURE,{code:c.errorCode??"command_failed",nextSteps:c.remediation?[c.remediation]:void 0})}throw new C(`Command "${i}" is provided by extensions and is not currently available.`,f.NOT_FOUND)}return c.exitCode!==void 0&&(process.exitCode=c.exitCode),ve(c.result),c.result}var ra=Symbol("pm.wrappedActionHandler");function qc(e,t){let n=e[e.length-1];return n instanceof Ro?n:t}function aa(e,t,n){e&&n.length>0&&_(`profile:extensions ${t}=${U(n)}`)}function Hc(e){let t=P.get(v(e.commandPath));if(!t||!so(e.activeRegistrations,e.commandPath))return;let n=Lt(t).length===0?Hr(e.commandArgs):Wn(e.commandArgs,e.extensionFlagDefinitions);lo(t,n)}function zc(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 Ta(e){let t=n=>{let o=n;if(typeof o._actionHandler=="function"&&o[ra]!==!0){let i=o._actionHandler;o._actionHandler=async function(...a){let s=qc(a,n),l=Date.now();un(s);let d=He(s),c=O(T(s));if(["package inventory","packages inventory","extension inventory"].includes(c))return await i.apply(this,a);let m=$(process.cwd(),d.path),p=s.args.map(String),u=ae(),g=u?Ze(u,c,p):[],h=await _a(c,m),y=Re(s,p,[...g,...h]),x=await dt({command:c,args:p,options:y,global:d,pm_root:m});aa(d.profile,"parser_warnings",x.warnings),p=x.context.args,y=x.context.options,ie(s,y),d=x.context.global,Hc({activeRegistrations:u,commandPath:c,commandArgs:p,extensionFlagDefinitions:g}),d=await ji(d),vt(s,d),zc(s,a,p),_t(s,y),ve(void 0),lt({command:c,args:p,options:{...y},global:{...d},pm_root:m});let S=await Zt({command:c,args:p,options:y,global:d,pm_root:m,sdk:Sa(m,d,c)});if(aa(d.profile,"command_handler_warnings",S.warnings),S.handled){ve(S.result),tn(S.result,{...d,command:c,commandArgs:p,commandOptions:y,pmRoot:m}),d.profile&&_(`profile:command=${c} took_ms=${Date.now()-l}`);return}return await i.apply(this,a)},o[ra]=!0}for(let i of n.commands)t(i)};t(e)}async function qt(e){P=new Map,ne({overrides:[]}),e&&await Po(e.rootProgram,e.pmRoot,e.invocationArgv,zo(),e.settings)}function Gc(e,t,n,o){if(t?.flags&&t.flags.length>0){jn(e,t.flags);let i=Un(e,t.flags);i&&e.addHelpText("after",i)}else n&&e.addHelpText("after",n);o&&e.addHelpText("after",o)}function Oa(e,t,n){let o={core:0,standard:1,full:2,internal:3},i=(r,a)=>{let s=a.join(" "),l=[...n.entries()].filter(([c])=>c===s||c.startsWith(`${s} `)).map(([,c])=>c),d=l.length===0?"standard":l.reduce((c,m)=>o[m.tier]<o[c]?m.tier:c,"internal");Ct(r,d);for(let c of r.commands)i(c,[...a,c.name()])};for(let r of e.commands)t.has(r.name())||i(r,[r.name()])}async function Ra(e,t){let n=G(t),o=$(process.cwd(),n.path);if(n.noExtensions){await qt({rootProgram:e,pmRoot:o,invocationArgv:t});return}let i=await Vt(o),r=Oe(t);if(!i){await qt();return}if(!Xe(i.discovery,r)){await qt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings}),Wt($o(t),i,r);return}let a=await Pe(o,r);if(!a){await qt({rootProgram:e,pmRoot:o,invocationArgv:t,settings:i.settings});return}ne(a.services),P=new Map(a.commandDescriptors),await Po(e,o,t,a.registrations,a.settings);let s=Dr(e,a.commandHandlers,a.commandDescriptors,a.commandAliases,c=>Nr(a.activationWarnings,_,c)),l=new Set(e.commands.map(c=>c.name())),d=c=>{let m=c.split(" ").filter(S=>S.length>0),p=a.commandDescriptors.get(c),u=te(e,m),g=a.commandFlagHelp.get(c),h=p?Pr(p):null;if(u){Gc(u,p,g,h);return}let y=$r(e,m);p?.description&&y.description(p.description);let x=g;p&&(Sr(y,p),p.flags.length>0&&(jn(y,p.flags),x=Un(y,p.flags)??void 0)),x&&y.addHelpText("after",x),h&&y.addHelpText("after",h),y.allowUnknownOption(!0).allowExcessArguments(!0).action(async(...S)=>{let z=S[S.length-1],j=z instanceof Ro?z:y,we=He(j),Bt=Date.now(),rt=Ze(a.registrations,c,j.args.map(String)),$e=Re(j,j.args.map(String),rt),_e=await Aa(j,$e,we,rt);await Ui(we,_e),tn(_e,{...we,command:c,commandArgs:j.args.map(String),commandOptions:$e,pmRoot:o}),we.profile&&_(`profile:command=${c} took_ms=${Date.now()-Bt}`)})};for(let c of s)d(c);Oa(e,l,a.commandDescriptors)}var ot=jo(import.meta.url,["../.."])??"0.0.0",w=nn(ot);async function sa(e){if(!L)return;let t=Reflect.get(e,da);typeof t=="string"&&await Hi(t)}function Ia(e,t){t&&et(t)||(e.hook("preAction",async(n,o)=>{Ie=null,L=null,ct(),un(o);let i=o.optsWithGlobals(),r=He(o),a=O(T(o)),s=o.args.map(String),l=Re(o,s),d={...r};ci(a,{...l,outputInclude:i.outputInclude,outputLimit:i.outputLimit,outputBudget:i.outputBudget,outputFormat:i.outputFormat,outputSession:i.outputSession,outputCursor:i.outputCursor}),ao(o,a,d,l),await Ri(a,d);let c=$(process.cwd(),r.path),m=await xa(o);if(!m){Ie=Jo({commandName:a,commandArgs:s,commandOptions:l,globalOptions:d,pmRoot:c}),L=await pn({command:a,pm_version:ot,args:s,options:l,global:d,pm_root:c}),await sa(e),cn(a,s,l,{source_context:L?.source_context,source_context_source:L?.source_context_source}),dn(a),await Jn(a,l,c,To()),await Kn(a,s,l,d,c);return}Yo(m.hooks),Xo(m.commands),Qo(m.parsers),Zo(m.preflight),ne(m.services),ei(m.renderers),ti(m.registrations);let p=Ze(m.registrations,a,s);l=Re(o,s,p),ao(o,a,d,l);let u=await dt({command:a,args:s,options:l,global:d,pm_root:m.pmRoot});d.profile&&u.warnings.length>0&&_(`profile:extensions parser_warnings=${U(u.warnings)}`),s=u.context.args,l=u.context.options,ie(o,l),d=u.context.global,_t(o,l);let g=await ii({command:a,args:s,options:l,global:d,pm_root:m.pmRoot,decision:To()});d.profile&&g.warnings.length>0&&_(`profile:extensions preflight_warnings=${U(g.warnings)}`),s=g.context.args,l=g.context.options,ie(o,l),d=g.context.global,_t(o,l);let h=g.decision;await Jn(a,l,m.pmRoot,h),await Kn(a,s,l,d,m.pmRoot);let y=h.run_extension_migrations?await Ea(m.registrations.migrations,m.pmRoot):[];d.profile&&y.length>0&&_(`profile:extensions migration_warnings=${U(y)}`);let x=Qr(m.registrations.migrations);Ie={hooks:m.hooks,commandName:a,commandArgs:s,commandOptions:{...l},globalOptions:{...d},pmRoot:m.pmRoot,profileEnabled:!!d.profile,migrationBlockers:x},ve(void 0),lt({command:a,args:s,options:{...l},global:{...d},pm_root:m.pmRoot}),L=await pn({command:a,pm_version:ot,args:s,options:l,global:d,pm_root:m.pmRoot}),await sa(e),cn(a,s,l,{source_context:L?.source_context,source_context_source:L?.source_context_source}),dn(a);let S=await Vo(m.hooks,{command:a,args:s,options:{...l},global:{...d},pm_root:m.pmRoot});d.profile&&S.length>0&&_(`profile:extensions hook_warnings=${U(S)}`),h.enforce_mandatory_migration_gate&&Zr(a,l,x)}),e.hook("postAction",async()=>{let n=xo();Le(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 it(n)}))}Ia(w);var la=Symbol("pmCliIdempotentTopLevelRegistration");function Pa(e){let t=e;if(t[la])return;t[la]=!0;let n=e.command.bind(e);e.command=((o,...i)=>{let r=o.split(/\s+/u)[0];return e.commands.some(a=>a.name()===r||a.aliases().includes(r))?new Ro(r):n(o,...i)})}async function Wc(e,t){if(Pa(e),t.setup){let{registerSetupCommands:n}=await Pc();n(e)}if(t.listQuery){let{registerListQueryCommands:n}=await $c(),o=typeof t.targetCommandName=="string"&&mo.has(t.targetCommandName)?new Set([t.targetCommandName]):void 0;n(e,o?{commandFilter:o}:void 0)}if(t.mutation){let{registerMutationCommands:n}=await Dc();n(e,{targetCommandName:t.targetCommandName})}if(t.operation){let{registerOperationCommands:n}=await Nc();n(e)}}function Vc(e){return async t=>{let n=at(t.errorCode),o=ft({ok:!1,errorCode:t.errorCode,errorCategory:n});return await Pi({command:t.command,args:e.invocationArgv,options:t.options,global:e.bootstrapGlobal,pm_version:ot,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 $a(e){if(e.bootstrapGlobal.noExtensions||et(e.invocationArgv))return;let t=Oe(e.invocationArgv),n=await Vt(e.bootstrapPmRoot);if(n&&Xe(n.discovery,t)){let o=await Pe(e.bootstrapPmRoot,t);Da(o);return}n&&Wt($o(e.invocationArgv),n,t),ne({overrides:[]})}function Da(e){if(!e){ne({overrides:[]});return}ne(e.services)}async function No(e){Le(!1,e.errorMessage,{error_code:e.classificationCode,error_category:e.errorCategory,exit_code:e.exitCode,command_resolution:e.commandResolution,resolution_stage:e.resolutionStage}),await it({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 Na(){Le(!0,void 0,{exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),await it({ok:!0,exit_code:f.SUCCESS,command_resolution:"success",resolution_stage:"parse"}),process.exitCode=f.SUCCESS}async function Ma(e,t){let n=typeof t=="number"&&Number.isFinite(t);if(!(e.error instanceof C)&&(an(e.error)||!n))return!1;let o=ce(e.error),i=e.error instanceof C?e.error.exitCode:rn(t),r=e.error instanceof C?e.error.context:void 0,a=pa(r,e.invocationArgv,o),s=dr(o,a),l=e.bootstrapGlobal.lean?Et(Rn(o,i,a)):Rn(o,i,a),d=e.jsonErrors?JSON.stringify(e.bootstrapGlobal.tokenAccounting?le(l,u=>`${JSON.stringify(u,null,2)}
|
|
34
|
+
`):l,null,2):cr(o,a);e.jsonErrors?be(`${d}
|
|
35
|
+
`):_(d);let{errorCategory:c,commandResolution:m}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:s.code,errorMessage:s.detail,exitCode:i,options:{bootstrap_global_options:e.bootstrapGlobal},resolutionStage:"execute"}),p=await Gt({command:e.attemptedCommand,error_code:s.code,error_category:c,exit_code:i,error_message:s.detail,command_resolution:m,resolution_stage:"execute",source_context:L?.source_context});return await No({errorMessage:o,exitCode:i,classificationCode:s.code,errorCategory:c,commandResolution:m,resolutionStage:"execute"}),p&&(mn(sn(e.error,o)),await je(Io)),process.exitCode=i,!0}async function Fa(e,t){let n=O(k(e.invocationArgv).commandPathTokens.join(" "))||$n(e.invocationArgv),o=`unknown command '${n}'`,i=$(process.cwd(),e.bootstrapGlobal.path),r=await ka(i),a=Oe(e.invocationArgv),s=await Vn(i,{},Te(a)),l=await Ve({message:o},w,r,{failedExtensions:s}),d=In(l.message,l.commandName,l.allowedTypes,{unknownCommandExamples:l.unknownCommandExamples,unknownCommandNextSteps:l.unknownCommandNextSteps,attemptedCommand:l.attemptedCommand,normalizedInvocationArgs:l.normalizedInvocationArgs,providedOptionFlags:l.providedOptionFlags,unknownOptionSuggestions:l.unknownOptionSuggestions,suggestedRetryCommand:l.suggestedRetryCommand,failedExtensions:s}),{errorCategory:c,commandResolution:m}=await e.emitTelemetryCommandError({command:n,errorCode:d.code,errorMessage:d.detail,exitCode:f.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t??"commander.helpDisplayed"},resolutionStage:"parse"}),p=await Gt({command:n,error_code:d.code,error_category:c,exit_code:f.USAGE,error_message:d.detail,command_resolution:m,resolution_stage:"parse"}),u=e.jsonErrors?await Fn({message:o},w,r,e.bootstrapGlobal.lean===!0,{failedExtensions:s}):await Mn({message:o},w,r,{failedExtensions:s}),g=Pn(u,e.jsonErrors,s);await No({errorMessage:o,exitCode:f.USAGE,classificationCode:d.code,errorCategory:c,commandResolution:m,resolutionStage:"parse"}),e.jsonErrors?be(`${g}
|
|
36
|
+
`):_(g),p&&await je(Io),process.exitCode=f.USAGE}async function La(e,t,n){if(!(t==="commander.helpDisplayed"||t==="commander.help"||t==="commander.helpCommand")&&!n.includes("(outputHelp)"))return!1;let i=k(e.invocationArgv);return i.requested&&!We(w,i.commandPathTokens)?(await Fa(e,t),!0):(await Na(),!0)}async function ja(e,t){let n=await Ve(e.error,w,P),o=In(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:i,commandResolution:r}=await e.emitTelemetryCommandError({command:e.attemptedCommand,errorCode:o.code,errorMessage:o.detail,exitCode:f.USAGE,options:{bootstrap_global_options:e.bootstrapGlobal,commander_code:t},resolutionStage:"parse"}),a=await Gt({command:e.attemptedCommand,error_code:o.code,error_category:i,exit_code:f.USAGE,error_message:o.detail,command_resolution:r,resolution_stage:"parse",source_context:L?.source_context}),s=e.jsonErrors?await Fn(e.error,w,P,e.bootstrapGlobal.lean===!0):await Mn(e.error,w,P),l=await zr(o.code,e.bootstrapPmRoot,{},Te(Oe(e.invocationArgv))),d=Pn(s,e.jsonErrors,l);await No({errorMessage:n.message,exitCode:f.USAGE,classificationCode:o.code,errorCategory:i,commandResolution:r,resolutionStage:"parse"}),e.jsonErrors?be(`${d}
|
|
37
|
+
`):_(d),a&&await je(Io),process.exitCode=f.USAGE}function Ua(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 qa(e){let t=e.error.code,n=String(e.error.message??"");if(!await La(e,t,n)){if(t==="commander.version"){await Na();return}await ja(e,t)}}async function Mo(e){let t=G(e.invocationArgv),n=$(process.cwd(),t.path),o={error:e.error,invocationArgv:e.invocationArgv,bootstrapGlobal:t,jsonErrors:t.json,bootstrapPmRoot:n,attemptedCommand:E(e.invocationArgv)??"<unknown>",emitTelemetryCommandError:Vc({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n})};if(await $a({invocationArgv:e.invocationArgv,bootstrapGlobal:t,bootstrapPmRoot:n}),!await Ma(o,on(e.error))){if(Ua(e.error)){await qa(o);return}await ha({error:e.error,attemptedCommand:o.attemptedCommand,bootstrapGlobal:t,emitTelemetryCommandError:o.emitTelemetryCommandError})}}function Bc(e,t,n){let o=n.requested?n.commandPathTokens:F(t),i=W(o);if(i&&!te(e,[...i.canonical_argv]))throw new ca(f.USAGE,"commander.unknownCommand",`unknown command '${i.alias}'`)}function Kc(e,t){let n=de(t);if(n===void 0)return;if(["pm","pm-cli"].includes(t[n]?.trim().toLowerCase())){let a=de(t.slice(n+1));if(a===void 0)return;n+=a+1}let o=zt.get(t[n]),i=t.slice(n).filter(a=>!["--global","--project","--local"].includes(a)),r=o?.find(a=>a.alias.split(" ").every((s,l)=>i[l]===s));r?.lifecycle==="deprecated"&&Reflect.set(e,da,r.alias)}async function Jc(e){w=nn(ot),Ia(w,e),nt=null,ye=null,P=new Map,ni();let t=[...e],n,o;try{let i=bt(e);t=i.argv,Kc(w,e);let r=[process.argv[0],process.argv[1],...t],a=t.length===0,s=G(t);if(s.authorMissingValue)throw new C("--author requires a non-empty value.",f.USAGE,{code:"missing_required_argument",nextSteps:["Pass an explicit author identifier with --author <id>."]});n=xi(s.author),ho(i),o=Gi(t);let l=po(t);await Wc(w,l),vn(w,!0),fo(w,t)?await Ra(w,t):(P=new Map,ne({overrides:[]})),go(t)&&await va(w,t),vn(w);let c=k(t);if(Bc(w,t,c),uo(t)&&tr(w,t),Ta(w),await Kr(w,t,P,e))return;if(c.requested&&!We(w,c.commandPathTokens))throw new ca(f.USAGE,"commander.helpDisplayed","(outputHelp)");if(a||oe(t)&&E(t)===void 0){w.outputHelp();return}if(et(t)){await w.parseAsync(r);return}let p=$(process.cwd(),s.path),u=await D(p),g=await _r(t,p,s.noExtensions,Pe);await gi({pmRoot:p,packages:g?.contextIntentPackages},()=>hi({env:{...process.env,PM_PATH:p},argv:r,cwd:process.cwd()},()=>yi(u.agent_identity.harness_signals,()=>w.parseAsync(r),{probesEnabled:u.agent_identity?.probes_enabled})))}catch(i){await Mo({error:i,invocationArgv:t})}finally{o?.(),n?.()}}async function dp(e=process.argv.slice(2)){try{await ki(process.env,()=>Jc(e))}catch(t){await Mo({error:t,invocationArgv:[...e]})}}var mp={activationCommandMatchesProbe:Xn,applyDynamicExtensionRootHelpVisibility:Oa,bootstrapProfileEnabled:$o,buildBootstrapActivationProbe:Oe,buildPostActionTelemetryOutcome:xo,buildPmCliRecoveryContext:pa,buildRuntimeExtensionDiscoverySnapshotCacheKey:Do,buildRuntimeExtensionActivationScope:Qe,buildRuntimeExtensionSnapshotCacheKey:ba,buildRuntimeExtensionFilterForProbe:oo,addRuntimeFieldOption:Ao,collectActivationCommandCandidates:Te,collectExtensionFlagDefinitionsForCommand:Ft,collectExtensionFlagDefinitionsForInvocation:Ze,collectLeadingCommandArgs:Yn,collectParsedActivationCommandArgs:io,collectRuntimeFieldLooseFlagDefinitionsForCommand:_a,commandHasLongOption:ya,commandHasShortOption:wa,commandPathNeedsSearchExtensions:Qn,commandPathNeedsTemplateExtensions:Dt,describeUnknownError:ce,defaultPreflightDecision:To,discoveryNeedsActivationForProbe:Xe,emitExtensionProfile:Ca,emitExtensionSkippedProfile:Wt,emitSettingsReadWarnings:Oo,ensureIdempotentTopLevelCommandRegistration:Pa,enforceExplicitRetryForFlagTypos:ho,envFlagEnabled:fa,executeRegisteredRuntimeMigrations:Ea,extractCommandScopedOptions:Re,extensionActivationCommands:$t,extensionCapabilities:Ye,extensionNeedsActivationForProbe:Nt,extensionProvidesTemplatesRuntime:eo,hasAnyCapability:Ae,hasGlobalExtensionContributions:to,handleGenericRunPmCliError:ha,handleRunPmCliCommanderError:qa,handleRunPmCliError:Mo,handleRunPmCliHelpDisplayError:La,handleRunPmCliKnownError:Ma,handleRunPmCliCommanderUsageError:ja,handleUnknownHelpCommandError:Fa,inferMissingFieldsFromErrorMessage:ma,inferPostActionErrorCode:Co,inferPostActionFailureMessage:bo,invocationRequestsVersion:tt,isCommanderError:an,loadRuntimeExtensionCommandDescriptorsForRecovery:ka,loadRuntimeExtensionDiscoverySnapshot:Vt,loadRuntimeExtensionSnapshot:Pe,maybeLoadRuntimeExtensions:xa,maybeAttachCreateUpdatePolicyHelpText:Po,maybeLogHandledCliErrorToSentry:Gt,matchesStaticExtensionCommand:Pt,normalizeTelemetryCommandResolution:wo,normalizeTelemetryErrorCategory:vo,normalizeTelemetryResolutionStage:_o,normalizeThrownExitCode:rn,probeUsesAnyFlag:Zn,prepareExtensionServicesForRunPmCliError:$a,readRecordBoolean:yo,readRecordNumber:Ut,readRecordString:he,recordCliReadOutputInvocationProvenance:ro,registerDynamicExtensionCommandPaths:Ra,registerRuntimeSchemaFieldFlags:va,resolveCoreCommandRegistrationSelection:po,resolveStaticExtensionActivationDecision:no,resolveUnknownHelpToken:$n,readThrownExitCode:on,runAndClearAfterCommandHooks:it,runRequiredExtensionCommand:Aa,shouldAttachRichHelpTextForInvocation:uo,shouldLogHandledErrorToSentry:ga,shouldRegisterDynamicExtensionPaths:fo,shouldRegisterRuntimeSchemaFlags:go,shouldHandleRunPmCliCommanderError:Ua,setActiveExtensionHookContextForTest:Tc,setActiveRuntimeExtensionCommandDescriptorsForTest:Oc,setRecoveredExtensionServices:Da,toLooseFieldDefinitionType:So,isImporterOrExporterCommandPath:so,validateDynamicExtensionCommandInvocation:co,wrapProgramActionsForExtensionHandlers:Ta,wrapThrownErrorForSentry:sn};export{mp as _testOnly,dp as runPmCli};
|
|
38
38
|
//# sourceMappingURL=main.js.map
|