@unbrained/pm-cli 2026.10.18 → 2026.10.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/.claude-plugin/marketplace.json +1 -1
  2. package/CHANGELOG.md +43 -0
  3. package/dist/cli/error-guidance.d.ts +7 -0
  4. package/dist/cli/error-guidance.js +2 -2
  5. package/dist/cli/help-content.js +2 -2
  6. package/dist/cli/register-mutation.js +2 -2
  7. package/dist/cli/register-setup.js +1 -1
  8. package/dist/cli/register-structured-mutation.js +1 -1
  9. package/dist/cli-bundle/bundle-manifest.json +1 -1
  10. package/dist/cli-bundle/chunks/{chunk-PYRREEUB.js → chunk-2GGGOD7P.js} +28 -28
  11. package/dist/cli-bundle/chunks/chunk-7NHA5K77.js +126 -0
  12. package/dist/cli-bundle/chunks/chunk-7ZOIZ2AZ.js +8 -0
  13. package/dist/cli-bundle/chunks/{chunk-4GA4MUTE.js → chunk-GHJOMRSF.js} +2 -2
  14. package/dist/cli-bundle/chunks/chunk-KU4Q3MSI.js +8 -0
  15. package/dist/cli-bundle/chunks/chunk-LS55VKRK.js +3 -0
  16. package/dist/cli-bundle/chunks/chunk-PNPE2OVJ.js +112 -0
  17. package/dist/cli-bundle/chunks/chunk-PTL3TBT6.js +20 -0
  18. package/dist/cli-bundle/chunks/chunk-QETMESEB.js +6 -0
  19. package/dist/cli-bundle/chunks/{chunk-7WIEAGDS.js → chunk-QMZ73FCW.js} +2 -2
  20. package/dist/cli-bundle/chunks/chunk-QQYCB2LO.js +2 -0
  21. package/dist/cli-bundle/chunks/chunk-RUKSEZE7.js +2 -0
  22. package/dist/cli-bundle/chunks/chunk-TZU6U5ZE.js +3 -0
  23. package/dist/cli-bundle/chunks/chunk-VLJLWZBO.js +70 -0
  24. package/dist/cli-bundle/chunks/chunk-VS565KBX.js +2 -0
  25. package/dist/cli-bundle/chunks/chunk-XAWE4EAK.js +2 -0
  26. package/dist/cli-bundle/chunks/chunk-YECCKB4E.js +3 -0
  27. package/dist/cli-bundle/chunks/{chunk-FIJOSX2C.js → chunk-YT2Z3JPC.js} +72 -66
  28. package/dist/cli-bundle/chunks/chunk-YTHI5DTH.js +2 -0
  29. package/dist/cli-bundle/chunks/{chunk-6VZKYJW7.js → chunk-YW6SIKYP.js} +2 -2
  30. package/dist/cli-bundle/chunks/{chunk-ZZED447K.js → chunk-ZA3XXHEE.js} +6 -6
  31. package/dist/cli-bundle/chunks/context-budget-recovery-L2WP5S26.js +2 -0
  32. package/dist/cli-bundle/chunks/indexed-receipt-blobs-U7VGKIYC.js +4 -0
  33. package/dist/cli-bundle/chunks/{register-list-query-PUCVYYBD.js → register-list-query-NNDV6F6I.js} +3 -3
  34. package/dist/cli-bundle/chunks/register-mutation-3GCBSNQS.js +20 -0
  35. package/dist/cli-bundle/chunks/register-operations-YKDGNKUL.js +2 -0
  36. package/dist/cli-bundle/chunks/register-setup-AOUZQQWB.js +2 -0
  37. package/dist/cli-bundle/chunks/settlement-hook-CLRGA6O7.js +7 -0
  38. package/dist/cli-bundle/chunks/stage-6QXYRMSU.js +2 -0
  39. package/dist/cli-bundle/focused-chunks/chunk-37SU7BZI.js +3 -0
  40. package/dist/cli-bundle/focused-chunks/chunk-6IU7BESB.js +65 -0
  41. package/dist/cli-bundle/focused-chunks/chunk-AK2CI2GI.js +2 -0
  42. package/dist/cli-bundle/focused-chunks/chunk-AS3MOBO3.js +25 -0
  43. package/dist/cli-bundle/focused-chunks/chunk-AW35RDKA.js +78 -0
  44. package/dist/cli-bundle/focused-chunks/chunk-E4II2D2B.js +3 -0
  45. package/dist/cli-bundle/focused-chunks/{chunk-A4ZHHTEX.js → chunk-F7FD25TG.js} +12 -12
  46. package/dist/cli-bundle/focused-chunks/chunk-FOA7XKWP.js +2 -0
  47. package/dist/cli-bundle/focused-chunks/{chunk-TB7F4FCR.js → chunk-GYHZ7W6O.js} +2 -2
  48. package/dist/cli-bundle/focused-chunks/chunk-H5Q2HUU6.js +8 -0
  49. package/dist/cli-bundle/focused-chunks/chunk-HUZAXSIJ.js +3 -0
  50. package/dist/cli-bundle/focused-chunks/chunk-J6EYUGAR.js +6 -0
  51. package/dist/cli-bundle/focused-chunks/chunk-JEXZEIAX.js +91 -0
  52. package/dist/cli-bundle/focused-chunks/{chunk-BFEMT5U3.js → chunk-KDGUIIRU.js} +3 -3
  53. package/dist/cli-bundle/focused-chunks/{chunk-ZDBS2DCT.js → chunk-KKRFSI2N.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/chunk-LJPUJ2KK.js +2 -0
  55. package/dist/cli-bundle/focused-chunks/chunk-MQ42BFGX.js +2 -0
  56. package/dist/cli-bundle/focused-chunks/{chunk-IRVL4UXR.js → chunk-NI6NS44Q.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/chunk-VAYS754X.js +2 -0
  58. package/dist/cli-bundle/focused-chunks/{chunk-Z7YIFCNE.js → chunk-VLSER3XW.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/chunk-VS6VTWTZ.js +8 -0
  60. package/dist/cli-bundle/focused-chunks/chunk-VVRXF4JO.js +2 -0
  61. package/dist/cli-bundle/focused-chunks/chunk-ZGEK57KD.js +2 -0
  62. package/dist/cli-bundle/focused-chunks/context-budget-recovery-5MKOCGY5.js +2 -0
  63. package/dist/cli-bundle/focused-chunks/indexed-receipt-blobs-H2G6CCGO.js +4 -0
  64. package/dist/cli-bundle/focused-chunks/settlement-hook-5SNBBT7C.js +7 -0
  65. package/dist/cli-bundle/focused-chunks/stage-EMTISXR7.js +2 -0
  66. package/dist/cli-bundle/main.js +21 -21
  67. package/dist/cli-bundle/sdk-authoring.js +1 -1
  68. package/dist/cli-bundle/sdk-contracts.js +2 -2
  69. package/dist/cli-bundle/sdk-core.js +28 -22
  70. package/dist/cli-bundle/sdk-governance.js +1 -1
  71. package/dist/cli-bundle/sdk-graph.js +1 -1
  72. package/dist/cli-bundle/sdk-merge.js +66 -53
  73. package/dist/cli-bundle/sdk-query.js +1 -1
  74. package/dist/cli-bundle/sdk-runtime.js +1 -1
  75. package/dist/cli-bundle/sdk-testing.js +1 -1
  76. package/dist/cli-bundle/sdk.js +8 -8
  77. package/dist/core/fs/fs-utils.d.ts +2 -2
  78. package/dist/core/fs/fs-utils.js +1 -1
  79. package/dist/core/history/event-index.js +2 -2
  80. package/dist/core/output/output.d.ts +7 -2
  81. package/dist/core/output/output.js +5 -5
  82. package/dist/core/shared/errors.d.ts +48 -0
  83. package/dist/core/shared/errors.js +1 -1
  84. package/dist/core/store/settings.js +2 -2
  85. package/dist/mcp/server.js +1 -1
  86. package/dist/sdk/cli-contracts/bootstrap-command-scanner.js +1 -1
  87. package/dist/sdk/cli-contracts/flag-contracts.js +1 -1
  88. package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +1 -1
  89. package/dist/sdk/cli-contracts/runtime-contracts.d.ts +1 -0
  90. package/dist/sdk/cli-contracts/runtime-contracts.js +1 -1
  91. package/dist/sdk/cli-contracts/tool-parameter-tables.js +1 -1
  92. package/dist/sdk/cli-contracts/tool-schema.js +1 -1
  93. package/dist/sdk/core.d.ts +1 -1
  94. package/dist/sdk/core.js +1 -1
  95. package/dist/sdk/dependencies/context-budget-recovery.d.ts +21 -0
  96. package/dist/sdk/dependencies/context-budget-recovery.js +2 -0
  97. package/dist/sdk/dependencies.js +1 -1
  98. package/dist/sdk/errors.d.ts +4 -1
  99. package/dist/sdk/errors.js +1 -1
  100. package/dist/sdk/extension/install-sources.js +3 -3
  101. package/dist/sdk/extension/shared.js +1 -1
  102. package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1 -1
  103. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1 -1
  104. package/dist/sdk/governance/health.js +1 -1
  105. package/dist/sdk/history-repair.js +1 -1
  106. package/dist/sdk/index.d.ts +1 -1
  107. package/dist/sdk/index.js +1 -1
  108. package/dist/sdk/item-transaction.d.ts +13 -0
  109. package/dist/sdk/item-transaction.js +1 -1
  110. package/dist/sdk/lifecycle/structured-mutation-plan.d.ts +14 -1
  111. package/dist/sdk/lifecycle/structured-mutation-plan.js +1 -1
  112. package/dist/sdk/merge/driver.js +7 -1
  113. package/dist/sdk/merge/indexed-receipt-blobs.d.ts +2 -0
  114. package/dist/sdk/merge/indexed-receipt-blobs.js +4 -0
  115. package/dist/sdk/merge/install.d.ts +8 -0
  116. package/dist/sdk/merge/install.js +3 -3
  117. package/dist/sdk/merge/receipts.d.ts +6 -0
  118. package/dist/sdk/merge/receipts.js +2 -2
  119. package/dist/sdk/merge/reconcile.d.ts +6 -0
  120. package/dist/sdk/merge/reconcile.js +1 -1
  121. package/dist/sdk/merge/settlement-hook.d.ts +12 -0
  122. package/dist/sdk/merge/settlement-hook.js +7 -0
  123. package/dist/sdk/merge/stage.d.ts +13 -0
  124. package/dist/sdk/merge/stage.js +2 -0
  125. package/dist/sdk/output/list-envelope.d.ts +7 -0
  126. package/dist/sdk/output/list-envelope.js +2 -0
  127. package/dist/sdk/output.d.ts +1 -0
  128. package/dist/sdk/output.js +2 -2
  129. package/dist/sdk/public-surface.json +1 -1
  130. package/dist/sdk/query/list.js +1 -1
  131. package/dist/sdk/relationship-context.d.ts +2 -0
  132. package/dist/sdk/relationship-context.js +1 -1
  133. package/dist/sdk/runtime-extended-actions.js +1 -1
  134. package/dist/sdk/structured-mutations.d.ts +2 -0
  135. package/dist/sdk/structured-mutations.js +1 -1
  136. package/docs/COMMANDS.md +27 -0
  137. package/docs/CONFIGURATION.md +14 -0
  138. package/docs/MERGE_SAFETY.md +88 -5
  139. package/docs/PR_REVIEW_LOOP.md +32 -12
  140. package/docs/SCRIPTING.md +10 -0
  141. package/docs/SDK.md +103 -0
  142. package/docs/TESTING.md +32 -1
  143. package/docs/generated/FLAG_LEXICON_BUDGETS.md +2 -2
  144. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +6 -3
  145. package/marketplace.json +1 -1
  146. package/package.json +1 -1
  147. package/packages/pm-beads/package.json +1 -1
  148. package/packages/pm-calendar/package.json +1 -1
  149. package/packages/pm-command-kit/package.json +1 -1
  150. package/packages/pm-digital-twin/package.json +1 -1
  151. package/packages/pm-governance-audit/package.json +1 -1
  152. package/packages/pm-guide-shell/package.json +1 -1
  153. package/packages/pm-kanban/package.json +1 -1
  154. package/packages/pm-lifecycle-hooks/package.json +1 -1
  155. package/packages/pm-linked-test-adapters/package.json +1 -1
  156. package/packages/pm-search-advanced/package.json +1 -1
  157. package/packages/pm-templates/package.json +1 -1
  158. package/packages/pm-todos/package.json +1 -1
  159. package/packages/pm-vcs/package.json +1 -1
  160. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  161. package/plugins/pm-claude/package.json +1 -1
  162. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  163. package/plugins/pm-codex/package.json +1 -1
  164. package/plugins/pm-codex/plugin.json +1 -1
  165. package/runtime-dependencies.json +1 -1
  166. package/dist/cli-bundle/chunks/chunk-4V6ONLI6.js +0 -3
  167. package/dist/cli-bundle/chunks/chunk-7PATQWTH.js +0 -20
  168. package/dist/cli-bundle/chunks/chunk-AETP4JEM.js +0 -3
  169. package/dist/cli-bundle/chunks/chunk-LUKVNL72.js +0 -2
  170. package/dist/cli-bundle/chunks/chunk-OJ77ZQN3.js +0 -8
  171. package/dist/cli-bundle/chunks/chunk-RHQJ6VWC.js +0 -237
  172. package/dist/cli-bundle/chunks/chunk-RNABUEFB.js +0 -80
  173. package/dist/cli-bundle/chunks/chunk-TO6CIV4C.js +0 -2
  174. package/dist/cli-bundle/chunks/register-mutation-GGGVBXD5.js +0 -20
  175. package/dist/cli-bundle/chunks/register-operations-NRZ6Q4QE.js +0 -2
  176. package/dist/cli-bundle/chunks/register-setup-MV3P3YSF.js +0 -2
  177. package/dist/cli-bundle/focused-chunks/chunk-2MPQUMTF.js +0 -2
  178. package/dist/cli-bundle/focused-chunks/chunk-5UKCSZWT.js +0 -2
  179. package/dist/cli-bundle/focused-chunks/chunk-B4YLP5ZB.js +0 -3
  180. package/dist/cli-bundle/focused-chunks/chunk-FW7CSSKL.js +0 -75
  181. package/dist/cli-bundle/focused-chunks/chunk-HYPRPSYD.js +0 -3
  182. package/dist/cli-bundle/focused-chunks/chunk-L55KQ2KT.js +0 -2
  183. package/dist/cli-bundle/focused-chunks/chunk-MASIOFPG.js +0 -8
  184. package/dist/cli-bundle/focused-chunks/chunk-RJ3EIHDU.js +0 -26
  185. package/dist/cli-bundle/focused-chunks/chunk-SEL4Z2OO.js +0 -167
  186. package/dist/cli-bundle/focused-chunks/chunk-TZUIBG3P.js +0 -2
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4f5b83c9-8f48-5a2c-9058-cd993d25dc98")}catch{}})();import{realpathSync}from"node:fs";import{readFile}from"node:fs/promises";import path from"node:path";import readline from"node:readline";import{fileURLToPath}from"node:url";import{resolvePmCliVersion,EXIT_CODE,PmCliError,decodeHtmlEntitiesInOptions,levenshteinDistanceWithinLimit,asRecordClone,createSerialQueue,evaluateMutationGuard,getSettingsPath,isMutationAction,pathExists,readSettings,runWithHarnessDetectionSignals,runWithWorkspaceHarnessSignalDescriptors,boundAgentEpisodeIdentity}from"../sdk/runtime-primitives.js";import{pmToolActionNestedOptionKeys}from"../sdk/cli-contracts/tool-schema.js";import{readRequiredString,runAction,runWithActiveExtensions}from"../sdk/runtime.js";import{NARROW_TOOL_ACTIONS,TOOLS}from"./tool-definitions.js";import{normalizeWorkspaceToolArguments,resolveMcpToolAccess,resolveMcpToolSurface}from"./runtime-capabilities.js";import{PM_MCP_PROMPT_CONTRACTS,PM_MCP_RESOURCE_CONTRACTS}from"../sdk/agent-capability-contracts.js";import{PM_MCP_ENTRY_TOOL_NAMES,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION,PM_MCP_PROGRESSIVE_DISCOVERY_SERVER_CAPABILITY,discoverPmTools,parsePmToolDiscoveryOptions}from"../sdk/mcp/discovery.js";import{commitItemMutations,previewItemMutations}from"../sdk/item-transaction.js";import{isRuntimeRecord,markMcpMutationTransportInput}from"../sdk/runtime-input.js";import{attachOutputTokenAccounting}from"../sdk/output-token-accounting.js";import{createReproducibleProcessRunner,runWithReproducibleProcessEnvironment}from"../sdk/reproducibility/process.js";import{parseAtomicMutationControls}from"../sdk/structured-mutations.js";import{planItemMutationDocument}from"../sdk/lifecycle/structured-mutation-plan.js";import{resolveAuthor,resolvePmRoot,resolveWorkspaceRoot}from"../sdk/runtime-primitives.js";import{PM_MCP_ERROR_CODES,PM_MCP_META_KEYS,PM_MCP_PROTOCOL_VERSION,PmMcpProtocolError,attachMcpServerInfo,buildMcpCompleteResult,buildMcpDiscoverResult,hasMcpClientExtension,isMcpRecord,resolveMcpRequestContext}from"../sdk/mcp/protocol.js";import{PmMcpInputRequiredError,buildMcpInputRequiredResult,parseMcpInputResponses,validateMcpJsonSchema,withMcpCachePolicy}from"../sdk/mcp/interactions.js";import{PM_MCP_TASKS_EXTENSION,createMcpTaskStore}from"../sdk/mcp/tasks.js";import{PmMcpSubscriptionRegistry}from"../sdk/mcp/subscriptions.js";import{extractMcpTraceContext,runWithMcpTraceContext}from"../sdk/mcp/authorization.js";import{LegacyMcpAdapter}from"./legacy-adapter.js";import{PM_MCP_APP_CONTRACTS,PM_MCP_APP_MIME_TYPE,PM_MCP_APPS_EXTENSION,PM_MCP_APPS_SERVER_CAPABILITY,decoratePmMcpToolsWithApps,findPmMcpAppByUri,hasPmMcpAppsCapability,renderPmMcpAppHtml}from"../sdk/mcp/apps.js";import{PM_MCP_SKILLS_EXTENSION,PM_MCP_SKILLS_SERVER_CAPABILITY,PmMcpSkillRegistry,assertPmMcpSkillsCapability}from"../sdk/mcp/skills.js";function runMcpAction(args){return runAction(markMcpMutationTransportInput(args))}const PM_PACKAGE_ROOT_ENV="PM_CLI_PACKAGE_ROOT";function resolvePmPackageRoot(){return fileURLToPath(new URL("../..",import.meta.url))}(typeof process.env[PM_PACKAGE_ROOT_ENV]!="string"||process.env[PM_PACKAGE_ROOT_ENV]?.trim().length===0)&&(process.env[PM_PACKAGE_ROOT_ENV]=resolvePmPackageRoot());const PM_MCP_SERVER_VERSION=resolvePmCliVersion(import.meta.url,["../.."])??"0.0.0",PM_MCP_SERVER_INFO={name:"pm-mcp",version:PM_MCP_SERVER_VERSION,description:"Stateless project-context management through pm SDK contracts.",websiteUrl:"https://github.com/unbraind/pm-cli"},PM_MCP_SERVER_CAPABILITIES={prompts:{listChanged:!0},resources:{listChanged:!0,subscribe:!0},tools:{listChanged:!0},extensions:{[PM_MCP_TASKS_EXTENSION]:{},[PM_MCP_APPS_EXTENSION]:PM_MCP_APPS_SERVER_CAPABILITY,[PM_MCP_SKILLS_EXTENSION]:PM_MCP_SKILLS_SERVER_CAPABILITY,[PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION]:PM_MCP_PROGRESSIVE_DISCOVERY_SERVER_CAPABILITY}},PM_MCP_SUBSCRIPTIONS=new Map;function createMcpSubscriptionRegistry(){return new PmMcpSubscriptionRegistry({capabilities:PM_MCP_SERVER_CAPABILITIES,serverInfo:PM_MCP_SERVER_INFO})}function pruneClosedMcpSubscriptionRegistries(){for(const[key,subscription]of PM_MCP_SUBSCRIPTIONS)subscription.registry.size===0&&PM_MCP_SUBSCRIPTIONS.delete(key)}const PM_MCP_CACHE_POLICIES={prompts:{ttlMs:6e4,cacheScope:"public"},resource:{ttlMs:0,cacheScope:"private"},resources:{ttlMs:6e4,cacheScope:"public"},tools:{ttlMs:3e4,cacheScope:"private"}},PM_MCP_DIRECT_TASK_TOOLS=new Set(["pm_graph","pm_health","pm_validate"]),PM_MCP_RUN_TASK_ACTIONS=new Set(["graph","health","import","reindex","test-all","validate"]),PM_MCP_SKILL_METHODS=new Set(["skills/list","skills/get","resources/directory/read"]),PM_MCP_INSTRUCTIONS="You have access to native pm CLI tools for git-based project management. When progressive discovery is negotiated, use pm_discover to expand the small entry catalog by intent and request schemas only when needed. Use pm_next to pick the next actionable item, or pm_context or pm_search before creating new work. Prefer narrow tools (pm_next, pm_context, pm_list, pm_get, pm_search, pm_events, pm_create, pm_mutate, pm_copy, pm_focus, pm_update, pm_append, pm_claim, pm_release, pm_close, pm_comments, pm_files, pm_docs, pm_notes, pm_learnings, pm_deps, pm_graph, pm_test, pm_validate, pm_health, pm_contracts, pm_schema, pm_profile, pm_config, pm_plan) over pm_run when they cover the operation. Use pm_plan for agent harness Plan workflows: it provides Codex/Claude/Cursor-style planning with durable steps, dependencies, decisions, discoveries, validation, and materialization. Use pm_schema and pm_config for workspace configuration: pm_schema manages custom item types/statuses and pm_config reads or writes settings keys. Use pm_run with an explicit action for active package-owned operations, plus activity, aggregate, history, stats, test-all, and gc. Use history-redact for audited history-stream redaction workflows, history-repair to re-anchor a drifted history chain, and history-compact to checkpoint/prune long history streams while preserving replay integrity. Agent harness and model provenance are detected automatically; pass author only for an intentional identity override. Do not pass path during real repository tracking \u2014 only pass path for sandbox or test runs.";function declaredToolKeys(tools=TOOLS){return new Map(tools.map(tool=>{const properties=tool.inputSchema.properties??{};return[tool.name,Object.keys(properties)]}))}function nearestDeclaredKey(unexpected,declared){const limit=Math.max(1,Math.min(3,Math.floor(unexpected.length/4)+1));let best;for(const candidate of declared){const distance=levenshteinDistanceWithinLimit(unexpected,candidate,limit);distance!==null&&(best===void 0||distance<best.distance)&&(best={key:candidate,distance})}return best?.key}const UNEXPECTED_KEY_WARNING_EXEMPT_TOOLS=new Set(["pm_run"]),MCP_RETRY_ARGUMENT_KEYS=new Set(["inputResponses","requestState"]);function resolveMcpDiscoveryCursorIntegrityKey(){const configuredKey=process.env.PM_MCP_DISCOVERY_CURSOR_KEY;if(configuredKey===void 0)return;const key=Buffer.from(configuredKey,"utf8");if(key.byteLength<32)throw new PmCliError("PM_MCP_DISCOVERY_CURSOR_KEY must contain at least 32 UTF-8 bytes.",64);return key}function detectUnexpectedTopLevelKeys(toolName,args,toolDeclaredKeys=declaredToolKeys()){if(typeof args!="object"||args===null||Array.isArray(args))return[];if(UNEXPECTED_KEY_WARNING_EXEMPT_TOOLS.has(toolName))return[];const declared=toolDeclaredKeys.get(toolName);if(declared===void 0)return[];const declaredSet=new Set([...declared,...MCP_RETRY_ARGUMENT_KEYS]),warnings=[];for(const key of Object.keys(args)){if(declaredSet.has(key))continue;const suggestion=nearestDeclaredKey(key,declared);warnings.push(suggestion!==void 0?`Unexpected top-level argument "${key}" for ${toolName} (did you mean "${suggestion}"?). It is not declared and may be ignored; declared arguments are: ${declared.join(", ")}.`:`Unexpected top-level argument "${key}" for ${toolName}. It is not declared and may be ignored; declared arguments are: ${declared.join(", ")}.`)}return warnings}const HANDLERS={pm_run:args=>runMcpAction(args),pm_discover:async args=>{const surface=await resolveMcpToolSurface(TOOLS,args),cursorIntegrityKey=resolveMcpDiscoveryCursorIntegrityKey(),discoveryOptions=parsePmToolDiscoveryOptions(args);return discoverPmTools(surface.tools.map(tool=>({name:tool.name,description:tool.description,inputSchema:tool.inputSchema,authorized:!0,signals:{freshness:1,usage:PM_MCP_ENTRY_TOOL_NAMES.includes(tool.name)?1:0}})),{...discoveryOptions,profile:surface.profile,...cursorIntegrityKey===void 0?{}:{cursorIntegrityKey}})},pm_mutate:async args=>{if(!Array.isArray(args.mutations)||args.mutations.length===0)throw new PmCliError("pm_mutate requires a non-empty mutations array.",EXIT_CODE.USAGE);const explicitTransactionId=args.transactionId===void 0?void 0:readRequiredString(args,"transactionId"),upsertKey=args.upsertKey===void 0?void 0:readRequiredString(args,"upsertKey"),controls=parseAtomicMutationControls(args),cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),pmRoot=resolvePmRoot(cwd,typeof args.path=="string"?args.path:void 0),extensionScope={cwd:typeof args.cwd=="string"?args.cwd:void 0,path:pmRoot,noExtensions:args.noExtensions===!0},plan=await runWithActiveExtensions(extensionScope,()=>planItemMutationDocument({pmRoot,input:JSON.stringify({schema_version:1,mutations:args.mutations}),...explicitTransactionId===void 0?{}:{transactionId:explicitTransactionId},...upsertKey===void 0?{}:{upsertKey}})),{mutations,references,rows}=plan,transactionId=plan.transaction_id,receipt={transaction_id:transactionId,transaction_id_source:plan.transaction_id_source,...plan.upsert_key===void 0?{}:{upsert_key:plan.upsert_key}};if(args.dryRun===!0){const validation=await runWithActiveExtensions(extensionScope,()=>previewItemMutations({pmRoot,transactionId,author:resolveAuthor(typeof args.author=="string"?args.author:void 0,"unknown"),mutations}));return{...receipt,dry_run:!0,validation,mutation_count:mutations.length,mutations,references,rows}}const result=await runWithActiveExtensions(extensionScope,()=>commitItemMutations({pmRoot,transactionId,author:resolveAuthor(typeof args.author=="string"?args.author:void 0,"unknown"),mutations,...controls}));return{...Object.fromEntries(Object.entries(result).filter(([key])=>key!=="transactionId")),...receipt,mutation_count:mutations.length,references,rows}},...Object.fromEntries(Object.entries(NARROW_TOOL_ACTIONS).map(([tool,action])=>[tool,args=>runMcpAction({...args,action})]))};function resolveInvokedAction(toolName,args){return toolName==="pm_run"?typeof args.action=="string"?args.action:void 0:NARROW_TOOL_ACTIONS[toolName]}async function collectMutationGuardWarnings(toolName,action,args){if(toolName!=="pm_mutate"&&!isMutationAction(action??""))return[];const cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),pmRoot=resolvePmRoot(cwd,typeof args.path=="string"?args.path:void 0);if(!await pathExists(getSettingsPath(pmRoot)))return[];const settings=await readSettings(pmRoot),nestedOptions=typeof args.options=="object"&&args.options!==null&&!Array.isArray(args.options)?args.options:{};return evaluateMutationGuard({author:resolveAuthor(typeof args.author=="string"?args.author:typeof nestedOptions.author=="string"?nestedOptions.author:void 0,settings.author_default),payload:Object.fromEntries(Object.entries(args).filter(([key])=>key!=="cwd"&&key!=="path")),settings:settings.mutation_guard,force:args.force===!0||nestedOptions.force===!0}).warnings}function detectUnexpectedOptionKeys(toolName,action,args){const options=args.options;if(action===void 0||typeof options!="object"||options===null||Array.isArray(options))return[];const declared=pmToolActionNestedOptionKeys(action);if(declared===void 0)return[];const declaredSet=new Set(declared),warnings=[];for(const key of Object.keys(options)){if(declaredSet.has(key))continue;const suggestion=nearestDeclaredKey(key,declared);warnings.push(suggestion!==void 0?`Unknown option "${key}" for ${toolName} action "${action}" (did you mean "${suggestion}"?). The ${action} contract does not read it, so it has no effect; declared keys are: ${declared.join(", ")}.`:`Unknown option "${key}" for ${toolName} action "${action}". The ${action} contract does not read it, so it has no effect; declared keys are: ${declared.join(", ")}.`)}return warnings}function resultContent(result,warnings,tokenAccounting=!1,canonicalStructuredResult=!1){const effectiveResult=tokenAccounting?attachOutputTokenAccounting(result,value=>JSON.stringify(value,null,2)):result,structuredContent=warnings!==void 0&&warnings.length>0?{result:effectiveResult,warnings}:{result:effectiveResult};return{content:[{type:"text",text:canonicalStructuredResult?"Canonical result: structuredContent.result":JSON.stringify(effectiveResult,null,2)}],structuredContent}}function errorContent(error,canonicalStructuredResult=!1){const code=error instanceof PmCliError?error.exitCode:1,message=error instanceof Error?error.message:String(error),details=error instanceof PmCliError?error.context:void 0;return{isError:!0,content:[{type:"text",text:canonicalStructuredResult?"Canonical error: structuredContent":JSON.stringify({error:message,code,details},null,2)}],structuredContent:{result:null,error:message,code,details}}}function boundMcpClientProvenance(value){const provenance=isRuntimeRecord(value)?value:{},bounded={};let acceptedCount=0;for(const key in provenance){if(acceptedCount>=32)break;if(!Object.prototype.hasOwnProperty.call(provenance,key))continue;const entry=provenance[key];/^[a-z][a-z0-9_-]{0,63}$/u.test(key)&&typeof entry=="string"&&entry.trim().length>0&&(bounded[key]=entry.trim().slice(0,256),acceptedCount+=1)}return bounded}function readMcpClientInfo(value){const clientInfo=isRuntimeRecord(value)?value:{},clientName=typeof clientInfo.name=="string"?clientInfo.name.trim():"";if(clientName.length===0)return;const optionalValues=[["version",clientInfo.version,128],["model",clientInfo.model,256],["session",clientInfo.session,256]],result={name:clientName.slice(0,128)};for(const[key,value2,limit]of optionalValues)typeof value2=="string"&&value2.trim().length>0&&(result[key]=value2.trim().slice(0,limit));const boundedProvenance=boundMcpClientProvenance(clientInfo.provenance);Object.keys(boundedProvenance).length>0&&(result.provenance=boundedProvenance);const episode=boundAgentEpisodeIdentity(clientInfo.episode,!1);return episode!==void 0&&(result.episode=episode),result}async function emitMcpChangeNotifications(action){isMutationAction(action??"")&&await Promise.all([...PM_MCP_SUBSCRIPTIONS.values()].flatMap(({registry})=>PM_MCP_RESOURCE_CONTRACTS.map(resource=>registry.emitResourceUpdated(resource.uri)))),["extension","install","package","uninstall"].includes(action??"")&&await Promise.all([...PM_MCP_SUBSCRIPTIONS.values()].map(({registry})=>registry.emitListChanged("tools"))),pruneClosedMcpSubscriptionRegistries()}async function handleToolCall(paramsInput,clientInfo,progressiveDiscoveryNegotiated=!1){const clientSignals=clientInfo?{client_info:clientInfo}:{};return runWithHarnessDetectionSignals({env:process.env,argv:process.argv,...clientSignals},async()=>{const params=asRecordClone(paramsInput),name=readRequiredString(params,"name"),handler=Object.prototype.hasOwnProperty.call(HANDLERS,name)?HANDLERS[name]:void 0;if(!handler)throw new PmCliError(`Unknown pm MCP tool: ${name}`,64);const inputResponses=params.inputResponses===void 0?void 0:parseMcpInputResponses(params.inputResponses);validateMcpToolArguments(params.arguments);const requestedArgs={...decodeHtmlEntitiesInOptions(asRecordClone(params.arguments)),...inputResponses?{inputResponses}:{},...typeof params.requestState=="string"?{requestState:params.requestState}:{}},access=await resolveMcpToolAccess(TOOLS,name,requestedArgs),requiredCustomDiscoveryEntry=progressiveDiscoveryNegotiated&&access.profile==="custom"&&name==="pm_discover";if(!access.available&&!requiredCustomDiscoveryEntry)throw new PmCliError(`pm MCP tool "${name}" is unavailable in the ${access.profile} profile.`,64);const args=await normalizeWorkspaceToolArguments(name,requestedArgs),cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),pmRoot=resolvePmRoot(cwd,typeof args.path=="string"?args.path:void 0),workspaceIdentity=await pathExists(getSettingsPath(pmRoot))?(await readSettings(pmRoot)).agent_identity:void 0;return runWithHarnessDetectionSignals({env:{...process.env,PM_PATH:pmRoot},argv:process.argv,cwd,...clientSignals},()=>runWithWorkspaceHarnessSignalDescriptors(workspaceIdentity?.harness_signals??[],async()=>{const action=resolveInvokedAction(name,args),warnings=[...detectUnexpectedTopLevelKeys(name,args,declaredToolKeys()),...detectUnexpectedOptionKeys(name,action,args),...await collectMutationGuardWarnings(name,action,args)];for(const warning of warnings)console.error(`[pm-mcp] ${warning}`);const result=await handler(args);return emitMcpChangeNotifications(action),resultContent(result,warnings,args.tokenAccounting===!0,progressiveDiscoveryNegotiated)},{probesEnabled:workspaceIdentity?.probes_enabled}))})}async function openMcpSubscription(input){if(typeof input.request.id!="string"&&typeof input.request.id!="number"||input.request.method!=="subscriptions/listen")throw new PmMcpProtocolError("Invalid MCP subscriptions/listen request",PM_MCP_ERROR_CODES.invalidParams,{required:["id","method","params.notifications"]});resolveMcpRequestContext(input.request.params);const key=input.key??input.request.id;if(PM_MCP_SUBSCRIPTIONS.has(key))throw new PmMcpProtocolError("MCP subscription id is already active",PM_MCP_ERROR_CODES.invalidParams,{subscriptionId:input.request.id});const registry=createMcpSubscriptionRegistry();await registry.open({id:input.request.id,notifications:input.request.params?.notifications,sink:input.sink}),PM_MCP_SUBSCRIPTIONS.set(key,{id:input.request.id,registry})}function closeMcpSubscription(id,key=id){const subscription=PM_MCP_SUBSCRIPTIONS.get(key);if(!(!subscription||subscription.id!==id))return PM_MCP_SUBSCRIPTIONS.delete(key),subscription.registry.close(id)}function closeStdioMcpSubscriptions(){const closed=[];for(const[key,subscription]of PM_MCP_SUBSCRIPTIONS){if(key!==subscription.id)continue;const result=closeMcpSubscription(subscription.id,key);result&&closed.push({id:subscription.id,result})}return closed}async function resolveMcpToolSchemaForRequest(request){if(request.method!=="tools/call")return;const name=request.params?.name;return typeof name!="string"?void 0:(await resolveMcpToolSurface(TOOLS,requestWorkspaceArgs(request.params))).tools.find(tool=>tool.name===name)?.inputSchema}function buildMcpToolCallErrorResult(request,error){if(request.method!=="tools/call"||error instanceof PmMcpProtocolError)return;const content=errorContent(error,hasMcpProtocolVersionMetadata(request)&&hasMcpClientExtension(resolveMcpRequestContext(request.params),PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION));return hasMcpProtocolVersionMetadata(request)?buildMcpCompleteResult(content,PM_MCP_SERVER_INFO):content}function requestWorkspaceArgs(params){const paramsRecord=asRecordClone(params);return asRecordClone(paramsRecord.arguments??paramsRecord)}async function readWorkspaceResource(uri,params){const args=requestWorkspaceArgs(params),cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),contract=PM_MCP_RESOURCE_CONTRACTS.find(resource=>resource.uri===uri);if(!contract)throw new PmCliError(`Unknown pm MCP resource: ${uri}`,64);let value;if(uri==="pm://workspace/context")value=await runMcpAction({...args,action:"context",limit:10});else if(uri==="pm://workspace/claims")value=await runMcpAction({...args,action:"list",status:"in_progress",limit:20});else if(uri==="pm://workspace/focus")value=await runMcpAction({...args,action:"focus",subcommand:"show"});else{const guidePath=path.join(cwd,"AGENTS.md");value=await pathExists(guidePath)?(await readFile(guidePath,"utf8")).slice(0,32e3):"No repository-local AGENTS.md was found."}return{contents:[{uri,mimeType:contract.mimeType,text:typeof value=="string"?value:JSON.stringify(value,null,2)}]}}async function loadRequestSkillRegistry(params){const args=requestWorkspaceArgs(params),cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),workspaceRoot=resolveWorkspaceRoot(resolvePmRoot(cwd,typeof args.path=="string"?args.path:void 0));return PmMcpSkillRegistry.load({packageRoot:resolvePmPackageRoot(),workspaceRoot,packageVersion:PM_MCP_SERVER_VERSION})}function renderWorkflowPrompt(params){const paramsRecord=asRecordClone(params),name=readRequiredString(paramsRecord,"name"),prompt=PM_MCP_PROMPT_CONTRACTS.find(candidate=>candidate.name===name);if(!prompt)throw new PmCliError(`Unknown pm MCP prompt: ${name}`,64);const argumentsRecord=asRecordClone(paramsRecord.arguments);let text=prompt.template;for(const argument of prompt.arguments){const value=argumentsRecord[argument.name];if(argument.required&&(typeof value!="string"||value.trim().length===0))throw new PmCliError(`Missing required prompt argument: ${argument.name}`,64);text=text.replaceAll(`{{${argument.name}}}`,typeof value=="string"?value:"")}return{description:prompt.description,messages:[{role:"user",content:{type:"text",text}}]}}const LEGACY_MCP_ADAPTER=new LegacyMcpAdapter({serverInfo:PM_MCP_SERVER_INFO,capabilities:PM_MCP_SERVER_CAPABILITIES,instructions:PM_MCP_INSTRUCTIONS,parseClientInfo:readMcpClientInfo,listTools:async params=>({tools:(await resolveMcpToolSurface(TOOLS,requestWorkspaceArgs(params))).tools}),callTool:handleToolCall,listResources:()=>({resources:PM_MCP_RESOURCE_CONTRACTS}),readResource:params=>readWorkspaceResource(readRequiredString(asRecordClone(params),"uri"),params),listPrompts:()=>({prompts:PM_MCP_PROMPT_CONTRACTS.map(prompt=>({name:prompt.name,description:prompt.description,arguments:prompt.arguments}))}),getPrompt:renderWorkflowPrompt});function deterministicMcpTools(tools){return tools.map(tool=>({...tool,inputSchema:validateMcpJsonSchema(tool.inputSchema)})).sort((left,right)=>left.name.localeCompare(right.name))}function mcpTaskPrincipal(requestContext){return requestContext.clientInfo?`${requestContext.clientInfo.name}@${requestContext.clientInfo.version}`:"anonymous-stdio"}function mcpTaskStore(){return createMcpTaskStore({pmRoot:resolvePmRoot(process.cwd()),owner:"pm-mcp-task-provider"})}function validateMcpToolArguments(value){if(value!==void 0&&!isMcpRecord(value))throw new PmCliError("pm MCP tool arguments must be an object.",64)}function shouldCreateMcpTask(params,requestContext){if(!hasMcpClientExtension(requestContext,PM_MCP_TASKS_EXTENSION))return!1;const requestParams=asRecordClone(params),name=requestParams.name,args=asRecordClone(requestParams.arguments);return PM_MCP_DIRECT_TASK_TOOLS.has(name)||name==="pm_test"&&(args.subcommand==="run"||isMcpRecord(args.options)&&args.options.subcommand==="run")?!0:name!=="pm_run"?!1:typeof args.action=="string"&&PM_MCP_RUN_TASK_ACTIONS.has(args.action)}const PENDING_MCP_TASKS=new Map;async function executeMcpTask(execution,inputResponses){const params={...execution.params,...inputResponses?{inputResponses}:{},...execution.requestState?{requestState:execution.requestState}:{}};try{const result=await handleToolCall(params,execution.context.clientInfo,hasMcpClientExtension(execution.context,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION));await execution.store.complete(execution.taskId,execution.principal,buildMcpCompleteResult(result,PM_MCP_SERVER_INFO)),PENDING_MCP_TASKS.delete(execution.taskId)}catch(error){if(error instanceof PmMcpInputRequiredError){execution.requestState=error.requestState,await execution.store.requireInput({taskId:execution.taskId,principal:execution.principal,requestContext:execution.context,inputRequests:error.inputRequests,statusMessage:"Task requires additional client input."});return}error instanceof PmMcpProtocolError?await execution.store.fail(execution.taskId,execution.principal,{code:error.code,message:error.message,data:error.data}):await execution.store.complete(execution.taskId,execution.principal,buildMcpCompleteResult(errorContent(error,hasMcpClientExtension(execution.context,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION)),PM_MCP_SERVER_INFO)),PENDING_MCP_TASKS.delete(execution.taskId)}}async function settleMcpTaskExecution(taskId,execution){try{await execution}catch{PENDING_MCP_TASKS.delete(taskId)}}function scheduleMcpTaskExecution(execution,inputResponses){settleMcpTaskExecution(execution.taskId,executeMcpTask(execution,inputResponses))}async function createMcpTaskForToolCall(params,requestContext){const store=mcpTaskStore(),principal=mcpTaskPrincipal(requestContext),task=await store.create({principal,statusMessage:"pm operation accepted for asynchronous execution."}),execution={context:requestContext,params:asRecordClone(params),principal,store,taskId:task.taskId};return PENDING_MCP_TASKS.set(task.taskId,execution),scheduleMcpTaskExecution(execution),attachMcpServerInfo(task,PM_MCP_SERVER_INFO)}async function dispatchMcpTaskMethod(request,requestContext){if(!hasMcpClientExtension(requestContext,PM_MCP_TASKS_EXTENSION))throw new PmMcpProtocolError("Missing required client capability",PM_MCP_ERROR_CODES.missingRequiredClientCapability,{requiredCapabilities:{extensions:{[PM_MCP_TASKS_EXTENSION]:{}}}});const params=asRecordClone(request.params),taskId=readRequiredString(params,"taskId"),principal=mcpTaskPrincipal(requestContext),store=mcpTaskStore();if(request.method==="tasks/get")return buildMcpCompleteResult(await store.get(taskId,principal),PM_MCP_SERVER_INFO);if(request.method==="tasks/update"){const update=await store.update(taskId,principal,params.inputResponses),execution=PENDING_MCP_TASKS.get(taskId);return execution&&update.acceptedKeys.length>0&&update.remainingKeys.length===0&&scheduleMcpTaskExecution(execution,await store.takeInputResponses(taskId,principal)),buildMcpCompleteResult({},PM_MCP_SERVER_INFO)}return await store.cancel(taskId,principal),PENDING_MCP_TASKS.delete(taskId),buildMcpCompleteResult({},PM_MCP_SERVER_INFO)}async function dispatchModernToolMethod(request,requestContext,clientInfo){if(request.method==="tools/list"){const surface=await resolveMcpToolSurface(TOOLS,requestWorkspaceArgs(request.params)),listedTools=hasMcpClientExtension(requestContext,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION)?[...surface.tools.filter(tool=>PM_MCP_ENTRY_TOOL_NAMES.includes(tool.name)),...surface.profile==="custom"&&!surface.tools.some(tool=>tool.name==="pm_discover")?TOOLS.filter(tool=>tool.name==="pm_discover"):[]]:surface.tools;return buildMcpCompleteResult(withMcpCachePolicy({tools:hasCompatiblePmMcpAppsCapability(requestContext)?decoratePmMcpToolsWithApps(deterministicMcpTools(listedTools)):deterministicMcpTools(listedTools)},PM_MCP_CACHE_POLICIES.tools),PM_MCP_SERVER_INFO)}if(validateMcpToolArguments(request.params?.arguments),shouldCreateMcpTask(request.params,requestContext))return createMcpTaskForToolCall(request.params,requestContext);try{return buildMcpCompleteResult(await handleToolCall(request.params,clientInfo,hasMcpClientExtension(requestContext,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION)),PM_MCP_SERVER_INFO)}catch(error){if(!(error instanceof PmMcpInputRequiredError))throw error;return buildMcpInputRequiredResult({requestContext,serverInfo:PM_MCP_SERVER_INFO,inputRequests:error.inputRequests,requestState:error.requestState})}}async function dispatchModernResourceMethod(request,requestContext){if(request.method==="resources/list"){const resources=[...PM_MCP_RESOURCE_CONTRACTS,...hasCompatiblePmMcpAppsCapability(requestContext)?PM_MCP_APP_CONTRACTS.map(contract=>({uri:contract.uri,name:contract.name,description:contract.description,mimeType:PM_MCP_APP_MIME_TYPE,_meta:{ui:contract.resourceMeta}})):[]].sort((left,right)=>left.uri.localeCompare(right.uri));return buildMcpCompleteResult(withMcpCachePolicy({resources},PM_MCP_CACHE_POLICIES.resources),PM_MCP_SERVER_INFO)}if(request.method==="resources/templates/list")return buildMcpCompleteResult(withMcpCachePolicy({resourceTemplates:[]},PM_MCP_CACHE_POLICIES.resources),PM_MCP_SERVER_INFO);try{const uri=readRequiredString(asRecordClone(request.params),"uri"),app=findPmMcpAppByUri(uri);let resource;if(app){if(!hasPmMcpAppsCapability(requestContext))throw new PmMcpProtocolError("MCP App resource requires negotiated client capability",PM_MCP_ERROR_CODES.missingRequiredClientCapability,{requiredCapabilities:{extensions:{[PM_MCP_APPS_EXTENSION]:PM_MCP_APPS_SERVER_CAPABILITY}}});resource={contents:[{uri,mimeType:PM_MCP_APP_MIME_TYPE,text:renderPmMcpAppHtml(app),_meta:{ui:app.resourceMeta}}]}}else uri.startsWith("skill://")?(assertPmMcpSkillsCapability(requestContext),resource={...(await loadRequestSkillRegistry(request.params)).read(uri)}):resource=await readWorkspaceResource(uri,request.params);return buildMcpCompleteResult(withMcpCachePolicy(resource,PM_MCP_CACHE_POLICIES.resource),PM_MCP_SERVER_INFO)}catch(error){throw!(error instanceof PmCliError)||!error.message.startsWith("Unknown pm MCP resource:")?error:new PmMcpProtocolError(error.message,PM_MCP_ERROR_CODES.invalidParams,{field:"uri"})}}function hasCompatiblePmMcpAppsCapability(requestContext){try{return hasPmMcpAppsCapability(requestContext)}catch(error){if(error instanceof PmMcpProtocolError)return!1;throw error}}function readSkillPageOptions(params){if(params.cursor!==void 0&&typeof params.cursor!="string")throw new PmMcpProtocolError("Skills cursor must be a string",PM_MCP_ERROR_CODES.invalidParams,{field:"cursor"});if(params.limit!==void 0&&typeof params.limit!="number")throw new PmMcpProtocolError("Skills limit must be a number",PM_MCP_ERROR_CODES.invalidParams,{field:"limit"});return{...typeof params.cursor=="string"?{cursor:params.cursor}:{},...typeof params.limit=="number"?{limit:params.limit}:{}}}async function dispatchModernSkillMethod(request,requestContext){const directoryRead=request.method==="resources/directory/read";assertPmMcpSkillsCapability(requestContext,directoryRead);const params=asRecordClone(request.params),registry=await loadRequestSkillRegistry(request.params);let result;return request.method==="skills/list"?result={...registry.list(readSkillPageOptions(params))}:request.method==="skills/get"?result={skill:registry.get(readRequiredString(params,"uri"))}:result={...registry.readDirectory(readRequiredString(params,"uri"),readSkillPageOptions(params))},buildMcpCompleteResult(withMcpCachePolicy(result,PM_MCP_CACHE_POLICIES.resource),PM_MCP_SERVER_INFO)}function dispatchModernPromptMethod(request){const result=request.method==="prompts/list"?withMcpCachePolicy({prompts:PM_MCP_PROMPT_CONTRACTS.map(prompt=>({name:prompt.name,description:prompt.description,arguments:prompt.arguments})).sort((left,right)=>left.name.localeCompare(right.name))},PM_MCP_CACHE_POLICIES.prompts):renderWorkflowPrompt(request.params);return buildMcpCompleteResult(result,PM_MCP_SERVER_INFO)}async function dispatchModernMcpRequest(request,meta){const requestContext=resolveMcpRequestContext(request.params),clientInfo=readMcpClientInfo(meta[PM_MCP_META_KEYS.clientInfo]);if(request.method==="server/discover")return buildMcpDiscoverResult({serverInfo:PM_MCP_SERVER_INFO,capabilities:PM_MCP_SERVER_CAPABILITIES,instructions:PM_MCP_INSTRUCTIONS});if(request.method==="ping")throw new PmMcpProtocolError("MCP method not found: ping",-32601,{removedIn:PM_MCP_PROTOCOL_VERSION});if(PM_MCP_SKILL_METHODS.has(request.method??""))return dispatchModernSkillMethod(request,requestContext);if(request.method==="tasks/get"||request.method==="tasks/update"||request.method==="tasks/cancel")return dispatchMcpTaskMethod(request,requestContext);if(request.method==="tools/list"||request.method==="tools/call")return dispatchModernToolMethod(request,requestContext,clientInfo);if(request.method==="resources/list"||request.method==="resources/templates/list"||request.method==="resources/read")return dispatchModernResourceMethod(request,requestContext);if(request.method==="prompts/list"||request.method==="prompts/get")return dispatchModernPromptMethod(request);throw new PmMcpProtocolError(`MCP method not found: ${request.method??"(missing)"}`,-32601)}async function handleRequestInReproducibleContext(request){if(!(!request.id&&request.method?.startsWith("notifications/"))){if(hasMcpProtocolVersionMetadata(request)){const allowlist=(process.env.PM_MCP_BAGGAGE_ALLOWLIST??"").split(",").map(entry=>entry.trim()).filter(Boolean);return runWithMcpTraceContext(extractMcpTraceContext(request.params,{baggageAllowlist:allowlist}),()=>dispatchModernMcpRequest(request,request.params._meta))}return request.method==="initialize"?LEGACY_MCP_ADAPTER.initialize(request.params):LEGACY_MCP_ADAPTER.dispatch(request)}}function hasMcpProtocolVersionMetadata(request){const meta=isMcpRecord(request.params)?request.params._meta:void 0;return isMcpRecord(meta)&&Object.prototype.hasOwnProperty.call(meta,PM_MCP_META_KEYS.protocolVersion)}async function handleRequest(request){return runWithReproducibleProcessEnvironment(process.env,()=>handleRequestInReproducibleContext(request))}function writeResponse(id,payload){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id,result:payload})}
2
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fe904212-6429-55c9-9d7b-39d7e2850fed")}catch{}})();import{realpathSync}from"node:fs";import{readFile}from"node:fs/promises";import path from"node:path";import readline from"node:readline";import{fileURLToPath}from"node:url";import{resolvePmCliVersion,EXIT_CODE,PmCliError,decodeHtmlEntitiesInOptions,levenshteinDistanceWithinLimit,asRecordClone,createSerialQueue,evaluateMutationGuard,getSettingsPath,isMutationAction,pathExists,readSettings,runWithHarnessDetectionSignals,runWithWorkspaceHarnessSignalDescriptors,boundAgentEpisodeIdentity}from"../sdk/runtime-primitives.js";import{pmToolActionNestedOptionKeys}from"../sdk/cli-contracts/tool-schema.js";import{readRequiredString,runAction,runWithActiveExtensions}from"../sdk/runtime.js";import{NARROW_TOOL_ACTIONS,TOOLS}from"./tool-definitions.js";import{normalizeWorkspaceToolArguments,resolveMcpToolAccess,resolveMcpToolSurface}from"./runtime-capabilities.js";import{PM_MCP_PROMPT_CONTRACTS,PM_MCP_RESOURCE_CONTRACTS}from"../sdk/agent-capability-contracts.js";import{PM_MCP_ENTRY_TOOL_NAMES,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION,PM_MCP_PROGRESSIVE_DISCOVERY_SERVER_CAPABILITY,discoverPmTools,parsePmToolDiscoveryOptions}from"../sdk/mcp/discovery.js";import{commitItemMutations}from"../sdk/item-transaction.js";import{isRuntimeRecord,markMcpMutationTransportInput}from"../sdk/runtime-input.js";import{attachOutputTokenAccounting}from"../sdk/output-token-accounting.js";import{createReproducibleProcessRunner,runWithReproducibleProcessEnvironment}from"../sdk/reproducibility/process.js";import{parseAtomicMutationControls}from"../sdk/structured-mutations.js";import{planItemMutationDocument,previewItemMutationDocument}from"../sdk/lifecycle/structured-mutation-plan.js";import{resolveAuthor,resolvePmRoot,resolveWorkspaceRoot}from"../sdk/runtime-primitives.js";import{PM_MCP_ERROR_CODES,PM_MCP_META_KEYS,PM_MCP_PROTOCOL_VERSION,PmMcpProtocolError,attachMcpServerInfo,buildMcpCompleteResult,buildMcpDiscoverResult,hasMcpClientExtension,isMcpRecord,resolveMcpRequestContext}from"../sdk/mcp/protocol.js";import{PmMcpInputRequiredError,buildMcpInputRequiredResult,parseMcpInputResponses,validateMcpJsonSchema,withMcpCachePolicy}from"../sdk/mcp/interactions.js";import{PM_MCP_TASKS_EXTENSION,createMcpTaskStore}from"../sdk/mcp/tasks.js";import{PmMcpSubscriptionRegistry}from"../sdk/mcp/subscriptions.js";import{extractMcpTraceContext,runWithMcpTraceContext}from"../sdk/mcp/authorization.js";import{LegacyMcpAdapter}from"./legacy-adapter.js";import{PM_MCP_APP_CONTRACTS,PM_MCP_APP_MIME_TYPE,PM_MCP_APPS_EXTENSION,PM_MCP_APPS_SERVER_CAPABILITY,decoratePmMcpToolsWithApps,findPmMcpAppByUri,hasPmMcpAppsCapability,renderPmMcpAppHtml}from"../sdk/mcp/apps.js";import{PM_MCP_SKILLS_EXTENSION,PM_MCP_SKILLS_SERVER_CAPABILITY,PmMcpSkillRegistry,assertPmMcpSkillsCapability}from"../sdk/mcp/skills.js";function runMcpAction(args){return runAction(markMcpMutationTransportInput(args))}const PM_PACKAGE_ROOT_ENV="PM_CLI_PACKAGE_ROOT";function resolvePmPackageRoot(){return fileURLToPath(new URL("../..",import.meta.url))}(typeof process.env[PM_PACKAGE_ROOT_ENV]!="string"||process.env[PM_PACKAGE_ROOT_ENV]?.trim().length===0)&&(process.env[PM_PACKAGE_ROOT_ENV]=resolvePmPackageRoot());const PM_MCP_SERVER_VERSION=resolvePmCliVersion(import.meta.url,["../.."])??"0.0.0",PM_MCP_SERVER_INFO={name:"pm-mcp",version:PM_MCP_SERVER_VERSION,description:"Stateless project-context management through pm SDK contracts.",websiteUrl:"https://github.com/unbraind/pm-cli"},PM_MCP_SERVER_CAPABILITIES={prompts:{listChanged:!0},resources:{listChanged:!0,subscribe:!0},tools:{listChanged:!0},extensions:{[PM_MCP_TASKS_EXTENSION]:{},[PM_MCP_APPS_EXTENSION]:PM_MCP_APPS_SERVER_CAPABILITY,[PM_MCP_SKILLS_EXTENSION]:PM_MCP_SKILLS_SERVER_CAPABILITY,[PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION]:PM_MCP_PROGRESSIVE_DISCOVERY_SERVER_CAPABILITY}},PM_MCP_SUBSCRIPTIONS=new Map;function createMcpSubscriptionRegistry(){return new PmMcpSubscriptionRegistry({capabilities:PM_MCP_SERVER_CAPABILITIES,serverInfo:PM_MCP_SERVER_INFO})}function pruneClosedMcpSubscriptionRegistries(){for(const[key,subscription]of PM_MCP_SUBSCRIPTIONS)subscription.registry.size===0&&PM_MCP_SUBSCRIPTIONS.delete(key)}const PM_MCP_CACHE_POLICIES={prompts:{ttlMs:6e4,cacheScope:"public"},resource:{ttlMs:0,cacheScope:"private"},resources:{ttlMs:6e4,cacheScope:"public"},tools:{ttlMs:3e4,cacheScope:"private"}},PM_MCP_DIRECT_TASK_TOOLS=new Set(["pm_graph","pm_health","pm_validate"]),PM_MCP_RUN_TASK_ACTIONS=new Set(["graph","health","import","reindex","test-all","validate"]),PM_MCP_SKILL_METHODS=new Set(["skills/list","skills/get","resources/directory/read"]),PM_MCP_INSTRUCTIONS="You have access to native pm CLI tools for git-based project management. When progressive discovery is negotiated, use pm_discover to expand the small entry catalog by intent and request schemas only when needed. Use pm_next to pick the next actionable item, or pm_context or pm_search before creating new work. Prefer narrow tools (pm_next, pm_context, pm_list, pm_get, pm_search, pm_events, pm_create, pm_mutate, pm_copy, pm_focus, pm_update, pm_append, pm_claim, pm_release, pm_close, pm_comments, pm_files, pm_docs, pm_notes, pm_learnings, pm_deps, pm_graph, pm_test, pm_validate, pm_health, pm_contracts, pm_schema, pm_profile, pm_config, pm_plan) over pm_run when they cover the operation. Use pm_plan for agent harness Plan workflows: it provides Codex/Claude/Cursor-style planning with durable steps, dependencies, decisions, discoveries, validation, and materialization. Use pm_schema and pm_config for workspace configuration: pm_schema manages custom item types/statuses and pm_config reads or writes settings keys. Use pm_run with an explicit action for active package-owned operations, plus activity, aggregate, history, stats, test-all, and gc. Use history-redact for audited history-stream redaction workflows, history-repair to re-anchor a drifted history chain, and history-compact to checkpoint/prune long history streams while preserving replay integrity. Agent harness and model provenance are detected automatically; pass author only for an intentional identity override. Do not pass path during real repository tracking \u2014 only pass path for sandbox or test runs.";function declaredToolKeys(tools=TOOLS){return new Map(tools.map(tool=>{const properties=tool.inputSchema.properties??{};return[tool.name,Object.keys(properties)]}))}function nearestDeclaredKey(unexpected,declared){const limit=Math.max(1,Math.min(3,Math.floor(unexpected.length/4)+1));let best;for(const candidate of declared){const distance=levenshteinDistanceWithinLimit(unexpected,candidate,limit);distance!==null&&(best===void 0||distance<best.distance)&&(best={key:candidate,distance})}return best?.key}const UNEXPECTED_KEY_WARNING_EXEMPT_TOOLS=new Set(["pm_run"]),MCP_RETRY_ARGUMENT_KEYS=new Set(["inputResponses","requestState"]);function resolveMcpDiscoveryCursorIntegrityKey(){const configuredKey=process.env.PM_MCP_DISCOVERY_CURSOR_KEY;if(configuredKey===void 0)return;const key=Buffer.from(configuredKey,"utf8");if(key.byteLength<32)throw new PmCliError("PM_MCP_DISCOVERY_CURSOR_KEY must contain at least 32 UTF-8 bytes.",64);return key}function detectUnexpectedTopLevelKeys(toolName,args,toolDeclaredKeys=declaredToolKeys()){if(typeof args!="object"||args===null||Array.isArray(args))return[];if(UNEXPECTED_KEY_WARNING_EXEMPT_TOOLS.has(toolName))return[];const declared=toolDeclaredKeys.get(toolName);if(declared===void 0)return[];const declaredSet=new Set([...declared,...MCP_RETRY_ARGUMENT_KEYS]),warnings=[];for(const key of Object.keys(args)){if(declaredSet.has(key))continue;const suggestion=nearestDeclaredKey(key,declared);warnings.push(suggestion!==void 0?`Unexpected top-level argument "${key}" for ${toolName} (did you mean "${suggestion}"?). It is not declared and may be ignored; declared arguments are: ${declared.join(", ")}.`:`Unexpected top-level argument "${key}" for ${toolName}. It is not declared and may be ignored; declared arguments are: ${declared.join(", ")}.`)}return warnings}const HANDLERS={pm_run:args=>runMcpAction(args),pm_discover:async args=>{const surface=await resolveMcpToolSurface(TOOLS,args),cursorIntegrityKey=resolveMcpDiscoveryCursorIntegrityKey(),discoveryOptions=parsePmToolDiscoveryOptions(args);return discoverPmTools(surface.tools.map(tool=>({name:tool.name,description:tool.description,inputSchema:tool.inputSchema,authorized:!0,signals:{freshness:1,usage:PM_MCP_ENTRY_TOOL_NAMES.includes(tool.name)?1:0}})),{...discoveryOptions,profile:surface.profile,...cursorIntegrityKey===void 0?{}:{cursorIntegrityKey}})},pm_mutate:async args=>{if(!Array.isArray(args.mutations)||args.mutations.length===0)throw new PmCliError("pm_mutate requires a non-empty mutations array.",EXIT_CODE.USAGE);const explicitTransactionId=args.transactionId===void 0?void 0:readRequiredString(args,"transactionId"),upsertKey=args.upsertKey===void 0?void 0:readRequiredString(args,"upsertKey"),controls=parseAtomicMutationControls(args),cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),pmRoot=resolvePmRoot(cwd,typeof args.path=="string"?args.path:void 0),extensionScope={cwd:typeof args.cwd=="string"?args.cwd:void 0,path:pmRoot,noExtensions:args.noExtensions===!0},plan=await runWithActiveExtensions(extensionScope,()=>planItemMutationDocument({pmRoot,input:JSON.stringify({schema_version:1,mutations:args.mutations}),...explicitTransactionId===void 0?{}:{transactionId:explicitTransactionId},...upsertKey===void 0?{}:{upsertKey}})),{mutations,references,rows}=plan,transactionId=plan.transaction_id,receipt={transaction_id:transactionId,transaction_id_source:plan.transaction_id_source,...plan.upsert_key===void 0?{}:{upsert_key:plan.upsert_key}};if(args.dryRun===!0){const preview=await runWithActiveExtensions(extensionScope,()=>previewItemMutationDocument({pmRoot,author:resolveAuthor(typeof args.author=="string"?args.author:void 0,"unknown"),plan}));return{...receipt,dry_run:!0,validation:preview.validation,mutation_count:mutations.length,mutations,references,rows:preview.rows}}const result=await runWithActiveExtensions(extensionScope,()=>commitItemMutations({pmRoot,transactionId,author:resolveAuthor(typeof args.author=="string"?args.author:void 0,"unknown"),mutations,...controls}));return{...Object.fromEntries(Object.entries(result).filter(([key])=>key!=="transactionId")),...receipt,mutation_count:mutations.length,references,rows}},...Object.fromEntries(Object.entries(NARROW_TOOL_ACTIONS).map(([tool,action])=>[tool,args=>runMcpAction({...args,action})]))};function resolveInvokedAction(toolName,args){return toolName==="pm_run"?typeof args.action=="string"?args.action:void 0:NARROW_TOOL_ACTIONS[toolName]}async function collectMutationGuardWarnings(toolName,action,args){if(toolName!=="pm_mutate"&&!isMutationAction(action??""))return[];const cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),pmRoot=resolvePmRoot(cwd,typeof args.path=="string"?args.path:void 0);if(!await pathExists(getSettingsPath(pmRoot)))return[];const settings=await readSettings(pmRoot),nestedOptions=typeof args.options=="object"&&args.options!==null&&!Array.isArray(args.options)?args.options:{};return evaluateMutationGuard({author:resolveAuthor(typeof args.author=="string"?args.author:typeof nestedOptions.author=="string"?nestedOptions.author:void 0,settings.author_default),payload:Object.fromEntries(Object.entries(args).filter(([key])=>key!=="cwd"&&key!=="path")),settings:settings.mutation_guard,force:args.force===!0||nestedOptions.force===!0}).warnings}function detectUnexpectedOptionKeys(toolName,action,args){const options=args.options;if(action===void 0||typeof options!="object"||options===null||Array.isArray(options))return[];const declared=pmToolActionNestedOptionKeys(action);if(declared===void 0)return[];const declaredSet=new Set(declared),warnings=[];for(const key of Object.keys(options)){if(declaredSet.has(key))continue;const suggestion=nearestDeclaredKey(key,declared);warnings.push(suggestion!==void 0?`Unknown option "${key}" for ${toolName} action "${action}" (did you mean "${suggestion}"?). The ${action} contract does not read it, so it has no effect; declared keys are: ${declared.join(", ")}.`:`Unknown option "${key}" for ${toolName} action "${action}". The ${action} contract does not read it, so it has no effect; declared keys are: ${declared.join(", ")}.`)}return warnings}function resultContent(result,warnings,tokenAccounting=!1,canonicalStructuredResult=!1){const effectiveResult=tokenAccounting?attachOutputTokenAccounting(result,value=>JSON.stringify(value,null,2)):result,structuredContent=warnings!==void 0&&warnings.length>0?{result:effectiveResult,warnings}:{result:effectiveResult};return{content:[{type:"text",text:canonicalStructuredResult?"Canonical result: structuredContent.result":JSON.stringify(effectiveResult,null,2)}],structuredContent}}function errorContent(error,canonicalStructuredResult=!1){const code=error instanceof PmCliError?error.exitCode:1,message=error instanceof Error?error.message:String(error),details=error instanceof PmCliError?error.context:void 0;return{isError:!0,content:[{type:"text",text:canonicalStructuredResult?"Canonical error: structuredContent":JSON.stringify({error:message,code,details},null,2)}],structuredContent:{result:null,error:message,code,details}}}function boundMcpClientProvenance(value){const provenance=isRuntimeRecord(value)?value:{},bounded={};let acceptedCount=0;for(const key in provenance){if(acceptedCount>=32)break;if(!Object.prototype.hasOwnProperty.call(provenance,key))continue;const entry=provenance[key];/^[a-z][a-z0-9_-]{0,63}$/u.test(key)&&typeof entry=="string"&&entry.trim().length>0&&(bounded[key]=entry.trim().slice(0,256),acceptedCount+=1)}return bounded}function readMcpClientInfo(value){const clientInfo=isRuntimeRecord(value)?value:{},clientName=typeof clientInfo.name=="string"?clientInfo.name.trim():"";if(clientName.length===0)return;const optionalValues=[["version",clientInfo.version,128],["model",clientInfo.model,256],["session",clientInfo.session,256]],result={name:clientName.slice(0,128)};for(const[key,value2,limit]of optionalValues)typeof value2=="string"&&value2.trim().length>0&&(result[key]=value2.trim().slice(0,limit));const boundedProvenance=boundMcpClientProvenance(clientInfo.provenance);Object.keys(boundedProvenance).length>0&&(result.provenance=boundedProvenance);const episode=boundAgentEpisodeIdentity(clientInfo.episode,!1);return episode!==void 0&&(result.episode=episode),result}async function emitMcpChangeNotifications(action){isMutationAction(action??"")&&await Promise.all([...PM_MCP_SUBSCRIPTIONS.values()].flatMap(({registry})=>PM_MCP_RESOURCE_CONTRACTS.map(resource=>registry.emitResourceUpdated(resource.uri)))),["extension","install","package","uninstall"].includes(action??"")&&await Promise.all([...PM_MCP_SUBSCRIPTIONS.values()].map(({registry})=>registry.emitListChanged("tools"))),pruneClosedMcpSubscriptionRegistries()}async function handleToolCall(paramsInput,clientInfo,progressiveDiscoveryNegotiated=!1){const clientSignals=clientInfo?{client_info:clientInfo}:{};return runWithHarnessDetectionSignals({env:process.env,argv:process.argv,...clientSignals},async()=>{const params=asRecordClone(paramsInput),name=readRequiredString(params,"name"),handler=Object.prototype.hasOwnProperty.call(HANDLERS,name)?HANDLERS[name]:void 0;if(!handler)throw new PmCliError(`Unknown pm MCP tool: ${name}`,64);const inputResponses=params.inputResponses===void 0?void 0:parseMcpInputResponses(params.inputResponses);validateMcpToolArguments(params.arguments);const requestedArgs={...decodeHtmlEntitiesInOptions(asRecordClone(params.arguments)),...inputResponses?{inputResponses}:{},...typeof params.requestState=="string"?{requestState:params.requestState}:{}},access=await resolveMcpToolAccess(TOOLS,name,requestedArgs),requiredCustomDiscoveryEntry=progressiveDiscoveryNegotiated&&access.profile==="custom"&&name==="pm_discover";if(!access.available&&!requiredCustomDiscoveryEntry)throw new PmCliError(`pm MCP tool "${name}" is unavailable in the ${access.profile} profile.`,64);const args=await normalizeWorkspaceToolArguments(name,requestedArgs),cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),pmRoot=resolvePmRoot(cwd,typeof args.path=="string"?args.path:void 0),workspaceIdentity=await pathExists(getSettingsPath(pmRoot))?(await readSettings(pmRoot)).agent_identity:void 0;return runWithHarnessDetectionSignals({env:{...process.env,PM_PATH:pmRoot},argv:process.argv,cwd,...clientSignals},()=>runWithWorkspaceHarnessSignalDescriptors(workspaceIdentity?.harness_signals??[],async()=>{const action=resolveInvokedAction(name,args),warnings=[...detectUnexpectedTopLevelKeys(name,args,declaredToolKeys()),...detectUnexpectedOptionKeys(name,action,args),...await collectMutationGuardWarnings(name,action,args)];for(const warning of warnings)console.error(`[pm-mcp] ${warning}`);const result=await handler(args);return emitMcpChangeNotifications(action),resultContent(result,warnings,args.tokenAccounting===!0,progressiveDiscoveryNegotiated)},{probesEnabled:workspaceIdentity?.probes_enabled}))})}async function openMcpSubscription(input){if(typeof input.request.id!="string"&&typeof input.request.id!="number"||input.request.method!=="subscriptions/listen")throw new PmMcpProtocolError("Invalid MCP subscriptions/listen request",PM_MCP_ERROR_CODES.invalidParams,{required:["id","method","params.notifications"]});resolveMcpRequestContext(input.request.params);const key=input.key??input.request.id;if(PM_MCP_SUBSCRIPTIONS.has(key))throw new PmMcpProtocolError("MCP subscription id is already active",PM_MCP_ERROR_CODES.invalidParams,{subscriptionId:input.request.id});const registry=createMcpSubscriptionRegistry();await registry.open({id:input.request.id,notifications:input.request.params?.notifications,sink:input.sink}),PM_MCP_SUBSCRIPTIONS.set(key,{id:input.request.id,registry})}function closeMcpSubscription(id,key=id){const subscription=PM_MCP_SUBSCRIPTIONS.get(key);if(!(!subscription||subscription.id!==id))return PM_MCP_SUBSCRIPTIONS.delete(key),subscription.registry.close(id)}function closeStdioMcpSubscriptions(){const closed=[];for(const[key,subscription]of PM_MCP_SUBSCRIPTIONS){if(key!==subscription.id)continue;const result=closeMcpSubscription(subscription.id,key);result&&closed.push({id:subscription.id,result})}return closed}async function resolveMcpToolSchemaForRequest(request){if(request.method!=="tools/call")return;const name=request.params?.name;return typeof name!="string"?void 0:(await resolveMcpToolSurface(TOOLS,requestWorkspaceArgs(request.params))).tools.find(tool=>tool.name===name)?.inputSchema}function buildMcpToolCallErrorResult(request,error){if(request.method!=="tools/call"||error instanceof PmMcpProtocolError)return;const content=errorContent(error,hasMcpProtocolVersionMetadata(request)&&hasMcpClientExtension(resolveMcpRequestContext(request.params),PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION));return hasMcpProtocolVersionMetadata(request)?buildMcpCompleteResult(content,PM_MCP_SERVER_INFO):content}function requestWorkspaceArgs(params){const paramsRecord=asRecordClone(params);return asRecordClone(paramsRecord.arguments??paramsRecord)}async function readWorkspaceResource(uri,params){const args=requestWorkspaceArgs(params),cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),contract=PM_MCP_RESOURCE_CONTRACTS.find(resource=>resource.uri===uri);if(!contract)throw new PmCliError(`Unknown pm MCP resource: ${uri}`,64);let value;if(uri==="pm://workspace/context")value=await runMcpAction({...args,action:"context",limit:10});else if(uri==="pm://workspace/claims")value=await runMcpAction({...args,action:"list",status:"in_progress",limit:20});else if(uri==="pm://workspace/focus")value=await runMcpAction({...args,action:"focus",subcommand:"show"});else{const guidePath=path.join(cwd,"AGENTS.md");value=await pathExists(guidePath)?(await readFile(guidePath,"utf8")).slice(0,32e3):"No repository-local AGENTS.md was found."}return{contents:[{uri,mimeType:contract.mimeType,text:typeof value=="string"?value:JSON.stringify(value,null,2)}]}}async function loadRequestSkillRegistry(params){const args=requestWorkspaceArgs(params),cwd=typeof args.cwd=="string"?args.cwd:process.cwd(),workspaceRoot=resolveWorkspaceRoot(resolvePmRoot(cwd,typeof args.path=="string"?args.path:void 0));return PmMcpSkillRegistry.load({packageRoot:resolvePmPackageRoot(),workspaceRoot,packageVersion:PM_MCP_SERVER_VERSION})}function renderWorkflowPrompt(params){const paramsRecord=asRecordClone(params),name=readRequiredString(paramsRecord,"name"),prompt=PM_MCP_PROMPT_CONTRACTS.find(candidate=>candidate.name===name);if(!prompt)throw new PmCliError(`Unknown pm MCP prompt: ${name}`,64);const argumentsRecord=asRecordClone(paramsRecord.arguments);let text=prompt.template;for(const argument of prompt.arguments){const value=argumentsRecord[argument.name];if(argument.required&&(typeof value!="string"||value.trim().length===0))throw new PmCliError(`Missing required prompt argument: ${argument.name}`,64);text=text.replaceAll(`{{${argument.name}}}`,typeof value=="string"?value:"")}return{description:prompt.description,messages:[{role:"user",content:{type:"text",text}}]}}const LEGACY_MCP_ADAPTER=new LegacyMcpAdapter({serverInfo:PM_MCP_SERVER_INFO,capabilities:PM_MCP_SERVER_CAPABILITIES,instructions:PM_MCP_INSTRUCTIONS,parseClientInfo:readMcpClientInfo,listTools:async params=>({tools:(await resolveMcpToolSurface(TOOLS,requestWorkspaceArgs(params))).tools}),callTool:handleToolCall,listResources:()=>({resources:PM_MCP_RESOURCE_CONTRACTS}),readResource:params=>readWorkspaceResource(readRequiredString(asRecordClone(params),"uri"),params),listPrompts:()=>({prompts:PM_MCP_PROMPT_CONTRACTS.map(prompt=>({name:prompt.name,description:prompt.description,arguments:prompt.arguments}))}),getPrompt:renderWorkflowPrompt});function deterministicMcpTools(tools){return tools.map(tool=>({...tool,inputSchema:validateMcpJsonSchema(tool.inputSchema)})).sort((left,right)=>left.name.localeCompare(right.name))}function mcpTaskPrincipal(requestContext){return requestContext.clientInfo?`${requestContext.clientInfo.name}@${requestContext.clientInfo.version}`:"anonymous-stdio"}function mcpTaskStore(){return createMcpTaskStore({pmRoot:resolvePmRoot(process.cwd()),owner:"pm-mcp-task-provider"})}function validateMcpToolArguments(value){if(value!==void 0&&!isMcpRecord(value))throw new PmCliError("pm MCP tool arguments must be an object.",64)}function shouldCreateMcpTask(params,requestContext){if(!hasMcpClientExtension(requestContext,PM_MCP_TASKS_EXTENSION))return!1;const requestParams=asRecordClone(params),name=requestParams.name,args=asRecordClone(requestParams.arguments);return PM_MCP_DIRECT_TASK_TOOLS.has(name)||name==="pm_test"&&(args.subcommand==="run"||isMcpRecord(args.options)&&args.options.subcommand==="run")?!0:name!=="pm_run"?!1:typeof args.action=="string"&&PM_MCP_RUN_TASK_ACTIONS.has(args.action)}const PENDING_MCP_TASKS=new Map;async function executeMcpTask(execution,inputResponses){const params={...execution.params,...inputResponses?{inputResponses}:{},...execution.requestState?{requestState:execution.requestState}:{}};try{const result=await handleToolCall(params,execution.context.clientInfo,hasMcpClientExtension(execution.context,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION));await execution.store.complete(execution.taskId,execution.principal,buildMcpCompleteResult(result,PM_MCP_SERVER_INFO)),PENDING_MCP_TASKS.delete(execution.taskId)}catch(error){if(error instanceof PmMcpInputRequiredError){execution.requestState=error.requestState,await execution.store.requireInput({taskId:execution.taskId,principal:execution.principal,requestContext:execution.context,inputRequests:error.inputRequests,statusMessage:"Task requires additional client input."});return}error instanceof PmMcpProtocolError?await execution.store.fail(execution.taskId,execution.principal,{code:error.code,message:error.message,data:error.data}):await execution.store.complete(execution.taskId,execution.principal,buildMcpCompleteResult(errorContent(error,hasMcpClientExtension(execution.context,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION)),PM_MCP_SERVER_INFO)),PENDING_MCP_TASKS.delete(execution.taskId)}}async function settleMcpTaskExecution(taskId,execution){try{await execution}catch{PENDING_MCP_TASKS.delete(taskId)}}function scheduleMcpTaskExecution(execution,inputResponses){settleMcpTaskExecution(execution.taskId,executeMcpTask(execution,inputResponses))}async function createMcpTaskForToolCall(params,requestContext){const store=mcpTaskStore(),principal=mcpTaskPrincipal(requestContext),task=await store.create({principal,statusMessage:"pm operation accepted for asynchronous execution."}),execution={context:requestContext,params:asRecordClone(params),principal,store,taskId:task.taskId};return PENDING_MCP_TASKS.set(task.taskId,execution),scheduleMcpTaskExecution(execution),attachMcpServerInfo(task,PM_MCP_SERVER_INFO)}async function dispatchMcpTaskMethod(request,requestContext){if(!hasMcpClientExtension(requestContext,PM_MCP_TASKS_EXTENSION))throw new PmMcpProtocolError("Missing required client capability",PM_MCP_ERROR_CODES.missingRequiredClientCapability,{requiredCapabilities:{extensions:{[PM_MCP_TASKS_EXTENSION]:{}}}});const params=asRecordClone(request.params),taskId=readRequiredString(params,"taskId"),principal=mcpTaskPrincipal(requestContext),store=mcpTaskStore();if(request.method==="tasks/get")return buildMcpCompleteResult(await store.get(taskId,principal),PM_MCP_SERVER_INFO);if(request.method==="tasks/update"){const update=await store.update(taskId,principal,params.inputResponses),execution=PENDING_MCP_TASKS.get(taskId);return execution&&update.acceptedKeys.length>0&&update.remainingKeys.length===0&&scheduleMcpTaskExecution(execution,await store.takeInputResponses(taskId,principal)),buildMcpCompleteResult({},PM_MCP_SERVER_INFO)}return await store.cancel(taskId,principal),PENDING_MCP_TASKS.delete(taskId),buildMcpCompleteResult({},PM_MCP_SERVER_INFO)}async function dispatchModernToolMethod(request,requestContext,clientInfo){if(request.method==="tools/list"){const surface=await resolveMcpToolSurface(TOOLS,requestWorkspaceArgs(request.params)),listedTools=hasMcpClientExtension(requestContext,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION)?[...surface.tools.filter(tool=>PM_MCP_ENTRY_TOOL_NAMES.includes(tool.name)),...surface.profile==="custom"&&!surface.tools.some(tool=>tool.name==="pm_discover")?TOOLS.filter(tool=>tool.name==="pm_discover"):[]]:surface.tools;return buildMcpCompleteResult(withMcpCachePolicy({tools:hasCompatiblePmMcpAppsCapability(requestContext)?decoratePmMcpToolsWithApps(deterministicMcpTools(listedTools)):deterministicMcpTools(listedTools)},PM_MCP_CACHE_POLICIES.tools),PM_MCP_SERVER_INFO)}if(validateMcpToolArguments(request.params?.arguments),shouldCreateMcpTask(request.params,requestContext))return createMcpTaskForToolCall(request.params,requestContext);try{return buildMcpCompleteResult(await handleToolCall(request.params,clientInfo,hasMcpClientExtension(requestContext,PM_MCP_PROGRESSIVE_DISCOVERY_EXTENSION)),PM_MCP_SERVER_INFO)}catch(error){if(!(error instanceof PmMcpInputRequiredError))throw error;return buildMcpInputRequiredResult({requestContext,serverInfo:PM_MCP_SERVER_INFO,inputRequests:error.inputRequests,requestState:error.requestState})}}async function dispatchModernResourceMethod(request,requestContext){if(request.method==="resources/list"){const resources=[...PM_MCP_RESOURCE_CONTRACTS,...hasCompatiblePmMcpAppsCapability(requestContext)?PM_MCP_APP_CONTRACTS.map(contract=>({uri:contract.uri,name:contract.name,description:contract.description,mimeType:PM_MCP_APP_MIME_TYPE,_meta:{ui:contract.resourceMeta}})):[]].sort((left,right)=>left.uri.localeCompare(right.uri));return buildMcpCompleteResult(withMcpCachePolicy({resources},PM_MCP_CACHE_POLICIES.resources),PM_MCP_SERVER_INFO)}if(request.method==="resources/templates/list")return buildMcpCompleteResult(withMcpCachePolicy({resourceTemplates:[]},PM_MCP_CACHE_POLICIES.resources),PM_MCP_SERVER_INFO);try{const uri=readRequiredString(asRecordClone(request.params),"uri"),app=findPmMcpAppByUri(uri);let resource;if(app){if(!hasPmMcpAppsCapability(requestContext))throw new PmMcpProtocolError("MCP App resource requires negotiated client capability",PM_MCP_ERROR_CODES.missingRequiredClientCapability,{requiredCapabilities:{extensions:{[PM_MCP_APPS_EXTENSION]:PM_MCP_APPS_SERVER_CAPABILITY}}});resource={contents:[{uri,mimeType:PM_MCP_APP_MIME_TYPE,text:renderPmMcpAppHtml(app),_meta:{ui:app.resourceMeta}}]}}else uri.startsWith("skill://")?(assertPmMcpSkillsCapability(requestContext),resource={...(await loadRequestSkillRegistry(request.params)).read(uri)}):resource=await readWorkspaceResource(uri,request.params);return buildMcpCompleteResult(withMcpCachePolicy(resource,PM_MCP_CACHE_POLICIES.resource),PM_MCP_SERVER_INFO)}catch(error){throw!(error instanceof PmCliError)||!error.message.startsWith("Unknown pm MCP resource:")?error:new PmMcpProtocolError(error.message,PM_MCP_ERROR_CODES.invalidParams,{field:"uri"})}}function hasCompatiblePmMcpAppsCapability(requestContext){try{return hasPmMcpAppsCapability(requestContext)}catch(error){if(error instanceof PmMcpProtocolError)return!1;throw error}}function readSkillPageOptions(params){if(params.cursor!==void 0&&typeof params.cursor!="string")throw new PmMcpProtocolError("Skills cursor must be a string",PM_MCP_ERROR_CODES.invalidParams,{field:"cursor"});if(params.limit!==void 0&&typeof params.limit!="number")throw new PmMcpProtocolError("Skills limit must be a number",PM_MCP_ERROR_CODES.invalidParams,{field:"limit"});return{...typeof params.cursor=="string"?{cursor:params.cursor}:{},...typeof params.limit=="number"?{limit:params.limit}:{}}}async function dispatchModernSkillMethod(request,requestContext){const directoryRead=request.method==="resources/directory/read";assertPmMcpSkillsCapability(requestContext,directoryRead);const params=asRecordClone(request.params),registry=await loadRequestSkillRegistry(request.params);let result;return request.method==="skills/list"?result={...registry.list(readSkillPageOptions(params))}:request.method==="skills/get"?result={skill:registry.get(readRequiredString(params,"uri"))}:result={...registry.readDirectory(readRequiredString(params,"uri"),readSkillPageOptions(params))},buildMcpCompleteResult(withMcpCachePolicy(result,PM_MCP_CACHE_POLICIES.resource),PM_MCP_SERVER_INFO)}function dispatchModernPromptMethod(request){const result=request.method==="prompts/list"?withMcpCachePolicy({prompts:PM_MCP_PROMPT_CONTRACTS.map(prompt=>({name:prompt.name,description:prompt.description,arguments:prompt.arguments})).sort((left,right)=>left.name.localeCompare(right.name))},PM_MCP_CACHE_POLICIES.prompts):renderWorkflowPrompt(request.params);return buildMcpCompleteResult(result,PM_MCP_SERVER_INFO)}async function dispatchModernMcpRequest(request,meta){const requestContext=resolveMcpRequestContext(request.params),clientInfo=readMcpClientInfo(meta[PM_MCP_META_KEYS.clientInfo]);if(request.method==="server/discover")return buildMcpDiscoverResult({serverInfo:PM_MCP_SERVER_INFO,capabilities:PM_MCP_SERVER_CAPABILITIES,instructions:PM_MCP_INSTRUCTIONS});if(request.method==="ping")throw new PmMcpProtocolError("MCP method not found: ping",-32601,{removedIn:PM_MCP_PROTOCOL_VERSION});if(PM_MCP_SKILL_METHODS.has(request.method??""))return dispatchModernSkillMethod(request,requestContext);if(request.method==="tasks/get"||request.method==="tasks/update"||request.method==="tasks/cancel")return dispatchMcpTaskMethod(request,requestContext);if(request.method==="tools/list"||request.method==="tools/call")return dispatchModernToolMethod(request,requestContext,clientInfo);if(request.method==="resources/list"||request.method==="resources/templates/list"||request.method==="resources/read")return dispatchModernResourceMethod(request,requestContext);if(request.method==="prompts/list"||request.method==="prompts/get")return dispatchModernPromptMethod(request);throw new PmMcpProtocolError(`MCP method not found: ${request.method??"(missing)"}`,-32601)}async function handleRequestInReproducibleContext(request){if(!(!request.id&&request.method?.startsWith("notifications/"))){if(hasMcpProtocolVersionMetadata(request)){const allowlist=(process.env.PM_MCP_BAGGAGE_ALLOWLIST??"").split(",").map(entry=>entry.trim()).filter(Boolean);return runWithMcpTraceContext(extractMcpTraceContext(request.params,{baggageAllowlist:allowlist}),()=>dispatchModernMcpRequest(request,request.params._meta))}return request.method==="initialize"?LEGACY_MCP_ADAPTER.initialize(request.params):LEGACY_MCP_ADAPTER.dispatch(request)}}function hasMcpProtocolVersionMetadata(request){const meta=isMcpRecord(request.params)?request.params._meta:void 0;return isMcpRecord(meta)&&Object.prototype.hasOwnProperty.call(meta,PM_MCP_META_KEYS.protocolVersion)}async function handleRequest(request){return runWithReproducibleProcessEnvironment(process.env,()=>handleRequestInReproducibleContext(request))}function writeResponse(id,payload){process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id,result:payload})}
3
3
  `)}function writeError(id,error){const code=error instanceof PmMcpProtocolError?error.code:error instanceof PmCliError?error.exitCode:-32603,message=error instanceof Error?error.message:String(error),data=error instanceof PmMcpProtocolError?error.data:error instanceof PmCliError?error.context:void 0;process.stdout.write(`${JSON.stringify({jsonrpc:"2.0",id,error:{code,message,data}})}
4
4
  `)}function writeToolCallErrorResponse(request,error){return request.method!=="tools/call"||error instanceof PmMcpProtocolError?!1:(writeResponse(request.id,buildMcpToolCallErrorResult(request,error)),!0)}async function handleStdioTransportControl(request){if(request.method==="subscriptions/listen")return await openMcpSubscription({request,sink:notification=>{process.stdout.write(`${JSON.stringify(notification)}
5
5
  `)}}),!0;if(request.method!=="notifications/cancelled")return!1;const requestId=request.params?.requestId;if(typeof requestId=="string"||typeof requestId=="number"){const result=closeMcpSubscription(requestId);result&&writeResponse(requestId,result)}return!0}async function processRpcLineWithHandler(line,requestHandler){if(line.trim().length===0)return;let request;try{request=JSON.parse(line)}catch(error){const message=error instanceof Error?error.message:String(error);writeError(null,new PmCliError(`Parse error: ${message}`,-32700));return}if(typeof request!="object"||request===null||Array.isArray(request)){writeError(null,new PmCliError("Invalid JSON-RPC request: expected an object",-32600));return}const shouldRespond=Object.prototype.hasOwnProperty.call(request,"id");try{if(await handleStdioTransportControl(request))return;const result=await requestHandler(request);shouldRespond&&result!==void 0&&writeResponse(request.id,result)}catch(error){if(!shouldRespond)return;writeToolCallErrorResponse(request,error)||writeError(request.id,error)}}async function processRpcLine(line){await processRpcLineWithHandler(line,handleRequest)}function startMcpServer(){const rl=readline.createInterface({input:process.stdin,crlfDelay:1/0}),queue=createSerialQueue();let processLine;try{const runInProcessContext=createReproducibleProcessRunner(process.env);processLine=line=>runInProcessContext(()=>processRpcLineWithHandler(line,handleRequestInReproducibleContext))}catch{processLine=processRpcLine}rl.on("line",line=>{queue.enqueue(()=>processLine(line))}),rl.on("close",()=>{queue.enqueue(()=>{for(const closed of closeStdioMcpSubscriptions())writeResponse(closed.id,closed.result)})})}function isInvokedAsMcpMainModule(argvPath,moduleUrl){if(!argvPath)return!1;const selfPath=fileURLToPath(moduleUrl);if(argvPath===selfPath)return!0;try{return realpathSync(argvPath)===realpathSync(selfPath)}catch{return!1}}function readRuntimeTestHook(key){const runtimeTestHooks=globalThis.__pmCliActionRunnerTestHooks;if(runtimeTestHooks===void 0)throw new PmCliError(`MCP runtime test hook "${String(key)}" is only available in test environments.`,64);return runtimeTestHooks[key]}const _testOnly={boundMcpClientProvenance,createMcpInputRequiredError:input=>new PmMcpInputRequiredError(input),createMcpProtocolError:(...input)=>new PmMcpProtocolError(...input),get closeManyOptionsFromFlat(){return readRuntimeTestHook("closeManyOptionsFromFlat")},detectUnexpectedOptionKeys,detectUnexpectedTopLevelKeys,collectMutationGuardWarnings,closeStdioMcpSubscriptions,errorContent,emitMcpChangeNotifications,expireMcpSubscriptionRecord:(id,key=id)=>PM_MCP_SUBSCRIPTIONS.get(key).registry.close(id),getMcpClientInfo:()=>LEGACY_MCP_ADAPTER.getClientInfo(),get extensionOptionsFromArgs(){return readRuntimeTestHook("extensionOptionsFromArgs")},get globalOptions(){return readRuntimeTestHook("globalOptions")},get mutationListOptions(){return readRuntimeTestHook("mutationListOptions")},nearestDeclaredKey,mcpTaskPrincipal,resultContent,resolveMcpRequestContext,shouldCreateMcpTask,settleMcpTaskExecution,subscriptionCount:()=>PM_MCP_SUBSCRIPTIONS.size,get normalizeActionName(){return readRuntimeTestHook("normalizeActionName")},get normalizeCommandPath(){return readRuntimeTestHook("normalizeCommandPath")},get normalizeMcpOptionsArrays(){return readRuntimeTestHook("normalizeMcpOptionsArrays")},get normalizeMcpUpdateOptions(){return readRuntimeTestHook("normalizeMcpUpdateOptions")},get optionsWithAuthor(){return readRuntimeTestHook("optionsWithAuthor")},get readRequiredString(){return readRuntimeTestHook("readRequiredString")},get readScalarString(){return readRuntimeTestHook("readScalarString")},get readScalarStringAllowBlank(){return readRuntimeTestHook("readScalarStringAllowBlank")},get readStringArray(){return readRuntimeTestHook("readStringArray")},runAction:runMcpAction,get updateManyOptionsFromFlat(){return readRuntimeTestHook("updateManyOptionsFromFlat")},get withAddNoteOption(){return readRuntimeTestHook("withAddNoteOption")},get withFilesDiscoveryOptions(){return readRuntimeTestHook("withFilesDiscoveryOptions")},get withMutationCompaction(){return readRuntimeTestHook("withMutationCompaction")},writeError};isInvokedAsMcpMainModule(process.argv[1],import.meta.url)&&startMcpServer();export{_testOnly,buildMcpToolCallErrorResult,closeMcpSubscription,handleRequest,isInvokedAsMcpMainModule,openMcpSubscription,processRpcLine,resolveMcpToolSchemaForRequest,startMcpServer};
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="177144db-ac15-59ef-84ab-708b4dd544cc")}catch{}})();const GLOBAL_VALUE_CONSUMING_FLAGS=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--output-session","--output-cursor"]),BOOTSTRAP_BOOLEAN_FLAGS=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function isInlineGlobalValueToken(token){const equalsIndex=token.indexOf("=");return equalsIndex>0&&GLOBAL_VALUE_CONSUMING_FLAGS.has(token.slice(0,equalsIndex))}function consumesBootstrapValue(flag,next){return typeof next!="string"?!1:flag==="--path"||flag==="--pm-path"||!next.startsWith("-")}function findBootstrapCommandTokenIndex(argv){for(let index=0;index<argv.length;index+=1){const token=argv[index];if(token==="--")return;if(GLOBAL_VALUE_CONSUMING_FLAGS.has(token)){index+=consumesBootstrapValue(token,argv[index+1])?1:0;continue}if(!(isInlineGlobalValueToken(token)||BOOTSTRAP_BOOLEAN_FLAGS.has(token)||token==="--profile"||token==="--id-only"||token==="--explain")&&!token.startsWith("-"))return index}}function parseBootstrapCommandName(argv){const index=findBootstrapCommandTokenIndex(argv);return index===void 0?void 0:argv[index].trim().toLowerCase()}export{BOOTSTRAP_BOOLEAN_FLAGS,GLOBAL_VALUE_CONSUMING_FLAGS,consumesBootstrapValue,findBootstrapCommandTokenIndex,isInlineGlobalValueToken,parseBootstrapCommandName};
1
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7607f0d2-6e95-5b85-9bc2-18f643a64171")}catch{}})();const GLOBAL_VALUE_CONSUMING_FLAGS=new Set(["--pm-path","--path","--author","--output-include","--output-limit","--output-budget","--output-format","--format","--output-session","--output-cursor"]),BOOTSTRAP_BOOLEAN_FLAGS=new Set(["--no-extensions","--no-pager","--json","--quiet","--lean","--token-accounting","--output-row-contract","--all"]);function isInlineGlobalValueToken(token){const equalsIndex=token.indexOf("=");return equalsIndex>0&&GLOBAL_VALUE_CONSUMING_FLAGS.has(token.slice(0,equalsIndex))}function consumesBootstrapValue(flag,next){return typeof next!="string"?!1:flag==="--path"||flag==="--pm-path"||!next.startsWith("-")}function findBootstrapCommandTokenIndex(argv){for(let index=0;index<argv.length;index+=1){const token=argv[index];if(token==="--")return;if(GLOBAL_VALUE_CONSUMING_FLAGS.has(token)){index+=consumesBootstrapValue(token,argv[index+1])?1:0;continue}if(!(isInlineGlobalValueToken(token)||BOOTSTRAP_BOOLEAN_FLAGS.has(token)||token==="--profile"||token==="--id-only"||token==="--explain")&&!token.startsWith("-"))return index}}function parseBootstrapCommandName(argv){const index=findBootstrapCommandTokenIndex(argv);return index===void 0?void 0:argv[index].trim().toLowerCase()}export{BOOTSTRAP_BOOLEAN_FLAGS,GLOBAL_VALUE_CONSUMING_FLAGS,consumesBootstrapValue,findBootstrapCommandTokenIndex,isInlineGlobalValueToken,parseBootstrapCommandName};
2
2
  //# sourceMappingURL=bootstrap-command-scanner.js.map
@@ -1,2 +1,2 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="2b953bb2-386d-5eaf-abc6-95cb0105f44e")}catch{}})();import{resolvePmHistoryOperation}from"./command-aliases.js";import{normalizeUniqueStringList}from"./string-lists.js";import{GRAPH_QUERY_DEFAULTS}from"../graph/query-contracts.js";import{RESERVED_EXTENSION_HOST_FLAGS}from"../../core/extensions/reserved-host-flags.js";import{PM_POSITIONAL_ACTION_CONTRACTS}from"./grammar-contracts.js";function normalizeFlagAliasKey(flag){return flag.startsWith("--")?`--${flag.slice(2).replaceAll("_","-")}`:flag}function withFlagAliasMetadata(flagContracts){const aliasesByCanonical=new Map;for(const contract of flagContracts){const canonical=normalizeFlagAliasKey(contract.flag),bucket=aliasesByCanonical.get(canonical)??new Set;contract.flag!==canonical&&bucket.add(contract.flag);for(const alias of contract.aliases??[])alias!==canonical&&bucket.add(alias);aliasesByCanonical.set(canonical,bucket)}return flagContracts.map(contract=>{const canonical=normalizeFlagAliasKey(contract.flag);if(contract.flag!==canonical)return contract;const aliases=normalizeUniqueStringList([...contract.aliases??[],...aliasesByCanonical.get(canonical)]).filter(alias=>alias!==canonical);return aliases.length===0?contract:{...contract,aliases}})}function compactFlagAliasContracts(flagContracts){const withAliases=withFlagAliasMetadata(flagContracts),canonicalFlags=new Set(withAliases.map(contract=>contract.flag));return withAliases.filter(contract=>{const canonical=normalizeFlagAliasKey(contract.flag);return contract.flag===canonical||!canonicalFlags.has(canonical)})}const SUBCOMMAND_GLOBAL_FLAG_CONTRACTS=RESERVED_EXTENSION_HOST_FLAGS.map(definition=>({flag:definition.flag,reservation_scope:"inherited",...definition.aliases?{aliases:[...definition.aliases]}:{},...definition.value_name?{value_name:definition.value_name}:{}})),GLOBAL_FLAG_CONTRACTS=[...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,{flag:"--version",value_type:"boolean",reservation_scope:"root_only"},{flag:"--all",value_type:"boolean",reservation_scope:"root_only",description:"Expand root help to every command."},{flag:"--explain",value_type:"boolean",reservation_scope:"root_only",description:"Expand root help with command guidance."}],GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--has-notes"},{flag:"--no-notes"},{flag:"--has-learnings"},{flag:"--no-learnings"},{flag:"--has-files"},{flag:"--no-files"},{flag:"--filter-files-missing"},{flag:"--has-docs"},{flag:"--no-docs"},{flag:"--filter-docs-missing"},{flag:"--has-tests"},{flag:"--no-tests"},{flag:"--has-comments"},{flag:"--no-comments"},{flag:"--has-deps"},{flag:"--no-deps"},{flag:"--has-body"},{flag:"--empty-body"},{flag:"--has-linked-command"},{flag:"--no-linked-command"}],MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--filter-has-notes"},{flag:"--filter-no-notes"},{flag:"--filter-has-learnings"},{flag:"--filter-no-learnings"},{flag:"--filter-has-files"},{flag:"--filter-no-files"},{flag:"--filter-has-docs"},{flag:"--filter-no-docs"},{flag:"--filter-has-tests"},{flag:"--filter-no-tests"},{flag:"--filter-has-comments"},{flag:"--filter-no-comments"},{flag:"--filter-has-deps"},{flag:"--filter-no-deps"},{flag:"--filter-has-body"},{flag:"--filter-empty-body"},{flag:"--filter-has-linked-command"},{flag:"--filter-no-linked-command"},{flag:"--ids",list:!0},{flag:"--limit"},{flag:"--offset"}],LIST_FILTER_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--status",list:!0},{flag:"--all",value_type:"boolean"},{flag:"--type",list:!0},{flag:"--tag",aliases:["--tags"],list:!0},{flag:"--priority",list:!0},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--today"},{flag:"--recent"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--ids",list:!0},{flag:"--assignee",list:!0},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:!0},{flag:"--release",list:!0},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--limit"},{flag:"--offset"},{flag:"--after"},{flag:"--no-truncate"},{flag:"--compact"},{flag:"--brief"},{flag:"--full"},{flag:"--fields",list:!0},{flag:"--sort"},{flag:"--order"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--include-body"},{flag:"--strict-read"},{flag:"--format"},{flag:"--stream"}],new Set(["--limit","--token-budget","--offset","--after","--no-truncate","--compact","--brief","--full","--fields","--include-body","--strict-read"])),AGGREGATE_FLAG_CONTRACTS=[{flag:"--group-by",list:!0},{flag:"--set-mode"},{flag:"--limit"},{flag:"--after"},{flag:"--count"},{flag:"--completion"},{flag:"--sum"},{flag:"--avg"},{flag:"--include-unparented"},{flag:"--include_unparented"},{flag:"--status",list:!0},{flag:"--type",list:!0},{flag:"--tag",list:!0},{flag:"--priority",list:!0},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--assignee",list:!0},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:!0},{flag:"--release",list:!0}],COMMENTS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--comment","--body","--text"]},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];function withCursorSemantics(contracts,presentationFlags){return contracts.map(contract=>presentationFlags.has(contract.flag)?{...contract,cursor_semantics:"presentation"}:contract)}const NOTES_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--note","--text"]},{flag:"--add-json"},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--since"},{flag:"--event-type"},{flag:"--include-meta"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],LEARNINGS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--learning","--text"]},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],FILES_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--append-stable"},{flag:"--validate-paths"},{flag:"--scope"},{flag:"--limit"},{flag:"--offset"},{flag:"--no-truncate"},{flag:"--strict-read"},{flag:"--explain"},{flag:"--lines",value_name:"start:end"},{flag:"--decision-depth",value_name:"n",value_type:"number"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],DOCS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--validate-paths"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],HISTORY_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--limit"},{flag:"--compact"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:!0},{flag:"--agent-instance",repeatable:!0},{flag:"--provenance-filter",repeatable:!0},{flag:"--diff"},{flag:"--field"},{flag:"--verify"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--format"}],MERGE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--message"},{flag:"--force"},{flag:"--include-reconciled"},{flag:"--output"},{flag:"--item-path"},{flag:"--prefer"}],HISTORY_REDACT_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--literal"},{flag:"--regex"},{flag:"--replacement"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],HISTORY_REPAIR_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--all"},{flag:"--dry-run"},{flag:"--normalize-provenance"},{flag:"--salvage-tail",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS=[{flag:"--event",repeatable:!0},{flag:"--all-actionable"},{flag:"--dry-run"},{flag:"--plan-fingerprint"},{flag:"--limit",value_type:"number"},{flag:"--attributed-author",aliases:["--attributed_author"]},{flag:"--reviewer"},{flag:"--reason"}],HISTORY_COMPACT_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--before"},{flag:"--ids",list:!0},{flag:"--all-over",value_type:"number"},{flag:"--closed"},{flag:"--all-streams"},{flag:"--min-entries",value_type:"number"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],HISTORY_ATTEST_FLAG_CONTRACTS=[{flag:"--verify",value_name:"file",value_type:"string"},{flag:"--output",value_name:"file",value_type:"string"},{flag:"--hash-algorithm",value_name:"name",value_type:"string"}],SCHEMA_FLAG_CONTRACTS=[{flag:"--definition",value_name:"json"},{flag:"--policy",value_name:"id"},{flag:"--message",value_name:"value"},{flag:"--description"},{flag:"--default-status",aliases:["--default_status"]},{flag:"--folder"},{flag:"--alias"},{flag:"--role"},{flag:"--order"},{flag:"--type"},{flag:"--commands"},{flag:"--cli-flag"},{flag:"--required"},{flag:"--required-on-create"},{flag:"--no-allow-unset"},{flag:"--required-types"},{flag:"--infer"},{flag:"--min-count"},{flag:"--apply",value_type:"boolean"},{flag:"--to"},{flag:"--migration-id",aliases:["--migration_id"]},{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}],PROFILE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}],PLAN_FLAG_CONTRACTS=[{flag:"--title"},{flag:"--description"},{flag:"--scope"},{flag:"--parent"},{flag:"--related"},{flag:"--blocks"},{flag:"--blocked-by",aliases:["--blocked_by"]},{flag:"--harness"},{flag:"--mode"},{flag:"--resume-context",aliases:["--resume_context"]},{flag:"--tags",aliases:["--tag"],list:!0},{flag:"--priority"},{flag:"--status",short:"-s"},{flag:"--create-mode",aliases:["--create_mode"]},{flag:"--deadline"},{flag:"--estimate",aliases:["--estimated-minutes","--estimated_minutes"]},{flag:"--acceptance-criteria",aliases:["--acceptance_criteria","--ac"],repeatable:!0},{flag:"--definition-of-ready",aliases:["--definition_of_ready"]},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now",aliases:["--why_now"]},{flag:"--assignee"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-reason",aliases:["--blocked_reason"]},{flag:"--unblock-note",aliases:["--unblock_note"]},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps",aliases:["--repro_steps"]},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--affected-version",aliases:["--affected_version"]},{flag:"--fixed-version",aliases:["--fixed_version"]},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact",aliases:["--customer_impact"]},{flag:"--comment",repeatable:!0},{flag:"--note",repeatable:!0},{flag:"--learning",repeatable:!0},{flag:"--reminder",repeatable:!0},{flag:"--event",repeatable:!0},{flag:"--type-option",aliases:["--type_option"],repeatable:!0},{flag:"--body"},{flag:"--claim"},{flag:"--from-search",aliases:["--from_search"]},{flag:"--template"},{flag:"--step-title",aliases:["--step_title"]},{flag:"--step"},{flag:"--step-body",aliases:["--step_body"]},{flag:"--step-owner",aliases:["--step_owner"]},{flag:"--step-status",aliases:["--step_status"]},{flag:"--step-evidence",aliases:["--step_evidence"]},{flag:"--step-blocked-reason",aliases:["--step_blocked_reason"]},{flag:"--step-replacement",aliases:["--step_replacement"]},{flag:"--depends-on",aliases:["--depends_on"]},{flag:"--link"},{flag:"--link-kind",aliases:["--link_kind"]},{flag:"--link-note",aliases:["--link_note"]},{flag:"--promote-to-item-dep",aliases:["--promote_to_item_dep"]},{flag:"--allow-multiple-active",aliases:["--allow_multiple_active"]},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--decision-text",aliases:["--decision_text","--decision"]},{flag:"--decision-rationale",aliases:["--decision_rationale"]},{flag:"--decision-evidence",aliases:["--decision_evidence"]},{flag:"--discovery-text",aliases:["--discovery_text","--discovery"]},{flag:"--validation-text",aliases:["--validation_text","--validation"]},{flag:"--validation-command",aliases:["--validation_command"]},{flag:"--validation-expected",aliases:["--validation_expected"]},{flag:"--depth"},{flag:"--field"},{flag:"--fields",list:!0},{flag:"--steps"},{flag:"--materialize-type",aliases:["--materialize_type"]},{flag:"--materialize-parent",aliases:["--materialize_parent"]},{flag:"--materialize-tags",aliases:["--materialize_tags"]},{flag:"--author"},{flag:"--message"},{flag:"--force"}],INIT_FLAG_CONTRACTS=[{flag:"--id-prefix",aliases:["--prefix"]},{flag:"--preset"},{flag:"--type-preset"},{flag:"--defaults",short:"-y",aliases:["--yes"]},{flag:"--author"},{flag:"--agent-guidance"},{flag:"--with-packages"},{flag:"--no-merge-fence"},{flag:"--workspace"},{flag:"--force"},{flag:"--verbose"}],CONFIG_FLAG_CONTRACTS=[{flag:"--value",value_name:"value"},{flag:"--criterion"},{flag:"--clear-criteria"},{flag:"--format"},{flag:"--policy"},{flag:"--default-depth"},{flag:"--activity-limit"},{flag:"--stale-threshold-days"},{flag:"--section-hierarchy"},{flag:"--section-activity"},{flag:"--section-progress"},{flag:"--section-blockers"},{flag:"--section-files"},{flag:"--section-workload"},{flag:"--section-staleness"},{flag:"--section-tests"}],EXTENSION_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--init"},{flag:"--scaffold"},{flag:"--capability"},{flag:"--install"},{flag:"--uninstall"},{flag:"--explore"},{flag:"--list"},{flag:"--manage"},{flag:"--offline",value_type:"boolean"},{flag:"--describe"},{flag:"--markdown"},{flag:"--output"},{flag:"--reload"},{flag:"--watch"},{flag:"--doctor"},{flag:"--catalog"},{flag:"--adopt"},{flag:"--adopt-all"},{flag:"--activate"},{flag:"--deactivate"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"},{flag:"--detail"},{flag:"--trace"},{flag:"--runtime-probe"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}],EXTENSION_SCOPE_FLAG_CONTRACTS=[{flag:"--project"},{flag:"--local"},{flag:"--global"}],EXTENSION_INIT_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--capability"}],PACKAGE_FLAG_CONTRACTS=[...EXTENSION_FLAG_CONTRACTS,{flag:"--declarative"}],PACKAGE_INIT_FLAG_CONTRACTS=[...EXTENSION_INIT_FLAG_CONTRACTS,{flag:"--declarative"}],EXTENSION_INSTALL_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],EXTENSION_UNINSTALL_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_EXPLORE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_DESCRIBE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--markdown"},{flag:"--output"}],EXTENSION_ADOPT_ALL_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_ACTIVATE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_DEACTIVATE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_MIGRATE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--dry-run"}],EXTENSION_MANAGE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--offline",value_type:"boolean"},{flag:"--runtime-probe"},{flag:"--fix-managed-state"}],EXTENSION_RELOAD_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--watch"}],EXTENSION_DOCTOR_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--detail"},{flag:"--trace"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}],EXTENSION_CATALOG_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--fields",list:!0}],EXTENSION_ADOPT_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],INSTALL_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],UPGRADE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--cli-only"},{flag:"--packages-only"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--repair"},{flag:"--tag"},{flag:"--package-name"}],REINDEX_FLAG_CONTRACTS=[{flag:"--mode"},{flag:"--progress"}],CLOSE_FLAG_CONTRACTS=[{flag:"--release-assignment",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--reason",value_name:"value"},{flag:"--close-reason",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--duplicate-of",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",aliases:["--expected_result","--expected"],value_name:"value"},{flag:"--actual-result",aliases:["--actual_result","--actual"],value_name:"value"},{flag:"--force",value_type:"boolean"}],CLOSE_MANY_FLAG_CONTRACTS=[{flag:"--filter-status",list:!0},{flag:"--filter-type"},{flag:"--filter-tag"},{flag:"--filter-priority"},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee"},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint"},{flag:"--filter-release"},...MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--reason"},{flag:"--completed-at"},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--validate-close"},{flag:"--author"},{flag:"--message"},{flag:"--force"},{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"}],APPEND_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--body",short:"-b"},{flag:"--text"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],CLAIM_FLAG_CONTRACTS=[{flag:"--start",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"},{flag:"--if-available"},{flag:"--next"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee-filter"},{flag:"--parent"},{flag:"--sprint"},{flag:"--release"},{flag:"--max-attempts"},{flag:"--include-decisions"},{flag:"--include-gates"},{flag:"--include-containers"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--explain-ranking",aliases:["--explain_ranking"]}],RESTORE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],DELETE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],RELEASE_FLAG_CONTRACTS=[{flag:"--pause",value_type:"boolean"},{flag:"--handoff",value_name:"status"},{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}],START_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}],PAUSE_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}],CLOSE_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--force"}],SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS=[{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--tags"},{flag:"--priority"},{flag:"--body"},{flag:"--description"},{flag:"--author"},{flag:"--message"}],MEET_FLAG_CONTRACTS=[{flag:"--start"},{flag:"--duration"},{flag:"--end"},{flag:"--location"},{flag:"--timezone"},{flag:"--all-day"},...SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS],EVENT_FLAG_CONTRACTS=MEET_FLAG_CONTRACTS,REMIND_FLAG_CONTRACTS=[{flag:"--at"},{flag:"--text"},...SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS],TEST_FLAG_CONTRACTS=[{flag:"--list"},{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-json"},{flag:"--remove"},{flag:"--remove-index",repeatable:!0},{flag:"--update"},{flag:"--update-index"},{flag:"--set-json"},{flag:"--run"},{flag:"--match"},{flag:"--only-index"},{flag:"--only-last"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--acknowledge-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"},{flag:"--measure",list:!0,description:"Record numeric measurement evidence; requires --run and an executed linked command."},{flag:"--metric-below"},{flag:"--metric-diff"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],TEST_ALL_FLAG_CONTRACTS=[{flag:"--status"},{flag:"--limit"},{flag:"--offset"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"}],TELEMETRY_FLAG_CONTRACTS=[{flag:"--limit"}],TEST_RUNS_FLAG_CONTRACTS=[{flag:"--status"},{flag:"--limit"},{flag:"--stream"},{flag:"--tail"},{flag:"--force"},{flag:"--author"}],GC_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--scope"}],STATS_FLAG_CONTRACTS=[{flag:"--include-empty"},{flag:"--storage"},{flag:"--metadata-coverage"},{flag:"--field-utilization"},{flag:"--by-assignee"},{flag:"--by-tag"},{flag:"--by-priority"},{flag:"--tag-prefix"},{flag:"--analytics"}],DUPLICATES_FLAG_CONTRACTS=[{flag:"--exhaustive",value_type:"boolean"},{flag:"--status",repeatable:!0,list:!0},{flag:"--since"},{flag:"--threshold"},{flag:"--limit"}],HEALTH_FLAG_CONTRACTS=[{flag:"--strict-directories"},{flag:"--require-merge-drivers"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--check-only"},{flag:"--check-telemetry"},{flag:"--no-refresh"},{flag:"--refresh-vectors"},{flag:"--verbose-stale-items"},{flag:"--verbose-author-events"},{flag:"--brief"},{flag:"--summary"},{flag:"--skip-vectors"},{flag:"--skip-integrity"},{flag:"--skip-drift"},{flag:"--full"}],VALIDATE_FLAG_CONTRACTS=[{flag:"--check-completeness",value_type:"boolean"},{flag:"--check-metadata"},{flag:"--metadata-profile"},{flag:"--check-resolution"},{flag:"--check-lifecycle"},{flag:"--check-stale-blockers"},{flag:"--dependency-cycle-severity"},{flag:"--parent-cycle-severity"},{flag:"--check-files"},{flag:"--scan-mode"},{flag:"--include-pm-internals"},{flag:"--verbose-file-lists"},{flag:"--verbose-diagnostics"},{flag:"--all-affected-ids"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--fix-hints"},{flag:"--auto-fix"},{flag:"--dry-run"},{flag:"--fix-scope"},{flag:"--prune-missing"},{flag:"--check-history-drift"},{flag:"--check-command-references"},{flag:"--check-storage-integrity"},{flag:"--counts"},{flag:"--full"}],ASSURANCE_FLAG_CONTRACTS=[{flag:"--definition",value_name:"json"},{flag:"--trigger",value_name:"value"},{flag:"--tree",value_name:"value"},{flag:"--gate",value_name:"id"},{flag:"--limit",value_name:"number"},{flag:"--dry-run"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--owner",value_name:"item-id"},{flag:"--apply",value_type:"boolean"},{flag:"--enforcement",value_name:"level"}],ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS=[{flag:"--assignee"},{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--allow-unresolved-deps"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-by"},{flag:"--blocked-reason"},{flag:"--unblock-note"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--actual-result"},{flag:"--affected-version"},{flag:"--fixed-version"}],ITEM_PORTFOLIO_FLAG_CONTRACTS=[{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"}],ITEM_CONTENT_METADATA_FLAG_CONTRACTS=[{short:"-p",flag:"--priority"},{flag:"--type"},{flag:"--tags",aliases:["--tag"],list:!0},{flag:"--add-tags",aliases:["--add_tags"]},{flag:"--remove-tags",aliases:["--remove_tags"]},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--add-ac",aliases:["--add_ac"]},{flag:"--remove-ac",aliases:["--remove_ac"]}],CREATE_FLAG_CONTRACTS=[{flag:"--stdin-json"},{short:"-t",flag:"--title"},{flag:"--id"},{short:"-d",flag:"--description"},{flag:"--type"},{flag:"--template"},{flag:"--create-mode"},{flag:"--create_mode"},{flag:"--schedule-preset"},{flag:"--schedule_preset"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},{flag:"--completed_at"},{short:"-p",flag:"--priority"},{flag:"--tags",aliases:["--tag"],list:!0},{flag:"--add-tags",aliases:["--add_tags"]},{short:"-b",flag:"--body",value_name:"value"},{flag:"--body-file"},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--author"},{flag:"--message"},...ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS,...ITEM_PORTFOLIO_FLAG_CONTRACTS,{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--fixed_version"},{flag:"--dep"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--reminder"},{flag:"--event"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--allow-duplicate",value_type:"boolean"}],ITEM_MUTATE_FLAG_CONTRACTS=[{flag:"--transaction-id",value_name:"value"},{flag:"--stdin-json"},{flag:"--from",value_name:"path"},{flag:"--upsert-key",value_name:"field"},{flag:"--dry-run"},{flag:"--create-compensation",value_name:"mode"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--author",value_name:"value"}],ITEM_COMPLETE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--transaction-id",value_name:"value",required:!0},{flag:"--reason",value_name:"value"},{flag:"--file",value_name:"value",repeatable:!0},{flag:"--doc",value_name:"value",repeatable:!0},{flag:"--test",value_name:"value",repeatable:!0},{flag:"--comment",value_name:"value",repeatable:!0},{flag:"--note",value_name:"value",repeatable:!0},{flag:"--learning",value_name:"value",repeatable:!0},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",value_name:"value"},{flag:"--actual-result",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--dry-run"},{flag:"--force"},{flag:"--author",value_name:"value"}],ITEM_REOPEN_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--status",value_name:"open|in_progress"},{flag:"--expected-result",value_name:"value",aliases:["--expected"]},{flag:"--message",value_name:"value"},{flag:"--force"},{flag:"--author",value_name:"value"}],COPY_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--title",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--allow-duplicate",value_type:"boolean"}],FOCUS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--clear"}],UPDATE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--stdin-json"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},{flag:"--body-file"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},...ITEM_CONTENT_METADATA_FLAG_CONTRACTS,...ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS,{flag:"--fixed_version"},...ITEM_PORTFOLIO_FLAG_CONTRACTS,{flag:"--author"},{flag:"--message"},{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--force"}],UPDATE_MANY_FLAG_CONTRACTS=[{flag:"--status",short:"-s"},{flag:"--assignee"},{flag:"--parent"},{flag:"--blocked-by",aliases:["--blocked_by"]},{flag:"--blocked-reason",aliases:["--blocked_reason"]},{flag:"--unblock-note",aliases:["--unblock_note"]},{flag:"--filter-status",list:!0},{flag:"--filter-type",list:!0},{flag:"--filter-tag",list:!0},{flag:"--filter-priority",list:!0},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee",list:!0},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint",list:!0},{flag:"--filter-release",list:!0},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},...ITEM_CONTENT_METADATA_FLAG_CONTRACTS,{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--repro_steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--expected_result"},{flag:"--expected"},{flag:"--actual-result"},{flag:"--actual_result"},{flag:"--actual"},{flag:"--affected-version"},{flag:"--affected_version"},{flag:"--fixed-version"},{flag:"--fixed_version"},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--allow-unresolved-deps"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],CALENDAR_FLAG_CONTRACTS=[{flag:"--view"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--full-period"},{flag:"--full_period"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--status"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--include"},{flag:"--recurrence-lookahead-days"},{flag:"--recurrence-lookback-days"},{flag:"--occurrence-limit"},{flag:"--limit"},{flag:"--format"}],ACTIVITY_FLAG_CONTRACTS=[{flag:"--id"},{flag:"--op"},{flag:"--author"},{flag:"--from"},{flag:"--to"},{flag:"--limit"},{flag:"--unbounded"},{flag:"--compact"},{flag:"--raw"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:!0},{flag:"--agent-instance",repeatable:!0},{flag:"--provenance-filter",repeatable:!0},{flag:"--stream"}],EVENTS_FLAG_CONTRACTS=[{flag:"--since"},{flag:"--type",repeatable:!0},{flag:"--author",repeatable:!0},{flag:"--item",repeatable:!0},{flag:"--limit",value_type:"number"},{flag:"--cursor-mode",value_name:"batch|row"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:!0},{flag:"--agent-instance",repeatable:!0},{flag:"--provenance-filter",repeatable:!0},{flag:"--follow"},{flag:"--interval-ms",value_type:"number"}],CONTEXT_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit",aliases:["--max-items"]},{flag:"--after"},{flag:"--format"},{flag:"--depth"},{flag:"--fields",list:!0},{flag:"--section"},{flag:"--activity-limit"},{flag:"--stale-threshold"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--no-extension-health"},{flag:"--no-tags"}],new Set(["--limit","--after","--format","--fields","--section","--activity-limit","--stale-threshold","--explain-ranking","--explain_ranking","--no-extension-health","--no-tags"])),GET_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--depth"},{flag:"--full",value_type:"boolean"},{flag:"--fields",list:!0},{flag:"--at"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--format"}],GUIDE_FLAG_CONTRACTS=[{flag:"--list"},{flag:"--format"},{flag:"--depth"}],DEPS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--format"},{flag:"--max-depth"},{flag:"--collapse"},{flag:"--summary"},{flag:"--full"},{flag:"--node-limit"},{flag:"--edge-limit"},{flag:"--token-budget"},{flag:"--cursor"},{flag:"--direction"},{flag:"--kind",list:!0}],GRAPH_FLAG_CONTRACTS=[{flag:"--kind",list:!0},{flag:"--max-depth",description:`Maximum traversal depth; paths default to ${GRAPH_QUERY_DEFAULTS.path_depth}.`},{flag:"--limit",description:`Maximum rows per collection; default ${GRAPH_QUERY_DEFAULTS.rows}. Use --full to remove the row cap.`},{flag:"--after"},{flag:"--direction"},{flag:"--max-paths",description:`Maximum enumerated paths; default ${GRAPH_QUERY_DEFAULTS.paths}.`},{flag:"--sample",description:`Maximum evidence examples per audit finding; default ${GRAPH_QUERY_DEFAULTS.samples}.`},{flag:"--exempt-isolate",list:!0},{flag:"--exempt-isolate-type",list:!0},{flag:"--save-baseline"},{flag:"--rebuild"},{flag:"--clear"},{flag:"--summary"},{flag:"--full"}],EVAL_FLAG_CONTRACTS=[{flag:"--mode"},{flag:"--k"},{flag:"--fail-under"},{flag:"--queries"},{flag:"--format"}],WORKSPACE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--force"},{flag:"--author"},{flag:"--message"}],WORKSPACE_POSITION_FLAG_CONTRACTS=[],NEXT_FLAG_CONTRACTS=[{flag:"--include-decisions"},{flag:"--include-gates"},{flag:"--include-containers"},{flag:"--for",value_name:"intent"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit"},{flag:"--blocked-limit"},{flag:"--blocked_limit"},{flag:"--ready-only"},{flag:"--ready_only"},{flag:"--format"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]}],SEARCH_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--mode"},{flag:"--semantic"},{flag:"--hybrid"},{flag:"--match-mode"},{flag:"--min-score"},{flag:"--count"},{flag:"--semantic-weight"},{flag:"--include-linked"},{flag:"--title-exact"},{flag:"--phrase-exact"},{flag:"--highlight"},{flag:"--compact"},{flag:"--full"},{flag:"--fields",list:!0},{flag:"--format"},{flag:"--limit"},{flag:"--after"},{flag:"--status",list:!0},{flag:"--type",list:!0},{flag:"--tag",aliases:["--tags"],list:!0},{flag:"--priority",list:!0},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--assignee",list:!0},{flag:"--sprint",list:!0},{flag:"--release",list:!0},{flag:"--parent"},...GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS],new Set(["--highlight","--compact","--full","--fields","--format","--limit","--token-budget","--after"])),CONTRACTS_FLAG_CONTRACTS=[{flag:"--action"},{flag:"--command"},{flag:"--summary"},{flag:"--schema-only"},{flag:"--flags-only"},{flag:"--availability-only"},{flag:"--runtime-only"},{flag:"--active-only"},{flag:"--full"}],COMPLETION_FLAG_CONTRACTS=[{flag:"--eager-tags"}];function toUniqueFlagContracts(contracts){const seen=new Set,unique=[];for(const contract of contracts){const aliasKey=(contract.aliases??[]).join(","),key=`${contract.flag}|${contract.short??""}|${aliasKey}`;seen.has(key)||(seen.add(key),unique.push(contract))}return unique}function withSubcommandGlobalFlags(contracts){const byCanonicalFlag=new Map;for(const contract of[...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,...contracts]){const canonicalFlag=normalizeFlagAliasKey(contract.flag),prior=byCanonicalFlag.get(canonicalFlag),{aliases:declaredAliases,...contractWithoutAliases}=contract,aliases=normalizeUniqueStringList([...declaredAliases??[],...contract.flag===canonicalFlag?[]:[contract.flag]]).filter(alias=>alias!==canonicalFlag),normalizedContract={...contractWithoutAliases,flag:canonicalFlag,...aliases.length>0?{aliases}:{}},mergedAliases=normalizeUniqueStringList([...prior?.aliases??[],...normalizedContract.aliases??[]]);byCanonicalFlag.set(canonicalFlag,prior===void 0?normalizedContract:{...prior,...normalizedContract,...mergedAliases.length>0?{aliases:mergedAliases}:{}})}return withFlagAliasMetadata([...byCanonicalFlag.values()])}const FIXED_STATUS_LIST_COMMAND_ALIASES=["list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled"],FIXED_STATUS_LIST_FLAG_CONTRACTS=LIST_FILTER_FLAG_CONTRACTS.filter(contract=>contract.flag!=="--status"&&contract.flag!=="--all");function indexCliFlagContracts(contracts){const index=new Map;for(const contract of contracts)for(const spelling of[contract.flag,...contract.aliases??[]]){const matches=index.get(spelling)??[];matches.push(contract),index.set(spelling,matches)}return index}const PLAN_FLAG_CONTRACT_INDEX=indexCliFlagContracts(PLAN_FLAG_CONTRACTS),ASSURANCE_FLAG_CONTRACT_INDEX=indexCliFlagContracts(ASSURANCE_FLAG_CONTRACTS),POSITIONAL_ACTION_FLAG_INDEX_BY_PARENT=new Map([["assurance",ASSURANCE_FLAG_CONTRACT_INDEX],["plan",PLAN_FLAG_CONTRACT_INDEX],["workspace",indexCliFlagContracts(WORKSPACE_POSITION_FLAG_CONTRACTS)],["workspace snapshot",indexCliFlagContracts(WORKSPACE_FLAG_CONTRACTS)]]);function resolvePmPositionalActionFlagContracts(actions=PM_POSITIONAL_ACTION_CONTRACTS){return actions.map(({command,parent,accepted_flags:acceptedFlags})=>{const parentFlagIndex=POSITIONAL_ACTION_FLAG_INDEX_BY_PARENT.get(parent);if(!parentFlagIndex)throw new Error(`Positional action ${command} has no flag-contract index for ${parent}.`);const selected=acceptedFlags.map(acceptedFlag=>{const matches=parentFlagIndex.get(acceptedFlag)??[];if(matches.length!==1)throw new Error(`Positional action ${command} accepted flag ${acceptedFlag} does not resolve to exactly one ${parent} flag contract.`);return matches[0]});return[command,selected]})}const PM_POSITIONAL_ACTION_FLAG_CONTRACTS=resolvePmPositionalActionFlagContracts(),SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND=new Map([["list",LIST_FILTER_FLAG_CONTRACTS],["list-all",LIST_FILTER_FLAG_CONTRACTS],...FIXED_STATUS_LIST_COMMAND_ALIASES.map(command=>[command,FIXED_STATUS_LIST_FLAG_CONTRACTS]),["templates",CREATE_FLAG_CONTRACTS],["cal",CALENDAR_FLAG_CONTRACTS],["ctx",CONTEXT_FLAG_CONTRACTS],["test-runs-worker",[]],["init",INIT_FLAG_CONTRACTS],["config",CONFIG_FLAG_CONTRACTS],["extension",EXTENSION_FLAG_CONTRACTS],["package",PACKAGE_FLAG_CONTRACTS],["packages",PACKAGE_FLAG_CONTRACTS],["install",INSTALL_FLAG_CONTRACTS],["upgrade",UPGRADE_FLAG_CONTRACTS],["create",CREATE_FLAG_CONTRACTS],["item",[]],["item mutate",ITEM_MUTATE_FLAG_CONTRACTS],["item complete",ITEM_COMPLETE_FLAG_CONTRACTS],["item reopen",ITEM_REOPEN_FLAG_CONTRACTS],["copy",COPY_FLAG_CONTRACTS],["focus",FOCUS_FLAG_CONTRACTS],["aggregate",AGGREGATE_FLAG_CONTRACTS],["calendar",CALENDAR_FLAG_CONTRACTS],["context",CONTEXT_FLAG_CONTRACTS],["get",GET_FLAG_CONTRACTS],["guide",GUIDE_FLAG_CONTRACTS],["search",SEARCH_FLAG_CONTRACTS],["next",NEXT_FLAG_CONTRACTS],["eval",EVAL_FLAG_CONTRACTS],["workspace",WORKSPACE_FLAG_CONTRACTS],["workspace position",WORKSPACE_POSITION_FLAG_CONTRACTS],["workspace snapshot",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot create",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot list",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot inspect",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot restore",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot delete",WORKSPACE_FLAG_CONTRACTS],["history",HISTORY_FLAG_CONTRACTS],["history-redact",HISTORY_REDACT_FLAG_CONTRACTS],["history-repair",HISTORY_REPAIR_FLAG_CONTRACTS],["history-author-acknowledge",HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS],["history-compact",HISTORY_COMPACT_FLAG_CONTRACTS],["history-attest",HISTORY_ATTEST_FLAG_CONTRACTS],["merge",MERGE_FLAG_CONTRACTS],["schema",SCHEMA_FLAG_CONTRACTS],["profile",PROFILE_FLAG_CONTRACTS],["plan",PLAN_FLAG_CONTRACTS],["activity",ACTIVITY_FLAG_CONTRACTS],["events",EVENTS_FLAG_CONTRACTS],["restore",RESTORE_FLAG_CONTRACTS],["update",UPDATE_FLAG_CONTRACTS],["update-many",UPDATE_MANY_FLAG_CONTRACTS],["close",CLOSE_FLAG_CONTRACTS],["close-many",CLOSE_MANY_FLAG_CONTRACTS],["delete",DELETE_FLAG_CONTRACTS],["append",APPEND_FLAG_CONTRACTS],["comments",COMMENTS_FLAG_CONTRACTS],["notes",NOTES_FLAG_CONTRACTS],["learnings",LEARNINGS_FLAG_CONTRACTS],["files",FILES_FLAG_CONTRACTS],["docs",DOCS_FLAG_CONTRACTS],["deps",DEPS_FLAG_CONTRACTS],["graph",GRAPH_FLAG_CONTRACTS],["test",TEST_FLAG_CONTRACTS],["test-all",TEST_ALL_FLAG_CONTRACTS],["telemetry",TELEMETRY_FLAG_CONTRACTS],["health",HEALTH_FLAG_CONTRACTS],["assurance",ASSURANCE_FLAG_CONTRACTS],...PM_POSITIONAL_ACTION_FLAG_CONTRACTS,["validate",VALIDATE_FLAG_CONTRACTS],["gc",GC_FLAG_CONTRACTS],["stats",STATS_FLAG_CONTRACTS],["duplicates",DUPLICATES_FLAG_CONTRACTS],["contracts",CONTRACTS_FLAG_CONTRACTS],["completion",COMPLETION_FLAG_CONTRACTS],["claim",CLAIM_FLAG_CONTRACTS],["release",RELEASE_FLAG_CONTRACTS],["start-task",START_TASK_FLAG_CONTRACTS],["pause-task",PAUSE_TASK_FLAG_CONTRACTS],["close-task",CLOSE_TASK_FLAG_CONTRACTS],["meet",MEET_FLAG_CONTRACTS],["event",EVENT_FLAG_CONTRACTS],["remind",REMIND_FLAG_CONTRACTS]]),EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND=new Map([["install",EXTENSION_INSTALL_FLAG_CONTRACTS],["uninstall",EXTENSION_UNINSTALL_FLAG_CONTRACTS],["explore",EXTENSION_EXPLORE_FLAG_CONTRACTS],["manage",EXTENSION_MANAGE_FLAG_CONTRACTS],["describe",EXTENSION_DESCRIBE_FLAG_CONTRACTS],["reload",EXTENSION_RELOAD_FLAG_CONTRACTS],["doctor",EXTENSION_DOCTOR_FLAG_CONTRACTS],["catalog",EXTENSION_CATALOG_FLAG_CONTRACTS],["list",EXTENSION_CATALOG_FLAG_CONTRACTS],["adopt",EXTENSION_ADOPT_FLAG_CONTRACTS],["adopt-all",EXTENSION_ADOPT_ALL_FLAG_CONTRACTS],["activate",EXTENSION_ACTIVATE_FLAG_CONTRACTS],["deactivate",EXTENSION_DEACTIVATE_FLAG_CONTRACTS],["migrate",EXTENSION_MIGRATE_FLAG_CONTRACTS]]);function normalizeCommandNameForContracts(commandName){return typeof commandName!="string"?"":resolvePmHistoryOperation(commandName.trim().toLowerCase())}function hasSubcommandFlagContractsForCommand(commandName){const normalized=normalizeCommandNameForContracts(commandName);if(SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND.has(normalized))return!0;const[rootCommand,lifecycleSubcommand,...extraParts]=normalized.split(/\s+/);return(rootCommand==="extension"||rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand!==void 0&&extraParts.length===0&&(lifecycleSubcommand==="init"||lifecycleSubcommand==="scaffold"||EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND.has(lifecycleSubcommand))}function resolveExtensionLifecycleFlagContracts(rootCommand,lifecycleSubcommand){return lifecycleSubcommand==="init"||lifecycleSubcommand==="scaffold"?rootCommand==="extension"?EXTENSION_INIT_FLAG_CONTRACTS:PACKAGE_INIT_FLAG_CONTRACTS:EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND.get(lifecycleSubcommand)??[]}function resolveSubcommandFlagContractsForCommand(commandName){const normalized=normalizeCommandNameForContracts(commandName);if(normalized.length===0)return withSubcommandGlobalFlags([]);const[rootCommand,lifecycleSubcommand,...extraParts]=normalized.split(/\s+/);if((rootCommand==="extension"||rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand!==void 0&&extraParts.length===0)return withSubcommandGlobalFlags((rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand==="upgrade"?UPGRADE_FLAG_CONTRACTS:resolveExtensionLifecycleFlagContracts(rootCommand,lifecycleSubcommand));const contracts=SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND.get(normalized)??[];return withSubcommandGlobalFlags(contracts)}function toCompletionFlagString(flagContracts,includeGlobal=!0){const scoped=withFlagAliasMetadata(flagContracts).flatMap(entry=>[entry.short,entry.flag,...entry.aliases??[]]).filter(value=>!!value),all=includeGlobal?[...scoped,...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS.flatMap(entry=>[entry.short,entry.flag,...entry.aliases??[]]).filter(value=>!!value)]:scoped;return normalizeUniqueStringList(all).join(" ")}export{ACTIVITY_FLAG_CONTRACTS,AGGREGATE_FLAG_CONTRACTS,APPEND_FLAG_CONTRACTS,ASSURANCE_FLAG_CONTRACTS,CALENDAR_FLAG_CONTRACTS,CLAIM_FLAG_CONTRACTS,CLOSE_FLAG_CONTRACTS,CLOSE_MANY_FLAG_CONTRACTS,CLOSE_TASK_FLAG_CONTRACTS,COMMENTS_FLAG_CONTRACTS,COMPLETION_FLAG_CONTRACTS,CONFIG_FLAG_CONTRACTS,CONTEXT_FLAG_CONTRACTS,CONTRACTS_FLAG_CONTRACTS,COPY_FLAG_CONTRACTS,CREATE_FLAG_CONTRACTS,DELETE_FLAG_CONTRACTS,DEPS_FLAG_CONTRACTS,DOCS_FLAG_CONTRACTS,DUPLICATES_FLAG_CONTRACTS,EVAL_FLAG_CONTRACTS,EVENTS_FLAG_CONTRACTS,EVENT_FLAG_CONTRACTS,EXTENSION_ACTIVATE_FLAG_CONTRACTS,EXTENSION_ADOPT_ALL_FLAG_CONTRACTS,EXTENSION_ADOPT_FLAG_CONTRACTS,EXTENSION_CATALOG_FLAG_CONTRACTS,EXTENSION_DEACTIVATE_FLAG_CONTRACTS,EXTENSION_DESCRIBE_FLAG_CONTRACTS,EXTENSION_DOCTOR_FLAG_CONTRACTS,EXTENSION_EXPLORE_FLAG_CONTRACTS,EXTENSION_FLAG_CONTRACTS,EXTENSION_INIT_FLAG_CONTRACTS,EXTENSION_INSTALL_FLAG_CONTRACTS,EXTENSION_MANAGE_FLAG_CONTRACTS,EXTENSION_MIGRATE_FLAG_CONTRACTS,EXTENSION_RELOAD_FLAG_CONTRACTS,EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_UNINSTALL_FLAG_CONTRACTS,FILES_FLAG_CONTRACTS,FOCUS_FLAG_CONTRACTS,GC_FLAG_CONTRACTS,GET_FLAG_CONTRACTS,GLOBAL_FLAG_CONTRACTS,GRAPH_FLAG_CONTRACTS,GUIDE_FLAG_CONTRACTS,HEALTH_FLAG_CONTRACTS,HISTORY_ATTEST_FLAG_CONTRACTS,HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS,HISTORY_COMPACT_FLAG_CONTRACTS,HISTORY_FLAG_CONTRACTS,HISTORY_REDACT_FLAG_CONTRACTS,HISTORY_REPAIR_FLAG_CONTRACTS,INIT_FLAG_CONTRACTS,INSTALL_FLAG_CONTRACTS,ITEM_COMPLETE_FLAG_CONTRACTS,ITEM_MUTATE_FLAG_CONTRACTS,ITEM_REOPEN_FLAG_CONTRACTS,LEARNINGS_FLAG_CONTRACTS,LIST_FILTER_FLAG_CONTRACTS,MEET_FLAG_CONTRACTS,MERGE_FLAG_CONTRACTS,NEXT_FLAG_CONTRACTS,NOTES_FLAG_CONTRACTS,PACKAGE_FLAG_CONTRACTS,PACKAGE_INIT_FLAG_CONTRACTS,PAUSE_TASK_FLAG_CONTRACTS,PLAN_FLAG_CONTRACTS,PM_POSITIONAL_ACTION_FLAG_CONTRACTS,PROFILE_FLAG_CONTRACTS,REINDEX_FLAG_CONTRACTS,RELEASE_FLAG_CONTRACTS,REMIND_FLAG_CONTRACTS,RESTORE_FLAG_CONTRACTS,SCHEMA_FLAG_CONTRACTS,SEARCH_FLAG_CONTRACTS,START_TASK_FLAG_CONTRACTS,STATS_FLAG_CONTRACTS,SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,TELEMETRY_FLAG_CONTRACTS,TEST_ALL_FLAG_CONTRACTS,TEST_FLAG_CONTRACTS,TEST_RUNS_FLAG_CONTRACTS,UPDATE_FLAG_CONTRACTS,UPDATE_MANY_FLAG_CONTRACTS,UPGRADE_FLAG_CONTRACTS,VALIDATE_FLAG_CONTRACTS,WORKSPACE_FLAG_CONTRACTS,WORKSPACE_POSITION_FLAG_CONTRACTS,compactFlagAliasContracts,hasSubcommandFlagContractsForCommand,resolvePmPositionalActionFlagContracts,resolveSubcommandFlagContractsForCommand,toCompletionFlagString,toUniqueFlagContracts,withFlagAliasMetadata};
1
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a549c8eb-3aaf-5f1f-8399-3f31408fde57")}catch{}})();import{resolvePmHistoryOperation}from"./command-aliases.js";import{normalizeUniqueStringList}from"./string-lists.js";import{GRAPH_QUERY_DEFAULTS}from"../graph/query-contracts.js";import{RESERVED_EXTENSION_HOST_FLAGS}from"../../core/extensions/reserved-host-flags.js";import{PM_POSITIONAL_ACTION_CONTRACTS}from"./grammar-contracts.js";function normalizeFlagAliasKey(flag){return flag.startsWith("--")?`--${flag.slice(2).replaceAll("_","-")}`:flag}function withFlagAliasMetadata(flagContracts){const aliasesByCanonical=new Map;for(const contract of flagContracts){const canonical=normalizeFlagAliasKey(contract.flag),bucket=aliasesByCanonical.get(canonical)??new Set;contract.flag!==canonical&&bucket.add(contract.flag);for(const alias of contract.aliases??[])alias!==canonical&&bucket.add(alias);aliasesByCanonical.set(canonical,bucket)}return flagContracts.map(contract=>{const canonical=normalizeFlagAliasKey(contract.flag);if(contract.flag!==canonical)return contract;const aliases=normalizeUniqueStringList([...contract.aliases??[],...aliasesByCanonical.get(canonical)]).filter(alias=>alias!==canonical);return aliases.length===0?contract:{...contract,aliases}})}function compactFlagAliasContracts(flagContracts){const withAliases=withFlagAliasMetadata(flagContracts),canonicalFlags=new Set(withAliases.map(contract=>contract.flag));return withAliases.filter(contract=>{const canonical=normalizeFlagAliasKey(contract.flag);return contract.flag===canonical||!canonicalFlags.has(canonical)})}const SUBCOMMAND_GLOBAL_FLAG_CONTRACTS=RESERVED_EXTENSION_HOST_FLAGS.map(definition=>({flag:definition.flag,reservation_scope:"inherited",...definition.aliases?{aliases:[...definition.aliases]}:{},...definition.value_name?{value_name:definition.value_name}:{}})),GLOBAL_FLAG_CONTRACTS=[...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,{flag:"--version",value_type:"boolean",reservation_scope:"root_only"},{flag:"--all",value_type:"boolean",reservation_scope:"root_only",description:"Expand root help to every command."},{flag:"--explain",value_type:"boolean",reservation_scope:"root_only",description:"Expand root help with command guidance."}],GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--has-notes"},{flag:"--no-notes"},{flag:"--has-learnings"},{flag:"--no-learnings"},{flag:"--has-files"},{flag:"--no-files"},{flag:"--filter-files-missing"},{flag:"--has-docs"},{flag:"--no-docs"},{flag:"--filter-docs-missing"},{flag:"--has-tests"},{flag:"--no-tests"},{flag:"--has-comments"},{flag:"--no-comments"},{flag:"--has-deps"},{flag:"--no-deps"},{flag:"--has-body"},{flag:"--empty-body"},{flag:"--has-linked-command"},{flag:"--no-linked-command"}],MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS=[{flag:"--filter-reviewer-missing"},{flag:"--filter-risk-missing"},{flag:"--filter-confidence-missing"},{flag:"--filter-sprint-missing"},{flag:"--filter-release-missing"},{flag:"--filter-has-notes"},{flag:"--filter-no-notes"},{flag:"--filter-has-learnings"},{flag:"--filter-no-learnings"},{flag:"--filter-has-files"},{flag:"--filter-no-files"},{flag:"--filter-has-docs"},{flag:"--filter-no-docs"},{flag:"--filter-has-tests"},{flag:"--filter-no-tests"},{flag:"--filter-has-comments"},{flag:"--filter-no-comments"},{flag:"--filter-has-deps"},{flag:"--filter-no-deps"},{flag:"--filter-has-body"},{flag:"--filter-empty-body"},{flag:"--filter-has-linked-command"},{flag:"--filter-no-linked-command"},{flag:"--ids",list:!0},{flag:"--limit"},{flag:"--offset"}],LIST_FILTER_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--status",list:!0},{flag:"--all",value_type:"boolean"},{flag:"--type",list:!0},{flag:"--tag",aliases:["--tags"],list:!0},{flag:"--priority",list:!0},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--today"},{flag:"--recent"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--ids",list:!0},{flag:"--assignee",list:!0},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:!0},{flag:"--release",list:!0},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--limit"},{flag:"--offset"},{flag:"--after"},{flag:"--no-truncate"},{flag:"--compact"},{flag:"--brief"},{flag:"--full"},{flag:"--fields",list:!0},{flag:"--sort"},{flag:"--order"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--include-body"},{flag:"--strict-read"},{flag:"--format"},{flag:"--stream"}],new Set(["--limit","--token-budget","--offset","--after","--no-truncate","--compact","--brief","--full","--fields","--include-body","--strict-read"])),AGGREGATE_FLAG_CONTRACTS=[{flag:"--group-by",list:!0},{flag:"--set-mode"},{flag:"--limit"},{flag:"--after"},{flag:"--count"},{flag:"--completion"},{flag:"--sum"},{flag:"--avg"},{flag:"--include-unparented"},{flag:"--include_unparented"},{flag:"--status",list:!0},{flag:"--type",list:!0},{flag:"--tag",list:!0},{flag:"--priority",list:!0},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--assignee",list:!0},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--parent"},{flag:"--sprint",list:!0},{flag:"--release",list:!0}],COMMENTS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--comment","--body","--text"]},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}];function withCursorSemantics(contracts,presentationFlags){return contracts.map(contract=>presentationFlags.has(contract.flag)?{...contract,cursor_semantics:"presentation"}:contract)}const NOTES_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--note","--text"]},{flag:"--add-json"},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--since"},{flag:"--event-type"},{flag:"--include-meta"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],LEARNINGS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add",aliases:["--learning","--text"]},{flag:"--stdin"},{flag:"--file"},{flag:"--edit"},{flag:"--delete"},{flag:"--limit"},{flag:"--full-history"},{flag:"--if-absent",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],FILES_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--append-stable"},{flag:"--validate-paths"},{flag:"--scope"},{flag:"--limit"},{flag:"--offset"},{flag:"--no-truncate"},{flag:"--strict-read"},{flag:"--explain"},{flag:"--lines",value_name:"start:end"},{flag:"--decision-depth",value_name:"n",value_type:"number"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],DOCS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-glob"},{flag:"--remove"},{flag:"--migrate"},{flag:"--note"},{flag:"--list"},{flag:"--validate-paths"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],HISTORY_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--limit"},{flag:"--compact"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:!0},{flag:"--agent-instance",repeatable:!0},{flag:"--provenance-filter",repeatable:!0},{flag:"--diff"},{flag:"--field"},{flag:"--verify"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--format"}],MERGE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--pre-commit-hook",value_type:"boolean"},{flag:"--stage",value_type:"boolean"},{flag:"--message"},{flag:"--force"},{flag:"--include-reconciled"},{flag:"--output"},{flag:"--item-path"},{flag:"--prefer"}],HISTORY_REDACT_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--literal"},{flag:"--regex"},{flag:"--replacement"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],HISTORY_REPAIR_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--all"},{flag:"--dry-run"},{flag:"--normalize-provenance"},{flag:"--salvage-tail",value_type:"boolean"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS=[{flag:"--event",repeatable:!0},{flag:"--all-actionable"},{flag:"--dry-run"},{flag:"--plan-fingerprint"},{flag:"--limit",value_type:"number"},{flag:"--attributed-author",aliases:["--attributed_author"]},{flag:"--reviewer"},{flag:"--reason"}],HISTORY_COMPACT_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--before"},{flag:"--ids",list:!0},{flag:"--all-over",value_type:"number"},{flag:"--closed"},{flag:"--all-streams"},{flag:"--min-entries",value_type:"number"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],HISTORY_ATTEST_FLAG_CONTRACTS=[{flag:"--verify",value_name:"file",value_type:"string"},{flag:"--output",value_name:"file",value_type:"string"},{flag:"--hash-algorithm",value_name:"name",value_type:"string"}],SCHEMA_FLAG_CONTRACTS=[{flag:"--definition",value_name:"json"},{flag:"--policy",value_name:"id"},{flag:"--message",value_name:"value"},{flag:"--description"},{flag:"--default-status",aliases:["--default_status"]},{flag:"--folder"},{flag:"--alias"},{flag:"--role"},{flag:"--order"},{flag:"--type"},{flag:"--commands"},{flag:"--cli-flag"},{flag:"--required"},{flag:"--required-on-create"},{flag:"--no-allow-unset"},{flag:"--required-types"},{flag:"--infer"},{flag:"--min-count"},{flag:"--apply",value_type:"boolean"},{flag:"--to"},{flag:"--migration-id",aliases:["--migration_id"]},{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}],PROFILE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--author"},{flag:"--force"}],PLAN_FLAG_CONTRACTS=[{flag:"--title"},{flag:"--description"},{flag:"--scope"},{flag:"--parent"},{flag:"--related"},{flag:"--blocks"},{flag:"--blocked-by",aliases:["--blocked_by"]},{flag:"--harness"},{flag:"--mode"},{flag:"--resume-context",aliases:["--resume_context"]},{flag:"--tags",aliases:["--tag"],list:!0},{flag:"--priority"},{flag:"--status",short:"-s"},{flag:"--create-mode",aliases:["--create_mode"]},{flag:"--deadline"},{flag:"--estimate",aliases:["--estimated-minutes","--estimated_minutes"]},{flag:"--acceptance-criteria",aliases:["--acceptance_criteria","--ac"],repeatable:!0},{flag:"--definition-of-ready",aliases:["--definition_of_ready"]},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now",aliases:["--why_now"]},{flag:"--assignee"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-reason",aliases:["--blocked_reason"]},{flag:"--unblock-note",aliases:["--unblock_note"]},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps",aliases:["--repro_steps"]},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--affected-version",aliases:["--affected_version"]},{flag:"--fixed-version",aliases:["--fixed_version"]},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact",aliases:["--customer_impact"]},{flag:"--comment",repeatable:!0},{flag:"--note",repeatable:!0},{flag:"--learning",repeatable:!0},{flag:"--reminder",repeatable:!0},{flag:"--event",repeatable:!0},{flag:"--type-option",aliases:["--type_option"],repeatable:!0},{flag:"--body"},{flag:"--claim"},{flag:"--from-search",aliases:["--from_search"]},{flag:"--template"},{flag:"--step-title",aliases:["--step_title"]},{flag:"--step"},{flag:"--step-body",aliases:["--step_body"]},{flag:"--step-owner",aliases:["--step_owner"]},{flag:"--step-status",aliases:["--step_status"]},{flag:"--step-evidence",aliases:["--step_evidence"]},{flag:"--step-blocked-reason",aliases:["--step_blocked_reason"]},{flag:"--step-replacement",aliases:["--step_replacement"]},{flag:"--depends-on",aliases:["--depends_on"]},{flag:"--link"},{flag:"--link-kind",aliases:["--link_kind"]},{flag:"--link-note",aliases:["--link_note"]},{flag:"--promote-to-item-dep",aliases:["--promote_to_item_dep"]},{flag:"--allow-multiple-active",aliases:["--allow_multiple_active"]},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--decision-text",aliases:["--decision_text","--decision"]},{flag:"--decision-rationale",aliases:["--decision_rationale"]},{flag:"--decision-evidence",aliases:["--decision_evidence"]},{flag:"--discovery-text",aliases:["--discovery_text","--discovery"]},{flag:"--validation-text",aliases:["--validation_text","--validation"]},{flag:"--validation-command",aliases:["--validation_command"]},{flag:"--validation-expected",aliases:["--validation_expected"]},{flag:"--depth"},{flag:"--field"},{flag:"--fields",list:!0},{flag:"--steps"},{flag:"--materialize-type",aliases:["--materialize_type"]},{flag:"--materialize-parent",aliases:["--materialize_parent"]},{flag:"--materialize-tags",aliases:["--materialize_tags"]},{flag:"--author"},{flag:"--message"},{flag:"--force"}],INIT_FLAG_CONTRACTS=[{flag:"--id-prefix",aliases:["--prefix"]},{flag:"--preset"},{flag:"--type-preset"},{flag:"--defaults",short:"-y",aliases:["--yes"]},{flag:"--author"},{flag:"--agent-guidance"},{flag:"--with-packages"},{flag:"--no-merge-fence"},{flag:"--workspace"},{flag:"--force"},{flag:"--verbose"}],CONFIG_FLAG_CONTRACTS=[{flag:"--value",value_name:"value"},{flag:"--criterion"},{flag:"--clear-criteria"},{flag:"--format"},{flag:"--policy"},{flag:"--default-depth"},{flag:"--activity-limit"},{flag:"--stale-threshold-days"},{flag:"--section-hierarchy"},{flag:"--section-activity"},{flag:"--section-progress"},{flag:"--section-blockers"},{flag:"--section-files"},{flag:"--section-workload"},{flag:"--section-staleness"},{flag:"--section-tests"}],EXTENSION_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--init"},{flag:"--scaffold"},{flag:"--capability"},{flag:"--install"},{flag:"--uninstall"},{flag:"--explore"},{flag:"--list"},{flag:"--manage"},{flag:"--offline",value_type:"boolean"},{flag:"--describe"},{flag:"--markdown"},{flag:"--output"},{flag:"--reload"},{flag:"--watch"},{flag:"--doctor"},{flag:"--catalog"},{flag:"--adopt"},{flag:"--adopt-all"},{flag:"--activate"},{flag:"--deactivate"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"},{flag:"--detail"},{flag:"--trace"},{flag:"--runtime-probe"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}],EXTENSION_SCOPE_FLAG_CONTRACTS=[{flag:"--project"},{flag:"--local"},{flag:"--global"}],EXTENSION_INIT_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--capability"}],PACKAGE_FLAG_CONTRACTS=[...EXTENSION_FLAG_CONTRACTS,{flag:"--declarative"}],PACKAGE_INIT_FLAG_CONTRACTS=[...EXTENSION_INIT_FLAG_CONTRACTS,{flag:"--declarative"}],EXTENSION_INSTALL_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],EXTENSION_UNINSTALL_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_EXPLORE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_DESCRIBE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--markdown"},{flag:"--output"}],EXTENSION_ADOPT_ALL_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_ACTIVATE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_DEACTIVATE_FLAG_CONTRACTS=EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_MIGRATE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--dry-run"}],EXTENSION_MANAGE_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--offline",value_type:"boolean"},{flag:"--runtime-probe"},{flag:"--fix-managed-state"}],EXTENSION_RELOAD_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--watch"}],EXTENSION_DOCTOR_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--detail"},{flag:"--trace"},{flag:"--fix-managed-state"},{flag:"--isolated"},{flag:"--ignore-global"},{flag:"--strict-exit"},{flag:"--fail-on-warn"}],EXTENSION_CATALOG_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--fields",list:!0}],EXTENSION_ADOPT_FLAG_CONTRACTS=[...EXTENSION_SCOPE_FLAG_CONTRACTS,{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],INSTALL_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--gh"},{flag:"--github"},{flag:"--ref"}],UPGRADE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--cli-only"},{flag:"--packages-only"},{flag:"--project"},{flag:"--local"},{flag:"--global"},{flag:"--repair"},{flag:"--tag"},{flag:"--package-name"}],REINDEX_FLAG_CONTRACTS=[{flag:"--mode"},{flag:"--progress"}],CLOSE_FLAG_CONTRACTS=[{flag:"--release-assignment",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--reason",value_name:"value"},{flag:"--close-reason",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--duplicate-of",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",aliases:["--expected_result","--expected"],value_name:"value"},{flag:"--actual-result",aliases:["--actual_result","--actual"],value_name:"value"},{flag:"--force",value_type:"boolean"}],CLOSE_MANY_FLAG_CONTRACTS=[{flag:"--filter-status",list:!0},{flag:"--filter-type"},{flag:"--filter-tag"},{flag:"--filter-priority"},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee"},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint"},{flag:"--filter-release"},...MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--reason"},{flag:"--completed-at"},{flag:"--resolution"},{flag:"--expected-result",aliases:["--expected_result","--expected"]},{flag:"--actual-result",aliases:["--actual_result","--actual"]},{flag:"--validate-close"},{flag:"--author"},{flag:"--message"},{flag:"--force"},{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"}],APPEND_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--body",short:"-b"},{flag:"--text"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],CLAIM_FLAG_CONTRACTS=[{flag:"--start",value_type:"boolean"},{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"},{flag:"--if-available"},{flag:"--next"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee-filter"},{flag:"--parent"},{flag:"--sprint"},{flag:"--release"},{flag:"--max-attempts"},{flag:"--include-decisions"},{flag:"--include-gates"},{flag:"--include-containers"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--explain-ranking",aliases:["--explain_ranking"]}],RESTORE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],DELETE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--dry-run"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],RELEASE_FLAG_CONTRACTS=[{flag:"--pause",value_type:"boolean"},{flag:"--handoff",value_name:"status"},{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}],START_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}],PAUSE_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--force"}],CLOSE_TASK_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--author",aliases:["--assignee"]},{flag:"--message"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--force"}],SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS=[{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--tags"},{flag:"--priority"},{flag:"--body"},{flag:"--description"},{flag:"--author"},{flag:"--message"}],MEET_FLAG_CONTRACTS=[{flag:"--start"},{flag:"--duration"},{flag:"--end"},{flag:"--location"},{flag:"--timezone"},{flag:"--all-day"},...SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS],EVENT_FLAG_CONTRACTS=MEET_FLAG_CONTRACTS,REMIND_FLAG_CONTRACTS=[{flag:"--at"},{flag:"--text"},...SCHEDULING_SHORTCUT_COMMON_FLAG_CONTRACTS],TEST_FLAG_CONTRACTS=[{flag:"--list"},{flag:"--id",value_name:"item-id"},{flag:"--add"},{flag:"--add-json"},{flag:"--remove"},{flag:"--remove-index",repeatable:!0},{flag:"--update"},{flag:"--update-index"},{flag:"--set-json"},{flag:"--run"},{flag:"--match"},{flag:"--only-index"},{flag:"--only-last"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--acknowledge-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"},{flag:"--measure",list:!0,description:"Record numeric measurement evidence; requires --run and an executed linked command."},{flag:"--metric-below"},{flag:"--metric-diff"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],TEST_ALL_FLAG_CONTRACTS=[{flag:"--status"},{flag:"--limit"},{flag:"--offset"},{flag:"--background"},{flag:"--timeout"},{flag:"--progress"},{flag:"--env-set"},{flag:"--env-clear"},{flag:"--shared-host-safe"},{flag:"--pm-context"},{flag:"--override-linked-pm-context"},{flag:"--workspace-context"},{flag:"--override-linked-workspace-context"},{flag:"--allow-untrusted-linked-tests"},{flag:"--fail-on-context-mismatch"},{flag:"--fail-on-skipped"},{flag:"--fail-on-empty-test-run"},{flag:"--require-assertions-for-pm"},{flag:"--check-context"},{flag:"--auto-pm-context"}],TELEMETRY_FLAG_CONTRACTS=[{flag:"--limit"}],TEST_RUNS_FLAG_CONTRACTS=[{flag:"--status"},{flag:"--limit"},{flag:"--stream"},{flag:"--tail"},{flag:"--force"},{flag:"--author"}],GC_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--scope"}],STATS_FLAG_CONTRACTS=[{flag:"--include-empty"},{flag:"--storage"},{flag:"--metadata-coverage"},{flag:"--field-utilization"},{flag:"--by-assignee"},{flag:"--by-tag"},{flag:"--by-priority"},{flag:"--tag-prefix"},{flag:"--analytics"}],DUPLICATES_FLAG_CONTRACTS=[{flag:"--exhaustive",value_type:"boolean"},{flag:"--status",repeatable:!0,list:!0},{flag:"--since"},{flag:"--threshold"},{flag:"--limit"}],HEALTH_FLAG_CONTRACTS=[{flag:"--strict-directories"},{flag:"--require-merge-drivers"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--check-only"},{flag:"--check-telemetry"},{flag:"--no-refresh"},{flag:"--refresh-vectors"},{flag:"--verbose-stale-items"},{flag:"--verbose-author-events"},{flag:"--brief"},{flag:"--summary"},{flag:"--skip-vectors"},{flag:"--skip-integrity"},{flag:"--skip-drift"},{flag:"--full"}],VALIDATE_FLAG_CONTRACTS=[{flag:"--check-completeness",value_type:"boolean"},{flag:"--check-metadata"},{flag:"--metadata-profile"},{flag:"--check-resolution"},{flag:"--check-lifecycle"},{flag:"--check-stale-blockers"},{flag:"--dependency-cycle-severity"},{flag:"--parent-cycle-severity"},{flag:"--check-files"},{flag:"--scan-mode"},{flag:"--include-pm-internals"},{flag:"--verbose-file-lists"},{flag:"--verbose-diagnostics"},{flag:"--all-affected-ids"},{flag:"--strict-exit"},{flag:"--fail-on-warn"},{flag:"--fix-hints"},{flag:"--auto-fix"},{flag:"--dry-run"},{flag:"--fix-scope"},{flag:"--prune-missing"},{flag:"--check-history-drift"},{flag:"--check-command-references"},{flag:"--check-storage-integrity"},{flag:"--counts"},{flag:"--full"}],ASSURANCE_FLAG_CONTRACTS=[{flag:"--definition",value_name:"json"},{flag:"--trigger",value_name:"value"},{flag:"--tree",value_name:"value"},{flag:"--gate",value_name:"id"},{flag:"--limit",value_name:"number"},{flag:"--dry-run"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--owner",value_name:"item-id"},{flag:"--apply",value_type:"boolean"},{flag:"--enforcement",value_name:"level"}],ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS=[{flag:"--assignee"},{flag:"--parent"},{flag:"--allow-missing-parent"},{flag:"--allow-unresolved-deps"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--blocked-by"},{flag:"--blocked-reason"},{flag:"--unblock-note"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--actual-result"},{flag:"--affected-version"},{flag:"--fixed-version"}],ITEM_PORTFOLIO_FLAG_CONTRACTS=[{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"}],ITEM_CONTENT_METADATA_FLAG_CONTRACTS=[{short:"-p",flag:"--priority"},{flag:"--type"},{flag:"--tags",aliases:["--tag"],list:!0},{flag:"--add-tags",aliases:["--add_tags"]},{flag:"--remove-tags",aliases:["--remove_tags"]},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--add-ac",aliases:["--add_ac"]},{flag:"--remove-ac",aliases:["--remove_ac"]}],CREATE_FLAG_CONTRACTS=[{flag:"--stdin-json"},{short:"-t",flag:"--title"},{flag:"--id"},{short:"-d",flag:"--description"},{flag:"--type"},{flag:"--template"},{flag:"--create-mode"},{flag:"--create_mode"},{flag:"--schedule-preset"},{flag:"--schedule_preset"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},{flag:"--completed_at"},{short:"-p",flag:"--priority"},{flag:"--tags",aliases:["--tag"],list:!0},{flag:"--add-tags",aliases:["--add_tags"]},{short:"-b",flag:"--body",value_name:"value"},{flag:"--body-file"},{flag:"--deadline"},{flag:"--estimate"},{flag:"--estimated-minutes"},{flag:"--estimated_minutes"},{flag:"--acceptance-criteria"},{flag:"--acceptance_criteria"},{flag:"--ac"},{flag:"--author"},{flag:"--message"},...ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS,...ITEM_PORTFOLIO_FLAG_CONTRACTS,{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--fixed_version"},{flag:"--dep"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--reminder"},{flag:"--event"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--allow-duplicate",value_type:"boolean"}],ITEM_MUTATE_FLAG_CONTRACTS=[{flag:"--transaction-id",value_name:"value"},{flag:"--stdin-json"},{flag:"--from",value_name:"path"},{flag:"--upsert-key",value_name:"field"},{flag:"--dry-run"},{flag:"--create-compensation",value_name:"mode"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--author",value_name:"value"}],ITEM_COMPLETE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--transaction-id",value_name:"value",required:!0},{flag:"--reason",value_name:"value"},{flag:"--file",value_name:"value",repeatable:!0},{flag:"--doc",value_name:"value",repeatable:!0},{flag:"--test",value_name:"value",repeatable:!0},{flag:"--comment",value_name:"value",repeatable:!0},{flag:"--note",value_name:"value",repeatable:!0},{flag:"--learning",value_name:"value",repeatable:!0},{flag:"--resolution",value_name:"value"},{flag:"--expected-result",value_name:"value"},{flag:"--actual-result",value_name:"value"},{flag:"--completed-at",value_name:"value"},{flag:"--validate-close",value_name:"off|warn|strict"},{flag:"--lock-ttl-seconds",value_name:"n"},{flag:"--lock-wait-ms",value_name:"n"},{flag:"--dry-run"},{flag:"--force"},{flag:"--author",value_name:"value"}],ITEM_REOPEN_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--status",value_name:"open|in_progress"},{flag:"--expected-result",value_name:"value",aliases:["--expected"]},{flag:"--message",value_name:"value"},{flag:"--force"},{flag:"--author",value_name:"value"}],COPY_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--title",value_name:"value"},{flag:"--author",value_name:"value"},{flag:"--message",value_name:"value"},{flag:"--allow-duplicate",value_type:"boolean"}],FOCUS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--clear"}],UPDATE_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--stdin-json"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},{flag:"--body-file"},{short:"-s",flag:"--status"},{flag:"--close-reason"},{flag:"--close_reason"},{flag:"--completed-at"},...ITEM_CONTENT_METADATA_FLAG_CONTRACTS,...ITEM_OWNERSHIP_AND_ISSUE_FLAG_CONTRACTS,{flag:"--fixed_version"},...ITEM_PORTFOLIO_FLAG_CONTRACTS,{flag:"--author"},{flag:"--message"},{flag:"--blocked_by"},{flag:"--blocked_reason"},{flag:"--unblock_note"},{flag:"--repro_steps"},{flag:"--expected_result"},{flag:"--actual_result"},{flag:"--expected"},{flag:"--actual"},{flag:"--affected_version"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file",aliases:["--linked-file"]},{flag:"--test",aliases:["--linked-test"]},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--field"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--force"}],UPDATE_MANY_FLAG_CONTRACTS=[{flag:"--status",short:"-s"},{flag:"--assignee"},{flag:"--parent"},{flag:"--blocked-by",aliases:["--blocked_by"]},{flag:"--blocked-reason",aliases:["--blocked_reason"]},{flag:"--unblock-note",aliases:["--unblock_note"]},{flag:"--filter-status",list:!0},{flag:"--filter-type",list:!0},{flag:"--filter-tag",list:!0},{flag:"--filter-priority",list:!0},{flag:"--filter-deadline-before"},{flag:"--filter-deadline-after"},{flag:"--filter-updated-after"},{flag:"--filter-updated-before"},{flag:"--filter-created-after"},{flag:"--filter-created-before"},{flag:"--filter-assignee",list:!0},{flag:"--filter-assignee-filter"},{flag:"--filter-assignee_filter"},{flag:"--filter-parent"},{flag:"--filter-sprint",list:!0},{flag:"--filter-release",list:!0},{flag:"--filter-ac-missing"},{flag:"--filter-estimates-missing",aliases:["--filter-estimate-missing"]},{flag:"--filter-resolution-missing"},{flag:"--filter-metadata-missing"},...MANY_GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS,{flag:"--dry-run"},{flag:"--rollback"},{flag:"--no-checkpoint"},{short:"-t",flag:"--title"},{short:"-d",flag:"--description"},{short:"-b",flag:"--body"},...ITEM_CONTENT_METADATA_FLAG_CONTRACTS,{flag:"--definition-of-ready"},{flag:"--definition_of_ready"},{flag:"--order"},{flag:"--rank"},{flag:"--goal"},{flag:"--objective"},{flag:"--value"},{flag:"--impact"},{flag:"--outcome"},{flag:"--why-now"},{flag:"--why_now"},{flag:"--reviewer"},{flag:"--risk"},{flag:"--confidence"},{flag:"--sprint"},{flag:"--release"},{flag:"--reporter"},{flag:"--severity"},{flag:"--environment"},{flag:"--repro-steps"},{flag:"--repro_steps"},{flag:"--resolution"},{flag:"--expected-result"},{flag:"--expected_result"},{flag:"--expected"},{flag:"--actual-result"},{flag:"--actual_result"},{flag:"--actual"},{flag:"--affected-version"},{flag:"--affected_version"},{flag:"--fixed-version"},{flag:"--fixed_version"},{flag:"--component"},{flag:"--regression"},{flag:"--customer-impact"},{flag:"--customer_impact"},{flag:"--allow-unresolved-deps"},{flag:"--dep"},{flag:"--dep-remove"},{flag:"--dep_remove"},{flag:"--replace-deps"},{flag:"--replace-tests"},{flag:"--replace-files"},{flag:"--replace-docs"},{flag:"--comment"},{flag:"--note"},{flag:"--learning"},{flag:"--file"},{flag:"--test"},{flag:"--doc"},{flag:"--reminder"},{flag:"--event"},{flag:"--type-option"},{flag:"--type_option"},{flag:"--unset"},{flag:"--clear-deps"},{flag:"--clear-comments"},{flag:"--clear-notes"},{flag:"--clear-learnings"},{flag:"--clear-files"},{flag:"--clear-tests"},{flag:"--clear-docs"},{flag:"--clear-reminders"},{flag:"--clear-events"},{flag:"--clear-type-options"},{flag:"--author"},{flag:"--message"},{flag:"--force"}],CALENDAR_FLAG_CONTRACTS=[{flag:"--view"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--full-period"},{flag:"--full_period"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--status"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--include"},{flag:"--recurrence-lookahead-days"},{flag:"--recurrence-lookback-days"},{flag:"--occurrence-limit"},{flag:"--limit"},{flag:"--format"}],ACTIVITY_FLAG_CONTRACTS=[{flag:"--id"},{flag:"--op"},{flag:"--author"},{flag:"--from"},{flag:"--to"},{flag:"--limit"},{flag:"--unbounded"},{flag:"--compact"},{flag:"--raw"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:!0},{flag:"--agent-instance",repeatable:!0},{flag:"--provenance-filter",repeatable:!0},{flag:"--stream"}],EVENTS_FLAG_CONTRACTS=[{flag:"--since"},{flag:"--type",repeatable:!0},{flag:"--author",repeatable:!0},{flag:"--item",repeatable:!0},{flag:"--limit",value_type:"number"},{flag:"--cursor-mode",value_name:"batch|row"},{flag:"--full"},{flag:"--provenance"},{flag:"--provenance-summary"},{flag:"--harness",repeatable:!0},{flag:"--agent-instance",repeatable:!0},{flag:"--provenance-filter",repeatable:!0},{flag:"--follow"},{flag:"--interval-ms",value_type:"number"}],CONTEXT_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--date"},{flag:"--from"},{flag:"--to"},{flag:"--past"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit",aliases:["--max-items"]},{flag:"--after"},{flag:"--format"},{flag:"--depth"},{flag:"--fields",list:!0},{flag:"--section"},{flag:"--activity-limit"},{flag:"--stale-threshold"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--no-extension-health"},{flag:"--no-tags"}],new Set(["--limit","--after","--format","--fields","--section","--activity-limit","--stale-threshold","--explain-ranking","--explain_ranking","--no-extension-health","--no-tags"])),GET_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--depth"},{flag:"--full",value_type:"boolean"},{flag:"--fields",list:!0},{flag:"--at"},{flag:"--tree"},{flag:"--tree-depth"},{flag:"--tree_depth"},{flag:"--format"}],GUIDE_FLAG_CONTRACTS=[{flag:"--list"},{flag:"--format"},{flag:"--depth"}],DEPS_FLAG_CONTRACTS=[{flag:"--id",value_name:"item-id"},{flag:"--format"},{flag:"--max-depth"},{flag:"--collapse"},{flag:"--summary"},{flag:"--full"},{flag:"--node-limit"},{flag:"--edge-limit"},{flag:"--token-budget"},{flag:"--cursor"},{flag:"--direction"},{flag:"--kind",list:!0}],GRAPH_FLAG_CONTRACTS=[{flag:"--kind",list:!0},{flag:"--max-depth",description:`Maximum traversal depth; paths default to ${GRAPH_QUERY_DEFAULTS.path_depth}.`},{flag:"--limit",description:`Maximum rows per collection; default ${GRAPH_QUERY_DEFAULTS.rows}. Use --full to remove the row cap.`},{flag:"--after"},{flag:"--direction"},{flag:"--max-paths",description:`Maximum enumerated paths; default ${GRAPH_QUERY_DEFAULTS.paths}.`},{flag:"--sample",description:`Maximum evidence examples per audit finding; default ${GRAPH_QUERY_DEFAULTS.samples}.`},{flag:"--exempt-isolate",list:!0},{flag:"--exempt-isolate-type",list:!0},{flag:"--save-baseline"},{flag:"--rebuild"},{flag:"--clear"},{flag:"--summary"},{flag:"--full"}],EVAL_FLAG_CONTRACTS=[{flag:"--mode"},{flag:"--k"},{flag:"--fail-under"},{flag:"--queries"},{flag:"--format"}],WORKSPACE_FLAG_CONTRACTS=[{flag:"--dry-run"},{flag:"--force"},{flag:"--author"},{flag:"--message"}],WORKSPACE_POSITION_FLAG_CONTRACTS=[],NEXT_FLAG_CONTRACTS=[{flag:"--include-decisions"},{flag:"--include-gates"},{flag:"--include-containers"},{flag:"--for",value_name:"intent"},{flag:"--type"},{flag:"--tag"},{flag:"--priority"},{flag:"--assignee"},{flag:"--assignee-filter"},{flag:"--assignee_filter"},{flag:"--sprint"},{flag:"--release"},{flag:"--parent"},{flag:"--limit"},{flag:"--blocked-limit"},{flag:"--blocked_limit"},{flag:"--ready-only"},{flag:"--ready_only"},{flag:"--format"},{flag:"--explain-ranking"},{flag:"--explain_ranking"},{flag:"--token-budget",aliases:["--token_budget"]}],SEARCH_FLAG_CONTRACTS=withCursorSemantics([{flag:"--for",value_name:"intent"},{flag:"--token-budget",aliases:["--token_budget"]},{flag:"--mode"},{flag:"--semantic"},{flag:"--hybrid"},{flag:"--match-mode"},{flag:"--min-score"},{flag:"--count"},{flag:"--semantic-weight"},{flag:"--include-linked"},{flag:"--title-exact"},{flag:"--phrase-exact"},{flag:"--highlight"},{flag:"--compact"},{flag:"--full"},{flag:"--fields",list:!0},{flag:"--format"},{flag:"--limit"},{flag:"--after"},{flag:"--status",list:!0},{flag:"--type",list:!0},{flag:"--tag",aliases:["--tags"],list:!0},{flag:"--priority",list:!0},{flag:"--deadline-before"},{flag:"--deadline-after"},{flag:"--updated-after"},{flag:"--updated-before"},{flag:"--created-after"},{flag:"--created-before"},{flag:"--assignee",list:!0},{flag:"--sprint",list:!0},{flag:"--release",list:!0},{flag:"--parent"},...GOVERNANCE_AND_CONTENT_FILTER_FLAG_CONTRACTS],new Set(["--highlight","--compact","--full","--fields","--format","--limit","--token-budget","--after"])),CONTRACTS_FLAG_CONTRACTS=[{flag:"--action"},{flag:"--command"},{flag:"--summary"},{flag:"--schema-only"},{flag:"--flags-only"},{flag:"--availability-only"},{flag:"--runtime-only"},{flag:"--active-only"},{flag:"--full"}],COMPLETION_FLAG_CONTRACTS=[{flag:"--eager-tags"}];function toUniqueFlagContracts(contracts){const seen=new Set,unique=[];for(const contract of contracts){const aliasKey=(contract.aliases??[]).join(","),key=`${contract.flag}|${contract.short??""}|${aliasKey}`;seen.has(key)||(seen.add(key),unique.push(contract))}return unique}function withSubcommandGlobalFlags(contracts,allowOutputFormatAlias=!1){const byCanonicalFlag=new Map;for(const contract of[...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,...contracts]){const canonicalFlag=normalizeFlagAliasKey(contract.flag),prior=byCanonicalFlag.get(canonicalFlag),{aliases:declaredAliases,...contractWithoutAliases}=contract,aliases=normalizeUniqueStringList([...declaredAliases??[],...contract.flag===canonicalFlag?[]:[contract.flag]]).filter(alias=>alias!==canonicalFlag),normalizedContract={...contractWithoutAliases,flag:canonicalFlag,...aliases.length>0?{aliases}:{}},mergedAliases=normalizeUniqueStringList([...prior?.aliases??[],...normalizedContract.aliases??[]]);byCanonicalFlag.set(canonicalFlag,prior===void 0?normalizedContract:{...prior,...normalizedContract,...mergedAliases.length>0?{aliases:mergedAliases}:{}})}if(allowOutputFormatAlias&&contracts.length>0&&!byCanonicalFlag.has("--format")){const encoding=byCanonicalFlag.get("--output-format");byCanonicalFlag.set("--output-format",{...encoding,aliases:[...encoding.aliases??[],"--format"]})}return withFlagAliasMetadata([...byCanonicalFlag.values()])}const FIXED_STATUS_LIST_COMMAND_ALIASES=["list-draft","list-open","list-in-progress","list-blocked","list-closed","list-canceled"],FIXED_STATUS_LIST_FLAG_CONTRACTS=LIST_FILTER_FLAG_CONTRACTS.filter(contract=>contract.flag!=="--status"&&contract.flag!=="--all");function indexCliFlagContracts(contracts){const index=new Map;for(const contract of contracts)for(const spelling of[contract.flag,...contract.aliases??[]]){const matches=index.get(spelling)??[];matches.push(contract),index.set(spelling,matches)}return index}const PLAN_FLAG_CONTRACT_INDEX=indexCliFlagContracts(PLAN_FLAG_CONTRACTS),ASSURANCE_FLAG_CONTRACT_INDEX=indexCliFlagContracts(ASSURANCE_FLAG_CONTRACTS),POSITIONAL_ACTION_FLAG_INDEX_BY_PARENT=new Map([["assurance",ASSURANCE_FLAG_CONTRACT_INDEX],["plan",PLAN_FLAG_CONTRACT_INDEX],["workspace",indexCliFlagContracts(WORKSPACE_POSITION_FLAG_CONTRACTS)],["workspace snapshot",indexCliFlagContracts(WORKSPACE_FLAG_CONTRACTS)]]);function resolvePmPositionalActionFlagContracts(actions=PM_POSITIONAL_ACTION_CONTRACTS){return actions.map(({command,parent,accepted_flags:acceptedFlags})=>{const parentFlagIndex=POSITIONAL_ACTION_FLAG_INDEX_BY_PARENT.get(parent);if(!parentFlagIndex)throw new Error(`Positional action ${command} has no flag-contract index for ${parent}.`);const selected=acceptedFlags.map(acceptedFlag=>{const matches=parentFlagIndex.get(acceptedFlag)??[];if(matches.length!==1)throw new Error(`Positional action ${command} accepted flag ${acceptedFlag} does not resolve to exactly one ${parent} flag contract.`);return matches[0]});return[command,selected]})}const PM_POSITIONAL_ACTION_FLAG_CONTRACTS=resolvePmPositionalActionFlagContracts(),SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND=new Map([["list",LIST_FILTER_FLAG_CONTRACTS],["list-all",LIST_FILTER_FLAG_CONTRACTS],...FIXED_STATUS_LIST_COMMAND_ALIASES.map(command=>[command,FIXED_STATUS_LIST_FLAG_CONTRACTS]),["templates",CREATE_FLAG_CONTRACTS],["cal",CALENDAR_FLAG_CONTRACTS],["ctx",CONTEXT_FLAG_CONTRACTS],["test-runs-worker",[]],["init",INIT_FLAG_CONTRACTS],["config",CONFIG_FLAG_CONTRACTS],["extension",EXTENSION_FLAG_CONTRACTS],["package",PACKAGE_FLAG_CONTRACTS],["packages",PACKAGE_FLAG_CONTRACTS],["install",INSTALL_FLAG_CONTRACTS],["upgrade",UPGRADE_FLAG_CONTRACTS],["create",CREATE_FLAG_CONTRACTS],["item",[]],["item mutate",ITEM_MUTATE_FLAG_CONTRACTS],["item complete",ITEM_COMPLETE_FLAG_CONTRACTS],["item reopen",ITEM_REOPEN_FLAG_CONTRACTS],["copy",COPY_FLAG_CONTRACTS],["focus",FOCUS_FLAG_CONTRACTS],["aggregate",AGGREGATE_FLAG_CONTRACTS],["calendar",CALENDAR_FLAG_CONTRACTS],["context",CONTEXT_FLAG_CONTRACTS],["get",GET_FLAG_CONTRACTS],["guide",GUIDE_FLAG_CONTRACTS],["search",SEARCH_FLAG_CONTRACTS],["next",NEXT_FLAG_CONTRACTS],["eval",EVAL_FLAG_CONTRACTS],["workspace",WORKSPACE_FLAG_CONTRACTS],["workspace position",WORKSPACE_POSITION_FLAG_CONTRACTS],["workspace snapshot",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot create",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot list",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot inspect",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot restore",WORKSPACE_FLAG_CONTRACTS],["workspace snapshot delete",WORKSPACE_FLAG_CONTRACTS],["history",HISTORY_FLAG_CONTRACTS],["history-redact",HISTORY_REDACT_FLAG_CONTRACTS],["history-repair",HISTORY_REPAIR_FLAG_CONTRACTS],["history-author-acknowledge",HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS],["history-compact",HISTORY_COMPACT_FLAG_CONTRACTS],["history-attest",HISTORY_ATTEST_FLAG_CONTRACTS],["merge",MERGE_FLAG_CONTRACTS],["schema",SCHEMA_FLAG_CONTRACTS],["profile",PROFILE_FLAG_CONTRACTS],["plan",PLAN_FLAG_CONTRACTS],["activity",ACTIVITY_FLAG_CONTRACTS],["events",EVENTS_FLAG_CONTRACTS],["restore",RESTORE_FLAG_CONTRACTS],["update",UPDATE_FLAG_CONTRACTS],["update-many",UPDATE_MANY_FLAG_CONTRACTS],["close",CLOSE_FLAG_CONTRACTS],["close-many",CLOSE_MANY_FLAG_CONTRACTS],["delete",DELETE_FLAG_CONTRACTS],["append",APPEND_FLAG_CONTRACTS],["comments",COMMENTS_FLAG_CONTRACTS],["notes",NOTES_FLAG_CONTRACTS],["learnings",LEARNINGS_FLAG_CONTRACTS],["files",FILES_FLAG_CONTRACTS],["docs",DOCS_FLAG_CONTRACTS],["deps",DEPS_FLAG_CONTRACTS],["graph",GRAPH_FLAG_CONTRACTS],["test",TEST_FLAG_CONTRACTS],["test-all",TEST_ALL_FLAG_CONTRACTS],["telemetry",TELEMETRY_FLAG_CONTRACTS],["health",HEALTH_FLAG_CONTRACTS],["assurance",ASSURANCE_FLAG_CONTRACTS],...PM_POSITIONAL_ACTION_FLAG_CONTRACTS,["validate",VALIDATE_FLAG_CONTRACTS],["gc",GC_FLAG_CONTRACTS],["stats",STATS_FLAG_CONTRACTS],["duplicates",DUPLICATES_FLAG_CONTRACTS],["contracts",CONTRACTS_FLAG_CONTRACTS],["completion",COMPLETION_FLAG_CONTRACTS],["claim",CLAIM_FLAG_CONTRACTS],["release",RELEASE_FLAG_CONTRACTS],["start-task",START_TASK_FLAG_CONTRACTS],["pause-task",PAUSE_TASK_FLAG_CONTRACTS],["close-task",CLOSE_TASK_FLAG_CONTRACTS],["meet",MEET_FLAG_CONTRACTS],["event",EVENT_FLAG_CONTRACTS],["remind",REMIND_FLAG_CONTRACTS]]),EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND=new Map([["install",EXTENSION_INSTALL_FLAG_CONTRACTS],["uninstall",EXTENSION_UNINSTALL_FLAG_CONTRACTS],["explore",EXTENSION_EXPLORE_FLAG_CONTRACTS],["manage",EXTENSION_MANAGE_FLAG_CONTRACTS],["describe",EXTENSION_DESCRIBE_FLAG_CONTRACTS],["reload",EXTENSION_RELOAD_FLAG_CONTRACTS],["doctor",EXTENSION_DOCTOR_FLAG_CONTRACTS],["catalog",EXTENSION_CATALOG_FLAG_CONTRACTS],["list",EXTENSION_CATALOG_FLAG_CONTRACTS],["adopt",EXTENSION_ADOPT_FLAG_CONTRACTS],["adopt-all",EXTENSION_ADOPT_ALL_FLAG_CONTRACTS],["activate",EXTENSION_ACTIVATE_FLAG_CONTRACTS],["deactivate",EXTENSION_DEACTIVATE_FLAG_CONTRACTS],["migrate",EXTENSION_MIGRATE_FLAG_CONTRACTS]]);function normalizeCommandNameForContracts(commandName){return typeof commandName!="string"?"":resolvePmHistoryOperation(commandName.trim().toLowerCase())}function hasSubcommandFlagContractsForCommand(commandName){const normalized=normalizeCommandNameForContracts(commandName);if(SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND.has(normalized))return!0;const[rootCommand,lifecycleSubcommand,...extraParts]=normalized.split(/\s+/);return(rootCommand==="extension"||rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand!==void 0&&extraParts.length===0&&(lifecycleSubcommand==="init"||lifecycleSubcommand==="scaffold"||EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND.has(lifecycleSubcommand))}function resolveExtensionLifecycleFlagContracts(rootCommand,lifecycleSubcommand){return lifecycleSubcommand==="init"||lifecycleSubcommand==="scaffold"?rootCommand==="extension"?EXTENSION_INIT_FLAG_CONTRACTS:PACKAGE_INIT_FLAG_CONTRACTS:EXTENSION_LIFECYCLE_FLAG_CONTRACTS_BY_SUBCOMMAND.get(lifecycleSubcommand)??[]}function resolveSubcommandFlagContractsForCommand(commandName){const normalized=normalizeCommandNameForContracts(commandName);if(normalized.length===0)return withSubcommandGlobalFlags([]);const[rootCommand,lifecycleSubcommand,...extraParts]=normalized.split(/\s+/);if((rootCommand==="extension"||rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand!==void 0&&extraParts.length===0)return(rootCommand==="package"||rootCommand==="packages")&&lifecycleSubcommand==="upgrade"?withSubcommandGlobalFlags(UPGRADE_FLAG_CONTRACTS,!0):withSubcommandGlobalFlags(resolveExtensionLifecycleFlagContracts(rootCommand,lifecycleSubcommand),hasSubcommandFlagContractsForCommand(normalized));const contracts=SUBCOMMAND_FLAG_CONTRACTS_BY_COMMAND.get(normalized)??[];return withSubcommandGlobalFlags(contracts,hasSubcommandFlagContractsForCommand(normalized))}function toCompletionFlagString(flagContracts,includeGlobal=!0){const scoped=withFlagAliasMetadata(flagContracts).flatMap(entry=>[entry.short,entry.flag,...entry.aliases??[]]).filter(value=>!!value),all=includeGlobal?[...scoped,...SUBCOMMAND_GLOBAL_FLAG_CONTRACTS.flatMap(entry=>[entry.short,entry.flag,...entry.aliases??[]]).filter(value=>!!value)]:scoped;return normalizeUniqueStringList(all).join(" ")}export{ACTIVITY_FLAG_CONTRACTS,AGGREGATE_FLAG_CONTRACTS,APPEND_FLAG_CONTRACTS,ASSURANCE_FLAG_CONTRACTS,CALENDAR_FLAG_CONTRACTS,CLAIM_FLAG_CONTRACTS,CLOSE_FLAG_CONTRACTS,CLOSE_MANY_FLAG_CONTRACTS,CLOSE_TASK_FLAG_CONTRACTS,COMMENTS_FLAG_CONTRACTS,COMPLETION_FLAG_CONTRACTS,CONFIG_FLAG_CONTRACTS,CONTEXT_FLAG_CONTRACTS,CONTRACTS_FLAG_CONTRACTS,COPY_FLAG_CONTRACTS,CREATE_FLAG_CONTRACTS,DELETE_FLAG_CONTRACTS,DEPS_FLAG_CONTRACTS,DOCS_FLAG_CONTRACTS,DUPLICATES_FLAG_CONTRACTS,EVAL_FLAG_CONTRACTS,EVENTS_FLAG_CONTRACTS,EVENT_FLAG_CONTRACTS,EXTENSION_ACTIVATE_FLAG_CONTRACTS,EXTENSION_ADOPT_ALL_FLAG_CONTRACTS,EXTENSION_ADOPT_FLAG_CONTRACTS,EXTENSION_CATALOG_FLAG_CONTRACTS,EXTENSION_DEACTIVATE_FLAG_CONTRACTS,EXTENSION_DESCRIBE_FLAG_CONTRACTS,EXTENSION_DOCTOR_FLAG_CONTRACTS,EXTENSION_EXPLORE_FLAG_CONTRACTS,EXTENSION_FLAG_CONTRACTS,EXTENSION_INIT_FLAG_CONTRACTS,EXTENSION_INSTALL_FLAG_CONTRACTS,EXTENSION_MANAGE_FLAG_CONTRACTS,EXTENSION_MIGRATE_FLAG_CONTRACTS,EXTENSION_RELOAD_FLAG_CONTRACTS,EXTENSION_SCOPE_FLAG_CONTRACTS,EXTENSION_UNINSTALL_FLAG_CONTRACTS,FILES_FLAG_CONTRACTS,FOCUS_FLAG_CONTRACTS,GC_FLAG_CONTRACTS,GET_FLAG_CONTRACTS,GLOBAL_FLAG_CONTRACTS,GRAPH_FLAG_CONTRACTS,GUIDE_FLAG_CONTRACTS,HEALTH_FLAG_CONTRACTS,HISTORY_ATTEST_FLAG_CONTRACTS,HISTORY_AUTHOR_ACKNOWLEDGE_FLAG_CONTRACTS,HISTORY_COMPACT_FLAG_CONTRACTS,HISTORY_FLAG_CONTRACTS,HISTORY_REDACT_FLAG_CONTRACTS,HISTORY_REPAIR_FLAG_CONTRACTS,INIT_FLAG_CONTRACTS,INSTALL_FLAG_CONTRACTS,ITEM_COMPLETE_FLAG_CONTRACTS,ITEM_MUTATE_FLAG_CONTRACTS,ITEM_REOPEN_FLAG_CONTRACTS,LEARNINGS_FLAG_CONTRACTS,LIST_FILTER_FLAG_CONTRACTS,MEET_FLAG_CONTRACTS,MERGE_FLAG_CONTRACTS,NEXT_FLAG_CONTRACTS,NOTES_FLAG_CONTRACTS,PACKAGE_FLAG_CONTRACTS,PACKAGE_INIT_FLAG_CONTRACTS,PAUSE_TASK_FLAG_CONTRACTS,PLAN_FLAG_CONTRACTS,PM_POSITIONAL_ACTION_FLAG_CONTRACTS,PROFILE_FLAG_CONTRACTS,REINDEX_FLAG_CONTRACTS,RELEASE_FLAG_CONTRACTS,REMIND_FLAG_CONTRACTS,RESTORE_FLAG_CONTRACTS,SCHEMA_FLAG_CONTRACTS,SEARCH_FLAG_CONTRACTS,START_TASK_FLAG_CONTRACTS,STATS_FLAG_CONTRACTS,SUBCOMMAND_GLOBAL_FLAG_CONTRACTS,TELEMETRY_FLAG_CONTRACTS,TEST_ALL_FLAG_CONTRACTS,TEST_FLAG_CONTRACTS,TEST_RUNS_FLAG_CONTRACTS,UPDATE_FLAG_CONTRACTS,UPDATE_MANY_FLAG_CONTRACTS,UPGRADE_FLAG_CONTRACTS,VALIDATE_FLAG_CONTRACTS,WORKSPACE_FLAG_CONTRACTS,WORKSPACE_POSITION_FLAG_CONTRACTS,compactFlagAliasContracts,hasSubcommandFlagContractsForCommand,resolvePmPositionalActionFlagContracts,resolveSubcommandFlagContractsForCommand,toCompletionFlagString,toUniqueFlagContracts,withFlagAliasMetadata};
2
2
  //# sourceMappingURL=flag-contracts.js.map
@@ -1,3 +1,3 @@
1
- (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="05a34b9f-c097-5286-8bf3-490a9a7247dd")}catch{}})();import{hasSubcommandFlagContractsForCommand,resolveSubcommandFlagContractsForCommand}from"./flag-contracts.js";import{PM_COMMAND_CAPABILITY_CONTRACTS}from"../agent-capability-contracts.js";import{PM_NAMESPACED_COMMAND_ALIASES,resolvePmCommandOperation}from"./command-aliases.js";import{enrichCliFlagInvocationContracts}from"../flag-invocation-contracts.js";let cachedPmFlagLexicon;const FULL_PROJECTION_CONCEPT_BY_COMMAND=Object.freeze({list:"list-item-projection","list-all":"list-item-projection","list-draft":"list-item-projection","list-open":"list-item-projection","list-in-progress":"list-item-projection","list-blocked":"list-item-projection","list-closed":"list-item-projection","list-canceled":"list-item-projection",get:"get-item-projection",graph:"graph-detail-projection",search:"search-result-projection",history:"history-entry-projection",events:"mutation-event-projection",activity:"activity-entry-projection",deps:"dependency-graph-projection",health:"health-diagnostic-projection",validate:"validation-diagnostic-projection",contracts:"contract-catalog-projection"});function resolvePmFlagSemanticConcept(command,flag){if(flag==="--limit")return"result-row-limit";if(flag==="--node-limit")return"graph-node-limit";if(flag==="--edge-limit")return"graph-edge-limit";if(flag==="--output-limit")return"rendered-output-row-limit";if(flag==="--output-budget")return"rendered-output-byte-budget";if(flag==="--token-budget")return"context-intent-token-budget";if(flag==="--full"){const concept=FULL_PROJECTION_CONCEPT_BY_COMMAND[resolvePmCommandOperation(command)];if(concept===void 0)throw new Error(`Command ${command} exposes --full without a registered projection concept.`);return concept}return flag!=="--file"?flag.slice(2):["create","update","update-many"].includes(resolvePmCommandOperation(command))?"linked-file-path":["comments","notes","learnings"].includes(resolvePmCommandOperation(command))?"entry-file-input":"plan-definition-file"}function listPmFlagLexicon(){if(cachedPmFlagLexicon!==void 0)return cachedPmFlagLexicon;const provisionalEntries=PM_COMMAND_CAPABILITY_CONTRACTS.filter(({command})=>hasSubcommandFlagContractsForCommand(command)).flatMap(({command,family})=>enrichCliFlagInvocationContracts(command,resolveSubcommandFlagContractsForCommand(command)).map(contract=>({command,family,concept:resolvePmFlagSemanticConcept(command,contract.flag),flag:contract.flag,aliases:Object.freeze([...contract.aliases??[]]),value_kind:contract.repeatable?"list":contract.flag==="--limit"?"number":contract.value_type}))),compatibilityAliasFlags=new Set(provisionalEntries.flatMap(entry=>entry.aliases.map(alias=>`${entry.command}:${alias}`))),canonicalEntries=provisionalEntries.filter(entry=>!compatibilityAliasFlags.has(`${entry.command}:${entry.flag}`)),kindsByConcept=new Map;for(const entry of canonicalEntries){const kinds=kindsByConcept.get(entry.concept)??new Set;kinds.add(entry.value_kind),kindsByConcept.set(entry.concept,kinds)}return cachedPmFlagLexicon=Object.freeze(canonicalEntries.map(entry=>Object.freeze({...entry,concept:kindsByConcept.get(entry.concept)?.size===1?entry.concept:`${entry.concept}@${entry.command}`}))),cachedPmFlagLexicon}function listPmFlagSpellingInventory(){return Object.freeze(listPmFlagLexicon().map(entry=>Object.freeze({command:entry.command,canonical_flag:entry.flag,accepted_spellings:Object.freeze([...new Set([entry.flag,...entry.aliases])].sort())})))}const LEGACY_COMMAND_FLAG_BUDGET_MAXIMUMS=Object.freeze({init:30,item:20,config:36,extension:55,package:56,packages:56,install:27,upgrade:29,create:100,copy:24,focus:22,list:86,"list-all":86,"list-draft":84,"list-open":84,"list-in-progress":84,"list-blocked":84,"list-closed":84,"list-canceled":84,aggregate:40,context:45,ctx:45,get:30,graph:34,search:78,duplicates:25,eval:25,next:38,history:35,events:33,"history-attest":23,"history-redact":27,"history-repair":27,"history-compact":30,"history-author-acknowledge":28,merge:27,schema:43,profile:22,activity:35,restore:23,update:105,"update-many":146,close:32,"close-many":72,delete:24,append:25,comments:31,notes:35,learnings:31,files:39,docs:30,deps:32,plan:109,test:56,"test-all":40,telemetry:21,stats:29,health:36,validate:46,assurance:30,gc:22,workspace:23,contracts:29,claim:39,release:25,"start-task":23,"pause-task":23,"close-task":24,meet:33,event:33,remind:29,"test-runs-worker":20}),PM_COMMAND_FLAG_BUDGET_MAXIMUMS=Object.freeze({...LEGACY_COMMAND_FLAG_BUDGET_MAXIMUMS,...Object.fromEntries(PM_NAMESPACED_COMMAND_ALIASES.flatMap(({alias,canonical})=>{const maximum=LEGACY_COMMAND_FLAG_BUDGET_MAXIMUMS[alias];return maximum===void 0?[]:[[canonical,maximum]]}))});function listPmCommandFlagBudgets(){const currentByCommand=new Map(Object.keys(PM_COMMAND_FLAG_BUDGET_MAXIMUMS).map(command=>[command,0]));for(const{command}of listPmFlagLexicon())currentByCommand.set(command,Number(currentByCommand.get(command))+1);return Object.freeze(Object.entries(PM_COMMAND_FLAG_BUDGET_MAXIMUMS).map(([command,maximum])=>Object.freeze({command,current:Number(currentByCommand.get(command)),maximum})))}function appendAliasCollisionFindings(entries,canonicalOwners,findings){for(const entry of entries)for(const alias of entry.aliases){const owner=canonicalOwners.get(`${entry.command}:${alias}`);owner===void 0||owner.flag===entry.flag||findings.push({code:"alias_collision",command:entry.command,detail:`${alias} aliases ${entry.flag} but is canonical for ${owner.flag}.`})}}function appendBudgetFindings(counts,budgets,findings){const budgetedCommands=new Set(budgets.map(({command})=>command));for(const command of counts.keys())budgetedCommands.has(command)||findings.push({code:"missing_budget",command,detail:`${command} has canonical flags but no persisted budget.`});for(const budget of budgets){const actual=counts.get(budget.command)??0;actual===0&&findings.push({code:"stale_budget",command:budget.command,detail:`${budget.command} has a persisted budget but no canonical flags.`}),!(actual<=budget.maximum)&&findings.push({code:"budget_exceeded",command:budget.command,detail:`${actual} canonical flags exceed the ratcheted maximum ${budget.maximum}.`})}}function appendSpellingCompatibilityFindings(entries,baseline,findings){const current=new Map(entries.map(entry=>[`${entry.command}:${entry.flag}`,entry]));for(const historical of baseline){const key=`${historical.command}:${historical.canonical_flag}`,entry=current.get(key);if(!entry){findings.push({code:"removed_canonical_spelling",command:historical.command,detail:`${historical.canonical_flag} disappeared from the executable spelling inventory.`});continue}const accepted=new Set([entry.flag,...entry.aliases]);for(const spelling of historical.accepted_spellings)accepted.has(spelling)||findings.push({code:"removed_compatibility_spelling",command:historical.command,detail:`${spelling} no longer resolves to ${historical.canonical_flag}.`})}}function verifyPmFlagLexicon(entries=listPmFlagLexicon(),budgets=listPmCommandFlagBudgets(),baseline=[]){const findings=[],canonicalOwners=new Map,conceptKinds=new Map,conceptSpellings=new Map,counts=new Map;for(const entry of entries){const commandFlag=`${entry.command}:${entry.flag}`;canonicalOwners.has(commandFlag)?findings.push({code:"duplicate_canonical_flag",command:entry.command,detail:`${entry.flag} has more than one canonical row.`}):canonicalOwners.set(commandFlag,entry),counts.set(entry.command,(counts.get(entry.command)??0)+1);const priorKind=conceptKinds.get(entry.concept);priorKind!==void 0&&priorKind!==entry.value_kind?findings.push({code:"inconsistent_concept_kind",command:entry.command,detail:`${entry.concept} uses both ${priorKind} and ${entry.value_kind}.`}):conceptKinds.set(entry.concept,entry.value_kind);const priorSpelling=conceptSpellings.get(entry.concept);priorSpelling!==void 0&&priorSpelling!==entry.flag?findings.push({code:"semantic_spelling_collision",command:entry.command,detail:`${entry.concept} is canonicalized by both ${priorSpelling} and ${entry.flag}.`}):conceptSpellings.set(entry.concept,entry.flag)}return appendAliasCollisionFindings(entries,canonicalOwners,findings),appendBudgetFindings(counts,budgets,findings),appendSpellingCompatibilityFindings(entries,baseline,findings),findings.sort((left,right)=>left.command.localeCompare(right.command)||left.code.localeCompare(right.code)||left.detail.localeCompare(right.detail)),{ok:findings.length===0,entry_count:entries.length,budget_count:budgets.length,concept_count:new Set(entries.map(({concept})=>concept)).size,baseline_entry_count:baseline.length,findings}}function renderPmFlagLexiconMarkdown(){const lexicon=listPmFlagLexicon(),budgets=listPmCommandFlagBudgets(),familyByCommand=new Map(budgets.map(({command})=>[command,"unknown"]));for(const{command,family}of lexicon)familyByCommand.set(command,family);return["# Generated flag lexicon budgets","","This file is generated by `listPmFlagLexicon()`. Compatibility aliases do not consume canonical budget.","","| Command | Capability family | Canonical flags | Maximum |","| --- | --- | ---: | ---: |",...budgets.map(({command,current,maximum})=>{const family=familyByCommand.get(command);return`| \`${command}\` | ${family} | ${current} | ${maximum} |`}),""].join(`
1
+ (function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1335ff24-7fec-5bc4-8bc3-48ef7767f237")}catch{}})();import{hasSubcommandFlagContractsForCommand,resolveSubcommandFlagContractsForCommand}from"./flag-contracts.js";import{PM_COMMAND_CAPABILITY_CONTRACTS}from"../agent-capability-contracts.js";import{PM_NAMESPACED_COMMAND_ALIASES,resolvePmCommandOperation}from"./command-aliases.js";import{enrichCliFlagInvocationContracts}from"../flag-invocation-contracts.js";let cachedPmFlagLexicon;const FULL_PROJECTION_CONCEPT_BY_COMMAND=Object.freeze({list:"list-item-projection","list-all":"list-item-projection","list-draft":"list-item-projection","list-open":"list-item-projection","list-in-progress":"list-item-projection","list-blocked":"list-item-projection","list-closed":"list-item-projection","list-canceled":"list-item-projection",get:"get-item-projection",graph:"graph-detail-projection",search:"search-result-projection",history:"history-entry-projection",events:"mutation-event-projection",activity:"activity-entry-projection",deps:"dependency-graph-projection",health:"health-diagnostic-projection",validate:"validation-diagnostic-projection",contracts:"contract-catalog-projection"});function resolvePmFlagSemanticConcept(command,flag){if(flag==="--limit")return"result-row-limit";if(flag==="--node-limit")return"graph-node-limit";if(flag==="--edge-limit")return"graph-edge-limit";if(flag==="--output-limit")return"rendered-output-row-limit";if(flag==="--output-budget")return"rendered-output-byte-budget";if(flag==="--token-budget")return"context-intent-token-budget";if(flag==="--full"){const concept=FULL_PROJECTION_CONCEPT_BY_COMMAND[resolvePmCommandOperation(command)];if(concept===void 0)throw new Error(`Command ${command} exposes --full without a registered projection concept.`);return concept}return flag!=="--file"?flag.slice(2):["create","update","update-many"].includes(resolvePmCommandOperation(command))?"linked-file-path":["comments","notes","learnings"].includes(resolvePmCommandOperation(command))?"entry-file-input":"plan-definition-file"}function listPmFlagLexicon(){if(cachedPmFlagLexicon!==void 0)return cachedPmFlagLexicon;const provisionalEntries=PM_COMMAND_CAPABILITY_CONTRACTS.filter(({command})=>hasSubcommandFlagContractsForCommand(command)).flatMap(({command,family})=>enrichCliFlagInvocationContracts(command,resolveSubcommandFlagContractsForCommand(command)).map(contract=>({command,family,concept:resolvePmFlagSemanticConcept(command,contract.flag),flag:contract.flag,aliases:Object.freeze([...contract.aliases??[]]),value_kind:contract.repeatable?"list":contract.flag==="--limit"?"number":contract.value_type}))),compatibilityAliasFlags=new Set(provisionalEntries.flatMap(entry=>entry.aliases.map(alias=>`${entry.command}:${alias}`))),canonicalEntries=provisionalEntries.filter(entry=>!compatibilityAliasFlags.has(`${entry.command}:${entry.flag}`)),kindsByConcept=new Map;for(const entry of canonicalEntries){const kinds=kindsByConcept.get(entry.concept)??new Set;kinds.add(entry.value_kind),kindsByConcept.set(entry.concept,kinds)}return cachedPmFlagLexicon=Object.freeze(canonicalEntries.map(entry=>Object.freeze({...entry,concept:kindsByConcept.get(entry.concept)?.size===1?entry.concept:`${entry.concept}@${entry.command}`}))),cachedPmFlagLexicon}function listPmFlagSpellingInventory(){return Object.freeze(listPmFlagLexicon().map(entry=>Object.freeze({command:entry.command,canonical_flag:entry.flag,accepted_spellings:Object.freeze([...new Set([entry.flag,...entry.aliases])].sort())})))}const LEGACY_COMMAND_FLAG_BUDGET_MAXIMUMS=Object.freeze({init:30,item:20,config:36,extension:55,package:56,packages:56,install:27,upgrade:29,create:100,copy:24,focus:22,list:86,"list-all":86,"list-draft":84,"list-open":84,"list-in-progress":84,"list-blocked":84,"list-closed":84,"list-canceled":84,aggregate:40,context:45,ctx:45,get:30,graph:34,search:78,duplicates:25,eval:25,next:38,history:35,events:33,"history-attest":23,"history-redact":27,"history-repair":27,"history-compact":30,"history-author-acknowledge":28,merge:29,schema:43,profile:22,activity:35,restore:23,update:105,"update-many":146,close:32,"close-many":72,delete:24,append:25,comments:31,notes:35,learnings:31,files:39,docs:30,deps:32,plan:109,test:56,"test-all":40,telemetry:21,stats:29,health:36,validate:46,assurance:30,gc:22,workspace:23,contracts:29,claim:39,release:25,"start-task":23,"pause-task":23,"close-task":24,meet:33,event:33,remind:29,"test-runs-worker":20}),PM_COMMAND_FLAG_BUDGET_MAXIMUMS=Object.freeze({...LEGACY_COMMAND_FLAG_BUDGET_MAXIMUMS,...Object.fromEntries(PM_NAMESPACED_COMMAND_ALIASES.flatMap(({alias,canonical})=>{const maximum=LEGACY_COMMAND_FLAG_BUDGET_MAXIMUMS[alias];return maximum===void 0?[]:[[canonical,maximum]]}))});function listPmCommandFlagBudgets(){const currentByCommand=new Map(Object.keys(PM_COMMAND_FLAG_BUDGET_MAXIMUMS).map(command=>[command,0]));for(const{command}of listPmFlagLexicon())currentByCommand.set(command,Number(currentByCommand.get(command))+1);return Object.freeze(Object.entries(PM_COMMAND_FLAG_BUDGET_MAXIMUMS).map(([command,maximum])=>Object.freeze({command,current:Number(currentByCommand.get(command)),maximum})))}function appendAliasCollisionFindings(entries,canonicalOwners,findings){for(const entry of entries)for(const alias of entry.aliases){const owner=canonicalOwners.get(`${entry.command}:${alias}`);owner===void 0||owner.flag===entry.flag||findings.push({code:"alias_collision",command:entry.command,detail:`${alias} aliases ${entry.flag} but is canonical for ${owner.flag}.`})}}function appendBudgetFindings(counts,budgets,findings){const budgetedCommands=new Set(budgets.map(({command})=>command));for(const command of counts.keys())budgetedCommands.has(command)||findings.push({code:"missing_budget",command,detail:`${command} has canonical flags but no persisted budget.`});for(const budget of budgets){const actual=counts.get(budget.command)??0;actual===0&&findings.push({code:"stale_budget",command:budget.command,detail:`${budget.command} has a persisted budget but no canonical flags.`}),!(actual<=budget.maximum)&&findings.push({code:"budget_exceeded",command:budget.command,detail:`${actual} canonical flags exceed the ratcheted maximum ${budget.maximum}.`})}}function appendSpellingCompatibilityFindings(entries,baseline,findings){const current=new Map(entries.map(entry=>[`${entry.command}:${entry.flag}`,entry]));for(const historical of baseline){const key=`${historical.command}:${historical.canonical_flag}`,entry=current.get(key);if(!entry){findings.push({code:"removed_canonical_spelling",command:historical.command,detail:`${historical.canonical_flag} disappeared from the executable spelling inventory.`});continue}const accepted=new Set([entry.flag,...entry.aliases]);for(const spelling of historical.accepted_spellings)accepted.has(spelling)||findings.push({code:"removed_compatibility_spelling",command:historical.command,detail:`${spelling} no longer resolves to ${historical.canonical_flag}.`})}}function verifyPmFlagLexicon(entries=listPmFlagLexicon(),budgets=listPmCommandFlagBudgets(),baseline=[]){const findings=[],canonicalOwners=new Map,conceptKinds=new Map,conceptSpellings=new Map,counts=new Map;for(const entry of entries){const commandFlag=`${entry.command}:${entry.flag}`;canonicalOwners.has(commandFlag)?findings.push({code:"duplicate_canonical_flag",command:entry.command,detail:`${entry.flag} has more than one canonical row.`}):canonicalOwners.set(commandFlag,entry),counts.set(entry.command,(counts.get(entry.command)??0)+1);const priorKind=conceptKinds.get(entry.concept);priorKind!==void 0&&priorKind!==entry.value_kind?findings.push({code:"inconsistent_concept_kind",command:entry.command,detail:`${entry.concept} uses both ${priorKind} and ${entry.value_kind}.`}):conceptKinds.set(entry.concept,entry.value_kind);const priorSpelling=conceptSpellings.get(entry.concept);priorSpelling!==void 0&&priorSpelling!==entry.flag?findings.push({code:"semantic_spelling_collision",command:entry.command,detail:`${entry.concept} is canonicalized by both ${priorSpelling} and ${entry.flag}.`}):conceptSpellings.set(entry.concept,entry.flag)}return appendAliasCollisionFindings(entries,canonicalOwners,findings),appendBudgetFindings(counts,budgets,findings),appendSpellingCompatibilityFindings(entries,baseline,findings),findings.sort((left,right)=>left.command.localeCompare(right.command)||left.code.localeCompare(right.code)||left.detail.localeCompare(right.detail)),{ok:findings.length===0,entry_count:entries.length,budget_count:budgets.length,concept_count:new Set(entries.map(({concept})=>concept)).size,baseline_entry_count:baseline.length,findings}}function renderPmFlagLexiconMarkdown(){const lexicon=listPmFlagLexicon(),budgets=listPmCommandFlagBudgets(),familyByCommand=new Map(budgets.map(({command})=>[command,"unknown"]));for(const{command,family}of lexicon)familyByCommand.set(command,family);return["# Generated flag lexicon budgets","","This file is generated by `listPmFlagLexicon()`. Compatibility aliases do not consume canonical budget.","","| Command | Capability family | Canonical flags | Maximum |","| --- | --- | ---: | ---: |",...budgets.map(({command,current,maximum})=>{const family=familyByCommand.get(command);return`| \`${command}\` | ${family} | ${current} | ${maximum} |`}),""].join(`
2
2
  `)}export{listPmCommandFlagBudgets,listPmFlagLexicon,listPmFlagSpellingInventory,renderPmFlagLexiconMarkdown,resolvePmFlagSemanticConcept,verifyPmFlagLexicon};
3
3
  //# sourceMappingURL=flag-lexicon-contracts.js.map
@@ -321,6 +321,7 @@ includePackageOwnedActions?:boolean;
321
321
  }):ActionContractDescriptor[];
322
322
  /** Derive invocability from active handlers and policy, preserving installation hints for unavailable optional operations. */
323
323
  declare function resolveActionAvailability(descriptor:ActionContractDescriptor,runtimeProbe:RuntimeExtensionActionProbe):ContractsActionAvailability;
324
+ /** Expose core flags with the encoding alias accepted by the shared SDK parser. */
324
325
  declare function resolveCoreCommandFlags(command:string):CliFlagContract[];
325
326
  /** Recognize core flag contracts while keeping package-owned operations outside the core provider surface. */
326
327
  declare function isCoreCommandPath(command:string):boolean;