sprag-cli 3.97.1 → 3.98.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 +5 -0
- package/README.md +5 -0
- package/bin/cli.js +7 -1
- package/docs/DATA.ko.md +48 -0
- package/docs/DATA.md +48 -0
- package/package.json +3 -1
- package/src/brief.js +4 -2
- package/src/codex/hooks.js +2 -1
- package/src/codex/panel.js +2 -1
- package/src/commands/brief.js +15 -1
- package/src/commands/route-scan.js +19 -3
- package/src/commands/routing.js +72 -0
- package/src/harness.js +6 -3
- package/src/model-rules.js +29 -1
- package/src/preset-ratchet.js +4 -0
- package/src/route-follow.js +2 -0
- package/src/routing-switch.js +59 -0
- package/src/seed-rules.js +9 -3
package/README.ko.md
CHANGED
|
@@ -43,6 +43,8 @@
|
|
|
43
43
|
|
|
44
44
|
세션 분석은 로컬에서 실행하므로 추가 모델 호출이나 API 키가 필요하지 않습니다. Codex의 선택 기능인 예산·단가 조회는 기존 인증 정보로 사용자가 설정한 LiteLLM에 접속합니다. CLI는 Node.js 20 이상과 TOML 파서 하나를 사용합니다.
|
|
45
45
|
|
|
46
|
+
무료 CLI는 사용자를 알아볼 수 있는 데이터를 보내지 않고 계정도 필요 없습니다. Pro는 팀에 참여한 컴퓨터만 하루 단위 숫자를 올리고, Enterprise는 어드민이 켠 팀에 한해 가림 처리한 프롬프트를 더합니다. 플랜별 전체 항목과 근거 파일은 [Sprag 이 보내는 데이터](docs/DATA.ko.md)에 있습니다.
|
|
47
|
+
|
|
46
48
|
```bash
|
|
47
49
|
npm i -g sprag-cli # Claude Code용이며, Codex가 설치되어 있으면 Codex도 함께 설정합니다
|
|
48
50
|
```
|
|
@@ -215,6 +217,7 @@ Codex에는 기본 훅과 `AGENTS.md` 하네스, 범위별 래칫 규칙, 한국
|
|
|
215
217
|
| `sprag handoff` | 한도에 막히기 전에 작업 상태를 백업 |
|
|
216
218
|
| `sprag route-scan` | 내 기록에서 위임 후보 찾기 (LLM 호출 0회) |
|
|
217
219
|
| `sprag route-scan savings` | 라우팅 절감 원장 조회 |
|
|
220
|
+
| `sprag routing on\|off` | 모델 위임(룰과 힌트와 후보 안내) 켜기와 끄기 |
|
|
218
221
|
| `sprag harness check` | 🅷 하네스 점수 확인 |
|
|
219
222
|
| `sprag doc2md <파일>` | 문서 한 건을 Markdown 으로 변환 |
|
|
220
223
|
|
|
@@ -226,6 +229,7 @@ Codex에는 기본 훅과 `AGENTS.md` 하네스, 범위별 래칫 규칙, 한국
|
|
|
226
229
|
|---|---|
|
|
227
230
|
| [Codex](https://sprag.io/docs/ko/codex/) | 설치, 패널, 기본 훅, 자동 후보, 프리셋, 집계 한계 |
|
|
228
231
|
| [설치와 기본 설정](https://github.com/rootstudioyaml/sprag/blob/main/docs/INSTALL.ko.md) | 설치 직후 켜지는 기능, 직접 켜야 하는 기능, 끄는 방법 |
|
|
232
|
+
| [Sprag 이 보내는 데이터](https://sprag.io/docs/ko/data/) | 오픈소스, Pro, Enterprise 플랜별로 밖으로 나가는 항목, 볼 수 있는 사람, 끄는 방법 |
|
|
229
233
|
| [statusline](https://github.com/rootstudioyaml/sprag/blob/main/docs/STATUSLINE.ko.md) | 세그먼트 의미, 경고 칩, 토큰 급증 원인 코드, 업데이트 안내 |
|
|
230
234
|
| [명령](https://github.com/rootstudioyaml/sprag/blob/main/docs/COMMANDS.ko.md) | 전체 서브커맨드와 CLI 옵션 |
|
|
231
235
|
| [Harness](https://github.com/rootstudioyaml/sprag/blob/main/docs/HARNESS.ko.md) | 5원칙, 래칫 승격, compact-window 고정, seed 프리셋 |
|
|
@@ -303,6 +307,7 @@ Sprag 은 켜지 않으면 로컬에서만 동작합니다. `sprag team join <
|
|
|
303
307
|
`SPRAG_NO_TEAM_SYNC=1` 은 팀 관련 통신을 모두 끄고, `sprag team leave` 는 참여를 해제합니다.
|
|
304
308
|
|
|
305
309
|
- [팀 기능 안내](docs/TEAM.ko.md)
|
|
310
|
+
- [플랜별 전송 데이터 안내](docs/DATA.ko.md)
|
|
306
311
|
- 오너와 어드민용 팀 콘솔: https://sprag.io/team/
|
|
307
312
|
- 플랜 안내: https://sprag.io/license/
|
|
308
313
|
|
package/README.md
CHANGED
|
@@ -57,6 +57,8 @@ No extra model calls or API key are needed for analysis. Optional Codex gateway
|
|
|
57
57
|
budget and price lookups contact your configured LiteLLM endpoint using its
|
|
58
58
|
existing credentials. The CLI requires Node.js 20+ and one TOML parser dependency.
|
|
59
59
|
|
|
60
|
+
The free CLI sends nothing that identifies you and needs no account. Pro uploads daily figures only from computers that joined a team, and Enterprise adds masked prompt capture only for teams an admin switched on. [What Sprag sends](docs/DATA.md) lists every item by plan, with the source file behind it.
|
|
61
|
+
|
|
60
62
|
```bash
|
|
61
63
|
npm i -g sprag-cli # Claude Code, plus Codex when it is installed
|
|
62
64
|
```
|
|
@@ -269,6 +271,7 @@ The ratchet presets, model-routing presets and delegation agents in `presets/` a
|
|
|
269
271
|
| `sprag handoff` | Back work up to markdown before a cap blocks you |
|
|
270
272
|
| `sprag route-scan` | Find delegation candidates in your own history (0 LLM calls) |
|
|
271
273
|
| `sprag route-scan savings` | The routing-savings ledger |
|
|
274
|
+
| `sprag routing on\|off` | Turn model delegation (rules, hints, candidates) on or off |
|
|
272
275
|
| `sprag harness check` | Current 🅷 harness score |
|
|
273
276
|
| `sprag doc2md <file>` | Convert one document to Markdown |
|
|
274
277
|
|
|
@@ -280,6 +283,7 @@ Every subcommand, flag and the output-language setting: [command reference](http
|
|
|
280
283
|
|---|---|
|
|
281
284
|
| [Codex](https://sprag.io/docs/codex/) | Installation, panel, native hooks, automatic candidates, presets, and accounting limits |
|
|
282
285
|
| [Install](https://github.com/rootstudioyaml/sprag/blob/main/docs/INSTALL.md) | What the install turns on, what stays manual, how to turn each part off |
|
|
286
|
+
| [What Sprag sends](https://sprag.io/docs/data/) ([한국어](https://sprag.io/docs/ko/data/)) | Every outbound item by plan (open source, Pro, Enterprise), who can see it, and how to turn it off |
|
|
283
287
|
| [Statusline](https://github.com/rootstudioyaml/sprag/blob/main/docs/STATUSLINE.md) | Segments, warning chips, spike issue codes, update notifications |
|
|
284
288
|
| [Commands](https://github.com/rootstudioyaml/sprag/blob/main/docs/COMMANDS.md) | Full CLI surface |
|
|
285
289
|
| [Harness](https://github.com/rootstudioyaml/sprag/blob/main/docs/HARNESS.md) | The five principles, rule promotion, compact-window pinning, seed presets |
|
|
@@ -357,6 +361,7 @@ Sprag stays local unless you opt in. With `sprag team join <token>` (or `SPRAG_T
|
|
|
357
361
|
`SPRAG_NO_TEAM_SYNC=1` turns all team traffic off, and `sprag team leave` removes the membership.
|
|
358
362
|
|
|
359
363
|
- [Team layer guide](docs/TEAM.md)
|
|
364
|
+
- [What Sprag sends, by plan](docs/DATA.md)
|
|
360
365
|
- Team console for owners and admins: https://sprag.io/team/
|
|
361
366
|
- Plans: https://sprag.io/license/
|
|
362
367
|
|
package/bin/cli.js
CHANGED
|
@@ -116,7 +116,7 @@ function columnsFromArgs({ useEnv = true } = {}) {
|
|
|
116
116
|
const KNOWN_SUBCOMMANDS = new Set([
|
|
117
117
|
'last', 'brief', 'history', 'handoff', 'install', 'uninstall', 'mode', 'korean', 'cohesion',
|
|
118
118
|
'doc2md', 'delegate', 'harness', 'route-scan', 'compact-window', 'update-check', 'upgrade',
|
|
119
|
-
'seed', 'litellm-budget', 'oauth-budget', 'profile-map', 'feedback', 'saved', 'cowork', 'team', 'presets',
|
|
119
|
+
'seed', 'litellm-budget', 'oauth-budget', 'profile-map', 'feedback', 'saved', 'cowork', 'team', 'presets', 'routing',
|
|
120
120
|
]);
|
|
121
121
|
|
|
122
122
|
// Flags each entry path reads, collected from the hasFlag/getArg/numArg calls in
|
|
@@ -214,6 +214,7 @@ Usage:
|
|
|
214
214
|
sprag cowork [sync|on|off|exclude <dir>|include <dir>] copy the ratchet rules into Cowork tab folders
|
|
215
215
|
sprag korean on|off|status Korean writing guidance + write-time check
|
|
216
216
|
sprag cohesion on|off|status English sentence-connection guidance
|
|
217
|
+
sprag routing on|off|status model delegation master switch (rules, hints, candidates)
|
|
217
218
|
sprag doc2md on|off|<file> convert documents to Markdown before the model reads them
|
|
218
219
|
sprag delegate on|off|status add bounds and context to Task/Agent delegation prompts
|
|
219
220
|
sprag compact-window audit or pin autoCompactWindow for 1M sessions
|
|
@@ -393,6 +394,11 @@ async function main() {
|
|
|
393
394
|
return (await import('../src/commands/cohesion.js')).run({ args, hasFlag });
|
|
394
395
|
}
|
|
395
396
|
|
|
397
|
+
// Subcommand: routing — master switch for model delegation (ratchet-model.md
|
|
398
|
+
// rules, prompt hints, route-scan candidates).
|
|
399
|
+
// sprag routing on | off | status
|
|
400
|
+
if (args[0] === 'routing') return (await import('../src/commands/routing.js')).run({ args, hasFlag });
|
|
401
|
+
|
|
396
402
|
// Subcommand: doc2md — convert pptx/xlsx/pdf/docx to Markdown before the
|
|
397
403
|
// model reads them, so an unreadable binary never enters the context window.
|
|
398
404
|
// sprag doc2md on | off | <file> | --clean
|
package/docs/DATA.ko.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# Sprag 이 보내는 데이터
|
|
2
|
+
|
|
3
|
+
[← README](../README.ko.md) · [English](./DATA.md)
|
|
4
|
+
|
|
5
|
+
Sprag 서버로 데이터를 올리는 경우만 플랜별로 정리했습니다. 새 버전 확인처럼 내려받기만 하는 조회는 아무것도 올리지 않으므로 뺐습니다.
|
|
6
|
+
|
|
7
|
+
| 플랜 | 서버로 올리는 것 |
|
|
8
|
+
|---|---|
|
|
9
|
+
| 오픈소스 (무료 CLI) | 없음 |
|
|
10
|
+
| Pro | 팀에 참여한 컴퓨터의 하루 단위 숫자 집계 |
|
|
11
|
+
| Enterprise | Pro 의 집계, 그리고 수집을 켠 팀에 한해 직접 입력한 프롬프트 |
|
|
12
|
+
|
|
13
|
+
## 오픈소스
|
|
14
|
+
|
|
15
|
+
올리는 데이터가 없고 계정도 필요 없습니다. 분석은 모두 컴퓨터에 있는 세션 기록으로 합니다. `sprag feedback` 을 직접 실행했을 때만 입력한 메시지와 버전, OS 가 전달됩니다.
|
|
16
|
+
|
|
17
|
+
## Pro
|
|
18
|
+
|
|
19
|
+
`sprag team join` 을 실행하거나 조직이 `SPRAG_TEAM_TOKEN` 을 배포한 컴퓨터만 올립니다. 참여하기 전에는 계약이 있어도 아무것도 올라가지 않습니다.
|
|
20
|
+
|
|
21
|
+
**올리는 것** (하루 한 행)
|
|
22
|
+
- 지출, 절감액, 위임 비용(USD)과 위임 횟수
|
|
23
|
+
- 모델 계열별 지출과 비중(`opus`, `sonnet` 같은 이름 단위)
|
|
24
|
+
- OS 이름과 버전, Sprag 버전, 표시 이름(기본값은 `member-3f9a2c71` 같은 무작위 ID)
|
|
25
|
+
- 위임 룰 요약: 카테고리별 횟수, 실패율, 절감액 같은 숫자만
|
|
26
|
+
|
|
27
|
+
**올리지 않는 것**: 프롬프트, 대화 기록, 코드, 파일 경로, 프로젝트 이름, 룰 본문, API 키, 호스트 이름
|
|
28
|
+
|
|
29
|
+
조직의 오너와 어드민은 구성원별 하루 합계만 볼 수 있습니다.
|
|
30
|
+
|
|
31
|
+
## Enterprise
|
|
32
|
+
|
|
33
|
+
Pro 와 같은 집계를 올립니다. 조직 오너나 어드민이 팀별로 프롬프트 수집을 켠 경우에만 다음이 더해집니다.
|
|
34
|
+
|
|
35
|
+
- 메인 세션에 직접 입력한 프롬프트의 본문(최대 20,000자), 입력 시각, 프로젝트 폴더 이름
|
|
36
|
+
- API 키, 토큰, 비밀번호, 이메일, 전화번호, 주민등록번호, 카드번호는 업로드 전에 컴퓨터에서 `[redacted]` 로 가립니다
|
|
37
|
+
- 수집을 켜기 전에 쓴 기록은 올리지 않습니다
|
|
38
|
+
- 어시스턴트 답변, 도구 출력, 파일 내용은 올리지 않습니다
|
|
39
|
+
|
|
40
|
+
프롬프트는 그 조직의 오너와 어드민, 그리고 지원을 맡은 Sprag 운영자만 볼 수 있습니다.
|
|
41
|
+
|
|
42
|
+
## 확인하고 끄기
|
|
43
|
+
|
|
44
|
+
- `sprag team status --show-payload`: 다음에 올라갈 내용을 그대로 보여 줍니다
|
|
45
|
+
- `SPRAG_NO_TEAM_SYNC=1`: 업로드를 모두 멈춥니다
|
|
46
|
+
- `sprag team leave`: 팀에서 나갑니다
|
|
47
|
+
|
|
48
|
+
데이터는 Supabase 서울 리전에 HTTPS 로 저장되며 조직을 닫으면 30일 안에 지웁니다. 문의는 support@sprag.io 로 보내 주십시오. 세부 항목은 [팀 기능 안내](./TEAM.ko.md)에 있습니다.
|
package/docs/DATA.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# What Sprag sends
|
|
2
|
+
|
|
3
|
+
[← README](../README.md) · [한국어](./DATA.ko.md)
|
|
4
|
+
|
|
5
|
+
This page covers only the data Sprag uploads to its server, plan by plan. Download-only lookups such as the new-version check upload nothing, so they are left out.
|
|
6
|
+
|
|
7
|
+
| Plan | Uploaded to the server |
|
|
8
|
+
|---|---|
|
|
9
|
+
| Open source (free CLI) | nothing |
|
|
10
|
+
| Pro | daily numeric totals from computers that joined a team |
|
|
11
|
+
| Enterprise | the Pro totals, plus prompts people typed, only for teams with capture on |
|
|
12
|
+
|
|
13
|
+
## Open source
|
|
14
|
+
|
|
15
|
+
Nothing is uploaded and no account is needed. All analysis runs on the session logs already on your computer. Only when you run `sprag feedback` yourself are the message you typed, the version and the OS passed on.
|
|
16
|
+
|
|
17
|
+
## Pro
|
|
18
|
+
|
|
19
|
+
Only computers that ran `sprag team join` or got `SPRAG_TEAM_TOKEN` from their organization upload. Before joining, nothing goes up, even under a contract.
|
|
20
|
+
|
|
21
|
+
**Uploaded** (one row per day)
|
|
22
|
+
- spend, savings and delegation cost (USD), and delegation counts
|
|
23
|
+
- spend and share per model family (names such as `opus` and `sonnet`)
|
|
24
|
+
- OS name and version, Sprag version, display name (a random ID such as `member-3f9a2c71` by default)
|
|
25
|
+
- delegation rule summary: numbers only, such as counts, failure rate and savings per category
|
|
26
|
+
|
|
27
|
+
**Not uploaded**: prompts, conversations, code, file paths, project names, rule text, API keys, hostnames
|
|
28
|
+
|
|
29
|
+
Organization owners and admins see only each member's daily totals.
|
|
30
|
+
|
|
31
|
+
## Enterprise
|
|
32
|
+
|
|
33
|
+
The same totals as Pro. Only when an organization owner or admin turns prompt capture on for a team, these are added:
|
|
34
|
+
|
|
35
|
+
- the text of prompts typed in main sessions (up to 20,000 characters), the time, and the project folder name
|
|
36
|
+
- API keys, tokens, passwords, emails, phone numbers, Korean resident registration numbers and card numbers are masked as `[redacted]` on your computer before upload
|
|
37
|
+
- nothing written before capture was turned on is uploaded
|
|
38
|
+
- assistant replies, tool output and file contents are not uploaded
|
|
39
|
+
|
|
40
|
+
Prompts can be read only by that organization's owners and admins, and by Sprag operators handling support.
|
|
41
|
+
|
|
42
|
+
## Check and turn off
|
|
43
|
+
|
|
44
|
+
- `sprag team status --show-payload`: prints exactly what the next upload contains
|
|
45
|
+
- `SPRAG_NO_TEAM_SYNC=1`: stops every upload
|
|
46
|
+
- `sprag team leave`: leaves the team
|
|
47
|
+
|
|
48
|
+
Data is stored over HTTPS in Supabase's Seoul region and deleted within 30 days after an organization closes. Questions go to support@sprag.io. Item-level detail is in the [team guide](./TEAM.md).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprag-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.98.0",
|
|
4
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.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
"docs/CODEX.ko.md",
|
|
35
35
|
"docs/TEAM.md",
|
|
36
36
|
"docs/TEAM.ko.md",
|
|
37
|
+
"docs/DATA.md",
|
|
38
|
+
"docs/DATA.ko.md",
|
|
37
39
|
"LICENSE",
|
|
38
40
|
"NOTICE"
|
|
39
41
|
],
|
package/src/brief.js
CHANGED
|
@@ -30,6 +30,7 @@ import { join } from 'node:path';
|
|
|
30
30
|
import { userDataDir } from './paths.js';
|
|
31
31
|
import { resolveModelId, isOneMillionModel, effectiveWindow } from './compact-window.js';
|
|
32
32
|
import { liveWindowFor } from './ctx-window-cache.js';
|
|
33
|
+
import { routingEnabled } from './routing-switch.js';
|
|
33
34
|
|
|
34
35
|
// Context tiers as a fraction of the session's context window. Tier 1 warns
|
|
35
36
|
// (compaction/cost territory ahead), tier 2 urges wrapping up. A session only
|
|
@@ -214,8 +215,9 @@ export async function runBrief({ sessionId, transcriptPath, root = process.cwd()
|
|
|
214
215
|
}
|
|
215
216
|
|
|
216
217
|
// ── mid-session route-scan / rule-health changes (global state, briefed
|
|
217
|
-
// at most once per session per signature)
|
|
218
|
-
|
|
218
|
+
// at most once per session per signature). Skipped while the routing
|
|
219
|
+
// master switch is off. ──
|
|
220
|
+
if (routingEnabled()) try {
|
|
219
221
|
const rs = await import('./route-scan.js');
|
|
220
222
|
const mr = await import('./model-rules.js');
|
|
221
223
|
const briefed = new Set(s.briefed || []);
|
package/src/codex/hooks.js
CHANGED
|
@@ -18,6 +18,7 @@ import { bindCodexSubagent, closeStaleCodexRoutes, unsettledCodexRoutes } from '
|
|
|
18
18
|
import { seedOfferBlock } from '../seed-rules.js';
|
|
19
19
|
import { readCodexRouteScan, openCodexCandidates, shouldRescanCodex } from './route-scan.js';
|
|
20
20
|
import { userDataDir } from '../paths.js';
|
|
21
|
+
import { routingEnabled } from '../routing-switch.js';
|
|
21
22
|
import { debug } from '../debug.js';
|
|
22
23
|
import { updateOffer } from '../update-notice.js';
|
|
23
24
|
|
|
@@ -236,7 +237,7 @@ export async function codexHookOutput(event, payload, { cfg = loadConfig(), refr
|
|
|
236
237
|
if (event === 'prompt') {
|
|
237
238
|
const parts = [];
|
|
238
239
|
try { (await import('../team-ratchet.js')).spawnTeamSyncOnPrompt(); } catch (e) { debug('codex:team-prompts', e); }
|
|
239
|
-
if (codexDelegateEnabled(cfg)) {
|
|
240
|
+
if (codexDelegateEnabled(cfg) && routingEnabled(cfg)) {
|
|
240
241
|
// Before the hint for this prompt is recorded: a hint from an earlier turn
|
|
241
242
|
// that no child claimed is closed, and children that did run get priced.
|
|
242
243
|
try { closeStaleCodexRoutes(payload); } catch (e) { debug('codex:close-routes', e); }
|
package/src/codex/panel.js
CHANGED
|
@@ -24,6 +24,7 @@ import { codexRulesInReview, codexSharedRuleHealth } from './rule-health.js';
|
|
|
24
24
|
import { readCodexRouteScan, openCodexCandidates } from './route-scan.js';
|
|
25
25
|
import { codexBudgetProvider } from './budget.js';
|
|
26
26
|
import { readUpdateChip } from '../update-notice.js';
|
|
27
|
+
import { routingEnabled } from '../routing-switch.js';
|
|
27
28
|
import { cellWidth } from '../cell-width.js';
|
|
28
29
|
|
|
29
30
|
const CODEX_SUPPORTED_SEGMENTS = new Set([
|
|
@@ -125,7 +126,7 @@ export function createPanelReader({ root = process.cwd(), home, sessionId: pinne
|
|
|
125
126
|
catch { rules[scope] = null; }
|
|
126
127
|
}
|
|
127
128
|
let route = [];
|
|
128
|
-
try { route = openCodexCandidates(readCodexRouteScan(), { root: project }); } catch { /* No scan yet. */ }
|
|
129
|
+
try { if (routingEnabled(cfg)) route = openCodexCandidates(readCodexRouteScan(), { root: project }); } catch { /* No scan yet. */ }
|
|
129
130
|
let ruleReview = [];
|
|
130
131
|
try {
|
|
131
132
|
const modelRules = loadCodexModelRules();
|
package/src/commands/brief.js
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
import { readStdinJson } from '../stdin-payload.js';
|
|
19
19
|
import { debug } from '../debug.js';
|
|
20
|
+
import { routingEnabled } from '../routing-switch.js';
|
|
20
21
|
|
|
21
22
|
export async function run({ hasFlag }) {
|
|
22
23
|
if (hasFlag('--hook-tool')) {
|
|
@@ -52,7 +53,20 @@ export async function run({ hasFlag }) {
|
|
|
52
53
|
// resolving it against a general "don't spawn subagents" instruction; naming
|
|
53
54
|
// the match here removes both steps. Silent unless it is sure — see
|
|
54
55
|
// src/route-inject.js.
|
|
55
|
-
|
|
56
|
+
// Master switch off (`sprag routing off`): no hint, and the records of the
|
|
57
|
+
// previous turn are cleared so the PostToolUse nudge and the delegation
|
|
58
|
+
// guard do not act on a hint that is no longer shown.
|
|
59
|
+
const routingOn = routingEnabled();
|
|
60
|
+
if (!routingOn) {
|
|
61
|
+
try {
|
|
62
|
+
const { clearFollow } = await import('../route-follow.js');
|
|
63
|
+
clearFollow(ctx.session_id);
|
|
64
|
+
const { matchCaps } = await import('../route-inject.js');
|
|
65
|
+
const { recordRouteCaps } = await import('../route-caps.js');
|
|
66
|
+
recordRouteCaps(ctx.session_id, matchCaps(null));
|
|
67
|
+
} catch (e) { debug('brief:routing-off', e); }
|
|
68
|
+
}
|
|
69
|
+
if (routingOn) try {
|
|
56
70
|
const { routeHint, routeMatch, matchCaps, sessionModelRank, hintTarget, hintLabel } = await import('../route-inject.js');
|
|
57
71
|
// The payload names the session but not its model, so the rank comes from
|
|
58
72
|
// the transcript: without it a Sonnet session is told to delegate to
|
|
@@ -10,6 +10,7 @@ import { createRequire } from 'node:module';
|
|
|
10
10
|
const require = createRequire(import.meta.url);
|
|
11
11
|
import { readStdinJson } from '../stdin-payload.js';
|
|
12
12
|
import { debug } from '../debug.js';
|
|
13
|
+
import { routingEnabled } from '../routing-switch.js';
|
|
13
14
|
import { signedUsd } from '../money.js';
|
|
14
15
|
import { agentForRule, TIER_MODEL } from '../agents.js';
|
|
15
16
|
|
|
@@ -302,7 +303,12 @@ export async function run({ args, hasFlag, numArg }) {
|
|
|
302
303
|
spawnDetachedCli(['route-scan', '--refresh', '--quiet']);
|
|
303
304
|
} catch (e) { debug('route-scan:spawn-refresh', e); /* stale cache is still usable below */ }
|
|
304
305
|
}
|
|
305
|
-
|
|
306
|
+
// Routing master switch off: no candidate and no rule-health briefing goes
|
|
307
|
+
// to the session. The scan, agent files and ratchet files below still run,
|
|
308
|
+
// because the off state is rendered inside syncAllFiles and
|
|
309
|
+
// preparePresetRatchet.
|
|
310
|
+
const routingOn = routingEnabled();
|
|
311
|
+
const open = routingOn ? rs.openCandidates(cache) : [];
|
|
306
312
|
// Rule text shown to the model must be composed the same way the md file
|
|
307
313
|
// composes it, budget clause included — otherwise the briefing promises
|
|
308
314
|
// one rule and the file carries another.
|
|
@@ -321,7 +327,12 @@ export async function run({ args, hasFlag, numArg }) {
|
|
|
321
327
|
try { (await import('../preset-sync.js')).spawnPresetSyncIfDue(); } catch (e) { debug('route-scan:preset-sync', e); }
|
|
322
328
|
// Agent files come first so the ratchet-model.md rendered next names them.
|
|
323
329
|
try { (await import('../delegation-agents.js')).syncDelegationAgents(); } catch (e) { debug('route-scan:delegation-agents', e); }
|
|
324
|
-
|
|
330
|
+
// The session's project is passed so its rule-less file follows the
|
|
331
|
+
// routing switch as well (see syncAllFiles).
|
|
332
|
+
try {
|
|
333
|
+
const { findProjectRoot } = await import('../harness.js');
|
|
334
|
+
mrHook.syncAllFiles({ roots: [findProjectRoot(hookCtx.cwd || process.cwd())] });
|
|
335
|
+
} catch (e) { debug('route-scan:sync-ratchet', e); }
|
|
325
336
|
// Same reason for the preset ratchet: an upgrade that rewords or drops a
|
|
326
337
|
// bundled rule reaches ratchet-preset.md here, without a reinstall. It
|
|
327
338
|
// also moves presets older versions appended to ratchet.md.
|
|
@@ -345,7 +356,7 @@ export async function run({ args, hasFlag, numArg }) {
|
|
|
345
356
|
let reviewRules = [];
|
|
346
357
|
try {
|
|
347
358
|
const mr = mrHook;
|
|
348
|
-
reviewRules = mr.loadModelRules().rules
|
|
359
|
+
if (routingOn) reviewRules = mr.loadModelRules().rules
|
|
349
360
|
.map((r, i) => ({ ...r, n: i + 1 }))
|
|
350
361
|
.filter((r) => r.status === 'review');
|
|
351
362
|
} catch (e) { debug('route-scan:load-rules', e); /* candidate briefing still goes out */ }
|
|
@@ -533,6 +544,11 @@ export async function run({ args, hasFlag, numArg }) {
|
|
|
533
544
|
console.log(lang === 'ko'
|
|
534
545
|
? `route-scan — 최근 ${cache.days}일: 에피소드 ${cache.totalEpisodes}건 중 easy ${cache.easyEpisodes}건 (${easyPct}%) [스캔: ${cache.scannedAt}]`
|
|
535
546
|
: `route-scan — last ${cache.days}d: ${cache.easyEpisodes}/${cache.totalEpisodes} episodes easy (${easyPct}%) [scanned: ${cache.scannedAt}]`);
|
|
547
|
+
if (!routingEnabled()) {
|
|
548
|
+
console.log(lang === 'ko'
|
|
549
|
+
? 'routing 이 꺼져 있어 후보를 세션에 알리지 않습니다. 켜기: sprag routing on'
|
|
550
|
+
: 'Routing is off, so candidates are not announced to the session. Enable with: sprag routing on');
|
|
551
|
+
}
|
|
536
552
|
const open = rs.openCandidates(cache);
|
|
537
553
|
if (open.length === 0) {
|
|
538
554
|
console.log(lang === 'ko'
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Subcommand: routing — master switch for model delegation.
|
|
3
|
+
*
|
|
4
|
+
* sprag routing # status
|
|
5
|
+
* sprag routing on|off # turn every delegation path on or off
|
|
6
|
+
*
|
|
7
|
+
* Off removes the delegation rules from ratchet-model.md and the preset
|
|
8
|
+
* ratchet, the per-prompt route hint, and the route-scan candidate and
|
|
9
|
+
* rule-health briefings. Registered rules stay in the registry.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export async function run({ args }) {
|
|
13
|
+
const sub = args[1];
|
|
14
|
+
const { userLanguage } = await import('../config.js');
|
|
15
|
+
const ko = userLanguage() === 'ko';
|
|
16
|
+
const { routingEnabled, setRoutingEnabled } = await import('../routing-switch.js');
|
|
17
|
+
|
|
18
|
+
const rules = async () => (await import('../model-rules.js')).loadModelRules().rules.length;
|
|
19
|
+
// Re-render the files that carry delegation text so the change shows without
|
|
20
|
+
// waiting for the next session start. Each step may fail on its own.
|
|
21
|
+
const resync = async () => {
|
|
22
|
+
try {
|
|
23
|
+
const { findProjectRoot } = await import('../harness.js');
|
|
24
|
+
(await import('../model-rules.js')).syncAllFiles({ roots: [findProjectRoot()] });
|
|
25
|
+
} catch { /* the next session start re-renders */ }
|
|
26
|
+
try { (await import('../preset-ratchet.js')).syncPresetRatchet(); } catch { /* the next session start re-renders */ }
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
if (sub === 'off') {
|
|
30
|
+
setRoutingEnabled(false);
|
|
31
|
+
await resync();
|
|
32
|
+
const n = await rules().catch(() => 0);
|
|
33
|
+
console.log(ko ? '✓ 모델 위임을 껐습니다.' : '✓ Model delegation is off.');
|
|
34
|
+
console.log(ko
|
|
35
|
+
? '다음 세션부터 위임 룰과 프롬프트 힌트와 후보 안내가 빠집니다.'
|
|
36
|
+
: 'From the next session, delegation rules, prompt hints and candidate notices are left out.');
|
|
37
|
+
console.log(ko
|
|
38
|
+
? `등록된 룰 ${n}건은 보관됩니다. 다시 켜면 그대로 적용됩니다.`
|
|
39
|
+
: `The ${n} registered rule(s) are kept and apply again when you turn routing back on.`);
|
|
40
|
+
console.log(ko
|
|
41
|
+
? '위임 에이전트 파일까지 지우려면 sprag delegate agents off 를 쓰십시오.'
|
|
42
|
+
: 'To remove the delegation agent files too, run: sprag delegate agents off');
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (sub === 'on') {
|
|
47
|
+
setRoutingEnabled(true);
|
|
48
|
+
await resync();
|
|
49
|
+
console.log(ko ? '✓ 모델 위임을 켰습니다.' : '✓ Model delegation is on.');
|
|
50
|
+
console.log(ko
|
|
51
|
+
? '다음 세션부터 위임 룰과 프롬프트 힌트와 후보 안내가 적용됩니다.'
|
|
52
|
+
: 'From the next session, delegation rules, prompt hints and candidate notices apply.');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (sub === undefined || sub === 'status') {
|
|
57
|
+
const on = routingEnabled();
|
|
58
|
+
const n = await rules().catch(() => 0);
|
|
59
|
+
let agentsOn = true;
|
|
60
|
+
try { agentsOn = (await import('../delegation-agents.js')).delegationAgentStatus().enabled; } catch { /* default on */ }
|
|
61
|
+
console.log(`routing: ${on ? 'on' : 'off'}`);
|
|
62
|
+
console.log(ko ? `등록된 룰: ${n}건` : `registered rules: ${n}`);
|
|
63
|
+
console.log(`delegate agents: ${agentsOn ? 'on' : 'off'}`);
|
|
64
|
+
console.log(ko
|
|
65
|
+
? (on ? '끄기: sprag routing off' : '켜기: sprag routing on')
|
|
66
|
+
: (on ? 'Disable with: sprag routing off' : 'Enable with: sprag routing on'));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log('Usage: sprag routing on|off|status');
|
|
71
|
+
process.exitCode = 1;
|
|
72
|
+
}
|
package/src/harness.js
CHANGED
|
@@ -26,6 +26,7 @@ import { routeWarningForStatusline } from './route-scan.js';
|
|
|
26
26
|
import { ruleHealthWarningForStatusline, modelRatchetPathFor, renderModelRatchet } from './model-rules.js';
|
|
27
27
|
import { compactWindowWarningForStatusline } from './compact-window.js';
|
|
28
28
|
import { userLanguage } from './config.js';
|
|
29
|
+
import { routingEnabled, routingOffRatchetText } from './routing-switch.js';
|
|
29
30
|
import { codexUserDir } from './agent.js';
|
|
30
31
|
import { ratchetPresetEntries } from './presets-source.js';
|
|
31
32
|
|
|
@@ -281,7 +282,7 @@ export function harnessInit({ root = findProjectRoot(), force = false, scope = '
|
|
|
281
282
|
if (!existsSync(mrPath)) {
|
|
282
283
|
try {
|
|
283
284
|
mkdirSync(dirname(mrPath), { recursive: true });
|
|
284
|
-
writeFileSync(mrPath, renderModelRatchet([]));
|
|
285
|
+
writeFileSync(mrPath, routingEnabled() ? renderModelRatchet([]) : routingOffRatchetText(userLanguage()));
|
|
285
286
|
result.wrote.push(mrPath);
|
|
286
287
|
} catch { /* unwritable — route-scan will retry on its next sync */ }
|
|
287
288
|
} else {
|
|
@@ -652,15 +653,17 @@ export function harnessStatusForStatusline(cfg, { root, liveWindow = null } = {}
|
|
|
652
653
|
// Below session-quality warnings: a promoted delegation rule whose
|
|
653
654
|
// category started failing (`rule-health R<N>`) — the user approved that
|
|
654
655
|
// rule, so its degradation outranks a mere new-candidate nudge.
|
|
656
|
+
// Both routing warnings are skipped while the master switch is off.
|
|
657
|
+
const routingOn = routingEnabled(cfg);
|
|
655
658
|
try {
|
|
656
|
-
const w = ruleHealthWarningForStatusline(projectRoot);
|
|
659
|
+
const w = routingOn ? ruleHealthWarningForStatusline(projectRoot) : null;
|
|
657
660
|
if (w) warnings.push(w);
|
|
658
661
|
} catch { /* registry unreadable — stay silent */ }
|
|
659
662
|
// Lowest precedence: route-scan delegation candidate (`route? R<N>`).
|
|
660
663
|
// Session-quality warnings above always win — routing is an optimization
|
|
661
664
|
// nudge, not a correctness signal. Cheap: one small cached-JSON read.
|
|
662
665
|
try {
|
|
663
|
-
const w = routeWarningForStatusline(projectRoot);
|
|
666
|
+
const w = routingOn ? routeWarningForStatusline(projectRoot) : null;
|
|
664
667
|
if (w) warnings.push(w);
|
|
665
668
|
} catch { /* scan cache unreadable — stay silent */ }
|
|
666
669
|
// `warning` is the one shown; `moreWarnings` counts the ones it outranks.
|
package/src/model-rules.js
CHANGED
|
@@ -38,6 +38,7 @@ import { agentPhrase, agentPhraseEn, resolveAgentName, agentForRule, TIER_MODEL
|
|
|
38
38
|
import { writeStateFile } from './state-file.js';
|
|
39
39
|
import { signedUsd } from './money.js';
|
|
40
40
|
import { implementationDelegationRule } from './implementation-delegation.js';
|
|
41
|
+
import { routingEnabled, routingOffRatchetText } from './routing-switch.js';
|
|
41
42
|
|
|
42
43
|
// Post-promotion delegated-category error rate above this flags the rule
|
|
43
44
|
// for review (rule-health). Calibrated against local T0 avg error incidence.
|
|
@@ -548,7 +549,7 @@ export function modelRatchetPathFor(scope, targetRoot) {
|
|
|
548
549
|
* version's template, so an upgrade that reworded the rules reaches the disk
|
|
549
550
|
* on the next session rather than waiting for a rescan to happen to fire.
|
|
550
551
|
*/
|
|
551
|
-
export function syncAllFiles({ previousPaths = [] } = {}) {
|
|
552
|
+
export function syncAllFiles({ previousPaths = [], roots = [] } = {}) {
|
|
552
553
|
const data = loadModelRules();
|
|
553
554
|
const byPath = new Map();
|
|
554
555
|
for (const r of data.rules) {
|
|
@@ -572,6 +573,33 @@ export function syncAllFiles({ previousPaths = [] } = {}) {
|
|
|
572
573
|
}
|
|
573
574
|
};
|
|
574
575
|
const written = [];
|
|
576
|
+
// Files that hold no rule but exist: the global one and those of `roots`.
|
|
577
|
+
// `harness init` seeds them with renderModelRatchet([]), whose header alone
|
|
578
|
+
// tells the model the user approved delegation, so the master switch has to
|
|
579
|
+
// reach them too even though the registry names none of them.
|
|
580
|
+
const ruleless = [modelRatchetPathFor('global'), ...roots.map((r) => modelRatchetPathFor('project', r))]
|
|
581
|
+
.filter((p, i, all) => all.indexOf(p) === i && !byPath.has(p) && existsSync(p));
|
|
582
|
+
// Master switch off: every file this registry owns says so instead of
|
|
583
|
+
// carrying rules. The registry itself is untouched, so turning routing back
|
|
584
|
+
// on re-renders everything.
|
|
585
|
+
if (!routingEnabled()) {
|
|
586
|
+
const text = routingOffRatchetText(userLanguage());
|
|
587
|
+
for (const p of byPath.keys()) {
|
|
588
|
+
if (writeIfChanged(p, text)) written.push(p);
|
|
589
|
+
}
|
|
590
|
+
for (const p of [...previousPaths, ...ruleless]) {
|
|
591
|
+
if (!byPath.has(p) && existsSync(p) && writeIfChanged(p, text)) written.push(p);
|
|
592
|
+
}
|
|
593
|
+
return written;
|
|
594
|
+
}
|
|
595
|
+
// Back on: a rule-less file still carrying the off notice gets the empty
|
|
596
|
+
// rendering back. Any other content is left as it is.
|
|
597
|
+
const offTexts = new Set([routingOffRatchetText('ko'), routingOffRatchetText('en')]);
|
|
598
|
+
for (const p of ruleless) {
|
|
599
|
+
let text = null;
|
|
600
|
+
try { text = readFileSync(p, 'utf8'); } catch { /* unreadable — leave it */ }
|
|
601
|
+
if (offTexts.has(text) && writeIfChanged(p, renderModelRatchet([]))) written.push(p);
|
|
602
|
+
}
|
|
575
603
|
for (const [p, rules] of byPath) {
|
|
576
604
|
// Agents are looked up where the file's readers are: the project for a
|
|
577
605
|
// project file, the user directory alone for the global one.
|
package/src/preset-ratchet.js
CHANGED
|
@@ -22,6 +22,7 @@ import { homedir } from 'node:os';
|
|
|
22
22
|
import { dirname, join } from 'node:path';
|
|
23
23
|
import { codexUserDir } from './agent.js';
|
|
24
24
|
import { userLanguage } from './config.js';
|
|
25
|
+
import { routingEnabled, DELEGATION_PRESET_IDS } from './routing-switch.js';
|
|
25
26
|
import {
|
|
26
27
|
HARNESS_BLOCK_BEGIN,
|
|
27
28
|
HARNESS_BLOCK_END,
|
|
@@ -55,7 +56,10 @@ function writeIfChanged(file, text) {
|
|
|
55
56
|
/** The accepted-global presets, in the bundled order, with this version's wording. */
|
|
56
57
|
export function acceptedGlobalPresets({ agent = 'claude', lang = userLanguage() } = {}) {
|
|
57
58
|
const { decided } = loadSeedState({ agent });
|
|
59
|
+
// Routing off: delegation presets stay recorded in seed-state but are not rendered.
|
|
60
|
+
const on = routingEnabled();
|
|
58
61
|
return ratchetPresets(lang, { agent })
|
|
62
|
+
.filter((p) => on || !DELEGATION_PRESET_IDS.has(p.id))
|
|
59
63
|
.filter((p) => decided[p.id]?.action === 'accepted' && decided[p.id]?.scope === 'global')
|
|
60
64
|
.map((p) => ({ id: p.id, text: p.text }));
|
|
61
65
|
}
|
package/src/route-follow.js
CHANGED
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
import { join } from 'node:path';
|
|
38
38
|
import { userDataDir } from './paths.js';
|
|
39
39
|
import { loadConfig } from './config.js';
|
|
40
|
+
import { routingEnabled } from './routing-switch.js';
|
|
40
41
|
import { writeStateFile } from './state-file.js';
|
|
41
42
|
import { debug } from './debug.js';
|
|
42
43
|
|
|
@@ -182,6 +183,7 @@ function nudgeText(info, n, mcp) {
|
|
|
182
183
|
*/
|
|
183
184
|
export function followToolUse(payload, { now = Date.now(), cfg = loadConfig(), dir } = {}) {
|
|
184
185
|
try {
|
|
186
|
+
if (!routingEnabled(cfg)) return null;
|
|
185
187
|
if (cfg?.routeFollowUp === false) return null;
|
|
186
188
|
// A subagent's own tool calls reach this hook under the parent's session id,
|
|
187
189
|
// and PostToolUse for the Task call itself only fires once the subagent has
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* routing-switch — the master switch for model delegation.
|
|
3
|
+
*
|
|
4
|
+
* sprag puts delegation instructions into a Claude Code session through
|
|
5
|
+
* several paths: ratchet-model.md, the preset ratchet rules, the per-prompt
|
|
6
|
+
* route hint, the route-scan briefing, and the Codex prompt hook. One flag in
|
|
7
|
+
* config.json (`routing`) turns all of them off together. Only an explicit
|
|
8
|
+
* `false` means off; a missing key is on, so existing installs keep working.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
import { loadConfig, saveConfig } from './config.js';
|
|
12
|
+
|
|
13
|
+
export function routingEnabled(cfg = loadConfig()) {
|
|
14
|
+
try {
|
|
15
|
+
return cfg?.routing !== false;
|
|
16
|
+
} catch {
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function setRoutingEnabled(on) {
|
|
22
|
+
const cfg = loadConfig();
|
|
23
|
+
cfg.routing = on !== false;
|
|
24
|
+
saveConfig(cfg);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Preset ratchet rules (presets/ratchet-rules.json) whose text tells the model
|
|
28
|
+
// to delegate: fix-f558f9 sends simple lookups and commands to T2 agents and
|
|
29
|
+
// fix-777a15 sends multi-file implementation to the T1 worker. The other
|
|
30
|
+
// presets are general habits that stay useful with delegation off.
|
|
31
|
+
export const DELEGATION_PRESET_IDS = new Set(['fix-f558f9', 'fix-777a15']);
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Body of ratchet-model.md while routing is off. The file stays in place
|
|
35
|
+
* because CLAUDE.md imports its path, but it carries no delegation rule and
|
|
36
|
+
* no approval wording.
|
|
37
|
+
*/
|
|
38
|
+
export function routingOffRatchetText(lang = 'en') {
|
|
39
|
+
if (lang === 'ko') {
|
|
40
|
+
return [
|
|
41
|
+
'# Model-Fitting Ratchet (sprag 자동 관리)',
|
|
42
|
+
'',
|
|
43
|
+
'sprag 모델 위임이 꺼져 있어 이 파일은 위임 룰을 싣지 않습니다.',
|
|
44
|
+
'서브에이전트 사용은 사용자의 요청과 세션의 다른 지침을 따르십시오.',
|
|
45
|
+
'',
|
|
46
|
+
'등록된 룰은 보관되어 있습니다. `sprag routing on` 으로 다시 켜면 이 파일이 채워집니다.',
|
|
47
|
+
'',
|
|
48
|
+
].join('\n');
|
|
49
|
+
}
|
|
50
|
+
return [
|
|
51
|
+
'# Model-Fitting Ratchet (managed by sprag)',
|
|
52
|
+
'',
|
|
53
|
+
'sprag model delegation is off, so this file carries no delegation rules.',
|
|
54
|
+
'Use subagents as the user asks and as the other instructions in the session say.',
|
|
55
|
+
'',
|
|
56
|
+
'Registered rules are kept. Run `sprag routing on` to turn delegation back on and this file is filled again.',
|
|
57
|
+
'',
|
|
58
|
+
].join('\n');
|
|
59
|
+
}
|
package/src/seed-rules.js
CHANGED
|
@@ -38,6 +38,7 @@ import { firstSentence, OFFER_CUT } from './first-sentence.js';
|
|
|
38
38
|
// which stays dependency-free so the per-prompt hook does not load this module.
|
|
39
39
|
export { firstSentence, OFFER_CUT };
|
|
40
40
|
import { userLanguage } from './config.js';
|
|
41
|
+
import { routingEnabled, DELEGATION_PRESET_IDS } from './routing-switch.js';
|
|
41
42
|
import { writeStateFile } from './state-file.js';
|
|
42
43
|
import {
|
|
43
44
|
addModelRule,
|
|
@@ -109,8 +110,12 @@ const stripDate = (t) => t.replace(/^\d{4}-\d{2}-\d{2}(\s*\([^)]*\))?:\s*/, '').
|
|
|
109
110
|
* A shared policy covers its tier and category only within its approved scope.
|
|
110
111
|
* A decision in another project must not suppress this project's offer.
|
|
111
112
|
*/
|
|
112
|
-
export function pendingSeeds({ lang = userLanguage(), root = findProjectRoot(), agent = 'claude' } = {}) {
|
|
113
|
+
export function pendingSeeds({ lang = userLanguage(), root = findProjectRoot(), agent = 'claude', includeDelegation = false } = {}) {
|
|
113
114
|
const { decided } = loadSeedState({ agent });
|
|
115
|
+
// With the routing master switch off, delegation presets are not offered.
|
|
116
|
+
// `includeDelegation` is for findSeed, so an explicit `seed accept <id>`
|
|
117
|
+
// still finds them.
|
|
118
|
+
const offerDelegation = includeDelegation || routingEnabled();
|
|
114
119
|
const registered = sharedModelRulesForProject(loadSharedModelRules({ includeInactive: true }), root);
|
|
115
120
|
const haveModel = new Set(registered.map((r) => `${r.tier}|${r.category}`));
|
|
116
121
|
|
|
@@ -123,7 +128,7 @@ export function pendingSeeds({ lang = userLanguage(), root = findProjectRoot(),
|
|
|
123
128
|
|
|
124
129
|
const out = [];
|
|
125
130
|
const roots = sharedProjectRoots(root);
|
|
126
|
-
for (const p of modelPresets()) {
|
|
131
|
+
for (const p of (offerDelegation ? modelPresets() : [])) {
|
|
127
132
|
const decision = decided[p.id];
|
|
128
133
|
if (decision?.action === 'skipped') continue;
|
|
129
134
|
// An answer recorded before decisions kept targetRoot cannot name its
|
|
@@ -144,6 +149,7 @@ export function pendingSeeds({ lang = userLanguage(), root = findProjectRoot(),
|
|
|
144
149
|
}
|
|
145
150
|
for (const p of ratchetPresets(lang, { agent })) {
|
|
146
151
|
if (decided[p.id]) continue;
|
|
152
|
+
if (!offerDelegation && DELEGATION_PRESET_IDS.has(p.id)) continue;
|
|
147
153
|
// Either language counts as already registered: `harness pull` may have
|
|
148
154
|
// written the other one.
|
|
149
155
|
if (haveText.has(stripDate(p.text)) || haveText.has(stripDate(p.ko))) continue;
|
|
@@ -169,7 +175,7 @@ function codexSeedText(p, lang) {
|
|
|
169
175
|
|
|
170
176
|
/** One pending seed by id, or null. Ids are matched exactly. */
|
|
171
177
|
export function findSeed(id, opts = {}) {
|
|
172
|
-
return pendingSeeds(opts).find((s) => s.id === id) || null;
|
|
178
|
+
return pendingSeeds({ ...opts, includeDelegation: true }).find((s) => s.id === id) || null;
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
function recordDecision(id, action, extra = {}, { agent = 'claude' } = {}) {
|