@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.
- package/LICENSE +21 -0
- package/README.md +32 -0
- package/package.json +56 -0
- package/scripts/checkCitationsResolve.ts +45 -0
- package/scripts/checkContains.ts +23 -0
- package/scripts/checkCssMinBytes.ts +28 -0
- package/scripts/checkDistinctMatches.ts +48 -0
- package/scripts/checkFileCount.ts +37 -0
- package/scripts/checkFileExists.ts +43 -0
- package/scripts/checkFileMinBytes.ts +33 -0
- package/scripts/checkFileMinLines.ts +27 -0
- package/scripts/checkGrepMatches.ts +46 -0
- package/scripts/checkHtmlComplete.ts +34 -0
- package/scripts/checkHtmlGame.ts +48 -0
- package/scripts/checkImageRefsResolve.ts +40 -0
- package/scripts/checkJsParses.ts +69 -0
- package/scripts/checkJsonValid.ts +34 -0
- package/scripts/checkNamedEntitiesConsistent.ts +40 -0
- package/scripts/checkOrderedSections.ts +47 -0
- package/scripts/checkOutcomesMet.ts +54 -0
- package/scripts/checkPageRenders.ts +72 -0
- package/scripts/checkPlanFramed.ts +65 -0
- package/scripts/checkPlanReady.ts +94 -0
- package/scripts/checkPlanStructure.ts +62 -0
- package/scripts/checkReadingLevel.ts +55 -0
- package/scripts/checkRecordSchema.ts +57 -0
- package/scripts/checkReviewReport.ts +196 -0
- package/scripts/checkSecurityReport.ts +48 -0
- package/scripts/checkStandaloneJsParses.ts +32 -0
- package/scripts/checkStepsHaveDeliverables.ts +74 -0
- package/scripts/checkTableShape.ts +56 -0
- package/scripts/checkTaskNoteContains.ts +40 -0
- package/scripts/checkTotalMinBytes.ts +33 -0
- package/scripts/checkValueGrounding.ts +49 -0
- package/scripts/checkVerificationStep.ts +68 -0
- package/scripts/checkWordBand.ts +51 -0
- package/scripts/checkWorkspaceScript.ts +81 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
+
import { gateResult, jsonValid, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
|
|
3
|
+
|
|
4
|
+
export const meta = defineScript({
|
|
5
|
+
name: 'checkJsonValid',
|
|
6
|
+
description: 'Gate: a workspace file parses as valid JSON.',
|
|
7
|
+
kind: 'gate',
|
|
8
|
+
inputs: {
|
|
9
|
+
file: { type: 'string', description: 'JSON file to check.', required: true },
|
|
10
|
+
},
|
|
11
|
+
outputs: {
|
|
12
|
+
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
13
|
+
message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
|
|
14
|
+
},
|
|
15
|
+
requires: ['workspace.read'],
|
|
16
|
+
} as const);
|
|
17
|
+
|
|
18
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
19
|
+
const content = await workspaceFromGezel(gezel).read(input.file);
|
|
20
|
+
if (content === null) {
|
|
21
|
+
gezel.output(
|
|
22
|
+
gateResult(false, `${input.file} not found — write the deliverable before advancing.`),
|
|
23
|
+
);
|
|
24
|
+
} else {
|
|
25
|
+
const r = jsonValid(content);
|
|
26
|
+
gezel.output(
|
|
27
|
+
gateResult(
|
|
28
|
+
r.ok,
|
|
29
|
+
r.ok
|
|
30
|
+
? `${input.file} is valid JSON`
|
|
31
|
+
: `${input.file} is not valid JSON: ${r.error ?? 'parse error'}. Fix the syntax and re-advance.`,
|
|
32
|
+
),
|
|
33
|
+
);
|
|
34
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
+
import {
|
|
3
|
+
type EntitySpec,
|
|
4
|
+
gateResult,
|
|
5
|
+
namedEntitiesConsistent,
|
|
6
|
+
workspaceFromGezel,
|
|
7
|
+
} from '@bendyline/gezel-sdk/checks';
|
|
8
|
+
|
|
9
|
+
export const meta = defineScript({
|
|
10
|
+
name: 'checkNamedEntitiesConsistent',
|
|
11
|
+
description:
|
|
12
|
+
'Gate: a long document refers to each named entity consistently — no declared drifted spelling/numbering (e.g. "ACME Corporation" when the canonical form is "Acme Corp") appears anywhere. Case-sensitive.',
|
|
13
|
+
kind: 'gate',
|
|
14
|
+
inputs: {
|
|
15
|
+
file: { type: 'string', description: 'Workspace-relative file to check.', required: true },
|
|
16
|
+
entities: {
|
|
17
|
+
type: 'json',
|
|
18
|
+
description:
|
|
19
|
+
'Array of [{ canonical, variants: string[] }]. The gate rejects if any variant appears in the file.',
|
|
20
|
+
required: true,
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
outputs: {
|
|
24
|
+
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
25
|
+
message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
|
|
26
|
+
},
|
|
27
|
+
requires: ['workspace.read'],
|
|
28
|
+
} as const);
|
|
29
|
+
|
|
30
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
31
|
+
const content = await workspaceFromGezel(gezel).read(input.file);
|
|
32
|
+
if (content === null) {
|
|
33
|
+
gezel.output(
|
|
34
|
+
gateResult(false, `${input.file} not found — write the deliverable before advancing.`),
|
|
35
|
+
);
|
|
36
|
+
} else {
|
|
37
|
+
const entities = (Array.isArray(input.entities) ? input.entities : []) as EntitySpec[];
|
|
38
|
+
const r = namedEntitiesConsistent(content, entities);
|
|
39
|
+
gezel.output(gateResult(r.ok, `${input.file}: ${r.detail}`));
|
|
40
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
+
import {
|
|
3
|
+
gateResult,
|
|
4
|
+
requireOrderedSections,
|
|
5
|
+
workspaceFromGezel,
|
|
6
|
+
} from '@bendyline/gezel-sdk/checks';
|
|
7
|
+
|
|
8
|
+
export const meta = defineScript({
|
|
9
|
+
name: 'checkOrderedSections',
|
|
10
|
+
description:
|
|
11
|
+
'Gate: a Markdown file contains the given section headers IN ORDER (any # depth) — e.g. the canonical postmortem sections.',
|
|
12
|
+
kind: 'gate',
|
|
13
|
+
inputs: {
|
|
14
|
+
file: { type: 'string', description: 'Markdown file to check.', required: true },
|
|
15
|
+
sections: {
|
|
16
|
+
type: 'json',
|
|
17
|
+
description: 'Ordered array of header titles, e.g. ["Summary", "Impact", "Timeline"].',
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
outputs: {
|
|
22
|
+
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
23
|
+
message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
|
|
24
|
+
},
|
|
25
|
+
requires: ['workspace.read'],
|
|
26
|
+
} as const);
|
|
27
|
+
|
|
28
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
29
|
+
const sections = Array.isArray(input.sections) ? input.sections.map(String) : [];
|
|
30
|
+
const content = await workspaceFromGezel(gezel).read(input.file);
|
|
31
|
+
if (content === null) {
|
|
32
|
+
gezel.output(
|
|
33
|
+
gateResult(false, `${input.file} not found — write the deliverable before advancing.`),
|
|
34
|
+
);
|
|
35
|
+
} else if (sections.length === 0) {
|
|
36
|
+
gezel.output(gateResult(false, 'No sections configured — set the "sections" input.'));
|
|
37
|
+
} else {
|
|
38
|
+
const r = requireOrderedSections(content, sections);
|
|
39
|
+
gezel.output(
|
|
40
|
+
gateResult(
|
|
41
|
+
r.ok,
|
|
42
|
+
r.ok
|
|
43
|
+
? `${input.file} has all ${sections.length} sections in order`
|
|
44
|
+
: `${input.file} is missing the "${r.ok === false ? r.missing : ''}" section (or it appears out of order). Required order: ${sections.join(' → ')}.`,
|
|
45
|
+
),
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
+
import { gateResult } from '@bendyline/gezel-sdk/checks';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runtime gate (runs on the executing task's terminal verification step):
|
|
6
|
+
* every declared outcome has been verified — marked `met` with non-empty
|
|
7
|
+
* `evidence` (an artifact path or note). This is the "observe whether the
|
|
8
|
+
* outcomes were kept" bar that closes a planned task.
|
|
9
|
+
*/
|
|
10
|
+
export const meta = defineScript({
|
|
11
|
+
name: 'checkOutcomesMet',
|
|
12
|
+
description:
|
|
13
|
+
"Gate: every one of the task's outcomes has been verified (met === true with non-empty evidence). Use on the terminal verification step of a planned task so it can't close until each outcome is observed.",
|
|
14
|
+
kind: 'gate',
|
|
15
|
+
inputs: {
|
|
16
|
+
taskRef: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
description: 'Task to inspect (auto-filled by the runtime when this gate runs from a step).',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
outputs: {
|
|
22
|
+
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
23
|
+
message: { type: 'string', description: 'What passed, or the outcomes still to verify.' },
|
|
24
|
+
},
|
|
25
|
+
requires: ['tasks.read'],
|
|
26
|
+
} as const);
|
|
27
|
+
|
|
28
|
+
interface TaskView {
|
|
29
|
+
outcomes?: { id: string; text?: string; met?: boolean; evidence?: string }[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
33
|
+
|
|
34
|
+
const task = (await gezel.task.get(input.taskRef ?? '').catch(() => null)) as TaskView | null;
|
|
35
|
+
const outcomes = task?.outcomes ?? [];
|
|
36
|
+
|
|
37
|
+
let ok = false;
|
|
38
|
+
let message = '';
|
|
39
|
+
if (outcomes.length === 0) {
|
|
40
|
+
message =
|
|
41
|
+
'This task has no outcomes to verify. Define them with set_outcomes, then mark each met with verify_outcome before closing.';
|
|
42
|
+
} else {
|
|
43
|
+
const unmet = outcomes.filter((o) => o.met !== true || !(o.evidence ?? '').trim());
|
|
44
|
+
ok = unmet.length === 0;
|
|
45
|
+
message = ok
|
|
46
|
+
? `All ${outcomes.length} outcome(s) verified with evidence.`
|
|
47
|
+
: `${unmet.length}/${outcomes.length} outcome(s) not yet verified: ${unmet
|
|
48
|
+
.map((o) => `"${(o.text ?? o.id).slice(0, 60)}"`)
|
|
49
|
+
.join(
|
|
50
|
+
', ',
|
|
51
|
+
)}. For each, confirm it against the produced artifact and call verify_outcome({ ref, id, met: true, evidence }).`;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
gezel.output(gateResult(ok, message));
|
|
@@ -0,0 +1,72 @@
|
|
|
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: 'checkPageRenders',
|
|
6
|
+
description:
|
|
7
|
+
'Gate (EXPENSIVE — spawns headless Chromium): an HTML workspace file loads without page errors, optionally requiring a selector to exist. Use sparingly; static gates cover most cases.',
|
|
8
|
+
kind: 'gate',
|
|
9
|
+
inputs: {
|
|
10
|
+
file: { type: 'string', description: 'HTML file to render.', default: 'index.html' },
|
|
11
|
+
selector: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
description: 'CSS selector that must exist after load (optional).',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
outputs: {
|
|
17
|
+
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
18
|
+
message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
|
|
19
|
+
},
|
|
20
|
+
requires: ['workspace.read', 'network'],
|
|
21
|
+
} as const);
|
|
22
|
+
|
|
23
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
24
|
+
const file = input.file ?? 'index.html';
|
|
25
|
+
let html: string | null = null;
|
|
26
|
+
try {
|
|
27
|
+
html = await gezel.fs.read(file);
|
|
28
|
+
} catch {
|
|
29
|
+
html = null;
|
|
30
|
+
}
|
|
31
|
+
if (html === null) {
|
|
32
|
+
gezel.output(gateResult(false, `${file} not found — write the deliverable before advancing.`));
|
|
33
|
+
} else {
|
|
34
|
+
const script = `
|
|
35
|
+
import { chromium } from 'playwright';
|
|
36
|
+
const browser = await chromium.launch();
|
|
37
|
+
const page = await (await browser.newContext()).newPage();
|
|
38
|
+
const pageErrors = [];
|
|
39
|
+
page.on('pageerror', (err) => pageErrors.push(String(err && err.message ? err.message : err)));
|
|
40
|
+
await page.setContent(${JSON.stringify(html)}, { waitUntil: 'load', timeout: 30_000 });
|
|
41
|
+
await page.waitForTimeout(500);
|
|
42
|
+
const selectorOk = ${JSON.stringify(input.selector ?? '')}
|
|
43
|
+
? (await page.$(${JSON.stringify(input.selector ?? '')})) !== null
|
|
44
|
+
: true;
|
|
45
|
+
await browser.close();
|
|
46
|
+
console.log(JSON.stringify({ pageErrors: pageErrors.slice(0, 3), selectorOk }));
|
|
47
|
+
`;
|
|
48
|
+
const raw = await gezel.mcp.call('run_playwright_script', { script });
|
|
49
|
+
const text = typeof raw === 'string' ? raw : JSON.stringify(raw);
|
|
50
|
+
const jsonMatch = /\{[\s\S]*\}/.exec(text);
|
|
51
|
+
if (!jsonMatch) {
|
|
52
|
+
throw new Error(`run_playwright_script returned unparseable output: ${text.slice(0, 200)}`);
|
|
53
|
+
}
|
|
54
|
+
const parsed = JSON.parse(jsonMatch[0]!) as { pageErrors: string[]; selectorOk: boolean };
|
|
55
|
+
if (parsed.pageErrors.length > 0) {
|
|
56
|
+
gezel.output(
|
|
57
|
+
gateResult(
|
|
58
|
+
false,
|
|
59
|
+
`${file} throws on load: ${parsed.pageErrors[0]}. Fix the runtime error and re-advance.`,
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
} else if (!parsed.selectorOk) {
|
|
63
|
+
gezel.output(
|
|
64
|
+
gateResult(
|
|
65
|
+
false,
|
|
66
|
+
`${file} loads but "${input.selector}" is missing from the rendered page — make sure that element actually renders.`,
|
|
67
|
+
),
|
|
68
|
+
);
|
|
69
|
+
} else {
|
|
70
|
+
gezel.output(gateResult(true, `${file} renders without errors`));
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
+
import { gateResult } from '@bendyline/gezel-sdk/checks';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Plan gate (runs on a plan-AUTHORING task): the draft plan being built has a
|
|
6
|
+
* substantial "about" and at least three outcome statements. Reads the draft
|
|
7
|
+
* via the authoring task's `craftbookParams.draftRef`.
|
|
8
|
+
*/
|
|
9
|
+
export const meta = defineScript({
|
|
10
|
+
name: 'checkPlanFramed',
|
|
11
|
+
description:
|
|
12
|
+
"Plan gate: the draft plan this authoring task is building has a substantial 'about' (description ≥ 120 chars) and at least 3 outcomes. Reads the draft via the authoring task's craftbookParams.draftRef.",
|
|
13
|
+
kind: 'gate',
|
|
14
|
+
inputs: {
|
|
15
|
+
taskRef: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description:
|
|
18
|
+
'The authoring task (auto-filled by the runtime when this gate runs from a step).',
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
outputs: {
|
|
22
|
+
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
23
|
+
message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
|
|
24
|
+
},
|
|
25
|
+
requires: ['tasks.read'],
|
|
26
|
+
} as const);
|
|
27
|
+
|
|
28
|
+
interface DraftView {
|
|
29
|
+
description?: string;
|
|
30
|
+
outcomes?: { text?: string }[];
|
|
31
|
+
craftbookParams?: Record<string, string>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
35
|
+
|
|
36
|
+
let ok = false;
|
|
37
|
+
let message = '';
|
|
38
|
+
|
|
39
|
+
const authoring = (await gezel.task.get(input.taskRef ?? '').catch(() => null)) as DraftView | null;
|
|
40
|
+
const draftRef = authoring?.craftbookParams?.draftRef;
|
|
41
|
+
if (!draftRef) {
|
|
42
|
+
message =
|
|
43
|
+
'This gate must run on a plan-authoring task whose craftbookParams.draftRef points at the draft plan. Start planning with start_plan.';
|
|
44
|
+
} else {
|
|
45
|
+
const draft = (await gezel.task.get(draftRef).catch(() => null)) as DraftView | null;
|
|
46
|
+
const desc = (draft?.description ?? '').trim();
|
|
47
|
+
const outcomes = draft?.outcomes ?? [];
|
|
48
|
+
const gaps: string[] = [];
|
|
49
|
+
if (desc.length < 120) {
|
|
50
|
+
gaps.push(
|
|
51
|
+
`the plan's about is too thin (${desc.length}/120 chars) — call update_task({ task: "${draftRef}", description }) with a clear statement of the job to be done`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (outcomes.length < 3) {
|
|
55
|
+
gaps.push(
|
|
56
|
+
`only ${outcomes.length} outcome(s) defined — call set_outcomes({ task: "${draftRef}", outcomes: [...] }) with at least 3 concrete expected results`,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
ok = gaps.length === 0;
|
|
60
|
+
message = ok
|
|
61
|
+
? `Plan framed: about is ${desc.length} chars and ${outcomes.length} outcomes are defined.`
|
|
62
|
+
: `Frame the plan before advancing: ${gaps.join('; ')}.`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
gezel.output(gateResult(ok, message));
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
+
import { gateResult } from '@bendyline/gezel-sdk/checks';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Plan gate (runs on a plan-AUTHORING task): the aggregate readiness check for
|
|
6
|
+
* a draft plan — a substantial about + ≥3 outcomes, every build step gated on a
|
|
7
|
+
* concrete deliverable, and a terminal verification step. Combines
|
|
8
|
+
* checkPlanFramed + checkStepsHaveDeliverables + checkVerificationStep so the
|
|
9
|
+
* final review step rejects with the full list of remaining gaps at once.
|
|
10
|
+
*/
|
|
11
|
+
export const meta = defineScript({
|
|
12
|
+
name: 'checkPlanReady',
|
|
13
|
+
description:
|
|
14
|
+
"Plan gate: the draft plan is ready for the user — strong about + ≥3 outcomes, every build step gated on a concrete deliverable, and a terminal verification step. Reads the draft via the authoring task's craftbookParams.draftRef.",
|
|
15
|
+
kind: 'gate',
|
|
16
|
+
inputs: {
|
|
17
|
+
taskRef: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
description:
|
|
20
|
+
'The authoring task (auto-filled by the runtime when this gate runs from a step).',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
outputs: {
|
|
24
|
+
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
25
|
+
message: { type: 'string', description: 'What passed, or the concrete gaps to fix.' },
|
|
26
|
+
},
|
|
27
|
+
requires: ['tasks.read'],
|
|
28
|
+
} as const);
|
|
29
|
+
|
|
30
|
+
interface StepView {
|
|
31
|
+
id: string;
|
|
32
|
+
name?: string;
|
|
33
|
+
prompt?: string;
|
|
34
|
+
terminal?: boolean;
|
|
35
|
+
advanceWhen?: { file?: string } | null;
|
|
36
|
+
gate?: { checks?: unknown[]; scripts?: unknown[] } | null;
|
|
37
|
+
}
|
|
38
|
+
interface DraftView {
|
|
39
|
+
description?: string;
|
|
40
|
+
outcomes?: { text?: string }[];
|
|
41
|
+
craftbookParams?: Record<string, string>;
|
|
42
|
+
craftbook?: { steps?: StepView[] };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const VERIFY_RE = /outcome|verify_outcome|set_task_status/i;
|
|
46
|
+
|
|
47
|
+
function isGated(s: StepView): boolean {
|
|
48
|
+
const hasGate =
|
|
49
|
+
!!s.gate && ((s.gate.checks?.length ?? 0) > 0 || (s.gate.scripts?.length ?? 0) > 0);
|
|
50
|
+
return hasGate || !!s.advanceWhen?.file;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
54
|
+
|
|
55
|
+
let ok = false;
|
|
56
|
+
let message = '';
|
|
57
|
+
|
|
58
|
+
const authoring = (await gezel.task.get(input.taskRef ?? '').catch(() => null)) as DraftView | null;
|
|
59
|
+
const draftRef = authoring?.craftbookParams?.draftRef;
|
|
60
|
+
if (!draftRef) {
|
|
61
|
+
message =
|
|
62
|
+
'This gate must run on a plan-authoring task whose craftbookParams.draftRef points at the draft plan. Start planning with start_plan.';
|
|
63
|
+
} else {
|
|
64
|
+
const draft = (await gezel.task.get(draftRef).catch(() => null)) as DraftView | null;
|
|
65
|
+
const desc = (draft?.description ?? '').trim();
|
|
66
|
+
const outcomes = draft?.outcomes ?? [];
|
|
67
|
+
const steps = draft?.craftbook?.steps ?? [];
|
|
68
|
+
const buildSteps = steps.filter((s) => !s.terminal);
|
|
69
|
+
const bare = buildSteps.filter((s) => !isGated(s));
|
|
70
|
+
const hasVerifier = steps.some((s) => s.terminal && VERIFY_RE.test(s.prompt ?? ''));
|
|
71
|
+
|
|
72
|
+
const gaps: string[] = [];
|
|
73
|
+
if (desc.length < 120)
|
|
74
|
+
gaps.push('the about is too thin (write a clear job-to-be-done via update_task)');
|
|
75
|
+
if (outcomes.length < 3) gaps.push('fewer than 3 outcomes (add them via set_outcomes)');
|
|
76
|
+
if (buildSteps.length === 0) gaps.push('no build steps (add them via craftbook_add_step)');
|
|
77
|
+
if (bare.length > 0)
|
|
78
|
+
gaps.push(
|
|
79
|
+
`${bare.length} step(s) without a deliverable gate (${bare
|
|
80
|
+
.map((s) => `"${s.name ?? s.id}"`)
|
|
81
|
+
.join(', ')}) — fix with set_step_deliverable`,
|
|
82
|
+
);
|
|
83
|
+
if (!hasVerifier)
|
|
84
|
+
gaps.push(
|
|
85
|
+
'no terminal verification step (append one that calls verify_outcome then set_task_status)',
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
ok = gaps.length === 0;
|
|
89
|
+
message = ok
|
|
90
|
+
? `Plan ${draftRef} is ready: strong about, ${outcomes.length} outcomes, ${buildSteps.length} gated build step(s), and a verification step. Summarize it for the user and tell them to review and activate it.`
|
|
91
|
+
: `The plan is not ready yet — ${gaps.join('; ')}.`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
gezel.output(gateResult(ok, message));
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
+
import { gateResult, planStructure, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
|
|
3
|
+
|
|
4
|
+
export const meta = defineScript({
|
|
5
|
+
name: 'checkPlanStructure',
|
|
6
|
+
description:
|
|
7
|
+
"Gate: the plan's first Markdown table has ID | Task | Owner | Depends on | Done when columns, owners on the roster, dependencies that resolve without cycles (earlier rows only by default), and checkable done-states.",
|
|
8
|
+
kind: 'gate',
|
|
9
|
+
inputs: {
|
|
10
|
+
file: { type: 'string', description: 'Workspace-relative plan file.', required: true },
|
|
11
|
+
minRows: {
|
|
12
|
+
type: 'number',
|
|
13
|
+
description: 'Minimum number of plan rows.',
|
|
14
|
+
default: 1,
|
|
15
|
+
integer: true,
|
|
16
|
+
min: 0,
|
|
17
|
+
},
|
|
18
|
+
ownerRoster: {
|
|
19
|
+
type: 'json',
|
|
20
|
+
description: 'Optional array of allowed Owner names (case-insensitive).',
|
|
21
|
+
},
|
|
22
|
+
requireEarlierOnly: {
|
|
23
|
+
type: 'boolean',
|
|
24
|
+
description: 'Rows may only depend on earlier rows (default true).',
|
|
25
|
+
},
|
|
26
|
+
doneWhenMinChars: {
|
|
27
|
+
type: 'number',
|
|
28
|
+
description: 'Minimum "Done when" cell length (default 12).',
|
|
29
|
+
integer: true,
|
|
30
|
+
min: 1,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
outputs: {
|
|
34
|
+
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
35
|
+
message: { type: 'string', description: 'What passed, or the named row + cell to fix.' },
|
|
36
|
+
},
|
|
37
|
+
requires: ['workspace.read'],
|
|
38
|
+
} as const);
|
|
39
|
+
|
|
40
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
41
|
+
const content = await workspaceFromGezel(gezel).read(input.file);
|
|
42
|
+
if (content === null) {
|
|
43
|
+
gezel.output(gateResult(false, `${input.file} not found — write the plan before advancing.`));
|
|
44
|
+
} else {
|
|
45
|
+
const ownerRoster = Array.isArray(input.ownerRoster) ? input.ownerRoster.map(String) : undefined;
|
|
46
|
+
const result = planStructure(content, {
|
|
47
|
+
...(input.minRows !== undefined ? { minRows: input.minRows } : {}),
|
|
48
|
+
...(ownerRoster ? { ownerRoster } : {}),
|
|
49
|
+
...(input.requireEarlierOnly !== undefined
|
|
50
|
+
? { requireEarlierOnly: input.requireEarlierOnly }
|
|
51
|
+
: {}),
|
|
52
|
+
...(input.doneWhenMinChars !== undefined ? { doneWhenMinChars: input.doneWhenMinChars } : {}),
|
|
53
|
+
});
|
|
54
|
+
gezel.output(
|
|
55
|
+
gateResult(
|
|
56
|
+
result.ok,
|
|
57
|
+
result.ok
|
|
58
|
+
? `${input.file}: plan table valid (${result.rows.length} rows; owners + dependencies + done-states check out).`
|
|
59
|
+
: `${input.file}: ${result.detail}`,
|
|
60
|
+
),
|
|
61
|
+
);
|
|
62
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
+
import { gateResult, readingLevel, workspaceFromGezel } from '@bendyline/gezel-sdk/checks';
|
|
3
|
+
|
|
4
|
+
export const meta = defineScript({
|
|
5
|
+
name: 'checkReadingLevel',
|
|
6
|
+
description:
|
|
7
|
+
"Gate: a file's readability sits within a band — Flesch-Kincaid grade (minGrade/maxGrade) and/or Flesch reading-ease (minEase/maxEase). Heuristic; pairs well as an advisory comms gate.",
|
|
8
|
+
kind: 'gate',
|
|
9
|
+
inputs: {
|
|
10
|
+
file: { type: 'string', description: 'Workspace-relative file to check.', required: true },
|
|
11
|
+
minGrade: { type: 'number', description: 'Minimum Flesch-Kincaid grade level.' },
|
|
12
|
+
maxGrade: {
|
|
13
|
+
type: 'number',
|
|
14
|
+
description: 'Maximum Flesch-Kincaid grade level (cap complexity).',
|
|
15
|
+
},
|
|
16
|
+
minEase: { type: 'number', description: 'Minimum Flesch reading-ease (higher = easier).' },
|
|
17
|
+
maxEase: { type: 'number', description: 'Maximum Flesch reading-ease.' },
|
|
18
|
+
stripMarkdown: {
|
|
19
|
+
type: 'boolean',
|
|
20
|
+
description: 'Exclude Markdown markup before scoring.',
|
|
21
|
+
default: true,
|
|
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 content = await workspaceFromGezel(gezel).read(input.file);
|
|
33
|
+
const banded =
|
|
34
|
+
input.minGrade !== undefined ||
|
|
35
|
+
input.maxGrade !== undefined ||
|
|
36
|
+
input.minEase !== undefined ||
|
|
37
|
+
input.maxEase !== undefined;
|
|
38
|
+
if (content === null) {
|
|
39
|
+
gezel.output(
|
|
40
|
+
gateResult(false, `${input.file} not found — write the deliverable before advancing.`),
|
|
41
|
+
);
|
|
42
|
+
} else if (!banded) {
|
|
43
|
+
gezel.output(
|
|
44
|
+
gateResult(false, 'No band configured — set at least one of min/maxGrade or min/maxEase.'),
|
|
45
|
+
);
|
|
46
|
+
} else {
|
|
47
|
+
const r = readingLevel(content, {
|
|
48
|
+
minGrade: input.minGrade,
|
|
49
|
+
maxGrade: input.maxGrade,
|
|
50
|
+
minEase: input.minEase,
|
|
51
|
+
maxEase: input.maxEase,
|
|
52
|
+
stripMarkdown: input.stripMarkdown,
|
|
53
|
+
});
|
|
54
|
+
gezel.output(gateResult(r.ok, `${input.file}: ${r.detail}`));
|
|
55
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type InferredInput, defineScript, gezel } from '@bendyline/gezel-sdk';
|
|
2
|
+
import {
|
|
3
|
+
type RecordFieldSpec,
|
|
4
|
+
gateResult,
|
|
5
|
+
recordSchema,
|
|
6
|
+
workspaceFromGezel,
|
|
7
|
+
} from '@bendyline/gezel-sdk/checks';
|
|
8
|
+
|
|
9
|
+
export const meta = defineScript({
|
|
10
|
+
name: 'checkRecordSchema',
|
|
11
|
+
description:
|
|
12
|
+
"Gate: a JSON-array or CSV deliverable's rows validate against a declared field schema (types, required fields, no extras, row floor, uniqueness). Stops at the first failing record. Ported from the data-wrangle grader.",
|
|
13
|
+
kind: 'gate',
|
|
14
|
+
inputs: {
|
|
15
|
+
file: {
|
|
16
|
+
type: 'string',
|
|
17
|
+
description: 'Workspace-relative records file (JSON or CSV).',
|
|
18
|
+
required: true,
|
|
19
|
+
},
|
|
20
|
+
fields: {
|
|
21
|
+
type: 'json',
|
|
22
|
+
description:
|
|
23
|
+
'Array of field specs: [{ name, type?, required? }]. type ∈ string/number/integer/boolean/date/iso-date/email/nonempty or a regex source; required defaults to true.',
|
|
24
|
+
required: true,
|
|
25
|
+
},
|
|
26
|
+
allowExtraFields: {
|
|
27
|
+
type: 'boolean',
|
|
28
|
+
description: 'Permit fields not named in the schema.',
|
|
29
|
+
default: false,
|
|
30
|
+
},
|
|
31
|
+
minRows: { type: 'number', description: 'Minimum record count.', integer: true, min: 0 },
|
|
32
|
+
uniqueBy: { type: 'string', description: 'Field whose values must be unique across rows.' },
|
|
33
|
+
format: {
|
|
34
|
+
type: 'choice',
|
|
35
|
+
description: 'Input format. Defaults to auto (sniff JSON vs CSV).',
|
|
36
|
+
options: [{ value: 'auto' }, { value: 'json' }, { value: 'csv' }],
|
|
37
|
+
default: 'auto',
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
outputs: {
|
|
41
|
+
decision: { type: 'string', description: "'approve' or 'reject'." },
|
|
42
|
+
message: { type: 'string', description: 'What passed, or the concrete gap to fix.' },
|
|
43
|
+
},
|
|
44
|
+
requires: ['workspace.read'],
|
|
45
|
+
} as const);
|
|
46
|
+
|
|
47
|
+
const input = gezel.input as InferredInput<typeof meta>;
|
|
48
|
+
const content = await workspaceFromGezel(gezel).read(input.file);
|
|
49
|
+
const fields = (Array.isArray(input.fields) ? input.fields : []) as RecordFieldSpec[];
|
|
50
|
+
const r = recordSchema(content, {
|
|
51
|
+
fields,
|
|
52
|
+
allowExtraFields: input.allowExtraFields,
|
|
53
|
+
minRows: input.minRows,
|
|
54
|
+
uniqueBy: input.uniqueBy,
|
|
55
|
+
format: input.format as 'auto' | 'json' | 'csv' | undefined,
|
|
56
|
+
});
|
|
57
|
+
gezel.output(gateResult(r.ok, r.detail));
|