eyeling 1.33.1 → 1.33.3

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.
Files changed (144) hide show
  1. package/README.md +8 -0
  2. package/bin/eyeling.cjs +1 -1
  3. package/dist/browser/eyeling.browser.js +1 -1
  4. package/examples/eyelang/INTEGRATION.md +7 -0
  5. package/examples/eyelang/README.md +15 -76
  6. package/examples/eyelang/SPEC.md +1 -2
  7. package/examples/eyelang/output/vulnerability-impact.pl +20 -0
  8. package/examples/eyelang/vulnerability-impact.pl +70 -0
  9. package/examples/output/vulnerability-impact.n3 +22 -0
  10. package/examples/vulnerability-impact.n3 +80 -0
  11. package/eyelang.d.ts +0 -12
  12. package/eyeling.js +1 -1
  13. package/index.d.ts +0 -4
  14. package/index.js +2 -6
  15. package/lib/cli.js +1 -1
  16. package/lib/eyelang/bin.js +1 -1
  17. package/lib/eyelang/builtins/{aggregation.mjs → aggregation.js} +1 -1
  18. package/lib/eyelang/builtins/{alphametic.mjs → alphametic.js} +1 -1
  19. package/lib/eyelang/builtins/{arithmetic.mjs → arithmetic.js} +1 -1
  20. package/lib/eyelang/builtins/{core.mjs → core.js} +1 -1
  21. package/lib/eyelang/builtins/{formula.mjs → formula.js} +1 -1
  22. package/lib/eyelang/builtins/{lists.mjs → lists.js} +1 -1
  23. package/lib/eyelang/builtins/{matrix.mjs → matrix.js} +1 -1
  24. package/lib/eyelang/builtins/{number-theory.mjs → number-theory.js} +1 -1
  25. package/lib/eyelang/builtins/{portfolio.mjs → portfolio.js} +1 -1
  26. package/lib/eyelang/builtins/{registry.mjs → registry.js} +14 -15
  27. package/lib/eyelang/builtins/{search.mjs → search.js} +5 -5
  28. package/lib/eyelang/builtins/{strings.mjs → strings.js} +1 -1
  29. package/lib/eyelang/builtins/{sudoku.mjs → sudoku.js} +1 -1
  30. package/lib/eyelang/{cli.mjs → cli.js} +6 -18
  31. package/lib/eyelang/{explain.mjs → explain.js} +4 -4
  32. package/lib/eyelang/{hash.mjs → hash.js} +2 -2
  33. package/lib/eyelang/{index.mjs → index.js} +11 -12
  34. package/lib/eyelang/package.json +3 -0
  35. package/lib/eyelang/{parser.mjs → parser.js} +1 -1
  36. package/lib/eyelang/{program.mjs → program.js} +2 -9
  37. package/lib/eyelang/{solver.mjs → solver.js} +4 -4
  38. package/package.json +3 -3
  39. package/test/eyelang/run-conformance.mjs +1 -1
  40. package/test/eyelang/run-examples.mjs +2 -3
  41. package/test/eyelang/run-regression.mjs +4 -65
  42. package/test/eyelang/test-style.mjs +10 -7
  43. package/test/eyelang.test.js +1 -1
  44. package/test/run.js +186 -37
  45. package/examples/eyelang/annotation-rdf12.ttl +0 -12
  46. package/examples/eyelang/directional-language.ttl +0 -9
  47. package/examples/eyelang/eyeling-ackermann.n3 +0 -41
  48. package/examples/eyelang/eyeling-age-threshold.n3 +0 -12
  49. package/examples/eyelang/eyeling-alignment-demo.n3 +0 -11
  50. package/examples/eyelang/eyeling-allen-interval-calculus-small.n3 +0 -13
  51. package/examples/eyelang/eyeling-backward-recursion.n3 +0 -11
  52. package/examples/eyelang/eyeling-backward.n3 +0 -10
  53. package/examples/eyelang/eyeling-basic-monadic-small.n3 +0 -11
  54. package/examples/eyelang/eyeling-bmi.n3 +0 -10
  55. package/examples/eyelang/eyeling-cat-koko.n3 +0 -15
  56. package/examples/eyelang/eyeling-collatz-small.n3 +0 -11
  57. package/examples/eyelang/eyeling-collection.n3 +0 -11
  58. package/examples/eyelang/eyeling-complex-arithmetic.n3 +0 -10
  59. package/examples/eyelang/eyeling-context-association.n3 +0 -11
  60. package/examples/eyelang/eyeling-control-system-small.n3 +0 -11
  61. package/examples/eyelang/eyeling-crypto-builtins-extra.n3 +0 -10
  62. package/examples/eyelang/eyeling-crypto-builtins.n3 +0 -8
  63. package/examples/eyelang/eyeling-deep-taxonomy-10.n3 +0 -18
  64. package/examples/eyelang/eyeling-derived-backward-rule-flat.n3 +0 -10
  65. package/examples/eyelang/eyeling-derived-rule-flat.n3 +0 -9
  66. package/examples/eyelang/eyeling-digital-product-passport-small.n3 +0 -11
  67. package/examples/eyelang/eyeling-dijkstra-tiny.n3 +0 -14
  68. package/examples/eyelang/eyeling-dog-license.n3 +0 -13
  69. package/examples/eyelang/eyeling-drone-corridor-planner-small.n3 +0 -13
  70. package/examples/eyelang/eyeling-equals.n3 +0 -8
  71. package/examples/eyelang/eyeling-equivalence-classes.n3 +0 -11
  72. package/examples/eyelang/eyeling-euler-identity.n3 +0 -9
  73. package/examples/eyelang/eyeling-existential-rule.n3 +0 -9
  74. package/examples/eyelang/eyeling-expression-eval.n3 +0 -11
  75. package/examples/eyelang/eyeling-family-cousins-extended.n3 +0 -12
  76. package/examples/eyelang/eyeling-fastpow.n3 +0 -10
  77. package/examples/eyelang/eyeling-fibonacci.n3 +0 -44
  78. package/examples/eyelang/eyeling-french-cities-reachability.n3 +0 -22
  79. package/examples/eyelang/eyeling-goldbach-small.n3 +0 -22
  80. package/examples/eyelang/eyeling-good-cobbler.n3 +0 -9
  81. package/examples/eyelang/eyeling-list-builtins.n3 +0 -10
  82. package/examples/eyelang/eyeling-list-collection-extra.n3 +0 -9
  83. package/examples/eyelang/eyeling-math-builtins.n3 +0 -9
  84. package/examples/eyelang/eyeling-string-builtins-extra.n3 +0 -9
  85. package/examples/eyelang/eyeling-string-builtins.n3 +0 -10
  86. package/examples/eyelang/eyeling-time-builtins.n3 +0 -11
  87. package/examples/eyelang/eyeling-time-components-extra.n3 +0 -10
  88. package/examples/eyelang/eyeling-witch.n3 +0 -10
  89. package/examples/eyelang/family-cousins.n3 +0 -17
  90. package/examples/eyelang/n3-builtins.n3 +0 -28
  91. package/examples/eyelang/output/annotation-rdf12.ttl +0 -1
  92. package/examples/eyelang/output/directional-language.ttl +0 -1
  93. package/examples/eyelang/output/eyeling-ackermann.n3 +0 -12
  94. package/examples/eyelang/output/eyeling-age-threshold.n3 +0 -4
  95. package/examples/eyelang/output/eyeling-alignment-demo.n3 +0 -1
  96. package/examples/eyelang/output/eyeling-allen-interval-calculus-small.n3 +0 -3
  97. package/examples/eyelang/output/eyeling-backward-recursion.n3 +0 -9
  98. package/examples/eyelang/output/eyeling-backward.n3 +0 -1
  99. package/examples/eyelang/output/eyeling-basic-monadic-small.n3 +0 -8
  100. package/examples/eyelang/output/eyeling-bmi.n3 +0 -2
  101. package/examples/eyelang/output/eyeling-cat-koko.n3 +0 -3
  102. package/examples/eyelang/output/eyeling-collatz-small.n3 +0 -3
  103. package/examples/eyelang/output/eyeling-collection.n3 +0 -1
  104. package/examples/eyelang/output/eyeling-complex-arithmetic.n3 +0 -5
  105. package/examples/eyelang/output/eyeling-context-association.n3 +0 -4
  106. package/examples/eyelang/output/eyeling-control-system-small.n3 +0 -4
  107. package/examples/eyelang/output/eyeling-crypto-builtins-extra.n3 +0 -3
  108. package/examples/eyelang/output/eyeling-crypto-builtins.n3 +0 -2
  109. package/examples/eyelang/output/eyeling-deep-taxonomy-10.n3 +0 -32
  110. package/examples/eyelang/output/eyeling-derived-backward-rule-flat.n3 +0 -4
  111. package/examples/eyelang/output/eyeling-derived-rule-flat.n3 +0 -2
  112. package/examples/eyelang/output/eyeling-digital-product-passport-small.n3 +0 -3
  113. package/examples/eyelang/output/eyeling-dijkstra-tiny.n3 +0 -9
  114. package/examples/eyelang/output/eyeling-dog-license.n3 +0 -1
  115. package/examples/eyelang/output/eyeling-drone-corridor-planner-small.n3 +0 -5
  116. package/examples/eyelang/output/eyeling-equals.n3 +0 -1
  117. package/examples/eyelang/output/eyeling-equivalence-classes.n3 +0 -2
  118. package/examples/eyelang/output/eyeling-euler-identity.n3 +0 -3
  119. package/examples/eyelang/output/eyeling-existential-rule.n3 +0 -4
  120. package/examples/eyelang/output/eyeling-expression-eval.n3 +0 -3
  121. package/examples/eyelang/output/eyeling-family-cousins-extended.n3 +0 -6
  122. package/examples/eyelang/output/eyeling-fastpow.n3 +0 -4
  123. package/examples/eyelang/output/eyeling-fibonacci.n3 +0 -6
  124. package/examples/eyelang/output/eyeling-french-cities-reachability.n3 +0 -25
  125. package/examples/eyelang/output/eyeling-goldbach-small.n3 +0 -2
  126. package/examples/eyelang/output/eyeling-good-cobbler.n3 +0 -2
  127. package/examples/eyelang/output/eyeling-list-builtins.n3 +0 -6
  128. package/examples/eyelang/output/eyeling-list-collection-extra.n3 +0 -5
  129. package/examples/eyelang/output/eyeling-math-builtins.n3 +0 -5
  130. package/examples/eyelang/output/eyeling-string-builtins-extra.n3 +0 -3
  131. package/examples/eyelang/output/eyeling-string-builtins.n3 +0 -4
  132. package/examples/eyelang/output/eyeling-time-builtins.n3 +0 -4
  133. package/examples/eyelang/output/eyeling-time-components-extra.n3 +0 -5
  134. package/examples/eyelang/output/eyeling-witch.n3 +0 -2
  135. package/examples/eyelang/output/family-cousins.n3 +0 -8
  136. package/examples/eyelang/output/n3-builtins.n3 +0 -6
  137. package/examples/eyelang/output/socrates.n3 +0 -1
  138. package/examples/eyelang/output/triple-term.n3 +0 -2
  139. package/examples/eyelang/socrates.n3 +0 -11
  140. package/examples/eyelang/triple-term.n3 +0 -9
  141. package/lib/eyelang/builtins/n3.mjs +0 -483
  142. package/lib/eyelang/rdf.mjs +0 -747
  143. /package/lib/eyelang/builtins/{control.mjs → control.js} +0 -0
  144. /package/lib/eyelang/{term.mjs → term.js} +0 -0
@@ -1,19 +1,18 @@
1
1
  // Registry for builtins and their execution metadata.
2
2
  // The solver uses the metadata to know when a builtin is deterministic, mode-ready, or should fall back to user clauses.
3
- import { arithmeticBuiltins } from './arithmetic.mjs';
4
- import { coreBuiltins } from './core.mjs';
5
- import { stringBuiltins } from './strings.mjs';
6
- import { listBuiltins } from './lists.mjs';
7
- import { aggregationBuiltins } from './aggregation.mjs';
8
- import { formulaBuiltins } from './formula.mjs';
9
- import { controlBuiltins } from './control.mjs';
10
- import { sudokuBuiltins } from './sudoku.mjs';
11
- import { portfolioBuiltins } from './portfolio.mjs';
12
- import { searchBuiltins } from './search.mjs';
13
- import { numberTheoryBuiltins } from './number-theory.mjs';
14
- import { matrixBuiltins } from './matrix.mjs';
15
- import { alphameticBuiltins } from './alphametic.mjs';
16
- import { n3Builtins } from './n3.mjs';
3
+ import { arithmeticBuiltins } from './arithmetic.js';
4
+ import { coreBuiltins } from './core.js';
5
+ import { stringBuiltins } from './strings.js';
6
+ import { listBuiltins } from './lists.js';
7
+ import { aggregationBuiltins } from './aggregation.js';
8
+ import { formulaBuiltins } from './formula.js';
9
+ import { controlBuiltins } from './control.js';
10
+ import { sudokuBuiltins } from './sudoku.js';
11
+ import { portfolioBuiltins } from './portfolio.js';
12
+ import { searchBuiltins } from './search.js';
13
+ import { numberTheoryBuiltins } from './number-theory.js';
14
+ import { matrixBuiltins } from './matrix.js';
15
+ import { alphameticBuiltins } from './alphametic.js';
17
16
 
18
17
  export class BuiltinRegistry {
19
18
  constructor() {
@@ -40,7 +39,7 @@ export class BuiltinRegistry {
40
39
 
41
40
  export function createDefaultRegistry() {
42
41
  const registry = new BuiltinRegistry();
43
- for (const mod of [coreBuiltins, arithmeticBuiltins, stringBuiltins, listBuiltins, aggregationBuiltins, formulaBuiltins, controlBuiltins, sudokuBuiltins, portfolioBuiltins, searchBuiltins, numberTheoryBuiltins, matrixBuiltins, alphameticBuiltins, n3Builtins]) {
42
+ for (const mod of [coreBuiltins, arithmeticBuiltins, stringBuiltins, listBuiltins, aggregationBuiltins, formulaBuiltins, controlBuiltins, sudokuBuiltins, portfolioBuiltins, searchBuiltins, numberTheoryBuiltins, matrixBuiltins, alphameticBuiltins]) {
44
43
  mod.register(registry);
45
44
  }
46
45
  return registry;
@@ -2,8 +2,8 @@
2
2
  // of their time in small relational generators. These predicates are generic
3
3
  // entry points (graph, CNF, QMC, range, and n-queens helpers), not compiled
4
4
  // replacements for particular example predicate names.
5
- import { atom, compound, deref, listFromItems, numberTerm, properListItems, unify } from '../term.mjs';
6
- import { compareLexicalOrNumeric } from './arithmetic.mjs';
5
+ import { atom, compound, deref, listFromItems, numberTerm, properListItems, unify } from '../term.js';
6
+ import { compareLexicalOrNumeric } from './arithmetic.js';
7
7
 
8
8
  export const searchBuiltins = {
9
9
  register(registry) {
@@ -230,9 +230,9 @@ function undirectedGraph(program, predicate) {
230
230
  }
231
231
 
232
232
  function* fixedLengthCycle({ solver, goal, env }) {
233
- // fixed_length_cycle(EdgePred, Length, Relation, Cycle) is useful for RDF-like
234
- // edge(Source, Relation, Target) data. It enumerates closed walks of exactly
235
- // Length steps and returns the relation label and node list.
233
+ // fixed_length_cycle(EdgePred, Length, Relation, Cycle) is useful for
234
+ // labelled edge(Source, Relation, Target) data. It enumerates closed walks
235
+ // of exactly Length steps and returns the relation label and node list.
236
236
  const predicate = atomKey(deref(goal.args[0], env));
237
237
  const length = intTerm(goal.args[1], env);
238
238
  if (!predicate || length == null || length < 0) return;
@@ -1,6 +1,6 @@
1
1
  // String and atom conversion builtins.
2
2
  // They mostly project from already-ground terms to avoid guessing string domains.
3
- import { atom, lexicalValue, stringTerm, unify } from '../term.mjs';
3
+ import { atom, lexicalValue, stringTerm, unify } from '../term.js';
4
4
 
5
5
  export const stringBuiltins = {
6
6
  register(registry) {
@@ -1,6 +1,6 @@
1
1
  // Sudoku-specific helpers used by the example suite.
2
2
  // The cover9/1 optimization prunes invalid row blocks early while leaving the declarative fallback available.
3
- import { deref, lexicalValue, listFromItems, numberTerm, properListItems, unify } from '../term.mjs';
3
+ import { deref, lexicalValue, listFromItems, numberTerm, properListItems, unify } from '../term.js';
4
4
 
5
5
  export const sudokuBuiltins = {
6
6
  register(registry) {
@@ -18,7 +18,6 @@ export async function main(argv) {
18
18
  proof: false,
19
19
  stats: false,
20
20
  version: false,
21
- inputFormat: 'auto',
22
21
  };
23
22
 
24
23
  let endOptions = false;
@@ -37,14 +36,6 @@ export async function main(argv) {
37
36
  options.proof = true;
38
37
  } else if (!endOptions && (arg === '--stats' || arg === '-s')) {
39
38
  options.stats = true;
40
- } else if (!endOptions && (arg === '--rdf' || arg === '--rdf12')) {
41
- options.inputFormat = 'rdf12';
42
- } else if (!endOptions && arg === '--n3') {
43
- options.inputFormat = 'n3';
44
- } else if (!endOptions && arg === '--input-format') {
45
- const value = argv[++i];
46
- if (!value) throw new Error('--input-format needs a value');
47
- options.inputFormat = value;
48
39
  } else if (!endOptions && arg.startsWith('-') && arg !== '-') {
49
40
  throw new Error(`unknown option: ${arg}`);
50
41
  } else {
@@ -79,7 +70,7 @@ export async function main(argv) {
79
70
  }
80
71
 
81
72
  const engine = await loadEngine();
82
- const program = engine.Program.parseSources(sourceParts, { sourceMetadata: options.proof, markRecursive: options.proof, inputFormat: options.inputFormat });
73
+ const program = engine.Program.parseSources(sourceParts, { sourceMetadata: options.proof, markRecursive: options.proof });
83
74
 
84
75
  await runDefault(engine, program, options);
85
76
  }
@@ -87,10 +78,10 @@ export async function main(argv) {
87
78
  async function loadEngine() {
88
79
  if (engineModule == null) {
89
80
  const [term, program, solver, registry] = await Promise.all([
90
- import('./term.mjs'),
91
- import('./program.mjs'),
92
- import('./solver.mjs'),
93
- import('./builtins/registry.mjs'),
81
+ import('./term.js'),
82
+ import('./program.js'),
83
+ import('./solver.js'),
84
+ import('./builtins/registry.js'),
94
85
  ]);
95
86
  engineModule = { ...term, ...program, ...solver, ...registry };
96
87
  }
@@ -98,7 +89,7 @@ async function loadEngine() {
98
89
  }
99
90
 
100
91
  async function loadExplanation() {
101
- if (explanationModule == null) explanationModule = await import('./explain.mjs');
92
+ if (explanationModule == null) explanationModule = await import('./explain.js');
102
93
  return explanationModule;
103
94
  }
104
95
 
@@ -152,9 +143,6 @@ Options:
152
143
  -h, --help Show this help text and exit.
153
144
  -p, --proof Enable proof explanations.
154
145
  -s, --stats Print solver statistics to stderr after execution.
155
- --rdf, --rdf12 Read input as RDF 1.2 Turtle/N-Triples compatibility syntax.
156
- --n3 Read input as Notation3 rule compatibility syntax.
157
- --input-format FORMAT Use eyelang, auto, rdf12, turtle, nt, or n3.
158
146
  -v, --version Show the package version and exit.
159
147
  -- Stop option parsing; following arguments are treated as files.
160
148
  `);
@@ -2,10 +2,10 @@
2
2
  // The explanation printer replays a successful goal against the program and emits
3
3
  // ordinary eyelang facts with nested proof terms. Explanations are therefore both
4
4
  // human-readable and machine-readable.
5
- import { COMPOUND, Env, Term, VAR, deref, flattenConjunction, freshTerm, termToString, unify, variantTerms } from './term.mjs';
6
- import { selectClauseCandidates } from './program.mjs';
7
- import { createDefaultRegistry } from './builtins/registry.mjs';
8
- import { Solver, nextFreshId } from './solver.mjs';
5
+ import { COMPOUND, Env, Term, VAR, deref, flattenConjunction, freshTerm, termToString, unify, variantTerms } from './term.js';
6
+ import { selectClauseCandidates } from './program.js';
7
+ import { createDefaultRegistry } from './builtins/registry.js';
8
+ import { Solver, nextFreshId } from './solver.js';
9
9
 
10
10
  export function whyProof(program, goal, options = {}) {
11
11
  const maxDepth = options.maxDepth ?? 256;
@@ -1,6 +1,6 @@
1
1
  // Small dependency-free hashing helpers shared by Node and browser builds.
2
- // They intentionally avoid node:crypto so src/index.js remains importable by the
3
- // browser playground when the N3 crypto builtins are registered.
2
+ // They intentionally avoid node:crypto so src/index.js remains importable by
3
+ // browser builds that register hashing builtins.
4
4
 
5
5
  const textEncoder = new TextEncoder();
6
6
 
@@ -1,17 +1,16 @@
1
1
  // Public JavaScript API surface for embedders and the browser playground.
2
2
  // The CLI imports the same parser, program, solver, and term primitives from here.
3
- export { Program, makeProgram } from './program.mjs';
4
- export { parseClauses, parseProgramText } from './parser.mjs';
5
- export { parseRdfClauses, rdfToEyelang, clausesToEyelang, rdfIri, rdfBlank, rdfLiteral, rdfTripleTerm, rdfGoal } from './rdf.mjs';
6
- export { Solver } from './solver.mjs';
7
- export * from './term.mjs';
8
- export { BuiltinRegistry, createDefaultRegistry, getDefaultRegistry } from './builtins/registry.mjs';
3
+ export { Program, makeProgram } from './program.js';
4
+ export { parseClauses, parseProgramText } from './parser.js';
5
+ export { Solver } from './solver.js';
6
+ export * from './term.js';
7
+ export { BuiltinRegistry, createDefaultRegistry, getDefaultRegistry } from './builtins/registry.js';
9
8
 
10
- import { Env, copyResolved, termIsGround, termToString } from './term.mjs';
11
- import { Program } from './program.mjs';
12
- import { Solver } from './solver.mjs';
13
- import { whyNoProof, whyProof } from './explain.mjs';
14
- import { getDefaultRegistry } from './builtins/registry.mjs';
9
+ import { Env, copyResolved, termIsGround, termToString } from './term.js';
10
+ import { Program } from './program.js';
11
+ import { Solver } from './solver.js';
12
+ import { whyNoProof, whyProof } from './explain.js';
13
+ import { getDefaultRegistry } from './builtins/registry.js';
15
14
 
16
15
  export function run(source, options = {}) {
17
16
  const includeWhy = options.proof === true || options.why === true || options.explain === true;
@@ -45,4 +44,4 @@ function appendExplanation(output, program, resolved, registry) {
45
44
  if (!proof.ok) output.push(whyNoProof(resolved));
46
45
  }
47
46
 
48
- export * from './explain.mjs';
47
+ export * from './explain.js';
@@ -0,0 +1,3 @@
1
+ {
2
+ "type": "module"
3
+ }
@@ -1,6 +1,6 @@
1
1
  // Tokenizer and recursive-descent parser for the eyelang source language.
2
2
  // It preserves the compact Prolog-like syntax while producing Term objects for the solver.
3
- import { atom, compound, cons, emptyList, numberTerm, stringTerm, variable } from './term.mjs';
3
+ import { atom, compound, cons, emptyList, numberTerm, stringTerm, variable } from './term.js';
4
4
 
5
5
  const TOK = {
6
6
  EOF: 'eof', ATOM: 'atom', VAR: 'var', STRING: 'string', NUMBER: 'number',
@@ -1,8 +1,7 @@
1
1
  // Program representation and clause indexing.
2
2
  // Indexes are deliberately conservative: they speed up common scalar arguments but never replace unification as the final check.
3
- import { ATOM, COMPOUND, Env, compound, deref, flattenConjunction, isScalar, termToString } from './term.mjs';
4
- import { parseClauses } from './parser.mjs';
5
- import { filenameLooksRdf, parseRdfClauses } from './rdf.mjs';
3
+ import { ATOM, COMPOUND, Env, compound, deref, flattenConjunction, isScalar, termToString } from './term.js';
4
+ import { parseClauses } from './parser.js';
6
5
 
7
6
  export class Program {
8
7
  constructor(clauses = [], options = {}) {
@@ -234,11 +233,5 @@ export function makeProgram(source, options = {}) {
234
233
  }
235
234
 
236
235
  export function parseSourceClauses(source, options = {}) {
237
- const inputFormat = (options.inputFormat ?? options.format ?? 'eyelang').toString().toLowerCase();
238
- const filename = options.filename ?? '<input>';
239
- const autoRdf = inputFormat === 'auto' && filenameLooksRdf(filename);
240
- if (inputFormat === 'rdf' || inputFormat === 'rdf12' || inputFormat === 'n3' || inputFormat === 'turtle' || inputFormat === 'ttl' || inputFormat === 'nt' || autoRdf) {
241
- return parseRdfClauses(source, options);
242
- }
243
236
  return parseClauses(source, options);
244
237
  }
@@ -1,8 +1,8 @@
1
1
  // Depth-first eyelang solver with builtin dispatch, memoization, and guarded recursion handling.
2
2
  // Most semantic decisions still flow through unification; optimizations only select candidates earlier.
3
- import { COMPOUND, Env, flattenConjunction, freshTerm, termToString, unify, variantTerms } from './term.mjs';
4
- import { createDefaultRegistry } from './builtins/registry.mjs';
5
- import { selectClauseCandidates } from './program.mjs';
3
+ import { COMPOUND, Env, flattenConjunction, freshTerm, termToString, unify, variantTerms } from './term.js';
4
+ import { createDefaultRegistry } from './builtins/registry.js';
5
+ import { selectClauseCandidates } from './program.js';
6
6
 
7
7
  let freshCounter = 0;
8
8
 
@@ -234,4 +234,4 @@ function importResolved(term, env) {
234
234
  }
235
235
 
236
236
  // Avoid circular import surprises in older Node loaders.
237
- import * as termModuleCache from './term.mjs';
237
+ import * as termModuleCache from './term.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eyeling",
3
- "version": "1.33.1",
3
+ "version": "1.33.3",
4
4
  "description": "A minimal Notation3 (N3) reasoner in JavaScript.",
5
5
  "main": "./index.js",
6
6
  "keywords": [
@@ -87,8 +87,8 @@
87
87
  "./package.json": "./package.json",
88
88
  "./eyelang": {
89
89
  "types": "./eyelang.d.ts",
90
- "import": "./lib/eyelang/index.mjs",
91
- "default": "./lib/eyelang/index.mjs"
90
+ "import": "./lib/eyelang/index.js",
91
+ "default": "./lib/eyelang/index.js"
92
92
  }
93
93
  },
94
94
  "typesVersions": {
@@ -4,7 +4,7 @@
4
4
  import fs from 'node:fs';
5
5
  import path from 'node:path';
6
6
  import { spawnSync } from 'node:child_process';
7
- import { Program, run } from '../../lib/eyelang/index.mjs';
7
+ import { Program, run } from '../../lib/eyelang/index.js';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { TestReporter, isMainModule } from './test-style.mjs';
10
10
 
@@ -4,7 +4,7 @@
4
4
  import fs from 'node:fs';
5
5
  import path from 'node:path';
6
6
  import { spawnSync } from 'node:child_process';
7
- import { Program, run } from '../../lib/eyelang/index.mjs';
7
+ import { Program, run } from '../../lib/eyelang/index.js';
8
8
  import { fileURLToPath } from 'node:url';
9
9
  import { TestReporter, isMainModule } from './test-style.mjs';
10
10
 
@@ -54,7 +54,7 @@ export function runExamples(reporter = new TestReporter()) {
54
54
 
55
55
 
56
56
  function exampleIsRunnable(name) {
57
- return name.endsWith('.pl') || name.endsWith('.n3') || name.endsWith('.ttl') || name.endsWith('.nt');
57
+ return name.endsWith('.pl');
58
58
  }
59
59
 
60
60
  function runExample(name) {
@@ -79,7 +79,6 @@ function runProgramExample(programFile, filename, options) {
79
79
  const program = Program.parseSources([{ text, filename }], {
80
80
  sourceMetadata: options.proof,
81
81
  markRecursive: options.proof,
82
- inputFormat: 'auto',
83
82
  });
84
83
  return run(program, options).stdout;
85
84
  } finally {
@@ -30,12 +30,11 @@ import {
30
30
  unify,
31
31
  variantTerms,
32
32
  parseProgramText,
33
- rdfToEyelang,
34
- } from '../../lib/eyelang/index.mjs';
35
- import { parseGoalText } from '../../lib/eyelang/parser.mjs';
36
- import { selectClauseCandidates } from '../../lib/eyelang/program.mjs';
33
+ } from '../../lib/eyelang/index.js';
34
+ import { parseGoalText } from '../../lib/eyelang/parser.js';
35
+ import { selectClauseCandidates } from '../../lib/eyelang/program.js';
37
36
  import { TestReporter, isMainModule } from './test-style.mjs';
38
- import { hashHex } from '../../lib/eyelang/hash.mjs';
37
+ import { hashHex } from '../../lib/eyelang/hash.js';
39
38
 
40
39
  const testRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)));
41
40
  const packageRoot = path.resolve(testRoot, '..', '..');
@@ -207,66 +206,6 @@ why(
207
206
  },
208
207
  },
209
208
 
210
- {
211
- name: 'RDF 1.2 Turtle annotations lower to rdf/3 facts',
212
- run: () => {
213
- const source = 'VERSION "1.2"\nPREFIX : <http://example.com/>\nPREFIX xsd: <http://www.w3.org/2001/XMLSchema#>\n:alice :name "Alice" ~ :t {| :statedBy :bob ; :recorded "2021-07-07"^^xsd:date |} .\n';
214
- const actual = rdfToEyelang(source, { materializeRdf: false });
215
- assertEqual(actual, [
216
- 'rdf(iri("http://example.com/alice"), iri("http://example.com/name"), literal("Alice", iri("http://www.w3.org/2001/XMLSchema#string"), "", "")).\n',
217
- 'rdf(iri("http://example.com/t"), iri("http://www.w3.org/1999/02/22-rdf-syntax-ns#reifies"), triple(iri("http://example.com/alice"), iri("http://example.com/name"), literal("Alice", iri("http://www.w3.org/2001/XMLSchema#string"), "", ""))).\n',
218
- 'rdf(iri("http://example.com/t"), iri("http://example.com/statedBy"), iri("http://example.com/bob")).\n',
219
- 'rdf(iri("http://example.com/t"), iri("http://example.com/recorded"), literal("2021-07-07", iri("http://www.w3.org/2001/XMLSchema#date"), "", "")).\n',
220
- ].join(''), 'rdfToEyelang');
221
- },
222
- },
223
- {
224
- name: 'Notation3 rules materialize derived RDF triples',
225
- run: () => {
226
- const source = '@prefix : <http://example.com/> .\n{ ?x :parent ?y . } => { ?x :related ?y . } .\n:alice :parent :bob .\n';
227
- const actual = run(source, { inputFormat: 'n3' }).stdout;
228
- assertEqual(actual, 'rdf(iri("http://example.com/alice"), iri("http://example.com/related"), iri("http://example.com/bob")).\n', 'stdout');
229
- },
230
- },
231
- {
232
- name: '--rdf reads RDF 1.2 / N3 compatibility input',
233
- run: () => {
234
- const source = '@prefix : <http://example.com/> .\n{ ?x :parent ?y . } => { ?x :related ?y . } .\n:alice :parent :bob .\n';
235
- const result = runCli(['--rdf', '-'], { input: source });
236
- assertEqual(result.status, 0, 'exit status');
237
- assertEqual(result.stdout, 'rdf(iri("http://example.com/alice"), iri("http://example.com/related"), iri("http://example.com/bob")).\n', 'stdout');
238
- assertEqual(result.stderr, '', 'stderr');
239
- },
240
- },
241
-
242
- {
243
- name: 'Notation3 <= rules and builtins materialize derived RDF triples',
244
- run: () => {
245
- const source = '@prefix : <http://example.com/> .\n@prefix math: <http://www.w3.org/2000/10/swap/math#> .\n{ ?x :ok true . } <= { (2 3) math:sum ?n . ?n math:equalTo 5 . ?x :seed true . } .\n:case :seed true .\n';
246
- const actual = run(source, { inputFormat: 'n3' }).stdout;
247
- assertEqual(actual, 'rdf(iri("http://example.com/case"), iri("http://example.com/ok"), literal("true", iri("http://www.w3.org/2001/XMLSchema#boolean"), "", "")).\n', 'stdout');
248
- },
249
- },
250
-
251
- {
252
- name: 'bundled RDF 1.2 / N3 examples match golden output',
253
- run: () => {
254
- const dir = path.join(packageRoot, 'examples', 'eyelang');
255
- const files = fs.readdirSync(dir)
256
- .filter((name) => name.endsWith('.n3') || name.endsWith('.ttl'))
257
- .sort();
258
- assertEqual(files.length > 0, true, 'rdf example files exist');
259
- for (const name of files) {
260
- const result = runCli([path.join('examples', 'eyelang', name)]);
261
- assertEqual(result.status, 0, `${name} exit status`);
262
- assertEqual(result.stderr, '', `${name} stderr`);
263
- const expected = fs.readFileSync(path.join(dir, 'output', name), 'utf8');
264
- assertEqual(result.stdout, expected, `${name} stdout`);
265
- }
266
- },
267
- },
268
-
269
-
270
209
  {
271
210
  name: '--proof enables materialization explanations',
272
211
  run: () => {
@@ -1,17 +1,20 @@
1
1
  // Shared test output helpers.
2
2
  // The runners use this small reporter so individual suites and `npm test` share
3
- // one compact, Eyesharl-like style with a continuous grey test number.
3
+ // one compact Eyeling-style layout: colored OK/FAIL, sequence number, test description, and dimmed timing.
4
4
  import process from 'node:process';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import path from 'node:path';
7
7
 
8
- const useColor = Boolean(process.stdout.isTTY) && process.env.NO_COLOR == null;
8
+ const useColor = process.env.NO_COLOR == null && (
9
+ Boolean(process.stdout.isTTY) ||
10
+ Boolean(process.env.FORCE_COLOR && process.env.FORCE_COLOR !== '0')
11
+ );
9
12
 
10
13
  export const colors = {
11
14
  green: useColor ? '\x1b[32m' : '',
12
15
  red: useColor ? '\x1b[31m' : '',
13
16
  yellow: useColor ? '\x1b[33m' : '',
14
- grey: useColor ? '\x1b[90m' : '',
17
+ dim: useColor ? '\x1b[2m' : '',
15
18
  reset: useColor ? '\x1b[0m' : '',
16
19
  };
17
20
 
@@ -45,7 +48,7 @@ export class TestReporter {
45
48
  const total = this.total - this.currentSection.totalAtStart;
46
49
  const ms = nowMs() - this.currentSection.startedAt;
47
50
  const suite = label ?? defaultSectionLabel(this.currentSection.name);
48
- this.stdout.write(`${colors.green}OK${colors.reset} ${ok}/${total} ${suite} tests passed ${colors.grey}(${ms} ms)${colors.reset}\n`);
51
+ this.stdout.write(`${colors.green}OK${colors.reset} ${ok}/${total} ${suite} tests passed ${colors.dim}(${ms} ms)${colors.reset}\n`);
49
52
  }
50
53
 
51
54
  test(name, run) {
@@ -57,10 +60,10 @@ export class TestReporter {
57
60
  run();
58
61
  const ms = nowMs() - startedAt;
59
62
  this.ok++;
60
- this.stdout.write(`${colors.grey}${nr}${colors.reset} ${colors.green}OK${colors.reset} ${name} ${colors.grey}(${ms} ms)${colors.reset}\n`);
63
+ this.stdout.write(`${colors.green}OK${colors.reset} ${nr} ${name} ${colors.dim}(${ms} ms)${colors.reset}\n`);
61
64
  } catch (error) {
62
65
  const ms = nowMs() - startedAt;
63
- this.stderr.write(`${colors.grey}${nr}${colors.reset} ${colors.red}FAIL${colors.reset} ${name} ${colors.grey}(${ms} ms)${colors.reset}\n`);
66
+ this.stderr.write(`${colors.red}FAIL${colors.reset} ${nr} ${name} ${colors.dim}(${ms} ms)${colors.reset}\n`);
64
67
  this.stderr.write(`${error?.stack ?? String(error)}\n`);
65
68
  throw error;
66
69
  }
@@ -69,7 +72,7 @@ export class TestReporter {
69
72
  totalLine() {
70
73
  const ms = nowMs() - this.startedAt;
71
74
  this.stdout.write(`\n${colors.yellow}== Total${colors.reset}\n`);
72
- this.stdout.write(`${colors.green}OK${colors.reset} ${this.ok}/${this.total} tests passed ${colors.grey}(${ms} ms)${colors.reset}\n`);
75
+ this.stdout.write(`${colors.green}OK${colors.reset} ${this.ok}/${this.total} tests passed ${colors.dim}(${ms} ms)${colors.reset}\n`);
73
76
  }
74
77
  }
75
78
 
@@ -47,7 +47,7 @@ out(X) :- in(X).
47
47
  assert.match(directCli.stdout, /ancestor\(jan, emma\)\./);
48
48
 
49
49
  // Sanity check the ESM file URL too; this catches nested package type regressions.
50
- const esm = await import(pathToFileURL(`${process.cwd()}/lib/eyelang/index.mjs`).href);
50
+ const esm = await import(pathToFileURL(`${process.cwd()}/lib/eyelang/index.js`).href);
51
51
  assert.equal(typeof esm.Program, 'function');
52
52
 
53
53
  pass(1, 'eyelang second-engine integration passed', Date.now() - startedAt);