@bendyline/gezel-sdk 1.0.8 → 1.0.10
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 +19 -1
- package/dist/checks.js +23 -9
- package/package.json +2 -2
package/dist/checks.d.ts
CHANGED
|
@@ -318,6 +318,24 @@ declare function jsonPathEquals(ws: WorkspaceLike, file: string, path: string, e
|
|
|
318
318
|
* spacing survive. (Ported verbatim from decoy-research.)
|
|
319
319
|
*/
|
|
320
320
|
declare function normalizeDigitGroups(text: string): string;
|
|
321
|
+
/**
|
|
322
|
+
* Drop inline-emphasis delimiters so a value is compared as a value, not as
|
|
323
|
+
* formatting. A deck that writes `Original wait: **14** minutes` is quoting
|
|
324
|
+
* its source exactly; the asterisks are presentation and must not decide a
|
|
325
|
+
* grounding verdict.
|
|
326
|
+
*
|
|
327
|
+
* Wild-caught on the powerpoint-deck eval: a correct, correctly-cited slide
|
|
328
|
+
* failed `valueGrounding` for /14 minutes/ because the model had bolded the
|
|
329
|
+
* figure. A gate that rejects right answers over markdown caps the pass rate
|
|
330
|
+
* of every model equally, which is the one kind of failure an eval must never
|
|
331
|
+
* manufacture.
|
|
332
|
+
*
|
|
333
|
+
* Only the UNAMBIGUOUS delimiters are stripped — `**`, `__`, and backticks.
|
|
334
|
+
* Single `*` and `_` are deliberately left alone: `_` is a word character in
|
|
335
|
+
* every identifier a fact might legitimately require (`read_file`), and `*`
|
|
336
|
+
* carries meaning in globs.
|
|
337
|
+
*/
|
|
338
|
+
declare function normalizeInlineEmphasis(text: string): string;
|
|
321
339
|
/** A single grounded fact: at least one `required` form must appear and no
|
|
322
340
|
* `forbidden` (decoy) form may. Values are regex sources, matched
|
|
323
341
|
* case-insensitively against the (optionally digit-normalized) text. */
|
|
@@ -829,4 +847,4 @@ declare function workspaceFromGezel(g: {
|
|
|
829
847
|
};
|
|
830
848
|
}): WorkspaceLike;
|
|
831
849
|
|
|
832
|
-
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, 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 TableShapeResult, type TableShapeSpec, type UnsupportedClaimPattern, type UnsupportedClaimViolation, type UnsupportedClaimsResult, type ValuesSubsetResult, type ValuesSubsetSpec, type WordBandResult, type WorkspaceLike, buildJudgePrompt, citationsResolve, citedPathKey, cleanCitedPath, codebaseReviewReport, containsPattern, countDistinctMatches, createCitedPathChecker, cssMinBytes, csvShape, dataTableSniff, detectTypeScriptOnlySyntax, detectUnclosedScript, esmImports, explainSniff, extractInlineScripts, fileCountByExt, fileMinBytes, fileMinLines, findImageRefs, gateResult, grepMatches, htmlCompleteSniff, htmlGameSniff, imageRefsResolve, inlineJsBytes, isRealIsoDate, jsonPathEquals, jsonValid, markdownHeadingsMatch, mergeCorpusCoverageShards, namedEntitiesConsistent, normalizeDigitGroups, notContainsPattern, parseCsv, parseJudgeVerdict, parseMarkdownTable, planStructure, readingLevel, recordSchema, requireOrderedSections, resolveRelative, securityReport, standaloneJsParses, tableShape, totalMinBytes, unsupportedClaims, validateJudgeEvidence, validateScriptSyntax, valueGrounding, valuesSubsetOf, wordBand, workspaceFromGezel, wrapperReturnHint };
|
|
850
|
+
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, 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 TableShapeResult, type TableShapeSpec, type UnsupportedClaimPattern, type UnsupportedClaimViolation, type UnsupportedClaimsResult, type ValuesSubsetResult, type ValuesSubsetSpec, type WordBandResult, type WorkspaceLike, buildJudgePrompt, citationsResolve, citedPathKey, cleanCitedPath, codebaseReviewReport, containsPattern, countDistinctMatches, createCitedPathChecker, cssMinBytes, csvShape, dataTableSniff, detectTypeScriptOnlySyntax, detectUnclosedScript, esmImports, explainSniff, extractInlineScripts, fileCountByExt, fileMinBytes, fileMinLines, findImageRefs, gateResult, grepMatches, htmlCompleteSniff, htmlGameSniff, imageRefsResolve, inlineJsBytes, isRealIsoDate, jsonPathEquals, jsonValid, markdownHeadingsMatch, mergeCorpusCoverageShards, namedEntitiesConsistent, normalizeDigitGroups, normalizeInlineEmphasis, notContainsPattern, parseCsv, parseJudgeVerdict, parseMarkdownTable, planStructure, readingLevel, recordSchema, requireOrderedSections, resolveRelative, securityReport, standaloneJsParses, tableShape, totalMinBytes, unsupportedClaims, validateJudgeEvidence, validateScriptSyntax, valueGrounding, valuesSubsetOf, wordBand, workspaceFromGezel, wrapperReturnHint };
|
package/dist/checks.js
CHANGED
|
@@ -529,6 +529,9 @@ async function jsonPathEquals(ws, file, path, expected, label) {
|
|
|
529
529
|
function normalizeDigitGroups(text) {
|
|
530
530
|
return text.replace(/(\d)[,\s](?=\d{3}(?:\D|$))/g, "$1");
|
|
531
531
|
}
|
|
532
|
+
function normalizeInlineEmphasis(text) {
|
|
533
|
+
return text.replace(/\*\*|__|`/g, "");
|
|
534
|
+
}
|
|
532
535
|
function safeRegExp(src, flags) {
|
|
533
536
|
try {
|
|
534
537
|
return new RegExp(src, flags);
|
|
@@ -537,7 +540,9 @@ function safeRegExp(src, flags) {
|
|
|
537
540
|
}
|
|
538
541
|
}
|
|
539
542
|
function valueGrounding(text, facts, opts = {}) {
|
|
540
|
-
const haystack =
|
|
543
|
+
const haystack = normalizeInlineEmphasis(
|
|
544
|
+
opts.normalizeDigits === false ? text : normalizeDigitGroups(text)
|
|
545
|
+
);
|
|
541
546
|
const signals = [];
|
|
542
547
|
const decoysDetected = [];
|
|
543
548
|
let firstFailure = null;
|
|
@@ -579,13 +584,14 @@ var DEFAULT_CITATION_RE = (
|
|
|
579
584
|
function stripFencedBlocks(text) {
|
|
580
585
|
return text.replace(/^[ \t]*(`{3,}|~{3,})[^\n]*\n[\s\S]*?^[ \t]*\1[ \t]*$/gm, "").replace(/^[ \t]*(`{3,}|~{3,})[^\n]*\n[\s\S]*$/m, "");
|
|
581
586
|
}
|
|
587
|
+
var TASK_REF_RE = /^[A-Za-z0-9][A-Za-z0-9._-]*\/\d+$/;
|
|
582
588
|
function extractCitations(text, re) {
|
|
583
589
|
const flags = re.flags.includes("g") ? re.flags : `${re.flags}g`;
|
|
584
590
|
const global = new RegExp(re.source, flags);
|
|
585
591
|
const out = [];
|
|
586
592
|
for (const m of stripFencedBlocks(text).matchAll(global)) {
|
|
587
593
|
const cap = m.slice(1).find((x) => x !== void 0) ?? m[0];
|
|
588
|
-
if (cap) out.push(cap);
|
|
594
|
+
if (cap && !TASK_REF_RE.test(cap)) out.push(cap);
|
|
589
595
|
}
|
|
590
596
|
return out;
|
|
591
597
|
}
|
|
@@ -690,9 +696,14 @@ function valuesSubsetOf(outputText, sourceTexts, spec) {
|
|
|
690
696
|
return out;
|
|
691
697
|
};
|
|
692
698
|
const caseInsensitive = flags.includes("i");
|
|
693
|
-
const
|
|
699
|
+
const foldSpace = (t) => t.replace(/ | | | /g, " ").replace(/\u00a0/g, " ").replace(/\s+/g, " ");
|
|
700
|
+
const normalize = (t) => {
|
|
701
|
+
const folded = foldSpace(t);
|
|
702
|
+
return caseInsensitive ? folded.toLowerCase() : folded;
|
|
703
|
+
};
|
|
704
|
+
const sourceHaystacks = sourceTexts.map(normalize);
|
|
694
705
|
const appearsInSources = (value) => {
|
|
695
|
-
const needle =
|
|
706
|
+
const needle = normalize(value);
|
|
696
707
|
return sourceHaystacks.some((t) => t.includes(needle));
|
|
697
708
|
};
|
|
698
709
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -1681,7 +1692,7 @@ function wrapperReturnHint(outputLines) {
|
|
|
1681
1692
|
|
|
1682
1693
|
// ../core/src/checks/markdown.ts
|
|
1683
1694
|
function cleanHeading(text) {
|
|
1684
|
-
return text.replace(/\s+#+\s*$/, "").replace(/[*_`]/g, "").replace(/[–—]/g, "-").replace(/[^\p{L}\p{N}]+/gu, " ").trim().toLocaleLowerCase();
|
|
1695
|
+
return text.replace(/\s+#+\s*$/, "").replace(/\s+\{\[[^\]\r\n]+\]\}\s*$/, "").replace(/[*_`]/g, "").replace(/[–—]/g, "-").replace(/[^\p{L}\p{N}]+/gu, " ").trim().toLocaleLowerCase();
|
|
1685
1696
|
}
|
|
1686
1697
|
function documentH1s(markdown) {
|
|
1687
1698
|
return [...markdown.matchAll(/^#\s+(.+?)\s*$/gm)].map((match) => match[1].trim());
|
|
@@ -1695,13 +1706,15 @@ function headingLevelHint(file, documentHeadings, h2s, expected) {
|
|
|
1695
1706
|
return `${file} puts its ${expected} slides at \`##\`${title}, but slides are split on H1 \u2014 as written this converts to a single slide. Promote each \`## Slide\` heading to \`# \` and drop the document title.`;
|
|
1696
1707
|
}
|
|
1697
1708
|
function outlineSlideHeadings(markdown) {
|
|
1698
|
-
const
|
|
1709
|
+
const explicit = [];
|
|
1710
|
+
const numberedOnly = [];
|
|
1699
1711
|
for (const match of markdown.matchAll(/^#{2,6}\s+(.+?)\s*$/gm)) {
|
|
1700
1712
|
const raw = match[1].trim();
|
|
1701
|
-
const numbered = /^(
|
|
1702
|
-
if (numbered?.[
|
|
1713
|
+
const numbered = /^(slide\s+)?\d+(?:\s*[.:\-–—]\s*|\s+)(\S.*)$/i.exec(raw);
|
|
1714
|
+
if (!numbered?.[2]) continue;
|
|
1715
|
+
(numbered[1] ? explicit : numberedOnly).push(numbered[2].trim());
|
|
1703
1716
|
}
|
|
1704
|
-
return
|
|
1717
|
+
return explicit.length > 0 ? explicit : numberedOnly;
|
|
1705
1718
|
}
|
|
1706
1719
|
async function markdownHeadingsMatch(ws, file, outlineFile, outlineWs = ws) {
|
|
1707
1720
|
const [document, outline] = await Promise.all([ws.read(file), outlineWs.read(outlineFile)]);
|
|
@@ -2264,6 +2277,7 @@ export {
|
|
|
2264
2277
|
mergeCorpusCoverageShards,
|
|
2265
2278
|
namedEntitiesConsistent,
|
|
2266
2279
|
normalizeDigitGroups,
|
|
2280
|
+
normalizeInlineEmphasis,
|
|
2267
2281
|
notContainsPattern,
|
|
2268
2282
|
parseCsv,
|
|
2269
2283
|
parseJudgeVerdict,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "SDK imported by scripts running in the Gezel sandbox. Exposes the `gezel` object and `defineScript` helper.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
"!dist/**/*.map"
|
|
60
60
|
],
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@bendyline/gezel": "1.1.
|
|
62
|
+
"@bendyline/gezel": "1.1.2",
|
|
63
63
|
"tsup": "^8.5.1",
|
|
64
64
|
"typescript": "^6.0.3",
|
|
65
65
|
"vitest": "^4.1.10"
|