Picks /effort per prompt: Jev (TypeSafe AI) grades how hard the task is, and the turn runs at that level.

A Claude Code mod that picks /effort for each prompt. Jev (TypeSafe AI) grades how hard the request is, and the turn's model requests run at that level: low, medium, high, xhigh or max. By default it only lowers effort below your own setting; raising is opt-in (see Settings).
» auto-effort ▰▰▱▱▱ effort MEDIUM ✓ sent (was high) · Jev 84% sure · 300ms [Turn off]
/plugin install auto-effort --marketplace peterlimg/auto-effort
Answer y to add the marketplace, then pick a scope. It needs a TypeSafe API key in the environment Claude Code starts with:
export TYPESAFE_API_KEY=... # fish: set -Ux TYPESAFE_API_KEY ...
Without a key, or when Jev fails or takes over 3s, your own /effort applies.
✓ sent), Jev's confidence, and a Turn off / Turn on button./auto-effort prints the last turns: what Jev picked, what each turn's requests ran at, and how many turns were lowered or raised from your session's effort. /auto-effort off and /auto-effort on switch it for this session, like the band's button. /auto-effort default on and /auto-effort default off also save that as the enabled setting, so new sessions start the same way.~/.claude/auto-effort/decisions.jsonl keeps one JSON line per judged prompt and per turn.enabled (default on): start every session with Jev picking the effort. Off, sessions start at your own effort and the band's Turn on button or /auto-effort on switches it on for that session. Set it in /config, or in settings under pluginConfigs.auto-effort.enabled.raise (default off): let Jev raise effort above your session setting for hard tasks. Off, a higher pick is capped at your setting and the band shows (Jev: xhigh, capped). Set it in /config, or in settings under pluginConfigs.auto-effort.raise.In the benchmark below, on the tasks Jev lowered from high, thinking fell by about half (1,164 to 502 tokens a run) and every run still passed. Those were small tasks, so the bill barely moved. Raising from medium cost 4-15% more and changed no outcomes. So it's off by default.
.md or .txt file ("Read ~/notes/brief.md and implement it") also sends the start of that file, so the work it hands over is judged rather than the one-line prompt.low or medium after 4 model requests is bigger than its prompt looked: Jev is asked once more with what the agent has found so far, and may raise the effort for the rest of the turn (never lower it).raise is on). A prompt queued with ctrl+x enter is judged for its own turn.bench/run.py runs the same tasks with the mod on and off and compares cost, tokens and pass rate. Each run copies a task's fixture repo to a temp dir, runs claude -p on its prompt, and grades the result with a hidden check.py. Both arms share the model, session effort, prompt and settings; only --plugin-dir differs.
bench/run.py # 12 tasks x 2 arms x 3 runs at --effort high
bench/run.py --tasks 02,10 --runs 1 # a quick smoke run
bench/run.py --effort medium # let the mod raise as well as lower
Costs come from Claude Code's own total_cost_usd; the effort each request ran at comes from the session transcript. --max-cost (default $60) stops new runs once the total is spent.
claude --plugin-dir . # run it from this folder
claude plugin validate .
claude plugin test .hooks/register.tsx 399 lines1import { atom, read, update } from 'claude-code'
2import type { EngineInterface, Register } from 'claude-code'
3
4import type { Effort, Judgement } from '../types'
5
6const JEV_URL = 'https://api.typesafe.ai/v1/systemone'
7const TIMEOUT_MS = 3000
8const LOG_LINES = 1000
9const LOG_TRIM_BYTES = 2_000_000 // under fs.read's 4 MiB cap
10const REPORT_TURNS = 12
11// A turn still at low/medium after this many model requests is bigger than its prompt looked:
12// Jev is asked once more with what the agent has found, and may only raise the effort.
13const RECHECK_AT = 4
14const PROGRESS_CHARS = 6000
15// A fresh TLS connection to Jev costs ~550ms on top of its ~250ms answer, and an idle one is dropped within a few
16// minutes. So while the session is in use, an unauthenticated HEAD (a free 405) keeps the host's connection open.
17const WARM_EVERY_MS = 60_000
18const WARM_IDLE_MS = 15 * 60_000
19// Where a prompt a person wrote comes from: typed, Remote Control, `claude -p`, a /loop or routine, a chat channel,
20// or a channel the engine can't attest. Every other origin is model- or agent-authored.
21const PERSON_ORIGINS = new Set<string | undefined>(['composer', 'bridge', 'sdk', 'scheduled-trigger', 'channel', 'unclassified'])
22const LEVELS: readonly Effort[] = ['low', 'medium', 'high', 'xhigh', 'max']
23const COLORS: Record<Effort, string> = { low: 'green', medium: 'cyan', high: 'blue', xhigh: 'magenta', max: 'red' }
24
25const judgement = atom({ plugin: 'auto-effort', key: 'judgement' } as const, null)
26// The band's button or `/auto-effort on|off` this session; null until used, then the `enabled` setting decides.
27const isOff = atom({ plugin: 'auto-effort', key: 'isOff' } as const, null)
28const previous = atom({ plugin: 'auto-effort', key: 'previous' } as const, null)
29const sessionEffort = atom({ plugin: 'auto-effort', key: 'sessionEffort' } as const, null)
30const queued = atom({ plugin: 'auto-effort', key: 'queued' } as const, null)
31const run = atom({ plugin: 'auto-effort', key: 'run' } as const, null)
32const lastReply = atom({ plugin: 'auto-effort', key: 'lastReply' } as const, null)
33
34// One Score question; its criteria are ordered like LEVELS, so round(score) indexes it.
35const QUESTION = {
36 type: 'score',
37 instructions:
38 'How much reasoning effort does a coding agent need for `request`? A short follow-up ("yes", "do it", "1", "continue") approves or continues the work proposed in `last_reply` or asked for in `previous_request`. When `request` points at a file to read and do, `brief` is the start of that file: judge the work it describes. `progress`, when present, is what the agent has done and found so far in this turn: judge the work that remains. Judge the thinking the answer needs, not how short the request is: "check X and see what we need to change" asks for a decision, not a lookup.',
39 criteria: [
40 'Trivial: a status check, a factual lookup, or a one-line edit, where the answer is just what was found',
41 'Small: a focused change in one or two files, or explaining one thing',
42 'Moderate: a feature or bug fix across several files, a non-obvious bug, or running a multi-step workflow such as a code review, or weighing feedback or a reviewer\'s claim (review, ticket or chat comments) against the current work',
43 'Hard: a cross-cutting refactor, tricky concurrency/security/performance work, debugging with little to go on, or a fix the user says still does not work, or re-planning a project after new requirements',
44 'Very hard: architecture or algorithm design where a wrong call is expensive',
45 ],
46}
47
48// Resolves `work`, or null once `ms` pass. Only a real timeout wins: the abort after the race settles nothing.
49// ponytail: $.http.fetch takes no signal, so a timed-out request runs on and is ignored
50function withTimeout<T>($: EngineInterface, ms: number, work: Promise<T>): Promise<T | null> {
51 const stop = new AbortController()
52 const timeout = $.clock.sleep(ms, { signal: stop.signal }).then(() => null, () => new Promise<never>(() => {}))
53 return Promise.race([work, timeout]).finally(() => stop.abort())
54}
55
56// On unless the `enabled` setting turns it off; set by register.
57let offByDefault = false
58const off = async ($: EngineInterface) => (await read($, isOff)) ?? offByDefault
59
60// ponytail: module-level, reset by a reload; at worst one prompt pays the handshake again
61let lastActive = 0
62let warming: unknown = null
63
64async function warm($: EngineInterface) {
65 if (!(await $.env.get('TYPESAFE_API_KEY')) || (await off($))) return
66 await $.http.fetch(JEV_URL, { method: 'HEAD' }).catch(() => {})
67}
68
69// The band's button and `/auto-effort on|off`: a stale pick must not apply once switched.
70async function setOff($: EngineInterface, off: boolean) {
71 await update($, isOff, () => off)
72 await update($, judgement, () => null)
73}
74
75// The session is in use: keep Jev's connection open until it has been idle for WARM_IDLE_MS.
76// Started by the first sign of use, so a mod loaded into a running session warms too.
77async function active($: EngineInterface) {
78 lastActive = await $.clock.now()
79 warming ??= $.clock.every(WARM_EVERY_MS, async () => {
80 if ((await $.clock.now()) - lastActive < WARM_IDLE_MS) await warm($)
81 })
82}
83
84// "Read /x/brief.md and implement it" says nothing about the work; the brief does. Its start, or null.
85// ponytail: first .md/.txt path only; a prompt naming several files is judged by the first
86async function readBrief($: EngineInterface, text: string): Promise<string | null> {
87 const path = text.match(/(?:^|[\s(`'"])(?:file:\/\/)?((?:~\/|\/|\.{0,2}\/?[\w.-]+\/)[^\s`'")]*\.(?:md|txt))\b/)?.[1]
88 if (!path) return null
89 const full = path.startsWith('~/') ? `${await $.env.get('HOME')}${path.slice(1)}` : path
90 return (await $.fs.read(full).catch(() => null))?.slice(0, 6000) ?? null
91}
92
93async function judge($: EngineInterface, text: string, before: string | null, reply: string | null, progress: string | null = null): Promise<Judgement> {
94 const key = await $.env.get('TYPESAFE_API_KEY')
95 if (!key) return { phase: 'kept', reason: 'no TYPESAFE_API_KEY' }
96
97 const brief = await readBrief($, text)
98 const startedAt = await $.clock.now()
99 const res = await withTimeout($, TIMEOUT_MS, $.http.fetch(JEV_URL, {
100 method: 'POST',
101 headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },
102 // ponytail: chars not tokens; 4k + 3k + 16k + 6k + 6k chars stays well under Jev's 32k-token state budget
103 body: JSON.stringify({
104 model: 'jev-latest',
105 state: { previous_request: before?.slice(0, 4000) ?? null, last_reply: reply, request: text.slice(0, 16000), brief, progress },
106 questions: { effort: QUESTION },
107 }),
108 }))
109 if (!res) return { phase: 'kept', reason: `Jev timed out (${TIMEOUT_MS / 1000}s)` }
110 if (!res.ok) return { phase: 'kept', reason: `Jev HTTP ${res.status}` }
111
112 const { score, confidence } = JSON.parse(res.text).answers?.effort ?? {}
113 // ponytail: round to the nearest level; a split answer (2.51) flips between neighbours
114 const pick = typeof score === 'number' && typeof confidence === 'number' ? LEVELS[Math.round(score)] : undefined
115 if (!pick) return { phase: 'kept', reason: 'Jev gave no score' }
116 return { phase: 'picked', pick, score, confidence, ms: (await $.clock.now()) - startedAt }
117}
118
119// The turn so far as text: the agent's words, its tool calls and what they returned. The end, where the findings are.
120// ponytail: the conversation's tail, not just this turn's; at RECHECK_AT requests the turn fills most of it
121async function progressOf($: EngineInterface): Promise<string> {
122 const lines = (await $.session.messages({ as: 'api' })).flatMap(m => m.content.map((b: any) =>
123 b.type === 'text' ? `${m.role}: ${b.text}`
124 : b.type === 'tool_use' ? `tool ${b.name} ${JSON.stringify(b.input).slice(0, 300)}`
125 : b.type === 'tool_result' ? `result: ${(typeof b.content === 'string' ? b.content : JSON.stringify(b.content)).slice(0, 1500)}`
126 : ''))
127 return lines.filter(Boolean).join('\n').slice(-PROGRESS_CHARS)
128}
129
130// One JSON line per judged prompt, for monitoring; outside the mod folder so writing it never reloads the mod.
131async function logPath($: EngineInterface) {
132 return `${await $.env.get('HOME')}/.claude/auto-effort/decisions.jsonl`
133}
134
135// Appended (fs has no append), so sessions logging at once don't drop each other's lines.
136async function log($: EngineInterface, entry: object) {
137 const path = await logPath($)
138 if (!(await $.fs.exists(path))) await $.fs.write(path, '') // makes the folder
139 await $.process.run(['sh', '-c', 'cat >> "$1"', 'sh', path], { stdin: JSON.stringify(entry) + '\n' })
140 // ponytail: a trim racing another session's append can drop that one line; once per LOG_TRIM_BYTES of log
141 if ((await $.fs.stat(path)).size < LOG_TRIM_BYTES) return
142 const lines = (await $.fs.read(path)).split('\n').filter(Boolean).slice(-LOG_LINES)
143 await $.fs.write(path, lines.join('\n') + '\n')
144}
145
146// The /auto-effort report: the last turns (all sessions), newest last, with what Jev picked and what ran.
147export function report(logText: string): string {
148 const turns = logText.split('\n').filter(Boolean).map(l => JSON.parse(l)).filter(x => x.kind === 'turn').slice(-REPORT_TURNS)
149 if (!turns.length) return 'no turns logged yet.'
150 const level = (x: unknown) => LEVELS.indexOf(x as Effort)
151 const moved = { lowered: 0, raised: 0, same: 0 }
152 const rows = turns.map(t => {
153 const ran = (t.efforts as unknown[]).map(String).join('/') || '·' // not '-': the reply is markdown, and a leading '- ' makes a list
154 const top = Math.max(...(t.efforts as unknown[]).map(level))
155 if (t.session !== undefined && t.efforts.length) {
156 const d = top - level(t.session)
157 moved[d < 0 ? 'lowered' : d > 0 ? 'raised' : 'same']++
158 }
159 const jev = t.jev === 'off' ? 'off'
160 : t.jev?.phase === 'picked' ? `${t.jev.pick} ${t.jev.score.toFixed(2)} (${Math.round(t.jev.confidence * 100)}%)`
161 : t.jev?.phase === 'kept' ? t.jev.reason : '·'
162 return `${ran.padEnd(14)}${String(t.session ?? '·').padEnd(9)}${String(t.requests).padStart(4)}${String(t.outputTokens).padStart(8)} ${jev.padEnd(28)}${String(t.prompt).replace(/\s+/g, ' ').slice(0, 50)}`
163 })
164 return [
165 `last ${turns.length} turns: ${moved.lowered} lowered, ${moved.raised} raised, ${moved.same} unchanged vs the session's effort`,
166 '',
167 `${'ran at'.padEnd(14)}${'session'.padEnd(9)}${'reqs'.padStart(4)}${'out tok'.padStart(8)} ${'jev'.padEnd(28)}prompt`,
168 ...rows,
169 ].join('\n')
170}
171
172// Asked by turn.step once a low/medium turn has made RECHECK_AT requests.
173async function recheck($: EngineInterface, turnId: string, was: Effort) {
174 const r = await read($, run)
175 if (r?.turnId !== turnId) return
176 const j = await judge($, r.prompt, null, null, await progressOf($))
177 // Raise only, and only the pick this turn still runs at: a newer prompt's pick is left alone.
178 const raised = j.phase === 'picked' && LEVELS.indexOf(j.pick) > LEVELS.indexOf(was) && (await read($, run))?.turnId === turnId
179 if (raised) await update($, judgement, cur => (cur?.phase === 'picked' && cur.pick === was ? { ...j, from: cur.from } : cur))
180 await log($, { kind: 'recheck', at: new Date(await $.clock.now()).toISOString(), prompt: r.prompt.slice(0, 120), was, raised, jev: j }).catch(() => {})
181}
182
183// The effort a pick runs at: capped at the session's own effort unless raising is allowed.
184function applied(pick: Effort, session: unknown, canRaise: boolean): Effort {
185 const cap = LEVELS.indexOf(session as Effort)
186 return !canRaise && cap >= 0 && LEVELS.indexOf(pick) > cap ? LEVELS[cap]! : pick
187}
188
189export const register: Register = (on, options) => {
190 // Benchmarks (bench/) found raising cost 4-15% more with no change in pass rate, so it's opt-in.
191 const canRaise = options.raise === true
192 offByDefault = options.enabled === false
193
194 // Grade the prompt before it enters, so the turn's first request already uses the pick.
195 on('prompt.submit', async ($, e, next) => {
196 // Only requests a person wrote are judged. A subagent's report, a task notification or a peer's message
197 // continues the work already running: it keeps the current pick and isn't the "previous request" either.
198 if (!PERSON_ORIGINS.has(e.origin?.kind)) return next(e)
199 await active($)
200 // Typed during a running turn (e.turnId): with ctrl+x enter (e.wait) it waits to run as its own turn, so its
201 // pick waits too and turn.start applies it; otherwise it's an aside delivered into the running task.
202 const waits = Boolean(e.turnId && e.wait)
203 const isAside = Boolean(e.turnId) && !waits
204 const isCommand = e.text.trim().startsWith('/')
205 const before = await read($, previous)
206 // The task a later "yes"/"continue" refers to: kept while off too; not a slash command, and not an aside
207 // sent mid-task, so "continue" after an interrupt is judged against the task, not the aside.
208 if (!isCommand && !e.turnId) await update($, previous, () => e.text)
209
210 if (isCommand || (await off($))) {
211 // Not judged: its turn runs at the session's effort, not the last task's pick.
212 if (waits) await update($, queued, () => ({ text: e.text, judgement: null }))
213 else if (!isAside) await update($, judgement, () => null)
214 return next(e)
215 }
216
217 const current = await read($, judgement)
218 // A message typed during a running turn must not unset the running task's pick while Jev answers.
219 if (!e.turnId) {
220 await update($, judgement, () => ({ phase: 'asking' }))
221 }
222 const judged = await judge($, e.text, before, await read($, lastReply)).catch((): Judgement => ({ phase: 'kept', reason: 'Jev unreachable' }))
223 // An aside can only raise a running pick. With none running the turn is at the session's effort,
224 // which we can't compare against, so the aside leaves it alone.
225 let j: Judgement | null = judged
226 if (isAside && (current?.phase !== 'picked' || j.phase !== 'picked' || LEVELS.indexOf(j.pick) < LEVELS.indexOf(current.pick))) {
227 j = current
228 }
229 if (waits) await update($, queued, () => ({ text: e.text, judgement: judged }))
230 else await update($, judgement, () => j)
231 await log($, {
232 kind: 'decision',
233 at: new Date(await $.clock.now()).toISOString(),
234 midTurn: isAside,
235 queued: waits,
236 prompt: e.text.slice(0, 120),
237 jev: judged,
238 applies: waits ? 'at its own turn' : j?.phase === 'picked' ? applied(j.pick, await read($, sessionEffort), canRaise) : 'session',
239 }).catch(() => {})
240
241 return next(e)
242 }).catch(async ($, e, next) => {
243 // Anything else broke: the prompt goes through untouched; between turns, no stale pick either.
244 if (!e.turnId) await update($, judgement, () => null)
245 return next(e)
246 })
247
248 // A queued prompt's turn begins: its held pick (or none, for a slash command) becomes the running one.
249 on('turn.start', async ($, e, next) => {
250 // ponytail: one turn record at a time; assumes turn.start is the main thread's (its input has no agentId)
251 await update($, run, () => ({ turnId: e.turnId, prompt: e.text, requests: 0, efforts: [], outputTokens: 0 }))
252 const q = await read($, queued)
253 if (q && e.text.includes(q.text)) {
254 await update($, queued, () => null)
255 await update($, judgement, () => q.judgement)
256 if (!q.text.trim().startsWith('/')) await update($, previous, () => q.text)
257 }
258 return next(e)
259 })
260
261 // Main thread only; subagents keep their own effort. Models without effort (e.effort absent) untouched.
262 on('turn.step', async function* ($, e, next) {
263 if (e.agentId || e.effort === undefined) return yield* next(e)
264 if ((await read($, sessionEffort)) !== e.effort) await update($, sessionEffort, () => e.effort ?? null)
265 // Once per turn, before its request RECHECK_AT + 1: awaited (~0.5s), so that request already runs at a raise.
266 const was = (await read($, judgement))
267 // Skipped when a raise can't apply: already high, or already at the session's effort with raising off.
268 const room = (p: Effort) => LEVELS.indexOf(p) < LEVELS.indexOf('high') && (canRaise || LEVELS.indexOf(p) < LEVELS.indexOf(e.effort as Effort))
269 if (e.index === RECHECK_AT && !(await off($)) && was?.phase === 'picked' && room(was.pick)) {
270 await recheck($, e.turnId, was.pick).catch(() => {})
271 }
272 const j = (await off($)) ? null : await read($, judgement)
273 const pick = j?.phase === 'picked' ? j.pick : undefined
274
275 const result = yield* next(pick ? { ...e, effort: applied(pick, e.effort, canRaise) } : e)
276 // Proof, not intent: the effort the bottom of the chain (the engine) actually received.
277 const sent = next.trace.at(-1)?.received.effort
278 // Written onto the latest pick only if it is still the one this step sent: a mid-turn raise
279 // that landed during the step must not be overwritten; the next step proves it instead.
280 if (pick) await update($, judgement, cur => (cur?.phase === 'picked' && cur.pick === pick ? { ...cur, from: e.effort, sent } : cur))
281 await update($, run, r => (r?.turnId !== e.turnId ? r : {
282 ...r,
283 session: e.effort,
284 requests: r.requests + 1,
285 efforts: sent === undefined || r.efforts.includes(sent) ? r.efforts : [...r.efforts, sent],
286 outputTokens: r.outputTokens + (result.usage?.output_tokens ?? 0),
287 }))
288 return result
289 })
290
291 // One log line per main-thread turn: what Jev said, and what the requests actually ran at.
292 on('turn.complete', async ($, e, next) => {
293 // What the agent last proposed or asked: a "yes, fix" approves that, so Jev needs it. Its end carries the ask.
294 if (!e.agentId && e.answer) await update($, lastReply, () => e.answer.slice(-3000))
295 await active($)
296 const r = await read($, run)
297 if (!e.agentId && r?.turnId === e.turnId) {
298 await update($, run, () => null)
299 const { turnId, ...turn } = r
300 await log($, {
301 kind: 'turn',
302 at: new Date(await $.clock.now()).toISOString(),
303 ...turn,
304 prompt: r.prompt.slice(0, 120),
305 jev: (await off($)) ? 'off' : await read($, judgement),
306 }).catch(() => {})
307 }
308 return next(e)
309 })
310
311 on('session.start', async ($, e, next) => {
312 const started = await next(e)
313 await $.command.register({ name: 'auto-effort', description: 'Show what auto-effort did on the last turns; `on`/`off` to switch it; `default on`/`default off` for new sessions' })
314 // Open the connection now for the first prompt, then keep it open while the session is in use.
315 await active($)
316 void warm($)
317 return started
318 })
319
320 on('command.run', { command: 'auto-effort' }, async ($, e) => {
321 const arg = e.args.trim().replace(/\s+/g, ' ')
322 // Saved as the `enabled` setting, so new sessions start this way; this session switches too.
323 if (arg === 'default on' || arg === 'default off') {
324 const enable = arg === 'default on'
325 const { deny } = await $.config.set({ key: 'auto-effort.enabled', value: enable })
326 if (deny) return { text: `default not changed: ${deny}` }
327 offByDefault = !enable
328 await setOff($, !enable)
329 return { text: enable ? 'on by default: new sessions start with Jev picking the effort' : 'off by default: new sessions start at your session effort' }
330 }
331 if (arg === 'on' || arg === 'off') {
332 await setOff($, arg === 'off')
333 return { text: arg === 'on' ? 'on: Jev picks the effort' : 'off: your session effort applies' }
334 }
335 return { text: report(await $.fs.read(await logPath($)).catch(() => '')) }
336 })
337
338 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
339 if (e.props.hasSurvey) return next(e)
340 // The band is shared: other mods draw here too, so stack our line on whatever the rest of the chain draws.
341 const below = await next(e)
342 const j = await read($, judgement)
343 const isOffNow = await off($)
344 const session = await read($, sessionEffort)
345
346 const { Box, Button, Text } = $.ui.resolve(e)
347 const toggle = (
348 <Button
349 key="toggle"
350 label={isOffNow ? 'Turn on' : 'Turn off'}
351 onPress={() => setOff($, !isOffNow)}
352 />
353 )
354 // One line: `<>...</>` is a column Box here, so every group of parts is a row Box.
355 const row = (body: JSX.Element) => (
356 <Box flexDirection="column">
357 <Box flexDirection="row" paddingX={1}><Text bold>» auto-effort </Text>{body}{toggle}</Box>
358 {below}
359 </Box>
360 )
361 // A 5-cell gauge, filled up to the level the turn runs at: ▰▰▰▱▱ = high.
362 const level = (use: Effort, tail: JSX.Element) => {
363 const n = LEVELS.indexOf(use) + 1
364 return row(
365 <Box flexDirection="row">
366 <Text color={COLORS[use]}>{'▰'.repeat(n) + '▱'.repeat(LEVELS.length - n)}</Text>
367 <Text color={COLORS[use]} bold>{` effort ${use.toUpperCase()}`}</Text>
368 {tail}
369 </Box>,
370 )
371 }
372 // No pick applies: the session's own effort, drawn like a pick once a request has shown it.
373 const unpicked = (note: JSX.Element) => LEVELS.includes(session as Effort)
374 ? level(session as Effort, <Box flexDirection="row"><Text dimColor>{' · '}</Text>{note}</Box>)
375 : row(note)
376
377 if (isOffNow) return unpicked(<Text dimColor>{'off, session effort applies '}</Text>)
378 if (!j) return unpicked(<Text dimColor>{'session effort until the next prompt '}</Text>)
379 if (j.phase === 'asking') return row(<Text dimColor>◌ asking Jev... </Text>)
380 if (j.phase === 'kept') {
381 return unpicked(<Box flexDirection="row"><Text color="yellow">kept session effort</Text><Text dimColor>{` · ${j.reason} `}</Text></Box>)
382 }
383
384 const use = applied(j.pick, session, canRaise)
385 const note = (j.from === undefined || j.from === use ? '' : ` (was ${j.from})`) + (use === j.pick ? '' : ` (Jev: ${j.pick}, capped)`)
386 return level(
387 use,
388 <Box flexDirection="row">
389 {j.sent === undefined
390 ? <Text dimColor>{' · not sent yet'}</Text>
391 : j.sent === use
392 ? <Text color="green">{' ✓ sent'}</Text>
393 : <Text color="yellow">{` ⚠ model got ${j.sent}`}</Text>}
394 <Text dimColor>{`${note} · Jev ${Math.round(j.confidence * 100)}% sure · ${Math.round(j.ms)}ms `}</Text>
395 </Box>,
396 )
397 })
398}
399types/index.d.ts 27 lines1export type Effort = 'low' | 'medium' | 'high' | 'xhigh' | 'max'
2
3/** The latest prompt's judgement: asking, a pick, or why there is none. */
4export type Judgement =
5 | { phase: 'asking' }
6 | { phase: 'picked'; pick: Effort; score: number; confidence: number; ms: number; from?: Effort | number; sent?: Effort | number }
7 | { phase: 'kept'; reason: string }
8
9declare module 'claude-code' {
10 interface PluginState {
11 'auto-effort': {
12 judgement: Judgement | null
13 /** Switched this session with the band or `/auto-effort on|off`; null defers to the `enabled` setting. */
14 isOff: boolean | null
15 previous: string | null
16 /** The session's own effort, as the last main-thread request carried it before any rewrite. */
17 sessionEffort: Effort | number | null
18 /** A prompt queued (ctrl+x enter) to run as its own turn, and its pick, held until that turn starts. */
19 queued: { text: string; judgement: Judgement | null } | null
20 /** The running main-thread turn, as its requests went out; logged at turn.complete. */
21 /** The end of the main thread's last reply: what a short "yes, fix" approves. */
22 lastReply: string | null
23 run: { turnId: string; prompt: string; session?: Effort | number; requests: number; efforts: (Effort | number)[]; outputTokens: number } | null
24 }
25 }
26}
27