@marver-design/marver 0.23.1 → 0.25.0

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 (80) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/README.md +3 -1
  3. package/dist/anchor-DVV732zR.mjs +33 -0
  4. package/dist/anchor-check-BE5VVN6Q.mjs +135 -0
  5. package/dist/{bake-DQtnDB8-.mjs → bake-D8byeRzB.mjs} +1 -1
  6. package/dist/{boards-BRLnoTC3.mjs → board-tree-DRioF94d.mjs} +21 -277
  7. package/dist/boards-CGg6piKF.mjs +342 -0
  8. package/dist/{boards-Dv-Ipd8G.mjs → boards-Csxj2WJn.mjs} +23 -9
  9. package/dist/{build-_ndp_dXn.mjs → build-BHoWLvSj.mjs} +63 -37
  10. package/dist/cli.mjs +31 -17
  11. package/dist/{collab-mAiNZlDj.mjs → collab-gqNdScUE.mjs} +39 -9
  12. package/dist/{comments-DZyobpxG.mjs → comments-Zoch254k.mjs} +19 -1
  13. package/dist/{comments-BlqyZh3D.mjs → comments-pTLlhjh4.mjs} +150 -20
  14. package/dist/{config-BUKprFAp.mjs → config-cKgZBRj0.mjs} +1 -1
  15. package/dist/{context-CdkNiKdJ.mjs → context-D2ugHqwO.mjs} +17 -123
  16. package/dist/{daemon-BvMPdQ3k.mjs → daemon-Cl8KXGW4.mjs} +146 -64
  17. package/dist/{dev-Cf-4eqaC.mjs → dev-DJdgow47.mjs} +23 -11
  18. package/dist/{events-B3LBn74P.mjs → events-DnK_AnrW.mjs} +13 -15
  19. package/dist/imports-WBSnnHLb.mjs +143 -0
  20. package/dist/{init-hfZV7TwY.mjs → init-DO4DhUt_.mjs} +28 -6
  21. package/dist/link-C-qUIuKU.mjs +160 -0
  22. package/dist/{board-status-BZSzc9Hp.mjs → manifest-DnAte_fB.mjs} +537 -13
  23. package/dist/marks-DFuintmJ.mjs +50 -0
  24. package/dist/marks-koRsbHfe.mjs +397 -0
  25. package/dist/{marver-id-gate-B_idGdHm.mjs → marver-id-gate-DGANtVyC.mjs} +2 -2
  26. package/dist/perf-CCisg-ny.mjs +49 -0
  27. package/dist/perf-QJIWtTw1.mjs +68 -0
  28. package/dist/{plugin-DoXql0ZZ.mjs → plugin-CTyhjwoJ.mjs} +469 -82
  29. package/dist/{poster-XBmUvQiL.mjs → poster-D0cbV7hi.mjs} +1 -1
  30. package/dist/{profile-CrZohD6g.mjs → profile-Do0nGkXO.mjs} +1 -1
  31. package/dist/{publish-bakes-KKTHWqq3.mjs → publish-bakes--l8ot2eQ.mjs} +9 -9
  32. package/dist/{serve-z5qtj_wJ.mjs → serve-wv2QWdxB.mjs} +6 -6
  33. package/dist/{share-BD-wcDQq.mjs → share-ScamJcks.mjs} +1 -1
  34. package/dist/{shot-DOD8v6fJ.mjs → shot-CckrGW-J.mjs} +19 -11
  35. package/dist/{shot-Dh6fV1Lm.mjs → shot-jdO_B6Qw.mjs} +1 -1
  36. package/dist/{summary-C7CAypbB.mjs → summary-CrW88e3q.mjs} +1 -1
  37. package/dist/{sync-DoA1vf4u.mjs → sync-C3035OnJ.mjs} +18 -8
  38. package/dist/{work-ClFFq0Qh.mjs → work-CpJn1gwY.mjs} +8 -4
  39. package/dist/{work-ayuL_9Kk.mjs → work-GE88wb_3.mjs} +4 -4
  40. package/docs/boards-and-folders.md +70 -4
  41. package/docs/live-jam.md +12 -4
  42. package/package.json +1 -1
  43. package/src/client/frame-host/bridge.js +2 -1
  44. package/src/client/frame-host/inspect.js +195 -84
  45. package/src/client/frame-host/main.tsx +7 -2
  46. package/src/client/frame-host/registry.ts +5 -5
  47. package/src/client/shell/App.tsx +98 -30
  48. package/src/client/shell/BoardList.tsx +74 -16
  49. package/src/client/shell/Comments.tsx +79 -34
  50. package/src/client/shell/ContextMenu.tsx +5 -2
  51. package/src/client/shell/LockedApp.tsx +45 -12
  52. package/src/client/shell/Play.tsx +35 -32
  53. package/src/client/shell/Toolbar.tsx +3 -1
  54. package/src/client/shell/canvas/Canvas.tsx +2 -0
  55. package/src/client/shell/canvas/FrameNode.tsx +15 -5
  56. package/src/client/shell/canvas/sleep.ts +4 -3
  57. package/src/client/shell/canvas/updates.ts +55 -0
  58. package/src/client/shell/comments-store.ts +48 -17
  59. package/src/client/shell/goto.ts +11 -14
  60. package/src/client/shell/hash.ts +12 -5
  61. package/src/client/shell/icons.tsx +1 -2
  62. package/src/client/shell/legacy-links.ts +67 -0
  63. package/src/client/shell/marks-ui.tsx +117 -0
  64. package/src/client/shell/pin-layout.ts +37 -0
  65. package/src/client/shell/store.ts +377 -67
  66. package/src/client/shell/styles.css +32 -8
  67. package/src/client/stage/main.tsx +19 -2
  68. package/src/shared/anchor.ts +57 -0
  69. package/src/shared/board-tree.ts +27 -10
  70. package/src/shared/events.ts +19 -10
  71. package/src/shared/marks.ts +70 -0
  72. package/templates/AGENTS-embedded.md +34 -15
  73. package/templates/AGENTS-studio.md +34 -15
  74. package/templates/instructions/boards.md +9 -5
  75. package/templates/instructions/iterate.md +20 -10
  76. package/templates/instructions/jam.md +13 -4
  77. package/templates/instructions/publish.md +2 -1
  78. package/templates/instructions/reference/deck-story.md +2 -2
  79. package/dist/link-BodAbIQz.mjs +0 -132
  80. package/dist/manifest-TpfDWldB.mjs +0 -528
@@ -1,6 +1,6 @@
1
1
  import { i as PKG, r as NAME } from "./cli.mjs";
2
- import { n as loadConfig, r as detectHost } from "./config-BUKprFAp.mjs";
3
- import { n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-DoXql0ZZ.mjs";
2
+ import { n as loadConfig, r as detectHost } from "./config-cKgZBRj0.mjs";
3
+ import { n as tailwind3Css, r as tailwind4Plugin, t as marverPlugin } from "./plugin-CTyhjwoJ.mjs";
4
4
  import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, statSync, watch } from "node:fs";
5
5
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
6
6
  import { fileURLToPath } from "node:url";
@@ -354,7 +354,9 @@ async function dev(root, portFlag) {
354
354
  const projectName = basename(root);
355
355
  const desiredPort = portFlag ?? (config.port !== 5199 ? config.port : void 0) ?? projectPort(root);
356
356
  const picked = await pickPort(root, desiredPort);
357
- const plugins = [denyLocalSecrets(root), react()];
357
+ const esc = (p) => join(p, "design").replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
358
+ const designDir = new RegExp(`^(${[.../* @__PURE__ */ new Set([root, safeReal(root)])].map(esc).join("|")})[/\\\\]`);
359
+ const plugins = [denyLocalSecrets(root), react({ exclude: [/\/node_modules\//, designDir] })];
358
360
  if (host.tailwind === 4) {
359
361
  const tw = await tailwind4Plugin(root);
360
362
  if (tw) plugins.push(...tw);
@@ -362,7 +364,7 @@ async function dev(root, portFlag) {
362
364
  }
363
365
  let css;
364
366
  if (host.tailwind === 3) css = await tailwind3Css(root) ?? void 0;
365
- plugins.push(marverPlugin({
367
+ plugins.push(...marverPlugin({
366
368
  root,
367
369
  clientDir,
368
370
  config,
@@ -386,6 +388,7 @@ async function dev(root, portFlag) {
386
388
  plugins,
387
389
  server: {
388
390
  port: picked.port,
391
+ hmr: { overlay: false },
389
392
  strictPort: false,
390
393
  fs: {
391
394
  allow: [.../* @__PURE__ */ new Set([
@@ -454,12 +457,12 @@ async function dev(root, portFlag) {
454
457
  console.log(`\n ${NAME} · ${projectName} → http://localhost:${port}/\n`);
455
458
  setTimeout(async () => {
456
459
  try {
457
- await (await import("./shot-DOD8v6fJ.mjs")).sweepGhosts((m) => console.log(` ${m}`));
460
+ await (await import("./shot-CckrGW-J.mjs")).sweepGhosts((m) => console.log(` ${m}`));
458
461
  } catch {}
459
462
  }, 0);
460
463
  try {
461
464
  const { staleManagedInstructions } = await import("./managed-HwHVNI3h.mjs");
462
- const { installedVersion } = await import("./plugin-DoXql0ZZ.mjs").then((n) => n.i);
465
+ const { installedVersion } = await import("./plugin-CTyhjwoJ.mjs").then((n) => n.i);
463
466
  const stale = staleManagedInstructions(root);
464
467
  if (stale.length) {
465
468
  const shown = stale.slice(0, 4).join(", ") + (stale.length > 4 ? `, +${stale.length - 4} more` : "");
@@ -469,11 +472,11 @@ async function dev(root, portFlag) {
469
472
  } catch {}
470
473
  try {
471
474
  if (!existsSync(join(root, "context"))) {
472
- const n = (await import("./manifest-TpfDWldB.mjs").then((n) => n.i)).statusBoards(root).length;
475
+ const n = (await import("./manifest-DnAte_fB.mjs").then((n) => n.i)).statusBoards(root).length;
473
476
  if (n) console.log(` ${n} feature/project board${n === 1 ? "" : "s"}, no context/ - every status reads Backlog. To start it, tell your agent: "Set up our context."\n`);
474
477
  }
475
478
  } catch {}
476
- const { loadCollab, syncOnce } = await import("./sync-DoA1vf4u.mjs").then((n) => n.o);
479
+ const { loadCollab, syncOnce } = await import("./sync-C3035OnJ.mjs").then((n) => n.o);
477
480
  if (loadCollab(root)) console.log(` comments: syncing with the published canvas\n`);
478
481
  let syncing = false;
479
482
  const tick = async () => {
@@ -488,7 +491,7 @@ async function dev(root, portFlag) {
488
491
  };
489
492
  tick();
490
493
  setInterval(tick, 3e4).unref();
491
- const { workActivity, writeDevInfo, removeDevInfo, boardsShowing, onBoardsChanged, nextActivitySeq } = await import("./work-ayuL_9Kk.mjs").then((n) => n.o);
494
+ const { workActivity, writeDevInfo, removeDevInfo, boardsShowing, onBoardsChanged, nextActivitySeq } = await import("./work-GE88wb_3.mjs").then((n) => n.o);
492
495
  let sent = "";
493
496
  const broadcast = (frames) => {
494
497
  const state = {
@@ -543,8 +546,17 @@ async function dev(root, portFlag) {
543
546
  } catch {}
544
547
  }
545
548
  if (config.jam) {
546
- const { startJam } = await import("./daemon-BvMPdQ3k.mjs");
547
- const jam = startJam(root, config.jam, (m) => console.log(m), (board) => server.ws.send("sh:jam-comment", { board }));
549
+ const { startJam } = await import("./daemon-Cl8KXGW4.mjs");
550
+ const { checkAnchor } = await import("./anchor-check-BE5VVN6Q.mjs");
551
+ const jam = startJam(root, config.jam, (m) => console.log(m), (board) => server.ws.send("sh:jam-comment", { board }), (frameId, target, others, look) => checkAnchor({
552
+ root,
553
+ viewports: config.viewports,
554
+ origin: `http://localhost:${port}`,
555
+ frameId,
556
+ target,
557
+ others,
558
+ ...look
559
+ }));
548
560
  if (jam) {
549
561
  const close = server.close.bind(server);
550
562
  server.close = (async () => {
@@ -1,4 +1,8 @@
1
1
  //#region src/shared/events.ts
2
+ /** Does this message ask the human something? The writer says so (`asks`); a message written
3
+ * before 0.25 says nothing, and the old rule reads it: a note asks, a reply asks when it ends
4
+ * in "?". `note` = the thread's root (a create event). */
5
+ const asks = (m, note) => m.asks ?? (note || /\?\s*$/.test(m.body ?? ""));
2
6
  /** Events the other side lacks, by id - the sync payload in either direction. */
3
7
  function diffEvents(mine, theirIds) {
4
8
  const have = new Set(theirIds);
@@ -27,6 +31,7 @@ function replay(events) {
27
31
  agent: ev.agent,
28
32
  agentMeta: ev.agentMeta,
29
33
  mentions: ev.mentions,
34
+ asks: ev.asks,
30
35
  replies: [],
31
36
  reactions: {}
32
37
  });
@@ -42,24 +47,17 @@ function replay(events) {
42
47
  ts: ev.ts,
43
48
  agent: ev.agent,
44
49
  agentMeta: ev.agentMeta,
45
- mentions: ev.mentions
50
+ mentions: ev.mentions,
51
+ asks: ev.asks
46
52
  });
47
53
  break;
48
54
  }
49
55
  case "edit": {
50
- if (!ev.commentId || ev.body === void 0) break;
51
- const t = threads.get(ev.commentId);
52
- if (t) {
53
- t.body = ev.body;
54
- break;
55
- }
56
- for (const th of threads.values()) {
57
- const r = th.replies.find((r) => r.id === ev.commentId);
58
- if (r) {
59
- r.body = ev.body;
60
- break;
61
- }
62
- }
56
+ if (!ev.commentId || ev.body === void 0 && ev.asks === void 0) break;
57
+ const m = threads.get(ev.commentId) ?? [...threads.values()].flatMap((th) => th.replies).find((r) => r.id === ev.commentId);
58
+ if (!m) break;
59
+ if (ev.body !== void 0) m.body = ev.body;
60
+ if (ev.asks !== void 0) m.asks = ev.asks;
63
61
  break;
64
62
  }
65
63
  case "resolve": {
@@ -100,4 +98,4 @@ function replay(events) {
100
98
  return [...threads.values()];
101
99
  }
102
100
  //#endregion
103
- export { replay as n, diffEvents as t };
101
+ export { diffEvents as n, replay as r, asks as t };
@@ -0,0 +1,143 @@
1
+ import { readFileSync, statSync } from "node:fs";
2
+ import { dirname, join, normalize, sep } from "node:path";
3
+ //#region src/server/imports.ts
4
+ /**
5
+ * Following a design file's imports statically, as repository paths: relative and root-relative
6
+ * specifiers, `design/tsconfig.json` aliases, side-effect imports, `?raw` and asset strings. Shared
7
+ * by what a build carries (publish-graph.ts) and what each frame reads (deps.ts). An approximation
8
+ * by design: globs, computed paths and CSS `@import` are outside it.
9
+ */
10
+ const IMPORT = /(?:import|export)\s[^'"]*?from\s*['"]([^'"]+)['"]|import\(\s*['"]([^'"]+)['"]\s*\)|require\(\s*['"]([^'"]+)['"]\s*\)|['"]((?:\.{1,2}\/|\/)[^'"\s]+\.[a-z0-9]{1,5})(?:\?[a-z]+)?['"]|\bimport\s*['"]([^'"]+)['"]/g;
11
+ const CODE = /\.(tsx?|jsx?|mjs|cjs|mdx?)$/;
12
+ /** JSON with comments and trailing commas, as tsconfig allows - comments stripped outside strings only
13
+ * (a "$schema": "https://..." is a string, not a comment). */
14
+ function parseJsonc(text) {
15
+ let out = "", i = 0, str = false;
16
+ const t = text.replace(/^/, "");
17
+ while (i < t.length) {
18
+ const c = t[i];
19
+ if (str) {
20
+ out += c;
21
+ if (c === "\\") {
22
+ out += t[i + 1] ?? "";
23
+ i += 2;
24
+ continue;
25
+ }
26
+ if (c === "\"") str = false;
27
+ i++;
28
+ continue;
29
+ }
30
+ if (c === "\"") {
31
+ str = true;
32
+ out += c;
33
+ i++;
34
+ continue;
35
+ }
36
+ if (c === "/" && t[i + 1] === "/") {
37
+ while (i < t.length && t[i] !== "\n") i++;
38
+ continue;
39
+ }
40
+ if (c === "/" && t[i + 1] === "*") {
41
+ i += 2;
42
+ while (i < t.length && !(t[i] === "*" && t[i + 1] === "/")) i++;
43
+ i += 2;
44
+ continue;
45
+ }
46
+ out += c;
47
+ i++;
48
+ }
49
+ return JSON.parse(out.replace(/,(\s*[}\]])/g, "$1"));
50
+ }
51
+ /** design/tsconfig.json's path aliases, resolved against the config that declares them - its own,
52
+ * or one it `extends` (the host's tsconfig), as TypeScript and Vite would. */
53
+ function aliases(root) {
54
+ const read = (rel, depth) => {
55
+ if (depth > 4) return [];
56
+ let cfg;
57
+ try {
58
+ cfg = parseJsonc(readFileSync(join(root, rel), "utf8"));
59
+ } catch {
60
+ return [];
61
+ }
62
+ const dir = dirname(rel);
63
+ const base = typeof cfg.compilerOptions?.baseUrl === "string" ? normalize(join(dir, cfg.compilerOptions.baseUrl)) : dir;
64
+ const own = Object.entries(cfg.compilerOptions?.paths ?? {}).flatMap(([k, v]) => Array.isArray(v) ? [{
65
+ prefix: k.replace(/\*$/, ""),
66
+ targets: v.map((t) => normalize(join(base, t.replace(/\*$/, ""))))
67
+ }] : []);
68
+ const ext = (Array.isArray(cfg.extends) ? cfg.extends : [cfg.extends]).filter((e) => typeof e === "string" && e.startsWith("."));
69
+ let inherited = [];
70
+ for (const e of ext) {
71
+ const got = read(normalize(join(dir, e.endsWith(".json") ? e : `${e}.json`)), depth + 1);
72
+ inherited = [...got, ...inherited.filter((p) => !got.some((g) => g.prefix === p.prefix))];
73
+ }
74
+ return [...own, ...inherited.filter((p) => !own.some((o) => o.prefix === p.prefix))];
75
+ };
76
+ return read("design/tsconfig.json", 0);
77
+ }
78
+ /** One resolver per pass: the aliases are read once, each file's imports at most once. */
79
+ function imports(root) {
80
+ const al = aliases(root);
81
+ const isFile = (p) => {
82
+ try {
83
+ return statSync(join(root, p)).isFile();
84
+ } catch {
85
+ return false;
86
+ }
87
+ };
88
+ const resolve = (from, spec) => {
89
+ const bare = spec.replace(/\?[a-z]+$/, "");
90
+ let bases = [];
91
+ if (bare.startsWith(".")) bases = [normalize(join(dirname(from), bare))];
92
+ else if (bare.startsWith("/")) bases = [normalize(bare.slice(1))];
93
+ else {
94
+ const a = al.find((x) => bare.startsWith(x.prefix) && x.prefix);
95
+ if (!a) return "";
96
+ bases = a.targets.map((t) => normalize(join(t, bare.slice(a.prefix.length))));
97
+ }
98
+ for (const b of bases) for (const cand of [
99
+ b,
100
+ `${b}.ts`,
101
+ `${b}.tsx`,
102
+ `${b}.js`,
103
+ `${b}.jsx`,
104
+ `${b}/index.ts`,
105
+ `${b}/index.tsx`
106
+ ]) if (!cand.startsWith("..") && isFile(cand)) return cand.split(sep).join("/");
107
+ return null;
108
+ };
109
+ const seen = /* @__PURE__ */ new Map();
110
+ return {
111
+ isFile,
112
+ of(from) {
113
+ const hit = seen.get(from);
114
+ if (hit) return hit;
115
+ const out = {
116
+ resolved: [],
117
+ unresolved: []
118
+ };
119
+ seen.set(from, out);
120
+ if (!CODE.test(from)) return out;
121
+ let text = "";
122
+ try {
123
+ text = readFileSync(join(root, from), "utf8");
124
+ } catch {
125
+ return out;
126
+ }
127
+ for (const m of text.matchAll(IMPORT)) {
128
+ const spec = m[1] || m[2] || m[3] || m[4] || m[5] || "";
129
+ if (!spec) continue;
130
+ const r = resolve(from, spec);
131
+ if (r === "") continue;
132
+ if (r === null) {
133
+ if (spec.startsWith(".") || spec.startsWith("/") || al.some((x) => x.prefix && spec.startsWith(x.prefix))) out.unresolved.push(spec);
134
+ continue;
135
+ }
136
+ out.resolved.push(r);
137
+ }
138
+ return out;
139
+ }
140
+ };
141
+ }
142
+ //#endregion
143
+ export { imports as t };
@@ -1,10 +1,11 @@
1
1
  import { r as NAME } from "./cli.mjs";
2
- import { E as FOLDER_MODULES, O as KIND_FOLDERS, n as addFolders } from "./boards-BRLnoTC3.mjs";
2
+ import { n as addFolders, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
3
+ import { S as KIND_FOLDERS, b as FOLDER_MODULES } from "./board-tree-DRioF94d.mjs";
4
+ import { s as scanFrames, u as writeManifest } from "./manifest-DnAte_fB.mjs";
3
5
  import { r as detectAgent } from "./agent-BsieQGTD.mjs";
4
6
  import { MANAGED_PREFIX, enumerateInstructionTemplates, hashBody, pkgDir } from "./managed-HwHVNI3h.mjs";
5
7
  import { t as writeManaged } from "./managed-write-Bo-oPc-i.mjs";
6
- import { l as writeManifest, o as scanFrames } from "./manifest-TpfDWldB.mjs";
7
- import { i as readJson, r as detectHost, t as DEFAULTS } from "./config-BUKprFAp.mjs";
8
+ import { i as readJson, r as detectHost, t as DEFAULTS } from "./config-cKgZBRj0.mjs";
8
9
  import { cpSync, existsSync, mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
9
10
  import { basename, dirname, join, relative } from "node:path";
10
11
  //#region src/cli/init.ts
@@ -216,6 +217,26 @@ function init(root, opts) {
216
217
  if (opts.demo && sceneDirs === 0 && !existsSync(join(design, "scenes", "demo"))) {
217
218
  cpSync(join(templates, "demo"), join(design, "scenes", "demo"), { recursive: true });
218
219
  created.push("design/scenes/demo/ (3 frames)");
220
+ if (!listBoardFiles(join(design, "boards")).boards.length) {
221
+ const frames = [
222
+ "welcome",
223
+ "form",
224
+ "dark"
225
+ ];
226
+ writeFileSync(join(design, "boards", "welcome.json"), JSON.stringify({
227
+ version: 1,
228
+ name: "welcome",
229
+ order: 0,
230
+ auto: false,
231
+ description: "The demo scene - the file shapes of a frame; delete both once your own frames are in",
232
+ layout: {
233
+ rows: [["demo"]],
234
+ scenes: { demo: { rows: [frames] } }
235
+ },
236
+ nodes: frames.map((f) => ({ frame: `demo/${f}` }))
237
+ }, null, 2) + "\n", { flag: "wx" });
238
+ created.push("design/boards/welcome.json (the demo, the landing board)");
239
+ }
219
240
  }
220
241
  if (host.tsconfigSweepsDesign) patchTsconfigExclude(root);
221
242
  const prev = readJson(join(design, "manifest.json"))?.project;
@@ -406,7 +427,7 @@ references when you can search (craft.md "Real assets"). Reveal it EARLY with
406
427
  the board deep link and iterate together: what belongs on each screen, what
407
428
  stays out, what the intent of each step is. Wireframes and the hi-fi draft
408
429
  come after the story is agreed - and by then the brief writes itself. Delete
409
- the generic demo scene once your frames are in.
430
+ the generic demo scene and its \`welcome\` board once your frames are in.
410
431
 
411
432
  **Chose "build me something"?** The impressive first draft, below.
412
433
 
@@ -430,8 +451,9 @@ product - it sets the direction. Take the time to do it well:
430
451
  specific, confident, witty where the brand allows, never placeholder. This
431
452
  first draft is the product's first impression AND ${NAME}'s - go above and
432
453
  beyond.
433
- - Delete the generic demo scene (design/scenes/demo/) once your frames are in -
434
- it exists to show YOU the file shapes, not to impress anyone.
454
+ - Delete the generic demo scene (design/scenes/demo/) and its \`welcome\` board
455
+ once your frames are in - they exist to show YOU the file shapes, not to
456
+ impress anyone.
435
457
  - Create a curated board for them (instructions/boards.md) containing every
436
458
  frame the flow visits.
437
459
  - Offer a divergence: "want a variant of <frame> exploring a different
@@ -0,0 +1,160 @@
1
+ import { r as NAME } from "./cli.mjs";
2
+ import { d as readMembership, i as checkBoardsDir, p as unplacedHint, s as listBoardFiles } from "./boards-CGg6piKF.mjs";
3
+ import { f as isBoardName } from "./board-tree-DRioF94d.mjs";
4
+ import { s as scanFrames } from "./manifest-DnAte_fB.mjs";
5
+ import { i as readDevInfo } from "./work-GE88wb_3.mjs";
6
+ import { join } from "node:path";
7
+ //#region src/cli/link.ts
8
+ /**
9
+ * `marver link <scene/frame | scene ...>` - the canvas link that lands ON the work: the board the
10
+ * frames sit on, opened in canvas mode with them selected and the camera fitted (never past 100%) -
11
+ * not the full-screen focus view. An agent knows frame ids and scene names; it does not know the
12
+ * shell's node keys or which port `marver dev` took, so it asks here and pastes what comes back.
13
+ * `work done` prints the same links for the frames it clears; `comments new` prints its thread's.
14
+ *
15
+ * The board: `--board` when given; else the first board in sidebar order that shows EVERY frame
16
+ * asked for (archive boards last - history is not where a change is reviewed); else one link per
17
+ * board, each frame on the first board that shows it. A frame on no board gets a hint instead of a
18
+ * link (spec 26, Part 7): every frame goes on the board it belongs to.
19
+ */
20
+ /** Frame ids and scene names, as an agent writes them, against the frames on disk. */
21
+ function resolveTargets(known, targets) {
22
+ const ids = new Set(known);
23
+ const frames = [], scenes = [], all = [], exact = [];
24
+ const add = (list, v) => {
25
+ if (!list.includes(v)) list.push(v);
26
+ };
27
+ for (const raw of targets) {
28
+ const t = raw.replace(/^design\/scenes\//, "").replace(/\.(tsx|jsx|html)$/, "").replace(/\/+$/, "");
29
+ if (ids.has(t)) {
30
+ add(frames, t);
31
+ add(all, t);
32
+ add(exact, t);
33
+ continue;
34
+ }
35
+ const members = known.filter((id) => id.startsWith(`${t}/`));
36
+ if (members.length) {
37
+ if (t.includes("/")) for (const m of members) {
38
+ add(frames, m);
39
+ add(all, m);
40
+ }
41
+ else {
42
+ add(scenes, t);
43
+ for (const m of members) add(all, m);
44
+ }
45
+ continue;
46
+ }
47
+ throw new Error(`no frame or scene "${raw}" in design/scenes/ - a frame is <scene>/<name>, a scene is its folder`);
48
+ }
49
+ return {
50
+ frames,
51
+ exact,
52
+ scenes,
53
+ all
54
+ };
55
+ }
56
+ function resolveLink(root, targets, board) {
57
+ if (!targets.length) throw new Error("name what to link: link <scene/frame | scene ...>");
58
+ const known = scanFrames(root).frames.map((f) => f.id);
59
+ const t = resolveTargets(known, targets);
60
+ const dir = join(root, "design", "boards");
61
+ const files = checkBoardsDir(root, dir) ? [] : listBoardFiles(dir).boards;
62
+ const nodesOf = (name) => {
63
+ const json = files.find((b) => b.name === name)?.json;
64
+ return Array.isArray(json?.nodes) ? json.nodes.filter((n) => !!n && typeof n.frame === "string") : [];
65
+ };
66
+ const m = readMembership(root, known);
67
+ const showsAll = (b) => t.all.every((f) => b.frames.includes(f));
68
+ const q = (frames, scenes) => [frames.length ? `f=${frames.join(",")}` : "", scenes.length ? `s=${scenes.join(",")}` : ""].filter(Boolean).join("&");
69
+ let links;
70
+ let unplaced = [];
71
+ if (board) {
72
+ if (!isBoardName(board)) throw new Error(`"${board}" is not a board name`);
73
+ const b = m.boards.find((x) => x.name === board);
74
+ if (!b) throw new Error(`no board "${board}" in design/boards/`);
75
+ const missing = t.all.filter((f) => !b.frames.includes(f));
76
+ if (missing.length) throw new Error(`board "${board}" does not show ${missing.join(", ")} - pin ${missing.length === 1 ? "it" : "them"} there first (npx ${NAME} boards pin ${board} ${missing.join(" ")}), or leave --board out`);
77
+ links = [{
78
+ board,
79
+ hash: `#/b/${board}?${q(t.frames, t.scenes)}`
80
+ }];
81
+ } else {
82
+ const one = m.boards.find(showsAll);
83
+ if (one) links = [{
84
+ board: one.name,
85
+ hash: `#/b/${one.name}?${q(t.frames, t.scenes)}`
86
+ }];
87
+ else {
88
+ const left = new Set(t.all);
89
+ links = [];
90
+ for (const b of m.boards) {
91
+ const here = t.all.filter((f) => left.has(f) && b.frames.includes(f));
92
+ if (!here.length) continue;
93
+ for (const f of here) left.delete(f);
94
+ links.push({
95
+ board: b.name,
96
+ hash: `#/b/${b.name}?${q(here, [])}`
97
+ });
98
+ }
99
+ unplaced = [...left];
100
+ }
101
+ }
102
+ return {
103
+ ...t,
104
+ board: links[0]?.board,
105
+ links,
106
+ hash: links[0]?.hash,
107
+ unplaced,
108
+ hints: unplacedHint(m, unplaced),
109
+ nodesOf
110
+ };
111
+ }
112
+ /** The dev server's origin when it is running in this repo and answers like `marver dev` - else null. */
113
+ async function devOrigin(root) {
114
+ const info = readDevInfo(root);
115
+ if (!info) return null;
116
+ try {
117
+ const res = await fetch(`http://localhost:${info.port}/__mv/api/work`, {
118
+ headers: { "x-mv-work": info.token },
119
+ signal: AbortSignal.timeout(1500)
120
+ });
121
+ const data = await res.json().catch(() => null);
122
+ return res.ok && Array.isArray(data?.frames) ? `http://localhost:${info.port}/` : null;
123
+ } catch {
124
+ return null;
125
+ }
126
+ }
127
+ const NOT_RUNNING = `\`${NAME} dev\` is not running in this repo - start it (\`npx ${NAME} dev\`), then run this again: the link carries its port`;
128
+ async function linkCommand(root, targets, opts) {
129
+ const r = resolveLink(root, targets, opts.board);
130
+ if (!r.links.length) throw new Error(r.hints.join("\n"));
131
+ const origin = await devOrigin(root);
132
+ if (!origin) throw new Error(NOT_RUNNING);
133
+ for (const l of r.links) console.log(`${origin}${l.hash}`);
134
+ for (const h of r.hints) console.error(` ${h}`);
135
+ }
136
+ /** The hand-back other commands print after their own output - a link per board when `dev` runs,
137
+ * and the hint for each frame on no board. Never fails them. */
138
+ async function handBack(root, targets) {
139
+ const live = new Set(scanFrames(root).frames.map((f) => f.id));
140
+ targets = targets.filter((t) => live.has(t));
141
+ if (!targets.length) return {
142
+ links: [],
143
+ hints: []
144
+ };
145
+ try {
146
+ const r = resolveLink(root, targets);
147
+ const origin = await devOrigin(root);
148
+ return {
149
+ links: origin ? r.links.map((l) => `${origin}${l.hash}`) : [],
150
+ hints: r.hints
151
+ };
152
+ } catch {
153
+ return {
154
+ links: [],
155
+ hints: []
156
+ };
157
+ }
158
+ }
159
+ //#endregion
160
+ export { devOrigin, handBack, linkCommand, resolveLink, resolveTargets };