@arxo/cli

中文文档
0.2.9发布于 2026/10/21Apache-2.0ES Module零依赖近 30 天下载 2127

Arxo Law law binary for npm: init/add/install/update/outdated/test/ask/eval over pinned canons. Thin launcher; the platform package carries the bytes of one GitHub Release.

原始使用文档
文档目录5 节
  1. Install
  2. Write a canon
  3. Ask a case under it
  4. Commands
  5. Related packages

Terminal: law init a canon package, law engine check reports LDC-E2102 for a typo, after the fix check OK, law test passes two scenarios

@arxo/cli

The law command of Arxo Law. Write a canon (a law, a tariff, a standard, a rulebook) as a package, check it, test it, pin it into a case and ask the case a question. Every answer is a canonical evaluation document with a proof and hashes; law eval replays it offline to the same bytes.

npm platforms license

Install · Write a canon · Ask a case · Commands · Related packages

Install

RouteCommandPlatforms
npmnpm i -g @arxo/climacOS arm64, Linux x64
Homebrewbrew install arxohq/tap/lawmacOS arm64, Linux x64
Shell scriptcurl -fsSL https://github.com/arxohq/law-releases/releases/latest/download/install.sh | shmacOS arm64, Linux x64
APTpackage arxo-law, setup at packages.arxo.ioDebian, Ubuntu (amd64)
ArchiveGitHub Releases with .sha256 next to each archivemacOS arm64, Linux x64

All routes carry the bytes of the same GitHub Release. This npm package is a thin launcher: the platform package @arxo/cli-<os>-<arch> holds the binary, and law version --json prints its sha256.

$ law version
law 0.1.1
semantics: law.core/0.2
std for language 0.2: 0.2.0
lawql: lawql/1 (queryResult 0.1)
binary hash: sha256:cfa7c17232f2…

Write a canon

The session above, from an empty folder: a parcel tariff — up to 2 kg the fee is 500, above that 500 plus 150 for every kilogram over 2. law init --template package creates law.toml and source.law; the rules go into source.law:

language "law.core" version "0.2";
package demo.parcel_tariff version "0.1.0";
namespace "urn:law:demo:parcel_tariff";

pub entity Shipment { label en unofficial "Shipment"; }

pub relation weight_kg(s: Shipment, kg: Decimal) kind empirical {
    label en unofficial "weight of the shipment, kg";
}
pub relation fee(s: Shipment, amount: Decimal) kind institutional {
    label en unofficial "postage under the tariff";
}

rule BaseFee(s: Shipment, kg: Decimal) strict {
    label en official "up to and including 2 kg: base fee 500";
    when weight_kg(s, kg);
    when kg <= 2.0;
    then fee(s, 500.0);
}

rule HeavyFee(s: Shipment, kg: Decimal) strict {
    label en official "over 2 kg: 500 plus 150 for each kilogram above 2";
    when weight_kg(s, kg);
    when kg > 2.0;
    then fee(s, 500.0 + (kg - 2.0) * 150.0);
}

Expectations are written from the tariff text before the run: 5 kg → 500 + 3 × 150 = 950; exactly 2 kg → 500. tests/tariff.lawtest:

language "law.core" version "0.2";
package demo.parcel_tariff version "0.1.0";
namespace "urn:law:demo:parcel_tariff";

test "urn:query:demo-parcel-tariff-t01-heavy" {
    given {
        context { legal_time @2026-09-25; decision_time @2026-09-25T00:00:00Z; knowledge_time @2026-09-25T00:00:00Z; timezone "UTC"; }
        assert "w": weight_kg(entity_ref("urn:case:box-1"), 5.0) { origin case_input; }
    }
    evaluate truth(fee(entity_ref("urn:case:box-1"), 950.0));
    expect truth_status == TRUE_ONLY;
    expect evaluation_status == COMPUTED;
}

test "urn:query:demo-parcel-tariff-t02-base" {
    given {
        context { legal_time @2026-09-25; decision_time @2026-09-25T00:00:00Z; knowledge_time @2026-09-25T00:00:00Z; timezone "UTC"; }
        assert "w": weight_kg(entity_ref("urn:case:box-2"), 2.0) { origin case_input; }
    }
    evaluate truth(fee(entity_ref("urn:case:box-2"), 500.0));
    expect truth_status == TRUE_ONLY;
    expect evaluation_status == COMPUTED;
}

and in law.toml:

[[tests]]
family = "parcel_tariff"
suites = ["tests/tariff.lawtest"]
world = ["demo.parcel_tariff"]

law engine check . is the static check: types, names, the header against the manifest. A misspelled relation is reported with its line, column and a stable code (LDC-E2102), so an editor or CI can react to the code, not to the wording. law test runs the declared scenarios.

Ask a case under it

Terminal: law pack into tariff.arxo, law init my-case, law add the container, law ask answers TRUE_ONLY with a result hash, law eval replays the same hash

A case package holds your situation; the canon comes in as a pinned dependency. law pack puts the canon into one portable .arxo file, and law add pins it in law.lock without any network. The case, main.lawcase:

language "law.core" version "0.2";
package my_case version "0.1.0";
namespace "urn:law:my_case";

case Main {
    context {
        legal_time @2026-10-01;
        knowledge_time @2026-10-01T12:00:00Z;
        decision_time @2026-10-01T12:00:00Z;
        timezone "UTC";
    }
    assert demo.parcel_tariff::weight_kg(entity_ref("urn:case:box-1"), 5.0) { origin case_input; }
}

law ask --out runs/fee saves the request and the full evaluation document; law eval runs/fee recomputes it and gets the same result hash. Without jq, --format brief prints a one-line JSON summary.

Commands

law --help lists every flag. The main ones:

CommandWhat it does
law init <dir> [--template case|package]a new case package (your situation) or canon package (your rules)
law add <name>@<version> · law add <file.arxo>pin a dependency in law.lock and install its bytes into deps/
law install [--offline]restore deps/ from law.lock
law update <name>[@<version>] [--replay <dir>]move a pin; --replay shows which saved answers would change
law outdatedwhat is pinned, what is published; the lock is untouched
law testrun the scenarios declared in law.toml
law ask (--query … | --query-json <file> | --card <id>)ask a case; --out <dir> saves the request and the evaluation document
law eval <dir | file.arxo>replay a saved evaluation offline; from a container, check it against the saved documents
law case questions · check · facts · document · diffwork with a case: question cards, facts with provenance, attached documents
law pack --out <file.arxo> · law unpack · law inspectone portable container: packages, lock, inputs; expand or inspect it
law key new · law sign · law publishsign a container; publish to a registry directory
law auditformalization measure of a package; executes no cases
law types <package>TypeScript declarations of a package
law serve --world <dir>an HTTP service over a pinned world: POST /v1/ask returns the same document
law engine check · lock · …low-level engine commands: static check, own lock, and more
law version [--json]tool version, semantics lines, hash of the binary

Arxo Law packages: which one to install

Apache-2.0.

版本与发布记录

@arxo/cli 共发布 25 个版本,首次发布于 2026/10/02;过去 12 个月发布了 25 个版本。

版本发布日期距今
0.2.9latest2026/10/2117 天前
0.2.82026/10/1622 天前
0.2.72026/10/1623 天前
0.2.62026/10/1524 天前
0.2.52026/10/1424 天前
0.2.42026/10/1425 天前

关于 @arxo/cli 的常见问题

@arxo/cli 是什么?

Arxo Law law binary for npm: init/add/install/update/outdated/test/ask/eval over pinned canons. Thin launcher; the platform package carries the bytes of one GitHub Release.

如何安装 @arxo/cli?

在项目目录运行 npm install @arxo/cli,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 law,可以用 npx law 直接运行。

@arxo/cli 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/arxo__cli 是否存在。

@arxo/cli 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@arxo/cli 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@arxo/cli 可以商用吗?

@arxo/cli 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@arxo/cli 的下载量有多少?

根据 npm 官方下载统计,@arxo/cli 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,127 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@arxo/cli 还在维护吗?

最新版本 0.2.9 发布于 2026/10/21(17 天前);至今共发布 25 个版本,其中过去 12 个月发布了 25 个;首次发布于 2026/10/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。