@slatesvideo/cli 0.6.13 → 0.6.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @slatesvideo/cli
2
2
 
3
- The `slates` command for the [Slates](https://slates.video) AI video studio. Drive Slates from your terminal, or let Codex (with your ChatGPT account) or Claude Code shell out to it instead of loading <!-- gen:tool-count -->208<!-- /gen:tool-count --> tool schemas into context.
3
+ The `slates` command for the [Slates](https://slates.video) AI video studio. Drive Slates from your terminal, or let Codex (with your ChatGPT account) or Claude Code shell out to it instead of loading <!-- gen:tool-count -->237<!-- /gen:tool-count --> tool schemas into context.
4
4
 
5
5
  ## Install
6
6
 
@@ -19,7 +19,7 @@ Requires Node.js 18+ and the Slates desktop app ([slates.video](https://slates.v
19
19
  | `slates status` | Show connection state, account, and credit balance |
20
20
  | `slates mcp` | Detect Codex, Claude and Cursor; print the Codex/Claude Code setup commands or the JSON config; `--write` merges it into Claude Desktop / Cursor configs (with a `.bak` backup) |
21
21
  | `slates install-skills` | Install the same bundled skills for Claude Code and Codex; `--client claude` or `--client codex` selects one, and `--global` covers every project |
22
- | `slates run <op>` | Invoke any Slates operation by id; `--list` shows all <!-- gen:tool-count -->208<!-- /gen:tool-count -->, `<op> --help` shows one op's flags |
22
+ | `slates run <op>` | Invoke any Slates operation by id; `--list` shows all <!-- gen:tool-count -->237<!-- /gen:tool-count -->, `<op> --help` shows one op's flags |
23
23
  | `slates run <op> --input '<json>'` | Pass a NESTED object (Shot `params`/`refs`, batch updates) — flags cannot express those |
24
24
  | `slates use <project>` | Set the default project, by id or name, so ops stop needing `--projectId` |
25
25
  | `slates doctor` | Check every setup precondition and print the fix for each failure |
@@ -27,7 +27,7 @@ Requires Node.js 18+ and the Slates desktop app ([slates.video](https://slates.v
27
27
 
28
28
  ## Skills
29
29
 
30
- <!-- gen:skill-count -->53<!-- /gen:skill-count --> agent skills come with a Slates account (the card and the router ship in `@slatesvideo/shared`; `slates install-skills` writes the ones your account opens): <!-- gen:workflow-skill-count -->37<!-- /gen:workflow-skill-count --> workflow recipes (<!-- gen:workflow-skills -->start-here, ad-variants, blocking-to-prompt, camera-language, captions, character-identity, chatgpt-images, cinematic-advertisement, cinematic-look, content-policy, cost-discipline, cuts, dialogue-blocking, direct-response-ad, edit-and-iterate, launch-video, layer-brand-captions, layer-lower-third, layer-title, layered-effects, matte-transitions, model-selection, motion, object-wipes, one-prompt-film, previs-blocking, project-organization, restyle-from-blocking, script-craft, shot-variety, storyboard-from-script, style-prompting, transitions, ugc-advertisement, ugc-influencer-ad, vision-feedback-loop, whip-pans<!-- /gen:workflow-skills -->) and <!-- gen:per-model-skill-count -->16<!-- /gen:per-model-skill-count --> per-model prompting guides covering <!-- gen:video-roster -->kling-v3.0-std, kling-v3.0-pro, kling-v3.0-omni, Seedance 2.0, Seedance 2.5, Gemini Omni Flash 1.2, Wan 3.0, Kling 4.0, MiniMax H3, MiniMax H3 Max, MiniMax H3 Max Turbo, LTX-2.5, LTX-2.5 Pro<!-- /gen:video-roster -->, <!-- gen:image-roster -->Nano Banana 2.1, GPT Image 2.6 Flare, GPT Image 2.6 Sunburst, FLUX 3 Image, Seedream 5.5<!-- /gen:image-roster --> and <!-- gen:audio-roster -->Seed Audio 1.0, ElevenLabs Sound Effects v2, Inworld Realtime TTS-2<!-- /gen:audio-roster -->.
30
+ <!-- gen:skill-count -->52<!-- /gen:skill-count --> agent skills come with a Slates account (the card and the router ship in `@slatesvideo/shared`; `slates install-skills` writes the ones your account opens): <!-- gen:workflow-skill-count -->37<!-- /gen:workflow-skill-count --> workflow recipes (<!-- gen:workflow-skills -->start-here, ad-variants, blocking-to-prompt, camera-language, captions, character-identity, chatgpt-images, cinematic-advertisement, cinematic-look, content-policy, cost-discipline, cuts, dialogue-blocking, direct-response-ad, edit-and-iterate, launch-video, layer-brand-captions, layer-lower-third, layer-title, layered-effects, matte-transitions, model-selection, motion, object-wipes, one-prompt-film, previs-blocking, project-organization, restyle-from-blocking, script-craft, shot-variety, storyboard-from-script, style-prompting, transitions, ugc-advertisement, ugc-influencer-ad, vision-feedback-loop, whip-pans<!-- /gen:workflow-skills -->) and <!-- gen:per-model-skill-count -->15<!-- /gen:per-model-skill-count --> per-model prompting guides covering <!-- gen:video-roster -->kling-v3.0-std, kling-v3.0-pro, kling-v3.0-omni, Seedance 2.0, Seedance 2.5, Gemini Omni Flash 1.2, Wan 3.0, Kling 4.0, MiniMax H3, MiniMax H3 Max, MiniMax H3 Max Turbo<!-- /gen:video-roster -->, <!-- gen:image-roster -->Nano Banana 2.1, GPT Image 2.6 Flare, GPT Image 2.6 Sunburst, FLUX 3 Image, Seedream 5.5<!-- /gen:image-roster --> and <!-- gen:audio-roster -->Seed Audio 1.0, ElevenLabs Sound Effects v2, Inworld Realtime TTS-2<!-- /gen:audio-roster -->.
31
31
 
32
32
  `slates install-skills` writes each portable `SKILL.md` to `.claude/skills/<skill-name>/` for Claude Code and `.agents/skills/<skill-name>/` for Codex. Both receive identical content. Use `--global` for every project, or `--client claude` / `--client codex` to install for one client. Skills reload automatically; use `/reload-skills` in Claude Code if the root was just created, or restart Codex if its list has not refreshed. The installer preserves other files, including old flat Markdown copies.
33
33
 
@@ -1,5 +1,5 @@
1
1
  import { ALL_OPERATIONS } from '@slatesvideo/shared';
2
- // `slates completion bash|zsh|pwsh` — op ids are long, there are 91 of them,
2
+ // `slates completion bash|zsh|pwsh` — op ids are long, there are many of them,
3
3
  // and every one starts with the same eleven characters. Tab completion is the
4
4
  // difference between typing an id and remembering one.
5
5
  //
@@ -5,7 +5,7 @@ import { fileURLToPath } from 'node:url';
5
5
  import { readConnection, CONNECTION_FILE, SlatesCloudClient, SlatesDesktopClient, brainFiles, refreshLatestVersion, compareVersions, } from '@slatesvideo/shared';
6
6
  import { EXIT } from '../exit-codes.js';
7
7
  import { skillInstallTargets, inspectSkillInstallation } from './install-skills.js';
8
- import { CODEX_MCP_SETUP, inspectCodexMcpConfig } from './mcp-config.js';
8
+ import { CODEX_MCP_SETUP, inspectCodexMcpConfig, inspectJsonMcpConfigs } from './mcp-config.js';
9
9
  /** Every capability an op checks with `requireCapability`, and what needs it.
10
10
  * scripts/agent-surface-lockstep-check.mjs (check 11) fails when this list and
11
11
  * the ops' call sites disagree. A third entry marks a token whose ops fall back
@@ -20,6 +20,7 @@ const REQUIRED_CAPABILITIES = [
20
20
  ['image-models-v6', 'seedream-5-5', 'a call naming no model runs gpt-image-2-6-sunburst, the previous default, until Slates updates'],
21
21
  ['edit-image', 'image edits'],
22
22
  ['edit-video', 'video edits'],
23
+ ['lip-sync-quote', 'lip-sync on uploaded audio, and lip-sync or motion transfer on a clip with no recorded length'],
23
24
  ['video-models-v2', 'omni-flash-1-2 / omni-flash-1-2-edit', 'Gemini Omni Flash 1.1 runs in their place up to 10s, at the same price, until Slates updates'],
24
25
  ['audio-generation', 'the audio lane'],
25
26
  ['voices', 'the preset voice shelf'],
@@ -105,6 +106,24 @@ const REQUIRED_CAPABILITIES = [
105
106
  ['whip-pans', 'whip pans in your footage and joining shots on them'],
106
107
  ['transcript-cut', 'cut by transcript'],
107
108
  ['proxies', "a clip's proxy and Make proxies automatically at import"],
109
+ ['export-encoding', 'platform presets, codec, bitrate and frame rate on export'],
110
+ ['audio-suite', 'denoise, voice enhance, auto duck and loudness match'],
111
+ ['clip-grade', 'the grade, LUTs, auto colour, colour keys, shape masks and reverse'],
112
+ ['freeze-frame', 'freeze frame'],
113
+ ['dialogue-cleanup', 'dialogue clean-up'],
114
+ ['punch-in', 'punch in'],
115
+ ['subject-follow', 'reframing to follow a subject mask'],
116
+ ['slide-edit', 'slide edit'],
117
+ ['stabilize', 'stabilize'],
118
+ ['image-upscale', 'picture upscale'],
119
+ ['review-mode', 'Review mode packets and answers'],
120
+ ['view-review', 'turning Review mode on and off'],
121
+ ['meta-winners', 'ad results per recipe, winner marks, More like this and split tests'],
122
+ ['client-ads', 'connected ad accounts and export-linked performance'],
123
+ ['visual-qa', 'Visual QA rounds on a cut'],
124
+ ['v2v-edits', 'stacked video edits on a clip'],
125
+ ['diagnostics', 'the crash and error report status'],
126
+ ['winning-ads', 'searching winning ads and breaking one down'],
108
127
  ];
109
128
  export async function runDoctor() {
110
129
  const checks = [];
@@ -202,20 +221,7 @@ export async function runDoctor() {
202
221
  });
203
222
  }
204
223
  // 6. MCP client configs — present is enough; `slates mcp` owns the detail.
205
- const mcpConfigs = [
206
- join(homedir(), '.claude.json'),
207
- join(homedir(), 'AppData', 'Roaming', 'Claude', 'claude_desktop_config.json'),
208
- join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json'),
209
- join(homedir(), '.cursor', 'mcp.json'),
210
- ].filter((p) => existsSync(p));
211
- const wired = mcpConfigs.filter((p) => {
212
- try {
213
- return readFileSync(p, 'utf8').includes('slates');
214
- }
215
- catch {
216
- return false;
217
- }
218
- });
224
+ const { files: mcpConfigs, configured: wired } = inspectJsonMcpConfigs();
219
225
  const codex = inspectCodexMcpConfig();
220
226
  checks.push({
221
227
  name: 'MCP client config',
@@ -1,4 +1,17 @@
1
1
  export declare const CODEX_MCP_SETUP = "codex mcp add slates -- npx -y @slatesvideo/mcp-server";
2
+ export declare function claudeDesktopConfigPath(): string;
3
+ export declare function cursorConfigPath(): string;
4
+ /** Claude Code's file: user-scope servers at the top, local-scope ones under each project. */
5
+ export declare function claudeCodeConfigPath(): string;
6
+ /**
7
+ * The JSON client configs that exist, and the ones with a Slates server entry: `mcpServers` at the
8
+ * top level or under one of Claude Code's `projects`. The file is parsed, because `.claude.json`
9
+ * lists every folder the user has opened and a folder named "slates" is not a server.
10
+ */
11
+ export declare function inspectJsonMcpConfigs(candidates?: string[]): {
12
+ files: string[];
13
+ configured: string[];
14
+ };
2
15
  /** Read configuration only. A detected entry does not prove authentication or connectivity. */
3
16
  export declare function inspectCodexMcpConfig(environment?: {
4
17
  cwd: string;
@@ -1,8 +1,51 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { homedir } from 'node:os';
3
+ import { homedir, platform } from 'node:os';
4
4
  import TOML from '@iarna/toml';
5
5
  export const CODEX_MCP_SETUP = 'codex mcp add slates -- npx -y @slatesvideo/mcp-server';
6
+ const SERVER_PACKAGE = '@slatesvideo/mcp-server';
7
+ /** A server entry is ours by its name or by the package it launches, whatever the config format. */
8
+ function isSlatesServer(name, server) {
9
+ return name === 'slates' || (Array.isArray(server.args) && server.args.includes(SERVER_PACKAGE));
10
+ }
11
+ export function claudeDesktopConfigPath() {
12
+ const os = platform();
13
+ if (os === 'win32') {
14
+ const appData = process.env.APPDATA ?? join(homedir(), 'AppData', 'Roaming');
15
+ return join(appData, 'Claude', 'claude_desktop_config.json');
16
+ }
17
+ if (os === 'darwin') {
18
+ return join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
19
+ }
20
+ return join(homedir(), '.config', 'Claude', 'claude_desktop_config.json');
21
+ }
22
+ export function cursorConfigPath() {
23
+ return join(homedir(), '.cursor', 'mcp.json');
24
+ }
25
+ /** Claude Code's file: user-scope servers at the top, local-scope ones under each project. */
26
+ export function claudeCodeConfigPath() {
27
+ return join(homedir(), '.claude.json');
28
+ }
29
+ /**
30
+ * The JSON client configs that exist, and the ones with a Slates server entry: `mcpServers` at the
31
+ * top level or under one of Claude Code's `projects`. The file is parsed, because `.claude.json`
32
+ * lists every folder the user has opened and a folder named "slates" is not a server.
33
+ */
34
+ export function inspectJsonMcpConfigs(candidates = [claudeCodeConfigPath(), claudeDesktopConfigPath(), cursorConfigPath()]) {
35
+ const files = candidates.filter(file => existsSync(file));
36
+ const hasSlates = (servers) => !!servers && typeof servers === 'object' && !Array.isArray(servers) &&
37
+ Object.entries(servers).some(([name, server]) => !!server && typeof server === 'object' && isSlatesServer(name, server));
38
+ const configured = files.filter(file => {
39
+ try {
40
+ const config = JSON.parse(readFileSync(file, 'utf8'));
41
+ return hasSlates(config.mcpServers) || Object.values(config.projects ?? {}).some(project => hasSlates(project?.mcpServers));
42
+ }
43
+ catch {
44
+ return false;
45
+ }
46
+ });
47
+ return { files, configured };
48
+ }
6
49
  /** Read configuration only. A detected entry does not prove authentication or connectivity. */
7
50
  export function inspectCodexMcpConfig(environment = { cwd: process.cwd(), home: homedir(), codexHome: process.env.CODEX_HOME }) {
8
51
  const files = [...new Set([join(environment.codexHome || join(environment.home, '.codex'), 'config.toml'), join(environment.cwd, '.codex', 'config.toml')])].filter(file => existsSync(file));
@@ -24,7 +67,7 @@ export function inspectCodexMcpConfig(environment = { cwd: process.cwd(), home:
24
67
  invalid.push(file);
25
68
  }
26
69
  }
27
- const slates = Object.entries(servers).filter(([name, server]) => name === 'slates' || (Array.isArray(server.args) && server.args.includes('@slatesvideo/mcp-server')));
70
+ const slates = Object.entries(servers).filter(([name, server]) => isSlatesServer(name, server));
28
71
  const configured = slates.some(([, server]) => server.enabled !== false && (typeof server.command === 'string' || typeof server.url === 'string'));
29
72
  return { files, configured: configured && invalid.length === 0, disabled: slates.length > 0 && !configured, invalid };
30
73
  }
@@ -1,7 +1,7 @@
1
1
  import { join, delimiter } from 'node:path';
2
- import { homedir, platform } from 'node:os';
2
+ import { platform } from 'node:os';
3
3
  import { existsSync, readFileSync, writeFileSync, copyFileSync } from 'node:fs';
4
- import { CODEX_MCP_SETUP, inspectCodexMcpConfig } from './mcp-config.js';
4
+ import { CODEX_MCP_SETUP, claudeDesktopConfigPath, cursorConfigPath, inspectCodexMcpConfig } from './mcp-config.js';
5
5
  // `slates mcp` — zero-to-configured MCP in one command.
6
6
  //
7
7
  // Detects installed MCP clients (Codex, Claude Code, Claude Desktop, Cursor) and
@@ -14,20 +14,6 @@ const SLATES_ENTRY = {
14
14
  args: ['-y', '@slatesvideo/mcp-server'],
15
15
  };
16
16
  const MCP_JSON_SNIPPET = JSON.stringify({ mcpServers: { slates: SLATES_ENTRY } }, null, 2);
17
- function claudeDesktopConfigPath() {
18
- const os = platform();
19
- if (os === 'win32') {
20
- const appData = process.env.APPDATA ?? join(homedir(), 'AppData', 'Roaming');
21
- return join(appData, 'Claude', 'claude_desktop_config.json');
22
- }
23
- if (os === 'darwin') {
24
- return join(homedir(), 'Library', 'Application Support', 'Claude', 'claude_desktop_config.json');
25
- }
26
- return join(homedir(), '.config', 'Claude', 'claude_desktop_config.json');
27
- }
28
- function cursorConfigPath() {
29
- return join(homedir(), '.cursor', 'mcp.json');
30
- }
31
17
  function binaryOnPath(name) {
32
18
  const pathVar = process.env.PATH ?? '';
33
19
  const exts = platform() === 'win32' ? ['.cmd', '.exe', '.bat', ''] : [''];
@@ -9,11 +9,34 @@ interface RunOpOptions {
9
9
  * `slates run <op> --help`.
10
10
  *
11
11
  * The only way to learn an op's parameters used to be `slates run --list`,
12
- * which printed all 91 descriptions — 29 KB, including the generated capability
13
- * tables — and not one parameter NAME. An agent shelling out had to guess the
12
+ * which printed every description in full, the generated capability tables
13
+ * included, and not one parameter NAME. An agent shelling out had to guess the
14
14
  * flags or go and read a skill.
15
15
  */
16
16
  export declare function printOpHelp(op: Operation<unknown>): void;
17
17
  export declare function runOp(opts: RunOpOptions): Promise<void>;
18
+ /**
19
+ * The op's input from the command line: `--input` under the flags, then the two
20
+ * things only a shell needs. `--folderId null` is JSON null where the field
21
+ * allows it, and one `--ids a,b` is a list where the field is a list and
22
+ * nothing else. Then the default project, for an op that takes one.
23
+ *
24
+ * Numbers and booleans are not touched here: `prepareOperation` repairs them
25
+ * for every host the same way, and refuses `--sound on` by name.
26
+ */
27
+ export declare function buildOpInput(op: Operation<unknown>, rawArgs: string[], defaultProjectId: () => string | null): Record<string, unknown>;
28
+ /**
29
+ * The call the flags describe. The default project is a guess: where the op
30
+ * refuses the input with it (an export names a project OR a timeline), the
31
+ * flags are tried as written. When both are refused, the refusal naming fewer
32
+ * problems is the one shown (one line each), so the guess is never the complaint.
33
+ */
34
+ export declare function prepareOpCall(op: Operation<unknown>, rawArgs: string[], defaultProjectId: () => string | null): {
35
+ ok: false;
36
+ message: string;
37
+ } | {
38
+ ok: true;
39
+ call: import("@slatesvideo/shared").PreparedOperation<unknown>;
40
+ };
18
41
  export {};
19
42
  //# sourceMappingURL=op.d.ts.map
@@ -1,7 +1,6 @@
1
- import { z } from 'zod/v3';
2
1
  import { readFileSync, writeFileSync, mkdirSync } from 'node:fs';
3
2
  import { join, extname } from 'node:path';
4
- import { ALL_OPERATIONS, defaultContext, readDefaultProjectId, } from '@slatesvideo/shared';
3
+ import { ALL_OPERATIONS, defaultContext, prepareOperation, readDefaultProjectId, toolDefinition, } from '@slatesvideo/shared';
5
4
  import { EXIT, exitFor } from '../exit-codes.js';
6
5
  // Run-command flags that are CLI-side controls, not operation inputs.
7
6
  // They get filtered out of rawArgs so they don't fail strict schemas
@@ -13,9 +12,9 @@ const RUN_COMMAND_FLAGS = new Set(['--json', '--list', '--full', '--help', '-h']
13
12
  const RUN_COMMAND_VALUE_FLAGS = new Set(['--save-images', '--input', '--input-file']);
14
13
  /**
15
14
  * Parse `--key value` pairs into an object. Repeated `--key` becomes an
16
- * array. Booleans accept `--flag` (true) and `--flag=false`. Numbers
17
- * auto-coerce when the Zod schema expects one — done at parse time
18
- * against the operation input shape.
15
+ * array. A bare `--flag` is true; every other value stays the string the shell
16
+ * sent, and the shared parse repairs a number or a `true`/`false` the op's
17
+ * schema asks for.
19
18
  *
20
19
  * 🚨 FLAGS CANNOT EXPRESS A NESTED OBJECT, AND THAT IS WHY `--input` EXISTS.
21
20
  * Every op with an object-shaped param was UNCALLABLE from the CLI: all eight
@@ -119,138 +118,70 @@ function assign(obj, key, value) {
119
118
  }
120
119
  obj[key] = [existing, value];
121
120
  }
122
- const WRAPPERS = new Set([
123
- 'ZodOptional',
124
- 'ZodDefault',
125
- 'ZodNullable',
126
- 'ZodReadonly',
127
- 'ZodEffects',
128
- 'ZodCatch',
129
- 'ZodBranded',
130
- ]);
131
- function unwrap(t) {
132
- let cur = t;
133
- let depth = 0;
134
- while (cur?._def?.typeName && WRAPPERS.has(cur._def.typeName) && depth < 8) {
135
- cur = cur._def.innerType ?? cur._def.schema;
136
- depth++;
137
- }
138
- return cur;
139
- }
140
- function isOptional(t) {
141
- let cur = t;
142
- let depth = 0;
143
- while (cur?._def?.typeName && depth < 8) {
144
- if (cur._def.typeName === 'ZodOptional' || cur._def.typeName === 'ZodDefault')
145
- return true;
146
- if (!WRAPPERS.has(cur._def.typeName))
147
- return false;
148
- cur = cur._def.innerType ?? cur._def.schema;
149
- depth++;
150
- }
151
- return false;
152
- }
153
- function describeOf(t) {
154
- let cur = t;
155
- let depth = 0;
156
- while (cur?._def && depth < 8) {
157
- if (cur._def.description)
158
- return cur._def.description;
159
- cur = cur._def.innerType ?? cur._def.schema;
160
- depth++;
161
- if (!cur)
162
- break;
163
- }
164
- return '';
121
+ function opFields(op) {
122
+ const schema = toolDefinition(op).inputSchema;
123
+ return { properties: schema.properties ?? {}, required: new Set(schema.required ?? []) };
165
124
  }
166
- function objectShape(schema) {
167
- const z = schema;
168
- if (z?._def?.typeName !== 'ZodObject')
169
- return {};
170
- return typeof z._def.shape === 'function' ? z._def.shape() : (z.shape ?? {});
125
+ /** Every JSON type a field accepts, through `anyOf` and a `type` list. */
126
+ function typesOf(field) {
127
+ if (!field)
128
+ return [];
129
+ const own = Array.isArray(field.type) ? field.type : field.type ? [field.type] : [];
130
+ const literal = field.const !== undefined ? [field.const === null ? 'null' : typeof field.const] : [];
131
+ return [...own, ...literal, ...(field.anyOf ?? []).flatMap(typesOf)];
171
132
  }
172
133
  /** A human type name plus, for an enum, its legal values. */
173
- function typeLabel(t) {
174
- const leaf = unwrap(t);
175
- const name = leaf?._def?.typeName ?? '';
176
- switch (name) {
177
- case 'ZodString':
178
- return 'string';
179
- case 'ZodNumber':
180
- return 'number';
181
- case 'ZodBoolean':
182
- return 'boolean';
183
- case 'ZodEnum':
184
- return `enum(${(leaf?._def?.values ?? []).join('|')})`;
185
- case 'ZodNativeEnum':
186
- return 'enum';
187
- case 'ZodArray':
188
- return `${typeLabel(leaf?._def?.type)}[]`;
189
- case 'ZodObject':
190
- return 'object';
191
- case 'ZodUnion':
192
- return 'union';
193
- default:
194
- return name.replace(/^Zod/, '').toLowerCase() || 'value';
134
+ function typeLabel(field) {
135
+ if (field.enum)
136
+ return `enum(${field.enum.join('|')})`;
137
+ if (field.anyOf) {
138
+ const values = field.anyOf.filter((branch) => branch.type !== 'null');
139
+ if (values.length > 0 && values.every((branch) => branch.const !== undefined))
140
+ return `enum(${values.map((branch) => branch.const).join('|')})`;
141
+ if (values.length === 1)
142
+ return typeLabel(values[0]);
143
+ return 'union';
195
144
  }
196
- }
197
- /**
198
- * Zod's default error is a JSON blob of issue objects. Flatten to one readable
199
- * line per problem, with the legal set printed whenever an enum was what
200
- * failed — the same treatment the MCP server gives it, because both surfaces
201
- * are read by an agent that pays a turn for every unclear error.
202
- */
203
- function flattenZodError(err) {
204
- return err.issues
205
- .map((issue) => {
206
- const path = issue.path.length > 0 ? issue.path.join('.') : '(root)';
207
- if (issue.code === 'invalid_enum_value') {
208
- const legal = issue.options ?? [];
209
- return ` ${path}: ${issue.message}. Legal values: ${legal.join(', ')}`;
210
- }
211
- if (issue.code === 'unrecognized_keys') {
212
- const keys = issue.keys ?? [];
213
- return ` ${path}: unknown parameter(s) ${keys.join(', ')}`;
214
- }
215
- return ` ${path}: ${issue.message}`;
216
- })
217
- .join('\n');
145
+ const type = Array.isArray(field.type) ? field.type.find((t) => t !== 'null') : field.type;
146
+ if (type === 'array')
147
+ return `${field.items ? typeLabel(field.items) : 'value'}[]`;
148
+ if (type === 'integer')
149
+ return 'number';
150
+ return type ?? 'value';
218
151
  }
219
152
  function firstSentence(text) {
220
153
  const s = text.split(/(?<=[.!?])\s/)[0].trim();
221
154
  return s.length > 200 ? `${s.slice(0, 197)}…` : s;
222
155
  }
156
+ /** The fields flags cannot express: an object, or a list of them. */
157
+ function objectFieldsOf(properties) {
158
+ return Object.keys(properties).filter((key) => typesOf(properties[key]).includes('object'));
159
+ }
223
160
  /**
224
161
  * `slates run <op> --help`.
225
162
  *
226
163
  * The only way to learn an op's parameters used to be `slates run --list`,
227
- * which printed all 91 descriptions — 29 KB, including the generated capability
228
- * tables — and not one parameter NAME. An agent shelling out had to guess the
164
+ * which printed every description in full, the generated capability tables
165
+ * included, and not one parameter NAME. An agent shelling out had to guess the
229
166
  * flags or go and read a skill.
230
167
  */
231
168
  export function printOpHelp(op) {
232
169
  console.log(`${op.id}\n`);
233
170
  console.log(`${op.description}\n`);
234
- const shape = objectShape(op.input);
235
- const keys = Object.keys(shape);
171
+ const { properties, required } = opFields(op);
172
+ const keys = Object.keys(properties);
236
173
  if (keys.length === 0) {
237
174
  console.log('Takes no parameters.');
238
175
  return;
239
176
  }
240
177
  console.log('Parameters:');
241
- const objectFields = [];
242
178
  for (const key of keys) {
243
- const node = shape[key];
244
- const leaf = unwrap(node);
245
- const required = !isOptional(node);
246
- const label = typeLabel(node);
247
- if (leaf?._def?.typeName === 'ZodObject')
248
- objectFields.push(key);
249
- const desc = describeOf(node);
250
- console.log(` --${key}${' '.repeat(Math.max(1, 26 - key.length))}${label}${required ? ' (required)' : ''}`);
251
- if (desc)
252
- console.log(` ${firstSentence(desc)}`);
179
+ const field = properties[key];
180
+ console.log(` --${key}${' '.repeat(Math.max(1, 26 - key.length))}${typeLabel(field)}${required.has(key) ? ' (required)' : ''}`);
181
+ if (field.description)
182
+ console.log(` ${firstSentence(field.description)}`);
253
183
  }
184
+ const objectFields = objectFieldsOf(properties);
254
185
  if (objectFields.length > 0) {
255
186
  console.log(`\nNested object field(s): ${objectFields.join(', ')}. Flags cannot express these — ` +
256
187
  `pass them with --input '<json>' or --input-file <path>.`);
@@ -270,33 +201,19 @@ export async function runOp(opts) {
270
201
  printOpHelp(op);
271
202
  return;
272
203
  }
273
- const raw = { ...readInputObject(opts.rawArgs), ...parseArgs(opts.rawArgs) };
274
- const coerced = coerceForSchema(op.input, raw);
275
- // `slates use <project>` writes a default. Filled ONLY when the op declares a
276
- // projectId and the caller left it out — never overriding an explicit value.
277
- const shape = objectShape(op.input);
278
- if (coerced.projectId === undefined && 'projectId' in shape) {
279
- const fallback = readDefaultProjectId();
280
- if (fallback)
281
- coerced.projectId = fallback;
282
- }
283
- let parsed;
284
- try {
285
- parsed = op.input.parse(coerced);
286
- }
287
- catch (err) {
288
- // 🚨 ONE LINE PER PROBLEM, not Zod's issue JSON. The raw error is an array
289
- // of objects the caller has to read past to find the field name — and this
290
- // is the surface a Claude Code session shells out to, so an unreadable
291
- // error costs a turn every time. Same flattening the MCP server does.
292
- console.error(`Invalid arguments for ${op.id}:`);
293
- console.error(err instanceof z.ZodError ? flattenZodError(err) : String(err));
204
+ const { properties } = opFields(op);
205
+ const prepared = prepareOpCall(op, opts.rawArgs, readDefaultProjectId);
206
+ if (!prepared.ok) {
207
+ // One line per problem (the shared flattener), never Zod's issue JSON: an
208
+ // agent shelling out pays a turn for every unreadable error.
209
+ console.error(prepared.message);
294
210
  // An OBJECT field is the failure the flag parser structurally cannot fix,
295
211
  // so name the one thing that does fix it rather than leaving the caller to
296
212
  // guess why `--params.duration 8` did nothing.
297
- const objectFields = Object.keys(shape).filter((k) => unwrap(shape[k])?._def?.typeName === 'ZodObject');
213
+ const objectFields = objectFieldsOf(properties);
298
214
  if (objectFields.length > 0) {
299
- console.error(`\nNote: ${objectFields.join(', ')} ${objectFields.length === 1 ? 'is an OBJECT' : 'are OBJECTS'} — ` +
215
+ console.error(`
216
+ Note: ${objectFields.join(', ')} ${objectFields.length === 1 ? 'is an OBJECT' : 'are OBJECTS'} — ` +
300
217
  `flags cannot express nested values. Pass them with --input '<json>' or --input-file <path>. ` +
301
218
  `\`slates run ${op.id} --help\` lists every flag.`);
302
219
  }
@@ -304,7 +221,7 @@ export async function runOp(opts) {
304
221
  }
305
222
  let result;
306
223
  try {
307
- result = await op.run(parsed, defaultContext());
224
+ result = await prepared.call.run(defaultContext());
308
225
  }
309
226
  catch (err) {
310
227
  const message = err instanceof Error ? err.message : String(err);
@@ -362,71 +279,53 @@ function saveImages(images, dir) {
362
279
  console.log(path);
363
280
  });
364
281
  }
365
- function coerceForSchema(schema, raw) {
366
- // Best-effort coercion for the strings produced by parseArgs.
367
- // Zod's parse will reject unknown inputs anyway; this just improves
368
- // the experience for the common cases (numbers, booleans).
369
- // Values that arrived through --input are already typed, so they pass through.
370
- const shape = objectShape(schema);
371
- if (Object.keys(shape).length === 0)
372
- return raw;
373
- // Does the declared type allow null anywhere in its wrapper chain?
374
- // (e.g. z.string().uuid().nullable() — so `--folderId null` → null.)
375
- const isNullable = (t) => {
376
- let cur = t;
377
- let depth = 0;
378
- while (cur?._def?.typeName && depth < 8) {
379
- if (cur._def.typeName === 'ZodNullable')
380
- return true;
381
- if (WRAPPERS.has(cur._def.typeName)) {
382
- cur = cur._def.innerType ?? cur._def.schema;
383
- depth++;
384
- continue;
385
- }
386
- break;
387
- }
388
- return false;
389
- };
390
- const coerceScalar = (fieldType, value) => {
391
- if (fieldType === 'ZodNumber') {
392
- const n = Number(value);
393
- return Number.isFinite(n) ? n : value;
394
- }
395
- if (fieldType === 'ZodBoolean')
396
- return value === 'true' || value === '1';
397
- return value;
398
- };
399
- const out = {};
400
- for (const [key, value] of Object.entries(raw)) {
401
- const declared = shape[key];
402
- const leaf = unwrap(declared);
403
- const fieldType = (leaf?._def?.typeName ?? '');
404
- // `--folderId null` (or a bare `--folderId` → true is NOT null) → JS null
405
- // for fields that actually allow null. Enables "move to project root",
406
- // "clear character identity", etc. from the CLI.
407
- if (value === 'null' && isNullable(declared)) {
408
- out[key] = null;
409
- continue;
410
- }
411
- // Array fields: a single `--ids X` produced a bare string; repeated
412
- // `--ids X --ids Y` produced an array. Accept either, plus comma-split
413
- // (`--ids a,b,c`). Coerce each element to the array's element type.
414
- if (fieldType === 'ZodArray' && (typeof value !== 'object' || Array.isArray(value))) {
415
- const elemType = (unwrap(leaf?._def?.type)?._def?.typeName ?? '');
416
- const arr = Array.isArray(value)
417
- ? value
418
- : typeof value === 'string'
419
- ? value.split(',').map((s) => s.trim()).filter((s) => s.length > 0)
420
- : [value];
421
- out[key] = arr.map((v) => (typeof v === 'string' ? coerceScalar(elemType, v) : v));
422
- continue;
423
- }
424
- if (typeof value === 'string') {
425
- out[key] = coerceScalar(fieldType, value);
426
- continue;
282
+ /**
283
+ * The op's input from the command line: `--input` under the flags, then the two
284
+ * things only a shell needs. `--folderId null` is JSON null where the field
285
+ * allows it, and one `--ids a,b` is a list where the field is a list and
286
+ * nothing else. Then the default project, for an op that takes one.
287
+ *
288
+ * Numbers and booleans are not touched here: `prepareOperation` repairs them
289
+ * for every host the same way, and refuses `--sound on` by name.
290
+ */
291
+ export function buildOpInput(op, rawArgs, defaultProjectId) {
292
+ const { properties } = opFields(op);
293
+ const input = { ...readInputObject(rawArgs) };
294
+ for (const [key, value] of Object.entries(parseArgs(rawArgs))) {
295
+ const types = typesOf(properties[key]);
296
+ if (value === 'null' && types.includes('null'))
297
+ input[key] = null;
298
+ else if (types.includes('array') && !types.includes('string') && !Array.isArray(value)) {
299
+ input[key] = typeof value === 'string' ? value.split(',').map((part) => part.trim()).filter((part) => part.length > 0) : [value];
427
300
  }
428
- out[key] = value;
301
+ else
302
+ input[key] = value;
429
303
  }
430
- return out;
304
+ // `slates use <project>` writes a default. Filled ONLY when the op declares a
305
+ // projectId and the caller left it out — never overriding an explicit value.
306
+ if (input.projectId === undefined && Object.hasOwn(properties, 'projectId')) {
307
+ const fallback = defaultProjectId();
308
+ if (fallback)
309
+ input.projectId = fallback;
310
+ }
311
+ return input;
312
+ }
313
+ /**
314
+ * The call the flags describe. The default project is a guess: where the op
315
+ * refuses the input with it (an export names a project OR a timeline), the
316
+ * flags are tried as written. When both are refused, the refusal naming fewer
317
+ * problems is the one shown (one line each), so the guess is never the complaint.
318
+ */
319
+ export function prepareOpCall(op, rawArgs, defaultProjectId) {
320
+ const input = buildOpInput(op, rawArgs, defaultProjectId);
321
+ const prepared = prepareOperation(op, input);
322
+ if (prepared.ok)
323
+ return prepared;
324
+ const asWritten = buildOpInput(op, rawArgs, () => null);
325
+ if (asWritten.projectId === input.projectId)
326
+ return prepared;
327
+ const retried = prepareOperation(op, asWritten);
328
+ const problems = (message) => message.split(/\n/).length;
329
+ return retried.ok || problems(retried.message) < problems(prepared.message) ? retried : prepared;
431
330
  }
432
331
  //# sourceMappingURL=op.js.map
@@ -14,8 +14,10 @@ export declare const EXIT: {
14
14
  /** No cloud token, or it was revoked. Run `slates login`. */
15
15
  readonly NOT_SIGNED_IN: 6;
16
16
  };
17
- /** Map a thrown error to its exit code. Retrying a 5 or a 6 is pointless until
18
- * the user does something; retrying a 1 might work. That distinction is the
19
- * whole reason these exist. */
17
+ /**
18
+ * Map a thrown error to its exit code, by the error's type and never its wording.
19
+ * Retrying a 5 or a 6 is pointless until the user does something; retrying a 1
20
+ * might work. That distinction is the whole reason these exist.
21
+ */
20
22
  export declare function exitFor(err: unknown): number;
21
23
  //# sourceMappingURL=exit-codes.d.ts.map
@@ -10,6 +10,8 @@
10
10
  // 🚨 THESE NUMBERS ARE PUBLIC. Scripts and agent skills will branch on them.
11
11
  // Add codes; never renumber one.
12
12
  // ============================================================
13
+ import { isDesktopDown } from '@slatesvideo/shared';
14
+ import { SlatesCloudHttpError } from '@slatesvideo/shared/clients/cloud';
13
15
  export const EXIT = {
14
16
  /** The op ran and finished. */
15
17
  OK: 0,
@@ -26,19 +28,17 @@ export const EXIT = {
26
28
  /** No cloud token, or it was revoked. Run `slates login`. */
27
29
  NOT_SIGNED_IN: 6,
28
30
  };
29
- /** Map a thrown error to its exit code. Retrying a 5 or a 6 is pointless until
30
- * the user does something; retrying a 1 might work. That distinction is the
31
- * whole reason these exist. */
31
+ /**
32
+ * Map a thrown error to its exit code, by the error's type and never its wording.
33
+ * Retrying a 5 or a 6 is pointless until the user does something; retrying a 1
34
+ * might work. That distinction is the whole reason these exist.
35
+ */
32
36
  export function exitFor(err) {
33
- const code = err?.code;
34
- if (code === 'DESKTOP_SERVER_MISSING')
37
+ if (isDesktopDown(err))
35
38
  return EXIT.DESKTOP_UNREACHABLE;
36
- if (code === 'CLOUD_TOKEN_MISSING')
39
+ if (err?.code === 'CLOUD_TOKEN_MISSING')
37
40
  return EXIT.NOT_SIGNED_IN;
38
- const message = err instanceof Error ? err.message : String(err);
39
- if (/not reachable|AI tools|Agent Control|is not running/i.test(message))
40
- return EXIT.DESKTOP_UNREACHABLE;
41
- if (/rejected the auth token|slates login|401/i.test(message))
41
+ if (err instanceof SlatesCloudHttpError && err.status === 401)
42
42
  return EXIT.NOT_SIGNED_IN;
43
43
  return EXIT.ERROR;
44
44
  }
package/dist/index.js CHANGED
@@ -49,7 +49,10 @@ program
49
49
  // Version handshake: one bounded registry lookup an hour, cached in
50
50
  // ~/.slates/update-check.json, printed to STDERR so JSON on stdout stays
51
51
  // clean and an agent driving the CLI still sees it. Fail-silent offline.
52
- .hook('preAction', async () => {
52
+ .hook('preAction', async (_program, command) => {
53
+ // A completion script is sourced at every shell start and must not wait on the network.
54
+ if (command.name() === 'completion')
55
+ return;
53
56
  const notice = updateNotice(CLI_PKG_NAME, pkg.version, await refreshLatestVersion(CLI_PKG_NAME), 'Run `npm i -g @slatesvideo/cli@latest` (or invoke it as `npx @slatesvideo/cli@latest`), then `slates install-skills` if you use skill files.');
54
57
  if (notice)
55
58
  console.error(`slates: ${notice}`);
@@ -99,14 +102,14 @@ program
99
102
  .action((project, opts) => runUse(project, opts));
100
103
  program
101
104
  .command('completion')
102
- .description('Print a shell completion script for the 91 operation ids.')
105
+ .description('Print a shell completion script for every operation id.')
103
106
  .argument('[shell]', 'bash | zsh | pwsh')
104
107
  .action((shell) => runCompletion(shell));
105
108
  program
106
109
  .command('run')
107
110
  .description('Invoke a Slates operation by id. `slates run --list` lists them; `slates run <op> --help` prints that op\'s flags.')
108
111
  .option('--list', 'List operation ids with a one-line summary', false)
109
- .option('--full', 'With --list: print each op\'s complete description (large — 29 KB)', false)
112
+ .option('--full', 'With --list: print each op\'s complete description (large)', false)
110
113
  .option('--json', 'Emit structured JSON ({text, data, images: [{mimeType, bytes}]}). Image binary is omitted — use --save-images to write the files.', false)
111
114
  .option('--save-images <dir>', 'Write returned images into <dir> and print the paths')
112
115
  .option('--input <json>', 'JSON object of inputs — the only way to pass a NESTED object (Shot params/refs, batch updates). Merged under explicit flags.')
@@ -134,7 +137,7 @@ program
134
137
  };
135
138
  const ops = ALL_OPERATIONS;
136
139
  if (listFlag || !opId) {
137
- // 🚨 IDS AND ONE SENTENCE, NOT 29 KB. `--list` printed every description
140
+ // 🚨 IDS AND ONE SENTENCE. `--list` printed every description
138
141
  // in full — including the generated capability tables — and not one
139
142
  // parameter name, so the one command that was supposed to teach the
140
143
  // surface was unreadable and taught nothing. `--full` keeps the old
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slatesvideo/cli",
3
- "version": "0.6.13",
3
+ "version": "0.6.15",
4
4
  "description": "Slates CLI: drive the Slates AI video studio from your terminal or let Codex (with your ChatGPT account) or Claude Code shell out to it. Includes the bundled agent skills and an MCP client configurator.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@iarna/toml": "^2.2.5",
50
- "@slatesvideo/shared": "^0.7.19",
50
+ "@slatesvideo/shared": "^0.7.22",
51
51
  "commander": "^12.1.0",
52
52
  "zod": "^4.6.7"
53
53
  },