Command-line interface for Kordex.
Kordex is a JavaScript runtime for reliable local-first applications. This module provides the kordex command used to initialize projects, run scripts, evaluate code, check files, bundle projects, manage packages, and expose project plugin commands.
- Run JavaScript and TypeScript files
- Evaluate JavaScript with
repl --eval - Resolve project entry from
kordex.jsonorpackage.json - Support relative imports and JSON modules
- Support standard modules such as
kordex:path,kordex:fs,kordex:env, andkordex:process - Bundle projects into
dist/main.js - Generate basic source maps
- Enforce runtime permissions
- Load plugin commands from project configuration
- Generate and update
kordex.lock
kordex init <name>
kordex run [file]
kordex repl --eval <source>
kordex check <file>
kordex build <file|project>
kordex install [package[@version]]
kordex update [package]
kordex version
kordex helpCreate a project:
kordex init app
cd appRun a file:
kordex run src/main.jsRun the project entry from kordex.json:
kordex runEvaluate code directly:
kordex repl --eval "1 + 2"Build a project:
kordex build . --project --out-dir dist --forceKordex looks for kordex.json first, then package.json.
Example kordex.json:
{
"name": "my-app",
"version": "0.1.0",
"entry": "src/main.ts",
"registry": "https://registry.vixcpp.com",
"dependencies": {
"kordex/std": "0.1.0"
},
"scripts": {
"dev": "kordex run src/main.ts",
"build": "kordex build . --project"
}
}Run JavaScript:
kordex run main.jsRun TypeScript:
kordex run main.tsRun the project entry:
kordex runThe CLI resolves the entry from:
kordex.jsonentrypackage.jsonkordexpackage.jsonmodulepackage.jsonmain- fallback files such as
src/main.ts,src/main.js,index.ts, orindex.js
Relative imports are supported:
import { message } from "./lib/message.js";
message;Extension resolution is supported:
import { message } from "./lib/message";Directory index resolution is supported:
import { name } from "./pkg";JSON imports are supported:
import user from "./data/user.json";
user.name;Kordex standard modules can be imported with the kordex: prefix.
Example:
import { join } from "kordex:path";
join("/tmp", "kordex", "app");Some modules require explicit permissions.
Sensitive modules are disabled by default.
Available permission flags:
--allow-fs--allow-env--allow-net--allow-process
Example:
kordex run main.js --allow-fsWithout --allow-fs, this script fails:
import { exists } from "kordex:fs";
exists("/tmp");With permission:
kordex run main.js --allow-fsBundle one file:
kordex build main.js --out-dir dist --forceBundle a project:
kordex build . --project --out-dir dist --forceChoose output file:
kordex build . --project --out-dir dist --out-file app.js --forceGenerate source map:
kordex build . --project --source-map --forceThis generates:
dist/main.js
dist/main.js.map
Install dependencies declared in kordex.json:
kordex installInstall one package:
kordex install softadastra/plugin-example@0.1.0Use a custom registry:
kordex install --registry https://registry.vixcpp.comThe command writes:
kordex.lock
Update all dependencies:
kordex updateUpdate one dependency:
kordex update softadastra/plugin-exampleKordex can load project plugin commands from kordex.json.
Example:
{
"plugins": {
"commands": [
{
"name": "hello",
"summary": "Run hello plugin",
"run": "scripts/hello.ts",
"aliases": ["hi"],
"permissions": {
"fs": false,
"env": false,
"net": false,
"process": false
}
}
]
}
}Then:
kordex helloor:
kordex hiPlugin commands are loaded with isolated permissions. They cannot override built-in commands.
| Option | Description |
|---|---|
-h, --help |
Show help |
-V, --version |
Show version |
-v, --verbose |
Enable verbose output |
--debug |
Enable debug output |
-q, --quiet |
Disable normal output |
--json |
Render machine-readable JSON output |
--no-color |
Disable colored output |
--dry-run |
Show what would happen without executing |
From the module directory:
vix build --preset dev-ninjaWith tests:
vix build \
--preset dev-ninja \
-- \
-DKORDEX_CLI_BUILD_TESTS=ON
vix tests -- --output-on-failureThe CLI integration test covers:
kordex runkordex repl --eval- relative imports
- JSON imports
- standard modules
- build output
- permissions
Run:
vix tests -R kordex_cli_integration_testskordex-cli is the user-facing command layer.
It connects:
kordex-runtimefor runtime options, project execution model, and permissionskordex-bindingsfor JavaScript engine executionkordex-stdfor native standard modules- project discovery for
kordex.jsonandpackage.json - package lock generation through
kordex.lock
MIT License.