option+up / option+down in the prompt raise / lower the effort level

<h1 align="center"> dotfiles </h1>
<h4 align="center"> My dotfiles. </h4>
<a href="https://github.com/wkentaro/dotfiles/actions"></a>
<img src=".readme/screencast.gif" width="400px" />
INSTALL_DIR=~/ghq/github.com/wkentaro/dotfiles # you can change this location
git clone --recursive https://github.com/wkentaro/dotfiles.git $INSTALL_DIR && cd $INSTALL_DIR
make install
Iterm2 > Preferences > Profiles > Colors > Load Presets > __Dark Pastel__.fcitx for Keyboard input method system in Language Support.

hooks/register.tsx 50 lines1import type { EngineInterface, Register } from 'claude-code'
2
3const LEVELS = ['low', 'medium', 'high', 'xhigh', 'max']
4
5// The session's level as last seen: a request's own, or the one set here.
6let current: string | undefined
7
8const saved = async ($: EngineInterface) => {
9 const model = (await $.session.model()).replace(/\[.*\]$/, '')
10 const { modelSettings } = (await $.settings.read()) as {
11 modelSettings?: Record<string, { effortLevel?: string }>
12 }
13 // ponytail: a model with no saved level is taken as medium; its real default
14 // may differ until the first request shows it.
15 const level = modelSettings?.[model]?.effortLevel
16 return level !== undefined && LEVELS.includes(level) ? level : 'medium'
17}
18
19const bump = async ($: EngineInterface, step: number) => {
20 const i = LEVELS.indexOf(current ?? (await saved($))) + step
21 const to = LEVELS[Math.max(0, Math.min(LEVELS.length - 1, i))]
22 if (to === undefined || to === current) return
23 current = to
24 // The real /effort, so the engine's own indicator and requests follow.
25 await $.command.run({ command: 'effort', args: to })
26}
27
28export const register: Register = on => {
29 // The Buttons borrow the diff panel's file-list actions, which the engine
30 // handles only while that panel is open, so their keys press these from the
31 // prompt: meta+up/down (and ctrl+up/down) by default. A bare shift+arrow never presses one.
32 on('ui.render', { component: 'AbovePrompt' }, ($, e, next) => {
33 if (e.props.hasSurvey) return next(e)
34 const { Box, Button } = $.ui.resolve(e)
35
36 // Hidden: the Buttons only need to be mounted for their keys to press them.
37 return (
38 <Box display="none">
39 <Button label="up" action="app:diffFileListUp" onPress={() => bump($, 1)} />
40 <Button label="down" action="app:diffFileListDown" onPress={() => bump($, -1)} />
41 </Box>
42 )
43 })
44
45 on('turn.step', async function* ($, e, next) {
46 if (e.agentId === undefined && typeof e.effort === 'string') current = e.effort
47 return yield* next(e)
48 })
49}
50