@ai-matrx/content-ir 0.19.0 → 0.19.2
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/CHANGELOG.md +36 -0
- package/dist/index.cjs +95 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +85 -23
- package/dist/index.js.map +1 -1
- package/dist/source.cjs +95 -22
- package/dist/source.cjs.map +1 -1
- package/dist/source.d.cts +43 -1
- package/dist/source.d.ts +43 -1
- package/dist/source.js +85 -23
- package/dist/source.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.19.2
|
|
4
|
+
### Unreleased
|
|
5
|
+
|
|
6
|
+
- `/source`: **THE GFM table rule** (`source/gfm-table.ts`, verify-RC-B4) —
|
|
7
|
+
`splitRowSegments` / `rowCells` (a `|` is a boundary unless an odd backslash
|
|
8
|
+
run precedes it), `unescapeCellPipes`, `isGfmDelimiterRow`, `isPipeLedRow`,
|
|
9
|
+
`startsPipelessTable`, `continuesTable`, `opensTable`, `tableStartsAt`,
|
|
10
|
+
`findTableStart`, `findTableEnd`. Held to the shared vectors
|
|
11
|
+
(`__tests__/gfm-table-vectors.json`, byte copy of matrx-frontend's and of the
|
|
12
|
+
Python block detector's fixture). Consumers: `@ai-matrx/print` now; the
|
|
13
|
+
matrx-frontend readers move onto it once this version is on npm.
|
|
14
|
+
|
|
15
|
+
## 0.19.1
|
|
16
|
+
|
|
17
|
+
Automatic republish — despite the generated note, this version carries source
|
|
18
|
+
changes: **the RC-B3 round 3 fix round** (verify-RC-B3 § round 3, RC-B3 lane;
|
|
19
|
+
aidream a8506eeeca, 4b92192527, aaef42333d).
|
|
20
|
+
|
|
21
|
+
- `/source` streaming: a trailing single `$` may be half of a `$$` (B3); a lone
|
|
22
|
+
CR is half of a line break still arriving (B4); a block that opens in
|
|
23
|
+
provisional text may still dissolve (a footnote or paragraph does not end
|
|
24
|
+
there); front matter still waiting for its closing fence is undecided.
|
|
25
|
+
Lone CR, tab, list-item and quote atoms joined the LLM-fragment generator.
|
|
26
|
+
- Holdbacks R4 (`$$` block may dissolve), R8 (spilled region), R10 (`\(`/`\[`
|
|
27
|
+
opener) each pinned by a reproducer that fails when it alone is removed; the
|
|
28
|
+
JSON open-tail holdback (R12) and a provisional-tree-root holdback were
|
|
29
|
+
deleted as redundant — planted-mutation differentials over 12,000 documents
|
|
30
|
+
showed 64 and 972 differing prefixes but 0 settled-island changes.
|
|
31
|
+
- Front matter behind a leading byte-order mark (`\uFEFF---`) is front matter.
|
|
32
|
+
- `isSingleDollarMath`: PHP/Perl member access is not math (`$this->$prop`,
|
|
33
|
+
`$obj->$method`, `$class::$instance`). Measured read-only over 86,136
|
|
34
|
+
assistant messages + 4,329 notes: 0 gained, 8 lost (6 shell-variable-chain,
|
|
35
|
+
2 php-perl-member), every one intended.
|
|
36
|
+
- No consumer action required.
|
|
37
|
+
|
|
3
38
|
## 0.19.0 — kind validation behind a schema-source port (Matrx Alchemy ALC-13)
|
|
4
39
|
|
|
5
40
|
`/registry` (and the root) now export `createKindValidator(source, options?)`,
|
|
@@ -976,3 +1011,4 @@ unchanged. Two things are worth doing at your next working session:
|
|
|
976
1011
|
- Added ESM and declaration builds, package linting, packed-artifact analysis, and an isolated consumer canary.
|
|
977
1012
|
- Preserved all parser, session, normalization, schema conversion, and structural-validation behavior with the existing shared fixtures and fingerprint vectors.
|
|
978
1013
|
|
|
1014
|
+
|
package/dist/index.cjs
CHANGED
|
@@ -5648,7 +5648,7 @@ function pendingCodeSpanStart(text) {
|
|
|
5648
5648
|
const n = text.length;
|
|
5649
5649
|
if (n === 0 || /\n[ \t]*\n[ \t]*$/.test(text)) return -1;
|
|
5650
5650
|
const lastLine = text.slice(text.lastIndexOf("\n") + 1);
|
|
5651
|
-
if (lastLine && /^(?: {0,3}>[ \t]?)*[ \t]*$/.test(lastLine)) return pendingCodeSpanStart(`${text}x`);
|
|
5651
|
+
if (lastLine && /^(?: {0,3}>[ \t]?)*[ \t\r]*$/.test(lastLine)) return pendingCodeSpanStart(`${text}x`);
|
|
5652
5652
|
const s = scan(text);
|
|
5653
5653
|
const para = s.pendingPara;
|
|
5654
5654
|
if (s.endsInFence || para === -1) return -1;
|
|
@@ -5812,7 +5812,7 @@ function isVariableChain(content, after) {
|
|
|
5812
5812
|
const run = /^[A-Za-z0-9_]+/.exec(after)?.[0];
|
|
5813
5813
|
if (!run) return false;
|
|
5814
5814
|
if (after.length === 1) return false;
|
|
5815
|
-
if (/^[A-Za-z_][A-Za-z0-9_]*[.@-]$/.test(content)) return true;
|
|
5815
|
+
if (/^[A-Za-z_][A-Za-z0-9_]*(?:[.@-]|->|::)$/.test(content)) return true;
|
|
5816
5816
|
return IDENTIFIER.test(content) && !MATH_SUFFIX.test(run);
|
|
5817
5817
|
}
|
|
5818
5818
|
var FUNCTION_NAMES = /* @__PURE__ */ new Set([
|
|
@@ -6217,7 +6217,7 @@ var Tokenizer = class {
|
|
|
6217
6217
|
if (close >= span) this.provisionalFrom = Math.min(this.provisionalFrom, open);
|
|
6218
6218
|
}
|
|
6219
6219
|
}
|
|
6220
|
-
for (const pad of ["`", "``", "```", "~~~"]) {
|
|
6220
|
+
for (const pad of ["`", "``", "```", "~~~", "$"]) {
|
|
6221
6221
|
const alt = pairDisplayMath(text + pad);
|
|
6222
6222
|
for (const [open, close] of this.mathPairs) {
|
|
6223
6223
|
if (alt.get(open) !== close) this.provisionalFrom = Math.min(this.provisionalFrom, open);
|
|
@@ -6249,19 +6249,6 @@ var Tokenizer = class {
|
|
|
6249
6249
|
provisionalFrom = Number.POSITIVE_INFINITY;
|
|
6250
6250
|
/** Streaming: the text ends in a lone CR whose LF has not arrived yet. */
|
|
6251
6251
|
pendingCR = false;
|
|
6252
|
-
/**
|
|
6253
|
-
* Streaming: an open last line that begins with `{` is undecided — each new
|
|
6254
|
-
* byte can balance or unbalance its braces and flip the whole line between
|
|
6255
|
-
* prose and a JSON island — so it is provisional until it ends (G5).
|
|
6256
|
-
* (A lone HTML tag on that line is held by {@link holdUndecidedTail}.)
|
|
6257
|
-
*/
|
|
6258
|
-
markOpenJsonTail() {
|
|
6259
|
-
const last = this.lineStarts.length - 1;
|
|
6260
|
-
if (!this.isOpenTail(last)) return;
|
|
6261
|
-
if (this.lineText(last).trim().startsWith("{")) {
|
|
6262
|
-
this.provisionalFrom = Math.min(this.provisionalFrom, this.lineStarts[last]);
|
|
6263
|
-
}
|
|
6264
|
-
}
|
|
6265
6252
|
/**
|
|
6266
6253
|
* `text.indexOf(needle, from)` in O(log k): the first query for a needle
|
|
6267
6254
|
* indexes all of its occurrences once, so repeated searches for a closer
|
|
@@ -6296,7 +6283,7 @@ var Tokenizer = class {
|
|
|
6296
6283
|
const rest = this.n - pe;
|
|
6297
6284
|
if (rest === 0) return true;
|
|
6298
6285
|
const tail = this.text.slice(pe);
|
|
6299
|
-
return /^(?:\r\n|\r|\n)[ \t]*$/.test(tail);
|
|
6286
|
+
return /^(?:\r\n|\r|\n)[ \t\r]*$/.test(tail);
|
|
6300
6287
|
}
|
|
6301
6288
|
/**
|
|
6302
6289
|
* Streaming: an open block that may still turn back into prose — a `$$`
|
|
@@ -6305,7 +6292,9 @@ var Tokenizer = class {
|
|
|
6305
6292
|
* or any opener that is itself still arriving on the open last line.
|
|
6306
6293
|
*/
|
|
6307
6294
|
mayDissolve(block) {
|
|
6308
|
-
if (!this.streaming
|
|
6295
|
+
if (!this.streaming) return false;
|
|
6296
|
+
if (block.start >= this.provisionalFrom) return true;
|
|
6297
|
+
if (block.complete) return false;
|
|
6309
6298
|
if (block.type === "math_block" || block.type === "json") return true;
|
|
6310
6299
|
return this.isOpenTail(this.lineOf(block.start));
|
|
6311
6300
|
}
|
|
@@ -6344,7 +6333,6 @@ var Tokenizer = class {
|
|
|
6344
6333
|
return this.text.slice(this.lineStarts[li], this.contentEnds[li]);
|
|
6345
6334
|
}
|
|
6346
6335
|
run() {
|
|
6347
|
-
if (this.streaming) this.markOpenJsonTail();
|
|
6348
6336
|
let pos = 0;
|
|
6349
6337
|
while (pos < this.n) {
|
|
6350
6338
|
const li = this.lineOf(pos);
|
|
@@ -6582,7 +6570,7 @@ var Tokenizer = class {
|
|
|
6582
6570
|
return { type, start, end, complete, meta };
|
|
6583
6571
|
}
|
|
6584
6572
|
frontMatter(li, t) {
|
|
6585
|
-
const fence = this.lineText(li);
|
|
6573
|
+
const fence = this.lineText(li).replace(/^\uFEFF/, "");
|
|
6586
6574
|
if (fence !== "---" && fence !== "+++" || t !== fence) return null;
|
|
6587
6575
|
const toml = fence === "+++";
|
|
6588
6576
|
let sawContent = false;
|
|
@@ -6593,9 +6581,13 @@ var Tokenizer = class {
|
|
|
6593
6581
|
}
|
|
6594
6582
|
if (!NOT_WHITESPACE.test(line)) continue;
|
|
6595
6583
|
const shaped = toml ? /^\s*(?:[A-Za-z0-9_."-]+\s*=|\[|#)/.test(line) : /^(?:[A-Za-z0-9_"'-][^:]*:(?:\s|$)|\s+\S|-\s|#)/.test(line);
|
|
6596
|
-
if (!shaped)
|
|
6584
|
+
if (!shaped) {
|
|
6585
|
+
if (this.isOpenTail(k)) break;
|
|
6586
|
+
return null;
|
|
6587
|
+
}
|
|
6597
6588
|
sawContent = true;
|
|
6598
6589
|
}
|
|
6590
|
+
if (this.streaming) return this.island("front_matter", 0, this.n, false, { format: toml ? "toml" : "yaml" });
|
|
6599
6591
|
return null;
|
|
6600
6592
|
}
|
|
6601
6593
|
/**
|
|
@@ -6996,7 +6988,7 @@ var Tokenizer = class {
|
|
|
6996
6988
|
const block = this.detectBlock(this.lineStarts[k], k, false);
|
|
6997
6989
|
if (block) {
|
|
6998
6990
|
breakLine = k;
|
|
6999
|
-
if (this.mayDissolve(block)
|
|
6991
|
+
if (this.mayDissolve(block)) {
|
|
7000
6992
|
this.undecidedBreaks.add(end);
|
|
7001
6993
|
}
|
|
7002
6994
|
break;
|
|
@@ -7627,6 +7619,76 @@ function mapRange(changes, start, end, unit = "utf16") {
|
|
|
7627
7619
|
return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
|
|
7628
7620
|
}
|
|
7629
7621
|
|
|
7622
|
+
// source/gfm-table.ts
|
|
7623
|
+
function splitRowSegments(line) {
|
|
7624
|
+
const segments = [];
|
|
7625
|
+
let start = 0;
|
|
7626
|
+
for (let i = 0; i < line.length; i += 1) {
|
|
7627
|
+
const ch = line[i];
|
|
7628
|
+
if (ch === "\\") {
|
|
7629
|
+
i += 1;
|
|
7630
|
+
continue;
|
|
7631
|
+
}
|
|
7632
|
+
if (ch === "|") {
|
|
7633
|
+
segments.push(line.slice(start, i));
|
|
7634
|
+
start = i + 1;
|
|
7635
|
+
}
|
|
7636
|
+
}
|
|
7637
|
+
segments.push(line.slice(start));
|
|
7638
|
+
return segments;
|
|
7639
|
+
}
|
|
7640
|
+
function rowCells(line) {
|
|
7641
|
+
const cells = splitRowSegments(line).map((cell) => cell.trim());
|
|
7642
|
+
if (cells.length > 1 && cells[0] === "") cells.shift();
|
|
7643
|
+
if (cells.length > 1 && cells[cells.length - 1] === "") cells.pop();
|
|
7644
|
+
else if (cells.length === 1 && cells[0] === "") cells.pop();
|
|
7645
|
+
return cells;
|
|
7646
|
+
}
|
|
7647
|
+
function unescapeCellPipes(cell) {
|
|
7648
|
+
return cell.replace(/\\\|/g, "|");
|
|
7649
|
+
}
|
|
7650
|
+
var BLOCK_START = /^(?:[-+*](?:\s|$)|\d{1,9}[.)](?:\s|$)|>|#{1,6}(?:\s|$)|```|~~~|(?:-\s*){3,}$|(?:\*\s*){3,}$|(?:_\s*){3,}$)/;
|
|
7651
|
+
var DELIMITER_CELL = /^:?-+:?$/;
|
|
7652
|
+
function isGfmDelimiterRow(line) {
|
|
7653
|
+
const trimmed = line.trim();
|
|
7654
|
+
if (!trimmed.includes("|")) return false;
|
|
7655
|
+
const cells = rowCells(trimmed);
|
|
7656
|
+
return cells.length > 0 && cells.every((cell) => DELIMITER_CELL.test(cell));
|
|
7657
|
+
}
|
|
7658
|
+
function isPipeLedRow(line) {
|
|
7659
|
+
const trimmed = line.trim();
|
|
7660
|
+
return trimmed.startsWith("|") && trimmed.includes("|", 1);
|
|
7661
|
+
}
|
|
7662
|
+
function startsPipelessTable(header, delimiter) {
|
|
7663
|
+
const head = header.trim();
|
|
7664
|
+
if (!head || head.startsWith("|") || BLOCK_START.test(head)) return false;
|
|
7665
|
+
if (splitRowSegments(head).length < 2) return false;
|
|
7666
|
+
if (delimiter === void 0 || !isGfmDelimiterRow(delimiter)) return false;
|
|
7667
|
+
return rowCells(head).length === rowCells(delimiter.trim()).length;
|
|
7668
|
+
}
|
|
7669
|
+
function continuesTable(line) {
|
|
7670
|
+
const trimmed = line.trim();
|
|
7671
|
+
if (!trimmed) return false;
|
|
7672
|
+
if (trimmed.startsWith("|")) return trimmed.includes("|", 1);
|
|
7673
|
+
return splitRowSegments(trimmed).length > 1 && !BLOCK_START.test(trimmed);
|
|
7674
|
+
}
|
|
7675
|
+
function opensTable(lines, index) {
|
|
7676
|
+
const line = lines[index] ?? "";
|
|
7677
|
+
return isPipeLedRow(line) || startsPipelessTable(line, lines[index + 1]);
|
|
7678
|
+
}
|
|
7679
|
+
function tableStartsAt(lines, index) {
|
|
7680
|
+
return opensTable(lines, index) && isGfmDelimiterRow(lines[index + 1] ?? "");
|
|
7681
|
+
}
|
|
7682
|
+
function findTableStart(lines, from = 0) {
|
|
7683
|
+
for (let i = Math.max(0, from); i < lines.length; i += 1) if (opensTable(lines, i)) return i;
|
|
7684
|
+
return -1;
|
|
7685
|
+
}
|
|
7686
|
+
function findTableEnd(lines, start) {
|
|
7687
|
+
let end = Math.min(lines.length, start + 2);
|
|
7688
|
+
while (end < lines.length && continuesTable(lines[end] ?? "")) end += 1;
|
|
7689
|
+
return end;
|
|
7690
|
+
}
|
|
7691
|
+
|
|
7630
7692
|
exports.ACTION_BY_CLASS = ACTION_BY_CLASS;
|
|
7631
7693
|
exports.AFTER_WINDOW = AFTER_WINDOW;
|
|
7632
7694
|
exports.BacktickRuns = BacktickRuns;
|
|
@@ -7677,6 +7739,7 @@ exports.codeSpanText = codeSpanText;
|
|
|
7677
7739
|
exports.collectReferencedKinds = collectReferencedKinds;
|
|
7678
7740
|
exports.collectSchemaReferencedKinds = collectSchemaReferencedKinds;
|
|
7679
7741
|
exports.compareWithExistingKindSchema = compareWithExistingKindSchema;
|
|
7742
|
+
exports.continuesTable = continuesTable;
|
|
7680
7743
|
exports.convertAiSchemaToBlockFields = convertAiSchemaToBlockFields;
|
|
7681
7744
|
exports.createFingerprinter = createFingerprinter;
|
|
7682
7745
|
exports.createKindStreamParser = createKindStreamParser;
|
|
@@ -7700,6 +7763,8 @@ exports.fenceOpenerOf = fenceOpenerOf;
|
|
|
7700
7763
|
exports.fenceParts = fenceParts;
|
|
7701
7764
|
exports.fieldsToDbPayload = fieldsToDbPayload;
|
|
7702
7765
|
exports.findCodeRanges = findCodeRanges;
|
|
7766
|
+
exports.findTableEnd = findTableEnd;
|
|
7767
|
+
exports.findTableStart = findTableStart;
|
|
7703
7768
|
exports.fingerprintText = fingerprintText;
|
|
7704
7769
|
exports.formatBlockLabel = formatBlockLabel;
|
|
7705
7770
|
exports.getParseSession = getParseSession;
|
|
@@ -7713,11 +7778,13 @@ exports.isDirectiveClass = isDirectiveClass;
|
|
|
7713
7778
|
exports.isDuplicateBlockSlug = isDuplicateBlockSlug;
|
|
7714
7779
|
exports.isEmptyResidue = isEmptyResidue;
|
|
7715
7780
|
exports.isEscapedBracketMath = isEscapedBracketMath;
|
|
7781
|
+
exports.isGfmDelimiterRow = isGfmDelimiterRow;
|
|
7716
7782
|
exports.isIrEnvelopeCache = isIrEnvelopeCache;
|
|
7717
7783
|
exports.isJsonAnyField = isJsonAnyField;
|
|
7718
7784
|
exports.isKindDirective = isKindDirective;
|
|
7719
7785
|
exports.isLegacyShell = isLegacyShell;
|
|
7720
7786
|
exports.isMathPlaceholder = isMathPlaceholder;
|
|
7787
|
+
exports.isPipeLedRow = isPipeLedRow;
|
|
7721
7788
|
exports.isProvisionalKind = isProvisionalKind;
|
|
7722
7789
|
exports.isReservedDirectiveSlug = isReservedDirectiveSlug;
|
|
7723
7790
|
exports.isScalarArrayType = isScalarArrayType;
|
|
@@ -7748,6 +7815,7 @@ exports.nounFamily = nounFamily;
|
|
|
7748
7815
|
exports.nounLabel = nounLabel;
|
|
7749
7816
|
exports.nounTitleColumn = nounTitleColumn;
|
|
7750
7817
|
exports.openParseSession = openParseSession;
|
|
7818
|
+
exports.opensTable = opensTable;
|
|
7751
7819
|
exports.pairDisplayMath = pairDisplayMath;
|
|
7752
7820
|
exports.parseDirectiveSlug = parseDirectiveSlug;
|
|
7753
7821
|
exports.parseFenceOpener = parseFenceOpener;
|
|
@@ -7765,6 +7833,7 @@ exports.rehydrateRunResult = rehydrateRunResult;
|
|
|
7765
7833
|
exports.resetLegacyShellUses = resetLegacyShellUses;
|
|
7766
7834
|
exports.resolvesInContent = resolvesInContent;
|
|
7767
7835
|
exports.reuseEnvelopeIfCurrent = reuseEnvelopeIfCurrent;
|
|
7836
|
+
exports.rowCells = rowCells;
|
|
7768
7837
|
exports.runKindDualGate = runKindDualGate;
|
|
7769
7838
|
exports.runSchemaConversion = runSchemaConversion;
|
|
7770
7839
|
exports.sanitizeInboundEnvelopeMetadata = sanitizeInboundEnvelopeMetadata;
|
|
@@ -7776,9 +7845,12 @@ exports.setJsonRootKeyLookup = setJsonRootKeyLookup;
|
|
|
7776
7845
|
exports.singleDollarAfter = singleDollarAfter;
|
|
7777
7846
|
exports.singleDollarMathEnd = singleDollarMathEnd;
|
|
7778
7847
|
exports.spliceSave = spliceSave;
|
|
7848
|
+
exports.splitRowSegments = splitRowSegments;
|
|
7779
7849
|
exports.splitsSurrogatePair = splitsSurrogatePair;
|
|
7850
|
+
exports.startsPipelessTable = startsPipelessTable;
|
|
7780
7851
|
exports.storageToKindSchema = storageToKindSchema;
|
|
7781
7852
|
exports.stripKindDeep = stripKindDeep;
|
|
7853
|
+
exports.tableStartsAt = tableStartsAt;
|
|
7782
7854
|
exports.titleCaseToken = titleCaseToken;
|
|
7783
7855
|
exports.toCodePointOffset = toCodePointOffset;
|
|
7784
7856
|
exports.toUtf16Offset = toUtf16Offset;
|
|
@@ -7786,6 +7858,7 @@ exports.tokenizeSource = tokenizeSource;
|
|
|
7786
7858
|
exports.trimFenceLine = trimFenceLine;
|
|
7787
7859
|
exports.tryDecodeDirective = tryDecodeDirective;
|
|
7788
7860
|
exports.tryDecodeDirectiveContent = tryDecodeDirectiveContent;
|
|
7861
|
+
exports.unescapeCellPipes = unescapeCellPipes;
|
|
7789
7862
|
exports.validateBlockSchemaSavePlan = validateBlockSchemaSavePlan;
|
|
7790
7863
|
exports.validateStructuralLeg = validateStructuralLeg;
|
|
7791
7864
|
exports.withRootKind = withRootKind;
|