@unbrained/pm-cli 2026.8.10 → 2026.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +153 -100
- package/dist/cli/commander-usage.js +113 -15
- package/dist/cli/error-guidance.d.ts +12 -0
- package/dist/cli/error-guidance.js +147 -29
- package/dist/cli/main.js +38 -19
- package/dist/cli/register-annotations.js +56 -3
- package/dist/cli/register-assurance.d.ts +8 -0
- package/dist/cli/register-assurance.js +52 -0
- package/dist/cli/register-files-lookup.js +14 -3
- package/dist/cli/register-list-query.js +10 -7
- package/dist/cli/register-mutation.js +30 -9
- package/dist/cli/register-operations.js +30 -15
- package/dist/cli-bundle/bundle-manifest.json +155 -155
- package/dist/cli-bundle/chunks/{chunk-TRWXF476.js → chunk-3PS7X6GS.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-7KL6KMWF.js +13 -0
- package/dist/cli-bundle/chunks/{chunk-EBO7OUUE.js → chunk-BM5YJ2UW.js} +69 -55
- package/dist/cli-bundle/chunks/chunk-D55A5AEN.js +33 -0
- package/dist/cli-bundle/chunks/chunk-KIKDWECH.js +196 -0
- package/dist/cli-bundle/chunks/{chunk-ETML5C6H.js → chunk-KOQMGCTA.js} +47 -47
- package/dist/cli-bundle/chunks/chunk-R76342NV.js +2 -0
- package/dist/cli-bundle/chunks/chunk-RBTK5EZV.js +5 -0
- package/dist/cli-bundle/chunks/chunk-VLUQOIDT.js +2 -0
- package/dist/cli-bundle/chunks/chunk-WLAHPSOX.js +3 -0
- package/dist/cli-bundle/chunks/register-list-query-XPCJRUUD.js +10 -0
- package/dist/cli-bundle/chunks/register-mutation-4RJCBKRS.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-2OGISOVR.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-S3KT2LTH.js → register-setup-LLHAKP2V.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-2DALMVF7.js +5 -0
- package/dist/cli-bundle/focused-chunks/chunk-5OQIMELN.js +155 -0
- package/dist/cli-bundle/focused-chunks/chunk-5TAGTDRE.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-ECADZMVC.js +18 -0
- package/dist/cli-bundle/focused-chunks/chunk-EJGXRA6B.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-FFGSZCPK.js +16 -0
- package/dist/cli-bundle/focused-chunks/{chunk-IW43E4XL.js → chunk-GQW4BPUT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ISKOBJCM.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-75774JWP.js → chunk-JAFRIWVF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-2COZ67XT.js → chunk-KHM2CS2C.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-M6RPIXKC.js → chunk-KPSXVBDV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-34SX654S.js → chunk-KTLOKKCQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-LGYK3NUF.js +8 -0
- package/dist/cli-bundle/focused-chunks/{chunk-2EXI2DKR.js → chunk-NBLUKITQ.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-NYLOUPOB.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-Q4T463SD.js +31 -0
- package/dist/cli-bundle/focused-chunks/chunk-QVZVY53N.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-DZGAHZZV.js → chunk-RWPAWUOT.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-UTEWXDEQ.js +17 -0
- package/dist/cli-bundle/focused-chunks/{chunk-7UN6BHHO.js → chunk-YIAXMC3T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZMGWAYH7.js +2 -0
- package/dist/cli-bundle/main.js +13 -13
- package/dist/cli-bundle/sdk-authoring.js +1 -1
- package/dist/cli-bundle/sdk-contracts.js +1 -1
- package/dist/cli-bundle/sdk-core.js +41 -39
- package/dist/cli-bundle/sdk-governance.js +1 -1
- package/dist/cli-bundle/sdk-graph.js +1 -1
- package/dist/cli-bundle/sdk-merge.js +1 -1
- package/dist/cli-bundle/sdk-query.js +1 -1
- package/dist/cli-bundle/sdk-runtime.js +1 -1
- package/dist/cli-bundle/sdk-testing.js +1 -1
- package/dist/cli-bundle/sdk.js +2 -2
- package/dist/core/extensions/reserved-host-flags.js +3 -2
- package/dist/core/history/drift-scan.js +13 -8
- package/dist/core/history/history.d.ts +8 -0
- package/dist/core/history/history.js +57 -7
- package/dist/core/history/replay.d.ts +9 -1
- package/dist/core/history/replay.js +48 -13
- package/dist/core/output/output.d.ts +2 -0
- package/dist/core/output/output.js +46 -14
- package/dist/core/session/session-state.d.ts +47 -0
- package/dist/core/session/session-state.js +207 -6
- package/dist/core/shared/author.d.ts +7 -1
- package/dist/core/shared/author.js +66 -46
- package/dist/core/shared/command-types.d.ts +2 -0
- package/dist/core/shared/command-types.js +2 -2
- package/dist/core/shared/errors.d.ts +13 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/store/item-metadata-cache.d.ts +1 -1
- package/dist/core/store/item-metadata-cache.js +14 -7
- package/dist/sdk/agent/refusal-reachability.d.ts +40 -0
- package/dist/sdk/agent/refusal-reachability.js +72 -0
- package/dist/sdk/agent/subcommand-recovery.d.ts +40 -0
- package/dist/sdk/agent/subcommand-recovery.js +84 -0
- package/dist/sdk/cli-bootstrap.d.ts +10 -0
- package/dist/sdk/cli-bootstrap.js +11 -7
- package/dist/sdk/cli-contracts/completeness.js +14 -3
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts/enum-contracts.js +3 -2
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +2 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +20 -2
- package/dist/sdk/cli-contracts/registration-helpers.d.ts +20 -3
- package/dist/sdk/cli-contracts/registration-helpers.js +18 -12
- package/dist/sdk/cli-contracts/runtime-contracts.js +4 -3
- package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +515 -0
- package/dist/sdk/cli-contracts/schemas/assurance-definition.js +252 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.js +3 -2
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +99 -2
- package/dist/sdk/cli-contracts/tool-schema.d.ts +3 -3
- package/dist/sdk/cli-contracts/tool-schema.js +38 -5
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +3 -3
- package/dist/sdk/cli-program.js +3 -2
- package/dist/sdk/completion.js +23 -8
- package/dist/sdk/config.js +9 -3
- package/dist/sdk/context/semantic-session-attribution.d.ts +32 -0
- package/dist/sdk/context/semantic-session-attribution.js +83 -0
- package/dist/sdk/context-intent-contracts.js +45 -4
- package/dist/sdk/core-governance.d.ts +3 -1
- package/dist/sdk/core-governance.js +5 -3
- package/dist/sdk/core.d.ts +2 -1
- package/dist/sdk/core.js +3 -2
- package/dist/sdk/error-code-catalog.d.ts +13 -0
- package/dist/sdk/error-code-catalog.js +35 -2
- package/dist/sdk/extension.js +18 -17
- package/dist/sdk/files.d.ts +11 -0
- package/dist/sdk/files.js +82 -24
- package/dist/sdk/generated/generated-error-code-catalog-part-1.d.ts +8 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +1585 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-2.d.ts +8 -0
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +1608 -0
- package/dist/sdk/generated-error-code-catalog.js +6 -3121
- package/dist/sdk/governance/assurance-action-contracts.d.ts +7 -0
- package/dist/sdk/governance/assurance-action-contracts.js +5 -0
- package/dist/sdk/governance/assurance-action.d.ts +70 -0
- package/dist/sdk/governance/assurance-action.js +200 -0
- package/dist/sdk/governance/assurance-limits.d.ts +7 -0
- package/dist/sdk/governance/assurance-limits.js +11 -0
- package/dist/sdk/governance/assurance-mutation-error.d.ts +7 -0
- package/dist/sdk/governance/assurance-mutation-error.js +35 -0
- package/dist/sdk/governance/assurance-runtime.d.ts +20 -0
- package/dist/sdk/governance/assurance-runtime.js +134 -0
- package/dist/sdk/governance/assurance.d.ts +438 -0
- package/dist/sdk/governance/assurance.js +804 -0
- package/dist/sdk/governance/health.d.ts +3 -1
- package/dist/sdk/governance/health.js +21 -4
- package/dist/sdk/governance/validate-item-reader.js +3 -3
- package/dist/sdk/governance/validate.d.ts +2 -0
- package/dist/sdk/governance/validate.js +13 -3
- package/dist/sdk/graph/durable-cache.d.ts +1 -1
- package/dist/sdk/graph/durable-cache.js +98 -29
- package/dist/sdk/graph/governance.d.ts +14 -0
- package/dist/sdk/graph/governance.js +34 -9
- package/dist/sdk/graph/run.js +8 -3
- package/dist/sdk/index.d.ts +7 -2
- package/dist/sdk/index.js +9 -4
- package/dist/sdk/lifecycle/claim.js +26 -4
- package/dist/sdk/lifecycle/focus.js +13 -3
- package/dist/sdk/lifecycle/plan.js +8 -3
- package/dist/sdk/merge/driver.d.ts +2 -2
- package/dist/sdk/merge/driver.js +3 -3
- package/dist/sdk/merge/receipts.d.ts +6 -4
- package/dist/sdk/merge/receipts.js +7 -5
- package/dist/sdk/merge/three-way.d.ts +2 -2
- package/dist/sdk/merge/three-way.js +3 -3
- package/dist/sdk/output-projection.d.ts +9 -1
- package/dist/sdk/output-projection.js +45 -9
- package/dist/sdk/provenance.d.ts +38 -0
- package/dist/sdk/provenance.js +64 -2
- package/dist/sdk/query/activity.d.ts +49 -2
- package/dist/sdk/query/activity.js +183 -37
- package/dist/sdk/query/context.js +19 -8
- package/dist/sdk/query/get.js +19 -2
- package/dist/sdk/read-output-contracts.d.ts +5 -1
- package/dist/sdk/read-output-contracts.js +17 -2
- package/dist/sdk/read-output-session.d.ts +2 -0
- package/dist/sdk/read-output-session.js +12 -5
- package/dist/sdk/runtime-extended-actions.js +22 -5
- package/dist/sdk/runtime-primitives.d.ts +5 -3
- package/dist/sdk/runtime-primitives.js +7 -5
- package/dist/sdk/runtime-stats-options.js +3 -2
- package/dist/sdk/runtime.d.ts +4 -0
- package/dist/sdk/runtime.js +34 -34
- package/dist/sdk/stats.d.ts +36 -3
- package/dist/sdk/stats.js +55 -15
- package/dist/sdk/telemetry.js +7 -4
- package/dist/sdk/test/execution.d.ts +4 -0
- package/dist/sdk/test/execution.js +86 -21
- package/dist/sdk/traceability/runtime-files-lookup.d.ts +8 -0
- package/dist/sdk/traceability/runtime-files-lookup.js +33 -0
- package/dist/sdk/traceability/source-traceability.d.ts +102 -0
- package/dist/sdk/traceability/source-traceability.js +293 -0
- package/dist/types.d.ts +10 -2
- package/dist/types.js +2 -2
- package/docs/ASSURANCE.md +137 -0
- package/docs/COMMANDS.md +29 -8
- package/docs/CONFIGURATION.md +7 -0
- package/docs/DEPENDENCY_KIND_CONTRACT.md +10 -8
- package/docs/MERGE_SAFETY.md +3 -1
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +26 -13
- package/docs/README.md +3 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +17 -2
- package/docs/RELEASING.md +9 -5
- package/docs/SDK.md +12 -1
- package/docs/SDK_AGENT_SESSION_CONTEXT.md +52 -5
- package/docs/SDK_CONTEXT_EVIDENCE_CONTRACTS.md +53 -0
- package/docs/SDK_CONTEXT_INTEGRITY.md +28 -1
- package/docs/SDK_EVIDENCE_TRACEABILITY.md +39 -1
- package/docs/SDK_RUNTIME_BOUNDARIES.md +36 -1
- package/docs/TESTING.md +12 -9
- package/docs/TRUSTWORTHY_CONTEXT_EVIDENCE.md +106 -0
- package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -0
- package/docs/performance/sdk-entrypoint-import-costs.md +6 -2
- package/marketplace.json +2 -2
- package/package.json +7 -7
- package/packages/pm-beads/package.json +1 -1
- package/packages/pm-calendar/package.json +1 -1
- package/packages/pm-command-kit/package.json +1 -1
- package/packages/pm-digital-twin/package.json +1 -1
- package/packages/pm-governance-audit/package.json +1 -1
- package/packages/pm-guide-shell/package.json +1 -1
- package/packages/pm-kanban/package.json +1 -1
- package/packages/pm-lifecycle-hooks/package.json +1 -1
- package/packages/pm-linked-test-adapters/package.json +1 -1
- package/packages/pm-search-advanced/package.json +1 -1
- package/packages/pm-templates/extensions/templates/index.ts +9 -3
- package/packages/pm-templates/package.json +1 -1
- package/packages/pm-todos/package.json +1 -1
- package/packages/pm-vcs/package.json +1 -1
- package/plugins/pm-claude/.claude-plugin/plugin.json +1 -1
- package/plugins/pm-codex/.codex-plugin/plugin.json +1 -1
- package/sdk/public-surface.json +1030 -67
- package/dist/cli-bundle/chunks/chunk-2QYH4QMI.js +0 -30
- package/dist/cli-bundle/chunks/chunk-JUDU4RO4.js +0 -194
- package/dist/cli-bundle/chunks/chunk-JZSNADRR.js +0 -5
- package/dist/cli-bundle/chunks/chunk-MENWVGJW.js +0 -2
- package/dist/cli-bundle/chunks/chunk-S4EITGLA.js +0 -3
- package/dist/cli-bundle/chunks/chunk-TIGKWVLA.js +0 -13
- package/dist/cli-bundle/chunks/chunk-TSLDTJLQ.js +0 -2
- package/dist/cli-bundle/chunks/register-list-query-OJ6ZXKV4.js +0 -10
- package/dist/cli-bundle/chunks/register-mutation-DKI7QC7O.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-P5OGMT6I.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-36FTZ2NT.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3CQECMKR.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-CHIBMEZR.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-FF4MNAYB.js +0 -153
- package/dist/cli-bundle/focused-chunks/chunk-GHTN2ILR.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-I4YM2I7S.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-IMDTEN7K.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-JMVA4HKR.js +0 -5
- package/dist/cli-bundle/focused-chunks/chunk-KR5RVXLQ.js +0 -31
- package/dist/cli-bundle/focused-chunks/chunk-KSNJG4KI.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-MXYSIQ56.js +0 -18
- package/dist/cli-bundle/focused-chunks/chunk-RIIN5V4N.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-RKWSCYYN.js +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
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]="
|
|
3
|
-
import { pathExists, resolveItemTypeRegistry, EXIT_CODE, getSettingsPath, resolvePmRoot, readSettings, getActiveExtensionRegistrations, runActiveServiceOverride, levenshteinDistanceWithinLimit, } from "../sdk/runtime-primitives.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]="05cf369c-7529-57ab-984a-f5505cc9c0c9")}catch(e){}}();
|
|
3
|
+
import { pathExists, resolveItemTypeRegistry, EXIT_CODE, getSettingsPath, resolvePmRoot, readSettings, getActiveExtensionRegistrations, locateItem, runActiveServiceOverride, levenshteinDistanceWithinLimit, } from "../sdk/runtime-primitives.js";
|
|
4
4
|
import { BUILTIN_ITEM_TYPE_VALUES } from "../types/index.js";
|
|
5
5
|
import { PM_CORE_COMMAND_NAMES, resolveSubcommandFlagContractsForCommand, } from "../sdk/cli-contracts.js";
|
|
6
6
|
import { formatCommanderErrorForDisplay, formatCommanderErrorForJson, projectLeanErrorEnvelope, } from "./error-guidance.js";
|
|
7
7
|
import { normalizeHelpCommandPath } from "./help-content.js";
|
|
8
8
|
import { getCommandPath } from "./registration-helpers.js";
|
|
9
|
-
import { EXECUTABLE_COMMAND_ALIASES, normalizeBootstrapInvocation, parseBootstrapHelpRequest, parseBootstrapGlobalOptions, parseBootstrapCommandName, } from "./bootstrap-args.js";
|
|
9
|
+
import { EXECUTABLE_COMMAND_ALIASES, findBootstrapCommandTokenIndex, normalizeBootstrapInvocation, parseBootstrapHelpRequest, parseBootstrapGlobalOptions, parseBootstrapCommandName, } from "./bootstrap-args.js";
|
|
10
10
|
import { extractProvidedOptionFlags, normalizeLongFlag, renderPmCommand, } from "./argv-utils.js";
|
|
11
11
|
import { normalizeExtensionNameForMatch } from "./commands/extension/shared.js";
|
|
12
12
|
import { rankCommandPaths } from "../sdk/agent/command-suggestions.js";
|
|
@@ -54,6 +54,23 @@ const SEMANTIC_UNKNOWN_OPTION_SUGGESTIONS = {
|
|
|
54
54
|
"--tag": ["--tags"],
|
|
55
55
|
},
|
|
56
56
|
};
|
|
57
|
+
const SCHEMA_SUBCOMMAND_VALUES = [
|
|
58
|
+
"add-field",
|
|
59
|
+
"add-status",
|
|
60
|
+
"add-type",
|
|
61
|
+
"apply-preset",
|
|
62
|
+
"list",
|
|
63
|
+
"list-fields",
|
|
64
|
+
"remap-status",
|
|
65
|
+
"remove-field",
|
|
66
|
+
"remove-status",
|
|
67
|
+
"remove-type",
|
|
68
|
+
"rename-field",
|
|
69
|
+
"rename-type",
|
|
70
|
+
"show",
|
|
71
|
+
"show-field",
|
|
72
|
+
"show-status",
|
|
73
|
+
];
|
|
57
74
|
function getSemanticUnknownOptionSuggestions(commandName, unknownOption) {
|
|
58
75
|
const commandSuggestions = SEMANTIC_UNKNOWN_OPTION_SUGGESTIONS[commandName];
|
|
59
76
|
if (!commandSuggestions) {
|
|
@@ -335,9 +352,17 @@ function findOtherCommandsForFlag(unknownOption, currentCommand) {
|
|
|
335
352
|
return [];
|
|
336
353
|
}
|
|
337
354
|
const normalizedCurrent = currentCommand?.trim().toLowerCase();
|
|
355
|
+
const currentFlags = new Set(collectKnownLongFlags(normalizedCurrent));
|
|
338
356
|
return commands
|
|
339
357
|
.filter((command) => command !== normalizedCurrent)
|
|
340
|
-
.
|
|
358
|
+
.map((command) => ({
|
|
359
|
+
command,
|
|
360
|
+
sharedFlagCount: collectKnownLongFlags(command).filter((flag) => currentFlags.has(flag)).length,
|
|
361
|
+
}))
|
|
362
|
+
.sort((left, right) => left.sharedFlagCount !== right.sharedFlagCount
|
|
363
|
+
? right.sharedFlagCount - left.sharedFlagCount
|
|
364
|
+
: left.command.localeCompare(right.command))
|
|
365
|
+
.map(({ command }) => command);
|
|
341
366
|
}
|
|
342
367
|
function rewriteUnknownOptionArgv(argv, unknownOption, replacementFlag) {
|
|
343
368
|
for (let index = 0; index < argv.length; index += 1) {
|
|
@@ -511,24 +536,46 @@ export function isKnownHelpCommandPath(root, commandPathTokens) {
|
|
|
511
536
|
}
|
|
512
537
|
return matchedAny;
|
|
513
538
|
}
|
|
514
|
-
async function
|
|
539
|
+
async function resolveWorkspaceUsageContext(bootstrapGlobal, message, invocationArgv, commandName) {
|
|
515
540
|
try {
|
|
516
541
|
const pmRoot = resolvePmRoot(process.cwd(), bootstrapGlobal.path);
|
|
517
542
|
if (!(await pathExists(getSettingsPath(pmRoot)))) {
|
|
518
|
-
return BUILTIN_TYPE_HELP_VALUES;
|
|
543
|
+
return { allowedTypes: BUILTIN_TYPE_HELP_VALUES };
|
|
519
544
|
}
|
|
520
545
|
const settings = await readSettings(pmRoot);
|
|
521
546
|
const extensionRegistrations = bootstrapGlobal.noExtensions
|
|
522
547
|
? undefined
|
|
523
548
|
: getActiveExtensionRegistrations();
|
|
524
549
|
const typeRegistry = resolveItemTypeRegistry(settings, extensionRegistrations);
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
550
|
+
let verifiedCollectionItemId;
|
|
551
|
+
if (/too many arguments/i.test(message) &&
|
|
552
|
+
["comments", "docs", "files", "learnings", "notes", "test"].includes(commandName ?? "")) {
|
|
553
|
+
const commandIndex = invocationArgv.findIndex((token) => token === commandName);
|
|
554
|
+
const candidate = invocationArgv[commandIndex + 2];
|
|
555
|
+
if (invocationArgv[commandIndex + 1]?.toLowerCase() === "add" &&
|
|
556
|
+
candidate !== undefined &&
|
|
557
|
+
!candidate.startsWith("-")) {
|
|
558
|
+
try {
|
|
559
|
+
verifiedCollectionItemId = (await locateItem(pmRoot, candidate, settings.id_prefix, settings.item_format, typeRegistry.type_to_folder))?.id;
|
|
560
|
+
}
|
|
561
|
+
catch {
|
|
562
|
+
// Usage rendering remains available when tracker storage is unreadable.
|
|
563
|
+
}
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
return {
|
|
567
|
+
allowedTypes: typeRegistry.types.length > 0
|
|
568
|
+
? typeRegistry.types.join("|")
|
|
569
|
+
: BUILTIN_TYPE_HELP_VALUES,
|
|
570
|
+
pmRoot,
|
|
571
|
+
settings,
|
|
572
|
+
typeToFolder: typeRegistry.type_to_folder,
|
|
573
|
+
verifiedCollectionItemId,
|
|
574
|
+
};
|
|
528
575
|
}
|
|
529
576
|
catch {
|
|
530
577
|
/* v8 ignore start -- defensive fallback for corrupted settings during usage-error rendering; command behavior is covered through normal settings paths */
|
|
531
|
-
return BUILTIN_TYPE_HELP_VALUES;
|
|
578
|
+
return { allowedTypes: BUILTIN_TYPE_HELP_VALUES };
|
|
532
579
|
/* v8 ignore stop */
|
|
533
580
|
}
|
|
534
581
|
}
|
|
@@ -571,6 +618,35 @@ function resolveSuggestedRetryForMissingOption(message, invocationArgv) {
|
|
|
571
618
|
requiredOptionToken,
|
|
572
619
|
]);
|
|
573
620
|
}
|
|
621
|
+
function resolveSplitSchemaSubcommand(message, invocationArgv) {
|
|
622
|
+
if (!/too many arguments/i.test(message)) {
|
|
623
|
+
return undefined;
|
|
624
|
+
}
|
|
625
|
+
if (parseBootstrapCommandName(invocationArgv) !== "schema") {
|
|
626
|
+
return undefined;
|
|
627
|
+
}
|
|
628
|
+
const schemaIndex = findBootstrapCommandTokenIndex(invocationArgv);
|
|
629
|
+
const verb = invocationArgv[schemaIndex + 1]?.trim().toLowerCase();
|
|
630
|
+
const noun = invocationArgv[schemaIndex + 2]?.trim().toLowerCase();
|
|
631
|
+
if (!verb || !noun) {
|
|
632
|
+
return undefined;
|
|
633
|
+
}
|
|
634
|
+
const joined = `${verb}-${noun}`;
|
|
635
|
+
if (!SCHEMA_SUBCOMMAND_VALUES.includes(joined)) {
|
|
636
|
+
return undefined;
|
|
637
|
+
}
|
|
638
|
+
const rewritten = [
|
|
639
|
+
...invocationArgv.slice(0, schemaIndex + 1),
|
|
640
|
+
joined,
|
|
641
|
+
...invocationArgv.slice(schemaIndex + 3),
|
|
642
|
+
];
|
|
643
|
+
return {
|
|
644
|
+
unknownSubcommandPath: "schema",
|
|
645
|
+
unknownSubcommandToken: `${verb} ${noun}`,
|
|
646
|
+
unknownSubcommandAllowedValues: [...SCHEMA_SUBCOMMAND_VALUES],
|
|
647
|
+
suggestedRetryCommand: renderAttemptedCommand(rewritten),
|
|
648
|
+
};
|
|
649
|
+
}
|
|
574
650
|
/** Implements resolve commander usage context for the public runtime surface of this module. */
|
|
575
651
|
export async function resolveCommanderUsageContext(error, rootProgram, extensionDescriptors, guidanceOverrides = {}) {
|
|
576
652
|
const rawMessage = typeof error === "object" && error !== null
|
|
@@ -582,10 +658,14 @@ export async function resolveCommanderUsageContext(error, rootProgram, extension
|
|
|
582
658
|
const commandName = parseBootstrapCommandName(invocationArgv);
|
|
583
659
|
const attemptedCommand = renderAttemptedCommand(invocationArgv);
|
|
584
660
|
const providedOptionFlags = extractProvidedOptionFlags(invocationArgv);
|
|
585
|
-
const
|
|
661
|
+
const workspaceUsage = await resolveWorkspaceUsageContext(bootstrapGlobal, message, invocationArgv, commandName);
|
|
662
|
+
const allowedTypes = workspaceUsage.allowedTypes;
|
|
586
663
|
const unknownCommandGuidance = buildUnknownCommandGuidanceFromRuntime(message, rootProgram, extensionDescriptors);
|
|
587
664
|
const unknownOption = resolveUnknownOptionSuggestions(message, commandName);
|
|
588
|
-
const
|
|
665
|
+
const splitSchemaSubcommand = resolveSplitSchemaSubcommand(message, invocationArgv);
|
|
666
|
+
const suggestedRetryCommand = splitSchemaSubcommand?.suggestedRetryCommand ??
|
|
667
|
+
resolveSuggestedRetryForUnknownOption(invocationArgv, unknownOption.match, unknownOption.suggestions) ??
|
|
668
|
+
resolveSuggestedRetryForMissingOption(message, invocationArgv);
|
|
589
669
|
return {
|
|
590
670
|
message,
|
|
591
671
|
commandName,
|
|
@@ -595,9 +675,15 @@ export async function resolveCommanderUsageContext(error, rootProgram, extension
|
|
|
595
675
|
providedOptionFlags,
|
|
596
676
|
unknownOptionSuggestions: unknownOption.suggestions,
|
|
597
677
|
unknownOptionOtherCommands: unknownOption.otherCommands.length > 0
|
|
598
|
-
? unknownOption.otherCommands
|
|
678
|
+
? unknownOption.otherCommands.slice(0, 12)
|
|
679
|
+
: undefined,
|
|
680
|
+
unknownOptionOtherCommandsTotal: unknownOption.otherCommands.length > 0
|
|
681
|
+
? unknownOption.otherCommands.length
|
|
599
682
|
: undefined,
|
|
683
|
+
unknownOptionOtherCommandsTruncated: unknownOption.otherCommands.length > 12 || undefined,
|
|
600
684
|
suggestedRetryCommand,
|
|
685
|
+
verifiedCollectionItemId: workspaceUsage.verifiedCollectionItemId,
|
|
686
|
+
...splitSchemaSubcommand,
|
|
601
687
|
...unknownCommandGuidance,
|
|
602
688
|
...guidanceOverrides,
|
|
603
689
|
};
|
|
@@ -605,7 +691,7 @@ export async function resolveCommanderUsageContext(error, rootProgram, extension
|
|
|
605
691
|
/** Implements format commander usage message for the public runtime surface of this module. */
|
|
606
692
|
export async function formatCommanderUsageMessage(error, rootProgram, extensionDescriptors, guidanceOverrides = {}) {
|
|
607
693
|
const usageContext = await resolveCommanderUsageContext(error, rootProgram, extensionDescriptors, guidanceOverrides);
|
|
608
|
-
const { message, commandName, allowedTypes, unknownCommandExamples, unknownCommandNextSteps, attemptedCommand, normalizedInvocationArgs, providedOptionFlags, unknownOptionSuggestions, unknownOptionOtherCommands, suggestedRetryCommand, failedExtensions, } = usageContext;
|
|
694
|
+
const { message, commandName, allowedTypes, unknownCommandExamples, unknownCommandNextSteps, attemptedCommand, normalizedInvocationArgs, providedOptionFlags, unknownOptionSuggestions, unknownOptionOtherCommands, unknownOptionOtherCommandsTotal, unknownOptionOtherCommandsTruncated, unknownSubcommandPath, unknownSubcommandToken, unknownSubcommandAllowedValues, suggestedRetryCommand, verifiedCollectionItemId, failedExtensions, } = usageContext;
|
|
609
695
|
const formatted = formatCommanderErrorForDisplay(message, commandName, allowedTypes, {
|
|
610
696
|
unknownCommandExamples,
|
|
611
697
|
unknownCommandNextSteps,
|
|
@@ -614,7 +700,13 @@ export async function formatCommanderUsageMessage(error, rootProgram, extensionD
|
|
|
614
700
|
providedOptionFlags,
|
|
615
701
|
unknownOptionSuggestions,
|
|
616
702
|
unknownOptionOtherCommands,
|
|
703
|
+
unknownOptionOtherCommandsTotal,
|
|
704
|
+
unknownOptionOtherCommandsTruncated,
|
|
705
|
+
unknownSubcommandPath,
|
|
706
|
+
unknownSubcommandToken,
|
|
707
|
+
unknownSubcommandAllowedValues,
|
|
617
708
|
suggestedRetryCommand,
|
|
709
|
+
verifiedCollectionItemId,
|
|
618
710
|
failedExtensions,
|
|
619
711
|
});
|
|
620
712
|
const serviceOverride = await runActiveServiceOverride("help_format", {
|
|
@@ -638,7 +730,13 @@ export async function formatCommanderUsageJson(error, rootProgram, extensionDesc
|
|
|
638
730
|
providedOptionFlags: usageContext.providedOptionFlags,
|
|
639
731
|
unknownOptionSuggestions: usageContext.unknownOptionSuggestions,
|
|
640
732
|
unknownOptionOtherCommands: usageContext.unknownOptionOtherCommands,
|
|
733
|
+
unknownOptionOtherCommandsTotal: usageContext.unknownOptionOtherCommandsTotal,
|
|
734
|
+
unknownOptionOtherCommandsTruncated: usageContext.unknownOptionOtherCommandsTruncated,
|
|
735
|
+
unknownSubcommandPath: usageContext.unknownSubcommandPath,
|
|
736
|
+
unknownSubcommandToken: usageContext.unknownSubcommandToken,
|
|
737
|
+
unknownSubcommandAllowedValues: usageContext.unknownSubcommandAllowedValues,
|
|
641
738
|
suggestedRetryCommand: usageContext.suggestedRetryCommand,
|
|
739
|
+
verifiedCollectionItemId: usageContext.verifiedCollectionItemId,
|
|
642
740
|
failedExtensions: usageContext.failedExtensions,
|
|
643
741
|
});
|
|
644
742
|
return JSON.stringify(lean ? projectLeanErrorEnvelope(envelope) : envelope, null, 2);
|
|
@@ -652,4 +750,4 @@ export const _testOnly = {
|
|
|
652
750
|
suggestNearestLongFlags,
|
|
653
751
|
};
|
|
654
752
|
//# sourceMappingURL=commander-usage.js.map
|
|
655
|
-
//# debugId=
|
|
753
|
+
//# debugId=05cf369c-7529-57ab-984a-f5505cc9c0c9
|
|
@@ -77,8 +77,20 @@ export interface CommanderGuidanceContext {
|
|
|
77
77
|
unknownOptionSuggestions?: string[];
|
|
78
78
|
/** Value that configures or reports unknown option other commands for this contract. */
|
|
79
79
|
unknownOptionOtherCommands?: string[];
|
|
80
|
+
/** Complete number of commands accepting the unknown option. */
|
|
81
|
+
unknownOptionOtherCommandsTotal?: number;
|
|
82
|
+
/** Whether the structured command candidates reached their own ceiling. */
|
|
83
|
+
unknownOptionOtherCommandsTruncated?: boolean;
|
|
84
|
+
/** Command family whose positional subcommand was split into invalid tokens. */
|
|
85
|
+
unknownSubcommandPath?: string;
|
|
86
|
+
/** Rejected positional subcommand token or token sequence. */
|
|
87
|
+
unknownSubcommandToken?: string;
|
|
88
|
+
/** Complete declared subcommand vocabulary for the command family. */
|
|
89
|
+
unknownSubcommandAllowedValues?: string[];
|
|
80
90
|
/** Value that configures or reports suggested retry command for this contract. */
|
|
81
91
|
suggestedRetryCommand?: string;
|
|
92
|
+
/** Existing item id verified against the selected tracker for collection recovery. */
|
|
93
|
+
verifiedCollectionItemId?: string;
|
|
82
94
|
/** Installed extensions whose activation failed for this invocation. */
|
|
83
95
|
failedExtensions?: Array<{
|
|
84
96
|
name: string;
|
|
@@ -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]="
|
|
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]="0203943b-16ea-5c3a-a2d3-56a0c4d2848f")}catch(e){}}();
|
|
3
3
|
import { renderPmCommand } from "./argv-utils.js";
|
|
4
4
|
import { discoverNearbyPmRoot } from "../sdk/tracker-root-discovery.js";
|
|
5
5
|
/** Compact an error envelope to fields that change the caller's next action. */
|
|
@@ -125,7 +125,21 @@ function assignRecoveryString(normalized, key, value) {
|
|
|
125
125
|
normalized[key] = value.trim();
|
|
126
126
|
}
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function assignRecoveryCollection(normalized, key, value) {
|
|
129
|
+
if (key === "parsed_positionals") {
|
|
130
|
+
if (!Array.isArray(value))
|
|
131
|
+
return;
|
|
132
|
+
const parsedPositionals = value
|
|
133
|
+
.map((entry) => ({
|
|
134
|
+
role: typeof entry?.role === "string" ? entry.role.trim() : "",
|
|
135
|
+
value: typeof entry?.value === "string" ? entry.value.trim() : "",
|
|
136
|
+
}))
|
|
137
|
+
.filter((entry) => entry.role.length > 0 && entry.value.length > 0);
|
|
138
|
+
if (parsedPositionals.length > 0) {
|
|
139
|
+
normalized.parsed_positionals = parsedPositionals;
|
|
140
|
+
}
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
129
143
|
const values = normalizeStringArray(value);
|
|
130
144
|
if (values) {
|
|
131
145
|
normalized[key] = values;
|
|
@@ -140,11 +154,22 @@ function normalizeRecoveryPayload(payload) {
|
|
|
140
154
|
normalized.recovery_mode = "compact";
|
|
141
155
|
}
|
|
142
156
|
assignRecoveryString(normalized, "attempted_command", payload.attempted_command);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
157
|
+
assignRecoveryCollection(normalized, "normalized_args", payload.normalized_args);
|
|
158
|
+
assignRecoveryCollection(normalized, "parsed_positionals", payload.parsed_positionals);
|
|
159
|
+
assignRecoveryCollection(normalized, "provided_fields", payload.provided_fields);
|
|
160
|
+
assignRecoveryCollection(normalized, "missing", payload.missing);
|
|
161
|
+
assignRecoveryCollection(normalized, "missing_required_fields", payload.missing_required_fields);
|
|
162
|
+
assignRecoveryCollection(normalized, "suggested_flags", payload.suggested_flags);
|
|
163
|
+
assignRecoveryCollection(normalized, "allowed_values", payload.allowed_values);
|
|
164
|
+
assignRecoveryCollection(normalized, "candidate_commands", payload.candidate_commands);
|
|
165
|
+
if (typeof payload.candidate_commands_total === "number" &&
|
|
166
|
+
Number.isSafeInteger(payload.candidate_commands_total) &&
|
|
167
|
+
payload.candidate_commands_total >= 0) {
|
|
168
|
+
normalized.candidate_commands_total = payload.candidate_commands_total;
|
|
169
|
+
}
|
|
170
|
+
if (payload.candidate_commands_truncated === true) {
|
|
171
|
+
normalized.candidate_commands_truncated = true;
|
|
172
|
+
}
|
|
148
173
|
assignRecoveryString(normalized, "suggested_retry", payload.suggested_retry);
|
|
149
174
|
if (typeof payload.retry_after_ms === "number" &&
|
|
150
175
|
Number.isSafeInteger(payload.retry_after_ms) &&
|
|
@@ -176,10 +201,25 @@ function renderRecoveryBundle(recovery) {
|
|
|
176
201
|
const lines = ["Recovery bundle:"];
|
|
177
202
|
appendRecoveryTextLine(lines, "attempted_command", normalized.attempted_command);
|
|
178
203
|
appendRecoveryListLine(lines, "normalized_args", normalized.normalized_args, " ");
|
|
204
|
+
if (normalized.parsed_positionals &&
|
|
205
|
+
normalized.parsed_positionals.length > 0) {
|
|
206
|
+
lines.push(" parsed_positionals:");
|
|
207
|
+
for (const positional of normalized.parsed_positionals) {
|
|
208
|
+
lines.push(` - ${positional.role}: ${positional.value}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
179
211
|
appendRecoveryListLine(lines, "provided_fields", normalized.provided_fields, ", ");
|
|
180
212
|
appendRecoveryListLine(lines, "missing", normalized.missing, ", ");
|
|
181
213
|
appendRecoveryListLine(lines, "missing_required_fields", normalized.missing_required_fields, ", ");
|
|
182
214
|
appendRecoveryListLine(lines, "suggested_flags", normalized.suggested_flags, ", ");
|
|
215
|
+
appendRecoveryListLine(lines, "allowed_values", normalized.allowed_values, ", ");
|
|
216
|
+
appendRecoveryListLine(lines, "candidate_commands", normalized.candidate_commands, ", ");
|
|
217
|
+
if (typeof normalized.candidate_commands_total === "number") {
|
|
218
|
+
lines.push(` candidate_commands_total: ${String(normalized.candidate_commands_total)}`);
|
|
219
|
+
}
|
|
220
|
+
if (normalized.candidate_commands_truncated === true) {
|
|
221
|
+
lines.push(" candidate_commands_truncated: true");
|
|
222
|
+
}
|
|
183
223
|
appendRecoveryTextLine(lines, "suggested_retry", normalized.suggested_retry);
|
|
184
224
|
if (typeof normalized.retry_after_ms === "number") {
|
|
185
225
|
lines.push(` retry_after_ms: ${normalized.retry_after_ms}`);
|
|
@@ -471,9 +511,7 @@ function buildLockConflictGuidance(rawMessage, message, context) {
|
|
|
471
511
|
happened: message,
|
|
472
512
|
required: "Wait for lock release, or use --force where supported if lock is stale and safe to override.",
|
|
473
513
|
why: "Locking protects item files from concurrent write races.",
|
|
474
|
-
examples: [
|
|
475
|
-
"pm update pm-a1b2 --status in_progress --force",
|
|
476
|
-
],
|
|
514
|
+
examples: ["pm update pm-a1b2 --status in_progress --force"],
|
|
477
515
|
}), rawMessage, context);
|
|
478
516
|
}
|
|
479
517
|
function buildPmMissingRequiredOptionGuidance(rawMessage, message, context) {
|
|
@@ -797,32 +835,38 @@ function buildUnknownOptionGuidance(message, commandName, context) {
|
|
|
797
835
|
if (!unknownOption) {
|
|
798
836
|
return null;
|
|
799
837
|
}
|
|
838
|
+
const guidanceContext = context ?? {};
|
|
800
839
|
const optionName = unknownOption[1];
|
|
801
|
-
const suggestions = normalizeOptionFlags(
|
|
802
|
-
const retryCommand =
|
|
840
|
+
const suggestions = normalizeOptionFlags(guidanceContext.unknownOptionSuggestions) ?? [];
|
|
841
|
+
const retryCommand = guidanceContext.suggestedRetryCommand;
|
|
803
842
|
if (commandName === "update" &&
|
|
804
843
|
(optionName === "--file" || optionName === "--doc")) {
|
|
805
844
|
return buildUnsupportedUpdateOptionGuidance(optionName, context, suggestions);
|
|
806
845
|
}
|
|
807
|
-
const otherCommands = normalizeContextList(
|
|
846
|
+
const otherCommands = normalizeContextList(guidanceContext.unknownOptionOtherCommands) ?? [];
|
|
847
|
+
const candidateTotal = guidanceContext.unknownOptionOtherCommandsTotal ?? otherCommands.length;
|
|
848
|
+
const proseCommands = otherCommands.slice(0, 3);
|
|
849
|
+
const proseRemainder = candidateTotal - proseCommands.length;
|
|
850
|
+
let proseRemainderText = "";
|
|
851
|
+
if (proseRemainder > 0) {
|
|
852
|
+
proseRemainderText = ` and ${String(proseRemainder)} more command path(s)`;
|
|
853
|
+
}
|
|
808
854
|
const nextSteps = [
|
|
809
855
|
"Run command help to confirm the exact option contracts for this command path.",
|
|
810
|
-
|
|
811
|
-
?
|
|
812
|
-
:
|
|
813
|
-
|
|
814
|
-
?
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
:
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
: []),
|
|
821
|
-
];
|
|
856
|
+
suggestions.length
|
|
857
|
+
? `Nearest supported options: ${suggestions.join(", ")}`
|
|
858
|
+
: undefined,
|
|
859
|
+
proseCommands.length
|
|
860
|
+
? `${optionName} is accepted by ${proseCommands.join(", ")}${proseRemainderText}. Inspect those command contracts only if you intended a different operation.`
|
|
861
|
+
: undefined,
|
|
862
|
+
retryCommand
|
|
863
|
+
? `Replay with suggested correction: ${retryCommand}`
|
|
864
|
+
: undefined,
|
|
865
|
+
].filter((entry) => typeof entry === "string");
|
|
822
866
|
const examples = [
|
|
823
|
-
|
|
867
|
+
retryCommand,
|
|
824
868
|
`pm ${commandName ?? "<command>"} --help`,
|
|
825
|
-
];
|
|
869
|
+
].filter((entry) => typeof entry === "string");
|
|
826
870
|
return makeGuidanceMessage({
|
|
827
871
|
code: "unknown_option",
|
|
828
872
|
title: `Unknown option ${optionName}`,
|
|
@@ -832,7 +876,10 @@ function buildUnknownOptionGuidance(message, commandName, context) {
|
|
|
832
876
|
examples,
|
|
833
877
|
nextSteps,
|
|
834
878
|
recovery: buildCommanderRecoveryPayload(context, {
|
|
835
|
-
suggested_flags: suggestions,
|
|
879
|
+
suggested_flags: suggestions.length > 0 ? suggestions : undefined,
|
|
880
|
+
candidate_commands: otherCommands,
|
|
881
|
+
candidate_commands_total: candidateTotal || undefined,
|
|
882
|
+
candidate_commands_truncated: guidanceContext.unknownOptionOtherCommandsTruncated,
|
|
836
883
|
}),
|
|
837
884
|
});
|
|
838
885
|
}
|
|
@@ -884,6 +931,33 @@ function buildUnknownCommandGuidance(message, context) {
|
|
|
884
931
|
recovery: buildCommanderRecoveryPayload(context),
|
|
885
932
|
});
|
|
886
933
|
}
|
|
934
|
+
function buildUnknownSubcommandGuidance(context) {
|
|
935
|
+
const commandPath = context?.unknownSubcommandPath?.trim();
|
|
936
|
+
const token = context?.unknownSubcommandToken?.trim();
|
|
937
|
+
const allowed = normalizeContextList(context?.unknownSubcommandAllowedValues);
|
|
938
|
+
if (!commandPath || !token || !allowed) {
|
|
939
|
+
return null;
|
|
940
|
+
}
|
|
941
|
+
const retryCommand = context?.suggestedRetryCommand;
|
|
942
|
+
return makeGuidanceMessage({
|
|
943
|
+
code: "unknown_subcommand",
|
|
944
|
+
title: `Unknown ${commandPath} subcommand ${token}`,
|
|
945
|
+
happened: `The positional token sequence "${token}" is not a declared ${commandPath} subcommand.`,
|
|
946
|
+
required: `Use one of: ${allowed.join(", ")}.`,
|
|
947
|
+
why: "Subcommands are single positional tokens; multi-word action names use hyphens.",
|
|
948
|
+
examples: [
|
|
949
|
+
...(retryCommand ? [retryCommand] : []),
|
|
950
|
+
`pm ${commandPath} --help`,
|
|
951
|
+
],
|
|
952
|
+
nextSteps: retryCommand
|
|
953
|
+
? [`Retry with the declared hyphenated action: ${retryCommand}`]
|
|
954
|
+
: ["Choose one value from recovery.allowed_values."],
|
|
955
|
+
recovery: buildCommanderRecoveryPayload(context, {
|
|
956
|
+
allowed_values: allowed,
|
|
957
|
+
suggested_retry: retryCommand,
|
|
958
|
+
}),
|
|
959
|
+
});
|
|
960
|
+
}
|
|
887
961
|
function buildLinkedTestValueNotQuotedGuidance(message, commandName, context) {
|
|
888
962
|
if (!/too many arguments/i.test(message) || commandName !== "test") {
|
|
889
963
|
return null;
|
|
@@ -916,6 +990,48 @@ function buildLinkedTestValueNotQuotedGuidance(message, commandName, context) {
|
|
|
916
990
|
recovery: buildCommanderRecoveryPayload(context, retryCommand ? { suggested_retry: retryCommand } : {}),
|
|
917
991
|
});
|
|
918
992
|
}
|
|
993
|
+
const TRANSPOSED_COLLECTION_COMMANDS = new Set([
|
|
994
|
+
"comments",
|
|
995
|
+
"docs",
|
|
996
|
+
"files",
|
|
997
|
+
"learnings",
|
|
998
|
+
"notes",
|
|
999
|
+
"test",
|
|
1000
|
+
]);
|
|
1001
|
+
function buildTransposedCollectionActionGuidance(message, commandName, context) {
|
|
1002
|
+
if (!/too many arguments/i.test(message) ||
|
|
1003
|
+
!TRANSPOSED_COLLECTION_COMMANDS.has(commandName ?? "")) {
|
|
1004
|
+
return null;
|
|
1005
|
+
}
|
|
1006
|
+
const argv = context?.normalizedInvocationArgs ?? [];
|
|
1007
|
+
const commandIndex = argv.findIndex((token) => token === commandName);
|
|
1008
|
+
const action = argv[commandIndex + 1];
|
|
1009
|
+
const parsedItemId = argv[commandIndex + 2];
|
|
1010
|
+
const itemId = context?.verifiedCollectionItemId?.trim();
|
|
1011
|
+
if (action?.toLowerCase() !== "add" ||
|
|
1012
|
+
!parsedItemId ||
|
|
1013
|
+
parsedItemId.startsWith("-") ||
|
|
1014
|
+
!itemId ||
|
|
1015
|
+
itemId.toLowerCase() !== parsedItemId.toLowerCase()) {
|
|
1016
|
+
return null;
|
|
1017
|
+
}
|
|
1018
|
+
const suggestedRetry = `pm ${commandName} ${itemId} --add <value>`;
|
|
1019
|
+
return makeGuidanceMessage({
|
|
1020
|
+
code: "collection_transposed_subcommand",
|
|
1021
|
+
title: `Transposed ${commandName} add syntax`,
|
|
1022
|
+
happened: `The positional token "add" occupied the item-id role and "${itemId}" occupied the next positional role. pm ${commandName} does not use an add subcommand.`,
|
|
1023
|
+
required: `Place the item id immediately after ${commandName}, then use --add for the value.`,
|
|
1024
|
+
why: "Collection mutations use object-first grammar: pm <collection> <item-id> --add <value>.",
|
|
1025
|
+
examples: [suggestedRetry, `pm ${commandName} --help`],
|
|
1026
|
+
recovery: buildCommanderRecoveryPayload(context, {
|
|
1027
|
+
parsed_positionals: [
|
|
1028
|
+
{ role: "transposed_subcommand", value: action },
|
|
1029
|
+
{ role: "item_id", value: itemId },
|
|
1030
|
+
],
|
|
1031
|
+
suggested_retry: suggestedRetry,
|
|
1032
|
+
}),
|
|
1033
|
+
});
|
|
1034
|
+
}
|
|
919
1035
|
const CONTEXT_GUIDANCE_VALUE_FLAGS = new Set([
|
|
920
1036
|
"--activity-limit",
|
|
921
1037
|
"--assignee",
|
|
@@ -990,6 +1106,8 @@ function buildCommanderErrorGuidance(rawMessage, commandName, allowedTypes, cont
|
|
|
990
1106
|
buildMissingRequiredArgumentGuidance(message, commandName, context) ??
|
|
991
1107
|
buildUnknownOptionGuidance(message, commandName, context) ??
|
|
992
1108
|
buildUnknownCommandGuidance(message, context) ??
|
|
1109
|
+
buildUnknownSubcommandGuidance(context) ??
|
|
1110
|
+
buildTransposedCollectionActionGuidance(message, commandName, context) ??
|
|
993
1111
|
buildLinkedTestValueNotQuotedGuidance(message, commandName, context) ??
|
|
994
1112
|
buildContextItemArgumentGuidance(message, commandName, context);
|
|
995
1113
|
if (guidance) {
|
|
@@ -1083,4 +1201,4 @@ export const _testOnly = {
|
|
|
1083
1201
|
resolveKnownPackageCommandHint,
|
|
1084
1202
|
};
|
|
1085
1203
|
//# sourceMappingURL=error-guidance.js.map
|
|
1086
|
-
//# debugId=
|
|
1204
|
+
//# debugId=0203943b-16ea-5c3a-a2d3-56a0c4d2848f
|
package/dist/cli/main.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
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]="
|
|
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]="6eb8f2a6-6096-54af-a3dc-eb15fdbe5999")}catch(e){}}();
|
|
7
7
|
import { Command } 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 { resolveSubcommandFlagContractsForCommand } from "../sdk/cli-contracts.js";
|
|
@@ -138,6 +138,10 @@ function projectExistingRecoveryOptionalFields(existingRecovery) {
|
|
|
138
138
|
"recovery_mode",
|
|
139
139
|
"missing_required_fields",
|
|
140
140
|
"suggested_flags",
|
|
141
|
+
"allowed_values",
|
|
142
|
+
"candidate_commands",
|
|
143
|
+
"candidate_commands_total",
|
|
144
|
+
"candidate_commands_truncated",
|
|
141
145
|
"fallback_candidates",
|
|
142
146
|
"next_best_command",
|
|
143
147
|
];
|
|
@@ -842,15 +846,29 @@ function activationCommandMatchesProbe(command, probe) {
|
|
|
842
846
|
return false;
|
|
843
847
|
}
|
|
844
848
|
function extensionActivationCommands(extension) {
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
849
|
+
const explicitCommands = extension.activation?.commands;
|
|
850
|
+
if (explicitCommands) {
|
|
851
|
+
return explicitCommands;
|
|
852
|
+
}
|
|
853
|
+
const contributions = extension.contributions;
|
|
854
|
+
if (!contributions) {
|
|
855
|
+
return [];
|
|
856
|
+
}
|
|
857
|
+
return [
|
|
858
|
+
...entriesOrEmpty(contributions.commands),
|
|
859
|
+
...entriesOrEmpty(contributions.command_handlers),
|
|
860
|
+
...entriesOrEmpty(contributions.command_overrides),
|
|
861
|
+
...entriesOrEmpty(contributions.flag_commands),
|
|
862
|
+
...entriesOrEmpty(contributions.parser_overrides),
|
|
863
|
+
...ownershipCommands(contributions.preflight_ownership),
|
|
864
|
+
...ownershipCommands(contributions.renderer_ownership),
|
|
865
|
+
];
|
|
866
|
+
}
|
|
867
|
+
function entriesOrEmpty(entries) {
|
|
868
|
+
return entries ?? [];
|
|
869
|
+
}
|
|
870
|
+
function ownershipCommands(entries) {
|
|
871
|
+
return entriesOrEmpty(entries).flatMap((entry) => entry.commands);
|
|
854
872
|
}
|
|
855
873
|
function extensionCapabilities(extension) {
|
|
856
874
|
/* c8 ignore next */
|
|
@@ -913,14 +931,15 @@ function matchesStaticExtensionCommand(commands, probe) {
|
|
|
913
931
|
/** Identify contribution surfaces that participate in global runtime behavior. */
|
|
914
932
|
function hasGlobalExtensionContributions(contributions) {
|
|
915
933
|
const contributionCounts = [
|
|
916
|
-
contributions.hooks
|
|
917
|
-
contributions.preflight_overrides ?? 0
|
|
918
|
-
|
|
919
|
-
contributions.
|
|
920
|
-
contributions.
|
|
921
|
-
contributions.
|
|
922
|
-
(contributions.
|
|
923
|
-
|
|
934
|
+
entriesOrEmpty(contributions.hooks).length,
|
|
935
|
+
(contributions.preflight_overrides ?? 0) -
|
|
936
|
+
entriesOrEmpty(contributions.preflight_ownership).length,
|
|
937
|
+
entriesOrEmpty(contributions.item_types).length,
|
|
938
|
+
entriesOrEmpty(contributions.item_fields).length,
|
|
939
|
+
entriesOrEmpty(contributions.relationship_kinds).length,
|
|
940
|
+
entriesOrEmpty(contributions.service_overrides).length,
|
|
941
|
+
entriesOrEmpty(contributions.renderer_overrides).length -
|
|
942
|
+
entriesOrEmpty(contributions.renderer_ownership).length,
|
|
924
943
|
];
|
|
925
944
|
return contributionCounts.some((count) => count > 0);
|
|
926
945
|
}
|
|
@@ -2455,4 +2474,4 @@ export const _testOnly = {
|
|
|
2455
2474
|
wrapThrownErrorForSentry,
|
|
2456
2475
|
};
|
|
2457
2476
|
//# sourceMappingURL=main.js.map
|
|
2458
|
-
//# debugId=
|
|
2477
|
+
//# debugId=6eb8f2a6-6096-54af-a3dc-eb15fdbe5999
|