sprag-cli 3.97.2 → 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 +1 -0
- package/README.md +1 -0
- package/bin/cli.js +7 -1
- package/docs/DATA.ko.md +27 -142
- package/docs/DATA.md +27 -142
- package/package.json +1 -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
|
@@ -217,6 +217,7 @@ Codex에는 기본 훅과 `AGENTS.md` 하네스, 범위별 래칫 규칙, 한국
|
|
|
217
217
|
| `sprag handoff` | 한도에 막히기 전에 작업 상태를 백업 |
|
|
218
218
|
| `sprag route-scan` | 내 기록에서 위임 후보 찾기 (LLM 호출 0회) |
|
|
219
219
|
| `sprag route-scan savings` | 라우팅 절감 원장 조회 |
|
|
220
|
+
| `sprag routing on\|off` | 모델 위임(룰과 힌트와 후보 안내) 켜기와 끄기 |
|
|
220
221
|
| `sprag harness check` | 🅷 하네스 점수 확인 |
|
|
221
222
|
| `sprag doc2md <파일>` | 문서 한 건을 Markdown 으로 변환 |
|
|
222
223
|
|
package/README.md
CHANGED
|
@@ -271,6 +271,7 @@ The ratchet presets, model-routing presets and delegation agents in `presets/` a
|
|
|
271
271
|
| `sprag handoff` | Back work up to markdown before a cap blocks you |
|
|
272
272
|
| `sprag route-scan` | Find delegation candidates in your own history (0 LLM calls) |
|
|
273
273
|
| `sprag route-scan savings` | The routing-savings ledger |
|
|
274
|
+
| `sprag routing on\|off` | Turn model delegation (rules, hints, candidates) on or off |
|
|
274
275
|
| `sprag harness check` | Current 🅷 harness score |
|
|
275
276
|
| `sprag doc2md <file>` | Convert one document to Markdown |
|
|
276
277
|
|
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
CHANGED
|
@@ -2,162 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
[← README](../README.ko.md) · [English](./DATA.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Sprag 서버로 데이터를 올리는 경우만 플랜별로 정리했습니다. 새 버전 확인처럼 내려받기만 하는 조회는 아무것도 올리지 않으므로 뺐습니다.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
팀 기능은 `sprag team join` 을 실행하거나 조직이 `SPRAG_TEAM_TOKEN` 을 배포해야 켜집니다. 그 전까지는 Pro 나 Enterprise 계약이 있어도 컴퓨터가 집계를 보내지 않습니다.
|
|
14
|
-
|
|
15
|
-
## 한눈에 보기
|
|
16
|
-
|
|
17
|
-
| 데이터 | 오픈소스 | Pro | Enterprise |
|
|
18
|
-
|---|---|---|---|
|
|
19
|
-
| 프롬프트 본문 | 보내지 않음 | 보내지 않음 | 수집을 켠 팀만, 가림 처리 후 |
|
|
20
|
-
| 어시스턴트 답변, 도구 출력 | 보내지 않음 | 보내지 않음 | 보내지 않음 |
|
|
21
|
-
| 소스 코드, 파일 내용 | 보내지 않음 | 보내지 않음 | 보내지 않음 (프롬프트에 직접 붙여 넣은 텍스트는 그 프롬프트에 포함) |
|
|
22
|
-
| 파일 경로, 프로젝트 전체 경로 | 보내지 않음 | 보내지 않음 | 보내지 않음 |
|
|
23
|
-
| 프로젝트 폴더 이름 | 보내지 않음 | 보내지 않음 | 수집한 프롬프트마다 경로의 마지막 폴더 이름 하나 |
|
|
24
|
-
| API 키, 토큰, 비밀번호 | 보내지 않음 | 보내지 않음 | 보내지 않음 (프롬프트에 섞인 키 모양 값은 업로드 전에 가림) |
|
|
25
|
-
| 호스트 이름, OS 사용자 이름 | 보내지 않음 | 보내지 않음 | 보내지 않음 |
|
|
26
|
-
| 이메일 주소 | 보내지 않음 | 대시보드에 로그인하는 오너와 어드민만 | Pro 와 같음 |
|
|
27
|
-
| 하루 단위 지출, 절감, 위임 횟수 | 보내지 않음 | 보냄 | 보냄 |
|
|
28
|
-
| OS 이름과 버전 | 보내지 않음 | 보냄 | 보냄 |
|
|
29
|
-
| 표시 이름 | 보내지 않음 | 보냄 (기본값은 무작위 ID) | 보냄 (기본값은 무작위 ID) |
|
|
30
|
-
| 위임 룰 요약 (숫자만) | 보내지 않음 | 보냄 | 보냄 |
|
|
31
|
-
| 룰 본문 | 보내지 않음 | `sprag team propose` 를 실행할 때만 | Pro 와 같음 |
|
|
32
|
-
| 익명 버전 확인, 프리셋 확인 | 요청만 | 요청만 | 요청만 |
|
|
33
|
-
|
|
34
|
-
## 오픈소스 (무료 CLI)
|
|
35
|
-
|
|
36
|
-
Sprag 의 분석은 Claude Code 와 Codex 가 이미 컴퓨터에 남긴 세션 기록을 읽어서 합니다. statusline, route-scan, 절감 원장, doc2md 변환은 모두 로컬 파일만 씁니다. statusline 을 그리는 동안 네트워크를 기다리지도 않습니다. 아래 요청은 분리된 자식 프로세스가 보내고 화면은 캐시된 답만 읽습니다.
|
|
37
|
-
|
|
38
|
-
### Sprag 이 보내는 익명 요청
|
|
39
|
-
|
|
40
|
-
| 목적지 | 시점 | 보내는 내용 | 끄는 방법 |
|
|
41
|
-
|---|---|---|---|
|
|
42
|
-
| npm 레지스트리의 `sprag-cli/latest` | 하루 한 번 안팎 | 요청만 보냅니다. 레지스트리 인증 토큰도 붙이지 않습니다 | `SPRAG_NO_UPDATE_CHECK=1` |
|
|
43
|
-
| `api.github.com/repos/rootstudioyaml/sprag/releases/tags/<버전>` | 새 버전이 보일 때만 | 요청만 보냅니다. 릴리스 핵심 세 줄을 받아 옵니다 | 위와 같음 |
|
|
44
|
-
| Sprag 프리셋 서버(Supabase)의 `presets_version`, `presets_published` | 최대 24시간에 한 번 | 요청만 보냅니다. 누구에게나 같은 공개 키를 쓰고 구성원 키나 기기 ID 는 붙이지 않습니다 | `SPRAG_NO_PRESET_SYNC=1` |
|
|
45
|
-
|
|
46
|
-
프리셋 서버의 두 함수는 게시된 프리셋을 읽기만 하는 SQL 조회이며 요청한 쪽에 대해 아무것도 기록하지 않습니다. 받은 프리셋은 CLI 에 들어 있는 공개 키로 서명을 확인한 뒤에만 적용합니다. 다만 인터넷의 모든 요청과 마찬가지로 받는 서버에는 접속한 IP 주소가 보입니다.
|
|
47
|
-
|
|
48
|
-
근거: `src/update-check.js`, `src/preset-sync.js`, `src/presets-source.js`
|
|
49
|
-
|
|
50
|
-
### 사용자를 대신해 다른 곳으로 가는 요청
|
|
51
|
-
|
|
52
|
-
다음 요청은 Sprag 서버로 가지 않습니다. 사용자가 이미 쓰고 있는 서비스에 사용자의 인증 정보로 접속합니다.
|
|
7
|
+
| 플랜 | 서버로 올리는 것 |
|
|
8
|
+
|---|---|
|
|
9
|
+
| 오픈소스 (무료 CLI) | 없음 |
|
|
10
|
+
| Pro | 팀에 참여한 컴퓨터의 하루 단위 숫자 집계 |
|
|
11
|
+
| Enterprise | Pro 의 집계, 그리고 수집을 켠 팀에 한해 직접 입력한 프롬프트 |
|
|
53
12
|
|
|
54
|
-
|
|
55
|
-
|---|---|---|---|
|
|
56
|
-
| `api.anthropic.com/api/oauth/usage` | claude.ai 계정으로 로그인했고 요금제가 Pro 나 Max 가 아닐 때(Team, Enterprise 등). 예산 게이지를 그리는 데 씁니다 | Claude Code 가 저장한 로그인 토큰을 Anthropic 에만 보냅니다. 토큰은 메모리에서만 쓰고 파일이나 로그에 적지 않습니다 | `sprag mode no-oauth-budget` 또는 `SPRAG_OAUTH_BUDGET=0` |
|
|
57
|
-
| 사용자의 LiteLLM 게이트웨이 | `ANTHROPIC_BASE_URL` 이 게이트웨이를 가리킬 때 | 이미 쓰는 게이트웨이 키로 예산과 단가를 조회합니다. 키는 캐시 파일에 적지 않습니다 | `ANTHROPIC_BASE_URL` 해제 또는 예산 세그먼트 제거 |
|
|
58
|
-
| npm, PyPI | `sprag upgrade` 를 수락했거나 doc2md 변환기를 설치할 때 | 일반 패키지 설치입니다 | 설치를 거절합니다 |
|
|
59
|
-
| GitHub 이슈 또는 익명 Google Form | `sprag feedback` 을 직접 실행할 때만 | 입력한 메시지와 Sprag 버전, OS, Node.js 버전 | 명령을 실행하지 않으면 됩니다 |
|
|
13
|
+
## 오픈소스
|
|
60
14
|
|
|
61
|
-
|
|
15
|
+
올리는 데이터가 없고 계정도 필요 없습니다. 분석은 모두 컴퓨터에 있는 세션 기록으로 합니다. `sprag feedback` 을 직접 실행했을 때만 입력한 메시지와 버전, OS 가 전달됩니다.
|
|
62
16
|
|
|
63
17
|
## Pro
|
|
64
18
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
컴퓨터는 두 경우에만 팀에 참여합니다. 사용자가 `sprag team join <토큰>` 을 실행하면 올라갈 항목 목록을 먼저 보여 주고 확인을 받습니다. 조직이 셸 프로필이나 Claude Code 관리 설정에 `SPRAG_TEAM_TOKEN` 을 넣어 두면 다음 세션에서 참여하고, 첫 세션에 팀 이름과 확인 명령을 한 줄로 알립니다.
|
|
68
|
-
|
|
69
|
-
### 올라가는 것
|
|
70
|
-
|
|
71
|
-
참여한 컴퓨터는 로컬 날짜마다 한 행을 올립니다. 업로드는 5분에 한 번 이하이고 한 번에 최근 30일까지 보냅니다.
|
|
72
|
-
|
|
73
|
-
- **금액**: Claude 지출, Codex 지출, 게이트웨이 지출, 총지출, 위임 비용, 서브에이전트 비용, 절감액(모두 USD), 모델 계열별 지출(`opus`, `sonnet` 같은 이름 단위)
|
|
74
|
-
- **횟수**: 위임 실행 횟수, 모델 계열 비중, 가격을 몰라 계산에서 뺀 건수
|
|
75
|
-
- **기기**: OS 이름과 버전(예: macOS 26), Sprag 버전, 에이전트 종류(`claude` 또는 `codex`), 표시 이름, 기기 ID
|
|
76
|
-
- **게이트웨이 사용자 해시**: LiteLLM 게이트웨이를 쓸 때만 보냅니다. 게이트웨이 주소와 사용자 ID 를 합쳐 해시한 값의 앞 16자리이며, 한 사람의 컴퓨터 두 대를 한 번만 세는 데 씁니다
|
|
77
|
-
- **위임 룰 요약**: 카테고리와 티어마다 위임 횟수, 실패율, 절감액, 상한, 시작일 같은 숫자만 담습니다
|
|
78
|
-
|
|
79
|
-
표시 이름과 기기 ID 의 기본값은 컴퓨터마다 한 번 만드는 `member-3f9a2c71` 같은 무작위 값입니다. 예전에는 OS 로그인 이름을 썼지만 실명이 서버에 올라갈 수 있어 무작위 ID 로 바꿨습니다. 실명을 쓰고 싶으면 `sprag team name "이름"` 으로 직접 정합니다. CPU 아키텍처 칸은 서버 함수의 인자로 남아 있지만 항상 빈 값을 보냅니다.
|
|
80
|
-
|
|
81
|
-
위임 룰 요약에는 허용 목록을 적용합니다. 원본 룰 파일에는 프로젝트 경로와 프롬프트 발췌가 들어 있어서, 요약은 정해진 키 12개에 숫자와 정해진 단어만 채운 새 객체로 다시 만듭니다. `test/team-rule-stats.test.js` 가 키 목록을 고정하고 경로나 예시 문장이 결과에 남지 않는지 검사합니다.
|
|
82
|
-
|
|
83
|
-
근거: `src/team-sync.js` 의 `aggregateDaily`, `deviceInfo`, `src/member-id.js`, `src/team-rule-stats.js`
|
|
84
|
-
|
|
85
|
-
### 받아 오는 것
|
|
19
|
+
`sprag team join` 을 실행하거나 조직이 `SPRAG_TEAM_TOKEN` 을 배포한 컴퓨터만 올립니다. 참여하기 전에는 계약이 있어도 아무것도 올라가지 않습니다.
|
|
86
20
|
|
|
87
|
-
|
|
21
|
+
**올리는 것** (하루 한 행)
|
|
22
|
+
- 지출, 절감액, 위임 비용(USD)과 위임 횟수
|
|
23
|
+
- 모델 계열별 지출과 비중(`opus`, `sonnet` 같은 이름 단위)
|
|
24
|
+
- OS 이름과 버전, Sprag 버전, 표시 이름(기본값은 `member-3f9a2c71` 같은 무작위 ID)
|
|
25
|
+
- 위임 룰 요약: 카테고리별 횟수, 실패율, 절감액 같은 숫자만
|
|
88
26
|
|
|
89
|
-
|
|
27
|
+
**올리지 않는 것**: 프롬프트, 대화 기록, 코드, 파일 경로, 프로젝트 이름, 룰 본문, API 키, 호스트 이름
|
|
90
28
|
|
|
91
|
-
조직의 오너와 어드민은
|
|
29
|
+
조직의 오너와 어드민은 구성원별 하루 합계만 볼 수 있습니다.
|
|
92
30
|
|
|
93
31
|
## Enterprise
|
|
94
32
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
### 수집하는 것
|
|
98
|
-
|
|
99
|
-
메인 Claude Code 세션과 Codex 세션에서 사용자가 직접 입력한 프롬프트만 올라갑니다. 프롬프트 하나마다 다음 세 값을 보냅니다.
|
|
100
|
-
|
|
101
|
-
- 입력한 시각
|
|
102
|
-
- 프로젝트 폴더 이름(경로의 마지막 부분 하나이며 전체 경로는 보내지 않습니다)
|
|
103
|
-
- 본문(최대 20,000자)
|
|
104
|
-
|
|
105
|
-
프롬프트에 직접 붙여 넣은 텍스트는 본문에 포함됩니다. 회사 정책상 민감한 코드나 문서를 프롬프트에 붙여 넣는다면 이 점을 구성원에게 알려 주십시오.
|
|
106
|
-
|
|
107
|
-
### 보내지 않는 것
|
|
108
|
-
|
|
109
|
-
어시스턴트 답변, 도구 출력, Claude 가 읽은 파일 내용, 서브에이전트 기록, 슬래시 명령 래퍼, 시스템 알림, 로컬 경로, 백그라운드 작업 알림, 다른 에이전트가 보낸 메시지, `!` 로 실행한 셸 명령과 그 출력은 올라가지 않습니다. 기록 파일 경로도 보내지 않습니다. 파일을 구분할 때는 경로를 SHA-256 으로 해시한 값의 앞 16자리를 씁니다.
|
|
110
|
-
|
|
111
|
-
### 업로드 전에 가리는 것
|
|
112
|
-
|
|
113
|
-
가림은 업로드 전에 사용자 컴퓨터에서 처리합니다.
|
|
114
|
-
|
|
115
|
-
| 종류 | 바뀌는 표지 |
|
|
116
|
-
|---|---|
|
|
117
|
-
| API 키와 토큰 (`sk-...`, `sk-ant-...`, `ghp_...`, `github_pat_...`, `AKIA...`, `xox?-...`), `Bearer` 토큰, 개인 키 블록, `KEY=`, `TOKEN=`, `PASSWORD=`, `SECRET=` 꼴의 대입 | `[redacted]` |
|
|
118
|
-
| 이메일 주소 | `[redacted:email]` |
|
|
119
|
-
| 한국 전화번호 | `[redacted:phone]` |
|
|
120
|
-
| 주민등록번호 | `[redacted:rrn]` |
|
|
121
|
-
| 카드번호 | `[redacted:card]` |
|
|
122
|
-
|
|
123
|
-
패턴은 코드 조각을 망가뜨리지 않는 쪽으로 맞췄습니다. 그래서 모양이 특이한 비밀값은 놓칠 수 있습니다. 비밀값은 프롬프트에 넣지 않는 것이 가장 안전합니다.
|
|
124
|
-
|
|
125
|
-
### 과거 기록은 올리지 않습니다
|
|
126
|
-
|
|
127
|
-
컴퓨터가 수집이 켜진 것을 처음 보면 모든 기록 파일의 현재 끝을 시작점으로 표시합니다. 그 뒤에 입력한 프롬프트만 올라가므로 정책이 닿기 전의 대화는 나가지 않습니다. 수집이 꺼지면 시작점 파일을 지우고, 다시 켜면 그 시점의 끝에서 새로 시작합니다. 꺼져 있던 동안 입력한 프롬프트도 나중에 올라가지 않습니다.
|
|
128
|
-
|
|
129
|
-
### 누가 보나
|
|
130
|
-
|
|
131
|
-
수집된 프롬프트는 그 조직의 오너와 어드민이 sprag.io/team 의 프롬프트 탭에서 봅니다. Sprag 운영자(슈퍼유저)도 지원과 장애 대응을 위해 운영 콘솔에서 같은 화면을 열 수 있습니다. 서버 함수 `prompt_access_check` 가 이 두 역할과 Enterprise 요금제만 통과시키며, Pro 조직에는 프롬프트 탭이 잠겨 있습니다.
|
|
132
|
-
|
|
133
|
-
근거: `src/team-prompts.js`
|
|
134
|
-
|
|
135
|
-
## 서버 보관과 보안
|
|
136
|
-
|
|
137
|
-
- **저장 위치**: Supabase 의 서울 리전(ap-northeast-2)
|
|
138
|
-
- **전송 구간**: Sprag 서버로 가는 요청은 모두 HTTPS 입니다
|
|
139
|
-
- **접근 경로**: 컴퓨터는 테이블에 직접 쓰지 못하고 정해진 서버 함수만 부릅니다. 각 함수는 멤버 키를 확인한 뒤 그 멤버의 행만 다룹니다. 대시보드는 행 단위 접근 제어로 자기 조직의 데이터만 보여 줍니다
|
|
140
|
-
- **멤버 키**: 사용자 데이터 디렉터리의 `team.json` 에 권한 0600 으로 보관합니다
|
|
141
|
-
- **보관 기간**: 조직을 닫은 뒤 30일 안에 조직 데이터를 지웁니다. 오너나 어드민이 제거한 컴퓨터를 "삭제"하면 그 컴퓨터의 사용 기록과 프롬프트가 바로 지워집니다
|
|
142
|
-
- **제3자 제공**: 데이터를 팔지 않습니다. 처리 위탁 업체는 [개인정보처리방침](https://sprag.io/privacy/)에 적었습니다
|
|
143
|
-
- **웹사이트**: sprag.io 에는 광고 쿠키와 분석 스크립트가 없습니다
|
|
144
|
-
|
|
145
|
-
## 직접 확인하는 방법
|
|
146
|
-
|
|
147
|
-
`sprag team status --show-payload` 는 다음 동기화에서 올라갈 기기 정보, 하루 단위 행, 위임 룰 요약을 그대로 출력합니다. Enterprise 수집이 켜져 있으면 대기 중인 프롬프트 수와 예시 하나의 앞 80자도 보여 줍니다. 네트워크에 접속하지 않고 로컬에서만 계산합니다.
|
|
148
|
-
|
|
149
|
-
모든 전송을 끄려면 아래 세 줄을 셸 프로필에 넣고 `sprag mode no-oauth-budget` 을 한 번 실행합니다.
|
|
33
|
+
Pro 와 같은 집계를 올립니다. 조직 오너나 어드민이 팀별로 프롬프트 수집을 켠 경우에만 다음이 더해집니다.
|
|
150
34
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
```
|
|
35
|
+
- 메인 세션에 직접 입력한 프롬프트의 본문(최대 20,000자), 입력 시각, 프로젝트 폴더 이름
|
|
36
|
+
- API 키, 토큰, 비밀번호, 이메일, 전화번호, 주민등록번호, 카드번호는 업로드 전에 컴퓨터에서 `[redacted]` 로 가립니다
|
|
37
|
+
- 수집을 켜기 전에 쓴 기록은 올리지 않습니다
|
|
38
|
+
- 어시스턴트 답변, 도구 출력, 파일 내용은 올리지 않습니다
|
|
156
39
|
|
|
157
|
-
|
|
40
|
+
프롬프트는 그 조직의 오너와 어드민, 그리고 지원을 맡은 Sprag 운영자만 볼 수 있습니다.
|
|
158
41
|
|
|
159
|
-
|
|
42
|
+
## 확인하고 끄기
|
|
160
43
|
|
|
161
|
-
|
|
44
|
+
- `sprag team status --show-payload`: 다음에 올라갈 내용을 그대로 보여 줍니다
|
|
45
|
+
- `SPRAG_NO_TEAM_SYNC=1`: 업로드를 모두 멈춥니다
|
|
46
|
+
- `sprag team leave`: 팀에서 나갑니다
|
|
162
47
|
|
|
163
|
-
|
|
48
|
+
데이터는 Supabase 서울 리전에 HTTPS 로 저장되며 조직을 닫으면 30일 안에 지웁니다. 문의는 support@sprag.io 로 보내 주십시오. 세부 항목은 [팀 기능 안내](./TEAM.ko.md)에 있습니다.
|
package/docs/DATA.md
CHANGED
|
@@ -2,162 +2,47 @@
|
|
|
2
2
|
|
|
3
3
|
[← README](../README.md) · [한국어](./DATA.ko.md)
|
|
4
4
|
|
|
5
|
-
This page
|
|
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
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
The team layer starts only when you run `sprag team join` or your organization deploys `SPRAG_TEAM_TOKEN`. Until then a computer sends no figures, even under a Pro or Enterprise contract.
|
|
14
|
-
|
|
15
|
-
## At a glance
|
|
16
|
-
|
|
17
|
-
| Data | Open source | Pro | Enterprise |
|
|
18
|
-
|---|---|---|---|
|
|
19
|
-
| Prompt text | not sent | not sent | teams with capture on only, after masking |
|
|
20
|
-
| Assistant replies, tool output | not sent | not sent | not sent |
|
|
21
|
-
| Source code, file contents | not sent | not sent | not sent (text you paste into a prompt is part of that prompt) |
|
|
22
|
-
| File paths, full project paths | not sent | not sent | not sent |
|
|
23
|
-
| Project folder name | not sent | not sent | the last folder name of the path, once per captured prompt |
|
|
24
|
-
| API keys, tokens, passwords | not sent | not sent | not sent (key-shaped values inside a prompt are masked before upload) |
|
|
25
|
-
| Hostname, OS user name | not sent | not sent | not sent |
|
|
26
|
-
| Email address | not sent | owners and admins who sign in to the dashboard | same as Pro |
|
|
27
|
-
| Daily spend, savings, delegation counts | not sent | sent | sent |
|
|
28
|
-
| OS name and version | not sent | sent | sent |
|
|
29
|
-
| Display name | not sent | sent (a random ID by default) | sent (a random ID by default) |
|
|
30
|
-
| Delegation rule summary (numbers only) | not sent | sent | sent |
|
|
31
|
-
| Rule text | not sent | only when you run `sprag team propose` | same as Pro |
|
|
32
|
-
| Anonymous version and preset checks | the request only | the request only | the request only |
|
|
33
|
-
|
|
34
|
-
## Open source (free CLI)
|
|
35
|
-
|
|
36
|
-
Sprag's analysis reads the session logs Claude Code and Codex already keep on your computer. The statusline, route-scan, the savings ledger and doc2md conversion all work on local files. The statusline never waits on the network: the requests below go out from a detached child process, and the screen reads only the cached answer.
|
|
37
|
-
|
|
38
|
-
### Anonymous requests Sprag makes
|
|
39
|
-
|
|
40
|
-
| Destination | When | What is sent | Turn off |
|
|
41
|
-
|---|---|---|---|
|
|
42
|
-
| `sprag-cli/latest` on your npm registry | about once a day | the request only, without the registry auth token | `SPRAG_NO_UPDATE_CHECK=1` |
|
|
43
|
-
| `api.github.com/repos/rootstudioyaml/sprag/releases/tags/<version>` | only when a newer version exists | the request only; it fetches three highlights of that release | same switch |
|
|
44
|
-
| `presets_version` and `presets_published` on the Sprag preset server (Supabase) | at most once every 24 hours | the request only, with the public key every install shares; no member key and no device ID | `SPRAG_NO_PRESET_SYNC=1` |
|
|
45
|
-
|
|
46
|
-
The two preset functions are read-only SQL queries over the published presets, and they record nothing about the caller. A fetched preset bundle is applied only after its signature checks out against a public key built into the CLI. As with any request on the internet, the receiving server does see the IP address it came from.
|
|
47
|
-
|
|
48
|
-
Source: `src/update-check.js`, `src/preset-sync.js`, `src/presets-source.js`
|
|
49
|
-
|
|
50
|
-
### Requests made on your behalf to other services
|
|
51
|
-
|
|
52
|
-
These never reach a Sprag server. They go to a service you already use, with your own credentials.
|
|
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 |
|
|
53
12
|
|
|
54
|
-
|
|
55
|
-
|---|---|---|---|
|
|
56
|
-
| `api.anthropic.com/api/oauth/usage` | signed in with a claude.ai account on a plan other than Pro or Max (Team, Enterprise and so on), to draw the budget gauge | the sign-in token Claude Code stored, sent to Anthropic only; it is used in memory and never written to a file or log | `sprag mode no-oauth-budget` or `SPRAG_OAUTH_BUDGET=0` |
|
|
57
|
-
| your LiteLLM gateway | `ANTHROPIC_BASE_URL` points at a gateway | budget and price lookups with the gateway key you already use; the key is not written to any cache file | unset `ANTHROPIC_BASE_URL` or drop the budget segment |
|
|
58
|
-
| npm, PyPI | you accept `sprag upgrade` or install the doc2md converter | an ordinary package install | decline the install |
|
|
59
|
-
| a GitHub issue or an anonymous Google Form | only when you run `sprag feedback` | the message you typed, plus Sprag version, OS and Node.js version | do not run the command |
|
|
13
|
+
## Open source
|
|
60
14
|
|
|
61
|
-
|
|
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.
|
|
62
16
|
|
|
63
17
|
## Pro
|
|
64
18
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
A computer joins a team in one of two ways. When you run `sprag team join <token>`, Sprag first prints the list of what will be uploaded and asks you to confirm. When your organization puts `SPRAG_TEAM_TOKEN` in a shell profile or in Claude Code's managed settings, the computer joins at the next session and the first session shows a one-line notice naming the team and the commands to inspect or stop it.
|
|
68
|
-
|
|
69
|
-
### What goes up
|
|
70
|
-
|
|
71
|
-
A joined computer uploads one row per local calendar day, at most once every 5 minutes, covering up to the last 30 days.
|
|
72
|
-
|
|
73
|
-
- **Money**: Claude spend, Codex spend, gateway spend, total spend, delegation cost, subagent cost and savings (all USD), plus spend per model family (names such as `opus` and `sonnet`)
|
|
74
|
-
- **Counts**: delegated runs, the share of each model family, and the number of sessions left out because their price was unknown
|
|
75
|
-
- **Device**: OS name and version (for example macOS 26), Sprag version, agent (`claude` or `codex`), display name and device ID
|
|
76
|
-
- **Gateway user hash**: only with a LiteLLM gateway. The first 16 hex characters of a hash over the gateway address and your gateway user ID, used to count one person's two computers once
|
|
77
|
-
- **Delegation rule summary**: per category and tier, numbers only, such as delegation count, failure rate, savings, budgets and the start date
|
|
78
|
-
|
|
79
|
-
The default display name and device ID are a random value such as `member-3f9a2c71`, made once per computer. Earlier versions used the OS login name, which could put a real name on the server, so it was replaced with the random ID. If you want your name on the dashboard, set it yourself with `sprag team name "Name"`. The CPU architecture field remains an argument of the server function but is always sent empty.
|
|
80
|
-
|
|
81
|
-
The rule summary is built from an allowlist. The local rule file holds project paths and prompt excerpts, so each summary row is a new object whose 12 fixed keys are filled only with numbers and fixed words. `test/team-rule-stats.test.js` pins the key set and checks that no path or example text survives into the output.
|
|
82
|
-
|
|
83
|
-
Source: `aggregateDaily` and `deviceInfo` in `src/team-sync.js`, `src/member-id.js`, `src/team-rule-stats.js`
|
|
84
|
-
|
|
85
|
-
### What comes down
|
|
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.
|
|
86
20
|
|
|
87
|
-
|
|
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
|
|
88
26
|
|
|
89
|
-
|
|
27
|
+
**Not uploaded**: prompts, conversations, code, file paths, project names, rule text, API keys, hostnames
|
|
90
28
|
|
|
91
|
-
Organization owners and admins see each member's daily totals
|
|
29
|
+
Organization owners and admins see only each member's daily totals.
|
|
92
30
|
|
|
93
31
|
## Enterprise
|
|
94
32
|
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
### What is captured
|
|
98
|
-
|
|
99
|
-
Only prompts a person typed in their main Claude Code and Codex sessions. Each prompt carries three values:
|
|
100
|
-
|
|
101
|
-
- the time it was typed
|
|
102
|
-
- the project folder name (the last part of the path only, never the full path)
|
|
103
|
-
- the text (up to 20,000 characters)
|
|
104
|
-
|
|
105
|
-
Text pasted into a prompt is part of that prompt's text. If company policy treats some code or documents as sensitive, let members know before they paste them into a prompt.
|
|
106
|
-
|
|
107
|
-
### What is never sent
|
|
108
|
-
|
|
109
|
-
Assistant replies, tool output, the contents of files Claude read, subagent transcripts, slash-command wrappers, system reminders, local paths, background-task notifications, messages from other agents, and `!` shell commands with their output. Transcript file paths are not sent either: a file is told apart by the first 16 hex characters of the SHA-256 of its path.
|
|
110
|
-
|
|
111
|
-
### What is masked before upload
|
|
112
|
-
|
|
113
|
-
Masking happens on your computer, before upload.
|
|
114
|
-
|
|
115
|
-
| Kind | Replaced with |
|
|
116
|
-
|---|---|
|
|
117
|
-
| API keys and tokens (`sk-...`, `sk-ant-...`, `ghp_...`, `github_pat_...`, `AKIA...`, `xox?-...`), `Bearer` tokens, private key blocks, assignments shaped like `KEY=`, `TOKEN=`, `PASSWORD=`, `SECRET=` | `[redacted]` |
|
|
118
|
-
| Email addresses | `[redacted:email]` |
|
|
119
|
-
| Korean phone numbers | `[redacted:phone]` |
|
|
120
|
-
| Korean resident registration numbers | `[redacted:rrn]` |
|
|
121
|
-
| Card numbers | `[redacted:card]` |
|
|
122
|
-
|
|
123
|
-
The patterns are tuned not to mangle code snippets, so an unusually shaped secret can slip through. The safest place for a secret is outside the prompt.
|
|
124
|
-
|
|
125
|
-
### History is never uploaded
|
|
126
|
-
|
|
127
|
-
The first time a computer sees capture switched on, it marks the current end of every transcript file as the starting point. Only prompts typed after that go up, so conversations from before the policy reached the computer never leave it. Switching capture off deletes the starting-point file, and switching it on again starts from the end of every file at that moment. Prompts typed while capture was off are never uploaded later.
|
|
128
|
-
|
|
129
|
-
### Who sees it
|
|
130
|
-
|
|
131
|
-
Captured prompts are read by the organization's owners and admins in the Prompts tab at sprag.io/team. Sprag operators (superusers) can open the same view in the operator console for support and incident response. The server function `prompt_access_check` lets only these two roles through, and only on the Enterprise plan; Pro organizations see the tab locked.
|
|
132
|
-
|
|
133
|
-
Source: `src/team-prompts.js`
|
|
134
|
-
|
|
135
|
-
## Storage and security on the server
|
|
136
|
-
|
|
137
|
-
- **Location**: Supabase, Seoul region (ap-northeast-2)
|
|
138
|
-
- **In transit**: every request to a Sprag server uses HTTPS
|
|
139
|
-
- **Access path**: computers cannot write tables directly; they call fixed server functions, and each function checks the member key and touches only that member's rows. The dashboard uses row-level access control, so each person sees only their own organization's data
|
|
140
|
-
- **Member key**: kept in `team.json` in the user data directory with mode 0600
|
|
141
|
-
- **Retention**: organization data is deleted within 30 days after the organization closes. When an owner or admin deletes a removed computer, that computer's usage history and prompts are erased at once
|
|
142
|
-
- **Third parties**: data is not sold. Processors are listed in the [privacy policy](https://sprag.io/privacy/)
|
|
143
|
-
- **Website**: sprag.io has no advertising cookies and no analytics scripts
|
|
144
|
-
|
|
145
|
-
## Checking it yourself
|
|
146
|
-
|
|
147
|
-
`sprag team status --show-payload` prints the device info, daily rows and rule summary that the next sync would upload. With Enterprise capture on, it also shows how many prompts are waiting and the first 80 characters of one of them. It computes all of this locally, without touching the network.
|
|
148
|
-
|
|
149
|
-
To turn every request off, put these three lines in your shell profile and run `sprag mode no-oauth-budget` once.
|
|
33
|
+
The same totals as Pro. Only when an organization owner or admin turns prompt capture on for a team, these are added:
|
|
150
34
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
```
|
|
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
|
|
156
39
|
|
|
157
|
-
|
|
40
|
+
Prompts can be read only by that organization's owners and admins, and by Sprag operators handling support.
|
|
158
41
|
|
|
159
|
-
|
|
42
|
+
## Check and turn off
|
|
160
43
|
|
|
161
|
-
|
|
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
|
|
162
47
|
|
|
163
|
-
|
|
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": {
|
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' } = {}) {
|