Skip to content

Commit 964c01b

Browse files
committed
fix(sim-cli): release audit follow-ups for the source loop
- Mothership's chat gets workflow guides without apply --run/--deploy, and no tested-deploy hint - workspaces source apply --run holds deployments/ back when it would publish an untested draft - apply --run checks its input is JSON before anything is saved - source get by name refuses a blank name and searches at most 200 characters - list flags refuse an unparsable [..] value and an empty array, and keep a /files/ path whole - the merged --run apply reports the failing write's applyId
1 parent 7ef574c commit 964c01b

15 files changed

Lines changed: 232 additions & 42 deletions

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10125,7 +10125,7 @@ sim workspaces source apply [options]
1012510125
| `--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. |
1012610126
| `--only <kinds>` | No | Apply only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
1012710127
| `--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. |
10128-
| `--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. |
10128+
| `--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. |
1012910129

1013010130
</CommandTable>
1013110131

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -759,7 +759,7 @@ sim workspaces source apply [options]
759759
| `--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. |
760760
| `--only <kinds>` | No | Apply only these kinds (comma-separated folders: secrets.ts, credentials.ts, tools, skills, mcp, tables, knowledge, files, workflows, deployments). |
761761
| `--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. |
762-
| `--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. |
762+
| `--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. |
763763

764764
</CommandTable>
765765

‎packages/sim-cli/src/commands/protocol/source-exit-codes.test.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { describe, expect, it } from 'vitest'
22
import * as exitCodes from '../../exit-codes'
33
import { sourceExitCodesHelp, sourceExitCodesTable } from './source-exit-codes'
4+
import type { PrimerSurface } from './source-primer'
45
import { WORKFLOW_TREE } from './workflow-dir'
56
import { WORKSPACE_TREE } from './workspace-source-dir'
67

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

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

2324
describe('the exit-code tables an agent or a reader relies on', () => {
2425
it.each([
25-
['the workflow directory guides', guidesOf(WORKFLOW_TREE)],
26-
['the workspace directory guides', guidesOf(WORKSPACE_TREE)],
26+
['the workflow directory guides', guidesOf(WORKFLOW_TREE, 'cli')],
27+
["the workflow directory guides Mothership's chat reads", guidesOf(WORKFLOW_TREE, 'chat')],
28+
['the workspace directory guides', guidesOf(WORKSPACE_TREE, 'cli')],
2729
])('%s list every code a source command exits with', (_name, text) => {
2830
const listed = [...text.matchAll(/^\| (\d+) \|/gm)].map((match) => Number(match[1]))
2931
expect(listed).toEqual(SOURCE_EXIT_CODES)

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

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ import {
5757
AGENTS_POINTER_MARKER,
5858
agentsPointer,
5959
type PrimerKind,
60+
type PrimerSurface,
6061
primerFor,
6162
primerSurface,
6263
} from './source-primer'
@@ -633,10 +634,13 @@ export function editLoop(kind: PrimerKind, dir: string): string[] {
633634
export interface SourceTreeProfile {
634635
/** Which primer opens `.sim/AGENTS.md`. */
635636
kind: PrimerKind
636-
/** The reference in `.sim/AGENTS.md`, below the primer. */
637-
agents: string
637+
/**
638+
* The reference in `.sim/AGENTS.md`, below the primer, for the surface that reads it: a guide
639+
* Mothership's chat reads never names a flag its shell refuses.
640+
*/
641+
agents: (surface: PrimerSurface) => string
638642
/** More guides beside `.sim/AGENTS.md` (path → text), rewritten every time like it. */
639-
guides?: ReadonlyArray<readonly [string, string]>
643+
guides?: (surface: PrimerSurface) => ReadonlyArray<readonly [string, string]>
640644
/**
641645
* A `tsconfig.json` the CLI writes, starting with {@link TSCONFIG_MARKER}, that type-checks the
642646
* source with the SDK declarations `sdkFiles` (directory-relative paths).
@@ -839,8 +843,8 @@ export async function sourceTreeChange(
839843
const surface = primerSurface()
840844
const primer = primerFor(profile.kind, surface, catalog, sources)
841845
const write: Array<readonly [string, string]> = [
842-
[SOURCE_AGENTS_FILE, `${primer}\n${profile.agents}`],
843-
...(profile.guides ?? []),
846+
[SOURCE_AGENTS_FILE, `${primer}\n${profile.agents(surface)}`],
847+
...(profile.guides?.(surface) ?? []),
844848
...Object.entries(COOKBOOK_EXAMPLES).map(
845849
([file, text]) => [`${SOURCE_EXAMPLES_DIR}/${file}`, text] as const
846850
),

0 commit comments

Comments
 (0)