@bendyline/gezel-cli 1.2.12 → 1.2.14

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 CHANGED
@@ -14,8 +14,10 @@ installs a current one.
14
14
  npm install -g @bendyline/gezel-cli
15
15
  ```
16
16
 
17
- To try it without installing, name the package: `npx -p @bendyline/gezel-cli gezel`.
18
- A bare `npx gezel` fetches an unrelated package from npm.
17
+ The unscoped [`gezel-cli`](https://www.npmjs.com/package/gezel-cli) package is the
18
+ short name for this one: `npx gezel-cli` runs it without installing, and
19
+ `npm install -g gezel-cli` installs the same program. Install one of the two
20
+ globally, not both: they both provide the `gezel` command.
19
21
 
20
22
  Then choose where the AI runs.
21
23
 
@@ -350,6 +352,11 @@ app already includes it:
350
352
  npm install -g @huggingface/transformers@^4.3.1
351
353
  ```
352
354
 
355
+ npm 12 then reports that the install scripts of `onnxruntime-node` and
356
+ `protobufjs` were blocked. That is expected and harmless: the first only
357
+ downloads CUDA libraries Gezel does not use, and the second only checks
358
+ versions.
359
+
353
360
  In a project install, also add the `overrides` from the
354
361
  [`@bendyline/gezel-service` README](https://www.npmjs.com/package/@bendyline/gezel-service),
355
362
  which keep Kokoro on the same Transformers.js copy as the service.
@@ -360,6 +360,7 @@ Authoring references:
360
360
  - [Building Gezel apps](https://github.com/bendyline/gezel/blob/main/docs/building-gezel-apps.md)
361
361
  - [Page APIs](https://github.com/bendyline/gezel/blob/main/docs/output-pane-api.md)
362
362
  - [Page style guide](https://github.com/bendyline/gezel/blob/main/docs/handboek/technical/gezel-app-page-style-guide.md)
363
+ - [App UX guide](https://github.com/bendyline/gezel/blob/main/docs/handboek/technical/gezel-app-ux-guide.md)
363
364
  `
364
365
  ],
365
366
  [
@@ -471,6 +472,7 @@ import { createHash, randomUUID } from "crypto";
471
472
  import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
472
473
  import { homedir } from "os";
473
474
  import { basename, dirname, join, resolve } from "path";
475
+ import { fileURLToPath } from "url";
474
476
  import {
475
477
  evaluateApiCompat,
476
478
  getLogLevel,
@@ -488,6 +490,7 @@ import {
488
490
  authorizeLocalOwner
489
491
  } from "@bendyline/gezel-app-sdk";
490
492
  import {
493
+ DaemonInAnotherNamespaceError,
491
494
  GezelApiError,
492
495
  GezelClient,
493
496
  LiveDaemonUnhealthyError,
@@ -517,7 +520,7 @@ import { createHash as createHash2 } from "crypto";
517
520
  import { readFileSync as readFileSync2 } from "fs";
518
521
  import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
519
522
  import { dirname as dirname2, join as join3, relative } from "path";
520
- import { fileURLToPath } from "url";
523
+ import { fileURLToPath as fileURLToPath2 } from "url";
521
524
  import { injectPageDemo, pageDemoBootstrapSource } from "@bendyline/gezel";
522
525
 
523
526
  // ../../scripts/project-page-typography.mjs
@@ -539,8 +542,8 @@ function buildProjectPageTypography(uiRoot) {
539
542
  // src/page-demo-export.ts
540
543
  function pageDemoAssets() {
541
544
  const sourceMode = import.meta.url.endsWith(".ts");
542
- const fonts = fileURLToPath(new URL("../../ui/src/assets/fonts/", import.meta.url));
543
- const css = sourceMode ? buildProjectPageTypography(fileURLToPath(new URL("../../ui", import.meta.url))) : readFileSync2(new URL("./page-typography.css", import.meta.url), "utf8");
545
+ const fonts = fileURLToPath2(new URL("../../ui/src/assets/fonts/", import.meta.url));
546
+ const css = sourceMode ? buildProjectPageTypography(fileURLToPath2(new URL("../../ui", import.meta.url))) : readFileSync2(new URL("./page-typography.css", import.meta.url), "utf8");
544
547
  const versioned = (stem, extension, source) => ({
545
548
  path: `${stem}-${createHash2("sha256").update(source).digest("hex").slice(0, 16)}.${extension}`,
546
549
  bytes: Buffer.from(source)
@@ -740,6 +743,7 @@ async function runAppNew(id, opts = {}) {
740
743
  }
741
744
  console.log(`Scaffolded ${id} (${files.length} files) in ${target}`);
742
745
  console.log("Next:");
746
+ console.log(" 0. Read the guide first (or give it to your AI agent): gezel app guide");
743
747
  console.log(" 1. Edit items/ \u2014 start with the two about.md files and the version manifest.");
744
748
  console.log(` 2. gezel app validate ${id}`);
745
749
  console.log(` 3. gezel app pack ${id}`);
@@ -10,6 +10,7 @@ import { createHash, randomUUID } from "crypto";
10
10
  import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
11
11
  import { homedir } from "os";
12
12
  import { basename, dirname, join, resolve } from "path";
13
+ import { fileURLToPath } from "url";
13
14
  import {
14
15
  evaluateApiCompat,
15
16
  getLogLevel,
@@ -27,6 +28,7 @@ import {
27
28
  authorizeLocalOwner
28
29
  } from "@bendyline/gezel-app-sdk";
29
30
  import {
31
+ DaemonInAnotherNamespaceError,
30
32
  GezelApiError,
31
33
  GezelClient,
32
34
  LiveDaemonUnhealthyError,
@@ -0,0 +1,128 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/app-guide.ts
4
+ import { createHandboekEngine, siteDeviceInfo } from "@bendyline/gezel-service/handboek";
5
+
6
+ // src/connection.ts
7
+ import { createHash, randomUUID } from "crypto";
8
+ import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
9
+ import { homedir } from "os";
10
+ import { basename, dirname, join, resolve } from "path";
11
+ import { fileURLToPath } from "url";
12
+ import {
13
+ evaluateApiCompat,
14
+ getLogLevel,
15
+ getLogOutput,
16
+ gezelNamesInUse,
17
+ pickUnusedGezelName,
18
+ projectLeadGezelId,
19
+ roleForMatching,
20
+ setLogLevel,
21
+ setLogOutput
22
+ } from "@bendyline/gezel";
23
+ import {
24
+ GezelSdkError,
25
+ authorizeLocal,
26
+ authorizeLocalOwner
27
+ } from "@bendyline/gezel-app-sdk";
28
+ import {
29
+ DaemonInAnotherNamespaceError,
30
+ GezelApiError,
31
+ GezelClient,
32
+ LiveDaemonUnhealthyError,
33
+ createTrustingFetch,
34
+ discoverOrSpawn,
35
+ electronNativeBinCandidates,
36
+ ensureProjectForFolder as ensureClientProjectForFolder,
37
+ forbiddenProjectFolderName,
38
+ isProcessAlive,
39
+ readRuntime,
40
+ readSystemServiceEndpoint,
41
+ resolveDaemonEntry,
42
+ stopOwnedDaemon,
43
+ systemServiceRuntimeIsStale,
44
+ systemSharedAssetsDir
45
+ } from "@bendyline/gezel-client/node";
46
+ import { gezelHome, gezelPaths, nativePayloadVerificationPath } from "@bendyline/gezel/paths";
47
+ var CliError = class extends Error {
48
+ constructor(message) {
49
+ super(message);
50
+ this.name = "CliError";
51
+ }
52
+ };
53
+
54
+ // src/handboek-links.ts
55
+ var PUBLISHED_HANDBOEK = "https://gezel.com/docs/";
56
+ var up = (depth) => "../".repeat(depth);
57
+ function rewriteSiteLinks(markdown, pageId, ids, byStem, hasAsset = () => true, base) {
58
+ const prefix = base ?? up(pageId.split("/").length);
59
+ return markdown.replace(/\]\(([^()\s]+)\)/g, (whole, rawTarget) => {
60
+ if (/^[a-z][a-z0-9+.-]*:/i.test(rawTarget) || rawTarget.startsWith("//") || rawTarget.startsWith("#")) {
61
+ return whole;
62
+ }
63
+ const [path, suffix = ""] = splitLinkSuffix(rawTarget);
64
+ const candidate = path.replace(/^(\.\.?\/)+/, "");
65
+ if (candidate.startsWith("assets/")) {
66
+ return hasAsset(candidate) ? `](${prefix}${candidate}${suffix})` : `](${PUBLISHED_HANDBOEK}${candidate}${suffix})`;
67
+ }
68
+ const article = candidate.replace(/\.md$/, "");
69
+ const target = ids.has(article) ? article : byStem.get(article.split("/").pop() ?? "");
70
+ if (!target) return whole;
71
+ return `](${prefix}${target}/${suffix})`;
72
+ });
73
+ }
74
+ function siteLinkIndex(entryIds) {
75
+ const byStem = /* @__PURE__ */ new Map();
76
+ for (const id of entryIds) {
77
+ const stem = id.split("/").pop();
78
+ if (stem && !byStem.has(stem)) byStem.set(stem, id);
79
+ }
80
+ return { ids: new Set(entryIds), byStem };
81
+ }
82
+ function splitLinkSuffix(raw) {
83
+ const idx = raw.search(/[?#]/);
84
+ return idx === -1 ? [raw, ""] : [raw.slice(0, idx), raw.slice(idx)];
85
+ }
86
+
87
+ // src/app-guide.ts
88
+ var APP_GUIDE_ARTICLE_ID = "build-a-gezel-app";
89
+ var NO_CATALOG = {
90
+ list: async () => [],
91
+ get: async () => null
92
+ };
93
+ async function renderAppGuide(opts = {}) {
94
+ const engine = createHandboekEngine({
95
+ catalog: NO_CATALOG,
96
+ device: siteDeviceInfo,
97
+ ...opts.contentDir ? { contentDir: opts.contentDir } : {}
98
+ });
99
+ const article = await engine.article(APP_GUIDE_ARTICLE_ID, {
100
+ mode: "agent",
101
+ inlineIncludes: true
102
+ });
103
+ if (!article) {
104
+ throw new CliError(
105
+ `this install has no "${APP_GUIDE_ARTICLE_ID}" Handboek article; read ${PUBLISHED_HANDBOEK}${APP_GUIDE_ARTICLE_ID}.md`
106
+ );
107
+ }
108
+ const { areas } = await engine.toc();
109
+ const { ids, byStem } = siteLinkIndex(areas.flatMap((a) => a.entries.map((e) => e.id)));
110
+ const markdown = rewriteSiteLinks(
111
+ article.markdown,
112
+ article.id,
113
+ ids,
114
+ byStem,
115
+ () => true,
116
+ PUBLISHED_HANDBOEK
117
+ );
118
+ return `${markdown.trimEnd()}
119
+ `;
120
+ }
121
+ async function runAppGuide() {
122
+ process.stdout.write(await renderAppGuide());
123
+ }
124
+ export {
125
+ APP_GUIDE_ARTICLE_ID,
126
+ renderAppGuide,
127
+ runAppGuide
128
+ };