@rppdice/cli
v1.1.0
Published
Developer CLI for RppDice TRPG system authors: validate, trace, and replay-test TOML systems.
Downloads
523
Maintainers
Readme
@rppdice/cli
RppDice TRPG システム作者向け開発支援 CLI。
想定読者
このパッケージが必要なのは、新しいプラグインを 作成 するか、CI でフィクスチャを回す場合だけです。
アプリケーションでプラグインを利用するなら @rppdice/core を直接使ってください。
インストール
npm install --save-dev @rppdice/cli @rppdice/core(プレアルファ — 公開 API が固まるまで npm への publish は保留しています。)
コマンド
rppdice validate <file.toml> スキーマ検証 (パス付きエラー)
rppdice trace <file.toml> <command> ステップ単位トレース
--seed <n> 決定論的 RNG
--locale <tag> i18n ラベル
rppdice test <system.toml> <fixtures.toml>
seeded リプレイ
exit 0 pass / 1 failrppdice validate
npx rppdice validate packages/example/src/systems/three-band-2d6.toml
# OK three-band-2d6失敗時はパス付きで返ります: commands[0].steps[2].when: must not be empty。
rppdice trace
npx rppdice trace packages/example/src/systems/three-band-2d6.toml "TB+3" --seed 42
# [0] eval mod_val = 3
# [1] roll r = [4, 6]
# [2] eval total = 13
# [3] outcome verdict = "strong"
# [4] output text = "2D6 [4, 6] mod=3 total=13 → Strong"
#
# success=true failure=false critical=false fumble=false secret=falserppdice test
フィクスチャファイルは TOML です:
[[fixture]]
name = "TB+3 で大成功になる"
command = "TB+3"
seed = 1
expects.success = true
expects.text_includes = "Strong"
[[fixture]]
name = "TB-5 で失敗になる"
command = "TB-5"
seed = 1
expects.failure = truenpx rppdice test system.toml fixtures.toml
# pass TB+3 で大成功になる
# pass TB-5 で失敗になる
# 2/2 passingライブラリ API
CLI の内部実装はライブラリ関数としても export されており、カスタム CI スクリプト・VS Code 拡張・Web プレイグラウンドなどから直接呼び出せます:
| Export | 対応 CLI コマンド |
| ----------------------------------------- | ------------------ |
| validate(src): ValidationResult | rppdice validate |
| trace(registry, id, command, opts?) | rppdice trace |
| traceFromToml(toml, command, opts?) | rppdice trace |
| runFixtures(registry, id, fixtures) | rppdice test |
| parseFixtureFile(src): Fixture[] | rppdice test |
| runFixtureFile(systemToml, fixtureToml) | rppdice test |
import { validate, trace, runFixtureFile } from "@rppdice/cli";
const r = validate(tomlSource);
if (!r.ok) console.error(r.issues[0]!.message);
const { frames, outcome } = trace(registry, "three-band-2d6", "TB+3", { seed: 42n });
const { results } = runFixtureFile(systemToml, fixtureToml);
const failed = results.filter((r) => !r.ok);ライセンス
MIT。LICENSE を参照。
