sprag-cli 3.103.1 → 3.105.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/README.ko.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <img alt="Sprag" src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/site/assets/logo/sprag-lockup-light.svg" width="220">
6
6
  </picture>
7
7
 
8
- **Claude Code와 Codex에 붙이는 모델 위임 라우터. 조회·확인·테스트 실행은 더 싼 모델에 보내고, 아낀 금액은 상태줄에 보여 줍니다.**
8
+ **Claude Code와 Codex의 위임 계층입니다. 일마다 맞는 모델과 effort로 보냅니다. 조회는 Haiku로 내리고 싼 실행이 놓칠 일은 effort나 모델을 올립니다. 모든 규칙 뒤에는 직접 열어 볼 수 있는 재생 사례가 있습니다.**
9
9
 
10
10
  [![npm](https://img.shields.io/npm/v/sprag-cli.svg?label=sprag-cli)](https://www.npmjs.com/package/sprag-cli)
11
11
  [![downloads](https://img.shields.io/npm/dm/sprag-cli.svg)](https://www.npmjs.com/package/sprag-cli)
@@ -19,8 +19,8 @@
19
19
 
20
20
  <a href="https://github.com/rootstudioyaml/sprag/blob/main/README.ko.md#팀"><img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/plan-pro-ko.gif" width="640" alt="팀원마다 동물 캐릭터로 앉아 있는 가상 사무실, 지출과 절감액, 좌석, 30일 차트가 있는 조직 대시보드, 한 번 승인하면 모든 컴퓨터에 적용되는 팀 규칙을 차례로 보여 줍니다."></a>
21
21
 
22
- **Sprag Pro · 팀이 함께 쓰는 Sprag**: 팀 전체의 AI 지출과 절감액을 한 화면에서 봅니다.<br>
23
- <sub>팀원마다 캐릭터가 앉아 있는 가상 사무실, 좌석 명단, 한 번 승인하면 모두에게 적용되는 팀 규칙을 담았습니다. <a href="https://github.com/rootstudioyaml/sprag/blob/main/README.ko.md#팀">팀 기능 보기</a> · <a href="mailto:support@sprag.io">support@sprag.io</a></sub>
22
+ **Sprag Pro와 Enterprise · 팀용**: 팀 전체가 같은 위임 규칙으로 일합니다. 규칙을 한 번 승인하면 모든 컴퓨터가 따릅니다.<br>
23
+ <sub>지출과 절감액, 좌석을 한 화면에서 보고 Enterprise에서는 예산 게이지와 프롬프트 모니터링이 더해집니다. 팀원마다 캐릭터가 앉은 가상 사무실도 있습니다. <a href="https://github.com/rootstudioyaml/sprag/blob/main/README.ko.md#팀">팀 기능 보기</a> · <a href="mailto:support@sprag.io">support@sprag.io</a></sub>
24
24
 
25
25
  <a href="https://sprag.io/assets/video/sprag-compare-ko.mp4"><img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/sprag-compare-ko.gif" width="760" alt="두 터미널에 같은 요청 12건을 넣습니다. sprag 를 적용한 쪽은 조회와 테스트 실행을 저렴한 모델에 넘기고 문서를 Markdown 으로 바꿔 넣어, 하루를 $6.68 대신 $1.83 로 마칩니다."></a>
26
26
 
@@ -35,7 +35,9 @@
35
35
 
36
36
  ---
37
37
 
38
- **Sprag는 일마다 그 일을 한 번도 틀린 적 없는 가장 싼 모델에게 보냅니다.** Claude Code와 Codex는 프롬프트마다 모델을 바꿀 수 없으므로, 통하는 방법 하나를 씁니다. 메인 세션의 규칙이 조회, 상태 확인, 빌드·테스트 실행, 일괄 수정을 더 싼 모델로 고정한 서브에이전트에 넘깁니다. 규칙은 사용자의 세션 기록에서 나오고 하나씩 승인을 받으며, 위임한 실행마다 가격 차액을 원장에 적습니다. `npm i -g sprag-cli` 하나로 설정이 끝나며, 프로젝트마다 따로 설정할 것은 없습니다.
38
+ **Sprag는 일마다 그 일을 틀리지 않는 가장 싼 모델과 effort로 보냅니다.** Claude Code와 Codex는 프롬프트마다 모델을 바꿀 수 없어서 통하는 방법 하나를 씁니다. 메인 세션의 규칙이 모델과 effort를 고정한 서브에이전트에 일을 넘깁니다. 조회와 상태 확인, 빌드와 테스트 실행은 Haiku로 내려갑니다. 싼 실행이 티 없이 놓치는 일은 반대로 올라갑니다. 여러 파일을 뒤지는 조회는 Sonnet high로, 열린 웹 조사는 xhigh로 보냅니다. 재생 실험에서 기본값 medium이 두 경우를 모두 놓쳤기 때문입니다. 규칙은 사용자의 세션 기록에서 나오고 하나씩 승인을 받습니다. 위임한 실행마다 가격 차액은 원장에 남습니다. `npm i -g sprag-cli` 하나로 설정이 끝나고 프로젝트마다 따로 설정할 것은 없습니다.
39
+
40
+ 모든 규칙은 직접 열어 볼 수 있는 재생 사례로 확인합니다. [sprag.io/proof](https://sprag.io/proof/)는 실제 위임을 여러 모델과 effort 설정으로 다시 돌려 블라인드로 채점하고 새 사례를 분석할 때마다 늘어납니다. 같은 표가 npm 패키지에도 실려 있어서 `sprag proof`로 볼 수 있습니다.
39
41
 
40
42
  두 가지가 함께 따라옵니다. 문서는 가벼운 Markdown으로 바뀌어 컨텍스트에 들어가고(54만 토큰짜리 발표 자료가 2.3만 토큰이 됩니다), 상태줄은 세션마다 쓴 금액과 아낀 금액을 보여 주다가 캐시·컨텍스트·사용량 한도에 문제가 생기면 경고 칩을 맨 앞에 띄웁니다.
41
43
 
@@ -126,6 +128,25 @@ LLMRouterBench(Findings of ACL 2026)에서 오프라인으로 측정했습니다
126
128
 
127
129
  위임된 실행은 한 건마다 단가 차액을 기록하므로, `sprag route-scan savings` 가 어떤 금액이든 그 원인이 된 규칙까지 역추적해 보여 줍니다. 집계에서 무엇을 빼는지는 [명령 문서](https://github.com/rootstudioyaml/sprag/blob/main/docs/COMMANDS.ko.md)에 적어 두었습니다.
128
130
 
131
+ <!-- sprag:evidence:start -->
132
+ ### 재생으로 검증한 위임
133
+
134
+ 위임 사례 10건을 라운드 3개에 걸쳐 실행 71회로 다시 돌렸고 가장 최근 재생은 2026-11-07입니다.
135
+
136
+ | 사례 | 추천 설정 | 판정 | Opus 대비 비용 |
137
+ | --- | --- | --- | --- |
138
+ | 모델 이름 해석 검토 | Sonnet · high | 그대로 전달 | 59.3% 저렴 |
139
+ | 프리셋 구조 파악 | Sonnet · high | 그대로 전달 | 60.9% 저렴 |
140
+ | 가격표 갱신 구현 | Sonnet · high | 부분 | 66.2% 저렴 |
141
+ | 업로드 주기 찾기 | Haiku · low | 부분 | 98.2% 저렴 |
142
+ | 전체 테스트 실행 보고 | Haiku · low | 그대로 전달 | 97.9% 저렴 |
143
+ | 코드에서 함수 위치 찾기 | Sonnet · high | 그대로 전달 | 67.9% 저렴 |
144
+ | 데모 화면에 타운이 보이는지 확인 | Haiku · low | 그대로 전달 | 98.0% 저렴 |
145
+ | GeekNews 글쓰기 규칙 확인 | Haiku · low | 그대로 전달 | 97.8% 저렴 |
146
+
147
+ 모든 실행 기록은 [sprag.io/proof](https://sprag.io/proof/)에서, 전체 표는 [evals/SUMMARY.md](https://github.com/rootstudioyaml/sprag/blob/main/evals/SUMMARY.md)에서 볼 수 있습니다.
148
+ <!-- sprag:evidence:end -->
149
+
129
150
  ## 티어 기준의 근거가 된 연구
130
151
 
131
152
  티어 기준은 감으로 정한 값이 아닙니다. 기준마다 공개된 라우팅 연구를 근거로 삼았고, 룰 문구에 나오는 수치(지식 회상 28% 대 54%, 도구 체인 작업의 +63%p 격차)는 아래 데이터셋으로 sprag가 직접 오프라인 실측한 값입니다.
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <img alt="Sprag" src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/site/assets/logo/sprag-lockup-light.svg" width="220">
6
6
  </picture>
7
7
 
8
- **A model-delegation router for Claude Code and Codex: lookups, checks and test runs go to cheaper models, and the savings show up in your statusline.**
8
+ **The delegation layer for Claude Code and Codex. Each task goes to the model and effort that fits it: down to Haiku for a lookup, up to higher effort or a stronger model when a cheaper run would miss. Every rule is backed by replayed cases you can open.**
9
9
 
10
10
  [![npm](https://img.shields.io/npm/v/sprag-cli.svg?label=sprag-cli)](https://www.npmjs.com/package/sprag-cli)
11
11
  [![downloads](https://img.shields.io/npm/dm/sprag-cli.svg)](https://www.npmjs.com/package/sprag-cli)
@@ -19,8 +19,8 @@
19
19
 
20
20
  <a href="https://github.com/rootstudioyaml/sprag#teams"><img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/plan-pro-en.gif" width="640" alt="A virtual office where every teammate sits as an animal character, then the organization dashboard with spend, savings, seats and a 30-day chart, then team rules approved once and picked up by every machine."></a>
21
21
 
22
- **Sprag Pro · for teams**: your whole team's AI spend and savings, on one screen.<br>
23
- <sub>A virtual office with a character for every teammate, a seat roster, and rules the team approves once. <a href="https://github.com/rootstudioyaml/sprag#teams">See the team features</a> · <a href="mailto:support@sprag.io">support@sprag.io</a></sub>
22
+ **Sprag Pro and Enterprise · for teams**: one set of delegation rules for the whole team. Approve a rule once and every machine follows it.<br>
23
+ <sub>Spend, savings and seats on one screen, budget gauges and prompt monitoring on Enterprise, and a virtual office with a character for every teammate. <a href="https://github.com/rootstudioyaml/sprag#teams">See the team features</a> · <a href="mailto:support@sprag.io">support@sprag.io</a></sub>
24
24
 
25
25
  <a href="https://sprag.io/assets/video/sprag-compare-en.mp4"><img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/sprag-compare-en.gif" width="760" alt="Two terminals receive the same twelve requests. With Sprag, lookups and test runs go to cheaper models and documents go in as Markdown; the day ends at $1.83 against $6.68 without Sprag."></a>
26
26
 
@@ -35,13 +35,22 @@ Same 12 requests, two terminals: **$6.68 → $1.83 (−72.6%)** with Sprag.<br>
35
35
 
36
36
  ---
37
37
 
38
- **Sprag routes each piece of work to the cheapest model that has never got it
39
- wrong.** Claude Code and Codex cannot switch models per prompt, so Sprag does it
40
- the one way that works: rules in the main session hand lookups, status checks,
41
- build and test runs and batch edits to sub-agents pinned to a cheaper model. The
42
- rules come from your own session logs, you approve each one, and every delegated
43
- run writes its price difference to a ledger. `npm i -g sprag-cli` sets it all
44
- up; nothing to configure per project.
38
+ **Sprag sends each piece of work to the cheapest model and effort that does not
39
+ get it wrong.** Claude Code and Codex cannot switch models per prompt, so Sprag
40
+ does it the one way that works: rules in the main session hand work to
41
+ sub-agents pinned to a model and an effort. Lookups, status checks, build and
42
+ test runs go down to Haiku. Work that a cheaper run misses without saying so
43
+ goes up instead: a lookup spread over many files runs on Sonnet at high effort,
44
+ and open web research at xhigh, because replays showed the default medium
45
+ effort missing both. The rules come from your own session logs, you approve
46
+ each one, and every delegated run writes its price difference to a ledger.
47
+ `npm i -g sprag-cli` sets it all up; nothing to configure per project.
48
+
49
+ Every rule is checked against replays you can open.
50
+ [sprag.io/proof](https://sprag.io/proof/) re-runs real delegations under
51
+ several model and effort settings and grades them blind, and the set grows as
52
+ new cases are analysed. The same table ships with the npm package: run
53
+ `sprag proof`.
45
54
 
46
55
  Two more things ride along. Documents reach the context as compact Markdown (a
47
56
  540k-token deck becomes 23k tokens), and the statusline shows what each session
@@ -159,6 +168,25 @@ ledger. Nothing here is a projection.
159
168
 
160
169
  Every delegated run records its own price difference, so `sprag route-scan savings` traces any amount back to the rule that caused it. What the ledger deliberately leaves out is written down in [the command reference](https://github.com/rootstudioyaml/sprag/blob/main/docs/COMMANDS.md).
161
170
 
171
+ <!-- sprag:evidence:start -->
172
+ ### Replayed delegations
173
+
174
+ 10 real delegations were replayed across 3 rounds in 71 runs, the latest on 2026-11-07.
175
+
176
+ | Case | Recommended setup | Verdict | Cost vs Opus |
177
+ | --- | --- | --- | --- |
178
+ | Review model-name parsing | Sonnet · high | Relayable | 59.3% cheaper |
179
+ | Map the preset system | Sonnet · high | Relayable | 60.9% cheaper |
180
+ | Implement a price table update | Sonnet · high | Partial | 66.2% cheaper |
181
+ | Find the upload intervals | Haiku · low | Partial | 98.2% cheaper |
182
+ | Run the full test suite | Haiku · low | Relayable | 97.9% cheaper |
183
+ | Locate functions in the codebase | Sonnet · high | Relayable | 67.9% cheaper |
184
+ | Check that the demo shows the town | Haiku · low | Relayable | 98.0% cheaper |
185
+ | Check GeekNews posting rules | Haiku · low | Relayable | 97.8% cheaper |
186
+
187
+ Every run is on [sprag.io/proof](https://sprag.io/proof/), and the full table is in [evals/SUMMARY.md](https://github.com/rootstudioyaml/sprag/blob/main/evals/SUMMARY.md).
188
+ <!-- sprag:evidence:end -->
189
+
162
190
  ## Research behind the tier rules
163
191
 
164
192
  The tier criteria are not a hunch. Each one traces back to published routing
package/bin/cli.js CHANGED
@@ -131,7 +131,7 @@ function columnsFromArgs({ useEnv = true } = {}) {
131
131
 
132
132
  const KNOWN_SUBCOMMANDS = new Set([
133
133
  'last', 'brief', 'history', 'handoff', 'install', 'uninstall', 'mode', 'korean', 'cohesion',
134
- 'doc2md', 'delegate', 'harness', 'route-scan', 'compact-window', 'update-check', 'upgrade',
134
+ 'doc2md', 'delegate', 'proof', 'harness', 'route-scan', 'compact-window', 'update-check', 'upgrade',
135
135
  'seed', 'litellm-budget', 'oauth-budget', 'profile-map', 'feedback', 'saved', 'cowork', 'team', 'presets', 'routing',
136
136
  ]);
137
137
 
@@ -233,6 +233,7 @@ Usage:
233
233
  sprag routing on|off|status model delegation master switch (rules, hints, candidates)
234
234
  sprag doc2md on|off|<file> convert documents to Markdown before the model reads them
235
235
  sprag delegate on|off|status add bounds and context to Task/Agent delegation prompts
236
+ sprag proof [--json] replayed delegation cases behind the tier rules (https://sprag.io/proof/)
236
237
  sprag compact-window audit or pin autoCompactWindow for 1M sessions
237
238
  sprag saved [reset|undo|keep] show, reset or restore the saved-money counters (--agent codex for Codex)
238
239
  sprag litellm-budget LiteLLM gateway key budget and spend
@@ -430,6 +431,12 @@ async function main() {
430
431
  return (await import('../src/commands/delegate.js')).run({ args, hasFlag });
431
432
  }
432
433
 
434
+ // Subcommand: proof — list the replayed delegation cases from evals/summary.json.
435
+ // sprag proof [--json]
436
+ if (args[0] === 'proof') {
437
+ return (await import('../src/commands/proof.js')).run({ args, hasFlag });
438
+ }
439
+
433
440
  // Subcommand: seed — register the bundled starter rules (model-fitting
434
441
  // presets + curated ratchet rules), one answer at a time.
435
442
  // sprag seed | seed accept <id> --global|--project | seed skip <id>
@@ -1005,18 +1012,24 @@ async function main() {
1005
1012
  // The same cached scan says how old the savings figures are: the ledger is
1006
1013
  // filled by route-scan, so a stale scan means a stale total.
1007
1014
  let routeScanAt = null;
1008
- // Sonnet delegations sprag ran at high effort (see buildDelegatedSeg).
1009
- let effortRaises = null;
1010
1015
  try {
1011
1016
  const { readRouteScan } = await import('../src/route-scan.js');
1012
1017
  const scan = readRouteScan();
1013
1018
  unresolvedRuns = Number(scan?.unresolvedRuns) || 0;
1014
- if (scan?.effortRaises && typeof scan.effortRaises === 'object') effortRaises = scan.effortRaises;
1015
1019
  const scannedAt = Date.parse(scan?.scannedAt);
1016
1020
  routeScanAt = Number.isFinite(scannedAt) ? scannedAt : null;
1017
1021
  } catch (e) {
1018
1022
  debug('route-scan:unresolved', e);
1019
1023
  }
1024
+ // Sonnet delegations sprag ran at high effort (see buildDelegatedSeg). A
1025
+ // lookup in the effort-raise ledger with the routing reset mark, never a scan.
1026
+ let effortRaises = null;
1027
+ try {
1028
+ const { effortRaiseTotals } = await import('../src/effort-raise-ledger.js');
1029
+ effortRaises = effortRaiseTotals();
1030
+ } catch (e) {
1031
+ debug('effort-raise-ledger:totals', e);
1032
+ }
1020
1033
  // 'auto' unless the user pinned a bucket. Read here rather than in the
1021
1034
  // statusline branch below because the table and JSON formatters want the
1022
1035
  // same answer.
@@ -0,0 +1,101 @@
1
+ # evals/: replayed delegation cases
2
+
3
+ This directory is the tracked corpus behind https://sprag.io/proof/. Each case is a real delegation that was replayed headlessly under several model and effort settings, graded blind against a rubric fixed before the run, and priced from the transcripts.
4
+
5
+ | Path | What it is |
6
+ | --- | --- |
7
+ | `index.json` | case ids in display order |
8
+ | `conditions.json` | the model, effort and prompt settings a lane can use |
9
+ | `rounds.json` | rounds (`conditions` or `effort`) with their dates |
10
+ | `cases/<id>.json` | one public case: wording, runs, baseline, optional repeats |
11
+ | `summary.json`, `SUMMARY.md` | generated; the npm package ships the JSON and `sprag proof` reads it |
12
+
13
+ Everything else is generated by `node scripts/evals/build.mjs` (`npm run evals:build`): `site/proof/data.json`, the summary files and the evidence blocks in the READMEs. `npm run evals:check` verifies them without writing. Do not edit generated files by hand.
14
+
15
+ ## The loop
16
+
17
+ Every script below lives in `scripts/evals/` and has an `npm run evals:<name>` alias. Round directories live under the work directory (step 2).
18
+
19
+ 1. **Harvest.** `node scripts/evals/harvest.mjs [--days 30] [--project <substring>]` scans `~/.claude/projects` for `Agent`/`Task` delegations, skips turns the harness injected, masks secrets, drops prompts already used in a round, and writes `candidates.jsonl` (347 today) into the work directory. It prints counts per agent and effort.
20
+ 2. **Pick, then fix the rules before running.** Choose candidates and create a round directory `<work>/rounds/<id>/` with:
21
+ - `cases/<case>.md`: the delegation prompt, with `{{REPO}}` where the repository path goes. Replay substitutes the worktree path.
22
+ - `rubric/<case>.md`: the scoring rubric. **Write it before step 3.** Replay refuses to start without it. Graders have no tools, so put the answer key (what the code actually says, with file and line) inside the rubric.
23
+ - `round.json`: see below.
24
+ 3. **Replay.** `node scripts/evals/replay.mjs <round-dir> --dry-run` prints the plan, a token estimate and every full command line. Then `--yes` runs them (`--only <case>` limits it). Replay creates a detached git worktree at `commit`, runs `claude -p` in it per case and condition, and writes `reports/`, `transcripts/`, `cost.json`, `blocked.json` and `runs.json`. It never uses `bypassPermissions`: runs use `--permission-mode dontAsk`, and without `"write": true` on the case they also get `--disallowedTools Edit Write NotebookEdit`. Finished runs are skipped on a rerun; failed runs are not recorded, so a rerun retries them.
25
+ 4. **Grade.** `node scripts/evals/grade.mjs <round-dir>` prints the plan and an estimate; `--yes` runs one Opus grader per case (at most 3 at once, `--case <id>` limits it). Reports get randomized labels (P, Q, R, ...), model and effort lines are stripped, and the blind prompt is saved to `blind/<case>.md`. The label key goes to `blind_key.json`, raw replies to `grading/`, and the unblinded scores are merged into `scores_by_run.json`. A reply that is not valid JSON or fails validation is reported and not merged; rerun to retry that case (`--regrade` redoes graded cases).
26
+ 5. **Write `public.json`** in the round directory: `{ "cases": [ ... ] }`, one entry per case to publish.
27
+
28
+ ```json
29
+ {
30
+ "id": "1001", "kind": "lookup", "story": "cost-down", "publish": true,
31
+ "recommended": "haiku-low",
32
+ "storyNote": { "ko": "...", "en": "..." },
33
+ "title": { "ko": "...", "en": "..." },
34
+ "userPrompt": { "ko": "...", "en": "..." },
35
+ "task": { "ko": "...", "en": "..." },
36
+ "truth": { "ko": "...", "en": "..." },
37
+ "lesson": { "ko": "...", "en": "..." }
38
+ }
39
+ ```
40
+
41
+ `story` is `quality-up`, `cost-down` or `context`. `recommended` is the id of one of the round's conditions. `publish` must be exactly `true`; `"ask"` or `false` entries are skipped. Write the user prompt without personal context. An optional `"screenshot": "assets/<file>.png"` needs the image copied into `site/proof/assets/` by hand.
42
+ 6. **Publish.** `node scripts/evals/publish.mjs <round-dir> [--case <id>] [--replace] [--yes]`. Without `--yes` it builds the cases in memory, validates the whole corpus and prints a summary. With `--yes` it writes `cases/<id>.json`, appends to `index.json`, adds the round to `rounds.json` and any new conditions to `conditions.json`, then runs `build.mjs`. It refuses to overwrite an existing case without `--replace`. An `effort` round does not create a case: it adds `repeats` to the case that its `conditions` round already published.
43
+ 7. **Commit and push.** Commit `evals/`, `site/proof/data.json` and the README blocks. A push to `main` deploys the site (the page is live after the Pages run). The npm summary and `sprag proof` ship with the next release.
44
+
45
+ ### round.json
46
+
47
+ ```json
48
+ {
49
+ "id": "r3", "date": "2026-11-08", "kind": "conditions",
50
+ "repo": "/path/to/repo", "commit": "0a4333c",
51
+ "repeats": 1, "concurrency": 2,
52
+ "allowedTools": ["Read", "Grep", "Glob", "Bash"],
53
+ "conditions": [
54
+ { "key": "A", "id": "haiku-low", "model": "claude-haiku-5-5", "effort": "low", "agent": "t2-explore", "prompt": "original" },
55
+ { "key": "B", "id": "sonnet-high", "model": "claude-sonnet-5-5", "effort": "high", "prompt": "original" },
56
+ { "key": "C", "id": "opus-direct", "model": "claude-opus-5-5", "effort": "high", "prompt": "original", "role": "baseline" }
57
+ ],
58
+ "cases": [
59
+ { "id": "1001", "prompt": "cases/1001.md", "rubric": "rubric/1001.md", "agents": { "A": "t2-runner" } },
60
+ { "id": "1002", "prompt": "cases/1002.md", "rubric": "rubric/1002.md", "write": true }
61
+ ]
62
+ }
63
+ ```
64
+
65
+ - `model` is the full model id passed to `--model`; published runs show only the family (haiku, sonnet, opus).
66
+ - Exactly one condition of a `conditions` round has `"role": "baseline"`. Savings are measured against it.
67
+ - `agents` overrides a condition's agent for one case (case 404 ran lane A as `t2-runner`). `write: true` lets that case edit files in the worktree.
68
+ - `allowedTools` is optional. `dontAsk` denies every tool that is not allowed, so list the tools the cases need if your settings do not already allow them. A case with `write: true` also gets `Edit` and `Write`.
69
+ - `prompt: "improved"` conditions need an `improvedPrompt` file on every case.
70
+ - An `effort` round sets `repeats` above 1 and uses conditions that differ only in effort. Run keys are `<case>-<key>-<rep>`.
71
+
72
+ ## Cost
73
+
74
+ Replays and grading run through the Claude Code CLI with `ANTHROPIC_API_KEY` and `ANTHROPIC_AUTH_TOKEN` removed from the child environment, so they are billed to the Max subscription and count toward its limits, not to API credit. Both scripts do nothing without `--yes`. Show the user the printed estimate and get a confirmation before adding `--yes`. The estimate comes from past rounds' averages per model; Opus runs and web research dominate it.
75
+
76
+ ## Privacy
77
+
78
+ - Transcripts, reports, prompts and candidates stay under the git-ignored work directory: `handoff/evals-work/` by default, or the directory in `SPRAG_EVALS_WORK`. Never copy them into `evals/`.
79
+ - Only public fields reach `evals/`. Publishing scrubs home paths, scratch paths, the owner's names, the server repository name and e-mail addresses, masks token-shaped strings in reports, caps reports at 8000 characters and trace labels at 60, and replaces any trace label that looks like a secret with `(hidden)`.
80
+ - Publish then checks every string with the corpus privacy pattern (`privacyRe()` in `build.mjs`) and aborts on a hit, naming the field. `build.mjs` runs the same check again.
81
+ - Personal names are never written into this repository, not even as patterns. List them one per line in `<work dir>/private-names.txt` (git-ignored) or comma-separated in `SPRAG_EVALS_PRIVATE_NAMES`; scrub removes them and the privacy check blocks them. Without either only the generic patterns (home paths, scratch dirs, emails) apply, which is the CI case.
82
+
83
+ ## Add a condition
84
+
85
+ Add an entry to `conditions` in `round.json` with the next free key, for example:
86
+
87
+ ```json
88
+ { "key": "E", "id": "sonnet-xhigh", "model": "claude-sonnet-5-5", "effort": "xhigh", "prompt": "original" }
89
+ ```
90
+
91
+ For a new round, nothing else is needed: replay runs it, and publish adds `sonnet-xhigh` to `conditions.json` and to each case's lanes. To add a lane to a case that is already published, add the condition to that round's `round.json`, run `replay --only <case> --yes` (finished runs are skipped), grade the new reports with `grade --case <case> --yes`, then `publish --case <case> --replace --yes`. The id of a condition must not be reused with a different setup: publish stops if `conditions.json` already has that id with other values.
92
+
93
+ ## Where replay sessions show up
94
+
95
+ Replay runs `claude` with the worktree as its working directory, so the sessions are written under `~/.claude/projects/` in a folder named after the worktree path (every character that is not a letter or digit becomes `-`). Replay copies each transcript into the round directory and reads cost from it. Those sessions also appear in sprag's own session stats under that project name; they are replays, not your work. Graders run in a temporary directory, so their sessions have their own folder.
96
+
97
+ ## Weekly candidates
98
+
99
+ `npm run evals:weekly` harvests the delegations made since its last run, drops replay sessions, and flags the turns the user corrected right after (a narrow keyword match on the next prompt, so it under-reports; the 2026-11-07 review of 57 delegations found 4 silent losses by reading every turn). It posts the list to the sprag Slack channel with the same `SLACK_BOT_TOKEN` and `SPRAG_SLACK_CHANNEL_ID` lookup as `scripts/upstream-watch.mjs`, and moves `<work>/weekly-state.json` forward only after Slack accepts the post. `--dry-run` prints the message instead. It makes no model call.
100
+
101
+ On the maintainer's Mac a launchd job (`com.rootstudioyaml.sprag-evals-weekly`, Mondays 06:30) runs it; the log is `~/Library/Logs/sprag-evals-weekly.log`. Picking cases from the list, writing rubrics and approving a replay stay with a person and the main session.
@@ -0,0 +1,18 @@
1
+ # Replayed delegations
2
+
3
+ Full write-ups and every run: https://sprag.io/proof/
4
+
5
+ 10 cases, 71 runs, 3 rounds, latest 2026-11-07. Cost is the recommended setup against the Opus baseline on the same task. Generated by `npm run evals:build`.
6
+
7
+ | Case | Kind | Story | Recommended setup | Verdict | Cost vs Opus baseline |
8
+ | --- | --- | --- | --- | --- | --- |
9
+ | Find this week's cybersecurity news | research | quality-up | Sonnet · high | Relayable | 55.3% cheaper |
10
+ | Find free animal character assets | research | quality-up | Sonnet · high | Relayable | 55.7% cheaper |
11
+ | Check GeekNews posting rules | lookup | cost-down | Haiku · low | Relayable | 97.8% cheaper |
12
+ | Check that the demo shows the town | lookup | cost-down | Haiku · low | Relayable | 98.0% cheaper |
13
+ | Locate functions in the codebase | lookup | quality-up | Sonnet · high | Relayable | 67.9% cheaper |
14
+ | Run the full test suite | run | cost-down | Haiku · low | Relayable | 97.9% cheaper |
15
+ | Find the upload intervals | lookup | cost-down | Haiku · low | Partial | 98.2% cheaper |
16
+ | Implement a price table update | implement | cost-down | Sonnet · high | Partial | 66.2% cheaper |
17
+ | Map the preset system | lookup | quality-up | Sonnet · high | Relayable | 60.9% cheaper |
18
+ | Review model-name parsing | review | quality-up | Sonnet · high | Relayable | 59.3% cheaper |
@@ -0,0 +1,224 @@
1
+ {
2
+ "generatedFrom": "evals/",
3
+ "cases": 10,
4
+ "runs": 71,
5
+ "rounds": [
6
+ "r0",
7
+ "r1",
8
+ "r2"
9
+ ],
10
+ "latest": "2026-11-07",
11
+ "byStory": {
12
+ "quality-up": 5,
13
+ "cost-down": 5
14
+ },
15
+ "byKind": {
16
+ "research": 2,
17
+ "lookup": 5,
18
+ "run": 1,
19
+ "implement": 1,
20
+ "review": 1
21
+ },
22
+ "items": [
23
+ {
24
+ "id": "49",
25
+ "title": {
26
+ "ko": "최근 사이버 보안 뉴스 찾기",
27
+ "en": "Find this week's cybersecurity news"
28
+ },
29
+ "kind": "research",
30
+ "story": "quality-up",
31
+ "round": "r0",
32
+ "recommended": "sonnet-high",
33
+ "recommendedLabel": "Sonnet · high",
34
+ "recommendedVerdict": "ok",
35
+ "recommendedUsd": 0.4636,
36
+ "baselineUsd": 1.0367,
37
+ "savingsPct": 55.3,
38
+ "lesson": {
39
+ "ko": "Sonnet medium과 high는 여섯 번 중 한 번도 핵심 소식을 찾지 못했습니다. xhigh로 올리자 세 번 모두 찾았고 비용은 Opus의 약 80%였습니다.",
40
+ "en": "Sonnet at medium and high missed the main story in all six repeat runs. At xhigh it found it three times out of three, at about 80% of Opus's cost."
41
+ }
42
+ },
43
+ {
44
+ "id": "19",
45
+ "title": {
46
+ "ko": "무료 동물 캐릭터 에셋 찾기",
47
+ "en": "Find free animal character assets"
48
+ },
49
+ "kind": "research",
50
+ "story": "quality-up",
51
+ "round": "r0",
52
+ "recommended": "sonnet-high",
53
+ "recommendedLabel": "Sonnet · high",
54
+ "recommendedVerdict": "ok",
55
+ "recommendedUsd": 0.4806,
56
+ "baselineUsd": 1.0853,
57
+ "savingsPct": 55.7,
58
+ "lesson": {
59
+ "ko": "Haiku는 대표 팩을 놓쳤습니다. 등급을 올려도 일부 출처를 못 열고 '유일한 후보'라고 단정하는 버릇은 남았습니다.",
60
+ "en": "Haiku missed the main pack. Higher tiers still called one option 'the only candidate' after failing to open some sources."
61
+ }
62
+ },
63
+ {
64
+ "id": "0",
65
+ "title": {
66
+ "ko": "GeekNews 글쓰기 규칙 확인",
67
+ "en": "Check GeekNews posting rules"
68
+ },
69
+ "kind": "lookup",
70
+ "story": "cost-down",
71
+ "round": "r0",
72
+ "recommended": "haiku-low",
73
+ "recommendedLabel": "Haiku · low",
74
+ "recommendedVerdict": "ok",
75
+ "recommendedUsd": 0.0084,
76
+ "baselineUsd": 0.3895,
77
+ "savingsPct": 97.8,
78
+ "lesson": {
79
+ "ko": "페이지 몇 개만 읽으면 되는 일이라 Haiku도 같은 답을 냈고 비용은 Opus의 30분의 1이었습니다.",
80
+ "en": "A few pages to read: Haiku gave the same answer at about one thirtieth of Opus's cost."
81
+ }
82
+ },
83
+ {
84
+ "id": "44",
85
+ "title": {
86
+ "ko": "데모 화면에 타운이 보이는지 확인",
87
+ "en": "Check that the demo shows the town"
88
+ },
89
+ "kind": "lookup",
90
+ "story": "cost-down",
91
+ "round": "r0",
92
+ "recommended": "haiku-low",
93
+ "recommendedLabel": "Haiku · low",
94
+ "recommendedVerdict": "ok",
95
+ "recommendedUsd": 0.0055,
96
+ "baselineUsd": 0.2819,
97
+ "savingsPct": 98,
98
+ "lesson": {
99
+ "ko": "스크린샷 한 장을 판정하는 일이라 다섯 조건이 모두 맞혔습니다.",
100
+ "en": "Judging one screenshot: all five setups got it right."
101
+ }
102
+ },
103
+ {
104
+ "id": "4",
105
+ "title": {
106
+ "ko": "코드에서 함수 위치 찾기",
107
+ "en": "Locate functions in the codebase"
108
+ },
109
+ "kind": "lookup",
110
+ "story": "quality-up",
111
+ "round": "r0",
112
+ "recommended": "sonnet-high",
113
+ "recommendedLabel": "Sonnet · high",
114
+ "recommendedVerdict": "ok",
115
+ "recommendedUsd": 0.1414,
116
+ "baselineUsd": 0.4403,
117
+ "savingsPct": 67.9,
118
+ "lesson": {
119
+ "ko": "여러 파일을 뒤져야 하는 조회에서 Sonnet medium은 세 번 모두 일부를 놓쳤고 high로 올리면 세 번 중 두 번 모두 찾았습니다.",
120
+ "en": "Across many files, Sonnet medium missed part of the answer in all three repeats; at high it found everything in two of three."
121
+ }
122
+ },
123
+ {
124
+ "id": "404",
125
+ "title": {
126
+ "ko": "전체 테스트 실행 보고",
127
+ "en": "Run the full test suite"
128
+ },
129
+ "kind": "run",
130
+ "story": "cost-down",
131
+ "round": "r2",
132
+ "recommended": "haiku-low",
133
+ "recommendedLabel": "Haiku · low",
134
+ "recommendedVerdict": "ok",
135
+ "recommendedUsd": 0.0058,
136
+ "baselineUsd": 0.2819,
137
+ "savingsPct": 97.9,
138
+ "lesson": {
139
+ "ko": "명령 출력을 옮기는 일이라 네 조건이 모두 같은 점수를 받았습니다. Haiku는 Opus 비용의 약 28분의 1이었습니다.",
140
+ "en": "Relaying command output: all four setups scored the same, and Haiku cost about one twenty-eighth of Opus."
141
+ }
142
+ },
143
+ {
144
+ "id": "186",
145
+ "title": {
146
+ "ko": "업로드 주기 찾기",
147
+ "en": "Find the upload intervals"
148
+ },
149
+ "kind": "lookup",
150
+ "story": "cost-down",
151
+ "round": "r2",
152
+ "recommended": "haiku-low",
153
+ "recommendedLabel": "Haiku · low",
154
+ "recommendedVerdict": "partial",
155
+ "recommendedUsd": 0.0098,
156
+ "baselineUsd": 0.5527,
157
+ "savingsPct": 98.2,
158
+ "lesson": {
159
+ "ko": "핵심 수치는 Haiku도 맞혔고 비용은 Opus의 약 55분의 1이었습니다. 세션 시작 계기까지 빠짐없이 짚은 것은 Sonnet high와 Opus였습니다.",
160
+ "en": "Haiku got the key numbers at about one fifty-fifth of Opus's cost. Only Sonnet high and Opus also covered the session-start trigger."
161
+ }
162
+ },
163
+ {
164
+ "id": "476",
165
+ "title": {
166
+ "ko": "가격표 갱신 구현",
167
+ "en": "Implement a price table update"
168
+ },
169
+ "kind": "implement",
170
+ "story": "cost-down",
171
+ "round": "r2",
172
+ "recommended": "sonnet-high",
173
+ "recommendedLabel": "Sonnet · high",
174
+ "recommendedVerdict": "partial",
175
+ "recommendedUsd": 0.7112,
176
+ "baselineUsd": 2.1072,
177
+ "savingsPct": 66.2,
178
+ "lesson": {
179
+ "ko": "설계가 정해진 구현은 테스트가 품질을 지켜 주므로 Sonnet으로 충분했습니다. 구현 결과는 같았고 비용은 Opus의 3분의 1 수준이었습니다.",
180
+ "en": "With the design fixed, tests guard quality, so Sonnet was enough: same result at about a third of Opus's cost."
181
+ }
182
+ },
183
+ {
184
+ "id": "119",
185
+ "title": {
186
+ "ko": "프리셋 구조 파악",
187
+ "en": "Map the preset system"
188
+ },
189
+ "kind": "lookup",
190
+ "story": "quality-up",
191
+ "round": "r2",
192
+ "recommended": "sonnet-high",
193
+ "recommendedLabel": "Sonnet · high",
194
+ "recommendedVerdict": "ok",
195
+ "recommendedUsd": 0.3064,
196
+ "baselineUsd": 0.7838,
197
+ "savingsPct": 60.9,
198
+ "lesson": {
199
+ "ko": "Haiku는 지정된 시점 대신 최신 저장소를 읽어 다른 코드를 설명했습니다. 요금 페이지 문구까지 찾은 것은 Sonnet high뿐이었습니다.",
200
+ "en": "Haiku read the latest checkout instead of the pinned one. Only Sonnet high found the pricing page line."
201
+ }
202
+ },
203
+ {
204
+ "id": "492",
205
+ "title": {
206
+ "ko": "모델 이름 해석 검토",
207
+ "en": "Review model-name parsing"
208
+ },
209
+ "kind": "review",
210
+ "story": "quality-up",
211
+ "round": "r2",
212
+ "recommended": "sonnet-high",
213
+ "recommendedLabel": "Sonnet · high",
214
+ "recommendedVerdict": "ok",
215
+ "recommendedUsd": 0.4758,
216
+ "baselineUsd": 1.1678,
217
+ "savingsPct": 59.3,
218
+ "lesson": {
219
+ "ko": "Sonnet medium은 이 위험을 상위 3위에서 빠뜨렸고 Sonnet high와 Opus는 그대로 전달할 수 있는 검토를 냈습니다.",
220
+ "en": "Sonnet medium left that risk out of its top three. Sonnet high and Opus produced reviews ready to relay."
221
+ }
222
+ }
223
+ ]
224
+ }
package/package.json CHANGED
@@ -1,13 +1,20 @@
1
1
  {
2
2
  "name": "sprag-cli",
3
- "version": "3.103.1",
4
- "description": "Model-delegation router for Claude Code and Codex: lookups, checks and test runs go to cheaper models, documents go in as compact Markdown, and a live statusline shows spend and savings.",
3
+ "version": "3.105.0",
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": {
7
7
  "sprag": "bin/cli.js",
8
8
  "claude-token-saver": "bin/cli.js"
9
9
  },
10
10
  "scripts": {
11
+ "evals:build": "node scripts/evals/build.mjs",
12
+ "evals:check": "node scripts/evals/build.mjs --check",
13
+ "evals:harvest": "node scripts/evals/harvest.mjs",
14
+ "evals:replay": "node scripts/evals/replay.mjs",
15
+ "evals:grade": "node scripts/evals/grade.mjs",
16
+ "evals:publish": "node scripts/evals/publish.mjs",
17
+ "evals:weekly": "node scripts/evals/weekly.mjs",
11
18
  "deploy": "node scripts/deploy.mjs",
12
19
  "docs:statusline": "node scripts/docs-statusline.mjs",
13
20
  "postinstall": "node bin/postinstall.js || true",
@@ -36,6 +43,8 @@
36
43
  "docs/TEAM.ko.md",
37
44
  "docs/DATA.md",
38
45
  "docs/DATA.ko.md",
46
+ "evals/summary.json",
47
+ "evals/SUMMARY.md",
39
48
  "LICENSE",
40
49
  "NOTICE"
41
50
  ],
@@ -57,6 +66,8 @@
57
66
  "model-routing",
58
67
  "model-router",
59
68
  "model-delegation",
69
+ "effort",
70
+ "subagents",
60
71
  "llm-router",
61
72
  "claude-code-router",
62
73
  "subagent",
@@ -2,10 +2,11 @@
2
2
 
3
3
  You were spawned by a delegation call from another session. These four rules
4
4
  keep your exploration finite and your output usable by the caller that spawned
5
- you, regardless of what the rest of your prompt asks for.
5
+ you.
6
6
 
7
- 1. **Stop at the cap, report what you finished.** If you are about to exceed
8
- the tool-call cap for this delegation, or a call fails and retrying would
7
+ 1. **Stop at the cap, report what you finished.** The cap is the budget your
8
+ prompt states when it states one, and the cap line below otherwise. If you
9
+ are about to exceed it, or a call fails and retrying would
9
10
  put you over it, stop where you are and report only the work you actually
10
11
  completed. The caller runs at a higher tier and can pick up from a partial
11
12
  result; pushing past the cap spends tokens nobody asked you to spend.