Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/docs/content/docs/cli/reference.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -10125,7 +10125,7 @@ sim workspaces source apply [options]
| `--delete-target-only` | No | With --to and --allow-delete, also delete the target's resources this directory never declared and no promotion from it left there (prod-only tables and their rows, skills made in prod). Without it a promotion keeps them, naming each with a warning. |
| `--only <kinds>` | No | Apply only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
| `--to <workspaceId>` | No | Promote the directory to another workspace (dev to prod): its resources bind by key to that workspace's own and are updated in place. Only .sim/targets/&lt;workspaceId&gt;.json changes, the record the next promotion compares with: a resource changed there since is kept, or refused as stale (exit 5) when the directory changed it too. |
| `--run <key=input>` | No | After the apply, dry-run workflows/&lt;key&gt;/'s saved draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it; `--run <key>` alone: no input). Repeat it to test more workflows. deployments/ is applied only after every run completed; a run that does not complete exits 1 and leaves the applied drafts in place. |
| `--run <key=input>` | No | After the apply, dry-run workflows/&lt;key&gt;/'s saved draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it; `--run <key>` alone: no input). Repeat it to test more workflows. deployments/ is applied only after every run completed, and only when every draft it publishes was test-run; a run that does not complete exits 1 and leaves the applied drafts in place. |

</CommandTable>

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/docs/cli/workspaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,7 @@ sim workspaces source apply [options]
| `--delete-target-only` | No | With --to and --allow-delete, also delete the target's resources this directory never declared and no promotion from it left there (prod-only tables and their rows, skills made in prod). Without it a promotion keeps them, naming each with a warning. |
| `--only <kinds>` | No | Apply only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
| `--to <workspaceId>` | No | Promote the directory to another workspace (dev to prod): its resources bind by key to that workspace's own and are updated in place. Only .sim/targets/&lt;workspaceId&gt;.json changes, the record the next promotion compares with: a resource changed there since is kept, or refused as stale (exit 5) when the directory changed it too. |
| `--run <key=input>` | No | After the apply, dry-run workflows/&lt;key&gt;/'s saved draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it; `--run <key>` alone: no input). Repeat it to test more workflows. deployments/ is applied only after every run completed; a run that does not complete exits 1 and leaves the applied drafts in place. |
| `--run <key=input>` | No | After the apply, dry-run workflows/&lt;key&gt;/'s saved draft with this input (JSON or @file, as `sim workflows run --dry --input` takes it; `--run <key>` alone: no input). Repeat it to test more workflows. deployments/ is applied only after every run completed, and only when every draft it publishes was test-run; a run that does not complete exits 1 and leaves the applied drafts in place. |

</CommandTable>

Expand Down
10 changes: 6 additions & 4 deletions packages/sim-cli/src/commands/protocol/source-exit-codes.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest'
import * as exitCodes from '../../exit-codes'
import { sourceExitCodesHelp, sourceExitCodesTable } from './source-exit-codes'
import type { PrimerSurface } from './source-primer'
import { WORKFLOW_TREE } from './workflow-dir'
import { WORKSPACE_TREE } from './workspace-source-dir'

Expand All @@ -17,13 +18,14 @@ const SOURCE_EXIT_CODES = [
].sort((a, b) => a - b)

/** Everything a get writes beside the primer for an agent to read: `.sim/AGENTS.md` and the guides. */
const guidesOf = (tree: typeof WORKFLOW_TREE) =>
[tree.agents, ...(tree.guides ?? []).map(([, text]) => text)].join('\n')
const guidesOf = (tree: typeof WORKFLOW_TREE, surface: PrimerSurface) =>
[tree.agents(surface), ...(tree.guides?.(surface) ?? []).map(([, text]) => text)].join('\n')

describe('the exit-code tables an agent or a reader relies on', () => {
it.each([
['the workflow directory guides', guidesOf(WORKFLOW_TREE)],
['the workspace directory guides', guidesOf(WORKSPACE_TREE)],
['the workflow directory guides', guidesOf(WORKFLOW_TREE, 'cli')],
["the workflow directory guides Mothership's chat reads", guidesOf(WORKFLOW_TREE, 'chat')],
['the workspace directory guides', guidesOf(WORKSPACE_TREE, 'cli')],
])('%s list every code a source command exits with', (_name, text) => {
const listed = [...text.matchAll(/^\| (\d+) \|/gm)].map((match) => Number(match[1]))
expect(listed).toEqual(SOURCE_EXIT_CODES)
Expand Down
14 changes: 9 additions & 5 deletions packages/sim-cli/src/commands/protocol/source-tree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ import {
AGENTS_POINTER_MARKER,
agentsPointer,
type PrimerKind,
type PrimerSurface,
primerFor,
primerSurface,
} from './source-primer'
Expand Down Expand Up @@ -633,10 +634,13 @@ export function editLoop(kind: PrimerKind, dir: string): string[] {
export interface SourceTreeProfile {
/** Which primer opens `.sim/AGENTS.md`. */
kind: PrimerKind
/** The reference in `.sim/AGENTS.md`, below the primer. */
agents: string
/**
* The reference in `.sim/AGENTS.md`, below the primer, for the surface that reads it: a guide
* Mothership's chat reads never names a flag its shell refuses.
*/
agents: (surface: PrimerSurface) => string
/** More guides beside `.sim/AGENTS.md` (path → text), rewritten every time like it. */
guides?: ReadonlyArray<readonly [string, string]>
guides?: (surface: PrimerSurface) => ReadonlyArray<readonly [string, string]>
/**
* A `tsconfig.json` the CLI writes, starting with {@link TSCONFIG_MARKER}, that type-checks the
* source with the SDK declarations `sdkFiles` (directory-relative paths).
Expand Down Expand Up @@ -839,8 +843,8 @@ export async function sourceTreeChange(
const surface = primerSurface()
const primer = primerFor(profile.kind, surface, catalog, sources)
const write: Array<readonly [string, string]> = [
[SOURCE_AGENTS_FILE, `${primer}\n${profile.agents}`],
...(profile.guides ?? []),
[SOURCE_AGENTS_FILE, `${primer}\n${profile.agents(surface)}`],
...(profile.guides?.(surface) ?? []),
...Object.entries(COOKBOOK_EXAMPLES).map(
([file, text]) => [`${SOURCE_EXAMPLES_DIR}/${file}`, text] as const
),
Expand Down
Loading
Loading