@bendyline/gezel-cli 1.2.3 → 1.2.4
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.
- package/README.md +85 -11
- package/dist/app-author-command.js +1 -1
- package/dist/app-command.js +3 -3
- package/dist/bin/gezel-main.js +997 -465
- package/dist/handboek-export.js +564 -8
- package/dist/knowledge-command.js +28 -3
- package/dist/tui/index.js +5 -2
- package/package.json +10 -10
package/dist/handboek-export.js
CHANGED
|
@@ -109,6 +109,464 @@ 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.",
|
|
296
|
+
"",
|
|
297
|
+
"| Model | Size | Memory needed | Commercial use | License |",
|
|
298
|
+
"| --- | --- | --- | --- | --- |",
|
|
299
|
+
...images.map(
|
|
300
|
+
(m) => row([
|
|
301
|
+
link(m.name, m.upstream),
|
|
302
|
+
formatGB(m.approxSizeBytes),
|
|
303
|
+
m.minRamGB ? `${m.minRamGB} GB` : "",
|
|
304
|
+
yesNo(m.commercialUse),
|
|
305
|
+
cell(m.licenseShortName ?? m.license ?? "")
|
|
306
|
+
])
|
|
307
|
+
)
|
|
308
|
+
);
|
|
309
|
+
}
|
|
310
|
+
if (videos.length > 0) {
|
|
311
|
+
lines.push(
|
|
312
|
+
"",
|
|
313
|
+
`## Video models (${videos.length})`,
|
|
314
|
+
"",
|
|
315
|
+
"Models that turn a prompt or a picture into a short clip.",
|
|
316
|
+
"",
|
|
317
|
+
"| Model | Size | Longest clip | Graphics memory needed | Commercial use | License |",
|
|
318
|
+
"| --- | --- | --- | --- | --- | --- |",
|
|
319
|
+
...videos.map(
|
|
320
|
+
(m) => row([
|
|
321
|
+
link(m.name, m.upstream),
|
|
322
|
+
formatGB(m.approxSizeBytes),
|
|
323
|
+
m.maxDurationSeconds ? `${m.maxDurationSeconds} s` : "",
|
|
324
|
+
m.minVramGB ? `${m.minVramGB} GB` : "",
|
|
325
|
+
yesNo(m.commercialUse),
|
|
326
|
+
cell(m.licenseShortName ?? m.license ?? "")
|
|
327
|
+
])
|
|
328
|
+
)
|
|
329
|
+
);
|
|
330
|
+
}
|
|
331
|
+
return lines.join("\n");
|
|
332
|
+
}
|
|
333
|
+
function chatModelMarkdown(m) {
|
|
334
|
+
const maker = m.maker?.name ?? m.maintainer?.name;
|
|
335
|
+
const facts = [
|
|
336
|
+
["Made by", maker ?? ""],
|
|
337
|
+
["Download size", formatGB(m.approxSizeBytes)],
|
|
338
|
+
["Parameters", m.parameterSize ?? ""],
|
|
339
|
+
["Quantization", quantization(m)],
|
|
340
|
+
["Context window", m.contextWindow ? `${formatContext(m.contextWindow)} tokens` : ""],
|
|
341
|
+
["Uses tools", m.supportsTools === false ? "No" : "Yes"],
|
|
342
|
+
["Best for", CATEGORY_LABELS[m.category ?? ""] ?? ""],
|
|
343
|
+
["Runs on", engines(m).join(", ")],
|
|
344
|
+
["License", m.licenseShortName ?? m.license ?? ""],
|
|
345
|
+
["Added to the catalog", m.releasedAt ? m.releasedAt.slice(0, 10) : ""]
|
|
346
|
+
];
|
|
347
|
+
const lines = [
|
|
348
|
+
`# ${m.name}`,
|
|
349
|
+
"",
|
|
350
|
+
m.description.trim(),
|
|
351
|
+
"",
|
|
352
|
+
"| At a glance | |",
|
|
353
|
+
"| --- | --- |",
|
|
354
|
+
...facts.filter(([, v]) => v).map(([k, v]) => row([k, cell(v)])),
|
|
355
|
+
"",
|
|
356
|
+
"Gezel downloads this model the first time a gezel needs it, checks the file against its published hash, and applies tuned settings for it."
|
|
357
|
+
];
|
|
358
|
+
const more = [
|
|
359
|
+
m.upstream ? `[The model\u2019s own page](${m.upstream})` : "",
|
|
360
|
+
"[Every model](model-catalog)",
|
|
361
|
+
"[Model scorecard](model-scorecard)"
|
|
362
|
+
].filter(Boolean);
|
|
363
|
+
lines.push("", more.join(" \xB7 "));
|
|
364
|
+
return lines.join("\n");
|
|
365
|
+
}
|
|
366
|
+
function toolsetCatalogMarkdown(addOns, connectors, communityCount) {
|
|
367
|
+
const lines = [
|
|
368
|
+
"# Add-on toolsets and connectors",
|
|
369
|
+
"",
|
|
370
|
+
"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."
|
|
371
|
+
];
|
|
372
|
+
if (addOns.length > 0) {
|
|
373
|
+
lines.push(
|
|
374
|
+
"",
|
|
375
|
+
"## Add-on toolsets",
|
|
376
|
+
"",
|
|
377
|
+
"Extra tools from Gezel\u2019s own catalog. Add one to a gezel from its Toolsets tab.",
|
|
378
|
+
"",
|
|
379
|
+
"| Toolset | What it does |",
|
|
380
|
+
"| --- | --- |",
|
|
381
|
+
...addOns.map((t) => row([cell(t.name), cell(firstSentence(t.description) ?? "")]))
|
|
382
|
+
);
|
|
383
|
+
}
|
|
384
|
+
if (connectors.length > 0) {
|
|
385
|
+
lines.push(
|
|
386
|
+
"",
|
|
387
|
+
"## Connectors",
|
|
388
|
+
"",
|
|
389
|
+
"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.",
|
|
390
|
+
"",
|
|
391
|
+
"| Connector | What it brings in |",
|
|
392
|
+
"| --- | --- |",
|
|
393
|
+
...connectors.map((c) => row([cell(c.name), cell(firstSentence(c.description) ?? "")]))
|
|
394
|
+
);
|
|
395
|
+
}
|
|
396
|
+
if (communityCount > 0) {
|
|
397
|
+
lines.push(
|
|
398
|
+
"",
|
|
399
|
+
"## Community servers",
|
|
400
|
+
"",
|
|
401
|
+
`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).`
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
return lines.join("\n");
|
|
405
|
+
}
|
|
406
|
+
function roleCatalogMarkdown(roles) {
|
|
407
|
+
return [
|
|
408
|
+
"# Every role template",
|
|
409
|
+
"",
|
|
410
|
+
"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).",
|
|
411
|
+
"",
|
|
412
|
+
"| Role | What they do |",
|
|
413
|
+
"| --- | --- |",
|
|
414
|
+
...roles.map(
|
|
415
|
+
(r) => row([`[${cell(r.name)}](role-template/${r.id})`, cell(firstSentence(r.description) ?? "")])
|
|
416
|
+
)
|
|
417
|
+
].join("\n");
|
|
418
|
+
}
|
|
419
|
+
function roleTemplateMarkdown(r, about) {
|
|
420
|
+
const lines = [`# ${r.name}`, "", r.description.trim()];
|
|
421
|
+
if (r.meesterCandidate) {
|
|
422
|
+
lines.push("", "This character can also act as your Meester, the gezel who runs the crew.");
|
|
423
|
+
}
|
|
424
|
+
if (about?.trim()) {
|
|
425
|
+
lines.push(
|
|
426
|
+
"",
|
|
427
|
+
"## How they work",
|
|
428
|
+
"",
|
|
429
|
+
"This is the character brief Gezel gives the model, word for word. It shapes how this gezel thinks, works and talks.",
|
|
430
|
+
"",
|
|
431
|
+
demoteHeadings(about.trim())
|
|
432
|
+
);
|
|
433
|
+
}
|
|
434
|
+
lines.push("", "[Every role template](role-catalog) \xB7 [Roles](roles-index)");
|
|
435
|
+
return lines.join("\n");
|
|
436
|
+
}
|
|
437
|
+
function demoteHeadings(markdown) {
|
|
438
|
+
return markdown.replace(
|
|
439
|
+
/^(#{1,4})(\s)/gm,
|
|
440
|
+
(_, hashes, space) => `${"#".repeat(Math.min(hashes.length + 2, 6))}${space}`
|
|
441
|
+
);
|
|
442
|
+
}
|
|
443
|
+
function craftbookGalleryHtml(books, art) {
|
|
444
|
+
const groups = /* @__PURE__ */ new Map();
|
|
445
|
+
for (const book of books) {
|
|
446
|
+
const category = resolveCraftbookCategory(book);
|
|
447
|
+
const index = CRAFTBOOK_CATEGORY_META.findIndex((item) => item.id === category);
|
|
448
|
+
const meta = CRAFTBOOK_CATEGORY_META[index] ?? CRAFTBOOK_CATEGORY_META.at(-1);
|
|
449
|
+
const family = CRAFTBOOK_CATEGORY_FAMILY_META.find((f) => f.id === meta.family);
|
|
450
|
+
const title = meta.family === "universal" || !family ? meta.label : `${family.label} \xB7 ${meta.label}`;
|
|
451
|
+
const group = groups.get(meta.id) ?? {
|
|
452
|
+
title,
|
|
453
|
+
order: index < 0 ? CRAFTBOOK_CATEGORY_META.length : index,
|
|
454
|
+
books: []
|
|
455
|
+
};
|
|
456
|
+
group.books.push(book);
|
|
457
|
+
groups.set(meta.id, group);
|
|
458
|
+
}
|
|
459
|
+
return [...groups.values()].sort((a, b) => a.order - b.order || a.title.localeCompare(b.title)).map(
|
|
460
|
+
(group) => `<section class="hb-gallery-group">
|
|
461
|
+
<h2>${escHtml(group.title)}</h2>
|
|
462
|
+
<ul class="hb-gallery">
|
|
463
|
+
${group.books.map((book) => {
|
|
464
|
+
const href = `../craftbook/${encodeURIComponent(book.id)}/`;
|
|
465
|
+
const img = art.has(book.id) ? `<img src="${href}${CRAFTBOOK_ART_FILE}" alt="" width="96" height="96" loading="lazy" decoding="async">` : "";
|
|
466
|
+
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>`;
|
|
467
|
+
}).join("\n")}
|
|
468
|
+
</ul>
|
|
469
|
+
</section>`
|
|
470
|
+
).join("\n");
|
|
471
|
+
}
|
|
472
|
+
function craftbookArtHtml(title) {
|
|
473
|
+
return `<img class="hb-craftbook-art" src="${CRAFTBOOK_ART_FILE}" alt="${escHtml(title)} illustration" width="160" height="160" decoding="async">`;
|
|
474
|
+
}
|
|
475
|
+
function insertAfterTitle(body, html) {
|
|
476
|
+
const end = body.indexOf("</h1>");
|
|
477
|
+
if (end === -1) return `${html}
|
|
478
|
+
${body}`;
|
|
479
|
+
const at = end + "</h1>".length;
|
|
480
|
+
return `${body.slice(0, at)}
|
|
481
|
+
${html}${body.slice(at)}`;
|
|
482
|
+
}
|
|
483
|
+
function escHtml(s) {
|
|
484
|
+
return s.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """);
|
|
485
|
+
}
|
|
486
|
+
async function projectTypeDemo(catalog, pt) {
|
|
487
|
+
const entry = safeRelativePath(pt.pages?.entry);
|
|
488
|
+
if (!entry) return null;
|
|
489
|
+
const prefix = `versions/${pt.version}/pages/`;
|
|
490
|
+
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);
|
|
491
|
+
if (!paths.includes(entry)) return null;
|
|
492
|
+
const files = [];
|
|
493
|
+
for (const path of paths) {
|
|
494
|
+
const bytes = await catalog.readItemFile("project-type", pt.id, `${prefix}${path}`);
|
|
495
|
+
if (bytes) files.push({ path, bytes });
|
|
496
|
+
}
|
|
497
|
+
return { projectTypeId: pt.id, entry, files };
|
|
498
|
+
}
|
|
499
|
+
function demoSectionHtml(demo, title) {
|
|
500
|
+
const src = `demo/${demo.entry.split("/").map(encodeURIComponent).join("/")}`;
|
|
501
|
+
const esc2 = (s) => s.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
502
|
+
return `<section class="hb-demo">
|
|
503
|
+
<h2>Try it</h2>
|
|
504
|
+
<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>
|
|
505
|
+
<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>
|
|
506
|
+
<p class="hb-demo-open"><a href="${src}" target="_blank" rel="noreferrer">Open the demo in a new tab</a></p>
|
|
507
|
+
</section>`;
|
|
508
|
+
}
|
|
509
|
+
function insertDemoSection(body, section) {
|
|
510
|
+
const firstParagraphEnd = body.indexOf("</p>");
|
|
511
|
+
if (firstParagraphEnd === -1) return `${body}
|
|
512
|
+
${section}`;
|
|
513
|
+
const at = firstParagraphEnd + "</p>".length;
|
|
514
|
+
return `${body.slice(0, at)}
|
|
515
|
+
${section}${body.slice(at)}`;
|
|
516
|
+
}
|
|
517
|
+
function safeRelativePath(value) {
|
|
518
|
+
if (typeof value !== "string") return void 0;
|
|
519
|
+
const normalized = value.replaceAll("\\", "/").replace(/^\.\//, "");
|
|
520
|
+
const segments = normalized.split("/");
|
|
521
|
+
if (!normalized || normalized.startsWith("/") || segments.some((s) => !s || s === "..")) {
|
|
522
|
+
return void 0;
|
|
523
|
+
}
|
|
524
|
+
return normalized;
|
|
525
|
+
}
|
|
526
|
+
function byName(a, b) {
|
|
527
|
+
return a.name.localeCompare(b.name);
|
|
528
|
+
}
|
|
529
|
+
function engines(m) {
|
|
530
|
+
return ENGINE_LABELS.filter(([key]) => m[key] !== void 0).map(([, label]) => label);
|
|
531
|
+
}
|
|
532
|
+
function quantization(m) {
|
|
533
|
+
const blocks = [m.llamaCpp, m.mlx, m.ds4];
|
|
534
|
+
return blocks.find((b) => b?.quantization)?.quantization ?? "";
|
|
535
|
+
}
|
|
536
|
+
function firstSentence(text) {
|
|
537
|
+
const s = text?.trim().split(/\.\s/)[0]?.replace(/\.$/, "").trim();
|
|
538
|
+
return s ? `${s}.` : void 0;
|
|
539
|
+
}
|
|
540
|
+
function clip(text, max) {
|
|
541
|
+
if (text.length <= max) return text;
|
|
542
|
+
const cut = text.slice(0, max);
|
|
543
|
+
const space = cut.lastIndexOf(" ");
|
|
544
|
+
return `${(space > max * 0.6 ? cut.slice(0, space) : cut).replace(/[\s,;:—–-]+$/, "")}\u2026`;
|
|
545
|
+
}
|
|
546
|
+
function formatGB(bytes) {
|
|
547
|
+
if (typeof bytes !== "number" || !Number.isFinite(bytes) || bytes <= 0) return "";
|
|
548
|
+
return `${(bytes / 1e9).toFixed(1)} GB`;
|
|
549
|
+
}
|
|
550
|
+
function formatContext(tokens) {
|
|
551
|
+
if (typeof tokens !== "number" || !Number.isFinite(tokens) || tokens <= 0) return "";
|
|
552
|
+
return tokens >= 1e3 ? `${Math.round(tokens / 1e3)}K` : String(tokens);
|
|
553
|
+
}
|
|
554
|
+
function yesNo(value) {
|
|
555
|
+
return value === void 0 ? "" : value ? "Yes" : "No";
|
|
556
|
+
}
|
|
557
|
+
function roundDown(n) {
|
|
558
|
+
return n >= 1e3 ? Math.floor(n / 100) * 100 : n;
|
|
559
|
+
}
|
|
560
|
+
function link(text, url) {
|
|
561
|
+
return url && /^https?:\/\//.test(url) ? `[${cell(text)}](${url})` : cell(text);
|
|
562
|
+
}
|
|
563
|
+
function cell(text) {
|
|
564
|
+
return text.replace(/\|/g, "\\|").replace(/\s*\n\s*/g, " ").trim();
|
|
565
|
+
}
|
|
566
|
+
function row(cells) {
|
|
567
|
+
return `| ${cells.join(" | ")} |`;
|
|
568
|
+
}
|
|
569
|
+
|
|
112
570
|
// src/handboek-site-css.ts
|
|
113
571
|
var BASELINE_CSS = `:root {
|
|
114
572
|
--hb-canvas: #eae5d6;
|
|
@@ -451,6 +909,66 @@ body.hb {
|
|
|
451
909
|
|
|
452
910
|
.hb-watch { max-width: var(--hb-measure); margin: 1.25rem 0 0; font-size: 0.9rem; }
|
|
453
911
|
|
|
912
|
+
/* A project type's page demo, framed like a window onto the room. */
|
|
913
|
+
.hb-demo-frame {
|
|
914
|
+
border: 1px solid var(--hb-border);
|
|
915
|
+
border-radius: var(--hb-radius-lg);
|
|
916
|
+
background: var(--hb-panel);
|
|
917
|
+
box-shadow: var(--hb-shadow);
|
|
918
|
+
padding: 6px;
|
|
919
|
+
}
|
|
920
|
+
.hb-demo-frame iframe {
|
|
921
|
+
display: block;
|
|
922
|
+
width: 100%;
|
|
923
|
+
height: 34rem;
|
|
924
|
+
border: 0;
|
|
925
|
+
border-radius: var(--hb-radius-md);
|
|
926
|
+
background: #fff;
|
|
927
|
+
}
|
|
928
|
+
.hb-demo-open { font-size: 0.9rem; }
|
|
929
|
+
|
|
930
|
+
/* Craftbook woodcuts: one under each craftbook's title, and a gallery shelf. */
|
|
931
|
+
.hb-craftbook-art {
|
|
932
|
+
display: block;
|
|
933
|
+
width: 160px;
|
|
934
|
+
height: 160px;
|
|
935
|
+
margin: 0 0 1.25rem;
|
|
936
|
+
border-radius: var(--hb-radius-md);
|
|
937
|
+
background: #e8dec7;
|
|
938
|
+
box-shadow: inset 0 0 0 1px rgba(74, 52, 30, 0.14);
|
|
939
|
+
}
|
|
940
|
+
.hb-article .hb-gallery {
|
|
941
|
+
list-style: none;
|
|
942
|
+
margin: 0 0 2rem;
|
|
943
|
+
padding: 0;
|
|
944
|
+
display: grid;
|
|
945
|
+
grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
|
|
946
|
+
gap: 0.75rem;
|
|
947
|
+
}
|
|
948
|
+
.hb-article .hb-gallery li { margin: 0; font-size: inherit; }
|
|
949
|
+
.hb-gallery a {
|
|
950
|
+
display: flex;
|
|
951
|
+
flex-direction: column;
|
|
952
|
+
gap: 0.35rem;
|
|
953
|
+
height: 100%;
|
|
954
|
+
padding: 0.75rem;
|
|
955
|
+
border: 1px solid var(--hb-border);
|
|
956
|
+
border-radius: var(--hb-radius-lg);
|
|
957
|
+
background: var(--hb-panel);
|
|
958
|
+
color: var(--hb-ink);
|
|
959
|
+
text-decoration: none;
|
|
960
|
+
box-shadow: var(--hb-shadow);
|
|
961
|
+
}
|
|
962
|
+
.hb-gallery a:hover { border-color: var(--hb-accent); }
|
|
963
|
+
.hb-gallery img {
|
|
964
|
+
width: 96px;
|
|
965
|
+
height: 96px;
|
|
966
|
+
border-radius: var(--hb-radius-md);
|
|
967
|
+
background: #e8dec7;
|
|
968
|
+
}
|
|
969
|
+
.hb-gallery-title { font-family: var(--hb-font-display); font-weight: 700; color: var(--hb-sage); }
|
|
970
|
+
.hb-gallery-summary { font-size: 0.85rem; line-height: 1.4; color: var(--hb-ink-muted); }
|
|
971
|
+
|
|
454
972
|
/* Home */
|
|
455
973
|
.hb-home-main { max-width: 62rem; margin: 0 auto; padding: 3rem 1.5rem 4rem; }
|
|
456
974
|
.hb-hero { max-width: var(--hb-measure); margin-bottom: 3rem; }
|
|
@@ -923,14 +1441,27 @@ async function runHandboekExport(opts) {
|
|
|
923
1441
|
"no handboek content tree found \u2014 run from a gezel checkout or install, or set GEZEL_HANDBOEK_DIR"
|
|
924
1442
|
);
|
|
925
1443
|
}
|
|
1444
|
+
const catalog = new CatalogService();
|
|
926
1445
|
const engine = createHandboekEngine({
|
|
927
|
-
catalog
|
|
1446
|
+
catalog,
|
|
928
1447
|
device: siteDeviceInfo,
|
|
929
1448
|
contentDir
|
|
930
1449
|
});
|
|
931
1450
|
const toc = await engine.toc();
|
|
932
|
-
const
|
|
933
|
-
const
|
|
1451
|
+
const site = await buildSiteCatalog(catalog);
|
|
1452
|
+
const sitePages = new Map(site.pages.map((p) => [p.entry.id, p]));
|
|
1453
|
+
const demos = new Map(site.demos.map((d) => [`project-type/${d.projectTypeId}`, d]));
|
|
1454
|
+
const areas = toc.areas.map((a) => ({
|
|
1455
|
+
...a,
|
|
1456
|
+
entries: [
|
|
1457
|
+
...a.entries.filter((e) => e.siteVisible !== false),
|
|
1458
|
+
...site.pages.filter((p) => p.listed && !p.replaces && p.entry.area === a.area).map((p) => p.entry)
|
|
1459
|
+
].sort((x, y) => x.order - y.order)
|
|
1460
|
+
})).filter((a) => a.entries.length > 0);
|
|
1461
|
+
const entries = [
|
|
1462
|
+
...areas.flatMap((a) => a.entries),
|
|
1463
|
+
...site.pages.filter((p) => !p.listed && !p.replaces).map((p) => p.entry)
|
|
1464
|
+
];
|
|
934
1465
|
const ids = new Set(entries.map((e) => e.id));
|
|
935
1466
|
const byStem = /* @__PURE__ */ new Map();
|
|
936
1467
|
for (const e of entries) {
|
|
@@ -947,7 +1478,13 @@ async function runHandboekExport(opts) {
|
|
|
947
1478
|
const ogBase = opts.ogOut ? normalizeBase(opts.ogBase) : void 0;
|
|
948
1479
|
const cardPlans = [];
|
|
949
1480
|
for (const entry of entries) {
|
|
950
|
-
const
|
|
1481
|
+
const sitePage = sitePages.get(entry.id);
|
|
1482
|
+
const article = sitePage ? {
|
|
1483
|
+
id: entry.id,
|
|
1484
|
+
title: entry.title,
|
|
1485
|
+
markdown: sitePage.markdown,
|
|
1486
|
+
defaultDuration: void 0
|
|
1487
|
+
} : await engine.article(entry.id, { mode: "site" });
|
|
951
1488
|
if (!article) {
|
|
952
1489
|
skipped.push(entry.id);
|
|
953
1490
|
continue;
|
|
@@ -955,11 +1492,26 @@ async function runHandboekExport(opts) {
|
|
|
955
1492
|
const depth = entry.id.split("/").length;
|
|
956
1493
|
const markdown = rewriteSiteLinks(article.markdown, entry.id, ids, byStem);
|
|
957
1494
|
const parsed = parseMarkdown(markdown);
|
|
958
|
-
const
|
|
959
|
-
|
|
1495
|
+
const demo = demos.get(entry.id);
|
|
1496
|
+
const art = entry.id.startsWith("craftbook/") ? site.craftbookArt.get(entry.id.slice("craftbook/".length)) : void 0;
|
|
1497
|
+
let rendered = wrapTables(
|
|
1498
|
+
extractBody(markdownDocToPlainHtml(parsed, { title: article.title }))
|
|
960
1499
|
);
|
|
1500
|
+
if (sitePage?.html) rendered = `${rendered}
|
|
1501
|
+
${sitePage.html}`;
|
|
1502
|
+
if (demo) rendered = insertDemoSection(rendered, demoSectionHtml(demo, entry.title));
|
|
1503
|
+
if (art) rendered = insertAfterTitle(rendered, craftbookArtHtml(entry.title));
|
|
1504
|
+
const { html: body, headings } = withHeadingIds(rendered);
|
|
961
1505
|
const dir = join2(out, ...entry.id.split("/"));
|
|
962
1506
|
await mkdir2(dir, { recursive: true });
|
|
1507
|
+
if (art) await writeFile2(join2(dir, CRAFTBOOK_ART_FILE), art);
|
|
1508
|
+
if (demo) {
|
|
1509
|
+
for (const file of demo.files) {
|
|
1510
|
+
const target = join2(dir, "demo", ...file.path.split("/"));
|
|
1511
|
+
await mkdir2(join2(target, ".."), { recursive: true });
|
|
1512
|
+
await writeFile2(target, file.bytes);
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
963
1515
|
const headline = resolveOgHeadline(entry, headlines);
|
|
964
1516
|
if (ogBase) {
|
|
965
1517
|
cardPlans.push({ id: entry.id, kicker: ogKicker(entry), headline });
|
|
@@ -1155,6 +1707,10 @@ ${links}
|
|
|
1155
1707
|
</nav>
|
|
1156
1708
|
</header>`;
|
|
1157
1709
|
}
|
|
1710
|
+
function articleCount(area) {
|
|
1711
|
+
const landing = areaLanding(area);
|
|
1712
|
+
return area.entries.filter((e) => !(e.id === landing && e.id.endsWith("-index"))).length;
|
|
1713
|
+
}
|
|
1158
1714
|
function areaLanding(area) {
|
|
1159
1715
|
const index = area.entries.find((e) => e.id.endsWith("-index") || e.id.endsWith("-overview"));
|
|
1160
1716
|
return (index ?? area.entries[0])?.id ?? "";
|
|
@@ -1164,7 +1720,7 @@ function sidebar(areas, entry, depth) {
|
|
|
1164
1720
|
const isCurrent = area.area === entry.area;
|
|
1165
1721
|
const items = isCurrent && area.entries.length <= NAV_INLINE_MAX ? area.entries : isCurrent ? dedupeById([...area.entries.filter((e) => e.id === areaLanding(area)), entry]) : [];
|
|
1166
1722
|
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
|
|
1723
|
+
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
1724
|
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
1725
|
return `<section>
|
|
1170
1726
|
${heading}
|
|
@@ -1283,7 +1839,7 @@ ${listed.map((e) => `<li><a href="${esc(e.id)}/">${esc(e.title)}</a></li>`).join
|
|
|
1283
1839
|
<h2><a href="${esc(landing)}/">${esc(area.title)}</a></h2>
|
|
1284
1840
|
<p class="hb-area-blurb">${esc(AREA_BLURBS[area.area] ?? "")}</p>
|
|
1285
1841
|
${list}
|
|
1286
|
-
<p class="hb-more"><a href="${esc(landing)}/">Browse all ${area
|
|
1842
|
+
<p class="hb-more"><a href="${esc(landing)}/">Browse all ${articleCount(area)} ${esc(area.title.toLowerCase())}</a></p>
|
|
1287
1843
|
</section>`;
|
|
1288
1844
|
}).join("\n");
|
|
1289
1845
|
return `${head("Gezel Handboek", css, 0, "Documentation for gezel \u2014 a crew of AI companions that works for you, from your own computer.", social)}
|