pkl-cli 0.33.1

Product `pkl` CLI binary for Apple Pkl 0.33.1
Documentation
# pkl-rs

A pure-Rust implementation of **[Apple Pkl 0.33.1](https://pkl-lang.org/)** — zero Java runtime required, `unsafe_code = "deny"` across the entire workspace, and a single shared evaluation engine powering native CLI tools, a Rust library, WebAssembly, and Node.js N-API bindings.

> [!NOTE]
> **General Availability (`0.33.1`)**: Language, standard library, CLI, `pkldoc`, Rust API (`pkl-lang`), `@openedges/pkl-wasm`, `@openedges/pkl-napi`, 3-browser Playwright verification (`chromium`, `firefox`, `webkit`), and Official Apple Pkl `0.33.1` `native-image` + Temurin 21 performance parity have been verified locally on macOS `arm64`. Cross-platform 7-target hosted CI artifacts and `ci-attestation.json` are generated by [.github/workflows/release.yml](.github/workflows/release.yml) when tagging `v0.33.1`. See [CHANGELOG.md](CHANGELOG.md) and [docs/development-history.md](docs/development-history.md) for exact verification scope.

## Products & Capabilities

- **`pkl` CLI & `pkldoc`** (`crates/pkl-cli`, `crates/pkl-doc`): Drop-in native binaries (~13–14 MiB) supporting `eval`, `repl`, `server`, `test`, `project resolve`, `project package`, `download-package`, `analyze imports`, `format`, `run`, `shell-completion`, and HTML documentation generation (`pkldoc`).
- **Rust Evaluator API** (`crates/pkl`): Ergonomic embedding API (`Evaluator`, `EvaluatorBuilder`, `ModuleSource`, `PklValue`/`FromPklValue`, `ModuleSchema`, `Project`, `Analyzer`, `SecurityManager`, `HttpClient`, custom `ModuleKeyFactory`/`ResourceReader`, cancellation, and timeouts).
- **Node.js Native Addon** (`@openedges/pkl-napi`): Dual ESM/CJS bindings with TypeScript types, non-blocking libuv worker threads (`Promise`) plus `*Sync` APIs, full native Host I/O (filesystem, HTTP/HTTPS, `PklProject`, `package:`, external readers), and custom JS extensions across 7 target platforms.
- **WebAssembly Package** (`@openedges/pkl-wasm`): Browser and Node.js ESM package (`<= 2.50 MiB` gzip-9 `.wasm`), pure-Wasm `VirtualFileSystem`, cooperative async Host callbacks, `createRepl()`, `analyzeImportGraph()`, `evaluateSchema()`, `evaluateTest()`, `format()`, and lossless `decodePklBinary()`.
- **Full Pkl `0.33.1` Core**: All 25 `pkl:*` standard library modules (588 builtins, including `pkl:net` and `pkl:syntax`), generic methods, `This` self types, all 9 renderers (`pcf`, `json`, `yaml`, `xml`, `properties`, `plist`, `jsonnet`, `textproto`, `pkl-binary`), `output.bytes`, `output.files`, `pkl:test`, and `pkl:Command`.

## Installation

For full platform matrices, checksum verification, shell completions, and build options, see [docs/installation.md](docs/installation.md).

### Homebrew (macOS & Linux)

```sh
brew install openedges/tap/pkl-rs
pkl --version
pkldoc --version
```

*(Installs both `pkl` and `pkldoc`, bundled license/notices, and `bash`/`zsh`/`fish` shell completions.)*

### Prebuilt CLI Binaries (`pkl` & `pkldoc`)

Download the archive for your platform from [GitHub Releases](https://github.com/openedges/pkl-rs/releases), verify against `SHA256SUMS.txt`, and place `pkl` / `pkldoc` on your `PATH`:

```sh
# Example: macOS Apple Silicon (replace version/target for your platform)
curl -fSLO https://github.com/openedges/pkl-rs/releases/download/v0.33.1/pkl-darwin-arm64.tar.gz
curl -fSLO https://github.com/openedges/pkl-rs/releases/download/v0.33.1/SHA256SUMS.txt
shasum -a 256 --check --ignore-missing SHA256SUMS.txt
tar -xzf pkl-darwin-arm64.tar.gz
./pkl --version
```

Supported prebuilt CLI targets:
- **Linux (`x64`, `arm64`)**: portable glibc `>= 2.28` (`*-gnu.tar.gz`) and static musl (`*-musl.tar.gz`)
- **macOS (`arm64`, `x64`)**: `*-darwin-{arm64,x64}.tar.gz`
- **Windows (`x64`)**: `*-win32-x64.zip`

### Rust Crates (`crates.io`)

```toml
[dependencies]
pkl-lang = "0.33.1"   # Imports as `use pkl::...;`
```

Or install CLI binaries from crates.io:

```sh
cargo install pkl-cli --version 0.33.1
cargo install pkl-doc --version 0.33.1
```

### Node.js (`@openedges/pkl-napi`) & WebAssembly (`@openedges/pkl-wasm`)

```sh
# Node.js native bindings (Node >= 18, full native Host I/O)
npm install @openedges/pkl-napi

# Browser & Node.js WebAssembly bindings (Node >= 20.16, sandboxed VFS + async Host)
npm install @openedges/pkl-wasm
```

*(GA `0.33.1` publishes under the npm `latest` dist-tag via [.github/workflows/release.yml](.github/workflows/release.yml); prereleases use `next`. To build local tarballs from source, see [docs/installation.md](docs/installation.md).)*

### Build from Source

Requires Git and [rustup](https://rustup.rs/) (toolchain pinned to `1.98.1` in [rust-toolchain.toml](rust-toolchain.toml)):

```sh
git -c core.autocrlf=false clone https://github.com/openedges/pkl-rs.git
cd pkl-rs
cargo build --release --locked -p pkl-cli --bin pkl -p pkl-doc --bin pkldoc
./target/release/pkl --version
```

*(Building `pkl` and `pkldoc` does not require initializing the upstream test submodules. For contributor verification and Java differential testing, initialize submodules with `git -c core.autocrlf=false submodule update --init --recursive`.)*

## Quick Start

### CLI

```sh
# Evaluate Pkl source to JSON
printf 'name = "pkl-rs"\nport = 8080\n' | pkl eval -f json -

# Format Pkl files and run Pkl tests
pkl format config.pkl
pkl test tests.pkl

# Generate HTML documentation
pkldoc -o docs-out/ docsite-info.pkl PklProject
```

### Rust API (`crates/pkl`)

```rust
use pkl::{Evaluator, ModuleSource};

fn main() -> pkl::Result<()> {
    let mut evaluator = Evaluator::preconfigured()?;
    let source = ModuleSource::text(r#"
        name = "pkl-rs"
        port = 8080
    "#);
    let output = evaluator.evaluate_output_text(&source)?;
    println!("{output}");
    evaluator.close();
    Ok(())
}
```

### Node.js (`@openedges/pkl-napi`)

```js
import { createEvaluator, ModuleSource } from '@openedges/pkl-napi';

const evaluator = await createEvaluator({ outputFormat: 'json' });
try {
  const json = await evaluator.evaluateOutputText(
    ModuleSource.text('name = "pkl-rs"\nport = 8080\n'),
  );
  console.log(json);
} finally {
  await evaluator.close();
}
```

### Browser & Node.js (`@openedges/pkl-wasm`)

```js
import { init, createEvaluator, ModuleSource, VirtualFileSystem } from '@openedges/pkl-wasm';

await init(); // Required once in browsers; optional in Node.js

const vfs = new VirtualFileSystem(
  { '/app/config.pkl': 'name = "pkl-wasm"\nport = 8080\n' },
  { rootDir: '/app' },
);
const evaluator = await createEvaluator({ vfs, outputFormat: 'json' });
try {
  console.log(await evaluator.evaluateOutputText(ModuleSource.path('/app/config.pkl')));
} finally {
  evaluator.close();
}
```

## Compatibility & Performance

- **Compatibility baseline**: Targets **Apple Pkl `0.33.1`** raw-byte output, diagnostics, source positions, generated files, and exit codes. Java/Kotlin code generation (`pkl-codegen-java`, `pkl-codegen-kotlin`) and JVM public API adapters are explicitly excluded from scope ([INTENT.md](INTENT.md)).
- **Performance (local macOS `arm64`, pinned `rustc 1.98.1`, 100% raw-byte parity)**: All **15 / 15** CLI, server, and `pkldoc` workloads pass at **`0.054x–0.833x` execution time** and **`0.140x–0.733x` peak RSS** against Official Apple Pkl `0.33.1` `native-image`, all **34 / 34** native, N-API, and Wasm workloads pass against pinned Temurin `21.0.13.1+2-LTS` (`0.012x–0.786x` time, `0.038x–0.981x` non-browser peak RSS; `10 / 10` across Chromium, Firefox, WebKit, and Node.js), and all **18 / 18** Core-6 workloads pass against archived M0 GraalVM CE `25.0.1`. `@openedges/pkl-wasm` compiles (`--no-default-features`) to **`1.91 MiB` (`2,001,646 B`) gzip-9** (`<= 2.50 MiB` budget).

| Target / Suite | Representative Workload | `pkl-rs` (`0.33.1`) | Reference (`0.33.1`) | Speed vs. Ref | Memory (`pkl-rs` vs. Ref) | `0.33.1` Opt Gain |
| --- | --- | ---: | ---: | ---: | --- | --- |
| **Native CLI** vs. Official `native-image` | M7 15-workload suite (`15/15` PASS) | `8.46–49.41 ms` (`server` `76.6 us`) | `22.38–346.98 ms` (`server` `283.3 us`) | **1.2x–18.6x faster** (`0.054x–0.833x`) | `3.4–21.8 MiB` (`0.140x–0.733x` RSS) | `pkldoc` **1.80x**, `renderers-files` **2.05x**, `formatter` **1.76x** |
| **Rust API** vs. Temurin 21 JVM | `large-output` (`persistent` / `fresh`) | `692.6 us` / `742.0 us` | `1.83 ms` / `2.14 ms` | **2.6x–2.9x faster** (`0.346x–0.379x`) | `0.071x–0.086x` RSS | **2.11x–2.13x faster** (`1.46→0.69 ms`) |
| **`@openedges/pkl-napi`** vs. Temurin 21 JVM | `eval-text` / `typed-conversion` | `40.5 us` / `5.84 us` | `214.3 us` / `48.9 us` | **5.3x–8.4x faster** (`0.119x–0.189x`) | `77.5` / `139.0 MiB` (`0.345x` / `0.881x` incl. Node) | `typed-conversion` **2.90x faster** (`16.9→5.8 us`) |
| **`@openedges/pkl-wasm`** (Node + 3 browsers) | `eval-text` / `typed-conversion` | `58.3–74.1 us` / `4.37–8.83 us` | `214.3 us` / `48.9 us` | **2.9x–11.2x faster** (`0.089x–0.346x`) | **`3.8–4.0 MiB`** Wasm linear mem (`1.91 MiB` gzip-9) | `eval-text` **-47% lin mem**, **1.33x–1.70x faster** |
| **Synthetic Scale CLI** (`--suite scale`, `6/7` NI) | `yaml-config-translate` / `reactive-schema` | `29.8 ms` / `45.0–48.6 ms` | `30.1 ms` / `56.8–58.5 ms` (NI) | **1.01x–1.28x faster** (`0.782x–0.990x`) | `39.5–47.9 MiB` (`0.453x–0.782x` NI RSS) | YAML **10.09x faster / 9.85x less RSS**; DAG **2.01x** (`1.787x` NI gap) |
| **Synthetic Scale JS/Wasm** (`scale` 3-browser) | `reactive-schema-js` / `yaml-translate-js` | N-API `21.5` / `10.0 ms`; Wasm `38–58` / `17–30 ms` | `56.8` / `30.1 ms` (NI CLI) | N-API **2.8x**, Wasm **1.3x–1.6x** faster (excl. Firefox) | **`15.3–24.5 MiB`** Wasm linear mem | YAML Wasm **6.4x–6.8x faster / 25x less lin mem** |

- Full milestone metrics, differential test counts, soak/fuzz records, and raw evidence archives are preserved separately in [docs/development-history.md](docs/development-history.md).

## Testing & Verification

Standard Rust checks:

```sh
cargo xtask verify
cargo fmt --all -- --check
cargo clippy --workspace --all-targets --locked -- -D warnings
cargo test --workspace --locked
cargo check -p pkl-runtime -p pkl-formatter -p pkl-wasm --target wasm32-unknown-unknown --locked
```

Unified local verification runner (covering Rust workspace, manifests, Python unit tests, platform Node.js tests, standalone npm packages, M0–M6 Java `0.33.1` differential suites, and M7 fuzz/soak/benchmark suites):

```sh
python3 tools/local_verify.py --list
python3 tools/local_verify.py --preset quick
python3 tools/local_verify.py --preset full-strict --local-checkpoint
```

See [TESTING.md](TESTING.md) for the complete verification contract and [docs/ci.md](docs/ci.md) for the GitHub Actions vs. local verification split.

## Versioning

All distributable components (`Cargo.toml` workspace crates, `pkl`/`pkldoc` binaries, `@openedges/pkl-wasm`, `@openedges/pkl-napi`, and Git release tags) follow a unified `0.33.1` versioning policy aligned with the Apple Pkl compatibility baseline. See [docs/versioning.md](docs/versioning.md) and [CHANGELOG.md](CHANGELOG.md).

## Documentation

| Category | Document | Description |
| --- | --- | --- |
| **Users & Release** | [docs/installation.md](docs/installation.md) | Prebuilt binaries, checksum verification, npm packages, source builds |
| | [docs/versioning.md](docs/versioning.md) | Versioning, branch & tag policy, upgrade rules, release checklist |
| | [CHANGELOG.md](CHANGELOG.md) | User-facing release notes and known pre-release boundaries |
| | [SECURITY.md](SECURITY.md) | Vulnerability reporting and Pkl security boundaries |
| | [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md) | Embedded assets, Unicode 15.0.0 UCD data, and crate licenses |
| **Contributors** | [CONTRIBUTING.md](CONTRIBUTING.md) | Development workflow, principles, and PR guidelines |
| | [TESTING.md](TESTING.md) | Complete test inventory and compatibility verification contract |
| | [docs/ci.md](docs/ci.md) | GitHub Actions CI/Release workflows and `local_verify.py` suites |
| | [docs/architecture.md](docs/architecture.md) | Engine, VM, heap, Host, and cross-target architecture |
| | [docs/oracle.md](docs/oracle.md) | Bootstrapping pinned JVM, Native Image, and GraalVM oracles |
| **History & Roadmap** | [docs/development-history.md](docs/development-history.md) | M0–M7 milestone checkpoints, metrics, and evidence archives |
| | [docs/README.md](docs/README.md) | Complete index of all repository documentation |
| | [INTENT.md](INTENT.md) | Project goals, scope, and performance requirements |
| | [PLAN.md](PLAN.md) | Roadmap, execution plan, and work status (Korean) |

## License & Trademarks

`pkl-rs` is licensed under the [Apache License, Version 2.0](LICENSE) (Copyright 2025–2026 The pkl-rs Authors).

`pkl-rs` is an independent open-source project and is not affiliated with, sponsored by, or endorsed by Apple Inc. "Pkl" is a trademark or product name of Apple Inc., referenced solely to describe language and specification compatibility.

Attribution and third-party notices for embedded Apple Pkl `0.33.1` standard library modules, `pkldoc` web assets/fonts, FDLIBM, SnakeYAML Engine, TimSort, Unicode 15.0.0 UCD data, and statically linked crate dependencies are provided in [NOTICE](NOTICE) and [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md).