@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.
- 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 +1036 -465
- package/dist/handboek-export.js +563 -9
- package/dist/knowledge-command.js +28 -3
- package/dist/tui/index.js +38 -33
- 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();
|
|
@@ -2498,9 +2501,12 @@ import {
|
|
|
2498
2501
|
formatModelAttribution,
|
|
2499
2502
|
isMoEFromTags,
|
|
2500
2503
|
isRecommendedModel,
|
|
2501
|
-
|
|
2504
|
+
lowBitScoreFactor,
|
|
2502
2505
|
pickRecommendedModel
|
|
2503
2506
|
} from "@bendyline/gezel";
|
|
2507
|
+
function fitVerdicts(res) {
|
|
2508
|
+
return res ? new Map(res.models.map((m) => [m.id, m.verdict])) : null;
|
|
2509
|
+
}
|
|
2504
2510
|
var CHAT_MEMORY_OVERHEAD = {
|
|
2505
2511
|
"llama-cpp": 1.2,
|
|
2506
2512
|
mlx: 1.3
|
|
@@ -2537,6 +2543,7 @@ function rankChatModels(items, device, provider) {
|
|
|
2537
2543
|
// Effective score: a model the shared gate rejects (restricted license,
|
|
2538
2544
|
// no tool support) sorts as unscored rather than leading the list.
|
|
2539
2545
|
recoScore: isRecommendedModel(manifest) ? manifest.recoScore ?? 0 : 0,
|
|
2546
|
+
...source.quantization ? { quantization: source.quantization } : {},
|
|
2540
2547
|
fit,
|
|
2541
2548
|
attribution: formatModelAttribution(manifest)
|
|
2542
2549
|
});
|
|
@@ -2548,7 +2555,8 @@ function rankChatModels(items, device, provider) {
|
|
|
2548
2555
|
...model.recoScore > 0 ? { recoScore: model.recoScore } : {},
|
|
2549
2556
|
licenseClass: "open",
|
|
2550
2557
|
tags: items.find((item) => item.manifest.kind === "chat-model" && item.manifest.id === model.id)?.manifest?.tags ?? [],
|
|
2551
|
-
residentBytes: model.residentBytes
|
|
2558
|
+
residentBytes: model.residentBytes,
|
|
2559
|
+
...model.quantization ? { quantization: model.quantization } : {}
|
|
2552
2560
|
})),
|
|
2553
2561
|
device
|
|
2554
2562
|
);
|
|
@@ -2556,8 +2564,9 @@ function rankChatModels(items, device, provider) {
|
|
|
2556
2564
|
(model) => model.fit === "fits" || model.fit === "fits-offload"
|
|
2557
2565
|
);
|
|
2558
2566
|
const pool = comfortable.length > 0 ? comfortable : candidates;
|
|
2567
|
+
const ranked = (model) => model.recoScore * lowBitScoreFactor(model.quantization);
|
|
2559
2568
|
pool.sort(
|
|
2560
|
-
(a, b) => b
|
|
2569
|
+
(a, b) => ranked(b) - ranked(a) || fitOrder(a.fit) - fitOrder(b.fit) || b.residentBytes - a.residentBytes || a.name.localeCompare(b.name)
|
|
2561
2570
|
);
|
|
2562
2571
|
if (!picked) return pool;
|
|
2563
2572
|
const bestIndex = pool.findIndex((model) => model.id === picked.id);
|
|
@@ -2575,9 +2584,9 @@ function rankChatModels(items, device, provider) {
|
|
|
2575
2584
|
function bootstrapChatModelLabel(model) {
|
|
2576
2585
|
return `${model.name} (${model.attribution})`;
|
|
2577
2586
|
}
|
|
2578
|
-
function pickAccessoryModels(input
|
|
2587
|
+
function pickAccessoryModels(input) {
|
|
2579
2588
|
const output = [];
|
|
2580
|
-
const image = pickCatalogMedia(input.imageItems,
|
|
2589
|
+
const image = pickCatalogMedia(input.imageItems, input.fit.image);
|
|
2581
2590
|
if (image && !input.installed.image?.has(image.id)) {
|
|
2582
2591
|
output.push({
|
|
2583
2592
|
kind: "image",
|
|
@@ -2616,7 +2625,7 @@ function pickAccessoryModels(input, device) {
|
|
|
2616
2625
|
approxSizeBytes: tts.approxSizeBytes
|
|
2617
2626
|
});
|
|
2618
2627
|
}
|
|
2619
|
-
const video = pickCatalogMedia(input.videoItems,
|
|
2628
|
+
const video = pickCatalogMedia(input.videoItems, input.fit.video);
|
|
2620
2629
|
if (video && !input.installed.video?.has(video.id)) {
|
|
2621
2630
|
output.push({
|
|
2622
2631
|
kind: "video",
|
|
@@ -2644,14 +2653,8 @@ function fitOrder(fit) {
|
|
|
2644
2653
|
return 3;
|
|
2645
2654
|
}
|
|
2646
2655
|
}
|
|
2647
|
-
function pickCatalogMedia(items,
|
|
2648
|
-
const models = items.map((item) => item.manifest).filter((model) =>
|
|
2649
|
-
if (model.licenseClass !== "open" || !model.recoScore) return false;
|
|
2650
|
-
return mediaModelFits(
|
|
2651
|
-
device,
|
|
2652
|
-
kind === "image" ? { minRamGB: model.minRamGB } : { minVramGB: model.minVramGB }
|
|
2653
|
-
);
|
|
2654
|
-
});
|
|
2656
|
+
function pickCatalogMedia(items, verdicts) {
|
|
2657
|
+
const models = items.map((item) => item.manifest).filter((model) => isRecommendedModel(model) && verdicts?.get(model.id) === "fits");
|
|
2655
2658
|
return pickScoredOpen(models);
|
|
2656
2659
|
}
|
|
2657
2660
|
function pickScoredOpen(models, requireLicense = true) {
|
|
@@ -4731,7 +4734,9 @@ function BootstrapGate(props) {
|
|
|
4731
4734
|
installedVideo,
|
|
4732
4735
|
installedStt,
|
|
4733
4736
|
installedTts,
|
|
4734
|
-
installedRecognition
|
|
4737
|
+
installedRecognition,
|
|
4738
|
+
imageFit,
|
|
4739
|
+
videoFit
|
|
4735
4740
|
] = await Promise.all([
|
|
4736
4741
|
client.listCatalogItems("image-model").catch(() => ({ items: [] })),
|
|
4737
4742
|
client.listCatalogItems("video-model").catch(() => ({ items: [] })),
|
|
@@ -4741,7 +4746,9 @@ function BootstrapGate(props) {
|
|
|
4741
4746
|
client.listInstalledVideoModels().catch(() => ({ models: [] })),
|
|
4742
4747
|
client.listInstalledSttModels().catch(() => ({ models: [] })),
|
|
4743
4748
|
client.listInstalledTtsModels().catch(() => ({ models: [] })),
|
|
4744
|
-
client.listInstalledRecognitionModels().catch(() => ({ models: [] }))
|
|
4749
|
+
client.listInstalledRecognitionModels().catch(() => ({ models: [] })),
|
|
4750
|
+
client.getImageModelFit().catch(() => null),
|
|
4751
|
+
client.getVideoModelFit().catch(() => null)
|
|
4745
4752
|
]);
|
|
4746
4753
|
const installedIds = new Set(installedChat.models.map((model) => model.id));
|
|
4747
4754
|
const rankedChatModels = rankChatModels(
|
|
@@ -4764,22 +4771,20 @@ function BootstrapGate(props) {
|
|
|
4764
4771
|
});
|
|
4765
4772
|
return;
|
|
4766
4773
|
}
|
|
4767
|
-
const accessories = pickAccessoryModels(
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
-
|
|
4776
|
-
|
|
4777
|
-
|
|
4778
|
-
recognition: idSet(installedRecognition.models)
|
|
4779
|
-
}
|
|
4774
|
+
const accessories = pickAccessoryModels({
|
|
4775
|
+
imageItems: imageCatalog.items,
|
|
4776
|
+
videoItems: videoCatalog.items,
|
|
4777
|
+
audio: audioCatalog,
|
|
4778
|
+
recognition: recognitionCatalog.models,
|
|
4779
|
+
installed: {
|
|
4780
|
+
image: idSet(installedImage.models),
|
|
4781
|
+
video: idSet(installedVideo.models),
|
|
4782
|
+
stt: idSet(installedStt.models),
|
|
4783
|
+
tts: idSet(installedTts.models),
|
|
4784
|
+
recognition: idSet(installedRecognition.models)
|
|
4780
4785
|
},
|
|
4781
|
-
|
|
4782
|
-
);
|
|
4786
|
+
fit: { image: fitVerdicts(imageFit), video: fitVerdicts(videoFit) }
|
|
4787
|
+
});
|
|
4783
4788
|
setScreen({
|
|
4784
4789
|
kind: "model-choice",
|
|
4785
4790
|
plan: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.5",
|
|
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.5",
|
|
48
|
+
"@bendyline/gezel-app-sdk": "1.1.5",
|
|
49
|
+
"@bendyline/gezel-catalog": "1.2.5",
|
|
50
|
+
"@bendyline/gezel-client": "1.2.5",
|
|
51
|
+
"@bendyline/gezel-knowledge": "1.2.5",
|
|
52
|
+
"@bendyline/gezel-service": "1.2.5",
|
|
53
|
+
"@bendyline/squisq": "2.11.19",
|
|
54
|
+
"@bendyline/squisq-formats": "2.6.20",
|
|
55
|
+
"@bendyline/squisq-react": "2.11.23",
|
|
56
56
|
"commander": "^15.0.0",
|
|
57
57
|
"ink": "^7.1.1",
|
|
58
58
|
"ink-text-input": "^6.0.0",
|