@routerlab/cli
Advanced tools
| import { type CliContext } from "../io.ts"; | ||
| export declare const CLI_VERSION = "0.0.1"; | ||
| /** | ||
@@ -4,0 +3,0 @@ * `version` subcommand: prints two lines, `@routerlab/cli` first then |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,KAAK,UAAU,EAAa,MAAM,UAAU,CAAC;AAItD,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAIlD"} | ||
| {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,UAAU,EAAa,MAAM,UAAU,CAAC;AAQtD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,UAAU,GAAG,MAAM,CAIlD"} |
+10
-10
| // commands/version.ts — print CLI + core versions. | ||
| // | ||
| // We import the core version from `@routerlab/core` directly so the two | ||
| // numbers can drift independently and the CLI honestly reports both. | ||
| // CLI version is read from its own package.json at build time via the | ||
| // constant below — keep this in lockstep with packages/cli/package.json. | ||
| import { version as coreVersion } from "@routerlab/core"; | ||
| // We read package.json at runtime so Changesets version bumps are reflected | ||
| // without duplicating version constants in source. | ||
| import { readFileSync } from "node:fs"; | ||
| import { writeLine } from "../io.js"; | ||
| // Pinned to packages/cli/package.json. If you bump `package.json`, bump | ||
| // this too — the repo's CI catches drift between the two via test. | ||
| export const CLI_VERSION = "0.0.1"; | ||
| function readPackageVersion(relativePackageJson) { | ||
| const packageJsonUrl = new URL(relativePackageJson, import.meta.url); | ||
| const packageJson = JSON.parse(readFileSync(packageJsonUrl, "utf8")); | ||
| return packageJson.version ?? "0.0.0"; | ||
| } | ||
| /** | ||
@@ -17,6 +17,6 @@ * `version` subcommand: prints two lines, `@routerlab/cli` first then | ||
| export function runVersion(ctx) { | ||
| writeLine(ctx.stdout, `@routerlab/cli ${CLI_VERSION}`); | ||
| writeLine(ctx.stdout, `@routerlab/core ${coreVersion}`); | ||
| writeLine(ctx.stdout, `@routerlab/cli ${readPackageVersion("../../package.json")}`); | ||
| writeLine(ctx.stdout, `@routerlab/core ${readPackageVersion("../../../core/package.json")}`); | ||
| return 0; | ||
| } | ||
| //# sourceMappingURL=version.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,wEAAwE;AACxE,qEAAqE;AACrE,sEAAsE;AACtE,yEAAyE;AAEzE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEzD,OAAO,EAAmB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEtD,wEAAwE;AACxE,mEAAmE;AACnE,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAe;IACxC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,WAAW,EAAE,CAAC,CAAC;IACvD,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,WAAW,EAAE,CAAC,CAAC;IACxD,OAAO,CAAC,CAAC;AACX,CAAC"} | ||
| {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/commands/version.ts"],"names":[],"mappings":"AAAA,mDAAmD;AACnD,EAAE;AACF,4EAA4E;AAC5E,mDAAmD;AAEnD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvC,OAAO,EAAmB,SAAS,EAAE,MAAM,UAAU,CAAC;AAEtD,SAAS,kBAAkB,CAAC,mBAA2B;IACrD,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC,mBAAmB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACrE,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,cAAc,EAAE,MAAM,CAAC,CAAyB,CAAC;IAC7F,OAAO,WAAW,CAAC,OAAO,IAAI,OAAO,CAAC;AACxC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CAAC,GAAe;IACxC,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,kBAAkB,kBAAkB,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAC;IACpF,SAAS,CAAC,GAAG,CAAC,MAAM,EAAE,mBAAmB,kBAAkB,CAAC,4BAA4B,CAAC,EAAE,CAAC,CAAC;IAC7F,OAAO,CAAC,CAAC;AACX,CAAC"} |
+1
-1
@@ -1,3 +0,3 @@ | ||
| #!/usr/bin/env bun | ||
| #!/usr/bin/env node | ||
| export {}; | ||
| //# sourceMappingURL=index.d.ts.map |
+1
-1
@@ -1,2 +0,2 @@ | ||
| #!/usr/bin/env bun | ||
| #!/usr/bin/env node | ||
| // @routerlab/cli — `route` command entrypoint. | ||
@@ -3,0 +3,0 @@ // |
+1
-1
@@ -23,3 +23,3 @@ import type { Readable, Writable } from "node:stream"; | ||
| * Returns an empty string if stdin is a TTY (interactive shell, no pipe) | ||
| * — that way `route --task=qa --quality-bar=0.85` without `--input` and | ||
| * — that way `route route --task=qa --quality-bar=0.85` without `--input` and | ||
| * without a piped stdin doesn't hang forever waiting on the user. | ||
@@ -26,0 +26,0 @@ */ |
+2
-2
@@ -12,7 +12,7 @@ // io.ts — IO seam for the CLI. | ||
| * Returns an empty string if stdin is a TTY (interactive shell, no pipe) | ||
| * — that way `route --task=qa --quality-bar=0.85` without `--input` and | ||
| * — that way `route route --task=qa --quality-bar=0.85` without `--input` and | ||
| * without a piped stdin doesn't hang forever waiting on the user. | ||
| */ | ||
| export async function readStdinToString(stdin) { | ||
| // Bun's stdin exposes `isTTY` (matches Node), so a TTY-attached caller | ||
| // Node and Bun expose `isTTY`, so a TTY-attached caller | ||
| // doesn't block. Real pipes (`echo "hi" | route ...`) and injected | ||
@@ -19,0 +19,0 @@ // memory streams in tests both have `isTTY` falsy. |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"io.js","sourceRoot":"","sources":["../src/io.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,EAAE;AACF,yEAAyE;AACzE,4EAA4E;AAC5E,wEAAwE;AACxE,2EAA2E;AAC3E,wCAAwC;AAsBxC;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CAAC,KAAe;IACrD,uEAAuE;IACvE,mEAAmE;IACnE,mDAAmD;IACnD,MAAM,QAAQ,GAAG,KAAuC,CAAC;IACzD,IAAI,QAAQ,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;QAC5B,OAAO,EAAE,CAAC;IACZ,CAAC;IAED,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,KAAK,EAAE,MAAM,KAAK,IAAI,KAAK,EAAE,CAAC;QAChC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC;QAC1C,CAAC;aAAM,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;YACvC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QAClC,CAAC;aAAM,CAAC;YACN,+DAA+D;YAC/D,8CAA8C;YAC9C,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AAChD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,MAAgB,EAAE,IAAY;IACtD,MAAM,CAAC,KAA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AC;AAC5B,CAAC"} |
+6
-2
| { | ||
| "name": "@routerlab/cli", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "CLI for routerlab — cost-quality routing for LLM APIs.", | ||
@@ -13,2 +13,5 @@ "license": "Apache-2.0", | ||
| }, | ||
| "engines": { | ||
| "node": ">=20" | ||
| }, | ||
| "files": [ | ||
@@ -26,7 +29,8 @@ "dist", | ||
| "build": "tsc -p tsconfig.json", | ||
| "lint": "tsc -p tsconfig.json --noEmit", | ||
| "test": "bun test" | ||
| }, | ||
| "dependencies": { | ||
| "@routerlab/core": "^1.0.1" | ||
| "@routerlab/core": "^1.0.2" | ||
| } | ||
| } |
+19
-17
@@ -12,13 +12,15 @@ # `@routerlab/cli` | ||
| > **Runtime**: `@routerlab/cli` requires [Bun](https://bun.sh) (>= 1.1.0). | ||
| > The binary's shebang is `#!/usr/bin/env bun` and the `eval` subcommand | ||
| > dynamically imports a `.ts` runner module. Node.js is not supported as | ||
| > the CLI runtime. The library package | ||
| > ([`@routerlab/core`](https://www.npmjs.com/package/@routerlab/core)) is | ||
| > runtime-agnostic and works on both. | ||
| > **Runtime**: the published CLI runs on Node.js >=20. This repository uses | ||
| > Bun for local workspace orchestration and tests. | ||
| ```bash | ||
| bun add @routerlab/cli | ||
| npm install --save-dev @routerlab/cli | ||
| ``` | ||
| Or run without installing: | ||
| ```bash | ||
| npx --yes @routerlab/cli route --task=qa --quality-bar=0.85 --input=prompt.txt | ||
| ``` | ||
| Or, inside the routerlab monorepo: | ||
@@ -36,28 +38,28 @@ | ||
| echo "What's the capital of France?" \ | ||
| | route route --task=qa --quality-bar=0.85 | ||
| | npx --yes @routerlab/cli route --task=qa --quality-bar=0.85 | ||
| # Same, with a $0.005 hard budget and JSON output for piping into jq: | ||
| echo "Write a python function that ..." \ | ||
| | route route --task=codegen --quality-bar=0.80 --max-cost-usd=0.005 --json \ | ||
| | npx --yes @routerlab/cli route --task=codegen --quality-bar=0.80 --max-cost-usd=0.005 --json \ | ||
| | jq '.chosen.model.model' | ||
| # Read the prompt from a file instead of stdin: | ||
| route route --task=qa --quality-bar=0.85 --input=./prompt.txt | ||
| npx --yes @routerlab/cli route --task=qa --quality-bar=0.85 --input=./prompt.txt | ||
| # Inspect the published Pareto frontier for codegen: | ||
| route frontier --task=codegen | ||
| npx --yes @routerlab/cli frontier --task=codegen | ||
| # Same, as JSON: | ||
| route frontier --task=codegen --format=json | ||
| npx --yes @routerlab/cli frontier --task=codegen --format=json | ||
| # List candidate models (optionally filtered by provider): | ||
| route models | ||
| route models --provider=anthropic | ||
| route models --json | ||
| npx --yes @routerlab/cli models | ||
| npx --yes @routerlab/cli models --provider=anthropic | ||
| npx --yes @routerlab/cli models --json | ||
| # Run the frontier eval pipeline for a single task: | ||
| route eval frontier --task=qa --n=20 | ||
| npx --yes @routerlab/cli eval frontier --task=qa --n=20 | ||
| # Print versions: | ||
| route version | ||
| npx --yes @routerlab/cli version | ||
| ``` | ||
@@ -64,0 +66,0 @@ |
94737
0.23%174
1.16%1077
-0.09%Updated