@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
@@ -0,0 +1,81 @@
1
+ import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
2
+ import { gateResult, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
3
+
4
+ export const meta = defineScript({
5
+ name: 'checkWorkspaceScript',
6
+ description:
7
+ 'Gate: run a caller-pinned Node.js/TypeScript checker from the workspace inside the existing no-network, no-child-process sandbox; exit 0 approves and any other result rejects with the checker output.',
8
+ kind: 'gate',
9
+ inputs: {
10
+ script: {
11
+ type: 'string',
12
+ description: 'Workspace-relative path to the checker script.',
13
+ required: true,
14
+ },
15
+ expectedSource: {
16
+ type: 'string',
17
+ description:
18
+ 'Optional exact checker source pinned by the caller. When supplied, a modified checker rejects before execution.',
19
+ },
20
+ timeoutMs: {
21
+ type: 'number',
22
+ description: 'Checker timeout in milliseconds (the runtime clamps it to 30s-30min).',
23
+ default: 120000,
24
+ },
25
+ },
26
+ outputs: {
27
+ decision: { type: 'string', description: "'approve' or 'reject'." },
28
+ message: { type: 'string', description: 'What passed, or the concrete checker failure.' },
29
+ },
30
+ // `mcp.call` is capability-gated as network even though this script only
31
+ // calls the local, sandboxed run_nodejs_script tool.
32
+ requires: ['workspace.read', 'network'],
33
+ } as const);
34
+
35
+ const input = gezel.input as InferredInput<typeof meta>;
36
+ const ws = workspaceFromGezel(gezel);
37
+ const source = await ws.read(input.script);
38
+
39
+ if (source === null) {
40
+ gezel.output(
41
+ gateResult(
42
+ false,
43
+ `Trusted checker ${input.script} is missing. Restore the caller-provided checker before completing the deliverable.`,
44
+ ),
45
+ );
46
+ } else if (input.expectedSource !== undefined && source !== input.expectedSource) {
47
+ gezel.output(
48
+ gateResult(
49
+ false,
50
+ `Trusted checker ${input.script} was modified. Restore the caller-pinned source; deliverable code must not alter its own acceptance checker.`,
51
+ ),
52
+ );
53
+ } else {
54
+ const raw = await gezel.mcp.call('run_nodejs_script', {
55
+ path: input.script,
56
+ timeoutMs: input.timeoutMs ?? 120000,
57
+ });
58
+ const content =
59
+ raw && typeof raw === 'object' && 'content' in raw && Array.isArray(raw.content)
60
+ ? raw.content
61
+ .map((part) =>
62
+ part && typeof part === 'object' && 'text' in part && typeof part.text === 'string'
63
+ ? part.text
64
+ : '',
65
+ )
66
+ .filter(Boolean)
67
+ .join('\n')
68
+ : typeof raw === 'string'
69
+ ? raw
70
+ : JSON.stringify(raw);
71
+ const ok = /completed \(exit 0\)/i.test(content);
72
+ const bounded = content.trim().slice(0, 3500);
73
+ gezel.output(
74
+ gateResult(
75
+ ok,
76
+ ok
77
+ ? `Trusted checker ${input.script} passed.`
78
+ : `Trusted checker ${input.script} failed. Fix the reported deliverable mismatch, then complete the turn again.\n${bounded || 'The checker returned no readable output.'}`,
79
+ ),
80
+ );
81
+ }