SLOPSHOPPER

first-mod

Counts tool calls, shows a band above the prompt, and adds /tally plus a ping tool

bandspinnerguardcommandtoasttool
v0.1.0MITupdated 2026-10-13parkjangwon/pawn/examples/mods/first-mod
A shopper browsing a rack in a slop shop
Preview · a replayed session in a sandbox
claude · ~/work/app · first-mod
› 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 ✻ Thinking · tool calls: 9… ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── › ? for shortcuts
README

first-mod

Sample mod. Counts tool calls, draws a band above the composer, adds /tally, and registers a ping tool.

How mods load, consent, and the $ API: docs/agent/MODS.md (한국어).

Layout

first-mod/
├── .claude-plugin/plugin.json
└── hooks/
    ├── hooks.json
    └── register.js

Try it

  1. Settings → Plugins → Mods → Install sample mod. Or copy this folder to ~/.pawn/mods/first-mod.
  2. Allow it in the review dialog. Consent is tied to plugin.json version.
  3. In chat, the thinking line shows · tool calls: N….
  4. Type /tally. The model can call mcp__first-mod__ping (it returns pong). Reset and the note field use ui.press and ui.input.
Source 1 files
hooks/register.js 75 lines
1// The count, shared by the hooks below
2let calls = 0
3let note = ''
4
5// Pawn / Claude Code calls this once when the mod loads
6export function register(on) {
7  // Runs when the session starts, before your first prompt.
8  // Pawn emits session.start once for every loaded mod, so only register
9  // when the event is about this mod; a second /tally register throws.
10  on('session.start', async ($, e, next) => {
11    if (e.plugin !== $.plugin.name) return next(e)
12    await $.command.register({
13      name: 'tally',
14      description: 'Show how many tool calls the agent has made'
15    })
16    await $.tool.register({
17      name: 'ping',
18      description: 'Reply pong. Use when the user asks this mod to ping.',
19      inputSchema: { type: 'object', properties: {} },
20      handler: async () => 'pong'
21    })
22    $.ui.invalidate('ui.render')
23    return next(e)
24  })
25
26  // Runs each time the agent is about to use a tool
27  on('tool.call', async ($, e, next) => {
28    calls += 1
29    $.ui.invalidate('ui.render')
30    return next(e)
31  })
32
33  // Runs when you type /tally
34  on('command.run', { command: 'tally' }, async () => {
35    return { text: 'The agent has made ' + calls + ' tool calls since this mod loaded' + (note ? ' · note: ' + note : '') }
36  })
37
38  // Interactive band above the composer
39  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
40    const el = $.ui.resolve(e)
41    return next({
42      ...e,
43      props: {
44        ...e.props,
45        plugin: $.plugin.name,
46        tree: el.Box({
47          children: [
48            el.Text({ text: 'first-mod · tool calls: ' + calls + (note ? ' · ' + note : '') }),
49            el.Button({ id: 'reset-tally', text: 'Reset count' }),
50            el.Input({ id: 'note', placeholder: 'Optional note…', value: note })
51          ]
52        })
53      }
54    })
55  })
56
57  on('ui.press', { id: 'reset-tally' }, async ($, e) => {
58    calls = 0
59    $.ui.toast('Tally reset')
60    $.ui.invalidate('ui.render')
61    return e
62  })
63
64  on('ui.input', { id: 'note' }, async ($, e) => {
65    note = String(e.value || '')
66    $.ui.invalidate('ui.render')
67    return e
68  })
69
70  // Runs each time the spinner is drawn
71  on('ui.render', { component: 'Spinner' }, async ($, e, next) => {
72    return next({ ...e, props: { ...e.props, suffix: calls ? ' · tool calls: ' + calls : '' } })
73  })
74}
75