@getrouter/getrouter-cli 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/ci.yml +19 -0
- package/AGENTS.md +78 -0
- package/README.ja.md +116 -0
- package/README.md +116 -0
- package/README.zh-cn.md +116 -0
- package/biome.json +10 -0
- package/bun.lock +397 -0
- package/dist/bin.mjs +1422 -0
- package/docs/plans/2026-01-01-getrouter-cli-config-command-plan.md +231 -0
- package/docs/plans/2026-01-01-getrouter-cli-config-core-plan.md +307 -0
- package/docs/plans/2026-01-01-getrouter-cli-design.md +106 -0
- package/docs/plans/2026-01-01-getrouter-cli-scaffold-plan.md +327 -0
- package/docs/plans/2026-01-02-getrouter-cli-auth-design.md +68 -0
- package/docs/plans/2026-01-02-getrouter-cli-auth-device-design.md +73 -0
- package/docs/plans/2026-01-02-getrouter-cli-auth-device-plan.md +411 -0
- package/docs/plans/2026-01-02-getrouter-cli-auth-plan.md +435 -0
- package/docs/plans/2026-01-02-getrouter-cli-http-client-plan.md +235 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-create-update-output-design.md +24 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-create-update-output-plan.md +141 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-delete-output-design.md +22 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-delete-output-plan.md +122 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-get-output-design.md +23 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-get-output-plan.md +141 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-interactive-design.md +28 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-interactive-plan.md +247 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-output-design.md +31 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-output-plan.md +187 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-subscription-design.md +52 -0
- package/docs/plans/2026-01-02-getrouter-cli-keys-subscription-plan.md +306 -0
- package/docs/plans/2026-01-02-getrouter-cli-setup-env-design.md +67 -0
- package/docs/plans/2026-01-02-getrouter-cli-setup-env-plan.md +441 -0
- package/docs/plans/2026-01-02-getrouter-cli-subscription-output-design.md +34 -0
- package/docs/plans/2026-01-02-getrouter-cli-subscription-output-plan.md +157 -0
- package/docs/plans/2026-01-03-bun-migration-plan.md +103 -0
- package/docs/plans/2026-01-03-cli-emoji-output.md +45 -0
- package/docs/plans/2026-01-03-cli-english-output.md +123 -0
- package/docs/plans/2026-01-03-cli-simplify-design.md +62 -0
- package/docs/plans/2026-01-03-cli-simplify-implementation.md +468 -0
- package/docs/plans/2026-01-03-readme-command-descriptions.md +116 -0
- package/docs/plans/2026-01-03-tsdown-migration-plan.md +75 -0
- package/docs/plans/2026-01-04-cli-docs-cleanup-design.md +49 -0
- package/docs/plans/2026-01-04-cli-docs-cleanup-plan.md +126 -0
- package/docs/plans/2026-01-04-codex-multistep-design.md +76 -0
- package/docs/plans/2026-01-04-codex-multistep-plan.md +240 -0
- package/docs/plans/2026-01-04-env-hook-design.md +48 -0
- package/docs/plans/2026-01-04-env-hook-plan.md +173 -0
- package/docs/plans/2026-01-04-models-keys-fuzzy-design.md +75 -0
- package/docs/plans/2026-01-04-models-keys-fuzzy-implementation.md +704 -0
- package/package.json +37 -0
- package/src/.gitkeep +0 -0
- package/src/bin.ts +4 -0
- package/src/cli.ts +12 -0
- package/src/cmd/auth.ts +44 -0
- package/src/cmd/claude.ts +10 -0
- package/src/cmd/codex.ts +119 -0
- package/src/cmd/config-helpers.ts +16 -0
- package/src/cmd/config.ts +31 -0
- package/src/cmd/env.ts +103 -0
- package/src/cmd/index.ts +20 -0
- package/src/cmd/keys.ts +207 -0
- package/src/cmd/models.ts +48 -0
- package/src/cmd/status.ts +106 -0
- package/src/cmd/usages.ts +29 -0
- package/src/core/api/client.ts +79 -0
- package/src/core/auth/device.ts +105 -0
- package/src/core/auth/index.ts +37 -0
- package/src/core/config/fs.ts +13 -0
- package/src/core/config/index.ts +37 -0
- package/src/core/config/paths.ts +5 -0
- package/src/core/config/redact.ts +18 -0
- package/src/core/config/types.ts +23 -0
- package/src/core/http/errors.ts +32 -0
- package/src/core/http/request.ts +41 -0
- package/src/core/http/url.ts +12 -0
- package/src/core/interactive/clipboard.ts +61 -0
- package/src/core/interactive/codex.ts +75 -0
- package/src/core/interactive/fuzzy.ts +64 -0
- package/src/core/interactive/keys.ts +164 -0
- package/src/core/output/table.ts +34 -0
- package/src/core/output/usages.ts +75 -0
- package/src/core/paths.ts +4 -0
- package/src/core/setup/codex.ts +129 -0
- package/src/core/setup/env.ts +220 -0
- package/src/core/usages/aggregate.ts +69 -0
- package/src/generated/router/dashboard/v1/index.ts +1104 -0
- package/src/index.ts +1 -0
- package/tests/.gitkeep +0 -0
- package/tests/auth/device.test.ts +75 -0
- package/tests/auth/status.test.ts +64 -0
- package/tests/cli.test.ts +31 -0
- package/tests/cmd/auth.test.ts +90 -0
- package/tests/cmd/claude.test.ts +132 -0
- package/tests/cmd/codex.test.ts +147 -0
- package/tests/cmd/config-helpers.test.ts +18 -0
- package/tests/cmd/config.test.ts +56 -0
- package/tests/cmd/keys.test.ts +163 -0
- package/tests/cmd/models.test.ts +63 -0
- package/tests/cmd/status.test.ts +82 -0
- package/tests/cmd/usages.test.ts +42 -0
- package/tests/config/fs.test.ts +14 -0
- package/tests/config/index.test.ts +63 -0
- package/tests/config/paths.test.ts +10 -0
- package/tests/config/redact.test.ts +17 -0
- package/tests/config/types.test.ts +10 -0
- package/tests/core/api/client.test.ts +92 -0
- package/tests/core/interactive/clipboard.test.ts +44 -0
- package/tests/core/interactive/codex.test.ts +17 -0
- package/tests/core/interactive/fuzzy.test.ts +30 -0
- package/tests/core/setup/codex.test.ts +38 -0
- package/tests/core/setup/env.test.ts +84 -0
- package/tests/core/usages/aggregate.test.ts +55 -0
- package/tests/http/errors.test.ts +15 -0
- package/tests/http/request.test.ts +82 -0
- package/tests/http/url.test.ts +17 -0
- package/tests/output/table.test.ts +29 -0
- package/tests/output/usages.test.ts +71 -0
- package/tests/paths.test.ts +9 -0
- package/tsconfig.json +13 -0
- package/tsdown.config.ts +5 -0
- package/vitest.config.ts +7 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
ci:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
steps:
|
|
12
|
+
- uses: actions/checkout@v4
|
|
13
|
+
- uses: oven-sh/setup-bun@v1
|
|
14
|
+
with:
|
|
15
|
+
bun-version: "1.3.5"
|
|
16
|
+
- run: bun install --frozen-lockfile
|
|
17
|
+
- run: bun run typecheck
|
|
18
|
+
- run: bun run test
|
|
19
|
+
- run: bun run build
|
package/AGENTS.md
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
# Repository Guidelines
|
|
2
|
+
|
|
3
|
+
## Project Structure & Module Organization
|
|
4
|
+
|
|
5
|
+
- `src/` contains CLI source code (TypeScript). Commands live in `src/cmd/`, shared logic in `src/core/`, and generated dashboard clients in `src/generated/`.
|
|
6
|
+
- `tests/` mirrors the source structure with Vitest test suites (e.g., `tests/cmd/`, `tests/core/`).
|
|
7
|
+
- `docs/plans/` holds design and implementation plan documents for recent features.
|
|
8
|
+
- Config and runtime files are written under `~/.getrouter` (or `GETROUTER_CONFIG_DIR`).
|
|
9
|
+
|
|
10
|
+
## Build, Test, and Development Commands
|
|
11
|
+
|
|
12
|
+
- `bun run dev -- --help`: run the CLI in dev mode via `tsx`.
|
|
13
|
+
- `bun run build`: bundle the CLI to `dist/` with `tsdown`.
|
|
14
|
+
- `bun run format`: format and lint code with Biome.
|
|
15
|
+
- `bun run test`: run the full Vitest suite.
|
|
16
|
+
- `bun run test -- tests/path/to/file.test.ts`: run a targeted test file.
|
|
17
|
+
- `bun run typecheck`: run TypeScript type checks without emitting files.
|
|
18
|
+
|
|
19
|
+
## Coding Style & Naming Conventions
|
|
20
|
+
|
|
21
|
+
- TypeScript with 2-space indentation and double quotes, matching existing files.
|
|
22
|
+
- File naming: kebab-case for docs, `*.test.ts` for tests, and `index.ts` for module entry points.
|
|
23
|
+
- Prefer small helpers in `src/core/` and command wiring in `src/cmd/`.
|
|
24
|
+
- Use Biome via `bun run format`; keep style consistent with nearby code.
|
|
25
|
+
|
|
26
|
+
## Import Patterns & Module Organization
|
|
27
|
+
|
|
28
|
+
- Use ES modules with `import type` for type-only imports.
|
|
29
|
+
- Generated API clients imported from `src/generated/router/` with type-only imports.
|
|
30
|
+
- Core utilities organized under `src/core/` with domain-specific folders (auth/, config/, http/, etc.).
|
|
31
|
+
- Commands import helpers from `src/core/` and CLI utilities from `src/cli.ts`.
|
|
32
|
+
|
|
33
|
+
## TypeScript Patterns
|
|
34
|
+
|
|
35
|
+
- Strict typing enabled; define interfaces for all config and data structures.
|
|
36
|
+
- Generic types for API responses (`ApiResponse<T>`) and HTTP handlers.
|
|
37
|
+
- Union types for status codes and error types.
|
|
38
|
+
- Prefer `interface` over `type` for object shapes unless you need union types.
|
|
39
|
+
|
|
40
|
+
## Error Handling Patterns
|
|
41
|
+
|
|
42
|
+
- Custom `ApiError` class with `createApiError(status, message)` helper.
|
|
43
|
+
- Export structured error objects with `code`, `message`, and `requestId` fields.
|
|
44
|
+
- HTTP methods should return data and throw `ApiError` for failures.
|
|
45
|
+
- Use try/catch blocks in commands and exit gracefully with `process.exit(1)`.
|
|
46
|
+
|
|
47
|
+
## CLI Development Patterns
|
|
48
|
+
|
|
49
|
+
- Use Commander.js: `.command()`, `.description()`, `.option()`, `.action()`.
|
|
50
|
+
- Commands are async functions that accept options object.
|
|
51
|
+
- Use `consoleLog()` helper from `src/cli.ts` for consistent output.
|
|
52
|
+
- Add emojis to command output for visual distinction.
|
|
53
|
+
- Use `checkAuthenticated()` helper for commands requiring auth.
|
|
54
|
+
|
|
55
|
+
## Testing Guidelines
|
|
56
|
+
|
|
57
|
+
- Test framework: Vitest.
|
|
58
|
+
- Test naming: `*.test.ts` under `tests/` with `describe/it` blocks.
|
|
59
|
+
- Mock external dependencies with `vi.mock()` and `vi.hoisted()`.
|
|
60
|
+
- Use temp directory helpers (`mkdtemp`, `rimraf`) for file system tests.
|
|
61
|
+
- Test both success and error paths for commands.
|
|
62
|
+
- Run targeted tests before full suite: `bun run test -- tests/path/to/file.test.ts`.
|
|
63
|
+
- After modifying, always run `bun run test && bun run lint && bun run format`.
|
|
64
|
+
|
|
65
|
+
## Configuration & Security
|
|
66
|
+
|
|
67
|
+
- Config stored in `~/.getrouter/` or `GETROUTER_CONFIG_DIR`.
|
|
68
|
+
- Auth tokens in `auth.json` with 0600 permissions.
|
|
69
|
+
- Use `fsConfig` helper for config file operations.
|
|
70
|
+
- Redact sensitive data in logs and CLI output.
|
|
71
|
+
- Validate configuration with Zod schemas where applicable.
|
|
72
|
+
|
|
73
|
+
## Commit & Pull Request Guidelines
|
|
74
|
+
|
|
75
|
+
- Commit messages follow conventional prefixes: `feat:`, `fix:`, `docs:`, `test:`, `chore:`.
|
|
76
|
+
- Keep commits scoped and focused (tests + implementation together when possible).
|
|
77
|
+
- PRs should include a concise summary and test plan (commands run).
|
|
78
|
+
- Screenshots are usually unnecessary for CLI changes.
|
package/README.ja.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# GetRouter CLI
|
|
2
|
+
|
|
3
|
+
getrouter.dev 向けの CLI — API キーやサブスクリプションを管理し、vibecoding ツールを設定します。
|
|
4
|
+
|
|
5
|
+
[English](README.md) | [简体中文](README.zh-cn.md) | 日本語
|
|
6
|
+
|
|
7
|
+
## 要件
|
|
8
|
+
|
|
9
|
+
- Node.js >= 18
|
|
10
|
+
- Bun >= 1.3.5(開発用)
|
|
11
|
+
|
|
12
|
+
## インストール
|
|
13
|
+
|
|
14
|
+
npm で公開済みの場合:
|
|
15
|
+
|
|
16
|
+
npm で
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @getrouter/getrouter-cli
|
|
20
|
+
# or
|
|
21
|
+
npx @getrouter/getrouter-cli --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
bun で
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bun add -g @getrouter/getrouter-cli
|
|
28
|
+
# or
|
|
29
|
+
bunx @getrouter/getrouter-cli --help
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
ローカルビルド:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bun install
|
|
36
|
+
bun run build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## クイックスタート
|
|
40
|
+
|
|
41
|
+
- `getrouter login` — デバイスフローでログイン
|
|
42
|
+
- `getrouter keys` — API キーを一覧表示(作成/更新/削除は対話式)
|
|
43
|
+
- `getrouter codex` — Codex を設定(`~/.codex/config.toml` + `~/.codex/auth.json` を書き込み)
|
|
44
|
+
|
|
45
|
+
## 認証
|
|
46
|
+
|
|
47
|
+
デバイスフローでのログイン:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
getrouter login
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
表示された URL をブラウザで開くと、CLI はトークンを受け取るまでポーリングします。
|
|
54
|
+
|
|
55
|
+
## よく使うコマンド
|
|
56
|
+
|
|
57
|
+
- `getrouter login` — デバイスフローでログイン
|
|
58
|
+
- `getrouter logout` — ローカルのトークンを削除
|
|
59
|
+
- `getrouter status` — ログイン + サブスクリプション状態を表示
|
|
60
|
+
- `getrouter keys` — API キーの一覧/作成/更新/削除
|
|
61
|
+
- `getrouter usages` — 直近 7 日間の使用量(チャート + テーブル)
|
|
62
|
+
- `getrouter codex` — Codex を設定(config.toml + auth.json)
|
|
63
|
+
- `getrouter claude --install` — Anthropic 互換の環境変数をインストール
|
|
64
|
+
- `getrouter config` — CLI 設定を表示
|
|
65
|
+
- `getrouter config apiBase https://getrouter.dev` — API Base URL を設定
|
|
66
|
+
|
|
67
|
+
メモ:
|
|
68
|
+
|
|
69
|
+
- `getrouter keys` はデフォルトで一覧表示し、作成/更新/削除は対話式です。
|
|
70
|
+
- `getrouter status` はトークンを表示せずに認証/サブスクリプション情報を要約します。
|
|
71
|
+
|
|
72
|
+
## 環境変数の設定
|
|
73
|
+
|
|
74
|
+
`getrouter codex` は Codex の設定ファイルを書き込みます(シェルの環境変数は変更しません)。
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
getrouter codex
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
書き込まれるファイル(codex):
|
|
81
|
+
|
|
82
|
+
- `~/.codex/config.toml`(model + reasoning + provider 設定)
|
|
83
|
+
- `~/.codex/auth.json`(OPENAI_API_KEY)
|
|
84
|
+
|
|
85
|
+
`getrouter claude` は Anthropic 互換の環境変数を `~/.getrouter/env.sh`(または `env.ps1`)へ書き込みます。
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
getrouter claude --install
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
オプション(claude のみ):
|
|
92
|
+
|
|
93
|
+
- `--install`: `source ~/.getrouter/env.sh` をシェル rc に追記し、`claude` の自動 source hook をインストールして即時読み込みを試みます。初回はシェルの再読み込み(または `source ~/.zshrc`)が必要です。
|
|
94
|
+
|
|
95
|
+
書き込まれる変数(claude):
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
ANTHROPIC_BASE_URL=https://api.getrouter.dev/claude
|
|
99
|
+
ANTHROPIC_API_KEY=<consumer api key>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 設定とファイル
|
|
103
|
+
|
|
104
|
+
デフォルトの設定ディレクトリ: `~/.getrouter`(`GETROUTER_CONFIG_DIR` で上書き)
|
|
105
|
+
|
|
106
|
+
- `config.json`: CLI 設定
|
|
107
|
+
- `auth.json`: アクセス/リフレッシュトークン
|
|
108
|
+
- `env.sh` / `env.ps1`: 環境変数
|
|
109
|
+
|
|
110
|
+
## 開発
|
|
111
|
+
|
|
112
|
+
- `bun install` — 依存関係をインストール
|
|
113
|
+
- `bun run dev -- --help` — ローカルで CLI を実行してヘルプ表示
|
|
114
|
+
- `bun run format` — Biome でフォーマットと lint
|
|
115
|
+
- `bun run test` — テスト実行
|
|
116
|
+
- `bun run typecheck` — TypeScript 型チェック
|
package/README.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# GetRouter CLI
|
|
2
|
+
|
|
3
|
+
CLI for getrouter.dev — manage API keys, subscriptions, and configure vibecoding tools.
|
|
4
|
+
|
|
5
|
+
English | [简体中文](README.zh-cn.md) | [日本語](README.ja.md)
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Node.js >= 18
|
|
10
|
+
- Bun >= 1.3.5 (for development)
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
If published to npm:
|
|
15
|
+
|
|
16
|
+
With npm
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @getrouter/getrouter-cli
|
|
20
|
+
# or
|
|
21
|
+
npx @getrouter/getrouter-cli --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
With bun
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bun add -g @getrouter/getrouter-cli
|
|
28
|
+
# or
|
|
29
|
+
bunx @getrouter/getrouter-cli --help
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Local build:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bun install
|
|
36
|
+
bun run build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Quick Start
|
|
40
|
+
|
|
41
|
+
- `getrouter login` — sign in via device flow
|
|
42
|
+
- `getrouter keys` — list API keys (create/update/delete are interactive)
|
|
43
|
+
- `getrouter codex` — configure Codex (writes `~/.codex/config.toml` + `~/.codex/auth.json`)
|
|
44
|
+
|
|
45
|
+
## Auth
|
|
46
|
+
|
|
47
|
+
Device-style login:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
getrouter login
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Follow the printed URL in your browser, then the CLI will poll until it receives tokens.
|
|
54
|
+
|
|
55
|
+
## Common Commands
|
|
56
|
+
|
|
57
|
+
- `getrouter login` — log in via device flow
|
|
58
|
+
- `getrouter logout` — clear local tokens
|
|
59
|
+
- `getrouter status` — show login + subscription status
|
|
60
|
+
- `getrouter keys` — list/create/update/delete API keys
|
|
61
|
+
- `getrouter usages` — show the last 7 days of usage (chart + table)
|
|
62
|
+
- `getrouter codex` — configure Codex (config.toml + auth.json)
|
|
63
|
+
- `getrouter claude --install` — install Anthropic-compatible env vars
|
|
64
|
+
- `getrouter config` — show current CLI config
|
|
65
|
+
- `getrouter config apiBase https://getrouter.dev` — set API base URL
|
|
66
|
+
|
|
67
|
+
Notes:
|
|
68
|
+
|
|
69
|
+
- `getrouter keys` lists keys by default; create/update/delete prompt for input.
|
|
70
|
+
- `getrouter status` summarizes auth and subscription without printing tokens.
|
|
71
|
+
|
|
72
|
+
## Environment Setup
|
|
73
|
+
|
|
74
|
+
`getrouter codex` writes Codex configuration files (no shell env changes).
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
getrouter codex
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Files written (codex):
|
|
81
|
+
|
|
82
|
+
- `~/.codex/config.toml` (model + reasoning + provider settings)
|
|
83
|
+
- `~/.codex/auth.json` (OPENAI_API_KEY)
|
|
84
|
+
|
|
85
|
+
`getrouter claude` writes Anthropic-compatible env vars to `~/.getrouter/env.sh` (or `env.ps1`).
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
getrouter claude --install
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Option (claude only):
|
|
92
|
+
|
|
93
|
+
- `--install`: append `source ~/.getrouter/env.sh` to your shell rc, install an auto-source hook for `claude`, and try to load it immediately. Reload your shell (or `source ~/.zshrc`) once to activate the hook.
|
|
94
|
+
|
|
95
|
+
Variables written (claude):
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
ANTHROPIC_BASE_URL=https://api.getrouter.dev/claude
|
|
99
|
+
ANTHROPIC_API_KEY=<consumer api key>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Config & Files
|
|
103
|
+
|
|
104
|
+
Default config dir: `~/.getrouter` (override with `GETROUTER_CONFIG_DIR`)
|
|
105
|
+
|
|
106
|
+
- `config.json`: CLI config
|
|
107
|
+
- `auth.json`: access/refresh tokens
|
|
108
|
+
- `env.sh` / `env.ps1`: environment variables
|
|
109
|
+
|
|
110
|
+
## Development
|
|
111
|
+
|
|
112
|
+
- `bun install` — install dependencies
|
|
113
|
+
- `bun run dev -- --help` — run the local CLI and show help
|
|
114
|
+
- `bun run format` — format and lint code with Biome
|
|
115
|
+
- `bun run test` — run the test suite
|
|
116
|
+
- `bun run typecheck` — run TypeScript type checks
|
package/README.zh-cn.md
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# GetRouter CLI
|
|
2
|
+
|
|
3
|
+
getrouter.dev 的 CLI —— 用于管理 API key、订阅,并配置 vibecoding 工具。
|
|
4
|
+
|
|
5
|
+
[English](README.md) | 简体中文 | [日本語](README.ja.md)
|
|
6
|
+
|
|
7
|
+
## 依赖
|
|
8
|
+
|
|
9
|
+
- Node.js >= 18
|
|
10
|
+
- Bun >= 1.3.5(开发)
|
|
11
|
+
|
|
12
|
+
## 安装
|
|
13
|
+
|
|
14
|
+
若已发布到 npm:
|
|
15
|
+
|
|
16
|
+
使用 npm
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install -g @getrouter/getrouter-cli
|
|
20
|
+
# 或
|
|
21
|
+
npx @getrouter/getrouter-cli --help
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
使用 bun
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
bun add -g @getrouter/getrouter-cli
|
|
28
|
+
# 或
|
|
29
|
+
bunx @getrouter/getrouter-cli --help
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
本地构建:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
bun install
|
|
36
|
+
bun run build
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 快速开始
|
|
40
|
+
|
|
41
|
+
- `getrouter login` — 登录并完成设备码授权
|
|
42
|
+
- `getrouter keys` — 列出 API key(创建/更新/删除为交互式)
|
|
43
|
+
- `getrouter codex` — 配置 Codex(写入 `~/.codex/config.toml` + `~/.codex/auth.json`)
|
|
44
|
+
|
|
45
|
+
## 登录
|
|
46
|
+
|
|
47
|
+
设备码式登录:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
getrouter login
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
按提示打开浏览器完成确认,CLI 会轮询直到拿到 token。
|
|
54
|
+
|
|
55
|
+
## 常用命令
|
|
56
|
+
|
|
57
|
+
- `getrouter login` — 设备码登录
|
|
58
|
+
- `getrouter logout` — 退出并清除本地 token
|
|
59
|
+
- `getrouter status` — 查看登录与订阅状态
|
|
60
|
+
- `getrouter keys` — 列出/创建/更新/删除 API key
|
|
61
|
+
- `getrouter usages` — 查看最近 7 天使用量(图表 + 表格)
|
|
62
|
+
- `getrouter codex` — 配置 Codex(config.toml + auth.json)
|
|
63
|
+
- `getrouter claude --install` — 安装 Anthropic 兼容环境变量
|
|
64
|
+
- `getrouter config` — 查看 CLI 配置
|
|
65
|
+
- `getrouter config apiBase https://getrouter.dev` — 设置 API Base URL
|
|
66
|
+
|
|
67
|
+
说明:
|
|
68
|
+
|
|
69
|
+
- `getrouter keys` 默认列出,创建/更新/删除会交互提问。
|
|
70
|
+
- `getrouter status` 会汇总登录与订阅信息,但不会展示 token。
|
|
71
|
+
|
|
72
|
+
## 环境配置
|
|
73
|
+
|
|
74
|
+
`getrouter codex` 写入 Codex 配置文件(不修改 shell 环境变量)。
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
getrouter codex
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
写入文件(codex):
|
|
81
|
+
|
|
82
|
+
- `~/.codex/config.toml`(model + reasoning + provider 设置)
|
|
83
|
+
- `~/.codex/auth.json`(OPENAI_API_KEY)
|
|
84
|
+
|
|
85
|
+
`getrouter claude` 写入 Anthropic 兼容环境变量到 `~/.getrouter/env.sh`(或 `env.ps1`)。
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
getrouter claude --install
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
可选参数(仅 claude):
|
|
92
|
+
|
|
93
|
+
- `--install`:写入 shell rc(追加 `source ~/.getrouter/env.sh`),安装 `claude` 自动 source 的 hook,并尝试立即生效;首次需要重新加载 shell(或 `source ~/.zshrc`)
|
|
94
|
+
|
|
95
|
+
写入变量(claude):
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
ANTHROPIC_BASE_URL=https://api.getrouter.dev/claude
|
|
99
|
+
ANTHROPIC_API_KEY=<consumer api key>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## 配置与文件
|
|
103
|
+
|
|
104
|
+
默认目录:`~/.getrouter`(可用 `GETROUTER_CONFIG_DIR` 覆盖)
|
|
105
|
+
|
|
106
|
+
- `config.json`:CLI 配置
|
|
107
|
+
- `auth.json`:token
|
|
108
|
+
- `env.sh` / `env.ps1`:环境变量
|
|
109
|
+
|
|
110
|
+
## 开发
|
|
111
|
+
|
|
112
|
+
- `bun install` — 安装依赖
|
|
113
|
+
- `bun run dev -- --help` — 本地运行 CLI 并查看帮助
|
|
114
|
+
- `bun run format` — 使用 Biome 格式化并检查代码
|
|
115
|
+
- `bun run test` — 运行测试
|
|
116
|
+
- `bun run typecheck` — 运行 TypeScript 类型检查
|