Getting Started
Configure a default engine, run scripts, and use the package manager.
Configuration
o- reads its engine choice from:
~/.config/o-/config.tomlExample:
[toolchain]
name = "spidermonkey"Supported built-in engine names:
spidermonkeyv8javascriptcoreorjscon macOS
Run a Script
From the repository root:
cargo run -- run index.jsThe run command reads the file and executes it with the selected engine.
Script Example
function memoize(fn) {
const cache = {};
return function (n) {
if (n in cache) return cache[n];
cache[n] = fn(n);
return cache[n];
};
}
const fib = memoize(function (n) {
return n < 2 ? n : fib(n - 1) + fib(n - 2);
});
console.log(fib(50));CLI Shape
Current commands:
o- run <path>
o- install
o- install --global <package>
o- uninstall <package>
o- toolchain add <user> <repo>
o- toolchain remove <toolchain>install reads the nearest project package.json. install --global installs
from the npm registry into the global package root.
Toolchain Selection
The runner supports three backends:
spidermonkeyjavascriptcorev8
The selected toolchain string is passed into the core dispatcher, which maps:
javascriptcoreorjsc-> JavaScriptCorev8-> V8spidermonkeyor empty string -> SpiderMonkey
Shared Built-ins
All engines load the shared jstd bootstrap before your script runs. That is
where the common JS surface is defined.
Currently documented shared built-ins include:
console.log(...)console.info(...)console.warn(...)console.error(...)console.debug(...)console.trace(...)console.assert(...)console.count(...)console.countReset(...)console.time(...)console.timeLog(...)console.timeEnd(...)console.group(...)console.groupCollapsed(...)console.groupEnd()print(...)println(...)
Errors
Runtime errors are formatted by the shared core crate and include:
- error kind
- filename when available
- a short source snippet
- ANSI color when the terminal supports it
Color is disabled automatically when NO_COLOR is set or when TERM=dumb.
Package-manager errors use the same Report style, so install and uninstall
failures print a short summary followed by concrete details such as paths,
package names, and IO causes.