@unbrained/pm-cli 2026.8.26 → 2026.8.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (161) hide show
  1. package/.agents/skills/HARNESS_COMPATIBILITY.md +32 -0
  2. package/.agents/skills/README.md +47 -0
  3. package/.agents/skills/pm-developer/SKILL.md +117 -0
  4. package/.agents/skills/pm-developer/references/COMMAND_PLAYBOOK.md +49 -0
  5. package/.agents/skills/pm-developer/references/GRAPH_AND_RELATIONSHIPS.md +91 -0
  6. package/.agents/skills/pm-developer/references/MULTI_AGENT_MERGE.md +72 -0
  7. package/.agents/skills/pm-developer/references/PROMPTS.md +17 -0
  8. package/.agents/skills/pm-developer/references/SCRIPTING_COMPOSITION.md +82 -0
  9. package/.agents/skills/pm-developer/references/TOKEN_BUDGETS.md +85 -0
  10. package/.agents/skills/pm-extensions/SKILL.md +106 -0
  11. package/.agents/skills/pm-extensions/references/AUTHORING.md +95 -0
  12. package/.agents/skills/pm-extensions/references/LIFECYCLE.md +40 -0
  13. package/.agents/skills/pm-extensions/references/TROUBLESHOOTING.md +25 -0
  14. package/.agents/skills/pm-sdk/SKILL.md +107 -0
  15. package/.agents/skills/pm-sdk/references/DOMAIN_MODELING.md +78 -0
  16. package/.agents/skills/pm-sdk/references/INTEGRATION_CHECKLIST.md +31 -0
  17. package/.agents/skills/pm-sdk/references/PROMPTS.md +13 -0
  18. package/.agents/skills/pm-sdk/references/SURFACE_MAP.md +82 -0
  19. package/.agents/skills/pm-user/SKILL.md +111 -0
  20. package/.agents/skills/pm-user/references/BACKLOG_SHAPING.md +105 -0
  21. package/.agents/skills/pm-user/references/PROMPTS.md +17 -0
  22. package/.agents/skills/pm-user/references/WORKFLOWS.md +35 -0
  23. package/.claude-plugin/marketplace.json +2 -2
  24. package/CHANGELOG.md +25 -3
  25. package/README.md +8 -5
  26. package/dist/cli/commander-usage.js +11 -7
  27. package/dist/cli/error-guidance.js +3 -3
  28. package/dist/cli/help-content.d.ts +2 -0
  29. package/dist/cli/help-content.js +53 -17
  30. package/dist/cli/help-json-payload.d.ts +8 -2
  31. package/dist/cli/help-json-payload.js +46 -12
  32. package/dist/cli/main.js +52 -74
  33. package/dist/cli/register-annotations.js +27 -21
  34. package/dist/cli/register-setup.js +98 -57
  35. package/dist/cli-bundle/bundle-manifest.json +152 -152
  36. package/dist/cli-bundle/chunks/chunk-3OO3W6FW.js +202 -0
  37. package/dist/cli-bundle/chunks/chunk-52EKTW6V.js +3 -0
  38. package/dist/cli-bundle/chunks/{chunk-KBFP3E4E.js → chunk-CVBBGWW5.js} +62 -44
  39. package/dist/cli-bundle/chunks/chunk-MFNTKMTI.js +13 -0
  40. package/dist/cli-bundle/chunks/{chunk-E2GCFJSU.js → chunk-OS27HHBN.js} +31 -31
  41. package/dist/cli-bundle/chunks/chunk-QTO7USTH.js +2 -0
  42. package/dist/cli-bundle/chunks/{chunk-S4U76VZF.js → chunk-R4ETAOJC.js} +2 -2
  43. package/dist/cli-bundle/chunks/{chunk-UKBCRPA2.js → chunk-SH6P7FXI.js} +2 -2
  44. package/dist/cli-bundle/chunks/{chunk-WRHJ3MB6.js → chunk-SHMDY36D.js} +2 -2
  45. package/dist/cli-bundle/chunks/{chunk-ZNRLJ54C.js → chunk-SKXLJIEK.js} +2 -2
  46. package/dist/cli-bundle/chunks/chunk-TNX6HC54.js +3 -0
  47. package/dist/cli-bundle/chunks/{register-list-query-EMCPMICY.js → register-list-query-EUWM6VII.js} +2 -2
  48. package/dist/cli-bundle/chunks/{register-mutation-OJ67ABCB.js → register-mutation-FD4HSAVU.js} +4 -4
  49. package/dist/cli-bundle/chunks/{register-operations-H2GLP7LT.js → register-operations-HRMNFEC3.js} +2 -2
  50. package/dist/cli-bundle/chunks/register-setup-33GNICLX.js +2 -0
  51. package/dist/cli-bundle/focused-chunks/{chunk-4XNH2HM7.js → chunk-2AGZ5BRT.js} +2 -2
  52. package/dist/cli-bundle/focused-chunks/{chunk-72T6JGAE.js → chunk-4BR5UU52.js} +45 -45
  53. package/dist/cli-bundle/focused-chunks/{chunk-OHIHZ7HS.js → chunk-6GCRSLPG.js} +2 -2
  54. package/dist/cli-bundle/focused-chunks/{chunk-UYBA57GY.js → chunk-AD6ULRAF.js} +2 -2
  55. package/dist/cli-bundle/focused-chunks/{chunk-7YCDTCBC.js → chunk-AQ5IYEZZ.js} +2 -2
  56. package/dist/cli-bundle/focused-chunks/{chunk-YO3ZF3FI.js → chunk-EKX37ZHA.js} +2 -2
  57. package/dist/cli-bundle/focused-chunks/{chunk-LV5N3LK5.js → chunk-FC2AXLB5.js} +2 -2
  58. package/dist/cli-bundle/focused-chunks/{chunk-IBHXMFE7.js → chunk-HC7ODMH3.js} +2 -2
  59. package/dist/cli-bundle/focused-chunks/{chunk-4K2II4TV.js → chunk-HVQ22RC4.js} +2 -2
  60. package/dist/cli-bundle/focused-chunks/{chunk-A644DUFQ.js → chunk-MEASX544.js} +2 -2
  61. package/dist/cli-bundle/focused-chunks/{chunk-FXDLT6FL.js → chunk-MXTYGECH.js} +2 -2
  62. package/dist/cli-bundle/focused-chunks/{chunk-MMXUPDDJ.js → chunk-SUBSWYW3.js} +2 -2
  63. package/dist/cli-bundle/focused-chunks/{chunk-57XY346D.js → chunk-XDPYBQCF.js} +9 -9
  64. package/dist/cli-bundle/focused-chunks/{chunk-TMJDFHVD.js → chunk-Y3JJXRVK.js} +2 -2
  65. package/dist/cli-bundle/focused-chunks/{chunk-66VGB23P.js → chunk-Y5A7SJJ7.js} +2 -2
  66. package/dist/cli-bundle/focused-chunks/chunk-YHWHX6YY.js +2 -0
  67. package/dist/cli-bundle/focused-chunks/{chunk-P2E6LDAE.js → chunk-YVVZ3LQ6.js} +3 -3
  68. package/dist/cli-bundle/focused-chunks/chunk-Z2USIBR2.js +5 -0
  69. package/dist/cli-bundle/main.js +15 -14
  70. package/dist/cli-bundle/sdk-authoring.js +1 -1
  71. package/dist/cli-bundle/sdk-contracts.js +2 -2
  72. package/dist/cli-bundle/sdk-core.js +31 -31
  73. package/dist/cli-bundle/sdk-governance.js +1 -1
  74. package/dist/cli-bundle/sdk-graph.js +1 -1
  75. package/dist/cli-bundle/sdk-merge.js +31 -31
  76. package/dist/cli-bundle/sdk-query.js +1 -1
  77. package/dist/cli-bundle/sdk-runtime.js +1 -1
  78. package/dist/cli-bundle/sdk-testing.js +1 -1
  79. package/dist/cli-bundle/sdk.js +32 -7
  80. package/dist/core/governance/issue-codes.d.ts +11 -2
  81. package/dist/core/governance/issue-codes.js +29 -10
  82. package/dist/core/item/item-format.js +3 -3
  83. package/dist/core/store/item-store.js +12 -5
  84. package/dist/mcp/server.js +123 -9
  85. package/dist/mcp/tool-definitions.d.ts +2 -0
  86. package/dist/mcp/tool-definitions.js +2 -2
  87. package/dist/sdk/agent/closed-domain-contracts.d.ts +1 -1
  88. package/dist/sdk/agent/closed-domain-contracts.js +24 -2
  89. package/dist/sdk/agent-capability-contracts.js +6 -2
  90. package/dist/sdk/cli-bootstrap.js +3 -2
  91. package/dist/sdk/cli-contracts/command-aliases.js +15 -2
  92. package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -1
  93. package/dist/sdk/cli-contracts/enum-contracts.js +7 -2
  94. package/dist/sdk/cli-contracts/flag-contracts.js +9 -5
  95. package/dist/sdk/cli-contracts/grammar-contracts.d.ts +3 -3
  96. package/dist/sdk/cli-contracts/grammar-contracts.js +24 -17
  97. package/dist/sdk/cli-contracts/runtime-contracts.js +13 -11
  98. package/dist/sdk/cli-contracts/tool-schema.js +18 -15
  99. package/dist/sdk/cli-contracts.d.ts +1 -1
  100. package/dist/sdk/cli-contracts.js +3 -3
  101. package/dist/sdk/cli-program.js +3 -2
  102. package/dist/sdk/completion.js +40 -13
  103. package/dist/sdk/generated/generated-error-code-catalog-part-2.js +14 -2
  104. package/dist/sdk/governance/upgrade.d.ts +2 -0
  105. package/dist/sdk/governance/upgrade.js +30 -8
  106. package/dist/sdk/governance/validate.js +8 -6
  107. package/dist/sdk/guide-topics.js +6 -6
  108. package/dist/sdk/index.d.ts +4 -2
  109. package/dist/sdk/index.js +5 -3
  110. package/dist/sdk/mcp/apps.d.ts +70 -0
  111. package/dist/sdk/mcp/apps.js +154 -0
  112. package/dist/sdk/mcp/skills.d.ts +127 -0
  113. package/dist/sdk/mcp/skills.js +390 -0
  114. package/dist/sdk/read-output-contracts.js +16 -3
  115. package/dist/sdk/runtime-action-aliases.js +7 -3
  116. package/dist/sdk/runtime-input.js +12 -4
  117. package/dist/sdk/runtime-primitives.d.ts +1 -1
  118. package/dist/sdk/runtime-primitives.js +3 -3
  119. package/docs/CLI_GRAMMAR.md +7 -1
  120. package/docs/COMMANDS.md +2 -2
  121. package/docs/EXTENSIONS.md +33 -32
  122. package/docs/MCP_2026_07_28.md +24 -2
  123. package/docs/MCP_2026_07_28_CONFORMANCE.md +4 -4
  124. package/docs/MCP_SKILLS_AND_APPS.md +107 -0
  125. package/docs/QUICKSTART.md +15 -15
  126. package/docs/README.md +1 -0
  127. package/docs/RELEASING.md +11 -3
  128. package/docs/SDK_CONTEXT_INTEGRITY.md +6 -0
  129. package/docs/SDK_EVIDENCE_TRACEABILITY.md +9 -1
  130. package/docs/generated/AGENT_CAPABILITY_ROUTING.md +1 -1
  131. package/docs/generated/REFUSAL_CLOSURE_CENSUS.md +7 -6
  132. package/marketplace.json +2 -2
  133. package/package.json +9 -7
  134. package/packages/pm-beads/README.md +12 -6
  135. package/packages/pm-beads/docs/MIGRATION.md +53 -0
  136. package/packages/pm-beads/extensions/beads/index.ts +8 -0
  137. package/packages/pm-beads/extensions/beads/runtime.ts +671 -112
  138. package/packages/pm-beads/package.json +1 -1
  139. package/packages/pm-calendar/package.json +1 -1
  140. package/packages/pm-command-kit/package.json +1 -1
  141. package/packages/pm-digital-twin/package.json +1 -1
  142. package/packages/pm-governance-audit/package.json +1 -1
  143. package/packages/pm-guide-shell/package.json +1 -1
  144. package/packages/pm-kanban/package.json +1 -1
  145. package/packages/pm-lifecycle-hooks/package.json +1 -1
  146. package/packages/pm-linked-test-adapters/package.json +1 -1
  147. package/packages/pm-search-advanced/package.json +1 -1
  148. package/packages/pm-templates/package.json +1 -1
  149. package/packages/pm-todos/package.json +1 -1
  150. package/packages/pm-vcs/package.json +1 -1
  151. package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
  152. package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
  153. package/sdk/public-surface.json +235 -13
  154. package/dist/cli-bundle/chunks/chunk-ES25LX3D.js +0 -202
  155. package/dist/cli-bundle/chunks/chunk-FRDWWB6R.js +0 -3
  156. package/dist/cli-bundle/chunks/chunk-ICQ3RVIY.js +0 -2
  157. package/dist/cli-bundle/chunks/chunk-IV64RJVE.js +0 -13
  158. package/dist/cli-bundle/chunks/chunk-MVYLQ67M.js +0 -3
  159. package/dist/cli-bundle/chunks/register-setup-GLZAHLVI.js +0 -2
  160. package/dist/cli-bundle/focused-chunks/chunk-7I23XGWO.js +0 -2
  161. package/dist/cli-bundle/focused-chunks/chunk-LMKG3DFE.js +0 -5
@@ -1,9 +1,9 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="26c3efa6-b820-5370-b0ab-65b08bc007ec")}catch(e){}}();
3
- import { hasSubcommandFlagContractsForCommand, PM_CORE_COMMAND_NAMES, } from "../sdk/cli-contracts.js";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="43167bb0-7cc0-599f-8587-8583d398f1ad")}catch(e){}}();
3
+ import { hasSubcommandFlagContractsForCommand, PM_COMMAND_ALIAS_CONTRACTS, PM_CORE_COMMAND_NAMES, } from "../sdk/cli-contracts.js";
4
4
  import { commandOptionFlagLabel, resolveCommandOptionPolicyState, resolveTypeDefinition, EXIT_CODE, printError, writeStdout, } from "../sdk/runtime-primitives.js";
5
5
  import { buildDynamicExtensionHelpOptionSummaries, mergeHelpOptionSummaries, findCommandByPath, findDirectChildCommand, commandAliases, } from "./extension-command-help.js";
6
- import { getPmCommandHelpVisibilityTier, normalizeHelpCommandPath, resolveHelpDetailMode, resolveHelpNarrative, } from "./help-content.js";
6
+ import { getPmCommandHelpVisibilityTier, isFullHelpDiscovery, normalizeHelpCommandPath, resolveHelpDetailMode, resolveHelpNarrative, } from "./help-content.js";
7
7
  import { getCommandPath } from "./registration-helpers.js";
8
8
  import { parseBootstrapGlobalOptions, parseBootstrapHelpRequest, parseBootstrapCommandName, parseBootstrapTypeValue, } from "./bootstrap-args.js";
9
9
  import { extractProvidedOptionFlags, renderPmCommand } from "./argv-utils.js";
@@ -206,23 +206,40 @@ function buildHelpArgumentSummaries(command) {
206
206
  };
207
207
  });
208
208
  }
209
- function buildHelpSubcommandSummaries(command, extensionDescriptors = new Map()) {
210
- return command
211
- .createHelp()
212
- .visibleCommands(command)
209
+ function buildHelpSubcommandSummaries(command, extensionDescriptors = new Map(), includeAll = false) {
210
+ const visible = command.createHelp().visibleCommands(command);
211
+ const candidates = includeAll
212
+ ? [...new Set([...visible, ...command.commands])]
213
+ : visible;
214
+ return candidates
213
215
  .filter((entry) => entry.name() !== "help" || command.parent === null)
216
+ .filter((entry) => !includeAll ||
217
+ (getPmCommandHelpVisibilityTier(entry) ??
218
+ resolvePmCommandVisibilityTier(entry.name())) !== "internal")
214
219
  .map((entry) => {
215
220
  const commandPath = normalizeHelpCommandPath(getCommandPath(entry));
216
221
  const rootCommand = commandPath.split(" ")[0];
217
- const extensionDescriptor = resolveExtensionCommandSurface(commandPath, extensionDescriptors, getPmCommandHelpVisibilityTier(entry) !== undefined);
222
+ const declaredTier = getPmCommandHelpVisibilityTier(entry);
223
+ const extensionDescriptor = resolveExtensionCommandSurface(commandPath, extensionDescriptors, declaredTier !== undefined);
224
+ const aliasContract = PM_COMMAND_ALIAS_CONTRACTS.find(({ alias }) => alias === commandPath);
218
225
  return {
219
226
  name: entry.name().trim(),
220
227
  aliases: commandAliases(entry),
221
228
  description: entry.description().trim(),
222
229
  tier: extensionDescriptor?.tier ??
230
+ declaredTier ??
223
231
  resolvePmCommandVisibilityTier(rootCommand),
224
232
  family: extensionDescriptor?.family ??
225
233
  resolvePmCommandCapabilityFamily(rootCommand),
234
+ ...(aliasContract
235
+ ? {
236
+ alias_for: aliasContract.canonical,
237
+ alias_lifecycle: aliasContract.lifecycle,
238
+ ...(aliasContract.lifecycle === "deprecated"
239
+ ? { deprecated: true }
240
+ : {}),
241
+ }
242
+ : {}),
226
243
  };
227
244
  })
228
245
  .sort((left, right) => left.name.localeCompare(right.name));
@@ -263,11 +280,23 @@ function resolveJsonHelpCapabilityFamily(rootCommandPath, extensionDescriptor) {
263
280
  return (extensionDescriptor?.family ??
264
281
  resolvePmCommandCapabilityFamily(rootCommandPath));
265
282
  }
283
+ function projectFullCommandAliases(rootProgram, targetCommand, fullDiscovery) {
284
+ if (targetCommand !== rootProgram || !fullDiscovery)
285
+ return undefined;
286
+ return PM_COMMAND_ALIAS_CONTRACTS.map((contract) => ({
287
+ alias: contract.alias,
288
+ canonical: contract.canonical,
289
+ canonical_argv: [...contract.canonical_argv],
290
+ lifecycle: contract.lifecycle,
291
+ hidden: contract.hidden,
292
+ deprecated: contract.lifecycle === "deprecated",
293
+ }));
294
+ }
266
295
  /** Build the command/action structural view shared by every JSON help field. */
267
- function buildPositionalActionHelpProjection(action, targetCommand, resolvedPath, allOptions, extensionDescriptors = new Map()) {
296
+ function buildPositionalActionHelpProjection(action, targetCommand, resolvedPath, allOptions, extensionDescriptors = new Map(), includeAll = false) {
268
297
  if (!action) {
269
298
  const argumentsList = buildHelpArgumentSummaries(targetCommand);
270
- const registeredSubcommands = buildHelpSubcommandSummaries(targetCommand, extensionDescriptors);
299
+ const registeredSubcommands = buildHelpSubcommandSummaries(targetCommand, extensionDescriptors, includeAll);
271
300
  const registeredSubcommandNames = new Set(registeredSubcommands.map(({ name }) => name));
272
301
  return {
273
302
  arguments: argumentsList,
@@ -316,6 +345,7 @@ function buildPositionalActionHelpProjection(action, targetCommand, resolvedPath
316
345
  }
317
346
  function buildJsonHelpPayload(rootProgram, targetCommand, argv, requestedPath, extensionDescriptors) {
318
347
  const detailMode = resolveHelpDetailMode(argv);
348
+ const fullDiscovery = isFullHelpDiscovery(argv);
319
349
  const commanderPath = normalizeHelpCommandPath(getCommandPath(targetCommand));
320
350
  const requestedCommandPath = normalizeHelpCommandPath(requestedPath.join(" "));
321
351
  const resolvedPath = requestedCommandPath.length > commanderPath.length
@@ -334,7 +364,8 @@ function buildJsonHelpPayload(rootProgram, targetCommand, argv, requestedPath, e
334
364
  : undefined;
335
365
  const narrative = buildJsonHelpNarrative(detailMode, fallbackNarrative, extensionDescriptor);
336
366
  const allOptionSummaries = compactHelpOptionAliases(mergeHelpOptionSummaries(buildHelpOptionSummaries(targetCommand), buildDynamicExtensionHelpOptionSummaries(extensionDescriptor)));
337
- const projection = buildPositionalActionHelpProjection(positionalAction, targetCommand, projectedPath, allOptionSummaries, extensionDescriptors);
367
+ const projection = buildPositionalActionHelpProjection(positionalAction, targetCommand, projectedPath, allOptionSummaries, extensionDescriptors, fullDiscovery);
368
+ const fullCommandAliases = projectFullCommandAliases(rootProgram, targetCommand, fullDiscovery);
338
369
  return {
339
370
  format: "pm_help_v1",
340
371
  detail_mode: detailMode,
@@ -356,6 +387,9 @@ function buildJsonHelpPayload(rootProgram, targetCommand, argv, requestedPath, e
356
387
  options: projection.options,
357
388
  subcommands: projection.subcommands,
358
389
  has_subcommands: projection.subcommands.length > 0,
390
+ ...(fullCommandAliases === undefined
391
+ ? {}
392
+ : { command_aliases: fullCommandAliases }),
359
393
  };
360
394
  }
361
395
  /** Implements maybe render bootstrap json help for the public runtime surface of this module. */
@@ -529,4 +563,4 @@ export const _testOnly = {
529
563
  resolveExtensionCommandSurface,
530
564
  };
531
565
  //# sourceMappingURL=help-json-payload.js.map
532
- //# debugId=26c3efa6-b820-5370-b0ab-65b08bc007ec
566
+ //# debugId=43167bb0-7cc0-599f-8587-8583d398f1ad
package/dist/cli/main.js CHANGED
@@ -3,17 +3,17 @@
3
3
  * @module cli/main
4
4
  */
5
5
 
6
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ffd55bde-cc30-529f-a6f9-ec43abe4efba")}catch(e){}}();
7
- import { Command } from "commander";
6
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f947c7f0-adf8-59da-8bc7-9cd746b05839")}catch(e){}}();
7
+ import { Command, CommanderError } from "commander";
8
8
  import { activateExtensions, clearActiveExtensionHooks, createCoreCommandHookContext, resetActiveExtensionRuntimeState, createEmptyExtensionRegistrationRegistry, discoverExtensions, getActiveCommandResult, getActiveExtensionRegistrations, loadExtensions, consumeAfterCommandAffectedItems, runActiveCommandHandler, runActiveParserOverride, runActivePreflightOverride, runAfterCommandHooks, runBeforeCommandHooks, setActiveCommandResult, setActiveCommandContext, setActiveExtensionCommands, setActiveExtensionHooks, setActiveExtensionParsers, setActiveExtensionPreflight, setActiveExtensionRegistrations, setActiveExtensionRenderers, setActiveExtensionServices, pathExists, resolvePmCliVersion, resolvePmPackageRootFromModule, resolveItemTypeRegistry, resolveRuntimeFieldRegistry, EXIT_CODE, resolveTelemetryErrorCategory, PmCliError, asRecordOrNull, printError, printResult, maybeRunFirstUseTelemetryPrompt, emitTelemetryErrorEvent, startTelemetryCommand, deriveTelemetryCommandResolution, sentryCaptureCliError, sentryFinishCommandSpan, sentryFlush, sentryLogCliUsageError, sentrySetCommandContext, sentryStartCommandSpan, ensureSentryInit, getSettingsPath, resolvePmRoot, readSettings, readSettingsWithMetadata, runWithWorkspaceHarnessSignalDescriptors, createLazyModule, } from "../sdk/runtime-primitives.js";
9
9
  import { runWithReproducibleProcessEnvironment } from "../sdk/reproducibility/process.js";
10
10
  import { resolveSubcommandFlagContractsForCommand } from "../sdk/cli-contracts.js";
11
11
  import { createExtensionCommandSdk } from "../sdk/extension-command-context.js";
12
12
  import { PmClient } from "../sdk/runtime.js";
13
13
  import { coerceLooseCommandOptionsWithFlagDefinitions, collectLooseCommandOptionKeysForDefinitions, collectLoosePositionalArgs, parseLooseCommandOptions, stripLooseCommandOptionTokens, validateLooseCommandOptionsWithFlagDefinitions, } from "./extension-command-options.js";
14
- import { attachRichHelpText, setPmCommandHelpVisibilityTier, } from "./help-content.js";
14
+ import { attachRichHelpText, isFullHelpDiscovery, setPmCommandHelpVisibilityTier, } from "./help-content.js";
15
15
  import { finishActiveTelemetryCommand, recordAfterCommandContextUsage } from "./after-command-context-usage.js";
16
- import { extractProvidedOptionFlags, normalizeLongOptionFlag, redactSensitiveCommandArgs, renderPmCommand, } from "./argv-utils.js";
16
+ import { extractProvidedOptionFlags, normalizeLongOptionFlag, redactSensitiveCommandArgs, renderPmCommand } from "./argv-utils.js";
17
17
  import { classifyCommanderError, classifyPmCliError, classifyUnknownError, formatPmCliErrorForDisplay, formatPmCliErrorForJson, formatUnknownErrorForJson, projectLeanErrorEnvelope, } from "./error-guidance.js";
18
18
  import { describeUnknownError, isCommanderError, normalizeThrownExitCode, readThrownExitCode, wrapThrownErrorForSentry } from "../sdk/error-runtime.js";
19
19
  import { applyDefaultOutputFormat, clearResolvedGlobalOptions, collect, formatHookWarnings, getCommandPath, getGlobalOptions, invalidateSearchCachesForMutation, setResolvedGlobalOptions, syncCommanderActionOptions, } from "./registration-helpers.js";
@@ -51,7 +51,7 @@ function recordCliReadOutputInvocationProvenance(actionCommand, commandPath, com
51
51
  const rawArgs = rootCommand.rawArgs;
52
52
  const providedFlags = new Set(extractProvidedOptionFlags(rawArgs.slice(2)));
53
53
  const contract = PM_READ_OUTPUT_SURFACE_CONTRACTS.find((candidate) => candidate.command === surface);
54
- const explicitLegacyAliases = Object.values(contract.dimensions).flatMap((dimension) => dimension.legacy_aliases.flatMap((alias) => providedFlags.has(alias.flag) ? [alias.flag] : []));
54
+ const explicitLegacyAliases = Object.values(contract.dimensions).flatMap((dimension) => dimension.legacy_aliases.flatMap((alias) => (providedFlags.has(alias.flag) ? [alias.flag] : [])));
55
55
  const previous = Reflect.get(commandOptions, READ_OUTPUT_INVOCATION_PROVENANCE);
56
56
  Reflect.set(commandOptions, READ_OUTPUT_INVOCATION_PROVENANCE, {
57
57
  canonical_include_modes: previous?.canonical_include_modes ?? [],
@@ -115,18 +115,14 @@ function inferMissingFieldsFromErrorMessage(message) {
115
115
  return normalized.length > 0 ? normalized : undefined;
116
116
  }
117
117
  function inferMissingFieldsForRecovery(rawMessage, invocationArgv, existingRecovery) {
118
- if (existingRecovery?.suggested_retry ||
119
- rawMessage.includes("failed in extension handler (") ||
120
- !/\b(?:missing|required|requires)\b/i.test(rawMessage)) {
118
+ if (existingRecovery?.suggested_retry || rawMessage.includes("failed in extension handler (") || !/\b(?:missing|required|requires)\b/i.test(rawMessage)) {
121
119
  return undefined;
122
120
  }
123
121
  const providedFields = extractProvidedOptionFlags(invocationArgv);
124
122
  const providedSet = new Set(providedFields.map((flag) => normalizeLongOptionFlag(flag) ?? flag));
125
123
  const rawInferred = inferMissingFieldsFromErrorMessage(rawMessage);
126
124
  const commandName = invocationArgv.find((token) => program.commands.some((candidate) => candidate.name() === token));
127
- const command = commandName
128
- ? program.commands.find((candidate) => candidate.name() === commandName)
129
- : undefined;
125
+ const command = commandName ? program.commands.find((candidate) => candidate.name() === commandName) : undefined;
130
126
  const declaredFlags = new Set([...program.options, ...(command?.options ?? [])].flatMap((option) => option.flags
131
127
  .split(/[ ,|]+/)
132
128
  .map((flag) => normalizeLongOptionFlag(flag))
@@ -136,8 +132,7 @@ function inferMissingFieldsForRecovery(rawMessage, invocationArgv, existingRecov
136
132
  if (providedSet.has(normalized)) {
137
133
  return false;
138
134
  }
139
- return (declaredFlags.has(normalized) ||
140
- extensionFlagTakesValueForInvocation(invocationArgv, commandName, normalized, activeRuntimeExtensionCommandDescriptors) !== undefined);
135
+ return declaredFlags.has(normalized) || extensionFlagTakesValueForInvocation(invocationArgv, commandName, normalized, activeRuntimeExtensionCommandDescriptors) !== undefined;
141
136
  });
142
137
  return trulyMissing && trulyMissing.length > 0 ? trulyMissing : undefined;
143
138
  }
@@ -151,11 +146,7 @@ function resolveRecoverySuggestedRetry(invocationArgv, attemptedCommand, inferre
151
146
  const command = commandName ? program.commands.find((candidate) => candidate.name() === commandName) : undefined;
152
147
  const missingOption = normalizedMissing ? command?.options.find((option) => option.flags.split(/[ ,|]+/).includes(normalizedMissing)) : undefined;
153
148
  const extensionFlagTakesValue = extensionFlagTakesValueForInvocation(invocationArgv, commandName, normalizedMissing, activeRuntimeExtensionCommandDescriptors);
154
- const missingTokens = normalizedMissing
155
- ? missingOption?.isBoolean() === true || extensionFlagTakesValue === false
156
- ? [normalizedMissing]
157
- : [normalizedMissing, "<value>"]
158
- : [];
149
+ const missingTokens = normalizedMissing ? (missingOption?.isBoolean() === true || extensionFlagTakesValue === false ? [normalizedMissing] : [normalizedMissing, "<value>"]) : [];
159
150
  const suggestedRetry = normalizedMissing ? renderAttemptedCommand([...invocationArgv, ...missingTokens]) : attemptedCommand;
160
151
  return suggestedRetry === attemptedCommand ? undefined : suggestedRetry;
161
152
  }
@@ -203,18 +194,10 @@ function buildPmCliRecoveryContext(context, invocationArgv, rawMessage) {
203
194
  const existingRecovery = rawExistingRecovery && safeInvocationArgv.includes("history-redact")
204
195
  ? {
205
196
  ...rawExistingRecovery,
206
- ...(rawExistingRecovery.attempted_command
207
- ? { attempted_command: renderAttemptedCommand(safeInvocationArgv) }
208
- : {}),
209
- ...(rawExistingRecovery.normalized_args
210
- ? { normalized_args: [...safeInvocationArgv] }
211
- : {}),
212
- ...(rawExistingRecovery.suggested_retry
213
- ? { suggested_retry: renderAttemptedCommand(safeInvocationArgv) }
214
- : {}),
215
- ...(rawExistingRecovery.suggested_retry_args
216
- ? { suggested_retry_args: [...safeInvocationArgv] }
217
- : {}),
197
+ ...(rawExistingRecovery.attempted_command ? { attempted_command: renderAttemptedCommand(safeInvocationArgv) } : {}),
198
+ ...(rawExistingRecovery.normalized_args ? { normalized_args: [...safeInvocationArgv] } : {}),
199
+ ...(rawExistingRecovery.suggested_retry ? { suggested_retry: renderAttemptedCommand(safeInvocationArgv) } : {}),
200
+ ...(rawExistingRecovery.suggested_retry_args ? { suggested_retry_args: [...safeInvocationArgv] } : {}),
218
201
  }
219
202
  : rawExistingRecovery;
220
203
  if (existingRecovery?.recovery_mode === "compact" && !explainRequested) {
@@ -372,8 +355,7 @@ function buildPostActionTelemetryOutcome() {
372
355
  const exitCode = processExitCode ?? resultExitCode ?? EXIT_CODE.SUCCESS;
373
356
  const ok = isPmSuccessfulExitCode(exitCode);
374
357
  const errorCode = readRecordString(result, "error_code", "errorCode") ?? inferPostActionErrorCode(ok, exitCode);
375
- const errorCategory = normalizeTelemetryErrorCategory(readRecordString(result, "error_category", "errorCategory")) ??
376
- (!ok ? resolveTelemetryErrorCategory(errorCode) : undefined);
358
+ const errorCategory = normalizeTelemetryErrorCategory(readRecordString(result, "error_category", "errorCategory")) ?? (!ok ? resolveTelemetryErrorCategory(errorCode) : undefined);
377
359
  const errorMessage = !ok ? (inferPostActionFailureMessage(result) ?? `command_exit_${exitCode}`) : undefined;
378
360
  const commandResolution = normalizeTelemetryCommandResolution(readRecordString(result, "command_resolution", "commandResolution")) ??
379
361
  deriveTelemetryCommandResolution({
@@ -546,6 +528,9 @@ function forwardReadOutputIncludeModes(actionCommand, commandPath, globalOptions
546
528
  if (requested === undefined)
547
529
  return;
548
530
  const { selectors, modes } = applyReadOutputIncludeModes(commandPath, requested, commandOptions);
531
+ if (commandPath === "get" && typeof commandOptions.fields === "string") {
532
+ actionCommand.setOptionValueWithSource("fields", commandOptions.fields, "cli");
533
+ }
549
534
  if (modes.length === 0)
550
535
  return;
551
536
  copyReadOutputInvocationProvenance(commandOptions, actionCommand);
@@ -804,9 +789,7 @@ async function registerRuntimeSchemaFieldFlags(rootProgram, invocationArgv) {
804
789
  if (!(await pathExists(getSettingsPath(pmRoot)))) {
805
790
  return;
806
791
  }
807
- const cachedDiscovery = runtimeExtensionDiscoverySnapshotCache?.key === buildRuntimeExtensionDiscoverySnapshotCacheKey(pmRoot)
808
- ? runtimeExtensionDiscoverySnapshotCache.snapshot
809
- : null;
792
+ const cachedDiscovery = runtimeExtensionDiscoverySnapshotCache?.key === buildRuntimeExtensionDiscoverySnapshotCacheKey(pmRoot) ? runtimeExtensionDiscoverySnapshotCache.snapshot : null;
810
793
  const settings = cachedDiscovery === null ? await readSettings(pmRoot) : cachedDiscovery.settings;
811
794
  const fieldRegistry = resolveRuntimeFieldRegistry(settings.schema);
812
795
  const mappings = [
@@ -995,23 +978,19 @@ function extensionProvidesTemplatesRuntime(commands) {
995
978
  }
996
979
  /** Match direct command paths plus the built-in create-template bridge. */
997
980
  function matchesStaticExtensionCommand(commands, probe) {
998
- return (commands.some((command) => activationCommandMatchesProbe(command, probe)) ||
999
- (commandPathNeedsTemplateExtensions(probe) &&
1000
- extensionProvidesTemplatesRuntime(commands)));
981
+ return commands.some((command) => activationCommandMatchesProbe(command, probe)) || (commandPathNeedsTemplateExtensions(probe) && extensionProvidesTemplatesRuntime(commands));
1001
982
  }
1002
983
  /** Identify contribution surfaces that participate in global runtime behavior. */
1003
984
  function hasGlobalExtensionContributions(contributions) {
1004
985
  const contributionCounts = [
1005
986
  entriesOrEmpty(contributions.hooks).length,
1006
- (contributions.preflight_overrides ?? 0) -
1007
- entriesOrEmpty(contributions.preflight_ownership).length,
987
+ (contributions.preflight_overrides ?? 0) - entriesOrEmpty(contributions.preflight_ownership).length,
1008
988
  entriesOrEmpty(contributions.item_types).length,
1009
989
  entriesOrEmpty(contributions.item_fields).length,
1010
990
  entriesOrEmpty(contributions.relationship_kinds).length,
1011
991
  entriesOrEmpty(contributions.service_overrides).length,
1012
992
  entriesOrEmpty(contributions.assurance_providers).length,
1013
- entriesOrEmpty(contributions.renderer_overrides).length -
1014
- entriesOrEmpty(contributions.renderer_ownership).length,
993
+ entriesOrEmpty(contributions.renderer_overrides).length - entriesOrEmpty(contributions.renderer_ownership).length,
1015
994
  ];
1016
995
  return contributionCounts.some((count) => count > 0);
1017
996
  }
@@ -1024,8 +1003,7 @@ function resolveStaticExtensionActivationDecision(extension, probe) {
1024
1003
  const commands = extensionActivationCommands(extension);
1025
1004
  if (matchesStaticExtensionCommand(commands, probe))
1026
1005
  return true;
1027
- if (extensionCapabilities(extension).has("search") &&
1028
- commandPathNeedsSearchExtensions(probe.commandPath)) {
1006
+ if (extensionCapabilities(extension).has("search") && commandPathNeedsSearchExtensions(probe.commandPath)) {
1029
1007
  return true;
1030
1008
  }
1031
1009
  if (extension.contributions) {
@@ -1220,7 +1198,10 @@ async function loadRuntimeExtensionSnapshot(pmRoot, probe, readSettingsFn = read
1220
1198
  loadedCount: loadResult.loaded.length,
1221
1199
  loadFailedCount: loadResult.failed.length,
1222
1200
  activationFailedCount: activationResult.failed.length,
1223
- contextIntentPackages: loadResult.loaded.map(({ name, module }) => ({ name, module })),
1201
+ contextIntentPackages: loadResult.loaded.map(({ name, module }) => ({
1202
+ name,
1203
+ module,
1204
+ })),
1224
1205
  };
1225
1206
  runtimeExtensionSnapshotCache = {
1226
1207
  key: cacheKey,
@@ -1353,9 +1334,7 @@ async function runRequiredExtensionCommand(command, options, globalOptions, exte
1353
1334
  const causeSuffix = cause ? ` ${cause}` : "";
1354
1335
  throw new PmCliError(`Command "${commandPath}" failed in extension handler (${warningCode}).${causeSuffix}`, EXIT_CODE.GENERIC_FAILURE, {
1355
1336
  code: extensionCommandResult.errorCode ?? "command_failed",
1356
- nextSteps: extensionCommandResult.remediation
1357
- ? [extensionCommandResult.remediation]
1358
- : undefined,
1337
+ nextSteps: extensionCommandResult.remediation ? [extensionCommandResult.remediation] : undefined,
1359
1338
  });
1360
1339
  }
1361
1340
  throw new PmCliError(`Command "${commandPath}" is provided by extensions and is not currently available.`, EXIT_CODE.NOT_FOUND);
@@ -1513,12 +1492,10 @@ function applyDynamicExtensionRootHelpVisibility(rootProgram, preexistingTopLeve
1513
1492
  const tierRank = { core: 0, standard: 1, full: 2, internal: 3 };
1514
1493
  const applyVisibility = (command, pathParts) => {
1515
1494
  const commandPath = pathParts.join(" ");
1516
- const matchingDescriptors = [...descriptors.entries()]
1517
- .filter(([path]) => path === commandPath || path.startsWith(`${commandPath} `))
1518
- .map(([, descriptor]) => descriptor);
1495
+ const matchingDescriptors = [...descriptors.entries()].filter(([path]) => path === commandPath || path.startsWith(`${commandPath} `)).map(([, descriptor]) => descriptor);
1519
1496
  const tier = matchingDescriptors.length === 0
1520
1497
  ? "standard"
1521
- : matchingDescriptors.reduce((selected, descriptor) => tierRank[descriptor.tier] < tierRank[selected] ? descriptor.tier : selected, "internal");
1498
+ : matchingDescriptors.reduce((selected, descriptor) => (tierRank[descriptor.tier] < tierRank[selected] ? descriptor.tier : selected), "internal");
1522
1499
  setPmCommandHelpVisibilityTier(command, tier);
1523
1500
  for (const child of command.commands) {
1524
1501
  applyVisibility(child, [...pathParts, child.name()]);
@@ -1942,7 +1919,10 @@ function resolveCoreCommandRegistrationSelection(invocationArgv) {
1942
1919
  return REGISTER_ALL_CORE_COMMAND_FAMILIES;
1943
1920
  }
1944
1921
  function shouldAttachRichHelpTextForInvocation(invocationArgv) {
1945
- return invocationArgv.length === 0 || parseBootstrapHelpRequest(invocationArgv).requested;
1922
+ return (invocationArgv.length === 0 ||
1923
+ parseBootstrapHelpRequest(invocationArgv).requested ||
1924
+ (invocationArgv.includes("--explain") &&
1925
+ parseBootstrapCommandName(invocationArgv) === undefined));
1946
1926
  }
1947
1927
  const IDEMPOTENT_TOP_LEVEL_REGISTRATION = Symbol("pmCliIdempotentTopLevelRegistration");
1948
1928
  /**
@@ -1988,9 +1968,7 @@ async function registerCoreCommandFamilies(rootProgram, selection) {
1988
1968
  }
1989
1969
  if (selection.listQuery) {
1990
1970
  const { registerListQueryCommands } = await loadListQueryRegistrationModule();
1991
- const commandFilter = typeof selection.targetCommandName === "string" && LIST_QUERY_COMMAND_NAMES.has(selection.targetCommandName)
1992
- ? new Set([selection.targetCommandName])
1993
- : undefined;
1971
+ const commandFilter = typeof selection.targetCommandName === "string" && LIST_QUERY_COMMAND_NAMES.has(selection.targetCommandName) ? new Set([selection.targetCommandName]) : undefined;
1994
1972
  registerListQueryCommands(rootProgram, commandFilter ? { commandFilter } : undefined);
1995
1973
  }
1996
1974
  if (selection.mutation) {
@@ -2008,6 +1986,9 @@ function shouldRegisterDynamicExtensionPaths(_rootProgram, invocationArgv) {
2008
1986
  if (invocationRequestsVersion(invocationArgv)) {
2009
1987
  return false;
2010
1988
  }
1989
+ if (isFullHelpDiscovery(invocationArgv)) {
1990
+ return true;
1991
+ }
2011
1992
  const helpRequest = parseBootstrapHelpRequest(invocationArgv);
2012
1993
  if (helpRequest.requested) {
2013
1994
  return true;
@@ -2046,20 +2027,12 @@ function redactSensitiveFlagTypo(params) {
2046
2027
  ? params.argv.map((token) => {
2047
2028
  const equalsIndex = token.indexOf("=");
2048
2029
  const flag = equalsIndex >= 0 ? token.slice(0, equalsIndex) : token;
2049
- return flag === rawTypoFlag
2050
- ? equalsIndex >= 0
2051
- ? `${sensitiveCanonicalFlag}${token.slice(equalsIndex)}`
2052
- : sensitiveCanonicalFlag
2053
- : token;
2030
+ return flag === rawTypoFlag ? (equalsIndex >= 0 ? `${sensitiveCanonicalFlag}${token.slice(equalsIndex)}` : sensitiveCanonicalFlag) : token;
2054
2031
  })
2055
2032
  : params.argv;
2056
2033
  const safeArgv = redactSensitiveCommandArgs(typoNormalizedArgv);
2057
- const safeTypoDisplay = sensitiveCanonicalFlag && rawTypoEqualsIndex >= 0
2058
- ? `${rawTypoFlag}=[redacted]`
2059
- : rawTypoToken;
2060
- const safeNormalizedDisplay = sensitiveCanonicalFlag && params.normalizedDisplay.includes("=")
2061
- ? `${sensitiveCanonicalFlag}=[redacted]`
2062
- : params.normalizedDisplay;
2034
+ const safeTypoDisplay = sensitiveCanonicalFlag && rawTypoEqualsIndex >= 0 ? `${rawTypoFlag}=[redacted]` : rawTypoToken;
2035
+ const safeNormalizedDisplay = sensitiveCanonicalFlag && params.normalizedDisplay.includes("=") ? `${sensitiveCanonicalFlag}=[redacted]` : params.normalizedDisplay;
2063
2036
  return {
2064
2037
  argv: safeArgv,
2065
2038
  normalizedDisplay: safeNormalizedDisplay,
@@ -2193,9 +2166,7 @@ async function handleRunPmCliKnownError(context, numericExitCode) {
2193
2166
  ? projectLeanErrorEnvelope(formatPmCliErrorForJson(errorMessage, exitCode, enrichedContext))
2194
2167
  : formatPmCliErrorForJson(errorMessage, exitCode, enrichedContext);
2195
2168
  const renderedError = context.jsonErrors
2196
- ? JSON.stringify(context.bootstrapGlobal.tokenAccounting
2197
- ? attachOutputTokenAccounting(jsonErrorPayload, (value) => `${JSON.stringify(value, null, 2)}\n`)
2198
- : jsonErrorPayload, null, 2)
2169
+ ? JSON.stringify(context.bootstrapGlobal.tokenAccounting ? attachOutputTokenAccounting(jsonErrorPayload, (value) => `${JSON.stringify(value, null, 2)}\n`) : jsonErrorPayload, null, 2)
2199
2170
  : formatPmCliErrorForDisplay(errorMessage, enrichedContext);
2200
2171
  printError(renderedError);
2201
2172
  const { errorCategory, commandResolution } = await context.emitTelemetryCommandError({
@@ -2270,7 +2241,6 @@ async function handleUnknownHelpCommandError(context, code) {
2270
2241
  error_message: classification.detail,
2271
2242
  command_resolution: commandResolution,
2272
2243
  resolution_stage: "parse",
2273
- source_context: activeTelemetryCommandContext?.source_context,
2274
2244
  });
2275
2245
  const baseRenderedUsage = context.jsonErrors
2276
2246
  ? await formatCommanderUsageJson({ message: unknownMessage }, program, recoveryCommandDescriptors, context.bootstrapGlobal.lean === true, { failedExtensions })
@@ -2463,7 +2433,13 @@ async function runPmCliInReproducibleContext(rawArgv) {
2463
2433
  if (renderedBootstrapJsonHelp) {
2464
2434
  return;
2465
2435
  }
2466
- if (isBareInvocation) {
2436
+ const helpRequest = parseBootstrapHelpRequest(invocationArgv);
2437
+ if (helpRequest.requested && !isKnownHelpCommandPath(program, helpRequest.commandPathTokens)) {
2438
+ throw new CommanderError(EXIT_CODE.USAGE, "commander.helpDisplayed", "(outputHelp)");
2439
+ }
2440
+ if (isBareInvocation ||
2441
+ (isFullHelpDiscovery(invocationArgv) &&
2442
+ parseBootstrapCommandName(invocationArgv) === undefined)) {
2467
2443
  program.outputHelp();
2468
2444
  return;
2469
2445
  }
@@ -2472,7 +2448,9 @@ async function runPmCliInReproducibleContext(rawArgv) {
2472
2448
  await runWithDiscoveredContextIntentContracts({
2473
2449
  pmRoot: resolvePmRoot(process.cwd(), bootstrapGlobal.path),
2474
2450
  packages: intentSnapshot?.contextIntentPackages,
2475
- }, () => runWithWorkspaceHarnessSignalDescriptors(invocationSettings.agent_identity.harness_signals, () => program.parseAsync(invocationProcessArgv), { probesEnabled: invocationSettings.agent_identity?.probes_enabled }));
2451
+ }, () => runWithWorkspaceHarnessSignalDescriptors(invocationSettings.agent_identity.harness_signals, () => program.parseAsync(invocationProcessArgv), {
2452
+ probesEnabled: invocationSettings.agent_identity?.probes_enabled,
2453
+ }));
2476
2454
  }
2477
2455
  catch (error) {
2478
2456
  await handleRunPmCliError({ error, invocationArgv });
@@ -2583,4 +2561,4 @@ export const _testOnly = {
2583
2561
  wrapThrownErrorForSentry,
2584
2562
  };
2585
2563
  //# sourceMappingURL=main.js.map
2586
- //# debugId=ffd55bde-cc30-529f-a6f9-ec43abe4efba
2564
+ //# debugId=f947c7f0-adf8-59da-8bc7-9cd746b05839
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="79bf0b3f-ad63-5d9f-9911-d5a142214ac1")}catch(e){}}();
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="263a15b4-5537-5e11-b0c0-3da453ee0357")}catch(e){}}();
3
3
  import { EXIT_CODE, PmCliError, } from "../sdk/runtime-primitives.js";
4
4
  import { renderPmCommand } from "../sdk/command-line.js";
5
5
  import { runComments } from "./commands/comments.js";
@@ -11,6 +11,7 @@ function assertNoTransposedAnnotationAction(collection, id, text, options) {
11
11
  return;
12
12
  }
13
13
  const suppliedText = readOptionString(options, "add") ??
14
+ readOptionString(options, "text") ??
14
15
  readOptionString(options, "note") ??
15
16
  readOptionString(options, "body") ??
16
17
  readOptionString(options, "comment");
@@ -25,12 +26,7 @@ function assertNoTransposedAnnotationAction(collection, id, text, options) {
25
26
  else
26
27
  retryArgs.push("--add", "-");
27
28
  const suggestedRetry = renderPmCommand(retryArgs);
28
- const stdinRetry = renderPmCommand([
29
- collection,
30
- text.trim(),
31
- "--add",
32
- "-",
33
- ]);
29
+ const stdinRetry = renderPmCommand([collection, text.trim(), "--add", "-"]);
34
30
  throw new PmCliError(`The positional token "add" was parsed as the item id, while "${text.trim()}" was parsed as annotation text. ${collection} does not use an add subcommand.`, EXIT_CODE.USAGE, {
35
31
  code: "annotation_transposed_subcommand",
36
32
  reason: "noun_verb_object_transposition",
@@ -47,12 +43,26 @@ function assertNoTransposedAnnotationAction(collection, id, text, options) {
47
43
  },
48
44
  });
49
45
  }
46
+ function resolveAnnotationTextAliases(label, options, aliases) {
47
+ const supplied = aliases.flatMap((alias) => {
48
+ const value = readOptionString(options, alias);
49
+ return value === undefined ? [] : [{ alias, value }];
50
+ });
51
+ const distinctValues = [...new Set(supplied.map(({ value }) => value))];
52
+ if (distinctValues.length > 1) {
53
+ throw new PmCliError(`Specify ${label} text with one alias or the same value across aliases: ${supplied.map(({ alias }) => `--${alias}`).join(", ")}`, EXIT_CODE.USAGE, { code: "annotation_alias_conflict" });
54
+ }
55
+ return supplied[0]?.value;
56
+ }
50
57
  function resolveCommentSources(text, options) {
51
58
  const editIndex = typeof options.edit === "number" ? options.edit : undefined;
52
59
  const deleteIndex = typeof options.delete === "number" ? options.delete : undefined;
53
- const addFromOption = readOptionString(options, "add") ??
54
- readOptionString(options, "body") ??
55
- readOptionString(options, "comment");
60
+ const addFromOption = resolveAnnotationTextAliases("comment", options, [
61
+ "add",
62
+ "text",
63
+ "body",
64
+ "comment",
65
+ ]);
56
66
  const addFromPositional = typeof text === "string" ? text : undefined;
57
67
  const readFromStdin = options.stdin === true;
58
68
  const readFromFile = readOptionString(options, "file");
@@ -84,14 +94,7 @@ function resolveCommentSources(text, options) {
84
94
  };
85
95
  }
86
96
  function resolveSingleTextSource(label, positional, options) {
87
- const canonicalAdd = readOptionString(options, "add");
88
- const aliasAdd = label === "note" ? readOptionString(options, "note") : undefined;
89
- if (canonicalAdd !== undefined &&
90
- aliasAdd !== undefined &&
91
- canonicalAdd !== aliasAdd) {
92
- throw new PmCliError("Specify note text with either --add or --note, not conflicting values for both aliases", EXIT_CODE.USAGE, { code: "annotation_alias_conflict" });
93
- }
94
- const addFromOption = canonicalAdd ?? aliasAdd;
97
+ const addFromOption = resolveAnnotationTextAliases(label, options, label === "note" ? ["add", "text", "note"] : ["add", "text"]);
95
98
  const addFromPositional = typeof positional === "string" ? positional : undefined;
96
99
  if (addFromOption !== undefined && addFromPositional !== undefined) {
97
100
  throw new PmCliError(`Specify ${label} text either as positional [text] or with --add, not both`, EXIT_CODE.USAGE);
@@ -205,8 +208,9 @@ export function registerAnnotationCommands(program, parsePositiveInteger) {
205
208
  .description("List, add, edit, or delete comments for an item.")
206
209
  .action(runCommentsAction);
207
210
  addHiddenOption(commentsCommand, "--body <text>", "Alias for --add", false);
211
+ addHiddenOption(commentsCommand, "--text <text>", "Alias for --add", false);
208
212
  addHiddenOption(commentsCommand, "--comment <text>", "Alias for --add", false);
209
- program
213
+ const notesCommand = program
210
214
  .command("notes")
211
215
  .argument("<id>", "Item id")
212
216
  .argument("[text]", "Optional note text shorthand (equivalent to --add; use - for stdin)")
@@ -227,7 +231,8 @@ export function registerAnnotationCommands(program, parsePositiveInteger) {
227
231
  .option("--force", "Force ownership override")
228
232
  .description("Manage merge-safe text notes and JSON context events.")
229
233
  .action(runNotesAction);
230
- program
234
+ addHiddenOption(notesCommand, "--text <text>", "Alias for --add", false);
235
+ const learningsCommand = program
231
236
  .command("learnings")
232
237
  .argument("<id>", "Item id")
233
238
  .argument("[text]", "Optional learning text shorthand (equivalent to --add; use - for stdin)")
@@ -243,6 +248,7 @@ export function registerAnnotationCommands(program, parsePositiveInteger) {
243
248
  .option("--force", "Force ownership override")
244
249
  .description("List, add, edit, or delete learnings for an item.")
245
250
  .action(runLearningsAction);
251
+ addHiddenOption(learningsCommand, "--text <text>", "Alias for --add", false);
246
252
  }
247
253
  //# sourceMappingURL=register-annotations.js.map
248
- //# debugId=79bf0b3f-ad63-5d9f-9911-d5a142214ac1
254
+ //# debugId=263a15b4-5537-5e11-b0c0-3da453ee0357