Annotates Claude Code's AskUserQuestion dialog with TypeSafe Jev's probabilities and a recommended option (labels in Japanese).

Small, quiet tools for Claude Code.
kuhaku is Japanese for "blank space". The plugins here try to stay in the margins of your work: they add a little context where you need it and otherwise keep out of the way.
| Plugin | Kind | What it does | |
|---|---|---|---|
| 01 | jev-judge | mod + skill | Writes TypeSafe Jev's judgment onto Claude's AskUserQuestion dialog, and lets you ask Jev directly with /jev-judge:jev |
More plugins (skills, mods and other tools) will be added over time.
Inside Claude Code:
/plugin marketplace add kuhku/kuhaku-plugins
/plugin install jev-judge@kuhaku-plugins
A second opinion, written in the margin of every question Claude asks you.
When Claude asks you something with AskUserQuestion, jev-judge asks TypeSafe's Jev model which option fits the conversation so far, and writes the answer onto the dialog itself.
<img src="docs/images/jev-judge-single.png" alt="jev-judge on a single-select question" width="100%"><br> <sub>Single-select: probability per option, recommendation, and the summary line below the dialog.</sub>
<img src="docs/images/jev-judge-multi.png" alt="jev-judge on a multi-select question" width="100%"><br> <sub>Multi-select: probability of being worth selecting, per option.</sub>
推奨 (recommended).【Jev 選ぶ 65%】).The labels on screen are in Japanese.
/jev-judge:jevAsk Jev about any decision in the conversation: "Jev に聞いて", "jev で判定して" or /jev-judge:jev. Claude picks the decision and its options, writes the question in English (Choice, Noul or Score), sends it with the bundled scripts/ask-jev.sh, and reports the probabilities and confidence back in Japanese, keeping its own view separate from Jev's.
AskUserQuestion ──> fork of the current session ──> TypeSafe API (Jev) ──> dialog redrawn
English translation + Choice per question,
context summary Noul per option (multi-select)
$.model.fork: the same model, with the transcript served from the prompt cache) to translate the question and options into English and summarize the context needed to answer. Jev is asked in English, where it is strongest.| Claude Code | A build with the function-hooks plugin API. Built and tested on 2.1.289. The API is early access and may change between releases. |
| TypeSafe API key | Enter it in the terminal when the plugin is enabled, or later with /plugin configure jev-judge@kuhaku-plugins. It is kept in secure storage. If it is empty, the TYPESAFE_API_KEY environment variable is used. Without a key, a toast and the line below the dialog say so, and the dialog is left as is. |
| Terminal | Supported. |
[!NOTE] The desktop app is not supported at the moment. On 2.1.289 the desktop app has no form for
/plugin configure, and a key saved from the terminal does not reach the plugin there, so every question ends with the "no API key" toast.
jev-judge calls the TypeSafe HTTP API directly. It does not need any other plugin at runtime.
It was designed with TypeSafe's own Claude Code plugin, which teaches Claude how to shape System One questions (Choice / Noul / Score), state and confidence. Install it if you want Claude's help adapting jev-judge's questions to your own judgments:
/plugin marketplace add typesafe-ai/skills
/plugin install typesafe@typesafe-ai
claude plugin validate plugins/jev-judge
claude plugin test plugins/jev-judge
To try local changes, add your clone as a marketplace (/plugin marketplace add <path>) and install from it. An installed plugin runs from a copy keyed by its version, so after a change bump version in both plugin.json and .claude-plugin/marketplace.json, commit, then run claude plugin update <plugin>@kuhaku-plugins and /reload-plugins.
MIT · © 2026 kuhku
hooks/register.tsx 201 lines1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4import type { QuestionVerdict, Verdict } from '../types'
5
6const JEV_URL = 'https://api.typesafe.ai/v1/systemone'
7// 別名(jev-latest)は動くと答えが変わるので、版を固定する
8const JEV_MODEL = 'jev-1.14.0'
9const KEEP = 20
10const NO_KEY = 'API キーがありません(/plugin configure jev-judge@kuhaku-plugins で設定)'
11
12const verdicts = atom({ plugin: 'jev-judge', key: 'verdicts' } as const, {})
13
14type AskOption = { label: string; description: string; preview?: string }
15type AskQuestion = { question: string; header: string; options: AskOption[]; multiSelect: boolean }
16
17/** fork が返す英訳。options は元の並びのまま。 */
18type English = {
19 context: string
20 questions: { question: string; options: string[] }[]
21}
22
23type JevAnswer =
24 | { type: 'choice'; choice: string; confidence: number; probabilities: Record<string, number> }
25 | { type: 'noul'; noul: number }
26
27const pct = (p: number) => `${Math.round(p * 100)}%`
28
29/** 長さがそろっている前提の 2 配列を組にする。ずれていたら判定を諦める。 */
30const zip = <A, B>(as: readonly A[], bs: readonly B[]): [A, B][] => {
31 if (as.length !== bs.length) throw new Error('判定と質問の数が合いません')
32 return as.map((a, i) => [a, bs[i] as B])
33}
34
35const topIndex = (probs: number[]) => probs.indexOf(Math.max(...probs))
36
37const forkPrompt = (questions: AskQuestion[]) =>
38 [
39 'You are about to show the user the following AskUserQuestion dialog (JSON).',
40 'Translate it into English and summarize, in English, the conversation context',
41 'needed to judge which option is better (goal, constraints, relevant decisions;',
42 'at most 150 words). Reply with ONLY a JSON object of this exact shape:',
43 '{"context": string, "questions": [{"question": string, "options": [string]}]}',
44 'Each option string is "<label>: <description>" in English, in the original order.',
45 '',
46 JSON.stringify(questions.map(({ question, options }) => ({ question, options }))),
47 ].join('\n')
48
49const parseEnglish = (text: string, questions: AskQuestion[]): English => {
50 const body = text.slice(text.indexOf('{'), text.lastIndexOf('}') + 1)
51 const parsed = JSON.parse(body) as English
52 const isAligned =
53 parsed.questions?.length === questions.length &&
54 parsed.questions.every((q, i) => q.options?.length === questions[i]?.options.length)
55 if (!isAligned) throw new Error('英訳の形が元の質問と合いません')
56 return parsed
57}
58
59/** Jev への質問。単一選択は Choice、複数選択は選択肢ごとの Noul。 */
60const jevQuestions = (en: English, questions: AskQuestion[]) => {
61 const out: Record<string, unknown> = {}
62 zip(questions, en.questions).forEach(([q, eq], i) => {
63 if (q.multiSelect) {
64 eq.options.forEach((option, j) => {
65 out[`q${i}_o${j}`] = {
66 type: 'noul',
67 instructions: {
68 question: eq.question,
69 option,
70 ask: 'Given `context`, should the user select `option` for `question`? Several options may be selected.',
71 },
72 }
73 })
74 return
75 }
76 out[`q${i}`] = {
77 type: 'choice',
78 instructions: `Given \`context\`, which option is the better answer to this question: ${eq.question}`,
79 criteria: Object.fromEntries(eq.options.map((option, j) => [`o${j}`, option])),
80 }
81 })
82 return out
83}
84
85const toVerdicts = (answers: Record<string, JevAnswer>, questions: AskQuestion[]): QuestionVerdict[] =>
86 questions.map((q, i) => {
87 if (q.multiSelect) {
88 const probs = q.options.map((_, j) => {
89 const a = answers[`q${i}_o${j}`]
90 return a?.type === 'noul' ? a.noul : 0
91 })
92 return { isMulti: true, probs, confidence: null }
93 }
94 const a = answers[`q${i}`]
95 if (a?.type !== 'choice') throw new Error(`q${i} の回答がありません`)
96 return {
97 isMulti: false,
98 probs: q.options.map((_, j) => a.probabilities[`o${j}`] ?? 0),
99 confidence: a.confidence,
100 }
101 })
102
103const summary = (questions: AskQuestion[], result: QuestionVerdict[]) =>
104 'Jev 推奨: ' +
105 zip(questions, result)
106 .map(([q, v]) => {
107 const options = zip(q.options, v.probs)
108 if (v.isMulti) {
109 const picked = options.filter(([, p]) => p >= 0.5).map(([o]) => o.label)
110 return `${q.header}「${picked.join('・') || 'なし'}」`
111 }
112 const [best, p] = options[topIndex(v.probs)] ?? [q.options[0], 0]
113 return `${q.header}「${best?.label}」${pct(p)}(確信度 ${v.confidence?.toFixed(2)})`
114 })
115 .join(' / ')
116
117/** ダイアログに描く質問。説明の先頭に判定を足すだけで、label は変えない(回答値になるため)。 */
118const annotate = (questions: AskQuestion[], result: QuestionVerdict[]): AskQuestion[] =>
119 zip(questions, result).map(([q, v]) => {
120 const top = topIndex(v.probs)
121 return {
122 ...q,
123 options: zip(q.options, v.probs).map(([o, p], j) => {
124 const tag = v.isMulti
125 ? `【Jev 選ぶ ${pct(p)}${p >= 0.5 ? '・推奨' : ''}】`
126 : `【Jev ${pct(p)}${j === top ? '・推奨' : ''}】`
127 return { ...o, description: `${tag} ${o.description}` }
128 }),
129 }
130 })
131
132export const register: Register = (on, options) => {
133 const configuredKey = typeof options.api_key === 'string' ? options.api_key : ''
134
135 on('tool.call', { tool: 'AskUserQuestion' }, ($, e, next) => {
136 const id = e.tool_use_id
137 const questions = e.questions as AskQuestion[]
138
139 const setVerdict = (v: Verdict) =>
140 update($, verdicts, all => {
141 const kept = Object.entries(all).filter(([key]) => key !== id).slice(-(KEEP - 1))
142 return { ...Object.fromEntries(kept), [id]: v }
143 })
144 // 回答済みのダイアログには出せない(エンジンが拒否する)ので握りつぶす
145 const notice = (text: string) => {
146 try {
147 $.ui.notice(id, text)
148 } catch {}
149 }
150
151 const judge = async () => {
152 await setVerdict({ status: 'pending' })
153 notice('Jev 判定中…')
154 try {
155 // Desktop アプリはシェルの設定を読まないので、設定(キーチェーン)を優先する
156 const key = configuredKey || (await $.env.get('TYPESAFE_API_KEY'))
157 if (!key) throw new Error(NO_KEY)
158
159 const forked = await $.model.fork({ prompt: forkPrompt(questions) })
160 if (!forked.isAnswered) throw new Error(`英訳に失敗しました(${forked.reason})`)
161 const en = parseEnglish(forked.text, questions)
162
163 const res = await $.http.fetch(JEV_URL, {
164 method: 'POST',
165 headers: { Authorization: `Bearer ${key}`, 'Content-Type': 'application/json' },
166 body: JSON.stringify({
167 model: JEV_MODEL,
168 state: { context: en.context },
169 questions: jevQuestions(en, questions),
170 }),
171 })
172 if (!res.ok) throw new Error(`Jev API が ${res.status} を返しました`)
173 const { answers } = JSON.parse(res.text) as { answers: Record<string, JevAnswer> }
174
175 const result = toVerdicts(answers, questions)
176 await setVerdict({ status: 'done', questions: result })
177 notice(summary(questions, result))
178 } catch (err) {
179 const message = err instanceof Error ? err.message : String(err)
180 await setVerdict({ status: 'error', message })
181 notice(`Jev 判定に失敗: ${message}`)
182 // ダイアログ直下の行を描かない画面もあるので、トーストでも知らせる
183 $.ui.toast(`Jev 判定に失敗: ${message}`)
184 }
185 }
186
187 // ダイアログは待たせずに開き、判定は回答待ちの間に裏で進める
188 const ran = next(e)
189 void judge()
190 return ran
191 })
192
193 on('ui.render', { component: 'AskUserQuestion' }, async ($, e, next) => {
194 const v = (await read($, verdicts))[e.requestId]
195 if (v?.status !== 'done') return next(e)
196 const questions = e.props.questions as AskQuestion[]
197 if (v.questions.length !== questions.length) return next(e)
198 return next({ ...e, props: { ...e.props, questions: annotate(questions, v.questions) } })
199 })
200}
201types/index.d.ts 18 lines1/** 1 問ぶんの判定。probs は options と同じ並び(multiSelect では各選択肢を選ぶ確率)。 */
2export type QuestionVerdict = {
3 isMulti: boolean
4 probs: number[]
5 confidence: number | null
6}
7
8export type Verdict =
9 | { status: 'pending' }
10 | { status: 'error'; message: string }
11 | { status: 'done'; questions: QuestionVerdict[] }
12
13declare module 'claude-code' {
14 interface PluginState {
15 'jev-judge': { verdicts: Record<string, Verdict> }
16 }
17}
18