@alexeiled/claude-router 0.4.0 → 0.4.1

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "router",
3
3
  "displayName": "Router",
4
- "version": "0.4.0",
4
+ "version": "0.4.1",
5
5
  "description": "Auto-picks the right Claude model for each turn — small models for quick edits, mid-tier for code, frontier for hard problems. Uses Jev to classify each request.",
6
6
  "author": { "name": "Alexei Ledenev", "url": "https://github.com/alexei-led" },
7
7
  "repository": "https://github.com/alexei-led/claude-router",
@@ -6,7 +6,7 @@
6
6
  | ------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
7
7
  | TypeSafe API key | `TYPESAFE_API_KEY` in the environment of the gateway | One name in all places. The key is never in a file. |
8
8
  | The key for an installed plugin | The plugin option `typesafe_api_key`. Claude Code asks for it when you enable the plugin and stores it in the macOS Keychain. The `SessionStart` hook gives it to the gateway as `TYPESAFE_API_KEY`. | Claude Code exports plugin options as `CLAUDE_PLUGIN_OPTION_<KEY>`. The gateway does not read that name. |
9
- | Claude Code settings | `~/.claude/settings.json`: `model`, `env.ANTHROPIC_BASE_URL`, the picker row, the status line. `/router:setup` writes them. | Claude Code reads the base URL at start. A plugin cannot set it. |
9
+ | Claude Code settings | `~/.claude/settings.json`: `model`, `env.ANTHROPIC_BASE_URL`, the `modelPicker` row, the status line. `/router:setup` writes them. | Claude Code reads the base URL at start. A plugin cannot set it. |
10
10
  | Routing configuration | `~/.claude/router.json`, user scope only | A cloned repository must not change your routing or your spend. |
11
11
 
12
12
  The gateway ignores project files. To use another file, set
@@ -23,16 +23,30 @@ starts it again.
23
23
  "model": "router",
24
24
  "env": {
25
25
  "ANTHROPIC_BASE_URL": "http://127.0.0.1:43170",
26
- "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1000000",
27
- "ANTHROPIC_CUSTOM_MODEL_OPTION": "router",
28
- "ANTHROPIC_CUSTOM_MODEL_OPTION_NAME": "Router (auto)",
29
- "ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION": "Picks Opus 5.5 / Sonnet 5 / Haiku 4.5 and the effort for each turn"
26
+ "CLAUDE_CODE_MAX_CONTEXT_TOKENS": "1000000"
27
+ },
28
+ "modelPicker": {
29
+ "options": [
30
+ {
31
+ "model": "router",
32
+ "label": "Router (auto)",
33
+ "description": "Auto-selects the model and effort for each turn",
34
+ "behavesAs": "claude-opus-5-5"
35
+ }
36
+ ]
30
37
  }
31
38
  }
32
39
  ```
33
40
 
34
- The three `ANTHROPIC_CUSTOM_MODEL_OPTION*` keys add a `Router (auto)` row to
35
- the `/model` picker.
41
+ The `modelPicker` row adds `Router (auto)` to the `/model` picker, next to the
42
+ built-in rows. `behavesAs` maps `router` to a model that Claude Code knows.
43
+ Without it, Claude Code rejects `router` because the model is not in its
44
+ catalog. Setup also removes the `ANTHROPIC_CUSTOM_MODEL_OPTION*` keys that
45
+ older versions wrote.
46
+
47
+ Setup writes the file as its last step. Restart Claude Code after it. Until
48
+ the restart, the session sends `router` to Anthropic and shows "There's an
49
+ issue with the selected model (router)".
36
50
 
37
51
  Claude Code does not know the model `router`, so it assumes a 200K window.
38
52
  `CLAUDE_CODE_MAX_CONTEXT_TOKENS` declares the real window: the largest
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alexeiled/claude-router",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "Claude Code plugin: auto-picks the right model and effort for each turn using Jev routing.",
5
5
  "license": "MIT",
6
6
  "author": "Alexei Ledenev",
@@ -5,21 +5,25 @@ disable-model-invocation: true
5
5
  allowed-tools: Read, Edit, Write
6
6
  ---
7
7
 
8
- Configure Claude Code for the router gateway. Do these steps:
8
+ Configure Claude Code for the router gateway. This session does not use the gateway until Claude Code restarts. When the file has `model: "router"`, this session can fail its next request. So ask all questions first, write the file once, and write it last.
9
9
 
10
- 1. Read `~/.claude/settings.json`. If the file does not exist, start from `{}`.
11
- 2. Set the key `model` to `"router"`.
12
- 3. Set the key `env.ANTHROPIC_BASE_URL` to `"http://127.0.0.1:43170"`. If `~/.claude/router.json` sets `gateway.port`, use that port.
13
- 4. Set these keys in `env`, for the `/model` picker row:
14
- - `ANTHROPIC_CUSTOM_MODEL_OPTION`: `"router"`
15
- - `ANTHROPIC_CUSTOM_MODEL_OPTION_NAME`: `"Router (auto)"`
16
- - `ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION`: `"Auto-selects the model and effort for each turn"`
17
- 5. Set the key `env.CLAUDE_CODE_MAX_CONTEXT_TOKENS` to `"1000000"`. Claude Code does not know the model `router` and assumes a 200K window without this key. If `~/.claude/router.json` changes `routes` or `models`, use the largest `contextWindow` of the models that the routes use. The gateway sends a turn only to a model whose window holds the context.
18
- 6. Keep every other key unchanged. Write the file.
19
- 7. The status line can show the model and effort of the last routed turn. The command is `node ${CLAUDE_PLUGIN_ROOT}/scripts/statusline.mjs`, followed by the current status line command if there is one (for example `node ${CLAUDE_PLUGIN_ROOT}/scripts/statusline.mjs claude-powerline`). Show the user the current `statusLine` value and the new one, and ask. Change `statusLine.command` only if the user agrees. Keep the other `statusLine` keys.
20
- 8. Tell the user:
21
- - Restart Claude Code. Then the router serves each turn, and `/router:status` shows the routes and the last turn.
10
+ 1. Read `~/.claude/settings.json`. If the file does not exist, start from `{}`. Read `~/.claude/router.json` if it exists.
11
+ 2. The status line can show the model and effort of the last routed turn. The command is `node ${CLAUDE_PLUGIN_ROOT}/scripts/statusline.mjs`, followed by the current status line command if there is one (for example `node ${CLAUDE_PLUGIN_ROOT}/scripts/statusline.mjs claude-powerline`). Show the user the current `statusLine` value and the new one, and ask. Change `statusLine.command` only if the user agrees. Keep the other `statusLine` keys.
12
+ 3. Prepare the new settings object in memory:
13
+ - `model`: `"router"`.
14
+ - `env.ANTHROPIC_BASE_URL`: `"http://127.0.0.1:43170"`. If `router.json` sets `gateway.port`, use that port.
15
+ - `env.CLAUDE_CODE_MAX_CONTEXT_TOKENS`: `"1000000"`. Claude Code does not know the model `router` and assumes a 200K window without this key. If `router.json` changes `routes` or `models`, use the largest `contextWindow` of the models that the routes use. The gateway sends a turn only to a model whose window holds the context.
16
+ - The `/model` picker row. In `modelPicker.options`, replace the row whose `model` is `"router"`, or append it if there is none:
17
+ `{ "model": "router", "label": "Router (auto)", "description": "Auto-selects the model and effort for each turn", "behavesAs": "claude-opus-5-5" }`.
18
+ If `modelPicker` does not exist, set it to `{ "options": [<the row>] }`. Keep the other rows and `replaceBuiltInOptions`. `behavesAs` names a model that Claude Code knows; without it, Claude Code rejects `router` as a model that is not in its catalog. If `router.json` changes the `high` route, use the `id` of its model.
19
+ - Remove `env.ANTHROPIC_CUSTOM_MODEL_OPTION`, `env.ANTHROPIC_CUSTOM_MODEL_OPTION_NAME` and `env.ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTION`. Older versions of this setup wrote them; the `modelPicker` row replaces them.
20
+ - The `statusLine` change from step 2, if the user agreed.
21
+ - Keep every other key unchanged.
22
+ 4. Tell the user, before you write the file:
23
+ - Restart Claude Code now. Until the restart, this session can show "There's an issue with the selected model (router)", because it still sends requests to Anthropic and not to the gateway.
24
+ - After the restart, the router serves each turn, and `/router:status` shows the routes and the last turn.
22
25
  - The status line path contains the plugin version. After a plugin update, run `/router:setup` again.
23
- - To stop the routing, remove `model`, `env.ANTHROPIC_BASE_URL`, `env.CLAUDE_CODE_MAX_CONTEXT_TOKENS` and the three `ANTHROPIC_CUSTOM_MODEL_OPTION*` keys, and restore the status line command.
26
+ - To stop the routing, remove `model`, `env.ANTHROPIC_BASE_URL`, `env.CLAUDE_CODE_MAX_CONTEXT_TOKENS` and the `router` row of `modelPicker.options`, and restore the status line command.
27
+ 5. Write the whole object to `~/.claude/settings.json` with one Write call. Do not use a sequence of edits. Do nothing after this step.
24
28
 
25
29
  Do not change any other file.