Registry / web-framework / krl-compiler

krl-compiler

JSON →
library1.3.0jsnpmunverified

The krl-compiler package (v1.3.0, stable, low release cadence) is a compiler that converts KRL (Kinetic Rule Language, used in the Pico Labs ecosystem) to JavaScript. It supports both programmatic API and CLI usage. Key differentiators: synchronous compilation, optional AST input, inline source maps, and a --verify flag for validation. Unlike general-purpose compilers, it is specialized for KRL rulesets targeting the pico-engine runtime.

npm install krl-compiler
INSTALL
IMPORT
SIG · KRL-COMPILER
K
krl-compiler
web-frameworkjavascriptv1.3.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 export
import compile from 'krl-compiler'
const { compile } = require('krl-compiler')
The module exports a single function directly. Default import is correct in ESM.
CommonJS require
const compile = require('krl-compiler')
const compile = require('krl-compiler').compile
In CJS, the module.exports is the compile function directly, not an object with a compile property.
CLI usage
krl-compiler < input.krl > output.js
krl-compiler input.krl output.js
The CLI uses stdin/stdout piping, not positional arguments.

Demonstrates basic programmatic usage: importing the compiler and converting KRL source to JavaScript.

const compile = require('krl-compiler'); const krlCode = ` ruleset a8x138 { meta { name "Hello World" description "A simple KRL ruleset" author "Pico Labs" } rule hello { select when echo hello send_directive("say") with something = "Hello World"; } } `; try { const jsCode = compile(krlCode); console.log(jsCode); } catch (err) { console.error('Compilation failed:', err.message); }
krl-compiler --version
Debug
Known issues
gotchaThe compile function throws synchronous errors for invalid KRL input.
fix
Wrap calls in try/catch blocks.
affects: >=1.0.0
deprecatedThe --no-source-map option is deprecated in favor of --no-inline-source-map.
fix
Use --no-inline-source-map instead.
affects: >=1.2.0
breakingAs of v1.0.0, the module is ESM-only; require() is not supported.
fix
Use import or switch to dynamic import().
affects: >=1.0.0
gotchaCLI output includes an inline source map by default, which may bloat the output.
fix
Use --no-source-map to omit it.
affects: >=0.5.0
Errors
Common errors & fixes
TypeError: compile is not a function
Importing the module incorrectly (e.g., treating as named export).
fix
Use default import: import compile from 'krl-compiler' or const compile = require('krl-compiler').
Cannot find module 'krl-compiler'
Package not installed or incorrect version resolution.
fix
Run npm install krl-compiler and ensure it's in node_modules.
Unexpected token: keyword 'ruleset'
Invalid KRL syntax passed to compile.
fix
Validate KRL code before compilation; use --verify flag for CLI.
Upgrade
Version history
1.3.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
krl-compiler — npm install krl-compiler · libregistry