@bendyline/gezel-cli 1.2.3 → 1.2.5

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.
@@ -109,6 +109,462 @@ async function writeOgCards(opts) {
109
109
  return result;
110
110
  }
111
111
 
112
+ // src/handboek-site-catalog.ts
113
+ import {
114
+ CRAFTBOOK_CATEGORY_FAMILY_META,
115
+ CRAFTBOOK_CATEGORY_META,
116
+ resolveCraftbookCategory
117
+ } from "@bendyline/gezel";
118
+ var CRAFTBOOK_ART_FILE = "logo.webp";
119
+ var MODEL_CATALOG_ID = "model-catalog";
120
+ var TOOLSET_CATALOG_ID = "toolset-catalog";
121
+ var ROLE_CATALOG_ID = "role-catalog";
122
+ var MODELS_AND_TESTING = {
123
+ id: "models-and-testing",
124
+ title: "Models and Testing",
125
+ order: 4
126
+ };
127
+ var HOW_GEZEL_WORKS = {
128
+ id: "how-gezel-works",
129
+ title: "How Gezel works",
130
+ order: 1
131
+ };
132
+ var ENGINE_LABELS = [
133
+ ["llamaCpp", "llama.cpp"],
134
+ ["mlx", "MLX"],
135
+ ["ollama", "Ollama"],
136
+ ["ds4", "DwarfStar"]
137
+ ];
138
+ var CATEGORY_LABELS = {
139
+ general: "Everyday work",
140
+ reasoning: "Reasoning",
141
+ coding: "Coding"
142
+ };
143
+ async function buildSiteCatalog(catalog) {
144
+ const manifests = async (kind) => (await catalog.list(kind)).map((s) => s.manifest);
145
+ const chat = (await manifests("chat-model")).sort(
146
+ (a, b) => (b.recoScore ?? -1) - (a.recoScore ?? -1) || a.name.localeCompare(b.name)
147
+ );
148
+ const images = (await manifests("image-model")).sort(byName);
149
+ const videos = (await manifests("video-model")).sort(byName);
150
+ const toolsets = await catalog.list("toolset");
151
+ const addOns = toolsets.filter((s) => s.sourceId !== "community" && s.sourceId !== "builtin").map((s) => s.manifest).sort(byName);
152
+ const communityCount = toolsets.filter((s) => s.sourceId === "community").length;
153
+ const connectors = (await manifests("connector-type")).sort(byName);
154
+ const roles = (await manifests("gezel-template")).sort(byName);
155
+ const projectTypes = await manifests("project-type");
156
+ const craftbooks = (await manifests("craftbook-template")).sort(
157
+ byName
158
+ );
159
+ const craftbookArt = /* @__PURE__ */ new Map();
160
+ for (const book of craftbooks) {
161
+ if (book.logo !== CRAFTBOOK_ART_FILE) continue;
162
+ const bytes = await catalog.readItemFile("craftbook-template", book.id, CRAFTBOOK_ART_FILE);
163
+ if (bytes) craftbookArt.set(book.id, bytes);
164
+ }
165
+ const roleAbouts = /* @__PURE__ */ new Map();
166
+ for (const role of roles) {
167
+ if (!role.about) continue;
168
+ const bytes = await catalog.readItemFile(
169
+ "gezel-template",
170
+ role.id,
171
+ role.about,
172
+ void 0,
173
+ role.version
174
+ );
175
+ if (bytes) roleAbouts.set(role.id, bytes.toString("utf8"));
176
+ }
177
+ const pages = [
178
+ {
179
+ entry: {
180
+ id: MODEL_CATALOG_ID,
181
+ title: "Every model",
182
+ area: "technical",
183
+ order: 14,
184
+ summary: "Every AI model Gezel can run on your own computer, with size, context and license.",
185
+ generated: true,
186
+ subcategory: MODELS_AND_TESTING
187
+ },
188
+ markdown: modelCatalogMarkdown(chat, images, videos),
189
+ listed: true
190
+ },
191
+ ...chat.map((m) => ({
192
+ entry: {
193
+ id: `model/${m.id}`,
194
+ title: m.name,
195
+ area: "technical",
196
+ order: 100,
197
+ summary: firstSentence(m.description),
198
+ generated: true,
199
+ subcategory: MODELS_AND_TESTING
200
+ },
201
+ markdown: chatModelMarkdown(m),
202
+ listed: false
203
+ })),
204
+ {
205
+ entry: {
206
+ id: TOOLSET_CATALOG_ID,
207
+ title: "Add-on toolsets and connectors",
208
+ area: "technical",
209
+ order: 4.5,
210
+ summary: "Toolsets you can add to a gezel, and connectors that bring outside data into a project.",
211
+ generated: true,
212
+ subcategory: HOW_GEZEL_WORKS
213
+ },
214
+ markdown: toolsetCatalogMarkdown(addOns, connectors, communityCount),
215
+ listed: true
216
+ },
217
+ {
218
+ entry: {
219
+ id: ROLE_CATALOG_ID,
220
+ title: "Every role template",
221
+ area: "gezel-roles",
222
+ order: 1,
223
+ summary: "Ready-made characters you can add to your crew, from researcher to meal planner.",
224
+ generated: true
225
+ },
226
+ markdown: roleCatalogMarkdown(roles),
227
+ listed: true
228
+ },
229
+ ...roles.map((r) => ({
230
+ entry: {
231
+ id: `role-template/${r.id}`,
232
+ title: r.name,
233
+ area: "gezel-roles",
234
+ order: 100,
235
+ summary: firstSentence(r.description),
236
+ generated: true
237
+ },
238
+ markdown: roleTemplateMarkdown(r, roleAbouts.get(r.id)),
239
+ listed: false
240
+ })),
241
+ {
242
+ entry: {
243
+ id: "craftbooks-index",
244
+ title: "Every craftbook",
245
+ area: "craftbooks",
246
+ order: 0,
247
+ generated: true
248
+ },
249
+ markdown: [
250
+ "# Every craftbook",
251
+ "",
252
+ `Craftbooks are step-by-step plans your crew follows to produce a real piece of work. Each one names its steps, who runs them, and the checks the result must pass. There are ${craftbooks.length} of them, grouped here by the kind of work they do.`
253
+ ].join("\n"),
254
+ html: craftbookGalleryHtml(craftbooks, craftbookArt),
255
+ listed: false,
256
+ replaces: true
257
+ }
258
+ ];
259
+ const demos = [];
260
+ for (const pt of projectTypes) {
261
+ const demo = await projectTypeDemo(catalog, pt);
262
+ if (demo) demos.push(demo);
263
+ }
264
+ return { pages, demos, craftbookArt };
265
+ }
266
+ function modelCatalogMarkdown(chat, images, videos) {
267
+ const lines = [
268
+ "# Every model",
269
+ "",
270
+ "These are all the AI models in Gezel\u2019s catalog. Each one runs on your own computer through an engine Gezel installs for you, and Gezel recommends the ones that fit your hardware when you set it up. The [model scorecard](model-scorecard) shows how the models we test actually do on real jobs, and [Local models and tiers](local-models-and-tiers) explains how to choose.",
271
+ "",
272
+ `## Chat models (${chat.length})`,
273
+ "",
274
+ "The models your gezels think and write with, recommended first.",
275
+ "",
276
+ "| Model | Size | Context | Tools | Best for | Runs on | License |",
277
+ "| --- | --- | --- | --- | --- | --- | --- |",
278
+ ...chat.map(
279
+ (m) => row([
280
+ `[${cell(m.name)}](model/${m.id})`,
281
+ formatGB(m.approxSizeBytes),
282
+ formatContext(m.contextWindow),
283
+ m.supportsTools === false ? "No" : "Yes",
284
+ CATEGORY_LABELS[m.category ?? ""] ?? "",
285
+ engines(m).join(", "),
286
+ cell(m.licenseShortName ?? m.license ?? "")
287
+ ])
288
+ )
289
+ ];
290
+ if (images.length > 0) {
291
+ lines.push(
292
+ "",
293
+ `## Image models (${images.length})`,
294
+ "",
295
+ "Models your crew can use to draw pictures, icons and illustrations. Gezel works out what each one needs from its files and offers only the ones your machine can run.",
296
+ "",
297
+ "| Model | Size | Commercial use | License |",
298
+ "| --- | --- | --- | --- |",
299
+ ...images.map(
300
+ (m) => row([
301
+ link(m.name, m.upstream),
302
+ formatGB(m.approxSizeBytes),
303
+ yesNo(m.commercialUse),
304
+ cell(m.licenseShortName ?? m.license ?? "")
305
+ ])
306
+ )
307
+ );
308
+ }
309
+ if (videos.length > 0) {
310
+ lines.push(
311
+ "",
312
+ `## Video models (${videos.length})`,
313
+ "",
314
+ "Models that turn a prompt or a picture into a short clip. Gezel works out what each one needs from its files and offers only the ones your machine can run.",
315
+ "",
316
+ "| Model | Size | Longest clip | Commercial use | License |",
317
+ "| --- | --- | --- | --- | --- |",
318
+ ...videos.map(
319
+ (m) => row([
320
+ link(m.name, m.upstream),
321
+ formatGB(m.approxSizeBytes),
322
+ m.maxDurationSeconds ? `${m.maxDurationSeconds} s` : "",
323
+ yesNo(m.commercialUse),
324
+ cell(m.licenseShortName ?? m.license ?? "")
325
+ ])
326
+ )
327
+ );
328
+ }
329
+ return lines.join("\n");
330
+ }
331
+ function chatModelMarkdown(m) {
332
+ const maker = m.maker?.name ?? m.maintainer?.name;
333
+ const facts = [
334
+ ["Made by", maker ?? ""],
335
+ ["Download size", formatGB(m.approxSizeBytes)],
336
+ ["Parameters", m.parameterSize ?? ""],
337
+ ["Quantization", quantization(m)],
338
+ ["Context window", m.contextWindow ? `${formatContext(m.contextWindow)} tokens` : ""],
339
+ ["Uses tools", m.supportsTools === false ? "No" : "Yes"],
340
+ ["Best for", CATEGORY_LABELS[m.category ?? ""] ?? ""],
341
+ ["Runs on", engines(m).join(", ")],
342
+ ["License", m.licenseShortName ?? m.license ?? ""],
343
+ ["Added to the catalog", m.releasedAt ? m.releasedAt.slice(0, 10) : ""]
344
+ ];
345
+ const lines = [
346
+ `# ${m.name}`,
347
+ "",
348
+ m.description.trim(),
349
+ "",
350
+ "| At a glance | |",
351
+ "| --- | --- |",
352
+ ...facts.filter(([, v]) => v).map(([k, v]) => row([k, cell(v)])),
353
+ "",
354
+ "Gezel downloads this model the first time a gezel needs it, checks the file against its published hash, and applies tuned settings for it."
355
+ ];
356
+ const more = [
357
+ m.upstream ? `[The model\u2019s own page](${m.upstream})` : "",
358
+ "[Every model](model-catalog)",
359
+ "[Model scorecard](model-scorecard)"
360
+ ].filter(Boolean);
361
+ lines.push("", more.join(" \xB7 "));
362
+ return lines.join("\n");
363
+ }
364
+ function toolsetCatalogMarkdown(addOns, connectors, communityCount) {
365
+ const lines = [
366
+ "# Add-on toolsets and connectors",
367
+ "",
368
+ "Every gezel starts with the built-in tool groups that fit its role, described in [Tools and toolsets](tools-and-toolsets). This page lists what you can add on top."
369
+ ];
370
+ if (addOns.length > 0) {
371
+ lines.push(
372
+ "",
373
+ "## Add-on toolsets",
374
+ "",
375
+ "Extra tools from Gezel\u2019s own catalog. Add one to a gezel from its Toolsets tab.",
376
+ "",
377
+ "| Toolset | What it does |",
378
+ "| --- | --- |",
379
+ ...addOns.map((t) => row([cell(t.name), cell(firstSentence(t.description) ?? "")]))
380
+ );
381
+ }
382
+ if (connectors.length > 0) {
383
+ lines.push(
384
+ "",
385
+ "## Connectors",
386
+ "",
387
+ "Connectors copy data from outside services, such as mail, calendars and issue trackers, into a project as searchable files. Your crew works on that local copy, never on the live account.",
388
+ "",
389
+ "| Connector | What it brings in |",
390
+ "| --- | --- |",
391
+ ...connectors.map((c) => row([cell(c.name), cell(firstSentence(c.description) ?? "")]))
392
+ );
393
+ }
394
+ if (communityCount > 0) {
395
+ lines.push(
396
+ "",
397
+ "## Community servers",
398
+ "",
399
+ `Gezel\u2019s toolset browser also lists about ${roundDown(communityCount).toLocaleString("en-US")} MCP servers from the public community registry, marked **Community**. They are third-party projects, so review one before you add it to a crew. You can also bring your own: see [Custom MCP toolsets](tools-and-toolsets#custom-mcp-toolsets).`
400
+ );
401
+ }
402
+ return lines.join("\n");
403
+ }
404
+ function roleCatalogMarkdown(roles) {
405
+ return [
406
+ "# Every role template",
407
+ "",
408
+ "A role template is a ready-made character for your crew: a name, a job, and a working style that shapes how they think and talk. The Meester picks from these when it builds a crew, and you can add any of them yourself with **New Gezel**. The core roles each have their own page in [Roles](roles-index).",
409
+ "",
410
+ "| Role | What they do |",
411
+ "| --- | --- |",
412
+ ...roles.map(
413
+ (r) => row([`[${cell(r.name)}](role-template/${r.id})`, cell(firstSentence(r.description) ?? "")])
414
+ )
415
+ ].join("\n");
416
+ }
417
+ function roleTemplateMarkdown(r, about) {
418
+ const lines = [`# ${r.name}`, "", r.description.trim()];
419
+ if (r.meesterCandidate) {
420
+ lines.push("", "This character can also act as your Meester, the gezel who runs the crew.");
421
+ }
422
+ if (about?.trim()) {
423
+ lines.push(
424
+ "",
425
+ "## How they work",
426
+ "",
427
+ "This is the character brief Gezel gives the model, word for word. It shapes how this gezel thinks, works and talks.",
428
+ "",
429
+ demoteHeadings(about.trim())
430
+ );
431
+ }
432
+ lines.push("", "[Every role template](role-catalog) \xB7 [Roles](roles-index)");
433
+ return lines.join("\n");
434
+ }
435
+ function demoteHeadings(markdown) {
436
+ return markdown.replace(
437
+ /^(#{1,4})(\s)/gm,
438
+ (_, hashes, space) => `${"#".repeat(Math.min(hashes.length + 2, 6))}${space}`
439
+ );
440
+ }
441
+ function craftbookGalleryHtml(books, art) {
442
+ const groups = /* @__PURE__ */ new Map();
443
+ for (const book of books) {
444
+ const category = resolveCraftbookCategory(book);
445
+ const index = CRAFTBOOK_CATEGORY_META.findIndex((item) => item.id === category);
446
+ const meta = CRAFTBOOK_CATEGORY_META[index] ?? CRAFTBOOK_CATEGORY_META.at(-1);
447
+ const family = CRAFTBOOK_CATEGORY_FAMILY_META.find((f) => f.id === meta.family);
448
+ const title = meta.family === "universal" || !family ? meta.label : `${family.label} \xB7 ${meta.label}`;
449
+ const group = groups.get(meta.id) ?? {
450
+ title,
451
+ order: index < 0 ? CRAFTBOOK_CATEGORY_META.length : index,
452
+ books: []
453
+ };
454
+ group.books.push(book);
455
+ groups.set(meta.id, group);
456
+ }
457
+ return [...groups.values()].sort((a, b) => a.order - b.order || a.title.localeCompare(b.title)).map(
458
+ (group) => `<section class="hb-gallery-group">
459
+ <h2>${escHtml(group.title)}</h2>
460
+ <ul class="hb-gallery">
461
+ ${group.books.map((book) => {
462
+ const href = `../craftbook/${encodeURIComponent(book.id)}/`;
463
+ const img = art.has(book.id) ? `<img src="${href}${CRAFTBOOK_ART_FILE}" alt="" width="96" height="96" loading="lazy" decoding="async">` : "";
464
+ return `<li><a href="${href}">${img}<span class="hb-gallery-title">${escHtml(book.name)}</span><span class="hb-gallery-summary">${escHtml(clip(firstSentence(book.description) ?? "", 110))}</span></a></li>`;
465
+ }).join("\n")}
466
+ </ul>
467
+ </section>`
468
+ ).join("\n");
469
+ }
470
+ function craftbookArtHtml(title) {
471
+ return `<img class="hb-craftbook-art" src="${CRAFTBOOK_ART_FILE}" alt="${escHtml(title)} illustration" width="160" height="160" decoding="async">`;
472
+ }
473
+ function insertAfterTitle(body, html) {
474
+ const end = body.indexOf("</h1>");
475
+ if (end === -1) return `${html}
476
+ ${body}`;
477
+ const at = end + "</h1>".length;
478
+ return `${body.slice(0, at)}
479
+ ${html}${body.slice(at)}`;
480
+ }
481
+ function escHtml(s) {
482
+ return s.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
483
+ }
484
+ async function projectTypeDemo(catalog, pt) {
485
+ const entry = safeRelativePath(pt.pages?.entry);
486
+ if (!entry) return null;
487
+ const prefix = `versions/${pt.version}/pages/`;
488
+ const paths = (await catalog.listItemFiles("project-type", pt.id)).map((p) => p.replaceAll("\\", "/")).filter((p) => p.startsWith(prefix)).map((p) => p.slice(prefix.length)).filter((p) => safeRelativePath(p) !== void 0);
489
+ if (!paths.includes(entry)) return null;
490
+ const files = [];
491
+ for (const path of paths) {
492
+ const bytes = await catalog.readItemFile("project-type", pt.id, `${prefix}${path}`);
493
+ if (bytes) files.push({ path, bytes });
494
+ }
495
+ return { projectTypeId: pt.id, entry, files };
496
+ }
497
+ function demoSectionHtml(demo, title) {
498
+ const src = `demo/${demo.entry.split("/").map(encodeURIComponent).join("/")}`;
499
+ const esc2 = (s) => s.replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;");
500
+ return `<section class="hb-demo">
501
+ <h2>Try it</h2>
502
+ <p>This is the project\u2019s page running on sample data in your browser. It doesn\u2019t connect to Gezel or to your files.</p>
503
+ <div class="hb-demo-frame"><iframe src="${src}" title="${esc2(title)} demo" loading="lazy" sandbox="allow-forms allow-modals allow-scripts" referrerpolicy="no-referrer"></iframe></div>
504
+ <p class="hb-demo-open"><a href="${src}" target="_blank" rel="noreferrer">Open the demo in a new tab</a></p>
505
+ </section>`;
506
+ }
507
+ function insertDemoSection(body, section) {
508
+ const firstParagraphEnd = body.indexOf("</p>");
509
+ if (firstParagraphEnd === -1) return `${body}
510
+ ${section}`;
511
+ const at = firstParagraphEnd + "</p>".length;
512
+ return `${body.slice(0, at)}
513
+ ${section}${body.slice(at)}`;
514
+ }
515
+ function safeRelativePath(value) {
516
+ if (typeof value !== "string") return void 0;
517
+ const normalized = value.replaceAll("\\", "/").replace(/^\.\//, "");
518
+ const segments = normalized.split("/");
519
+ if (!normalized || normalized.startsWith("/") || segments.some((s) => !s || s === "..")) {
520
+ return void 0;
521
+ }
522
+ return normalized;
523
+ }
524
+ function byName(a, b) {
525
+ return a.name.localeCompare(b.name);
526
+ }
527
+ function engines(m) {
528
+ return ENGINE_LABELS.filter(([key]) => m[key] !== void 0).map(([, label]) => label);
529
+ }
530
+ function quantization(m) {
531
+ const blocks = [m.llamaCpp, m.mlx, m.ds4];
532
+ return blocks.find((b) => b?.quantization)?.quantization ?? "";
533
+ }
534
+ function firstSentence(text) {
535
+ const s = text?.trim().split(/\.\s/)[0]?.replace(/\.$/, "").trim();
536
+ return s ? `${s}.` : void 0;
537
+ }
538
+ function clip(text, max) {
539
+ if (text.length <= max) return text;
540
+ const cut = text.slice(0, max);
541
+ const space = cut.lastIndexOf(" ");
542
+ return `${(space > max * 0.6 ? cut.slice(0, space) : cut).replace(/[\s,;:—–-]+$/, "")}\u2026`;
543
+ }
544
+ function formatGB(bytes) {
545
+ if (typeof bytes !== "number" || !Number.isFinite(bytes) || bytes <= 0) return "";
546
+ return `${(bytes / 1e9).toFixed(1)} GB`;
547
+ }
548
+ function formatContext(tokens) {
549
+ if (typeof tokens !== "number" || !Number.isFinite(tokens) || tokens <= 0) return "";
550
+ return tokens >= 1e3 ? `${Math.round(tokens / 1e3)}K` : String(tokens);
551
+ }
552
+ function yesNo(value) {
553
+ return value === void 0 ? "" : value ? "Yes" : "No";
554
+ }
555
+ function roundDown(n) {
556
+ return n >= 1e3 ? Math.floor(n / 100) * 100 : n;
557
+ }
558
+ function link(text, url) {
559
+ return url && /^https?:\/\//.test(url) ? `[${cell(text)}](${url})` : cell(text);
560
+ }
561
+ function cell(text) {
562
+ return text.replace(/\|/g, "\\|").replace(/\s*\n\s*/g, " ").trim();
563
+ }
564
+ function row(cells) {
565
+ return `| ${cells.join(" | ")} |`;
566
+ }
567
+
112
568
  // src/handboek-site-css.ts
113
569
  var BASELINE_CSS = `:root {
114
570
  --hb-canvas: #eae5d6;
@@ -119,7 +575,7 @@ var BASELINE_CSS = `:root {
119
575
  --hb-ink-warm: #2a2520;
120
576
  --hb-ink-muted: #5a4f42;
121
577
  --hb-ink-quiet: #8b7e6b;
122
- --hb-sage: #667f62;
578
+ --hb-sage: #5c6a4a;
123
579
  --hb-sage-forest: #3d4d3a;
124
580
  --hb-cream-ink: #f3ede0;
125
581
  --hb-accent: #b0724c;
@@ -451,6 +907,66 @@ body.hb {
451
907
 
452
908
  .hb-watch { max-width: var(--hb-measure); margin: 1.25rem 0 0; font-size: 0.9rem; }
453
909
 
910
+ /* A project type's page demo, framed like a window onto the room. */
911
+ .hb-demo-frame {
912
+ border: 1px solid var(--hb-border);
913
+ border-radius: var(--hb-radius-lg);
914
+ background: var(--hb-panel);
915
+ box-shadow: var(--hb-shadow);
916
+ padding: 6px;
917
+ }
918
+ .hb-demo-frame iframe {
919
+ display: block;
920
+ width: 100%;
921
+ height: 34rem;
922
+ border: 0;
923
+ border-radius: var(--hb-radius-md);
924
+ background: #fff;
925
+ }
926
+ .hb-demo-open { font-size: 0.9rem; }
927
+
928
+ /* Craftbook woodcuts: one under each craftbook's title, and a gallery shelf. */
929
+ .hb-craftbook-art {
930
+ display: block;
931
+ width: 160px;
932
+ height: 160px;
933
+ margin: 0 0 1.25rem;
934
+ border-radius: var(--hb-radius-md);
935
+ background: #e8dec7;
936
+ box-shadow: inset 0 0 0 1px rgba(74, 52, 30, 0.14);
937
+ }
938
+ .hb-article .hb-gallery {
939
+ list-style: none;
940
+ margin: 0 0 2rem;
941
+ padding: 0;
942
+ display: grid;
943
+ grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
944
+ gap: 0.75rem;
945
+ }
946
+ .hb-article .hb-gallery li { margin: 0; font-size: inherit; }
947
+ .hb-gallery a {
948
+ display: flex;
949
+ flex-direction: column;
950
+ gap: 0.35rem;
951
+ height: 100%;
952
+ padding: 0.75rem;
953
+ border: 1px solid var(--hb-border);
954
+ border-radius: var(--hb-radius-lg);
955
+ background: var(--hb-panel);
956
+ color: var(--hb-ink);
957
+ text-decoration: none;
958
+ box-shadow: var(--hb-shadow);
959
+ }
960
+ .hb-gallery a:hover { border-color: var(--hb-accent); }
961
+ .hb-gallery img {
962
+ width: 96px;
963
+ height: 96px;
964
+ border-radius: var(--hb-radius-md);
965
+ background: #e8dec7;
966
+ }
967
+ .hb-gallery-title { font-family: var(--hb-font-display); font-weight: 700; color: var(--hb-sage); }
968
+ .hb-gallery-summary { font-size: 0.85rem; line-height: 1.4; color: var(--hb-ink-muted); }
969
+
454
970
  /* Home */
455
971
  .hb-home-main { max-width: 62rem; margin: 0 auto; padding: 3rem 1.5rem 4rem; }
456
972
  .hb-hero { max-width: var(--hb-measure); margin-bottom: 3rem; }
@@ -923,14 +1439,27 @@ async function runHandboekExport(opts) {
923
1439
  "no handboek content tree found \u2014 run from a gezel checkout or install, or set GEZEL_HANDBOEK_DIR"
924
1440
  );
925
1441
  }
1442
+ const catalog = new CatalogService();
926
1443
  const engine = createHandboekEngine({
927
- catalog: new CatalogService(),
1444
+ catalog,
928
1445
  device: siteDeviceInfo,
929
1446
  contentDir
930
1447
  });
931
1448
  const toc = await engine.toc();
932
- const areas = toc.areas.map((a) => ({ ...a, entries: a.entries.filter((e) => e.siteVisible !== false) })).filter((a) => a.entries.length > 0);
933
- const entries = areas.flatMap((a) => a.entries);
1449
+ const site = await buildSiteCatalog(catalog);
1450
+ const sitePages = new Map(site.pages.map((p) => [p.entry.id, p]));
1451
+ const demos = new Map(site.demos.map((d) => [`project-type/${d.projectTypeId}`, d]));
1452
+ const areas = toc.areas.map((a) => ({
1453
+ ...a,
1454
+ entries: [
1455
+ ...a.entries.filter((e) => e.siteVisible !== false),
1456
+ ...site.pages.filter((p) => p.listed && !p.replaces && p.entry.area === a.area).map((p) => p.entry)
1457
+ ].sort((x, y) => x.order - y.order)
1458
+ })).filter((a) => a.entries.length > 0);
1459
+ const entries = [
1460
+ ...areas.flatMap((a) => a.entries),
1461
+ ...site.pages.filter((p) => !p.listed && !p.replaces).map((p) => p.entry)
1462
+ ];
934
1463
  const ids = new Set(entries.map((e) => e.id));
935
1464
  const byStem = /* @__PURE__ */ new Map();
936
1465
  for (const e of entries) {
@@ -947,7 +1476,13 @@ async function runHandboekExport(opts) {
947
1476
  const ogBase = opts.ogOut ? normalizeBase(opts.ogBase) : void 0;
948
1477
  const cardPlans = [];
949
1478
  for (const entry of entries) {
950
- const article = await engine.article(entry.id, { mode: "site" });
1479
+ const sitePage = sitePages.get(entry.id);
1480
+ const article = sitePage ? {
1481
+ id: entry.id,
1482
+ title: entry.title,
1483
+ markdown: sitePage.markdown,
1484
+ defaultDuration: void 0
1485
+ } : await engine.article(entry.id, { mode: "site" });
951
1486
  if (!article) {
952
1487
  skipped.push(entry.id);
953
1488
  continue;
@@ -955,11 +1490,26 @@ async function runHandboekExport(opts) {
955
1490
  const depth = entry.id.split("/").length;
956
1491
  const markdown = rewriteSiteLinks(article.markdown, entry.id, ids, byStem);
957
1492
  const parsed = parseMarkdown(markdown);
958
- const { html: body, headings } = withHeadingIds(
959
- wrapTables(extractBody(markdownDocToPlainHtml(parsed, { title: article.title })))
1493
+ const demo = demos.get(entry.id);
1494
+ const art = entry.id.startsWith("craftbook/") ? site.craftbookArt.get(entry.id.slice("craftbook/".length)) : void 0;
1495
+ let rendered = wrapTables(
1496
+ extractBody(markdownDocToPlainHtml(parsed, { title: article.title }))
960
1497
  );
1498
+ if (sitePage?.html) rendered = `${rendered}
1499
+ ${sitePage.html}`;
1500
+ if (demo) rendered = insertDemoSection(rendered, demoSectionHtml(demo, entry.title));
1501
+ if (art) rendered = insertAfterTitle(rendered, craftbookArtHtml(entry.title));
1502
+ const { html: body, headings } = withHeadingIds(rendered);
961
1503
  const dir = join2(out, ...entry.id.split("/"));
962
1504
  await mkdir2(dir, { recursive: true });
1505
+ if (art) await writeFile2(join2(dir, CRAFTBOOK_ART_FILE), art);
1506
+ 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
+ }
1512
+ }
963
1513
  const headline = resolveOgHeadline(entry, headlines);
964
1514
  if (ogBase) {
965
1515
  cardPlans.push({ id: entry.id, kicker: ogKicker(entry), headline });
@@ -1155,6 +1705,10 @@ ${links}
1155
1705
  </nav>
1156
1706
  </header>`;
1157
1707
  }
1708
+ function articleCount(area) {
1709
+ const landing = areaLanding(area);
1710
+ return area.entries.filter((e) => !(e.id === landing && e.id.endsWith("-index"))).length;
1711
+ }
1158
1712
  function areaLanding(area) {
1159
1713
  const index = area.entries.find((e) => e.id.endsWith("-index") || e.id.endsWith("-overview"));
1160
1714
  return (index ?? area.entries[0])?.id ?? "";
@@ -1164,7 +1718,7 @@ function sidebar(areas, entry, depth) {
1164
1718
  const isCurrent = area.area === entry.area;
1165
1719
  const items = isCurrent && area.entries.length <= NAV_INLINE_MAX ? area.entries : isCurrent ? dedupeById([...area.entries.filter((e) => e.id === areaLanding(area)), entry]) : [];
1166
1720
  const list = items.length ? sidebarEntryList(items, entry.id, depth) : "";
1167
- const more = isCurrent && area.entries.length > NAV_INLINE_MAX ? `<p class="hb-more"><a href="${up(depth)}${esc(areaLanding(area))}/">All ${area.entries.length} ${esc(area.title.toLowerCase())}</a></p>` : "";
1721
+ const more = isCurrent && area.entries.length > NAV_INLINE_MAX ? `<p class="hb-more"><a href="${up(depth)}${esc(areaLanding(area))}/">All ${articleCount(area)} ${esc(area.title.toLowerCase())}</a></p>` : "";
1168
1722
  const heading = isCurrent ? `<h2 class="hb-current">${esc(area.title)}</h2>` : `<h2><a href="${up(depth)}${esc(areaLanding(area))}/">${esc(area.title)}</a></h2>`;
1169
1723
  return `<section>
1170
1724
  ${heading}
@@ -1283,7 +1837,7 @@ ${listed.map((e) => `<li><a href="${esc(e.id)}/">${esc(e.title)}</a></li>`).join
1283
1837
  <h2><a href="${esc(landing)}/">${esc(area.title)}</a></h2>
1284
1838
  <p class="hb-area-blurb">${esc(AREA_BLURBS[area.area] ?? "")}</p>
1285
1839
  ${list}
1286
- <p class="hb-more"><a href="${esc(landing)}/">Browse all ${area.entries.length} ${esc(area.title.toLowerCase())}</a></p>
1840
+ <p class="hb-more"><a href="${esc(landing)}/">Browse all ${articleCount(area)} ${esc(area.title.toLowerCase())}</a></p>
1287
1841
  </section>`;
1288
1842
  }).join("\n");
1289
1843
  return `${head("Gezel Handboek", css, 0, "Documentation for gezel \u2014 a crew of AI companions that works for you, from your own computer.", social)}