@bendyline/gezel-cli 1.0.6 → 1.0.7
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 +3 -3
- package/dist/app-author-command.js +464 -0
- package/dist/app-command.js +685 -0
- package/dist/bin/gezel-main.js +423 -25
- package/dist/handboek-export.js +713 -30
- package/dist/knowledge-command.js +351 -0
- package/dist/tui/index.js +372 -51
- package/package.json +10 -9
package/README.md
CHANGED
|
@@ -8,8 +8,8 @@ as ordinary files you can `cat` and `grep`, and talks to whichever LLM provider
|
|
|
8
8
|
you point it at. No cloud service of ours stands between you and the model.
|
|
9
9
|
|
|
10
10
|
```bash
|
|
11
|
-
npm install
|
|
12
|
-
gezel
|
|
11
|
+
npm install @bendyline/gezel-cli
|
|
12
|
+
npx gezel
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
On a clean machine, the TUI stays in first-time setup until you decide what to
|
|
@@ -150,7 +150,7 @@ Run `gezel --help` for the full list. The most-used ones:
|
|
|
150
150
|
| `gezel agent list\|create\|show` | Manage your gezels |
|
|
151
151
|
| `gezel env list\|create\|install` | Manage projects and their packages |
|
|
152
152
|
| `gezel task list\|create\|show` | Manage tasks |
|
|
153
|
-
| `gezel model list\|pull` | Manage on-device chat models |
|
|
153
|
+
| `gezel model list\|pull\|export` | Manage on-device chat models. `export <id> [file]` downloads the catalog model if needed, then writes a portable, checksum-verified `.gezmodel` you can move to another machine |
|
|
154
154
|
| `gezel native install\|list\|status` | Manage native engine binaries |
|
|
155
155
|
| `gezel create-image\|create-video\|create-audio` | Generate media |
|
|
156
156
|
| `gezel skills import\|convert` | Import and convert skills |
|
|
@@ -0,0 +1,464 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/app-author-command.ts
|
|
4
|
+
import { mkdir as mkdir2, readFile as readFile2, readdir, stat, writeFile as writeFile2 } from "fs/promises";
|
|
5
|
+
import { dirname as dirname2, isAbsolute, join as join2 } from "path";
|
|
6
|
+
import {
|
|
7
|
+
GezappSourceError,
|
|
8
|
+
packGezappFromSource,
|
|
9
|
+
readGezapp,
|
|
10
|
+
renderGezappAuthoringSchemaFiles,
|
|
11
|
+
validateGezappSource,
|
|
12
|
+
verifyGezapp
|
|
13
|
+
} from "@bendyline/gezel-service/gezapp";
|
|
14
|
+
|
|
15
|
+
// src/app-scaffold.ts
|
|
16
|
+
var SCAFFOLD_ID_PATTERN = /^[a-z0-9][a-z0-9-]{1,63}$/;
|
|
17
|
+
function titleCase(id) {
|
|
18
|
+
return id.split("-").map((part) => part ? part[0].toUpperCase() + part.slice(1) : part).join(" ");
|
|
19
|
+
}
|
|
20
|
+
function shard(id) {
|
|
21
|
+
return id.slice(0, 2).toLowerCase();
|
|
22
|
+
}
|
|
23
|
+
var json = (value) => `${JSON.stringify(value, null, 2)}
|
|
24
|
+
`;
|
|
25
|
+
var STORE_SCRIPT = `import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
26
|
+
|
|
27
|
+
export const meta = defineScript({
|
|
28
|
+
name: 'records-store',
|
|
29
|
+
description: 'Add and list records in data.json.',
|
|
30
|
+
kind: 'action',
|
|
31
|
+
inputs: {
|
|
32
|
+
action: { type: 'string', description: "'add' or 'list'.", default: 'list' },
|
|
33
|
+
title: { type: 'string', description: 'Title for a new record.', default: '' },
|
|
34
|
+
},
|
|
35
|
+
outputs: {
|
|
36
|
+
records: { type: 'json', description: 'The records after the operation.' },
|
|
37
|
+
},
|
|
38
|
+
requires: ['workspace.read', 'workspace.write'],
|
|
39
|
+
} as const);
|
|
40
|
+
|
|
41
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
42
|
+
const raw = await gezel.fs.read('data.json').catch(() => '{"records":[]}');
|
|
43
|
+
const data = JSON.parse(raw) as { records: Array<{ title: string; at: string }> };
|
|
44
|
+
if (input.action === 'add' && input.title) {
|
|
45
|
+
data.records.push({ title: input.title, at: new Date().toISOString() });
|
|
46
|
+
await gezel.fs.write('data.json', JSON.stringify(data, null, 2));
|
|
47
|
+
}
|
|
48
|
+
gezel.output({ records: data.records });
|
|
49
|
+
`;
|
|
50
|
+
function dashboardHtml(name) {
|
|
51
|
+
return `<!doctype html>
|
|
52
|
+
<html lang="en">
|
|
53
|
+
<head>
|
|
54
|
+
<meta charset="utf-8" />
|
|
55
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
56
|
+
<style>
|
|
57
|
+
:root {
|
|
58
|
+
color-scheme: light dark;
|
|
59
|
+
--bg: #f7f4ee;
|
|
60
|
+
--ink: #2c2925;
|
|
61
|
+
--card: #fffdf9;
|
|
62
|
+
--line: #d9d2c6;
|
|
63
|
+
}
|
|
64
|
+
@media (prefers-color-scheme: dark) {
|
|
65
|
+
:root {
|
|
66
|
+
--bg: #211e1a;
|
|
67
|
+
--ink: #e8e2d8;
|
|
68
|
+
--card: #2b2723;
|
|
69
|
+
--line: #47413a;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
body {
|
|
73
|
+
margin: 0;
|
|
74
|
+
padding: 1.5rem;
|
|
75
|
+
background: var(--bg);
|
|
76
|
+
color: var(--ink);
|
|
77
|
+
font: 15px/1.5 system-ui, sans-serif;
|
|
78
|
+
}
|
|
79
|
+
h1 { font-size: 1.2rem; margin: 0 0 1rem; }
|
|
80
|
+
ul { list-style: none; margin: 0; padding: 0; }
|
|
81
|
+
li {
|
|
82
|
+
background: var(--card);
|
|
83
|
+
border: 1px solid var(--line);
|
|
84
|
+
border-radius: 4px;
|
|
85
|
+
padding: 0.5rem 0.75rem;
|
|
86
|
+
margin-bottom: 0.5rem;
|
|
87
|
+
}
|
|
88
|
+
button {
|
|
89
|
+
background: var(--card);
|
|
90
|
+
color: var(--ink);
|
|
91
|
+
border: 1px solid var(--line);
|
|
92
|
+
border-radius: 4px;
|
|
93
|
+
padding: 0.4rem 0.9rem;
|
|
94
|
+
cursor: pointer;
|
|
95
|
+
}
|
|
96
|
+
</style>
|
|
97
|
+
</head>
|
|
98
|
+
<body>
|
|
99
|
+
<h1>${name}</h1>
|
|
100
|
+
<ul id="records"></ul>
|
|
101
|
+
<button id="add">Add a record</button>
|
|
102
|
+
<script>
|
|
103
|
+
const list = document.querySelector('#records');
|
|
104
|
+
function render(data) {
|
|
105
|
+
list.replaceChildren();
|
|
106
|
+
for (const record of data.records) {
|
|
107
|
+
const item = document.createElement('li');
|
|
108
|
+
item.textContent = record.title + ' \u2014 ' + record.at.slice(0, 10);
|
|
109
|
+
list.append(item);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
async function refresh() {
|
|
113
|
+
render(await gezel.data.read('data.json', { as: 'json' }));
|
|
114
|
+
}
|
|
115
|
+
gezel.data.watch('data.json', refresh);
|
|
116
|
+
document.querySelector('#add').addEventListener('click', async () => {
|
|
117
|
+
await gezel.tools.invoke('add_record', { title: 'Added from the page' });
|
|
118
|
+
await refresh();
|
|
119
|
+
});
|
|
120
|
+
refresh();
|
|
121
|
+
</script>
|
|
122
|
+
</body>
|
|
123
|
+
</html>
|
|
124
|
+
`;
|
|
125
|
+
}
|
|
126
|
+
function scaffoldGezappSource(id, opts) {
|
|
127
|
+
if (!SCAFFOLD_ID_PATTERN.test(id)) {
|
|
128
|
+
throw new Error(
|
|
129
|
+
`"${id}" is not a valid app id \u2014 use lowercase letters, digits, and hyphens (2-64 chars)`
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const name = opts?.name ?? titleCase(id);
|
|
133
|
+
const roleId = `${id}-lead`;
|
|
134
|
+
const typeDir = `items/project-types/${shard(id)}/${id}`;
|
|
135
|
+
const roleDir = `items/gezel-templates/${shard(roleId)}/${roleId}`;
|
|
136
|
+
const files = [
|
|
137
|
+
[
|
|
138
|
+
"gezapp.json",
|
|
139
|
+
json({
|
|
140
|
+
format: "gezel-ai-app-source",
|
|
141
|
+
schemaVersion: 1
|
|
142
|
+
})
|
|
143
|
+
],
|
|
144
|
+
[
|
|
145
|
+
"README.md",
|
|
146
|
+
`# ${name}
|
|
147
|
+
|
|
148
|
+
An AI App source folder scaffolded by \`gezel app new\`.
|
|
149
|
+
|
|
150
|
+
The loop:
|
|
151
|
+
|
|
152
|
+
1. Edit the files under \`items/\` (schemas: \`gezel app schemas --out schemas\`).
|
|
153
|
+
2. \`gezel app validate .\`
|
|
154
|
+
3. \`gezel app pack .\`
|
|
155
|
+
4. \`gezel app add ${id}-1.0.0.gezapp --yes\` then \`gezel app apply ${id}\` in a project folder.
|
|
156
|
+
`
|
|
157
|
+
],
|
|
158
|
+
[
|
|
159
|
+
`${typeDir}/manifest.json`,
|
|
160
|
+
json({
|
|
161
|
+
schemaVersion: 1,
|
|
162
|
+
kind: "project-type",
|
|
163
|
+
id,
|
|
164
|
+
name,
|
|
165
|
+
description: `A focused ${name} workspace with one gezel and a records store.`,
|
|
166
|
+
tags: [],
|
|
167
|
+
maintainer: { name: "Your name" },
|
|
168
|
+
license: "MIT",
|
|
169
|
+
yankedVersions: []
|
|
170
|
+
})
|
|
171
|
+
],
|
|
172
|
+
[
|
|
173
|
+
`${typeDir}/versions/1.0.0/manifest.json`,
|
|
174
|
+
json({
|
|
175
|
+
schemaVersion: 1,
|
|
176
|
+
version: "1.0.0",
|
|
177
|
+
releasedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
178
|
+
mode: "solo",
|
|
179
|
+
leadLabel: "Keeper",
|
|
180
|
+
params: {
|
|
181
|
+
type: "object",
|
|
182
|
+
properties: {
|
|
183
|
+
focus: {
|
|
184
|
+
type: "string",
|
|
185
|
+
title: "What is this workspace about?",
|
|
186
|
+
default: "everyday records"
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
nameTemplate: `{{focus}} ${name}`,
|
|
191
|
+
aboutTemplate: "about.md",
|
|
192
|
+
missionTemplate: "mission.md",
|
|
193
|
+
gezels: [{ templateId: roleId, voorman: true }],
|
|
194
|
+
tools: [
|
|
195
|
+
{
|
|
196
|
+
name: "add_record",
|
|
197
|
+
description: "Add one record to data.json.",
|
|
198
|
+
script: "records-store",
|
|
199
|
+
inputs: {
|
|
200
|
+
type: "object",
|
|
201
|
+
properties: { title: { type: "string" } },
|
|
202
|
+
required: ["title"]
|
|
203
|
+
},
|
|
204
|
+
bind: { action: "add" }
|
|
205
|
+
}
|
|
206
|
+
],
|
|
207
|
+
workspaceSeed: ["data.json"],
|
|
208
|
+
...opts?.withPage ? {
|
|
209
|
+
pages: {
|
|
210
|
+
entry: "dashboard/index.html",
|
|
211
|
+
api: 1,
|
|
212
|
+
reads: [{ source: "workspace", path: "data.json" }],
|
|
213
|
+
tools: ["add_record"]
|
|
214
|
+
}
|
|
215
|
+
} : {}
|
|
216
|
+
})
|
|
217
|
+
],
|
|
218
|
+
[
|
|
219
|
+
`${typeDir}/versions/1.0.0/about.md`,
|
|
220
|
+
`This project is a ${name} workspace focused on {{focus}}.
|
|
221
|
+
|
|
222
|
+
Records live in data.json; use the add_record tool rather than editing it by hand.
|
|
223
|
+
`
|
|
224
|
+
],
|
|
225
|
+
[
|
|
226
|
+
`${typeDir}/versions/1.0.0/mission.md`,
|
|
227
|
+
`- Keep data.json accurate and current.
|
|
228
|
+
- Add a record whenever the user mentions something worth keeping.
|
|
229
|
+
`
|
|
230
|
+
],
|
|
231
|
+
[`${typeDir}/versions/1.0.0/data.json`, json({ records: [] })],
|
|
232
|
+
[`${typeDir}/versions/1.0.0/scripts/records-store.ts`, STORE_SCRIPT],
|
|
233
|
+
[
|
|
234
|
+
`${roleDir}/manifest.json`,
|
|
235
|
+
json({
|
|
236
|
+
schemaVersion: 1,
|
|
237
|
+
kind: "gezel-template",
|
|
238
|
+
id: roleId,
|
|
239
|
+
name: `${name} Keeper`,
|
|
240
|
+
description: `The resident keeper of a ${name} workspace.`,
|
|
241
|
+
role: "Keeper",
|
|
242
|
+
tags: [],
|
|
243
|
+
maintainer: { name: "Your name" },
|
|
244
|
+
license: "MIT",
|
|
245
|
+
yankedVersions: []
|
|
246
|
+
})
|
|
247
|
+
],
|
|
248
|
+
[
|
|
249
|
+
`${roleDir}/versions/1.0.0/manifest.json`,
|
|
250
|
+
json({
|
|
251
|
+
schemaVersion: 1,
|
|
252
|
+
version: "1.0.0",
|
|
253
|
+
releasedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
254
|
+
about: "about.md"
|
|
255
|
+
})
|
|
256
|
+
],
|
|
257
|
+
[
|
|
258
|
+
`${roleDir}/versions/1.0.0/about.md`,
|
|
259
|
+
`You are the keeper of this ${name} workspace.
|
|
260
|
+
|
|
261
|
+
Working style: short, warm answers. When the user mentions something worth keeping, add it with the add_record tool and confirm in one line. Never edit data.json by hand.
|
|
262
|
+
`
|
|
263
|
+
]
|
|
264
|
+
];
|
|
265
|
+
if (opts?.withPage) {
|
|
266
|
+
files.push([`${typeDir}/versions/1.0.0/pages/dashboard/index.html`, dashboardHtml(name)]);
|
|
267
|
+
}
|
|
268
|
+
return files;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
// src/connection.ts
|
|
272
|
+
import { createHash, randomUUID } from "crypto";
|
|
273
|
+
import { chmod, mkdir, readFile, rm, writeFile } from "fs/promises";
|
|
274
|
+
import { homedir } from "os";
|
|
275
|
+
import { basename, dirname, join, resolve } from "path";
|
|
276
|
+
import { pickRandomNameWithGender } from "@bendyline/gezel";
|
|
277
|
+
import {
|
|
278
|
+
GezelSdkError,
|
|
279
|
+
authorizeLocal,
|
|
280
|
+
authorizeLocalOwner
|
|
281
|
+
} from "@bendyline/gezel-app-sdk";
|
|
282
|
+
import {
|
|
283
|
+
GezelApiError,
|
|
284
|
+
GezelClient,
|
|
285
|
+
createTrustingFetch,
|
|
286
|
+
discoverOrSpawn,
|
|
287
|
+
electronNativeBinCandidates,
|
|
288
|
+
isProcessAlive,
|
|
289
|
+
readRuntime,
|
|
290
|
+
readSystemServiceEndpoint,
|
|
291
|
+
resolveDaemonEntry,
|
|
292
|
+
stopOwnedDaemon,
|
|
293
|
+
systemSharedAssetsDir
|
|
294
|
+
} from "@bendyline/gezel-client/node";
|
|
295
|
+
import { gezelPaths } from "@bendyline/gezel/paths";
|
|
296
|
+
var CliError = class extends Error {
|
|
297
|
+
constructor(message) {
|
|
298
|
+
super(message);
|
|
299
|
+
this.name = "CliError";
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
// src/app-author-command.ts
|
|
304
|
+
function resolvePath(input) {
|
|
305
|
+
return isAbsolute(input) ? input : join2(process.cwd(), input);
|
|
306
|
+
}
|
|
307
|
+
function formatFinding(finding) {
|
|
308
|
+
const where = finding.file || ".";
|
|
309
|
+
const pointer = finding.pointer ? ` #${finding.pointer}` : "";
|
|
310
|
+
return `${finding.severity.toUpperCase()} ${where}${pointer} - ${finding.rule}: ${finding.message}`;
|
|
311
|
+
}
|
|
312
|
+
function printFindings(findings) {
|
|
313
|
+
for (const finding of findings) console.log(formatFinding(finding));
|
|
314
|
+
return {
|
|
315
|
+
errors: findings.filter((finding) => finding.severity === "error").length,
|
|
316
|
+
warnings: findings.filter((finding) => finding.severity === "warn").length
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
async function statKind(path) {
|
|
320
|
+
try {
|
|
321
|
+
const info = await stat(path);
|
|
322
|
+
return info.isDirectory() ? "dir" : "file";
|
|
323
|
+
} catch {
|
|
324
|
+
return null;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
async function runAppValidate(target, opts = {}) {
|
|
328
|
+
const path = resolvePath(target);
|
|
329
|
+
const kind = await statKind(path);
|
|
330
|
+
if (!kind) throw new CliError(`No such file or folder: ${target}`);
|
|
331
|
+
let findings;
|
|
332
|
+
let entry = null;
|
|
333
|
+
if (kind === "dir") {
|
|
334
|
+
const result = await validateGezappSource(path);
|
|
335
|
+
findings = result.findings;
|
|
336
|
+
entry = result.manifest?.entry ?? null;
|
|
337
|
+
} else {
|
|
338
|
+
let parsed;
|
|
339
|
+
try {
|
|
340
|
+
parsed = readGezapp(await readFile2(path));
|
|
341
|
+
} catch (err) {
|
|
342
|
+
throw new CliError(err instanceof Error ? err.message : String(err));
|
|
343
|
+
}
|
|
344
|
+
entry = parsed.manifest.entry;
|
|
345
|
+
findings = verifyGezapp(parsed).errors.map((message) => ({
|
|
346
|
+
severity: "error",
|
|
347
|
+
file: "",
|
|
348
|
+
pointer: "",
|
|
349
|
+
rule: "package-verify",
|
|
350
|
+
message
|
|
351
|
+
}));
|
|
352
|
+
}
|
|
353
|
+
const ok = !findings.some((finding) => finding.severity === "error");
|
|
354
|
+
if (opts.json) {
|
|
355
|
+
console.log(JSON.stringify({ ok, entry, findings }, null, 2));
|
|
356
|
+
} else {
|
|
357
|
+
const { errors, warnings } = printFindings(findings);
|
|
358
|
+
if (ok) {
|
|
359
|
+
const suffix = warnings > 0 ? ` (${warnings} warning${warnings === 1 ? "" : "s"})` : "";
|
|
360
|
+
console.log(
|
|
361
|
+
`OK \u2014 ${entry ? `${entry.projectType}@${entry.version}` : "package"} is valid${suffix}.`
|
|
362
|
+
);
|
|
363
|
+
} else {
|
|
364
|
+
console.log(
|
|
365
|
+
`${errors} error${errors === 1 ? "" : "s"}, ${warnings} warning${warnings === 1 ? "" : "s"}.`
|
|
366
|
+
);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
if (!ok) process.exitCode = 1;
|
|
370
|
+
}
|
|
371
|
+
async function runAppPack(folder, opts = {}) {
|
|
372
|
+
const dir = resolvePath(folder);
|
|
373
|
+
if (await statKind(dir) !== "dir") throw new CliError(`No such folder: ${folder}`);
|
|
374
|
+
try {
|
|
375
|
+
const packed = await packGezappFromSource(dir);
|
|
376
|
+
const out = resolvePath(
|
|
377
|
+
opts.out ?? `${packed.manifest.entry.projectType}-${packed.manifest.entry.version}.gezapp`
|
|
378
|
+
);
|
|
379
|
+
await writeFile2(out, packed.buffer);
|
|
380
|
+
if (opts.json) {
|
|
381
|
+
console.log(
|
|
382
|
+
JSON.stringify(
|
|
383
|
+
{ ok: true, path: out, manifest: packed.manifest, findings: packed.findings },
|
|
384
|
+
null,
|
|
385
|
+
2
|
|
386
|
+
)
|
|
387
|
+
);
|
|
388
|
+
return;
|
|
389
|
+
}
|
|
390
|
+
printFindings(packed.findings);
|
|
391
|
+
const items = packed.manifest.items.map((item) => `${item.kind} ${item.id}@${item.version}`).join(", ");
|
|
392
|
+
console.log(`Packed ${packed.manifest.name} ${packed.manifest.entry.version} -> ${out}`);
|
|
393
|
+
console.log(` items: ${items}`);
|
|
394
|
+
if (packed.manifest.dependencies.length > 0) {
|
|
395
|
+
console.log(
|
|
396
|
+
` dependency locks: ${packed.manifest.dependencies.map((dependency) => `${dependency.kind} ${dependency.id}@${dependency.version}`).join(", ")}`
|
|
397
|
+
);
|
|
398
|
+
}
|
|
399
|
+
console.log(` ${packed.buffer.length.toLocaleString()} bytes`);
|
|
400
|
+
} catch (err) {
|
|
401
|
+
if (!(err instanceof GezappSourceError)) throw err;
|
|
402
|
+
if (opts.json) {
|
|
403
|
+
console.log(JSON.stringify({ ok: false, findings: err.findings }, null, 2));
|
|
404
|
+
} else {
|
|
405
|
+
const { errors } = printFindings(err.findings);
|
|
406
|
+
console.log(`Not packed \u2014 fix the ${errors} error${errors === 1 ? "" : "s"} above.`);
|
|
407
|
+
}
|
|
408
|
+
process.exitCode = 1;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
async function runAppNew(id, opts = {}) {
|
|
412
|
+
if (!SCAFFOLD_ID_PATTERN.test(id)) {
|
|
413
|
+
throw new CliError(
|
|
414
|
+
`"${id}" is not a valid app id \u2014 use lowercase letters, digits, and hyphens (2-64 chars).`
|
|
415
|
+
);
|
|
416
|
+
}
|
|
417
|
+
const target = join2(opts.dir ? resolvePath(opts.dir) : process.cwd(), id);
|
|
418
|
+
const existing = await statKind(target);
|
|
419
|
+
if (existing === "file") throw new CliError(`${target} already exists.`);
|
|
420
|
+
if (existing === "dir" && (await readdir(target)).length > 0) {
|
|
421
|
+
throw new CliError(`${target} already exists and is not empty.`);
|
|
422
|
+
}
|
|
423
|
+
const files = scaffoldGezappSource(id, {
|
|
424
|
+
...opts.withPage ? { withPage: true } : {}
|
|
425
|
+
});
|
|
426
|
+
for (const [rel, content] of files) {
|
|
427
|
+
const abs = join2(target, rel);
|
|
428
|
+
await mkdir2(dirname2(abs), { recursive: true });
|
|
429
|
+
await writeFile2(abs, content);
|
|
430
|
+
}
|
|
431
|
+
console.log(`Scaffolded ${id} (${files.length} files) in ${target}`);
|
|
432
|
+
console.log("Next:");
|
|
433
|
+
console.log(" 1. Edit items/ \u2014 start with the two about.md files and the version manifest.");
|
|
434
|
+
console.log(` 2. gezel app validate ${id}`);
|
|
435
|
+
console.log(` 3. gezel app pack ${id}`);
|
|
436
|
+
console.log(` 4. gezel app add ${id}-1.0.0.gezapp --yes && gezel app apply ${id}`);
|
|
437
|
+
}
|
|
438
|
+
async function runAppSchemas(opts = {}) {
|
|
439
|
+
const files = renderGezappAuthoringSchemaFiles();
|
|
440
|
+
if (opts.json) {
|
|
441
|
+
const byName = {};
|
|
442
|
+
for (const [filename, content] of files) byName[filename] = JSON.parse(content);
|
|
443
|
+
console.log(JSON.stringify(byName, null, 2));
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
if (opts.out) {
|
|
447
|
+
const dir = resolvePath(opts.out);
|
|
448
|
+
await mkdir2(dir, { recursive: true });
|
|
449
|
+
for (const [filename, content] of files) {
|
|
450
|
+
await writeFile2(join2(dir, filename), content);
|
|
451
|
+
}
|
|
452
|
+
console.log(`Wrote ${files.length} JSON Schemas to ${dir}`);
|
|
453
|
+
return;
|
|
454
|
+
}
|
|
455
|
+
for (const [filename] of files) console.log(filename);
|
|
456
|
+
console.log("");
|
|
457
|
+
console.log("Use --out <dir> to write the files, or --json for one combined object.");
|
|
458
|
+
}
|
|
459
|
+
export {
|
|
460
|
+
runAppNew,
|
|
461
|
+
runAppPack,
|
|
462
|
+
runAppSchemas,
|
|
463
|
+
runAppValidate
|
|
464
|
+
};
|