opencode-model-router 2.6.1 → 2.7.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/CHANGELOG.md +20 -0
- package/README.md +3 -1
- package/package.json +2 -2
- package/src/verify/reference.ts +92 -24
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,26 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [2.7.0] - 2026-10-10
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- README: 90-second demo video below the title.
|
|
15
|
+
|
|
16
|
+
### Removed
|
|
17
|
+
|
|
18
|
+
- **Breaking (requirement): Node.js 20 is no longer supported.** Node.js 20 reached end-of-life in April 2026; the
|
|
19
|
+
minimum is now Node.js 22 (`engines.node` is `>=22`, and the CI matrix runs Node 22 and 24).
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- A file edited by another writer during verification (for example LF lines appended to a CRLF file) could be
|
|
24
|
+
misreported as a checkout line-ending conversion, which made the reference approximate and turned a provable
|
|
25
|
+
rejection into an unverifiable result. The drift diff is now re-taken, limited to those paths, before they are
|
|
26
|
+
flagged. A re-diffed path gets the dependency and workspace-link drift checks and is then judged like any file
|
|
27
|
+
edited after dispatch: it is flagged only when the reference's checkout converted it (still the case under
|
|
28
|
+
`* text=auto` with native CRLF), and a failed re-diff keeps the flag (#88).
|
|
29
|
+
|
|
10
30
|
## [2.6.1] - 2026-10-09
|
|
11
31
|
|
|
12
32
|
### Fixed
|
package/README.md
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/opencode-model-router)
|
|
4
4
|
|
|
5
|
+
https://github.com/user-attachments/assets/ad521e3b-a978-475c-a07f-7a5908253057
|
|
6
|
+
|
|
5
7
|
> **Use the cheapest model that can do the job. Automatically.**
|
|
6
8
|
|
|
7
9
|
An [OpenCode](https://opencode.ai) plugin that routes every coding task to the right-priced AI tier — automatically, on every message, with 3,249–6,357 characters of system-prompt overhead depending on the orchestrator and enforcement mode.
|
|
@@ -1309,7 +1311,7 @@ These are character counts of the prompts the shipped config actually produces,
|
|
|
1309
1311
|
## Requirements
|
|
1310
1312
|
|
|
1311
1313
|
- [OpenCode](https://opencode.ai) v1 (`>=1.0.0 <2.0.0`) or v2 **2.0.20+** (TUI status: 2.0.24+)
|
|
1312
|
-
- Node.js
|
|
1314
|
+
- Node.js 22+
|
|
1313
1315
|
- Provider API keys configured in OpenCode
|
|
1314
1316
|
|
|
1315
1317
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opencode-model-router",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.0",
|
|
4
4
|
"description": "OpenCode plugin that routes tasks to tiered subagents (fast/medium/heavy) based on complexity",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
"license": "GPL-3.0-only",
|
|
22
22
|
"engines": {
|
|
23
|
-
"node": ">=
|
|
23
|
+
"node": ">=22"
|
|
24
24
|
},
|
|
25
25
|
"repository": {
|
|
26
26
|
"type": "git",
|
package/src/verify/reference.ts
CHANGED
|
@@ -101,7 +101,16 @@
|
|
|
101
101
|
// "a0\r\n" while exact stayed true. LF files under text=auto are common
|
|
102
102
|
// on win32 (e.g. Prettier's default endOfLine: lf). Each differing path
|
|
103
103
|
// adds "checkout-conversion" for it, up to MAX_CONVERSION_REASONS, then
|
|
104
|
-
// one "" reason.
|
|
104
|
+
// one "" reason. A file another writer edits between the drift diff
|
|
105
|
+
// and the live listing is in neither set, so when the listing finds a
|
|
106
|
+
// live-vs-reference `w/` difference the diff is taken again, limited
|
|
107
|
+
// to those paths, and the paths it reports join the changed set
|
|
108
|
+
// before flagging (#88). They get checks (c) and (d) and are then
|
|
109
|
+
// judged like any file edited after dispatch (the QA-1.5-16 rule
|
|
110
|
+
// above: flagged only when the reference's `w/` differs from its
|
|
111
|
+
// `i/`; under `* text=auto` with native CRLF still flagged,
|
|
112
|
+
// QA-1.5-19). A failed or unaffordable re-diff (budget spent, more
|
|
113
|
+
// than MAX_REDIFF_PATHS paths) keeps every flag.
|
|
105
114
|
// (f) No index entry is assume-unchanged or skip-worktree at capture
|
|
106
115
|
// (QA-1.5-6b). Git skips such entries, so neither stash create nor the
|
|
107
116
|
// drift diff sees a local edit to them (live "v2-local" became "v1" at
|
|
@@ -312,11 +321,22 @@
|
|
|
312
321
|
// "checkout-conversion" for it. A path in the drift set but not in
|
|
313
322
|
// ref.tracked (edited after capture, QA-1.5-16) has unknown dispatch
|
|
314
323
|
// bytes, so it adds "checkout-conversion" when the reference's own `w/`
|
|
315
|
-
// class differs from its `i/` class (the checkout converted it).
|
|
316
|
-
// the
|
|
317
|
-
//
|
|
318
|
-
//
|
|
319
|
-
//
|
|
324
|
+
// class differs from its `i/` class (the checkout converted it). When
|
|
325
|
+
// the lists show a path with a live-vs-reference `w/` difference that is
|
|
326
|
+
// in neither set (#88: edited by another writer after the step-7 diff),
|
|
327
|
+
// the step-7 diff (private index, `--literal-pathspecs`, limited to
|
|
328
|
+
// those paths, at most MAX_REDIFF_PATHS) is taken again. The paths it
|
|
329
|
+
// reports join the drift set, get the (c)/(d) checks of step 7, and are
|
|
330
|
+
// then judged by the QA-1.5-16 rule above (a re-diffed path whose
|
|
331
|
+
// checkout converted it, w/ != i/, stays flagged, QA-1.5-19). A failed
|
|
332
|
+
// re-diff (logged), a spent budget or too many paths keeps every flag.
|
|
333
|
+
// This is the last step, so the two listings get the remaining budget
|
|
334
|
+
// with the caller's signal only: a budget that runs out here, or a
|
|
335
|
+
// failing call, adds "" instead of failing materialize; a caller abort
|
|
336
|
+
// returns ok:false "aborted". The re-diff is the exception: like step 7
|
|
337
|
+
// it runs under the budget's signal (its private-index copy), so a
|
|
338
|
+
// spent budget there skips it and keeps the flags, while a caller abort
|
|
339
|
+
// returns "aborted" and an UnsafeReferencePathError "unsafe-path".
|
|
320
340
|
// 8. Return { ok: true, reference: { dir, exact, inexactReasons,
|
|
321
341
|
// unreproduced, links, toRefPath, dispose } }. toRefPath(p) maps an
|
|
322
342
|
// absolute live path under root, or under realpath(root), to the same
|
|
@@ -386,7 +406,7 @@
|
|
|
386
406
|
// so a junction created after the sweep costs nothing (QA-1.5-3 repro:
|
|
387
407
|
// `git worktree remove` in this slot deleted the late junction's target
|
|
388
408
|
// contents; fs.rm left them intact). The sweep stays, because fs.rm's
|
|
389
|
-
// non-following is proven only on Node v24.21.0 and engines is >=
|
|
409
|
+
// non-following is proven only on Node v24.21.0 and engines is >=22. If
|
|
390
410
|
// dir still exists afterwards (EBUSY from a process whose cwd is inside),
|
|
391
411
|
// warn and leave it for GC; git is not run.
|
|
392
412
|
// 4. Only once dir is gone, and while the admin entry is still registered:
|
|
@@ -661,6 +681,12 @@
|
|
|
661
681
|
// reference inexact. Avoiding it needs each path's `w/` class at capture,
|
|
662
682
|
// i.e. a full `ls-files --eol` inside the capture budget; not done, since
|
|
663
683
|
// the error only yields "unverifiable", never a wrong excuse.
|
|
684
|
+
// - The QA-1.5-16 rule cannot see a legacy-checkout conversion (QA-1.5-18
|
|
685
|
+
// class: old core.autocrlf, `crlf` attribute) in a file edited after
|
|
686
|
+
// dispatch, because the reference's `i/` equals its `w/` there. That was
|
|
687
|
+
// already true for edits before the step-7 diff; the step-7b re-diff
|
|
688
|
+
// (#88) extends it to edits in the window between the diff and the live
|
|
689
|
+
// listing.
|
|
664
690
|
// - Output cap (QA-1.5-24, owner 2.1): the seam caps each stream (p12
|
|
665
691
|
// runArgv default 10 M chars) and a cut listing is a failed call. Capture's
|
|
666
692
|
// `ls-files --stage` hits the cap first, at ~95-150k tracked paths (path
|
|
@@ -889,6 +915,8 @@ export const MAX_UNTRACKED_BYTES = 64 * 1024 * 1024;
|
|
|
889
915
|
export const MAX_SWEEP_ENTRIES = 500_000;
|
|
890
916
|
/** Per-path "checkout-conversion" reasons from the eol comparison (section 2e); beyond it, one "" reason. */
|
|
891
917
|
export const MAX_CONVERSION_REASONS = 100;
|
|
918
|
+
/** Most paths the step-7b re-diff (#88) is limited to; more than this keeps every conversion flag. */
|
|
919
|
+
const MAX_REDIFF_PATHS = 64;
|
|
892
920
|
/** Marker value for an untracked symbolic link (not a sha256, so it never matches a file hash). */
|
|
893
921
|
export const UNTRACKED_SYMLINK = "symlink";
|
|
894
922
|
/** Basenames whose drift between commit and the live tree makes a linked node_modules stale (section 2c). */
|
|
@@ -1802,10 +1830,17 @@ export async function materialize(
|
|
|
1802
1830
|
const scratchEnv: PrivateIndexEnv = {
|
|
1803
1831
|
argv: deps.argv, fs, root, tmpdir: tmp, platform, pid: deps.pid ?? process.pid, logger: deps.logger,
|
|
1804
1832
|
};
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1833
|
+
// `only`: the step-7b re-diff (#88) is limited to the paths it must classify, as literal
|
|
1834
|
+
// pathspecs whatever GIT_LITERAL_PATHSPECS says.
|
|
1835
|
+
const driftDiff = (only: readonly string[] = []) =>
|
|
1836
|
+
withPrivateIndex(scratchEnv, budget, (copy) =>
|
|
1837
|
+
runGit(deps.argv, [
|
|
1838
|
+
...(only.length > 0 ? ["--literal-pathspecs"] : []),
|
|
1839
|
+
"-c", "core.splitIndex=false", "diff", "--name-only", "-z", "--no-renames", "--no-ext-diff", ref.commit, "--", ...only,
|
|
1840
|
+
], {
|
|
1841
|
+
cwd: root, timeoutMs: budget.remaining(), signal: budget.signal, env: { GIT_INDEX_FILE: copy },
|
|
1842
|
+
}));
|
|
1843
|
+
const diff = await driftDiff();
|
|
1809
1844
|
const nowUntracked = await git(["ls-files", "--others", "--exclude-standard", "-z"]);
|
|
1810
1845
|
if (budget.spent()) return await abandon("aborted", "aborted during drift checks");
|
|
1811
1846
|
if (!diff || diff.code !== 0 || !nowUntracked || nowUntracked.code !== 0) {
|
|
@@ -1813,10 +1848,6 @@ export async function materialize(
|
|
|
1813
1848
|
}
|
|
1814
1849
|
for (const rel of splitZ(diff.stdout)) changed.add(rel);
|
|
1815
1850
|
for (const rel of splitZ(nowUntracked.stdout)) if (!ref.untracked.has(rel)) changed.add(rel);
|
|
1816
|
-
const changedSorted = [...changed].sort(byCodeUnit);
|
|
1817
|
-
for (const rel of changedSorted) {
|
|
1818
|
-
if (DEPENDENCY_FILES.has(rel.split("/").at(-1) ?? "")) reasons.push({ cause: "dependency-drift", path: rel });
|
|
1819
|
-
}
|
|
1820
1851
|
const realRoot = p.resolve(await fs.realpath(root));
|
|
1821
1852
|
const workspaceDirs = new Set<string>();
|
|
1822
1853
|
for (const target of linkTargets) {
|
|
@@ -1837,12 +1868,22 @@ export async function materialize(
|
|
|
1837
1868
|
}
|
|
1838
1869
|
}
|
|
1839
1870
|
const fold = (s: string) => (platform === "win32" ? s.toLowerCase() : s);
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1871
|
+
// Section 2 (c) and (d) over a set of drifted paths; run on the step-7 set and, in step 7b, on
|
|
1872
|
+
// the paths its re-diff adds (#88), so a late edit is judged like any other drift.
|
|
1873
|
+
const driftReasons = (paths: readonly string[]) => {
|
|
1874
|
+
const sorted = [...paths].sort(byCodeUnit);
|
|
1875
|
+
for (const rel of sorted) {
|
|
1876
|
+
if (DEPENDENCY_FILES.has(rel.split("/").at(-1) ?? "")) reasons.push({ cause: "dependency-drift", path: rel });
|
|
1844
1877
|
}
|
|
1845
|
-
|
|
1878
|
+
for (const rel of [...workspaceDirs].sort(byCodeUnit)) {
|
|
1879
|
+
const prefix = fold(rel) + "/";
|
|
1880
|
+
if (reasons.some((r) => r.cause === "workspace-link-drift" && r.path === rel)) continue;
|
|
1881
|
+
if (sorted.some((c) => fold(c) === fold(rel) || fold(c).startsWith(prefix))) {
|
|
1882
|
+
reasons.push({ cause: "workspace-link-drift", path: rel });
|
|
1883
|
+
}
|
|
1884
|
+
}
|
|
1885
|
+
};
|
|
1886
|
+
driftReasons([...changed]);
|
|
1846
1887
|
|
|
1847
1888
|
// 7b. Clean-file checkout conversion (section 2e, QA-1.5-13): the working-tree eol class
|
|
1848
1889
|
// of every tracked path that is neither hashed above (ref.tracked) nor changed since
|
|
@@ -1872,14 +1913,41 @@ export async function materialize(
|
|
|
1872
1913
|
if (!liveEol || !refEol) {
|
|
1873
1914
|
conversion(""); // not compared: budget spent or git failed
|
|
1874
1915
|
} else {
|
|
1916
|
+
// #88: a writer that edits a file between the step-7 diff and the live listing leaves it
|
|
1917
|
+
// in neither set; its live `w/` then differs from the reference's with no checkout
|
|
1918
|
+
// conversion behind it. Take the diff again, limited to those paths (at most
|
|
1919
|
+
// MAX_REDIFF_PATHS; beyond that the flags stay), before flagging them. A failed or
|
|
1920
|
+
// unaffordable re-diff changes nothing, so every flag stays (fail safe). Paths it adds go
|
|
1921
|
+
// through the (c)/(d) drift checks and then the QA-1.5-16 rule below.
|
|
1922
|
+
const unexplained = (rel: string, w: string) => {
|
|
1923
|
+
if (ref.tracked.has(rel) || changed.has(rel)) return false;
|
|
1924
|
+
const live = liveEol.get(rel);
|
|
1925
|
+
return live !== undefined && live.w !== w;
|
|
1926
|
+
};
|
|
1927
|
+
const suspects = [...refEol].filter(([rel, { w }]) => unexplained(rel, w)).map(([rel]) => rel).sort(byCodeUnit);
|
|
1928
|
+
if (suspects.length > 0 && suspects.length <= MAX_REDIFF_PATHS && !budget.spent()) {
|
|
1929
|
+
let again: ExecResult | undefined;
|
|
1930
|
+
try {
|
|
1931
|
+
again = await driftDiff(suspects);
|
|
1932
|
+
} catch (error) {
|
|
1933
|
+
if (signal.aborted || error instanceof UnsafeReferencePathError) throw error;
|
|
1934
|
+
deps.logger?.warn("reference eol re-diff failed: flags kept", { error: describeError(error) });
|
|
1935
|
+
}
|
|
1936
|
+
if (signal.aborted) return await abandon("aborted", "aborted during the eol comparison");
|
|
1937
|
+
if (again && again.code === 0) {
|
|
1938
|
+
const added = splitZ(again.stdout).filter((rel) => !changed.has(rel));
|
|
1939
|
+
for (const rel of added) changed.add(rel);
|
|
1940
|
+
driftReasons(added);
|
|
1941
|
+
} else if (again) {
|
|
1942
|
+
deps.logger?.warn("reference eol re-diff failed: flags kept", { code: again.code, stderr: again.stderr.trim() });
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1875
1945
|
// QA-1.5-16: a path edited since capture (in changed, not in ref.tracked) has unknown
|
|
1876
1946
|
// dispatch bytes; it is flagged when the reference's checkout converted it (w/ != i/).
|
|
1877
1947
|
const differing = [...refEol]
|
|
1878
1948
|
.filter(([rel, { i, w }]) => {
|
|
1879
|
-
if (ref.tracked.has(rel)) return
|
|
1880
|
-
|
|
1881
|
-
const live = liveEol.get(rel);
|
|
1882
|
-
return live !== undefined && live.w !== w;
|
|
1949
|
+
if (changed.has(rel) && !ref.tracked.has(rel)) return i !== "" && w !== "" && i !== w;
|
|
1950
|
+
return unexplained(rel, w);
|
|
1883
1951
|
})
|
|
1884
1952
|
.map(([rel]) => rel)
|
|
1885
1953
|
.sort(byCodeUnit);
|