sprag-cli 3.138.0 → 3.139.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 +15 -1
- package/README.md +15 -1
- package/bin/cli.js +5 -0
- package/mod/sprag-statusline/hooks/register.tsx +33 -1
- package/package.json +1 -1
- package/src/doc2md.cjs +14 -2
- package/src/formatters/statusline.js +20 -4
- package/src/stdin-payload.js +22 -0
package/README.ko.md
CHANGED
|
@@ -75,6 +75,18 @@ Sprag는 사용자가 고른 모델을 바꾸지 않습니다. 분석은 로컬
|
|
|
75
75
|
|
|
76
76
|
Codex를 쓴다면 아래 [Codex](#codex) 절을 보십시오.
|
|
77
77
|
|
|
78
|
+
## Sprag Bar: macOS 메뉴 막대에서 모든 세션 보기
|
|
79
|
+
|
|
80
|
+
Mac에서는 메뉴 막대에 동물 한 마리가 함께 뜹니다. 에이전트 세션이 기기를 많이 쓸수록 빨리 달리고 옆에 CPU 사용률이 나옵니다. 누르면 실행 중인 Claude Code와 Codex 세션이 모두 보입니다. 세션마다 모델과 effort, 지금 하는 일, 컨텍스트 사용량, 비용, CPU와 메모리가 나오고 계정별 5시간 한도와 주간 한도도 함께 나옵니다.
|
|
81
|
+
|
|
82
|
+
<img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/sprag-bar-panel.png" width="400" alt="Sprag Bar 패널. 세션 5개 가운데 3개는 작업 중이고 2개는 입력을 기다립니다. 줄마다 Claude인지 Codex인지, 맡은 일, 모델과 effort, 그 상태로 지난 시간, CPU, 메모리, 컨텍스트, 비용이 나옵니다.">
|
|
83
|
+
|
|
84
|
+
대시보드 창은 세션을 프로젝트별로 묶고 각 세션이 지금 돌리는 도구 호출과 일을 넘긴 서브에이전트를 보여 줍니다. 타일의 이동 단추를 누르면 그 세션이 열린 Terminal.app이나 iTerm2 탭이 앞으로 나옵니다. 창 크기는 세 가지(⌘1, ⌘2, ⌘3)이고 끝난 세션이 남긴 프로세스는 목록에서 골라 끌 수 있습니다.
|
|
85
|
+
|
|
86
|
+
<img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/sprag-bar-dashboard.png" width="760" alt="중간 크기의 Sprag Bar 대시보드. 프로젝트별로 묶인 세션 타일마다 상태, 모델, 컨텍스트, CPU, 메모리, GPU, 비용과 지금 하는 단계(테스트를 돌리는 서브에이전트, npm test 등)가 나옵니다.">
|
|
87
|
+
|
|
88
|
+
앱은 실행 파일로 배포하지 않습니다. 세션이 시작될 때 Sprag가 사용자의 Mac에서 Swift 소스를 컴파일하고 릴리스가 그 소스를 바꿨을 때만 다시 컴파일하므로 Xcode 명령줄 도구가 있어야 합니다. `sprag bar off` 로 끄고 `sprag bar on` 으로 다시 켭니다. 앱이 뜨지 않으면 `sprag bar status` 가 이유를 알려 줍니다. 팀에 들어 있으면 메뉴 막대 동물은 이번 달 [Sprag Town](#팀) 등급을 따릅니다.
|
|
89
|
+
|
|
78
90
|
## 작동 방식
|
|
79
91
|
|
|
80
92
|
<picture>
|
|
@@ -304,7 +316,9 @@ CLI는 무료이고 컴퓨터 한 대에서 혼자 동작합니다. 조직에는
|
|
|
304
316
|
<a href="https://sprag.io/assets/video/plan-pro-ko.mp4"><img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/plan-pro-ko.gif" width="640" alt="팀원마다 동물 캐릭터로 앉아 있는 가상 사무실, 지출과 절감액, 좌석, 30일 차트가 있는 조직 대시보드, 한 번 승인하면 모든 컴퓨터에 적용되는 팀 규칙을 차례로 보여 줍니다."></a>
|
|
305
317
|
|
|
306
318
|
- 조직 대시보드와 30일 추이 차트
|
|
307
|
-
- 사람마다 동물
|
|
319
|
+
- Sprag Town: 이번 달 지출과 위임 순위에 따라 사람마다 동물 30종 가운데 하나로 앉아 있는 가상 사무실
|
|
320
|
+
- 멤버 누구나 `sprag team town` 이 여는 12시간짜리 링크로 타운을 봅니다. 다른 사람은 이름과 동물과 팀만 보이고 수치는 보이지 않습니다.
|
|
321
|
+
- 사용량과 위임 비율이 쌓이면 책상 소품과 머리 소품, 반려동물이 열립니다. 내 동물은 Sprag Bar 메뉴 막대에서도 달립니다.
|
|
308
322
|
- 컴퓨터별 상태가 보이는 좌석 명단
|
|
309
323
|
- 세션 시작 때 적용되는 팀 승인 규칙
|
|
310
324
|
- `sprag team join` 으로 조직 배포
|
package/README.md
CHANGED
|
@@ -98,6 +98,18 @@ everything it added and restores a statusline it merged with.
|
|
|
98
98
|
|
|
99
99
|
Using Codex? See [Codex](#codex) below.
|
|
100
100
|
|
|
101
|
+
## Sprag Bar: every session in the macOS menu bar
|
|
102
|
+
|
|
103
|
+
On a Mac, sprag also puts an animal in the menu bar. It runs faster as the agent sessions load the machine, with the CPU figure beside it. Click it to see every running Claude Code and Codex session: the model and effort, what it is doing now, context use, cost, CPU and memory, and the 5-hour and weekly limits of each account.
|
|
104
|
+
|
|
105
|
+
<img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/sprag-bar-panel.png" width="400" alt="The Sprag Bar panel: five sessions, three working and two waiting for input. Each row shows Claude or Codex, the task, the model and effort, how long it has been in that state, CPU, memory, context use and cost.">
|
|
106
|
+
|
|
107
|
+
The dashboard window groups the sessions by project and shows what each one is running, from the tool call to the subagent it handed work to. The jump button on a tile brings that session's Terminal.app or iTerm2 tab to the front. The window has three sizes (⌘1, ⌘2, ⌘3), and processes left behind by sessions that have ended can be stopped from a checklist.
|
|
108
|
+
|
|
109
|
+
<img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/sprag-bar-dashboard.png" width="760" alt="The Sprag Bar dashboard at its middle size: session tiles grouped by project, each with its state, model, context, CPU, memory, GPU, cost and the step it is on, such as a subagent running the tests or npm test.">
|
|
110
|
+
|
|
111
|
+
The app is not shipped as a binary. Sprag compiles its Swift source on your Mac when a session starts, once per release that changes it, so it needs the Xcode command line tools. `sprag bar off` turns it off, `sprag bar on` brings it back, and `sprag bar status` says why it is not showing. On a team, the animal is your [Sprag Town](#teams) grade for the month.
|
|
112
|
+
|
|
101
113
|
## How it works
|
|
102
114
|
|
|
103
115
|
<picture>
|
|
@@ -365,7 +377,9 @@ The CLI is free and works on its own on one machine. For organizations, **Sprag
|
|
|
365
377
|
<a href="https://sprag.io/assets/video/plan-pro-en.mp4"><img src="https://raw.githubusercontent.com/rootstudioyaml/sprag/main/docs/plan-pro-en.gif" width="640" alt="A virtual office where every teammate sits as an animal character, then the organization dashboard with spend, savings, seats and a 30-day chart, then team rules approved once and picked up by every machine."></a>
|
|
366
378
|
|
|
367
379
|
- Organization dashboard with a 30-day chart
|
|
368
|
-
-
|
|
380
|
+
- Sprag Town, a virtual office where each person sits as one of 30 animals picked by this month's ranking of spend and delegation
|
|
381
|
+
- `sprag team town` opens the town for any member through a 12-hour link; other people show only their name, animal and team, never their figures
|
|
382
|
+
- Desk props, head props and pets unlock as your usage and delegation grow, and your animal runs in the Sprag Bar menu bar
|
|
369
383
|
- Seat roster with each machine's status
|
|
370
384
|
- Team-approved rules applied at session start
|
|
371
385
|
- Rollout with `sprag team join`
|
package/bin/cli.js
CHANGED
|
@@ -38,6 +38,7 @@ import {
|
|
|
38
38
|
extractContextUsage,
|
|
39
39
|
extractEffort,
|
|
40
40
|
extractModel,
|
|
41
|
+
extractPromptCache,
|
|
41
42
|
extractSessionId,
|
|
42
43
|
extractTranscriptPath,
|
|
43
44
|
} from '../src/stdin-payload.js';
|
|
@@ -1230,6 +1231,10 @@ async function main() {
|
|
|
1230
1231
|
? readStarChip({ savedUsd: delegationSaved + (Number(doc2mdTotals?.total) || 0) })
|
|
1231
1232
|
: null,
|
|
1232
1233
|
lastActivity,
|
|
1234
|
+
// Claude Code's own cache figures for this session (2.1.333+, and the
|
|
1235
|
+
// desktop mod); when present the TTL chip counts down to them instead of
|
|
1236
|
+
// estimating from the last activity across transcripts.
|
|
1237
|
+
promptCache: isStatusline ? extractPromptCache(stdinJson) : null,
|
|
1233
1238
|
monthSpend: monthSpendInfo,
|
|
1234
1239
|
modelShare,
|
|
1235
1240
|
spikeReport,
|
|
@@ -63,7 +63,8 @@ export function statuslineArgv(settings: Readonly<Record<string, unknown>>): str
|
|
|
63
63
|
* The JSON Claude Code's statusline would have been fed. Fields the engine has
|
|
64
64
|
* no value for are left out, never zeroed: sprag reads an absent rate_limits as
|
|
65
65
|
* "no data" but a 0 as "0% used". transcript_path is left out because the mod
|
|
66
|
-
* cannot know it, and sprag takes it only for the effort chip.
|
|
66
|
+
* cannot know it, and sprag takes it only for the effort chip. prompt_cache
|
|
67
|
+
* lets the cache chip count down to the engine's own expiry time.
|
|
67
68
|
*/
|
|
68
69
|
export function statuslinePayload(input: {
|
|
69
70
|
sessionId: string
|
|
@@ -96,9 +97,40 @@ export function statuslinePayload(input: {
|
|
|
96
97
|
payload.rate_limits = limits
|
|
97
98
|
}
|
|
98
99
|
if (usage.cost) payload.cost = { total_cost_usd: usage.cost.usd }
|
|
100
|
+
const cache = promptCacheOf(usage)
|
|
101
|
+
if (cache) payload.prompt_cache = cache
|
|
99
102
|
return payload
|
|
100
103
|
}
|
|
101
104
|
|
|
105
|
+
/**
|
|
106
|
+
* The engine's prompt cache figures (2.1.333+) as the terminal statusline gets
|
|
107
|
+
* them in `prompt_cache`: epoch seconds for the expiry, null when nothing is
|
|
108
|
+
* cached. Read through a local type so the module still type-checks against
|
|
109
|
+
* engines whose SessionUsage has no promptCache; there it is simply absent and
|
|
110
|
+
* sprag keeps estimating the countdown from the transcripts.
|
|
111
|
+
*/
|
|
112
|
+
type EnginePromptCache = {
|
|
113
|
+
isWarm?: unknown
|
|
114
|
+
expiresAt?: unknown
|
|
115
|
+
ttl?: unknown
|
|
116
|
+
lastMissCauses?: unknown
|
|
117
|
+
recacheTokens?: unknown
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function promptCacheOf(usage: SessionUsage): Record<string, unknown> | undefined {
|
|
121
|
+
const pc = (usage as { promptCache?: EnginePromptCache }).promptCache
|
|
122
|
+
if (!pc || (pc.ttl !== '5m' && pc.ttl !== '1h')) return undefined
|
|
123
|
+
const at = typeof pc.expiresAt === 'number' && Number.isFinite(pc.expiresAt) ? Math.floor(pc.expiresAt / 1000) : null
|
|
124
|
+
const causes = Array.isArray(pc.lastMissCauses) ? pc.lastMissCauses.filter(c => typeof c === 'string') : undefined
|
|
125
|
+
return {
|
|
126
|
+
warm: pc.isWarm === true,
|
|
127
|
+
ttl: pc.ttl,
|
|
128
|
+
expires_at: at,
|
|
129
|
+
...(causes?.length ? { last_miss_cause: { causes } } : {}),
|
|
130
|
+
...(typeof pc.recacheTokens === 'number' ? { recache_tokens_if_cold: pc.recacheTokens } : {}),
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
102
134
|
/**
|
|
103
135
|
* The argv with `--columns <n>` added, so sprag fits its chips to the band and
|
|
104
136
|
* wraps them at chip boundaries instead of the band wrapping them mid-chip. A
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sprag-cli",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.139.0",
|
|
4
4
|
"description": "The delegation layer for Claude Code and Codex: each task goes to the model and effort that fits it, down to cheaper models for lookups and up to higher effort when a cheaper run would miss, backed by public replay cases, with a live statusline and team rules for Pro and Enterprise.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
package/src/doc2md.cjs
CHANGED
|
@@ -358,6 +358,16 @@ const MARKITDOWN_SPEC = 'markitdown[pptx,pdf,xlsx,docx]>=0.1,<0.2';
|
|
|
358
358
|
// pre-installed so "swap the chart on slide 23" does not stall on pip.
|
|
359
359
|
const EDIT_LIBS = ['python-pptx>=1.0,<2', 'python-docx>=1.1,<2', 'openpyxl>=3.1,<4'];
|
|
360
360
|
|
|
361
|
+
// Transitive dependencies held below a release that broke conversion. None of
|
|
362
|
+
// the specs above names them, so pip takes the newest on the day of install.
|
|
363
|
+
// lxml 6.2.0 (2026-11-27) makes markitdown's DocxConverter fail on every .docx
|
|
364
|
+
// with "Could not find the body element"; 6.1.3 converts the same file. Rerunning
|
|
365
|
+
// `sprag doc2md install-converter` moves a venv built on 6.2.0 back down.
|
|
366
|
+
const PIN_LIBS = ['lxml>=4.9,<6.2'];
|
|
367
|
+
|
|
368
|
+
/** Everything one pip call installs into the managed venv, in order. */
|
|
369
|
+
function installSpecs() { return [MARKITDOWN_SPEC, ...EDIT_LIBS, ...PIN_LIBS]; }
|
|
370
|
+
|
|
361
371
|
/**
|
|
362
372
|
* Build the managed venv and install markitdown into it.
|
|
363
373
|
*
|
|
@@ -435,8 +445,8 @@ function installConverter({ onProgress = () => {} } = {}) {
|
|
|
435
445
|
}
|
|
436
446
|
}
|
|
437
447
|
|
|
438
|
-
onProgress(`installing ${MARKITDOWN_SPEC} + ${EDIT_LIBS.join(', ')}`);
|
|
439
|
-
const install = spawnSync(target, ['-m', 'pip', 'install', '--quiet',
|
|
448
|
+
onProgress(`installing ${MARKITDOWN_SPEC} + ${EDIT_LIBS.join(', ')} + ${PIN_LIBS.join(', ')}`);
|
|
449
|
+
const install = spawnSync(target, ['-m', 'pip', 'install', '--quiet', ...installSpecs()], {
|
|
440
450
|
encoding: 'utf8',
|
|
441
451
|
timeout: 900_000,
|
|
442
452
|
windowsHide: true,
|
|
@@ -1072,6 +1082,8 @@ module.exports = {
|
|
|
1072
1082
|
INSTALL_HINT,
|
|
1073
1083
|
MARKITDOWN_SPEC,
|
|
1074
1084
|
EDIT_LIBS,
|
|
1085
|
+
PIN_LIBS,
|
|
1086
|
+
installSpecs,
|
|
1075
1087
|
managedPython,
|
|
1076
1088
|
installConverter,
|
|
1077
1089
|
ensureConverterInstalled,
|
|
@@ -993,7 +993,15 @@ function buildPeriodSeg(options, c, verbose) {
|
|
|
993
993
|
* Which cache bucket the session is in, and the countdown length that follows
|
|
994
994
|
* from it: `{ is1h, bucketLabel, bucketColor, ttlSeconds }`.
|
|
995
995
|
*/
|
|
996
|
-
function resolveTtlBucket(ttl, ttlBucket) {
|
|
996
|
+
function resolveTtlBucket(ttl, ttlBucket, promptCache) {
|
|
997
|
+
// Claude Code's own report of the bucket the last request wrote is a
|
|
998
|
+
// measurement of this very session, so it settles what the transcript split
|
|
999
|
+
// and the gateway guess below can only estimate. A pinned bucket still wins:
|
|
1000
|
+
// it exists for providers whose reports cannot be trusted.
|
|
1001
|
+
if (promptCache && (promptCache.ttl === '5m' || promptCache.ttl === '1h') && ttlBucket !== '5m' && ttlBucket !== '1h') {
|
|
1002
|
+
const is1h = promptCache.ttl === '1h';
|
|
1003
|
+
return { is1h, bucketLabel: promptCache.ttl, bucketColor: is1h ? GREEN : YELLOW, ttlSeconds: is1h ? 3600 : 300 };
|
|
1004
|
+
}
|
|
997
1005
|
// TTL dominance → color signal (1h = good, 5m = warning).
|
|
998
1006
|
// The subscription plan fixes this, so the bucket rarely changes — it's the countdown that matters.
|
|
999
1007
|
// When ttl.total === 0 (no cache writes observed in the window), we cannot
|
|
@@ -1029,8 +1037,16 @@ function resolveTtlBucket(ttl, ttlBucket) {
|
|
|
1029
1037
|
* Cache TTL chip: the countdown on the last call's cache entry, or just the
|
|
1030
1038
|
* bucket when the timer is off or there is no last call.
|
|
1031
1039
|
*/
|
|
1032
|
-
function buildTtlSeg({ ttl, ttlBucket, lastActivity }, timer, c, isIcon, verbose, g) {
|
|
1033
|
-
const { is1h, bucketLabel, bucketColor, ttlSeconds } = resolveTtlBucket(ttl, ttlBucket);
|
|
1040
|
+
function buildTtlSeg({ ttl, ttlBucket, lastActivity, promptCache }, timer, c, isIcon, verbose, g) {
|
|
1041
|
+
const { is1h, bucketLabel, bucketColor, ttlSeconds } = resolveTtlBucket(ttl, ttlBucket, promptCache);
|
|
1042
|
+
// With Claude Code's figures in hand the countdown runs to its expiry time.
|
|
1043
|
+
// A null expiry there means the last response cached nothing, so there is no
|
|
1044
|
+
// clock to show, only the bucket; estimating one from other sessions'
|
|
1045
|
+
// activity would count down a cache this session does not have.
|
|
1046
|
+
const reported = promptCache && (promptCache.ttl === '5m' || promptCache.ttl === '1h');
|
|
1047
|
+
if (reported) {
|
|
1048
|
+
lastActivity = Number.isFinite(promptCache.expiresAtMs) ? promptCache.expiresAtMs - ttlSeconds * 1000 : null;
|
|
1049
|
+
}
|
|
1034
1050
|
|
|
1035
1051
|
// TTL countdown — how much time is left on the last API call's cache entry.
|
|
1036
1052
|
// Matches Anthropic's actual prompt-cache behaviour: each call starts a fresh
|
|
@@ -1907,7 +1923,7 @@ export function formatReport(data, { color = true, verbose: verboseOpt = false,
|
|
|
1907
1923
|
usage: buildUsageSegs(caps, capWarn, c, isIcon, verbose, g, color, mode),
|
|
1908
1924
|
ctx: buildCtxSeg(ctxLive, contextWindow, c, isIcon, verbose, g),
|
|
1909
1925
|
compactions: buildCompactionsSeg(data.compactions, c, isIcon, verbose, g),
|
|
1910
|
-
ttl: buildTtlSeg({ ttl, ttlBucket: data.ttlBucket, lastActivity }, timer, c, isIcon, verbose, g),
|
|
1926
|
+
ttl: buildTtlSeg({ ttl, ttlBucket: data.ttlBucket, lastActivity, promptCache: data.promptCache }, timer, c, isIcon, verbose, g),
|
|
1911
1927
|
// Model, then the effort that qualifies it: the same model answers
|
|
1912
1928
|
// differently at `low` and at `max`, and the pair is one glance.
|
|
1913
1929
|
model: buildModelSeg(model, c, isIcon, g),
|
package/src/stdin-payload.js
CHANGED
|
@@ -172,6 +172,28 @@ export function extractContextUsage(stdinJson) {
|
|
|
172
172
|
};
|
|
173
173
|
}
|
|
174
174
|
|
|
175
|
+
/**
|
|
176
|
+
* The main conversation's prompt cache as Claude Code 2.1.333+ reports it
|
|
177
|
+
* (`prompt_cache`), the desktop mod passing `$.session.usage().promptCache` in
|
|
178
|
+
* the same shape. Subset used:
|
|
179
|
+
* "prompt_cache": { "warm": true, "ttl": "1h", "expires_at": 1764550000 }
|
|
180
|
+
* `expires_at` is epoch seconds, or null when the last response cached
|
|
181
|
+
* nothing. Returns `{ ttl, expiresAtMs }` with `expiresAtMs` null in that case,
|
|
182
|
+
* or null when the key is absent or its ttl is not one of the two buckets: an
|
|
183
|
+
* older Claude Code, or a payload this reader does not understand, keeps the
|
|
184
|
+
* transcript-based estimate.
|
|
185
|
+
*/
|
|
186
|
+
export function extractPromptCache(stdinJson) {
|
|
187
|
+
const pc = stdinJson && stdinJson.prompt_cache;
|
|
188
|
+
if (!pc || typeof pc !== 'object') return null;
|
|
189
|
+
if (pc.ttl !== '5m' && pc.ttl !== '1h') return null;
|
|
190
|
+
const at = typeof pc.expires_at === 'number' ? pc.expires_at : NaN;
|
|
191
|
+
return {
|
|
192
|
+
ttl: pc.ttl,
|
|
193
|
+
expiresAtMs: Number.isFinite(at) && at > 0 ? (at < 1e12 ? at * 1000 : at) : null,
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
|
|
175
197
|
/** The session the payload belongs to, or null when the field is absent. */
|
|
176
198
|
export function extractSessionId(stdinJson) {
|
|
177
199
|
const id = stdinJson?.session_id;
|