SLOPSHOPPER

quiet-tools

Draws successful tool calls as one dim line in the terminal and hides their output, keeping its key facts (git commit, background, exit code meaning); a call a…

rowscommand
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · quiet-tools
› fix the failing auth test and add an audit log call ⏺ Read(src/auth.ts) ⎿ Read 6 lines ⏺ Update(src/auth.ts) ⎿ Added 2 lines, removed 1 line ⏺ Bash(bun test) ⎿ 3 pass, 1 fail ● Done. refresh now rejects expired claims and logs an audit event. ✻ Worked for 42s · done 4:20 PM › /quiet-tools ⎿ quiet-tools: quiet-tools off: tool rows draw in full. ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts
README

quiet-tools

A long turn reads and searches dozens of times, and every call draws its own block with its output under it. quiet-tools draws each successful call as one dim line and hides its output:

✓ Read · README.md
✓ Bash · Run the unit tests
✓ Read 3 files, searched 2 patterns

A call still running shows … in place of ✓.

What the hidden output would have told you stays on the line: the git operation a command made, a command moved to the background (or timed out into it), and what a non-zero exit code means:

✓ Bash · git commit -m "…" — committed 5756c6d → main, pushed → main
✓ Bash · npm run dev — in background
✓ Bash · grep -r TODO src — No matches found

A call that a PreToolUse hook refused never ran, so there is nothing to read but the reason; it becomes one red line:

✗ Bash · git commit -m "…" — blocked by hook: ⚠️ VERIFICATION GATE: run the tests first

Calls that ran and failed, and interrupted ones, keep the full row, so errors stay where you will see them. SendUserFile cards also stay full: the file they put in front of you is the point of the call.

ctrl+o (or --verbose) draws every call in full, the ones already folded in the history included, and closing it folds them again. Tool rows don't say which view they are in, so quiet-tools reads it from your own prompt rows: a session with no prompt yet drawn stays folded.

/quiet-tools turns it off and on for the current session.

Options

language: en (default) or zh-TW, from /config or settings:

"pluginConfigs": { "quiet-tools@claude-code-mods": { "options": { "language": "zh-TW" } } }
Source 3 files
hooks/register.tsx 229 lines
1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3import { stringsFor } from './strings'
4import type { Strings } from './strings'
5
6// ponytail: on/off lives in session state and resets to on each session; persist it in $.store if that gets annoying
7const isOn = atom({ plugin: 'quiet-tools', key: 'isOn' } as const, true)
8
9const FIELDS = ['description', 'command', 'file_path', 'pattern', 'url', 'query', 'prompt'] as const
10
11// The card itself is the deliverable (a file put in front of the owner), so folding it hides the thing asked for.
12const ALWAYS_FULL = new Set(['SendUserFile'])
13
14export function summarize(input: unknown): string {
15  if (typeof input !== 'object' || input === null) return ''
16  const fields = input as Record<string, unknown>
17  for (const name of FIELDS) {
18    const value = fields[name]
19    if (typeof value !== 'string' || value.trim() === '') continue
20    const text = name === 'file_path' ? (value.split('/').pop() ?? value) : value
21    return text.replace(/\s+/g, ' ').trim()
22  }
23  return ''
24}
25
26const GROUP_WORDS: Record<string, [string, string]> = {
27  Read: ['read', 'file'],
28  Grep: ['searched', 'pattern'],
29  Glob: ['searched', 'pattern'],
30  Bash: ['ran', 'command'],
31}
32
33export function summarizeGroup(tools: readonly string[]): string {
34  const counts = new Map<string, number>()
35  for (const tool of tools) counts.set(tool, (counts.get(tool) ?? 0) + 1)
36  const parts = [...counts].map(([tool, n]) => {
37    const words = GROUP_WORDS[tool]
38    if (words === undefined) return `${tool} ×${n}`
39    return `${words[0]} ${n} ${words[1]}${n === 1 ? '' : 's'}`
40  })
41  const text = parts.join(', ')
42  return text.charAt(0).toUpperCase() + text.slice(1)
43}
44
45// A PreToolUse hook refused the call before it ran: there is no output to read, and
46// the reason fits on one line. A command that ran and failed is not this.
47const HOOK_DENIED = /^(?:Error:\s*)?(?:<tool_use_error>\s*)?PreToolUse:(\S+) hook error:\s*/
48
49/**
50 * The first line of the refusing hook's reason when a PreToolUse hook refused this
51 * call to `tool`; null otherwise, and null when the hook gave no reason (the full
52 * row then says what little there is).
53 */
54export function hookDenial(output: unknown, tool: string): string | null {
55  const text = typeof output === 'string'
56    ? output
57    : Array.isArray(output)
58      ? output.map(block => (block && typeof block === 'object' && typeof block.text === 'string' ? block.text : '')).join('\n')
59      : ''
60  const trimmed = text.trimStart()
61  const match = HOOK_DENIED.exec(trimmed)
62  if (match === null || match[1] !== tool) return null
63  const reason = trimmed.slice(match[0].length).replace(/<\/tool_use_error>\s*$/, '')
64    .split(/\r?\n/).map(line => line.trim()).find(Boolean)
65  return reason || null
66}
67
68function deniedLine(tool: string, detail: string, reason: string, s: Strings): string {
69  return `✗ ${tool}${detail === '' ? '' : ` · ${detail}`} — ${s.blocked}${reason}`
70}
71
72type GitOperation = {
73  commit?: { sha: string; kind: string; branch?: string }
74  push?: { branch: string }
75  branch?: { ref: string; action: string }
76  pr?: { number: number; action: string }
77}
78
79/**
80 * What a Bash call's hidden result would have told: the git operation it made (never
81 * shown to the model either), a move to the background, the exit code's meaning.
82 * Empty when there is nothing; an errored call's output is plain text, so it has none.
83 * Other tools' results are not read: the same field names there mean something else.
84 */
85export function metaOf(tool: string, output: unknown, s: Strings): string {
86  if (tool !== 'Bash' || typeof output !== 'object' || output === null || Array.isArray(output)) return ''
87  const result = output as Record<string, unknown>
88  const notes: string[] = []
89  const git = (result.gitOperation ?? {}) as GitOperation
90  if (git.commit) notes.push(`${git.commit.kind} ${git.commit.sha.slice(0, 7)}${git.commit.branch ? ` → ${git.commit.branch}` : ''}`)
91  if (git.push) notes.push(`pushed → ${git.push.branch}`)
92  if (git.branch) notes.push(`${git.branch.action} ${git.branch.ref}`)
93  if (git.pr) notes.push(`PR #${git.pr.number} ${git.pr.action}`)
94  if (typeof result.timedOutAfterMs === 'number') notes.push(s.timedOut(Math.round(result.timedOutAfterMs / 1000)))
95  else if (typeof result.backgroundTaskId === 'string') notes.push(s.background)
96  if (typeof result.returnCodeInterpretation === 'string' && result.returnCodeInterpretation !== '') notes.push(result.returnCodeInterpretation)
97  return notes.join(', ')
98}
99
100// Cells the engine indents a transcript row by, with a little slack.
101const ROW_INDENT = 4
102
103// Tool rows don't say whether the ctrl+o transcript (or --verbose) is open, but the
104// person's own prompt rows do; the last one drawn is mirrored here, and while it says
105// expanded every tool row is the engine's, history included.
106let isExpandedView = false
107
108// A peer's or teammate's row can report expanded in the normal view (under a speaker
109// label, when its body fits), so only the person's own prompts are read.
110const OWN_PROMPT = new Set(['composer', 'bridge'])
111
112export const register: Register = (on, options) => {
113  const s = stringsFor(options?.language)
114
115  on('session.start', async ($, e, next) => {
116    await $.command.register({
117      name: 'quiet-tools',
118      description: 'Toggle one-line tool rows: successful calls draw as one dim line, their output hidden',
119    })
120
121    return next(e)
122  })
123
124  on('command.run', { command: 'quiet-tools' }, async $ => {
125    const now = await update($, isOn, value => !value)
126
127    return { text: now ? s.on : s.off }
128  })
129
130  on('ui.render', { component: 'UserMessage' }, async ($, e, next) => {
131    if (e.surface === 'terminal' && OWN_PROMPT.has(e.props.origin.kind) && e.props.isExpanded !== isExpandedView) {
132      isExpandedView = e.props.isExpanded
133      // Tool rows keep their last drawing until asked again, so the switch redraws them.
134      $.ui.invalidate('ui.render')
135    }
136    return next(e)
137  })
138
139  // Failed and interrupted calls keep the engine's full row, so failures stay visible;
140  // a call a hook refused is one red line naming the reason.
141  on('ui.render', { component: 'ToolUse' }, async ($, e, next) => {
142    if (e.surface !== 'terminal' || isExpandedView || e.props.isInterrupted || ALWAYS_FULL.has(e.props.tool)) return next(e)
143    const denial = e.props.isErrored ? hookDenial(e.props.output, e.props.tool) : null
144    if (e.props.isErrored && denial === null) return next(e)
145    if (!(await read($, isOn))) return next(e)
146
147    const { Box, Text } = $.ui.resolve(e)
148    const detail = summarize(e.props.input)
149
150    if (denial !== null) {
151      return (
152        <Box key="quiet-denied">
153          <Text color="error" wrap="truncate-end">
154            {deniedLine(e.props.tool, detail, denial, s)}
155          </Text>
156        </Box>
157      )
158    }
159
160    // The meta sits in its own box that does not shrink, so a long command is cut before
161    // it is; past the room the tool name and the engine's indent leave, the meta is cut too.
162    // ponytail: counts characters, not cells; a meta full of CJK can still run past the row, count cells if one does
163    const room = Math.max(12, (e.viewport?.columns ?? 80) - `✓ ${e.props.tool} — `.length - ROW_INDENT)
164    const full = metaOf(e.props.tool, e.props.output, s)
165    const meta = full.length > room ? `${full.slice(0, room - 1)}…` : full
166
167    return (
168      <Box key="quiet-row">
169        <Text dimColor wrap="truncate-end">
170          {e.props.isRunning ? '… ' : '✓ '}
171          {e.props.tool}
172          {detail === '' ? '' : ` · ${detail}`}
173        </Text>
174        {meta !== '' && (
175          <Box key="quiet-meta" flexShrink={0}>
176            <Text dimColor>{` — ${meta}`}</Text>
177          </Box>
178        )}
179      </Box>
180    )
181  })
182
183  // isExpanded is ctrl+o or --verbose: the engine's expanded rows stay reachable there.
184  // A refused call in the group gets its own red line; any other failure unfolds it.
185  on('ui.render', { component: 'ToolGroup' }, async ($, e, next) => {
186    if (e.surface !== 'terminal' || e.props.isExpanded) return next(e)
187    const calls = e.props.calls.map(call => ({ call, denial: call.isErrored ? hookDenial(call.output, call.tool) : null }))
188    if (calls.some(({ call, denial }) => (call.isErrored && denial === null) || call.isInterrupted || ALWAYS_FULL.has(call.tool))) return next(e)
189    if (!(await read($, isOn))) return next(e)
190
191    const { Box, Text } = $.ui.resolve(e)
192    const ran = calls.filter(({ denial }) => denial === null).map(({ call }) => call)
193    const isRunning = ran.some(call => call.isRunning)
194    const meta = ran.map(call => metaOf(call.tool, call.output, s)).filter(Boolean).join(', ')
195
196    return (
197      <Box key="quiet-group" flexDirection="column">
198        {ran.length > 0 && (
199          <Box key="quiet-group-ran">
200            <Text dimColor wrap="truncate-end">
201              {isRunning ? '… ' : '✓ '}
202              {summarizeGroup(ran.map(call => call.tool))}
203              {meta === '' ? '' : ` — ${meta}`}
204            </Text>
205          </Box>
206        )}
207        {calls.flatMap(({ call, denial }, i) => denial === null ? [] : [
208          <Box key={`quiet-group-denied-${i}`}>
209            <Text color="error" wrap="truncate-end">
210              {deniedLine(call.tool, summarize(call.input), denial, s)}
211            </Text>
212          </Box>,
213        ])}
214      </Box>
215    )
216  })
217
218  // The refused call's row already carries the reason; its error block would repeat it.
219  on('ui.render', { component: 'ToolResult' }, async ($, e, next) => {
220    if (e.surface !== 'terminal' || isExpandedView || ALWAYS_FULL.has(e.props.tool)) return next(e)
221    if (e.props.isErrored && hookDenial(e.props.output, e.props.tool) === null) return next(e)
222    if (!(await read($, isOn))) return next(e)
223
224    const { Box } = $.ui.resolve(e)
225
226    return <Box key="quiet-result" />
227  })
228}
229
hooks/strings.ts 29 lines
1export type Strings = {
2  on: string
3  off: string
4  blocked: string
5  background: string
6  timedOut: (seconds: number) => string
7}
8
9export const STRINGS: Record<'en' | 'zh-TW', Strings> = {
10  en: {
11    on: 'quiet-tools on: successful tool calls draw as one line.',
12    off: 'quiet-tools off: tool rows draw in full.',
13    blocked: 'blocked by hook: ',
14    background: 'in background',
15    timedOut: seconds => `timed out after ${seconds}s, in background`,
16  },
17  'zh-TW': {
18    on: 'quiet-tools 已開啟:成功的工具呼叫收成一行。',
19    off: 'quiet-tools 已關閉:工具呼叫完整顯示。',
20    blocked: 'hook 擋下:',
21    background: '背景執行中',
22    timedOut: seconds => `${seconds} 秒逾時,轉到背景`,
23  },
24}
25
26export function stringsFor(language: unknown): Strings {
27  return language === 'zh-TW' ? STRINGS['zh-TW'] : STRINGS.en
28}
29
types/index.d.ts 8 lines
1export type QuietToolsMode = boolean
2
3declare module 'claude-code' {
4  interface PluginState {
5    'quiet-tools': { isOn: QuietToolsMode }
6  }
7}
8