Skip to content

Commit 3321522

Browse files
authored
fix(sim-cli): consistent source command flags and refusals (#10555)
* fix(sim-cli): consistent source command flags and refusals - workflows source resources and catalog take --dir (the directory's workspace, and for catalog its workflow); catalog --workflow-id takes an exact name like get - --json (same as --output json, errors included) on every workflows/workspaces source subcommand; an unknown --json elsewhere suggests --output json - SOURCE_DIR_KIND_MISMATCH names the command run, says 'would replace its base' only for get, and points at the workflow folder or the matching command - the not-found hint says -w <id>, which the wire-name rewording no longer turns into -w <--workspace> - writing a source answer back skips files whose text on disk is already the answer's, so a no-op apply moves no mtimes * fix(sim-cli): resolve resources and catalog --dir as the directory's other commands do --dir defaults to the working directory, so catalog includes the workflow it holds; a directory naming no workspace clears the working directory's; and a -w or SIM_WORKSPACE naming another workspace than the directory's record is refused (SOURCE_OTHER_WORKSPACE). The docs baseline records the changed resources usage fence.
1 parent cf7b488 commit 3321522

30 files changed

Lines changed: 448 additions & 100 deletions

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

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8596,7 +8596,9 @@ sim workflows source catalog [options]
85968596

85978597
| Option | Required | Description |
85988598
| --- | --- | --- |
8599-
| `--workflow-id <value>` | No | Return the source catalog for this workflow: the workspace catalog plus every block type already placed in it, the ones the caller could not add marked `addable: false`. |
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`. |
8600+
| `--dir <dir>` | No | Source directory whose workspace and workflow to read. Defaults to `.`. |
8601+
| `--json` | No | Print machine-readable JSON (same as --output json). |
86008602

86018603
</CommandTable>
86028604

@@ -8607,9 +8609,20 @@ API request and response schemas: [getSourceCatalog](/api-reference/catalog/getS
86078609
List the tables, knowledge bases, credentials, workflows, skills, custom tools, MCP servers, files and env names source can name
86088610

86098611
```bash
8610-
sim workflows source resources
8612+
sim workflows source resources [options]
86118613
```
86128614

8615+
**Options**
8616+
8617+
<CommandTable>
8618+
8619+
| Option | Required | Description |
8620+
| --- | --- | --- |
8621+
| `--dir <dir>` | No | Source directory whose workspace to read. Defaults to `.`. |
8622+
| `--json` | No | Print machine-readable JSON (same as --output json). |
8623+
8624+
</CommandTable>
8625+
86138626
API request and response schemas: [getSourceResources](/api-reference/workflows/getSourceResources).
86148627

86158628
### sim workflows source get
@@ -8639,6 +8652,7 @@ sim workflows source get <workflow> [options]
86398652
| `--function-code <value>` | No | Where function-block code goes: `files` (default) writes it to `functions/*` files referenced with `codeFile()`; `inline` prints it in tagged templates. Accepted values: `inline`, `files`. |
86408653
| `--dir <dir>` | No | Write the source, its lock and SDK type declarations into this directory instead of printing them. |
86418654
| `--force` | No | With --dir: replace another workflow's source or edits no apply has saved. |
8655+
| `--json` | No | Print machine-readable JSON (same as --output json). |
86428656

86438657
</CommandTable>
86448658

@@ -8678,6 +8692,7 @@ sim workflows source apply [workflowId] [options]
86788692
| `--run [input]` | No | After the write is saved, dry-run the draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it): a run that does not complete exits 1 and deploys nothing. With several triggers (an API and a webhook), name the one to enter through by its const: --run 'shopWebhook=&#123;…&#125;' (--run shopWebhook alone: no input). Repeat --run to test more inputs or triggers: every run is made and reported, and --deploy needs all to complete. Sandboxed code (Python, shell, imports) really runs in it, network requests included, and is listed in sideEffects.unchecked, so --run --deploy in CI sends those. |
86798693
| `--deploy` | No | After the write is saved (and a --run completed), deploy the workflow (as `sim workflows deploy <workflowId>` does). |
86808694
| `--allow-delete` | No | Delete blocks and variables the source no longer declares; without it, an apply that deletes one is refused. |
8695+
| `--json` | No | Print machine-readable JSON (same as --output json). |
86818696

86828697
</CommandTable>
86838698

@@ -8708,6 +8723,7 @@ sim workflows source create [options]
87088723
| `-y, --yes` | No | Create without asking for confirmation. |
87098724
| `--run [input]` | No | After the write is saved, dry-run the draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it): a run that does not complete exits 1 and deploys nothing. With several triggers (an API and a webhook), name the one to enter through by its const: --run 'shopWebhook=&#123;…&#125;' (--run shopWebhook alone: no input). Repeat --run to test more inputs or triggers: every run is made and reported, and --deploy needs all to complete. Sandboxed code (Python, shell, imports) really runs in it, network requests included, and is listed in sideEffects.unchecked, so --run --deploy in CI sends those. |
87108725
| `--deploy` | No | After the write is saved (and a --run completed), deploy the workflow (as `sim workflows deploy <workflowId>` does). |
8726+
| `--json` | No | Print machine-readable JSON (same as --output json). |
87118727

87128728
</CommandTable>
87138729

@@ -8734,6 +8750,7 @@ sim workflows source check [options]
87348750
| `--no-strict` | No | Never fail on a warning an apply saves. |
87358751
| `--no-types` | No | Skip the type check (TypeScript 7.0.2 over tsconfig.json) that runs after the compile. |
87368752
| `--verbose` | No | Also list the info findings hidden by default: every one with --output json, blocks placed by autolayout in the display. |
8753+
| `--json` | No | Print machine-readable JSON (same as --output json). |
87378754

87388755
</CommandTable>
87398756

@@ -8762,7 +8779,7 @@ sim workflows source status [options]
87628779
| `--summary-file <path>` | No | Also write the plan as Markdown to this file (or set SIM_SUMMARY_FILE), replacing it each run; its first line is a comment that names the directory, for a CI step that updates one pull-request comment. |
87638780
| `--dir <dir>` | No | Source directory: workflow.ts, functions/* and .sim/. Defaults to `.`. |
87648781
| `--offline` | No | Report local changes only, without asking the server. |
8765-
| `--json` | No | Print the machine-readable status (same as --output json). |
8782+
| `--json` | No | Print machine-readable JSON (same as --output json). |
87668783

87678784
</CommandTable>
87688785

@@ -8798,7 +8815,7 @@ sim workflows source diff [paths...] [options]
87988815
| --- | --- | --- |
87998816
| `--dir <dir>` | No | Source directory: workflow.ts, functions/* and .sim/. Defaults to `.`. |
88008817
| `--server` | No | Compare with the server's current source instead of the base. |
8801-
| `--json` | No | Print the machine-readable diff (same as --output json). |
8818+
| `--json` | No | Print machine-readable JSON (same as --output json). |
88028819

88038820
</CommandTable>
88048821

@@ -8832,6 +8849,7 @@ sim workflows source params <builder> [options]
88328849
| --- | --- | --- |
88338850
| `--dir <dir>` | No | Source directory whose catalog to read. Defaults to `.`. |
88348851
| `--full` | No | Print every param with its type, enum, default and doc, not the brief form. |
8852+
| `--json` | No | Print machine-readable JSON (same as --output json). |
88358853

88368854
</CommandTable>
88378855

@@ -8864,6 +8882,7 @@ sim workflows source find <block...> [options]
88648882
| Option | Required | Description |
88658883
| --- | --- | --- |
88668884
| `--dir <dir>` | No | Workflow source directory to read. Defaults to `.`. |
8885+
| `--json` | No | Print machine-readable JSON (same as --output json). |
88678886

88688887
</CommandTable>
88698888

@@ -10093,6 +10112,7 @@ sim workspaces source get [options]
1009310112
| `--dir <dir>` | Yes | Directory to write the workspace source into. |
1009410113
| `--only <kinds>` | No | Read only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
1009510114
| `--force` | No | Replace files with edits no apply has saved. |
10115+
| `--json` | No | Print machine-readable JSON (same as --output json). |
1009610116

1009710117
</CommandTable>
1009810118

@@ -10126,6 +10146,7 @@ sim workspaces source apply [options]
1012610146
| `--only <kinds>` | No | Apply only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
1012710147
| `--to <workspaceId>` | No | Promote the directory to another workspace (dev to prod): its resources bind by key to that workspace's own and are updated in place. Only .sim/targets/&lt;workspaceId&gt;.json changes, the record the next promotion compares with: a resource changed there since is kept, or refused as stale (exit 5) when the directory changed it too. |
1012810148
| `--run <key=input>` | No | After the apply, dry-run workflows/&lt;key&gt;/'s saved draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it; `--run <key>` alone: no input). Repeat it to test more workflows. deployments/ is applied only after every run completed, and only when every draft it publishes was test-run; a run that does not complete exits 1 and leaves the applied drafts in place. Sandboxed code (Python, shell, imports) really runs in it, network requests included, and is listed in runs[].sideEffects.unchecked. |
10149+
| `--json` | No | Print machine-readable JSON (same as --output json). |
1012910150

1013010151
</CommandTable>
1013110152

@@ -10152,6 +10173,7 @@ sim workspaces source check [options]
1015210173
| `--no-strict` | No | Never fail on a warning an apply saves. |
1015310174
| `--no-types` | No | Skip the type check (TypeScript 7.0.2 over tsconfig.json) that runs after the compile. |
1015410175
| `--verbose` | No | Also list the info findings hidden by default: every one with --output json, blocks placed by autolayout in the display. |
10176+
| `--json` | No | Print machine-readable JSON (same as --output json). |
1015510177

1015610178
</CommandTable>
1015710179

@@ -10183,7 +10205,7 @@ sim workspaces source status [options]
1018310205
| `--dir <dir>` | No | Workspace source directory written by `workspaces source get`. Defaults to `.`. |
1018410206
| `--only <kinds>` | No | Report only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
1018510207
| `--offline` | No | Report local changes only, without asking the server. |
10186-
| `--json` | No | Print the machine-readable status (same as --output json). |
10208+
| `--json` | No | Print machine-readable JSON (same as --output json). |
1018710209

1018810210
</CommandTable>
1018910211

@@ -10219,7 +10241,7 @@ sim workspaces source diff [paths...] [options]
1021910241
| --- | --- | --- |
1022010242
| `--dir <dir>` | No | Workspace source directory written by `workspaces source get`. Defaults to `.`. |
1022110243
| `--server` | No | Compare with the server's current source instead of the base. |
10222-
| `--json` | No | Print the machine-readable diff (same as --output json). |
10244+
| `--json` | No | Print machine-readable JSON (same as --output json). |
1022310245

1022410246
</CommandTable>
1022510247

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

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1396,6 +1396,7 @@ sim workflows source get <workflow> [options]
13961396
| `--function-code <value>` | No | Where function-block code goes: `files` (default) writes it to `functions/*` files referenced with `codeFile()`; `inline` prints it in tagged templates. Accepted values: `inline`, `files`. |
13971397
| `--dir <dir>` | No | Write the source, its lock and SDK type declarations into this directory instead of printing them. |
13981398
| `--force` | No | With --dir: replace another workflow's source or edits no apply has saved. |
1399+
| `--json` | No | Print machine-readable JSON (same as --output json). |
13991400

14001401
</CommandTable>
14011402

@@ -1418,7 +1419,7 @@ sim workflows source status [options]
14181419
| `--summary-file <path>` | No | Also write the plan as Markdown to this file (or set SIM_SUMMARY_FILE), replacing it each run; its first line is a comment that names the directory, for a CI step that updates one pull-request comment. |
14191420
| `--dir <dir>` | No | Source directory: workflow.ts, functions/* and .sim/. Defaults to `.`. |
14201421
| `--offline` | No | Report local changes only, without asking the server. |
1421-
| `--json` | No | Print the machine-readable status (same as --output json). |
1422+
| `--json` | No | Print machine-readable JSON (same as --output json). |
14221423

14231424
</CommandTable>
14241425

@@ -1449,6 +1450,7 @@ sim workflows source create [options]
14491450
| `-y, --yes` | No | Create without asking for confirmation. |
14501451
| `--run [input]` | No | After the write is saved, dry-run the draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it): a run that does not complete exits 1 and deploys nothing. With several triggers (an API and a webhook), name the one to enter through by its const: --run 'shopWebhook=&#123;…&#125;' (--run shopWebhook alone: no input). Repeat --run to test more inputs or triggers: every run is made and reported, and --deploy needs all to complete. Sandboxed code (Python, shell, imports) really runs in it, network requests included, and is listed in sideEffects.unchecked, so --run --deploy in CI sends those. |
14511452
| `--deploy` | No | After the write is saved (and a --run completed), deploy the workflow (as `sim workflows deploy <workflowId>` does). |
1453+
| `--json` | No | Print machine-readable JSON (same as --output json). |
14521454

14531455
</CommandTable>
14541456

@@ -1486,6 +1488,7 @@ sim workflows source apply [workflowId] [options]
14861488
| `--run [input]` | No | After the write is saved, dry-run the draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it): a run that does not complete exits 1 and deploys nothing. With several triggers (an API and a webhook), name the one to enter through by its const: --run 'shopWebhook=&#123;…&#125;' (--run shopWebhook alone: no input). Repeat --run to test more inputs or triggers: every run is made and reported, and --deploy needs all to complete. Sandboxed code (Python, shell, imports) really runs in it, network requests included, and is listed in sideEffects.unchecked, so --run --deploy in CI sends those. |
14871489
| `--deploy` | No | After the write is saved (and a --run completed), deploy the workflow (as `sim workflows deploy <workflowId>` does). |
14881490
| `--allow-delete` | No | Delete blocks and variables the source no longer declares; without it, an apply that deletes one is refused. |
1491+
| `--json` | No | Print machine-readable JSON (same as --output json). |
14891492

14901493
</CommandTable>
14911494

@@ -1505,7 +1508,9 @@ sim workflows source catalog [options]
15051508

15061509
| Option | Required | Description |
15071510
| --- | --- | --- |
1508-
| `--workflow-id <value>` | No | Return the source catalog for this workflow: the workspace catalog plus every block type already placed in it, the ones the caller could not add marked `addable: false`. |
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`. |
1512+
| `--dir <dir>` | No | Source directory whose workspace and workflow to read. Defaults to `.`. |
1513+
| `--json` | No | Print machine-readable JSON (same as --output json). |
15091514

15101515
</CommandTable>
15111516

@@ -1528,6 +1533,7 @@ sim workflows source check [options]
15281533
| `--no-strict` | No | Never fail on a warning an apply saves. |
15291534
| `--no-types` | No | Skip the type check (TypeScript 7.0.2 over tsconfig.json) that runs after the compile. |
15301535
| `--verbose` | No | Also list the info findings hidden by default: every one with --output json, blocks placed by autolayout in the display. |
1536+
| `--json` | No | Print machine-readable JSON (same as --output json). |
15311537

15321538
</CommandTable>
15331539

@@ -1563,7 +1569,7 @@ sim workflows source diff [paths...] [options]
15631569
| --- | --- | --- |
15641570
| `--dir <dir>` | No | Source directory: workflow.ts, functions/* and .sim/. Defaults to `.`. |
15651571
| `--server` | No | Compare with the server's current source instead of the base. |
1566-
| `--json` | No | Print the machine-readable diff (same as --output json). |
1572+
| `--json` | No | Print machine-readable JSON (same as --output json). |
15671573

15681574
</CommandTable>
15691575

@@ -1596,6 +1602,7 @@ sim workflows source find <block...> [options]
15961602
| Option | Required | Description |
15971603
| --- | --- | --- |
15981604
| `--dir <dir>` | No | Workflow source directory to read. Defaults to `.`. |
1605+
| `--json` | No | Print machine-readable JSON (same as --output json). |
15991606

16001607
</CommandTable>
16011608

@@ -1629,6 +1636,7 @@ sim workflows source params <builder> [options]
16291636
| --- | --- | --- |
16301637
| `--dir <dir>` | No | Source directory whose catalog to read. Defaults to `.`. |
16311638
| `--full` | No | Print every param with its type, enum, default and doc, not the brief form. |
1639+
| `--json` | No | Print machine-readable JSON (same as --output json). |
16321640

16331641
</CommandTable>
16341642

@@ -1639,9 +1647,20 @@ Exit codes: 0 printed; 1 no builder or namespace of that name (the closest one i
16391647
### List the tables, knowledge bases, credentials, workflows, skills, custom tools, MCP servers, files and env names source can name
16401648

16411649
```bash
1642-
sim workflows source resources
1650+
sim workflows source resources [options]
16431651
```
16441652

1653+
**Options**
1654+
1655+
<CommandTable>
1656+
1657+
| Option | Required | Description |
1658+
| --- | --- | --- |
1659+
| `--dir <dir>` | No | Source directory whose workspace to read. Defaults to `.`. |
1660+
| `--json` | No | Print machine-readable JSON (same as --output json). |
1661+
1662+
</CommandTable>
1663+
16451664
API request and response schemas: [getSourceResources](/api-reference/workflows/getSourceResources).
16461665

16471666
## Related docs

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,6 +703,7 @@ sim workspaces source get [options]
703703
| `--dir <dir>` | Yes | Directory to write the workspace source into. |
704704
| `--only <kinds>` | No | Read only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
705705
| `--force` | No | Replace files with edits no apply has saved. |
706+
| `--json` | No | Print machine-readable JSON (same as --output json). |
706707

707708
</CommandTable>
708709

@@ -728,7 +729,7 @@ sim workspaces source status [options]
728729
| `--dir <dir>` | No | Workspace source directory written by `workspaces source get`. Defaults to `.`. |
729730
| `--only <kinds>` | No | Report only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
730731
| `--offline` | No | Report local changes only, without asking the server. |
731-
| `--json` | No | Print the machine-readable status (same as --output json). |
732+
| `--json` | No | Print machine-readable JSON (same as --output json). |
732733

733734
</CommandTable>
734735

@@ -760,6 +761,7 @@ sim workspaces source apply [options]
760761
| `--only <kinds>` | No | Apply only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
761762
| `--to <workspaceId>` | No | Promote the directory to another workspace (dev to prod): its resources bind by key to that workspace's own and are updated in place. Only .sim/targets/&lt;workspaceId&gt;.json changes, the record the next promotion compares with: a resource changed there since is kept, or refused as stale (exit 5) when the directory changed it too. |
762763
| `--run <key=input>` | No | After the apply, dry-run workflows/&lt;key&gt;/'s saved draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it; `--run <key>` alone: no input). Repeat it to test more workflows. deployments/ is applied only after every run completed, and only when every draft it publishes was test-run; a run that does not complete exits 1 and leaves the applied drafts in place. Sandboxed code (Python, shell, imports) really runs in it, network requests included, and is listed in runs[].sideEffects.unchecked. |
764+
| `--json` | No | Print machine-readable JSON (same as --output json). |
763765

764766
</CommandTable>
765767

@@ -784,6 +786,7 @@ sim workspaces source check [options]
784786
| `--no-strict` | No | Never fail on a warning an apply saves. |
785787
| `--no-types` | No | Skip the type check (TypeScript 7.0.2 over tsconfig.json) that runs after the compile. |
786788
| `--verbose` | No | Also list the info findings hidden by default: every one with --output json, blocks placed by autolayout in the display. |
789+
| `--json` | No | Print machine-readable JSON (same as --output json). |
787790

788791
</CommandTable>
789792

@@ -821,7 +824,7 @@ sim workspaces source diff [paths...] [options]
821824
| --- | --- | --- |
822825
| `--dir <dir>` | No | Workspace source directory written by `workspaces source get`. Defaults to `.`. |
823826
| `--server` | No | Compare with the server's current source instead of the base. |
824-
| `--json` | No | Print the machine-readable diff (same as --output json). |
827+
| `--json` | No | Print machine-readable JSON (same as --output json). |
825828

826829
</CommandTable>
827830

‎apps/docs/scripts/fixtures/content-baseline.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13164,7 +13164,7 @@
1316413164
{
1316513165
"lang": "bash",
1316613166
"meta": null,
13167-
"sha256": "face4eea006073000b49334d0a2bea7f15f9df86cb1f606ac8fe39004c754027",
13167+
"sha256": "f893698f2fd6f13766a0f3e9d0ad0d4200ccb097939860a634500730358066ab",
1316813168
"bytes": null,
1316913169
"line": null
1317013170
},
@@ -17813,7 +17813,7 @@
1781317813
{
1781417814
"lang": "bash",
1781517815
"meta": null,
17816-
"sha256": "face4eea006073000b49334d0a2bea7f15f9df86cb1f606ac8fe39004c754027",
17816+
"sha256": "f893698f2fd6f13766a0f3e9d0ad0d4200ccb097939860a634500730358066ab",
1781717817
"bytes": null,
1781817818
"line": null
1781917819
}

0 commit comments

Comments
 (0)