From a7b837e7b3392928dbeed0bcf49f7918d70b9f1c Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 26 Nov 2026 12:13:56 -0800 Subject: [PATCH 1/2] fix(cli): comma lists, stale table types hint, and block version note - Every id list flag reads repeated, space-, comma-separated and JSON-array values alike (`--row-ids a,b` deleted nothing); dependency specifiers and folder paths keep their commas. - An unknown option names the commands one group down that take it, by any spelling (`tables batch-delete --row-ids` points to `tables rows batch-delete`). - `blocks get table` notes on stderr that it reads as table_v2, the type to add. - `workflows source check` hints `source status` to refresh table types when a row write names a column the last get's types lack. --- apps/docs/content/docs/cli/files.mdx | 6 +- apps/docs/content/docs/cli/knowledge.mdx | 10 ++-- apps/docs/content/docs/cli/logs.mdx | 8 +-- .../content/docs/cli/permission-groups.mdx | 2 +- apps/docs/content/docs/cli/reference.mdx | 56 +++++++++---------- apps/docs/content/docs/cli/sandboxes.mdx | 8 +-- apps/docs/content/docs/cli/tables.mdx | 10 ++-- .../content/docs/cli/workflow-mcp-servers.mdx | 2 +- apps/docs/content/docs/cli/workflows.mdx | 6 +- apps/docs/content/docs/cli/workspaces.mdx | 4 +- .../src/commands/protocol/source-tree.ts | 13 +++++ .../src/commands/protocol/source-types.ts | 47 +++++++++++++++- .../protocol/workflow-source-check.ts | 19 ++++++- .../protocol/workflow-source-get.test.ts | 56 +++++++++++++++++++ packages/sim-cli/src/contract/commands.ts | 8 +-- packages/sim-cli/src/contract/types.ts | 8 +-- packages/sim-cli/src/embed-isolation.test.ts | 17 ++++++ .../src/runtime/block-version-note.test.ts | 28 ++++++++++ packages/sim-cli/src/runtime/build.ts | 23 ++++---- packages/sim-cli/src/runtime/execute.ts | 22 ++++++-- .../src/runtime/file-references.test.ts | 33 +++++++++++ packages/sim-cli/src/runtime/options.ts | 8 ++- packages/sim-cli/src/runtime/request.ts | 24 +++++--- 23 files changed, 323 insertions(+), 95 deletions(-) create mode 100644 packages/sim-cli/src/runtime/block-version-note.test.ts diff --git a/apps/docs/content/docs/cli/files.mdx b/apps/docs/content/docs/cli/files.mdx index 655dc78ab90..a794fb77003 100644 --- a/apps/docs/content/docs/cli/files.mdx +++ b/apps/docs/content/docs/cli/files.mdx @@ -333,7 +333,7 @@ Also available as `sim files mv`. | Option | Required | Description | | --- | --- | --- | -| `--file-ids ` | Yes | File identifiers to update. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--file-ids ` | Yes | File identifiers to update. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--to ` | No | Destination folder path; omit for root. | @@ -417,7 +417,7 @@ sim files share set [options] | `--is-active ` | Yes | Whether the share should resolve. Disabling preserves the token and the whole access configuration, so re-enabling restores the share as it was; enabling rewrites the credentials the resulting mode does not use. Accepted values: `true`, `false`. | | `--auth-type ` | No | How access to the share is gated. The stored mode is kept when omitted. Enabling `public` clears the stored password and empties `allowedEmails`; `password` empties `allowedEmails`; `email` and `sso` clear the stored password. Accepted values: `public`, `password`, `email`, `sso`. | | `--password ` | No | Password of 15 to 1024 characters for a password-gated share. Kept when omitted; enabling `password` with neither a supplied nor a stored password is a 400. Taken literally, except that a request from the Sim agent resolves a whole-value `{{ENV_VAR}}` reference to that variable before the rules apply. | -| `--allowed-emails ` | No | Allowed addresses or `@domain` patterns for email and SSO shares. Kept when omitted; enabling `email` or `sso` with an empty resulting list is a 400. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--allowed-emails ` | No | Allowed addresses or `@domain` patterns for email and SSO shares. Kept when omitted; enabling `email` or `sso` with an empty resulting list is a 400. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | @@ -653,7 +653,7 @@ sim files batch-delete [file-ids...] [options] | Option | Required | Description | | --- | --- | --- | -| `--file-ids ` | No | Files to delete, each by identifier or by the VFS path of a live file: `files//`. Pass the id when two files in a folder have names that display alike. At most 100 entries may be paths. (space-separated, or @path / @- with one value per line; @@value for a literal leading @) (required, or pass the values as arguments). | +| `--file-ids ` | No | Files to delete, each by identifier or by the VFS path of a live file: `files//`. Pass the id when two files in a folder have names that display alike. At most 100 entries may be paths. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @) (required, or pass the values as arguments). | | `-y, --yes` | Yes | Confirm this operation. | diff --git a/apps/docs/content/docs/cli/knowledge.mdx b/apps/docs/content/docs/cli/knowledge.mdx index 2d424c49bc1..19653c19e37 100644 --- a/apps/docs/content/docs/cli/knowledge.mdx +++ b/apps/docs/content/docs/cli/knowledge.mdx @@ -187,7 +187,7 @@ sim knowledge search [options] | Option | Required | Description | | --- | --- | --- | -| `--kb ` | Yes | Knowledge base ID (repeatable) (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--kb ` | Yes | Knowledge base ID (repeatable) (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--query ` | No | Text to search for. | | `--top-k ` | No | Maximum number of search results to return. Must be a whole number between 1 and 100. Defaults to 10. | | `--tag-filters ` | No | Tag filters as [{"tagName":"...","operator":"...","value":"..."}] (JSON, or @path / @- to read a file or stdin). | @@ -464,7 +464,7 @@ sim knowledge documents batch-update [options] | Option | Required | Description | | --- | --- | --- | | `--operation ` | Yes | Whether the selected documents become enabled or disabled for search. Accepted values: `enable`, `disable`. | -| `--document ` | No | Documents to update, by identifier. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--document ` | No | Documents to update, by identifier. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--select-all` | No | Apply to every document in the knowledge base. | | `--enabled-filter ` | No | With `selectAll`, restrict the update to documents in this state. Accepted values: `all`, `enabled`, `disabled`. | @@ -527,7 +527,7 @@ sim knowledge from-workspace-files create [options] | Option | Required | Description | | --- | --- | --- | -| `--file ` | Yes | Workspace file ID or canonical files/<folder>/<name> path (repeatable) (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--file ` | Yes | Workspace file ID or canonical files/<folder>/<name> path (repeatable) (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | @@ -688,7 +688,7 @@ sim knowledge chunks batch-update [options] | Option | Required | Description | | --- | --- | --- | | `--operation ` | Yes | What to do with the selected chunks. Accepted values: `enable`, `disable`, `delete`. | -| `--chunk ` | Yes | Chunks to operate on, by identifier. An id naming no chunk in the document is reported in errors and does not fail the request. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--chunk ` | Yes | Chunks to operate on, by identifier. An id naming no chunk in the document is reported in errors and does not fail the request. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `-y, --yes` | Yes | Confirm this operation. | @@ -1174,7 +1174,7 @@ sim knowledge connectors documents update [optio | Option | Required | Description | | --- | --- | --- | | `--operation ` | Yes | Whether to restore or exclude the selected documents. Accepted values: `restore`, `exclude`. | -| `--document ` | Yes | Connector document identifiers to update. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--document ` | Yes | Connector document identifiers to update. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | diff --git a/apps/docs/content/docs/cli/logs.mdx b/apps/docs/content/docs/cli/logs.mdx index 5ae8626c80d..d1a1e9cd7c9 100644 --- a/apps/docs/content/docs/cli/logs.mdx +++ b/apps/docs/content/docs/cli/logs.mdx @@ -23,8 +23,8 @@ sim logs list [options] | Option | Required | Description | | --- | --- | --- | -| `--workflow ` | No | Comma-separated workflow identifiers to include. An empty entry is rejected. At most 200 entries. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | -| `--trigger ` | No | Comma-separated, lowercase trigger types or webhook provider IDs. Matching is exact and case-sensitive; unknown values select no runs. An empty entry is rejected. The sentinel `all` disables this filter, even when listed with other values. At most 100 entries. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | No | Comma-separated workflow identifiers to include. An empty entry is rejected. At most 200 entries. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--trigger ` | No | Comma-separated, lowercase trigger types or webhook provider IDs. Matching is exact and case-sensitive; unknown values select no runs. An empty entry is rejected. The sentinel `all` disables this filter, even when listed with other values. At most 100 entries. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--level ` | No | Severity level to include. Accepted values: `info`, `error`. | | `--start-date ` | No | Only include runs started at or after this UTC ISO 8601 timestamp, e.g. `2026-08-06T00:00:00Z`. A date without a time, or a timestamp carrying a UTC offset instead of `Z`, is rejected, as is year `0000`, which names no storable instant. | | `--end-date ` | No | Only include runs started at or before this UTC ISO 8601 timestamp, e.g. `2026-08-06T00:00:00Z`. A date without a time, or a timestamp carrying a UTC offset instead of `Z`, is rejected, as is year `0000`, which names no storable instant. | @@ -95,9 +95,9 @@ sim logs stats [options] | Option | Required | Description | | --- | --- | --- | -| `--workflow ` | No | Comma-separated workflow identifiers to include. At most 200 entries. An empty entry is rejected. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | No | Comma-separated workflow identifiers to include. At most 200 entries. An empty entry is rejected. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | -| `--trigger ` | No | Comma-separated trigger types to include. An empty entry is rejected. The vocabulary is open, so an unrecognized member selects no runs; the literal `all` disables this filter. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--trigger ` | No | Comma-separated trigger types to include. An empty entry is rejected. The vocabulary is open, so an unrecognized member selects no runs; the literal `all` disables this filter. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--level ` | No | Severity level to include. Accepted values: `info`, `error`. | | `--include-handled-errors` | No | Whether runs with a handled block error are counted as `handledErrorRuns`, and whether `level=error` also selects them. Off by default: counting them scans each run’s stored trace. | | `--no-include-handled-errors` | No | Send --include-handled-errors as false. | diff --git a/apps/docs/content/docs/cli/permission-groups.mdx b/apps/docs/content/docs/cli/permission-groups.mdx index dd6bafa29b9..2729a53c35a 100644 --- a/apps/docs/content/docs/cli/permission-groups.mdx +++ b/apps/docs/content/docs/cli/permission-groups.mdx @@ -229,7 +229,7 @@ sim permission-groups members batch-add [options] | --- | --- | --- | | `--organization ` | Yes | Organization identifier. | | `--group ` | Yes | Permission group identifier. | -| `--user ` | No | User IDs to add; cannot be combined with --all-members (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--user ` | No | User IDs to add; cannot be combined with --all-members (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--all-members` | No | Add every current organization member; cannot be combined with --user. | diff --git a/apps/docs/content/docs/cli/reference.mdx b/apps/docs/content/docs/cli/reference.mdx index 80202cd3497..10a011f2e69 100644 --- a/apps/docs/content/docs/cli/reference.mdx +++ b/apps/docs/content/docs/cli/reference.mdx @@ -1083,7 +1083,7 @@ sim files batch-delete [file-ids...] [options] | Option | Required | Description | | --- | --- | --- | -| `--file-ids ` | No | Files to delete, each by identifier or by the VFS path of a live file: `files//`. Pass the id when two files in a folder have names that display alike. At most 100 entries may be paths. (space-separated, or @path / @- with one value per line; @@value for a literal leading @) (required, or pass the values as arguments). | +| `--file-ids ` | No | Files to delete, each by identifier or by the VFS path of a live file: `files//`. Pass the id when two files in a folder have names that display alike. At most 100 entries may be paths. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @) (required, or pass the values as arguments). | | `-y, --yes` | Yes | Confirm this operation. | @@ -1581,7 +1581,7 @@ sim files share set [options] | `--is-active ` | Yes | Whether the share should resolve. Disabling preserves the token and the whole access configuration, so re-enabling restores the share as it was; enabling rewrites the credentials the resulting mode does not use. Accepted values: `true`, `false`. | | `--auth-type ` | No | How access to the share is gated. The stored mode is kept when omitted. Enabling `public` clears the stored password and empties `allowedEmails`; `password` empties `allowedEmails`; `email` and `sso` clear the stored password. Accepted values: `public`, `password`, `email`, `sso`. | | `--password ` | No | Password of 15 to 1024 characters for a password-gated share. Kept when omitted; enabling `password` with neither a supplied nor a stored password is a 400. Taken literally, except that a request from the Sim agent resolves a whole-value `{{ENV_VAR}}` reference to that variable before the rules apply. | -| `--allowed-emails ` | No | Allowed addresses or `@domain` patterns for email and SSO shares. Kept when omitted; enabling `email` or `sso` with an empty resulting list is a 400. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--allowed-emails ` | No | Allowed addresses or `@domain` patterns for email and SSO shares. Kept when omitted; enabling `email` or `sso` with an empty resulting list is a 400. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | @@ -1630,7 +1630,7 @@ Also available as `sim files mv`. | Option | Required | Description | | --- | --- | --- | -| `--file-ids ` | Yes | File identifiers to update. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--file-ids ` | Yes | File identifiers to update. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--to ` | No | Destination folder path; omit for root. | @@ -1951,7 +1951,7 @@ sim knowledge from-workspace-files create [options] | Option | Required | Description | | --- | --- | --- | -| `--file ` | Yes | Workspace file ID or canonical files/<folder>/<name> path (repeatable) (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--file ` | Yes | Workspace file ID or canonical files/<folder>/<name> path (repeatable) (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | @@ -2216,7 +2216,7 @@ sim knowledge chunks batch-update [options] | Option | Required | Description | | --- | --- | --- | | `--operation ` | Yes | What to do with the selected chunks. Accepted values: `enable`, `disable`, `delete`. | -| `--chunk ` | Yes | Chunks to operate on, by identifier. An id naming no chunk in the document is reported in errors and does not fail the request. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--chunk ` | Yes | Chunks to operate on, by identifier. An id naming no chunk in the document is reported in errors and does not fail the request. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `-y, --yes` | Yes | Confirm this operation. | @@ -2407,7 +2407,7 @@ sim knowledge documents batch-update [options] | Option | Required | Description | | --- | --- | --- | | `--operation ` | Yes | Whether the selected documents become enabled or disabled for search. Accepted values: `enable`, `disable`. | -| `--document ` | No | Documents to update, by identifier. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--document ` | No | Documents to update, by identifier. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--select-all` | No | Apply to every document in the knowledge base. | | `--enabled-filter ` | No | With `selectAll`, restrict the update to documents in this state. Accepted values: `all`, `enabled`, `disabled`. | @@ -2806,7 +2806,7 @@ sim knowledge connectors documents update [optio | Option | Required | Description | | --- | --- | --- | | `--operation ` | Yes | Whether to restore or exclude the selected documents. Accepted values: `restore`, `exclude`. | -| `--document ` | Yes | Connector document identifiers to update. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--document ` | Yes | Connector document identifiers to update. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | @@ -3121,7 +3121,7 @@ sim knowledge search [options] | Option | Required | Description | | --- | --- | --- | -| `--kb ` | Yes | Knowledge base ID (repeatable) (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--kb ` | Yes | Knowledge base ID (repeatable) (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--query ` | No | Text to search for. | | `--top-k ` | No | Maximum number of search results to return. Must be a whole number between 1 and 100. Defaults to 10. | | `--tag-filters ` | No | Tag filters as [{"tagName":"...","operator":"...","value":"..."}] (JSON, or @path / @- to read a file or stdin). | @@ -3355,9 +3355,9 @@ sim logs stats [options] | Option | Required | Description | | --- | --- | --- | -| `--workflow ` | No | Comma-separated workflow identifiers to include. At most 200 entries. An empty entry is rejected. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | No | Comma-separated workflow identifiers to include. At most 200 entries. An empty entry is rejected. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | -| `--trigger ` | No | Comma-separated trigger types to include. An empty entry is rejected. The vocabulary is open, so an unrecognized member selects no runs; the literal `all` disables this filter. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--trigger ` | No | Comma-separated trigger types to include. An empty entry is rejected. The vocabulary is open, so an unrecognized member selects no runs; the literal `all` disables this filter. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--level ` | No | Severity level to include. Accepted values: `info`, `error`. | | `--include-handled-errors` | No | Whether runs with a handled block error are counted as `handledErrorRuns`, and whether `level=error` also selects them. Off by default: counting them scans each run’s stored trace. | | `--no-include-handled-errors` | No | Send --include-handled-errors as false. | @@ -3384,8 +3384,8 @@ sim logs list [options] | Option | Required | Description | | --- | --- | --- | -| `--workflow ` | No | Comma-separated workflow identifiers to include. An empty entry is rejected. At most 200 entries. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | -| `--trigger ` | No | Comma-separated, lowercase trigger types or webhook provider IDs. Matching is exact and case-sensitive; unknown values select no runs. An empty entry is rejected. The sentinel `all` disables this filter, even when listed with other values. At most 100 entries. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | No | Comma-separated workflow identifiers to include. An empty entry is rejected. At most 200 entries. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--trigger ` | No | Comma-separated, lowercase trigger types or webhook provider IDs. Matching is exact and case-sensitive; unknown values select no runs. An empty entry is rejected. The sentinel `all` disables this filter, even when listed with other values. At most 100 entries. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--level ` | No | Severity level to include. Accepted values: `info`, `error`. | | `--start-date ` | No | Only include runs started at or after this UTC ISO 8601 timestamp, e.g. `2026-08-06T00:00:00Z`. A date without a time, or a timestamp carrying a UTC offset instead of `Z`, is rejected, as is year `0000`, which names no storable instant. | | `--end-date ` | No | Only include runs started at or before this UTC ISO 8601 timestamp, e.g. `2026-08-06T00:00:00Z`. A date without a time, or a timestamp carrying a UTC offset instead of `Z`, is rejected, as is year `0000`, which names no storable instant. | @@ -5094,7 +5094,7 @@ sim permission-groups members batch-add [options] | --- | --- | --- | | `--organization ` | Yes | Organization identifier. | | `--group ` | Yes | Permission group identifier. | -| `--user ` | No | User IDs to add; cannot be combined with --all-members (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--user ` | No | User IDs to add; cannot be combined with --all-members (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--all-members` | No | Add every current organization member; cannot be combined with --user. | @@ -5331,8 +5331,8 @@ sim sandboxes create [options] | `--name ` | Yes | Display name, unique within the workspace; 1 to 64 characters. | | `--language ` | Yes | Dependency ecosystem: `javascript` installs from npm, `python` from PyPI. Accepted values: `javascript`, `python`. | | `--dependencies ` | No | Package specifiers installed into the sandbox, one per entry. Defaults to []. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | -| `--cli-tools ` | No | Pinned managed CLI ids installed into the sandbox, at most 10, no duplicates. Defaults to []. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | -| `--system-packages ` | No | Debian packages installed into the sandbox, one per entry. Defaults to []. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | +| `--cli-tools ` | No | Pinned managed CLI ids installed into the sandbox, at most 10, no duplicates. Defaults to []. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--system-packages ` | No | Debian packages installed into the sandbox, one per entry. Defaults to []. (space- or comma-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | @@ -5440,8 +5440,8 @@ sim sandboxes update [options] | `--name ` | No | New display name, unique within the workspace; 1 to 64 characters. | | `--language ` | No | Replacement dependency ecosystem. The whole spec is revalidated against it, so a Python dependency list does not survive a switch to JavaScript. Accepted values: `javascript`, `python`. | | `--dependencies ` | No | Replacement package list; replaces the whole list. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | -| `--cli-tools ` | No | Replacement managed CLI list; replaces the whole list. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | -| `--system-packages ` | No | Replacement Debian package list; replaces the whole list. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | +| `--cli-tools ` | No | Replacement managed CLI list; replaces the whole list. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--system-packages ` | No | Replacement Debian package list; replaces the whole list. (space- or comma-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | @@ -6234,7 +6234,7 @@ sim tables rows batch-delete [options] | --- | --- | --- | | `--filter ` | No | Predicate: {"all":[{"field":"status","op":"eq","value":"active"}]}; groups use all/any. Operators: eq, ne, gt, gte, lt, lte, in, nin, contains, ncontains, startsWith, endsWith, like, ilike, nlike, nilike, isEmpty, isNotEmpty, isNull, isNotNull (JSON, or @path / @- to read a file or stdin). | | `--limit ` | No | Maximum matching rows to delete. (caps a --filter match only; omit it to act on every match, and note 0 is not accepted). | -| `--row ` | No | Explicit row identifiers to delete. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--row ` | No | Explicit row identifiers to delete. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `-y, --yes` | Yes | Confirm this operation. | @@ -6548,11 +6548,11 @@ sim tables dispatches create [options] | Option | Required | Description | | --- | --- | --- | -| `--group-ids ` | Yes | Workflow or enrichment groups to run. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--group-ids ` | Yes | Workflow or enrichment groups to run. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--run-mode ` | No | Whether to run all or only incomplete cells. Defaults to "all". Accepted values: `all`, `incomplete`. | -| `--row-ids ` | No | Explicit row subset to run. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--row-ids ` | No | Explicit row subset to run. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--filter ` | No | Predicate: {"all":[{"field":"status","op":"eq","value":"active"}]}; groups use all/any. Operators: eq, ne, gt, gte, lt, lte, in, nin, contains, ncontains, startsWith, endsWith, like, ilike, nlike, nilike, isEmpty, isNotEmpty, isNull, isNotNull (JSON, or @path / @- to read a file or stdin). | -| `--exclude-row-ids ` | No | Rows excluded from a select-all run scope. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--exclude-row-ids ` | No | Rows excluded from a select-all run scope. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--max-rows ` | No | Stop after this many eligible rows have run (1-1,000,000). Omit for an unbounded run. | @@ -6774,7 +6774,7 @@ sim tables cancel-runs [options] | `--scope ` | Yes | Whether to cancel across the table or one row. Accepted values: `all`, `row`. | | `--row-id ` | No | Row whose runs should be canceled for row scope. | | `--filter ` | No | Predicate: {"all":[{"field":"status","op":"eq","value":"active"}]}; groups use all/any. Operators: eq, ne, gt, gte, lt, lte, in, nin, contains, ncontains, startsWith, endsWith, like, ilike, nlike, nilike, isEmpty, isNotEmpty, isNull, isNotNull (JSON, or @path / @- to read a file or stdin). | -| `--exclude-row-ids ` | No | Rows excluded from an all-scope cancellation. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--exclude-row-ids ` | No | Rows excluded from an all-scope cancellation. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `-y, --yes` | Yes | Confirm this operation. | @@ -7493,7 +7493,7 @@ sim workflow-mcp-servers create [options] | `--description ` | No | Optional server description. | | `--is-public` | No | Whether the server accepts MCP clients without a Sim API key. Defaults to false; a public server lets anyone holding its URL execute the workflows it exposes. | | `--no-is-public` | No | Send --is-public as false. | -| `--workflow ` | No | Deployed workflows to expose as MCP tools on the new server. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | No | Deployed workflows to expose as MCP tools on the new server. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | @@ -7923,7 +7923,7 @@ sim workflows runs get [options] | --- | --- | --- | | `--workflow ` | Yes | Workflow ID. | | `--include-output` | No | Include the final output in JSON or YAML output. | -| `--select-output ` | No | Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--select-output ` | No | Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-file-base64` | No | Inline each produced file's bytes as base64. Requires `includeOutput`. A file above the inline ceiling answers `413` naming its download path; fetch large files from `downloadPath` instead. | | `--no-include-file-base64` | No | Send --include-file-base64 as false. | | `--base64-max-bytes ` | No | Per-file inline ceiling, lowering but never raising the server limit of 16 MiB. | @@ -8510,7 +8510,7 @@ sim workflows run [options] | `--input ` | No | Trigger input as JSON (JSON, or @path / @- to read a file or stdin). | | `--async` | No | Queue the run and return immediately. Defaults to false. | | `--execution-timeout-seconds ` | No | Maximum duration of the run in seconds, capped by the plan's execution timeout. Requires --async or --wait-timeout. | -| `--select-output ` | No | Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--select-output ` | No | Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-file-base64` | No | Inline eligible output files as base64 content. Defaults to true for the installed CLI; Chat defaults to file references and admits requested bytes only for synchronous runs. Rejected when async is true. | | `--no-include-file-base64` | No | Send --include-file-base64 as false. | | `--base64-max-bytes ` | No | Maximum total bytes of file content to inline as base64, lowering but never raising the server limit of 16 MiB. Rejected when `async` is true. | @@ -9140,7 +9140,7 @@ sim workflows move [options] | Option | Required | Description | | --- | --- | --- | -| `--workflow ` | Yes | Workflows to move. Duplicates are collapsed. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | Yes | Workflows to move. Duplicates are collapsed. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--to ` | Yes | Destination folder path; / moves the workflows to the workspace root. | @@ -9506,7 +9506,7 @@ sim workspaces invitations create [options] | Option | Required | Description | | --- | --- | --- | -| `--emails ` | Yes | Email addresses to invite. Each address is processed separately; inspect failed for unsuccessful recipients. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--emails ` | Yes | Email addresses to invite. Each address is processed separately; inspect failed for unsuccessful recipients. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--permission ` | No | Workspace permission to grant. Existing workspace access is preserved. Defaults to "read". Accepted values: `admin`, `write`, `read`. | | `--membership ` | No | Organization membership: member or admin uses a seat when billing is enabled. External grants workspace access only and requires an eligible paid account when billing is enabled. Existing members of another organization remain external. Defaults to "member". Accepted values: `member`, `admin`, `external`. | @@ -10067,7 +10067,7 @@ sim workspaces sync-exclusions [options] | Option | Required | Description | | --- | --- | --- | -| `--workflow ` | Yes | Workflow identifiers in the current workspace. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | Yes | Workflow identifiers in the current workspace. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--fork-sync-excluded ` | Yes | Whether the named workflows should be skipped as sync sources and targets. Accepted values: `true`, `false`. | diff --git a/apps/docs/content/docs/cli/sandboxes.mdx b/apps/docs/content/docs/cli/sandboxes.mdx index 4382b6ec5c1..88d48ca4c93 100644 --- a/apps/docs/content/docs/cli/sandboxes.mdx +++ b/apps/docs/content/docs/cli/sandboxes.mdx @@ -67,8 +67,8 @@ sim sandboxes create [options] | `--name ` | Yes | Display name, unique within the workspace; 1 to 64 characters. | | `--language ` | Yes | Dependency ecosystem: `javascript` installs from npm, `python` from PyPI. Accepted values: `javascript`, `python`. | | `--dependencies ` | No | Package specifiers installed into the sandbox, one per entry. Defaults to []. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | -| `--cli-tools ` | No | Pinned managed CLI ids installed into the sandbox, at most 10, no duplicates. Defaults to []. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | -| `--system-packages ` | No | Debian packages installed into the sandbox, one per entry. Defaults to []. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | +| `--cli-tools ` | No | Pinned managed CLI ids installed into the sandbox, at most 10, no duplicates. Defaults to []. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--system-packages ` | No | Debian packages installed into the sandbox, one per entry. Defaults to []. (space- or comma-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | @@ -101,8 +101,8 @@ sim sandboxes update [options] | `--name ` | No | New display name, unique within the workspace; 1 to 64 characters. | | `--language ` | No | Replacement dependency ecosystem. The whole spec is revalidated against it, so a Python dependency list does not survive a switch to JavaScript. Accepted values: `javascript`, `python`. | | `--dependencies ` | No | Replacement package list; replaces the whole list. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | -| `--cli-tools ` | No | Replacement managed CLI list; replaces the whole list. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | -| `--system-packages ` | No | Replacement Debian package list; replaces the whole list. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | +| `--cli-tools ` | No | Replacement managed CLI list; replaces the whole list. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--system-packages ` | No | Replacement Debian package list; replaces the whole list. (space- or comma-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | diff --git a/apps/docs/content/docs/cli/tables.mdx b/apps/docs/content/docs/cli/tables.mdx index 5a94a7998e4..d3634cc27b9 100644 --- a/apps/docs/content/docs/cli/tables.mdx +++ b/apps/docs/content/docs/cli/tables.mdx @@ -564,7 +564,7 @@ sim tables rows batch-delete [options] | --- | --- | --- | | `--filter ` | No | Predicate: {"all":[{"field":"status","op":"eq","value":"active"}]}; groups use all/any. Operators: eq, ne, gt, gte, lt, lte, in, nin, contains, ncontains, startsWith, endsWith, like, ilike, nlike, nilike, isEmpty, isNotEmpty, isNull, isNotNull (JSON, or @path / @- to read a file or stdin). | | `--limit ` | No | Maximum matching rows to delete. (caps a --filter match only; omit it to act on every match, and note 0 is not accepted). | -| `--row ` | No | Explicit row identifiers to delete. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--row ` | No | Explicit row identifiers to delete. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `-y, --yes` | Yes | Confirm this operation. | @@ -1022,11 +1022,11 @@ sim tables dispatches create [options] | Option | Required | Description | | --- | --- | --- | -| `--group-ids ` | Yes | Workflow or enrichment groups to run. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--group-ids ` | Yes | Workflow or enrichment groups to run. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--run-mode ` | No | Whether to run all or only incomplete cells. Defaults to "all". Accepted values: `all`, `incomplete`. | -| `--row-ids ` | No | Explicit row subset to run. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--row-ids ` | No | Explicit row subset to run. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--filter ` | No | Predicate: {"all":[{"field":"status","op":"eq","value":"active"}]}; groups use all/any. Operators: eq, ne, gt, gte, lt, lte, in, nin, contains, ncontains, startsWith, endsWith, like, ilike, nlike, nilike, isEmpty, isNotEmpty, isNull, isNotNull (JSON, or @path / @- to read a file or stdin). | -| `--exclude-row-ids ` | No | Rows excluded from a select-all run scope. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--exclude-row-ids ` | No | Rows excluded from a select-all run scope. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--max-rows ` | No | Stop after this many eligible rows have run (1-1,000,000). Omit for an unbounded run. | @@ -1091,7 +1091,7 @@ sim tables cancel-runs [options] | `--scope ` | Yes | Whether to cancel across the table or one row. Accepted values: `all`, `row`. | | `--row-id ` | No | Row whose runs should be canceled for row scope. | | `--filter ` | No | Predicate: {"all":[{"field":"status","op":"eq","value":"active"}]}; groups use all/any. Operators: eq, ne, gt, gte, lt, lte, in, nin, contains, ncontains, startsWith, endsWith, like, ilike, nlike, nilike, isEmpty, isNotEmpty, isNull, isNotNull (JSON, or @path / @- to read a file or stdin). | -| `--exclude-row-ids ` | No | Rows excluded from an all-scope cancellation. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--exclude-row-ids ` | No | Rows excluded from an all-scope cancellation. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `-y, --yes` | Yes | Confirm this operation. | diff --git a/apps/docs/content/docs/cli/workflow-mcp-servers.mdx b/apps/docs/content/docs/cli/workflow-mcp-servers.mdx index 2a630a233d4..85d5be6d55d 100644 --- a/apps/docs/content/docs/cli/workflow-mcp-servers.mdx +++ b/apps/docs/content/docs/cli/workflow-mcp-servers.mdx @@ -73,7 +73,7 @@ sim workflow-mcp-servers create [options] | `--description ` | No | Optional server description. | | `--is-public` | No | Whether the server accepts MCP clients without a Sim API key. Defaults to false; a public server lets anyone holding its URL execute the workflows it exposes. | | `--no-is-public` | No | Send --is-public as false. | -| `--workflow ` | No | Deployed workflows to expose as MCP tools on the new server. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | No | Deployed workflows to expose as MCP tools on the new server. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | diff --git a/apps/docs/content/docs/cli/workflows.mdx b/apps/docs/content/docs/cli/workflows.mdx index a3271b8e013..286ece6265d 100644 --- a/apps/docs/content/docs/cli/workflows.mdx +++ b/apps/docs/content/docs/cli/workflows.mdx @@ -149,7 +149,7 @@ sim workflows move [options] | Option | Required | Description | | --- | --- | --- | -| `--workflow ` | Yes | Workflows to move. Duplicates are collapsed. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | Yes | Workflows to move. Duplicates are collapsed. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--to ` | Yes | Destination folder path; / moves the workflows to the workspace root. | @@ -827,7 +827,7 @@ sim workflows run [options] | `--input ` | No | Trigger input as JSON (JSON, or @path / @- to read a file or stdin). | | `--async` | No | Queue the run and return immediately. Defaults to false. | | `--execution-timeout-seconds ` | No | Maximum duration of the run in seconds, capped by the plan's execution timeout. Requires --async or --wait-timeout. | -| `--select-output ` | No | Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--select-output ` | No | Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-file-base64` | No | Inline eligible output files as base64 content. Defaults to true for the installed CLI; Chat defaults to file references and admits requested bytes only for synchronous runs. Rejected when async is true. | | `--no-include-file-base64` | No | Send --include-file-base64 as false. | | `--base64-max-bytes ` | No | Maximum total bytes of file content to inline as base64, lowering but never raising the server limit of 16 MiB. Rejected when `async` is true. | @@ -937,7 +937,7 @@ sim workflows runs get [options] | --- | --- | --- | | `--workflow ` | Yes | Workflow ID. | | `--include-output` | No | Include the final output in JSON or YAML output. | -| `--select-output ` | No | Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--select-output ` | No | Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-file-base64` | No | Inline each produced file's bytes as base64. Requires `includeOutput`. A file above the inline ceiling answers `413` naming its download path; fetch large files from `downloadPath` instead. | | `--no-include-file-base64` | No | Send --include-file-base64 as false. | | `--base64-max-bytes ` | No | Per-file inline ceiling, lowering but never raising the server limit of 16 MiB. | diff --git a/apps/docs/content/docs/cli/workspaces.mdx b/apps/docs/content/docs/cli/workspaces.mdx index 8c1cf5ebd9b..ced64883970 100644 --- a/apps/docs/content/docs/cli/workspaces.mdx +++ b/apps/docs/content/docs/cli/workspaces.mdx @@ -156,7 +156,7 @@ sim workspaces invitations create [options] | Option | Required | Description | | --- | --- | --- | -| `--emails ` | Yes | Email addresses to invite. Each address is processed separately; inspect failed for unsuccessful recipients. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--emails ` | Yes | Email addresses to invite. Each address is processed separately; inspect failed for unsuccessful recipients. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--permission ` | No | Workspace permission to grant. Existing workspace access is preserved. Defaults to "read". Accepted values: `admin`, `write`, `read`. | | `--membership ` | No | Organization membership: member or admin uses a seat when billing is enabled. External grants workspace access only and requires an eligible paid account when billing is enabled. Existing members of another organization remain external. Defaults to "member". Accepted values: `member`, `admin`, `external`. | @@ -633,7 +633,7 @@ sim workspaces sync-exclusions [options] | Option | Required | Description | | --- | --- | --- | -| `--workflow ` | Yes | Workflow identifiers in the current workspace. (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--workflow ` | Yes | Workflow identifiers in the current workspace. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--fork-sync-excluded ` | Yes | Whether the named workflows should be skipped as sync sources and targets. Accepted values: `true`, `false`. | diff --git a/packages/sim-cli/src/commands/protocol/source-tree.ts b/packages/sim-cli/src/commands/protocol/source-tree.ts index e741411aa23..24c275329a8 100644 --- a/packages/sim-cli/src/commands/protocol/source-tree.ts +++ b/packages/sim-cli/src/commands/protocol/source-tree.ts @@ -389,6 +389,19 @@ async function readKeptManifest(dir: string): Promise>> { + const tables = (await readKeptManifest(dir))?.tables ?? {} + return new Map( + Object.entries(tables).map(([key, table]) => [key, new Set(Object.keys(table?.columns ?? {}))]) + ) +} + /** * `workspace.d.ts` for the kept stored manifest and `local`, as {@link refreshWorkspaceTypes} * would write it, without writing it; `null` for no file. A manifest that does not parse counts diff --git a/packages/sim-cli/src/commands/protocol/source-types.ts b/packages/sim-cli/src/commands/protocol/source-types.ts index e5b507538aa..dc681f976db 100644 --- a/packages/sim-cli/src/commands/protocol/source-types.ts +++ b/packages/sim-cli/src/commands/protocol/source-types.ts @@ -31,7 +31,7 @@ import { updateSourceDir, type Written, } from './source-dir' -import { TSCONFIG_FILE, WORKSPACE_TYPES_FILE } from './source-tree' +import { keptTableColumns, TSCONFIG_FILE, WORKSPACE_TYPES_FILE } from './source-tree' import type { Diagnostic } from './source-ui' /** The `--types` / `--no-types` pair: absent runs the type check. */ @@ -464,3 +464,48 @@ export async function typeCheck( } return { checked: true, findings } } + +/** tsc's excess-property error: the property, and the object type it is missing from. */ +const UNKNOWN_PROPERTY = /^TS2353: .*'([^']+)' does not exist in type '(.*)'\.?$/ + +/** A member name in a printed object type (`{ body?: …; "due date": … }`), quoted or bare. */ +const TYPE_MEMBER = /(?:^|[{;]\s*)("(?:[^"\\]|\\.)*"|[A-Za-z_$][\w$]*)\??:/g + +/** The member names of a printed object type. */ +function typeMembers(printed: string): string[] { + return [...printed.matchAll(TYPE_MEMBER)].map(([, name]) => + name.startsWith('"') ? String(JSON.parse(name)) : name + ) +} + +/** + * Adds the refresh to a row write's excess-property type error when the row type is a table's as + * the last get typed it: a column created since (`sim tables columns create`) is missing from those + * types until a command that reads the server rewrites them, and a check makes no request. The + * table is the one whose stored columns hold every member the error prints, and not the property. + */ +export async function withStaleTableHints( + findings: Diagnostic[], + dir: string, + refresh: string +): Promise { + const excess = (finding: Diagnostic) => + finding.code === 'E_TYPE' && !finding.hint && UNKNOWN_PROPERTY.test(finding.message) + if (!findings.some(excess)) return findings + const tables = await keptTableColumns(dir) + return findings.map((finding) => { + const unknown = excess(finding) ? UNKNOWN_PROPERTY.exec(finding.message) : null + if (!unknown) return finding + const [, property, printed] = unknown + const members = typeMembers(printed) + if (members.length === 0) return finding + const table = [...tables].find( + ([, columns]) => !columns.has(property) && members.every((member) => columns.has(member)) + )?.[0] + if (table === undefined) return finding + return { + ...finding, + hint: `"${property}" is not a column of table "${table}" in the types the last get wrote. If it was added since (sim tables columns create), refresh them with \`${refresh}\`, then check again.`, + } + }) +} diff --git a/packages/sim-cli/src/commands/protocol/workflow-source-check.ts b/packages/sim-cli/src/commands/protocol/workflow-source-check.ts index 170eeff6ab2..016fc521d63 100644 --- a/packages/sim-cli/src/commands/protocol/workflow-source-check.ts +++ b/packages/sim-cli/src/commands/protocol/workflow-source-check.ts @@ -24,7 +24,14 @@ import { workspaceFolderOf, } from './source-dir' import { cachedCatalog, cachedSourceCatalog, refreshTsconfigs } from './source-tree' -import { TYPES_HELP, type TypeCheck, type TypesOptions, typeCheck, typesFlag } from './source-types' +import { + TYPES_HELP, + type TypeCheck, + type TypesOptions, + typeCheck, + typesFlag, + withStaleTableHints, +} from './source-types' import { verboseFlag } from './source-ui' import { requireEntry, WORKFLOW_TREE } from './workflow-dir' @@ -118,7 +125,15 @@ export function attachWorkflowSourceCheck(source: Command): void { { sources: [entry] }, { incremental: true } ) - types = await typeCheck(options.dir, { enabled, compiled: findings }) + const checked = await typeCheck(options.dir, { enabled, compiled: findings }) + types = { + ...checked, + findings: await withStaleTableHints( + checked.findings, + options.dir, + `sim workflows source status --dir ${options.dir}` + ), + } } reportCheck( profile.output, diff --git a/packages/sim-cli/src/commands/protocol/workflow-source-get.test.ts b/packages/sim-cli/src/commands/protocol/workflow-source-get.test.ts index 90fa18540de..1cb2ce38cba 100644 --- a/packages/sim-cli/src/commands/protocol/workflow-source-get.test.ts +++ b/packages/sim-cli/src/commands/protocol/workflow-source-get.test.ts @@ -477,6 +477,62 @@ describe('sim workflows source get --dir', () => { ]) }) + it('names the refresh when a row write names a column the table types the last get wrote lack', async () => { + const workflow = [ + '// @sim-sdk 1', + "import { table, trigger, workflow } from '@sim/workflow-sdk'", + '', + "export default workflow('W', {}, () => {", + " const start = trigger.start('Start', {})", + " const save = table.insertRow('Save', { tableId: table('tickets'), data: { subject: 's', category: 'c' } })", + ' start.to(save)', + '})', + '', + ].join('\n') + serve({ + [SOURCE_PATH]: () => source({ 'workflow.ts': workflow }, ['table_v2']), + [MANIFEST_PATH]: () => ({ + data: { + ...MANIFEST.data, + tables: [ + { + key: 'tickets', + id: 'tbl-1', + name: 'tickets', + columns: [ + { name: 'subject', type: 'string' }, + { name: 'body', type: 'string' }, + ], + }, + ], + }, + }), + }) + await get('--dir', outDir) + writeFileSync(join(outDir, 'workflow.ts'), `${workflow}\n`) + contextMockFns.mockProfileFrom.mockReturnValue({ + ...mockedProfile(), + workspaceId: WORKSPACE_ID, + output: 'json', + }) + const check = new Command('source') + attachWorkflowSourceCheck(check) + check.commands.forEach((command) => command.exitOverride()) + await check.parseAsync(['node', 'source', 'check', '--dir', outDir]) + + expect(process.exitCode).toBe(1) + process.exitCode = undefined + const printed = JSON.parse(vi.mocked(console.log).mock.calls.at(-1)?.join(' ') ?? '{}') + expect( + (printed.diagnostics as Array<{ code: string }>).filter(({ code }) => code === 'E_TYPE') + ).toEqual([ + expect.objectContaining({ + message: expect.stringMatching(/^TS2353: .*'category' does not exist/), + hint: expect.stringContaining(`sim workflows source status --dir ${outDir}`), + }), + ]) + }) + it('writes the example workflows beside the guide, outside what the tsconfig files type-check', async () => { serve() diff --git a/packages/sim-cli/src/contract/commands.ts b/packages/sim-cli/src/contract/commands.ts index 720e53ee52b..6273be067d7 100644 --- a/packages/sim-cli/src/contract/commands.ts +++ b/packages/sim-cli/src/contract/commands.ts @@ -1082,19 +1082,20 @@ blocks you add from it.`, updateCustomTool: { flags: { schema: { json: true, describe: CUSTOM_TOOL_SCHEMA_HELP } } }, // A dependency set is typed one specifier at a time or pasted from a // requirements file, so each list takes space-separated values or `@path` - // with one entry per line rather than a JSON array. The package lists are + // with one entry per line; a specifier holds commas (`requests>=2,<3`), so + // the dependency lists keep them (`keepsCommas`). The package lists are // manifests: a requirements file carries blank lines and `#` comments, which // the API ignores, so the reader drops them instead of refusing the file. createSandbox: { flags: { - dependencies: { list: true, manifest: true }, + dependencies: { list: true, manifest: true, keepsCommas: true }, cliTools: { list: true }, systemPackages: { list: true, manifest: true }, }, }, updateSandbox: { flags: { - dependencies: { list: true, manifest: true }, + dependencies: { list: true, manifest: true, keepsCommas: true }, cliTools: { list: true }, systemPackages: { list: true, manifest: true }, }, @@ -1791,7 +1792,6 @@ blocks you add from it.`, fileIds: { list: true, trailing: true, - fileReferences: true, hiddenAliases: ['ids', 'paths'], }, }, diff --git a/packages/sim-cli/src/contract/types.ts b/packages/sim-cli/src/contract/types.ts index 393acd06cff..d7ba43158b3 100644 --- a/packages/sim-cli/src/contract/types.ts +++ b/packages/sim-cli/src/contract/types.ts @@ -51,12 +51,10 @@ export interface FlagSpec { */ hiddenAliases?: readonly string[] /** - * The list holds workspace file ids or `files/…` paths, so an inline value written as a JSON - * array (`["wf_a","wf_b"]`) or joined with commas (`wf_a,wf_b`) is read as its entries. - * Unambiguous because an id is `[A-Za-z0-9_-]` and a path starts with `files/`: neither starts - * with `[`, and a comma splits only a value with no `/`, so a path keeps a comma in its name. + * A {@link list} whose values may themselves hold a comma (a pip requirement such as + * `requests>=2,<3`), so each value is sent as typed rather than split into entries. */ - fileReferences?: true + keepsCommas?: true /** * Accept one or more space-separated values, or `@path` / `@-` with one * value per line. diff --git a/packages/sim-cli/src/embed-isolation.test.ts b/packages/sim-cli/src/embed-isolation.test.ts index 64fc4a82810..1769c75baed 100644 --- a/packages/sim-cli/src/embed-isolation.test.ts +++ b/packages/sim-cli/src/embed-isolation.test.ts @@ -118,6 +118,23 @@ describe('embedded CLI output ownership', () => { expect(noOptions.stderr).not.toContain('Options for') }) + it('names the command a guessed flag belongs to one group down, by any spelling it answers to', async () => { + const guessed = await runEmbeddedCli( + ['tables', 'batch-delete', 'tbl_1', '--row-ids', 'row_1', '--yes'], + { + ...identity, + transport: async () => { + throw new Error('a parse error must not reach the API') + }, + } + ) + expect(guessed.exitCode).toBe(1) + expect(guessed.stderr).toContain('--row-ids is an option of:\n') + expect(guessed.stderr).toContain( + ' sim tables rows batch-delete — Delete rows matching a filter' + ) + }) + it('answers a value typed where a flag belongs with the command line that takes it', async () => { const transport = async () => { throw new Error('a parse error must not reach the API') diff --git a/packages/sim-cli/src/runtime/block-version-note.test.ts b/packages/sim-cli/src/runtime/block-version-note.test.ts new file mode 100644 index 00000000000..c942d76181b --- /dev/null +++ b/packages/sim-cli/src/runtime/block-version-note.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, it } from 'vitest' +import { runEmbeddedCli } from '../embed' + +const identity = { endpoint: 'https://sim.test', apiKey: 'fixture', workspaceId: 'workspace' } + +/** `sim blocks get ` against a catalog that answers with block `answered`. */ +function getBlock(requested: string, answered: string) { + return runEmbeddedCli(['blocks', 'get', requested, '--output', 'json'], { + ...identity, + transport: async () => Response.json({ data: { id: answered, name: 'Table' } }), + }) +} + +describe('blocks get for a base type that reads as its newer version', () => { + it('names the type to add on stderr, which a jq filter on stdout cannot drop', async () => { + const result = await getBlock('table', 'table_v2') + expect(result.exitCode).toBe(0) + expect(JSON.parse(result.stdout)).toMatchObject({ id: 'table_v2' }) + expect(result.stderr).toContain('"table" reads as "table_v2"') + expect(result.stderr).toContain('"type":"table_v2"') + }) + + it('says nothing when the type read is the type asked for', async () => { + const result = await getBlock('table_v2', 'table_v2') + expect(result.exitCode).toBe(0) + expect(result.stderr).toBe('') + }) +}) diff --git a/packages/sim-cli/src/runtime/build.ts b/packages/sim-cli/src/runtime/build.ts index a6ea65c323d..14371ed52a1 100644 --- a/packages/sim-cli/src/runtime/build.ts +++ b/packages/sim-cli/src/runtime/build.ts @@ -145,23 +145,22 @@ function misplacedFlagValue(command: Command): { option: Option; value: string } } /** - * The visible sibling commands that do declare a flag this one does not, each - * with its description, so a read never picks a sibling that deletes. + * The visible commands beside this one, or in a group beside it, that answer to a flag this one + * does not, by any spelling (a hidden alias such as `--row-ids` too), each with its description, + * so a read never picks a sibling that deletes. Looking one group down is what reaches `tables + * rows batch-delete` from `tables batch-delete --row-ids`, which deletes tables, not rows. */ function siblingsDeclaring(command: Command, flag: string): string[] { const parent = command.parent if (!parent) return [] - return parent - .createHelp() - .visibleCommands(parent) - .filter( - (sibling) => - sibling !== command && - sibling.options.some( - (option) => !option.hidden && (option.long === flag || option.short === flag) - ) + const visible = (group: Command) => group.createHelp().visibleCommands(group) + return visible(parent) + .filter((sibling) => sibling !== command) + .flatMap((sibling) => [sibling, ...visible(sibling)]) + .filter((candidate) => + candidate.options.some((option) => option.long === flag || option.short === flag) ) - .map((sibling) => ` ${commandPath(sibling)} — ${sibling.description().split('\n', 1)[0]}`) + .map((owner) => ` ${commandPath(owner)} — ${owner.description().split('\n', 1)[0]}`) } /** diff --git a/packages/sim-cli/src/runtime/execute.ts b/packages/sim-cli/src/runtime/execute.ts index d3e6068c27e..0ccda545442 100644 --- a/packages/sim-cli/src/runtime/execute.ts +++ b/packages/sim-cli/src/runtime/execute.ts @@ -18,6 +18,7 @@ import { camel } from './derive' import { DEFAULT_PAGE_SIZE, defaultListLimit } from './options' import { warnRenamedFlag } from './renamed' import { + type BuiltRequest, buildRequest, cursorSlot, flagNameFor, @@ -232,23 +233,34 @@ const RESULT_NOTES: Readonly< Partial< Record< V2OperationName, - (payload: Record, body: Record | undefined) => string | null + (payload: Record, request: BuiltRequest) => string | null > > > = { - replaceWorkflowChatDeployment: (payload, body) => { + replaceWorkflowChatDeployment: (payload, { body }) => { const authType = payload.authType ?? body?.authType ?? 'public' return authType === 'public' ? 'note: auth type is public — anyone with the link can chat; pass --auth-type password|email to restrict it.' : null }, + /** + * `blocks get table` answers with `table_v2`, the type an add takes, and an add of the base + * type is refused. The resolved `id` is one field of a long record, and an agent's jq filter + * over `configuration` dropped it, so the add that followed said `table`. + */ + getBlock: (payload, { params }) => { + const requested = params.blockId + return typeof payload.id === 'string' && requested !== undefined && payload.id !== requested + ? `note: "${requested}" reads as "${payload.id}", its current version; add it as {"type":"${payload.id}"}.` + : null + }, } /** Writes the operation's result note to stderr, when it has one and the result calls for it. */ function writeResultNote( operation: V2OperationName, payload: unknown, - body: Record | undefined + request: BuiltRequest ): void { const note = RESULT_NOTES[operation] if (!note) return @@ -256,7 +268,7 @@ function writeResultNote( payload && typeof payload === 'object' && !Array.isArray(payload) ? (payload as Record) : {} - const message = note(record, body) + const message = note(record, request) if (message) writeStderr(styles().dim(`${message}\n`)) } @@ -672,7 +684,7 @@ export async function executeOperation( // its own truncation there, and unwrapping `data` discarded it. result ) - writeResultNote(operation, payload, request.body) + writeResultNote(operation, payload, request) // Printed first, then failed, for the reason `followRun` gives: the envelope // carries the block outputs that explain *why* the run failed, and exiting diff --git a/packages/sim-cli/src/runtime/file-references.test.ts b/packages/sim-cli/src/runtime/file-references.test.ts index fe037c29f5a..a9777aeb58b 100644 --- a/packages/sim-cli/src/runtime/file-references.test.ts +++ b/packages/sim-cli/src/runtime/file-references.test.ts @@ -116,3 +116,36 @@ describe('id lists answer to the request field name behind a shortened flag', () expect(result.bodies).toEqual([{ workspaceId: 'workspace', rowIds: ['row_a'] }]) }) }) + +describe('every id list reads repeated, comma-joined and JSON-array values alike', () => { + async function sentRowIds(listArgs: string[]) { + const result = await run(['tables', 'rows', 'batch-delete', 'tbl_a', ...listArgs, '--yes']) + expect(result.exitCode).toBe(0) + return result.bodies.map((body) => (body as { rowIds: string[] }).rowIds) + } + + it('sends each row of a comma-joined --row-ids, not one id holding the commas', async () => { + expect(await sentRowIds(['--row-ids', 'row_a,row_b'])).toEqual([['row_a', 'row_b']]) + expect(await sentRowIds(['--row', 'row_a, row_b'])).toEqual([['row_a', 'row_b']]) + }) + + it('sends the same rows for the repeated and JSON-array forms', async () => { + expect(await sentRowIds(['--row', 'row_a', '--row', 'row_b'])).toEqual([['row_a', 'row_b']]) + expect(await sentRowIds(['--row-ids', '["row_a","row_b"]'])).toEqual([['row_a', 'row_b']]) + }) + + it('keeps a comma that belongs to the value: a requirement specifier', async () => { + const result = await run([ + 'sandboxes', + 'create', + '--name', + 'box', + '--language', + 'python', + '--dependencies', + 'requests>=2,<3', + ]) + expect(result.exitCode).toBe(0) + expect(result.bodies).toEqual([expect.objectContaining({ dependencies: ['requests>=2,<3'] })]) + }) +}) diff --git a/packages/sim-cli/src/runtime/options.ts b/packages/sim-cli/src/runtime/options.ts index 65b2aa36247..436faa77c00 100644 --- a/packages/sim-cli/src/runtime/options.ts +++ b/packages/sim-cli/src/runtime/options.ts @@ -9,6 +9,7 @@ import { otherSpellings, PROFILE_INJECTED_FIELD, pathFlagNameFor, + splitsListValues, takesJson, } from './request' import type { OperationSpec } from './types' @@ -211,6 +212,9 @@ function addFieldOption( } const takesList = flag.list === true + const inlineForms = splitsListValues(flag) + ? 'space- or comma-separated, a JSON array' + : 'space-separated' const wantsJson = takesJson(descriptor, flag) const placeholder = takesList ? '' @@ -232,8 +236,8 @@ function addFieldOption( const describe = `${documented}${ takesList ? flag.manifest - ? ' (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @)' - : ' (space-separated, or @path / @- with one value per line; @@value for a literal leading @)' + ? ` (${inlineForms}, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @)` + : ` (${inlineForms}, or @path / @- with one value per line; @@value for a literal leading @)` : wantsJson ? ' (JSON, or @path / @- to read a file or stdin)' : flag.textSource diff --git a/packages/sim-cli/src/runtime/request.ts b/packages/sim-cli/src/runtime/request.ts index dcbaa7c0235..9800b15d882 100644 --- a/packages/sim-cli/src/runtime/request.ts +++ b/packages/sim-cli/src/runtime/request.ts @@ -328,11 +328,19 @@ export async function readArgumentSource( } /** - * The file references one list value carries: a JSON array's strings, a comma-joined run of - * ids, or the value itself. See {@link FlagSpec.fileReferences} for why neither reading can - * misread a single id or path. + * Whether a list flag reads one value as several entries ({@link listEntries}). A folder path and + * a {@link FlagSpec.keepsCommas} value may hold a comma of its own, so neither splits. */ -function fileReferenceEntries(value: string, flagName: string): string[] { +export function splitsListValues(flag: FlagSpec): boolean { + return !flag.keepsCommas && !flag.folderPath +} + +/** + * The entries one list value carries: a JSON array's strings, a comma-joined run of ids, or the + * value itself. A value holding a `/` (a `files/…` path) keeps its commas, so a path is never cut + * in two. + */ +function listEntries(value: string, flagName: string): string[] { const entries = value.startsWith('[') ? jsonStringArray(value) : value.includes(',') && !value.includes('/') @@ -525,11 +533,11 @@ export async function coerce( */ if (flag.list) { const listed = await readListValues(raw, flagName, flag.manifest === true) - const values = ( - flag.fileReferences - ? listed.flatMap((value) => fileReferenceEntries(value, flagName)) + const values = flag.folderPath + ? listed.map(encodeFolderPath) + : splitsListValues(flag) + ? listed.flatMap((value) => listEntries(value, flagName)) : listed - ).map((value) => (flag.folderPath ? encodeFolderPath(value) : value)) // Encoding first is also what keeps the comma-joined form unambiguous: a // folder name containing a comma leaves here as `%2C`, so the route's split // cannot cut one path in half. From ac3e9ea0ead079890d495c6195cef7783df0a093 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Thu, 26 Nov 2026 12:35:25 -0800 Subject: [PATCH 2/2] fix(cli): explicit list value policy and an unambiguous stale-table hint - List flags declare how a value reads (`listValues`): ids split on commas, `text` (dependencies, output selectors, folder paths) keeps commas, and `fileReferences` keeps a `files/` path whole; every list decodes a JSON array. - `workflows runs get --select-output` reads its values with the same parser before resolving block names. - The stale-table hint names a table only when exactly one stored table is the printed row, reads single-quoted keys, and shell-quotes the directory. --- apps/docs/content/docs/cli/files.mdx | 2 +- apps/docs/content/docs/cli/logs.mdx | 4 +- apps/docs/content/docs/cli/reference.mdx | 18 ++--- apps/docs/content/docs/cli/sandboxes.mdx | 4 +- apps/docs/content/docs/cli/tables.mdx | 4 +- apps/docs/content/docs/cli/workflows.mdx | 4 +- .../src/commands/protocol/source-types.ts | 64 ++++++++++----- .../protocol/stale-table-hints.test.ts | 81 +++++++++++++++++++ .../protocol/workflow-run-get.test.ts | 11 +++ .../src/commands/protocol/workflow-run-get.ts | 8 +- .../protocol/workflow-source-check.ts | 6 +- packages/sim-cli/src/contract/commands.ts | 10 ++- packages/sim-cli/src/contract/types.ts | 13 ++- .../src/runtime/file-references.test.ts | 31 +++++++ packages/sim-cli/src/runtime/options.ts | 9 ++- packages/sim-cli/src/runtime/request.ts | 60 +++++++++----- 16 files changed, 254 insertions(+), 75 deletions(-) create mode 100644 packages/sim-cli/src/commands/protocol/stale-table-hints.test.ts diff --git a/apps/docs/content/docs/cli/files.mdx b/apps/docs/content/docs/cli/files.mdx index a794fb77003..80c45e63e89 100644 --- a/apps/docs/content/docs/cli/files.mdx +++ b/apps/docs/content/docs/cli/files.mdx @@ -82,7 +82,7 @@ sim files search [options] | `--query ` | Yes | Regular expression, or exact text when `mode` is `exact`. | | `--mode ` | No | How `query` is read. Defaults to "regex". Accepted values: `exact`, `regex`. | | `--max-results ` | No | Maximum matching lines to return. Defaults to 50. | -| `--folder ` | No | Folders to search, by path as shown in the app; omit to search the whole workspace (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Folders to search, by path as shown in the app; omit to search the whole workspace (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-subfolders` | No | Whether each folder scope includes nested folders; on by default. | | `--no-include-subfolders` | No | Send --include-subfolders as false. | diff --git a/apps/docs/content/docs/cli/logs.mdx b/apps/docs/content/docs/cli/logs.mdx index d1a1e9cd7c9..fa6af1b6acb 100644 --- a/apps/docs/content/docs/cli/logs.mdx +++ b/apps/docs/content/docs/cli/logs.mdx @@ -47,7 +47,7 @@ sim logs list [options] | `--run-id ` | No | Exact run identifier to match. | | `--sort-by ` | No | Field used to sort the result. `durationMs` and `cost` are null until a run settles; those runs sort before recorded values in ascending order and after them in descending order. Only `startedAt` can order Chat and Sim-agent job runs, so any other value is rejected when job runs are included. Defaults to "startedAt". Accepted values: `startedAt`, `durationMs`, `cost`, `status`. | | `--sort-order ` | No | Sort direction. Defaults to "desc". Accepted values: `asc`, `desc`. | -| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | @@ -96,7 +96,7 @@ sim logs stats [options] | Option | Required | Description | | --- | --- | --- | | `--workflow ` | No | Comma-separated workflow identifiers to include. At most 200 entries. An empty entry is rejected. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | -| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--trigger ` | No | Comma-separated trigger types to include. An empty entry is rejected. The vocabulary is open, so an unrecognized member selects no runs; the literal `all` disables this filter. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--level ` | No | Severity level to include. Accepted values: `info`, `error`. | | `--include-handled-errors` | No | Whether runs with a handled block error are counted as `handledErrorRuns`, and whether `level=error` also selects them. Off by default: counting them scans each run’s stored trace. | diff --git a/apps/docs/content/docs/cli/reference.mdx b/apps/docs/content/docs/cli/reference.mdx index 10a011f2e69..7053bf921fd 100644 --- a/apps/docs/content/docs/cli/reference.mdx +++ b/apps/docs/content/docs/cli/reference.mdx @@ -1736,7 +1736,7 @@ sim files search [options] | `--query ` | Yes | Regular expression, or exact text when `mode` is `exact`. | | `--mode ` | No | How `query` is read. Defaults to "regex". Accepted values: `exact`, `regex`. | | `--max-results ` | No | Maximum matching lines to return. Defaults to 50. | -| `--folder ` | No | Folders to search, by path as shown in the app; omit to search the whole workspace (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Folders to search, by path as shown in the app; omit to search the whole workspace (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-subfolders` | No | Whether each folder scope includes nested folders; on by default. | | `--no-include-subfolders` | No | Send --include-subfolders as false. | @@ -3356,7 +3356,7 @@ sim logs stats [options] | Option | Required | Description | | --- | --- | --- | | `--workflow ` | No | Comma-separated workflow identifiers to include. At most 200 entries. An empty entry is rejected. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | -| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--trigger ` | No | Comma-separated trigger types to include. An empty entry is rejected. The vocabulary is open, so an unrecognized member selects no runs; the literal `all` disables this filter. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--level ` | No | Severity level to include. Accepted values: `info`, `error`. | | `--include-handled-errors` | No | Whether runs with a handled block error are counted as `handledErrorRuns`, and whether `level=error` also selects them. Off by default: counting them scans each run’s stored trace. | @@ -3408,7 +3408,7 @@ sim logs list [options] | `--run-id ` | No | Exact run identifier to match. | | `--sort-by ` | No | Field used to sort the result. `durationMs` and `cost` are null until a run settles; those runs sort before recorded values in ascending order and after them in descending order. Only `startedAt` can order Chat and Sim-agent job runs, so any other value is rejected when job runs are included. Defaults to "startedAt". Accepted values: `startedAt`, `durationMs`, `cost`, `status`. | | `--sort-order ` | No | Sort direction. Defaults to "desc". Accepted values: `asc`, `desc`. | -| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | @@ -5330,7 +5330,7 @@ sim sandboxes create [options] | --- | --- | --- | | `--name ` | Yes | Display name, unique within the workspace; 1 to 64 characters. | | `--language ` | Yes | Dependency ecosystem: `javascript` installs from npm, `python` from PyPI. Accepted values: `javascript`, `python`. | -| `--dependencies ` | No | Package specifiers installed into the sandbox, one per entry. Defaults to []. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | +| `--dependencies ` | No | Package specifiers installed into the sandbox, one per entry. Defaults to []. (space-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | | `--cli-tools ` | No | Pinned managed CLI ids installed into the sandbox, at most 10, no duplicates. Defaults to []. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--system-packages ` | No | Debian packages installed into the sandbox, one per entry. Defaults to []. (space- or comma-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | @@ -5439,7 +5439,7 @@ sim sandboxes update [options] | --- | --- | --- | | `--name ` | No | New display name, unique within the workspace; 1 to 64 characters. | | `--language ` | No | Replacement dependency ecosystem. The whole spec is revalidated against it, so a Python dependency list does not survive a switch to JavaScript. Accepted values: `javascript`, `python`. | -| `--dependencies ` | No | Replacement package list; replaces the whole list. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | +| `--dependencies ` | No | Replacement package list; replaces the whole list. (space-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | | `--cli-tools ` | No | Replacement managed CLI list; replaces the whole list. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--system-packages ` | No | Replacement Debian package list; replaces the whole list. (space- or comma-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | @@ -6105,7 +6105,7 @@ sim tables batch-delete [options] | Option | Required | Description | | --- | --- | --- | | `--table-ids ` | No | Tables to archive, by identifier. Defaults to []. (JSON, or @path / @- to read a file or stdin). | -| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `-y, --yes` | Yes | Confirm this operation. | @@ -7179,7 +7179,7 @@ sim tables move [options] | Option | Required | Description | | --- | --- | --- | | `--table-ids ` | No | Tables to move, by identifier. Defaults to []. (JSON, or @path / @- to read a file or stdin). | -| `--folder ` | No | Table folders to move, by path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Table folders to move, by path as shown in the app; the leading / is optional (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--to ` | No | Destination folder path; omit for root. | @@ -7923,7 +7923,7 @@ sim workflows runs get [options] | --- | --- | --- | | `--workflow ` | Yes | Workflow ID. | | `--include-output` | No | Include the final output in JSON or YAML output. | -| `--select-output ` | No | Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--select-output ` | No | Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-file-base64` | No | Inline each produced file's bytes as base64. Requires `includeOutput`. A file above the inline ceiling answers `413` naming its download path; fetch large files from `downloadPath` instead. | | `--no-include-file-base64` | No | Send --include-file-base64 as false. | | `--base64-max-bytes ` | No | Per-file inline ceiling, lowering but never raising the server limit of 16 MiB. | @@ -8510,7 +8510,7 @@ sim workflows run [options] | `--input ` | No | Trigger input as JSON (JSON, or @path / @- to read a file or stdin). | | `--async` | No | Queue the run and return immediately. Defaults to false. | | `--execution-timeout-seconds ` | No | Maximum duration of the run in seconds, capped by the plan's execution timeout. Requires --async or --wait-timeout. | -| `--select-output ` | No | Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--select-output ` | No | Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-file-base64` | No | Inline eligible output files as base64 content. Defaults to true for the installed CLI; Chat defaults to file references and admits requested bytes only for synchronous runs. Rejected when async is true. | | `--no-include-file-base64` | No | Send --include-file-base64 as false. | | `--base64-max-bytes ` | No | Maximum total bytes of file content to inline as base64, lowering but never raising the server limit of 16 MiB. Rejected when `async` is true. | diff --git a/apps/docs/content/docs/cli/sandboxes.mdx b/apps/docs/content/docs/cli/sandboxes.mdx index 88d48ca4c93..2fd83e5e805 100644 --- a/apps/docs/content/docs/cli/sandboxes.mdx +++ b/apps/docs/content/docs/cli/sandboxes.mdx @@ -66,7 +66,7 @@ sim sandboxes create [options] | --- | --- | --- | | `--name ` | Yes | Display name, unique within the workspace; 1 to 64 characters. | | `--language ` | Yes | Dependency ecosystem: `javascript` installs from npm, `python` from PyPI. Accepted values: `javascript`, `python`. | -| `--dependencies ` | No | Package specifiers installed into the sandbox, one per entry. Defaults to []. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | +| `--dependencies ` | No | Package specifiers installed into the sandbox, one per entry. Defaults to []. (space-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | | `--cli-tools ` | No | Pinned managed CLI ids installed into the sandbox, at most 10, no duplicates. Defaults to []. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--system-packages ` | No | Debian packages installed into the sandbox, one per entry. Defaults to []. (space- or comma-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | @@ -100,7 +100,7 @@ sim sandboxes update [options] | --- | --- | --- | | `--name ` | No | New display name, unique within the workspace; 1 to 64 characters. | | `--language ` | No | Replacement dependency ecosystem. The whole spec is revalidated against it, so a Python dependency list does not survive a switch to JavaScript. Accepted values: `javascript`, `python`. | -| `--dependencies ` | No | Replacement package list; replaces the whole list. (space-separated, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | +| `--dependencies ` | No | Replacement package list; replaces the whole list. (space-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | | `--cli-tools ` | No | Replacement managed CLI list; replaces the whole list. (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--system-packages ` | No | Replacement Debian package list; replaces the whole list. (space- or comma-separated, a JSON array, or @path / @- with one value per line; in a file, blank lines and # comments are ignored, while inline values are sent as typed and may not be empty; @@value for a literal leading @). | diff --git a/apps/docs/content/docs/cli/tables.mdx b/apps/docs/content/docs/cli/tables.mdx index d3634cc27b9..56b2086b8b9 100644 --- a/apps/docs/content/docs/cli/tables.mdx +++ b/apps/docs/content/docs/cli/tables.mdx @@ -118,7 +118,7 @@ sim tables move [options] | Option | Required | Description | | --- | --- | --- | | `--table-ids ` | No | Tables to move, by identifier. Defaults to []. (JSON, or @path / @- to read a file or stdin). | -| `--folder ` | No | Table folders to move, by path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Table folders to move, by path as shown in the app; the leading / is optional (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--to ` | No | Destination folder path; omit for root. | @@ -189,7 +189,7 @@ sim tables batch-delete [options] | Option | Required | Description | | --- | --- | --- | | `--table-ids ` | No | Tables to archive, by identifier. Defaults to []. (JSON, or @path / @- to read a file or stdin). | -| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, or @path / @- with one value per line; @@value for a literal leading @). | +| `--folder ` | No | Folder path as shown in the app; the leading / is optional (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `-y, --yes` | Yes | Confirm this operation. | diff --git a/apps/docs/content/docs/cli/workflows.mdx b/apps/docs/content/docs/cli/workflows.mdx index 286ece6265d..5c8e30f6e51 100644 --- a/apps/docs/content/docs/cli/workflows.mdx +++ b/apps/docs/content/docs/cli/workflows.mdx @@ -827,7 +827,7 @@ sim workflows run [options] | `--input ` | No | Trigger input as JSON (JSON, or @path / @- to read a file or stdin). | | `--async` | No | Queue the run and return immediately. Defaults to false. | | `--execution-timeout-seconds ` | No | Maximum duration of the run in seconds, capped by the plan's execution timeout. Requires --async or --wait-timeout. | -| `--select-output ` | No | Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--select-output ` | No | Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-file-base64` | No | Inline eligible output files as base64 content. Defaults to true for the installed CLI; Chat defaults to file references and admits requested bytes only for synchronous runs. Rejected when async is true. | | `--no-include-file-base64` | No | Send --include-file-base64 as false. | | `--base64-max-bytes ` | No | Maximum total bytes of file content to inline as base64, lowering but never raising the server limit of 16 MiB. Rejected when `async` is true. | @@ -937,7 +937,7 @@ sim workflows runs get [options] | --- | --- | --- | | `--workflow ` | Yes | Workflow ID. | | `--include-output` | No | Include the final output in JSON or YAML output. | -| `--select-output ` | No | Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted (space- or comma-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | +| `--select-output ` | No | Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted (space-separated, a JSON array, or @path / @- with one value per line; @@value for a literal leading @). | | `--include-file-base64` | No | Inline each produced file's bytes as base64. Requires `includeOutput`. A file above the inline ceiling answers `413` naming its download path; fetch large files from `downloadPath` instead. | | `--no-include-file-base64` | No | Send --include-file-base64 as false. | | `--base64-max-bytes ` | No | Per-file inline ceiling, lowering but never raising the server limit of 16 MiB. | diff --git a/packages/sim-cli/src/commands/protocol/source-types.ts b/packages/sim-cli/src/commands/protocol/source-types.ts index dc681f976db..5cbce967139 100644 --- a/packages/sim-cli/src/commands/protocol/source-types.ts +++ b/packages/sim-cli/src/commands/protocol/source-types.ts @@ -32,7 +32,7 @@ import { type Written, } from './source-dir' import { keptTableColumns, TSCONFIG_FILE, WORKSPACE_TYPES_FILE } from './source-tree' -import type { Diagnostic } from './source-ui' +import { type Diagnostic, shellWord } from './source-ui' /** The `--types` / `--no-types` pair: absent runs the type check. */ export interface TypesOptions { @@ -468,44 +468,72 @@ export async function typeCheck( /** tsc's excess-property error: the property, and the object type it is missing from. */ const UNKNOWN_PROPERTY = /^TS2353: .*'([^']+)' does not exist in type '(.*)'\.?$/ -/** A member name in a printed object type (`{ body?: …; "due date": … }`), quoted or bare. */ -const TYPE_MEMBER = /(?:^|[{;]\s*)("(?:[^"\\]|\\.)*"|[A-Za-z_$][\w$]*)\??:/g +/** A member name in a printed object type (`{ body?: …; 'due date': … }`), quoted or bare. */ +const TYPE_MEMBER = /(?:^|[{;]\s*)('(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"|[A-Za-z_$][\w$]*)\??:/g -/** The member names of a printed object type. */ +/** What tsc prints in place of the members a long type leaves out. */ +const ELIDED_MEMBERS = /\.\.\. \d+ more \.\.\./ + +/** The member names of a printed object type, unquoted. */ function typeMembers(printed: string): string[] { return [...printed.matchAll(TYPE_MEMBER)].map(([, name]) => - name.startsWith('"') ? String(JSON.parse(name)) : name + /^['"]/.test(name) ? name.slice(1, -1).replace(/\\(.)/g, '$1') : name + ) +} + +/** + * The stored table a row type printed in a type error is, when exactly one fits: its columns are + * the printed members (or hold them, when tsc elided some) and lack `property`. `null` when none + * fits, `undefined` when several do. + */ +function tableOfRow( + tables: ReadonlyMap>, + property: string, + printed: string +): string | null | undefined { + const members = typeMembers(printed) + if (members.length === 0) return null + const elided = ELIDED_MEMBERS.test(printed) + const fits = [...tables].filter( + ([, columns]) => + !columns.has(property) && + (elided || columns.size === members.length) && + members.every((member) => columns.has(member)) ) + if (fits.length === 0) return null + return fits.length === 1 ? fits[0][0] : undefined } /** - * Adds the refresh to a row write's excess-property type error when the row type is a table's as - * the last get typed it: a column created since (`sim tables columns create`) is missing from those - * types until a command that reads the server rewrites them, and a check makes no request. The - * table is the one whose stored columns hold every member the error prints, and not the property. + * Adds the refresh to a row write's excess-property type error when the row type is a stored + * table's as the last get typed it: a column created since (`sim tables columns create`) is + * missing from those types until a command that reads the server (`source status`) rewrites + * them, and a check makes no request. The hint names the table only when one table alone fits. + * Only a workflow directory of its own types tables from the kept manifest: in a workspace + * directory a table's row type comes from its `tables/.ts`, which the check reads fresh. */ export async function withStaleTableHints( findings: Diagnostic[], - dir: string, - refresh: string + dir: string ): Promise { const excess = (finding: Diagnostic) => finding.code === 'E_TYPE' && !finding.hint && UNKNOWN_PROPERTY.test(finding.message) if (!findings.some(excess)) return findings const tables = await keptTableColumns(dir) + const refresh = `sim workflows source status --dir ${shellWord(dir)}` return findings.map((finding) => { const unknown = excess(finding) ? UNKNOWN_PROPERTY.exec(finding.message) : null if (!unknown) return finding const [, property, printed] = unknown - const members = typeMembers(printed) - if (members.length === 0) return finding - const table = [...tables].find( - ([, columns]) => !columns.has(property) && members.every((member) => columns.has(member)) - )?.[0] - if (table === undefined) return finding + const table = tableOfRow(tables, property, printed) + if (table === null) return finding + const missing = + table === undefined + ? `"${property}" is not a column of the table in the types the last get wrote.` + : `"${property}" is not a column of table "${table}" in the types the last get wrote.` return { ...finding, - hint: `"${property}" is not a column of table "${table}" in the types the last get wrote. If it was added since (sim tables columns create), refresh them with \`${refresh}\`, then check again.`, + hint: `${missing} If it was added since (sim tables columns create), refresh them with \`${refresh}\`, then check again.`, } }) } diff --git a/packages/sim-cli/src/commands/protocol/stale-table-hints.test.ts b/packages/sim-cli/src/commands/protocol/stale-table-hints.test.ts new file mode 100644 index 00000000000..1e0ea94b30e --- /dev/null +++ b/packages/sim-cli/src/commands/protocol/stale-table-hints.test.ts @@ -0,0 +1,81 @@ +import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs' +import { tmpdir } from 'node:os' +import { join } from 'node:path' +import { afterEach, beforeEach, describe, expect, it } from 'vitest' +import { withStaleTableHints } from './source-types' +import type { Diagnostic } from './source-ui' + +let dir: string + +/** Keeps a manifest with these tables' columns, as a get leaves it beside `workspace.d.ts`. */ +function keep(tables: Record) { + mkdirSync(join(dir, '.sim/sdk'), { recursive: true }) + const manifest = { + tables: Object.fromEntries( + Object.entries(tables).map(([key, columns]) => [ + key, + { columns: Object.fromEntries(columns.map((name) => [name, { type: 'string' }])) }, + ]) + ), + } + writeFileSync(join(dir, '.sim/sdk/workspace.manifest.json'), JSON.stringify(manifest)) +} + +function excess(property: string, members: string): Diagnostic { + return { + code: 'E_TYPE', + severity: 'error', + message: `TS2353: Object literal may only specify known properties, and '${property}' does not exist in type '{} & { ${members} }'.`, + } +} + +async function hintFor(finding: Diagnostic) { + const [hinted] = await withStaleTableHints([finding], dir) + return hinted.hint +} + +beforeEach(() => { + dir = mkdtempSync(join(tmpdir(), 'sim-stale-')) +}) + +afterEach(() => { + rmSync(dir, { recursive: true, force: true }) +}) + +describe('the refresh hint on a row write naming a column the stored table lacks', () => { + it('names no table when two stored tables both fit the printed row', async () => { + keep({ tickets: ['subject', 'body'], archive: ['subject', 'body'] }) + const hint = await hintFor( + excess('category', 'body?: Value | undefined; subject?: Value | undefined;') + ) + expect(hint).toContain('sim workflows source status') + expect(hint).not.toMatch(/table "(tickets|archive)"/) + }) + + it('names the one table whose columns are exactly the printed row', async () => { + keep({ tickets: ['subject', 'body'], wide: ['subject', 'body', 'owner'] }) + const hint = await hintFor( + excess('category', 'body?: Value | undefined; subject?: Value | undefined;') + ) + expect(hint).toContain('table "tickets"') + }) + + it('reads a single-quoted column name', async () => { + keep({ other: ['subject'], tickets: ['due date', 'subject'] }) + const hint = await hintFor( + excess( + 'category', + "'due date'?: Value | undefined; subject?: Value | undefined;" + ) + ) + expect(hint).toContain('table "tickets"') + }) + + it('quotes a directory the shell would split', async () => { + rmSync(dir, { recursive: true, force: true }) + dir = mkdtempSync(join(tmpdir(), 'sim stale ')) + keep({ tickets: ['subject'] }) + const hint = await hintFor(excess('category', 'subject?: Value | undefined;')) + expect(hint).toContain(`sim workflows source status --dir '${dir}'`) + }) +}) diff --git a/packages/sim-cli/src/commands/protocol/workflow-run-get.test.ts b/packages/sim-cli/src/commands/protocol/workflow-run-get.test.ts index 2775f7286c0..28a4797156b 100644 --- a/packages/sim-cli/src/commands/protocol/workflow-run-get.test.ts +++ b/packages/sim-cli/src/commands/protocol/workflow-run-get.test.ts @@ -96,6 +96,17 @@ describe('sim workflows runs get --select-output', () => { }) }) + it('reads a JSON array of selectors as its entries before resolving names', async () => { + answer({ data: { runId: RUN_ID, status: 'completed', blockOutputs: {} } }) + stdout() + + await get('--select-output', '["summarizeresult.text","Save"]') + + expect(request.mock.calls[1][1].query).toEqual({ + selectedOutputs: `${SUMMARIZE_ID}.text,${SAVE_ID}`, + }) + }) + it('refuses a name no block carries, says names are accepted, and lists them', async () => { answer({ data: { runId: RUN_ID, status: 'completed' } }) diff --git a/packages/sim-cli/src/commands/protocol/workflow-run-get.ts b/packages/sim-cli/src/commands/protocol/workflow-run-get.ts index 21a77cd6118..b412fa8b0da 100644 --- a/packages/sim-cli/src/commands/protocol/workflow-run-get.ts +++ b/packages/sim-cli/src/commands/protocol/workflow-run-get.ts @@ -10,7 +10,7 @@ import { type OperationClient, } from '../../runtime/called-operations' import { retypeApiError } from '../../runtime/naming' -import { buildRequest, readListValues } from '../../runtime/request' +import { buildRequest, flagSpecFor, readListFlag } from '../../runtime/request' import { renderResult } from '../../runtime/result' import type { OperationSpec } from '../../runtime/types' @@ -232,7 +232,11 @@ export function attachWorkflowRunGet(runs: Command): void { } // Expanded here, once: a `@-` source cannot be read twice, and the // generated path would read it again if it still saw the `@`. - const typed = await readListValues(raw, SELECT_OUTPUT_FLAG) + const typed = await readListFlag( + raw, + flagSpecFor('getWorkflowRun', 'selectedOutputs'), + SELECT_OUTPUT_FLAG + ) command.setOptionValue('selectOutput', typed) if (typed.every(isIdHeaded)) { await previous(command.processedArgs) diff --git a/packages/sim-cli/src/commands/protocol/workflow-source-check.ts b/packages/sim-cli/src/commands/protocol/workflow-source-check.ts index 016fc521d63..debb5f90c6b 100644 --- a/packages/sim-cli/src/commands/protocol/workflow-source-check.ts +++ b/packages/sim-cli/src/commands/protocol/workflow-source-check.ts @@ -128,11 +128,7 @@ export function attachWorkflowSourceCheck(source: Command): void { const checked = await typeCheck(options.dir, { enabled, compiled: findings }) types = { ...checked, - findings: await withStaleTableHints( - checked.findings, - options.dir, - `sim workflows source status --dir ${options.dir}` - ), + findings: await withStaleTableHints(checked.findings, options.dir), } } reportCheck( diff --git a/packages/sim-cli/src/contract/commands.ts b/packages/sim-cli/src/contract/commands.ts index 6273be067d7..61a1b256a42 100644 --- a/packages/sim-cli/src/contract/commands.ts +++ b/packages/sim-cli/src/contract/commands.ts @@ -1083,19 +1083,19 @@ blocks you add from it.`, // A dependency set is typed one specifier at a time or pasted from a // requirements file, so each list takes space-separated values or `@path` // with one entry per line; a specifier holds commas (`requests>=2,<3`), so - // the dependency lists keep them (`keepsCommas`). The package lists are + // the dependency lists keep them (`listValues: 'text'`). The package lists are // manifests: a requirements file carries blank lines and `#` comments, which // the API ignores, so the reader drops them instead of refusing the file. createSandbox: { flags: { - dependencies: { list: true, manifest: true, keepsCommas: true }, + dependencies: { list: true, manifest: true, listValues: 'text' }, cliTools: { list: true }, systemPackages: { list: true, manifest: true }, }, }, updateSandbox: { flags: { - dependencies: { list: true, manifest: true, keepsCommas: true }, + dependencies: { list: true, manifest: true, listValues: 'text' }, cliTools: { list: true }, systemPackages: { list: true, manifest: true }, }, @@ -1229,6 +1229,7 @@ blocks you add from it.`, fileReferences: { name: 'file', list: true, + listValues: 'fileReferences', describe: 'Workspace file ID or canonical files// path (repeatable)', }, }, @@ -1792,6 +1793,7 @@ blocks you add from it.`, fileIds: { list: true, trailing: true, + listValues: 'fileReferences', hiddenAliases: ['ids', 'paths'], }, }, @@ -2405,6 +2407,7 @@ always prints as null. For a copy to share outside this workspace, pass selectedOutputs: { name: 'select-output', list: true, + listValues: 'text', describe: 'Return blockName.path values (e.g. agent_1.content), or childWorkflowId.blockName.path for a child workflow (applies to every invocation) — in blockOutputs on a sync run, or from the streamed result with --follow; missing paths are omitted. Not available with --async', }, @@ -2456,6 +2459,7 @@ always prints as null. For a copy to share outside this workspace, pass selectedOutputs: { name: 'select-output', list: true, + listValues: 'text', describe: 'Include blockName.path or blockId.path values (e.g. agent_1.content) in JSON or YAML output; names resolve against the workflow’s current blocks, and missing paths are omitted', }, diff --git a/packages/sim-cli/src/contract/types.ts b/packages/sim-cli/src/contract/types.ts index d7ba43158b3..698fad3954d 100644 --- a/packages/sim-cli/src/contract/types.ts +++ b/packages/sim-cli/src/contract/types.ts @@ -51,10 +51,17 @@ export interface FlagSpec { */ hiddenAliases?: readonly string[] /** - * A {@link list} whose values may themselves hold a comma (a pip requirement such as - * `requests>=2,<3`), so each value is sent as typed rather than split into entries. + * How a {@link list} reads one inline value as entries; every list reads a JSON array of + * strings (`["a","b"]`) as its entries. + * + * - unset: ids, so a comma-joined run (`a,b`) is its entries too. + * - `text`: a value may hold a comma of its own (a pip requirement `requests>=2,<3`, an output + * selector naming a block `Draft, Review`), so a comma never splits it. A folder path list + * reads this way without saying so. + * - `fileReferences`: workspace file ids or `files/…` paths. A comma splits ids, never a value + * that is a `files/` path, so a path keeps a comma in its name. */ - keepsCommas?: true + listValues?: 'text' | 'fileReferences' /** * Accept one or more space-separated values, or `@path` / `@-` with one * value per line. diff --git a/packages/sim-cli/src/runtime/file-references.test.ts b/packages/sim-cli/src/runtime/file-references.test.ts index a9777aeb58b..9d95acc30d6 100644 --- a/packages/sim-cli/src/runtime/file-references.test.ts +++ b/packages/sim-cli/src/runtime/file-references.test.ts @@ -1,5 +1,6 @@ import { describe, expect, it } from 'vitest' import { runEmbeddedCli } from '../embed' +import { flagSpecFor, readListFlag } from './request' const identity = { endpoint: 'https://sim.test', apiKey: 'fixture', workspaceId: 'workspace' } @@ -149,3 +150,33 @@ describe('every id list reads repeated, comma-joined and JSON-array values alike expect(result.bodies).toEqual([expect.objectContaining({ dependencies: ['requests>=2,<3'] })]) }) }) + +describe('lists whose values hold commas still read a JSON array', () => { + it('sends each specifier of a JSON-array --dependencies, keeping the commas inside one', async () => { + const result = await run([ + 'sandboxes', + 'create', + '--name', + 'box', + '--language', + 'python', + '--dependencies', + '["requests>=2,<3","httpx"]', + ]) + expect(result.exitCode).toBe(0) + expect(result.bodies).toEqual([ + expect.objectContaining({ dependencies: ['requests>=2,<3', 'httpx'] }), + ]) + }) + + it('keeps an output selector naming a block whose name holds a comma as one selector', async () => { + const flag = flagSpecFor('executeWorkflow', 'selectedOutputs') + expect(await readListFlag(['Draft, Review.content'], flag, 'select-output')).toEqual([ + 'Draft, Review.content', + ]) + expect(await readListFlag(['["a.content","b"]'], flag, 'select-output')).toEqual([ + 'a.content', + 'b', + ]) + }) +}) diff --git a/packages/sim-cli/src/runtime/options.ts b/packages/sim-cli/src/runtime/options.ts index 436faa77c00..9c6f72f4a5a 100644 --- a/packages/sim-cli/src/runtime/options.ts +++ b/packages/sim-cli/src/runtime/options.ts @@ -6,10 +6,10 @@ import { type FieldSpec, flagNameFor, flagSpecFor, + listValuesOf, otherSpellings, PROFILE_INJECTED_FIELD, pathFlagNameFor, - splitsListValues, takesJson, } from './request' import type { OperationSpec } from './types' @@ -212,9 +212,10 @@ function addFieldOption( } const takesList = flag.list === true - const inlineForms = splitsListValues(flag) - ? 'space- or comma-separated, a JSON array' - : 'space-separated' + const inlineForms = + listValuesOf(flag) === 'text' + ? 'space-separated, a JSON array' + : 'space- or comma-separated, a JSON array' const wantsJson = takesJson(descriptor, flag) const placeholder = takesList ? '' diff --git a/packages/sim-cli/src/runtime/request.ts b/packages/sim-cli/src/runtime/request.ts index 9800b15d882..1ff2dc51d64 100644 --- a/packages/sim-cli/src/runtime/request.ts +++ b/packages/sim-cli/src/runtime/request.ts @@ -327,23 +327,30 @@ export async function readArgumentSource( } } -/** - * Whether a list flag reads one value as several entries ({@link listEntries}). A folder path and - * a {@link FlagSpec.keepsCommas} value may hold a comma of its own, so neither splits. - */ -export function splitsListValues(flag: FlagSpec): boolean { - return !flag.keepsCommas && !flag.folderPath +/** How a list flag reads one value as entries ({@link FlagSpec.listValues}). */ +export function listValuesOf(flag: FlagSpec): 'ids' | 'text' | 'fileReferences' { + return flag.listValues ?? (flag.folderPath ? 'text' : 'ids') +} + +/** Whether `value`, read as `listValues`, is a comma-joined run of entries. */ +function splitsOnCommas(value: string, listValues: ReturnType): boolean { + if (!value.includes(',')) return false + if (listValues === 'fileReferences') return !value.startsWith('files/') + return listValues === 'ids' } /** - * The entries one list value carries: a JSON array's strings, a comma-joined run of ids, or the - * value itself. A value holding a `/` (a `files/…` path) keeps its commas, so a path is never cut - * in two. + * The entries one list value carries under its flag's {@link FlagSpec.listValues}: a JSON array's + * strings, a comma-joined run, or the value itself. */ -function listEntries(value: string, flagName: string): string[] { +function listEntries( + value: string, + flagName: string, + listValues: ReturnType +): string[] { const entries = value.startsWith('[') ? jsonStringArray(value) - : value.includes(',') && !value.includes('/') + : splitsOnCommas(value, listValues) ? value.split(',') : undefined if (!entries) return [value] @@ -371,16 +378,29 @@ function isManifestNoise(line: string): boolean { return trimmed === '' || trimmed.startsWith('#') } +/** + * A list flag's values as entries: argv and `@path` values ({@link readListValues}), each read + * under the flag's {@link FlagSpec.listValues}. The one parser every list goes through, a + * wrapper that reads a list before the request is built (`workflows runs get --select-output`) + * included. + */ +export async function readListFlag( + raw: unknown, + flag: FlagSpec, + flagName: string +): Promise { + const listValues = listValuesOf(flag) + return (await readListValues(raw, flagName, flag.manifest === true)).flatMap((value) => + listEntries(value, flagName, listValues) + ) +} + /** * Reads a primitive list from argv or a newline-delimited file. A `manifest` * list drops blank and `#` comment lines read from a file, so a requirements * file can be passed as it is on disk. */ -export async function readListValues( - raw: unknown, - flagName: string, - manifest = false -): Promise { +async function readListValues(raw: unknown, flagName: string, manifest = false): Promise { const arguments_ = Array.isArray(raw) ? raw : [raw] const values: string[] = [] for (const argument of arguments_) { @@ -532,12 +552,8 @@ export async function coerce( * or failed validation outright. */ if (flag.list) { - const listed = await readListValues(raw, flagName, flag.manifest === true) - const values = flag.folderPath - ? listed.map(encodeFolderPath) - : splitsListValues(flag) - ? listed.flatMap((value) => listEntries(value, flagName)) - : listed + const listed = await readListFlag(raw, flag, flagName) + const values = flag.folderPath ? listed.map(encodeFolderPath) : listed // Encoding first is also what keeps the comma-joined form unambiguous: a // folder name containing a comma leaves here as `%2C`, so the route's split // cannot cut one path in half.