@weave-os/router 0.2.14
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/LICENSE +90 -0
- package/README.md +172 -0
- package/bin.js +68 -0
- package/cc-statusline.sh +951 -0
- package/codex-skills/disable-routing/SKILL.md +22 -0
- package/codex-skills/fm/SKILL.md +15 -0
- package/codex-skills/fm/scripts/emit.sh +8 -0
- package/codex-skills/force-model/SKILL.md +15 -0
- package/codex-skills/force-model/scripts/emit.sh +9 -0
- package/codex-skills/rf/SKILL.md +15 -0
- package/codex-skills/rf/scripts/emit.sh +7 -0
- package/codex-skills/router-feedback/SKILL.md +15 -0
- package/codex-skills/router-feedback/scripts/emit.sh +9 -0
- package/codex-skills/router-models/SKILL.md +51 -0
- package/codex-skills/router-off/SKILL.md +22 -0
- package/codex-skills/router-on/SKILL.md +22 -0
- package/codex-skills/router-status/SKILL.md +19 -0
- package/codex-skills/ufm/SKILL.md +14 -0
- package/codex-skills/ufm/scripts/emit.sh +3 -0
- package/codex-skills/unforce-model/SKILL.md +14 -0
- package/codex-skills/unforce-model/scripts/emit.sh +4 -0
- package/codex-status.sh +378 -0
- package/commands/beta.md +5 -0
- package/commands/fm.md +6 -0
- package/commands/force-model.md +6 -0
- package/commands/models.md +46 -0
- package/commands/rf.md +6 -0
- package/commands/router-feedback.md +6 -0
- package/commands/router-models.md +46 -0
- package/commands/router-off.md +10 -0
- package/commands/router-on.md +10 -0
- package/commands/router-session.md +15 -0
- package/commands/router-status.md +10 -0
- package/commands/ufm.md +5 -0
- package/commands/unforce-model.md +5 -0
- package/directives.tsv +13 -0
- package/install.sh +5092 -0
- package/opencode-weave/README.md +78 -0
- package/opencode-weave/package.json +18 -0
- package/opencode-weave/src/index.ts +655 -0
- package/package.json +79 -0
- package/pi-router/README.md +123 -0
- package/pi-router/package.json +25 -0
- package/pi-router/skills/install-lsps/SKILL.md +75 -0
- package/pi-router/skills/lsp-guide/SKILL.md +63 -0
- package/pi-router/src/beta.ts +21 -0
- package/pi-router/src/compaction.ts +188 -0
- package/pi-router/src/config.ts +293 -0
- package/pi-router/src/context-window.ts +12 -0
- package/pi-router/src/dispatch.ts +377 -0
- package/pi-router/src/force-model.ts +126 -0
- package/pi-router/src/index.ts +62 -0
- package/pi-router/src/lsp-broker.ts +255 -0
- package/pi-router/src/lsp-client.ts +435 -0
- package/pi-router/src/lsp-format.ts +230 -0
- package/pi-router/src/lsp-install.ts +215 -0
- package/pi-router/src/lsp-protocol.ts +128 -0
- package/pi-router/src/lsp-servers.ts +361 -0
- package/pi-router/src/lsp.ts +529 -0
- package/pi-router/src/metadata.ts +32 -0
- package/pi-router/src/pricing.generated.ts +91 -0
- package/pi-router/src/provider.ts +64 -0
- package/pi-router/src/routed-model.ts +182 -0
- package/pi-router/src/safety.ts +66 -0
- package/pi-router/src/savings.ts +191 -0
- package/pi-router/src/ui.ts +91 -0
- package/pi-router/src/wooly.ts +408 -0
- package/registry.sh +102 -0
- package/uninstall.sh +788 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
Copyright 2025 Workweave, Inc.
|
|
2
|
+
|
|
3
|
+
Elastic License 2.0
|
|
4
|
+
|
|
5
|
+
URL: https://www.elastic.co/licensing/elastic-license
|
|
6
|
+
|
|
7
|
+
## Acceptance
|
|
8
|
+
|
|
9
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide,
|
|
14
|
+
non-sublicensable, non-transferable license to use, copy, distribute, make
|
|
15
|
+
available, and prepare derivative works of the software, in each case subject to
|
|
16
|
+
the limitations and conditions below.
|
|
17
|
+
|
|
18
|
+
## Limitations
|
|
19
|
+
|
|
20
|
+
You may not provide the software to third parties as a hosted or managed
|
|
21
|
+
service, where the service provides users with access to any substantial set of
|
|
22
|
+
the features or functionality of the software.
|
|
23
|
+
|
|
24
|
+
You may not move, change, disable, or circumvent the license key functionality
|
|
25
|
+
in the software, and you may not remove or obscure any functionality in the
|
|
26
|
+
software that is protected by the license key.
|
|
27
|
+
|
|
28
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices
|
|
29
|
+
of the licensor in the software. Any use of the licensor's trademarks is subject
|
|
30
|
+
to applicable law.
|
|
31
|
+
|
|
32
|
+
## Patents
|
|
33
|
+
|
|
34
|
+
The licensor grants you a license, under any patent claims the licensor can
|
|
35
|
+
license, or becomes able to license, to make, have made, use, practice,
|
|
36
|
+
sell, offer for sale, import or transfer any part of the software. This license
|
|
37
|
+
does not cover any patent claims that you cause to be infringed by modifications
|
|
38
|
+
or additions to the software. If you or your company make any written claim that
|
|
39
|
+
the software infringes or contributes to infringement of any patent, your patent
|
|
40
|
+
license for the software granted under these terms ends immediately.
|
|
41
|
+
|
|
42
|
+
## Notices
|
|
43
|
+
|
|
44
|
+
You must ensure that anyone who gets a copy of any part of the software from you
|
|
45
|
+
also gets a copy of these terms.
|
|
46
|
+
|
|
47
|
+
If you modify the software, you must include in any modified copies of the
|
|
48
|
+
software prominent notices stating that you have modified the software.
|
|
49
|
+
|
|
50
|
+
## No Other Rights
|
|
51
|
+
|
|
52
|
+
These terms do not imply any licenses other than those expressly granted in
|
|
53
|
+
these terms.
|
|
54
|
+
|
|
55
|
+
## Termination
|
|
56
|
+
|
|
57
|
+
If you use the software in violation of these terms, such use is not licensed,
|
|
58
|
+
and your licenses will automatically terminate. If the licensor provides you
|
|
59
|
+
with a notice of your violation, and you cease all violation of this license no
|
|
60
|
+
later than 30 days after you receive that notice, your licenses will
|
|
61
|
+
automatically be reinstated unless the licensor notifies you otherwise. If you
|
|
62
|
+
violate these terms after reinstatement, any additional violation will
|
|
63
|
+
automatically and permanently terminate your licenses.
|
|
64
|
+
|
|
65
|
+
## No Liability
|
|
66
|
+
|
|
67
|
+
*As far as the law allows, the software comes as is, without any warranty or
|
|
68
|
+
condition, and the licensor will not be liable to you for any damages arising
|
|
69
|
+
out of these terms or the use or nature of the software, under any kind of
|
|
70
|
+
legal claim.*
|
|
71
|
+
|
|
72
|
+
## Definitions
|
|
73
|
+
|
|
74
|
+
The **licensor** is the entity offering these terms, and the **software** is the
|
|
75
|
+
software the licensor makes available under these terms, including any portion
|
|
76
|
+
of it.
|
|
77
|
+
|
|
78
|
+
**you** refers to the individual or entity agreeing to these terms.
|
|
79
|
+
|
|
80
|
+
**your company** is any legal entity, sole proprietorship, or other kind of
|
|
81
|
+
organization that you work for, plus all organizations that have more than 25%
|
|
82
|
+
ownership in the relationship with you.
|
|
83
|
+
|
|
84
|
+
**your licenses** are all the licenses granted to you for the software under
|
|
85
|
+
these terms.
|
|
86
|
+
|
|
87
|
+
**use** includes anything you do with the software requiring one of your
|
|
88
|
+
licenses.
|
|
89
|
+
|
|
90
|
+
**trademark** includes logos, service marks, and other designations.
|
package/README.md
ADDED
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
# @weave-os/router
|
|
2
|
+
|
|
3
|
+
One command, anywhere, to point Claude Code, Codex, opencode, or pi at the Weave Router.
|
|
4
|
+
|
|
5
|
+
The package was renamed from `@workweave/router`. The old package remains
|
|
6
|
+
published as a compatibility alias and continues to receive the same releases;
|
|
7
|
+
it prints a migration warning directing users to `@weave-os/router`.
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @weave-os/router # interactive: pick Claude Code / Codex / opencode / pi, then scope
|
|
11
|
+
npx @weave-os/router --claude # skip the picker, target Claude Code
|
|
12
|
+
npx @weave-os/router --codex # skip the picker, target the OpenAI Codex CLI
|
|
13
|
+
npx @weave-os/router setup --claude --codex # configure both native clients
|
|
14
|
+
npx @weave-os/router accounts list --claude # list enrolled subscription accounts
|
|
15
|
+
npx @weave-os/router login claude # enroll Claude Pro/Max with PKCE
|
|
16
|
+
npx @weave-os/router login codex # enroll ChatGPT Pro/Plus device flow
|
|
17
|
+
npx @weave-os/router status # connectivity, native configs, account health
|
|
18
|
+
npx @weave-os/router --opencode # skip the picker, target opencode
|
|
19
|
+
npx @weave-os/router --pi # skip the picker, target pi + Loom UI
|
|
20
|
+
npx @weave-os/router --scope project # per-repo install, commit settings.json (or .codex/ / opencode.json)
|
|
21
|
+
npx @weave-os/router --local # self-hosted via docker-compose (localhost:8080)
|
|
22
|
+
npx @weave-os/router --base-url https://router.acme.internal
|
|
23
|
+
npx @weave-os/router --non-interactive # reads $WEAVE_ROUTER_KEY, no prompts (defaults to claude)
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Re-running the installer to pick up changes reuses the key already on disk, so
|
|
27
|
+
you paste it once and never again — for every client, not just Claude Code.
|
|
28
|
+
`update` is the never-prompting form of that (safe for cron; errors instead of
|
|
29
|
+
asking when no key can be found):
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx @weave-os/router --claude # reuses the installed key
|
|
33
|
+
npx @weave-os/router --codex # same for Codex, opencode, and pi
|
|
34
|
+
npx @weave-os/router --claude --rotate-key # ignore it and prompt for a new one
|
|
35
|
+
npx @weave-os/router update --claude # non-interactive refresh in place
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
For Claude Code the installed statusline and `/force-model`, `/router-*` slash
|
|
39
|
+
commands also refresh themselves in the background about once a week (never
|
|
40
|
+
overwriting a wrapper you edited). Opt out with `WEAVE_STATUSLINE_UPDATE=0`, or
|
|
41
|
+
just the commands with `WEAVE_COMMANDS_UPDATE=0`. Codex installs native `$` skills
|
|
42
|
+
plus managed `SessionStart`/`Stop` hooks: the latest routed model is reflected in
|
|
43
|
+
the terminal title and a compact `Weave Router · …` status message is shown when
|
|
44
|
+
the router reports a new route. Existing Codex hooks are preserved. OpenCode and pi
|
|
45
|
+
have their own target-specific integrations.
|
|
46
|
+
|
|
47
|
+
Version-pin for reproducible setups:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx @weave-os/router@0.1.0 --claude --scope project
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Switch on/off without uninstalling (keeps your config so switching back is
|
|
54
|
+
instant; requires an explicit client):
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
npx @weave-os/router off --claude # route Claude Code directly to Anthropic
|
|
58
|
+
npx @weave-os/router on --claude # route Claude Code through the router again
|
|
59
|
+
npx @weave-os/router status --codex # is Codex on the router or direct?
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Claude Code reads its router setting at launch, so quit and reopen it after an
|
|
63
|
+
on/off. Codex and opencode pick it up on their next run. Inside Claude Code the
|
|
64
|
+
slash commands `/router-off`, `/router-on`, and `/router-status` do the same.
|
|
65
|
+
Codex installs `$router-status`, `$router-off`, `$router-on`, and
|
|
66
|
+
`$router-models` skills that call the same CLI verbs, plus a
|
|
67
|
+
`$disable-routing` skill that switches its next session back
|
|
68
|
+
to the normal provider; Codex does not support third-party `/disable-routing`
|
|
69
|
+
slash commands. The shell equivalent is `npx @weave-os/router disable-routing`.
|
|
70
|
+
Cursor has no config file we own — toggle its base URL override in **Settings →
|
|
71
|
+
Models** instead.
|
|
72
|
+
|
|
73
|
+
Pick which models the router is allowed to route to:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
npx @weave-os/router models --claude # list every model, with its on/off state
|
|
77
|
+
npx @weave-os/router models --codex # same, for a Codex install
|
|
78
|
+
npx @weave-os/router models disable gpt-5.6 --claude # take one out of rotation
|
|
79
|
+
npx @weave-os/router models enable gpt-5.6 --claude # put it back
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Inside Claude Code that's `/router-models` (alias `/models`). Editing needs a
|
|
83
|
+
router that serves the model-selection API; against the Weave-hosted router the
|
|
84
|
+
list still prints and points you at the dashboard, where model selection is an
|
|
85
|
+
organization-wide setting.
|
|
86
|
+
|
|
87
|
+
Uninstall:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
npx @weave-os/router --uninstall # Claude Code, user scope
|
|
91
|
+
npx @weave-os/router --uninstall --codex # Codex, user scope
|
|
92
|
+
npx @weave-os/router --uninstall --opencode # opencode, user scope
|
|
93
|
+
npx @weave-os/router --uninstall --pi # pi, user scope
|
|
94
|
+
npx @weave-os/router --uninstall --scope project # Claude Code, inside the repo
|
|
95
|
+
npx @weave-os/router --uninstall --codex --scope project
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## What it does
|
|
99
|
+
|
|
100
|
+
This package is a thin Node wrapper around [`install.sh`](../install.sh) from
|
|
101
|
+
the Weave Router repo. It exists so you can install from any machine with
|
|
102
|
+
Node ≥ 18 — no `curl | sh`, no Git clone, no PATH fiddling. Everything the
|
|
103
|
+
shell installer documents (targets, scopes, flags, environment variables)
|
|
104
|
+
works identically here.
|
|
105
|
+
|
|
106
|
+
Four install targets:
|
|
107
|
+
|
|
108
|
+
- **Claude Code** (default) — patches `~/.claude/settings.json` (or
|
|
109
|
+
`<repo>/.claude/settings.json` with `--scope project`) so `claude` routes
|
|
110
|
+
through Weave automatically. Anthropic plan credentials flow through to
|
|
111
|
+
api.anthropic.com.
|
|
112
|
+
- **Codex** (`--codex`) — patches `~/.codex/config.toml` (or
|
|
113
|
+
`<repo>/.codex/config.toml`) with a managed `[model_providers.weave]`
|
|
114
|
+
block plus `model_provider = "weave"`. The provider preserves the existing
|
|
115
|
+
ChatGPT OAuth login. No install pins `X-Weave-Router-Strategy`; every
|
|
116
|
+
endpoint keeps its router's configured default. HMM or forced
|
|
117
|
+
`gpt-5.6-sol`, `gpt-5.6-terra`, and `gpt-5.6-luna` turns use that plan;
|
|
118
|
+
every other selected model uses its WorkWeave deployment or BYOK credential.
|
|
119
|
+
The block lives between begin/end markers
|
|
120
|
+
so re-running the installer rewrites it cleanly and `--uninstall --codex`
|
|
121
|
+
removes it without touching the rest of your config. Codex does not load
|
|
122
|
+
third-party slash-command files; the installer provides native skills
|
|
123
|
+
`$force-model` (`$fm`), `$unforce-model` (`$ufm`), and `$router-feedback`
|
|
124
|
+
(`$rf`), each of which execs a local `scripts/emit.sh` that prints the same
|
|
125
|
+
leading-space directive Claude Code uses (for example,
|
|
126
|
+
` /force-model gpt-5.6-terra`) — you can also type that form directly. It
|
|
127
|
+
also installs `$router-status`, `$router-off`, `$router-on`, and
|
|
128
|
+
`$router-models`, which call this installer's own verbs, plus a
|
|
129
|
+
`$disable-routing` skill that returns the next Codex session to the default
|
|
130
|
+
provider without logging out or deleting the router configuration. The
|
|
131
|
+
managed lifecycle hooks also keep the latest routed model in the terminal
|
|
132
|
+
title and emit a compact status message when the router reports a new route.
|
|
133
|
+
- **opencode** (`--opencode`) — merges a `provider.weave` entry (backed by
|
|
134
|
+
opencode's built-in `@ai-sdk/anthropic` provider) into
|
|
135
|
+
`~/.config/opencode/opencode.json` (or `<repo>/opencode.json` with
|
|
136
|
+
`--scope project`). The router speaks the Anthropic Messages API
|
|
137
|
+
natively, so opencode talks to it unmodified. Re-install rewrites only
|
|
138
|
+
the managed `provider.weave` block; `--uninstall --opencode` strips it
|
|
139
|
+
and leaves your other providers and settings alone.
|
|
140
|
+
- **pi** (`--pi`) — registers the `weave` provider and installs this package as
|
|
141
|
+
a pi extension. Stock pi then gets the Loom startup header, Wooly's animated
|
|
142
|
+
mascot, the persistent actual-route display, cumulative session savings,
|
|
143
|
+
`/fm` + `/ufm` model-pin commands with a `[forced]` status, and the
|
|
144
|
+
context-isolated `dispatch` tool. There is no forked pi binary and no separate
|
|
145
|
+
Loom runtime.
|
|
146
|
+
|
|
147
|
+
See the [main installer docs](https://github.com/weave-os/router/tree/main/install)
|
|
148
|
+
for the full reference.
|
|
149
|
+
|
|
150
|
+
## Requirements
|
|
151
|
+
|
|
152
|
+
- Node ≥ 18 (ships with `npx`)
|
|
153
|
+
- `bash` on PATH (macOS / Linux native; Windows needs Git Bash or WSL)
|
|
154
|
+
- `jq` on PATH — used by the Claude Code status line, the Codex lifecycle helper, and the opencode/pi JSON merges.
|
|
155
|
+
|
|
156
|
+
## Why npx
|
|
157
|
+
|
|
158
|
+
`npx @weave-os/router` gives Windows support via Git Bash, painless version
|
|
159
|
+
pinning, and discoverability via the npm registry.
|
|
160
|
+
|
|
161
|
+
## Older npm
|
|
162
|
+
|
|
163
|
+
On npm ≤ 6 the bundled `npx` treats an undeclared `-y` as consuming the next
|
|
164
|
+
token, so `npx -y @weave-os/router --claude` silently drops the package name
|
|
165
|
+
and resolves the following argument as the command instead. Either upgrade
|
|
166
|
+
(`npm i -g npm@latest`) or name the binary explicitly:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
npx --package @weave-os/router -y -- weave-router --claude
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
That form is correct on every npm version.
|
package/bin.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Thin wrapper that runs install.sh with the user's arguments.
|
|
3
|
+
// Bundled install.sh ships with the npm package so `npx @weave-os/router`
|
|
4
|
+
// works offline (modulo the router API ping the installer does).
|
|
5
|
+
|
|
6
|
+
const { spawnSync } = require("node:child_process");
|
|
7
|
+
const { existsSync, readFileSync } = require("node:fs");
|
|
8
|
+
const path = require("node:path");
|
|
9
|
+
|
|
10
|
+
const args = process.argv.slice(2);
|
|
11
|
+
const packageName = JSON.parse(
|
|
12
|
+
readFileSync(path.join(__dirname, "package.json"), "utf8"),
|
|
13
|
+
).name;
|
|
14
|
+
|
|
15
|
+
if (packageName === "@workweave/router") {
|
|
16
|
+
console.error(
|
|
17
|
+
"warning: @workweave/router is deprecated; use @weave-os/router instead (npx @weave-os/router).",
|
|
18
|
+
);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const uninstallIdx = args.indexOf("--uninstall");
|
|
22
|
+
const isUninstall = uninstallIdx !== -1;
|
|
23
|
+
if (isUninstall) args.splice(uninstallIdx, 1);
|
|
24
|
+
|
|
25
|
+
const scriptName = isUninstall ? "uninstall.sh" : "install.sh";
|
|
26
|
+
const script = path.join(__dirname, scriptName);
|
|
27
|
+
|
|
28
|
+
if (!existsSync(script)) {
|
|
29
|
+
console.error(
|
|
30
|
+
`Weave Router: ${scriptName} missing from package — report it at https://github.com/weave-os/router/issues`,
|
|
31
|
+
);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const bash = pickBash();
|
|
36
|
+
if (!bash) {
|
|
37
|
+
console.error(
|
|
38
|
+
"Weave Router: bash is required. On Windows install Git Bash or run inside WSL.",
|
|
39
|
+
);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const result = spawnSync(bash, [script, ...args], {
|
|
44
|
+
stdio: "inherit",
|
|
45
|
+
env: {
|
|
46
|
+
...process.env,
|
|
47
|
+
WEAVE_ROUTER_NPM_PACKAGE: packageName,
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
if (result.error) {
|
|
52
|
+
console.error("Weave Router:", result.error.message);
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
process.exit(result.status ?? 1);
|
|
56
|
+
|
|
57
|
+
function pickBash() {
|
|
58
|
+
if (process.platform !== "win32") return "bash";
|
|
59
|
+
const candidates = [
|
|
60
|
+
process.env.SHELL,
|
|
61
|
+
"C:\\Program Files\\Git\\bin\\bash.exe",
|
|
62
|
+
"C:\\Program Files (x86)\\Git\\bin\\bash.exe",
|
|
63
|
+
].filter(Boolean);
|
|
64
|
+
for (const c of candidates) {
|
|
65
|
+
if (existsSync(c)) return c;
|
|
66
|
+
}
|
|
67
|
+
return null;
|
|
68
|
+
}
|