@bendyline/gezel-script-stdlib 1.1.2 → 1.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/gezel-script-stdlib",
3
- "version": "1.1.2",
3
+ "version": "1.1.4",
4
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
5
  "license": "MIT",
6
6
  "keywords": [
@@ -41,7 +41,7 @@
41
41
  "!scripts/**/*.test.ts"
42
42
  ],
43
43
  "dependencies": {
44
- "@bendyline/gezel-sdk": "1.1.2"
44
+ "@bendyline/gezel-sdk": "1.1.4"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "^24.13.3",
@@ -1,23 +1,47 @@
1
1
  import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
- import { containsPattern, gateResult, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
2
+ import {
3
+ type WorkspaceLike,
4
+ containsPattern,
5
+ gateResult,
6
+ notContainsPattern,
7
+ workspaceFromGezel,
8
+ } from '@bendyline/gezel-sdk/checks';
3
9
 
4
10
  export const meta = defineScript({
5
11
  name: 'checkContains',
6
12
  description:
7
- 'Gate: a workspace file matches a regular expression — e.g. a "Game Over" marker, a required token, a section header.',
13
+ 'Gate: a workspace or artifacts file matches a regular expression — e.g. a "Game Over" marker, a required token, a section header — or, with absent, does not.',
8
14
  kind: 'gate',
9
15
  inputs: {
10
- file: { type: 'string', description: 'Workspace-relative file to check.', required: true },
16
+ file: { type: 'string', description: 'File to check, relative to its tree.', required: true },
11
17
  pattern: { type: 'string', description: 'Regular expression to look for.', required: true },
12
18
  flags: { type: 'string', description: 'Regex flags, e.g. "i".', default: 'i' },
19
+ label: {
20
+ type: 'string',
21
+ description: 'What the match stands for, named in the verdict (e.g. "a Risks section").',
22
+ },
23
+ artifact: {
24
+ type: 'boolean',
25
+ description: 'Read the file from the artifacts drawer instead of the workspace.',
26
+ default: false,
27
+ },
28
+ absent: {
29
+ type: 'boolean',
30
+ description: 'Pass only when nothing matches: the pattern is forbidden content.',
31
+ default: false,
32
+ },
13
33
  },
14
34
  outputs: {
15
35
  decision: { type: 'string', description: "'approve' or 'reject'." },
16
36
  message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
17
37
  },
18
- requires: ['workspace.read'],
38
+ requires: ['workspace.read', 'artifacts.read'],
19
39
  } as const);
20
40
 
21
41
  const input = gezel.input as InferredInput<typeof meta>;
22
- const r = await containsPattern(workspaceFromGezel(gezel), input.file, input.pattern, input.flags);
42
+ const files: WorkspaceLike = input.artifact
43
+ ? { read: (file) => gezel.artifacts.read(file).catch(() => null), list: async () => [] }
44
+ : workspaceFromGezel(gezel);
45
+ const check = input.absent ? notContainsPattern : containsPattern;
46
+ const r = await check(files, input.file, input.pattern, input.flags, input.label);
23
47
  gezel.output(gateResult(r.ok, r.detail));
@@ -83,6 +83,25 @@ interface TaskStepView {
83
83
 
84
84
  const input = gezel.input as InferredInput<typeof meta>;
85
85
 
86
+ /**
87
+ * File types a review can cite. Any backticked `name.ext` used to count, so
88
+ * `JSON.parse`, `USERS.get`, `order.giftNote`, `68.00` and `src/{a,b}.js`
89
+ * were reported as fabricated files: 87 trials across 12 books hit citation
90
+ * rejections, many for code a reviewer quoted correctly (2026-10-06 review).
91
+ */
92
+ const CITED_FILE_EXTENSIONS = new Set(
93
+ 'js mjs cjs jsx ts mts cts tsx json jsonc md mdx txt csv tsv yml yaml toml ini cfg conf env html htm css scss sass less vue svelte py rb go rs java kt kts swift c h cc cpp hpp cs php sh bash ps1 sql xml svg png jpg jpeg gif webp pdf docx xlsx pptx lock graphql gql proto gradle dockerfile'.split(
94
+ ' ',
95
+ ),
96
+ );
97
+
98
+ /** True for a backticked token that names a file rather than code or a number. */
99
+ function looksLikeCitedFile(token: string): boolean {
100
+ if (/[{}*?]/.test(token)) return false;
101
+ const ext = token.slice(token.lastIndexOf('.') + 1).toLowerCase();
102
+ return CITED_FILE_EXTENSIONS.has(ext);
103
+ }
104
+
86
105
  /** Strip citation decoration so `./src/x.ts`, `a/src/x.ts`, `src/x.ts` compare equal. */
87
106
  function normPath(p: string): string {
88
107
  return p
@@ -241,7 +260,7 @@ if (!reviewPath) {
241
260
  }
242
261
  for (const m of report.matchAll(/`([^`\s]+?\.[A-Za-z0-9]{1,8})(?::\d+(?:-\d+)?)?`/g)) {
243
262
  const p = m[1];
244
- if (p) cited.add(normPath(p));
263
+ if (p && looksLikeCitedFile(p)) cited.add(normPath(p));
245
264
  }
246
265
  const reviewDir = reviewPath.includes('/')
247
266
  ? reviewPath.slice(0, reviewPath.lastIndexOf('/'))
@@ -1,5 +1,6 @@
1
1
  import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
2
  import {
3
+ explainSniff,
3
4
  gateResult,
4
5
  htmlGameSniff,
5
6
  inlineJsBytes,
@@ -9,7 +10,7 @@ import {
9
10
  export const meta = defineScript({
10
11
  name: 'checkHtmlGame',
11
12
  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
+ 'Gate: an HTML file is plausibly a real browser game — a canvas/SVG, frame loop, or interactive DOM surface, closed script tags, and non-trivial inline JavaScript.',
13
14
  kind: 'gate',
14
15
  inputs: {
15
16
  file: { type: 'string', description: 'HTML file to check.', default: 'index.html' },
@@ -42,7 +43,7 @@ if (content === null) {
42
43
  ok,
43
44
  ok
44
45
  ? `${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
+ : `${file} is not yet a working game page: ${explainSniff('html-game', content, minJs)}`,
46
47
  ),
47
48
  );
48
49
  }