@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.
Files changed (120) hide show
  1. package/.github/workflows/ci.yml +19 -0
  2. package/AGENTS.md +78 -0
  3. package/README.ja.md +116 -0
  4. package/README.md +116 -0
  5. package/README.zh-cn.md +116 -0
  6. package/biome.json +10 -0
  7. package/bun.lock +397 -0
  8. package/dist/bin.mjs +1422 -0
  9. package/docs/plans/2026-01-01-getrouter-cli-config-command-plan.md +231 -0
  10. package/docs/plans/2026-01-01-getrouter-cli-config-core-plan.md +307 -0
  11. package/docs/plans/2026-01-01-getrouter-cli-design.md +106 -0
  12. package/docs/plans/2026-01-01-getrouter-cli-scaffold-plan.md +327 -0
  13. package/docs/plans/2026-01-02-getrouter-cli-auth-design.md +68 -0
  14. package/docs/plans/2026-01-02-getrouter-cli-auth-device-design.md +73 -0
  15. package/docs/plans/2026-01-02-getrouter-cli-auth-device-plan.md +411 -0
  16. package/docs/plans/2026-01-02-getrouter-cli-auth-plan.md +435 -0
  17. package/docs/plans/2026-01-02-getrouter-cli-http-client-plan.md +235 -0
  18. package/docs/plans/2026-01-02-getrouter-cli-keys-create-update-output-design.md +24 -0
  19. package/docs/plans/2026-01-02-getrouter-cli-keys-create-update-output-plan.md +141 -0
  20. package/docs/plans/2026-01-02-getrouter-cli-keys-delete-output-design.md +22 -0
  21. package/docs/plans/2026-01-02-getrouter-cli-keys-delete-output-plan.md +122 -0
  22. package/docs/plans/2026-01-02-getrouter-cli-keys-get-output-design.md +23 -0
  23. package/docs/plans/2026-01-02-getrouter-cli-keys-get-output-plan.md +141 -0
  24. package/docs/plans/2026-01-02-getrouter-cli-keys-interactive-design.md +28 -0
  25. package/docs/plans/2026-01-02-getrouter-cli-keys-interactive-plan.md +247 -0
  26. package/docs/plans/2026-01-02-getrouter-cli-keys-output-design.md +31 -0
  27. package/docs/plans/2026-01-02-getrouter-cli-keys-output-plan.md +187 -0
  28. package/docs/plans/2026-01-02-getrouter-cli-keys-subscription-design.md +52 -0
  29. package/docs/plans/2026-01-02-getrouter-cli-keys-subscription-plan.md +306 -0
  30. package/docs/plans/2026-01-02-getrouter-cli-setup-env-design.md +67 -0
  31. package/docs/plans/2026-01-02-getrouter-cli-setup-env-plan.md +441 -0
  32. package/docs/plans/2026-01-02-getrouter-cli-subscription-output-design.md +34 -0
  33. package/docs/plans/2026-01-02-getrouter-cli-subscription-output-plan.md +157 -0
  34. package/docs/plans/2026-01-03-bun-migration-plan.md +103 -0
  35. package/docs/plans/2026-01-03-cli-emoji-output.md +45 -0
  36. package/docs/plans/2026-01-03-cli-english-output.md +123 -0
  37. package/docs/plans/2026-01-03-cli-simplify-design.md +62 -0
  38. package/docs/plans/2026-01-03-cli-simplify-implementation.md +468 -0
  39. package/docs/plans/2026-01-03-readme-command-descriptions.md +116 -0
  40. package/docs/plans/2026-01-03-tsdown-migration-plan.md +75 -0
  41. package/docs/plans/2026-01-04-cli-docs-cleanup-design.md +49 -0
  42. package/docs/plans/2026-01-04-cli-docs-cleanup-plan.md +126 -0
  43. package/docs/plans/2026-01-04-codex-multistep-design.md +76 -0
  44. package/docs/plans/2026-01-04-codex-multistep-plan.md +240 -0
  45. package/docs/plans/2026-01-04-env-hook-design.md +48 -0
  46. package/docs/plans/2026-01-04-env-hook-plan.md +173 -0
  47. package/docs/plans/2026-01-04-models-keys-fuzzy-design.md +75 -0
  48. package/docs/plans/2026-01-04-models-keys-fuzzy-implementation.md +704 -0
  49. package/package.json +37 -0
  50. package/src/.gitkeep +0 -0
  51. package/src/bin.ts +4 -0
  52. package/src/cli.ts +12 -0
  53. package/src/cmd/auth.ts +44 -0
  54. package/src/cmd/claude.ts +10 -0
  55. package/src/cmd/codex.ts +119 -0
  56. package/src/cmd/config-helpers.ts +16 -0
  57. package/src/cmd/config.ts +31 -0
  58. package/src/cmd/env.ts +103 -0
  59. package/src/cmd/index.ts +20 -0
  60. package/src/cmd/keys.ts +207 -0
  61. package/src/cmd/models.ts +48 -0
  62. package/src/cmd/status.ts +106 -0
  63. package/src/cmd/usages.ts +29 -0
  64. package/src/core/api/client.ts +79 -0
  65. package/src/core/auth/device.ts +105 -0
  66. package/src/core/auth/index.ts +37 -0
  67. package/src/core/config/fs.ts +13 -0
  68. package/src/core/config/index.ts +37 -0
  69. package/src/core/config/paths.ts +5 -0
  70. package/src/core/config/redact.ts +18 -0
  71. package/src/core/config/types.ts +23 -0
  72. package/src/core/http/errors.ts +32 -0
  73. package/src/core/http/request.ts +41 -0
  74. package/src/core/http/url.ts +12 -0
  75. package/src/core/interactive/clipboard.ts +61 -0
  76. package/src/core/interactive/codex.ts +75 -0
  77. package/src/core/interactive/fuzzy.ts +64 -0
  78. package/src/core/interactive/keys.ts +164 -0
  79. package/src/core/output/table.ts +34 -0
  80. package/src/core/output/usages.ts +75 -0
  81. package/src/core/paths.ts +4 -0
  82. package/src/core/setup/codex.ts +129 -0
  83. package/src/core/setup/env.ts +220 -0
  84. package/src/core/usages/aggregate.ts +69 -0
  85. package/src/generated/router/dashboard/v1/index.ts +1104 -0
  86. package/src/index.ts +1 -0
  87. package/tests/.gitkeep +0 -0
  88. package/tests/auth/device.test.ts +75 -0
  89. package/tests/auth/status.test.ts +64 -0
  90. package/tests/cli.test.ts +31 -0
  91. package/tests/cmd/auth.test.ts +90 -0
  92. package/tests/cmd/claude.test.ts +132 -0
  93. package/tests/cmd/codex.test.ts +147 -0
  94. package/tests/cmd/config-helpers.test.ts +18 -0
  95. package/tests/cmd/config.test.ts +56 -0
  96. package/tests/cmd/keys.test.ts +163 -0
  97. package/tests/cmd/models.test.ts +63 -0
  98. package/tests/cmd/status.test.ts +82 -0
  99. package/tests/cmd/usages.test.ts +42 -0
  100. package/tests/config/fs.test.ts +14 -0
  101. package/tests/config/index.test.ts +63 -0
  102. package/tests/config/paths.test.ts +10 -0
  103. package/tests/config/redact.test.ts +17 -0
  104. package/tests/config/types.test.ts +10 -0
  105. package/tests/core/api/client.test.ts +92 -0
  106. package/tests/core/interactive/clipboard.test.ts +44 -0
  107. package/tests/core/interactive/codex.test.ts +17 -0
  108. package/tests/core/interactive/fuzzy.test.ts +30 -0
  109. package/tests/core/setup/codex.test.ts +38 -0
  110. package/tests/core/setup/env.test.ts +84 -0
  111. package/tests/core/usages/aggregate.test.ts +55 -0
  112. package/tests/http/errors.test.ts +15 -0
  113. package/tests/http/request.test.ts +82 -0
  114. package/tests/http/url.test.ts +17 -0
  115. package/tests/output/table.test.ts +29 -0
  116. package/tests/output/usages.test.ts +71 -0
  117. package/tests/paths.test.ts +9 -0
  118. package/tsconfig.json +13 -0
  119. package/tsdown.config.ts +5 -0
  120. package/vitest.config.ts +7 -0
@@ -0,0 +1,468 @@
1
+ # CLI Simplification Implementation Plan
2
+
3
+ > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
4
+
5
+ **Goal:** Replace existing multi-level commands with simplified top-level commands (login/logout/keys/usages/status/codex/claude/config), add usage aggregation + chart output, and remove deprecated commands.
6
+
7
+ **Architecture:** Introduce new command modules for usages/status/codex/claude, repurpose keys into an interactive menu, and extend generated API client + request layer to support usage listing. Update output helpers for charts and keep all output human-friendly (no JSON flags). Remove old command registrations and associated tests.
8
+
9
+ **Tech Stack:** Bun, Commander, Prompts, Vitest, generated TypeScript HTTP clients.
10
+
11
+ ---
12
+
13
+ ### Task 1: Add UsageService to generated client + API client wiring
14
+
15
+ **Files:**
16
+ - Modify: `src/generated/router/dashboard/v1/index.ts`
17
+ - Modify: `src/core/api/client.ts`
18
+ - Test: `tests/core/api/client.test.ts`
19
+
20
+ **Step 1: Write failing test for usage client exposure**
21
+
22
+ Add to `tests/core/api/client.test.ts`:
23
+ ```ts
24
+ expect("usageService" in createApiClients({})).toBe(true);
25
+ ```
26
+
27
+ **Step 2: Run targeted test to see failure**
28
+
29
+ Run:
30
+ ```bash
31
+ bun run test -- tests/core/api/client.test.ts
32
+ ```
33
+ Expected: FAIL (usageService missing).
34
+
35
+ **Step 3: Update generated client to include UsageService**
36
+
37
+ Copy the UsageService types/creator from
38
+ `/Users/xus/code/github/getrouter/router/frontend/dashboard/src/services/router/dashboard/v1/index.ts`
39
+ into `src/generated/router/dashboard/v1/index.ts` (just before the EOF insertion point):
40
+ - `ListUsagesRequest`, `ListUsagesResponse`, `routercommonv1_Usage`
41
+ - `UsageService` interface
42
+ - `createUsageServiceClient` (GET `v1/dashboard/usages`)
43
+
44
+ **Step 4: Wire usageService into API client**
45
+
46
+ Update `src/core/api/client.ts` to import/export `UsageService` and include
47
+ `usageService` in `ClientFactories`/`ApiClients` and return value.
48
+
49
+ **Step 5: Re-run targeted test**
50
+
51
+ Run:
52
+ ```bash
53
+ bun run test -- tests/core/api/client.test.ts
54
+ ```
55
+ Expected: PASS.
56
+
57
+ **Step 6: Commit**
58
+
59
+ ```bash
60
+ git add src/generated/router/dashboard/v1/index.ts src/core/api/client.ts tests/core/api/client.test.ts
61
+ git commit -m "feat: add usage service client"
62
+ ```
63
+
64
+ ---
65
+
66
+ ### Task 2: Usage aggregation + chart rendering helpers
67
+
68
+ **Files:**
69
+ - Create: `src/core/usages/aggregate.ts`
70
+ - Create: `src/core/output/usages.ts`
71
+ - Test: `tests/core/usages/aggregate.test.ts`
72
+ - Test: `tests/output/usages.test.ts`
73
+
74
+ **Step 1: Write failing tests for aggregation + chart**
75
+
76
+ `tests/core/usages/aggregate.test.ts` (example):
77
+ ```ts
78
+ import { describe, expect, it } from "vitest";
79
+ import { aggregateUsages } from "../../../src/core/usages/aggregate";
80
+
81
+ describe("aggregateUsages", () => {
82
+ it("groups by local day and totals tokens", () => {
83
+ const rows = [
84
+ { createdAt: "2026-01-03T12:00:00Z", inputTokens: 5, outputTokens: 7, totalTokens: 12 },
85
+ { createdAt: "2026-01-03T18:00:00Z", inputTokens: 3, outputTokens: 2, totalTokens: 5 },
86
+ ];
87
+ const result = aggregateUsages(rows, 7);
88
+ expect(result[0].totalTokens).toBe(17);
89
+ expect(result[0].inputTokens).toBe(8);
90
+ expect(result[0].outputTokens).toBe(9);
91
+ });
92
+ });
93
+ ```
94
+
95
+ `tests/output/usages.test.ts` (example):
96
+ ```ts
97
+ import { describe, expect, it } from "vitest";
98
+ import { renderUsageChart } from "../../../src/core/output/usages";
99
+
100
+ describe("renderUsageChart", () => {
101
+ it("renders stacked bars", () => {
102
+ const output = renderUsageChart([
103
+ { day: "2026-01-03", inputTokens: 10, outputTokens: 20, totalTokens: 30, requests: 2 },
104
+ ]);
105
+ expect(output).toContain("2026-01-03");
106
+ expect(output).toMatch(/█/);
107
+ });
108
+ });
109
+ ```
110
+
111
+ **Step 2: Run tests to see failures**
112
+
113
+ ```bash
114
+ bun run test -- tests/core/usages/aggregate.test.ts tests/output/usages.test.ts
115
+ ```
116
+ Expected: FAIL (missing modules).
117
+
118
+ **Step 3: Implement aggregation helper**
119
+
120
+ `src/core/usages/aggregate.ts` should:
121
+ - Accept raw usages and `days` (fixed to 7 for now).
122
+ - Convert `createdAt` to **local day string** (`YYYY-MM-DD`).
123
+ - Group by day, summing input/output/total and counting requests.
124
+ - Return sorted (newest → oldest) list, truncated to 7 unique days.
125
+
126
+ **Step 4: Implement chart/table renderer**
127
+
128
+ `src/core/output/usages.ts` should:
129
+ - Render stacked bars (input + output) with max width (e.g., 24–30 chars).
130
+ - Distinguish input/output segments (different block chars or symbols).
131
+ - Provide table rows for date/input/output/total/requests.
132
+
133
+ **Step 5: Re-run tests**
134
+
135
+ ```bash
136
+ bun run test -- tests/core/usages/aggregate.test.ts tests/output/usages.test.ts
137
+ ```
138
+ Expected: PASS.
139
+
140
+ **Step 6: Commit**
141
+
142
+ ```bash
143
+ git add src/core/usages/aggregate.ts src/core/output/usages.ts tests/core/usages/aggregate.test.ts tests/output/usages.test.ts
144
+ git commit -m "feat: add usage aggregation and chart output"
145
+ ```
146
+
147
+ ---
148
+
149
+ ### Task 3: Add `getrouter usages` command
150
+
151
+ **Files:**
152
+ - Create: `src/cmd/usages.ts`
153
+ - Modify: `src/cmd/index.ts`
154
+ - Test: `tests/cmd/usages.test.ts`
155
+
156
+ **Step 1: Write failing command test**
157
+
158
+ `tests/cmd/usages.test.ts`:
159
+ ```ts
160
+ import { describe, expect, it, vi } from "vitest";
161
+ import { createProgram } from "../../src/cli";
162
+ import { createApiClients } from "../../src/core/api/client";
163
+
164
+ vi.mock("../../src/core/api/client", () => ({ createApiClients: vi.fn() }));
165
+
166
+ describe("usages command", () => {
167
+ it("prints chart and table", async () => {
168
+ (createApiClients as unknown as ReturnType<typeof vi.fn>).mockReturnValue({
169
+ usageService: { ListUsage: vi.fn().mockResolvedValue({ usages: [] }) },
170
+ });
171
+ const log = vi.spyOn(console, "log").mockImplementation(() => {});
172
+ const program = createProgram();
173
+ await program.parseAsync(["node", "getrouter", "usages"]);
174
+ expect(log.mock.calls.length).toBeGreaterThan(0);
175
+ log.mockRestore();
176
+ });
177
+ });
178
+ ```
179
+
180
+ **Step 2: Run test and observe failure**
181
+
182
+ ```bash
183
+ bun run test -- tests/cmd/usages.test.ts
184
+ ```
185
+ Expected: FAIL (command not registered).
186
+
187
+ **Step 3: Implement command**
188
+
189
+ `src/cmd/usages.ts`:
190
+ - Use `createApiClients().usageService.ListUsage` with pagination.
191
+ - Collect rows until 7 unique days found (or pages exhausted).
192
+ - Use `aggregateUsages` + `renderUsageChart`/`renderUsageTable`.
193
+ - Always print chart + table.
194
+
195
+ **Step 4: Register command**
196
+
197
+ In `src/cmd/index.ts`, add `registerUsagesCommand`.
198
+
199
+ **Step 5: Re-run test**
200
+
201
+ ```bash
202
+ bun run test -- tests/cmd/usages.test.ts
203
+ ```
204
+ Expected: PASS.
205
+
206
+ **Step 6: Commit**
207
+
208
+ ```bash
209
+ git add src/cmd/usages.ts src/cmd/index.ts tests/cmd/usages.test.ts
210
+ git commit -m "feat: add usages command"
211
+ ```
212
+
213
+ ---
214
+
215
+ ### Task 4: Simplify login/logout + status command
216
+
217
+ **Files:**
218
+ - Modify: `src/cmd/auth.ts` (or rename to `login.ts` if preferred)
219
+ - Create: `src/cmd/status.ts`
220
+ - Modify: `src/cmd/index.ts`
221
+ - Modify: `tests/cmd/auth.test.ts` → adjust to new command name
222
+ - Modify: `tests/cmd/subscription.test.ts` → replace with status tests
223
+
224
+ **Step 1: Update tests for login/logout**
225
+
226
+ Change `tests/cmd/auth.test.ts` to call:
227
+ - `getrouter login`
228
+ - `getrouter logout`
229
+
230
+ Run:
231
+ ```bash
232
+ bun run test -- tests/cmd/auth.test.ts
233
+ ```
234
+ Expected: FAIL (command not found).
235
+
236
+ **Step 2: Implement top-level login/logout**
237
+
238
+ Update `src/cmd/auth.ts` to register commands directly on program:
239
+ - `program.command("login")` and `program.command("logout")`
240
+ - Same behavior as existing auth login/logout.
241
+
242
+ **Step 3: Add status command tests**
243
+
244
+ Create `tests/cmd/status.test.ts` covering:
245
+ - Logged-out status output (auth missing)
246
+ - Logged-in status output with expiresAt
247
+ - Subscription info displayed
248
+
249
+ **Step 4: Implement status command**
250
+
251
+ Create `src/cmd/status.ts`:
252
+ - Fetch auth status via `getAuthStatus()`
253
+ - Fetch subscription via `subscriptionService.CurrentSubscription({})`
254
+ - Render combined status output with emoji and alignment
255
+
256
+ **Step 5: Remove subscription command registration**
257
+
258
+ Update `src/cmd/index.ts` to stop registering subscription.
259
+
260
+ **Step 6: Run tests**
261
+
262
+ ```bash
263
+ bun run test -- tests/cmd/auth.test.ts tests/cmd/status.test.ts
264
+ ```
265
+ Expected: PASS.
266
+
267
+ **Step 7: Commit**
268
+
269
+ ```bash
270
+ git add src/cmd/auth.ts src/cmd/status.ts src/cmd/index.ts tests/cmd/auth.test.ts tests/cmd/status.test.ts
271
+ git commit -m "feat: add login/logout and status commands"
272
+ ```
273
+
274
+ ---
275
+
276
+ ### Task 5: Keys interactive menu
277
+
278
+ **Files:**
279
+ - Modify: `src/cmd/keys.ts`
280
+ - Modify: `src/core/interactive/keys.ts` (menu helpers)
281
+ - Modify: `tests/cmd/keys.test.ts`
282
+
283
+ **Step 1: Update tests to use menu flow**
284
+
285
+ Adjust `tests/cmd/keys.test.ts` to call `getrouter keys` with prompts injection for:
286
+ - list
287
+ - get
288
+ - create
289
+ - update
290
+ - delete
291
+
292
+ Run:
293
+ ```bash
294
+ bun run test -- tests/cmd/keys.test.ts
295
+ ```
296
+ Expected: FAIL (menu not implemented).
297
+
298
+ **Step 2: Implement menu helper**
299
+
300
+ Extend `src/core/interactive/keys.ts` with a menu prompt that returns selected action.
301
+
302
+ **Step 3: Refactor keys command**
303
+
304
+ Update `src/cmd/keys.ts`:
305
+ - Replace subcommands with a single `.command("keys")` that loops menu.
306
+ - Use existing list/get/create/update/delete logic internally.
307
+ - Confirm delete via y/N prompt.
308
+
309
+ **Step 4: Re-run tests**
310
+
311
+ ```bash
312
+ bun run test -- tests/cmd/keys.test.ts
313
+ ```
314
+ Expected: PASS.
315
+
316
+ **Step 5: Commit**
317
+
318
+ ```bash
319
+ git add src/cmd/keys.ts src/core/interactive/keys.ts tests/cmd/keys.test.ts
320
+ git commit -m "feat: add interactive keys menu"
321
+ ```
322
+
323
+ ---
324
+
325
+ ### Task 6: codex/claude commands (replace setup env)
326
+
327
+ **Files:**
328
+ - Modify: `src/core/setup/env.ts`
329
+ - Create: `src/cmd/codex.ts`
330
+ - Create: `src/cmd/claude.ts`
331
+ - Modify: `src/cmd/index.ts`
332
+ - Remove: `src/cmd/setup.ts`
333
+ - Modify: `tests/cmd/setup.test.ts` → replace with codex/claude tests
334
+
335
+ **Step 1: Add failing tests**
336
+
337
+ Create `tests/cmd/codex.test.ts` + `tests/cmd/claude.test.ts` to verify:
338
+ - env file writing with correct variables only
339
+ - `--install` triggers rc append
340
+ - immediate `process.env` update (assert within command)
341
+
342
+ Run:
343
+ ```bash
344
+ bun run test -- tests/cmd/codex.test.ts tests/cmd/claude.test.ts
345
+ ```
346
+ Expected: FAIL.
347
+
348
+ **Step 2: Update env helpers**
349
+
350
+ In `src/core/setup/env.ts`, add helpers to build provider-specific env (only OpenAI or only Anthropic). Reuse existing render logic.
351
+
352
+ **Step 3: Implement codex/claude commands**
353
+
354
+ Each command:
355
+ - Select key (interactive if missing)
356
+ - Render provider-specific env
357
+ - Write env file
358
+ - If `--install`: append to rc, set `process.env`, and attempt to `source`/`. <path>` (best-effort)
359
+
360
+ **Step 4: Remove setup env**
361
+
362
+ Stop registering setup, delete file + tests.
363
+
364
+ **Step 5: Re-run tests**
365
+
366
+ ```bash
367
+ bun run test -- tests/cmd/codex.test.ts tests/cmd/claude.test.ts
368
+ ```
369
+ Expected: PASS.
370
+
371
+ **Step 6: Commit**
372
+
373
+ ```bash
374
+ git add src/core/setup/env.ts src/cmd/codex.ts src/cmd/claude.ts src/cmd/index.ts tests/cmd/codex.test.ts tests/cmd/claude.test.ts
375
+ git rm src/cmd/setup.ts tests/cmd/setup.test.ts
376
+ git commit -m "feat: add codex/claude env commands"
377
+ ```
378
+
379
+ ---
380
+
381
+ ### Task 7: Simplify config command
382
+
383
+ **Files:**
384
+ - Modify: `src/cmd/config.ts`
385
+ - Modify: `tests/cmd/config.test.ts`
386
+
387
+ **Step 1: Update tests**
388
+
389
+ Adjust `tests/cmd/config.test.ts` to call:
390
+ - `getrouter config`
391
+ - `getrouter config apiBase https://...`
392
+
393
+ Run:
394
+ ```bash
395
+ bun run test -- tests/cmd/config.test.ts
396
+ ```
397
+ Expected: FAIL.
398
+
399
+ **Step 2: Implement simplified command**
400
+
401
+ Update command to:
402
+ - No subcommands
403
+ - No `--json`
404
+ - Show all config by default
405
+
406
+ **Step 3: Re-run test**
407
+
408
+ ```bash
409
+ bun run test -- tests/cmd/config.test.ts
410
+ ```
411
+ Expected: PASS.
412
+
413
+ **Step 4: Commit**
414
+
415
+ ```bash
416
+ git add src/cmd/config.ts tests/cmd/config.test.ts
417
+ git commit -m "feat: simplify config command"
418
+ ```
419
+
420
+ ---
421
+
422
+ ### Task 8: Update command registration + docs
423
+
424
+ **Files:**
425
+ - Modify: `src/cmd/index.ts`
426
+ - Modify: `README.md`
427
+ - Modify: `AGENTS.md`
428
+
429
+ **Step 1: Update command registration**
430
+
431
+ Ensure only: login/logout/keys/usages/status/codex/claude/config registered.
432
+
433
+ **Step 2: Update docs**
434
+
435
+ Adjust README quick start + command list to new UX. Update AGENTS command list to match.
436
+
437
+ **Step 3: Run full test suite**
438
+
439
+ ```bash
440
+ bun run test
441
+ ```
442
+ Expected: PASS.
443
+
444
+ **Step 4: Commit**
445
+
446
+ ```bash
447
+ git add src/cmd/index.ts README.md AGENTS.md
448
+ git commit -m "docs: update command list"
449
+ ```
450
+
451
+ ---
452
+
453
+ ### Task 9: Final verification
454
+
455
+ **Step 1: Run format + tests**
456
+
457
+ ```bash
458
+ bun run format
459
+ bun run test
460
+ ```
461
+ Expected: PASS.
462
+
463
+ **Step 2: Final commit if needed**
464
+
465
+ ```bash
466
+ git status -sb
467
+ ```
468
+ Ensure clean.
@@ -0,0 +1,116 @@
1
+ # README Command Descriptions Implementation Plan
2
+
3
+ > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
4
+
5
+ **Goal:** Add per-command explanations in README quick start/common commands/development sections (English + Chinese).
6
+
7
+ **Architecture:** Convert command code blocks to bullet lists with inline command + short description; keep existing notes/options intact.
8
+
9
+ **Tech Stack:** Markdown.
10
+
11
+ ### Task 1: Update English sections in README
12
+
13
+ **Files:**
14
+ - Modify: `README.md`
15
+
16
+ **Step 1: Replace English Quick Start block with a described list**
17
+
18
+ ```md
19
+ ### Quick Start
20
+ - `getrouter auth login` — sign in via device flow
21
+ - `getrouter keys list` — view API keys you can use
22
+ - `getrouter setup env` — generate env exports for vibecoding tools
23
+ ```
24
+
25
+ **Step 2: Replace English Common Commands block with a described list**
26
+
27
+ ```md
28
+ ### Common Commands
29
+ - `getrouter auth login` — log in via device flow
30
+ - `getrouter auth logout` — clear local tokens
31
+ - `getrouter auth status` — show login status and token expiry
32
+ - `getrouter keys list` — list API keys
33
+ - `getrouter keys create` — create a new API key
34
+ - `getrouter keys update` — update key name/metadata
35
+ - `getrouter keys delete` — delete an API key
36
+ - `getrouter keys get` — show a single key (use `--show-secret` to reveal full token)
37
+ - `getrouter subscription show` — show current subscription/plan
38
+ - `getrouter setup env [--key <id>] [--print] [--install] [--shell <zsh|bash|fish|pwsh>]` — generate or print env exports for OpenAI/Anthropic-compatible tools
39
+ - `getrouter config get` — read CLI config
40
+ - `getrouter config set` — update CLI config
41
+ - `getrouter plans list` — list available plans
42
+ - `getrouter models list` — list available models
43
+ - `getrouter providers list` — list supported providers
44
+ - `getrouter user current` — show current account info
45
+ ```
46
+
47
+ **Step 3: Replace English Development block with a described list**
48
+
49
+ ```md
50
+ ### Development
51
+ - `npm install` — install dependencies
52
+ - `npm run dev -- --help` — run the local CLI and show help
53
+ - `npm test` — run the test suite
54
+ ```
55
+
56
+ ### Task 2: Update Chinese sections in README
57
+
58
+ **Files:**
59
+ - Modify: `README.md`
60
+
61
+ **Step 1: Replace Chinese Quick Start block with a described list**
62
+
63
+ ```md
64
+ ### 快速开始
65
+ - `getrouter auth login` — 登录并完成设备码授权
66
+ - `getrouter keys list` — 查看已有 API key
67
+ - `getrouter setup env` — 生成供工具加载的环境变量
68
+ ```
69
+
70
+ **Step 2: Replace Chinese Common Commands block with a described list**
71
+
72
+ ```md
73
+ ### 常用命令
74
+ - `getrouter auth login` — 设备码登录
75
+ - `getrouter auth logout` — 退出并清除本地 token
76
+ - `getrouter auth status` — 查看登录状态与过期时间
77
+ - `getrouter keys list` — 列出 API key
78
+ - `getrouter keys create` — 创建 API key
79
+ - `getrouter keys update` — 更新 key 名称/信息
80
+ - `getrouter keys delete` — 删除 API key
81
+ - `getrouter keys get` — 查看指定 key(配合 `--show-secret` 显示完整 token)
82
+ - `getrouter subscription show` — 查看订阅信息
83
+ - `getrouter setup env [--key <id>] [--print] [--install] [--shell <zsh|bash|fish|pwsh>]` — 生成或输出 OpenAI/Anthropic 兼容的环境变量
84
+ - `getrouter config get` — 读取 CLI 配置
85
+ - `getrouter config set` — 修改 CLI 配置
86
+ - `getrouter plans list` — 查看可用套餐
87
+ - `getrouter models list` — 查看可用模型
88
+ - `getrouter providers list` — 查看可用供应商
89
+ - `getrouter user current` — 查看当前账号信息
90
+ ```
91
+
92
+ **Step 3: Replace Chinese Development block with a described list**
93
+
94
+ ```md
95
+ ### 开发
96
+ - `npm install` — 安装依赖
97
+ - `npm run dev -- --help` — 本地运行 CLI 并查看帮助
98
+ - `npm test` — 运行测试
99
+ ```
100
+
101
+ ### Task 3: Verify and commit
102
+
103
+ **Step 1: Sanity-check README formatting**
104
+
105
+ Open `README.md` and ensure headings and lists render correctly.
106
+
107
+ **Step 2: Tests**
108
+
109
+ No tests required for README-only changes.
110
+
111
+ **Step 3: Commit**
112
+
113
+ ```bash
114
+ git add README.md
115
+ git commit -m "docs: add command descriptions to README"
116
+ ```
@@ -0,0 +1,75 @@
1
+ # Tsdown Migration Implementation Plan
2
+
3
+ > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
4
+
5
+ **Goal:** Replace tsup with tsdown for builds, accept tsdown defaults, and remove tsup config/dependency.
6
+
7
+ **Architecture:** Use `tsdown` as the build script, add a minimal `tsdown.config.ts` with only `entry`, and update docs to reference tsdown.
8
+
9
+ **Tech Stack:** Bun, tsdown.
10
+
11
+ ### Task 1: Switch build tooling to tsdown
12
+
13
+ **Files:**
14
+ - Modify: `package.json`
15
+ - Modify: `bun.lock`
16
+ - Delete: `tsup.config.ts`
17
+ - Create: `tsdown.config.ts`
18
+
19
+ **Step 1: Install tsdown and remove tsup**
20
+
21
+ Run:
22
+ ```bash
23
+ bun add -d tsdown
24
+ bun remove tsup
25
+ ```
26
+ Expected: `package.json` devDependencies updated, `bun.lock` updated.
27
+
28
+ **Step 2: Update build script**
29
+
30
+ Edit `package.json`:
31
+ ```json
32
+ "build": "tsdown"
33
+ ```
34
+
35
+ **Step 3: Add minimal tsdown config (defaults)**
36
+
37
+ Create `tsdown.config.ts`:
38
+ ```ts
39
+ import { defineConfig } from "tsdown";
40
+
41
+ export default defineConfig({
42
+ entry: ["src/bin.ts"],
43
+ });
44
+ ```
45
+
46
+ **Step 4: Remove tsup config**
47
+
48
+ Delete `tsup.config.ts`.
49
+
50
+ ### Task 2: Update docs to reference tsdown
51
+
52
+ **Files:**
53
+ - Modify: `AGENTS.md`
54
+
55
+ **Step 1: Update build description**
56
+
57
+ Replace tsup wording with tsdown in build command description.
58
+
59
+ ### Task 3: Verify and commit
60
+
61
+ **Step 1: Run build**
62
+
63
+ Run:
64
+ ```bash
65
+ bun run build
66
+ ```
67
+ Expected: build completes without errors.
68
+
69
+ **Step 2: Commit**
70
+
71
+ ```bash
72
+ git add package.json bun.lock tsdown.config.ts AGENTS.md
73
+ git rm tsup.config.ts
74
+ git commit -m "chore: migrate build to tsdown"
75
+ ```
@@ -0,0 +1,49 @@
1
+ # CLI Command Cleanup + README Localization Design
2
+
3
+ ## Goals
4
+ - Remove command entrypoints that are not registered in `--help` to keep the CLI surface minimal and consistent.
5
+ - Keep existing, registered commands unchanged (`auth`, `codex`, `claude`, `config`, `keys`, `models`, `status`, `usages`).
6
+ - Split README content by language: English in `README.md`, Simplified Chinese in `README.zh-cn.md`, and Japanese in `README.ja.md`.
7
+ - Keep documentation structure consistent across languages.
8
+
9
+ ## Non-Goals
10
+ - No new commands or flags.
11
+ - No changes to existing command behavior or output.
12
+ - No dependency changes.
13
+
14
+ ## Command Cleanup Scope
15
+ Commands that are implemented but not registered in `src/cmd/index.ts` should be removed:
16
+ - `src/cmd/plans.ts`
17
+ - `src/cmd/providers.ts`
18
+ - `src/cmd/subscription.ts`
19
+ - `src/cmd/user.ts`
20
+
21
+ Notes:
22
+ - `src/cmd/env.ts` stays because it is used by `codex` and `claude`.
23
+ - No tests currently cover the removed commands; no new tests required unless help output is asserted.
24
+
25
+ ## Documentation Split
26
+ - `README.md`: English only. Add language switch links at the top.
27
+ - `README.zh-cn.md`: Move the existing Chinese section into this file.
28
+ - `README.ja.md`: Japanese translation based on the English README.
29
+ - Keep section order and content consistent across languages (Requirements, Install, Quick Start, etc.).
30
+
31
+ ## Help Output Consistency
32
+ - Help output should only include the commands registered in `src/cmd/index.ts`.
33
+ - Removing unused command files ensures no confusion about unsupported commands.
34
+
35
+ ## Testing Plan
36
+ - Run the full suite after changes:
37
+ - `bun run test`
38
+ - `bun run typecheck`
39
+ - `bun run lint`
40
+ - `bun run format`
41
+
42
+ ## Files To Touch
43
+ - Delete: `src/cmd/plans.ts`
44
+ - Delete: `src/cmd/providers.ts`
45
+ - Delete: `src/cmd/subscription.ts`
46
+ - Delete: `src/cmd/user.ts`
47
+ - Modify: `README.md`
48
+ - Create: `README.zh-cn.md`
49
+ - Create: `README.ja.md`