codex-model-router 1.1.0 → 2.0.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/MAINTAINERS.md +92 -0
- package/README.md +84 -95
- package/SECURITY.md +21 -0
- package/lib/manifest.js +207 -0
- package/lib/router-core.js +882 -240
- package/lib/router.js +1 -210
- package/lib/toml.js +11 -15
- package/package.json +16 -5
package/MAINTAINERS.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Maintainer Guide
|
|
2
|
+
|
|
3
|
+
## First npm publication bootstrap
|
|
4
|
+
|
|
5
|
+
The first publication of a new npm package cannot use Trusted Publishing because the npm package settings do not exist yet. Use the Release workflow's explicit `bootstrap` publication mode exactly once.
|
|
6
|
+
|
|
7
|
+
The bootstrap token must be a granular npm access token with package read/write access and non-interactive publishing permission. Store it only as the GitHub Actions repository secret named `NPM_TOKEN`; never commit it to the repository or write it into workflow logs.
|
|
8
|
+
|
|
9
|
+
For the first publication:
|
|
10
|
+
|
|
11
|
+
1. Open **Actions → Release → Run workflow**.
|
|
12
|
+
2. Keep the workflow definition branch on `main`.
|
|
13
|
+
3. Enter the exact version tag required by `package.json`, for example `v1.2.0`.
|
|
14
|
+
4. Select `bootstrap` for `publish_mode`.
|
|
15
|
+
5. Run the workflow.
|
|
16
|
+
|
|
17
|
+
The tag may already exist. When it does, the workflow checks out that exact tag and verifies that it is reachable from `main`.
|
|
18
|
+
|
|
19
|
+
When the tag does not yet exist, a manual bootstrap run starts from the exact current `origin/main` commit, verifies the requested tag matches `v<package.json version>`, runs all tests, validates the release metadata and current Changelog entry, and only then creates and pushes the tag. Normal mode and tag-triggered runs are never allowed to create a missing tag.
|
|
20
|
+
|
|
21
|
+
Bootstrap mode is rejected when the npm package or exact version already exists. The token is exposed only to the guarded bootstrap step. Tag-triggered releases and manual runs in `normal` mode never receive `NPM_TOKEN`.
|
|
22
|
+
|
|
23
|
+
After the first version is published, configure Trusted Publishing as described below. Once a later release succeeds through OIDC, delete the `NPM_TOKEN` repository secret.
|
|
24
|
+
|
|
25
|
+
## npm Trusted Publishing setup
|
|
26
|
+
|
|
27
|
+
This one-time npm account configuration cannot be committed to the repository.
|
|
28
|
+
|
|
29
|
+
On the npm package settings page for `codex-model-router`, add a GitHub Actions trusted publisher with:
|
|
30
|
+
|
|
31
|
+
```text
|
|
32
|
+
Organization or user: Honguan
|
|
33
|
+
Repository: codex-model-router
|
|
34
|
+
Workflow filename: release.yml
|
|
35
|
+
Environment: leave empty unless the workflow is updated to use one
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
The same relationship can be configured by an authenticated maintainer with npm 11.15.0 or newer:
|
|
39
|
+
|
|
40
|
+
```sh
|
|
41
|
+
npm trust github codex-model-router \
|
|
42
|
+
--repo Honguan/codex-model-router \
|
|
43
|
+
--file release.yml \
|
|
44
|
+
--allow-publish \
|
|
45
|
+
--yes
|
|
46
|
+
npm trust list codex-model-router
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Normal releases use only `contents: write` and `id-token: write` and publish with provenance.
|
|
50
|
+
|
|
51
|
+
## Release checklist
|
|
52
|
+
|
|
53
|
+
1. Verify all Issues and pull-request checks are complete.
|
|
54
|
+
2. Update `package.json`, `CHANGELOG.md`, README version examples, and the shared manifest behavior together.
|
|
55
|
+
3. Run `npm run check`, `npm test`, `npm run test:package`, and `npm pack --dry-run`.
|
|
56
|
+
4. Confirm CI passes on Windows, Linux, and macOS with Node.js 18, 20, 22, and 24.
|
|
57
|
+
5. Confirm actionlint and ShellCheck pass.
|
|
58
|
+
6. For normal releases, create and push the exact tag `v<package.json version>` from `main`.
|
|
59
|
+
7. For the first package publication only, the manual bootstrap flow may create the missing exact tag after all validations pass.
|
|
60
|
+
8. Verify the Release workflow publishes with npm provenance.
|
|
61
|
+
9. Verify the clean public npm end-to-end step passes before the GitHub Release appears.
|
|
62
|
+
10. Confirm `npm view codex-model-router version` and `npx --yes codex-model-router@<version> --version`.
|
|
63
|
+
|
|
64
|
+
## Manual release retry
|
|
65
|
+
|
|
66
|
+
Open **Actions → Release → Run workflow**, keep the workflow definition on `main`, and enter the exact version tag in the required `tag` field.
|
|
67
|
+
|
|
68
|
+
Select publication mode as follows:
|
|
69
|
+
|
|
70
|
+
- `bootstrap`: only for the first creation of the npm package; it may safely create the missing exact version tag from current `main` after validation.
|
|
71
|
+
- `normal`: every later version and every idempotent retry after the package exists; the tag must already exist.
|
|
72
|
+
|
|
73
|
+
The branch selector chooses which workflow definition to run; it is not the release target. For an existing tag, the workflow checks out that tag, verifies that its commit is reachable from `main`, validates that the tag matches `package.json`, and then resumes the npm and GitHub Release checks.
|
|
74
|
+
|
|
75
|
+
Never enter a branch name in the `tag` field. Never reuse a package version that already exists on npm. Never use bootstrap mode for later versions.
|
|
76
|
+
|
|
77
|
+
## Compatibility update checklist
|
|
78
|
+
|
|
79
|
+
For every release that changes generated paths, TOML fields, models, or Codex integration:
|
|
80
|
+
|
|
81
|
+
1. Review the official Codex subagent, skill, and configuration references.
|
|
82
|
+
2. Record the exact Codex CLI version used as the compatibility baseline.
|
|
83
|
+
3. Run the compatibility smoke check in CI.
|
|
84
|
+
4. Update README paths and minimum version claims.
|
|
85
|
+
5. Test project and global scope separately.
|
|
86
|
+
6. Preserve Windows junction, POSIX symlink, LF/CRLF, and user-modification tests.
|
|
87
|
+
|
|
88
|
+
## Recovery
|
|
89
|
+
|
|
90
|
+
A failed npm publication does not create a GitHub Release. For an unpublished package, verify the `NPM_TOKEN` bootstrap secret and run the exact version with `publish_mode=bootstrap`; the workflow can create the missing tag safely when necessary. For an existing package, fix the Trusted Publisher relationship and retry the existing exact tag with `publish_mode=normal`.
|
|
91
|
+
|
|
92
|
+
Delete or recreate a tag manually only when npm does not contain that version and the existing tag is demonstrably wrong. Published npm versions are immutable and must never be reused.
|
package/README.md
CHANGED
|
@@ -1,156 +1,145 @@
|
|
|
1
1
|
# codex-model-router
|
|
2
2
|
|
|
3
|
-
A small Node.js CLI that installs
|
|
3
|
+
A small Node.js CLI that safely installs adaptive Codex subagent routing for Terra, Luna, and Sol without replacing unrelated user configuration or the user's selected primary model.
|
|
4
4
|
|
|
5
|
-
Routing is advisory
|
|
5
|
+
> Routing is advisory. Codex reads the installed skills and decides when to delegate. This package does not intercept prompts, guarantee a hard model switch, or modify AGENTS.md.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Routing model
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
- A current Codex release with custom agents and local skills
|
|
9
|
+
The normal installation uses free mode:
|
|
11
10
|
|
|
12
|
-
|
|
11
|
+
- The user-selected primary model handles conversation, clarification, follow-ups, final replies, and trivial work.
|
|
12
|
+
- Terra/high investigates, produces implementation-ready plans, verifies results, debugs, and replans.
|
|
13
|
+
- Luna/max performs most clear, bounded, repetitive, or independently verifiable implementation work.
|
|
14
|
+
- Sol/medium is read-only and used only when Terra still cannot resolve core logic after focused investigation and one materially revised plan, or when the user explicitly requests Sol.
|
|
15
|
+
- Existing built-in and custom agents remain available and take precedence when they are a better match.
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
A normal workflow is Terra -> Luna -> Terra. Implementation errors return to Luna as focused corrections. Plan or logic errors return to Terra for a revised plan before Luna continues. Sol is not a routine reviewer.
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
npx codex-model-router install
|
|
18
|
-
```
|
|
19
|
+
## Quick start
|
|
19
20
|
|
|
20
|
-
|
|
21
|
+
Preview without changing files:
|
|
21
22
|
|
|
22
23
|
```sh
|
|
23
|
-
|
|
24
|
-
codex-model-router install
|
|
24
|
+
npx codex-model-router install --dry-run
|
|
25
25
|
```
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
Install free-mode routing and verify it:
|
|
28
28
|
|
|
29
29
|
```sh
|
|
30
|
-
codex-model-router install
|
|
30
|
+
npx codex-model-router install
|
|
31
|
+
npx codex-model-router doctor
|
|
31
32
|
```
|
|
32
33
|
|
|
33
|
-
|
|
34
|
+
Remove only unchanged package-managed files and settings:
|
|
34
35
|
|
|
35
36
|
```sh
|
|
36
|
-
codex-model-router
|
|
37
|
+
npx codex-model-router uninstall
|
|
37
38
|
```
|
|
38
39
|
|
|
39
|
-
|
|
40
|
+
## Optional Terra default
|
|
41
|
+
|
|
42
|
+
A normal install does not add or change top-level model settings. Users remain free to select any primary model through Codex.
|
|
43
|
+
|
|
44
|
+
To explicitly set and track Terra/high as the selected scope's default:
|
|
40
45
|
|
|
41
46
|
```sh
|
|
42
|
-
codex-model-router install --set-default
|
|
43
|
-
codex-model-router uninstall --dry-run
|
|
47
|
+
codex-model-router install --set-default
|
|
44
48
|
```
|
|
45
49
|
|
|
46
|
-
|
|
50
|
+
Running a later plain `install` returns package-managed default settings to free mode. User-modified model settings are preserved.
|
|
47
51
|
|
|
48
|
-
|
|
52
|
+
## Install
|
|
49
53
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
.agents/skills/model-router/SKILL.md
|
|
54
|
+
Run from npm:
|
|
55
|
+
|
|
56
|
+
```sh
|
|
57
|
+
npx codex-model-router install
|
|
55
58
|
```
|
|
56
59
|
|
|
57
|
-
|
|
60
|
+
Install the command globally:
|
|
58
61
|
|
|
59
|
-
|
|
62
|
+
```sh
|
|
63
|
+
npm install -g codex-model-router
|
|
64
|
+
codex-model-router install
|
|
65
|
+
```
|
|
60
66
|
|
|
61
|
-
|
|
67
|
+
Installing the CLI globally only makes the command available system-wide. Use `install --global` to install routing for the current user's Codex configuration.
|
|
62
68
|
|
|
63
|
-
|
|
69
|
+
Install a specific GitHub release:
|
|
64
70
|
|
|
65
|
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
|
|
69
|
-
- Simple questions do not spawn a subagent
|
|
71
|
+
```sh
|
|
72
|
+
npm install -g https://github.com/Honguan/codex-model-router/archive/refs/tags/v2.0.0.tar.gz
|
|
73
|
+
codex-model-router install
|
|
74
|
+
```
|
|
70
75
|
|
|
71
|
-
|
|
76
|
+
## Managed files
|
|
72
77
|
|
|
73
|
-
|
|
78
|
+
Project scope is the default and manages only:
|
|
74
79
|
|
|
75
80
|
```text
|
|
76
|
-
codex
|
|
77
|
-
codex
|
|
78
|
-
codex
|
|
79
|
-
codex
|
|
81
|
+
.codex/config.toml # only with --set-default or a managed migration
|
|
82
|
+
.codex/agents/terra.toml
|
|
83
|
+
.codex/agents/luna.toml
|
|
84
|
+
.codex/agents/sol.toml
|
|
85
|
+
.codex/model-router-state.json
|
|
86
|
+
.codex/config.toml.codex-model-router.bak # only when needed
|
|
87
|
+
.agents/skills/model-router/SKILL.md
|
|
88
|
+
.agents/skills/implementation-planning/SKILL.md
|
|
80
89
|
```
|
|
81
90
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
## Automatic npm publication
|
|
91
|
+
Use global scope with:
|
|
85
92
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
Repository Settings
|
|
90
|
-
→ Secrets and variables
|
|
91
|
-
→ Actions
|
|
92
|
-
→ New repository secret
|
|
93
|
+
```sh
|
|
94
|
+
codex-model-router install --global
|
|
95
|
+
codex-model-router doctor --global
|
|
93
96
|
```
|
|
94
97
|
|
|
95
|
-
|
|
98
|
+
Global scope stores agents under `$CODEX_HOME/agents` and skills under `~/.agents/skills`. When `CODEX_HOME` is unset, it defaults to `~/.codex`.
|
|
96
99
|
|
|
97
|
-
|
|
100
|
+
Existing files at managed paths are never overwritten. Later manual edits are preserved and reported by `doctor`.
|
|
98
101
|
|
|
99
|
-
|
|
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.
|
|
102
|
+
## Prompt and cache efficiency
|
|
104
103
|
|
|
105
|
-
|
|
104
|
+
The installed model-router skill is intentionally short. Detailed planning rules live in the separate implementation-planning skill and are loaded only for nontrivial or uncertain changes.
|
|
106
105
|
|
|
107
|
-
|
|
106
|
+
Within the same agent thread, accepted state is kept and concise deltas are appended. A new agent thread receives the latest self-contained snapshot. After three deltas or a material contract or logic change, Terra produces a new snapshot.
|
|
108
107
|
|
|
109
|
-
|
|
108
|
+
Prompt-cache reuse is best effort: genuinely new information cannot be a cache hit on first use. Stable wording and ordering improve repeated-prefix reuse, but correctness takes priority over cache behavior.
|
|
110
109
|
|
|
111
|
-
##
|
|
110
|
+
## Planning rules
|
|
112
111
|
|
|
113
|
-
|
|
112
|
+
For nontrivial changes, Terra identifies only applicable correctness-critical details, including exact files and symbols, names, contracts, parameter flow, callers, ordered logic, invariants, fixed decisions, safe local choices, return conditions, and acceptance criteria.
|
|
114
113
|
|
|
115
|
-
|
|
116
|
-
npm view codex-model-router
|
|
117
|
-
npm login
|
|
118
|
-
npm whoami
|
|
119
|
-
```
|
|
114
|
+
Information is marked as CONFIRMED, PROPOSED, or UNKNOWN. Luna does not begin implementation while an UNKNOWN can materially change behavior, targets, contracts, parameter flow, control flow, or compatibility.
|
|
120
115
|
|
|
121
|
-
|
|
116
|
+
Terra verifies separately whether implementation matches the plan and whether the plan plus implementation satisfy the original requirement. After three cycles without new evidence or a changed decision, the workflow stops instead of repeating the same approach.
|
|
122
117
|
|
|
123
|
-
|
|
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:
|
|
118
|
+
## Commands
|
|
132
119
|
|
|
133
|
-
```
|
|
134
|
-
|
|
120
|
+
```text
|
|
121
|
+
codex-model-router install [--global] [--set-default] [--dry-run]
|
|
122
|
+
codex-model-router uninstall [--global] [--dry-run]
|
|
123
|
+
codex-model-router doctor [--global]
|
|
124
|
+
codex-model-router --version
|
|
135
125
|
```
|
|
136
126
|
|
|
137
|
-
|
|
127
|
+
`doctor` is read-only. Exit code 0 means healthy; exit code 1 means action is required.
|
|
138
128
|
|
|
139
|
-
|
|
140
|
-
npm view codex-model-router version
|
|
141
|
-
npx codex-model-router --version
|
|
142
|
-
```
|
|
129
|
+
## Safety behavior
|
|
143
130
|
|
|
144
|
-
|
|
131
|
+
- Preserves unrelated TOML settings, comments, BOM, ordering, and LF/CRLF line endings.
|
|
132
|
+
- Rejects malformed, non-UTF-8, duplicate, or unsafe configuration before writing.
|
|
133
|
+
- Rejects symlinks and Windows junctions in managed paths.
|
|
134
|
+
- Uses scope-level locking, atomic transactions, rollback, and conflict-safe recovery.
|
|
135
|
+
- Never overwrites post-interruption user changes.
|
|
136
|
+
- Dry-run creates no files, directories, backups, locks, journals, or state.
|
|
137
|
+
- Never modifies AGENTS.md, shell profiles, editor settings, hooks, MCP servers, telemetry, accounts, or environment variables.
|
|
145
138
|
|
|
146
|
-
##
|
|
139
|
+
## Compatibility
|
|
147
140
|
|
|
148
|
-
|
|
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
|
|
141
|
+
Compatibility is tested on Node.js 18, 20, 22, and 24 across Windows, Linux, and macOS runners. The selected Codex account must have access to gpt-5.6-terra, gpt-5.6-luna, and gpt-5.6-sol.
|
|
153
142
|
|
|
154
|
-
Restart Codex
|
|
143
|
+
Restart Codex after installation so new agents and skills are discovered. Use `doctor` for missing, user-modified, unsafe-state, lock, or interrupted-transaction reports.
|
|
155
144
|
|
|
156
|
-
|
|
145
|
+
Security vulnerabilities should be reported privately according to [SECURITY.md](SECURITY.md). Maintainer setup and release steps are documented in [MAINTAINERS.md](MAINTAINERS.md).
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Supported versions
|
|
4
|
+
|
|
5
|
+
Only the latest stable release receives security fixes.
|
|
6
|
+
|
|
7
|
+
## Reporting a vulnerability
|
|
8
|
+
|
|
9
|
+
Do not report security vulnerabilities through a public Issue.
|
|
10
|
+
|
|
11
|
+
Use GitHub's private security advisory feature for this repository and include:
|
|
12
|
+
|
|
13
|
+
- affected version and operating system
|
|
14
|
+
- selected project or global scope
|
|
15
|
+
- minimal reproduction steps
|
|
16
|
+
- files or paths affected
|
|
17
|
+
- expected and observed behavior
|
|
18
|
+
|
|
19
|
+
Do not include npm tokens, OpenAI credentials, private Codex configuration, or unrelated project source code.
|
|
20
|
+
|
|
21
|
+
Reports involving path escape, unsafe uninstall, transaction recovery, release provenance, or package publication are treated as security-sensitive.
|
package/lib/manifest.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
|
|
3
|
+
const require = createRequire(import.meta.url);
|
|
4
|
+
const packageJson = require("../package.json");
|
|
5
|
+
|
|
6
|
+
export const VERSION = packageJson.version;
|
|
7
|
+
|
|
8
|
+
// Explicit opt-in only. A normal install leaves the user's primary model unchanged.
|
|
9
|
+
export const DEFAULTS = Object.freeze({
|
|
10
|
+
model: "gpt-5.6-terra",
|
|
11
|
+
model_reasoning_effort: "high"
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const legacyLunaV12 = `name = "luna"
|
|
15
|
+
description = "Low-risk helper for repeated edits, searches, formatting, extraction, counting, and summaries."
|
|
16
|
+
model = "gpt-5.6-luna"
|
|
17
|
+
model_reasoning_effort = "high"
|
|
18
|
+
developer_instructions = """
|
|
19
|
+
Handle only deterministic, low-risk work delegated by Terra.
|
|
20
|
+
Follow the assigned pattern exactly and return a concise result.
|
|
21
|
+
Escalate ambiguous, security-sensitive, or logic-heavy decisions to Terra.
|
|
22
|
+
"""
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const legacySolWorkspaceWrite = `name = "sol"
|
|
26
|
+
description = "High-capability specialist for security-sensitive or high-regression-risk work."
|
|
27
|
+
model = "gpt-5.6-sol"
|
|
28
|
+
model_reasoning_effort = "medium"
|
|
29
|
+
sandbox_mode = "workspace-write"
|
|
30
|
+
developer_instructions = """
|
|
31
|
+
Review or implement only when explicitly delegated by Terra.
|
|
32
|
+
For review-only tasks, report concrete findings without changing files.
|
|
33
|
+
For implementation tasks, make focused changes, run relevant checks, and report the result to Terra.
|
|
34
|
+
Focus on security, authentication, permissions, secrets, destructive actions, financial logic, SQL writes, concurrency, complex state, and regression risk.
|
|
35
|
+
Do not expand the scope beyond the delegated task.
|
|
36
|
+
"""
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
const legacySolReadOnly = `name = "sol"
|
|
40
|
+
description = "Read-only reviewer for security-sensitive or high-regression-risk logic."
|
|
41
|
+
model = "gpt-5.6-sol"
|
|
42
|
+
model_reasoning_effort = "medium"
|
|
43
|
+
sandbox_mode = "read-only"
|
|
44
|
+
developer_instructions = """
|
|
45
|
+
Review only. Focus on security, authentication, permissions, secrets, destructive actions, financial logic, SQL writes, concurrency, complex state, and regression risk.
|
|
46
|
+
Report concrete findings to Terra; do not apply fixes.
|
|
47
|
+
"""
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const legacySkillWorkspaceWrite = `---
|
|
51
|
+
name: model-router
|
|
52
|
+
description: Route Codex work between Terra, Luna, and Sol with the fewest required agents.
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
Terra handles ordinary questions, coding, debugging, fixes, testing, and implementation. Never create a Terra subagent.
|
|
56
|
+
Use Luna only for deterministic low-risk repeated edits, bulk patterns, read-heavy searches, formatting, counting, extraction, or summaries; prefer Luna when the same clear operation repeats at least three times.
|
|
57
|
+
Use Sol for security, authentication, authorization, permissions, secrets, destructive actions, financial logic, SQL writes, concurrency, complex state changes, high-regression-risk logic, or an explicit review. Prefer review-only delegation first; when implementation or a confirmed fix is explicitly required, Sol may edit files in workspace-write mode and run relevant checks.
|
|
58
|
+
Do not spawn a subagent for a simple question. Use the minimum number of agents and run Luna with Sol only when both independent tasks are required.
|
|
59
|
+
`;
|
|
60
|
+
|
|
61
|
+
const legacySkillReadOnly = `---
|
|
62
|
+
name: model-router
|
|
63
|
+
description: Route Codex work between Terra, Luna, and Sol with the fewest required agents.
|
|
64
|
+
---
|
|
65
|
+
|
|
66
|
+
Terra handles ordinary questions, coding, debugging, fixes, testing, and implementation. Never create a Terra subagent.
|
|
67
|
+
Use Luna only for deterministic low-risk repeated edits, bulk patterns, read-heavy searches, formatting, counting, extraction, or summaries; prefer Luna when the same clear operation repeats at least three times.
|
|
68
|
+
Use Sol only as a read-only reviewer for security, authentication, authorization, permissions, secrets, destructive actions, financial logic, SQL writes, concurrency, complex state changes, high-regression-risk logic, or an explicit review. Terra applies fixes.
|
|
69
|
+
Do not spawn a subagent for a simple question. Use the minimum number of agents and run Luna with Sol only when both independent tasks are required.
|
|
70
|
+
`;
|
|
71
|
+
|
|
72
|
+
const terra = `name = "terra"
|
|
73
|
+
description = "Investigates, plans, verifies, debugs, and replans nontrivial code changes."
|
|
74
|
+
model = "gpt-5.6-terra"
|
|
75
|
+
model_reasoning_effort = "high"
|
|
76
|
+
sandbox_mode = "read-only"
|
|
77
|
+
developer_instructions = """
|
|
78
|
+
Own focused investigation, compact implementation-ready planning, verification, debugging, and replanning.
|
|
79
|
+
Use the implementation-planning skill only for nontrivial or uncertain changes.
|
|
80
|
+
Never invent repository facts; preserve valid work and revise only affected parts.
|
|
81
|
+
Verify both plan conformance and whether the plan plus implementation satisfy the user's requirement.
|
|
82
|
+
Use Sol only when focused investigation and one materially revised plan still leave the core logic unresolved.
|
|
83
|
+
Return only the artifact required by the current stage.
|
|
84
|
+
"""
|
|
85
|
+
`;
|
|
86
|
+
|
|
87
|
+
const luna = `name = "luna"
|
|
88
|
+
description = "Implements clear, bounded work from an approved plan."
|
|
89
|
+
model = "gpt-5.6-luna"
|
|
90
|
+
model_reasoning_effort = "max"
|
|
91
|
+
sandbox_mode = "workspace-write"
|
|
92
|
+
developer_instructions = """
|
|
93
|
+
Implement the current approved plan with the smallest coherent change.
|
|
94
|
+
Preserve fixed behavior, contracts, scope, parameter flow, control flow, callers, and invariants.
|
|
95
|
+
Use local choice only for equivalent implementation details.
|
|
96
|
+
Return to Terra when the plan conflicts with current code, is stale, omits a required target or caller, or needs a new correctness-affecting decision.
|
|
97
|
+
Report the plan version, changed files and symbols, deviations, logical checks, and remaining uncertainty.
|
|
98
|
+
Do not self-approve.
|
|
99
|
+
"""
|
|
100
|
+
`;
|
|
101
|
+
|
|
102
|
+
const sol = `name = "sol"
|
|
103
|
+
description = "Last-resort advisor for core logic Terra cannot resolve."
|
|
104
|
+
model = "gpt-5.6-sol"
|
|
105
|
+
model_reasoning_effort = "medium"
|
|
106
|
+
sandbox_mode = "read-only"
|
|
107
|
+
developer_instructions = """
|
|
108
|
+
Analyze only the unresolved logical conflict.
|
|
109
|
+
Identify unsupported assumptions, the likely root cause, required invariants, viable correction directions, and remaining uncertainty.
|
|
110
|
+
Do not perform routine planning, implementation, verification, or final review.
|
|
111
|
+
Return findings to Terra; do not manage Luna.
|
|
112
|
+
"""
|
|
113
|
+
`;
|
|
114
|
+
|
|
115
|
+
const skill = `---
|
|
116
|
+
name: model-router
|
|
117
|
+
description: Adaptively route code planning and implementation while preserving the selected primary model and existing agents.
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
Preserve repository rules and existing specialized agents. Explicit user instructions win.
|
|
121
|
+
The selected primary model handles conversation, clarification, follow-ups, final replies, and trivial work.
|
|
122
|
+
For code changes: ask the user when expected behavior is unclear; use Terra to investigate, plan, verify, debug, and replan; use Luna for clear bounded implementation; use Sol only when Terra still cannot resolve core logic after focused investigation and one materially revised plan, or when the user explicitly requests Sol.
|
|
123
|
+
Use the implementation-planning skill for nontrivial or uncertain changes.
|
|
124
|
+
Luna may choose equivalent local details only; approved behavior, contracts, scope, parameter flow, control flow, and invariants remain fixed.
|
|
125
|
+
Terra verifies both plan conformance and requirement correctness. Preserve verified work and revise only affected parts.
|
|
126
|
+
Stop after three cycles without new evidence or a changed decision. Use the fewest agents needed.
|
|
127
|
+
Within one agent thread append concise deltas; a new thread receives the latest self-contained snapshot.
|
|
128
|
+
`;
|
|
129
|
+
|
|
130
|
+
const planning = `---
|
|
131
|
+
name: implementation-planning
|
|
132
|
+
description: Create or revise a compact implementation-ready plan for nontrivial code changes involving multiple symbols, contracts, parameters, callers, control flow, or uncertain targets.
|
|
133
|
+
---
|
|
134
|
+
|
|
135
|
+
Inspect only enough code to confirm correctness-critical facts. Mark information as CONFIRMED, PROPOSED, or UNKNOWN. Do not implement while an UNKNOWN can change behavior, targets, contracts, parameter flow, control flow, or compatibility.
|
|
136
|
+
|
|
137
|
+
Produce one compact current snapshot using only applicable fields:
|
|
138
|
+
|
|
139
|
+
- TASK, REQUIREMENT_VERSION, PLAN_VERSION
|
|
140
|
+
- OBJECTIVE: observable result
|
|
141
|
+
- TARGETS: exact files, symbols, and change type
|
|
142
|
+
- SYMBOLS: exact new names and naming basis
|
|
143
|
+
- CONTRACTS: current and proposed signatures, parameters, defaults, returns, and failure behavior
|
|
144
|
+
- FLOW: source -> caller -> parameter -> transformation -> use -> destination
|
|
145
|
+
- LOGIC: ordered steps and branches
|
|
146
|
+
- CALLERS: affected callers and argument changes
|
|
147
|
+
- INVARIANTS: behavior that must remain true
|
|
148
|
+
- FIXED: decisions Luna cannot change
|
|
149
|
+
- LOCAL_CHOICE: safe implementation freedom
|
|
150
|
+
- RETURN_REQUIRED: conditions requiring Terra
|
|
151
|
+
- DONE_WHEN: acceptance conditions
|
|
152
|
+
|
|
153
|
+
Omit irrelevant fields and vague instructions. Preserve verified work, revise only affected sections, and identify superseded decisions. Create a new snapshot after three deltas or any material contract or logic change.
|
|
154
|
+
|
|
155
|
+
Verification answers separately: did implementation match the plan, and did the plan plus implementation satisfy the request? Use PASS, IMPLEMENTATION_FIX, PLAN_REVISION, EVIDENCE_GAP, or REQUIREMENT_CLARIFICATION.
|
|
156
|
+
`;
|
|
157
|
+
|
|
158
|
+
export const TEMPLATES = Object.freeze({
|
|
159
|
+
terra: Object.freeze({ relative: ["agents", "terra.toml"], content: terra }),
|
|
160
|
+
luna: Object.freeze({ relative: ["agents", "luna.toml"], content: luna }),
|
|
161
|
+
sol: Object.freeze({ relative: ["agents", "sol.toml"], content: sol }),
|
|
162
|
+
skill: Object.freeze({ relative: ["model-router", "SKILL.md"], content: skill }),
|
|
163
|
+
planning: Object.freeze({ relative: ["implementation-planning", "SKILL.md"], content: planning })
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
export const MANAGED_FILE_NAMES = Object.freeze(["terra", "luna", "sol", "skill", "planning"]);
|
|
167
|
+
export const AGENT_NAMES = Object.freeze(["terra", "luna", "sol"]);
|
|
168
|
+
|
|
169
|
+
export const LEGACY_TEMPLATES = Object.freeze({
|
|
170
|
+
terra: Object.freeze([]),
|
|
171
|
+
luna: Object.freeze([legacyLunaV12]),
|
|
172
|
+
sol: Object.freeze([legacySolWorkspaceWrite, legacySolReadOnly]),
|
|
173
|
+
skill: Object.freeze([legacySkillWorkspaceWrite, legacySkillReadOnly]),
|
|
174
|
+
planning: Object.freeze([])
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
export const AGENT_EXPECTATIONS = Object.freeze({
|
|
178
|
+
terra: Object.freeze({
|
|
179
|
+
name: "terra",
|
|
180
|
+
model: "gpt-5.6-terra",
|
|
181
|
+
model_reasoning_effort: "high",
|
|
182
|
+
sandbox_mode: "read-only"
|
|
183
|
+
}),
|
|
184
|
+
luna: Object.freeze({
|
|
185
|
+
name: "luna",
|
|
186
|
+
model: "gpt-5.6-luna",
|
|
187
|
+
model_reasoning_effort: "max",
|
|
188
|
+
sandbox_mode: "workspace-write"
|
|
189
|
+
}),
|
|
190
|
+
sol: Object.freeze({
|
|
191
|
+
name: "sol",
|
|
192
|
+
model: "gpt-5.6-sol",
|
|
193
|
+
model_reasoning_effort: "medium",
|
|
194
|
+
sandbox_mode: "read-only"
|
|
195
|
+
})
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
export const SKILL_EXPECTATIONS = Object.freeze({
|
|
199
|
+
skill: Object.freeze({
|
|
200
|
+
name: "model-router",
|
|
201
|
+
required: Object.freeze(["primary model", "Terra", "Luna", "Sol", "three cycles"])
|
|
202
|
+
}),
|
|
203
|
+
planning: Object.freeze({
|
|
204
|
+
name: "implementation-planning",
|
|
205
|
+
required: Object.freeze(["CONFIRMED", "PROPOSED", "UNKNOWN", "FIXED", "LOCAL_CHOICE", "RETURN_REQUIRED", "PLAN_REVISION"])
|
|
206
|
+
})
|
|
207
|
+
});
|