@bendyline/gezel-cli 1.2.7 → 1.2.8

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.
@@ -4,6 +4,10 @@
4
4
  import { basename as basename4, isAbsolute as isAbsolutePath, join as joinPath } from "path";
5
5
  import {
6
6
  GEZEL_VERSION,
7
+ IMAGE_ASPECT_RATIOS,
8
+ IMAGE_QUALITIES,
9
+ ImageAspectRatioSchema,
10
+ ImageQualitySchema,
7
11
  evaluateApiCompat as evaluateApiCompat2,
8
12
  getLogLevel as getLogLevel2,
9
13
  getLogOutput as getLogOutput2,
@@ -527,7 +531,7 @@ function cliGrantError(error, target) {
527
531
  if (error instanceof GezelSdkError) {
528
532
  if (error.code === "already_connected") {
529
533
  return new CliError(
530
- "Gezel already has a CLI authorization, but this terminal no longer has its token. Revoke \u201CGezel CLI\u201D in Settings \u2192 Connected Apps, then run this command again."
534
+ "Gezel already has a CLI authorization, but this terminal no longer has its token. Revoke \u201CGezel CLI\u201D in Settings \u2192 Integrations, then run this command again."
531
535
  );
532
536
  }
533
537
  if (error.code === "user_denied") {
@@ -545,7 +549,7 @@ function cliGrantError(error, target) {
545
549
  }
546
550
  if (error.code === "grant_already_pending") {
547
551
  return new CliError(
548
- `An earlier Gezel CLI connection request to ${target} is still waiting to be approved, so a new code cannot be issued yet. Approve or dismiss it in Gezel under Settings \u2192 Connected Apps, or wait ${PENDING_GRANT_MINUTES} minutes for it to expire and run this command again.`
552
+ `An earlier Gezel CLI connection request to ${target} is still waiting to be approved, so a new code cannot be issued yet. Approve or dismiss it in Gezel under Settings \u2192 Integrations, or wait ${PENDING_GRANT_MINUTES} minutes for it to expire and run this command again.`
549
553
  );
550
554
  }
551
555
  if (error.code === "daemon_not_running") {
@@ -621,7 +625,7 @@ async function validateCliClient(client, label) {
621
625
  } catch (error) {
622
626
  if (error instanceof GezelApiError && (error.status === 401 || error.status === 403)) {
623
627
  throw new CliError(
624
- `${label} does not have CLI access. Revoke \u201CGezel CLI\u201D in Settings \u2192 Connected Apps and authorize it again.`
628
+ `${label} does not have CLI access. Revoke \u201CGezel CLI\u201D in Settings \u2192 Integrations and authorize it again.`
625
629
  );
626
630
  }
627
631
  throw error;
@@ -1828,6 +1832,13 @@ function intOpt(name, v) {
1828
1832
  if (!Number.isInteger(n)) throw new CliError(`--${name} must be an integer (got "${v}").`);
1829
1833
  return n;
1830
1834
  }
1835
+ function enumOpt(name, v, schema) {
1836
+ if (v === void 0) return void 0;
1837
+ const value = schema.options.find((o) => o === v.trim());
1838
+ if (!value)
1839
+ throw new CliError(`--${name} must be one of ${schema.options.join(", ")} (got "${v}").`);
1840
+ return value;
1841
+ }
1831
1842
  function floatOpt(name, v) {
1832
1843
  if (v === void 0) return void 0;
1833
1844
  const n = Number.parseFloat(v);
@@ -1888,6 +1899,111 @@ function assertCatalogOnlyOptions(opts, kind) {
1888
1899
  }
1889
1900
  }
1890
1901
 
1902
+ // src/mcp-command.ts
1903
+ import {
1904
+ HARNESS_AGENT_FILE,
1905
+ HARNESS_CLIENT_IDS,
1906
+ HarnessClientIdSchema,
1907
+ harnessAgentFileLine,
1908
+ harnessPromptInvocation
1909
+ } from "@bendyline/gezel";
1910
+ import { GezelApiError as GezelApiError2, apiErrorMessage } from "@bendyline/gezel-client";
1911
+ var STATE_WORDS = {
1912
+ configured: "set up",
1913
+ "not-configured": "not set up",
1914
+ "update-needed": "needs repair",
1915
+ conflict: "needs attention",
1916
+ unavailable: "unavailable"
1917
+ };
1918
+ function clientId(name) {
1919
+ const parsed = HarnessClientIdSchema.safeParse(name);
1920
+ if (!parsed.success) {
1921
+ throw new CliError(`Unknown app "${name}". Choose one of: ${HARNESS_CLIENT_IDS.join(", ")}.`);
1922
+ }
1923
+ return parsed.data;
1924
+ }
1925
+ function describe(status) {
1926
+ const lines = [`${status.label}: ${STATE_WORDS[status.state]}`];
1927
+ if (status.configPath) lines.push(` settings: ${status.configPath}`);
1928
+ for (const reason of status.reasons) lines.push(` ${reason}`);
1929
+ if (status.state !== "configured" && status.manualCommand) {
1930
+ lines.push(` to set it up yourself: ${status.manualCommand}`);
1931
+ }
1932
+ return lines.join("\n");
1933
+ }
1934
+ async function call(fn) {
1935
+ try {
1936
+ return await fn();
1937
+ } catch (error) {
1938
+ if (error instanceof GezelApiError2) throw new CliError(apiErrorMessage(error));
1939
+ throw error;
1940
+ }
1941
+ }
1942
+ function registerMcpCommands(program2, connect, output = console.log) {
1943
+ const mcp = program2.command("mcp").description(
1944
+ "Give other AI apps Gezel's tools (Claude Code, Codex, Cursor, Claude Desktop, VS Code)"
1945
+ );
1946
+ mcp.command("status").description("Show which apps have Gezel's tools and what they may do").option("--json", "Output the full status as JSON").action(async (options) => {
1947
+ const status = await call(async () => (await connect()).getHarnessTools());
1948
+ if (options.json) {
1949
+ output(JSON.stringify(status));
1950
+ return;
1951
+ }
1952
+ const { config } = status;
1953
+ const lines = [
1954
+ `Gezel's tools in other apps: ${config.enabled ? "on" : "off"} (memories: ${config.memory}, images: ${config.images}, new folders: ${config.newFolders})`,
1955
+ ...status.unavailableReason ? [status.unavailableReason] : [],
1956
+ "",
1957
+ ...status.clients.map(describe)
1958
+ ];
1959
+ if (status.connections.length > 0) {
1960
+ lines.push("", "In use now:");
1961
+ for (const c of status.connections) {
1962
+ lines.push(
1963
+ ` ${c.label}: ${c.projectName ?? "no project"}${c.folder ? ` (${c.folder})` : ""}`
1964
+ );
1965
+ }
1966
+ }
1967
+ output(lines.join("\n"));
1968
+ });
1969
+ mcp.command("install <app>").description(`Set up Gezel's tools in one app: ${HARNESS_CLIENT_IDS.join(", ")}`).option("--project <id>", "Claude Desktop: the Gezel project it works in").option("--profile <id>", "VS Code: the profile to set up").option("--replace", 'Replace a "gezel" entry Gezel did not write (it is kept as a backup)').option("--json", "Output the app status as JSON").action(async (app, options) => {
1970
+ const client = clientId(app);
1971
+ const status = await call(
1972
+ async () => (await connect()).configureHarnessTools(client, {
1973
+ ...options.project ? { projectId: options.project } : {},
1974
+ ...options.profile ? { profileId: options.profile } : {},
1975
+ ...options.replace ? { replaceExisting: true } : {}
1976
+ })
1977
+ );
1978
+ if (options.json) {
1979
+ output(JSON.stringify(status));
1980
+ return;
1981
+ }
1982
+ const lines = [describe(status)];
1983
+ const line = harnessAgentFileLine(client);
1984
+ if (status.state === "configured" && line) {
1985
+ lines.push(
1986
+ "",
1987
+ `${status.label} reaches for its own search first. So it uses Gezel's, add this line to the ${HARNESS_AGENT_FILE[client]} file in a folder you work in:`,
1988
+ "",
1989
+ ` ${line}`
1990
+ );
1991
+ }
1992
+ const triage = harnessPromptInvocation(client, "triage_issues");
1993
+ if (status.state === "configured" && triage) {
1994
+ lines.push(
1995
+ "",
1996
+ `To have ${status.label} check the suspected problems Gezel's night shift found, run ${triage} in a folder Gezel knows.`
1997
+ );
1998
+ }
1999
+ output(lines.join("\n"));
2000
+ });
2001
+ mcp.command("remove <app>").description("Take Gezel's tools out of one app").option("--json", "Output the app status as JSON").action(async (app, options) => {
2002
+ const status = await call(async () => (await connect()).removeHarnessTools(clientId(app)));
2003
+ output(options.json ? JSON.stringify(status) : describe(status));
2004
+ });
2005
+ }
2006
+
1891
2007
  // src/model-choice.ts
1892
2008
  async function installedChatModels(client, engine) {
1893
2009
  const { models } = engine === "mlx" ? await client.listMlxModels() : engine === "ds4" ? await client.listDs4Models() : await client.listLlamaCppModels();
@@ -2439,9 +2555,40 @@ var ReplyPrinter = class {
2439
2555
  this.printed = visible;
2440
2556
  }
2441
2557
  };
2558
+ var RunOutput = class {
2559
+ constructor(write) {
2560
+ this.write = write;
2561
+ this.current = this.nextReply();
2562
+ }
2563
+ write;
2564
+ current;
2565
+ printedAny = false;
2566
+ push(chunk) {
2567
+ this.current.push(chunk);
2568
+ }
2569
+ /** One assistant message was saved; later deltas belong to the next one. */
2570
+ complete(committed) {
2571
+ this.current.finish(committed);
2572
+ this.current = this.nextReply();
2573
+ }
2574
+ /** The stream ended. Returns whether anything was printed. */
2575
+ finish() {
2576
+ this.current.finish();
2577
+ return this.printedAny;
2578
+ }
2579
+ nextReply() {
2580
+ let started = false;
2581
+ return new ReplyPrinter((text) => {
2582
+ if (!started && this.printedAny) this.write("\n\n");
2583
+ started = true;
2584
+ this.printedAny = true;
2585
+ this.write(text);
2586
+ });
2587
+ }
2588
+ };
2442
2589
 
2443
2590
  // src/secrets-command.ts
2444
- import { GezelApiError as GezelApiError2 } from "@bendyline/gezel-client";
2591
+ import { GezelApiError as GezelApiError3 } from "@bendyline/gezel-client";
2445
2592
  var credentialFlags = {
2446
2593
  githubToken: "hasGithubToken",
2447
2594
  openaiApiKey: "hasOpenaiApiKey",
@@ -2495,7 +2642,7 @@ async function writeCredential(client, patch) {
2495
2642
  try {
2496
2643
  await client.updateConfig(patch);
2497
2644
  } catch (error) {
2498
- const status = error instanceof GezelApiError2 ? ` (HTTP ${error.status})` : "";
2645
+ const status = error instanceof GezelApiError3 ? ` (HTTP ${error.status})` : "";
2499
2646
  throw new CliError(
2500
2647
  `Could not update the credential${status}. Check the service connection and permissions.`
2501
2648
  );
@@ -2892,6 +3039,7 @@ program.name("gezel").description("Gezel \u2014 assemble a team of AI companions
2892
3039
  );
2893
3040
  var cliGlobals = () => program.opts();
2894
3041
  registerSecretCommands(program, () => connectOwned(cliGlobals()));
3042
+ registerMcpCommands(program, () => connectOwned(cliGlobals()));
2895
3043
  registerSecurityCommands(program, () => connectOwned(cliGlobals()));
2896
3044
  program.hook("preAction", () => {
2897
3045
  const globals = cliGlobals();
@@ -3336,9 +3484,8 @@ Replies go to stdout; diagnostics go to stderr.`
3336
3484
  }
3337
3485
  const session = await client.createChatSession({ gezelId, projectId, oneShot: true });
3338
3486
  await client.sendToChatSession(session.id, prompt);
3339
- const reply = new ReplyPrinter((text) => process.stdout.write(text));
3487
+ const reply = new RunOutput((text) => process.stdout.write(text));
3340
3488
  const progress = new RunProgress((text) => process.stderr.write(text));
3341
- let printed = false;
3342
3489
  let errored = false;
3343
3490
  for await (const ev of streamChatEvents({
3344
3491
  url: client.sessionEventsUrl(session.id),
@@ -3352,7 +3499,7 @@ Replies go to stdout; diagnostics go to stderr.`
3352
3499
  reply.push(ev.content);
3353
3500
  } else if (ev.type === "complete") {
3354
3501
  progress.settle();
3355
- printed = reply.finish(ev.message.content);
3502
+ reply.complete(ev.message.content);
3356
3503
  } else if (ev.type === "error") {
3357
3504
  progress.settle();
3358
3505
  console.error(`
@@ -3361,8 +3508,7 @@ ${ev.error}`);
3361
3508
  }
3362
3509
  }
3363
3510
  progress.settle();
3364
- printed = reply.finish() || printed;
3365
- if (printed) process.stdout.write("\n");
3511
+ if (reply.finish()) process.stdout.write("\n");
3366
3512
  if (errored) process.exitCode = 1;
3367
3513
  } finally {
3368
3514
  removeSignalCleanup?.();
@@ -3978,6 +4124,10 @@ appCmd.command("pack <folder>").description("Validate and pack an AI App source
3978
4124
  const { runAppPack } = await loadAppAuthorCommand();
3979
4125
  await runAppPack(folder, opts);
3980
4126
  });
4127
+ appCmd.command("demo <folder>").description("Export an offline page demo with shared components and fonts (no daemon needed)").requiredOption("-o, --out <directory>", "new output directory for the generated demo").action(async (folder, opts) => {
4128
+ const { runAppDemo } = await loadAppAuthorCommand();
4129
+ await runAppDemo(folder, opts);
4130
+ });
3981
4131
  appCmd.command("schemas").description("The JSON Schemas an AI App author codes against, rendered from this build").option("--out <dir>", "write the schema files into a directory").option("--json", "print one combined JSON object").action(async (opts) => {
3982
4132
  const { runAppSchemas } = await loadAppAuthorCommand();
3983
4133
  await runAppSchemas(opts);
@@ -4076,8 +4226,10 @@ ${warning.text}`)
4076
4226
  ].join("\n\n") || "(no task notes)"
4077
4227
  );
4078
4228
  });
4079
- program.command("create-image [prompt...]").description("Generate an image from a prompt (or --file) via the configured image engine").option("-f, --file <path>", "read the prompt from a text file instead of the argument").option("-m, --model <id>", "image model catalog id (default: the engine default)").option("-n, --negative <text>", "negative prompt").option("-W, --width <px>", "width in pixels").option("-H, --height <px>", "height in pixels").option("-s, --steps <n>", "sampler steps (default: the model recommendation)").option("--seed <n>", "seed for reproducible output").option("-p, --project <id>", "project to write the artifact under", "default").option("-o, --output <path>", "write the image here (default: ./<artifact name>)").action(
4229
+ program.command("create-image [prompt...]").description("Generate an image from a prompt (or --file) via the configured image engine").option("-f, --file <path>", "read the prompt from a text file instead of the argument").option("-m, --model <id>", "image model catalog id (default: the engine default)").option("-n, --negative <text>", "negative prompt").option("-W, --width <px>", "width in pixels").option("-H, --height <px>", "height in pixels").option("-a, --aspect <ratio>", `aspect ratio: ${IMAGE_ASPECT_RATIOS.join(", ")}`).option("-q, --quality <tier>", `size tier: ${IMAGE_QUALITIES.join(", ")} (default: standard)`).option("-s, --steps <n>", "sampler steps (default: the model recommendation)").option("--seed <n>", "seed for reproducible output").option("-p, --project <id>", "project to write the artifact under", "default").option("-o, --output <path>", "write the image here (default: ./<artifact name>)").action(
4080
4230
  async (promptParts, opts) => {
4231
+ const aspect = enumOpt("aspect", opts.aspect, ImageAspectRatioSchema);
4232
+ const quality = enumOpt("quality", opts.quality, ImageQualitySchema);
4081
4233
  const prompt = await resolvePromptText(promptParts, opts.file, "prompt");
4082
4234
  const client = await connectOwned(cliGlobals());
4083
4235
  const projectId = opts.project ?? "default";
@@ -4095,6 +4247,8 @@ program.command("create-image [prompt...]").description("Generate an image from
4095
4247
  ...opts.negative ? { negativePrompt: opts.negative } : {},
4096
4248
  ...width !== void 0 ? { width } : {},
4097
4249
  ...height !== void 0 ? { height } : {},
4250
+ ...aspect ? { aspectRatio: aspect } : {},
4251
+ ...quality ? { quality } : {},
4098
4252
  ...steps !== void 0 ? { steps } : {},
4099
4253
  ...seed !== void 0 ? { seed } : {}
4100
4254
  });
@@ -2,8 +2,8 @@
2
2
 
3
3
  // src/handboek-export.ts
4
4
  import { existsSync as existsSync2 } from "fs";
5
- import { cp, mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
6
- import { join as join2, resolve } from "path";
5
+ import { cp, mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
6
+ import { join as join4, resolve } from "path";
7
7
  import { SCORECARD_DATA_ATTRS as SCORECARD_DATA_ATTRS2 } from "@bendyline/gezel";
8
8
  import { CatalogService } from "@bendyline/gezel-catalog";
9
9
  import {
@@ -492,7 +492,7 @@ async function projectTypeDemo(catalog, pt) {
492
492
  const bytes = await catalog.readItemFile("project-type", pt.id, `${prefix}${path}`);
493
493
  if (bytes) files.push({ path, bytes });
494
494
  }
495
- return { projectTypeId: pt.id, entry, files };
495
+ return { projectTypeId: pt.id, entry, files, imports: pt.pages?.imports };
496
496
  }
497
497
  function demoSectionHtml(demo, title) {
498
498
  const src = `demo/${demo.entry.split("/").map(encodeURIComponent).join("/")}`;
@@ -1413,6 +1413,77 @@ var SCORECARD_FILTER_JS = `(function () {
1413
1413
  })();
1414
1414
  `;
1415
1415
 
1416
+ // src/page-demo-export.ts
1417
+ import { createHash as createHash2 } from "crypto";
1418
+ import { readFileSync as readFileSync2 } from "fs";
1419
+ import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
1420
+ import { dirname as dirname2, join as join3, relative as relative2 } from "path";
1421
+ import { fileURLToPath } from "url";
1422
+ import { injectPageDemo, pageDemoBootstrapSource } from "@bendyline/gezel";
1423
+
1424
+ // ../../scripts/project-page-typography.mjs
1425
+ import { readFileSync } from "fs";
1426
+ import { join as join2 } from "path";
1427
+ function buildProjectPageTypography(uiRoot) {
1428
+ const fonts = join2(uiRoot, "src/assets/fonts");
1429
+ const faces = readFileSync(join2(fonts, "ui-fonts.css"), "utf8").replace(
1430
+ /url\("\.\/([a-z0-9-]+\.woff2)"\)/g,
1431
+ (_, name) => `url("data:font/woff2;base64,${readFileSync(join2(fonts, name)).toString("base64")}")`
1432
+ );
1433
+ return [
1434
+ faces,
1435
+ readFileSync(join2(fonts, "typography-tokens.css"), "utf8"),
1436
+ readFileSync(join2(fonts, "page-defaults.css"), "utf8")
1437
+ ].join("\n");
1438
+ }
1439
+
1440
+ // src/page-demo-export.ts
1441
+ function pageDemoAssets() {
1442
+ const sourceMode = import.meta.url.endsWith(".ts");
1443
+ const fonts = fileURLToPath(new URL("../../ui/src/assets/fonts/", import.meta.url));
1444
+ const css = sourceMode ? buildProjectPageTypography(fileURLToPath(new URL("../../ui", import.meta.url))) : readFileSync2(new URL("./page-typography.css", import.meta.url), "utf8");
1445
+ const versioned = (stem, extension, source) => ({
1446
+ path: `${stem}-${createHash2("sha256").update(source).digest("hex").slice(0, 16)}.${extension}`,
1447
+ bytes: Buffer.from(source)
1448
+ });
1449
+ return [
1450
+ versioned("bootstrap", "js", pageDemoBootstrapSource()),
1451
+ versioned("typography", "css", css),
1452
+ ...["LICENSE-HankenGrotesk-OFL-1.1.txt", "LICENSE-PTSerif-OFL-1.1.txt"].map((path) => ({
1453
+ path,
1454
+ bytes: readFileSync2(sourceMode ? join3(fonts, path) : new URL(`./${path}`, import.meta.url))
1455
+ }))
1456
+ ];
1457
+ }
1458
+ async function writePageDemoAssets(directory) {
1459
+ const assets = pageDemoAssets();
1460
+ await mkdir2(directory, { recursive: true });
1461
+ for (const asset of assets) await writeFile2(join3(directory, asset.path), asset.bytes);
1462
+ return assets;
1463
+ }
1464
+ async function writePageDemo(directory, files, config, shared) {
1465
+ const script = shared.assets.find((file) => file.path.endsWith(".js"));
1466
+ const style = shared.assets.find((file) => file.path.endsWith(".css"));
1467
+ for (const file of files) {
1468
+ if (!file.path || file.path.split(/[\\/]/).some((part) => !part || part === "." || part === "..") || /[:\\]/.test(file.path)) {
1469
+ throw new Error(`Unsafe demo asset path: ${file.path}`);
1470
+ }
1471
+ const target = join3(directory, file.path);
1472
+ let bytes = file.bytes;
1473
+ if (/\.html?$/i.test(file.path)) {
1474
+ const url = (name) => relative2(dirname2(target), join3(shared.directory, name)).split(/[\\/]/).map((part) => part === ".." ? part : encodeURIComponent(part)).join("/");
1475
+ bytes = Buffer.from(
1476
+ injectPageDemo(bytes.toString("utf8"), config, {
1477
+ scriptUrl: url(script.path),
1478
+ styleUrl: url(style.path)
1479
+ })
1480
+ );
1481
+ }
1482
+ await mkdir2(dirname2(target), { recursive: true });
1483
+ await writeFile2(target, bytes);
1484
+ }
1485
+ }
1486
+
1416
1487
  // src/handboek-export.ts
1417
1488
  var NAV_INLINE_MAX = 40;
1418
1489
  var SCORECARD_SCRIPT = "scorecard.js";
@@ -1449,6 +1520,8 @@ async function runHandboekExport(opts) {
1449
1520
  const site = await buildSiteCatalog(catalog);
1450
1521
  const sitePages = new Map(site.pages.map((p) => [p.entry.id, p]));
1451
1522
  const demos = new Map(site.demos.map((d) => [`project-type/${d.projectTypeId}`, d]));
1523
+ const demoAssetsDirectory = join4(out, "_gezel-demo");
1524
+ const demoAssets = site.demos.length ? await writePageDemoAssets(demoAssetsDirectory) : [];
1452
1525
  const areas = toc.areas.map((a) => ({
1453
1526
  ...a,
1454
1527
  entries: [
@@ -1466,9 +1539,9 @@ async function runHandboekExport(opts) {
1466
1539
  const stem = e.id.split("/").pop();
1467
1540
  if (stem && !byStem.has(stem)) byStem.set(stem, e.id);
1468
1541
  }
1469
- await mkdir2(join2(out, "assets"), { recursive: true });
1470
- await writeFile2(join2(out, "assets", "squisq-player.js"), PLAYER_BUNDLE, "utf8");
1471
- await writeFile2(join2(out, "assets", SCORECARD_SCRIPT), SCORECARD_FILTER_JS, "utf8");
1542
+ await mkdir3(join4(out, "assets"), { recursive: true });
1543
+ await writeFile3(join4(out, "assets", "squisq-player.js"), PLAYER_BUNDLE, "utf8");
1544
+ await writeFile3(join4(out, "assets", SCORECARD_SCRIPT), SCORECARD_FILTER_JS, "utf8");
1472
1545
  const skipped = [];
1473
1546
  let pages = 0;
1474
1547
  const headlines = readOgHeadlines(contentDir);
@@ -1500,15 +1573,19 @@ ${sitePage.html}`;
1500
1573
  if (demo) rendered = insertDemoSection(rendered, demoSectionHtml(demo, entry.title));
1501
1574
  if (art) rendered = insertAfterTitle(rendered, craftbookArtHtml(entry.title));
1502
1575
  const { html: body, headings } = withHeadingIds(rendered);
1503
- const dir = join2(out, ...entry.id.split("/"));
1504
- await mkdir2(dir, { recursive: true });
1505
- if (art) await writeFile2(join2(dir, CRAFTBOOK_ART_FILE), art);
1576
+ const dir = join4(out, ...entry.id.split("/"));
1577
+ await mkdir3(dir, { recursive: true });
1578
+ if (art) await writeFile3(join4(dir, CRAFTBOOK_ART_FILE), art);
1506
1579
  if (demo) {
1507
- for (const file of demo.files) {
1508
- const target = join2(dir, "demo", ...file.path.split("/"));
1509
- await mkdir2(join2(target, ".."), { recursive: true });
1510
- await writeFile2(target, file.bytes);
1511
- }
1580
+ await writePageDemo(
1581
+ join4(dir, "demo"),
1582
+ demo.files,
1583
+ { imports: demo.imports },
1584
+ {
1585
+ directory: demoAssetsDirectory,
1586
+ assets: demoAssets
1587
+ }
1588
+ );
1512
1589
  }
1513
1590
  const headline = resolveOgHeadline(entry, headlines);
1514
1591
  if (ogBase) {
@@ -1520,8 +1597,8 @@ ${sitePage.html}`;
1520
1597
  image: ogBase ? `${ogBase}${ogCardPath(entry.id)}` : void 0,
1521
1598
  imageAlt: headline
1522
1599
  } : void 0;
1523
- await writeFile2(
1524
- join2(dir, "index.html"),
1600
+ await writeFile3(
1601
+ join4(dir, "index.html"),
1525
1602
  articlePage({
1526
1603
  entry,
1527
1604
  body,
@@ -1539,8 +1616,8 @@ ${sitePage.html}`;
1539
1616
  articleId: article.id,
1540
1617
  defaultDuration: article.defaultDuration ?? 6
1541
1618
  });
1542
- await writeFile2(
1543
- join2(dir, "watch.html"),
1619
+ await writeFile3(
1620
+ join4(dir, "watch.html"),
1544
1621
  generateExternalHtml(doc, {
1545
1622
  playerScriptPath: `${up(depth)}assets/squisq-player.js`,
1546
1623
  mode: "slideshow",
@@ -1564,13 +1641,13 @@ ${sitePage.html}`;
1564
1641
  headline: "The Gezel Handboek"
1565
1642
  });
1566
1643
  }
1567
- await writeFile2(join2(out, "index.html"), landingPage(areas, css, siteUrl, landingSocial), "utf8");
1644
+ await writeFile3(join4(out, "index.html"), landingPage(areas, css, siteUrl, landingSocial), "utf8");
1568
1645
  pages += 1;
1569
- const assetsSrc = join2(contentDir, "assets");
1646
+ const assetsSrc = join4(contentDir, "assets");
1570
1647
  if (existsSync2(assetsSrc)) {
1571
- await cp(assetsSrc, join2(out, "assets"), { recursive: true });
1648
+ await cp(assetsSrc, join4(out, "assets"), { recursive: true });
1572
1649
  }
1573
- await writeFile2(join2(out, "assets", "handboek.css"), BASELINE_CSS, "utf8");
1650
+ await writeFile3(join4(out, "assets", "handboek.css"), BASELINE_CSS, "utf8");
1574
1651
  const cards = ogBase && opts.ogOut ? await writeOgCards({
1575
1652
  home: opts.home ?? gezelHome(),
1576
1653
  dir: resolve(opts.ogOut),
@@ -1591,11 +1668,12 @@ function rewriteSiteLinks(markdown, pageId, ids, byStem) {
1591
1668
  return whole;
1592
1669
  }
1593
1670
  const [path, suffix = ""] = splitLinkSuffix(rawTarget);
1594
- const candidate = path.replace(/\.md$/, "").replace(/^(\.\.?\/)+/, "");
1671
+ const candidate = path.replace(/^(\.\.?\/)+/, "");
1595
1672
  if (candidate.startsWith("assets/")) {
1596
1673
  return `](${prefix}${candidate}${suffix})`;
1597
1674
  }
1598
- const target = ids.has(candidate) ? candidate : byStem.get(candidate.split("/").pop() ?? "");
1675
+ const article = candidate.replace(/\.md$/, "");
1676
+ const target = ids.has(article) ? article : byStem.get(article.split("/").pop() ?? "");
1599
1677
  if (!target) return whole;
1600
1678
  return `](${prefix}${target}/${suffix})`;
1601
1679
  });