@1agh/maude 2.1.1 → 2.1.2

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.
Files changed (70) hide show
  1. package/apps/studio/actions/agents.ts +18 -42
  2. package/apps/studio/actions/verbs.ts +49 -0
  3. package/apps/studio/actions.manifest.json +103 -19
  4. package/apps/studio/ai/create-claim.ts +1 -1
  5. package/apps/studio/bin/_asset-file.mjs +117 -0
  6. package/apps/studio/bin/_canvas-file.mjs +146 -0
  7. package/apps/studio/bin/_footage.mjs +123 -0
  8. package/apps/studio/bin/_pdf-playwright.mjs +14 -0
  9. package/apps/studio/bin/_png-playwright.mjs +15 -1
  10. package/apps/studio/bin/_pw-launch.mjs +98 -0
  11. package/apps/studio/bin/_retry-save.mjs +49 -0
  12. package/apps/studio/bin/_sync.mjs +145 -2
  13. package/apps/studio/bin/asset-rename.sh +12 -0
  14. package/apps/studio/bin/asset-trash.sh +12 -0
  15. package/apps/studio/bin/canvas-move.sh +12 -0
  16. package/apps/studio/bin/canvas-new.sh +12 -0
  17. package/apps/studio/bin/footage.sh +12 -0
  18. package/apps/studio/bin/generate.sh +7 -0
  19. package/apps/studio/bin/retry-save.sh +13 -0
  20. package/apps/studio/bridge/canvas-mode-store.ts +11 -2
  21. package/apps/studio/bridge/dgn-protocol.ts +8 -3
  22. package/apps/studio/bridge/occlusion.ts +45 -0
  23. package/apps/studio/canvas-theme-pill.tsx +169 -26
  24. package/apps/studio/client/export-center.jsx +32 -3
  25. package/apps/studio/client/home/HomeAccountBanner.jsx +61 -0
  26. package/apps/studio/client/home/HomeAccountsChip.jsx +404 -0
  27. package/apps/studio/client/home/HomeConnection.jsx +4 -3
  28. package/apps/studio/client/home/ProjectRows.jsx +514 -0
  29. package/apps/studio/client/home/home-accounts-model.js +148 -99
  30. package/apps/studio/client/home/home-api.js +4 -0
  31. package/apps/studio/client/home/home-app.jsx +127 -432
  32. package/apps/studio/client/home/home-icons.jsx +8 -0
  33. package/apps/studio/client/home/home-model.js +109 -0
  34. package/apps/studio/client/home/home.css +447 -111
  35. package/apps/studio/client/home/use-account-fix.js +123 -0
  36. package/apps/studio/client/v2/assets/generate-ask.jsx +3 -1
  37. package/apps/studio/client/v2/export/done-toast.jsx +2 -5
  38. package/apps/studio/client/v2/export/export-sheet.jsx +9 -2
  39. package/apps/studio/client/v2/export/export.css +9 -0
  40. package/apps/studio/client/v2/export/exports-model.js +16 -3
  41. package/apps/studio/client/v2/export/file-rows.jsx +81 -5
  42. package/apps/studio/client/v2/export/native-save.js +33 -0
  43. package/apps/studio/client/v2/export/sections/print-copy.js +3 -0
  44. package/apps/studio/client/v2/export/sections/print.jsx +37 -20
  45. package/apps/studio/client/v2/shell/occlusion-insets.js +37 -9
  46. package/apps/studio/client/v2/shell/use-occluded-insets.js +13 -3
  47. package/apps/studio/collab/room.ts +21 -7
  48. package/apps/studio/dist/client.bundle.js +692 -692
  49. package/apps/studio/dist/comment-mount.js +2 -2
  50. package/apps/studio/dist/styles.css +1 -1
  51. package/apps/studio/exporters/ghostscript.ts +78 -1
  52. package/apps/studio/exporters/pdf-fonts.ts +31 -4
  53. package/apps/studio/generation/jobs.ts +6 -0
  54. package/apps/studio/http.ts +6 -2
  55. package/apps/studio/routes/agent.ts +6 -2
  56. package/apps/studio/routes/project-undo.ts +10 -0
  57. package/apps/studio/server.ts +25 -0
  58. package/apps/studio/shell/cli-yield.ts +48 -11
  59. package/apps/studio/whats-new.json +18 -0
  60. package/cli/commands/design.mjs +74 -16
  61. package/cli/lib/bash-guard.mjs +4 -4
  62. package/cli/lib/confine-read.mjs +2 -0
  63. package/cli/lib/design-help.gen.mjs +15 -2
  64. package/cli/lib/design-hook.mjs +1 -1
  65. package/cli/lib/desktop-locate.mjs +36 -8
  66. package/cli/lib/studio-locate.mjs +8 -2
  67. package/cli/lib/sub-verbs.mjs +13 -1
  68. package/package.json +8 -8
  69. package/apps/studio/client/home/HomeAccounts.jsx +0 -262
  70. package/apps/studio/client/home/HomeAccountsRow.jsx +0 -221
@@ -32,6 +32,8 @@ import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
32
32
  import { tmpdir } from 'node:os';
33
33
  import path from 'node:path';
34
34
 
35
+ import { PDFArray, PDFDocument, PDFName, PDFNumber, type PDFPage } from 'pdf-lib';
36
+
35
37
  /**
36
38
  * argv prefix for Ghostscript. `MAUDE_GHOSTSCRIPT` overrides (space-separated,
37
39
  * so a wrapper or an absolute path both work); otherwise the usual binary
@@ -135,6 +137,80 @@ export const OUTLINE_FLAGS: readonly string[] = [
135
137
  '-dSAFER',
136
138
  ];
137
139
 
140
+ /** Boxes the outline pass carries over. Neither is inheritable, so each lives on its page leaf. */
141
+ const PRINT_BOXES = ['TrimBox', 'BleedBox'] as const;
142
+ /** Points. Ghostscript writes boxes at 4 decimals; anything closer than this is the same box. */
143
+ const BOX_TOLERANCE_PT = 0.05;
144
+
145
+ function boxNumbers(page: PDFPage, key: string): [number, number, number, number] | null {
146
+ const raw = page.node.lookup(PDFName.of(key));
147
+ if (!(raw instanceof PDFArray) || raw.size() !== 4) return null;
148
+ const nums = raw.asArray().map((v) => (v instanceof PDFNumber ? v.asNumber() : Number.NaN));
149
+ if (nums.some((n) => !Number.isFinite(n))) return null;
150
+ const [x1, y1, x2, y2] = nums as [number, number, number, number];
151
+ return [Math.min(x1, x2), Math.min(y1, y2), Math.max(x1, x2), Math.max(y1, y2)];
152
+ }
153
+
154
+ /**
155
+ * Put the input's TrimBox / BleedBox back on Ghostscript's output, shifted by however far
156
+ * Ghostscript moved the MediaBox origin (B4, fix-bulk 2026-11-10).
157
+ *
158
+ * A print page with crop marks has a MediaBox with a negative origin (the slug). `pdfwrite`
159
+ * re-bases every page to a 0,0 MediaBox, and a reported run also dropped both boxes — the
160
+ * outlined file then no longer says where to cut, which is the one thing a print PDF must say.
161
+ * Current Ghostscript keeps and shifts them itself; this makes the result independent of the
162
+ * build the user (or the image) has. Only a box the INPUT page set is restored, and only on a
163
+ * page whose MediaBox kept its size (a page Ghostscript rotated or resized is left alone rather
164
+ * than given a box that no longer fits it). Returns whether anything changed.
165
+ */
166
+ export function restorePageBoxes(input: PDFDocument, output: PDFDocument): boolean {
167
+ if (input.getPageCount() !== output.getPageCount()) return false;
168
+ let changed = false;
169
+ for (let i = 0; i < input.getPageCount(); i += 1) {
170
+ const src = input.getPage(i);
171
+ const dst = output.getPage(i);
172
+ const a = src.getMediaBox();
173
+ const b = dst.getMediaBox();
174
+ if (
175
+ Math.abs(a.width - b.width) > BOX_TOLERANCE_PT ||
176
+ Math.abs(a.height - b.height) > BOX_TOLERANCE_PT
177
+ )
178
+ continue;
179
+ const dx = b.x - a.x;
180
+ const dy = b.y - a.y;
181
+ for (const key of PRINT_BOXES) {
182
+ const want = boxNumbers(src, key);
183
+ if (!want) continue;
184
+ const [x1, y1, x2, y2] = [want[0] + dx, want[1] + dy, want[2] + dx, want[3] + dy];
185
+ const have = boxNumbers(dst, key);
186
+ if (
187
+ have &&
188
+ [x1, y1, x2, y2].every((v, n) => Math.abs(v - (have[n] as number)) <= BOX_TOLERANCE_PT)
189
+ )
190
+ continue;
191
+ dst.node.set(PDFName.of(key), output.context.obj([x1, y1, x2, y2]));
192
+ changed = true;
193
+ }
194
+ }
195
+ return changed;
196
+ }
197
+
198
+ /**
199
+ * `outlined` with the input's print boxes restored, re-saved only when a box was missing or
200
+ * moved. A document pdf-lib cannot read is returned as Ghostscript wrote it: the box repair is a
201
+ * best effort on top of an outline that already succeeded, never a reason to fail the export.
202
+ */
203
+ async function withPrintBoxes(input: Uint8Array, outlined: Uint8Array): Promise<Uint8Array> {
204
+ try {
205
+ const before = await PDFDocument.load(input, { updateMetadata: false });
206
+ const after = await PDFDocument.load(outlined, { updateMetadata: false });
207
+ if (!restorePageBoxes(before, after)) return outlined;
208
+ return await after.save();
209
+ } catch {
210
+ return outlined;
211
+ }
212
+ }
213
+
138
214
  export interface OutlineOptions {
139
215
  /** Aborts the pass and kills Ghostscript. */
140
216
  signal?: AbortSignal;
@@ -187,7 +263,8 @@ export async function outlinePdf(
187
263
  `Ghostscript failed to outline the PDF (exit ${code})${detail ? `: ${detail}` : ''}`
188
264
  );
189
265
  }
190
- return new Uint8Array(readFileSync(outPath));
266
+ const outlined = new Uint8Array(readFileSync(outPath));
267
+ return await withPrintBoxes(bytes, outlined);
191
268
  } finally {
192
269
  rmSync(dir, { recursive: true, force: true });
193
270
  }
@@ -27,10 +27,12 @@ import {
27
27
  PDFArray,
28
28
  PDFDict,
29
29
  type PDFDocument,
30
+ PDFHexString,
30
31
  PDFName,
31
32
  type PDFObject,
32
33
  PDFRef,
33
34
  PDFStream,
35
+ PDFString,
34
36
  } from 'pdf-lib';
35
37
 
36
38
  /**
@@ -88,6 +90,27 @@ function descriptorHasFontProgram(descriptor: PDFDict): boolean {
88
90
  return false;
89
91
  }
90
92
 
93
+ /** Read a string-valued key (`/FontFamily (Arvo)`) as plain text, or null. */
94
+ function stringValue(dict: PDFDict, key: string): string | null {
95
+ const v = dict.lookup(PDFName.of(key));
96
+ if (v instanceof PDFString || v instanceof PDFHexString) return v.decodeText() || null;
97
+ return v instanceof PDFName ? v.decodeText() || null : null;
98
+ }
99
+
100
+ /**
101
+ * A name for a font dict that has no `/BaseFont`: its descriptor's
102
+ * `/FontName`, then its `/FontFamily`, then the dict's own `/Name`.
103
+ */
104
+ function fallbackFontName(font: PDFDict): string | null {
105
+ const descriptor = font.lookup(PDFName.of('FontDescriptor'));
106
+ if (descriptor instanceof PDFDict) {
107
+ const fromDescriptor =
108
+ nameValue(descriptor, 'FontName') ?? stringValue(descriptor, 'FontFamily');
109
+ if (fromDescriptor) return fromDescriptor;
110
+ }
111
+ return nameValue(font, 'Name');
112
+ }
113
+
91
114
  /**
92
115
  * Classify ONE font dictionary.
93
116
  *
@@ -101,10 +124,14 @@ function classifyFontDict(font: PDFDict): PdfFontInfo | null {
101
124
  const subtype = nameValue(font, 'Subtype');
102
125
  if (!subtype) return null;
103
126
 
104
- const baseFontRaw = nameValue(font, 'BaseFont');
105
- // A Type 3 font is not required to have a /BaseFont at all. Chromium does set
106
- // one, but a hand-authored or third-party PDF may not — name it after the
107
- // subtype rather than dropping it from the report.
127
+ // A Type 3 font is not required to have a /BaseFont at all, and today's
128
+ // Chromium (Skia) writes none: it names the face only in the font's
129
+ // /FontDescriptor (`/FontName /AAAAAA+Arvo-Bold`, `/FontFamily (Arvo)`).
130
+ // Reading only /BaseFont reported a real Gators-Bold headline as
131
+ // "(unnamed Type3)" (B4, fix-bulk 2026-11-10), which tells the user nothing
132
+ // about which text to fix. Fall back through the descriptor, then the PDF 1.0
133
+ // `/Name`, and name it after the subtype only when nothing names it at all.
134
+ const baseFontRaw = nameValue(font, 'BaseFont') ?? fallbackFontName(font);
108
135
  const name = baseFontRaw ? stripSubsetPrefix(baseFontRaw) : `(unnamed ${subtype})`;
109
136
 
110
137
  if (subtype === 'Type3') {
@@ -230,6 +230,12 @@ export function createGenerationJobQueue(bus: Bus, designRoot: string): Generati
230
230
  release();
231
231
  }
232
232
  })();
233
+ // #220 — the failure is on the job record (status, error, the generate:job push), so a caller
234
+ // that drops `result` — POST /_api/generate-jobs answers 202 and never awaits it — must not leave
235
+ // a rejection nobody handles: the server has no unhandledRejection handler and Bun would end the
236
+ // whole project server (exit 1) on every failed generation. This marks it handled; a caller that
237
+ // awaits `result` still gets the rejection.
238
+ result.catch(() => {});
233
239
 
234
240
  return { id, result };
235
241
  }
@@ -1688,6 +1688,8 @@ export function createHttp(
1688
1688
  cloudRenderDoor?: () => CloudRenderDoor | null;
1689
1689
  /** V2-1.15 §4 #13 — the people holding an element of a canvas now (collab/holds.ts) */
1690
1690
  personHolds?: AgentRouteDeps['personHolds'];
1691
+ /** #216 — flush a canvas's live collab room (repo-relative path) before ⌘Z reads its stack */
1692
+ settleCanvasRoom?: (repoRel: string) => Promise<void>;
1691
1693
  } = {}
1692
1694
  ): Http {
1693
1695
  /** The current request's inspector state (Cloud Phase 27 D3). Resolved per
@@ -2454,6 +2456,7 @@ export function createHttp(
2454
2456
  control: () => ctx.syncControl?.current?.() ?? null,
2455
2457
  designRel: ctx.paths.designRel,
2456
2458
  emit: (e, p) => ctx.bus.emit(e, p),
2459
+ ...(opts.settleCanvasRoom ? { settle: opts.settleCanvasRoom } : {}),
2457
2460
  },
2458
2461
  // S1.12b — Version history (V2-1.9 §5.11): rows, words, names, kept-aside versions. The
2459
2462
  // session's access is `currentAccess()` (S9.9, server.ts withSession).
@@ -4261,7 +4264,7 @@ export function createHttp(
4261
4264
  { status: result.status, headers: { 'Cache-Control': 'no-store' } }
4262
4265
  );
4263
4266
  }
4264
- // S12.16 — the AI chat creates through `maude design curl-local`, which names its chat
4267
+ // S12.16 — the AI chat creates through `maude design canvas-new`, which names its chat
4265
4268
  // (ai/create-claim.ts): the new canvas is that chat's live run's write, not an outside one.
4266
4269
  const mine = runForCreate(req, runs);
4267
4270
  if (mine) {
@@ -6853,7 +6856,8 @@ export function createHttp(
6853
6856
  });
6854
6857
  // Don't await the run — the job's own status (GET + the generate:job WS
6855
6858
  // push) is the completion signal. A failure is recorded on the job
6856
- // record, so swallow the rejection here to avoid an unhandled rejection.
6859
+ // record; the queue itself marks the rejection handled (generation/jobs.ts,
6860
+ // #220 — before that, a failed job ended the whole server).
6857
6861
  return Response.json(
6858
6862
  { jobId: id },
6859
6863
  { status: 202, headers: { 'Cache-Control': 'no-store' } }
@@ -809,11 +809,15 @@ function hookRouteSpecs(deps: AgentRouteDeps): RouteSpec[] {
809
809
  ? ('*' as const)
810
810
  : reach.artboards;
811
811
  const self = runs.get(session, chat);
812
- // G-AI-6: a ⌘/ selection-scoped run changes only its selection
812
+ // G-AI-6: a scoped run changes only its canvas. #219 (Michal): the ARTBOARDS a chat started from
813
+ // (the scope chip follows the selection) are a hint for the AI, never a write lock — another
814
+ // artboard of the canvas goes on to the lock, hold and lease checks below like any lazy write,
815
+ // so one AI per artboard still holds. Only an element-scoped ask (⌘/ on a selection, S2.19)
816
+ // keeps its artboards as a limit.
813
817
  const sc = self?.scope;
814
818
  if (sc) {
815
819
  const offCanvas = rel !== sc.canvas;
816
- const allowed = sc.artboards.length ? sc.artboards : null;
820
+ const allowed = sc.artboards.length && sc.elements?.length ? sc.artboards : null;
817
821
  const outside = offCanvas
818
822
  ? reach.artboards
819
823
  : allowed
@@ -179,6 +179,14 @@ export interface ProjectUndoDeps {
179
179
  * sticky while keeping the thread (contract S4-S9-votes-comments §3.2).
180
180
  */
181
181
  guard?: (target: UndoTarget, req: Request) => Promise<Response | null>;
182
+ /**
183
+ * #216 — bring the canvas's pending writes onto the op log before the stack is read. An annotation
184
+ * gesture made with the canvas open lands in its live collab room, which reaches the op log only at
185
+ * the room's debounced flush (800 ms, re-armed by every update): ⌘Z read before it found nothing, or
186
+ * took back the step BEFORE the gesture (the stickies made inside a section the person just moved).
187
+ * http.ts wires it to that room's `flush()`. A failure never blocks the read.
188
+ */
189
+ settle?: (repoRel: string) => Promise<void>;
182
190
  }
183
191
 
184
192
  /** V2-1.5 §5.3 bus payload, from a history row (+ the attribution when known). */
@@ -356,6 +364,8 @@ export function createProjectUndoRoutes(deps: ProjectUndoDeps): RouteSpec[] {
356
364
  const since = Number(url.searchParams.get('since') ?? 0);
357
365
  const runtime = deps.control();
358
366
  if (!runtime?.acceptedHistory) return json(200, { ok: false, reason: 'legacy' });
367
+ // #216 — the canvas's live room flushed first: the gesture ⌘Z means is on the stack
368
+ await deps.settle?.(repoRel).catch(() => {});
359
369
  // P8 (board 01 cf-undo-ai) — a run whose turn just ended is on the stack before ⌘Z reads it.
360
370
  await runsLanded(runtime);
361
371
  const rows = await runtime
@@ -78,6 +78,7 @@ import {
78
78
  terminalKeyMode,
79
79
  } from './shell/api-key.ts';
80
80
  import {
81
+ appAlreadyServes,
81
82
  isCliRole,
82
83
  registryPath,
83
84
  SERVER_ROLE_ENV,
@@ -125,6 +126,26 @@ if (process.argv.includes('--home')) {
125
126
  const ctx = createContext();
126
127
  bootStep('context');
127
128
 
129
+ // fix-bulk B2 (#206 DDR-250 decision 1, boot half) — a terminal-started server decides whether the
130
+ // app already serves this root BEFORE it writes anything (key file, `_server.json`, the store lock) or
131
+ // joins sync. It used to boot fully, overwrite the app's `_server.json`, step down 2 s later and remove
132
+ // the file it had written: the app's server was left with none. The running watcher below still
133
+ // covers an app that opens the project later.
134
+ if (!isWorkspaceMode() && isCliRole(process.env)) {
135
+ const appPort = await appAlreadyServes({
136
+ root: ctx.paths.repoRoot,
137
+ rootId: rootIdentity(ctx.paths.repoRoot),
138
+ file: registryPath(),
139
+ });
140
+ if (appPort !== null) {
141
+ console.log(
142
+ ` Maude is serving this project now (port ${appPort}) — this server is not starting.\n` +
143
+ ' `maude design open <canvas>` shows a canvas there.'
144
+ );
145
+ process.exit(0);
146
+ }
147
+ }
148
+
128
149
  // V2-2.9 (T23) — persist the per-source diagnostics (server · sync · ai · export) under
129
150
  // ~/.maude/logs (or $MAUDE_LOG_DIR), scrubbed, 7 days. Local only: nothing is sent anywhere.
130
151
  await initDiagnostics({ repoRoot: ctx.paths.repoRoot });
@@ -425,6 +446,10 @@ const http = createHttp(ctx, api, inspects, aiActivity, exportJobs, generateJobs
425
446
  runs: runRegistry,
426
447
  // V2-1.15 §4 #13 — a person's live hold (awareness `holding`) denies the AI's write
427
448
  personHolds: collab ? personHoldsOf(collab.registry, (rel) => api.fileSlug(rel)) : undefined,
449
+ // #216 — ⌘Z reads the stack after the canvas's live room has flushed its pending gesture
450
+ settleCanvasRoom: async (repoRel) => {
451
+ await collab?.registry.peek(api.fileSlug(repoRel))?.flush();
452
+ },
428
453
  });
429
454
  askQueue = http.askQueue;
430
455
  // S9.9 — `currentAccess()` outside a request (timers, boot): this process's own answer.
@@ -194,6 +194,52 @@ export interface CliYieldOptions {
194
194
 
195
195
  export type CliYieldState = 'watching' | 'yielding' | 'yielded' | 'stopped';
196
196
 
197
+ /**
198
+ * The port of a RUNNING app sidecar for `root` that answers the attest challenge, or null. Skips this
199
+ * server's own entry (pid, or port once it has one). Never throws.
200
+ */
201
+ export async function attestedSidecarPort(o: {
202
+ root: string;
203
+ rootId: string;
204
+ selfPid: number;
205
+ selfPort?: number;
206
+ file: string;
207
+ fetchImpl?: typeof fetch;
208
+ alive?: (pid: number) => boolean;
209
+ }): Promise<number | null> {
210
+ try {
211
+ const reg = readRegistry(o.file);
212
+ if (!reg || !(o.alive ?? pidAlive)(reg.appPid)) return null;
213
+ const ownRoot = real(o.root) ?? o.root;
214
+ for (const e of reg.servers) {
215
+ if (e.state !== 'running' || (o.selfPort !== undefined && e.port === o.selfPort)) continue;
216
+ if (e.pid !== undefined && e.pid === o.selfPid) continue;
217
+ if (real(e.root) !== ownRoot) continue;
218
+ if (await attests(e, o.rootId, o.fetchImpl)) return e.port;
219
+ }
220
+ } catch {
221
+ /* no answer is no sidecar */
222
+ }
223
+ return null;
224
+ }
225
+
226
+ /**
227
+ * fix-bulk B2 — the boot-time half of the handover: a cli-role server asks once, BEFORE it writes its
228
+ * key file or `_server.json`, takes the store lock or joins sync. When the app's sidecar already
229
+ * serves this root (attested), the server prints one line and does not start — so it never writes
230
+ * over the app's `_server.json` and its shutdown never removes the file it wrote there.
231
+ */
232
+ export async function appAlreadyServes(o: {
233
+ root: string;
234
+ rootId: string;
235
+ file: string | null;
236
+ fetchImpl?: typeof fetch;
237
+ alive?: (pid: number) => boolean;
238
+ }): Promise<number | null> {
239
+ if (!o.file) return null;
240
+ return attestedSidecarPort({ ...o, file: o.file, selfPid: process.pid });
241
+ }
242
+
197
243
  export function watchForAppSidecar(o: CliYieldOptions): {
198
244
  stop(): void;
199
245
  state(): CliYieldState;
@@ -238,17 +284,8 @@ export function watchForAppSidecar(o: CliYieldOptions): {
238
284
  if (state !== 'watching' || checking) return;
239
285
  checking = true;
240
286
  try {
241
- const reg = readRegistry(o.file);
242
- if (!reg || !alive(reg.appPid)) return;
243
- for (const e of reg.servers) {
244
- if (e.state !== 'running' || e.port === o.selfPort) continue;
245
- if (e.pid !== undefined && e.pid === o.selfPid) continue;
246
- if (real(e.root) !== ownRoot) continue;
247
- if (await attests(e, o.rootId, o.fetchImpl)) {
248
- if (state === 'watching') beginYield(e.port);
249
- return;
250
- }
251
- }
287
+ const port = await attestedSidecarPort({ ...o, root: ownRoot, alive });
288
+ if (port !== null && state === 'watching') beginYield(port);
252
289
  } finally {
253
290
  checking = false;
254
291
  }
@@ -1,6 +1,24 @@
1
1
  {
2
2
  "$schema": "./whats-new.schema.json",
3
3
  "entries": [
4
+ {
5
+ "id": "export-and-chat-fixes-2026-11",
6
+ "version": "2.1.2",
7
+ "date": "2026-11-10",
8
+ "kind": "fix",
9
+ "title": "Export from the chat, steadier AI edits",
10
+ "summary": "Export works again from the AI chat, and Save to can be any folder. ⌘Z undoes your latest annotation, a failed picture generation no longer stops the project, and a selected artboard no longer stops the AI from editing the others.",
11
+ "surface": "design-ui"
12
+ },
13
+ {
14
+ "id": "home-declutter",
15
+ "version": "2.1.2",
16
+ "date": "2026-11-10",
17
+ "kind": "improvement",
18
+ "title": "A calmer Home",
19
+ "summary": "Home now shows what you make and where: recent canvases and your projects. Accounts sit behind one button at the top right, a banner appears only when a sign-in needs you, old servers fold away with Forget, and a project row says where it lives and when you last opened it.",
20
+ "surface": "design-ui"
21
+ },
4
22
  {
5
23
  "id": "accounts-and-where-projects-live",
6
24
  "version": "2.1.1",
@@ -38,6 +38,7 @@ import {
38
38
  } from '../lib/export-spec.mjs';
39
39
  import { writeGitignoreBlock } from '../lib/gitignore-block.mjs';
40
40
  import { isCompiledBinary, resolveAppSidecar } from '../lib/pkg-root.mjs';
41
+ import { studioHeaders } from '../lib/studio-locate.mjs';
41
42
  import { subVerbArgs } from '../lib/sub-verbs.mjs';
42
43
 
43
44
  const SUBCOMMANDS = new Set([
@@ -87,6 +88,18 @@ const BIN_VERBS = new Set([
87
88
  // S11.6 — read-only: the canvases that can't be drawn, and a canvas's source or one artboard's lines.
88
89
  'canvas-errors',
89
90
  'canvas-source',
91
+ // fix-bulk W1 follow-up. `canvas-new` makes a canvas (blank / brief / empty video, or a duplicate) and
92
+ // `canvas-move` renames or moves one, through the studio's own routes WITH its key — the recipes used
93
+ // `curl-local …/_api/canvas|fs-move`, which every keyed studio answers 401 (sec-loopback-bearer §7).
94
+ 'canvas-new',
95
+ 'canvas-move',
96
+ // fix-bulk 2026-11-10 follow-up — the last `curl-local` recipe families, each a verb that sends the
97
+ // studio's key: Assets › Move to trash / Rename…, Retry on Not saved, and the footage sidecars
98
+ // (/design-video:reel). Sync details' buttons are `sync` sub-verbs. All prompt (verbs.ts).
99
+ 'asset-trash',
100
+ 'asset-rename',
101
+ 'retry-save',
102
+ 'footage',
90
103
  'chat-open',
91
104
  'ensure-browser',
92
105
  'fetch-asset',
@@ -546,6 +559,10 @@ Studio (talk to the running Maude window — contract V2-1.11 §5.3):
546
559
  Restore a canvas / undo an action or a whole AI chat, each as ONE new version; name a version (synced projects). Asks first.
547
560
  history restore <canvas> <ref> --artboard <id> | --element <artboard>/<id> · history restore <canvas> @last-good
548
561
  Put back only one artboard or object, or the last version that drew without an error.
562
+ canvas-new [<name>] [--kind blank|brief-board|video-comp] [--group <folder>] · canvas-new --duplicate <canvas>
563
+ Make a canvas as Canvases › New canvas / Duplicate do; prints the file to Edit.
564
+ canvas-move <canvas> [--name <new name>] [--to <folder>]
565
+ Rename or move a canvas as Canvases › Rename / Move to… do.
549
566
  trash list [--json] · trash move <canvas> · trash restore <id | canvas path>
550
567
  What is in the Trash; move one canvas to it (as Canvases › Move canvas to trash); bring one item back.
551
568
  trash clear [--item <id>]... [--yes]
@@ -557,12 +574,22 @@ Studio (talk to the running Maude window — contract V2-1.11 §5.3):
557
574
  runs only the items of one export that did not make it.
558
575
  assets [--usage <asset>] [--not-used] [--json]
559
576
  The project's assets and the canvases that use them; not-used ones once older versions are checked. Read-only.
577
+ asset-trash <asset>... · asset-rename <asset> <new name>
578
+ Move pictures to the Trash or rename one, as Assets does; one a canvas uses stays. Asks first.
579
+ retry-save
580
+ The saves a full disk held try to land now (Retry on Not saved). Asks first.
581
+ footage show (--asset <clip> | --cut <slug>) · footage save (--asset | --cut) --from <file.json>
582
+ A clip's footage analysis or a cut's EDL; save stores it as the studio validates it. Asks first.
560
583
  runs list [--canvas <canvas>] [--json] · runs stop <run>
561
584
  The AI runs on this project and the artboards each is changing; stop one of yours.
562
585
  logs [--source all|sync|server|ai|export] [--tail N] [--grep <text>] [--json]
563
586
  This Mac's Maude log lines, redacted, merged by time (what Diagnostics › Logs shows). Read-only.
564
587
  sync status [--json] · sync resync [--no-wait] [--json]
565
588
  Sync in one word + the last resync; or compare every file with the cloud copy. Resync asks first.
589
+ sync compare <canvas> · sync keep-mine|use-theirs|keep-both <canvas>
590
+ sync publish-ai-edit|discard-ai-edit [--run <id>] · sync cancel-transfer
591
+ Sync details' buttons: a held conflict's two versions and its answer, an unfinished AI edit's
592
+ answer, stop the picture transfer. Each asks first.
566
593
  captions add|list|export <canvas>#<artboard> · cut-words <canvas>#<artboard> --clip <id> --words w12-w15
567
594
  cut-to-beat <canvas>#<artboard> [--every 1|2|4] · beats <assets/x.mp3> [--bpm N] [--dry-run]
568
595
  A video's captions, edit by transcript, Cut to the beat (one undoable edit each, in the
@@ -991,6 +1018,42 @@ function checkDevDeps({ pkgRoot }) {
991
1018
  return missing;
992
1019
  }
993
1020
 
1021
+ const UNVERIFIED_LINE =
1022
+ 'Maude has this project open, but its server did not answer the check. Close and reopen the tab in Maude, or quit Maude to use a separate server.';
1023
+
1024
+ /**
1025
+ * fix-bulk B1 — `{ base, apiKey? }` of the studio an export goes to, or `{ error }`. The project is
1026
+ * the session's (AI chat) or the one at or above the cwd; `--port` names a port, else the app's
1027
+ * attested server or `_server.json` (verified by `/_health`) is used. Always 127.0.0.1.
1028
+ */
1029
+ export async function exportStudio(portFlag, { env = process.env, cwd = process.cwd() } = {}) {
1030
+ const { sessionRoot } = await import('../lib/confine-root.mjs');
1031
+ const { probeStudio } = await import('../lib/studio-locate.mjs');
1032
+ const { ATTEST_PATIENCE, serverKeyFor } = await import('../lib/desktop-locate.mjs');
1033
+ const root = sessionRoot(env, cwd) ?? cwd;
1034
+ if (portFlag !== undefined && portFlag !== true) {
1035
+ const port = Number(portFlag);
1036
+ if (!Number.isInteger(port) || port < 1 || port > 65535)
1037
+ return { error: `--port ${portFlag} is not a port.` };
1038
+ const k = await serverKeyFor(root, port, { env, ...ATTEST_PATIENCE });
1039
+ if (k.unverified) return { error: UNVERIFIED_LINE };
1040
+ return { base: `http://127.0.0.1:${port}`, ...(k.key ? { apiKey: k.key } : {}) };
1041
+ }
1042
+ const p = await probeStudio(root, {
1043
+ timeoutMs: ATTEST_PATIENCE.timeoutMs,
1044
+ attempts: ATTEST_PATIENCE.attempts,
1045
+ retryDelayMs: ATTEST_PATIENCE.retryDelayMs,
1046
+ });
1047
+ if (p.studio) return p.studio;
1048
+ if (p.unverified) return { error: UNVERIFIED_LINE };
1049
+ if (p.state === 'busy')
1050
+ return { error: 'the studio is busy and did not answer. Try again in a moment.' };
1051
+ return {
1052
+ error:
1053
+ 'no running studio for this project (no --port given, and neither the Maude app nor .design/_server.json names one). Open the project in Maude, or start one with `maude design serve`.',
1054
+ };
1055
+ }
1056
+
994
1057
  async function runExport({ args }) {
995
1058
  // `maude design export <format> [--scope ...] [--port N] [--out <path>] [--option key=value]`
996
1059
  // v2 (S8.1c, contract S8-export-spec.md §5.7): `--scope selection|canvas|folder|project` with
@@ -1022,20 +1085,15 @@ async function runExport({ args }) {
1022
1085
  process.exit(2);
1023
1086
  }
1024
1087
 
1025
- // Resolve port: --port > .design/_server.json
1026
- let port = flags.port ? Number(flags.port) : null;
1027
- if (!port) {
1028
- try {
1029
- const raw = await readFile(resolve(process.cwd(), '.design', '_server.json'), 'utf8');
1030
- port = JSON.parse(raw).port;
1031
- } catch {
1032
- /* no server.json — handled below */
1033
- }
1034
- }
1035
- if (!port) {
1036
- process.stderr.write(
1037
- 'maude design export: no --port given and .design/_server.json not found. Start the dev server first (`maude design serve`).\n'
1038
- );
1088
+ // fix-bulk B1 (#221) — the studio and its key, the way every other verb finds them
1089
+ // (sec-loopback-bearer §7.6): the desktop app's ATTESTED server for this project first (its key from
1090
+ // the app's registry), else `_server.json`'s port once `/_health` names this project (a
1091
+ // terminal-started server's key from its per-user key file). An explicit --port gets the key of
1092
+ // whichever of those serves there. Never a key or an address from a project file; the export used
1093
+ // to POST with no key at all, and a server in required mode answered 401 api-key-required.
1094
+ const studio = await exportStudio(flags.port);
1095
+ if (studio.error) {
1096
+ process.stderr.write(`maude design export: ${studio.error}\n`);
1039
1097
  process.exit(1);
1040
1098
  }
1041
1099
 
@@ -1065,9 +1123,9 @@ async function runExport({ args }) {
1065
1123
  body = { format, scope, options: parsed.options };
1066
1124
  }
1067
1125
 
1068
- const r = await fetch(`http://localhost:${port}${route}`, {
1126
+ const r = await fetch(`${studio.base}${route}`, {
1069
1127
  method: 'POST',
1070
- headers: { 'content-type': 'application/json' },
1128
+ headers: studioHeaders(studio, { 'content-type': 'application/json' }),
1071
1129
  body: JSON.stringify(body),
1072
1130
  });
1073
1131
  if (!r.ok) {
@@ -565,13 +565,13 @@ const SCRIPT_WRITES =
565
565
  /\b(?:writeFile(?:Sync)?|appendFile(?:Sync)?|createWriteStream|rmSync|unlink(?:Sync)?|rename(?:Sync)?|copyFile(?:Sync)?|cpSync|truncate(?:Sync)?|Bun\.write|write_text|write_bytes|os\.remove|os\.replace|os\.rename|shutil\.\w+|File\.write|FileUtils)\b|\bopen\s*\([^)]*['"][wax+]b?['"]|\bmode\s*=\s*['"][wax+]|\bopen\s*\([^)]*['"]\+?>{1,2}/;
566
566
 
567
567
  const MESSAGES = {
568
- // The route is the studio's own (the one Canvases uses), reached with `curl-local`; the port is in
569
- // `.design/_server.json`. (These messages once named `maude design trash move` / `canvas move`:
570
- // neither verb exists, and the agent spent 15+ calls finding this route.)
568
+ // The verbs are the studio's own routes (the ones Canvases uses), sent with the studio's key —
569
+ // `curl-local` sends none, and a keyed studio answers it 401 (sec-loopback-bearer §7). (These
570
+ // messages once named verbs that did not exist, and the agent spent 15+ calls finding the route.)
571
571
  'use-trash': (rel) =>
572
572
  `use-trash: ${rel} is a versioned design file — Bash never deletes it. Move a canvas to the trash with \`maude design trash move <canvas path>\` (the studio's own Move canvas to trash; \`maude design trash restore <canvas path>\` brings it back — or ask the person to delete it in Canvases); remove one artboard by deleting its DCArtboard block with Edit.`,
573
573
  'use-verb': (rel) =>
574
- `use-verb: ${rel} is a versioned design file — Bash never moves it. Rename or move it with the studio's own route: \`maude design curl-local http://127.0.0.1:<port>/_api/fs-move --method POST --header "Content-Type: application/json" --data '{"file":"<canvas path>","toName":"<new name>"}'\` (add "toDir" to move it to another folder; port: .design/_server.json; or ask the person to move it in Canvases). To the trash: \`maude design trash move <canvas path>\`.`,
574
+ `use-verb: ${rel} is a versioned design file — Bash never moves it. Rename or move it as Canvases does: \`maude design canvas-move <canvas path> --name "<new name>"\` (\`--to <folder>\` moves it to another folder; or ask the person to move it in Canvases). To the trash: \`maude design trash move <canvas path>\`.`,
575
575
  'out-of-project': (path) =>
576
576
  `out-of-project: this \`maude\` command's output would be written to ${path}, outside the project. Write inside the project or the temp dir (or drop the redirection and read the output).`,
577
577
  'other-project': (what) =>
@@ -56,6 +56,8 @@ export const SOURCE_VERBS = new Set([
56
56
  */
57
57
  export const SOURCE_FLAGS = new Map([
58
58
  ['annotate', ['--board', '--flow', '--ops', '--rects', '--canvas-state']],
59
+ // fix-bulk 2026-11-10 follow-up: `footage save --from <file.json>` stores that file's JSON in the project
60
+ ['footage', ['--from']],
59
61
  ]);
60
62
 
61
63
  /** The values of `flags` in `args` (`--f v` and `--f=v`). */
@@ -1,9 +1,9 @@
1
1
  // GENERATED by scripts/gen-actions.mjs from apps/studio/actions/verbs.ts — DO NOT EDIT BY HAND.
2
2
  // What `maude design help` prints under the static usage (contract V2-1.11 §5.7 rule 6).
3
- // manifest cc9b94549577
3
+ // manifest 924d3acafe2c
4
4
 
5
5
  export const DESIGN_VERB_TIERS_HELP =
6
- "Verbs by permission tier (generated from actions.manifest.json, contract V2-1.11 §5.3):\n auto No prompt in the Maude chat (effect none/project):\n prep · bootstrap-check · slug · server-up · runtime-health · screenshot · smoke\n visual-sanity · perf · canvas-rects · canvas-errors · canvas-source\n read-annotations · svg-optimize · asset-sweep · draw-proof · probe-footage\n smart-frames · agent-browser-safe · chat-open · serve · status · index · assets\n help · check · place · layout-check · open · history list · history show\n history diff · history object · trash list · comments list · exports list\n exports again · runs list · runs stop · logs · sync status · annotate · canvas-edit\n handoff · import-asset · import-tokens · ingest-footage · photo-adjust\n transcribe-local · beats · captions list · captions add · captions export · captions\n cut-words · cut-to-beat · reel-place · ds-check · ds-upgrade analyse\n ds-upgrade plan · ds-upgrade validate · ds-upgrade status · ds-upgrade stage\n ds-upgrade prove · ds-upgrade discard · ds-upgrade cancel · trash move\n trash restore · ds status · ds usage · ds check-system · ds revisions\n prompt Shows the permission card:\n hook · video-proxy · export · curl-local · draw-build · to-lottie · generate\n audio-search · fetch-asset · ensure-browser · transcribe · import-figma\n import-brand · photo-bg-remove · describe · init · ds-upgrade · bulk-deletes\n history restore · trash · history undo · history name · exports · sync resync · sync\n runs · ds · comments reply · comments resolve · comments reopen · comments add\n comments · history\n human For people in a terminal. Never in the AI allow list:\n trash clear · link · adopt · unlink · detach\n Every studio capability's file or verb: the design plugin's studio-actions skill.\n";
6
+ "Verbs by permission tier (generated from actions.manifest.json, contract V2-1.11 §5.3):\n auto No prompt in the Maude chat (effect none/project):\n prep · bootstrap-check · slug · server-up · runtime-health · screenshot · smoke\n visual-sanity · perf · canvas-rects · canvas-errors · canvas-source\n read-annotations · svg-optimize · asset-sweep · draw-proof · probe-footage\n smart-frames · agent-browser-safe · chat-open · serve · status · index · assets\n help · check · place · layout-check · open · history list · history show\n history diff · history object · trash list · comments list · exports list\n exports again · runs list · runs stop · logs · sync status · annotate · canvas-edit\n canvas-new · canvas-move · handoff · import-asset · import-tokens · ingest-footage\n photo-adjust · transcribe-local · beats · captions list · captions add\n captions export · captions · cut-words · cut-to-beat · reel-place · ds-check\n ds-upgrade analyse · ds-upgrade plan · ds-upgrade validate · ds-upgrade status\n ds-upgrade stage · ds-upgrade prove · ds-upgrade discard · ds-upgrade cancel\n trash move · trash restore · ds status · ds usage · ds check-system · ds revisions\n prompt Shows the permission card:\n hook · video-proxy · export · asset-trash · asset-rename · retry-save · footage\n sync compare · sync cancel-transfer · sync keep-mine · sync use-theirs\n sync keep-both · sync publish-ai-edit · sync discard-ai-edit · curl-local\n draw-build · to-lottie · generate · audio-search · fetch-asset · ensure-browser\n transcribe · import-figma · import-brand · photo-bg-remove · describe · init\n ds-upgrade · bulk-deletes · history restore · trash · history undo · history name\n exports · sync resync · sync · runs · ds · comments reply · comments resolve\n comments reopen · comments add · comments · history\n human For people in a terminal. Never in the AI allow list:\n trash clear · link · adopt · unlink · detach\n Every studio capability's file or verb: the design plugin's studio-actions skill.\n";
7
7
 
8
8
  /** The `maude design` verbs the manifest knows, by tier. */
9
9
  export const DESIGN_VERBS_BY_TIER = {
@@ -51,6 +51,8 @@ export const DESIGN_VERBS_BY_TIER = {
51
51
  'sync status',
52
52
  'annotate',
53
53
  'canvas-edit',
54
+ 'canvas-new',
55
+ 'canvas-move',
54
56
  'handoff',
55
57
  'import-asset',
56
58
  'import-tokens',
@@ -85,6 +87,17 @@ export const DESIGN_VERBS_BY_TIER = {
85
87
  'hook',
86
88
  'video-proxy',
87
89
  'export',
90
+ 'asset-trash',
91
+ 'asset-rename',
92
+ 'retry-save',
93
+ 'footage',
94
+ 'sync compare',
95
+ 'sync cancel-transfer',
96
+ 'sync keep-mine',
97
+ 'sync use-theirs',
98
+ 'sync keep-both',
99
+ 'sync publish-ai-edit',
100
+ 'sync discard-ai-edit',
88
101
  'curl-local',
89
102
  'draw-build',
90
103
  'to-lottie',
@@ -1104,7 +1104,7 @@ export function handMadeCanvasReason(designRoot, rel) {
1104
1104
  return dir !== '' && (rel === dir || rel.startsWith(`${dir}/`));
1105
1105
  };
1106
1106
  if (dirs.some(under)) return null;
1107
- return `new-canvas: ${rel} does not exist yet, and a canvas is never written by hand. Make it with the app's own create — \`maude design curl-local "http://127.0.0.1:<port>/_api/canvas" --method POST --header "Content-Type: application/json" --data '{"kind":"blank","name":"<name>"}'\` (the port is in ${DESIGN_REL}/_server.json; the answer's \`rel\` is the file) — then Edit the file it made. A component goes in the newComponentDir instead.`;
1107
+ return `new-canvas: ${rel} does not exist yet, and a canvas is never written by hand. Make it with the app's own create — \`maude design canvas-new "<name>"\` (it prints the file it made) — then Edit that file. A component goes in the newComponentDir instead.`;
1108
1108
  }
1109
1109
 
1110
1110
  async function preEdit(ctx, input) {