@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
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
|
|
32
32
|
// src/connection.ts
|
|
33
33
|
import { createHash, randomUUID } from "crypto";
|
|
34
|
-
import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
34
|
+
import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
|
|
35
35
|
import { homedir } from "os";
|
|
36
36
|
import { basename, dirname, join, resolve } from "path";
|
|
37
37
|
import {
|
|
@@ -74,6 +74,26 @@ var CliError = class extends Error {
|
|
|
74
74
|
// src/knowledge-command.ts
|
|
75
75
|
var CATALOG_JSON = "catalog.json";
|
|
76
76
|
var CONTENT_DIR = "content";
|
|
77
|
+
async function defaultCreateMediaEmbedder(profile) {
|
|
78
|
+
const { createCatalogMediaEmbedder } = await import("@bendyline/gezel-service/media");
|
|
79
|
+
return createCatalogMediaEmbedder(profile, {
|
|
80
|
+
cacheDir: hfCacheDir(),
|
|
81
|
+
onWarning: (message) => console.warn(`warning: ${message}`)
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
function withAssetAttribution(assets, attribution) {
|
|
85
|
+
if (!attribution) return assets;
|
|
86
|
+
const known = new Set(assets.map((a) => a.path));
|
|
87
|
+
for (const key of Object.keys(attribution)) {
|
|
88
|
+
const path = key.startsWith("assets/") ? key : `assets/${key}`;
|
|
89
|
+
if (!known.has(path))
|
|
90
|
+
console.warn(`warning: catalog.json assets: '${key}' is not an asset of this catalog`);
|
|
91
|
+
}
|
|
92
|
+
return assets.map((asset) => {
|
|
93
|
+
const entry = attribution[asset.path] ?? attribution[asset.path.replace(/^assets\//, "")];
|
|
94
|
+
return entry ? { ...asset, attribution: entry } : asset;
|
|
95
|
+
});
|
|
96
|
+
}
|
|
77
97
|
function hfCacheDir() {
|
|
78
98
|
if (process.env.GEZEL_HF_CACHE_DIR) return process.env.GEZEL_HF_CACHE_DIR;
|
|
79
99
|
const home = process.env.GEZEL_HOME ?? join2(homedir2(), ".gezel");
|
|
@@ -226,6 +246,7 @@ async function runKnowledgeBuild(dir, opts, deps = {}) {
|
|
|
226
246
|
);
|
|
227
247
|
console.log("Loading the embedding model (first run downloads it)\u2026");
|
|
228
248
|
const embedder = await (deps.createEmbedder ?? defaultCreateEmbedder)(profileId);
|
|
249
|
+
const media = profile.media ? await (deps.createMediaEmbedder ?? defaultCreateMediaEmbedder)(profile) : null;
|
|
229
250
|
const signKeyPem = opts.signKey ? await readFile2(resolve2(opts.signKey), "utf8") : null;
|
|
230
251
|
const outputPath = resolve2(opts.out ?? join2(root, `${config.id}-${config.version}.gezk`));
|
|
231
252
|
const workDir = await mkdtemp(join2(tmpdir(), "gezk-build-"));
|
|
@@ -252,7 +273,8 @@ async function runKnowledgeBuild(dir, opts, deps = {}) {
|
|
|
252
273
|
embed: (texts) => embedder.embed(texts),
|
|
253
274
|
countTokens: (text) => embedder.countTokens(text),
|
|
254
275
|
workDir,
|
|
255
|
-
assets: source.assets,
|
|
276
|
+
assets: withAssetAttribution(source.assets, config.assets),
|
|
277
|
+
...media ? { embedMedia: media.embedMedia } : {},
|
|
256
278
|
invalidAssets: "warn",
|
|
257
279
|
onWarning: (message) => console.warn(`warning: ${message}`),
|
|
258
280
|
...signKeyPem ? { finalizeManifest: (manifest) => signManifest(manifest, signKeyPem) } : {},
|
|
@@ -266,12 +288,15 @@ async function runKnowledgeBuild(dir, opts, deps = {}) {
|
|
|
266
288
|
}
|
|
267
289
|
});
|
|
268
290
|
if (process.stderr.isTTY && lastPct >= 0) process.stderr.write("\n");
|
|
291
|
+
const mediaRows = report.media.image + report.media.video + report.media.audio;
|
|
269
292
|
console.log(
|
|
270
|
-
`Wrote ${outputPath} \u2014 ${report.documents} documents, ${report.chunks} chunks, ${report.shards} shard${report.shards === 1 ? "" : "s"}, ${formatBytes(report.archiveBytes)}${report.manifest.signature ? `, signed (key ${report.manifest.signature.keyId})` : ""}`
|
|
293
|
+
`Wrote ${outputPath} \u2014 ${report.documents} documents, ${report.chunks} chunks, ${mediaRows > 0 ? `${mediaRows} media rows, ` : ""}${report.shards} shard${report.shards === 1 ? "" : "s"}, ${formatBytes(report.archiveBytes)}${report.manifest.signature ? `, signed (key ${report.manifest.signature.keyId})` : ""}`
|
|
271
294
|
);
|
|
272
295
|
} finally {
|
|
273
296
|
await embedder.dispose().catch(() => {
|
|
274
297
|
});
|
|
298
|
+
await media?.dispose().catch(() => {
|
|
299
|
+
});
|
|
275
300
|
await rm2(workDir, { recursive: true, force: true });
|
|
276
301
|
}
|
|
277
302
|
}
|
package/dist/tui/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { useCallback as useCallback2, useEffect as useEffect4, useMemo, useRef a
|
|
|
12
12
|
|
|
13
13
|
// src/connection.ts
|
|
14
14
|
import { createHash, randomUUID } from "crypto";
|
|
15
|
-
import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
15
|
+
import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
|
|
16
16
|
import { homedir } from "os";
|
|
17
17
|
import { basename, dirname, join, resolve } from "path";
|
|
18
18
|
import {
|
|
@@ -2235,6 +2235,7 @@ function normalizeCraftbooks(items, showWorkInProgressFeatures = false) {
|
|
|
2235
2235
|
...manifest.description ? { description: manifest.description } : {},
|
|
2236
2236
|
version: manifest.version,
|
|
2237
2237
|
sourceId: item.sourceId,
|
|
2238
|
+
command: manifest.command ?? manifest.id,
|
|
2238
2239
|
source: item.sourceId === "project" ? "project" : item.sourceId === "local" ? "local" : "bundled",
|
|
2239
2240
|
stepCount: manifest.steps.length,
|
|
2240
2241
|
tags: manifest.tags ?? [],
|
|
@@ -2309,7 +2310,9 @@ function countLabel(count) {
|
|
|
2309
2310
|
}
|
|
2310
2311
|
function findCraftbook(books, value) {
|
|
2311
2312
|
const query = value.trim().toLowerCase();
|
|
2312
|
-
return books.find(
|
|
2313
|
+
return books.find(
|
|
2314
|
+
(book) => book.id.toLowerCase() === query || book.command?.toLowerCase() === query || book.name.toLowerCase() === query
|
|
2315
|
+
);
|
|
2313
2316
|
}
|
|
2314
2317
|
function craftbookStartRequest(book) {
|
|
2315
2318
|
const summary = book.description?.trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"description": "The `gezel` command-line tool.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -44,15 +44,15 @@
|
|
|
44
44
|
"!dist/**/*.map"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@bendyline/gezel": "1.2.
|
|
48
|
-
"@bendyline/gezel-app-sdk": "1.1.
|
|
49
|
-
"@bendyline/gezel-catalog": "1.2.
|
|
50
|
-
"@bendyline/gezel-client": "1.2.
|
|
51
|
-
"@bendyline/gezel-knowledge": "1.2.
|
|
52
|
-
"@bendyline/gezel-service": "1.2.
|
|
53
|
-
"@bendyline/squisq": "2.11.
|
|
54
|
-
"@bendyline/squisq-formats": "2.6.
|
|
55
|
-
"@bendyline/squisq-react": "2.11.
|
|
47
|
+
"@bendyline/gezel": "1.2.4",
|
|
48
|
+
"@bendyline/gezel-app-sdk": "1.1.4",
|
|
49
|
+
"@bendyline/gezel-catalog": "1.2.4",
|
|
50
|
+
"@bendyline/gezel-client": "1.2.4",
|
|
51
|
+
"@bendyline/gezel-knowledge": "1.2.4",
|
|
52
|
+
"@bendyline/gezel-service": "1.2.4",
|
|
53
|
+
"@bendyline/squisq": "2.11.17",
|
|
54
|
+
"@bendyline/squisq-formats": "2.6.17",
|
|
55
|
+
"@bendyline/squisq-react": "2.11.19",
|
|
56
56
|
"commander": "^15.0.0",
|
|
57
57
|
"ink": "^7.1.1",
|
|
58
58
|
"ink-text-input": "^6.0.0",
|