@impractical-ai/motion 0.1.13 → 0.1.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,16 +1,16 @@
1
1
  # Impractical Motion CLI
2
2
 
3
- <!-- ARRIVAL-DRIFT-STANDARD START -->
4
- ## Default motion: arrival and residual drift
3
+ <!-- MOTION-STANDARD START -->
4
+ ## Default motion: arrival, hold and exit
5
5
 
6
- Foreground motion defaults to an energetic arrival, strong deceleration, and small continuing travel through the reading hold. Compose a deterministic residual trajectory with the native entrance; do not stop and restart with a disconnected tween. “Settled” and “hold” mean readable and visually stable, with subtle nonzero travel unless an explicit freeze, exact alignment or reduced-motion mode requires stillness.
6
+ Each foreground element follows one continuous trajectory: it arrives with energy, decelerates strongly to near-zero speed for the reading hold, then accelerates into its exit or its next authored move. Shape this with the entrance and exit eases themselves; there is no separate drift layer, no constant velocity floor and no perpetual creep. Finish the visible travel quickly: during the hold the ease tail moves the subject less than about 0.5 output px in total, so “settled” and “hold” mean visually still and readable. Exits ease in (or in-out) from that near-zero state, so nothing starts from a dead stop. This applies to whole entities, not to every element inside them: a card, product window, headline block or logo lockup arrives, holds and exits as one unit, and its children (labels, icons, rows, words, buttons) ride with it. Don't recurse and give each child its own arrival, deceleration and exit; that reads as fidgeting and splits attention. Children may still have their own discrete actions inside the hold (text typing in, a toggle flipping, a row highlighting, a number counting), but not their own arrive/hold/exit motion.
7
7
 
8
- Use the Rox `ambientOffset(seconds, amount, phase)` pattern: native 960×540 product groups start around amount 3.2–4, text around 0.8–1. Keep a signed velocity floor with gentle curvature, not a pure sine bob. Move attached labels, controls, connectors and shadows together, avoid double drift, preserve 3D hierarchy, and verify reverse/retimed seeks and late-hold displacement.
8
+ Why no creep: exports render in headless Linux Chromium, which snaps slowly moving text and elements to whole pixels, so a slow drift of about 1 px/s shows up as a visible 1 px tick every ~0.9 s. Move attached labels, controls, connectors and shadows together with their subject, preserve 3D hierarchy, and verify reverse/retimed seeks.
9
9
 
10
- The host owns the background environment. Animate foreground objects only; never move or retime the background to simulate object motion. Reusable foregrounds should be transparent. Keep one primary focus and room around it; purposeful object camera moves remain welcome, and a generic card is not the default visual container.
10
+ The host owns the background environment. Animate foreground objects only; never move or retime the background to simulate object motion. Reusable foregrounds should be transparent. Make things breathe: only one focus at a time, with generous negative space and comfortable margins around it. Keep supporting context subordinate; sequence competing text and actions. Let the focal idea land and be read before handing attention to the next event. If crowded, remove or sequence content before shrinking it. Check entry, hold and exit as well as playback. Purposeful object camera moves remain welcome; a generic card is not the default visual container.
11
11
 
12
12
  Full specification: [motion standard](../docs/motion-standard.md).
13
- <!-- ARRIVAL-DRIFT-STANDARD END -->
13
+ <!-- MOTION-STANDARD END -->
14
14
 
15
15
  Connect Claude Code, Codex, Cursor, or OpenCode to Impractical Motion through
16
16
  its MCP server.
@@ -134,5 +134,11 @@ Opt-in flags on the MCP process, for testing quality interventions without touch
134
134
  - `IMPRACTICAL_MOTION_LIBRARY_FILE=<path>` — overlay locally generated motion-library
135
135
  guidance onto the live catalog.
136
136
 
137
+ With quality-loop checks active, text-density findings (`OVERLOADED`) from `get_motion`
138
+ are advisory and never refuse `export_video`: UI labels can exceed the density threshold
139
+ without making a beat unreadable. Review the findings and simplify crowded beats when needed.
140
+ Other shot-list and study-timing findings still refuse export once per draft revision in each
141
+ MCP session; a second attempt on that revision can pass that gate. Other export gates still apply.
142
+
137
143
  If authorization is rejected, rerun the setup command. If the configuration file is malformed,
138
144
  the CLI reports its exact path instead of silently ignoring it.
@@ -5,17 +5,17 @@ description: Create and refine studio-quality motion-graphics launch videos with
5
5
 
6
6
  # Impractical Motion
7
7
 
8
- <!-- ARRIVAL-DRIFT-STANDARD START -->
9
- ## Default motion: arrival and residual drift
8
+ <!-- MOTION-STANDARD START -->
9
+ ## Default motion: arrival, hold and exit
10
10
 
11
- Foreground motion defaults to an energetic arrival, strong deceleration, and small continuing travel through the reading hold. Compose a deterministic residual trajectory with the native entrance; do not stop and restart with a disconnected tween. “Settled” and “hold” mean readable and visually stable, with subtle nonzero travel unless an explicit freeze, exact alignment or reduced-motion mode requires stillness.
11
+ Each foreground element follows one continuous trajectory: it arrives with energy, decelerates strongly to near-zero speed for the reading hold, then accelerates into its exit or its next authored move. Shape this with the entrance and exit eases themselves; there is no separate drift layer, no constant velocity floor and no perpetual creep. Finish the visible travel quickly: during the hold the ease tail moves the subject less than about 0.5 output px in total, so “settled” and “hold” mean visually still and readable. Exits ease in (or in-out) from that near-zero state, so nothing starts from a dead stop. This applies to whole entities, not to every element inside them: a card, product window, headline block or logo lockup arrives, holds and exits as one unit, and its children (labels, icons, rows, words, buttons) ride with it. Don't recurse and give each child its own arrival, deceleration and exit; that reads as fidgeting and splits attention. Children may still have their own discrete actions inside the hold (text typing in, a toggle flipping, a row highlighting, a number counting), but not their own arrive/hold/exit motion.
12
12
 
13
- Use the Rox `ambientOffset(seconds, amount, phase)` pattern: native 960×540 product groups start around amount 3.2–4, text around 0.8–1. Keep a signed velocity floor with gentle curvature, not a pure sine bob. Move attached labels, controls, connectors and shadows together, avoid double drift, preserve 3D hierarchy, and verify reverse/retimed seeks and late-hold displacement.
13
+ Why no creep: exports render in headless Linux Chromium, which snaps slowly moving text and elements to whole pixels, so a slow drift of about 1 px/s shows up as a visible 1 px tick every ~0.9 s. Move attached labels, controls, connectors and shadows together with their subject, preserve 3D hierarchy, and verify reverse/retimed seeks.
14
14
 
15
- The host owns the background environment. Animate foreground objects only; never move or retime the background to simulate object motion. Reusable foregrounds should be transparent. Keep one primary focus and room around it; purposeful object camera moves remain welcome, and a generic card is not the default visual container.
15
+ The host owns the background environment. Animate foreground objects only; never move or retime the background to simulate object motion. Reusable foregrounds should be transparent. Make things breathe: only one focus at a time, with generous negative space and comfortable margins around it. Keep supporting context subordinate; sequence competing text and actions. Let the focal idea land and be read before handing attention to the next event. If crowded, remove or sequence content before shrinking it. Check entry, hold and exit as well as playback. Purposeful object camera moves remain welcome; a generic card is not the default visual container.
16
16
 
17
- For the complete trajectory and review checks, read `motion_context` → `guidance.director` before authoring.
18
- <!-- ARRIVAL-DRIFT-STANDARD END -->
17
+ For the complete standard and review checks, read `motion_context` → `guidance.director` before authoring.
18
+ <!-- MOTION-STANDARD END -->
19
19
 
20
20
  You direct the video yourself. Impractical provides the engine, the preview
21
21
  build, the render, and the studio the user tweaks in — you provide the
@@ -3,29 +3,33 @@ import {
3
3
  ApiContractError,
4
4
  ApiError,
5
5
  ApiTransportError,
6
+ WORKSPACE_HEADER,
6
7
  admitMcpCall,
7
8
  delay,
8
9
  invoke,
9
10
  invokeAt,
10
11
  jobStatus,
11
12
  studioLink,
13
+ studioQuery,
12
14
  validateApiResponse,
13
15
  waitForJobs,
14
16
  withAdmissionReceipt,
15
17
  withMeteredCall
16
- } from "./chunk-GAHKKLF3.js";
17
- import "./chunk-PTYSKJ2Y.js";
18
+ } from "./chunk-2VIBS7AS.js";
19
+ import "./chunk-52D5QRLI.js";
18
20
  import "./chunk-77HVPD4G.js";
19
21
  export {
20
22
  ApiContractError,
21
23
  ApiError,
22
24
  ApiTransportError,
25
+ WORKSPACE_HEADER,
23
26
  admitMcpCall,
24
27
  delay,
25
28
  invoke,
26
29
  invokeAt,
27
30
  jobStatus,
28
31
  studioLink,
32
+ studioQuery,
29
33
  validateApiResponse,
30
34
  waitForJobs,
31
35
  withAdmissionReceipt,
@@ -2,9 +2,9 @@
2
2
  import {
3
3
  PRODUCTION_APP_URL,
4
4
  PRODUCTION_SUPABASE_URL
5
- } from "./chunk-PTYSKJ2Y.js";
5
+ } from "./chunk-52D5QRLI.js";
6
6
 
7
- // src/config.ts
7
+ // cli/src/config.ts
8
8
  import {
9
9
  chmodSync,
10
10
  existsSync,
@@ -63,7 +63,9 @@ Run: npx --yes @impractical-ai/motion setup --agent`
63
63
  }
64
64
  function loadConfig() {
65
65
  const stored = readStoredConfig();
66
+ const workspace = process.env.IMPRACTICAL_WORKSPACE?.trim() || void 0;
66
67
  return {
68
+ ...workspace ? { workspace } : {},
67
69
  apiKey: process.env.IMPRACTICAL_API_KEY ?? stored.apiKey,
68
70
  supabaseUrl: process.env.IMPRACTICAL_SUPABASE_URL ?? stored.supabaseUrl ?? PRODUCTION_SUPABASE_URL,
69
71
  appUrl: process.env.IMPRACTICAL_APP_URL ?? stored.appUrl ?? PRODUCTION_APP_URL
@@ -104,7 +106,7 @@ function requireConfig() {
104
106
  return config;
105
107
  }
106
108
 
107
- // src/api.ts
109
+ // cli/src/api.ts
108
110
  import { AsyncLocalStorage } from "node:async_hooks";
109
111
  import { randomUUID } from "node:crypto";
110
112
  var admissionContext = new AsyncLocalStorage();
@@ -144,7 +146,15 @@ function validateApiResponse(name, body, data) {
144
146
  if (name === "video-shares" && input.action === "clone" && (typeof data.projectId !== "string" || !/^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(data.projectId) || typeof data.alreadyForked !== "boolean")) {
145
147
  throw new ApiContractError(name, "a projectId and alreadyForked flag");
146
148
  }
147
- if (name === "workspace-bootstrap") {
149
+ if (name === "workspace-bootstrap" && input.action === "project_workspace") {
150
+ if (!("workspace" in data) || "orgId" in data) {
151
+ throw new ApiContractError(name, "a workspace field");
152
+ }
153
+ } else if (name === "workspace-bootstrap" && input.action === "list_workspaces") {
154
+ if (!Array.isArray(data.workspaces)) {
155
+ throw new ApiContractError(name, "an object with a workspaces array");
156
+ }
157
+ } else if (name === "workspace-bootstrap") {
148
158
  const billing = data.billing;
149
159
  if (typeof data.orgId !== "string" || typeof data.plan !== "string" || typeof data.hasAccess !== "boolean" || !isRecord(billing) || typeof billing.status !== "string") {
150
160
  throw new ApiContractError(
@@ -188,12 +198,13 @@ function validateApiResponse(name, body, data) {
188
198
  }
189
199
  return data;
190
200
  }
201
+ var WORKSPACE_HEADER = "x-impractical-workspace";
191
202
  async function invoke(name, body = {}) {
192
- const { apiKey, supabaseUrl } = requireConfig();
193
- const receipt = admissionContext.getStore();
194
- return invokeAt(supabaseUrl, name, body, apiKey, receipt);
203
+ const { apiKey, supabaseUrl, workspace } = requireConfig();
204
+ const call = admissionContext.getStore();
205
+ return invokeAt(supabaseUrl, name, body, apiKey, call?.receipt, call ? call.workspace : workspace);
195
206
  }
196
- async function invokeAt(supabaseUrl, name, body = {}, apiKey, admissionReceipt) {
207
+ async function invokeAt(supabaseUrl, name, body = {}, apiKey, admissionReceipt, workspace) {
197
208
  const requestUrl = `${supabaseUrl.replace(/\/$/, "")}/functions/v1/${name}`;
198
209
  let response;
199
210
  try {
@@ -202,6 +213,7 @@ async function invokeAt(supabaseUrl, name, body = {}, apiKey, admissionReceipt)
202
213
  headers: {
203
214
  ...apiKey ? { authorization: `Bearer ${apiKey}` } : {},
204
215
  ...admissionReceipt ? { "x-impractical-admission": admissionReceipt } : {},
216
+ ...apiKey && workspace ? { [WORKSPACE_HEADER]: workspace } : {},
205
217
  "content-type": "application/json"
206
218
  },
207
219
  body: JSON.stringify(body)
@@ -231,16 +243,33 @@ async function invokeAt(supabaseUrl, name, body = {}, apiKey, admissionReceipt)
231
243
  }
232
244
  return validateApiResponse(name, body, data);
233
245
  }
234
- async function admitMcpCall(toolName, callId = randomUUID()) {
246
+ async function admitMcpCall(toolName, target, callId = randomUUID()) {
235
247
  const { apiKey, supabaseUrl } = requireConfig();
236
- return invokeAt(supabaseUrl, "mcp-admission", { callId, toolName }, apiKey);
248
+ return invokeAt(
249
+ supabaseUrl,
250
+ "mcp-admission",
251
+ { callId, toolName, ...target && Object.keys(target).length ? { target } : {} },
252
+ apiKey
253
+ );
237
254
  }
238
- function withAdmissionReceipt(receipt, task) {
239
- return admissionContext.run(receipt, task);
255
+ function withAdmissionReceipt(receipt, task, workspace) {
256
+ return admissionContext.run({ receipt, workspace }, task);
240
257
  }
241
258
  async function withMeteredCall(toolName, task) {
242
- const admission = await admitMcpCall(toolName);
243
- return withAdmissionReceipt(admission.receipt, task);
259
+ const { workspace } = requireConfig();
260
+ const admission = await admitMcpCall(toolName, workspace ? { workspace } : void 0);
261
+ return withAdmissionReceipt(
262
+ admission.receipt,
263
+ task,
264
+ admission.keyScope === "user" ? admission.workspace?.id : void 0
265
+ );
266
+ }
267
+ function studioQuery(slug, workspace) {
268
+ const params = [
269
+ ...slug ? [`scene=${slug}`] : [],
270
+ ...workspace ? [`workspace=${encodeURIComponent(workspace)}`] : []
271
+ ];
272
+ return params.length ? `?${params.join("&")}` : "";
244
273
  }
245
274
  var delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
246
275
  async function jobStatus(jobIds) {
@@ -264,9 +293,9 @@ async function waitForJobs(jobIds, onTick, deadlineMs = 72e5) {
264
293
  }
265
294
  return latest;
266
295
  }
267
- function studioLink(appUrl, projectId, slug) {
296
+ function studioLink(appUrl, projectId, slug, workspace) {
268
297
  const base = (appUrl ?? "http://localhost:5173").replace(/\/$/, "");
269
- return `${base}/projects/${projectId}/studio${slug ? `?scene=${slug}` : ""}`;
298
+ return `${base}/projects/${projectId}/studio${studioQuery(slug, workspace)}`;
270
299
  }
271
300
 
272
301
  export {
@@ -278,11 +307,13 @@ export {
278
307
  ApiContractError,
279
308
  ApiTransportError,
280
309
  validateApiResponse,
310
+ WORKSPACE_HEADER,
281
311
  invoke,
282
312
  invokeAt,
283
313
  admitMcpCall,
284
314
  withAdmissionReceipt,
285
315
  withMeteredCall,
316
+ studioQuery,
286
317
  delay,
287
318
  jobStatus,
288
319
  waitForJobs,
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- // package.json
3
+ // cli/package.json
4
4
  var package_default = {
5
5
  name: "@impractical-ai/motion",
6
- version: "0.1.13",
6
+ version: "0.1.15",
7
7
  private: false,
8
8
  description: "Create and refine Impractical Motion videos from coding agents and the terminal.",
9
9
  homepage: "https://github.com/Openpod/impractical-motion#readme",
@@ -30,7 +30,7 @@ var package_default = {
30
30
  scripts: {
31
31
  build: 'node ../scripts/verify-locked-cli-install.mjs && node ../scripts/build-engine-dts.mjs --cli-only && rm -rf dist && ./node_modules/esbuild/bin/esbuild src/index.ts --define:__BUILD_COMMIT__=\\"$(git rev-parse --short HEAD 2>/dev/null || echo dev)\\" --bundle --platform=node --format=esm --target=node22 --splitting --outdir=dist --external:playwright-core --banner:js="#!/usr/bin/env node" && chmod +x dist/index.js',
32
32
  typecheck: "tsc --noEmit",
33
- test: "npm run typecheck && npm run build && esbuild tests/onboarding.test.ts tests/mcp-tools.test.ts tests/mcp-frames.test.ts tests/mcp-browser-pool.test.ts tests/mcp-motion.test.ts tests/mcp-craft.test.ts tests/mcp-depthkit.test.ts tests/mcp-motion-score.test.ts tests/mcp-install-font.test.ts tests/mcp-metric-catalog.test.ts tests/mcp-text-census.test.ts tests/mcp-phased-flow.test.ts tests/mcp-preflight.test.ts tests/engine-dts.test.ts tests/mcp-connect.test.ts tests/mcp-longpoll.test.ts tests/mcp-agent-timeout.test.ts tests/api-hardening.test.ts --bundle --platform=node --format=esm --packages=external --outdir=dist --out-extension:.js=.mjs && node --test dist/onboarding.test.mjs dist/mcp-tools.test.mjs dist/mcp-frames.test.mjs dist/mcp-browser-pool.test.mjs dist/mcp-motion.test.mjs dist/mcp-craft.test.mjs dist/mcp-depthkit.test.mjs dist/mcp-motion-score.test.mjs dist/mcp-install-font.test.mjs dist/mcp-metric-catalog.test.mjs dist/mcp-text-census.test.mjs dist/mcp-phased-flow.test.mjs dist/mcp-preflight.test.mjs dist/engine-dts.test.mjs dist/mcp-connect.test.mjs dist/mcp-longpoll.test.mjs dist/mcp-agent-timeout.test.mjs dist/api-hardening.test.mjs",
33
+ test: "npm run typecheck && npm run build && esbuild tests/onboarding.test.ts tests/mcp-tools.test.ts tests/mcp-frames.test.ts tests/mcp-browser-pool.test.ts tests/mcp-motion.test.ts tests/mcp-craft.test.ts tests/mcp-depthkit.test.ts tests/mcp-motion-score.test.ts tests/mcp-install-font.test.ts tests/mcp-metric-catalog.test.ts tests/mcp-text-census.test.ts tests/mcp-phased-flow.test.ts tests/mcp-preflight.test.ts tests/engine-dts.test.ts tests/mcp-connect.test.ts tests/mcp-workspaces.test.ts tests/mcp-longpoll.test.ts tests/mcp-agent-timeout.test.ts tests/api-hardening.test.ts --bundle --platform=node --format=esm --packages=external --outdir=dist --out-extension:.js=.mjs && node --test dist/onboarding.test.mjs dist/mcp-tools.test.mjs dist/mcp-frames.test.mjs dist/mcp-browser-pool.test.mjs dist/mcp-motion.test.mjs dist/mcp-craft.test.mjs dist/mcp-depthkit.test.mjs dist/mcp-motion-score.test.mjs dist/mcp-install-font.test.mjs dist/mcp-metric-catalog.test.mjs dist/mcp-text-census.test.mjs dist/mcp-phased-flow.test.mjs dist/mcp-preflight.test.mjs dist/engine-dts.test.mjs dist/mcp-connect.test.mjs dist/mcp-workspaces.test.mjs dist/mcp-longpoll.test.mjs dist/mcp-agent-timeout.test.mjs dist/api-hardening.test.mjs",
34
34
  prepack: "npm run build",
35
35
  "test:rig": "npm run typecheck && esbuild tests/engine-dts.test.ts tests/mcp-agent-timeout.test.ts tests/mcp-browser-pool.test.ts tests/mcp-component-assertions.test.ts tests/mcp-components.test.ts tests/mcp-connect.test.ts tests/mcp-craft.test.ts tests/mcp-depthkit.test.ts tests/mcp-exposed-ground.test.ts tests/mcp-frames.test.ts tests/mcp-install-font.test.ts tests/mcp-legibility.test.ts tests/mcp-longpoll.test.ts tests/mcp-metric-catalog.test.ts tests/mcp-motion-score.test.ts tests/mcp-motion-slop.test.ts tests/mcp-motion.test.ts tests/mcp-phased-flow.test.ts tests/mcp-preflight.test.ts tests/mcp-ref-inject.test.ts tests/mcp-shot-list.test.ts tests/mcp-text-census.test.ts tests/mcp-tools.test.ts tests/review-modules.test.ts tests/rig-transplant.test.ts --bundle --platform=node --format=esm --packages=external --outdir=.rig-tests --out-extension:.js=.mjs && node --test .rig-tests/engine-dts.test.mjs .rig-tests/mcp-agent-timeout.test.mjs .rig-tests/mcp-browser-pool.test.mjs .rig-tests/mcp-component-assertions.test.mjs .rig-tests/mcp-components.test.mjs .rig-tests/mcp-connect.test.mjs .rig-tests/mcp-craft.test.mjs .rig-tests/mcp-depthkit.test.mjs .rig-tests/mcp-exposed-ground.test.mjs .rig-tests/mcp-frames.test.mjs .rig-tests/mcp-install-font.test.mjs .rig-tests/mcp-legibility.test.mjs .rig-tests/mcp-longpoll.test.mjs .rig-tests/mcp-metric-catalog.test.mjs .rig-tests/mcp-motion-score.test.mjs .rig-tests/mcp-motion-slop.test.mjs .rig-tests/mcp-motion.test.mjs .rig-tests/mcp-phased-flow.test.mjs .rig-tests/mcp-preflight.test.mjs .rig-tests/mcp-ref-inject.test.mjs .rig-tests/mcp-shot-list.test.mjs .rig-tests/mcp-text-census.test.mjs .rig-tests/mcp-tools.test.mjs .rig-tests/review-modules.test.mjs .rig-tests/rig-transplant.test.mjs"
36
36
  },
@@ -43,13 +43,13 @@ var package_default = {
43
43
  typescript: "^5.6.3"
44
44
  },
45
45
  dependencies: {
46
- "@modelcontextprotocol/sdk": "^1.30.0",
46
+ "@modelcontextprotocol/sdk": "^1.32.1",
47
47
  "playwright-core": "^1.55.1",
48
48
  zod: "^4.4.3"
49
49
  }
50
50
  };
51
51
 
52
- // src/constants.ts
52
+ // cli/src/constants.ts
53
53
  if (package_default.name !== "@impractical-ai/motion" || typeof package_default.version !== "string" || !package_default.version) {
54
54
  throw new Error("The packaged CLI manifest is missing valid release metadata");
55
55
  }
@@ -57,7 +57,7 @@ var PRODUCTION_APP_URL = "https://motion.impractical.ai";
57
57
  var PRODUCTION_SUPABASE_URL = "https://uaxjweednprtbhbceify.supabase.co";
58
58
  var PACKAGE_NAME = "@impractical-ai/motion";
59
59
  var PACKAGE_VERSION = package_default.version;
60
- var BUILD_COMMIT = "ffb78fc" ? "ffb78fc" : "dev";
60
+ var BUILD_COMMIT = "e3a238b6" ? "e3a238b6" : "dev";
61
61
  var BUILD_ID = `${PACKAGE_VERSION}+${BUILD_COMMIT}`;
62
62
  var PACKAGE_COMMAND = `npx --yes ${PACKAGE_NAME}`;
63
63
 
@@ -1,21 +1,22 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
+ ApiContractError,
3
4
  ApiError,
4
5
  delay,
5
6
  invokeAt,
6
7
  loadConfig,
7
8
  recoverCorruptConfig,
8
9
  saveConfig
9
- } from "./chunk-GAHKKLF3.js";
10
+ } from "./chunk-2VIBS7AS.js";
10
11
  import {
11
12
  PACKAGE_COMMAND,
12
13
  PACKAGE_NAME,
13
14
  PACKAGE_VERSION,
14
15
  PRODUCTION_APP_URL,
15
16
  PRODUCTION_SUPABASE_URL
16
- } from "./chunk-PTYSKJ2Y.js";
17
+ } from "./chunk-52D5QRLI.js";
17
18
 
18
- // src/onboarding.ts
19
+ // cli/src/onboarding.ts
19
20
  import {
20
21
  chmodSync,
21
22
  existsSync,
@@ -31,6 +32,48 @@ import { dirname, join } from "node:path";
31
32
  import { fileURLToPath } from "node:url";
32
33
  import { spawnSync } from "node:child_process";
33
34
  import { createRequire } from "node:module";
35
+
36
+ // cli/src/workspaces.ts
37
+ var UNSUPPORTED = {
38
+ supported: false,
39
+ keyScope: null,
40
+ lastOpenWorkspaceId: null,
41
+ workspaces: []
42
+ };
43
+ async function fetchWorkspaces(request) {
44
+ let result;
45
+ try {
46
+ result = await request("workspace-bootstrap", { action: "list_workspaces" });
47
+ } catch (error) {
48
+ if (error instanceof ApiContractError) return UNSUPPORTED;
49
+ throw error;
50
+ }
51
+ if (!Array.isArray(result?.workspaces)) return UNSUPPORTED;
52
+ const keyScope = result.keyScope === "user" ? "user" : result.keyScope === "org" ? "org" : null;
53
+ const workspaces = result.workspaces.filter((row) => typeof row?.id === "string").map((row) => ({
54
+ id: String(row.id),
55
+ name: typeof row.name === "string" ? row.name : null,
56
+ slug: typeof row.slug === "string" ? row.slug : null,
57
+ role: typeof row.role === "string" ? row.role : "",
58
+ plan: typeof row.plan === "string" ? row.plan : null,
59
+ usage: row.usage && typeof row.usage === "object" ? row.usage : null
60
+ }));
61
+ return {
62
+ supported: true,
63
+ keyScope,
64
+ lastOpenWorkspaceId: typeof result.lastOpenWorkspaceId === "string" ? result.lastOpenWorkspaceId : null,
65
+ workspaces
66
+ };
67
+ }
68
+ function workspaceLabel(workspace) {
69
+ return workspace.name ? `${workspace.name} (${workspace.id})` : workspace.id;
70
+ }
71
+ var DEVICE_START_BODY = { action: "start", scope: "user" };
72
+ function grantScope(grant) {
73
+ return grant.scope === "user" ? "user" : "org";
74
+ }
75
+
76
+ // cli/src/onboarding.ts
34
77
  var CLAUDE_MARKETPLACE = "Openpod/impractical-agent-plugins";
35
78
  var CLAUDE_PLUGIN = "impractical-motion@impractical";
36
79
  var CLAUDE_MARKETPLACE_NAME = "impractical";
@@ -656,7 +699,7 @@ async function waitForApproval(supabaseUrl, authorization, log, setupFlag) {
656
699
  action: "poll",
657
700
  deviceCode: authorization.deviceCode
658
701
  });
659
- if (result.status === "authorized") return result.apiKey;
702
+ if (result.status === "authorized") return result;
660
703
  if (!announced) {
661
704
  log("Waiting for browser approval\u2026");
662
705
  announced = true;
@@ -681,9 +724,25 @@ async function setup(options) {
681
724
  const existing = loadConfig();
682
725
  let apiKey = existing.supabaseUrl === supabaseUrl ? existing.apiKey : void 0;
683
726
  let verified;
727
+ let workspacesLine;
728
+ const listWorkspaces = async (key) => {
729
+ const listing = await fetchWorkspaces((name, body) => invokeAt(supabaseUrl, name, body, key));
730
+ workspacesLine = `Workspaces: ${listing.workspaces.map(workspaceLabel).join(", ") || "none yet"} (one key for all of them)`;
731
+ };
732
+ const verify = async (key, scope) => {
733
+ if (scope === "user") return listWorkspaces(key);
734
+ try {
735
+ verified = await invokeAt(supabaseUrl, "workspace-bootstrap", {}, key);
736
+ } catch (error) {
737
+ if (scope === "unknown" && error instanceof ApiError && error.status === 409 && error.details?.error === "workspace_selection_required") {
738
+ return listWorkspaces(key);
739
+ }
740
+ throw error;
741
+ }
742
+ };
684
743
  if (apiKey) {
685
744
  try {
686
- verified = await invokeAt(supabaseUrl, "workspace-bootstrap", {}, apiKey);
745
+ await verify(apiKey, "unknown");
687
746
  options.log("Existing connection verified; browser authorization is not needed.");
688
747
  } catch (error) {
689
748
  if (!(error instanceof ApiError) || error.status !== 401) throw error;
@@ -692,9 +751,11 @@ async function setup(options) {
692
751
  }
693
752
  if (!apiKey) {
694
753
  if (options.installAgentMcp) verifyAgentConfigs();
695
- const authorization = await invokeAt(supabaseUrl, "cli-device-auth", {
696
- action: "start"
697
- });
754
+ const authorization = await invokeAt(
755
+ supabaseUrl,
756
+ "cli-device-auth",
757
+ DEVICE_START_BODY
758
+ );
698
759
  options.log("");
699
760
  options.log("Connect Impractical Motion");
700
761
  options.log(`Code: ${authorization.userCode}`);
@@ -704,15 +765,17 @@ async function setup(options) {
704
765
  const opened = openBrowser(authorization.verificationUri);
705
766
  options.log(opened ? "Opened your browser." : "Could not open a browser automatically; use the link above.");
706
767
  }
768
+ let grant;
707
769
  try {
708
- apiKey = await waitForApproval(supabaseUrl, authorization, options.log, setupFlag);
770
+ grant = await waitForApproval(supabaseUrl, authorization, options.log, setupFlag);
709
771
  } catch (error) {
710
772
  if (error instanceof ApiError && error.status === 410) {
711
773
  throw new Error(`Authorization expired. Run \`${PACKAGE_COMMAND} setup ${setupFlag}\` again.`);
712
774
  }
713
775
  throw error;
714
776
  }
715
- verified = await invokeAt(supabaseUrl, "workspace-bootstrap", {}, apiKey);
777
+ apiKey = grant.apiKey;
778
+ await verify(apiKey, grantScope(grant));
716
779
  saveConfig({ apiKey, supabaseUrl, appUrl });
717
780
  }
718
781
  const claudePlugin = options.installClaudePlugin ? installClaudePlugin(options.log) : void 0;
@@ -735,7 +798,9 @@ async function setup(options) {
735
798
  options.log(`Refreshed legacy /impractical for ${skill.harness}; previous copy preserved at ${skill.backupPath}.`);
736
799
  }
737
800
  if (claudePlugin) options.log(pluginResultLine(claudePlugin));
738
- options.log(`Workspace: ${verified.orgId}${verified.plan ? ` \xB7 ${verified.plan}` : ""}`);
801
+ options.log(
802
+ workspacesLine ?? `Workspace: ${verified.orgId}${verified.plan ? ` \xB7 ${verified.plan}` : ""}`
803
+ );
739
804
  options.log("");
740
805
  if (options.installClaudePlugin) {
741
806
  options.log("Run /reload-plugins, then type continue.");
@@ -752,6 +817,10 @@ async function setup(options) {
752
817
  }
753
818
 
754
819
  export {
820
+ fetchWorkspaces,
821
+ workspaceLabel,
822
+ DEVICE_START_BODY,
823
+ grantScope,
755
824
  openBrowser,
756
825
  setup
757
826
  };
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  setup
4
- } from "./chunk-ZCTJTQB7.js";
4
+ } from "./chunk-TPFRXA7C.js";
5
5
  import {
6
6
  invoke,
7
7
  invokeAt,
@@ -11,15 +11,15 @@ import {
11
11
  saveConfig,
12
12
  studioLink,
13
13
  waitForJobs
14
- } from "./chunk-GAHKKLF3.js";
15
- import "./chunk-PTYSKJ2Y.js";
14
+ } from "./chunk-2VIBS7AS.js";
15
+ import "./chunk-52D5QRLI.js";
16
16
  import "./chunk-77HVPD4G.js";
17
17
 
18
- // src/commands.ts
18
+ // cli/src/commands.ts
19
19
  import { readFileSync as readFileSync2, writeFileSync } from "node:fs";
20
20
  import { randomBytes } from "node:crypto";
21
21
 
22
- // src/media.ts
22
+ // cli/src/media.ts
23
23
  import { readFileSync, statSync } from "node:fs";
24
24
  import { basename, extname } from "node:path";
25
25
  var MAX_UPLOAD_BYTES = 3e8;
@@ -79,7 +79,7 @@ async function uploadAsset(input) {
79
79
  return registered.assetId;
80
80
  }
81
81
 
82
- // ../src/studio/sampleLogos.ts
82
+ // src/studio/sampleLogos.ts
83
83
  var SAMPLE_LOGOS = [
84
84
  {
85
85
  id: "bolt",
@@ -117,7 +117,7 @@ function sampleLogo(id) {
117
117
  return SAMPLE_LOGOS.find((s) => s.id === id);
118
118
  }
119
119
 
120
- // ../src/studio/templates.ts
120
+ // src/studio/templates.ts
121
121
  var esc = (s) => s.replace(/\\/g, "\\\\").replace(/'/g, "\\'");
122
122
  var escTemplate = (s) => s.replace(/\\/g, "\\\\").replace(/`/g, "\\`").replace(/\$\{/g, "\\${");
123
123
  var num = (v, fallback) => {
@@ -1091,7 +1091,7 @@ var TEMPLATES = [
1091
1091
  blank
1092
1092
  ];
1093
1093
 
1094
- // ../src/studio/parseFiles.ts
1094
+ // src/studio/parseFiles.ts
1095
1095
  var FENCE = /```([^\n`]*)\n([\s\S]*?)```/g;
1096
1096
  var DROP = /* @__PURE__ */ new Set([
1097
1097
  "index.tsx",
@@ -1143,7 +1143,7 @@ function parseSceneFiles(pasted) {
1143
1143
  return files;
1144
1144
  }
1145
1145
 
1146
- // ../src/shared/local-project.ts
1146
+ // src/shared/local-project.ts
1147
1147
  var LOCAL_PROJECT_ID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
1148
1148
  var LOCAL_SCENE_NAME_RE = /^[a-z0-9][a-z0-9-]{0,63}$/;
1149
1149
  function isLocalProjectId(value) {
@@ -1163,7 +1163,7 @@ function localProjectMarker(input) {
1163
1163
  `;
1164
1164
  }
1165
1165
 
1166
- // ../src/shared/initial-files.ts
1166
+ // src/shared/initial-files.ts
1167
1167
  var TITLE_TEMPLATE = TEMPLATES.find((t) => t.id === "title-card");
1168
1168
  var BLANK_DIRECTION = TEMPLATES.find((t) => t.id === "blank").generate({});
1169
1169
  var defaultParams = (t) => Object.fromEntries(t.params.map((p) => [p.key, p.default]));
@@ -1201,10 +1201,10 @@ function buildInitialFiles(input) {
1201
1201
  };
1202
1202
  }
1203
1203
 
1204
- // ../src/shared/video-models.ts
1204
+ // src/shared/video-models.ts
1205
1205
  var DEFAULT_OPENROUTER_VIDEO_MODEL = "anthropic/claude-opus-5";
1206
1206
 
1207
- // ../src/shared/video-clone-command.ts
1207
+ // src/shared/video-clone-command.ts
1208
1208
  var TOKEN = /^[A-Za-z0-9_-]{43}$/;
1209
1209
  var SHARE_HOSTS = /* @__PURE__ */ new Set(["impractical.ai", "www.impractical.ai", "impractical-video-shares.vercel.app"]);
1210
1210
  function videoShareToken(source) {
@@ -1218,7 +1218,7 @@ function videoShareToken(source) {
1218
1218
  throw new Error("Use an Impractical video share URL: https://impractical.ai/v/<token>");
1219
1219
  }
1220
1220
 
1221
- // src/clone-video-project.ts
1221
+ // cli/src/clone-video-project.ts
1222
1222
  async function cloneVideoProject(source, json = false) {
1223
1223
  const token = videoShareToken(source);
1224
1224
  const result = await invoke("video-shares", { action: "clone", token });
@@ -1234,7 +1234,7 @@ async function cloneVideoProject(source, json = false) {
1234
1234
  console.log(`Use Impractical to open project ${result.projectId} and help me iterate on this video.`);
1235
1235
  }
1236
1236
 
1237
- // src/video-sharing.ts
1237
+ // cli/src/video-sharing.ts
1238
1238
  import { openAsBlob } from "node:fs";
1239
1239
  import { readFile, stat } from "node:fs/promises";
1240
1240
  import { basename as basename2, extname as extname2 } from "node:path";
@@ -1247,7 +1247,11 @@ async function shareVideo(rest, flags) {
1247
1247
  method: body ? "POST" : "GET",
1248
1248
  redirect: "error",
1249
1249
  signal: AbortSignal.timeout(45e3),
1250
- headers: { authorization: `Bearer ${config.apiKey}`, "content-type": "application/json" },
1250
+ headers: {
1251
+ authorization: `Bearer ${config.apiKey}`,
1252
+ ...config.workspace ? { "x-impractical-workspace": config.workspace } : {},
1253
+ "content-type": "application/json"
1254
+ },
1251
1255
  body: body ? JSON.stringify(body) : void 0
1252
1256
  }
1253
1257
  );
@@ -1331,7 +1335,7 @@ async function shareVideo(rest, flags) {
1331
1335
  }
1332
1336
  }
1333
1337
 
1334
- // src/commands.ts
1338
+ // cli/src/commands.ts
1335
1339
  var flagString = (flags, name) => {
1336
1340
  const value = flags[name];
1337
1341
  if (Array.isArray(value)) return value[value.length - 1];
@@ -1380,7 +1384,10 @@ async function login(flags) {
1380
1384
  config.supabaseUrl,
1381
1385
  "workspace-bootstrap",
1382
1386
  {},
1383
- config.apiKey
1387
+ config.apiKey,
1388
+ void 0,
1389
+ // IMPRACTICAL_WORKSPACE, for a multi-workspace key; unset sends nothing.
1390
+ config.workspace
1384
1391
  );
1385
1392
  if (Object.keys(patch).length) saveConfig(patch);
1386
1393
  out(`org: ${snapshot.orgId}`);
@@ -1431,9 +1438,14 @@ async function generate(flags) {
1431
1438
  }
1432
1439
  const projectId = flagString(flags, "project");
1433
1440
  const feedback = flagString(flags, "feedback");
1434
- const append = Boolean(projectId && feedback);
1441
+ if (projectId && feedback) {
1442
+ throw new Error(
1443
+ "Projects have one draft now. To revise this video, edit its draft with the MCP tools edit_draft_file / write_draft_files; every save is kept as a version."
1444
+ );
1445
+ }
1446
+ const append = false;
1435
1447
  const slug = flagString(flags, "slug") ?? `${slugify(valueProp)}-${randomBytes(2).toString("hex")}`;
1436
- const directorIds = (flagString(flags, "directors") ?? "d1,d2").split(",").map((d) => d.trim());
1448
+ const directorIds = (flagString(flags, "directors") ?? "d1").split(",").map((d) => d.trim()).slice(0, 1);
1437
1449
  const files = buildInitialFiles({ valueProp, appCode, brand: brand2 });
1438
1450
  const prepared = await invoke("prepare-generation", {
1439
1451
  ...projectId ? { projectId } : {},