// Example mod: restyle built-in rows with cmd.ui.override. // // `spinner` appends nodes after the working status line, so "tool calls: 3" sits beside the // spinner while the agent works. `tool_row` draws a tool's row instead of the built-in one; // returning undefined keeps the built-in row, and `next()` is what mods loaded after this one // drew (undefined when nobody did). A throwing override falls back to the built-in drawing. // // The permission prompt is never overridable: what a person approves is always drawn by the host. import type {ModApi, ModUiOverrideProps} from '@commandcode/harness'; function statusMark(status: ModUiOverrideProps['tool_row']['status']): string { if (status === 'error') return '✗'; if (status === 'pending') return '…'; return '✓'; } export default function (cmd: ModApi): void { const calls = (): number => cmd.state.get('calls') ?? 0; cmd.on('tool_completed', () => { cmd.state.set('calls', calls() + 1); }); // One count per run: reset when the agent starts working on a new prompt. cmd.on('run_start', () => { cmd.state.set('calls', 0); }); cmd.ui.override('spinner', (_props, next) => [ {type: 'text', text: `tool calls: ${calls()}`, color: 'cyan'}, ...(next() ?? []), ]); // Shell rows as one compact line; every other tool keeps its built-in row. cmd.ui.override('tool_row', ({toolName, input, status}) => { if (toolName !== 'shell_command') return undefined; return [ { type: 'row', children: [ {type: 'text', text: statusMark(status), bold: true}, {type: 'text', text: `$ ${input}`, dim: true}, ], }, ]; }); }