sprag-cli 3.106.0 → 3.106.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.
- package/package.json +1 -1
- package/src/brief.js +20 -2
- package/src/ctx-window-cache.js +14 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprag-cli",
|
|
3
|
-
"version": "3.106.
|
|
3
|
+
"version": "3.106.1",
|
|
4
4
|
"description": "The delegation layer for Claude Code and Codex: each task goes to the model and effort that fits it, down to cheaper models for lookups and up to higher effort when a cheaper run would miss, backed by public replay cases, with a live statusline and team rules for Pro and Enterprise.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/brief.js
CHANGED
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
import { readFileSync, writeFileSync, existsSync, mkdirSync, statSync, openSync, readSync, closeSync } from 'node:fs';
|
|
29
29
|
import { join } from 'node:path';
|
|
30
30
|
import { userDataDir } from './paths.js';
|
|
31
|
-
import { resolveModelId, isOneMillionModel, effectiveWindow } from './compact-window.js';
|
|
32
|
-
import { liveWindowFor, liveModelFor } from './ctx-window-cache.js';
|
|
31
|
+
import { resolveModelId, isOneMillionModel, effectiveWindow, canonicalModelId } from './compact-window.js';
|
|
32
|
+
import { liveWindowFor, liveModelFor, liveWindowsByModel } from './ctx-window-cache.js';
|
|
33
33
|
import { routingEnabled } from './routing-switch.js';
|
|
34
34
|
|
|
35
35
|
// Context tiers as a fraction of the session's context window. Tier 1 warns
|
|
@@ -100,6 +100,24 @@ export function ctxWindowFor(observedMax = 0, root = process.cwd(), { liveWindow
|
|
|
100
100
|
try {
|
|
101
101
|
const { model } = resolveModelId(root);
|
|
102
102
|
if (!reported && isOneMillionModel(model)) modelWindow = window = 1_000_000;
|
|
103
|
+
// No report for this session yet and no `[1m]` in the id: a model Claude
|
|
104
|
+
// Code runs at 1M by default (Opus 5.5 as `opus`) read as 200k until its
|
|
105
|
+
// biggest request passed 250k, so the 80% briefing fired at ~160k (#14).
|
|
106
|
+
// The window another session's statusline reported for the same model is
|
|
107
|
+
// the best evidence there is; the observed-size guess stays the last resort.
|
|
108
|
+
else if (!reported) {
|
|
109
|
+
// A bare alias (`opus`) names whichever version Claude Code resolves it
|
|
110
|
+
// to today, and the statusline records the full id, so an alias matches
|
|
111
|
+
// the newest report of its family.
|
|
112
|
+
const key = canonicalModelId(model);
|
|
113
|
+
const alias = key && /^(opus|sonnet|haiku|fable|mythos)$/.test(key) ? key : null;
|
|
114
|
+
const same = (id) => {
|
|
115
|
+
const c = canonicalModelId(id);
|
|
116
|
+
return c === key || (alias !== null && (c === `claude-${alias}` || (c || '').startsWith(`claude-${alias}-`)));
|
|
117
|
+
};
|
|
118
|
+
const seen = key ? liveWindowsByModel().find((e) => same(e.model)) : null;
|
|
119
|
+
if (seen) modelWindow = window = Math.max(seen.size, modelWindow);
|
|
120
|
+
}
|
|
103
121
|
const cap = effectiveWindow(root).value;
|
|
104
122
|
if (cap !== null && cap < window) {
|
|
105
123
|
window = cap;
|
package/src/ctx-window-cache.js
CHANGED
|
@@ -84,6 +84,20 @@ export function latestLiveWindow() {
|
|
|
84
84
|
return best ? best.size : null;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
+
/**
|
|
88
|
+
* Every recorded window with the model its session reported, newest first.
|
|
89
|
+
* A session that has not rendered a statusline yet borrows the window another
|
|
90
|
+
* session reported for the same model (brief.js ctxWindowFor): Claude Code
|
|
91
|
+
* runs some models at 1M by default with no `[1m]` in the id, and only its
|
|
92
|
+
* own report says so.
|
|
93
|
+
*/
|
|
94
|
+
export function liveWindowsByModel() {
|
|
95
|
+
return Object.values(load().sessions)
|
|
96
|
+
.filter((s) => s && validSize(s.size) && Number.isFinite(s.ts) && typeof s.model === 'string' && s.model !== '')
|
|
97
|
+
.sort((a, b) => b.ts - a.ts)
|
|
98
|
+
.map((s) => ({ model: s.model, size: s.size, ts: s.ts }));
|
|
99
|
+
}
|
|
100
|
+
|
|
87
101
|
/** The model id a session's statusline payload reported, or null. */
|
|
88
102
|
export function liveModelFor(sessionId) {
|
|
89
103
|
if (typeof sessionId !== 'string' || sessionId === '') return null;
|