@ai-matrx/content-ir 0.19.1 → 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 CHANGED
@@ -1,10 +1,39 @@
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
+
3
15
  ## 0.19.1
4
16
 
5
- Automatic changed-only republish (docs/metadata drift since the last tag — see
6
- `git diff npm/content-ir-core/v0.19.0..npm/content-ir-core/v0.19.1 -- apps/shared/content-ir-core`).
7
- No source changes intended and no consumer action required.
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.
8
37
 
9
38
  ## 0.19.0 — kind validation behind a schema-source port (Matrx Alchemy ALC-13)
10
39
 
package/dist/index.cjs CHANGED
@@ -7619,6 +7619,76 @@ function mapRange(changes, start, end, unit = "utf16") {
7619
7619
  return { start: newStart, end: newEnd, touched, collapsed: newEnd === newStart && end > start };
7620
7620
  }
7621
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
+
7622
7692
  exports.ACTION_BY_CLASS = ACTION_BY_CLASS;
7623
7693
  exports.AFTER_WINDOW = AFTER_WINDOW;
7624
7694
  exports.BacktickRuns = BacktickRuns;
@@ -7669,6 +7739,7 @@ exports.codeSpanText = codeSpanText;
7669
7739
  exports.collectReferencedKinds = collectReferencedKinds;
7670
7740
  exports.collectSchemaReferencedKinds = collectSchemaReferencedKinds;
7671
7741
  exports.compareWithExistingKindSchema = compareWithExistingKindSchema;
7742
+ exports.continuesTable = continuesTable;
7672
7743
  exports.convertAiSchemaToBlockFields = convertAiSchemaToBlockFields;
7673
7744
  exports.createFingerprinter = createFingerprinter;
7674
7745
  exports.createKindStreamParser = createKindStreamParser;
@@ -7692,6 +7763,8 @@ exports.fenceOpenerOf = fenceOpenerOf;
7692
7763
  exports.fenceParts = fenceParts;
7693
7764
  exports.fieldsToDbPayload = fieldsToDbPayload;
7694
7765
  exports.findCodeRanges = findCodeRanges;
7766
+ exports.findTableEnd = findTableEnd;
7767
+ exports.findTableStart = findTableStart;
7695
7768
  exports.fingerprintText = fingerprintText;
7696
7769
  exports.formatBlockLabel = formatBlockLabel;
7697
7770
  exports.getParseSession = getParseSession;
@@ -7705,11 +7778,13 @@ exports.isDirectiveClass = isDirectiveClass;
7705
7778
  exports.isDuplicateBlockSlug = isDuplicateBlockSlug;
7706
7779
  exports.isEmptyResidue = isEmptyResidue;
7707
7780
  exports.isEscapedBracketMath = isEscapedBracketMath;
7781
+ exports.isGfmDelimiterRow = isGfmDelimiterRow;
7708
7782
  exports.isIrEnvelopeCache = isIrEnvelopeCache;
7709
7783
  exports.isJsonAnyField = isJsonAnyField;
7710
7784
  exports.isKindDirective = isKindDirective;
7711
7785
  exports.isLegacyShell = isLegacyShell;
7712
7786
  exports.isMathPlaceholder = isMathPlaceholder;
7787
+ exports.isPipeLedRow = isPipeLedRow;
7713
7788
  exports.isProvisionalKind = isProvisionalKind;
7714
7789
  exports.isReservedDirectiveSlug = isReservedDirectiveSlug;
7715
7790
  exports.isScalarArrayType = isScalarArrayType;
@@ -7740,6 +7815,7 @@ exports.nounFamily = nounFamily;
7740
7815
  exports.nounLabel = nounLabel;
7741
7816
  exports.nounTitleColumn = nounTitleColumn;
7742
7817
  exports.openParseSession = openParseSession;
7818
+ exports.opensTable = opensTable;
7743
7819
  exports.pairDisplayMath = pairDisplayMath;
7744
7820
  exports.parseDirectiveSlug = parseDirectiveSlug;
7745
7821
  exports.parseFenceOpener = parseFenceOpener;
@@ -7757,6 +7833,7 @@ exports.rehydrateRunResult = rehydrateRunResult;
7757
7833
  exports.resetLegacyShellUses = resetLegacyShellUses;
7758
7834
  exports.resolvesInContent = resolvesInContent;
7759
7835
  exports.reuseEnvelopeIfCurrent = reuseEnvelopeIfCurrent;
7836
+ exports.rowCells = rowCells;
7760
7837
  exports.runKindDualGate = runKindDualGate;
7761
7838
  exports.runSchemaConversion = runSchemaConversion;
7762
7839
  exports.sanitizeInboundEnvelopeMetadata = sanitizeInboundEnvelopeMetadata;
@@ -7768,9 +7845,12 @@ exports.setJsonRootKeyLookup = setJsonRootKeyLookup;
7768
7845
  exports.singleDollarAfter = singleDollarAfter;
7769
7846
  exports.singleDollarMathEnd = singleDollarMathEnd;
7770
7847
  exports.spliceSave = spliceSave;
7848
+ exports.splitRowSegments = splitRowSegments;
7771
7849
  exports.splitsSurrogatePair = splitsSurrogatePair;
7850
+ exports.startsPipelessTable = startsPipelessTable;
7772
7851
  exports.storageToKindSchema = storageToKindSchema;
7773
7852
  exports.stripKindDeep = stripKindDeep;
7853
+ exports.tableStartsAt = tableStartsAt;
7774
7854
  exports.titleCaseToken = titleCaseToken;
7775
7855
  exports.toCodePointOffset = toCodePointOffset;
7776
7856
  exports.toUtf16Offset = toUtf16Offset;
@@ -7778,6 +7858,7 @@ exports.tokenizeSource = tokenizeSource;
7778
7858
  exports.trimFenceLine = trimFenceLine;
7779
7859
  exports.tryDecodeDirective = tryDecodeDirective;
7780
7860
  exports.tryDecodeDirectiveContent = tryDecodeDirectiveContent;
7861
+ exports.unescapeCellPipes = unescapeCellPipes;
7781
7862
  exports.validateBlockSchemaSavePlan = validateBlockSchemaSavePlan;
7782
7863
  exports.validateStructuralLeg = validateStructuralLeg;
7783
7864
  exports.withRootKind = withRootKind;