codex-model-router 1.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/LICENSE +21 -0
- package/README.md +156 -0
- package/bin/codex-model-router.js +4 -0
- package/lib/router-core.js +679 -0
- package/lib/router.js +210 -0
- package/lib/toml.js +420 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Honguan
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# codex-model-router
|
|
2
|
+
|
|
3
|
+
A small Node.js CLI that installs a Codex skill and two custom subagents without replacing unrelated user configuration.
|
|
4
|
+
|
|
5
|
+
Routing is advisory: Terra reads the skill and decides when to delegate. This package does not intercept prompts or guarantee a hard model switch.
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Node.js 18 or newer
|
|
10
|
+
- A current Codex release with custom agents and local skills
|
|
11
|
+
|
|
12
|
+
## Install
|
|
13
|
+
|
|
14
|
+
From npm after publication:
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
npx codex-model-router install
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
From GitHub:
|
|
21
|
+
|
|
22
|
+
```sh
|
|
23
|
+
npm install -g https://github.com/Honguan/codex-model-router/archive/refs/tags/v1.1.0.tar.gz
|
|
24
|
+
codex-model-router install
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Project scope is the default. Use `--global` only when the setup should apply to every project:
|
|
28
|
+
|
|
29
|
+
```sh
|
|
30
|
+
codex-model-router install --global
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
A normal install preserves an existing main model. To explicitly set Terra/high and make the change reversible:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
codex-model-router install --set-default
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Preview without writing anything:
|
|
40
|
+
|
|
41
|
+
```sh
|
|
42
|
+
codex-model-router install --set-default --dry-run
|
|
43
|
+
codex-model-router uninstall --dry-run
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## What is changed
|
|
47
|
+
|
|
48
|
+
Project scope manages only:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
.codex/config.toml
|
|
52
|
+
.codex/agents/luna.toml
|
|
53
|
+
.codex/agents/sol.toml
|
|
54
|
+
.agents/skills/model-router/SKILL.md
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Global scope uses `$CODEX_HOME` or `~/.codex` for Codex files and `~/.agents/skills/model-router/` for the skill.
|
|
58
|
+
|
|
59
|
+
A plain install adds Terra/high only when the top-level values are absent. Existing values are preserved. `--set-default` replaces only `model` and `model_reasoning_effort`, records the exact prior values, and restores them during uninstall only when the user has not changed them afterward.
|
|
60
|
+
|
|
61
|
+
Existing Luna, Sol, or skill files are never overwritten. Uninstall removes only unchanged package-owned files. Unrelated TOML settings, comments, BOM, ordering, and LF/CRLF line endings are preserved.
|
|
62
|
+
|
|
63
|
+
## Installed routing
|
|
64
|
+
|
|
65
|
+
- Terra/high: normal questions, coding, debugging, fixes, tests, and implementation
|
|
66
|
+
- Luna/high: deterministic repeated edits, bulk patterns, searches, formatting, counting, extraction, and summaries
|
|
67
|
+
- Sol/medium/workspace-write: security-sensitive or high-regression-risk review and implementation
|
|
68
|
+
- Sol normally reviews first; it may edit files when Terra explicitly delegates implementation or a confirmed fix
|
|
69
|
+
- Simple questions do not spawn a subagent
|
|
70
|
+
|
|
71
|
+
Users may edit model names, reasoning levels, and `sandbox_mode` directly in the generated TOML files. Later installs preserve those manual edits and `doctor` reports them as user-modified.
|
|
72
|
+
|
|
73
|
+
## Commands
|
|
74
|
+
|
|
75
|
+
```text
|
|
76
|
+
codex-model-router install [--global] [--set-default] [--dry-run]
|
|
77
|
+
codex-model-router uninstall [--global] [--dry-run]
|
|
78
|
+
codex-model-router doctor [--global]
|
|
79
|
+
codex-model-router --version
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
`doctor` is read-only. Exit code `0` means healthy; exit code `1` reports missing, invalid, user-modified, overridden, or unsafe state.
|
|
83
|
+
|
|
84
|
+
## Automatic npm publication
|
|
85
|
+
|
|
86
|
+
Create a GitHub Actions repository secret named `NPM_TOKEN`:
|
|
87
|
+
|
|
88
|
+
```text
|
|
89
|
+
Repository Settings
|
|
90
|
+
→ Secrets and variables
|
|
91
|
+
→ Actions
|
|
92
|
+
→ New repository secret
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Paste the npm access token as the secret value. Never place the real token in this repository or in the workflow YAML.
|
|
96
|
+
|
|
97
|
+
The `Release` workflow runs after a pull request is merged into `main`, or when started manually. It:
|
|
98
|
+
|
|
99
|
+
1. Runs syntax checks, tests, and the packed-package smoke test.
|
|
100
|
+
2. Reads the name and version from `package.json`.
|
|
101
|
+
3. Creates the matching GitHub release when missing.
|
|
102
|
+
4. Checks whether that exact version already exists on npm.
|
|
103
|
+
5. Publishes only a version that is not already present.
|
|
104
|
+
|
|
105
|
+
Before merging a new release, update `package.json` and `CHANGELOG.md` to the new version. Merges without a version change do not republish the package.
|
|
106
|
+
|
|
107
|
+
The npm token must have package read/write permission and must be permitted to publish without an interactive OTP when the account or package requires 2FA.
|
|
108
|
+
|
|
109
|
+
To publish the current version after adding the secret, open `Actions → Release → Run workflow`.
|
|
110
|
+
|
|
111
|
+
## Manual npm publication
|
|
112
|
+
|
|
113
|
+
The package name is unscoped and public. Before the first publish, confirm the name is available and sign in:
|
|
114
|
+
|
|
115
|
+
```sh
|
|
116
|
+
npm view codex-model-router
|
|
117
|
+
npm login
|
|
118
|
+
npm whoami
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
Review exactly what will be uploaded:
|
|
122
|
+
|
|
123
|
+
```sh
|
|
124
|
+
npm run check
|
|
125
|
+
npm test
|
|
126
|
+
npm run test:package
|
|
127
|
+
npm pack --dry-run
|
|
128
|
+
npm publish --dry-run
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Publish from the package root:
|
|
132
|
+
|
|
133
|
+
```sh
|
|
134
|
+
npm publish
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
After publication, verify:
|
|
138
|
+
|
|
139
|
+
```sh
|
|
140
|
+
npm view codex-model-router version
|
|
141
|
+
npx codex-model-router --version
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
For maximum security, npm Trusted Publishing can replace the long-lived token later.
|
|
145
|
+
|
|
146
|
+
## Safety behavior
|
|
147
|
+
|
|
148
|
+
- Refuses malformed or unsafe configuration before writing
|
|
149
|
+
- Uses atomic file replacement and rolls back failed multi-file upgrades where possible
|
|
150
|
+
- Stores a small package-owned state file and one backup only when an existing config is changed
|
|
151
|
+
- Never modifies `AGENTS.md`, shell profiles, editor settings, hooks, MCP servers, telemetry, or environment variables
|
|
152
|
+
- Dry-run creates no files, directories, backups, or temporary state
|
|
153
|
+
|
|
154
|
+
Restart Codex if newly installed agents or skills are not immediately visible.
|
|
155
|
+
|
|
156
|
+
Codex references: [Subagents](https://developers.openai.com/codex/subagents), [Build skills](https://developers.openai.com/codex/build-skills), and [Configuration reference](https://developers.openai.com/codex/config-reference).
|