Skip to content

Commit ea832bc

Browse files
committed
fix(cli): one --workflow flag across commands; deprecate --workflow-id
chat-deployments list, workflows source catalog, workflow-mcp-servers tools create and tables groups update named the workflow --workflow-id; they now take --workflow like every other command. --workflow-id still works with the rename warning. Drops the hidden aliases the previous commit added. A former spelling is now copied onto the documented flag as it is parsed, so a required renamed flag stays required in commander and the command inventory (tables rows search --query and workflows move --to were reported optional). A required flag missing beside an unknown one suggests it in commander's words.
1 parent ee5fb09 commit ea832bc

14 files changed

Lines changed: 170 additions & 121 deletions

File tree

‎apps/docs/content/docs/cli/chat-deployments.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ sim chat-deployments list [options]
2121

2222
| Option | Required | Description |
2323
| --- | --- | --- |
24-
| `--workflow-id <value>` | No | Restrict to deployments of one workflow. |
24+
| `--workflow <value>` | No | Restrict to deployments of one workflow. |
2525
| `--is-active` | No | Restrict to active or inactive deployments. |
2626
| `--no-is-active` | No | Send --is-active as false. |
2727
| `--sort-by <value>` | No | Field used to sort the result. Defaults to "createdAt". Accepted values: `identifier`, `createdAt`, `updatedAt`. |

‎apps/docs/content/docs/cli/reference.mdx‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ sim chat-deployments list [options]
487487

488488
| Option | Required | Description |
489489
| --- | --- | --- |
490-
| `--workflow-id <value>` | No | Restrict to deployments of one workflow. |
490+
| `--workflow <value>` | No | Restrict to deployments of one workflow. |
491491
| `--is-active` | No | Restrict to active or inactive deployments. |
492492
| `--no-is-active` | No | Send --is-active as false. |
493493
| `--sort-by <value>` | No | Field used to sort the result. Defaults to "createdAt". Accepted values: `identifier`, `createdAt`, `updatedAt`. |
@@ -6072,7 +6072,7 @@ sim tables groups update <tableId> [options]
60726072
| Option | Required | Description |
60736073
| --- | --- | --- |
60746074
| `--group-id <value>` | Yes | Workflow group to update. |
6075-
| `--workflow-id <value>` | No | Replacement backing workflow identifier. |
6075+
| `--workflow <value>` | No | Replacement backing workflow identifier. |
60766076
| `--name <value>` | No | Replacement workflow-group display name. |
60776077
| `--dependencies <json\|@file>` | No | Replacement input dependencies. (JSON, or @path / @- to read a file or stdin). |
60786078
| `--outputs <json\|@file>` | No | Replacement producer outputs. (JSON, or @path / @- to read a file or stdin). |
@@ -7555,7 +7555,7 @@ sim workflow-mcp-servers tools create <serverId> [options]
75557555

75567556
| Option | Required | Description |
75577557
| --- | --- | --- |
7558-
| `--workflow-id <value>` | Yes | Workflow to expose as an MCP tool. It must already be deployed. |
7558+
| `--workflow <value>` | Yes | Workflow to expose as an MCP tool. It must already be deployed. |
75597559
| `--tool-name <value>` | No | Name MCP clients call. Normalized to the MCP tool-name grammar, and derived from the workflow name when omitted. |
75607560
| `--tool-description <value>` | No | Description shown to MCP clients. Derived from the workflow name when omitted. |
75617561
| `--parameter-descriptions <json\|@file>` | No | Per-field description overrides applied to the schema generated from the deployed workflow inputs, as [&#123;"name":"email","description":"Customer email address"&#125;]. A name matching no input field is ignored (JSON, or @path / @- to read a file or stdin). |
@@ -8596,7 +8596,7 @@ sim workflows source catalog [options]
85968596

85978597
| Option | Required | Description |
85988598
| --- | --- | --- |
8599-
| `--workflow-id <value>` | No | Workflow id, or its exact name: adds every block type already placed in it, the ones the caller could not add marked `addable: false`. |
8599+
| `--workflow <value>` | No | Workflow id, or its exact name: adds every block type already placed in it, the ones the caller could not add marked `addable: false`. |
86008600
| `--dir <dir>` | No | Source directory whose workspace and workflow to read. Defaults to `.`. |
86018601
| `--json` | No | Print machine-readable JSON (same as --output json). |
86028602

‎apps/docs/content/docs/cli/tables.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ sim tables groups update <tableId> [options]
896896
| Option | Required | Description |
897897
| --- | --- | --- |
898898
| `--group-id <value>` | Yes | Workflow group to update. |
899-
| `--workflow-id <value>` | No | Replacement backing workflow identifier. |
899+
| `--workflow <value>` | No | Replacement backing workflow identifier. |
900900
| `--name <value>` | No | Replacement workflow-group display name. |
901901
| `--dependencies <json\|@file>` | No | Replacement input dependencies. (JSON, or @path / @- to read a file or stdin). |
902902
| `--outputs <json\|@file>` | No | Replacement producer outputs. (JSON, or @path / @- to read a file or stdin). |

‎apps/docs/content/docs/cli/workflow-mcp-servers.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ sim workflow-mcp-servers tools create <serverId> [options]
158158

159159
| Option | Required | Description |
160160
| --- | --- | --- |
161-
| `--workflow-id <value>` | Yes | Workflow to expose as an MCP tool. It must already be deployed. |
161+
| `--workflow <value>` | Yes | Workflow to expose as an MCP tool. It must already be deployed. |
162162
| `--tool-name <value>` | No | Name MCP clients call. Normalized to the MCP tool-name grammar, and derived from the workflow name when omitted. |
163163
| `--tool-description <value>` | No | Description shown to MCP clients. Derived from the workflow name when omitted. |
164164
| `--parameter-descriptions <json\|@file>` | No | Per-field description overrides applied to the schema generated from the deployed workflow inputs, as [&#123;"name":"email","description":"Customer email address"&#125;]. A name matching no input field is ignored (JSON, or @path / @- to read a file or stdin). |

‎apps/docs/content/docs/cli/workflows.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1508,7 +1508,7 @@ sim workflows source catalog [options]
15081508

15091509
| Option | Required | Description |
15101510
| --- | --- | --- |
1511-
| `--workflow-id <value>` | No | Workflow id, or its exact name: adds every block type already placed in it, the ones the caller could not add marked `addable: false`. |
1511+
| `--workflow <value>` | No | Workflow id, or its exact name: adds every block type already placed in it, the ones the caller could not add marked `addable: false`. |
15121512
| `--dir <dir>` | No | Source directory whose workspace and workflow to read. Defaults to `.`. |
15131513
| `--json` | No | Print machine-readable JSON (same as --output json). |
15141514

‎packages/sim-cli/src/commands/protocol/logs-follow.test.ts‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,4 @@ describe('sim logs follow', () => {
211211

212212
expect(process.listenerCount('SIGINT')).toBe(before)
213213
})
214-
215-
it('filters by --workflow-id, the spelling workflows source catalog takes, as by --workflow', async () => {
216-
respondWith([page([])])
217-
218-
await follow('--workflow', 'wf_1', '--workflow-id', 'wf_2', '-n', '0')
219-
220-
expect(mockRequest.mock.calls[0][1]).toMatchObject({ query: { workflowIds: 'wf_1,wf_2' } })
221-
})
222214
})

‎packages/sim-cli/src/commands/protocol/logs-follow.ts‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ const ERASE_LINE = `${String.fromCharCode(27)}[K`
8989

9090
interface FollowOptions {
9191
workflow?: string[]
92-
/** Hidden: the spelling `logs list` and `workflows source catalog` also answer to. */
93-
workflowId?: string[]
9492
folder?: string[]
9593
trigger?: string[]
9694
level?: string
@@ -503,7 +501,6 @@ export function attachLogsFollow(logs: Command): void {
503501
collectRepeated,
504502
[]
505503
)
506-
.addOption(new Option('--workflow-id <id>').hideHelp().argParser(collectRepeated).default([]))
507504
.option(
508505
'--folder <path>',
509506
'Only follow runs of workflows in this folder (repeatable)',
@@ -548,12 +545,10 @@ Examples:
548545
const lines = nonNegativeInteger(options.lines, '--lines')
549546
const delay = intervalMs(options.interval)
550547

551-
const workflows = [...(options.workflow ?? []), ...(options.workflowId ?? [])]
552-
553548
const { client, profile } = connectFollow()
554549
const query = {
555550
workspaceId: client.requireWorkspace(),
556-
workflowIds: workflows.length ? workflows.join(',') : undefined,
551+
workflowIds: options.workflow?.length ? options.workflow.join(',') : undefined,
557552
// Encoded exactly as the contract-driven `--folder` encodes it, so a
558553
// path that works on `logs list` works here; encoding first is also what
559554
// keeps the comma-joined form unambiguous.

‎packages/sim-cli/src/commands/protocol/workflow-source-reads.ts‎

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function actInDirectory(command: Command): Promise<string> {
5050
* Teaches the generated `workflows source resources` and `catalog` leaves the `--dir <dir>` every
5151
* other `workflows source` command takes: each reads the workspace the directory names, and
5252
* `catalog` also the block types placed in the workflow the directory holds. `catalog
53-
* --workflow-id` takes a workflow's exact name as well as its id, as `get` does. Commander offers
53+
* --workflow` takes a workflow's exact name as well as its id, as `get` does. Commander offers
5454
* no way to read the action a leaf holds, so it is captured and delegated to, as `get` does.
5555
*/
5656
export function attachWorkflowSourceReads(source: Command): void {
@@ -64,18 +64,17 @@ export function attachWorkflowSourceReads(source: Command): void {
6464
const connectCatalog = callsOperations(catalog, ['getSourceCatalog', 'listWorkflows'])
6565
catalog.action(async (_options: unknown, command: Command): Promise<void> => {
6666
const dir = await actInDirectory(command)
67-
// `--workflow` is a hidden spelling of `--workflow-id`; both together are refused downstream.
68-
const typed =
69-
command.getOptionValue('workflowId') === undefined &&
70-
command.getOptionValue('workflow') !== undefined
71-
? 'workflow'
72-
: 'workflowId'
73-
const workflow: unknown = command.getOptionValue(typed)
67+
const workflow: unknown = command.getOptionValue('workflow')
7468
if (typeof workflow === 'string') {
75-
command.setOptionValue(typed, await resolveWorkflow(connectCatalog().client, workflow))
69+
// Keeps the source, so `--workflow-id` still warns that it was renamed.
70+
command.setOptionValueWithSource(
71+
'workflow',
72+
await resolveWorkflow(connectCatalog().client, workflow),
73+
command.getOptionValueSource('workflow')
74+
)
7675
} else {
7776
const held = await heldWorkflowId(dir)
78-
if (held !== null) command.setOptionValue('workflowId', held)
77+
if (held !== null) command.setOptionValue('workflow', held)
7978
}
8079
await readCatalog(command.processedArgs)
8180
})

‎packages/sim-cli/src/contract/commands.ts‎

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,12 @@ const KNOWLEDGE_BASE_PATH_ARGUMENT = { knowledgeBaseId: 'knowledgeBaseId' } as c
174174
* workspace it already sends.
175175
*/
176176
const TRANSFER_TOKEN_OMITTED = { 'upload-token': { omit: true } } as const
177+
/**
178+
* A `workflowId` request field, spelled `--workflow` like every other flag naming a workflow.
179+
* Commands that derived `--workflow-id` from the field name shipped that spelling, so it still
180+
* works, with the rename warning.
181+
*/
182+
const WORKFLOW_FLAG = { name: 'workflow', renamedFrom: ['workflow-id'] } as const
177183
const WORKFLOW_RUN_SCOPE = {
178184
workflowId: {
179185
name: 'workflow',
@@ -194,12 +200,10 @@ const TARGET_FOLDER_PATH_FLAG = {
194200
* that the route splits on commas. They live on one constant because a flag
195201
* that means `--workflow` on one log command and `--workflow-ids` on the next
196202
* is the exact divergence `spells one concept with one flag name` exists to
197-
* catch, and nothing about that failure would point back here. `--workflow-id`
198-
* is the spelling commands deriving it from a `workflowId` field take
199-
* (`workflows source catalog`), so callers who learned it there type it here.
203+
* catch, and nothing about that failure would point back here.
200204
*/
201205
const LOG_LIST_FILTER_FLAGS = {
202-
workflowIds: { name: 'workflow', list: true, hiddenAliases: ['workflow-ids', 'workflow-id'] },
206+
workflowIds: { name: 'workflow', list: true, hiddenAliases: ['workflow-ids'] },
203207
folderPaths: FOLDER_PATHS_FLAG,
204208
triggers: { name: 'trigger', list: true },
205209
} as const
@@ -552,6 +556,9 @@ export const CLI_CONTRACT: CliContract = {
552556
{ header: 'remaining columns', path: 'columns', format: 'count' },
553557
],
554558
},
559+
updateWorkflowGroup: {
560+
flags: { workflowId: WORKFLOW_FLAG },
561+
},
555562
// Fields whose type misdescribes their meaning
556563
// `z.string()` that the route splits on commas. No generator can infer this.
557564
listLogs: {
@@ -633,9 +640,8 @@ export const CLI_CONTRACT: CliContract = {
633640
command: 'meta status',
634641
describe: 'Show API availability and the calling credential’s type and expiry',
635642
},
636-
// `--workflow` is how the other workflow filters (`logs list`, `workflows runs`) are spelled.
637643
listChatDeployments: {
638-
flags: { workflowId: { hiddenAliases: ['workflow'] } },
644+
flags: { workflowId: WORKFLOW_FLAG },
639645
},
640646
getWorkflowChatDeployment: {
641647
command: 'workflows chat status',
@@ -674,6 +680,7 @@ export const CLI_CONTRACT: CliContract = {
674680
},
675681
deployWorkflowMcpTool: {
676682
flags: {
683+
workflowId: WORKFLOW_FLAG,
677684
parameterDescriptions: { json: true, describe: MCP_PARAMETER_DESCRIPTIONS_HELP },
678685
},
679686
},
@@ -743,9 +750,9 @@ export const CLI_CONTRACT: CliContract = {
743750
flags: {
744751
'if-none-match': { omit: true },
745752
workflowId: {
753+
...WORKFLOW_FLAG,
746754
describe:
747755
'Workflow id, or its exact name: adds every block type already placed in it, the ones the caller could not add marked `addable: false`',
748-
hiddenAliases: ['workflow'],
749756
},
750757
},
751758
},

‎packages/sim-cli/src/runtime/build.ts‎

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,26 @@ function unknownOptionToken(command: Command): string | undefined {
154154
return command.args.find((arg) => arg.length > 1 && arg.startsWith('-'))
155155
}
156156

157+
function missingMandatory(command: Command): Option[] {
158+
return command.options.filter(
159+
(option) => option.mandatory && command.getOptionValue(option.attributeName()) === undefined
160+
)
161+
}
162+
163+
/**
164+
* An unknown flag typed while a required one is missing, in commander's unknown-option words.
165+
* Commander checks required flags before unknown ones, so its own near-spelling suggestion never
166+
* reaches `runs get <id> --workflow-id`. With one required flag missing, that is the one suggested.
167+
*/
168+
function unknownBesideMissing(command: Command): string | undefined {
169+
const token = unknownOptionToken(command)
170+
if (!token) return undefined
171+
const missing = missingMandatory(command)
172+
const suggestion =
173+
missing.length === 1 && missing[0].long ? ` (Did you mean ${missing[0].long}?)` : ''
174+
return `${token.split('=', 1)[0]} is not an option of ${commandPath(command)}.${suggestion}`
175+
}
176+
157177
/**
158178
* The value a caller typed as a positional where the one missing required flag
159179
* was wanted (`files rename <id> new.pdf`, `knowledge search <kbId>`), when
@@ -163,9 +183,7 @@ function unknownOptionToken(command: Command): string | undefined {
163183
* reads the same as an unknown option here).
164184
*/
165185
function misplacedFlagValue(command: Command): { option: Option; value: string } | undefined {
166-
const missing = command.options.filter(
167-
(option) => option.mandatory && command.getOptionValue(option.attributeName()) === undefined
168-
)
186+
const missing = missingMandatory(command)
169187
if (missing.length !== 1 || unknownOptionToken(command) !== undefined) return undefined
170188
if (command.registeredArguments.some((argument) => argument.variadic)) return undefined
171189
const extra = command.args.slice(command.registeredArguments.length)
@@ -289,10 +307,8 @@ function siblingsDeclaring(command: Command, flag: string): string[] {
289307
*
290308
* - A missing positional or required flag gets the full command line, and a
291309
* value typed as a positional where the flag was wanted is named against
292-
* that flag when nothing else could have put it there. Commander checks
293-
* required flags before unknown ones, so an unknown flag typed in place of
294-
* the required one (`runs get <id> --workflow-id`) is named here, or the
295-
* caller never learns it was the problem.
310+
* that flag when nothing else could have put it there. An unknown flag
311+
* typed beside it is named, with the missing flag suggested.
296312
* - Too many positionals get the same command line and the flag list; an option that took
297313
* another flag as its value is named, and a JSON operand is moved to the JSON flag it belongs to.
298314
* - An unknown option gets the command's own flags, and the sibling commands
@@ -308,13 +324,13 @@ function parseErrorGuidance(command: Command, code: string | undefined): string[
308324
return [`Example: ${usageExample(command)}`]
309325
case 'commander.missingMandatoryOptionValue': {
310326
const misplaced = misplacedFlagValue(command)
311-
const unknown = unknownOptionToken(command)
327+
const unknown = unknownBesideMissing(command)
312328
const moved = misplaced
313329
? [
314330
`"${misplaced.value}" was passed as a positional; pass it as ${misplaced.option.long ?? misplaced.option.short} "${misplaced.value}".`,
315331
]
316332
: unknown
317-
? [`${unknown.split('=', 1)[0]} is not an option of ${commandPath(command)}.`]
333+
? [unknown]
318334
: []
319335
return [...moved, `Example: ${usageExample(command)}`]
320336
}

0 commit comments

Comments
 (0)