@unbrained/pm-cli 2026.8.18 → 2026.8.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +2 -2
- package/CHANGELOG.md +35 -2
- package/dist/cli/error-guidance.js +3 -2
- package/dist/cli/help-content.js +32 -13
- package/dist/cli/help-json-payload.d.ts +15 -0
- package/dist/cli/help-json-payload.js +101 -23
- package/dist/cli/main.js +6 -2
- package/dist/cli/register-list-query.js +18 -13
- package/dist/cli/register-mutation.js +8 -8
- package/dist/cli/register-operations.js +6 -6
- package/dist/cli/register-structured-mutation.d.ts +2 -0
- package/dist/cli/register-structured-mutation.js +29 -6
- package/dist/cli-bundle/bundle-manifest.json +151 -143
- package/dist/cli-bundle/chunks/{chunk-UYCLQVL2.js → chunk-2RDVGYWE.js} +12 -12
- package/dist/cli-bundle/chunks/{chunk-BSK2IN3C.js → chunk-4GB2LTOQ.js} +2 -2
- package/dist/cli-bundle/chunks/{chunk-RZQTVMRQ.js → chunk-7BRF2BX2.js} +2 -2
- package/dist/cli-bundle/chunks/chunk-BLVQHFSY.js +35 -0
- package/dist/cli-bundle/chunks/chunk-CU25EQVV.js +5 -0
- package/dist/cli-bundle/chunks/chunk-K3EN3LK2.js +2 -0
- package/dist/cli-bundle/chunks/{chunk-YRGOLZA7.js → chunk-L4LGPBJU.js} +49 -49
- package/dist/cli-bundle/chunks/chunk-RS3IV2R6.js +197 -0
- package/dist/cli-bundle/chunks/chunk-TSMWLCHS.js +3 -0
- package/dist/cli-bundle/chunks/chunk-US2ZQW2M.js +77 -0
- package/dist/cli-bundle/chunks/{chunk-5UZZAJKR.js → chunk-XYDDWBZN.js} +2 -2
- package/dist/cli-bundle/chunks/register-list-query-JSAQCVOC.js +11 -0
- package/dist/cli-bundle/chunks/register-mutation-XJPAW63D.js +20 -0
- package/dist/cli-bundle/chunks/register-operations-DSOSB2XQ.js +2 -0
- package/dist/cli-bundle/chunks/{register-setup-PPPEF3SN.js → register-setup-QUR6QL2C.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-325UXIO7.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-5L7M4AI7.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-ODOVCP45.js → chunk-6AHG2YW7.js} +44 -44
- package/dist/cli-bundle/focused-chunks/chunk-AZBACT5T.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-TN4AE665.js → chunk-BLJCGGID.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-FUREQLQN.js +18 -0
- package/dist/cli-bundle/focused-chunks/{chunk-M62NO7EI.js → chunk-G3C5ERXG.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-K43KKAFS.js → chunk-GXWQBE3T.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-UI6AJ5TD.js → chunk-JWKEDZJI.js} +3 -3
- package/dist/cli-bundle/focused-chunks/chunk-KYZ6JGPL.js +155 -0
- package/dist/cli-bundle/focused-chunks/{chunk-EX6MKP2X.js → chunk-M32HFIQB.js} +2 -2
- package/dist/cli-bundle/focused-chunks/{chunk-EUEGXZ2A.js → chunk-OM65KHGF.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-Q47EX4DI.js +2 -0
- package/dist/cli-bundle/focused-chunks/{chunk-V5XTGLK7.js → chunk-RIHDMCUM.js} +2 -2
- package/dist/cli-bundle/focused-chunks/chunk-T4ZFY7ZJ.js +16 -0
- package/dist/cli-bundle/focused-chunks/chunk-TDR5OGG3.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-UGSS4F5X.js +2 -0
- package/dist/cli-bundle/focused-chunks/chunk-Z3PLWSGM.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 +2 -1
- package/dist/cli-bundle/sdk-core.js +41 -41
- 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 +32 -32
- 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 +5 -4
- package/dist/core/output/mutation-projection.js +26 -2
- package/dist/core/shared/constants.d.ts +1 -5
- package/dist/core/shared/constants.js +3 -81
- package/dist/core/shared/errors.d.ts +2 -0
- package/dist/core/shared/errors.js +2 -2
- package/dist/core/shared/item-metadata-contract.d.ts +14 -0
- package/dist/core/shared/item-metadata-contract.js +90 -0
- package/dist/core/store/item-store.d.ts +60 -0
- package/dist/core/store/item-store.js +22 -5
- package/dist/sdk/agent/closed-domain-contracts.d.ts +25 -0
- package/dist/sdk/agent/closed-domain-contracts.js +140 -0
- package/dist/sdk/agent/refusal-closure.d.ts +53 -0
- package/dist/sdk/agent/refusal-closure.js +134 -0
- package/dist/sdk/agent/refusal-reachability.d.ts +27 -1
- package/dist/sdk/agent/refusal-reachability.js +26 -2
- package/dist/sdk/agent-capability-contracts.d.ts +13 -0
- package/dist/sdk/agent-capability-contracts.js +101 -9
- package/dist/sdk/cli-contracts/command-aliases.js +18 -2
- package/dist/sdk/cli-contracts/commander-mutation-options.js +30 -6
- package/dist/sdk/cli-contracts/commander-types.js +5 -4
- package/dist/sdk/cli-contracts/completeness.js +8 -2
- package/dist/sdk/cli-contracts/enum-contracts.d.ts +4 -2
- package/dist/sdk/cli-contracts/enum-contracts.js +16 -6
- package/dist/sdk/cli-contracts/flag-contracts.d.ts +7 -0
- package/dist/sdk/cli-contracts/flag-contracts.js +84 -8
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.d.ts +72 -0
- package/dist/sdk/cli-contracts/flag-lexicon-contracts.js +340 -0
- package/dist/sdk/cli-contracts/grammar-contracts.d.ts +83 -2
- package/dist/sdk/cli-contracts/grammar-contracts.js +618 -2
- package/dist/sdk/cli-contracts/runtime-contracts.d.ts +15 -4
- package/dist/sdk/cli-contracts/runtime-contracts.js +47 -13
- package/dist/sdk/cli-contracts/tool-option-contracts.d.ts +28 -1
- package/dist/sdk/cli-contracts/tool-option-contracts.js +38 -3
- package/dist/sdk/cli-contracts/tool-schema.js +7 -2
- package/dist/sdk/cli-contracts.d.ts +4 -3
- package/dist/sdk/cli-contracts.js +6 -5
- package/dist/sdk/context-intent-contracts.d.ts +2 -2
- package/dist/sdk/context-intent-contracts.js +22 -7
- package/dist/sdk/contracts.d.ts +3 -0
- package/dist/sdk/contracts.js +5 -2
- package/dist/sdk/core.d.ts +1 -1
- package/dist/sdk/core.js +3 -3
- package/dist/sdk/flag-invocation-contracts.d.ts +37 -0
- package/dist/sdk/flag-invocation-contracts.js +218 -9
- package/dist/sdk/generated/generated-error-code-catalog-part-1.js +206 -2
- package/dist/sdk/generated/generated-error-code-catalog-part-2.js +244 -40
- package/dist/sdk/index.d.ts +11 -7
- package/dist/sdk/index.js +10 -6
- package/dist/sdk/init-agent-guidance.d.ts +5 -3
- package/dist/sdk/init-agent-guidance.js +69 -9
- package/dist/sdk/lifecycle/mcp-actions.d.ts +18 -0
- package/dist/sdk/lifecycle/mcp-actions.js +52 -0
- package/dist/sdk/lifecycle/reopen.d.ts +44 -0
- package/dist/sdk/lifecycle/reopen.js +69 -0
- package/dist/sdk/lifecycle/update.d.ts +31 -0
- package/dist/sdk/lifecycle/update.js +95 -13
- package/dist/sdk/output-projection.d.ts +2 -0
- package/dist/sdk/output-projection.js +11 -5
- package/dist/sdk/query/get.d.ts +1 -1
- package/dist/sdk/query/get.js +34 -49
- package/dist/sdk/query/list.d.ts +7 -21
- package/dist/sdk/query/list.js +44 -44
- package/dist/sdk/query/projection-contracts.d.ts +33 -0
- package/dist/sdk/query/projection-contracts.js +185 -0
- package/dist/sdk/query/search-contracts.d.ts +3 -2
- package/dist/sdk/query/search-contracts.js +30 -85
- package/dist/sdk/query/search.d.ts +15 -0
- package/dist/sdk/query/search.js +32 -6
- package/dist/sdk/read-output/continuation.d.ts +1 -1
- package/dist/sdk/read-output/continuation.js +7 -24
- package/dist/sdk/read-output-contracts.js +55 -6
- package/dist/sdk/read-output-rows.d.ts +4 -0
- package/dist/sdk/read-output-rows.js +47 -18
- package/dist/sdk/runtime-primitives.d.ts +1 -1
- package/dist/sdk/runtime-primitives.js +3 -3
- package/dist/sdk/runtime.d.ts +6 -0
- package/dist/sdk/runtime.js +25 -17
- package/dist/sdk/similarity.d.ts +13 -0
- package/dist/sdk/similarity.js +32 -6
- package/dist/sdk/workspace-snapshot.d.ts +2 -0
- package/dist/sdk/workspace-snapshot.js +10 -2
- package/docs/COMMANDS.md +29 -5
- package/docs/OUTPUT_PROJECTION_CONTRACTS.md +11 -2
- package/docs/README.md +1 -0
- package/docs/READ_OUTPUT_CONTRACTS.md +10 -6
- package/docs/RECURRENCE_RECOVERY_CONTRACTS.md +114 -0
- package/docs/SDK.md +16 -2
- package/docs/SDK_CONTEXT_INTEGRITY.md +45 -0
- package/docs/TESTING.md +14 -1
- package/docs/generated/AGENT_COMMAND_SURFACE.md +78 -78
- package/docs/generated/FLAG_LEXICON_BUDGETS.md +76 -0
- package/docs/performance/sdk-entrypoint-import-costs.md +14 -21
- package/marketplace.json +2 -2
- package/package.json +9 -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/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/scripts/generate-agent-capability-surfaces.mjs +20 -14
- package/sdk/public-surface.json +950 -24
- package/dist/cli-bundle/chunks/chunk-ALDJGKAK.js +0 -2
- package/dist/cli-bundle/chunks/chunk-DY4DMUMC.js +0 -197
- package/dist/cli-bundle/chunks/chunk-GNFAFIJI.js +0 -77
- package/dist/cli-bundle/chunks/chunk-L5Q2CLPE.js +0 -35
- package/dist/cli-bundle/chunks/chunk-PVRUN5ZS.js +0 -5
- package/dist/cli-bundle/chunks/chunk-SARFF5H5.js +0 -3
- package/dist/cli-bundle/chunks/register-list-query-I23LALEE.js +0 -11
- package/dist/cli-bundle/chunks/register-mutation-6YGU3GPH.js +0 -20
- package/dist/cli-bundle/chunks/register-operations-4HTFC6J7.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-2PN4TJXH.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-3TKWMNKF.js +0 -18
- package/dist/cli-bundle/focused-chunks/chunk-5AF3ZBNB.js +0 -155
- package/dist/cli-bundle/focused-chunks/chunk-C5IW2NDA.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-RNDNMARJ.js +0 -16
- package/dist/cli-bundle/focused-chunks/chunk-TVV2DONO.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-WGHQVU6P.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-XYNBXTDQ.js +0 -2
- package/dist/cli-bundle/focused-chunks/chunk-Z56ECT7I.js +0 -2
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Canonical top-level domains an agent must retain to route pm operations. */
|
|
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]="21495fd2-6abb-5a4f-965c-e7b9c8f87dff")}catch(e){}}();
|
|
4
4
|
export const PM_CLI_GRAMMAR_NOUNS = [
|
|
5
5
|
"item",
|
|
6
6
|
"list",
|
|
@@ -43,6 +43,7 @@ export const PM_CLI_SHARED_VERBS = [
|
|
|
43
43
|
"redact",
|
|
44
44
|
"reload",
|
|
45
45
|
"remove",
|
|
46
|
+
"reopen",
|
|
46
47
|
"repair",
|
|
47
48
|
"restore",
|
|
48
49
|
"run",
|
|
@@ -50,6 +51,495 @@ export const PM_CLI_SHARED_VERBS = [
|
|
|
50
51
|
"uninstall",
|
|
51
52
|
"verify",
|
|
52
53
|
];
|
|
54
|
+
function positionalSlot(name, valueKind, required, options = {}) {
|
|
55
|
+
return {
|
|
56
|
+
name,
|
|
57
|
+
required,
|
|
58
|
+
variadic: options.variadic === true,
|
|
59
|
+
value_kind: valueKind,
|
|
60
|
+
polymorphic: options.polymorphic === true,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Convert a kebab-case positional action into a sentence-leading verb phrase. */
|
|
64
|
+
function positionalActionVerb(action) {
|
|
65
|
+
const phrase = action.replaceAll("-", " ");
|
|
66
|
+
return `${phrase.charAt(0).toUpperCase()}${phrase.slice(1)}`;
|
|
67
|
+
}
|
|
68
|
+
const ITEM_ID = positionalSlot("id", "item_id", true);
|
|
69
|
+
const OPTIONAL_ITEM_ID = positionalSlot("id", "item_id", false);
|
|
70
|
+
const OPTIONAL_TEXT = positionalSlot("text", "string", false);
|
|
71
|
+
const PLAN_ITEM_ID = positionalSlot("plan-id", "item_id", true);
|
|
72
|
+
const PLAN_STEP = positionalSlot("step", "string", true);
|
|
73
|
+
const PLAN_CREATE_FLAGS = [
|
|
74
|
+
"--acceptance-criteria",
|
|
75
|
+
"--actual-result",
|
|
76
|
+
"--affected-version",
|
|
77
|
+
"--assignee",
|
|
78
|
+
"--blocked-by",
|
|
79
|
+
"--blocked-reason",
|
|
80
|
+
"--blocks",
|
|
81
|
+
"--body",
|
|
82
|
+
"--claim",
|
|
83
|
+
"--comment",
|
|
84
|
+
"--component",
|
|
85
|
+
"--confidence",
|
|
86
|
+
"--create-mode",
|
|
87
|
+
"--customer-impact",
|
|
88
|
+
"--deadline",
|
|
89
|
+
"--definition-of-ready",
|
|
90
|
+
"--description",
|
|
91
|
+
"--doc",
|
|
92
|
+
"--environment",
|
|
93
|
+
"--estimate",
|
|
94
|
+
"--event",
|
|
95
|
+
"--expected-result",
|
|
96
|
+
"--fixed-version",
|
|
97
|
+
"--file",
|
|
98
|
+
"--from-search",
|
|
99
|
+
"--goal",
|
|
100
|
+
"--harness",
|
|
101
|
+
"--impact",
|
|
102
|
+
"--learning",
|
|
103
|
+
"--message",
|
|
104
|
+
"--mode",
|
|
105
|
+
"--note",
|
|
106
|
+
"--objective",
|
|
107
|
+
"--order",
|
|
108
|
+
"--outcome",
|
|
109
|
+
"--parent",
|
|
110
|
+
"--priority",
|
|
111
|
+
"--rank",
|
|
112
|
+
"--related",
|
|
113
|
+
"--release",
|
|
114
|
+
"--reminder",
|
|
115
|
+
"--reporter",
|
|
116
|
+
"--repro-steps",
|
|
117
|
+
"--resolution",
|
|
118
|
+
"--resume-context",
|
|
119
|
+
"--reviewer",
|
|
120
|
+
"--risk",
|
|
121
|
+
"--scope",
|
|
122
|
+
"--severity",
|
|
123
|
+
"--sprint",
|
|
124
|
+
"--status",
|
|
125
|
+
"--step",
|
|
126
|
+
"--step-blocked-reason",
|
|
127
|
+
"--step-body",
|
|
128
|
+
"--step-evidence",
|
|
129
|
+
"--step-owner",
|
|
130
|
+
"--step-replacement",
|
|
131
|
+
"--step-status",
|
|
132
|
+
"--step-title",
|
|
133
|
+
"--tags",
|
|
134
|
+
"--template",
|
|
135
|
+
"--test",
|
|
136
|
+
"--title",
|
|
137
|
+
"--type-option",
|
|
138
|
+
"--unblock-note",
|
|
139
|
+
"--value",
|
|
140
|
+
"--why-now",
|
|
141
|
+
];
|
|
142
|
+
const PLAN_STEP_FLAGS = [
|
|
143
|
+
"--allow-multiple-active",
|
|
144
|
+
"--depends-on",
|
|
145
|
+
"--file",
|
|
146
|
+
"--force",
|
|
147
|
+
"--message",
|
|
148
|
+
"--step-blocked-reason",
|
|
149
|
+
"--step-body",
|
|
150
|
+
"--step-evidence",
|
|
151
|
+
"--step-owner",
|
|
152
|
+
"--step-status",
|
|
153
|
+
"--step-title",
|
|
154
|
+
"--test",
|
|
155
|
+
];
|
|
156
|
+
const PLAN_STEP_ACTION_DESCRIPTIONS = {
|
|
157
|
+
"update-step": "Update one declared Plan step.",
|
|
158
|
+
"complete-step": "Complete one declared Plan step.",
|
|
159
|
+
"block-step": "Block one declared Plan step.",
|
|
160
|
+
"remove-step": "Remove one declared Plan step.",
|
|
161
|
+
link: "Link one dependency to a declared Plan step.",
|
|
162
|
+
unlink: "Unlink one dependency from a declared Plan step.",
|
|
163
|
+
};
|
|
164
|
+
/** Virtual action paths dispatched by positional parent commands. */
|
|
165
|
+
export const PM_POSITIONAL_ACTION_CONTRACTS = [
|
|
166
|
+
{
|
|
167
|
+
command: "plan create",
|
|
168
|
+
parent: "plan",
|
|
169
|
+
action: "create",
|
|
170
|
+
slots: [positionalSlot("title", "string", false, { polymorphic: true })],
|
|
171
|
+
accepted_flags: PLAN_CREATE_FLAGS,
|
|
172
|
+
description: "Create a Plan item and optionally seed its ordered steps.",
|
|
173
|
+
example: 'pm plan create --title "Refactor lock retry"',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
command: "plan show",
|
|
177
|
+
parent: "plan",
|
|
178
|
+
action: "show",
|
|
179
|
+
slots: [PLAN_ITEM_ID],
|
|
180
|
+
accepted_flags: ["--depth", "--fields"],
|
|
181
|
+
description: "Read one Plan item with a bounded plan projection.",
|
|
182
|
+
example: "pm plan show pm-a1b2 --depth standard",
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
command: "plan add-step",
|
|
186
|
+
parent: "plan",
|
|
187
|
+
action: "add-step",
|
|
188
|
+
slots: [PLAN_ITEM_ID],
|
|
189
|
+
accepted_flags: PLAN_STEP_FLAGS,
|
|
190
|
+
description: "Append one ordered step to a Plan item.",
|
|
191
|
+
example: 'pm plan add-step pm-a1b2 --step-title "Run tests"',
|
|
192
|
+
},
|
|
193
|
+
...Object.entries(PLAN_STEP_ACTION_DESCRIPTIONS).map(([action, description]) => ({
|
|
194
|
+
command: `plan ${action}`,
|
|
195
|
+
parent: "plan",
|
|
196
|
+
action,
|
|
197
|
+
slots: [PLAN_ITEM_ID, PLAN_STEP],
|
|
198
|
+
accepted_flags: PLAN_STEP_FLAGS,
|
|
199
|
+
description,
|
|
200
|
+
example: `pm plan ${action} pm-a1b2 plan-step-001`,
|
|
201
|
+
})),
|
|
202
|
+
{
|
|
203
|
+
command: "plan reorder-step",
|
|
204
|
+
parent: "plan",
|
|
205
|
+
action: "reorder-step",
|
|
206
|
+
slots: [
|
|
207
|
+
PLAN_ITEM_ID,
|
|
208
|
+
PLAN_STEP,
|
|
209
|
+
positionalSlot("new-order", "integer", true),
|
|
210
|
+
],
|
|
211
|
+
accepted_flags: ["--force", "--message"],
|
|
212
|
+
description: "Move one Plan step to a declared integer order.",
|
|
213
|
+
example: "pm plan reorder-step pm-a1b2 plan-step-001 2",
|
|
214
|
+
},
|
|
215
|
+
...[
|
|
216
|
+
"decision",
|
|
217
|
+
"discovery",
|
|
218
|
+
"validation",
|
|
219
|
+
"resume",
|
|
220
|
+
"approve",
|
|
221
|
+
"materialize",
|
|
222
|
+
].map((action) => ({
|
|
223
|
+
command: `plan ${action}`,
|
|
224
|
+
parent: "plan",
|
|
225
|
+
action,
|
|
226
|
+
slots: [PLAN_ITEM_ID],
|
|
227
|
+
accepted_flags: PLAN_STEP_FLAGS,
|
|
228
|
+
description: `${positionalActionVerb(action)} for one Plan item.`,
|
|
229
|
+
example: `pm plan ${action} pm-a1b2`,
|
|
230
|
+
})),
|
|
231
|
+
...["list", "show", "put", "remove"].map((action) => ({
|
|
232
|
+
command: `assurance ${action}`,
|
|
233
|
+
parent: "assurance",
|
|
234
|
+
action,
|
|
235
|
+
slots: [
|
|
236
|
+
positionalSlot("kind", "string", true),
|
|
237
|
+
...(action === "list" ? [] : [positionalSlot("id", "string", true)]),
|
|
238
|
+
],
|
|
239
|
+
accepted_flags: action === "put"
|
|
240
|
+
? ["--author", "--definition", "--message"]
|
|
241
|
+
: action === "remove"
|
|
242
|
+
? ["--author", "--message"]
|
|
243
|
+
: [],
|
|
244
|
+
description: `${positionalActionVerb(action)} assurance declarations by kind.`,
|
|
245
|
+
example: action === "list"
|
|
246
|
+
? "pm assurance list measurement"
|
|
247
|
+
: `pm assurance ${action} measurement example-id`,
|
|
248
|
+
})),
|
|
249
|
+
{
|
|
250
|
+
command: "assurance run",
|
|
251
|
+
parent: "assurance",
|
|
252
|
+
action: "run",
|
|
253
|
+
slots: [positionalSlot("gate-id", "string", true)],
|
|
254
|
+
accepted_flags: ["--dry-run", "--trigger", "--tree"],
|
|
255
|
+
description: "Evaluate one assurance gate for a lifecycle trigger.",
|
|
256
|
+
example: "pm assurance run tracker-context-quality --trigger ci --dry-run",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
command: "assurance verdicts",
|
|
260
|
+
parent: "assurance",
|
|
261
|
+
action: "verdicts",
|
|
262
|
+
slots: [positionalSlot("gate-id", "string", false)],
|
|
263
|
+
accepted_flags: ["--gate", "--limit"],
|
|
264
|
+
description: "List bounded assurance verdict history.",
|
|
265
|
+
example: "pm assurance verdicts --limit 20",
|
|
266
|
+
},
|
|
267
|
+
...["presets", "apply"].map((action) => ({
|
|
268
|
+
command: `assurance ${action}`,
|
|
269
|
+
parent: "assurance",
|
|
270
|
+
action,
|
|
271
|
+
slots: [positionalSlot("preset", "string", action === "apply")],
|
|
272
|
+
accepted_flags: ["--author", "--message", "--owner"],
|
|
273
|
+
description: action === "apply"
|
|
274
|
+
? "Apply one assurance adoption preset."
|
|
275
|
+
: "List available assurance adoption presets.",
|
|
276
|
+
example: action === "apply"
|
|
277
|
+
? "pm assurance apply software-delivery --owner <pm-item-id>"
|
|
278
|
+
: "pm assurance presets",
|
|
279
|
+
})),
|
|
280
|
+
{
|
|
281
|
+
command: "assurance derive",
|
|
282
|
+
parent: "assurance",
|
|
283
|
+
action: "derive",
|
|
284
|
+
slots: [],
|
|
285
|
+
accepted_flags: ["--apply", "--author", "--message", "--owner"],
|
|
286
|
+
description: "Derive assurance proposals from current project context.",
|
|
287
|
+
example: "pm assurance derive --owner pm-a1b2",
|
|
288
|
+
},
|
|
289
|
+
{
|
|
290
|
+
command: "assurance promote",
|
|
291
|
+
parent: "assurance",
|
|
292
|
+
action: "promote",
|
|
293
|
+
slots: [positionalSlot("assertion-id", "string", true)],
|
|
294
|
+
accepted_flags: ["--author", "--enforcement", "--message"],
|
|
295
|
+
description: "Promote one assertion into a warning or blocking gate.",
|
|
296
|
+
example: "pm assurance promote assertion-id --enforcement warn",
|
|
297
|
+
},
|
|
298
|
+
{
|
|
299
|
+
command: "assurance risk",
|
|
300
|
+
parent: "assurance",
|
|
301
|
+
action: "risk",
|
|
302
|
+
slots: [],
|
|
303
|
+
accepted_flags: ["--definition"],
|
|
304
|
+
description: "Analyze bounded defect-recurrence risk for a proposed change.",
|
|
305
|
+
example: 'pm assurance risk --definition \'{"change":{"files":[]}}\'',
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
command: "workspace snapshot create",
|
|
309
|
+
parent: "workspace snapshot",
|
|
310
|
+
action: "create",
|
|
311
|
+
slots: [positionalSlot("name", "string", false)],
|
|
312
|
+
accepted_flags: [],
|
|
313
|
+
description: "Capture authoritative tracker state as an immutable snapshot.",
|
|
314
|
+
example: "pm workspace snapshot create before-migration",
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
command: "workspace snapshot list",
|
|
318
|
+
parent: "workspace snapshot",
|
|
319
|
+
action: "list",
|
|
320
|
+
slots: [],
|
|
321
|
+
accepted_flags: [],
|
|
322
|
+
description: "List immutable workspace snapshots and named references.",
|
|
323
|
+
example: "pm workspace snapshot list",
|
|
324
|
+
},
|
|
325
|
+
{
|
|
326
|
+
command: "workspace snapshot inspect",
|
|
327
|
+
parent: "workspace snapshot",
|
|
328
|
+
action: "inspect",
|
|
329
|
+
slots: [positionalSlot("target", "string", true)],
|
|
330
|
+
accepted_flags: [],
|
|
331
|
+
description: "Inspect one workspace snapshot target.",
|
|
332
|
+
example: "pm workspace snapshot inspect before-migration",
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
command: "workspace snapshot restore",
|
|
336
|
+
parent: "workspace snapshot",
|
|
337
|
+
action: "restore",
|
|
338
|
+
slots: [positionalSlot("target", "string", true)],
|
|
339
|
+
accepted_flags: ["--author", "--dry-run", "--force", "--message"],
|
|
340
|
+
description: "Restore an immutable workspace snapshot with explicit recovery controls.",
|
|
341
|
+
example: "pm workspace snapshot restore before-migration --dry-run",
|
|
342
|
+
},
|
|
343
|
+
{
|
|
344
|
+
command: "workspace snapshot delete",
|
|
345
|
+
parent: "workspace snapshot",
|
|
346
|
+
action: "delete",
|
|
347
|
+
slots: [positionalSlot("target", "string", true)],
|
|
348
|
+
accepted_flags: [],
|
|
349
|
+
description: "Delete one workspace snapshot target.",
|
|
350
|
+
example: "pm workspace snapshot delete before-migration",
|
|
351
|
+
},
|
|
352
|
+
];
|
|
353
|
+
const POSITIONAL_ACTION_CONTRACTS_BY_SPECIFICITY = [
|
|
354
|
+
...PM_POSITIONAL_ACTION_CONTRACTS,
|
|
355
|
+
].sort((left, right) => right.command.length - left.command.length);
|
|
356
|
+
const EXPLICIT_POSITIONAL_SLOTS = new Map([
|
|
357
|
+
["append", [ITEM_ID, OPTIONAL_TEXT]],
|
|
358
|
+
[
|
|
359
|
+
"assurance",
|
|
360
|
+
[
|
|
361
|
+
positionalSlot("action", "action", true),
|
|
362
|
+
positionalSlot("kind", "string", false),
|
|
363
|
+
positionalSlot("id", "string", false),
|
|
364
|
+
],
|
|
365
|
+
],
|
|
366
|
+
["beads import", [positionalSlot("file", "string", false)]],
|
|
367
|
+
["changelog export", [positionalSlot("file", "string", false)]],
|
|
368
|
+
["claim", [OPTIONAL_ITEM_ID]],
|
|
369
|
+
["close", [ITEM_ID, OPTIONAL_TEXT]],
|
|
370
|
+
["close-task", [ITEM_ID, positionalSlot("reason", "string", false)]],
|
|
371
|
+
["comments", [ITEM_ID, OPTIONAL_TEXT]],
|
|
372
|
+
["completion", [positionalSlot("shell", "string", false)]],
|
|
373
|
+
[
|
|
374
|
+
"config",
|
|
375
|
+
[
|
|
376
|
+
positionalSlot("scope", "string", false, { polymorphic: true }),
|
|
377
|
+
positionalSlot("action", "action", false),
|
|
378
|
+
positionalSlot("key", "string", false),
|
|
379
|
+
positionalSlot("value", "string", false, { polymorphic: true }),
|
|
380
|
+
],
|
|
381
|
+
],
|
|
382
|
+
["copy", [ITEM_ID]],
|
|
383
|
+
[
|
|
384
|
+
"create",
|
|
385
|
+
[
|
|
386
|
+
positionalSlot("type-or-title", "string", false, { polymorphic: true }),
|
|
387
|
+
positionalSlot("title", "string", false),
|
|
388
|
+
],
|
|
389
|
+
],
|
|
390
|
+
["delete", [ITEM_ID]],
|
|
391
|
+
["deps", [ITEM_ID]],
|
|
392
|
+
["docs", [ITEM_ID]],
|
|
393
|
+
["event", [positionalSlot("title", "string", true)]],
|
|
394
|
+
[
|
|
395
|
+
"extension",
|
|
396
|
+
[positionalSlot("target", "string", false, { polymorphic: true })],
|
|
397
|
+
],
|
|
398
|
+
["extension list", []],
|
|
399
|
+
["extension scaffold", [positionalSlot("target", "string", true)]],
|
|
400
|
+
["files", [ITEM_ID]],
|
|
401
|
+
["files discover", [ITEM_ID]],
|
|
402
|
+
[
|
|
403
|
+
"files lookup",
|
|
404
|
+
[positionalSlot("paths", "string", true, { variadic: true })],
|
|
405
|
+
],
|
|
406
|
+
["focus", [OPTIONAL_ITEM_ID]],
|
|
407
|
+
["get", [ITEM_ID]],
|
|
408
|
+
[
|
|
409
|
+
"graph",
|
|
410
|
+
[
|
|
411
|
+
positionalSlot("subcommand", "action", true),
|
|
412
|
+
OPTIONAL_ITEM_ID,
|
|
413
|
+
positionalSlot("target", "item_id", false),
|
|
414
|
+
],
|
|
415
|
+
],
|
|
416
|
+
["guide", [positionalSlot("topic", "string", false)]],
|
|
417
|
+
["history", [ITEM_ID]],
|
|
418
|
+
["history-compact", [OPTIONAL_ITEM_ID]],
|
|
419
|
+
["history-redact", [ITEM_ID]],
|
|
420
|
+
["history-repair", [OPTIONAL_ITEM_ID]],
|
|
421
|
+
[
|
|
422
|
+
"init",
|
|
423
|
+
[positionalSlot("prefix-or-path", "string", false, { polymorphic: true })],
|
|
424
|
+
],
|
|
425
|
+
["install", [positionalSlot("targets", "string", false, { variadic: true })]],
|
|
426
|
+
["item complete", [ITEM_ID, positionalSlot("reason", "string", false)]],
|
|
427
|
+
["item reopen", [ITEM_ID, positionalSlot("reason", "string", true)]],
|
|
428
|
+
["learnings", [ITEM_ID, OPTIONAL_TEXT]],
|
|
429
|
+
["meet", [positionalSlot("title", "string", true)]],
|
|
430
|
+
[
|
|
431
|
+
"merge",
|
|
432
|
+
[
|
|
433
|
+
positionalSlot("subcommand", "action", true),
|
|
434
|
+
positionalSlot("artifact", "string", false),
|
|
435
|
+
positionalSlot("base", "string", false),
|
|
436
|
+
positionalSlot("ours", "string", false),
|
|
437
|
+
positionalSlot("theirs", "string", false),
|
|
438
|
+
],
|
|
439
|
+
],
|
|
440
|
+
["notes", [ITEM_ID, OPTIONAL_TEXT]],
|
|
441
|
+
[
|
|
442
|
+
"package",
|
|
443
|
+
[positionalSlot("target", "string", false, { polymorphic: true })],
|
|
444
|
+
],
|
|
445
|
+
["package list", []],
|
|
446
|
+
["package scaffold", [positionalSlot("target", "string", true)]],
|
|
447
|
+
[
|
|
448
|
+
"packages",
|
|
449
|
+
[positionalSlot("target", "string", false, { polymorphic: true })],
|
|
450
|
+
],
|
|
451
|
+
["packages list", []],
|
|
452
|
+
["packages scaffold", [positionalSlot("target", "string", true)]],
|
|
453
|
+
["pause-task", [ITEM_ID]],
|
|
454
|
+
[
|
|
455
|
+
"plan",
|
|
456
|
+
[
|
|
457
|
+
positionalSlot("subcommand", "action", true),
|
|
458
|
+
positionalSlot("id", "item_id", false, { polymorphic: true }),
|
|
459
|
+
positionalSlot("step", "string", false),
|
|
460
|
+
positionalSlot("new-order", "integer", false),
|
|
461
|
+
],
|
|
462
|
+
],
|
|
463
|
+
[
|
|
464
|
+
"profile",
|
|
465
|
+
[
|
|
466
|
+
positionalSlot("subcommand", "action", true),
|
|
467
|
+
positionalSlot("name", "string", false),
|
|
468
|
+
],
|
|
469
|
+
],
|
|
470
|
+
["release", [ITEM_ID]],
|
|
471
|
+
["remind", [positionalSlot("title", "string", true)]],
|
|
472
|
+
["restore", [ITEM_ID, positionalSlot("target", "string", true)]],
|
|
473
|
+
[
|
|
474
|
+
"schema",
|
|
475
|
+
[
|
|
476
|
+
positionalSlot("subcommand", "action", true),
|
|
477
|
+
positionalSlot("name", "string", false),
|
|
478
|
+
],
|
|
479
|
+
],
|
|
480
|
+
[
|
|
481
|
+
"search-advanced",
|
|
482
|
+
[positionalSlot("keywords", "string", true, { variadic: true })],
|
|
483
|
+
],
|
|
484
|
+
["search", [positionalSlot("keywords", "string", true, { variadic: true })]],
|
|
485
|
+
["start-task", [ITEM_ID]],
|
|
486
|
+
[
|
|
487
|
+
"telemetry",
|
|
488
|
+
[
|
|
489
|
+
positionalSlot("namespace-or-subcommand", "action", false, {
|
|
490
|
+
polymorphic: true,
|
|
491
|
+
}),
|
|
492
|
+
positionalSlot("subcommand", "action", false),
|
|
493
|
+
],
|
|
494
|
+
],
|
|
495
|
+
["test", [ITEM_ID]],
|
|
496
|
+
["update", [ITEM_ID]],
|
|
497
|
+
["upgrade", [positionalSlot("target", "string", false)]],
|
|
498
|
+
[
|
|
499
|
+
"workspace snapshot",
|
|
500
|
+
[
|
|
501
|
+
positionalSlot("action", "action", true),
|
|
502
|
+
positionalSlot("target", "string", false),
|
|
503
|
+
],
|
|
504
|
+
],
|
|
505
|
+
...["activate", "adopt", "deactivate", "init", "uninstall"].flatMap((action) => ["extension", "package", "packages"].map((root) => [
|
|
506
|
+
`${root} ${action}`,
|
|
507
|
+
[positionalSlot("target", "string", true)],
|
|
508
|
+
])),
|
|
509
|
+
...["describe"].flatMap((action) => ["extension", "package", "packages"].map((root) => [
|
|
510
|
+
`${root} ${action}`,
|
|
511
|
+
[positionalSlot("target", "string", false)],
|
|
512
|
+
])),
|
|
513
|
+
...["install"].flatMap((action) => ["extension", "package", "packages"].map((root) => [
|
|
514
|
+
`${root} ${action}`,
|
|
515
|
+
[positionalSlot("targets", "string", false, { variadic: true })],
|
|
516
|
+
])),
|
|
517
|
+
["vcs abandon", [ITEM_ID]],
|
|
518
|
+
["vcs create", [positionalSlot("title", "string", true)]],
|
|
519
|
+
["vcs merge", [ITEM_ID]],
|
|
520
|
+
["vcs propose", [ITEM_ID]],
|
|
521
|
+
["vcs ref-create", [positionalSlot("name", "string", true)]],
|
|
522
|
+
["vcs show", [ITEM_ID]],
|
|
523
|
+
]);
|
|
524
|
+
/** Normalize a command path for every positional-contract lookup and identity check. */
|
|
525
|
+
function normalizePositionalCommandPath(command) {
|
|
526
|
+
return command.trim().toLowerCase().replace(/\s+/gu, " ");
|
|
527
|
+
}
|
|
528
|
+
/** Resolve one declared signature without treating arbitrary object keys as commands. */
|
|
529
|
+
export function resolvePmCommandPositionalContract(command) {
|
|
530
|
+
const normalized = normalizePositionalCommandPath(command);
|
|
531
|
+
return PM_COMMAND_POSITIONAL_CONTRACTS.find((contract) => contract.command === normalized);
|
|
532
|
+
}
|
|
533
|
+
/** Resolve one action-specific help/contract view. */
|
|
534
|
+
export function resolvePmPositionalActionContract(command) {
|
|
535
|
+
const normalized = normalizePositionalCommandPath(command);
|
|
536
|
+
return POSITIONAL_ACTION_CONTRACTS_BY_SPECIFICITY.find((contract) => contract.command === normalized ||
|
|
537
|
+
normalized.startsWith(`${contract.command} `));
|
|
538
|
+
}
|
|
539
|
+
/** Format the shared action-flag tip rendered by text and structured help. */
|
|
540
|
+
export function formatPmPositionalActionFlagTip(acceptedFlags) {
|
|
541
|
+
return `Applicable flags: ${acceptedFlags.length > 0 ? acceptedFlags.join(", ") : "none"}.`;
|
|
542
|
+
}
|
|
53
543
|
function destinationRows(noun, target, disposition, owner, commands) {
|
|
54
544
|
return commands.map((command) => ({
|
|
55
545
|
command,
|
|
@@ -65,6 +555,7 @@ export const PM_COMMAND_DESTINATION_CONTRACTS = [
|
|
|
65
555
|
"item",
|
|
66
556
|
"item complete",
|
|
67
557
|
"item mutate",
|
|
558
|
+
"item reopen",
|
|
68
559
|
]),
|
|
69
560
|
...destinationRows("item", "item", "consolidation", "pm-yql1", [
|
|
70
561
|
"append",
|
|
@@ -88,6 +579,10 @@ export const PM_COMMAND_DESTINATION_CONTRACTS = [
|
|
|
88
579
|
"update",
|
|
89
580
|
"update-many",
|
|
90
581
|
]),
|
|
582
|
+
...destinationRows("item", "item files", "consolidation", "pm-ya7x55", [
|
|
583
|
+
"files discover",
|
|
584
|
+
"files lookup",
|
|
585
|
+
]),
|
|
91
586
|
...destinationRows("list", "list", "target_noun", "pm-pfqi", ["list"]),
|
|
92
587
|
...destinationRows("list", "list --group-by", "consolidation", "pm-xkgq", [
|
|
93
588
|
"aggregate",
|
|
@@ -153,9 +648,11 @@ export const PM_COMMAND_DESTINATION_CONTRACTS = [
|
|
|
153
648
|
"package explore",
|
|
154
649
|
"package init",
|
|
155
650
|
"package install",
|
|
651
|
+
"package list",
|
|
156
652
|
"package manage",
|
|
157
653
|
"package migrate",
|
|
158
654
|
"package reload",
|
|
655
|
+
"package scaffold",
|
|
159
656
|
"package uninstall",
|
|
160
657
|
]),
|
|
161
658
|
...destinationRows("package", "package", "consolidation", "pm-tnud", [
|
|
@@ -170,9 +667,11 @@ export const PM_COMMAND_DESTINATION_CONTRACTS = [
|
|
|
170
667
|
"extension explore",
|
|
171
668
|
"extension init",
|
|
172
669
|
"extension install",
|
|
670
|
+
"extension list",
|
|
173
671
|
"extension manage",
|
|
174
672
|
"extension migrate",
|
|
175
673
|
"extension reload",
|
|
674
|
+
"extension scaffold",
|
|
176
675
|
"extension uninstall",
|
|
177
676
|
"install",
|
|
178
677
|
"packages",
|
|
@@ -186,9 +685,11 @@ export const PM_COMMAND_DESTINATION_CONTRACTS = [
|
|
|
186
685
|
"packages explore",
|
|
187
686
|
"packages init",
|
|
188
687
|
"packages install",
|
|
688
|
+
"packages list",
|
|
189
689
|
"packages manage",
|
|
190
690
|
"packages migrate",
|
|
191
691
|
"packages reload",
|
|
692
|
+
"packages scaffold",
|
|
192
693
|
"packages uninstall",
|
|
193
694
|
"upgrade",
|
|
194
695
|
]),
|
|
@@ -210,7 +711,9 @@ export const PM_COMMAND_DESTINATION_CONTRACTS = [
|
|
|
210
711
|
"test-all",
|
|
211
712
|
"validate",
|
|
212
713
|
]),
|
|
714
|
+
...destinationRows("ops", "ops assurance", "consolidation", "pm-2tan", PM_POSITIONAL_ACTION_CONTRACTS.filter(({ parent }) => parent === "assurance").map(({ command }) => command)),
|
|
213
715
|
...destinationRows("plan", "plan", "target_noun", "pm-pbyu", ["plan"]),
|
|
716
|
+
...destinationRows("plan", "plan", "target_noun", "pm-2tan", PM_POSITIONAL_ACTION_CONTRACTS.filter(({ parent }) => parent === "plan").map(({ command }) => command)),
|
|
214
717
|
...destinationRows("contracts", "contracts", "target_noun", "pm-pbyu", [
|
|
215
718
|
"contracts",
|
|
216
719
|
]),
|
|
@@ -223,6 +726,15 @@ export const PM_COMMAND_DESTINATION_CONTRACTS = [
|
|
|
223
726
|
"guide",
|
|
224
727
|
]),
|
|
225
728
|
];
|
|
729
|
+
/** Exhaustive current command and positional-action signature table. */
|
|
730
|
+
export const PM_COMMAND_POSITIONAL_CONTRACTS = [
|
|
731
|
+
...new Set(PM_COMMAND_DESTINATION_CONTRACTS.map(({ command }) => command)),
|
|
732
|
+
].map((command) => ({
|
|
733
|
+
command,
|
|
734
|
+
slots: resolvePmPositionalActionContract(command)?.slots ??
|
|
735
|
+
EXPLICIT_POSITIONAL_SLOTS.get(command) ??
|
|
736
|
+
[],
|
|
737
|
+
}));
|
|
226
738
|
/** Immutable grammar policy used by contracts and the CI gate. */
|
|
227
739
|
export const PM_CLI_GRAMMAR_CONTRACT = {
|
|
228
740
|
nouns: PM_CLI_GRAMMAR_NOUNS,
|
|
@@ -230,7 +742,111 @@ export const PM_CLI_GRAMMAR_CONTRACT = {
|
|
|
230
742
|
scope_before_verb: true,
|
|
231
743
|
visible_top_level_ceiling: 69,
|
|
232
744
|
ceiling_raise_requires_pm_item: true,
|
|
745
|
+
positional_shape_budget: 21,
|
|
233
746
|
};
|
|
747
|
+
/** Report explicit positional entries that no destination command declares. */
|
|
748
|
+
export function verifyExplicitPositionalSlotCensus(explicitCommands, destinationCommands) {
|
|
749
|
+
const destinations = new Set(destinationCommands);
|
|
750
|
+
return [...new Set(explicitCommands)]
|
|
751
|
+
.filter((command) => !destinations.has(command))
|
|
752
|
+
.map((command) => ({
|
|
753
|
+
code: "positional_signature_mismatch",
|
|
754
|
+
command,
|
|
755
|
+
detail: `Positional signature ${command} has no destination declaration.`,
|
|
756
|
+
}));
|
|
757
|
+
}
|
|
758
|
+
/** Return the semantic shape identity used by the positional-shape budget. */
|
|
759
|
+
export function positionalShapeKey(slots) {
|
|
760
|
+
return slots
|
|
761
|
+
.map(({ required, variadic, value_kind: valueKind, polymorphic }) => `${required ? "r" : "o"}:${variadic ? "v" : "s"}:${valueKind}:${polymorphic ? "p" : "m"}`)
|
|
762
|
+
.join("|");
|
|
763
|
+
}
|
|
764
|
+
/** Return the exact canonical identity of an ordered positional signature. */
|
|
765
|
+
export function positionalSignatureKey(slots) {
|
|
766
|
+
return slots
|
|
767
|
+
.map(({ name, required, variadic, value_kind: valueKind, polymorphic }) => `${name}:${required ? "r" : "o"}:${variadic ? "v" : "s"}:${valueKind}:${polymorphic ? "p" : "m"}`)
|
|
768
|
+
.join("|");
|
|
769
|
+
}
|
|
770
|
+
/** Return one deterministic finding for every repeated command path. */
|
|
771
|
+
function duplicatePositionalSignatureFindings(contracts, surface) {
|
|
772
|
+
const counts = new Map();
|
|
773
|
+
for (const { command } of contracts) {
|
|
774
|
+
const normalized = normalizePositionalCommandPath(command);
|
|
775
|
+
counts.set(normalized, (counts.get(normalized) ?? 0) + 1);
|
|
776
|
+
}
|
|
777
|
+
return [...counts.entries()]
|
|
778
|
+
.filter(([, count]) => count > 1)
|
|
779
|
+
.map(([command, count]) => ({
|
|
780
|
+
code: "positional_signature_mismatch",
|
|
781
|
+
command,
|
|
782
|
+
detail: `${count} ${surface} positional signatures exist for ${command}; exactly one is required.`,
|
|
783
|
+
}));
|
|
784
|
+
}
|
|
785
|
+
/** Compare independently observed Commander signatures with the SDK declaration. */
|
|
786
|
+
export function verifyPmCommandPositionalContracts(observed, options = {}) {
|
|
787
|
+
const declared = options.declared ?? PM_COMMAND_POSITIONAL_CONTRACTS;
|
|
788
|
+
const positionalShapeBudget = options.positionalShapeBudget ??
|
|
789
|
+
PM_CLI_GRAMMAR_CONTRACT.positional_shape_budget;
|
|
790
|
+
const declaredByCommand = new Map(declared.map((contract) => [normalizePositionalCommandPath(contract.command), contract]));
|
|
791
|
+
const observedByCommand = new Map(observed.map((contract) => [normalizePositionalCommandPath(contract.command), contract]));
|
|
792
|
+
const findings = [
|
|
793
|
+
...duplicatePositionalSignatureFindings(declared, "declared"),
|
|
794
|
+
...duplicatePositionalSignatureFindings(observed, "observed"),
|
|
795
|
+
...(options.declared === undefined
|
|
796
|
+
? [
|
|
797
|
+
...verifyExplicitPositionalSlotCensus(EXPLICIT_POSITIONAL_SLOTS.keys(), PM_COMMAND_DESTINATION_CONTRACTS.map(({ command }) => command)),
|
|
798
|
+
...verifyExplicitPositionalSlotCensus(PM_POSITIONAL_ACTION_CONTRACTS.map(({ command }) => command), PM_COMMAND_DESTINATION_CONTRACTS.map(({ command }) => command)),
|
|
799
|
+
]
|
|
800
|
+
: []),
|
|
801
|
+
];
|
|
802
|
+
for (const contract of declaredByCommand.values()) {
|
|
803
|
+
const normalizedCommand = normalizePositionalCommandPath(contract.command);
|
|
804
|
+
const actual = observedByCommand.get(normalizedCommand);
|
|
805
|
+
if (!actual) {
|
|
806
|
+
findings.push({
|
|
807
|
+
code: "missing_observed_signature",
|
|
808
|
+
command: contract.command,
|
|
809
|
+
detail: `No observed positional signature exists for ${contract.command}.`,
|
|
810
|
+
});
|
|
811
|
+
}
|
|
812
|
+
else if (positionalSignatureKey(actual.slots) !==
|
|
813
|
+
positionalSignatureKey(contract.slots)) {
|
|
814
|
+
findings.push({
|
|
815
|
+
code: "positional_signature_mismatch",
|
|
816
|
+
command: contract.command,
|
|
817
|
+
detail: `Observed positional signature for ${contract.command} differs from its declared SDK contract: observed=${positionalSignatureKey(actual.slots) || "<none>"}; declared=${positionalSignatureKey(contract.slots) || "<none>"}.`,
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
for (const contract of observedByCommand.values()) {
|
|
822
|
+
if (!declaredByCommand.has(normalizePositionalCommandPath(contract.command))) {
|
|
823
|
+
findings.push({
|
|
824
|
+
code: "stale_observed_signature",
|
|
825
|
+
command: contract.command,
|
|
826
|
+
detail: `Observed positional signature ${contract.command} has no declaration.`,
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
const positionalShapeCount = new Set(declared.map(({ slots }) => positionalShapeKey(slots))).size;
|
|
831
|
+
if (positionalShapeCount > positionalShapeBudget) {
|
|
832
|
+
findings.push({
|
|
833
|
+
code: "positional_shape_budget_exceeded",
|
|
834
|
+
command: "*",
|
|
835
|
+
detail: `Distinct positional shape count ${positionalShapeCount} exceeds budget ${positionalShapeBudget}.`,
|
|
836
|
+
});
|
|
837
|
+
}
|
|
838
|
+
findings.sort((left, right) => left.command !== right.command
|
|
839
|
+
? left.command.localeCompare(right.command)
|
|
840
|
+
: left.code.localeCompare(right.code));
|
|
841
|
+
return {
|
|
842
|
+
ok: findings.length === 0,
|
|
843
|
+
declared_command_count: declared.length,
|
|
844
|
+
observed_command_count: observed.length,
|
|
845
|
+
positional_shape_count: positionalShapeCount,
|
|
846
|
+
positional_shape_budget: positionalShapeBudget,
|
|
847
|
+
findings,
|
|
848
|
+
};
|
|
849
|
+
}
|
|
234
850
|
function validateCommandDestinations(commands, destinationsByCommand, nounSet) {
|
|
235
851
|
return commands.flatMap((command) => {
|
|
236
852
|
const destinations = destinationsByCommand.get(command) ?? [];
|
|
@@ -342,4 +958,4 @@ export function verifyPmCliGrammar(commands, aliases = [], destinations = PM_COM
|
|
|
342
958
|
};
|
|
343
959
|
}
|
|
344
960
|
//# sourceMappingURL=grammar-contracts.js.map
|
|
345
|
-
//# debugId=
|
|
961
|
+
//# debugId=21495fd2-6abb-5a4f-965c-e7b9c8f87dff
|