@bendyline/gezel-sdk 1.1.4 → 1.1.6
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/dist/checks.d.ts +9 -1
- package/dist/checks.js +21 -8
- package/dist/index.js +44 -7
- package/package.json +3 -3
package/dist/checks.d.ts
CHANGED
|
@@ -337,6 +337,14 @@ declare function normalizeDigitGroups(text: string): string;
|
|
|
337
337
|
* carries meaning in globs.
|
|
338
338
|
*/
|
|
339
339
|
declare function normalizeInlineEmphasis(text: string): string;
|
|
340
|
+
/**
|
|
341
|
+
* Fold typographic hyphens (U+2010-U+2012, U+2212) and no-break, figure, thin
|
|
342
|
+
* and narrow spaces to ASCII. Nemotron 3.5 Lightning writes dates and
|
|
343
|
+
* compounds with U+2011 between the parts, so a faithful 2026-09-01 read as a
|
|
344
|
+
* missing value (2026-10-15). En and em dashes are punctuation and stay. Like
|
|
345
|
+
* the emphasis fold, this only ever widens what a required value can match.
|
|
346
|
+
*/
|
|
347
|
+
declare function normalizeTypography(text: string): string;
|
|
340
348
|
/** A single grounded fact: at least one `required` form must appear and no
|
|
341
349
|
* `forbidden` (decoy) form may. Values are regex sources, matched
|
|
342
350
|
* case-insensitively against the (optionally digit-normalized) text. */
|
|
@@ -901,4 +909,4 @@ declare function workspaceFromGezel(g: {
|
|
|
901
909
|
};
|
|
902
910
|
}): WorkspaceLike;
|
|
903
911
|
|
|
904
|
-
export { type CellType, type CheckResult, type CitationsResult, type CodebaseReviewReportOptions, type CodebaseReviewReportResult, type CorpusCoverageLedger, type CorpusCoverageMergeResult, type CorpusCoverageShardInput, type CsvShapeResult, type CsvShapeSpec, type EntitiesResult, type EntitySpec, type ExplainableSniff, type FigureCheckOptions, type FigureCheckResult, type FigureFinding, type FigureFindingKind, GateScriptResult, type GroundingFact, type GroundingResult, IMG_EXT, type ImageRefsReport, type InlineScript, type JsonPathEqualsResult, type JsonScalar, type JudgeVerdict, MIN_INLINE_JS_BYTES, MIN_JUDGE_EVIDENCE_SUBSTRING, type MarkdownHeadingsMatchResult, type ParsedTable, type PlanRow, type PlanStructureResult, type PlanStructureSpec, type ReadingLevelResult, type RecordFieldSpec, type RecordSchemaResult, type RecordSchemaSpec, type ScriptValidation, type SecurityReportOptions, type SecurityReportResult, type StepSniffName, type TableShapeResult, type TableShapeSpec, type UnsupportedClaimPattern, type UnsupportedClaimViolation, type UnsupportedClaimsResult, type ValuesSubsetResult, type ValuesSubsetSpec, type WordBandResult, type WorkspaceLike, buildJudgePrompt, checkFigures, citationsResolve, citedPathKey, cleanCitedPath, codebaseReviewReport, containsPattern, countDistinctMatches, createCitedPathChecker, cssMinBytes, csvShape, dataTableSniff, detectTypeScriptOnlySyntax, detectUnclosedScript, esmImports, explainSniff, extractInlineScripts, extractMoneyAmounts, fileCountByExt, fileMinBytes, fileMinLines, findImageRefs, frontmatterList, gateResult, grepMatches, htmlCompleteSniff, htmlGameSniff, imageRefsResolve, inlineJsBytes, isRealIsoDate, jsonPathEquals, jsonValid, listedFiles, markdownHeadingsMatch, mergeCorpusCoverageShards, namedEntitiesConsistent, normalizeDigitGroups, normalizeInlineEmphasis, notContainsPattern, parseCsv, parseJudgeVerdict, parseMarkdownTable, planStructure, readingLevel, recordSchema, requireOrderedSections, resolveRelative, runSniff, securityReport, standaloneJsParses, tableShape, totalMinBytes, unsupportedClaims, validateJudgeEvidence, validateScriptSyntax, valueGrounding, valuesSubsetOf, wordBand, workspaceFromGezel, wrapperReturnHint };
|
|
912
|
+
export { type CellType, type CheckResult, type CitationsResult, type CodebaseReviewReportOptions, type CodebaseReviewReportResult, type CorpusCoverageLedger, type CorpusCoverageMergeResult, type CorpusCoverageShardInput, type CsvShapeResult, type CsvShapeSpec, type EntitiesResult, type EntitySpec, type ExplainableSniff, type FigureCheckOptions, type FigureCheckResult, type FigureFinding, type FigureFindingKind, GateScriptResult, type GroundingFact, type GroundingResult, IMG_EXT, type ImageRefsReport, type InlineScript, type JsonPathEqualsResult, type JsonScalar, type JudgeVerdict, MIN_INLINE_JS_BYTES, MIN_JUDGE_EVIDENCE_SUBSTRING, type MarkdownHeadingsMatchResult, type ParsedTable, type PlanRow, type PlanStructureResult, type PlanStructureSpec, type ReadingLevelResult, type RecordFieldSpec, type RecordSchemaResult, type RecordSchemaSpec, type ScriptValidation, type SecurityReportOptions, type SecurityReportResult, type StepSniffName, type TableShapeResult, type TableShapeSpec, type UnsupportedClaimPattern, type UnsupportedClaimViolation, type UnsupportedClaimsResult, type ValuesSubsetResult, type ValuesSubsetSpec, type WordBandResult, type WorkspaceLike, buildJudgePrompt, checkFigures, citationsResolve, citedPathKey, cleanCitedPath, codebaseReviewReport, containsPattern, countDistinctMatches, createCitedPathChecker, cssMinBytes, csvShape, dataTableSniff, detectTypeScriptOnlySyntax, detectUnclosedScript, esmImports, explainSniff, extractInlineScripts, extractMoneyAmounts, fileCountByExt, fileMinBytes, fileMinLines, findImageRefs, frontmatterList, gateResult, grepMatches, htmlCompleteSniff, htmlGameSniff, imageRefsResolve, inlineJsBytes, isRealIsoDate, jsonPathEquals, jsonValid, listedFiles, markdownHeadingsMatch, mergeCorpusCoverageShards, namedEntitiesConsistent, normalizeDigitGroups, normalizeInlineEmphasis, normalizeTypography, notContainsPattern, parseCsv, parseJudgeVerdict, parseMarkdownTable, planStructure, readingLevel, recordSchema, requireOrderedSections, resolveRelative, runSniff, securityReport, standaloneJsParses, tableShape, totalMinBytes, unsupportedClaims, validateJudgeEvidence, validateScriptSyntax, valueGrounding, valuesSubsetOf, wordBand, workspaceFromGezel, wrapperReturnHint };
|
package/dist/checks.js
CHANGED
|
@@ -530,7 +530,7 @@ function requireOrderedSections(text, headers) {
|
|
|
530
530
|
let cursor = 0;
|
|
531
531
|
for (const header of headers) {
|
|
532
532
|
const escaped = header.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
533
|
-
const re = new RegExp(`^#+\\s+${escaped}\\s*$`, "im");
|
|
533
|
+
const re = new RegExp(`^#+\\s+${escaped}(?:\\s*\\([^)\\n]*\\))?\\s*:?\\s*$`, "im");
|
|
534
534
|
const slice = text.slice(cursor);
|
|
535
535
|
const m = slice.match(re);
|
|
536
536
|
if (!m || m.index === void 0) {
|
|
@@ -1004,6 +1004,9 @@ function normalizeDigitGroups(text) {
|
|
|
1004
1004
|
function normalizeInlineEmphasis(text) {
|
|
1005
1005
|
return text.replace(/\*\*|__|`/g, "");
|
|
1006
1006
|
}
|
|
1007
|
+
function normalizeTypography(text) {
|
|
1008
|
+
return text.replace(/[\u2010-\u2012\u2212]/g, "-").replace(/[\u00a0\u2007\u2009\u202f]/g, " ");
|
|
1009
|
+
}
|
|
1007
1010
|
function safeRegExp(src, flags) {
|
|
1008
1011
|
try {
|
|
1009
1012
|
return new RegExp(src, flags);
|
|
@@ -1012,8 +1015,8 @@ function safeRegExp(src, flags) {
|
|
|
1012
1015
|
}
|
|
1013
1016
|
}
|
|
1014
1017
|
function valueGrounding(text, facts, opts = {}) {
|
|
1015
|
-
const haystack =
|
|
1016
|
-
opts.normalizeDigits === false ? text : normalizeDigitGroups(text)
|
|
1018
|
+
const haystack = normalizeTypography(
|
|
1019
|
+
normalizeInlineEmphasis(opts.normalizeDigits === false ? text : normalizeDigitGroups(text))
|
|
1017
1020
|
);
|
|
1018
1021
|
const signals = [];
|
|
1019
1022
|
const decoysDetected = [];
|
|
@@ -1187,7 +1190,7 @@ function valuesSubsetOf(outputText, sourceTexts, spec) {
|
|
|
1187
1190
|
return out;
|
|
1188
1191
|
};
|
|
1189
1192
|
const caseInsensitive = flags.includes("i");
|
|
1190
|
-
const foldSpace = (t) => t.replace(/ | | | /g, " ").replace(/\
|
|
1193
|
+
const foldSpace = (t) => normalizeTypography(t).replace(/ | | | /g, " ").replace(/\s+/g, " ");
|
|
1191
1194
|
const normalize = (t) => {
|
|
1192
1195
|
const folded = foldSpace(t);
|
|
1193
1196
|
return caseInsensitive ? folded.toLowerCase() : folded;
|
|
@@ -2406,12 +2409,21 @@ var REQUIRED_COLUMNS = ["id", "task", "owner", "depends on", "done when"];
|
|
|
2406
2409
|
function headerIndex(headers, name) {
|
|
2407
2410
|
return headers.findIndex((h) => h.trim().toLowerCase() === name);
|
|
2408
2411
|
}
|
|
2412
|
+
function plainCell(cell) {
|
|
2413
|
+
let text = cell.trim();
|
|
2414
|
+
for (; ; ) {
|
|
2415
|
+
const unwrapped = text.match(/^(\*\*|__|\*|_|`)(.+)\1$/)?.[2]?.trim();
|
|
2416
|
+
if (!unwrapped) return text;
|
|
2417
|
+
text = unwrapped;
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2409
2420
|
function parseDeps(cell) {
|
|
2410
2421
|
const trimmed = cell.trim();
|
|
2411
|
-
|
|
2422
|
+
const plain = plainCell(trimmed);
|
|
2423
|
+
if (!plain || /^[-\u2010-\u2015\u2212]$/.test(plain) || /^(none|n\/a)$/i.test(plain)) {
|
|
2412
2424
|
return [];
|
|
2413
2425
|
}
|
|
2414
|
-
return trimmed.split(/[,;]/).map(
|
|
2426
|
+
return trimmed.split(/[,;]/).map(plainCell).filter(Boolean);
|
|
2415
2427
|
}
|
|
2416
2428
|
function planStructure(text, spec = {}) {
|
|
2417
2429
|
const fail = (detail, partial = {}) => ({
|
|
@@ -2446,9 +2458,9 @@ function planStructure(text, spec = {}) {
|
|
|
2446
2458
|
estimate: headerIndex(headers, "estimate")
|
|
2447
2459
|
};
|
|
2448
2460
|
const rows = table.rows.map((cells) => ({
|
|
2449
|
-
id: (cells[col.id] ?? "")
|
|
2461
|
+
id: plainCell(cells[col.id] ?? ""),
|
|
2450
2462
|
task: (cells[col.task] ?? "").trim(),
|
|
2451
|
-
owner: (cells[col.owner] ?? "")
|
|
2463
|
+
owner: plainCell(cells[col.owner] ?? ""),
|
|
2452
2464
|
dependsOn: parseDeps(cells[col.deps] ?? ""),
|
|
2453
2465
|
doneWhen: (cells[col.done] ?? "").trim(),
|
|
2454
2466
|
...col.estimate >= 0 && (cells[col.estimate] ?? "").trim() ? { estimate: (cells[col.estimate] ?? "").trim() } : {}
|
|
@@ -2786,6 +2798,7 @@ export {
|
|
|
2786
2798
|
namedEntitiesConsistent,
|
|
2787
2799
|
normalizeDigitGroups,
|
|
2788
2800
|
normalizeInlineEmphasis,
|
|
2801
|
+
normalizeTypography,
|
|
2789
2802
|
notContainsPattern,
|
|
2790
2803
|
parseCsv,
|
|
2791
2804
|
parseJudgeVerdict,
|
package/dist/index.js
CHANGED
|
@@ -102,8 +102,12 @@ function createGezelSDK(rpc, options = {}) {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
// src/rpc.ts
|
|
105
|
-
import { readFileSync, writeSync } from "fs";
|
|
105
|
+
import { readFileSync, readSync, writeSync } from "fs";
|
|
106
106
|
import { Socket } from "net";
|
|
107
|
+
var STDIO_RPC = process.env.GEZEL_SCRIPT_RPC === "stdio";
|
|
108
|
+
var RPC_FD = STDIO_RPC ? 1 : 3;
|
|
109
|
+
var FRAME_PREFIX = STDIO_RPC ? `gezel-rpc:${process.env.GEZEL_SCRIPT_RPC_NONCE ?? ""}:` : "";
|
|
110
|
+
var stdioLeftover = "";
|
|
107
111
|
var DEFAULT_INIT = {
|
|
108
112
|
input: void 0,
|
|
109
113
|
runId: "",
|
|
@@ -122,7 +126,7 @@ function readInitSync() {
|
|
|
122
126
|
}
|
|
123
127
|
let raw = "";
|
|
124
128
|
try {
|
|
125
|
-
raw = readFileSync(0, "utf8");
|
|
129
|
+
raw = STDIO_RPC ? readFirstLineSync(0) : readFileSync(0, "utf8");
|
|
126
130
|
} catch {
|
|
127
131
|
return DEFAULT_INIT;
|
|
128
132
|
}
|
|
@@ -133,6 +137,33 @@ function readInitSync() {
|
|
|
133
137
|
return DEFAULT_INIT;
|
|
134
138
|
}
|
|
135
139
|
}
|
|
140
|
+
function readFirstLineSync(fd) {
|
|
141
|
+
const chunk = Buffer.alloc(64 * 1024);
|
|
142
|
+
const parts = [];
|
|
143
|
+
for (; ; ) {
|
|
144
|
+
let read;
|
|
145
|
+
try {
|
|
146
|
+
read = readSync(fd, chunk, 0, chunk.length, null);
|
|
147
|
+
} catch (error) {
|
|
148
|
+
const code = error.code;
|
|
149
|
+
if (code === "EOF") break;
|
|
150
|
+
if (code === "EAGAIN") {
|
|
151
|
+
Atomics.wait(WRITE_BACKPRESSURE_SIGNAL, 0, 0, WRITE_BACKPRESSURE_RETRY_MS);
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
}
|
|
156
|
+
if (read === 0) break;
|
|
157
|
+
const newline = chunk.subarray(0, read).indexOf(10);
|
|
158
|
+
if (newline >= 0) {
|
|
159
|
+
parts.push(Buffer.from(chunk.subarray(0, newline)));
|
|
160
|
+
stdioLeftover = chunk.subarray(newline + 1, read).toString("utf8");
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
parts.push(Buffer.from(chunk.subarray(0, read)));
|
|
164
|
+
}
|
|
165
|
+
return Buffer.concat(parts).toString("utf8");
|
|
166
|
+
}
|
|
136
167
|
var RpcClient = class {
|
|
137
168
|
init;
|
|
138
169
|
nextId = 0;
|
|
@@ -150,7 +181,7 @@ var RpcClient = class {
|
|
|
150
181
|
*/
|
|
151
182
|
get socket() {
|
|
152
183
|
if (!this._socket) {
|
|
153
|
-
this._socket = new Socket({ fd: 3, readable: true, writable: true });
|
|
184
|
+
this._socket = STDIO_RPC ? new Socket({ fd: 0, readable: true, writable: false }) : new Socket({ fd: 3, readable: true, writable: true });
|
|
154
185
|
this._socket.setEncoding("utf8");
|
|
155
186
|
this._socket.unref();
|
|
156
187
|
}
|
|
@@ -164,8 +195,7 @@ var RpcClient = class {
|
|
|
164
195
|
ensureStarted() {
|
|
165
196
|
if (this.started) return;
|
|
166
197
|
this.started = true;
|
|
167
|
-
|
|
168
|
-
this.buffer += typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
198
|
+
const drain = () => {
|
|
169
199
|
let newline = this.buffer.indexOf("\n");
|
|
170
200
|
while (newline >= 0) {
|
|
171
201
|
const line = this.buffer.slice(0, newline);
|
|
@@ -175,7 +205,14 @@ var RpcClient = class {
|
|
|
175
205
|
}
|
|
176
206
|
newline = this.buffer.indexOf("\n");
|
|
177
207
|
}
|
|
208
|
+
};
|
|
209
|
+
this.buffer += stdioLeftover;
|
|
210
|
+
stdioLeftover = "";
|
|
211
|
+
this.socket.on("data", (chunk) => {
|
|
212
|
+
this.buffer += typeof chunk === "string" ? chunk : chunk.toString("utf8");
|
|
213
|
+
drain();
|
|
178
214
|
});
|
|
215
|
+
drain();
|
|
179
216
|
this.socket.on("error", (err) => {
|
|
180
217
|
for (const pending of this.pending.values()) {
|
|
181
218
|
pending.reject(err instanceof Error ? err : new Error(String(err)));
|
|
@@ -238,12 +275,12 @@ var RpcClient = class {
|
|
|
238
275
|
}
|
|
239
276
|
};
|
|
240
277
|
function writeFrame(payload) {
|
|
241
|
-
const buf = Buffer.from(payload
|
|
278
|
+
const buf = Buffer.from(`${FRAME_PREFIX}${payload}`, "utf8");
|
|
242
279
|
let offset = 0;
|
|
243
280
|
const startedAt = Date.now();
|
|
244
281
|
while (offset < buf.length) {
|
|
245
282
|
try {
|
|
246
|
-
const written = writeSync(
|
|
283
|
+
const written = writeSync(RPC_FD, buf, offset, buf.length - offset);
|
|
247
284
|
if (written > 0) {
|
|
248
285
|
offset += written;
|
|
249
286
|
continue;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-sdk",
|
|
3
|
-
"version": "1.1.
|
|
4
|
-
"description": "SDK
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "SDK for scripts that run in the Gezel sandbox: the gezel object and the defineScript helper.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"gezel",
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"!dist/**/*.map"
|
|
64
64
|
],
|
|
65
65
|
"devDependencies": {
|
|
66
|
-
"@bendyline/gezel": "1.2.
|
|
66
|
+
"@bendyline/gezel": "1.2.6",
|
|
67
67
|
"tsup": "^8.5.1",
|
|
68
68
|
"typescript": "^6.0.3",
|
|
69
69
|
"vitest": "^4.1.10"
|