{"id":25844,"library":"krl-compiler","title":"krl-compiler","description":"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.","status":"maintenance","version":"1.3.0","language":"javascript","source_language":"en","source_url":"https://github.com/Picolab/pico-engine","tags":["javascript","pico-engine","krl","compiler"],"install":[{"cmd":"npm install krl-compiler","lang":"bash","label":"npm"},{"cmd":"yarn add krl-compiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add krl-compiler","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The module exports a single function directly. Default import is correct in ESM.","wrong":"const { compile } = require('krl-compiler')","symbol":"default export","correct":"import compile from 'krl-compiler'"},{"note":"In CJS, the module.exports is the compile function directly, not an object with a compile property.","wrong":"const compile = require('krl-compiler').compile","symbol":"CommonJS require","correct":"const compile = require('krl-compiler')"},{"note":"The CLI uses stdin/stdout piping, not positional arguments.","wrong":"krl-compiler input.krl output.js","symbol":"CLI usage","correct":"krl-compiler < input.krl > output.js"}],"quickstart":{"code":"const compile = require('krl-compiler');\n\nconst krlCode = `\n  ruleset a8x138 {\n    meta {\n      name \"Hello World\"\n      description \"A simple KRL ruleset\"\n      author \"Pico Labs\"\n    }\n    rule hello {\n      select when echo hello\n      send_directive(\"say\") with\n        something = \"Hello World\";\n    }\n  }\n`;\n\ntry {\n  const jsCode = compile(krlCode);\n  console.log(jsCode);\n} catch (err) {\n  console.error('Compilation failed:', err.message);\n}","lang":"javascript","description":"Demonstrates basic programmatic usage: importing the compiler and converting KRL source to JavaScript."},"warnings":[{"fix":"Wrap calls in try/catch blocks.","message":"The compile function throws synchronous errors for invalid KRL input.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use --no-inline-source-map instead.","message":"The --no-source-map option is deprecated in favor of --no-inline-source-map.","severity":"deprecated","affected_versions":">=1.2.0"},{"fix":"Use import or switch to dynamic import().","message":"As of v1.0.0, the module is ESM-only; require() is not supported.","severity":"breaking","affected_versions":">=1.0.0"},{"fix":"Use --no-source-map to omit it.","message":"CLI output includes an inline source map by default, which may bloat the output.","severity":"gotcha","affected_versions":">=0.5.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use default import: import compile from 'krl-compiler' or const compile = require('krl-compiler').","cause":"Importing the module incorrectly (e.g., treating as named export).","error":"TypeError: compile is not a function"},{"fix":"Run npm install krl-compiler and ensure it's in node_modules.","cause":"Package not installed or incorrect version resolution.","error":"Cannot find module 'krl-compiler'"},{"fix":"Validate KRL code before compilation; use --verify flag for CLI.","cause":"Invalid KRL syntax passed to compile.","error":"Unexpected token: keyword 'ruleset'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}