@bendyline/gezel-script-stdlib 0.1.0

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.
Files changed (37) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +32 -0
  3. package/package.json +56 -0
  4. package/scripts/checkCitationsResolve.ts +45 -0
  5. package/scripts/checkContains.ts +23 -0
  6. package/scripts/checkCssMinBytes.ts +28 -0
  7. package/scripts/checkDistinctMatches.ts +48 -0
  8. package/scripts/checkFileCount.ts +37 -0
  9. package/scripts/checkFileExists.ts +43 -0
  10. package/scripts/checkFileMinBytes.ts +33 -0
  11. package/scripts/checkFileMinLines.ts +27 -0
  12. package/scripts/checkGrepMatches.ts +46 -0
  13. package/scripts/checkHtmlComplete.ts +34 -0
  14. package/scripts/checkHtmlGame.ts +48 -0
  15. package/scripts/checkImageRefsResolve.ts +40 -0
  16. package/scripts/checkJsParses.ts +69 -0
  17. package/scripts/checkJsonValid.ts +34 -0
  18. package/scripts/checkNamedEntitiesConsistent.ts +40 -0
  19. package/scripts/checkOrderedSections.ts +47 -0
  20. package/scripts/checkOutcomesMet.ts +54 -0
  21. package/scripts/checkPageRenders.ts +72 -0
  22. package/scripts/checkPlanFramed.ts +65 -0
  23. package/scripts/checkPlanReady.ts +94 -0
  24. package/scripts/checkPlanStructure.ts +62 -0
  25. package/scripts/checkReadingLevel.ts +55 -0
  26. package/scripts/checkRecordSchema.ts +57 -0
  27. package/scripts/checkReviewReport.ts +196 -0
  28. package/scripts/checkSecurityReport.ts +48 -0
  29. package/scripts/checkStandaloneJsParses.ts +32 -0
  30. package/scripts/checkStepsHaveDeliverables.ts +74 -0
  31. package/scripts/checkTableShape.ts +56 -0
  32. package/scripts/checkTaskNoteContains.ts +40 -0
  33. package/scripts/checkTotalMinBytes.ts +33 -0
  34. package/scripts/checkValueGrounding.ts +49 -0
  35. package/scripts/checkVerificationStep.ts +68 -0
  36. package/scripts/checkWordBand.ts +51 -0
  37. package/scripts/checkWorkspaceScript.ts +81 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bendyline
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @bendyline/gezel-script-stdlib
2
+
3
+ The standard gate-script library for [gezel](https://github.com/bendyline/gezel).
4
+
5
+ ```bash
6
+ npm install @bendyline/gezel-script-stdlib
7
+ ```
8
+
9
+ ## What it ships
10
+
11
+ Plain `defineScript` TypeScript sources under `scripts/`, written against
12
+ [`@bendyline/gezel-sdk`](https://www.npmjs.com/package/@bendyline/gezel-sdk).
13
+ The daemon's script runner locates this package on disk and resolves these
14
+ sources **in place**, under scope `standard`.
15
+
16
+ Standard scripts are trusted: the runner executes them even when the security
17
+ policy disables user script execution. That is exactly why nothing outside this
18
+ package may ever masquerade as one — resolution only ever reads from this
19
+ package's own directory, and the module that does it exposes no write or delete
20
+ function.
21
+
22
+ The package is read-only by construction. It is published so that a Node-only
23
+ install of `@bendyline/gezel-service` gets the same standard library the
24
+ desktop app bundles.
25
+
26
+ ## Stability
27
+
28
+ The supported surface is the **set of standard scripts and their check
29
+ semantics**, under semver. Removing a script or changing what it treats as a
30
+ pass is a breaking change.
31
+
32
+ MIT © Bendyline
package/package.json ADDED
@@ -0,0 +1,56 @@
1
+ {
2
+ "name": "@bendyline/gezel-script-stdlib",
3
+ "version": "0.1.0",
4
+ "description": "Standard gate-script library packed into the app. Plain defineScript sources resolved in place by the script runner (scope: 'standard'); read-only, trusted, versioned with the app.",
5
+ "license": "MIT",
6
+ "keywords": [
7
+ "gezel",
8
+ "ai",
9
+ "agents",
10
+ "local-first",
11
+ "scripts",
12
+ "stdlib"
13
+ ],
14
+ "homepage": "https://github.com/bendyline/gezel",
15
+ "bugs": {
16
+ "url": "https://github.com/bendyline/gezel/issues"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/bendyline/gezel.git",
21
+ "directory": "packages/script-stdlib"
22
+ },
23
+ "author": {
24
+ "name": "Bendyline",
25
+ "email": "support@bendyline.com"
26
+ },
27
+ "publishConfig": {
28
+ "access": "public",
29
+ "provenance": true
30
+ },
31
+ "type": "module",
32
+ "engines": {
33
+ "node": ">=24.0.0"
34
+ },
35
+ "exports": {
36
+ "./package.json": "./package.json",
37
+ "./scripts/*": "./scripts/*"
38
+ },
39
+ "files": [
40
+ "scripts",
41
+ "!scripts/**/*.test.ts"
42
+ ],
43
+ "dependencies": {
44
+ "@bendyline/gezel-sdk": "0.1.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/node": "^24.13.3",
48
+ "typescript": "^6.0.3",
49
+ "vitest": "^4.1.10"
50
+ },
51
+ "scripts": {
52
+ "typecheck": "tsc --noEmit",
53
+ "test": "vitest run",
54
+ "clean": "rm -rf .turbo"
55
+ }
56
+ }
@@ -0,0 +1,45 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { citationsResolve, gateResult, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkCitationsResolve',
6
+ description:
7
+ 'Gate: every source a file cites resolves to a real workspace file (the anti-fabrication gate). By default detects (source: path), Markdown links, and backticked paths; URLs are not checked offline unless a corpus allowlist is given.',
8
+ kind: 'gate',
9
+ inputs: {
10
+ file: { type: 'string', description: 'Workspace-relative file to check.', required: true },
11
+ pattern: {
12
+ type: 'string',
13
+ description:
14
+ 'Optional citation-extractor regex; first non-empty capture group is the cited path. Omit to use the built-in extractor.',
15
+ },
16
+ flags: { type: 'string', description: 'Regex flags for a custom pattern.', default: 'gi' },
17
+ minCitations: {
18
+ type: 'number',
19
+ description: 'Minimum number of citations required.',
20
+ default: 1,
21
+ integer: true,
22
+ min: 0,
23
+ },
24
+ corpus: {
25
+ type: 'json',
26
+ description:
27
+ 'Optional allowlist of acceptable paths/URLs. When set, every cited path AND URL must be a member.',
28
+ },
29
+ },
30
+ outputs: {
31
+ decision: { type: 'string', description: "'approve' or 'reject'." },
32
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
33
+ },
34
+ requires: ['workspace.read'],
35
+ } as const);
36
+
37
+ const input = gezel.input as InferredInput<typeof meta>;
38
+ const corpus = Array.isArray(input.corpus) ? input.corpus.map(String) : undefined;
39
+ const r = await citationsResolve(workspaceFromGezel(gezel), input.file, {
40
+ pattern: input.pattern,
41
+ flags: input.flags,
42
+ minCitations: input.minCitations,
43
+ corpus,
44
+ });
45
+ gezel.output(gateResult(r.ok, r.detail));
@@ -0,0 +1,23 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { containsPattern, gateResult, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkContains',
6
+ description:
7
+ 'Gate: a workspace file matches a regular expression — e.g. a "Game Over" marker, a required token, a section header.',
8
+ kind: 'gate',
9
+ inputs: {
10
+ file: { type: 'string', description: 'Workspace-relative file to check.', required: true },
11
+ pattern: { type: 'string', description: 'Regular expression to look for.', required: true },
12
+ flags: { type: 'string', description: 'Regex flags, e.g. "i".', default: 'i' },
13
+ },
14
+ outputs: {
15
+ decision: { type: 'string', description: "'approve' or 'reject'." },
16
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
17
+ },
18
+ requires: ['workspace.read'],
19
+ } as const);
20
+
21
+ const input = gezel.input as InferredInput<typeof meta>;
22
+ const r = await containsPattern(workspaceFromGezel(gezel), input.file, input.pattern, input.flags);
23
+ gezel.output(gateResult(r.ok, r.detail));
@@ -0,0 +1,28 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { cssMinBytes, gateResult, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkCssMinBytes',
6
+ description:
7
+ 'Gate: real styling exists — inline <style> plus linked local stylesheets in an HTML file total at least minBytes.',
8
+ kind: 'gate',
9
+ inputs: {
10
+ file: { type: 'string', description: 'HTML file to inspect.', default: 'index.html' },
11
+ minBytes: {
12
+ type: 'number',
13
+ description: 'Minimum combined CSS bytes.',
14
+ required: true,
15
+ integer: true,
16
+ min: 1,
17
+ },
18
+ },
19
+ outputs: {
20
+ decision: { type: 'string', description: "'approve' or 'reject'." },
21
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
22
+ },
23
+ requires: ['workspace.read'],
24
+ } as const);
25
+
26
+ const input = gezel.input as InferredInput<typeof meta>;
27
+ const r = await cssMinBytes(workspaceFromGezel(gezel), input.minBytes, input.file);
28
+ gezel.output(gateResult(r.ok, r.detail));
@@ -0,0 +1,48 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { countDistinctMatches, gateResult, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkDistinctMatches',
6
+ description:
7
+ 'Gate: a file contains at least N DISTINCT matches of a pattern (distinct by first capture group) — e.g. cites ≥ 4 different evidence files.',
8
+ kind: 'gate',
9
+ inputs: {
10
+ file: { type: 'string', description: 'Workspace-relative file to check.', required: true },
11
+ pattern: {
12
+ type: 'string',
13
+ description: 'Regular expression; group 1 (if present) defines distinctness.',
14
+ required: true,
15
+ },
16
+ flags: { type: 'string', description: 'Regex flags, e.g. "i".', default: 'gi' },
17
+ min: {
18
+ type: 'number',
19
+ description: 'Minimum distinct matches.',
20
+ required: true,
21
+ integer: true,
22
+ min: 1,
23
+ },
24
+ },
25
+ outputs: {
26
+ decision: { type: 'string', description: "'approve' or 'reject'." },
27
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
28
+ },
29
+ requires: ['workspace.read'],
30
+ } as const);
31
+
32
+ const input = gezel.input as InferredInput<typeof meta>;
33
+ const content = await workspaceFromGezel(gezel).read(input.file);
34
+ if (content === null) {
35
+ gezel.output(
36
+ gateResult(false, `${input.file} not found — write the deliverable before advancing.`),
37
+ );
38
+ } else {
39
+ const count = countDistinctMatches(content, new RegExp(input.pattern, input.flags ?? 'gi'));
40
+ gezel.output(
41
+ gateResult(
42
+ count >= input.min,
43
+ count >= input.min
44
+ ? `${input.file} has ${count} distinct match(es) of /${input.pattern}/`
45
+ : `${input.file} has ${count} distinct match(es) of /${input.pattern}/, need ≥ ${input.min}.`,
46
+ ),
47
+ );
48
+ }
@@ -0,0 +1,37 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { fileCountByExt, gateResult, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkFileCount',
6
+ description:
7
+ 'Gate: at least minCount workspace files with one of the given extensions exist (optionally under a directory) — e.g. ≥ 3 images.',
8
+ kind: 'gate',
9
+ inputs: {
10
+ extensions: {
11
+ type: 'string',
12
+ description: 'Comma-separated extensions, e.g. "png,jpg,svg".',
13
+ required: true,
14
+ },
15
+ minCount: {
16
+ type: 'number',
17
+ description: 'Minimum number of matching files.',
18
+ required: true,
19
+ integer: true,
20
+ min: 1,
21
+ },
22
+ dir: { type: 'string', description: 'Restrict to this directory (optional).' },
23
+ },
24
+ outputs: {
25
+ decision: { type: 'string', description: "'approve' or 'reject'." },
26
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
27
+ },
28
+ requires: ['workspace.read'],
29
+ } as const);
30
+
31
+ const input = gezel.input as InferredInput<typeof meta>;
32
+ const ext = input.extensions
33
+ .split(',')
34
+ .map((e) => e.trim())
35
+ .filter(Boolean);
36
+ const r = await fileCountByExt(workspaceFromGezel(gezel), ext, input.minCount, input.dir);
37
+ gezel.output(gateResult(r.ok, r.detail));
@@ -0,0 +1,43 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { gateResult } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkFileExists',
6
+ description:
7
+ 'Gate: a file exists (and is non-empty) in the project workspace or the artifacts area.',
8
+ kind: 'gate',
9
+ inputs: {
10
+ file: { type: 'string', description: 'Relative path of the file.', required: true },
11
+ area: {
12
+ type: 'choice',
13
+ description: 'Where to look.',
14
+ options: [{ value: 'workspace' }, { value: 'artifacts' }],
15
+ default: 'workspace',
16
+ },
17
+ },
18
+ outputs: {
19
+ decision: { type: 'string', description: "'approve' or 'reject'." },
20
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
21
+ },
22
+ requires: ['workspace.read', 'artifacts.read'],
23
+ } as const);
24
+
25
+ const input = gezel.input as InferredInput<typeof meta>;
26
+ let content: string | null = null;
27
+ try {
28
+ content =
29
+ input.area === 'artifacts'
30
+ ? await gezel.artifacts.read(input.file)
31
+ : await gezel.fs.read(input.file);
32
+ } catch {
33
+ content = null;
34
+ }
35
+ const ok = content !== null && content.trim().length > 0;
36
+ gezel.output(
37
+ gateResult(
38
+ ok,
39
+ ok
40
+ ? `${input.file} exists (${content?.length ?? 0} bytes)`
41
+ : `${input.file} is missing or empty in the ${input.area ?? 'workspace'} area — create it before advancing.`,
42
+ ),
43
+ );
@@ -0,0 +1,33 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { fileMinBytes, gateResult, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkFileMinBytes',
6
+ description:
7
+ 'Gate: a workspace file exists and is at least minBytes long (optionally measured after trimming whitespace).',
8
+ kind: 'gate',
9
+ inputs: {
10
+ file: { type: 'string', description: 'Workspace-relative file to check.', required: true },
11
+ minBytes: {
12
+ type: 'number',
13
+ description: 'Minimum size in bytes.',
14
+ required: true,
15
+ integer: true,
16
+ min: 1,
17
+ },
18
+ trim: {
19
+ type: 'boolean',
20
+ description: 'Trim surrounding whitespace before measuring.',
21
+ default: false,
22
+ },
23
+ },
24
+ outputs: {
25
+ decision: { type: 'string', description: "'approve' or 'reject'." },
26
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
27
+ },
28
+ requires: ['workspace.read'],
29
+ } as const);
30
+
31
+ const input = gezel.input as InferredInput<typeof meta>;
32
+ const r = await fileMinBytes(workspaceFromGezel(gezel), input.file, input.minBytes, input.trim);
33
+ gezel.output(gateResult(r.ok, r.detail));
@@ -0,0 +1,27 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { fileMinLines, gateResult, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkFileMinLines',
6
+ description: 'Gate: a workspace file has at least minLines non-blank lines.',
7
+ kind: 'gate',
8
+ inputs: {
9
+ file: { type: 'string', description: 'Workspace-relative file to check.', required: true },
10
+ minLines: {
11
+ type: 'number',
12
+ description: 'Minimum count of non-blank lines.',
13
+ required: true,
14
+ integer: true,
15
+ min: 1,
16
+ },
17
+ },
18
+ outputs: {
19
+ decision: { type: 'string', description: "'approve' or 'reject'." },
20
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
21
+ },
22
+ requires: ['workspace.read'],
23
+ } as const);
24
+
25
+ const input = gezel.input as InferredInput<typeof meta>;
26
+ const r = await fileMinLines(workspaceFromGezel(gezel), input.file, input.minLines);
27
+ gezel.output(gateResult(r.ok, r.detail));
@@ -0,0 +1,46 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { gateResult, grepMatches, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkGrepMatches',
6
+ description:
7
+ 'Gate: grepping the workspace for a pattern returns results — at least minMatches files contain it (optionally scoped by directory/extensions).',
8
+ kind: 'gate',
9
+ inputs: {
10
+ pattern: { type: 'string', description: 'Regular expression to search for.', required: true },
11
+ dir: { type: 'string', description: 'Restrict to this directory (optional).' },
12
+ extensions: {
13
+ type: 'string',
14
+ description: 'Comma-separated extensions to scan, e.g. "ts,js" (optional).',
15
+ },
16
+ flags: { type: 'string', description: 'Regex flags, e.g. "i".', default: 'i' },
17
+ minMatches: {
18
+ type: 'number',
19
+ description: 'Minimum number of files that must match.',
20
+ default: 1,
21
+ integer: true,
22
+ min: 1,
23
+ },
24
+ },
25
+ outputs: {
26
+ decision: { type: 'string', description: "'approve' or 'reject'." },
27
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
28
+ },
29
+ requires: ['workspace.read'],
30
+ } as const);
31
+
32
+ const input = gezel.input as InferredInput<typeof meta>;
33
+ const r = await grepMatches(workspaceFromGezel(gezel), input.pattern, {
34
+ ...(input.dir ? { dir: input.dir } : {}),
35
+ ...(input.extensions
36
+ ? {
37
+ ext: input.extensions
38
+ .split(',')
39
+ .map((e) => e.trim())
40
+ .filter(Boolean),
41
+ }
42
+ : {}),
43
+ ...(input.flags ? { flags: input.flags } : {}),
44
+ minMatches: input.minMatches,
45
+ });
46
+ gezel.output(gateResult(r.ok, r.detail));
@@ -0,0 +1,34 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { gateResult, htmlCompleteSniff, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkHtmlComplete',
6
+ description:
7
+ 'Gate: an HTML file is not truncated — every <script> tag closes and the document has a closing </body> or </html>.',
8
+ kind: 'gate',
9
+ inputs: {
10
+ file: { type: 'string', description: 'HTML file to check.', default: 'index.html' },
11
+ },
12
+ outputs: {
13
+ decision: { type: 'string', description: "'approve' or 'reject'." },
14
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
15
+ },
16
+ requires: ['workspace.read'],
17
+ } as const);
18
+
19
+ const input = gezel.input as InferredInput<typeof meta>;
20
+ const file = input.file ?? 'index.html';
21
+ const content = await workspaceFromGezel(gezel).read(file);
22
+ if (content === null) {
23
+ gezel.output(gateResult(false, `${file} not found — write the deliverable before advancing.`));
24
+ } else {
25
+ const ok = htmlCompleteSniff(content);
26
+ gezel.output(
27
+ gateResult(
28
+ ok,
29
+ ok
30
+ ? `${file} is a complete HTML document`
31
+ : `${file} looks truncated: make sure every <script> has a matching </script> and the document ends with </body></html>.`,
32
+ ),
33
+ );
34
+ }
@@ -0,0 +1,48 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import {
3
+ gateResult,
4
+ htmlGameSniff,
5
+ inlineJsBytes,
6
+ workspaceFromGezel,
7
+ } from '@bendyline/gezel-sdk/checks';
8
+
9
+ export const meta = defineScript({
10
+ name: 'checkHtmlGame',
11
+ description:
12
+ 'Gate: an HTML file is plausibly a real browser game — a <canvas>/<svg> render surface, closed <script> tags, and non-trivial inline JavaScript.',
13
+ kind: 'gate',
14
+ inputs: {
15
+ file: { type: 'string', description: 'HTML file to check.', default: 'index.html' },
16
+ minInlineJsBytes: {
17
+ type: 'number',
18
+ description: 'Minimum bytes of inline JavaScript.',
19
+ default: 400,
20
+ integer: true,
21
+ min: 1,
22
+ },
23
+ },
24
+ outputs: {
25
+ decision: { type: 'string', description: "'approve' or 'reject'." },
26
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
27
+ },
28
+ requires: ['workspace.read'],
29
+ } as const);
30
+
31
+ const input = gezel.input as InferredInput<typeof meta>;
32
+ const file = input.file ?? 'index.html';
33
+ const content = await workspaceFromGezel(gezel).read(file);
34
+ if (content === null) {
35
+ gezel.output(gateResult(false, `${file} not found — write the deliverable before advancing.`));
36
+ } else {
37
+ const minJs = input.minInlineJsBytes ?? 400;
38
+ const ok = htmlGameSniff(content, minJs);
39
+ const js = inlineJsBytes(content);
40
+ gezel.output(
41
+ gateResult(
42
+ ok,
43
+ ok
44
+ ? `${file} has a render surface and ${js} bytes of inline JS`
45
+ : `${file} is not yet a working game page: it needs a <canvas> or <svg> render surface, every <script> closed, and at least ${minJs} bytes of inline JavaScript (currently ${js}).`,
46
+ ),
47
+ );
48
+ }
@@ -0,0 +1,40 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { gateResult, imageRefsResolve, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkImageRefsResolve',
6
+ description:
7
+ 'Gate: <img src> references in an HTML file point at files that actually exist in the workspace (catches assets linked from the wrong path).',
8
+ kind: 'gate',
9
+ inputs: {
10
+ file: { type: 'string', description: 'HTML file to check.', default: 'index.html' },
11
+ requireAll: {
12
+ type: 'boolean',
13
+ description: 'Require EVERY image ref to resolve (default: at least one).',
14
+ default: false,
15
+ },
16
+ },
17
+ outputs: {
18
+ decision: { type: 'string', description: "'approve' or 'reject'." },
19
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
20
+ },
21
+ requires: ['workspace.read'],
22
+ } as const);
23
+
24
+ const input = gezel.input as InferredInput<typeof meta>;
25
+ const file = input.file ?? 'index.html';
26
+ const ws = workspaceFromGezel(gezel);
27
+ const content = await ws.read(file);
28
+ if (content === null) {
29
+ gezel.output(gateResult(false, `${file} not found — write the deliverable before advancing.`));
30
+ } else {
31
+ const report = imageRefsResolve(content, file, await ws.list(), input.requireAll);
32
+ gezel.output(
33
+ gateResult(
34
+ report.ok,
35
+ report.ok
36
+ ? report.detail
37
+ : `${report.detail}. Generate the missing assets or fix the src paths so they resolve relative to ${file}.`,
38
+ ),
39
+ );
40
+ }
@@ -0,0 +1,69 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import {
3
+ detectUnclosedScript,
4
+ extractInlineScripts,
5
+ gateResult,
6
+ validateScriptSyntax,
7
+ workspaceFromGezel,
8
+ } from '@bendyline/gezel-sdk/checks';
9
+
10
+ export const meta = defineScript({
11
+ name: 'checkJsParses',
12
+ description:
13
+ 'Gate: every inline <script> in an HTML file parses as valid JavaScript (V8 parser), with truncation detection and an optional total-size floor.',
14
+ kind: 'gate',
15
+ inputs: {
16
+ file: { type: 'string', description: 'HTML file to check.', default: 'index.html' },
17
+ minInlineJsBytes: {
18
+ type: 'number',
19
+ description: 'Minimum total inline JS bytes (0 = no size floor).',
20
+ default: 0,
21
+ integer: true,
22
+ min: 0,
23
+ },
24
+ },
25
+ outputs: {
26
+ decision: { type: 'string', description: "'approve' or 'reject'." },
27
+ message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
28
+ },
29
+ requires: ['workspace.read'],
30
+ } as const);
31
+
32
+ const input = gezel.input as InferredInput<typeof meta>;
33
+ const file = input.file ?? 'index.html';
34
+ const content = await workspaceFromGezel(gezel).read(file);
35
+ if (content === null) {
36
+ gezel.output(gateResult(false, `${file} not found — write the deliverable before advancing.`));
37
+ } else {
38
+ const truncation = detectUnclosedScript(content);
39
+ if (truncation.unclosed) {
40
+ gezel.output(
41
+ gateResult(
42
+ false,
43
+ `${file} has ${truncation.opens} <script> opener(s) but only ${truncation.closes} </script> closer(s) — the file was cut off mid-script. Rewrite it completely, ending every script block.`,
44
+ ),
45
+ );
46
+ } else {
47
+ const validation = validateScriptSyntax(extractInlineScripts(content));
48
+ const minJs = input.minInlineJsBytes ?? 0;
49
+ if (!validation.allParse) {
50
+ gezel.output(
51
+ gateResult(
52
+ false,
53
+ `${file} has inline JavaScript that does not parse: ${validation.firstError ?? 'syntax error'}. Fix the syntax error and re-advance.`,
54
+ ),
55
+ );
56
+ } else if (minJs > 0 && validation.totalBytes < minJs) {
57
+ gezel.output(
58
+ gateResult(
59
+ false,
60
+ `${file} has only ${validation.totalBytes} bytes of inline JavaScript, need ≥ ${minJs} — the page logic looks like a stub.`,
61
+ ),
62
+ );
63
+ } else {
64
+ gezel.output(
65
+ gateResult(true, `${file}: all inline JS parses (${validation.totalBytes} bytes)`),
66
+ );
67
+ }
68
+ }
69
+ }