@bendyline/gezel-cli 1.2.1 → 1.2.2
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 +24 -1
- package/dist/app-author-command.js +2 -0
- package/dist/app-command.js +2 -0
- package/dist/bin/gezel-main.js +35 -6
- package/dist/knowledge-command.js +38 -11
- package/dist/tui/index.js +9 -0
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -170,10 +170,33 @@ export async function run({ client, projectId, workspace, args, log, runCraftboo
|
|
|
170
170
|
|
|
171
171
|
Run it with `gezel workflow storyify c23n --json`. The module receives the
|
|
172
172
|
public `GezelClient`, the directory's project id, its absolute workspace,
|
|
173
|
-
arguments, a stderr logger,
|
|
173
|
+
arguments, a stderr logger, `complete(request)` (below), and
|
|
174
|
+
`runCraftbook(id, params, options)`. That helper
|
|
174
175
|
starts a **project** craftbook and waits; options include `timeoutMs`, a saved
|
|
175
176
|
`taskRef` to follow, `parentTaskRef` to link the child to its batch, and
|
|
176
177
|
`onCreated(task)` to checkpoint the new reference.
|
|
178
|
+
When a step needs model judgment on input the driver already holds — extract
|
|
179
|
+
the facts in this page, check this paragraph against these quotations — use
|
|
180
|
+
`complete(request)` instead of a craftbook. It makes one bounded call on the
|
|
181
|
+
project's engine queue and returns `{ content, json?, jsonError?, elapsedMs }`:
|
|
182
|
+
|
|
183
|
+
```js
|
|
184
|
+
const { json } = await complete({
|
|
185
|
+
gezelId: 'checker', // or provider + model
|
|
186
|
+
system: 'You are a meticulous fact-checker.',
|
|
187
|
+
prompt: `FACTS:\n${facts}\n\nSENTENCES:\n${sentences}`,
|
|
188
|
+
jsonSchema: verdictSchema, // grammar-constrained on local engines
|
|
189
|
+
thinking: false, // skip a local model's reasoning phase
|
|
190
|
+
maxTokens: 4000,
|
|
191
|
+
timeoutMs: 300_000,
|
|
192
|
+
label: 'check · Taylorville ¶3',
|
|
193
|
+
});
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
No tools, session or transcript are involved, so there is nothing to read
|
|
197
|
+
back and nothing to save: the driver validates the answer and persists what it
|
|
198
|
+
keeps. Use a craftbook when the work genuinely needs tools or a person.
|
|
199
|
+
|
|
177
200
|
For drivers that generate craftbook documents, `validateCraftbook(document)`
|
|
178
201
|
checks the same schema and step contracts as the daemon and returns the runtime
|
|
179
202
|
craftbook. Call it before installing files or freezing a batch checkpoint;
|
|
@@ -277,6 +277,7 @@ import {
|
|
|
277
277
|
getLogLevel,
|
|
278
278
|
getLogOutput,
|
|
279
279
|
pickRandomNameWithGender,
|
|
280
|
+
projectLeadGezelId,
|
|
280
281
|
setLogLevel,
|
|
281
282
|
setLogOutput
|
|
282
283
|
} from "@bendyline/gezel";
|
|
@@ -293,6 +294,7 @@ import {
|
|
|
293
294
|
discoverOrSpawn,
|
|
294
295
|
electronNativeBinCandidates,
|
|
295
296
|
ensureProjectForFolder as ensureClientProjectForFolder,
|
|
297
|
+
forbiddenProjectFolderName,
|
|
296
298
|
isProcessAlive,
|
|
297
299
|
readRuntime,
|
|
298
300
|
readSystemServiceEndpoint,
|
package/dist/app-command.js
CHANGED
|
@@ -14,6 +14,7 @@ import {
|
|
|
14
14
|
getLogLevel,
|
|
15
15
|
getLogOutput,
|
|
16
16
|
pickRandomNameWithGender,
|
|
17
|
+
projectLeadGezelId,
|
|
17
18
|
setLogLevel,
|
|
18
19
|
setLogOutput
|
|
19
20
|
} from "@bendyline/gezel";
|
|
@@ -30,6 +31,7 @@ import {
|
|
|
30
31
|
discoverOrSpawn,
|
|
31
32
|
electronNativeBinCandidates,
|
|
32
33
|
ensureProjectForFolder as ensureClientProjectForFolder,
|
|
34
|
+
forbiddenProjectFolderName,
|
|
33
35
|
isProcessAlive,
|
|
34
36
|
readRuntime,
|
|
35
37
|
readSystemServiceEndpoint,
|
package/dist/bin/gezel-main.js
CHANGED
|
@@ -65,6 +65,7 @@ import {
|
|
|
65
65
|
getLogLevel,
|
|
66
66
|
getLogOutput,
|
|
67
67
|
pickRandomNameWithGender,
|
|
68
|
+
projectLeadGezelId,
|
|
68
69
|
setLogLevel,
|
|
69
70
|
setLogOutput
|
|
70
71
|
} from "@bendyline/gezel";
|
|
@@ -81,6 +82,7 @@ import {
|
|
|
81
82
|
discoverOrSpawn,
|
|
82
83
|
electronNativeBinCandidates,
|
|
83
84
|
ensureProjectForFolder as ensureClientProjectForFolder,
|
|
85
|
+
forbiddenProjectFolderName,
|
|
84
86
|
isProcessAlive,
|
|
85
87
|
readRuntime,
|
|
86
88
|
readSystemServiceEndpoint,
|
|
@@ -619,9 +621,37 @@ async function ensureProjectForFolder(client, folderPath) {
|
|
|
619
621
|
});
|
|
620
622
|
return result.projectId;
|
|
621
623
|
}
|
|
624
|
+
var DEFAULT_PROJECT_ID = "default";
|
|
625
|
+
function defaultProjectNotice(folder, name) {
|
|
626
|
+
return `Using the Default project: gezel does not make a project of ${name} (${folder}). To work in a project, run gezel from its folder or pass --project <folder>.
|
|
627
|
+
`;
|
|
628
|
+
}
|
|
629
|
+
async function resolveCommandProject(client, globals) {
|
|
630
|
+
const p = globals.project;
|
|
631
|
+
const folder = resolve(typeof p === "string" ? p : process.cwd());
|
|
632
|
+
try {
|
|
633
|
+
return await ensureProjectForFolder(client, folder);
|
|
634
|
+
} catch (err) {
|
|
635
|
+
const name = forbiddenProjectFolderName(err);
|
|
636
|
+
if (!name) throw err;
|
|
637
|
+
if (p === true || typeof p === "string") {
|
|
638
|
+
throw new CliError(
|
|
639
|
+
`gezel does not make a project of ${name} (${folder}). Pass --project with a project folder, or leave out --project to use the Default project.`
|
|
640
|
+
);
|
|
641
|
+
}
|
|
642
|
+
process.stderr.write(defaultProjectNotice(folder, name));
|
|
643
|
+
return DEFAULT_PROJECT_ID;
|
|
644
|
+
}
|
|
645
|
+
}
|
|
622
646
|
async function ensureCliProjectLead(client, projectId) {
|
|
623
647
|
const project = await client.getProject(projectId);
|
|
624
648
|
if (project.voormanGezelId) return project.voormanGezelId;
|
|
649
|
+
if (project.id === DEFAULT_PROJECT_ID) {
|
|
650
|
+
const { meesterGezelId } = await client.getConfig();
|
|
651
|
+
const lead = projectLeadGezelId(project, meesterGezelId);
|
|
652
|
+
if (!lead) throw new CliError("the Default project has no Meester yet");
|
|
653
|
+
return lead;
|
|
654
|
+
}
|
|
625
655
|
if (project.mode === "solo") {
|
|
626
656
|
if (project.gezelIds?.[0]) return project.gezelIds[0];
|
|
627
657
|
if (project.workingDir) {
|
|
@@ -655,14 +685,10 @@ async function ensureCliProjectLead(client, projectId) {
|
|
|
655
685
|
return updated.voormanGezelId;
|
|
656
686
|
}
|
|
657
687
|
async function resolveRunProject(client, globals) {
|
|
658
|
-
|
|
659
|
-
const folder = p === void 0 || p === true || p === false ? process.cwd() : p;
|
|
660
|
-
return ensureProjectForFolder(client, folder);
|
|
688
|
+
return resolveCommandProject(client, globals);
|
|
661
689
|
}
|
|
662
690
|
async function resolveTuiProject(client, globals) {
|
|
663
|
-
|
|
664
|
-
const folder = p === void 0 || p === true || p === false ? process.cwd() : p;
|
|
665
|
-
return ensureProjectForFolder(client, folder);
|
|
691
|
+
return resolveCommandProject(client, globals);
|
|
666
692
|
}
|
|
667
693
|
|
|
668
694
|
// src/craftbook-command.ts
|
|
@@ -1766,6 +1792,9 @@ async function runWorkflow(client, projectId, workspace, file, args, log = conso
|
|
|
1766
1792
|
...invocation ?? {},
|
|
1767
1793
|
log,
|
|
1768
1794
|
validateCraftbook: validateWorkflowCraftbook,
|
|
1795
|
+
// A bounded model call whose input the driver already holds. Cheaper and
|
|
1796
|
+
// more reliable than a task that must read its input back through tools.
|
|
1797
|
+
complete: (request, signal) => client.completeInProject(projectId, request, signal),
|
|
1769
1798
|
runCraftbook: async (id, params, options = {}) => {
|
|
1770
1799
|
let ref = options.taskRef;
|
|
1771
1800
|
if (!ref) {
|
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
// src/knowledge-command.ts
|
|
4
4
|
import { createHash as createHash2 } from "crypto";
|
|
5
5
|
import { existsSync } from "fs";
|
|
6
|
-
import { mkdir as mkdir2, mkdtemp, readFile as readFile2, rm as rm2, stat, writeFile as writeFile2 } from "fs/promises";
|
|
6
|
+
import { mkdir as mkdir2, mkdtemp, readFile as readFile2, readdir, rm as rm2, stat, writeFile as writeFile2 } from "fs/promises";
|
|
7
7
|
import { homedir as homedir2, tmpdir } from "os";
|
|
8
|
-
import { basename as basename2, dirname as dirname2, join as join2, relative, resolve as resolve2 } from "path";
|
|
8
|
+
import { basename as basename2, dirname as dirname2, isAbsolute, join as join2, relative, resolve as resolve2 } from "path";
|
|
9
9
|
import { KnowledgeIdSchema, formatKnowledgeUri } from "@bendyline/gezel";
|
|
10
10
|
import {
|
|
11
11
|
CatalogHandle,
|
|
@@ -34,6 +34,7 @@ import {
|
|
|
34
34
|
getLogLevel,
|
|
35
35
|
getLogOutput,
|
|
36
36
|
pickRandomNameWithGender,
|
|
37
|
+
projectLeadGezelId,
|
|
37
38
|
setLogLevel,
|
|
38
39
|
setLogOutput
|
|
39
40
|
} from "@bendyline/gezel";
|
|
@@ -50,6 +51,7 @@ import {
|
|
|
50
51
|
discoverOrSpawn,
|
|
51
52
|
electronNativeBinCandidates,
|
|
52
53
|
ensureProjectForFolder as ensureClientProjectForFolder,
|
|
54
|
+
forbiddenProjectFolderName,
|
|
53
55
|
isProcessAlive,
|
|
54
56
|
readRuntime,
|
|
55
57
|
readSystemServiceEndpoint,
|
|
@@ -99,6 +101,15 @@ function embeddingRuntimeMissingMessage() {
|
|
|
99
101
|
"The Gezel desktop app already includes it, and full-text search works without it."
|
|
100
102
|
].join("\n");
|
|
101
103
|
}
|
|
104
|
+
async function holdsMarkdown(dir) {
|
|
105
|
+
const entries = await readdir(dir, { withFileTypes: true }).catch(() => []);
|
|
106
|
+
const visible = entries.filter((e) => !e.name.startsWith(".") && e.name !== "node_modules");
|
|
107
|
+
if (visible.some((e) => e.isFile() && /\.(md|markdown)$/i.test(e.name))) return true;
|
|
108
|
+
for (const entry of visible) {
|
|
109
|
+
if (entry.isDirectory() && await holdsMarkdown(join2(dir, entry.name))) return true;
|
|
110
|
+
}
|
|
111
|
+
return false;
|
|
112
|
+
}
|
|
102
113
|
async function runKnowledgeInit(dir) {
|
|
103
114
|
const root = resolve2(dir);
|
|
104
115
|
const configPath = join2(root, CATALOG_JSON);
|
|
@@ -107,7 +118,8 @@ async function runKnowledgeInit(dir) {
|
|
|
107
118
|
() => false
|
|
108
119
|
);
|
|
109
120
|
if (exists) throw new CliError(`${configPath} already exists`);
|
|
110
|
-
await
|
|
121
|
+
const inPlace = await holdsMarkdown(root);
|
|
122
|
+
await mkdir2(inPlace ? root : join2(root, CONTENT_DIR, "Getting Started"), { recursive: true });
|
|
111
123
|
const id = sanitizeCatalogId(basename2(root));
|
|
112
124
|
const config = {
|
|
113
125
|
id,
|
|
@@ -121,16 +133,25 @@ async function runKnowledgeInit(dir) {
|
|
|
121
133
|
};
|
|
122
134
|
await writeFile2(configPath, `${JSON.stringify(config, null, 2)}
|
|
123
135
|
`, "utf8");
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
136
|
+
if (!inPlace) {
|
|
137
|
+
await writeFile2(
|
|
138
|
+
join2(root, CONTENT_DIR, "Getting Started", "welcome.md"),
|
|
139
|
+
"# Welcome\n\nPut Markdown files under content/ \u2014 folders become the table of contents.\n",
|
|
140
|
+
"utf8"
|
|
141
|
+
);
|
|
142
|
+
}
|
|
129
143
|
console.log(`Initialized knowledge catalog at ${root}`);
|
|
130
144
|
console.log(` ${CATALOG_JSON} \u2014 identity, license, embedding profile`);
|
|
131
|
-
|
|
145
|
+
if (inPlace) {
|
|
146
|
+
const toc = await detectTableOfContents(root);
|
|
147
|
+
console.log(
|
|
148
|
+
` The Markdown already in this folder is the content (table of contents: ${describeToc(toc, root)})`
|
|
149
|
+
);
|
|
150
|
+
} else {
|
|
151
|
+
console.log(` ${CONTENT_DIR}/ \u2014 Markdown content (folders become topics)`);
|
|
152
|
+
}
|
|
132
153
|
console.log(
|
|
133
|
-
" An outline the tree already has is honored: SUMMARY.md, an mkdocs.yml nav, _toc.yml, or Hugo _index.md pages"
|
|
154
|
+
" An outline the tree already has is honored: SUMMARY.md, an mkdocs.yml nav, _toc.yml, docfx toc.yml files, or Hugo _index.md pages"
|
|
134
155
|
);
|
|
135
156
|
console.log(`Build with: gezel knowledge build ${dir}`);
|
|
136
157
|
}
|
|
@@ -165,9 +186,14 @@ async function resolveContentRoot(root, config) {
|
|
|
165
186
|
}
|
|
166
187
|
return root;
|
|
167
188
|
}
|
|
189
|
+
function displayPath(root, path) {
|
|
190
|
+
const rel = relative(root, path);
|
|
191
|
+
if (rel === "") return ".";
|
|
192
|
+
return rel.startsWith("..") || isAbsolute(rel) ? path : rel;
|
|
193
|
+
}
|
|
168
194
|
function describeToc(toc, root) {
|
|
169
195
|
const source = toc.format === "folders" ? "folders" : toc.format === "hugo" ? "Hugo conventions (_index.md, weight)" : toc.format;
|
|
170
|
-
return toc.path ? `${source} (${
|
|
196
|
+
return toc.path ? `${source} (${displayPath(root, toc.path)})` : source;
|
|
171
197
|
}
|
|
172
198
|
async function runKnowledgeBuild(dir, opts, deps = {}) {
|
|
173
199
|
const root = resolve2(dir);
|
|
@@ -181,6 +207,7 @@ async function runKnowledgeBuild(dir, opts, deps = {}) {
|
|
|
181
207
|
toc,
|
|
182
208
|
onWarning: (message) => console.warn(`warning: ${message}`)
|
|
183
209
|
});
|
|
210
|
+
console.log(`Content: ${displayPath(root, contentRoot)}`);
|
|
184
211
|
console.log(`Table of contents: ${describeToc(source.toc, root)}`);
|
|
185
212
|
const profileId = config.profile ?? "bge-small-en-v1.5@1";
|
|
186
213
|
const profile = knowledgeEmbeddingProfile(profileId);
|
package/dist/tui/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
getLogLevel,
|
|
20
20
|
getLogOutput,
|
|
21
21
|
pickRandomNameWithGender,
|
|
22
|
+
projectLeadGezelId,
|
|
22
23
|
setLogLevel,
|
|
23
24
|
setLogOutput
|
|
24
25
|
} from "@bendyline/gezel";
|
|
@@ -35,6 +36,7 @@ import {
|
|
|
35
36
|
discoverOrSpawn,
|
|
36
37
|
electronNativeBinCandidates,
|
|
37
38
|
ensureProjectForFolder as ensureClientProjectForFolder,
|
|
39
|
+
forbiddenProjectFolderName,
|
|
38
40
|
isProcessAlive,
|
|
39
41
|
readRuntime,
|
|
40
42
|
readSystemServiceEndpoint,
|
|
@@ -49,9 +51,16 @@ var CliError = class extends Error {
|
|
|
49
51
|
this.name = "CliError";
|
|
50
52
|
}
|
|
51
53
|
};
|
|
54
|
+
var DEFAULT_PROJECT_ID = "default";
|
|
52
55
|
async function ensureCliProjectLead(client, projectId) {
|
|
53
56
|
const project = await client.getProject(projectId);
|
|
54
57
|
if (project.voormanGezelId) return project.voormanGezelId;
|
|
58
|
+
if (project.id === DEFAULT_PROJECT_ID) {
|
|
59
|
+
const { meesterGezelId } = await client.getConfig();
|
|
60
|
+
const lead = projectLeadGezelId(project, meesterGezelId);
|
|
61
|
+
if (!lead) throw new CliError("the Default project has no Meester yet");
|
|
62
|
+
return lead;
|
|
63
|
+
}
|
|
55
64
|
if (project.mode === "solo") {
|
|
56
65
|
if (project.gezelIds?.[0]) return project.gezelIds[0];
|
|
57
66
|
if (project.workingDir) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "The `gezel` command-line tool.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -44,12 +44,12 @@
|
|
|
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.
|
|
47
|
+
"@bendyline/gezel": "1.2.2",
|
|
48
|
+
"@bendyline/gezel-app-sdk": "1.1.2",
|
|
49
|
+
"@bendyline/gezel-catalog": "1.2.2",
|
|
50
|
+
"@bendyline/gezel-client": "1.2.2",
|
|
51
|
+
"@bendyline/gezel-knowledge": "1.2.2",
|
|
52
|
+
"@bendyline/gezel-service": "1.2.2",
|
|
53
53
|
"@bendyline/squisq": "2.11.11",
|
|
54
54
|
"@bendyline/squisq-formats": "2.6.11",
|
|
55
55
|
"@bendyline/squisq-react": "2.11.13",
|