SLOPSHOPPER

stop-you-violated-the-law

Mod: STOP! You violated the law! toast when opus is used for a light turn

newguardtoastprompt
A shopper browsing a rack in a slop shop
README

stop-you-violated-the-law

Mod. After a light turn on opus (few tool calls, short reply) it toasts "STOP! You violated the law!" and suggests sonnet or haiku. It only nags; it never switches models or blocks anything.

Options: maxTools (2), maxOutputTokens (400), cooldownTurns (5). The thresholds are heuristics.

Source 1 files
hooks/register.ts 40 lines
1import type { Register } from 'claude-code'
2
3// Three lines of at most 40 columns: that is all a toast shows.
4export const TOAST = 'STOP! You violated the law!\nOpus for a light turn? Sonnet or haiku\nwould do. Switch with /model'
5
6const num = (v: unknown, d: number) => (typeof v === 'number' && v >= 0 ? v : d)
7
8export const register: Register = (on, options) => {
9  const MAX_TOOLS = num(options.maxTools, 2)
10  const MAX_OUTPUT = num(options.maxOutputTokens, 400)
11  const COOLDOWN = num(options.cooldownTurns, 5)
12
13  let tools = 0
14  let quiet = 0
15
16  on('prompt.submit', ($, e, next) => {
17    tools = 0
18    return next(e)
19  })
20
21  on('tool.call', ($, e, next) => {
22    tools += 1
23    return next(e)
24  })
25
26  on('turn.complete', ($, e, next) => {
27    if (quiet > 0) quiet -= 1
28
29    const u = e.usage
30    const isLight = u !== undefined && tools <= MAX_TOOLS && u.output_tokens <= MAX_OUTPUT
31
32    if (isLight && /opus/i.test(u.model) && quiet === 0) {
33      quiet = COOLDOWN
34      $.ui.toast(TOAST)
35    }
36
37    return next(e)
38  })
39}
40