@tempo-ai/mcp 0.0.142 → 0.0.143-staging.1

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.
@@ -28182,7 +28182,7 @@ var require_files = __commonJS({
28182
28182
  var base = options2.relativeToFile ? dirname3(options2.relativeToFile) : null;
28183
28183
  function read2(uri, encoding) {
28184
28184
  return resolveUri(uri).then(function(path86) {
28185
- return readFile41(path86, encoding).caught(function(error) {
28185
+ return readFile42(path86, encoding).caught(function(error) {
28186
28186
  var message = "could not open external image: '" + uri + "' (document directory: '" + base + "')\n" + error.message;
28187
28187
  return promises.reject(new Error(message));
28188
28188
  });
@@ -28202,7 +28202,7 @@ var require_files = __commonJS({
28202
28202
  read: read2
28203
28203
  };
28204
28204
  }
28205
- var readFile41 = promises.promisify(fs9.readFile.bind(fs9));
28205
+ var readFile42 = promises.promisify(fs9.readFile.bind(fs9));
28206
28206
  function uriToPath(uriString, platform) {
28207
28207
  if (!platform) {
28208
28208
  platform = os5.platform();
@@ -30948,10 +30948,10 @@ var require_unzip = __commonJS({
30948
30948
  var promises = require_promises();
30949
30949
  var zipfile = require_zipfile();
30950
30950
  exports2.openZip = openZip;
30951
- var readFile41 = promises.promisify(fs9.readFile);
30951
+ var readFile42 = promises.promisify(fs9.readFile);
30952
30952
  function openZip(options2) {
30953
30953
  if (options2.path) {
30954
- return readFile41(options2.path).then(zipfile.openArrayBuffer);
30954
+ return readFile42(options2.path).then(zipfile.openArrayBuffer);
30955
30955
  } else if (options2.buffer) {
30956
30956
  return promises.resolve(zipfile.openArrayBuffer(options2.buffer));
30957
30957
  } else if (options2.file) {
@@ -81536,7 +81536,7 @@ Before creating, modifying, restyling, or reviewing UI, read the existing app to
81536
81536
  4. **Providers** \u2014 confirm the app's entry point wires every provider the new component needs. If you add a provider to make the new UI work, add it to the app's entry, not to CanvasProviders.
81537
81537
  5. **Mock data** \u2014 if backing data isn't available yet, hardcode realistic fixtures inline in the component as a "UI-only prototype". Do not build API clients or data-fetching scaffolding for a prototype.
81538
81538
 
81539
- The test: open the app's devserver (not the canvas), navigate to the new screen, and verify it looks correct in the real app shell. Only after that passes should you add the canvas.
81539
+ The test: open the app's devserver (not the canvas), navigate to the new screen, and verify it looks correct in the real app shell.
81540
81540
 
81541
81541
  ---
81542
81542
 
@@ -81770,7 +81770,7 @@ Mechanics:
81770
81770
  - Lifecycle: warm with a 5-minute idle stop \u2014 the supervisor stays alive while a canvas with route storyboards is open and stops 5 minutes after the last canvas closes.
81771
81771
  - While starting, an overlay reads "Starting your app dev server\u2026" on every route storyboard.
81772
81772
 
81773
- **Screenshotting a route storyboard headlessly \u2014 start the app dev server first.** \`canvas_screenshot\` / \`canvas_debug\` cold-capture a route storyboard from the app dev server, but they do **not** start it for you \u2014 they only use it if it is already running, and \`set_app_dev_command\` merely SAVES the command (the supervisor auto-starts only when a route-storyboard canvas is opened in the Design tab, which doesn't happen when you're driving via the MCP). So when you screenshot a route storyboard headlessly, pre-flight: \`check_app_dev_server\` \u2192 if \`running\` is \`false\`, \`start_app_dev_server\` (it blocks until the server is ready and returns its \`url\`) \u2192 then \`canvas_screenshot\`. Skipping this returns \`capture_threw\` "Route storyboard \u2026 could not be cold-captured \u2014 ensure the app dev server is running"; the fix is \`start_app_dev_server\`, not a retry. Component (non-route) storyboards are served by the canvas sidecar and don't need this.
81773
+ **Screenshotting a route storyboard headlessly \u2014 start the app dev server first.** \`canvas_screenshot\` / \`canvas_debug\` cold-capture a route storyboard from the app dev server, but they do **not** start it for you \u2014 they only use it if it is already running, and \`set_app_dev_command\` merely SAVES the command (the supervisor auto-starts only when a route-storyboard canvas is opened in the app, which doesn't happen when you're driving via the MCP). So when you screenshot a route storyboard headlessly, pre-flight: \`check_app_dev_server\` \u2192 if \`running\` is \`false\`, \`start_app_dev_server\` (it blocks until the server is ready and returns its \`url\`) \u2192 then \`canvas_screenshot\`. Skipping this returns \`capture_threw\` "Route storyboard \u2026 could not be cold-captured \u2014 ensure the app dev server is running"; the fix is \`start_app_dev_server\`, not a retry. Component (non-route) storyboards are served by the canvas sidecar and don't need this.
81774
81774
 
81775
81775
  **Picking the command per framework:**
81776
81776
 
@@ -81867,7 +81867,7 @@ Internally this tool:
81867
81867
  2. Slugifies the canvas name to create the directory (e.g., "Auth Components" \u2192 \`auth-components/\`)
81868
81868
  3. Computes non-overlapping layout positions for all storyboards
81869
81869
  4. Generates the React-format \`index.canvas.tsx\` (component imports + one storyboard element per entry). An \`import_path\` ending in \`.svelte\`, \`.vue\` or \`.astro\` gets \`<SvelteStoryboard>\`, \`<VueStoryboard>\` or \`<AstroStoryboard>\` (an Astro import is written with its \`?tempo-component\` descriptor query); an extensionless one follows \`apps[0].uiFramework\`
81870
- 5. Scaffolds \`<div />\` stub files for any canvas-local storyboard imports that don't exist yet, in the storyboard's framework (\`.tsx\`, \`.svelte\`, \`.vue\` or \`.astro\`)
81870
+ 5. Scaffolds \`<div />\` stub files for any canvas-local storyboard imports that don't exist yet, in the storyboard's framework (\`.tsx\`, \`.svelte\`, \`.vue\` or \`.astro\`). A stub renders nothing, so its frame shows as work in progress at its \`width\`/\`height\` (returned with \`stub: true\`) until you write the component and call \`finish_working_on_storyboard\` for it, or finish the canvas
81871
81871
 
81872
81872
  \`\`\`
81873
81873
  canvas_create({
@@ -81931,7 +81931,7 @@ canvas_delete({ "canvas_dir": "{{canvasesDir}}/auth-components" })
81931
81931
 
81932
81932
  ### canvas_migrate_to_latest (mutating)
81933
81933
 
81934
- Migrates a canvas from the legacy object-export format (\`export const X: TempoStoryboard = \u2026\`) to the current React \`<Canvas>\` format, the same conversion Tempo applies automatically when a legacy canvas is opened in the Design tab. Rewrites \`index.canvas.tsx\` in place and removes legacy component sizing flags; safe no-op when no migration is needed. Call it BEFORE hand-editing any legacy-format canvas.
81934
+ Migrates a canvas from the legacy object-export format (\`export const X: TempoStoryboard = \u2026\`) to the current React \`<Canvas>\` format, the same conversion Tempo applies automatically when a legacy canvas is opened in the app. Rewrites \`index.canvas.tsx\` in place and removes legacy component sizing flags; safe no-op when no migration is needed. Call it BEFORE hand-editing any legacy-format canvas.
81935
81935
 
81936
81936
  \`\`\`
81937
81937
  canvas_migrate_to_latest({ "canvas_file": "{{canvasesDir}}/auth-components/index.canvas.tsx" })
@@ -82045,31 +82045,31 @@ The visual-review setup pair, split exactly like \`canvas_validate\` / \`canvas_
82045
82045
 
82046
82046
  ### Creating a New Canvas
82047
82047
 
82048
- **Re-read \xA75.1 "Authoring Principle" before starting.** The workflow below assumes you will build new UI in the app, not in the canvas folder.
82048
+ **Re-read \xA75.1 "Authoring Principle" before starting.** The workflow below assumes you will build new UI in the app, not in the canvas folder. The canvas is created and opened FIRST, so the user watches it fill in while you build.
82049
82049
 
82050
- 1. **Search the codebase for an existing component or route** that satisfies the request. If one exists, skip to step 5 and point the canvas at it.
82050
+ 1. **Search the codebase for an existing component or route** that satisfies the request. If one exists, skip building (steps 5\u20136) and point the storyboard at it.
82051
82051
  2. **If nothing matches, confirm scope with the user.** **(required)** Specifically confirm: which part of the app does this belong to, and is a UI-only prototype with mock data acceptable for now?
82052
- 3. **Build the new UI inside the app following the "Explore before you build" checklist in \xA75.1.** Place the component in the app's real component tree (e.g., \`src/components/<feature>/\` or \`app/<route>/page.tsx\`). Wire it into the router/shell if it's a page. Use the app's existing UI kit, tokens, and layout primitives. Use inline mock data where real data isn't available.
82053
- 4. **Verify the new UI in the real app** (not the canvas) \u2014 open the app's devserver, navigate to the screen, confirm it renders correctly inside the app shell with the right styling. Do not proceed until this looks right.
82054
- 5. **Call \`start_working_on_canvas({ canvas_slug })\` BEFORE \`canvas_create\`.** **(required)** This announces canvas activity in tabs/sidebar; rendering stays live. Use the separate storyboard tools for shimmer on each frame. Use the slug you intend to pass to \`canvas_create\` \u2014 it doesn't need to exist on disk yet to announce the activity.
82055
- 6. **Run \`canvas_create\`** with a local storyboard import such as \`./Storyboard1\`. After it succeeds, fill in \`Storyboard1.tsx\` with a default-exported component returning one sized root around the real app component, as in \xA76. Keep product UI in the app. **Do not create the canvas directory or write any files into it before this step**: \`canvas_create\` creates the directory, and direct \`Write\` to \`*.canvas.tsx\` is blocked.
82056
- 7. **Run \`canvas_validate\`** for deep dependency analysis. **(required)**
82057
- 8. **Fix any issues** and re-validate until \`valid\` is true, \`checks.type_check.status\` is \`"passed"\` and \`canvas_type_errors\` is 0. If a returned issue is a \`host_setup_issue\`, call \`canvas_project_init\` to fix it (validate diagnoses; init scaffolds).
82058
- 9. **Call \`canvas_screenshot\`** on one representative storyboard for visual verification (one try, no retries on typed errors \u2014 see \xA79).
82059
- 10. **Call \`finish_working_on_canvas({ canvas_slug })\`** to end canvas activity and capture the final preview. **(required)** Pair with the matching \`start_working_on_canvas\` from step 5.
82052
+ 3. **Call \`start_working_on_canvas({ canvas_slug })\`, then \`canvas_create\` with NO \`storyboards\`.** **(required)** Start announces canvas activity in tabs/sidebar; use the slug you will pass to \`canvas_create\` \u2014 it doesn't need to exist on disk yet. \`canvas_create\` writes an empty canvas and opens it in this chat's split view. **Do not create the canvas directory or write any files into it before this step**: \`canvas_create\` creates the directory, and direct \`Write\` to \`*.canvas.tsx\` is blocked.
82053
+ 4. **For each planned frame, call \`start_working_on_storyboard({ canvas_slug, storyboard, layout: { x, y, width, height } })\`** so its placeholder shows at its planned size while you build.
82054
+ 5. **Build the new UI inside the app following the "Explore before you build" checklist in \xA75.1.** Place the component in the app's real component tree (e.g., \`src/components/<feature>/\` or \`app/<route>/page.tsx\`). Wire it into the router/shell if it's a page. Use the app's existing UI kit, tokens, and layout primitives. Use inline mock data where real data isn't available.
82055
+ 6. **Verify the new UI in the real app** (not the canvas) \u2014 open the app's devserver, navigate to the screen, confirm it renders correctly inside the app shell with the right styling.
82056
+ 7. **Add each storyboard as soon as its component is useful.** Create the local \`StoryboardN.tsx\` in the returned \`canvas_dir\` (a default-exported component returning one sized root around the real app component, as in \xA76), then \`Edit\` \`index.canvas.tsx\` to import it and add a \`<Storyboard>\` with the same id and the x/y from step 4. Keep product UI in the app. Finish each frame with \`finish_working_on_storyboard\`.
82057
+ 8. **Run \`canvas_validate\`** for deep dependency analysis. **(required)**
82058
+ 9. **Fix any issues** and re-validate until \`valid\` is true, \`checks.type_check.status\` is \`"passed"\` and \`canvas_type_errors\` is 0. If a returned issue is a \`host_setup_issue\`, call \`canvas_project_init\` to fix it (validate diagnoses; init scaffolds).
82059
+ 10. **Call \`canvas_screenshot\`** on one representative storyboard for visual verification (one try, no retries on typed errors \u2014 see \xA79).
82060
+ 11. **Call \`finish_working_on_canvas({ canvas_slug })\`** to end canvas activity and capture the final preview. **(required)** Pair with the matching \`start_working_on_canvas\` from step 3.
82060
82061
 
82061
82062
  **Note:** \`canvas_create\` does not check anything; it just writes the files and returns. \`canvas_validate\` is where checking happens: it walks the full import tree, type-checks every reachable file, and returns structured issues and type errors with fix suggestions. Always run \`canvas_validate\` after creating or editing a canvas, once it has real content.
82062
82063
 
82063
82064
  **Anti-patterns to avoid:**
82064
82065
  - Writing new screen/component JSX directly inside \`index.canvas.tsx\` or as a canvas-local file when that UI could live in the app.
82065
- - Skipping the sibling-screen read in step 3 and guessing at the app's patterns.
82066
+ - Skipping the sibling-screen read in step 5 and guessing at the app's patterns.
82066
82067
  - Adding new providers to \`CanvasProviders\` to make a new component work \u2014 if the component needs a provider, the app's entry point needs it too.
82067
- - Creating the canvas before the underlying component is landed and verified in the real app.
82068
82068
  - Creating a route storyboard unless explicitly asked for or a user explicitly wants a canvas to show a specific page of the app.
82069
82069
 
82070
82070
  ### Adding Storyboards to an Existing Canvas
82071
82071
 
82072
- 1. **Call \`start_working_on_canvas({ canvas_slug })\`** \u2014 announces canvas activity; rendering stays live. **(required)**
82072
+ 1. **Call \`start_working_on_canvas({ canvas_slug })\`** \u2014 announces canvas activity and opens the canvas in this chat's split view; rendering stays live. **(required)**
82073
82073
  2. Read current \`index.canvas.tsx\`. If it is still in the legacy object-export format (\`export const X: TempoStoryboard = \u2026\`), run \`canvas_migrate_to_latest\` first and re-read \u2014 never hand-edit a legacy file or mix the two formats.
82074
82074
  3. Run \`canvas_compute_layout\` with the canvas file path and new storyboard specs to get positions that don't overlap with existing storyboards.
82075
82075
  4. Create the component storyboard file with one root as in \xA76. Import it into the canvas and add a \`<Storyboard>\` child with only the computed x/y in its layout; put size on the root element.
@@ -82103,7 +82103,8 @@ The snapshot is always a whole-canvas render. Only
82103
82103
 
82104
82104
  Canvas activity and storyboard work are independent:
82105
82105
  - \`start_working_on_canvas({ canvas_slug })\` / \`finish_working_on_canvas({ canvas_slug })\`
82106
- control the canvas's tabs/sidebar activity indicator.
82106
+ control the canvas's tabs/sidebar activity indicator. Start also opens an
82107
+ existing canvas in this chat's split view (\`canvas_create\` opens a new one).
82107
82108
  - \`start_working_on_storyboard({ canvas_slug, storyboard, layout? })\` /
82108
82109
  \`finish_working_on_storyboard({ canvas_slug, storyboard })\` control ONLY
82109
82110
  the shimmer on that exact Storyboard id. For a new frame, supply
@@ -82146,7 +82147,7 @@ Screenshot ONE representative storyboard you actually edited \u2014 not every st
82146
82147
 
82147
82148
  **Stop conditions \u2014 do not retry:**
82148
82149
 
82149
- - A \`canvas_not_open\` error means the user does not have any canvas open in the Design tab. Stop calling \`canvas_screenshot\`, tell the user to open the canvas, and move on \u2014 firing more screenshots will not change the outcome.
82150
+ - A \`canvas_not_open\` error means the user does not have the canvas open as a tab. Stop calling \`canvas_screenshot\`, tell the user to open the canvas, and move on \u2014 firing more screenshots will not change the outcome.
82150
82151
  - Any typed error (\`storyboard_not_found\`, \`storyboard_empty\`, \`capture_timeout\`, \`capture_threw\`, \`canvas_mismatch\`, \`capture_unsupported\`) \u2014 one try per storyboard. Don't retry, don't broaden to other storyboards, don't fire a second wave. **One exception:** a route storyboard's \`capture_threw\` "could not be cold-captured" means the app dev server isn't running \u2014 call \`start_app_dev_server\` once, then a single retry is warranted (better, pre-flight per the route-storyboard rule above so it never fails).
82151
82152
  - If you need to understand the failure, call \`canvas_debug({ canvas_slug, storyboard? })\` once and inspect the diagnostics instead of repeatedly calling \`canvas_screenshot\`.
82152
82153
  - \`canvas_verify_vrt\` adds its own typed errors, also one try each: \`storyboard_not_tested\` (add a literal \`vrt\` prop first), \`storyboard_paused\` (remove \`skip: true\` before verifying), \`storyboard_unsupported\` (route storyboards are not verified \u2014 component and local HTML storyboards only), \`storyboard_invalid\` (parse error, or \`vrt.ignore\` masks \u226590% of the board), \`capture_incomplete\` / \`compare_failed\` (the batch or the pixel comparison broke \u2014 \`canvas_debug\` once), \`determinism_setup_failed\` (the browser could not install frozen clocks/timezone \u2014 an environment problem, not the storyboard's). An \`unstable\` verdict is NOT an error: fix the nondeterministic input and rerun.
@@ -83318,7 +83319,7 @@ ${assetLibrarySection}## Hard invariants
83318
83319
  }
83319
83320
 
83320
83321
  // ../canvas-mcp/tools.ts
83321
- import { realpath as realpath13, writeFile as writeFile14 } from "fs/promises";
83322
+ import { readFile as readFile41, realpath as realpath13, writeFile as writeFile14 } from "fs/promises";
83322
83323
  import path81 from "path";
83323
83324
 
83324
83325
  // ../asset-libraries/mcp/tools.ts
@@ -88059,9 +88060,6 @@ function registerMembershipTool(server, context, tool) {
88059
88060
  );
88060
88061
  }
88061
88062
 
88062
- // ../canvas-tools/commands/compute-layout.ts
88063
- import path63 from "path";
88064
-
88065
88063
  // ../canvas-pages/codegen.ts
88066
88064
  import path43 from "path";
88067
88065
 
@@ -88519,7 +88517,7 @@ var MissingRootDepsError = class extends TempoDevServerError {
88519
88517
  // ../tempo-sdk/package.json
88520
88518
  var package_default = {
88521
88519
  name: "tempo-sdk",
88522
- version: "0.0.94",
88520
+ version: "0.0.99",
88523
88521
  publishConfig: {
88524
88522
  tag: "sdk-v2-latest"
88525
88523
  },
@@ -99745,6 +99743,7 @@ var TempoDevServer = class _TempoDevServer {
99745
99743
  // can surface its stdout/stderr tail (diagnostics) without threading the
99746
99744
  // local `process` var out of `startDevServer`.
99747
99745
  this.activeHostProcess = null;
99746
+ this.hostStartGeneration = 0;
99748
99747
  // The `flutter run` daemon beside the host when canvases declare previews (specs/flutter-storyboard-rendering.md §4). Created by the first
99749
99748
  // startDevServer, kept across the host's crash retries, stopped with the
99750
99749
  // host handle and on dispose.
@@ -99883,6 +99882,45 @@ var TempoDevServer = class _TempoDevServer {
99883
99882
  }
99884
99883
  };
99885
99884
  }
99885
+ /** Read-only proof for starting a local Vite host alongside a canvas scan. */
99886
+ async canStartDevServerDuringPreparation() {
99887
+ const hasCustomHostLifecycle = this.config.tempoHostUrl !== null || Boolean(this.config.scripts.stop?.trim()) || Boolean(this.config.scripts.updateSdk?.trim());
99888
+ if (hasCustomHostLifecycle || !this.state.dependenciesInstalled)
99889
+ return false;
99890
+ const processStatus = this.currentProcessStatus();
99891
+ if (processStatus === "running" || processStatus === "starting")
99892
+ return false;
99893
+ if (!looksLikeGeneratedInstallScript(
99894
+ this.config.scripts.install,
99895
+ path26.relative(this.projectRoot, this.appRoot).split(path26.sep).join("/")
99896
+ ))
99897
+ return false;
99898
+ if (await this.resolveStartFramework() !== "vite") return false;
99899
+ const pkg = await readJsonFile(
99900
+ path26.join(this.tempoRoot, "package.json")
99901
+ );
99902
+ let command = this.config.scripts.start.trim();
99903
+ const scriptInvocation = /^(?:npm|pnpm|bun|yarn)[ \t]+run[ \t]+([\w:-]+)$/.exec(command);
99904
+ const scriptShorthand = /^(?:pnpm|yarn)[ \t]+(dev|start)$/.exec(command);
99905
+ const scriptName = scriptInvocation?.[1] ?? scriptShorthand?.[1];
99906
+ if (scriptName) {
99907
+ const hasLifecycleHooks = pkg?.scripts?.[`pre${scriptName}`] || pkg?.scripts?.[`post${scriptName}`];
99908
+ if (hasLifecycleHooks) return false;
99909
+ const script = pkg?.scripts?.[scriptName];
99910
+ command = typeof script === "string" ? script.trim() : "";
99911
+ }
99912
+ const isLocalViteCommand = /^vite(?:[ \t]+[\w./:=@-]+)*$/.test(command) && !/^vite[ \t]+(?:build|preview|optimize)\b/.test(command);
99913
+ if (!isLocalViteCommand) return false;
99914
+ if (!await pathExists2(
99915
+ path26.join(this.tempoRoot, "node_modules", "vite", "package.json")
99916
+ ))
99917
+ return false;
99918
+ const [tempoReady, appReady] = await Promise.all([
99919
+ this.tempoInstallReady(),
99920
+ this.appSideInstallReady()
99921
+ ]);
99922
+ return this.state.dependenciesInstalled && tempoReady && appReady;
99923
+ }
99886
99924
  // The single source of host liveness. A held, signalable child is authority
99887
99925
  // for foreground starts; after a clean daemonizing launcher exits, the
99888
99926
  // retained host handle switches authority to the HTTP probe. Terminal
@@ -100020,6 +100058,7 @@ var TempoDevServer = class _TempoDevServer {
100020
100058
  );
100021
100059
  }
100022
100060
  throwIfLaunchAborted(options2?.signal);
100061
+ const startGeneration = ++this.hostStartGeneration;
100023
100062
  const startDialectIssue = findPowerShellSyntax(this.config.scripts.start);
100024
100063
  if (startDialectIssue) {
100025
100064
  t.done({ ok: false, reason: "start_shell_dialect_mismatch" });
@@ -100072,21 +100111,24 @@ var TempoDevServer = class _TempoDevServer {
100072
100111
  });
100073
100112
  void this.releaseNextDistDirClaim();
100074
100113
  }
100075
- if (this.activeHostProcess === activeProcess) {
100114
+ const ownsSupervisor = this.activeHostProcess === activeProcess;
100115
+ if (ownsSupervisor) {
100076
100116
  this.activeHostProcess = null;
100077
100117
  }
100078
100118
  if (process2 !== activeProcess) {
100079
100119
  return;
100080
100120
  }
100081
- this.devserverExternalRuntimePending = false;
100082
- this.state.devserverUrl = null;
100083
- this.state.urlUnreachableSince = null;
100084
- this.idleProcessStatus = "exited";
100085
- this.stopUrlHealthProbe();
100086
100121
  this.removeProcessMarkerForPid(activeProcess.getPid()).catch(() => {
100087
100122
  });
100088
- this.persistStatus().catch(() => {
100089
- });
100123
+ if (ownsSupervisor) {
100124
+ this.devserverExternalRuntimePending = false;
100125
+ this.state.devserverUrl = null;
100126
+ this.state.urlUnreachableSince = null;
100127
+ this.idleProcessStatus = "exited";
100128
+ this.stopUrlHealthProbe();
100129
+ this.persistStatus().catch(() => {
100130
+ });
100131
+ }
100090
100132
  for (const listener of exitListeners) {
100091
100133
  listener(code, signal, crashed, reason, intentional);
100092
100134
  }
@@ -100115,6 +100157,12 @@ var TempoDevServer = class _TempoDevServer {
100115
100157
  attemptedPorts.add(startPlan.injectedPort);
100116
100158
  throwIfLaunchAborted(options2?.signal);
100117
100159
  const expectedIdentity = await this.readExpectedHostIdentity();
100160
+ const nuxtEnv = await this.isNuxtTempoHost() ? nuxtSocketTmpdirEnv() : {};
100161
+ const nuxtNodePathEnv = await this.nuxtSidecarNodePathEnv();
100162
+ const watchdogScriptPath = await this.ensureDevserverWatchdogScript();
100163
+ throwIfLaunchAborted(options2?.signal);
100164
+ if (this.hostStartGeneration !== startGeneration)
100165
+ throw launchAbortError();
100118
100166
  const stopCommand = this.config.scripts.stop ? substituteAppPort(this.config.scripts.stop, startPlan.injectedPort) : null;
100119
100167
  this.devserverStopCommand = stopCommand;
100120
100168
  this.devserverLaunchPort = startPlan.injectedPort;
@@ -100144,9 +100192,9 @@ var TempoDevServer = class _TempoDevServer {
100144
100192
  extraEnv: {
100145
100193
  // Nuxt 4.4.7's vite-node socket under macOS's TMPDIR passes the
100146
100194
  // Unix socket path limit (see nuxt-socket-tmpdir.ts).
100147
- ...await this.isNuxtTempoHost() ? nuxtSocketTmpdirEnv() : {},
100195
+ ...nuxtEnv,
100148
100196
  // The app's pnpm hoist dir, for its undeclared config imports.
100149
- ...await this.nuxtSidecarNodePathEnv(),
100197
+ ...nuxtNodePathEnv,
100150
100198
  ...startPlan.env,
100151
100199
  // Scoped to this canvas host. The SDK uses this to retire the old
100152
100200
  // all-canvas optimizer glob in memory, preserving the user's file.
@@ -100160,7 +100208,7 @@ var TempoDevServer = class _TempoDevServer {
100160
100208
  // then forwarded, or the typed 503 once Flutter has failed.
100161
100209
  ...this.flutterDevServer ? { TEMPO_FLUTTER_URL: this.flutterDevServer.url } : {}
100162
100210
  },
100163
- watchdogScriptPath: await this.ensureDevserverWatchdogScript(),
100211
+ watchdogScriptPath,
100164
100212
  projectNode: toProjectNodeEnvOption(this.projectNodeOverride)
100165
100213
  });
100166
100214
  process2 = activeProcess;
@@ -100321,7 +100369,15 @@ var TempoDevServer = class _TempoDevServer {
100321
100369
  restartingForFlutter = false;
100322
100370
  }
100323
100371
  };
100372
+ let readinessCancelled = false;
100373
+ const assertReadinessOwnership = () => {
100374
+ throwIfLaunchAborted(options2?.signal);
100375
+ if (readinessCancelled || self2.hostStartGeneration !== startGeneration) {
100376
+ throw launchAbortError();
100377
+ }
100378
+ };
100324
100379
  const stopActiveProcess = async () => {
100380
+ readinessCancelled = true;
100325
100381
  self2.stopUrlHealthProbe();
100326
100382
  await Promise.all([process2.terminate(), self2.stopFlutterDevServer()]);
100327
100383
  await self2.releaseNextDistDirClaim();
@@ -100384,6 +100440,7 @@ var TempoDevServer = class _TempoDevServer {
100384
100440
  await stopActiveProcess();
100385
100441
  },
100386
100442
  forceKill() {
100443
+ readinessCancelled = true;
100387
100444
  self2.flutterHostActive = false;
100388
100445
  self2.restartHostForFlutter = null;
100389
100446
  self2.flutterChangedPaths.clear();
@@ -100397,7 +100454,13 @@ var TempoDevServer = class _TempoDevServer {
100397
100454
  self2.idleProcessStatus = "stopped";
100398
100455
  },
100399
100456
  async waitUntilReady(timeoutMs) {
100400
- let result2 = await process2.waitUntilReady(timeoutMs);
100457
+ const owned = async (pending) => {
100458
+ const value = await pending;
100459
+ assertReadinessOwnership();
100460
+ return value;
100461
+ };
100462
+ assertReadinessOwnership();
100463
+ let result2 = await owned(process2.waitUntilReady(timeoutMs));
100401
100464
  self2.recordStartAttempt({
100402
100465
  at: Date.now(),
100403
100466
  kind: "initial",
@@ -100431,9 +100494,10 @@ var TempoDevServer = class _TempoDevServer {
100431
100494
  } else if (nodeToolchainRetry) {
100432
100495
  nodeToolchainRetriesUsed += 1;
100433
100496
  setBundledNodeActivated(true);
100434
- self2.projectNodeOverride = await resolveProjectNodeOverrideForDir(
100435
- self2.tempoRoot
100497
+ const nodeOverride = await owned(
100498
+ resolveProjectNodeOverrideForDir(self2.tempoRoot)
100436
100499
  );
100500
+ self2.projectNodeOverride = nodeOverride;
100437
100501
  devLog("supervisor:node_toolchain_retry", {
100438
100502
  command: self2.config.scripts.start,
100439
100503
  bundledNodeBinDir: getBundledNodeBinDir()
@@ -100442,19 +100506,29 @@ var TempoDevServer = class _TempoDevServer {
100442
100506
  crashRetriesUsed += 1;
100443
100507
  }
100444
100508
  self2.stopUrlHealthProbe();
100445
- await process2.terminate();
100446
- await self2.removeProcessMarkerForPid(process2.getPid()).catch(() => {
100447
- });
100509
+ await owned(process2.terminate());
100510
+ await owned(
100511
+ self2.removeProcessMarkerForPid(process2.getPid()).catch(() => {
100512
+ })
100513
+ );
100448
100514
  if (lockConflictSidestep) {
100449
- self2.nextDistDir = await self2.selectSuffixedNextDistDir();
100515
+ const distDir = await owned(self2.selectSuffixedNextDistDir());
100516
+ self2.nextDistDir = distDir;
100450
100517
  devLog("supervisor:next_dist_dir_suffixed", {
100451
100518
  distDir: self2.nextDistDir,
100452
100519
  reason: "observed-live-lock",
100453
100520
  tempoRoot: self2.tempoRoot
100454
100521
  });
100455
100522
  }
100456
- process2 = await spawnProcess(attempt);
100457
- result2 = await process2.waitUntilReady(timeoutMs);
100523
+ const spawned = await spawnProcess(attempt);
100524
+ try {
100525
+ assertReadinessOwnership();
100526
+ } catch (error) {
100527
+ await spawned.terminate();
100528
+ throw error;
100529
+ }
100530
+ process2 = spawned;
100531
+ result2 = await owned(process2.waitUntilReady(timeoutMs));
100458
100532
  self2.recordStartAttempt({
100459
100533
  at: Date.now(),
100460
100534
  kind: portCollision ? "port-retry" : lockConflictSidestep ? "lock-sidestep-retry" : nodeToolchainRetry ? "node-toolchain-retry" : "crash-retry",
@@ -100473,29 +100547,36 @@ var TempoDevServer = class _TempoDevServer {
100473
100547
  const shellPid = process2.getPid();
100474
100548
  if (shellPid) {
100475
100549
  const workerPids = new Set(
100476
- await resolveDescendantPids(shellPid).catch(() => [])
100550
+ await owned(resolveDescendantPids(shellPid).catch(() => []))
100477
100551
  );
100478
100552
  const readyPort = portFromReadyUrl(result2.url);
100479
100553
  if (readyPort != null) {
100480
- const listenerPid = await findPortListenerPid(readyPort).catch(
100481
- () => null
100554
+ const listenerPid = await owned(
100555
+ findPortListenerPid(readyPort).catch(() => null)
100482
100556
  );
100483
100557
  if (listenerPid != null && workerPids.has(listenerPid)) {
100484
100558
  self2.devserverLaunchPid = listenerPid;
100485
- self2.devserverLaunchProcessStartedAt = await readProcessStartedAt(listenerPid);
100559
+ const processStartedAt = await owned(
100560
+ readProcessStartedAt(listenerPid)
100561
+ );
100562
+ self2.devserverLaunchProcessStartedAt = processStartedAt;
100486
100563
  }
100487
100564
  }
100488
- await self2.writeProcessMarker(shellPid, [...workerPids]).catch(() => {
100489
- });
100565
+ await owned(
100566
+ self2.writeProcessMarker(shellPid, [...workerPids]).catch(() => {
100567
+ })
100568
+ );
100490
100569
  }
100491
- await self2.persistStatus();
100570
+ await owned(self2.persistStatus());
100492
100571
  self2.startUrlHealthProbe(result2.url);
100493
100572
  t.done({ ok: true, url: result2.url, pid: result2.pid });
100494
100573
  } else {
100495
100574
  self2.stopUrlHealthProbe();
100496
- await process2.terminate();
100497
- await self2.removeProcessMarkerForPid(process2.getPid()).catch(() => {
100498
- });
100575
+ await owned(process2.terminate());
100576
+ await owned(
100577
+ self2.removeProcessMarkerForPid(process2.getPid()).catch(() => {
100578
+ })
100579
+ );
100499
100580
  self2.idleProcessStatus = "error";
100500
100581
  const finalConflict = parseDevServerLockConflict(
100501
100582
  process2.getRecentOutputTail()
@@ -100533,8 +100614,8 @@ var TempoDevServer = class _TempoDevServer {
100533
100614
  };
100534
100615
  }
100535
100616
  self2.state.lastError = result2.message ?? "Canvas dev server failed to become ready";
100536
- await self2.persistStatus().catch(() => {
100537
- });
100617
+ await owned(self2.persistStatus().catch(() => {
100618
+ }));
100538
100619
  t.done({
100539
100620
  ok: false,
100540
100621
  reason: "not_ready",
@@ -102580,6 +102661,7 @@ async function nodeModulesHasMeaningfulEntries(packageRoot) {
102580
102661
  }
102581
102662
  function looksLikeGeneratedInstallScript(command, appDir) {
102582
102663
  const normalized = command.trim();
102664
+ if (normalized === "npm install && npm install --prefix ..") return true;
102583
102665
  const installCommand = "(?:npm\\s+(?:install|ci)|pnpm\\s+install(?:\\s+--(?:no-)?frozen-lockfile)?|yarn\\s+install(?:\\s+--immutable)?|bun\\s+install)";
102584
102666
  const appFolder = "[\\w@-][\\w@.-]*(?:/[\\w@-][\\w@.-]*)*";
102585
102667
  const backToTempo = "(?:\\.\\./)+tempo";
@@ -116611,6 +116693,12 @@ var TempoProject = class _TempoProject {
116611
116693
  const devserver = await this.getDevServer(config);
116612
116694
  return await devserver.startDevServer(options2);
116613
116695
  }
116696
+ async canStartDevServerDuringPreparation() {
116697
+ const config = await this.getResolvedConfig();
116698
+ if (config.apps[0]?.uiFramework === "flutter") return false;
116699
+ const devserver = await this.getDevServer(config);
116700
+ return await devserver.canStartDevServerDuringPreparation();
116701
+ }
116614
116702
  async getAppDevServerLaunchPlan() {
116615
116703
  return await analyzeProject(this.projectRoot);
116616
116704
  }
@@ -117767,7 +117855,7 @@ function createQueuedFileEditor() {
117767
117855
  };
117768
117856
  return runAtIndex(0);
117769
117857
  }
117770
- async function readFile41(absolutePath) {
117858
+ async function readFile42(absolutePath) {
117771
117859
  return withFileLock(absolutePath, () => readFileUnlocked(absolutePath));
117772
117860
  }
117773
117861
  async function readBinaryFile(absolutePath) {
@@ -117853,7 +117941,7 @@ function createQueuedFileEditor() {
117853
117941
  });
117854
117942
  }
117855
117943
  return {
117856
- readFile: readFile41,
117944
+ readFile: readFile42,
117857
117945
  readBinaryFile,
117858
117946
  readFileIfExists,
117859
117947
  writeFile: writeFile15,
@@ -117865,7 +117953,7 @@ function createQueuedFileEditor() {
117865
117953
  unlinkFile,
117866
117954
  withFileLock,
117867
117955
  withFileLocks,
117868
- readWorkspaceFile: (workspacePath, relativePath) => readFile41(resolveWorkspaceRelativePath(workspacePath, relativePath)),
117956
+ readWorkspaceFile: (workspacePath, relativePath) => readFile42(resolveWorkspaceRelativePath(workspacePath, relativePath)),
117869
117957
  readWorkspaceFileIfExists: (workspacePath, relativePath) => readFileIfExists(
117870
117958
  resolveWorkspaceRelativePath(workspacePath, relativePath)
117871
117959
  ),
@@ -119535,7 +119623,8 @@ async function findInstalledPackageDir2(fromDir, packageName) {
119535
119623
  }
119536
119624
  }
119537
119625
  async function scaffoldCanvasLocalStubs(storyboards, pageDir, uiFramework) {
119538
- const written = [];
119626
+ const written = /* @__PURE__ */ new Set();
119627
+ const stubbed = /* @__PURE__ */ new Set();
119539
119628
  for (const storyboard of storyboards) {
119540
119629
  if (!storyboard.importPath) continue;
119541
119630
  const framework = storyboardFrameworkForImport(
@@ -119548,6 +119637,10 @@ async function scaffoldCanvasLocalStubs(storyboards, pageDir, uiFramework) {
119548
119637
  framework
119549
119638
  );
119550
119639
  if (!stubPath) continue;
119640
+ if (written.has(stubPath)) {
119641
+ stubbed.add(storyboard.exportName);
119642
+ continue;
119643
+ }
119551
119644
  if (await pathExists11(stubPath)) continue;
119552
119645
  await mkdir13(path49.dirname(stubPath), { recursive: true });
119553
119646
  await queuedFileEditor.writeFile(
@@ -119557,9 +119650,10 @@ async function scaffoldCanvasLocalStubs(storyboards, pageDir, uiFramework) {
119557
119650
  storyboard.importName
119558
119651
  )
119559
119652
  );
119560
- written.push(stubPath);
119653
+ written.add(stubPath);
119654
+ stubbed.add(storyboard.exportName);
119561
119655
  }
119562
- return written;
119656
+ return stubbed;
119563
119657
  }
119564
119658
  async function markCanvasAsHome(filePath) {
119565
119659
  const source = await readFile32(filePath, "utf-8");
@@ -119649,7 +119743,11 @@ async function createPage(options2) {
119649
119743
  });
119650
119744
  await mkdir13(pageDir, { recursive: true });
119651
119745
  await queuedFileEditor.writeFile(pageFile, pageFileContent);
119652
- await scaffoldCanvasLocalStubs(storyboardDefs, pageDir, uiFramework);
119746
+ const stubbed = await scaffoldCanvasLocalStubs(
119747
+ storyboardDefs,
119748
+ pageDir,
119749
+ uiFramework
119750
+ );
119653
119751
  return {
119654
119752
  projectRoot,
119655
119753
  pageDir,
@@ -119660,7 +119758,8 @@ async function createPage(options2) {
119660
119758
  x: storyboard.x,
119661
119759
  y: storyboard.y,
119662
119760
  width: positions[index].width,
119663
- height: positions[index].height
119761
+ height: positions[index].height,
119762
+ ...stubbed.has(storyboard.exportName) ? { stub: true } : {}
119664
119763
  })),
119665
119764
  initResult
119666
119765
  };
@@ -122479,6 +122578,9 @@ function formatAlternatives2(items) {
122479
122578
  return `${items.slice(0, -1).join(", ")}, or ${items[items.length - 1]}`;
122480
122579
  }
122481
122580
 
122581
+ // ../canvas-tools/commands/compute-layout.ts
122582
+ import path63 from "path";
122583
+
122482
122584
  // ../canvas-tools/commands/utils.ts
122483
122585
  import { readdir as readdir16, stat as stat16 } from "fs/promises";
122484
122586
  import path62 from "path";
@@ -122574,7 +122676,8 @@ async function runCreatePageCommand(args) {
122574
122676
  x: storyboard.x,
122575
122677
  y: storyboard.y,
122576
122678
  width: storyboard.width,
122577
- height: storyboard.height
122679
+ height: storyboard.height,
122680
+ ...storyboard.stub ? { stub: true } : {}
122578
122681
  }))
122579
122682
  };
122580
122683
  }
@@ -122990,14 +123093,14 @@ async function collectAssetDeclarationIssues(options2) {
122990
123093
  canvasesDir: options2.canvasesDir
122991
123094
  });
122992
123095
  const referenced = /* @__PURE__ */ new Set();
122993
- const readFile41 = (file) => {
123096
+ const readFile42 = (file) => {
122994
123097
  try {
122995
123098
  return readFileSync4(path71.join(options2.workspaceRoot, file), "utf8");
122996
123099
  } catch {
122997
123100
  return null;
122998
123101
  }
122999
123102
  };
123000
- const canvasSource = readFile41(`${canvasFolderRel}/index.canvas.tsx`);
123103
+ const canvasSource = readFile42(`${canvasFolderRel}/index.canvas.tsx`);
123001
123104
  if (canvasSource) {
123002
123105
  const { program } = parseAssetProgram(
123003
123106
  `${canvasFolderRel}/index.canvas.tsx`,
@@ -123009,7 +123112,7 @@ async function collectAssetDeclarationIssues(options2) {
123009
123112
  ).referenceableImports.values()) {
123010
123113
  const identityPath = imported.importSpecifier.startsWith(".") ? resolveRelativeImport(canvasFolderRel, imported.importSpecifier) : `pkg:${imported.importSpecifier}`;
123011
123114
  const identity2 = resolveComponentIdentity(
123012
- { readFile: readFile41 },
123115
+ { readFile: readFile42 },
123013
123116
  identityPath,
123014
123117
  imported.importedName,
123015
123118
  `${canvasFolderRel}/index.canvas.tsx`
@@ -123129,7 +123232,7 @@ import path79 from "path";
123129
123232
  var PROJECTION_PENDING_ATTRIBUTE = "data-tempo-projection-pending";
123130
123233
 
123131
123234
  // ../tempo-sdk/canvas/client-protocol.ts
123132
- var CANVAS_CLIENT_PROTOCOL = 2;
123235
+ var CANVAS_CLIENT_PROTOCOL = 3;
123133
123236
  var CANVAS_CLIENT_PROTOCOL_PARAM = "canvasProtocol";
123134
123237
 
123135
123238
  // ../../modules/component-render-pool/direct-render.ts
@@ -137817,6 +137920,9 @@ async function normalizeCanvasSlug(input, workspaceRoot) {
137817
137920
  return value;
137818
137921
  }
137819
137922
  async function canvasWorkIdentity(context, input) {
137923
+ return (await resolveCanvasWork(context, input)).identity;
137924
+ }
137925
+ async function resolveCanvasWork(context, input) {
137820
137926
  const root3 = path81.resolve(context.workspaceRoot, context.canvasesDir);
137821
137927
  let slug = input.trim().replace(/\\/g, "/").replace(/\/index\.canvas\.tsx$/, "").replace(/\/$/, "");
137822
137928
  const workspaceCandidate = path81.resolve(context.workspaceRoot, slug);
@@ -137829,24 +137935,35 @@ async function canvasWorkIdentity(context, input) {
137829
137935
  );
137830
137936
  }
137831
137937
  let dir;
137938
+ let canvasFile = null;
137832
137939
  try {
137833
- dir = path81.dirname(
137834
- await resolveCanvasFile({
137835
- workspaceRoot: context.workspaceRoot,
137836
- canvasesDir: root3,
137837
- canvasSlug: slug
137838
- })
137839
- );
137940
+ canvasFile = await resolveCanvasFile({
137941
+ workspaceRoot: context.workspaceRoot,
137942
+ canvasesDir: root3,
137943
+ canvasSlug: slug
137944
+ });
137945
+ dir = path81.dirname(canvasFile);
137840
137946
  } catch (error) {
137841
137947
  if (!(error instanceof StoryboardStabilityTargetError && error.code === "canvas_not_found") && error.code !== "ENOENT")
137842
137948
  throw error;
137843
137949
  dir = path81.join(root3, slug.includes("/") ? slug : `canvases/${slug}`);
137844
137950
  }
137845
137951
  return {
137846
- canvas_slug: path81.relative(root3, dir).replace(/\\/g, "/"),
137847
- canvas_dir: dir
137952
+ identity: {
137953
+ canvas_slug: path81.relative(root3, dir).replace(/\\/g, "/"),
137954
+ canvas_dir: dir
137955
+ },
137956
+ canvasFile
137848
137957
  };
137849
137958
  }
137959
+ async function openCanvasInSplitView(context, canvasFile) {
137960
+ if (!context.canvasSplitView) return false;
137961
+ try {
137962
+ return await context.canvasSplitView.open({ canvasFile });
137963
+ } catch {
137964
+ return false;
137965
+ }
137966
+ }
137850
137967
  var PREVIEW_CAPTURE_TIMEOUT_MS = 6e4;
137851
137968
  async function capturePreviewSnapshot(context, canvasSlug) {
137852
137969
  if (!context.canvasPreviewCapture) return {};
@@ -137939,7 +138056,7 @@ function withCreateCanvasDefaults(args, context) {
137939
138056
  function registerTools(server, context) {
137940
138057
  server.tool(
137941
138058
  "canvas_create",
137942
- "Create a new canvas under the project's canvases root (`paths.canvases` in tempo.config.json \u2014 canonically `tempo/designs`). A plain `canvas_name` creates a FREEFORM canvas at `<root>/canvases/<slug>`; a `/`-separated name is an explicit path under the root and is how you create INTO a zone \u2014 e.g. `\"design-system/Badges\"` \u2192 `<root>/design-system/badges`, `\"libraries/ios/Buttons\"` \u2192 `<root>/libraries/ios/buttons`. Zone canvases (design-system/**, libraries/**) must declare their showcased components via defineAsset or `canvas_validate` fails with `missing_asset_declaration`. **MUTATING.** **Call `start_working_on_canvas({ canvas_slug })` FIRST** to announce canvas activity. Use `start_working_on_storyboard` / `finish_working_on_storyboard` around each frame; normal live updates remain visible. Reuse pre-created onboarding canvases instead of recreating them. Do NOT mkdir the canvas directory or Write any files into it beforehand \u2014 this tool creates the directory itself; put canvas-local helper files inside the returned `canvas_dir` AFTER it succeeds. The scaffolded `<Canvas backgroundColor>` is the user's theme backdrop: keep it as-is when you edit the canvas \u2014 never change or remove it unless the user explicitly asks. Returns `{ canvas_dir, canvas_file, storyboards: [{export_name, x, y, width, height}] }`. Width/height describe the box to reserve on the canvas; a component storyboard's real size is its root element's. Use a local StoryboardN.tsx default export with one root carrying size through className/style, wrapping the app component in a div if needed. Component layout uses only x/y and optional zIndex; route and HTML layouts require width/height. Run `canvas_validate` afterward to surface unresolved-import / missing-package / type errors.",
138059
+ "Create a new canvas under the project's canvases root (`paths.canvases` in tempo.config.json \u2014 canonically `tempo/designs`). A plain `canvas_name` creates a FREEFORM canvas at `<root>/canvases/<slug>`; a `/`-separated name is an explicit path under the root and is how you create INTO a zone \u2014 e.g. `\"design-system/Badges\"` \u2192 `<root>/design-system/badges`, `\"libraries/ios/Buttons\"` \u2192 `<root>/libraries/ios/buttons`. Zone canvases (design-system/**, libraries/**) must declare their showcased components via defineAsset or `canvas_validate` fails with `missing_asset_declaration`. **MUTATING.** **Call `start_working_on_canvas({ canvas_slug })` FIRST** to announce canvas activity. Opens the new canvas in this chat's split view; `opened: true` means no `open_in_split_view` call is needed. Use `start_working_on_storyboard` / `finish_working_on_storyboard` around each frame; normal live updates remain visible. Reuse pre-created onboarding canvases instead of recreating them. Do NOT mkdir the canvas directory or Write any files into it beforehand \u2014 this tool creates the directory itself; put canvas-local helper files inside the returned `canvas_dir` AFTER it succeeds. The scaffolded `<Canvas backgroundColor>` is the user's theme backdrop: keep it as-is when you edit the canvas \u2014 never change or remove it unless the user explicitly asks. Returns `{ canvas_dir, canvas_file, storyboards: [{export_name, x, y, width, height, stub?}], opened }`. Width/height describe the box to reserve on the canvas; a component storyboard's real size is its root element's. A canvas-local `import_path` with no file yet is scaffolded as an empty stub (`stub: true`): its frame shows as work in progress at that width/height until you finish it with `finish_working_on_storyboard` or finish the canvas, so write the component, then finish the frame. Use a local StoryboardN.tsx default export with one root carrying size through className/style, wrapping the app component in a div if needed. Component layout uses only x/y and optional zIndex; route and HTML layouts require width/height. Run `canvas_validate` afterward to surface unresolved-import / missing-package / type errors.",
137943
138060
  {
137944
138061
  canvas_name: z29.string().describe(
137945
138062
  'Friendly canvas name (e.g. `"Auth Components"`). The folder slug is derived from this.'
@@ -137965,11 +138082,16 @@ function registerTools(server, context) {
137965
138082
  source: "mcp",
137966
138083
  storyboard_type: "create-canvas"
137967
138084
  });
138085
+ const opened = await openCanvasInSplitView(
138086
+ context,
138087
+ result2.canvas_file
138088
+ );
137968
138089
  const isHome = args.home === true;
137969
- const output = isHome ? {
138090
+ const output = {
137970
138091
  ...result2,
137971
- home_canvas: { marked: true }
137972
- } : result2;
138092
+ ...isHome ? { home_canvas: { marked: true } } : {},
138093
+ opened
138094
+ };
137973
138095
  const createArgs = args;
137974
138096
  const hasRouteStoryboard = (createArgs.storyboards ?? []).some(
137975
138097
  (s) => typeof s.route === "string" && s.route.trim().length > 0
@@ -138522,15 +138644,21 @@ function registerTools(server, context) {
138522
138644
  };
138523
138645
  server.tool(
138524
138646
  "start_working_on_canvas",
138525
- "Begin a canvas editing session. Turns on this canvas's activity indicator in tabs/sidebar; does not shimmer storyboards or freeze live rendering. Call before canvas_create or the first edit. Reuse an existing onboarding canvas. Use start_working_on_storyboard for each frame you work on. Pair with finish_working_on_canvas once the full task is verified. Takes only a canvas, never a storyboard.",
138647
+ "Begin a canvas editing session. Call it FIRST, the moment you decide to create or edit a canvas, before reading files or planning, and before canvas_create. Turns on this canvas's activity indicator in tabs/sidebar; does not shimmer storyboards or freeze live rendering. If the canvas exists, opens it in this chat's split view (`opened: true`; no `open_in_split_view` call needed); canvas_create opens a new one. Reuse an existing onboarding canvas. Use start_working_on_storyboard for each frame you work on. Pair with finish_working_on_canvas once the full task is verified. Takes only a canvas, never a storyboard.",
138526
138648
  canvasWorkSchema,
138527
138649
  async ({ canvas_slug }) => {
138528
138650
  try {
138529
- const identity2 = await canvasWorkIdentity(context, canvas_slug);
138651
+ const { identity: identity2, canvasFile } = await resolveCanvasWork(
138652
+ context,
138653
+ canvas_slug
138654
+ );
138530
138655
  await context.canvasEditingState?.start({
138531
138656
  canvasSlug: identity2.canvas_slug
138532
138657
  });
138533
- return textResult2(JSON.stringify({ ...identity2, editing: true }));
138658
+ const opened = canvasFile ? await openCanvasInSplitView(context, canvasFile) : false;
138659
+ return textResult2(
138660
+ JSON.stringify({ ...identity2, editing: true, opened })
138661
+ );
138534
138662
  } catch (error) {
138535
138663
  return errorResult9(String(error));
138536
138664
  }
@@ -138574,12 +138702,23 @@ function registerTools(server, context) {
138574
138702
  },
138575
138703
  async ({ canvas_slug, storyboard, layout }) => {
138576
138704
  try {
138705
+ const { identity: identity2, canvasFile } = await resolveCanvasWork(
138706
+ context,
138707
+ canvas_slug
138708
+ );
138709
+ const existingStoryboards = !layout && canvasFile ? parsePageSource(canvasFile, await readFile41(canvasFile, "utf8")).storyboards : [];
138710
+ const isNewFrame = !layout && !existingStoryboards.some(
138711
+ (candidate) => candidate.storyboardKey === storyboard || candidate.exportName === storyboard
138712
+ );
138577
138713
  return textResult2(
138578
138714
  JSON.stringify({
138579
- ...await canvasWorkIdentity(context, canvas_slug),
138715
+ ...identity2,
138580
138716
  storyboard,
138581
138717
  editing: true,
138582
- ...layout ? { layout } : {}
138718
+ ...layout ? { layout } : {},
138719
+ ...isNewFrame ? {
138720
+ warning: `Storyboard "${storyboard}" is not in the canvas yet. Call again with layout: { x, y, width, height } so its placeholder has the frame's planned size.`
138721
+ } : {}
138583
138722
  })
138584
138723
  );
138585
138724
  } catch (error) {
@@ -139038,7 +139177,7 @@ function unsupportedEnvironmentResult(hookName) {
139038
139177
  );
139039
139178
  }
139040
139179
  var ROUTE_SNAPSHOT_NEXT_STEP = {
139041
- canvas_not_open: 'Open the canvas with open_in_split_view({ type: "canvas", path }) so a Design view shows it, then retry once.',
139180
+ canvas_not_open: 'Open the canvas with open_in_split_view({ type: "canvas", path }) so a canvas tab shows it, then retry once.',
139042
139181
  ambiguous_canvas_slug: "Retry with the root-relative path of the canvas you mean.",
139043
139182
  storyboard_not_found: "Retry with one of the canvas's storyboard ids, or add the RouteStoryboard first.",
139044
139183
  not_route_storyboard: "Only a <RouteStoryboard> has a live page to snapshot. Add one for the URL and snapshot that.",
@@ -139147,7 +139286,7 @@ function buildBackends(runtime, toolsets, workspace) {
139147
139286
  }
139148
139287
 
139149
139288
  // src/version.ts
139150
- var CLI_VERSION = "0.0.142";
139289
+ var CLI_VERSION = "0.0.143-staging.1";
139151
139290
 
139152
139291
  // src/canvas-hooks.ts
139153
139292
  var import_pngjs4 = __toESM(require_png(), 1);
@@ -140386,4 +140525,4 @@ unpdf/dist/index.mjs:
140386
140525
  * @license Apache-2.0
140387
140526
  *)
140388
140527
  */
140389
- //# sourceMappingURL=serve-AK3XOBT4.js.map
140528
+ //# sourceMappingURL=serve-PIPVSKEN.js.map