From 56a7966e92ffb912724df28b2de909fb08fb70f1 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 30 Nov 2026 23:41:19 -0800 Subject: [PATCH] docs(workflow-code): document --run trigger selection, multi-block find, and the root AGENTS.md pointer edit.mdx and coding-agents.mdx now cover naming a trigger in --run and repeating it, and find taking several block names. directory.mdx, ci.mdx and coding-agents.mdx list the root AGENTS.md pointer get writes. The advanced guide's find line and the layout TSDoc match the CLI. --- apps/docs/content/docs/workflows/code/ci.mdx | 2 +- apps/docs/content/docs/workflows/code/coding-agents.mdx | 5 +++-- apps/docs/content/docs/workflows/code/directory.mdx | 2 ++ apps/docs/content/docs/workflows/code/edit.mdx | 2 +- packages/sim-cli/src/commands/protocol/source-dir/layout.ts | 2 +- packages/sim-cli/src/commands/protocol/workflow-dir.ts | 2 +- 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/apps/docs/content/docs/workflows/code/ci.mdx b/apps/docs/content/docs/workflows/code/ci.mdx index d4f3c5ac9a2..2035744955c 100644 --- a/apps/docs/content/docs/workflows/code/ci.mdx +++ b/apps/docs/content/docs/workflows/code/ci.mdx @@ -11,7 +11,7 @@ Saving and dry-running source act as a person. Use a personal API key (**Setting ## What to commit -- **A workflow directory:** commit `workflow.ts`, `functions/`, `.sim/lock.json`, `.sim/base.json`, `.sim/written.json`, `.sim/stored-edges.json`, `tsconfig.json` and `.gitattributes`. CI finds the workflow from `workflowId` in `.sim/base.json`, and `status` and `get` use `.sim/written.json` to tell your edits apart from what the CLI last wrote. Gitignore `tsconfig.full.json`; `.sim/sdk/` is optional. +- **A workflow directory:** commit `workflow.ts`, `functions/`, `.sim/lock.json`, `.sim/base.json`, `.sim/written.json`, `.sim/stored-edges.json`, `tsconfig.json` and `.gitattributes`. CI finds the workflow from `workflowId` in `.sim/base.json`, and `status` and `get` use `.sim/written.json` to tell your edits apart from what the CLI last wrote. Gitignore `tsconfig.full.json`; `.sim/sdk/` and the root `AGENTS.md` pointer are optional. - **A workspace directory:** commit everything, including `.sim/`. Its generated `.gitignore` leaves out only temporary files. [Directory layout](/workflows/code/directory) lists every file. diff --git a/apps/docs/content/docs/workflows/code/coding-agents.mdx b/apps/docs/content/docs/workflows/code/coding-agents.mdx index b66da76a980..b6bbebfc57b 100644 --- a/apps/docs/content/docs/workflows/code/coding-agents.mdx +++ b/apps/docs/content/docs/workflows/code/coding-agents.mdx @@ -8,6 +8,7 @@ Claude Code, Cursor, Codex and other coding agents work from a directory that `g ## What get gives an agent - A **primer**, which opens `.sim/AGENTS.md`. `get` prints a short summary instead (the files written, the guide, and the `editLoop` command to run). It covers the edit loop, how block identity, references and renames work, failures and retries, test runs, deletes, deploy, exit codes, and the params of each builder the workflow already uses. +- **`AGENTS.md`** at the directory root: a short pointer to `.sim/AGENTS.md` with the edit loop and exit codes, which agents that load the nearest `AGENTS.md` find first. `get` writes it again unless you delete its first line, which makes the file yours. - **`.sim/AGENTS.md`**: the primer followed by a reference, by task. **`.sim/GUIDE-advanced.md`** beside it has the rest, by task, in a workflow directory and a workspace directory alike. - **`.sim/examples/`**: one correct example of each common block to copy from. - **`.sim/sdk/`**: the type declarations, with `.sim/sdk/INDEX.md` listing the builders. @@ -26,7 +27,7 @@ Point the agent at `.sim/AGENTS.md` before it edits. A non-zero exit code stops the chain at the first failure. `apply` compiles the source and compares it with the saved draft again, so an agent can skip `--dry`. `check` also type-checks the directory, so the chain needs no separate `tsc`. People and CI use `apply --dry` to review the plan, and `status` shows what changed and what to run next. - `--run` dry-runs the saved draft with that input, and `--deploy` deploys only if the run completed; a run that fails exits 1, deploys nothing, and maps the failing block to its file and line. Drop `--deploy` to keep the change a draft. The result opens with a one-line `summary` and ends with `errors`, `warnings`, `live` and `next`, so a `| head` or `| tail` of it still shows the outcome. + `--run` dry-runs the saved draft with that input, and `--deploy` deploys only if the run completed; a run that fails exits 1, deploys nothing, and maps the failing block to its file and line. With several triggers (an API and a webhook), name the entry by its const, as in `--run 'shopWebhook={...}'`, and repeat `--run` to test each path: `--deploy` needs every run to complete. Drop `--deploy` to keep the change a draft. The result opens with a one-line `summary` and ends with `errors`, `warnings`, `live` and `next`, so a `| head` or `| tail` of it still shows the outcome. The dry run (also `sim workflows run --dry`) tests the saved draft without sending its writes: each write returns a placeholder and is listed under `sideEffects` with the request it would have sent, so the agent checks payloads instead of cleaning up rows or messages. `--allow ` sends one block's writes for real against a test resource, and `--draft` runs everything for real. @@ -34,7 +35,7 @@ For a whole workspace, use `sim workspaces source` with the same steps: its chai ## Look things up -- `sim workflows source find ` prints one block of the workflow by name, key or identifier, from the directory without a request: its declaration with line numbers, its function file, its incoming and outgoing wiring and every block that reads its outputs, each as `file:line`. A part of a name prints every block it matches. +- `sim workflows source find ` prints each named block of the workflow by name, key or identifier, from the directory without a request: its declaration with line numbers, its function file, its incoming and outgoing wiring and every block that reads its outputs, each as `file:line`. A part of a name prints every block it matches. Name every block a change touches in one call; a name that matches no block exits `1` after the others print. - `sim workflows source params ` prints a builder in brief (an example call, the required params with types, the optional ones by name and the outputs) from the cached block catalog without a request. `--full` prints every param with its type, options, default and doc. A legacy builder names the one that replaces it, and a namespace such as `gmail` lists its builders. - `sim workflows source resources` lists the tables, knowledge bases, credentials, workflows, skills, custom tools, MCP servers and environment variable names the file can name. - `sim workflows source catalog` shows the block catalog the source is checked against. diff --git a/apps/docs/content/docs/workflows/code/directory.mdx b/apps/docs/content/docs/workflows/code/directory.mdx index 3bd416acb86..b55385c2bec 100644 --- a/apps/docs/content/docs/workflows/code/directory.mdx +++ b/apps/docs/content/docs/workflows/code/directory.mdx @@ -18,6 +18,7 @@ description: Every file a workflow directory and a workspace directory holds, wh | `.sim/written.json` | A digest of each file as the CLI last wrote it, so `status` and `get` tell your edits from the CLI's | Commit | | `.sim/stored-edges.json` | The connections the stored workflow held when it was printed, so an offline `check` tells them from connections you added. The CLI's own record, never sent | Commit | | `.sim/starter.json` | The workspace a starter was written for, before `create` | Not kept: removed once the workflow exists | +| `AGENTS.md` | A pointer for coding agents to `.sim/AGENTS.md`, with the edit loop and exit codes | Optional, written again by `get` unless you delete its first line | | `.sim/AGENTS.md` | The guide for coding agents: the primer, then a reference | Optional, written again by `get` | | `.sim/GUIDE-advanced.md` | The rest of the guide, by task: the edit loop step by step and what a dry run stubs, a new workflow or a fork, finding a builder and its types, the rules, and every diagnostic and exit code | Optional, written again by `get` | | `.sim/examples/` | Example workflows to copy from | Optional, written again by `get` | @@ -76,6 +77,7 @@ Beside the resources: | `.sim/written.json` | A digest of each file as the CLI last wrote it, so `status` and `get` tell your edits from the CLI's | Commit | | `.sim/targets/.json` | What each [promotion](/workflows/code/promote) left in that workspace | Commit | | `.sim/skipped.json` | Documents and files a get left out, with the reason | Optional | +| `AGENTS.md` | A pointer for coding agents to `.sim/AGENTS.md`, as for a workflow directory | Optional, written again by `get` unless you delete its first line | | `.sim/AGENTS.md`, `.sim/GUIDE-advanced.md`, `.sim/examples/`, `.sim/sdk/` | The agent guide with deletes, Git and CI, and promotion in depth; examples of every kind; type declarations including `.sim/sdk/workspace.d.ts` | Optional, written again by `get` | | `.sim/cache/` | This machine's file stats. It ignores itself | Not committed | | `tsconfig.json`, `tsconfig.full.json`, `.gitattributes`, `.gitignore` | As for a workflow directory. `.gitattributes` also keeps workspace files and knowledge base documents byte for byte | Commit all but `tsconfig.full.json` | diff --git a/apps/docs/content/docs/workflows/code/edit.mdx b/apps/docs/content/docs/workflows/code/edit.mdx index 75c4f0136a8..76b962fa00b 100644 --- a/apps/docs/content/docs/workflows/code/edit.mdx +++ b/apps/docs/content/docs/workflows/code/edit.mdx @@ -76,7 +76,7 @@ Editing the name or description in `workflow('…')` renames or redescribes the ### Deploy -Saving writes the draft. Add `--deploy` to deploy right after the save, which also prints the URL of each webhook the workflow now serves. Add `--run ''` to dry-run the saved draft with that input first: with `--deploy`, it deploys only if the run completed. Without `--deploy`, a deployed workflow whose draft now differs prints the `sim workflows deploy` command to run, pinned to the draft this apply saved; after an apply without `--run`, it also names the apply that tests and deploys in one step. +Saving writes the draft. Add `--deploy` to deploy right after the save, which also prints the URL of each webhook the workflow now serves. Add `--run ''` to dry-run the saved draft with that input first: with `--deploy`, it deploys only if the run completed. A workflow with several triggers (an API and a webhook) needs the entry named by its const, as in `--run 'shopWebhook={…}'`. Repeat `--run` to test each input or trigger: every run is made and reported, and `--deploy` needs all of them to complete. Without `--deploy`, a deployed workflow whose draft now differs prints the `sim workflows deploy` command to run, pinned to the draft this apply saved; after an apply without `--run`, it also names the apply that tests and deploys in one step. ### Deletes diff --git a/packages/sim-cli/src/commands/protocol/source-dir/layout.ts b/packages/sim-cli/src/commands/protocol/source-dir/layout.ts index e9d1e637466..302d02c87ba 100644 --- a/packages/sim-cli/src/commands/protocol/source-dir/layout.ts +++ b/packages/sim-cli/src/commands/protocol/source-dir/layout.ts @@ -15,7 +15,7 @@ import { SourceDirError } from '../local-errors' /** Generated SDK declarations: the blocks the source uses (every block's are cached), plus `workspace.d.ts`. */ export const SOURCE_SDK_DIR = '.sim/sdk' -/** A short guide for an agent working in the directory; never a top-level `AGENTS.md`. */ +/** The guide for an agent working in the directory, which the root `AGENTS.md` pointer names. */ export const SOURCE_AGENTS_FILE = '.sim/AGENTS.md' /** * Example workflows (`cookbook.ts`, `integrations.ts`, `agents.ts`): together one correct example diff --git a/packages/sim-cli/src/commands/protocol/workflow-dir.ts b/packages/sim-cli/src/commands/protocol/workflow-dir.ts index 17fdf65918b..87753476cb3 100644 --- a/packages/sim-cli/src/commands/protocol/workflow-dir.ts +++ b/packages/sim-cli/src/commands/protocol/workflow-dir.ts @@ -299,7 +299,7 @@ Editing the \`workflow('…')\` name or description renames or redescribes the w ## Finding a builder and its types -- \`sim workflows source find \`: one block of this workflow by name, key or identifier, from the directory alone: its declaration with line numbers, its function file, its incoming and outgoing wiring and every block that reads its outputs, each as file:line. A part of a name prints every block it matches (\`find 'Fetch Policy'\`). Use it instead of searching a long \`${SOURCE_ENTRY_FILE}\`. +- \`sim workflows source find \`: each named block of this workflow by name, key or identifier, from the directory alone: its declaration with line numbers, its function file, its incoming and outgoing wiring and every block that reads its outputs, each as file:line. A part of a name prints every block it matches; name every block a change touches in one call (\`find 'Fetch Policy' 'Refunds Score'\`). Use it instead of searching a long \`${SOURCE_ENTRY_FILE}\`. - \`sim workflows source params \`: one builder's params (required first, enums, defaults) and outputs; a namespace (\`gmail\`) lists its builders; a miss names the closest. Builders are named for the service, not the block type: \`gmail_v2\` is \`gmail.*\`, \`workflow_input\` is \`runWorkflow\`, the HTTP request block is \`api\`, and \`legacy.*\` builders are old versions not to write. - \`${SDK_DIR}/core.d.ts\`: the SDK (\`workflow\`, \`t\`, \`env\`, \`credential\`, \`table\`, \`loop\`, \`parallel\`, \`BlockMeta\`). - \`${SDK_DIR}/blocks/.d.ts\`: the builders of a block the source uses, with their params and outputs (check adds the file of a block an edit starts using). Do not read them, or \`${SDK_DIR}/models.d.ts\`, whole: \`params\` prints the part you need, and \`grep\` finds a model id.