Registry / ai-ml / benoit

benoit

JSON →
library0.8.0jsnpmunverified

Benoît is a self-interpreting, self-evolving, self-proving programming language where every line is simultaneously code, test, proof, and documentation. Version 0.8.0 runs .ben files natively via a Pratt parser and tree-walking evaluator (zero eval, zero new Function), offers 68% token reduction compared to equivalent JavaScript, and includes a genetic algorithm (evolve.mjs) that discovers functions from assertions alone with 80% success rate. Active development with monthly releases, it targets Node >=18 and focuses on human-AI collaboration, pattern matching with guards, pipes, async/await, and a built-in property inference engine that detects 31 mathematical properties automatically. Unlike traditional languages, there is no separation between code, tests, and documentation.

npm install benoit
INSTALL
IMPORT
SIG · BENOIT
B
benoit
ai-mljavascriptv0.8.0
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import benoit from 'benoit'
const benoit = require('benoit')
ESM-only since v0.4.0. Default export is the transpiler/interpreter function.
runBen
import { runBen } from 'benoit'
import { run_ben } from 'benoit'
Function to run .ben strings or files. Exported as runBen (camelCase), not run_ben.
transpile
import { transpile } from 'benoit'
import { compile } from 'benoit'
Transpiles Benoît code to JavaScript. compile was removed in v0.5.0.
EvolveMachine
import { EvolveMachine } from 'benoit'
import { evolve } from 'benoit'
Class for the self-programming machine. evolve is a CLI script (evolve.mjs), not a library export.

Shows how to run Benoît code inline via runBen, verifying assertions directly from a string. The language ships with full TypeScript definitions.

import { runBen } from 'benoit'; const code = ` fib n -> n < 2? -> n else? -> fib(n - 1) + fib(n - 2) fib(0) is 0 fib(5) is 5 fib(10) is 55 `; runBen(code).then(({ passed, total }) => { console.log(`Passed ${passed}/${total} assertions.`); }).catch(err => console.error(err));
benoit --version
Debug
Known issues
breakingv0.4.0 dropped CommonJS support; package is ESM-only.
fix
Use import syntax instead of require(). Update Node to >=12 and set "type": "module" in package.json.
affects: >=0.4.0
breakingv0.5.0 renamed compile API to transpile.
fix
Replace compile with transpile in imports. compile is no longer exported.
affects: >=0.5.0
breakingv0.6.0 changed default export from a parse function to a multi-purpose transformer.
fix
If using default import, adjust usage to new shape. Use named exports for specific operations.
affects: >=0.6.0
deprecatedevalBen function deprecated since v0.7.0; use runBen instead.
fix
Replace evalBen with runBen. evalBen remains for backward compatibility but will be removed in next major.
affects: >=0.7.0
gotchaPattern-matching guards use 'when' keyword; 'if' is not valid inside patterns.
fix
Use 'when condition ->' inside alt patterns, not 'if condition ->'.
affects: >=0.3.0
gotchaToken-reduction measurement is for transpiled JS, not for performance; no benchmarks guarantee speed improvement.
fix
Do not assume Benoît code runs faster; it is a syntactic compaction tool.
affects: >=0.3.0
Errors
Common errors & fixes
Error [ERR_REQUIRE_ESM]: require() of ES Module not supported
Package is ESM-only since v0.4.0; using require() in a CJS context.
fix
Use dynamic import or switch to ESM: import benoit from 'benoit'.
TypeError: benoit.compile is not a function
compile was renamed to transpile in v0.5.0.
fix
Use import { transpile } from 'benoit' instead.
SyntaxError: Unexpected token (0:22) - '?' is not valid at this position
Using '?' as a condition marker in a pattern without proper alt branch syntax.
fix
Ensure guard '?' follows the pattern arrow correctly: pattern -> guard? -> expr.
Error: runBen expects a string or a file path, got object
runBen requires a string of code or a .ben file path.
fix
Call runBen with a string or a path, not an options object.
Upgrade
Version history
0.8.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
17 hits · last 30 days
node
14
Amazon
1
OpenAI (training)
1
Resources