@unbrained/pm-cli 2026.11.25 → 2026.11.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +1 -1
- package/dist/cli/commander-usage.js +9 -9
- package/dist/cli/error-guidance.js +5 -5
- package/dist/cli/help-content.js +4 -4
- package/dist/cli/register-setup.js +1 -1
- package/dist/cli/runtime/selection.js +1 -1
- package/dist/cli-bundle/bundle-manifest.json +1 -1
- package/dist/cli-bundle/chunks/{chunk-CZEMEPPQ.js → chunk-5CMR4R5V.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-YIGBEY7K.js → chunk-5M7UTO2G.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-63AVXDZS.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-CONBVY2O.js → chunk-66TNCHHG.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-LPW7S5KA.js → chunk-6NJ3BONB.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-AVHRMUXJ.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-FVY7U3SU.js → chunk-HTT52JL3.js} +37 -37
- package/dist/cli-bundle/chunks/{chunk-OS5W4ZG2.js → chunk-J25DZRYJ.js} +31 -31
- package/dist/cli-bundle/chunks/chunk-J6TFG34A.js +4 -0
- package/dist/cli-bundle/chunks/{chunk-K34FR5CO.js → chunk-JX475QVU.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-KP75JTTO.js +35 -0
- package/dist/cli-bundle/chunks/chunk-KS47NGMQ.js +69 -0
- package/dist/cli-bundle/chunks/{chunk-BVJMVU4Z.js → chunk-O23KTJL6.js} +6 -6
- package/dist/cli-bundle/chunks/{chunk-DF6A7C32.js → chunk-OFX2VA5Z.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-FHLOGAGA.js → chunk-QVDEZBSV.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-SIRZ4VMT.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-C4KIZQHW.js → chunk-VC4BJIA7.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-GBVF2ZB3.js → chunk-W7SPEGSP.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-WY7467RY.js +3 -0
- package/dist/cli-bundle/chunks/{chunk-7EPYCU7U.js → chunk-X6TE47CS.js} +5 -5
- package/dist/cli-bundle/chunks/chunk-XB6QEVUK.js +2 -0
- package/dist/cli-bundle/chunks/chunk-XYX4CXFR.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-SCIPT7WF.js → chunk-Y5U7QCNX.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-L6VS7F3R.js → chunk-YGK6SA7P.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-OWK2JL4I.js → chunk-ZGV4ZXDS.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-CNUFU454.js → chunk-ZILIHDDY.js} +41 -41
- package/dist/cli-bundle/chunks/{field-option-collisions-QE65APSD.js → field-option-collisions-UL6BIPAK.js} +2 -2
- package/dist/cli-bundle/chunks/{item-revision-INDHJV6X.js → item-revision-WNUDY5DM.js} +2 -2
- package/dist/cli-bundle/chunks/item-transaction-ER3OWOPV.js +2 -0
- package/dist/cli-bundle/chunks/{mutation-actor-KU7BMLUN.js → mutation-actor-SFYTD2ZB.js} +2 -2
- package/dist/cli-bundle/chunks/{mutation-admission-3OMCTQD4.js → mutation-admission-AVOOT3KH.js} +2 -2
- package/dist/cli-bundle/chunks/{register-list-query-3GV3LBOT.js → register-list-query-Q7UW2EPV.js} +2 -2
- package/dist/cli-bundle/chunks/{register-mutation-GZLF47SX.js → register-mutation-YNW7E3T4.js} +2 -2
- package/dist/cli-bundle/chunks/{register-operations-PBJZGCAL.js → register-operations-DAUTQCIO.js} +2 -2
- package/dist/cli-bundle/chunks/register-setup-VSURGF7V.js +2 -0
- package/dist/cli-bundle/chunks/{stage-3WIZBD4N.js → stage-N5GDBS5A.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-X4EWD6TL.js → chunk-24W63UPP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-C3FEDTSD.js → chunk-2XGHBYDA.js} +26 -26
- package/dist/cli-bundle/focused-chunks/{chunk-ZLRRII55.js → chunk-3QRMY6KF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-PKX2EHE3.js → chunk-4HLZOOZI.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-52PHSTGP.js +27 -0
- package/dist/cli-bundle/focused-chunks/{chunk-YYEWIKNI.js → chunk-7FKGIJEB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-7GZMOLQY.js +15 -0
- package/dist/cli-bundle/focused-chunks/chunk-AL47ODFZ.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-AN4NFFLL.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-BYQK5DGH.js → chunk-B2HJI6KA.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-JOKRDFMQ.js → chunk-C2HW7BSE.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-TQIKDFOD.js → chunk-GISZWMBS.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-BOIMP2AR.js → chunk-GUAT4OAC.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-VU2PH4PF.js → chunk-H4JBS477.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-XKLBTDJ7.js → chunk-HGJ4MILN.js} +37 -37
- package/dist/cli-bundle/focused-chunks/{chunk-TRL4JDWX.js → chunk-HSWL6L2O.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-SXC2EO3E.js → chunk-I4GY7HAP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-KMG4O2IU.js +4 -0
- package/dist/cli-bundle/focused-chunks/{chunk-4LQL4EO6.js → chunk-N7ZAMULP.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UWWAVXG4.js → chunk-REORRDPH.js} +3 -3
- package/dist/cli-bundle/focused-chunks/{chunk-MB56Y4M6.js → chunk-SXWUKNTY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-5RBC4WSE.js → chunk-UGQ2EXTU.js} +58 -59
- package/dist/cli-bundle/focused-chunks/chunk-YPOATPTX.js +3 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7SSGTGZO.js → chunk-ZZYJS74B.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{field-option-collisions-5ROXGUME.js → field-option-collisions-BP7ILGQK.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-revision-KYMSQVZE.js → item-revision-NOHVIOQQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{item-transaction-I4HLVHEJ.js → item-transaction-O26COBOJ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-actor-GGOQKAE6.js → mutation-actor-HVJV5S76.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{mutation-admission-OS36ZCMH.js → mutation-admission-JRICEVYN.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{stage-4ZFWJUKO.js → stage-NSX6ASBZ.js} +2 -2
- package/dist/cli-bundle/main.js +26 -26
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +4 -4
- package/dist/cli-bundle/sdk-core.js +1 -1
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +63 -63
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +11 -11
- package/dist/core/extensions/index.js +1 -1
- package/dist/core/reproducibility/context.d.ts +2 -0
- package/dist/core/reproducibility/context.js +1 -1
- package/dist/core/shared/command-line.d.ts +2 -2
- package/dist/core/shared/command-line.js +1 -1
- package/dist/core/shared/secret-rules.js +5 -5
- package/dist/sdk/cli-bootstrap.d.ts +17 -0
- package/dist/sdk/cli-bootstrap.js +1 -1
- package/dist/sdk/cli-contracts/command-aliases.js +1 -1
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
- package/dist/sdk/cli-contracts/grammar-contracts.js +1 -1
- package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
- package/dist/sdk/cli-contracts/tool-schema.d.ts +1 -1
- package/dist/sdk/cli-contracts/tool-schema.js +1 -1
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +1 -1
- package/dist/sdk/completion/shared.d.ts +1 -1
- package/dist/sdk/completion/shared.js +1 -1
- package/dist/sdk/extension/bundled-catalog.js +1 -1
- package/dist/sdk/extension/install-sources.js +5 -5
- package/dist/sdk/extension/listing-fields.d.ts +15 -0
- package/dist/sdk/extension/listing-fields.js +2 -0
- package/dist/sdk/extension/managed-update-status.js +1 -1
- package/dist/sdk/extension/npm-spec.d.ts +18 -0
- package/dist/sdk/extension/npm-spec.js +2 -0
- package/dist/sdk/extension/static-inventory.d.ts +53 -1
- package/dist/sdk/extension/static-inventory.js +1 -1
- package/dist/sdk/extension/update-check.js +1 -1
- package/dist/sdk/extension/update-observations.js +3 -0
- package/dist/sdk/extension/upgrade-hints.js +2 -0
- package/dist/sdk/extension.d.ts +2 -0
- package/dist/sdk/extension.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
- package/dist/sdk/governance/upgrade.d.ts +7 -2
- package/dist/sdk/governance/upgrade.js +2 -2
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/public-surface.json +1 -1
- package/dist/sdk/query/context.d.ts +20 -7
- package/dist/sdk/query/context.js +4 -2
- package/dist/sdk/runtime-input.js +1 -1
- package/dist/sdk/testing.d.ts +20 -2
- package/docs/COMMANDS.md +19 -1
- package/docs/CONFIGURATION.md +1 -1
- package/docs/DIAGNOSTIC_OUTPUT_CONTRACTS.md +6 -0
- package/docs/EXTENSION_LIFECYCLE.md +72 -2
- package/docs/MUTATION_INTEGRITY.md +47 -0
- package/docs/SDK.md +24 -3
- package/marketplace.json +1 -1
- package/package.json +1 -1
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-claude/package.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/plugins/pm-codex/package.json +1 -1
- package/plugins/pm-codex/plugin.json +1 -1
- package/runtime-dependencies.json +1 -1
- package/dist/cli-bundle/chunks/chunk-4FZH5BTV.js +0 -2
- package/dist/cli-bundle/chunks/chunk-GZI7ZAB7.js +0 -2
- package/dist/cli-bundle/chunks/chunk-LOX3VY4T.js +0 -2
- package/dist/cli-bundle/chunks/chunk-VA4T37Q4.js +0 -70
- package/dist/cli-bundle/chunks/chunk-WQOEVGLQ.js +0 -2
- package/dist/cli-bundle/chunks/chunk-XHCIOLJP.js +0 -3
- package/dist/cli-bundle/chunks/chunk-XKWJONAO.js +0 -2
- package/dist/cli-bundle/chunks/chunk-ZBOQEZ2H.js +0 -33
- package/dist/cli-bundle/chunks/chunk-ZLICQPRG.js +0 -3
- package/dist/cli-bundle/chunks/item-transaction-LCKK4XXB.js +0 -2
- package/dist/cli-bundle/chunks/register-setup-ZLJEF6NZ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3Y5PTQ2F.js +0 -27
- package/dist/cli-bundle/focused-chunks/chunk-A4R57E4K.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IAOKVKWW.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VMYVN36N.js +0 -13
- package/dist/cli-bundle/focused-chunks/chunk-WL2R7T5G.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-WVA5KOXF.js +0 -3
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{PM_TOOL_PARAMETER_PROPERTIES as De}from"./tool-parameter-tables.js";import{resolveExtensionFlagValueContract as Ue,resolveExtensionLongFlagName as $e,EXIT_CODE as f,SETTINGS_DEFAULTS as R,PmCliError as S,activateExtensions as je,getActiveExtensionRegistrations as qe,loadExtensions as Be,pathExists as We,commandOptionFlagLabel as Xe,resolveCommandOptionPolicyState as Ve,resolveItemTypeRegistry as Ke,resolveRuntimeFieldRegistry as Ye,resolveRuntimeStatusRegistry as ze,getSettingsPath as He,resolvePmRoot as $,readSettings as j}from"../runtime-primitives.js";import{PM_HISTORY_OPERATION_CONTRACT as Je}from"../../core/history/operation-contract.js";import{buildMcpToolContracts as Qe}from"../../mcp/tool-definitions.js";import{ACTIVITY_COMMANDER_STRING_OPTION_CONTRACTS as Ze,ACTIVITY_FLAG_CONTRACTS as et,AGGREGATE_FLAG_CONTRACTS as tt,ASSURANCE_FLAG_CONTRACTS as nt,APPEND_FLAG_CONTRACTS as at,CALENDAR_COMMANDER_STRING_OPTION_CONTRACTS as st,CALENDAR_FLAG_CONTRACTS as q,CLAIM_FLAG_CONTRACTS as ot,CLOSE_TASK_FLAG_CONTRACTS as rt,COMMENTS_FLAG_CONTRACTS as it,CLOSE_FLAG_CONTRACTS as ct,CLOSE_MANY_FLAG_CONTRACTS as lt,COMPLETION_FLAG_CONTRACTS as dt,CONFIG_FLAG_CONTRACTS as ut,CONTRACTS_FLAG_CONTRACTS as mt,COPY_FLAG_CONTRACTS as pt,CONTEXT_COMMANDER_STRING_OPTION_CONTRACTS as _t,CONTEXT_FLAG_CONTRACTS as B,CREATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS as ft,CREATE_COMMANDER_STRING_OPTION_CONTRACTS as Ct,CREATE_FLAG_CONTRACTS as At,DELETE_FLAG_CONTRACTS as gt,DEPS_FLAG_CONTRACTS as Tt,GRAPH_FLAG_CONTRACTS as Ot,DOCS_FLAG_CONTRACTS as ht,EXTENSION_ACTIVATE_FLAG_CONTRACTS as St,EXTENSION_ADOPT_ALL_FLAG_CONTRACTS as yt,EXTENSION_ADOPT_FLAG_CONTRACTS as Nt,EXTENSION_CATALOG_FLAG_CONTRACTS as Et,EXTENSION_DEACTIVATE_FLAG_CONTRACTS as Rt,EXTENSION_DESCRIBE_FLAG_CONTRACTS as Lt,EXTENSION_DOCTOR_FLAG_CONTRACTS as vt,EXTENSION_EXPLORE_FLAG_CONTRACTS as Mt,EXTENSION_FLAG_CONTRACTS as It,EXTENSION_INIT_FLAG_CONTRACTS as wt,EXTENSION_INSTALL_FLAG_CONTRACTS as xt,EXTENSION_MANAGE_FLAG_CONTRACTS as Ft,EXTENSION_MIGRATE_FLAG_CONTRACTS as kt,EXTENSION_RELOAD_FLAG_CONTRACTS as bt,EXTENSION_UNINSTALL_FLAG_CONTRACTS as Gt,FILES_FLAG_CONTRACTS as Pt,FOCUS_FLAG_CONTRACTS as Dt,GC_FLAG_CONTRACTS as Ut,GET_FLAG_CONTRACTS as $t,GUIDE_FLAG_CONTRACTS as jt,GLOBAL_FLAG_CONTRACTS as qt,HEALTH_FLAG_CONTRACTS as Bt,HISTORY_FLAG_CONTRACTS as Wt,HISTORY_COMPACT_FLAG_CONTRACTS as Xt,HISTORY_REDACT_FLAG_CONTRACTS as Vt,HISTORY_REPAIR_FLAG_CONTRACTS as Kt,HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS as Yt,INSTALL_FLAG_CONTRACTS as zt,INIT_FLAG_CONTRACTS as Ht,ITEM_COMPLETE_FLAG_CONTRACTS as Jt,ITEM_MUTATE_FLAG_CONTRACTS as Qt,ITEM_REOPEN_FLAG_CONTRACTS as Zt,LEARNINGS_FLAG_CONTRACTS as en,LIST_COMMANDER_STRING_OPTION_CONTRACTS as tn,LIST_FILTER_FLAG_CONTRACTS as nn,MERGE_FLAG_CONTRACTS as an,NOTES_FLAG_CONTRACTS as sn,PACKAGE_FLAG_CONTRACTS as W,PACKAGE_INIT_FLAG_CONTRACTS as on,PM_EXTENSION_CAPABILITY_CONTRACTS as rn,PM_EXTENSION_POLICY_MODE_CONTRACTS as cn,PM_EXTENSION_POLICY_SURFACE_CONTRACTS as ln,PM_EXTENSION_SANDBOX_PROFILE_CONTRACTS as dn,PM_EXTENSION_SERVICE_NAME_CONTRACTS as un,PM_EXTENSION_TRUST_MODE_CONTRACTS as mn,PM_OUTPUT_DEGRADATION_STEPS as pn,PLAN_FLAG_CONTRACTS as _n,PM_CORE_COMMAND_NAMES as X,PM_DEPRECATED_TOOL_ACTIONS as fn,PM_TOOL_ACTIONS as Cn,PM_TOOL_PARAMETERS_SCHEMA as An,REINDEX_FLAG_CONTRACTS as gn,RELEASE_FLAG_CONTRACTS as Tn,RESTORE_FLAG_CONTRACTS as On,SCHEMA_FLAG_CONTRACTS as hn,PROFILE_FLAG_CONTRACTS as Sn,SEARCH_COMMANDER_STRING_OPTION_CONTRACTS as yn,EVAL_FLAG_CONTRACTS as Nn,EVENTS_FLAG_CONTRACTS as En,WORKSPACE_FLAG_CONTRACTS as T,NEXT_FLAG_CONTRACTS as Rn,SEARCH_FLAG_CONTRACTS as Ln,STATS_FLAG_CONTRACTS as vn,DUPLICATES_FLAG_CONTRACTS as Mn,START_TASK_FLAG_CONTRACTS as In,PAUSE_TASK_FLAG_CONTRACTS as wn,TELEMETRY_FLAG_CONTRACTS as xn,TEST_ALL_FLAG_CONTRACTS as Fn,TEST_FLAG_CONTRACTS as kn,TEST_RUNS_FLAG_CONTRACTS as bn,UPDATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS as Gn,UPDATE_COMMANDER_STRING_OPTION_CONTRACTS as Pn,UPDATE_FLAG_CONTRACTS as Dn,UPDATE_MANY_FLAG_CONTRACTS as Un,UPGRADE_FLAG_CONTRACTS as V,VALIDATE_FLAG_CONTRACTS as $n,compactFlagAliasContracts as K,SUBCOMMAND_GLOBAL_FLAG_CONTRACTS as Y,PM_COMMAND_ALIAS_CONTRACTS as z,PM_DIAGNOSTIC_OUTPUT_BUDGET_CONTRACTS as jn,resolvePmCommandOutputBudget as H}from"../cli-contracts.js";import{PM_NAMESPACED_COMMAND_ALIASES as O,resolvePmCommandOperation as d}from"./command-aliases.js";import{HISTORY_ATTEST_FLAG_CONTRACTS as qn,PM_POSITIONAL_ACTION_FLAG_CONTRACTS as Bn,resolveExtensionCommandInheritedFlagContracts as Wn,resolveSubcommandFlagContractsForCommand as Xn}from"./flag-contracts.js";import{resolveExtensionFlagOptionKey as J}from"../extension/command-options.js";import{GOVERNANCE_CLOSE_VALIDATION_DEFAULT_VALUES as Vn,GOVERNANCE_CREATE_MODE_DEFAULT_VALUES as Kn,GOVERNANCE_OWNERSHIP_ENFORCEMENT_VALUES as Yn,GOVERNANCE_WORKFLOW_ENFORCEMENT_VALUES as zn}from"../../types.js";import{BRIEF_LIST_FIELDS as Hn,DEFAULT_COMPACT_LIST_FIELDS as Jn,LIST_COMMAND_DEFAULT_PROJECTIONS as Qn}from"../query/list.js";import{getActiveContextIntentContracts as Zn}from"../context-intent-contracts.js";import{readOutputIncludeModeOptions as ea,resolveReadOutputSurface as ta,PM_READ_OUTPUT_SURFACE_CONTRACTS as na}from"../read-output-contracts.js";import{enrichCliFlagInvocationContracts as aa}from"../flag-invocation-contracts.js";import{resolvePmCommandVisibilityTier as Q}from"../agent-capability-contracts.js";import{PM_ERROR_CODE_CATALOG as sa}from"../generated-error-code-catalog.js";import{resolvePmCommandOutputEnvelope as oa}from"../output-contracts.js";import{PM_COMMAND_EXIT_OUTCOME_CONTRACTS as ra,resolvePmCommandExitContract as ia}from"./command-exit-contracts.js";import{BUILTIN_RELATIONSHIP_KINDS as ca}from"../relationship-kinds/contract.js";import{ASSURANCE_GATE_TRIGGERS as la,ASSURANCE_MEASUREMENT_SOURCE_KINDS as da}from"../governance/assurance.js";import{PM_CLI_GRAMMAR_CONTRACT as y,PM_COMMAND_DESTINATION_CONTRACTS as ua,PM_COMMAND_POSITIONAL_CONTRACTS as Z,PM_POSITIONAL_ACTION_CONTRACTS as ee,positionalShapeKey as ma,resolvePmCommandPositionalContract as pa}from"./grammar-contracts.js";const te=new Map([["activity",["--limit","--after","--full"]],["claim",["--if-available","--next","--type","--priority","--token-budget","--explain-ranking"]],["close",["--reason","--validate-close","--resolution","--expected-result","--actual-result","--message"]],["context",["--limit","--after","--depth","--section","--token-budget","--explain-ranking"]],["contracts",["--command","--flags-only","--summary","--runtime-only","--availability-only","--full"]],["create",["--title","--type","--status","--priority","--dep","--comment"]],["get",["--full","--depth","--fields","--tree","--tree-depth","--format"]],["health",["--check-only","--summary","--brief","--check-telemetry","--strict-exit","--full"]],["list",["--status","--type","--limit","--after","--brief","--fields"]],["next",["--limit","--blocked-limit","--ready-only","--token-budget","--explain-ranking","--format"]],["search",["--mode","--status","--type","--limit","--after","--fields"]],["update",["--status","--message","--dep","--comment","--file","--test"]],["validate",["--check-resolution","--check-history-drift","--check-storage-integrity","--counts","--strict-exit","--fix-hints"]]]),_a=["--limit","--after","--offset","--token-budget","--brief","--summary","--compact","--fields","--full","--format","--since","--until"],ne=new Set(["list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled"]),L=new Set(["calendar","guide","reindex","completion","test-runs-list","test-runs-status","test-runs-logs","test-runs-stop","test-runs-resume","templates-list","templates-save","templates-show"]),h=new Set(["meet","event","remind","search-advanced","dedupe-audit","dedupe-merge","comments-audit","cal","calendar","completion","completion-statuses","completion-tags","completion-types","guide","reindex","normalize","templates","templates list","templates save","templates show","test-runs","test-runs list","test-runs status","test-runs logs","test-runs stop","test-runs resume"]),ae=new Map([["meet","calendar"],["event","calendar"],["remind","calendar"],["search-advanced","search-advanced"],["dedupe-audit","governance-audit"],["dedupe-merge","governance-audit"],["comments-audit","governance-audit"],["cal","calendar"],["calendar","calendar"],["completion","guide-shell"],["completion-statuses","guide-shell"],["completion-tags","guide-shell"],["completion-types","guide-shell"],["guide","guide-shell"],["reindex","search-advanced"],["normalize","governance-audit"],["templates","templates"],["templates list","templates"],["templates save","templates"],["templates show","templates"],["test-runs","linked-test-adapters"],["test-runs list","linked-test-adapters"],["test-runs status","linked-test-adapters"],["test-runs logs","linked-test-adapters"],["test-runs stop","linked-test-adapters"],["test-runs resume","linked-test-adapters"]]),se=new Map([["calendar","calendar|cal"],["guide","guide"],["reindex","reindex"],["completion","completion"],["test-runs-list","test-runs|test-runs list"],["test-runs-status","test-runs status"],["test-runs-logs","test-runs logs"],["test-runs-stop","test-runs stop"],["test-runs-resume","test-runs resume"],["templates-list","templates|templates list"],["templates-save","templates save"],["templates-show","templates show"]]),oe=new Map([...se.entries()].flatMap(([e,t])=>A(t).map(n=>[n,e]))),re=[{canonical:"context",aliases:["ctx"]},{canonical:"package",aliases:["extension","packages"]}],w=new Map(re.flatMap(e=>e.aliases.map(t=>[t,e.canonical]))),fa=10,Ca=20,ie=new Map([["activity","Read activity."],["aggregate","Group counts."],["append","Append body."],["assurance","Evaluate assurance."],["assurance derive","Derive checks."],["assurance risk","Select checks for changes."],["assurance lineages","Measure recurrence coverage."],["beads","Manage Beads interoperability."],["cal","Manage calendar integration."],["calendar","Manage calendar integration."],["changelog","Generate changelog output."],["claim","Claim work."],["close","Close work."],["close-many","Close matching work."],["close-task","Close task work."],["command-kit","Inspect command authoring primitives."],["comments","Manage comments."],["comments-audit","Audit comment governance."],["completion","Generate shell completions."],["config","Manage settings."],["context","Build context."],["contracts","Inspect contracts."],["copy","Copy work."],["create","Create work."],["dedupe-audit","Audit duplicate work."],["dedupe-merge","Merge duplicate work."],["delete","Delete work."],["deps","Manage deps."],["duplicates","Find duplicate clusters."],["docs","Link docs."],["eval","Run evaluations."],["event","Manage events."],["events","Read events."],["files","Link files."],["focus","Manage focus."],["gc","Clean caches."],["get","Read item."],["graph","Query graph."],["guide","Show user guides."],["health","Check health."],["help","Show help."],["history","Inspect history."],["init","Initialize workspace."],["install","Install packages."],["item","Mutate items."],["learnings","Manage learnings."],["list","List work."],["list-all","List work across every status."],["list-blocked","List blocked work."],["list-canceled","List canceled work."],["list-closed","List closed work."],["list-draft","List draft work."],["list-in-progress","List in-progress work."],["list-open","List open work."],["meet","Record meeting context."],["merge","Manage tracker merges."],["next","Pick next work."],["notes","Manage notes."],["normalize","Normalize tracker data."],["ops","Run operations."],["package","Manage packages."],["packages","Manage packages."],["pause-task","Pause task work."],["plan","Manage plans."],["profile","Manage profiles."],["reindex","Refresh search index."],["release","Release claim."],["remind","Manage reminders."],["restore","Restore history."],["schema","Customize schema."],["search","Search work."],["search-advanced","Run advanced search."],["start-task","Start task work."],["stats","Show stats."],["telemetry","Manage telemetry."],["templates","Manage work templates."],["test","Run linked tests."],["test-all","Run all linked tests."],["test-runs","Inspect background test runs."],["todos","Manage source-code todos."],["twin","Manage repository twins."],["update","Update work."],["update-many","Update matching work."],["upgrade","Upgrade packages."],["validate","Validate data."],["vcs","Inspect version-control context."],["workspace","Manage workspaces."],["history-author-acknowledge","Acknowledge reviewed history authors."],["history-compact","Compact history."],["history-attest","Export or verify detached history proof."],["history-redact","Redact sensitive history values."],["history-repair","Repair history integrity."]]),ce=[["init",wt],["install",xt],["uninstall",Gt],["explore",Mt],["manage",Ft],["describe",Lt],["reload",bt],["doctor",vt],["catalog",Et],["adopt",Nt],["adopt-all",yt],["activate",St],["deactivate",Rt],["migrate",kt]],Aa=[...ce.map(([e,t])=>e==="init"?[e,on]:[e,t]),["upgrade",V]],ga=[...ce.map(([e,t])=>[`extension ${e}`,t]),...Aa.flatMap(([e,t])=>[[`package ${e}`,t],[`packages ${e}`,t]]),["init",Ht],["config",ut],["extension",It],["package",W],["packages",W],["install",zt],["create",At],["item mutate",Qt],["item complete",Jt],["item reopen",Zt],["copy",pt],["focus",Dt],["update",Dn],["update-many",Un],["upgrade",V],["calendar",q],["cal",q],["context",B],["ctx",B],["get",$t],["search",Ln],["eval",Nn],["events",En],["workspace",T],["workspace position",[]],["workspace snapshot",T],["workspace snapshot create",T],["workspace snapshot list",T],["workspace snapshot inspect",T],["workspace snapshot restore",T],["workspace snapshot delete",T],["next",Rn],["aggregate",tt],["deps",Tt],["graph",Ot],["guide",jt],["reindex",gn],["history",Wt],["history-compact",Xt],["history-attest",qn],["history-redact",Vt],["history-repair",Kt],["history-author-acknowledge",Yt],["merge",an],["schema",hn],["profile",Sn],["plan",_n],["restore",On],["delete",gt],["close",ct],["close-many",lt],["append",at],["claim",ot],["release",Tn],["start-task",In],["pause-task",wn],["close-task",rt],["comments",it],["notes",sn],["learnings",en],["files",Pt],["docs",ht],["test",kn],["test-runs-worker",[]],["test-all",Fn],["telemetry",xn],["test-runs",bn],["gc",Ut],["stats",vn],["ops",[]],["duplicates",Mn],["validate",$n],["health",Bt],["assurance",nt],...Bn,["contracts",mt],["completion",dt],["activity",et],...[...ne].map(e=>[e,nn])],E=new Map(ga);for(const{alias:e,canonical:t}of O){const n=E.get(e);n!==void 0&&E.set(t,n)}function le(e){const t=oe.get(e);return t||(e.startsWith("test-runs ")?`test-runs-${e.slice(10)}`:e.startsWith("templates ")?`templates-${e.slice(10)}`:e)}function x(e){const t=O.find(n=>n.alias===e);return t?`${t.canonical}|${t.alias}`:X.includes(e)?p(e):e.startsWith("extension-")?p(`extension ${e.slice(10)}`):e.startsWith("package-")?p(`package ${e.slice(8)}`):e.startsWith("item-")?p(`item ${e.slice(5)}`):e.startsWith("test-runs-")?p(`test-runs ${e.slice(10)}`):e.startsWith("templates-")?p(`templates ${e.slice(10)}`):L.has(e)?se.get(e)??p(e):null}function de(e,t){const n=d(t);return n!==t||O.some(s=>s.alias===t)?e.action===n:e.command_path===null?!1:A(e.command_path).some(s=>s===t?!0:s.startsWith(`${t} `)||t.startsWith(`${s} `))}function A(e){return e.split("|").map(t=>p(t)).filter(t=>t.length>0)}function ue(e,t){const n=new Set(t),s=new Set;for(const a of e)if(a.command_path)for(const o of A(a.command_path)){const r=o.split(" ").filter(i=>i.length>0);if(r.length!==0)for(let i=r.length;i>0;i-=1){const c=r.slice(0,i).join(" ");if(n.has(c)){s.add(c);break}}}return[...s].sort((a,o)=>a.localeCompare(o))}function v(e){if(typeof e!="string")return;const t=e.trim().toLowerCase();return t.length>0?t:void 0}function N(e){const t=e.oneOf;return Array.isArray(t)?t.filter(n=>typeof n=="object"&&n!==null):[]}function me(e,t){if(!t)return{...e};const s=N(e).filter(a=>{const o=a.properties;if(typeof o!="object"||o===null)return!1;const r=o.action;return typeof r!="object"||r===null?!1:r.const===t});return{...e,oneOf:s}}function M(e,t){const s=N(e).filter(a=>{const o=a.properties;if(typeof o!="object"||o===null)return!1;const r=o.action;if(typeof r!="object"||r===null)return!1;const i=r.const;return typeof i=="string"&&t.has(i)});return{...e,oneOf:s}}function p(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function F(e){return e.replace(/\s+/g,"-")}function g(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function pe(e){if(!Array.isArray(e))return[];const t=[],n=new Set;for(const s of e){const a=g(s);!a||n.has(a)||(n.add(a),t.push(a))}return t}function k(e,t,n){n&&(e[t]=!0)}function b(e,t){if(e==null)return null;if(typeof e!="string")throw new TypeError("Expected string for extension flag name.");const n=e.trim();return n.length===0?null:t==="long"?n.startsWith("--")&&n.length>2?$e(n):null:n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function Ta(e){const t=b(e.long,"long"),n=b(e.short,"short"),s=t??n;if(!s)return null;const a={flag:s};n&&t&&(a.short=n),k(a,"required",e.required===!0),k(a,"repeatable",e.repeatable===!0),k(a,"list",e.list===!0),e.default!==void 0&&(a.default=e.default);const o=g(e.description);o&&(a.description=o);const r=Ue(e);a.value_arity=r.value_arity;const i=g(e.value_name)??r.value_name;i&&(a.value_name=i);const c=r.value_type??(r.value_name?"string":null);return c&&(a.value_type=c),a}function G(e){const t=new Map;for(const s of e){const a=p(s.target_command);if(a.length===0)continue;const o=t.get(a)??{flags:[],sources:[],dedupe:new Set,sourceDedupe:new Set},r=`${s.layer}:${s.name}`;o.sourceDedupe.has(r)||(o.sourceDedupe.add(r),o.sources.push({layer:s.layer,name:s.name}));for(const i of s.flags){const c=Ta(i);if(!c)continue;const l=`${c.flag}|${c.short??""}`;o.dedupe.has(l)||(o.dedupe.add(l),o.flags.push(c))}t.set(a,o)}const n=new Map;for(const[s,a]of t.entries())n.set(s,{flags:a.flags,sources:a.sources.sort((o,r)=>{const i=o.layer.localeCompare(r.layer);return i!==0?i:(o.name??"").localeCompare(r.name??"")})});return n}function Oa(e,t){return e.read_output===void 0?{flags:t}:{read_output:e.read_output,flags:[...t,...Y.filter(({flag:n})=>n.startsWith("--output-"))]}}function _e(e){const t=G(e.flagRegistrations),n=new Map;for(const o of e.commandDefinitions){const r=p(o.command);if(r.length===0)continue;const i=g(o.action)??F(r),c=Array.isArray(o.arguments)?o.arguments.map(l=>{const u=g(l.name);return u?{name:u,required:l.required===!0,variadic:l.variadic===!0,description:g(l.description)}:null}).filter(l=>l!==null):[];n.set(r,{...o.tier===void 0?{}:{tier:o.tier},...Oa(o,t.get(r)?.flags??[]),command:r,action:i,source:{layer:o.layer,name:o.name},description:g(o.description),intent:g(o.intent),arguments:c,examples:pe(o.examples),failure_hints:pe(o.failure_hints)})}const s=new Set;for(const o of e.handlers)s.add(p(o));for(const o of n.keys())s.add(o);for(const o of t.keys())s.add(o);const a=[];for(const o of[...s].sort((r,i)=>r.localeCompare(i))){const r=n.get(o);a.push(ha(o,r,t.get(o)?.flags??[]))}return a}function ha(e,t,n){return t?{...t,flags:t.flags.length>0?t.flags:n}:{command:e,action:F(e),source:null,description:null,intent:null,arguments:[],flags:n,examples:[],failure_hints:[]}}function fe(e){const t=e.flag.startsWith("--")?e.flag:void 0,n=J({long:t,short:t===void 0?e.flag:void 0});return n!==null&&/[a-z0-9]/iu.test(n)?n:null}function Sa(e,t){return e.variadic?{type:"array",items:{type:"string"},description:e.description??`Variadic argument '${e.name}' for extension action '${t}'.`}:{type:"string",description:e.description??`Argument '${e.name}' for extension action '${t}'.`}}function ya(e,t){const n=e.value_type??"boolean",s=n==="boolean"?"boolean":n==="number"?["number","string"]:"string",a=e.repeatable===!0||e.list===!0;return{type:a?"array":s,...a?{items:{type:s}}:{},...e.default!==void 0?{default:e.default}:{},description:e.description??`Extension option '${e.flag}' for action '${t}'.`}}function Ce(e){const t=e.command.split("|").map(a=>a.trim()).filter(a=>a.length>0),n={action:{type:"string",const:e.action,description:e.intent??e.description??`Invoke extension command '${e.command}'.`}},s=["action"];for(const a of e.arguments)n[a.name]=Sa(a,e.action),a.required&&s.push(a.name);for(const a of e.flags){const o=fe(a);!o||n[o]!==void 0||(n[o]=Y.some(r=>r.flag===a.flag&&r.flag.startsWith("--output-"))?De[o]:ya(a,e.action),a.required===!0&&s.push(o))}return{type:"object",properties:n,required:s,additionalProperties:!0,"x-extension-source":e.source,"x-extension-command":t[0]??e.command,"x-extension-commands":t}}function Na(e,t){e.description??=t.description,e.value_name??=t.value_name,e.value_type??=t.value_type,t.required===!0&&(e.required=!0),t.repeatable===!0&&(e.repeatable=!0)}function Ae(e){const t=new Map;for(const n of e){const s=t.get(n.action);if(!s){t.set(n.action,{...n,flags:[...n.flags],examples:[...n.examples],failure_hints:[...n.failure_hints]});continue}s.command=[...new Set([s.command,n.command])].sort((o,r)=>o.localeCompare(r)).join("|"),s.arguments=s.arguments.length>=n.arguments.length?s.arguments:n.arguments;const a=new Set(s.flags.map(o=>`${o.flag}|${o.short??""}`));for(const o of n.flags){const r=`${o.flag}|${o.short??""}`;if(!a.has(r))a.add(r),s.flags.push(o);else{const i=s.flags.find(c=>`${c.flag}|${c.short??""}`===r);i&&Na(i,o)}}s.examples=[...new Set([...s.examples,...n.examples])],s.failure_hints=[...new Set([...s.failure_hints,...n.failure_hints])]}return[...t.values()].sort((n,s)=>n.action.localeCompare(s.action))}async function ge(e,t=j){const n={mode:R.extensions.policy.mode,trust_mode:R.extensions.policy.trust_mode,default_sandbox_profile:R.extensions.policy.default_sandbox_profile};if(e.noExtensions)return{handlers:new Set,disabledReason:"extensions_disabled",commandDefinitions:[],flagRegistrations:[],registrations:null,policyState:n};const s=$(process.cwd(),e.path);if(!await We(He(s)))return{handlers:new Set,disabledReason:null,commandDefinitions:[],flagRegistrations:[],registrations:null,policyState:n};try{const a=await t(s),o=await Be({pmRoot:s,settings:a,cwd:process.cwd(),noExtensions:!1}),r=await je({...o,loaded:o.loaded});return{handlers:new Set(r.commands.handlers.map(c=>p(c.command))),disabledReason:null,commandDefinitions:r.registrations.commands,flagRegistrations:r.registrations.flags,registrations:r.registrations,policyState:{mode:o.policy.mode,trust_mode:o.policy.trust_mode,default_sandbox_profile:o.policy.default_sandbox_profile}}}catch{return{handlers:new Set,disabledReason:"extension_runtime_probe_failed",commandDefinitions:[],flagRegistrations:[],registrations:null,policyState:n}}}function Te(e,t={}){const n=new Map;for(const s of Cn){const a=L.has(s);if(a&&!t.includePackageOwnedActions)continue;const o=x(s);n.set(s,{action:s,provider:a?"extension":"core",requires_extension:a,command_path:o})}if(t.includePackageOwnedActions)for(const s of L)n.has(s)||n.set(s,{action:s,provider:"extension",requires_extension:!0,command_path:x(s)});for(const s of e)n.has(s.action)||n.set(s.action,{action:s.action,provider:"extension",requires_extension:!0,command_path:O.find(a=>a.alias===s.command)?.canonical??p(s.command)});return[...n.values()].sort((s,a)=>(s.action??"").localeCompare(a.action??""))}function Oe(e,t){if(e.provider==="core"&&!e.requires_extension)return{action:e.action,invocable:!0,available:!0,requires_extension:!1,provider:"core",disabled_reason:null,command_path:e.command_path,cli_exposed:e.command_path!==null&&(!h.has(e.action)||t.handlers.has(e.action))};const n=e.command_path?A(e.command_path):[],s=n.some(r=>t.handlers.has(r)||t.handlers.has(d(r))),a=n.map(r=>ae.get(d(r))).find(r=>typeof r=="string"),o=t.disabledReason===null&&s;return{action:e.action,invocable:o,available:o,requires_extension:!0,provider:"extension",disabled_reason:o?null:t.disabledReason??(a?`optional_package_not_installed:${a}`:"extension_command_not_registered"),command_path:e.command_path,cli_exposed:s,policy_state:{mode:t.policyState.mode,trust_mode:t.policyState.trust_mode,default_sandbox_profile:t.policyState.default_sandbox_profile}}}function P(e){const t=E.get(e)??qt,n=Xn(e).find(s=>s.flag==="--output-format"&&s.aliases?.includes("--format"));return n?[...t,n]:t}function he(e){return h.has(d(e))?!1:E.has(e)}function Se(e){return ne.has(e)?"list":e==="cal"?"calendar":e==="ctx"?"context":e==="update-many"?"update_many":e}function D(e){const t=e.trim();return t?t.startsWith("--")?t:t.startsWith("-")?null:`--${t}`:null}function ye(e){const t=e.trim();return!t||t.startsWith("--")?null:t.startsWith("-")?t:null}function Ne(e){const t=new Map;for(const s of e.definitions){const a=D(s.cli_flag);if(!a)continue;const o=s.cli_aliases.map(i=>ye(i)).find(i=>i!==null),r=s.cli_aliases.map(i=>D(i)).filter(i=>i!==null&&i!==a);for(const i of s.commands){const c=t.get(i)??{flags:[],seen:new Set},l=o?{flag:a,short:o}:{flag:a},u=`${l.flag}|${l.short??""}`;c.seen.has(u)||(c.seen.add(u),c.flags.push(l));for(const m of r){const _=`${m}|`;c.seen.has(_)||(c.seen.add(_),c.flags.push({flag:m}))}t.set(i,c)}}const n=new Map;for(const[s,a]of t.entries())n.set(s,K(a.flags));return n}function Ee(e,t){const n=[],s=new Set;for(const a of[...e,...t]){const o=`${a.flag}|${a.short??""}`;s.has(o)||(s.add(o),n.push(a))}return K(n)}function Re(e){const t=J(e.flag.startsWith("--")?{long:e.flag}:{short:e.flag});return{...e,owner:"extension",...t===null?{}:{sdk_option:t}}}function Ea(e,t,n,s){const a=(n??[]).map(Re),o=t==="extension"&&(n!==void 0||Ra(e,s));return{flags:a,inherited:o?{inherited_flags:Wn({readOutput:La(e,s)})}:{}}}function Le(e,t){const n=d(e);return t.find(s=>d(s.command)===n)}function Ra(e,t){return Le(e,t)!==void 0}function La(e,t){return Le(e,t)?.read_output!==void 0}function va(e,t,n,s,a){const o=new Map(t);for(const{alias:r,canonical:i}of O){const c=t.get(i)??t.get(r);c&&(o.set(r,c),o.set(i,c))}return e.map(r=>{const i=he(r),c=i?P(r):[],l=n.get(Se(r))??[],u=o.get(r),m=Ee(c,l),_=c.length>0&&(u?.flags.length??0)>0?"mixed":i?"core":"extension",C=Ea(r,_,u?.flags,a),U=Ee(m,C.flags);return{command:r,flags:U,...C.inherited,...s?{canonical_command:ke(r),visibility:Fe(r,a),positionals:pa(r)?.slots??[],flag_invocations:aa(r,U)}:{},provider:_,extension_sources:u?.sources}}).sort((r,i)=>r.command.localeCompare(i.command))}function Ma(e,t=z){const n=new Set(e),s=new Map;for(const a of re){const o=a.aliases.filter(r=>n.has(r));s.set(a.canonical,{canonical:a.canonical,aliases:o,contracts:[]})}for(const a of t){if(!n.has(a.canonical)||a.registration==="commander"&&!n.has(a.alias))continue;const o=s.get(a.canonical)??{canonical:a.canonical,aliases:[],contracts:[]};o.aliases.includes(a.alias)||o.aliases.push(a.alias),o.contracts.push(a),s.set(a.canonical,o)}return[...s.values()].map(({contracts:a,...o})=>a.length===0?o:{...o,contracts:a}).sort((a,o)=>a.canonical.localeCompare(o.canonical))}function Ia(){return{create_string_options:Ct,create_repeatable_options:ft,update_string_options:Pn,update_repeatable_options:Gn,list_string_options:tn,search_string_options:yn,calendar_string_options:st,context_string_options:_t,activity_string_options:Ze}}function ve(e,t){const n=new Set(["title","type"]);if(t==="strict"){for(const i of e.required_create_fields)n.add(i);for(const i of e.required_create_repeatables)n.add(i)}const s=Ve(e,"create",n),a=[...new Set(s.required)].sort((i,c)=>i.localeCompare(c)),o=[...new Set(a.map(i=>Xe("create",i)))].sort((i,c)=>i.localeCompare(c)),r=[...new Set(e.options.filter(i=>i.required===!0).map(i=>i.key))].sort((i,c)=>i.localeCompare(c));return{required_option_keys:a,required_flags:o,required_type_options:r,policy_errors:[...new Set(s.errors)].sort((i,c)=>i.localeCompare(c))}}function wa(e){const t={},n={};for(const s of[...e.types].sort((a,o)=>a.localeCompare(o))){const a=e.by_type[s];t[s]=ve(a,"strict"),n[s]=ve(a,"progressive")}return{default_create_mode:"strict",by_create_mode:{strict:{by_type:t},progressive:{by_type:n}}}}function Me(e,t){const n=N(e);if(n.length===0)return e;let s=!1;const a=n.map(o=>{const r=o.properties;if(typeof r!="object"||r===null)return o;const i=r.action;return typeof i!="object"||i===null||i.const!=="create"?o:(s=!0,{...o,"x-create-required-options":t})});return s?{...e,oneOf:a}:e}function xa(e){const t=v(e.action)!==void 0||v(e.command)!==void 0,n=e.schemaOnly===!0||e.flagsOnly===!0||e.availabilityOnly===!0,s=e.summary===!0||e.full!==!0&&e.runtimeOnly!==!0&&!t&&!n,a=e.schemaOnly===!0,o=e.flagsOnly===!0,r=e.availabilityOnly===!0,i=e.runtimeOnly===!0,c=e.full===!0,l=v(e.action),u=v(e.command),m=!s&&!c&&!a&&!o&&!r&&!l&&!u;return{selectedAction:l,selectedCommand:u,summary:s,schemaOnly:a,flagsOnly:o,availabilityOnly:r,runtimeOnly:i,fullOutput:c,omitUnfilteredSchema:m,omitUnfilteredCommandFlags:m,omitUnfilteredCommanderAliases:m||u!==void 0&&!c}}function Fa(e){if([e.summary,e.schemaOnly,e.flagsOnly,e.availabilityOnly].filter(n=>n).length>1)throw new S("Choose only one projection flag: --summary, --schema-only, --flags-only, or --availability-only.",f.USAGE)}async function Ie(e,t=j){try{return await t(e)}catch{return structuredClone(R)}}async function ka(e,t,n){const s=await Ie(t),a=await ge(e),o=Ke(s,a.registrations??qe()),r=Ye(s.schema),i=_e(a);return{settings:s,runtimeProbe:a,typeRegistry:o,statusRegistry:ze(s.schema),runtimeFieldRegistry:r,runtimeFieldFlagMap:Ne(r),createRequiredOptionContracts:wa(o),extensionContracts:i,mergedExtensionContracts:Ae(i.filter(c=>I(n,c.command,i))),extensionFlagMap:G(a.flagRegistrations)}}function we(e){return e.availabilityOnly&&(e.selectedAction!==void 0&&L.has(e.selectedAction)||e.selectedCommand!==void 0&&h.has(d(e.selectedCommand)))}function ba(e,t){const n=Te(t,{includePackageOwnedActions:we(e)});if(e.selectedAction===void 0&&e.selectedCommand===void 0){const s=new Set(fn);return n.filter(a=>!s.has(a.action)&&(e.fullOutput||(t.find(o=>o.action===a.action)?.tier??Q(a.action))!=="internal"))}return we(e)&&e.selectedCommand!==void 0&&h.has(d(e.selectedCommand))&&!n.some(s=>s.command_path===e.selectedCommand)&&n.push({action:le(d(e.selectedCommand)),provider:"extension",requires_extension:!0,command_path:e.selectedCommand}),n}function Ga(e,t){const n=new Set(t.map(s=>s.action));if(e.selectedAction&&!n.has(e.selectedAction))throw new S(`Unknown action: "${e.selectedAction}".`,f.USAGE)}function Pa(e,t){return[...new Set([...X.filter(n=>!h.has(d(n))),...[...E.keys()].filter(n=>!h.has(d(n))),...e.flatMap(n=>n.command_path?A(n.command_path).filter(s=>n.provider==="extension"||!h.has(d(s))||t.some(a=>a.action===n.action)):[]),...t.flatMap(n=>n.command.split("|").flatMap(s=>{const a=O.find(o=>o.alias===s||o.canonical===s);return a===void 0?[s]:[a.alias,a.canonical]}))])].map(n=>p(n)).filter(n=>n.length>0).sort((n,s)=>n.localeCompare(s))}function Da(e,t){const n=t.slice(0,fa),s=t.length-n.length,a=s>0?`${n.join(", ")}, and ${s} more`:n.join(", "),o=t.slice(0,Ca),r=t.slice(0,5).map(c=>`pm contracts --command "${c}" --flags-only --json`),i=t[0];return new S(`Command "${e}" is a command namespace. Choose a concrete child command: ${a}.`,f.USAGE,{code:"command_namespace",required:"Use a concrete child command path listed under this namespace.",why:"Command groups expose help at the namespace root, but command flag contracts belong to executable child commands.",examples:r,nextSteps:[`Retry with a child command, for example: ${r[0]}`],recovery:{suggested_retry:`pm contracts --command "${i}" --flags-only --json`,fallback_candidates:o.map(c=>({source:"command_namespace",command:`pm contracts --command "${c}" --flags-only --json`,reason:`Child command under ${e}`}))}})}function Ua(e,t){return new S(`Unknown command: "${e}". Command "${e}" is provided by the optional "${t}" package. Run "pm package install ${t} --project" and retry.`,f.USAGE,{code:"unknown_command",required:`Install the optional "${t}" package, or choose a command from pm contracts --flags-only --json.`,why:"Command contracts include core commands plus commands registered by active packages and extensions.",examples:[`pm package install ${t} --project`,`pm contracts --command ${e} --flags-only --json`],nextSteps:[`Install the optional package first: pm package install ${t} --project`],recovery:{suggested_retry:`pm package install ${t} --project`}})}function $a(e){return new S(`Unknown command: "${e}".`,f.USAGE,{code:"unknown_command",required:"Use a command path listed by pm contracts --flags-only --json.",why:"Command contracts are generated from the active core, package, and extension command registry.",examples:["pm contracts --flags-only --json","pm --help"],nextSteps:["Verify spelling and active packages/extensions, then rerun with a known command path."],recovery:{suggested_retry:"pm contracts --flags-only --json"}})}function ja(e,t){if(!e.selectedCommand||new Set(t).has(e.selectedCommand))return;const s=t.filter(o=>o.startsWith(`${e.selectedCommand} `));if(s.length>0)throw Da(e.selectedCommand,s);const a=ae.get(d(e.selectedCommand));throw a?Ua(e.selectedCommand,a):$a(e.selectedCommand)}function qa(e,t){const n=ba(e,t.mergedExtensionContracts);Ga(e,n);const s=Pa(n,t.mergedExtensionContracts);ja(e,s);const a=e.selectedCommand?oe.get(d(e.selectedCommand)):void 0,o=e.selectedCommand?n.filter(l=>a?l.action===a:de(l,e.selectedCommand)):n;if(e.selectedCommand&&e.selectedAction&&!o.some(l=>l.action===e.selectedAction))throw new S(`Action "${e.selectedAction}" is not mapped to command "${e.selectedCommand}" in contracts output.`,f.USAGE);const r=e.selectedAction?o.filter(l=>l.action===e.selectedAction):o,i=[...new Map(r.map(l=>Oe(l,t.runtimeProbe)).map(l=>[a?l.action:`${l.action}|${l.command_path??""}`,l])).values()],c=e.runtimeOnly&&!e.selectedAction&&!e.availabilityOnly?i.filter(l=>l.invocable):i;return{actionDescriptors:n,commandCatalog:s,commandScopedDescriptors:o,scopedActionDescriptors:r,selectedPackageOwnedAction:a,actionAvailability:c,actions:[...new Set(c.map(l=>l.action))]}}function Ba(e){return new Set(N(e).map(t=>{const n=t.properties;if(typeof n!="object"||n===null)return null;const s=n.action;if(typeof s!="object"||s===null)return null;const a=s.const;return typeof a=="string"?a:null}).filter(t=>t!==null))}function Wa(e){const t=An,n=N(t),s=Ba(t),a=e.filter(o=>!s.has(o.action)).map(o=>Ce(o));return a.length>0?{...t,oneOf:[...n,...a]}:t}function xe(e,t,n){const s=new Set(t.actionDescriptors.map(o=>o.action)),a=e.selectedAction?me(n,e.selectedAction):e.selectedCommand?M(n,new Set(t.scopedActionDescriptors.map(o=>o.action))):M(n,s);return e.runtimeOnly&&!e.selectedAction?M(a,new Set(t.actions)):a}function Xa(e,t,n){const s=Wa(t.mergedExtensionContracts),o=!e.flagsOnly&&!e.availabilityOnly?Me(xe(e,n,s),t.createRequiredOptionContracts):xe(e,n,s);return{mergedSchema:s,filteredSchema:o}}function Va(e,t){return e.selectedCommand!==void 0?[e.selectedCommand]:e.selectedAction?ue(t.scopedActionDescriptors,t.commandCatalog):t.commandCatalog}function Fe(e,t){return t.find(n=>d(n.command)===d(e))?.tier??Q(e)}function I(e,t,n){return e.fullOutput||e.selectedCommand!==void 0||e.selectedAction!==void 0||Fe(t,n)!=="internal"}function Ka(e,t,n){if(e.selectedCommand!==void 0||e.selectedAction!==void 0)return t;const s=new Set(z.filter(a=>a.hidden&&(a.lifecycle==="deprecated"||!e.fullOutput&&!e.availabilityOnly)).map(a=>a.alias));if(e.summary&&!e.fullOutput)for(const a of w.keys())s.add(a);return t.filter(a=>!s.has(a)&&I(e,a,n))}function ke(e){const t=O.find(s=>s.alias===e||s.canonical===e);if(t)return t.canonical;const n=e.split(" ")[0];return n.startsWith("list-")?"list":w.get(n)??n}const Ya=new Map([["activate","Activate"],["adopt","Adopt"],["adopt-all","Adopt all"],["catalog","Catalog"],["complete","Complete"],["create","Create"],["deactivate","Deactivate"],["delete","Delete"],["describe","Describe"],["doctor","Diagnose"],["explore","Explore"],["init","Initialize"],["inspect","Inspect"],["install","Install"],["list","List"],["manage","Manage"],["migrate","Migrate"],["mutate","Mutate"],["reload","Reload"],["restore","Restore"],["run","Run"],["snapshot","Manage snapshots for"],["uninstall","Uninstall"],["upgrade","Upgrade"]]),za=new Map([["extension adopt-all","extensions"],["package adopt-all","packages"],["workspace snapshot list","workspace snapshots"]]);function Ha(e,t){const n=ie.get(d(e))??(e.includes(" ")?void 0:ie.get(ke(e)));if(n!==void 0)return{intent:n,intent_source:"command"};const s=t.find(l=>A(l.command).some(u=>d(u)===d(e)));if(s?.intent!==null&&s?.intent!==void 0)return{intent:s.intent,intent_source:"command"};if(s?.description!==null&&s?.description!==void 0)return{intent:s.description,intent_source:"description"};const a=e.split(" "),o=a.at(-1),r=a.slice(0,-1).join(" "),i=Ya.get(o),c=za.get(e)??r;return{intent:i===void 0||r.length===0?`Run ${e}.`:`${i} ${c}.`,intent_source:"generated"}}function be(e,t=[],n={}){const s=n.includeFormatBudgets??!0,a=n.includeIntentProvenance??!0;return[...new Set(e.map(p))].filter(o=>o.length>0).sort((o,r)=>o.localeCompare(r)).map(o=>{const r=H(o,{generateFallback:!0}),i=o.split(" ")[0],c=w.get(i)??(i.startsWith("list-")?"list":i.startsWith("history-")?"history":i),l=new Set([...P(o).map(_=>_.flag),...t.filter(_=>A(_.command).some(C=>d(C)===d(o))).flatMap(_=>_.flags.map(C=>C.flag))]),u=(te.get(d(o))??te.get(c)??_a).filter(_=>l.has(_)),m=Ha(o,t);return{command:o,intent:m.intent,...a||m.intent_source!=="command"?{intent_source:m.intent_source}:{},...u.length>0?{flags:u}:{},default_max_estimated_tokens:r.default_max_estimated_tokens,...s?{default_max_estimated_tokens_by_format:{...r.default_max_estimated_tokens_by_format}}:{}}})}function Ge(e){return e.map(t=>({budget:H(t,{generateFallback:!0}),envelope:oa(t)}))}function Pe(e){const t=new Map;for(const n of e){const s=ia(n),a=s===void 0?[f.SUCCESS,f.GENERIC_FAILURE,f.USAGE,f.NOT_FOUND,f.CONFLICT,f.DEPENDENCY_FAILED]:s.exit_codes,o=a.join(","),r=t.get(o)??{commands:[],exit_codes:a};r.commands.push(n),t.set(o,r)}return[...t.values()]}function Ja(e,t,n){if(e.selectedCommand)return t.extensionContracts.filter(s=>A(s.command).some(a=>d(a)===d(e.selectedCommand)));if(e.selectedAction){const s=new Set(n);return t.extensionContracts.filter(a=>A(a.command).some(o=>s.has(o)))}return t.extensionContracts.filter(s=>I(e,s.command,t.extensionContracts))}function Qa(e,t,n,s){return{schema_version:typeof t.mergedSchema["x-schema-version"]=="string"?t.mergedSchema["x-schema-version"]:null,schema_id:typeof t.mergedSchema.$id=="string"?t.mergedSchema.$id:null,selected:{action:e.selectedAction??null,command:e.selectedCommand??null,summary:e.summary,schema_only:e.schemaOnly,flags_only:e.flagsOnly,availability_only:e.availabilityOnly,runtime_only:e.runtimeOnly,command_scoped:e.selectedCommand!==void 0},commands:e.summary?[]:s,...!e.summary&&!e.flagsOnly?{actions:n.actions,action_availability:n.actionAvailability}:{}}}function Za(e,t,n){(n.selectedCommand==="history"||n.fullOutput)&&!n.flagsOnly&&!n.schemaOnly&&!n.availabilityOnly&&(e.history_operations=Je);const s=n.selectedCommand;e.runtime_schema={statuses:t.statusRegistry.definitions.map(a=>a.id),open_status:t.statusRegistry.open_status,close_status:t.statusRegistry.close_status,canceled_status:t.statusRegistry.canceled_status,types:[...t.typeRegistry.types],fields_by_command:Object.fromEntries([...t.runtimeFieldRegistry.command_to_fields.entries()].filter(([a])=>s===void 0||a===s).map(([a,o])=>[a,[...new Set(o.map(r=>`--${r.cli_flag}`))].sort((r,i)=>r.localeCompare(i))]))},!(s!==void 0&&!n.fullOutput)&&(e.extension_contracts={capabilities:[...rn],services:[...un],policy_modes:[...cn],policy_mode_scope:"extensions.policy.mode",policy_surfaces:[...ln],trust_modes:[...mn],trust_mode_scope:"extensions.policy.trust_mode",sandbox_profiles:[...dn],manifest_versions:[1,2],compatibility:{current:"v2",previous:["v1"],breaking_strategy:"versioned_breaking"}},e.governance_contracts={ownership_enforcement_modes:[...Yn],create_modes:[...Kn],close_validation_modes:[...Vn],workflow_enforcement_modes:[...zn]},e.relationship_kind_contracts=[...ca,...(t.runtimeProbe.registrations?.relationship_kinds??[]).flatMap(a=>a.definitions)].sort((a,o)=>a.kind.localeCompare(o.kind)).map(a=>({canonical:a.kind,aliases:[...a.aliases??[]],...a.inverse===void 0?{}:{inverse:a.inverse},ordering:a.ordering,hierarchy:a.hierarchy})))}function es(e,t,n,s){if(!(t.flagsOnly||t.availabilityOnly)){if(!t.omitUnfilteredSchema){e.schema=n.filteredSchema,e.extension_commands=s;return}e.schema_omitted_reason="unfiltered_default_brief",e.extension_commands=s}}function ts(e,t,n,s,a){if(!(t.schemaOnly||t.availabilityOnly)){if(t.omitUnfilteredCommandFlags)e.command_flags_omitted_reason="unfiltered_default_brief";else{e.command_flags=va(s,n.extensionFlagMap,n.runtimeFieldFlagMap,t.selectedCommand!==void 0,n.extensionContracts);const o=new Set(s);e.list_projections=Object.entries(Qn).filter(([r])=>o.has(r)).map(([r,i])=>({command:r,default:i,brief_fields:[...Hn,"priority"],compact_fields:[...Jn]}))}e.command_aliases=t.fullOutput?a:a.map(({canonical:o,aliases:r})=>({canonical:o,aliases:r})),t.fullOutput||(e.command_alias_contracts_omitted_reason="compact_projection; restore with --full")}}function ns(e,t){if(!(t.schemaOnly||t.flagsOnly||t.availabilityOnly)){if(!t.omitUnfilteredCommanderAliases){e.commander_aliases=Ia();return}e.commander_aliases_omitted_reason=t.selectedCommand?"command_scoped":"unfiltered_default_brief"}}function as(e,t,n,s){e.command_summaries=be(t,n,{includeFormatBudgets:s.includeFormatBudgets,includeIntentProvenance:s.includeIntentProvenance}),e.output_policy={token_estimate:"ceil(utf8_bytes / 4)",degradation_ladder:[...pn],allows_unbounded_opt_out:!0},e.output_projection_contracts={global_ladder_field:"output_policy.degradation_ladder",global_ladder_scope:"union_not_per_command",discovery:"pm contracts --command <command> --summary",...s.includeProjectionModeMatrix?{commands:[...new Set(t.map(p))].filter(a=>ta(a)!==void 0).sort((a,o)=>a.localeCompare(o)).map(a=>({command:a,modes:[...ea(a).keys()]}))}:{}},e.grammar_contracts={nouns:y.nouns,shared_verbs:y.shared_verbs,scope_before_verb:y.scope_before_verb,visible_top_level_ceiling:y.visible_top_level_ceiling,ceiling_raise_requires_pm_item:y.ceiling_raise_requires_pm_item,positional_shape_budget:y.positional_shape_budget,positional_shape_count:new Set(Z.map(({slots:a})=>ma(a))).size,positional_action_count:ee.length,positional_action_parents:[...new Set(ee.map(({parent:a})=>a))].sort((a,o)=>a.localeCompare(o)),...s.includePositionalSignatures?{positional_signatures:Z}:{}}}async function Ns(e,t){const n=xa(e);Fa(n);const s=$(process.cwd(),t.path),a=await ka(t,s,n),o=qa(n,a),r=Xa(n,a,o),i=Va(n,o),c=Ka(n,i,a.extensionContracts),l=Qa(n,r,o,c),u=Ja(n,a,c),m=n.fullOutput||n.selectedCommand!==void 0;if((n.summary||n.fullOutput)&&as(l,c,u,{includeFormatBudgets:m,includeIntentProvenance:m,includePositionalSignatures:m,includeProjectionModeMatrix:m}),n.summary)return l;const _=Ma(o.commandCatalog.filter(C=>I(n,C,a.extensionContracts)));return n.flagsOnly&&!n.fullOutput||Za(l,a,n),es(l,n,r,u),ts(l,n,a,c,_),ns(l,n),(n.selectedCommand==="assurance"||n.fullOutput)&&(l.assurance_contracts={measurement_source_kinds:[...da],gate_triggers:[...la]}),n.fullOutput&&l.grammar_contracts&&(l.grammar_contracts.destinations=ua.map(C=>({...C,reason:C.reason??""}))),n.fullOutput&&!n.schemaOnly&&!n.flagsOnly&&!n.availabilityOnly&&(l.mcp_tools=Qe(),l.context_intents=Zn(),l.read_output_dimensions=na,l.error_codes=sa,l.command_output_contracts=Ge(c),l.diagnostic_output_contracts=jn,l.command_exit_contracts={vocabulary:ra,command_sets:Pe(c)}),l}const Es={actionDescriptorMatchesSelectedCommand:de,attachCreateRequiredOptionContracts:Me,buildExtensionActionSchemaBranch:Ce,buildCommandSummarySurface:be,buildCommandOutputContracts:Ge,buildCommandExitContractGroups:Pe,buildRuntimeFieldFlagContracts:Ne,collectActionContractDescriptors:Te,collectExtensionCommandContracts:_e,collectExtensionFlagContractsByCommand:G,extractActionBranches:N,extensionSchemaPropertyNameFromFlag:fe,withExtensionFlagOwnership:Re,filterSchemaByAction:me,filterSchemaByActions:M,isCoreCommandPath:he,mergeExtensionContractsByAction:Ae,normalizeExtensionFlagName:b,normalizeActionNameFromCommand:F,normalizeCommandForRuntimeFieldFlags:Se,normalizeCommandPath:p,packageOwnedActionForCommand:le,readContractsSettings:Ie,resolveActionCommandPath:x,resolveActionAvailability:Oe,resolveCoreCommandFlags:P,resolveRuntimeExtensionActionProbe:ge,resolveScopedCommandsFromActionDescriptors:ue,splitCommandPathAliases:A,toRuntimeLongFlagToken:D,toRuntimeShortFlagToken:ye};export{Es as _testOnlyContractsCommand,Ma as buildCommandAliasSurface,he as isCoreCommandPath,Ns as runContracts};
|
|
1
|
+
import{PM_TOOL_PARAMETER_PROPERTIES as Ue}from"./tool-parameter-tables.js";import{resolveExtensionFlagValueContract as $e,resolveExtensionLongFlagName as je,EXIT_CODE as f,SETTINGS_DEFAULTS as R,PmCliError as S,activateExtensions as qe,getActiveExtensionRegistrations as Be,loadExtensions as We,pathExists as Xe,commandOptionFlagLabel as Ve,resolveCommandOptionPolicyState as Ke,resolveItemTypeRegistry as Ye,resolveRuntimeFieldRegistry as ze,resolveRuntimeStatusRegistry as He,getSettingsPath as Je,resolvePmRoot as j,readSettings as q}from"../runtime-primitives.js";import{PM_HISTORY_OPERATION_CONTRACT as Qe}from"../../core/history/operation-contract.js";import{buildMcpToolContracts as Ze}from"../../mcp/tool-definitions.js";import{ACTIVITY_COMMANDER_STRING_OPTION_CONTRACTS as et,ACTIVITY_FLAG_CONTRACTS as tt,AGGREGATE_FLAG_CONTRACTS as nt,ASSURANCE_FLAG_CONTRACTS as at,APPEND_FLAG_CONTRACTS as st,CALENDAR_COMMANDER_STRING_OPTION_CONTRACTS as ot,CALENDAR_FLAG_CONTRACTS as B,CLAIM_FLAG_CONTRACTS as rt,CLOSE_TASK_FLAG_CONTRACTS as it,COMMENTS_FLAG_CONTRACTS as ct,CLOSE_FLAG_CONTRACTS as lt,CLOSE_MANY_FLAG_CONTRACTS as dt,COMPLETION_FLAG_CONTRACTS as ut,CONFIG_FLAG_CONTRACTS as mt,CONTRACTS_FLAG_CONTRACTS as pt,COPY_FLAG_CONTRACTS as _t,CONTEXT_COMMANDER_STRING_OPTION_CONTRACTS as ft,CONTEXT_FLAG_CONTRACTS as W,CREATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS as Ct,CREATE_COMMANDER_STRING_OPTION_CONTRACTS as At,CREATE_FLAG_CONTRACTS as gt,DELETE_FLAG_CONTRACTS as Tt,DEPS_FLAG_CONTRACTS as Ot,GRAPH_FLAG_CONTRACTS as ht,DOCS_FLAG_CONTRACTS as St,EXTENSION_ACTIVATE_FLAG_CONTRACTS as yt,EXTENSION_ADOPT_ALL_FLAG_CONTRACTS as Nt,EXTENSION_ADOPT_FLAG_CONTRACTS as Et,EXTENSION_CATALOG_FLAG_CONTRACTS as Rt,EXTENSION_DEACTIVATE_FLAG_CONTRACTS as Lt,EXTENSION_DESCRIBE_FLAG_CONTRACTS as vt,EXTENSION_DOCTOR_FLAG_CONTRACTS as Mt,EXTENSION_EXPLORE_FLAG_CONTRACTS as It,EXTENSION_INVENTORY_FLAG_CONTRACTS as L,EXTENSION_FLAG_CONTRACTS as wt,EXTENSION_INIT_FLAG_CONTRACTS as xt,EXTENSION_INSTALL_FLAG_CONTRACTS as Ft,EXTENSION_MANAGE_FLAG_CONTRACTS as kt,EXTENSION_MIGRATE_FLAG_CONTRACTS as bt,EXTENSION_RELOAD_FLAG_CONTRACTS as Gt,EXTENSION_UNINSTALL_FLAG_CONTRACTS as Pt,FILES_FLAG_CONTRACTS as Dt,FOCUS_FLAG_CONTRACTS as Ut,GC_FLAG_CONTRACTS as $t,GET_FLAG_CONTRACTS as jt,GUIDE_FLAG_CONTRACTS as qt,GLOBAL_FLAG_CONTRACTS as Bt,HEALTH_FLAG_CONTRACTS as Wt,HISTORY_FLAG_CONTRACTS as Xt,HISTORY_COMPACT_FLAG_CONTRACTS as Vt,HISTORY_REDACT_FLAG_CONTRACTS as Kt,HISTORY_REPAIR_FLAG_CONTRACTS as Yt,HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS as zt,INSTALL_FLAG_CONTRACTS as Ht,INIT_FLAG_CONTRACTS as Jt,ITEM_COMPLETE_FLAG_CONTRACTS as Qt,ITEM_MUTATE_FLAG_CONTRACTS as Zt,ITEM_REOPEN_FLAG_CONTRACTS as en,LEARNINGS_FLAG_CONTRACTS as tn,LIST_COMMANDER_STRING_OPTION_CONTRACTS as nn,LIST_FILTER_FLAG_CONTRACTS as an,MERGE_FLAG_CONTRACTS as sn,NOTES_FLAG_CONTRACTS as on,PACKAGE_FLAG_CONTRACTS as X,PACKAGE_INIT_FLAG_CONTRACTS as rn,PM_EXTENSION_CAPABILITY_CONTRACTS as cn,PM_EXTENSION_POLICY_MODE_CONTRACTS as ln,PM_EXTENSION_POLICY_SURFACE_CONTRACTS as dn,PM_EXTENSION_SANDBOX_PROFILE_CONTRACTS as un,PM_EXTENSION_SERVICE_NAME_CONTRACTS as mn,PM_EXTENSION_TRUST_MODE_CONTRACTS as pn,PM_OUTPUT_DEGRADATION_STEPS as _n,PLAN_FLAG_CONTRACTS as fn,PM_CORE_COMMAND_NAMES as V,PM_DEPRECATED_TOOL_ACTIONS as Cn,PM_TOOL_ACTIONS as An,PM_TOOL_PARAMETERS_SCHEMA as gn,REINDEX_FLAG_CONTRACTS as Tn,RELEASE_FLAG_CONTRACTS as On,RESTORE_FLAG_CONTRACTS as hn,SCHEMA_FLAG_CONTRACTS as Sn,PROFILE_FLAG_CONTRACTS as yn,SEARCH_COMMANDER_STRING_OPTION_CONTRACTS as Nn,EVAL_FLAG_CONTRACTS as En,EVENTS_FLAG_CONTRACTS as Rn,WORKSPACE_FLAG_CONTRACTS as T,NEXT_FLAG_CONTRACTS as Ln,SEARCH_FLAG_CONTRACTS as vn,STATS_FLAG_CONTRACTS as Mn,DUPLICATES_FLAG_CONTRACTS as In,START_TASK_FLAG_CONTRACTS as wn,PAUSE_TASK_FLAG_CONTRACTS as xn,TELEMETRY_FLAG_CONTRACTS as Fn,TEST_ALL_FLAG_CONTRACTS as kn,TEST_FLAG_CONTRACTS as bn,TEST_RUNS_FLAG_CONTRACTS as Gn,UPDATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS as Pn,UPDATE_COMMANDER_STRING_OPTION_CONTRACTS as Dn,UPDATE_FLAG_CONTRACTS as Un,UPDATE_MANY_FLAG_CONTRACTS as $n,UPGRADE_FLAG_CONTRACTS as K,VALIDATE_FLAG_CONTRACTS as jn,compactFlagAliasContracts as Y,SUBCOMMAND_GLOBAL_FLAG_CONTRACTS as z,PM_COMMAND_ALIAS_CONTRACTS as H,PM_DIAGNOSTIC_OUTPUT_BUDGET_CONTRACTS as qn,resolvePmCommandOutputBudget as J}from"../cli-contracts.js";import{PM_NAMESPACED_COMMAND_ALIASES as O,resolvePmCommandOperation as d}from"./command-aliases.js";import{HISTORY_ATTEST_FLAG_CONTRACTS as Bn,PM_POSITIONAL_ACTION_FLAG_CONTRACTS as Wn,resolveExtensionCommandInheritedFlagContracts as Xn,resolveSubcommandFlagContractsForCommand as Vn}from"./flag-contracts.js";import{resolveExtensionFlagOptionKey as Q}from"../extension/command-options.js";import{GOVERNANCE_CLOSE_VALIDATION_DEFAULT_VALUES as Kn,GOVERNANCE_CREATE_MODE_DEFAULT_VALUES as Yn,GOVERNANCE_OWNERSHIP_ENFORCEMENT_VALUES as zn,GOVERNANCE_WORKFLOW_ENFORCEMENT_VALUES as Hn}from"../../types.js";import{BRIEF_LIST_FIELDS as Jn,DEFAULT_COMPACT_LIST_FIELDS as Qn,LIST_COMMAND_DEFAULT_PROJECTIONS as Zn}from"../query/list.js";import{getActiveContextIntentContracts as ea}from"../context-intent-contracts.js";import{readOutputIncludeModeOptions as ta,resolveReadOutputSurface as na,PM_READ_OUTPUT_SURFACE_CONTRACTS as aa}from"../read-output-contracts.js";import{enrichCliFlagInvocationContracts as sa}from"../flag-invocation-contracts.js";import{resolvePmCommandVisibilityTier as Z}from"../agent-capability-contracts.js";import{PM_ERROR_CODE_CATALOG as oa}from"../generated-error-code-catalog.js";import{resolvePmCommandOutputEnvelope as ra}from"../output-contracts.js";import{PM_COMMAND_EXIT_OUTCOME_CONTRACTS as ia,resolvePmCommandExitContract as ca}from"./command-exit-contracts.js";import{BUILTIN_RELATIONSHIP_KINDS as la}from"../relationship-kinds/contract.js";import{ASSURANCE_GATE_TRIGGERS as da,ASSURANCE_MEASUREMENT_SOURCE_KINDS as ua}from"../governance/assurance.js";import{PM_CLI_GRAMMAR_CONTRACT as y,PM_COMMAND_DESTINATION_CONTRACTS as ma,PM_COMMAND_POSITIONAL_CONTRACTS as ee,PM_POSITIONAL_ACTION_CONTRACTS as te,positionalShapeKey as pa,resolvePmCommandPositionalContract as _a}from"./grammar-contracts.js";const ne=new Map([["activity",["--limit","--after","--full"]],["claim",["--if-available","--next","--type","--priority","--token-budget","--explain-ranking"]],["close",["--reason","--validate-close","--resolution","--expected-result","--actual-result","--message"]],["context",["--limit","--after","--depth","--section","--token-budget","--explain-ranking"]],["contracts",["--command","--flags-only","--summary","--runtime-only","--availability-only","--full"]],["create",["--title","--type","--status","--priority","--dep","--comment"]],["get",["--full","--depth","--fields","--tree","--tree-depth","--format"]],["health",["--check-only","--summary","--brief","--check-telemetry","--strict-exit","--full"]],["list",["--status","--type","--limit","--after","--brief","--fields"]],["next",["--limit","--blocked-limit","--ready-only","--token-budget","--explain-ranking","--format"]],["search",["--mode","--status","--type","--limit","--after","--fields"]],["update",["--status","--message","--dep","--comment","--file","--test"]],["validate",["--check-resolution","--check-history-drift","--check-storage-integrity","--counts","--strict-exit","--fix-hints"]]]),fa=["--limit","--after","--offset","--token-budget","--brief","--summary","--compact","--fields","--full","--format","--since","--until"],ae=new Set(["list","list-all","list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled"]),v=new Set(["calendar","guide","reindex","completion","test-runs-list","test-runs-status","test-runs-logs","test-runs-stop","test-runs-resume","templates-list","templates-save","templates-show"]),h=new Set(["meet","event","remind","search-advanced","dedupe-audit","dedupe-merge","comments-audit","cal","calendar","completion","completion-statuses","completion-tags","completion-types","guide","reindex","normalize","templates","templates list","templates save","templates show","test-runs","test-runs list","test-runs status","test-runs logs","test-runs stop","test-runs resume"]),se=new Map([["meet","calendar"],["event","calendar"],["remind","calendar"],["search-advanced","search-advanced"],["dedupe-audit","governance-audit"],["dedupe-merge","governance-audit"],["comments-audit","governance-audit"],["cal","calendar"],["calendar","calendar"],["completion","guide-shell"],["completion-statuses","guide-shell"],["completion-tags","guide-shell"],["completion-types","guide-shell"],["guide","guide-shell"],["reindex","search-advanced"],["normalize","governance-audit"],["templates","templates"],["templates list","templates"],["templates save","templates"],["templates show","templates"],["test-runs","linked-test-adapters"],["test-runs list","linked-test-adapters"],["test-runs status","linked-test-adapters"],["test-runs logs","linked-test-adapters"],["test-runs stop","linked-test-adapters"],["test-runs resume","linked-test-adapters"]]),oe=new Map([["calendar","calendar|cal"],["guide","guide"],["reindex","reindex"],["completion","completion"],["test-runs-list","test-runs|test-runs list"],["test-runs-status","test-runs status"],["test-runs-logs","test-runs logs"],["test-runs-stop","test-runs stop"],["test-runs-resume","test-runs resume"],["templates-list","templates|templates list"],["templates-save","templates save"],["templates-show","templates show"]]),re=new Map([...oe.entries()].flatMap(([e,t])=>A(t).map(n=>[n,e]))),ie=[{canonical:"context",aliases:["ctx"]},{canonical:"package",aliases:["extension","packages"]}],x=new Map(ie.flatMap(e=>e.aliases.map(t=>[t,e.canonical]))),Ca=10,Aa=20,ce=new Map([["activity","Read activity."],["aggregate","Group counts."],["append","Append body."],["assurance","Evaluate assurance."],["assurance derive","Derive checks."],["assurance risk","Select checks for changes."],["assurance lineages","Measure recurrence coverage."],["beads","Manage Beads interoperability."],["cal","Manage calendar integration."],["calendar","Manage calendar integration."],["changelog","Generate changelog output."],["claim","Claim work."],["close","Close work."],["close-many","Close matching work."],["close-task","Close task work."],["command-kit","Inspect command authoring primitives."],["comments","Manage comments."],["comments-audit","Audit comment governance."],["completion","Generate shell completions."],["config","Manage settings."],["context","Build context."],["contracts","Inspect contracts."],["copy","Copy work."],["create","Create work."],["dedupe-audit","Audit duplicate work."],["dedupe-merge","Merge duplicate work."],["delete","Delete work."],["deps","Manage deps."],["duplicates","Find duplicate clusters."],["docs","Link docs."],["eval","Run evaluations."],["event","Manage events."],["events","Read events."],["files","Link files."],["focus","Manage focus."],["gc","Clean caches."],["get","Read item."],["graph","Query graph."],["guide","Show user guides."],["health","Check health."],["help","Show help."],["history","Inspect history."],["init","Initialize workspace."],["install","Install packages."],["item","Mutate items."],["learnings","Manage learnings."],["list","List work."],["list-all","List work across every status."],["list-blocked","List blocked work."],["list-canceled","List canceled work."],["list-closed","List closed work."],["list-draft","List draft work."],["list-in-progress","List in-progress work."],["list-open","List open work."],["meet","Record meeting context."],["merge","Manage tracker merges."],["next","Pick next work."],["notes","Manage notes."],["normalize","Normalize tracker data."],["ops","Run operations."],["package","Manage packages."],["packages","Manage packages."],["pause-task","Pause task work."],["plan","Manage plans."],["profile","Manage profiles."],["reindex","Refresh search index."],["release","Release claim."],["remind","Manage reminders."],["restore","Restore history."],["schema","Customize schema."],["search","Search work."],["search-advanced","Run advanced search."],["start-task","Start task work."],["stats","Show stats."],["telemetry","Manage telemetry."],["templates","Manage work templates."],["test","Run linked tests."],["test-all","Run all linked tests."],["test-runs","Inspect background test runs."],["todos","Manage source-code todos."],["twin","Manage repository twins."],["update","Update work."],["update-many","Update matching work."],["upgrade","Upgrade packages."],["validate","Validate data."],["vcs","Inspect version-control context."],["workspace","Manage workspaces."],["history-author-acknowledge","Acknowledge reviewed history authors."],["history-compact","Compact history."],["history-attest","Export or verify detached history proof."],["history-redact","Redact sensitive history values."],["history-repair","Repair history integrity."]]),le=[["init",xt],["install",Ft],["uninstall",Pt],["explore",It],["inventory",L],["manage",kt],["describe",vt],["reload",Gt],["doctor",Mt],["catalog",Rt],["adopt",Et],["adopt-all",Nt],["activate",yt],["deactivate",Lt],["migrate",bt]],ga=[...le.map(([e,t])=>e==="init"?[e,rn]:[e,t]),["upgrade",K]],Ta=[...le.map(([e,t])=>[`extension ${e}`,t]),...ga.flatMap(([e,t])=>[[`package ${e}`,t],[`packages ${e}`,t]]),["package list",L],["packages list",L],["extension list",L],["init",Jt],["config",mt],["extension",wt],["package",X],["packages",X],["install",Ht],["create",gt],["item mutate",Zt],["item complete",Qt],["item reopen",en],["copy",_t],["focus",Ut],["update",Un],["update-many",$n],["upgrade",K],["calendar",B],["cal",B],["context",W],["ctx",W],["get",jt],["search",vn],["eval",En],["events",Rn],["workspace",T],["workspace position",[]],["workspace snapshot",T],["workspace snapshot create",T],["workspace snapshot list",T],["workspace snapshot inspect",T],["workspace snapshot restore",T],["workspace snapshot delete",T],["next",Ln],["aggregate",nt],["deps",Ot],["graph",ht],["guide",qt],["reindex",Tn],["history",Xt],["history-compact",Vt],["history-attest",Bn],["history-redact",Kt],["history-repair",Yt],["history-author-acknowledge",zt],["merge",sn],["schema",Sn],["profile",yn],["plan",fn],["restore",hn],["delete",Tt],["close",lt],["close-many",dt],["append",st],["claim",rt],["release",On],["start-task",wn],["pause-task",xn],["close-task",it],["comments",ct],["notes",on],["learnings",tn],["files",Dt],["docs",St],["test",bn],["test-runs-worker",[]],["test-all",kn],["telemetry",Fn],["test-runs",Gn],["gc",$t],["stats",Mn],["ops",[]],["duplicates",In],["validate",jn],["health",Wt],["assurance",at],...Wn,["contracts",pt],["completion",ut],["activity",tt],...[...ae].map(e=>[e,an])],E=new Map(Ta);for(const{alias:e,canonical:t}of O){const n=E.get(e);n!==void 0&&E.set(t,n)}function de(e){const t=re.get(e);return t||(e.startsWith("test-runs ")?`test-runs-${e.slice(10)}`:e.startsWith("templates ")?`templates-${e.slice(10)}`:e)}function F(e){const t=O.find(n=>n.alias===e);return t?`${t.canonical}|${t.alias}`:V.includes(e)?p(e):e.startsWith("extension-")?p(`extension ${e.slice(10)}`):e.startsWith("package-")?p(`package ${e.slice(8)}`):e.startsWith("item-")?p(`item ${e.slice(5)}`):e.startsWith("test-runs-")?p(`test-runs ${e.slice(10)}`):e.startsWith("templates-")?p(`templates ${e.slice(10)}`):v.has(e)?oe.get(e)??p(e):null}function ue(e,t){const n=d(t);return n!==t||O.some(s=>s.alias===t)?e.action===n:e.command_path===null?!1:A(e.command_path).some(s=>s===t?!0:s.startsWith(`${t} `)||t.startsWith(`${s} `))}function A(e){return e.split("|").map(t=>p(t)).filter(t=>t.length>0)}function me(e,t){const n=new Set(t),s=new Set;for(const a of e)if(a.command_path)for(const o of A(a.command_path)){const r=o.split(" ").filter(i=>i.length>0);if(r.length!==0)for(let i=r.length;i>0;i-=1){const c=r.slice(0,i).join(" ");if(n.has(c)){s.add(c);break}}}return[...s].sort((a,o)=>a.localeCompare(o))}function M(e){if(typeof e!="string")return;const t=e.trim().toLowerCase();return t.length>0?t:void 0}function N(e){const t=e.oneOf;return Array.isArray(t)?t.filter(n=>typeof n=="object"&&n!==null):[]}function pe(e,t){if(!t)return{...e};const s=N(e).filter(a=>{const o=a.properties;if(typeof o!="object"||o===null)return!1;const r=o.action;return typeof r!="object"||r===null?!1:r.const===t});return{...e,oneOf:s}}function I(e,t){const s=N(e).filter(a=>{const o=a.properties;if(typeof o!="object"||o===null)return!1;const r=o.action;if(typeof r!="object"||r===null)return!1;const i=r.const;return typeof i=="string"&&t.has(i)});return{...e,oneOf:s}}function p(e){return e.trim().toLowerCase().split(/\s+/).filter(t=>t.length>0).join(" ")}function k(e){return e.replace(/\s+/g,"-")}function g(e){if(typeof e!="string")return null;const t=e.trim();return t.length>0?t:null}function _e(e){if(!Array.isArray(e))return[];const t=[],n=new Set;for(const s of e){const a=g(s);!a||n.has(a)||(n.add(a),t.push(a))}return t}function b(e,t,n){n&&(e[t]=!0)}function G(e,t){if(e==null)return null;if(typeof e!="string")throw new TypeError("Expected string for extension flag name.");const n=e.trim();return n.length===0?null:t==="long"?n.startsWith("--")&&n.length>2?je(n):null:n.startsWith("-")&&!n.startsWith("--")&&n.length>1?n:null}function Oa(e){const t=G(e.long,"long"),n=G(e.short,"short"),s=t??n;if(!s)return null;const a={flag:s};n&&t&&(a.short=n),b(a,"required",e.required===!0),b(a,"repeatable",e.repeatable===!0),b(a,"list",e.list===!0),e.default!==void 0&&(a.default=e.default);const o=g(e.description);o&&(a.description=o);const r=$e(e);a.value_arity=r.value_arity;const i=g(e.value_name)??r.value_name;i&&(a.value_name=i);const c=r.value_type??(r.value_name?"string":null);return c&&(a.value_type=c),a}function P(e){const t=new Map;for(const s of e){const a=p(s.target_command);if(a.length===0)continue;const o=t.get(a)??{flags:[],sources:[],dedupe:new Set,sourceDedupe:new Set},r=`${s.layer}:${s.name}`;o.sourceDedupe.has(r)||(o.sourceDedupe.add(r),o.sources.push({layer:s.layer,name:s.name}));for(const i of s.flags){const c=Oa(i);if(!c)continue;const l=`${c.flag}|${c.short??""}`;o.dedupe.has(l)||(o.dedupe.add(l),o.flags.push(c))}t.set(a,o)}const n=new Map;for(const[s,a]of t.entries())n.set(s,{flags:a.flags,sources:a.sources.sort((o,r)=>{const i=o.layer.localeCompare(r.layer);return i!==0?i:(o.name??"").localeCompare(r.name??"")})});return n}function ha(e,t){return e.read_output===void 0?{flags:t}:{read_output:e.read_output,flags:[...t,...z.filter(({flag:n})=>n.startsWith("--output-"))]}}function fe(e){const t=P(e.flagRegistrations),n=new Map;for(const o of e.commandDefinitions){const r=p(o.command);if(r.length===0)continue;const i=g(o.action)??k(r),c=Array.isArray(o.arguments)?o.arguments.map(l=>{const u=g(l.name);return u?{name:u,required:l.required===!0,variadic:l.variadic===!0,description:g(l.description)}:null}).filter(l=>l!==null):[];n.set(r,{...o.tier===void 0?{}:{tier:o.tier},...ha(o,t.get(r)?.flags??[]),command:r,action:i,source:{layer:o.layer,name:o.name},description:g(o.description),intent:g(o.intent),arguments:c,examples:_e(o.examples),failure_hints:_e(o.failure_hints)})}const s=new Set;for(const o of e.handlers)s.add(p(o));for(const o of n.keys())s.add(o);for(const o of t.keys())s.add(o);const a=[];for(const o of[...s].sort((r,i)=>r.localeCompare(i))){const r=n.get(o);a.push(Sa(o,r,t.get(o)?.flags??[]))}return a}function Sa(e,t,n){return t?{...t,flags:t.flags.length>0?t.flags:n}:{command:e,action:k(e),source:null,description:null,intent:null,arguments:[],flags:n,examples:[],failure_hints:[]}}function Ce(e){const t=e.flag.startsWith("--")?e.flag:void 0,n=Q({long:t,short:t===void 0?e.flag:void 0});return n!==null&&/[a-z0-9]/iu.test(n)?n:null}function ya(e,t){return e.variadic?{type:"array",items:{type:"string"},description:e.description??`Variadic argument '${e.name}' for extension action '${t}'.`}:{type:"string",description:e.description??`Argument '${e.name}' for extension action '${t}'.`}}function Na(e,t){const n=e.value_type??"boolean",s=n==="boolean"?"boolean":n==="number"?["number","string"]:"string",a=e.repeatable===!0||e.list===!0;return{type:a?"array":s,...a?{items:{type:s}}:{},...e.default!==void 0?{default:e.default}:{},description:e.description??`Extension option '${e.flag}' for action '${t}'.`}}function Ae(e){const t=e.command.split("|").map(a=>a.trim()).filter(a=>a.length>0),n={action:{type:"string",const:e.action,description:e.intent??e.description??`Invoke extension command '${e.command}'.`}},s=["action"];for(const a of e.arguments)n[a.name]=ya(a,e.action),a.required&&s.push(a.name);for(const a of e.flags){const o=Ce(a);!o||n[o]!==void 0||(n[o]=z.some(r=>r.flag===a.flag&&r.flag.startsWith("--output-"))?Ue[o]:Na(a,e.action),a.required===!0&&s.push(o))}return{type:"object",properties:n,required:s,additionalProperties:!0,"x-extension-source":e.source,"x-extension-command":t[0]??e.command,"x-extension-commands":t}}function Ea(e,t){e.description??=t.description,e.value_name??=t.value_name,e.value_type??=t.value_type,t.required===!0&&(e.required=!0),t.repeatable===!0&&(e.repeatable=!0)}function ge(e){const t=new Map;for(const n of e){const s=t.get(n.action);if(!s){t.set(n.action,{...n,flags:[...n.flags],examples:[...n.examples],failure_hints:[...n.failure_hints]});continue}s.command=[...new Set([s.command,n.command])].sort((o,r)=>o.localeCompare(r)).join("|"),s.arguments=s.arguments.length>=n.arguments.length?s.arguments:n.arguments;const a=new Set(s.flags.map(o=>`${o.flag}|${o.short??""}`));for(const o of n.flags){const r=`${o.flag}|${o.short??""}`;if(!a.has(r))a.add(r),s.flags.push(o);else{const i=s.flags.find(c=>`${c.flag}|${c.short??""}`===r);i&&Ea(i,o)}}s.examples=[...new Set([...s.examples,...n.examples])],s.failure_hints=[...new Set([...s.failure_hints,...n.failure_hints])]}return[...t.values()].sort((n,s)=>n.action.localeCompare(s.action))}async function Te(e,t=q){const n={mode:R.extensions.policy.mode,trust_mode:R.extensions.policy.trust_mode,default_sandbox_profile:R.extensions.policy.default_sandbox_profile};if(e.noExtensions)return{handlers:new Set,disabledReason:"extensions_disabled",commandDefinitions:[],flagRegistrations:[],registrations:null,policyState:n};const s=j(process.cwd(),e.path);if(!await Xe(Je(s)))return{handlers:new Set,disabledReason:null,commandDefinitions:[],flagRegistrations:[],registrations:null,policyState:n};try{const a=await t(s),o=await We({pmRoot:s,settings:a,cwd:process.cwd(),noExtensions:!1}),r=await qe({...o,loaded:o.loaded});return{handlers:new Set(r.commands.handlers.map(c=>p(c.command))),disabledReason:null,commandDefinitions:r.registrations.commands,flagRegistrations:r.registrations.flags,registrations:r.registrations,policyState:{mode:o.policy.mode,trust_mode:o.policy.trust_mode,default_sandbox_profile:o.policy.default_sandbox_profile}}}catch{return{handlers:new Set,disabledReason:"extension_runtime_probe_failed",commandDefinitions:[],flagRegistrations:[],registrations:null,policyState:n}}}function Oe(e,t={}){const n=new Map;for(const s of An){const a=v.has(s);if(a&&!t.includePackageOwnedActions)continue;const o=F(s);n.set(s,{action:s,provider:a?"extension":"core",requires_extension:a,command_path:o})}if(t.includePackageOwnedActions)for(const s of v)n.has(s)||n.set(s,{action:s,provider:"extension",requires_extension:!0,command_path:F(s)});for(const s of e)n.has(s.action)||n.set(s.action,{action:s.action,provider:"extension",requires_extension:!0,command_path:O.find(a=>a.alias===s.command)?.canonical??p(s.command)});return[...n.values()].sort((s,a)=>(s.action??"").localeCompare(a.action??""))}function he(e,t){if(e.provider==="core"&&!e.requires_extension)return{action:e.action,invocable:!0,available:!0,requires_extension:!1,provider:"core",disabled_reason:null,command_path:e.command_path,cli_exposed:e.command_path!==null&&(!h.has(e.action)||t.handlers.has(e.action))};const n=e.command_path?A(e.command_path):[],s=n.some(r=>t.handlers.has(r)||t.handlers.has(d(r))),a=n.map(r=>se.get(d(r))).find(r=>typeof r=="string"),o=t.disabledReason===null&&s;return{action:e.action,invocable:o,available:o,requires_extension:!0,provider:"extension",disabled_reason:o?null:t.disabledReason??(a?`optional_package_not_installed:${a}`:"extension_command_not_registered"),command_path:e.command_path,cli_exposed:s,policy_state:{mode:t.policyState.mode,trust_mode:t.policyState.trust_mode,default_sandbox_profile:t.policyState.default_sandbox_profile}}}function D(e){const t=E.get(e)??Bt,n=Vn(e).find(s=>s.flag==="--output-format"&&s.aliases?.includes("--format"));return n?[...t,n]:t}function Se(e){return h.has(d(e))?!1:E.has(e)}function ye(e){return ae.has(e)?"list":e==="cal"?"calendar":e==="ctx"?"context":e==="update-many"?"update_many":e}function U(e){const t=e.trim();return t?t.startsWith("--")?t:t.startsWith("-")?null:`--${t}`:null}function Ne(e){const t=e.trim();return!t||t.startsWith("--")?null:t.startsWith("-")?t:null}function Ee(e){const t=new Map;for(const s of e.definitions){const a=U(s.cli_flag);if(!a)continue;const o=s.cli_aliases.map(i=>Ne(i)).find(i=>i!==null),r=s.cli_aliases.map(i=>U(i)).filter(i=>i!==null&&i!==a);for(const i of s.commands){const c=t.get(i)??{flags:[],seen:new Set},l=o?{flag:a,short:o}:{flag:a},u=`${l.flag}|${l.short??""}`;c.seen.has(u)||(c.seen.add(u),c.flags.push(l));for(const m of r){const _=`${m}|`;c.seen.has(_)||(c.seen.add(_),c.flags.push({flag:m}))}t.set(i,c)}}const n=new Map;for(const[s,a]of t.entries())n.set(s,Y(a.flags));return n}function Re(e,t){const n=[],s=new Set;for(const a of[...e,...t]){const o=`${a.flag}|${a.short??""}`;s.has(o)||(s.add(o),n.push(a))}return Y(n)}function Le(e){const t=Q(e.flag.startsWith("--")?{long:e.flag}:{short:e.flag});return{...e,owner:"extension",...t===null?{}:{sdk_option:t}}}function Ra(e,t,n,s){const a=(n??[]).map(Le),o=t==="extension"&&(n!==void 0||La(e,s));return{flags:a,inherited:o?{inherited_flags:Xn({readOutput:va(e,s)})}:{}}}function ve(e,t){const n=d(e);return t.find(s=>d(s.command)===n)}function La(e,t){return ve(e,t)!==void 0}function va(e,t){return ve(e,t)?.read_output!==void 0}function Ma(e,t,n,s,a){const o=new Map(t);for(const{alias:r,canonical:i}of O){const c=t.get(i)??t.get(r);c&&(o.set(r,c),o.set(i,c))}return e.map(r=>{const i=Se(r),c=i?D(r):[],l=n.get(ye(r))??[],u=o.get(r),m=Re(c,l),_=c.length>0&&(u?.flags.length??0)>0?"mixed":i?"core":"extension",C=Ra(r,_,u?.flags,a),$=Re(m,C.flags);return{command:r,flags:$,...C.inherited,...s?{canonical_command:be(r),visibility:ke(r,a),positionals:_a(r)?.slots??[],flag_invocations:sa(r,$)}:{},provider:_,extension_sources:u?.sources}}).sort((r,i)=>r.command.localeCompare(i.command))}function Ia(e,t=H){const n=new Set(e),s=new Map;for(const a of ie){const o=a.aliases.filter(r=>n.has(r));s.set(a.canonical,{canonical:a.canonical,aliases:o,contracts:[]})}for(const a of t){if(!n.has(a.canonical)||a.registration==="commander"&&!n.has(a.alias))continue;const o=s.get(a.canonical)??{canonical:a.canonical,aliases:[],contracts:[]};o.aliases.includes(a.alias)||o.aliases.push(a.alias),o.contracts.push(a),s.set(a.canonical,o)}return[...s.values()].map(({contracts:a,...o})=>a.length===0?o:{...o,contracts:a}).sort((a,o)=>a.canonical.localeCompare(o.canonical))}function wa(){return{create_string_options:At,create_repeatable_options:Ct,update_string_options:Dn,update_repeatable_options:Pn,list_string_options:nn,search_string_options:Nn,calendar_string_options:ot,context_string_options:ft,activity_string_options:et}}function Me(e,t){const n=new Set(["title","type"]);if(t==="strict"){for(const i of e.required_create_fields)n.add(i);for(const i of e.required_create_repeatables)n.add(i)}const s=Ke(e,"create",n),a=[...new Set(s.required)].sort((i,c)=>i.localeCompare(c)),o=[...new Set(a.map(i=>Ve("create",i)))].sort((i,c)=>i.localeCompare(c)),r=[...new Set(e.options.filter(i=>i.required===!0).map(i=>i.key))].sort((i,c)=>i.localeCompare(c));return{required_option_keys:a,required_flags:o,required_type_options:r,policy_errors:[...new Set(s.errors)].sort((i,c)=>i.localeCompare(c))}}function xa(e){const t={},n={};for(const s of[...e.types].sort((a,o)=>a.localeCompare(o))){const a=e.by_type[s];t[s]=Me(a,"strict"),n[s]=Me(a,"progressive")}return{default_create_mode:"strict",by_create_mode:{strict:{by_type:t},progressive:{by_type:n}}}}function Ie(e,t){const n=N(e);if(n.length===0)return e;let s=!1;const a=n.map(o=>{const r=o.properties;if(typeof r!="object"||r===null)return o;const i=r.action;return typeof i!="object"||i===null||i.const!=="create"?o:(s=!0,{...o,"x-create-required-options":t})});return s?{...e,oneOf:a}:e}function Fa(e){const t=M(e.action)!==void 0||M(e.command)!==void 0,n=e.schemaOnly===!0||e.flagsOnly===!0||e.availabilityOnly===!0,s=e.summary===!0||e.full!==!0&&e.runtimeOnly!==!0&&!t&&!n,a=e.schemaOnly===!0,o=e.flagsOnly===!0,r=e.availabilityOnly===!0,i=e.runtimeOnly===!0,c=e.full===!0,l=M(e.action),u=M(e.command),m=!s&&!c&&!a&&!o&&!r&&!l&&!u;return{selectedAction:l,selectedCommand:u,summary:s,schemaOnly:a,flagsOnly:o,availabilityOnly:r,runtimeOnly:i,fullOutput:c,omitUnfilteredSchema:m,omitUnfilteredCommandFlags:m,omitUnfilteredCommanderAliases:m||u!==void 0&&!c}}function ka(e){if([e.summary,e.schemaOnly,e.flagsOnly,e.availabilityOnly].filter(n=>n).length>1)throw new S("Choose only one projection flag: --summary, --schema-only, --flags-only, or --availability-only.",f.USAGE)}async function we(e,t=q){try{return await t(e)}catch{return structuredClone(R)}}async function ba(e,t,n){const s=await we(t),a=await Te(e),o=Ye(s,a.registrations??Be()),r=ze(s.schema),i=fe(a);return{settings:s,runtimeProbe:a,typeRegistry:o,statusRegistry:He(s.schema),runtimeFieldRegistry:r,runtimeFieldFlagMap:Ee(r),createRequiredOptionContracts:xa(o),extensionContracts:i,mergedExtensionContracts:ge(i.filter(c=>w(n,c.command,i))),extensionFlagMap:P(a.flagRegistrations)}}function xe(e){return e.availabilityOnly&&(e.selectedAction!==void 0&&v.has(e.selectedAction)||e.selectedCommand!==void 0&&h.has(d(e.selectedCommand)))}function Ga(e,t){const n=Oe(t,{includePackageOwnedActions:xe(e)});if(e.selectedAction===void 0&&e.selectedCommand===void 0){const s=new Set(Cn);return n.filter(a=>!s.has(a.action)&&(e.fullOutput||(t.find(o=>o.action===a.action)?.tier??Z(a.action))!=="internal"))}return xe(e)&&e.selectedCommand!==void 0&&h.has(d(e.selectedCommand))&&!n.some(s=>s.command_path===e.selectedCommand)&&n.push({action:de(d(e.selectedCommand)),provider:"extension",requires_extension:!0,command_path:e.selectedCommand}),n}function Pa(e,t){const n=new Set(t.map(s=>s.action));if(e.selectedAction&&!n.has(e.selectedAction))throw new S(`Unknown action: "${e.selectedAction}".`,f.USAGE)}function Da(e,t){return[...new Set([...V.filter(n=>!h.has(d(n))),...[...E.keys()].filter(n=>!h.has(d(n))),...e.flatMap(n=>n.command_path?A(n.command_path).filter(s=>n.provider==="extension"||!h.has(d(s))||t.some(a=>a.action===n.action)):[]),...t.flatMap(n=>n.command.split("|").flatMap(s=>{const a=O.find(o=>o.alias===s||o.canonical===s);return a===void 0?[s]:[a.alias,a.canonical]}))])].map(n=>p(n)).filter(n=>n.length>0).sort((n,s)=>n.localeCompare(s))}function Ua(e,t){const n=t.slice(0,Ca),s=t.length-n.length,a=s>0?`${n.join(", ")}, and ${s} more`:n.join(", "),o=t.slice(0,Aa),r=t.slice(0,5).map(c=>`pm contracts --command "${c}" --flags-only --json`),i=t[0];return new S(`Command "${e}" is a command namespace. Choose a concrete child command: ${a}.`,f.USAGE,{code:"command_namespace",required:"Use a concrete child command path listed under this namespace.",why:"Command groups expose help at the namespace root, but command flag contracts belong to executable child commands.",examples:r,nextSteps:[`Retry with a child command, for example: ${r[0]}`],recovery:{suggested_retry:`pm contracts --command "${i}" --flags-only --json`,fallback_candidates:o.map(c=>({source:"command_namespace",command:`pm contracts --command "${c}" --flags-only --json`,reason:`Child command under ${e}`}))}})}function $a(e,t){return new S(`Unknown command: "${e}". Command "${e}" is provided by the optional "${t}" package. Run "pm package install ${t} --project" and retry.`,f.USAGE,{code:"unknown_command",required:`Install the optional "${t}" package, or choose a command from pm contracts --flags-only --json.`,why:"Command contracts include core commands plus commands registered by active packages and extensions.",examples:[`pm package install ${t} --project`,`pm contracts --command ${e} --flags-only --json`],nextSteps:[`Install the optional package first: pm package install ${t} --project`],recovery:{suggested_retry:`pm package install ${t} --project`}})}function ja(e){return new S(`Unknown command: "${e}".`,f.USAGE,{code:"unknown_command",required:"Use a command path listed by pm contracts --flags-only --json.",why:"Command contracts are generated from the active core, package, and extension command registry.",examples:["pm contracts --flags-only --json","pm --help"],nextSteps:["Verify spelling and active packages/extensions, then rerun with a known command path."],recovery:{suggested_retry:"pm contracts --flags-only --json"}})}function qa(e,t){if(!e.selectedCommand||new Set(t).has(e.selectedCommand))return;const s=t.filter(o=>o.startsWith(`${e.selectedCommand} `));if(s.length>0)throw Ua(e.selectedCommand,s);const a=se.get(d(e.selectedCommand));throw a?$a(e.selectedCommand,a):ja(e.selectedCommand)}function Ba(e,t){const n=Ga(e,t.mergedExtensionContracts);Pa(e,n);const s=Da(n,t.mergedExtensionContracts);qa(e,s);const a=e.selectedCommand?re.get(d(e.selectedCommand)):void 0,o=e.selectedCommand?n.filter(l=>a?l.action===a:ue(l,e.selectedCommand)):n;if(e.selectedCommand&&e.selectedAction&&!o.some(l=>l.action===e.selectedAction))throw new S(`Action "${e.selectedAction}" is not mapped to command "${e.selectedCommand}" in contracts output.`,f.USAGE);const r=e.selectedAction?o.filter(l=>l.action===e.selectedAction):o,i=[...new Map(r.map(l=>he(l,t.runtimeProbe)).map(l=>[a?l.action:`${l.action}|${l.command_path??""}`,l])).values()],c=e.runtimeOnly&&!e.selectedAction&&!e.availabilityOnly?i.filter(l=>l.invocable):i;return{actionDescriptors:n,commandCatalog:s,commandScopedDescriptors:o,scopedActionDescriptors:r,selectedPackageOwnedAction:a,actionAvailability:c,actions:[...new Set(c.map(l=>l.action))]}}function Wa(e){return new Set(N(e).map(t=>{const n=t.properties;if(typeof n!="object"||n===null)return null;const s=n.action;if(typeof s!="object"||s===null)return null;const a=s.const;return typeof a=="string"?a:null}).filter(t=>t!==null))}function Xa(e){const t=gn,n=N(t),s=Wa(t),a=e.filter(o=>!s.has(o.action)).map(o=>Ae(o));return a.length>0?{...t,oneOf:[...n,...a]}:t}function Fe(e,t,n){const s=new Set(t.actionDescriptors.map(o=>o.action)),a=e.selectedAction?pe(n,e.selectedAction):e.selectedCommand?I(n,new Set(t.scopedActionDescriptors.map(o=>o.action))):I(n,s);return e.runtimeOnly&&!e.selectedAction?I(a,new Set(t.actions)):a}function Va(e,t,n){const s=Xa(t.mergedExtensionContracts),o=!e.flagsOnly&&!e.availabilityOnly?Ie(Fe(e,n,s),t.createRequiredOptionContracts):Fe(e,n,s);return{mergedSchema:s,filteredSchema:o}}function Ka(e,t){return e.selectedCommand!==void 0?[e.selectedCommand]:e.selectedAction?me(t.scopedActionDescriptors,t.commandCatalog):t.commandCatalog}function ke(e,t){return t.find(n=>d(n.command)===d(e))?.tier??Z(e)}function w(e,t,n){return e.fullOutput||e.selectedCommand!==void 0||e.selectedAction!==void 0||ke(t,n)!=="internal"}function Ya(e,t,n){if(e.selectedCommand!==void 0||e.selectedAction!==void 0)return t;const s=new Set(H.filter(a=>a.hidden&&(a.lifecycle==="deprecated"||!e.fullOutput&&!e.availabilityOnly)).map(a=>a.alias));if(e.summary&&!e.fullOutput)for(const a of x.keys())s.add(a);return t.filter(a=>!s.has(a)&&w(e,a,n))}function be(e){const t=O.find(s=>s.alias===e||s.canonical===e);if(t)return t.canonical;const n=e.split(" ")[0];return n.startsWith("list-")?"list":x.get(n)??n}const za=new Map([["activate","Activate"],["adopt","Adopt"],["adopt-all","Adopt all"],["catalog","Catalog"],["complete","Complete"],["create","Create"],["deactivate","Deactivate"],["delete","Delete"],["describe","Describe"],["doctor","Diagnose"],["explore","Explore"],["init","Initialize"],["inspect","Inspect"],["install","Install"],["list","List"],["manage","Manage"],["migrate","Migrate"],["mutate","Mutate"],["reload","Reload"],["restore","Restore"],["run","Run"],["snapshot","Manage snapshots for"],["uninstall","Uninstall"],["upgrade","Upgrade"]]),Ha=new Map([["extension adopt-all","extensions"],["package adopt-all","packages"],["workspace snapshot list","workspace snapshots"]]);function Ja(e,t){const n=ce.get(d(e))??(e.includes(" ")?void 0:ce.get(be(e)));if(n!==void 0)return{intent:n,intent_source:"command"};const s=t.find(l=>A(l.command).some(u=>d(u)===d(e)));if(s?.intent!==null&&s?.intent!==void 0)return{intent:s.intent,intent_source:"command"};if(s?.description!==null&&s?.description!==void 0)return{intent:s.description,intent_source:"description"};const a=e.split(" "),o=a.at(-1),r=a.slice(0,-1).join(" "),i=za.get(o),c=Ha.get(e)??r;return{intent:i===void 0||r.length===0?`Run ${e}.`:`${i} ${c}.`,intent_source:"generated"}}function Ge(e,t=[],n={}){const s=n.includeFormatBudgets??!0,a=n.includeIntentProvenance??!0;return[...new Set(e.map(p))].filter(o=>o.length>0).sort((o,r)=>o.localeCompare(r)).map(o=>{const r=J(o,{generateFallback:!0}),i=o.split(" ")[0],c=x.get(i)??(i.startsWith("list-")?"list":i.startsWith("history-")?"history":i),l=new Set([...D(o).map(_=>_.flag),...t.filter(_=>A(_.command).some(C=>d(C)===d(o))).flatMap(_=>_.flags.map(C=>C.flag))]),u=(ne.get(d(o))??ne.get(c)??fa).filter(_=>l.has(_)),m=Ja(o,t);return{command:o,intent:m.intent,...a||m.intent_source!=="command"?{intent_source:m.intent_source}:{},...u.length>0?{flags:u}:{},default_max_estimated_tokens:r.default_max_estimated_tokens,...s?{default_max_estimated_tokens_by_format:{...r.default_max_estimated_tokens_by_format}}:{}}})}function Pe(e){return e.map(t=>({budget:J(t,{generateFallback:!0}),envelope:ra(t)}))}function De(e){const t=new Map;for(const n of e){const s=ca(n),a=s===void 0?[f.SUCCESS,f.GENERIC_FAILURE,f.USAGE,f.NOT_FOUND,f.CONFLICT,f.DEPENDENCY_FAILED]:s.exit_codes,o=a.join(","),r=t.get(o)??{commands:[],exit_codes:a};r.commands.push(n),t.set(o,r)}return[...t.values()]}function Qa(e,t,n){if(e.selectedCommand)return t.extensionContracts.filter(s=>A(s.command).some(a=>d(a)===d(e.selectedCommand)));if(e.selectedAction){const s=new Set(n);return t.extensionContracts.filter(a=>A(a.command).some(o=>s.has(o)))}return t.extensionContracts.filter(s=>w(e,s.command,t.extensionContracts))}function Za(e,t,n,s){return{schema_version:typeof t.mergedSchema["x-schema-version"]=="string"?t.mergedSchema["x-schema-version"]:null,schema_id:typeof t.mergedSchema.$id=="string"?t.mergedSchema.$id:null,selected:{action:e.selectedAction??null,command:e.selectedCommand??null,summary:e.summary,schema_only:e.schemaOnly,flags_only:e.flagsOnly,availability_only:e.availabilityOnly,runtime_only:e.runtimeOnly,command_scoped:e.selectedCommand!==void 0},commands:e.summary?[]:s,...!e.summary&&!e.flagsOnly?{actions:n.actions,action_availability:n.actionAvailability}:{}}}function es(e,t,n){(n.selectedCommand==="history"||n.fullOutput)&&!n.flagsOnly&&!n.schemaOnly&&!n.availabilityOnly&&(e.history_operations=Qe);const s=n.selectedCommand;e.runtime_schema={statuses:t.statusRegistry.definitions.map(a=>a.id),open_status:t.statusRegistry.open_status,close_status:t.statusRegistry.close_status,canceled_status:t.statusRegistry.canceled_status,types:[...t.typeRegistry.types],fields_by_command:Object.fromEntries([...t.runtimeFieldRegistry.command_to_fields.entries()].filter(([a])=>s===void 0||a===s).map(([a,o])=>[a,[...new Set(o.map(r=>`--${r.cli_flag}`))].sort((r,i)=>r.localeCompare(i))]))},!(s!==void 0&&!n.fullOutput)&&(e.extension_contracts={capabilities:[...cn],services:[...mn],policy_modes:[...ln],policy_mode_scope:"extensions.policy.mode",policy_surfaces:[...dn],trust_modes:[...pn],trust_mode_scope:"extensions.policy.trust_mode",sandbox_profiles:[...un],manifest_versions:[1,2],compatibility:{current:"v2",previous:["v1"],breaking_strategy:"versioned_breaking"}},e.governance_contracts={ownership_enforcement_modes:[...zn],create_modes:[...Yn],close_validation_modes:[...Kn],workflow_enforcement_modes:[...Hn]},e.relationship_kind_contracts=[...la,...(t.runtimeProbe.registrations?.relationship_kinds??[]).flatMap(a=>a.definitions)].sort((a,o)=>a.kind.localeCompare(o.kind)).map(a=>({canonical:a.kind,aliases:[...a.aliases??[]],...a.inverse===void 0?{}:{inverse:a.inverse},ordering:a.ordering,hierarchy:a.hierarchy})))}function ts(e,t,n,s){if(!(t.flagsOnly||t.availabilityOnly)){if(!t.omitUnfilteredSchema){e.schema=n.filteredSchema,e.extension_commands=s;return}e.schema_omitted_reason="unfiltered_default_brief",e.extension_commands=s}}function ns(e,t,n,s,a){if(!(t.schemaOnly||t.availabilityOnly)){if(t.omitUnfilteredCommandFlags)e.command_flags_omitted_reason="unfiltered_default_brief";else{e.command_flags=Ma(s,n.extensionFlagMap,n.runtimeFieldFlagMap,t.selectedCommand!==void 0,n.extensionContracts);const o=new Set(s);e.list_projections=Object.entries(Zn).filter(([r])=>o.has(r)).map(([r,i])=>({command:r,default:i,brief_fields:[...Jn,"priority"],compact_fields:[...Qn]}))}e.command_aliases=t.fullOutput?a:a.map(({canonical:o,aliases:r})=>({canonical:o,aliases:r})),t.fullOutput||(e.command_alias_contracts_omitted_reason="compact_projection; restore with --full")}}function as(e,t){if(!(t.schemaOnly||t.flagsOnly||t.availabilityOnly)){if(!t.omitUnfilteredCommanderAliases){e.commander_aliases=wa();return}e.commander_aliases_omitted_reason=t.selectedCommand?"command_scoped":"unfiltered_default_brief"}}function ss(e,t,n,s){e.command_summaries=Ge(t,n,{includeFormatBudgets:s.includeFormatBudgets,includeIntentProvenance:s.includeIntentProvenance}),e.output_policy={token_estimate:"ceil(utf8_bytes / 4)",degradation_ladder:[..._n],allows_unbounded_opt_out:!0},e.output_projection_contracts={global_ladder_field:"output_policy.degradation_ladder",global_ladder_scope:"union_not_per_command",discovery:"pm contracts --command <command> --summary",...s.includeProjectionModeMatrix?{commands:[...new Set(t.map(p))].filter(a=>na(a)!==void 0).sort((a,o)=>a.localeCompare(o)).map(a=>({command:a,modes:[...ta(a).keys()]}))}:{}},e.grammar_contracts={nouns:y.nouns,shared_verbs:y.shared_verbs,scope_before_verb:y.scope_before_verb,visible_top_level_ceiling:y.visible_top_level_ceiling,ceiling_raise_requires_pm_item:y.ceiling_raise_requires_pm_item,positional_shape_budget:y.positional_shape_budget,positional_shape_count:new Set(ee.map(({slots:a})=>pa(a))).size,positional_action_count:te.length,positional_action_parents:[...new Set(te.map(({parent:a})=>a))].sort((a,o)=>a.localeCompare(o)),...s.includePositionalSignatures?{positional_signatures:ee}:{}}}async function Es(e,t){const n=Fa(e);ka(n);const s=j(process.cwd(),t.path),a=await ba(t,s,n),o=Ba(n,a),r=Va(n,a,o),i=Ka(n,o),c=Ya(n,i,a.extensionContracts),l=Za(n,r,o,c),u=Qa(n,a,c),m=n.fullOutput||n.selectedCommand!==void 0;if((n.summary||n.fullOutput)&&ss(l,c,u,{includeFormatBudgets:m,includeIntentProvenance:m,includePositionalSignatures:m,includeProjectionModeMatrix:m}),n.summary)return l;const _=Ia(o.commandCatalog.filter(C=>w(n,C,a.extensionContracts)));return n.flagsOnly&&!n.fullOutput||es(l,a,n),ts(l,n,r,u),ns(l,n,a,c,_),as(l,n),(n.selectedCommand==="assurance"||n.fullOutput)&&(l.assurance_contracts={measurement_source_kinds:[...ua],gate_triggers:[...da]}),n.fullOutput&&l.grammar_contracts&&(l.grammar_contracts.destinations=ma.map(C=>({...C,reason:C.reason??""}))),n.fullOutput&&!n.schemaOnly&&!n.flagsOnly&&!n.availabilityOnly&&(l.mcp_tools=Ze(),l.context_intents=ea(),l.read_output_dimensions=aa,l.error_codes=oa,l.command_output_contracts=Pe(c),l.diagnostic_output_contracts=qn,l.command_exit_contracts={vocabulary:ia,command_sets:De(c)}),l}const Rs={actionDescriptorMatchesSelectedCommand:ue,attachCreateRequiredOptionContracts:Ie,buildExtensionActionSchemaBranch:Ae,buildCommandSummarySurface:Ge,buildCommandOutputContracts:Pe,buildCommandExitContractGroups:De,buildRuntimeFieldFlagContracts:Ee,collectActionContractDescriptors:Oe,collectExtensionCommandContracts:fe,collectExtensionFlagContractsByCommand:P,extractActionBranches:N,extensionSchemaPropertyNameFromFlag:Ce,withExtensionFlagOwnership:Le,filterSchemaByAction:pe,filterSchemaByActions:I,isCoreCommandPath:Se,mergeExtensionContractsByAction:ge,normalizeExtensionFlagName:G,normalizeActionNameFromCommand:k,normalizeCommandForRuntimeFieldFlags:ye,normalizeCommandPath:p,packageOwnedActionForCommand:de,readContractsSettings:we,resolveActionCommandPath:F,resolveActionAvailability:he,resolveCoreCommandFlags:D,resolveRuntimeExtensionActionProbe:Te,resolveScopedCommandsFromActionDescriptors:me,splitCommandPathAliases:A,toRuntimeLongFlagToken:U,toRuntimeShortFlagToken:Ne};export{Rs as _testOnlyContractsCommand,Ia as buildCommandAliasSurface,Se as isCoreCommandPath,Es as runContracts};
|
|
2
2
|
//# sourceMappingURL=runtime-contracts.js.map
|