@unbrained/pm-cli 2026.8.9 → 2026.8.11
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 +142 -80
- package/dist/cli/commander-usage.js +94 -17
- package/dist/cli/error-guidance.d.ts +10 -0
- package/dist/cli/error-guidance.js +76 -25
- package/dist/cli/help-json-payload.js +51 -16
- package/dist/cli/main.js +11 -6
- 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-mutation.js +30 -9
- package/dist/cli/register-operations.js +16 -11
- package/dist/cli-bundle/bundle-manifest.json +163 -163
- package/dist/cli-bundle/chunks/{chunk-RJC7TPF4.js → chunk-2OOU2AFH.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-2RA2YTHJ.js +33 -0
- package/dist/cli-bundle/chunks/chunk-A2SJGHSI.js +3 -0
- package/dist/cli-bundle/chunks/chunk-DSKYD4LG.js +13 -0
- package/dist/cli-bundle/chunks/chunk-HC3GM6YY.js +194 -0
- package/dist/cli-bundle/chunks/chunk-IUNRVDAI.js +2 -0
- package/dist/cli-bundle/chunks/chunk-W7CPZGSB.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-YC3UF2IO.js → chunk-WMEZHCFI.js} +66 -60
- package/dist/cli-bundle/chunks/{chunk-GMX5YOI3.js → chunk-ZU34C3LH.js} +48 -48
- package/dist/cli-bundle/chunks/chunk-ZXOC6HG5.js +5 -0
- package/dist/cli-bundle/chunks/{register-list-query-BUE7PTCU.js → register-list-query-HAUXVUPY.js} +8 -8
- package/dist/cli-bundle/chunks/register-mutation-7Y5U7ABT.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-EQX3DLAZ.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-UQDTNTLJ.js → register-setup-NOCOOWQY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-KNEHLPBF.js → chunk-23FTGO3W.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-6DO4YQWZ.js → chunk-2DL3MRTD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-3AYKXMYX.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-4AHEC74N.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-MRWVJ3ZG.js → chunk-4H5IA6AV.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-4SV3ZKG3.js +16 -0
- package/dist/cli-bundle/focused-chunks/chunk-55BIB6DV.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-6JW6Z2P5.js +8 -0
- package/dist/cli-bundle/focused-chunks/chunk-BKPIY34S.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-D4PIWE6D.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-DPO7TEFX.js +31 -0
- package/dist/cli-bundle/focused-chunks/{chunk-3WVHTUAW.js → chunk-E3KCL7AY.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-ERAAFLPS.js +153 -0
- package/dist/cli-bundle/focused-chunks/chunk-F6E4JZKG.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-FPSYO5ZG.js +18 -0
- package/dist/cli-bundle/focused-chunks/{chunk-73FIJONU.js → chunk-J5EKAIVD.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-KDH5OX3D.js +4 -0
- package/dist/cli-bundle/focused-chunks/chunk-OJ3LVVIS.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-TL5M2PAY.js +3 -0
- package/dist/cli-bundle/focused-chunks/chunk-UDAZWT25.js +6 -0
- package/dist/cli-bundle/focused-chunks/chunk-VABB4L5Y.js +17 -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/diagnostics/remediation.js +9 -9
- package/dist/core/fs/fs-utils.d.ts +10 -0
- package/dist/core/fs/fs-utils.js +16 -4
- package/dist/core/item/item-format.js +3 -32
- package/dist/core/schema/fields-file.d.ts +1 -2
- package/dist/core/schema/fields-file.js +4 -11
- package/dist/core/schema/runtime-schema.js +3 -10
- package/dist/core/schema/status-defs-file.d.ts +1 -2
- package/dist/core/schema/status-defs-file.js +4 -32
- package/dist/core/schema/status-token.d.ts +2 -0
- package/dist/core/schema/status-token.js +32 -0
- package/dist/core/schema/type-workflows.d.ts +1 -2
- package/dist/core/schema/type-workflows.js +4 -11
- 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 +8 -2
- package/dist/core/shared/author.js +85 -52
- package/dist/core/shared/errors.d.ts +12 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/shared/text-normalization.d.ts +1 -1
- package/dist/core/shared/text-normalization.js +2 -2
- package/dist/sdk/agent/command-recovery.d.ts +4 -0
- package/dist/sdk/agent/command-recovery.js +52 -0
- package/dist/sdk/agent/command-suggestions.d.ts +4 -0
- package/dist/sdk/agent/command-suggestions.js +67 -0
- package/dist/sdk/agent/create-option-policy.d.ts +12 -0
- package/dist/sdk/agent/create-option-policy.js +32 -0
- package/dist/sdk/agent/item-addressing.d.ts +19 -0
- package/dist/sdk/agent/item-addressing.js +208 -0
- 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 +9 -1
- package/dist/sdk/cli-bootstrap.js +25 -10
- package/dist/sdk/cli-contracts/commander-mutation-options.js +16 -4
- package/dist/sdk/cli-contracts/completeness.js +13 -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 +77 -21
- package/dist/sdk/cli-contracts/registration-helpers.js +10 -2
- package/dist/sdk/cli-contracts/runtime-contracts.js +6 -3
- package/dist/sdk/cli-contracts/schemas/assurance-definition.d.ts +513 -0
- package/dist/sdk/cli-contracts/schemas/assurance-definition.js +251 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +6 -0
- package/dist/sdk/cli-contracts/tool-option-contracts.js +4 -2
- package/dist/sdk/cli-contracts/tool-parameter-tables.js +96 -4
- package/dist/sdk/cli-contracts/tool-schema.d.ts +2 -2
- package/dist/sdk/cli-contracts/tool-schema.js +49 -6
- package/dist/sdk/cli-contracts.d.ts +1 -1
- package/dist/sdk/cli-contracts.js +3 -3
- package/dist/sdk/completion.js +9 -3
- 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-runtime.js +8 -5
- package/dist/sdk/context-signal-store.d.ts +34 -0
- package/dist/sdk/context-signal-store.js +24 -2
- package/dist/sdk/core-governance.d.ts +3 -1
- package/dist/sdk/core-governance.js +5 -3
- package/dist/sdk/core.d.ts +1 -1
- package/dist/sdk/core.js +2 -2
- package/dist/sdk/dependency-flag-validation.d.ts +15 -1
- package/dist/sdk/dependency-flag-validation.js +54 -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-error-code-catalog.js +104 -13
- 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 +198 -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-runtime.d.ts +20 -0
- package/dist/sdk/governance/assurance-runtime.js +131 -0
- package/dist/sdk/governance/assurance.d.ts +432 -0
- package/dist/sdk/governance/assurance.js +689 -0
- package/dist/sdk/governance/health.js +14 -7
- package/dist/sdk/governance/provenance-health.d.ts +13 -0
- package/dist/sdk/governance/provenance-health.js +63 -17
- package/dist/sdk/governance/validate-item-reader.d.ts +13 -0
- package/dist/sdk/governance/validate-item-reader.js +18 -0
- package/dist/sdk/governance/validate.d.ts +2 -2
- package/dist/sdk/governance/validate.js +15 -6
- package/dist/sdk/graph/run.js +8 -3
- package/dist/sdk/index.d.ts +10 -1
- package/dist/sdk/index.js +12 -3
- package/dist/sdk/lifecycle/claim.js +18 -3
- package/dist/sdk/lifecycle/close.js +17 -14
- package/dist/sdk/lifecycle/create.d.ts +2 -0
- package/dist/sdk/lifecycle/create.js +62 -9
- package/dist/sdk/lifecycle/focus.js +13 -3
- package/dist/sdk/lifecycle/plan.js +8 -3
- package/dist/sdk/lifecycle/update-many.js +39 -27
- package/dist/sdk/lifecycle/update.d.ts +6 -1
- package/dist/sdk/lifecycle/update.js +47 -10
- package/dist/sdk/merge/index.d.ts +1 -1
- package/dist/sdk/merge/index.js +3 -3
- package/dist/sdk/merge/install.d.ts +4 -0
- package/dist/sdk/merge/install.js +28 -16
- package/dist/sdk/merge/receipts.d.ts +3 -0
- package/dist/sdk/merge/receipts.js +81 -17
- package/dist/sdk/output-projection.js +24 -4
- package/dist/sdk/provenance.d.ts +38 -0
- package/dist/sdk/provenance.js +64 -2
- package/dist/sdk/query/context.d.ts +2 -0
- package/dist/sdk/query/context.js +24 -10
- package/dist/sdk/query/light-metadata.d.ts +3 -0
- package/dist/sdk/query/light-metadata.js +19 -0
- package/dist/sdk/runtime-extended-actions.js +22 -5
- package/dist/sdk/runtime-primitives.d.ts +2 -0
- package/dist/sdk/runtime-primitives.js +4 -2
- package/dist/sdk/runtime.d.ts +8 -1
- package/dist/sdk/runtime.js +37 -28
- package/dist/sdk/schema-migration.js +7 -9
- package/dist/sdk/similarity-scoring.d.ts +1 -2
- package/dist/sdk/similarity-scoring.js +4 -16
- package/dist/sdk/telemetry.js +7 -4
- 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/sdk/workspace-snapshot.d.ts +4 -0
- package/dist/sdk/workspace-snapshot.js +24 -11
- package/dist/types.d.ts +8 -2
- package/dist/types.js +2 -2
- package/docs/AGENT_GUIDE.md +3 -1
- package/docs/ASSURANCE.md +132 -0
- package/docs/COMMANDS.md +8 -5
- package/docs/MERGE_SAFETY.md +7 -5
- package/docs/README.md +3 -5
- package/docs/READ_OUTPUT_CONTRACTS.md +2 -2
- package/docs/RELEASING.md +9 -5
- package/docs/SDK.md +44 -8
- package/docs/SDK_AGENT_SESSION_CONTEXT.md +43 -6
- package/docs/SDK_CONTEXT.md +97 -0
- package/docs/SDK_CONTEXT_INTEGRITY.md +18 -3
- package/docs/SDK_EVIDENCE_TRACEABILITY.md +39 -1
- package/docs/SDK_RUNTIME_BOUNDARIES.md +36 -1
- package/docs/TESTING.md +12 -9
- package/docs/agent-task-token-baseline.json +2 -2
- package/docs/generated/AGENT_COMMAND_SURFACE.md +1 -0
- package/marketplace.json +2 -2
- package/package.json +7 -6
- 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 +1028 -48
- package/dist/cli-bundle/chunks/chunk-2DTCZXSD.js +0 -13
- package/dist/cli-bundle/chunks/chunk-5JO6R4BS.js +0 -3
- package/dist/cli-bundle/chunks/chunk-5KN4DZYV.js +0 -194
- package/dist/cli-bundle/chunks/chunk-EF43KODO.js +0 -2
- package/dist/cli-bundle/chunks/chunk-HUV2Z7IS.js +0 -28
- package/dist/cli-bundle/chunks/chunk-MHBVCUF2.js +0 -2
- package/dist/cli-bundle/chunks/chunk-PYO5GZU6.js +0 -5
- package/dist/cli-bundle/chunks/register-mutation-FC3XLVIK.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-YH2WAOXU.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2VVP5RAA.js +0 -153
- package/dist/cli-bundle/focused-chunks/chunk-3GSFUDAI.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-4H6MVCK3.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-54TZJ4BM.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-5NK5TJ5D.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-C3GCHDSQ.js +0 -31
- package/dist/cli-bundle/focused-chunks/chunk-JGRSQZJT.js +0 -18
- package/dist/cli-bundle/focused-chunks/chunk-NL57J7BZ.js +0 -4
- package/dist/cli-bundle/focused-chunks/chunk-P6BBIQRG.js +0 -6
- package/dist/cli-bundle/focused-chunks/chunk-PZAGVQNN.js +0 -3
- package/dist/cli-bundle/focused-chunks/chunk-QDAO3XEK.js +0 -14
- package/dist/cli-bundle/focused-chunks/chunk-T4IGQCSY.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-U46GQJNY.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-VRXJSGIT.js +0 -8
- package/dist/cli-bundle/focused-chunks/chunk-XC2ZW3CJ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-ZG54B4XG.js +0 -2
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/item-addressing
|
|
3
|
+
*
|
|
4
|
+
* Defines the shared item-address grammar used by CLI adapters. Commands keep
|
|
5
|
+
* their canonical positional id while accepting `--id` as a compatibility
|
|
6
|
+
* spelling, so integrations no longer need a per-command addressing table.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
!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]="271cf7c1-f84b-5f59-aa13-ed8cb4ee232f")}catch(e){}}();
|
|
10
|
+
import { resolveSubcommandFlagContractsForCommand, } from "../cli-contracts.js";
|
|
11
|
+
const ITEM_ID_ALIAS_COMMANDS = new Set([
|
|
12
|
+
"append",
|
|
13
|
+
"claim",
|
|
14
|
+
"close",
|
|
15
|
+
"close-task",
|
|
16
|
+
"comments",
|
|
17
|
+
"copy",
|
|
18
|
+
"delete",
|
|
19
|
+
"deps",
|
|
20
|
+
"docs",
|
|
21
|
+
"files",
|
|
22
|
+
"focus",
|
|
23
|
+
"get",
|
|
24
|
+
"history",
|
|
25
|
+
"history-compact",
|
|
26
|
+
"history-redact",
|
|
27
|
+
"history-repair",
|
|
28
|
+
"learnings",
|
|
29
|
+
"notes",
|
|
30
|
+
"pause-task",
|
|
31
|
+
"release",
|
|
32
|
+
"restore",
|
|
33
|
+
"start-task",
|
|
34
|
+
"test",
|
|
35
|
+
"update",
|
|
36
|
+
]);
|
|
37
|
+
const ITEM_ID_ALIAS_SUBCOMMANDS = new Map([
|
|
38
|
+
["files", "discover"],
|
|
39
|
+
["item", "complete"],
|
|
40
|
+
]);
|
|
41
|
+
const GLOBAL_VALUE_FLAGS = new Set([
|
|
42
|
+
"--author",
|
|
43
|
+
"--output-budget",
|
|
44
|
+
"--output-format",
|
|
45
|
+
"--output-include",
|
|
46
|
+
"--output-limit",
|
|
47
|
+
"--output-session",
|
|
48
|
+
"--path",
|
|
49
|
+
"--pm-path",
|
|
50
|
+
]);
|
|
51
|
+
const TRAILING_POSITIONAL_COUNTS = new Map([
|
|
52
|
+
["append", 1],
|
|
53
|
+
["close", 1],
|
|
54
|
+
["close-task", 1],
|
|
55
|
+
["comments", 1],
|
|
56
|
+
["item complete", 1],
|
|
57
|
+
["learnings", 1],
|
|
58
|
+
["notes", 1],
|
|
59
|
+
["restore", 1],
|
|
60
|
+
]);
|
|
61
|
+
/** Return whether a command participates in the shared item-id alias contract. */
|
|
62
|
+
export function supportsItemIdAlias(commandName) {
|
|
63
|
+
const normalized = commandName?.trim().toLowerCase() ?? "";
|
|
64
|
+
return (ITEM_ID_ALIAS_COMMANDS.has(normalized) ||
|
|
65
|
+
ITEM_ID_ALIAS_SUBCOMMANDS.has(normalized));
|
|
66
|
+
}
|
|
67
|
+
function findCommandIndex(argv) {
|
|
68
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
69
|
+
const token = argv[index];
|
|
70
|
+
if (token === "--")
|
|
71
|
+
return undefined;
|
|
72
|
+
if (GLOBAL_VALUE_FLAGS.has(token)) {
|
|
73
|
+
index += 1;
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (token.startsWith("-"))
|
|
77
|
+
continue;
|
|
78
|
+
return index;
|
|
79
|
+
}
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
/** Resolve the positional-id slot for direct and declared nested commands. */
|
|
83
|
+
function resolveItemAddressIndex(argv, commandIndex, commandName) {
|
|
84
|
+
const declaredSubcommand = ITEM_ID_ALIAS_SUBCOMMANDS.get(commandName);
|
|
85
|
+
if (declaredSubcommand === undefined)
|
|
86
|
+
return commandIndex + 1;
|
|
87
|
+
const usesDeclaredSubcommand = argv[commandIndex + 1]?.toLowerCase() === declaredSubcommand;
|
|
88
|
+
if (!usesDeclaredSubcommand && !ITEM_ID_ALIAS_COMMANDS.has(commandName)) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return commandIndex + (usesDeclaredSubcommand ? 2 : 1);
|
|
92
|
+
}
|
|
93
|
+
function buildFlagContractMap(commandPath) {
|
|
94
|
+
const contractsByFlag = new Map();
|
|
95
|
+
for (const contract of resolveSubcommandFlagContractsForCommand(commandPath)) {
|
|
96
|
+
for (const flag of [
|
|
97
|
+
contract.flag,
|
|
98
|
+
contract.short,
|
|
99
|
+
...(contract.aliases ?? []),
|
|
100
|
+
]) {
|
|
101
|
+
if (flag)
|
|
102
|
+
contractsByFlag.set(flag, contract);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return contractsByFlag;
|
|
106
|
+
}
|
|
107
|
+
function collectNamedItemIds(argv) {
|
|
108
|
+
const namedIds = [];
|
|
109
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
110
|
+
const token = argv[index];
|
|
111
|
+
if (token === "--")
|
|
112
|
+
break;
|
|
113
|
+
if (token === "--id") {
|
|
114
|
+
namedIds.push({ index, consumed: 2, value: argv[index + 1] });
|
|
115
|
+
index += 1;
|
|
116
|
+
}
|
|
117
|
+
else if (token.startsWith("--id=")) {
|
|
118
|
+
namedIds.push({
|
|
119
|
+
index,
|
|
120
|
+
consumed: 1,
|
|
121
|
+
value: token.slice("--id=".length),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
return namedIds;
|
|
126
|
+
}
|
|
127
|
+
function consumesSeparateFlagValue(token, nextToken, contractsByFlag) {
|
|
128
|
+
const separatorIndex = token.indexOf("=");
|
|
129
|
+
if (separatorIndex >= 0 || nextToken === undefined || nextToken.startsWith("-")) {
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
const contract = contractsByFlag.get(token);
|
|
133
|
+
return contract !== undefined && contract.value_type !== "boolean";
|
|
134
|
+
}
|
|
135
|
+
function hasPositionalItemId(argv, addressIndex, commandPath, namedIndex, contractsByFlag) {
|
|
136
|
+
let trailingPositionals = 0;
|
|
137
|
+
for (let index = addressIndex; index < argv.length; index += 1) {
|
|
138
|
+
const token = argv[index];
|
|
139
|
+
if (token === "--")
|
|
140
|
+
break;
|
|
141
|
+
if (token === "--id") {
|
|
142
|
+
index += 1;
|
|
143
|
+
continue;
|
|
144
|
+
}
|
|
145
|
+
if (token.startsWith("--id="))
|
|
146
|
+
continue;
|
|
147
|
+
if (!token.startsWith("-")) {
|
|
148
|
+
if (index < namedIndex)
|
|
149
|
+
return true;
|
|
150
|
+
trailingPositionals += 1;
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (consumesSeparateFlagValue(token, argv[index + 1], contractsByFlag)) {
|
|
154
|
+
index += 1;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return trailingPositionals > (TRAILING_POSITIONAL_COUNTS.get(commandPath) ?? 0);
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Normalize `pm <command> --id <value>` to the command's positional id form.
|
|
161
|
+
* The transformation is lossless for every other argument and reports a
|
|
162
|
+
* conflict instead of guessing when both forms are present.
|
|
163
|
+
*/
|
|
164
|
+
export function normalizeItemAddressInvocation(argv) {
|
|
165
|
+
const commandIndex = findCommandIndex(argv);
|
|
166
|
+
const commandName = commandIndex === undefined ? undefined : argv[commandIndex]?.toLowerCase();
|
|
167
|
+
if (!supportsItemIdAlias(commandName)) {
|
|
168
|
+
return { argv: [...argv], changed: false, conflict: false };
|
|
169
|
+
}
|
|
170
|
+
const commandPath = ITEM_ID_ALIAS_SUBCOMMANDS.get(commandName) ===
|
|
171
|
+
argv[commandIndex + 1]?.toLowerCase()
|
|
172
|
+
? `${commandName} ${argv[commandIndex + 1]?.toLowerCase()}`
|
|
173
|
+
: commandName;
|
|
174
|
+
const contractsByFlag = buildFlagContractMap(commandPath);
|
|
175
|
+
const namedIds = collectNamedItemIds(argv);
|
|
176
|
+
const named = namedIds[0];
|
|
177
|
+
if (!named || !named.value?.trim()) {
|
|
178
|
+
return { argv: [...argv], changed: false, conflict: false };
|
|
179
|
+
}
|
|
180
|
+
const addressIndex = resolveItemAddressIndex(argv, commandIndex, commandName);
|
|
181
|
+
if (addressIndex === undefined) {
|
|
182
|
+
return { argv: [...argv], changed: false, conflict: false };
|
|
183
|
+
}
|
|
184
|
+
if (namedIds.length > 1 ||
|
|
185
|
+
hasPositionalItemId(argv, addressIndex, commandPath, named.index, contractsByFlag)) {
|
|
186
|
+
return {
|
|
187
|
+
argv: [...argv],
|
|
188
|
+
changed: false,
|
|
189
|
+
conflict: true,
|
|
190
|
+
itemId: named.value,
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
const withoutNamed = [
|
|
194
|
+
...argv.slice(0, named.index),
|
|
195
|
+
...argv.slice(named.index + named.consumed),
|
|
196
|
+
];
|
|
197
|
+
const normalizedCommandIndex = findCommandIndex(withoutNamed);
|
|
198
|
+
const normalizedAddressIndex = resolveItemAddressIndex(withoutNamed, normalizedCommandIndex, commandName);
|
|
199
|
+
withoutNamed.splice(normalizedAddressIndex, 0, named.value);
|
|
200
|
+
return {
|
|
201
|
+
argv: withoutNamed,
|
|
202
|
+
changed: true,
|
|
203
|
+
conflict: false,
|
|
204
|
+
itemId: named.value,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
//# sourceMappingURL=item-addressing.js.map
|
|
208
|
+
//# debugId=271cf7c1-f84b-5f59-aa13-ed8cb4ee232f
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/agent/refusal-reachability
|
|
3
|
+
*
|
|
4
|
+
* Verifies real-entrypoint observations against refusal states declared by the
|
|
5
|
+
* generated public error-code catalog.
|
|
6
|
+
*/
|
|
7
|
+
import type { PmErrorCodeContract, PmErrorCodeClass } from "../error-code-catalog.js";
|
|
8
|
+
/** One recorded result from driving a real public entrypoint into a refusal. */
|
|
9
|
+
export interface PmRefusalProbeObservation {
|
|
10
|
+
/** Stable probe identifier from the owning error-code contract. */
|
|
11
|
+
probe_id: string;
|
|
12
|
+
/** Public command entrypoint exercised by the probe. */
|
|
13
|
+
entrypoint: string;
|
|
14
|
+
/** Machine-readable code observed at the transport boundary. */
|
|
15
|
+
code: string;
|
|
16
|
+
/** Semantic exit class observed at the transport boundary. */
|
|
17
|
+
exit_class: PmErrorCodeClass;
|
|
18
|
+
}
|
|
19
|
+
/** One actionable conformance failure. */
|
|
20
|
+
export interface PmRefusalReachabilityFinding {
|
|
21
|
+
/** Stable finding kind for automation. */
|
|
22
|
+
kind: "duplicate_probe" | "missing_probe" | "wrong_entrypoint" | "wrong_error_code" | "wrong_exit_class" | "undeclared_probe";
|
|
23
|
+
/** Probe whose declaration or observation failed. */
|
|
24
|
+
probe_id: string;
|
|
25
|
+
/** Human-readable mismatch summary. */
|
|
26
|
+
detail: string;
|
|
27
|
+
}
|
|
28
|
+
/** Complete refusal-reachability conformance receipt. */
|
|
29
|
+
export interface PmRefusalReachabilityReport {
|
|
30
|
+
/** Whether every declaration and observation agreed. */
|
|
31
|
+
ok: boolean;
|
|
32
|
+
/** Number of declared probes evaluated. */
|
|
33
|
+
declared_probe_count: number;
|
|
34
|
+
/** Number of real-entrypoint observations supplied. */
|
|
35
|
+
observed_probe_count: number;
|
|
36
|
+
/** Stable, sorted conformance findings. */
|
|
37
|
+
findings: PmRefusalReachabilityFinding[];
|
|
38
|
+
}
|
|
39
|
+
/** Compare declared refusal states with real-entrypoint observations. */
|
|
40
|
+
export declare function verifyPmRefusalReachability(catalog: readonly PmErrorCodeContract[], observations: readonly PmRefusalProbeObservation[]): PmRefusalReachabilityReport;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/** Compare declared refusal states with real-entrypoint observations. */
|
|
2
|
+
|
|
3
|
+
!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]="55318c8e-1fbd-5abd-b18f-f0cc1f81dd5c")}catch(e){}}();
|
|
4
|
+
export function verifyPmRefusalReachability(catalog, observations) {
|
|
5
|
+
const declarations = catalog.flatMap((contract) => (contract.owned_states ?? []).map((state) => ({ contract, state })));
|
|
6
|
+
const findings = [];
|
|
7
|
+
const observationsByProbe = new Map();
|
|
8
|
+
for (const observation of observations) {
|
|
9
|
+
if (observationsByProbe.has(observation.probe_id)) {
|
|
10
|
+
findings.push({
|
|
11
|
+
kind: "duplicate_probe",
|
|
12
|
+
probe_id: observation.probe_id,
|
|
13
|
+
detail: `Observation ${observation.probe_id} was supplied more than once.`,
|
|
14
|
+
});
|
|
15
|
+
continue;
|
|
16
|
+
}
|
|
17
|
+
observationsByProbe.set(observation.probe_id, observation);
|
|
18
|
+
}
|
|
19
|
+
const declaredProbeIds = new Set(declarations.map(({ state }) => state.probe_id));
|
|
20
|
+
for (const { contract, state } of declarations) {
|
|
21
|
+
const observation = observationsByProbe.get(state.probe_id);
|
|
22
|
+
if (!observation) {
|
|
23
|
+
findings.push({
|
|
24
|
+
kind: "missing_probe",
|
|
25
|
+
probe_id: state.probe_id,
|
|
26
|
+
detail: `No entrypoint observation was recorded for ${contract.code}.`,
|
|
27
|
+
});
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (observation.code !== contract.code) {
|
|
31
|
+
findings.push({
|
|
32
|
+
kind: "wrong_error_code",
|
|
33
|
+
probe_id: state.probe_id,
|
|
34
|
+
detail: `Expected ${contract.code}; observed ${observation.code}.`,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (observation.exit_class !== state.expected_exit_class) {
|
|
38
|
+
findings.push({
|
|
39
|
+
kind: "wrong_exit_class",
|
|
40
|
+
probe_id: state.probe_id,
|
|
41
|
+
detail: `Expected ${state.expected_exit_class}; observed ${observation.exit_class}.`,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if (!state.entrypoints.includes(observation.entrypoint)) {
|
|
45
|
+
findings.push({
|
|
46
|
+
kind: "wrong_entrypoint",
|
|
47
|
+
probe_id: state.probe_id,
|
|
48
|
+
detail: `Expected one of ${state.entrypoints.join(", ")}; observed ${observation.entrypoint}.`,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
for (const observation of observations) {
|
|
53
|
+
if (!declaredProbeIds.has(observation.probe_id)) {
|
|
54
|
+
findings.push({
|
|
55
|
+
kind: "undeclared_probe",
|
|
56
|
+
probe_id: observation.probe_id,
|
|
57
|
+
detail: `Observation ${observation.probe_id} has no catalog declaration.`,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
findings.sort((left, right) => left.probe_id !== right.probe_id
|
|
62
|
+
? left.probe_id.localeCompare(right.probe_id)
|
|
63
|
+
: left.kind.localeCompare(right.kind));
|
|
64
|
+
return {
|
|
65
|
+
ok: findings.length === 0,
|
|
66
|
+
declared_probe_count: declarations.length,
|
|
67
|
+
observed_probe_count: observations.length,
|
|
68
|
+
findings,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=refusal-reachability.js.map
|
|
72
|
+
//# debugId=55318c8e-1fbd-5abd-b18f-f0cc1f81dd5c
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { PmCliError, type PmCliErrorRecoveryPayload } from "../../core/shared/errors.js";
|
|
2
|
+
/** Catalog-only alias retained for consumers of the former package lifecycle code. */
|
|
3
|
+
export declare const UNKNOWN_SUBCOMMAND_COMPATIBILITY_CODES: readonly [{
|
|
4
|
+
readonly code: "unknown_lifecycle_action";
|
|
5
|
+
}];
|
|
6
|
+
/** Inputs for constructing a portable unknown-subcommand refusal. */
|
|
7
|
+
export interface UnknownSubcommandErrorOptions {
|
|
8
|
+
/** Command family path without the rejected token. */
|
|
9
|
+
command_path: string;
|
|
10
|
+
/** Rejected positional token. */
|
|
11
|
+
token: string;
|
|
12
|
+
/** Complete declared subcommand vocabulary for the family. */
|
|
13
|
+
allowed: readonly string[];
|
|
14
|
+
/** Human-readable command family, defaulting to `pm <command_path>`. */
|
|
15
|
+
display_name?: string;
|
|
16
|
+
/** Positional token role used in the compatibility message. */
|
|
17
|
+
token_kind?: "subcommand" | "action" | "path";
|
|
18
|
+
/** Arguments that follow the rejected token and should survive a retry. */
|
|
19
|
+
trailing_args?: readonly string[];
|
|
20
|
+
/** Family-aware retry that takes precedence over edit-distance recovery. */
|
|
21
|
+
retry_command?: string;
|
|
22
|
+
/** Compatibility suffix appended after the allowed-value sentence. */
|
|
23
|
+
message_suffix?: string;
|
|
24
|
+
/** Additional ranked recovery candidates supplied by the command family. */
|
|
25
|
+
fallback_candidates?: PmCliErrorRecoveryPayload["fallback_candidates"];
|
|
26
|
+
/** Transport exit used by non-CLI protocol adapters. */
|
|
27
|
+
exit_code?: number;
|
|
28
|
+
/** Additional family-specific examples. */
|
|
29
|
+
examples?: readonly string[];
|
|
30
|
+
}
|
|
31
|
+
declare function nearestSubcommand(token: string, allowed: readonly string[]): string | undefined;
|
|
32
|
+
declare function renderCommand(tokens: readonly string[]): string;
|
|
33
|
+
/** Build the shared typed refusal used by CLI, SDK, MCP, and packages. */
|
|
34
|
+
export declare function createUnknownSubcommandError(options: UnknownSubcommandErrorOptions): PmCliError;
|
|
35
|
+
/** Test-only access to deterministic nearest-match behavior. */
|
|
36
|
+
export declare const _testOnly: {
|
|
37
|
+
nearestSubcommand: typeof nearestSubcommand;
|
|
38
|
+
renderCommand: typeof renderCommand;
|
|
39
|
+
};
|
|
40
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module sdk/agent/subcommand-recovery
|
|
3
|
+
*
|
|
4
|
+
* Provides one SDK-owned refusal contract for unknown positional subcommands.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
!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]="a9b23a46-0bba-5174-8793-dfc37016d1fb")}catch(e){}}();
|
|
8
|
+
import { levenshteinDistanceWithinLimit } from "../../core/shared/levenshtein.js";
|
|
9
|
+
import { EXIT_CODE } from "../../core/shared/constants.js";
|
|
10
|
+
import { PmCliError, } from "../../core/shared/errors.js";
|
|
11
|
+
/** Catalog-only alias retained for consumers of the former package lifecycle code. */
|
|
12
|
+
export const UNKNOWN_SUBCOMMAND_COMPATIBILITY_CODES = [
|
|
13
|
+
{ code: "unknown_lifecycle_action" },
|
|
14
|
+
];
|
|
15
|
+
function nearestSubcommand(token, allowed) {
|
|
16
|
+
const normalized = token.trim().toLowerCase();
|
|
17
|
+
if (normalized.length === 0)
|
|
18
|
+
return undefined;
|
|
19
|
+
const maxDistance = Math.floor(normalized.length / 3);
|
|
20
|
+
return allowed
|
|
21
|
+
.map((candidate) => ({
|
|
22
|
+
candidate,
|
|
23
|
+
distance: levenshteinDistanceWithinLimit(normalized, candidate.toLowerCase(), maxDistance) ?? Number.POSITIVE_INFINITY,
|
|
24
|
+
}))
|
|
25
|
+
.filter(({ distance }) => Number.isFinite(distance))
|
|
26
|
+
.sort((left, right) => left.distance !== right.distance
|
|
27
|
+
? left.distance - right.distance
|
|
28
|
+
: left.candidate.localeCompare(right.candidate))[0]?.candidate;
|
|
29
|
+
}
|
|
30
|
+
function renderCommand(tokens) {
|
|
31
|
+
return ["pm", ...tokens]
|
|
32
|
+
.map((token) => /^[A-Za-z0-9_./:@=-]+$/u.test(token) ? token : JSON.stringify(token))
|
|
33
|
+
.join(" ");
|
|
34
|
+
}
|
|
35
|
+
/** Build the shared typed refusal used by CLI, SDK, MCP, and packages. */
|
|
36
|
+
export function createUnknownSubcommandError(options) {
|
|
37
|
+
const commandPath = options.command_path.trim().replaceAll(/\s+/gu, " ");
|
|
38
|
+
const normalizedToken = options.token.trim();
|
|
39
|
+
const token = normalizedToken.length === 0 ? "<empty>" : normalizedToken;
|
|
40
|
+
const allowed = [...new Set(options.allowed.map((value) => value.trim()))]
|
|
41
|
+
.filter(Boolean)
|
|
42
|
+
.sort((left, right) => left.localeCompare(right));
|
|
43
|
+
if (commandPath.length === 0 || token.length === 0 || allowed.length === 0) {
|
|
44
|
+
throw new TypeError("Unknown-subcommand contracts require a path, token, and allowed set");
|
|
45
|
+
}
|
|
46
|
+
const commandTokens = commandPath.split(" ");
|
|
47
|
+
const trailingArgs = options.trailing_args ?? [];
|
|
48
|
+
const displayName = options.display_name ?? `pm ${commandPath}`;
|
|
49
|
+
const tokenKind = options.token_kind ?? "subcommand";
|
|
50
|
+
const nearest = options.retry_command
|
|
51
|
+
? undefined
|
|
52
|
+
: nearestSubcommand(token, allowed);
|
|
53
|
+
const attemptedCommand = renderCommand([
|
|
54
|
+
...commandTokens,
|
|
55
|
+
token,
|
|
56
|
+
...trailingArgs,
|
|
57
|
+
]);
|
|
58
|
+
const suggestedRetry = options.retry_command ??
|
|
59
|
+
(nearest
|
|
60
|
+
? renderCommand([...commandTokens, nearest, ...trailingArgs])
|
|
61
|
+
: undefined);
|
|
62
|
+
return new PmCliError(`Unknown ${displayName} ${tokenKind} "${token}". Allowed: ${allowed.join(", ")}${options.message_suffix ?? ""}`, options.exit_code ?? EXIT_CODE.USAGE, {
|
|
63
|
+
code: "unknown_subcommand",
|
|
64
|
+
reason: "unknown_positional_token",
|
|
65
|
+
examples: [
|
|
66
|
+
...(suggestedRetry ? [suggestedRetry] : []),
|
|
67
|
+
...(options.examples ?? []),
|
|
68
|
+
`pm ${commandPath} --help`,
|
|
69
|
+
],
|
|
70
|
+
nextSteps: suggestedRetry
|
|
71
|
+
? [`Retry with the suggested command: ${suggestedRetry}`]
|
|
72
|
+
: ["Choose one value from recovery.allowed_values."],
|
|
73
|
+
recovery: {
|
|
74
|
+
attempted_command: attemptedCommand,
|
|
75
|
+
allowed_values: allowed,
|
|
76
|
+
suggested_retry: suggestedRetry,
|
|
77
|
+
fallback_candidates: options.fallback_candidates,
|
|
78
|
+
},
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/** Test-only access to deterministic nearest-match behavior. */
|
|
82
|
+
export const _testOnly = { nearestSubcommand, renderCommand };
|
|
83
|
+
//# sourceMappingURL=subcommand-recovery.js.map
|
|
84
|
+
//# debugId=a9b23a46-0bba-5174-8793-dfc37016d1fb
|
|
@@ -49,13 +49,21 @@ export interface BootstrapHelpRequest {
|
|
|
49
49
|
}
|
|
50
50
|
/** Implements parse bootstrap help request for the public runtime surface of this module. */
|
|
51
51
|
export declare function parseBootstrapHelpRequest(argv: string[]): BootstrapHelpRequest;
|
|
52
|
+
/**
|
|
53
|
+
* Index of the command token in argv — the first non-flag token, skipping the
|
|
54
|
+
* value-consuming/global bootstrap flags. Returns undefined when there is none
|
|
55
|
+
* (bare invocation, only global flags, or a leading `--`). Single source of truth
|
|
56
|
+
* for command-position scanning shared by {@link parseBootstrapCommandName} and the
|
|
57
|
+
* command-alias rewrite so their precedence rules can never drift apart.
|
|
58
|
+
*/
|
|
59
|
+
export declare function findBootstrapCommandTokenIndex(argv: string[]): number | undefined;
|
|
52
60
|
/** Implements parse bootstrap command name for the public runtime surface of this module. */
|
|
53
61
|
export declare function parseBootstrapCommandName(argv: string[]): string | undefined;
|
|
54
62
|
/** Implements apply bootstrap pager policy for the public runtime surface of this module. */
|
|
55
63
|
export declare function applyBootstrapPagerPolicy(argv: string[]): () => void;
|
|
56
64
|
/** Implements normalize legacy extension action syntax for the public runtime surface of this module. */
|
|
57
65
|
export declare function normalizeLegacyExtensionActionSyntax(argv: string[]): string[];
|
|
58
|
-
type BootstrapNormalizationReason = "executable_alias" | "legacy_extension_action" | "command_alias" | "flag_alias" | "flag_typo" | "bare_key_value" | "list_merge";
|
|
66
|
+
type BootstrapNormalizationReason = "executable_alias" | "legacy_extension_action" | "command_alias" | "item_id_alias" | "flag_alias" | "flag_typo" | "bare_key_value" | "list_merge";
|
|
59
67
|
type BootstrapNormalizationConfidence = "high" | "medium";
|
|
60
68
|
/** Documents the bootstrap normalization event payload exchanged by command, SDK, and package integrations. */
|
|
61
69
|
export interface BootstrapNormalizationEvent {
|
|
@@ -4,10 +4,13 @@
|
|
|
4
4
|
* Provides public bootstrap argument normalization for embedded CLI hosts.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
!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]="
|
|
7
|
+
!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]="eac8ed6b-43c4-54fa-820a-220154001a6b")}catch(e){}}();
|
|
8
8
|
import { EXECUTABLE_COMMAND_ALIASES, resolveSubcommandFlagContractsForCommand, } from "./cli-contracts.js";
|
|
9
9
|
export { EXECUTABLE_COMMAND_ALIASES };
|
|
10
10
|
import { levenshteinDistanceWithinLimit } from "../core/shared/levenshtein.js";
|
|
11
|
+
import { EXIT_CODE } from "../core/shared/constants.js";
|
|
12
|
+
import { PmCliError } from "../core/shared/errors.js";
|
|
13
|
+
import { normalizeItemAddressInvocation } from "./agent/item-addressing.js";
|
|
11
14
|
const GLOBAL_VALUE_CONSUMING_FLAGS = new Set([
|
|
12
15
|
"--pm-path",
|
|
13
16
|
"--path",
|
|
@@ -191,7 +194,7 @@ export function parseBootstrapHelpRequest(argv) {
|
|
|
191
194
|
* for command-position scanning shared by {@link parseBootstrapCommandName} and the
|
|
192
195
|
* command-alias rewrite so their precedence rules can never drift apart.
|
|
193
196
|
*/
|
|
194
|
-
function
|
|
197
|
+
export function findBootstrapCommandTokenIndex(argv) {
|
|
195
198
|
for (let index = 0; index < argv.length; index += 1) {
|
|
196
199
|
const token = argv[index];
|
|
197
200
|
if (token === "--") {
|
|
@@ -217,7 +220,7 @@ function findCommandTokenIndex(argv) {
|
|
|
217
220
|
}
|
|
218
221
|
/** Implements parse bootstrap command name for the public runtime surface of this module. */
|
|
219
222
|
export function parseBootstrapCommandName(argv) {
|
|
220
|
-
const index =
|
|
223
|
+
const index = findBootstrapCommandTokenIndex(argv);
|
|
221
224
|
return index === undefined ? undefined : argv[index].trim().toLowerCase();
|
|
222
225
|
}
|
|
223
226
|
function shouldDisablePagerForInvocation(argv, bootstrapGlobal) {
|
|
@@ -276,7 +279,7 @@ const EXTENSION_ACTION_SYNTAX_TOKENS = new Set([
|
|
|
276
279
|
]);
|
|
277
280
|
/** Implements normalize legacy extension action syntax for the public runtime surface of this module. */
|
|
278
281
|
export function normalizeLegacyExtensionActionSyntax(argv) {
|
|
279
|
-
const extensionIndex =
|
|
282
|
+
const extensionIndex = findBootstrapCommandTokenIndex(argv);
|
|
280
283
|
if (extensionIndex === undefined || argv[extensionIndex] !== "extension") {
|
|
281
284
|
return [...argv];
|
|
282
285
|
}
|
|
@@ -307,7 +310,7 @@ const CLI_EXECUTABLE_ALIASES = new Set(["pm", "pm-cli"]);
|
|
|
307
310
|
* `bunx <package> pm-cli init` behave like direct executable invocations.
|
|
308
311
|
*/
|
|
309
312
|
function stripLeadingExecutableAlias(argv, trace) {
|
|
310
|
-
const index =
|
|
313
|
+
const index = findBootstrapCommandTokenIndex(argv);
|
|
311
314
|
if (index === undefined) {
|
|
312
315
|
return argv;
|
|
313
316
|
}
|
|
@@ -331,7 +334,7 @@ function stripLeadingExecutableAlias(argv, trace) {
|
|
|
331
334
|
* value-consuming global flag, mirroring {@link parseBootstrapCommandName}.
|
|
332
335
|
*/
|
|
333
336
|
function rewriteCommandAlias(argv, trace) {
|
|
334
|
-
const index =
|
|
337
|
+
const index = findBootstrapCommandTokenIndex(argv);
|
|
335
338
|
if (index === undefined) {
|
|
336
339
|
return argv;
|
|
337
340
|
}
|
|
@@ -811,10 +814,22 @@ export function normalizeBootstrapInvocation(argv) {
|
|
|
811
814
|
});
|
|
812
815
|
}
|
|
813
816
|
const aliasNormalized = rewriteCommandAlias(legacyNormalized, trace);
|
|
814
|
-
const
|
|
815
|
-
|
|
817
|
+
const itemAddress = normalizeItemAddressInvocation(aliasNormalized);
|
|
818
|
+
if (itemAddress.conflict) {
|
|
819
|
+
throw new PmCliError("Provide the item id either positionally or with --id, not both.", EXIT_CODE.USAGE);
|
|
820
|
+
}
|
|
821
|
+
if (itemAddress.changed) {
|
|
822
|
+
trace.push({
|
|
823
|
+
from: `--id ${itemAddress.itemId}`,
|
|
824
|
+
to: [itemAddress.itemId],
|
|
825
|
+
reason: "item_id_alias",
|
|
826
|
+
confidence: "high",
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
const commandName = parseBootstrapCommandName(itemAddress.argv);
|
|
830
|
+
const commandPathName = parseBootstrapCommandPathName(itemAddress.argv);
|
|
816
831
|
const lookup = buildFlagLookup(commandPathName ?? commandName);
|
|
817
|
-
const normalizedArgv = normalizeBootstrapTokens(
|
|
832
|
+
const normalizedArgv = normalizeBootstrapTokens(itemAddress.argv, lookup, commandName, trace);
|
|
818
833
|
const linkedTestNormalized = mergeLinkedTestTwoTokenEntries(normalizedArgv, commandName, trace);
|
|
819
834
|
const coalesced = coalesceRepeatedListFlags(linkedTestNormalized, lookup.listCanonicalFlags, GLOBAL_VALUE_CONSUMING_FLAGS, commandName === "create" ? new Set(["--tags"]) : new Set());
|
|
820
835
|
for (const event of coalesced.events) {
|
|
@@ -871,4 +886,4 @@ export const _testOnly = {
|
|
|
871
886
|
resolveCanonicalFlag,
|
|
872
887
|
};
|
|
873
888
|
//# sourceMappingURL=cli-bootstrap.js.map
|
|
874
|
-
//# debugId=
|
|
889
|
+
//# debugId=eac8ed6b-43c4-54fa-820a-220154001a6b
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Creates commander option registration contracts using the validated operation inputs. */
|
|
2
2
|
|
|
3
|
-
!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
|
+
!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]="f7e87e15-b5f3-53ab-86e2-768e94d5d329")}catch(e){}}();
|
|
4
4
|
export const CREATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS = [
|
|
5
5
|
{
|
|
6
6
|
target: "title",
|
|
@@ -242,6 +242,12 @@ export const CREATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS = [
|
|
|
242
242
|
option: "--allow-missing-parent",
|
|
243
243
|
description: "Allow creating with an unresolved parent reference and emit a validation warning",
|
|
244
244
|
},
|
|
245
|
+
{
|
|
246
|
+
target: "allowUnresolvedDeps",
|
|
247
|
+
keys: ["allowUnresolvedDeps", "allow_unresolved_deps"],
|
|
248
|
+
option: "--allow-unresolved-deps",
|
|
249
|
+
description: "Allow unresolved local dependency targets and emit explicit warning receipts",
|
|
250
|
+
},
|
|
245
251
|
{
|
|
246
252
|
target: "reviewer",
|
|
247
253
|
keys: ["reviewer"],
|
|
@@ -620,7 +626,7 @@ export const UPDATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS = [
|
|
|
620
626
|
target: "acceptanceCriteria",
|
|
621
627
|
keys: ["acceptanceCriteria", "acceptance_criteria", "ac"],
|
|
622
628
|
option: "--acceptance-criteria <value>",
|
|
623
|
-
description: "
|
|
629
|
+
description: "Replace the complete acceptance-criteria list (repeatable values join with '; '); use --remove-ac plus --add-ac for one-entry repair",
|
|
624
630
|
repeatable: true,
|
|
625
631
|
aliasOptions: [
|
|
626
632
|
{
|
|
@@ -647,7 +653,7 @@ export const UPDATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS = [
|
|
|
647
653
|
target: "removeAc",
|
|
648
654
|
keys: ["removeAc", "remove_ac"],
|
|
649
655
|
option: "--remove-ac <value>",
|
|
650
|
-
description: "Remove one semicolon-free acceptance criterion by exact text match (repeatable)",
|
|
656
|
+
description: "Remove one semicolon-free acceptance criterion by exact text match; fails if any selector is unmatched (repeatable)",
|
|
651
657
|
repeatable: true,
|
|
652
658
|
aliasOptions: [
|
|
653
659
|
{ option: "--remove_ac <value>", description: "Alias for --remove-ac" },
|
|
@@ -746,6 +752,12 @@ export const UPDATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS = [
|
|
|
746
752
|
option: "--allow-missing-parent",
|
|
747
753
|
description: "Allow updating to an unresolved parent reference and emit a validation warning",
|
|
748
754
|
},
|
|
755
|
+
{
|
|
756
|
+
target: "allowUnresolvedDeps",
|
|
757
|
+
keys: ["allowUnresolvedDeps", "allow_unresolved_deps"],
|
|
758
|
+
option: "--allow-unresolved-deps",
|
|
759
|
+
description: "Allow unresolved local dependency targets and emit explicit warning receipts",
|
|
760
|
+
},
|
|
749
761
|
{
|
|
750
762
|
target: "completedAt",
|
|
751
763
|
keys: ["completedAt", "completed_at"],
|
|
@@ -1043,4 +1055,4 @@ export const UPDATE_COMMANDER_STRING_OPTION_CONTRACTS = UPDATE_COMMANDER_OPTION_
|
|
|
1043
1055
|
/** Public contract for update commander repeatable option contracts, shared by SDK and presentation-layer consumers. */
|
|
1044
1056
|
export const UPDATE_COMMANDER_REPEATABLE_OPTION_CONTRACTS = UPDATE_COMMANDER_OPTION_REGISTRATION_CONTRACTS.filter((entry) => entry.repeatable === true).map((entry) => ({ target: entry.target, keys: entry.keys }));
|
|
1045
1057
|
//# sourceMappingURL=commander-mutation-options.js.map
|
|
1046
|
-
//# debugId=
|
|
1058
|
+
//# debugId=f7e87e15-b5f3-53ab-86e2-768e94d5d329
|