SLOPSHOPPER

callouts

Makes what needs you impossible to miss, in three tiers. Blockers, `> [!ACTION]` and `> [!SECRET]`, draw as bright yellow cards; questions, `> [!ASK]` and `>…

bandrowstoast
v0.3.0MITupdated 2026-10-17michaelezehi/nw-skills/mods/callouts
A shopper browsing a rack in a slop shop
README

NW skills

New Ward skills: agent skills and slash commands for Claude Code that I use on every project.

Most are my own. Some started as other people's skills and now carry my changes, mostly an unlazy completion gate and plain-writing rules wired in. Each one is marked in the tables below.

Install

Claude Code plugin

claude plugin marketplace add michaelezehi/nw-skills
claude plugin install nw-skills@nw-skills

Plugin skills and commands are namespaced, so /research becomes /nw-skills:research.

skills.sh

npx skills@latest add michaelezehi/nw-skills

This copies editable skill folders into your project or ~/.claude/skills.

By hand

Copy any folder under skills/<category>/ into ~/.claude/skills/, and any file under commands/ into ~/.claude/commands/.

Several skills point at ~/.claude/skills/unlazy/scripts/gate-check.mjs and ~/.claude/skills/unslop/SKILL.md. Install unlazy and unslop first if you take only a few.

Skills (40)

Engineering

SkillWhat it doesOrigin
agent-reachSee, hear and read what a link points at when built-in fetch can't: full transcripts of YouTube videos, Instagram reels, TikTok and X video (subtitles or local Whisper), plus read-only search and read across 14 platforms through the Agent Reach CLI.Modified from EdisonChenAI/agent-reach and Panniantong/Agent-Reach
app-user-journeyScan a codebase for every user role and map each one's real journey, registration, onboarding, the day-one surface, and a proposed leaner path, then ship it as an...Original
build-speedAudit and fix any project's build + deploy pipeline for speed, kill cache-busting, move builds off the deploy box into CI, wire registry pull mode, and prove every...Original
convex-backup-cronInstall a 4x-daily production backup cron for Convex + DigitalOcean Spaces projects.Original
ogInstall a dynamic Open Graph / Twitter social card route into a Next.js project.Original
own-goalRun a goal or a whole PRD to completion: a verifiable completion condition worked in a loop until met, with an accountability record and a /reviewer gate.Original
project-optimisationFind and fix why a JS/TS monorepo is slow, from dev server memory to first-load JS per route: measure, fan out by cause, fix in parallel, re-measure, ship through staging.Original
qa-casesGenerate a shareable QA test case .md document for the current project.Original
terminal-upgradeTurn pnpm dev / npm run dev / yarn dev / bun dev in every repo on the machine into Devdeck, a calm live terminal dashboard.Original
ts-upgradeMove a repo's type checking to TypeScript 7, the native compiler, without breaking ESLint, tsup, Next, Expo, Remotion, Convex, CI or Docker builds, and measure before and after.Original
unlazyAnti-laziness execution discipline, required on every task sized L or XL (the /prd-ch scale) and run on request for anything smaller.Modified from Leonxlnx/unlazy
vercel-react-best-practicesReact and Next.js performance optimization guidelines from Vercel Engineering.Modified from vercel-labs/agent-skills
walkthroughAdd a guided walkthrough to any web app, one story per user role plus feature stories: a story bar with arrow keys and a story picker, a focus light on the one control each step is about, a journey reader that moves clear of what it explains with "show me how to get there", split prompt cards, a spoken narrator the viewer can mute (also added to an existing tour), and an optional demo tier...Original

Design and frontend

SkillWhat it doesOrigin
apple-designApple's approach to interface design and fluid, physical motion, translated for the web.Modified from emilkowalski/skill
brandkitPremium brand-kit image generation skill for creating high-end brand-guidelines boards, logo systems, identity decks, and visual-world presentations.Modified from Leonxlnx/taste-skill
click-burstAdds a performant click-triggered full-viewport color burst transition (scale + opacity only, no animated blur).Original
design-taste-frontendAnti-slop frontend rules for LANDING PAGES, PORTFOLIOS, and MARKETING REDESIGNS: reads the brief, infers direction, ships interfaces that do not look templated, with...Modified from Leonxlnx/taste-skill
emil-design-engEmil Kowalski's design-engineering philosophy, animation decisions, springs, gestures, component feel, and the invisible details that make software feel great.Modified from emilkowalski/skill
fedAlias for frontend-design.Original
find-animation-opportunitiesSearch a codebase or UI for places that don't animate but should, and reject everything that shouldn't.Modified from emilkowalski/skill
frontend-designThe main frontend skill. Distinctive, production-grade UI with high craft in typography, layout, colour and motion.Original
iconizeExtract individual icons from sprite sheets into named, square PNG files organized by category.Original
image-to-codeAlias for imagegen-frontend-web (image-first web flow: generate section images, then code them).Modified from Leonxlnx/taste-skill
imagegen-frontend-mobilePremium mobile app screen concept images, iOS, Android, and cross-platform screens and multi-screen flows (onboarding, auth, home, profile, settings, chat, commerce,...Modified from Leonxlnx/taste-skill
imagegen-frontend-webThe image-first WEB flow, generate one premium horizontal reference image per section (hero, landing page, marketing site, product page, portfolio), deeply analyze...Modified from Leonxlnx/taste-skill
impeccableUse when the user wants to design, redesign, shape, critique, audit, polish, clarify, distill, harden, optimize, adapt, animate, colorize, extract, or otherwise...Modified from pbakaus/impeccable
improve-animationsSurvey a codebase's animation and motion code as a senior motion advisor, then produce a prioritized audit and self-contained implementation plans for other agents...Modified from emilkowalski/skill
industrial-brutalist-uiOPT-IN STYLE PRESET, use ONLY when the user explicitly asks for brutalist / industrial / Swiss-print / terminal aesthetics, or names this skill.Modified from Leonxlnx/taste-skill
minimalist-uiOPT-IN STYLE PRESET, use ONLY when the user explicitly asks for a minimalist / Notion-like / warm-monochrome editorial look, or names this skill.Modified from Leonxlnx/taste-skill
pick-ui-libraryPick the right library for a given frontend task from a curated, opinionated list, numbers, OTP inputs, charts, command menus, virtualization, drag and drop, toasts,...Modified from emilkowalski/skill
prototypeBuild multiple genuinely different versions of a UI piece you describe, rendered behind a visual picker so you can flip through them live and promote the one that...Modified from emilkowalski/skill
redesign-existing-projectsUpgrades existing websites and apps to premium quality.Modified from Leonxlnx/taste-skill
review-animationsReviews animation and motion code against a high craft bar derived from Emil Kowalski's design engineering philosophy.Modified from emilkowalski/skill
sketchesHand-drawn SVG sketch/doodle system with a growing, brand-themeable repertoire.Original
stitch-design-tasteSemantic Design System Skill for Google Stitch.Modified from Leonxlnx/taste-skill
the-broadsideInstall the broadside editorial slide-deck design system into the current React/Next.js project.Original
the-stripe-modalInstall the editorial-press design system (surface card + slide-in modal flow + hero empty state) into the current React/Next.js project.Original
ui-ux-pro-maxUI/UX design intelligence for web and mobile.Modified from nextlevelbuilder/ui-ux-pro-max-skill

Writing

SkillWhat it doesOrigin
copy-panel-rewriteRewrite every string in a product in plain language, then let three blind, research-backed judge panels decide each change (2 of 3 wins, ranking round for splits), apply the verdicts in code and publish a tabbed report.Original
humanizerRewrite AI-sounding text so it reads like the writer without changing what it says.Modified from blader/humanizer
rndCreate a shareable internal R&D page from a team brief, a votable consensus spec with a participant intro gate (--consensus), a screen-by-screen product build deck...Original
unslopCut AI tells from any writing.Original
writing-clearly-and-conciselyStrunk companion for prose humans will read.Modified from softaworks/agent-toolkit

Strategy

SkillWhat it doesOrigin
gtmGo-to-market toolkit for any project: /gtm lists twelve sub-commands (validate, feature, brief, competitors, personas, interviews, mvp, pricing, plan, metrics, fundraise, deck); each run reads what the project knows, sources every outside claim and hands back a black-and-white PDF with a designed cover; /gtm on <repo> runs the whole review into one PDF, and /gtm:all or /gtm:pricing (one command per sub-command) run from any repo.Modified from emotixco/claude-skills-founder

Commands

CommandWhat it does
/cfForce-continue a context-exhausted session.
/chHandoff continuity mode: numbered task list, accountability record with every question and decision, optional HTML summary.
/fd-chFrontend design run with reconnaissance, a quality gate and an accountability record, built on the frontend-design skill.
/prRead every PR review comment, fix what is actionable, and reply to each one.
/prd-chCreate a PRD fast and well.
/researchDeep research on any topic.
/reviewerFull audit and fix pass on the current task's changes, using any review skills installed on your machine (never Greptile or CodeRabbit).

Mods

Claude Code mods (plugins with function hooks) in mods/. Each one installs on its own from this marketplace:

claude plugin marketplace add michaelezehi/nw-skills
claude plugin install savvy-progress@nw-skills
ModWhat it doesOrigin
savvy-progressProgress bar above the prompt and an agents panel (/agents-info) with each subagent's model, context, cost and time. Draws in 24-bit colour in any truecolor terminal (Warp, iTerm2, Ghostty, WezTerm, kitty) as well as on the desktop.Modified from johnnyvizz/claude-kit
agent-barTurns the savvy-progress bar on for every task: todos, tasks and subagent launches become its rows. Steps aside when a skill reports its own plan. Needs savvy-progress.Original
guard-railsDenies git commands that sweep other agents' work (git add -A, commit -a, stash, reset, clean, restore, checkout) and dashes in commit or PR text.Original
session-pane/session-pane opens a pane with the files changed this session as a tree and the latest 50 tool calls.Original
turn-chimeA toast and a chime when a turn that ran a minute or longer finishes.Original

The skills and commands report to the progress panel by the rules in references/progress-panel.md. Copy it to ~/.claude/references/. Without savvy-progress installed they skip it.

Handoff hooks (optional)

/ch, /fd-ch and /prd-ch hand work over to a fresh session when context runs low. That needs three hooks in hooks/:

  • context-monitor.sh warns at about 70 and 90 percent context use.
  • precompact.sh writes .claude/handoffs/current.md (todos and modified files) before compaction.
  • session-start.sh feeds that handoff back in when the next session starts.

They are not switched on by installing the plugin. To use them, copy the scripts to ~/.claude/hooks/ and add this to ~/.claude/settings.json:

{
  "hooks": {
    "PostToolUse": [{ "hooks": [{ "type": "command", "command": "~/.claude/hooks/context-monitor.sh" }] }],
    "PreCompact": [{ "hooks": [{ "type": "command", "command": "~/.claude/hooks/precompact.sh" }] }],
    "SessionStart": [{ "hooks": [{ "type": "command", "command": "~/.claude/hooks/session-start.sh" }] }]
  }
}

Without them the commands still run; you just lose the automatic handoff.

Licence

My own skills and commands are MIT, see LICENSE. Modified skills keep their upstream licence and credit; see NOTICE.md.

Source 5 files
hooks/register.tsx 157 lines
1// callouts: what a reply marks for the person stands out. `> [!ACTION]` and `> [!SECRET]`
2// draw as yellow cards, `> [!ASK]` and `> [!INPUT]` as violet ones, `> [!REVIEW]` as a violet
3// outline, and all stay listed above the prompt, each with its answer, until answered or
4// dismissed; a key typed into a SECRET goes straight into its .env file. `> [!DONE]` draws
5// as a finished banner.
6// Every function that takes `$` lives in this file: the engine follows `$` across no import.
7import { atom, read, update } from 'claude-code'
8import type { EngineInterface, Register } from 'claude-code'
9
10import type { Callout } from '../types'
11
12import { band, calloutBlock } from './draw'
13import { DEFAULT_PALETTE, parsePalette, themePath } from './palette'
14import { openOf, parseCallouts, upsertEnv } from './parse'
15
16const openAtom = atom({ plugin: 'callouts', key: 'open' } as const, [])
17const paletteAtom = atom({ plugin: 'callouts', key: 'palette' } as const, DEFAULT_PALETTE)
18const typedAtom = atom({ plugin: 'callouts', key: 'typed' } as const, {})
19
20/**
21 * What the person has typed into each SECRET field, by item key. Module memory only: never
22 * in $.state, the transcript or a message, and dropped once saved or dismissed.
23 */
24const secrets = new Map<string, string>()
25const keyOf = (c: Callout): string => `${c.kind}:${c.title}`
26
27/** The field's text after an edit, from the masked value the field now holds. */
28export function nextSecret(current: string, fieldValue: string): string {
29  const dots = (fieldValue.match(/•/g) ?? []).length
30  return current.slice(0, dots) + fieldValue.replace(/•/g, '')
31}
32
33/** Read the Devdeck theme, so the cards share the palette the person picked. */
34async function loadPalette($: EngineInterface): Promise<void> {
35  const xdg = await $.env.get('XDG_CONFIG_HOME').catch(() => undefined)
36  const home = await $.env.get('HOME').catch(() => undefined)
37  const path = themePath(xdg, home)
38  const text = path === null ? null : await $.fs.read(path).then(out => (typeof out === 'string' ? out : null), () => null)
39  await update($, paletteAtom, () => parsePalette(text))
40}
41
42/** Drop item `c`, and anything typed into it. */
43async function drop($: EngineInterface, c: Callout): Promise<void> {
44  secrets.delete(keyOf(c))
45  await update($, typedAtom, typed => Object.fromEntries(Object.entries(typed).filter(([k]) => k !== keyOf(c))))
46  await update($, openAtom, list => list.filter(x => keyOf(x) !== keyOf(c)))
47}
48
49/** Write the typed key into its .env file and tell the chat where it went, without the value. */
50async function saveSecret($: EngineInterface, c: Callout): Promise<void> {
51  const value = secrets.get(keyOf(c)) ?? ''
52  if (!c.secret || !value || /[\r\n]/.test(value)) {
53    $.ui.toast(value ? 'A key cannot hold a line break.' : 'Paste the key first.')
54    return
55  }
56  const { name } = c.secret
57  // Anchored to the session's folder, so the key lands in this repo whatever the process cwd.
58  const cwd = await $.session.cwd()
59  if (!cwd.startsWith('/')) throw new Error('no working directory')
60  const path = `${cwd.replace(/\/+$/, '')}/${c.secret.path}`
61  const before = await $.fs.read(path).then(out => (typeof out === 'string' ? out : ''), () => '')
62  await $.fs.write(path, upsertEnv(before, name, value))
63  await drop($, c)
64  await $.prompt.submit({ text: `Saved ${name} to ${c.secret.path} (${value.length} characters; the value is not in this chat).` })
65}
66
67export const register: Register = on => {
68  on('session.start', async ($, e, next) => {
69    const started = await next(e)
70    secrets.clear()
71    await update($, openAtom, () => [])
72    await update($, typedAtom, () => ({}))
73    await loadPalette($).catch(() => undefined)
74    return started
75  })
76
77  // A reply that marks something replaces the list; a reply that marks nothing leaves it, so
78  // an open question survives an unrelated command. The theme is read again with it.
79  on('turn.complete', async ($, e, next) => {
80    const done = await next(e)
81    // A subagent's turn is not the reply the person reads.
82    if (e.agentId === undefined && !e.isAborted) {
83      const open = openOf(parseCallouts(e.answer))
84      if (open.length > 0) {
85        secrets.clear()
86        await update($, typedAtom, () => ({}))
87        await update($, openAtom, () => open)
88      }
89      await loadPalette($).catch(() => undefined)
90    }
91    return done
92  })
93
94  on('ui.render', { component: 'AssistantMessage' }, async ($, e, next) => {
95    const segments = parseCallouts(e.props.text)
96    if (!segments.some(s => s.kind === 'callout')) return next(e)
97    const ui = $.ui.resolve(e)
98    const palette = await read($, paletteAtom)
99    const parts: JSX.Element[] = []
100    for (const [i, s] of segments.entries()) {
101      // Markdown between the cards keeps the engine's own drawing: tables, code, lists.
102      if (s.kind === 'markdown') parts.push(<ui.Box key={`md-${i}`}>{await next({ ...e, props: { ...e.props, text: s.text } })}</ui.Box>)
103      else parts.push(calloutBlock(ui, s.callout, palette, `callout-${i}`))
104    }
105    return (
106      <ui.Box key="callouts-message" flexDirection="column">
107        {parts}
108      </ui.Box>
109    )
110  })
111
112  on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
113    const open = await read($, openAtom)
114    if (open.length === 0 || e.props.hasSurvey) return next(e)
115    const ui = $.ui.resolve(e)
116    const palette = await read($, paletteAtom)
117    const typed = await read($, typedAtom)
118    const at = (index: number): Callout | undefined => open[index]
119    const mine = band({
120      ui,
121      open,
122      palette,
123      columns: e.props.bodyColumns,
124      masked: Object.fromEntries(open.map((c, i) => [i, typed[keyOf(c)] ?? 0])),
125      answer: (index, text) => {
126        const c = at(index)
127        if (!c) return
128        void drop($, c)
129          .then(() => $.prompt.submit({ text }))
130          .catch(() => undefined)
131      },
132      dismiss: index => {
133        const c = at(index)
134        if (c) void drop($, c).catch(() => undefined)
135      },
136      secretInput: (index, value) => {
137        const c = at(index)
138        if (!c) return
139        const typedNow = nextSecret(secrets.get(keyOf(c)) ?? '', value)
140        secrets.set(keyOf(c), typedNow)
141        void update($, typedAtom, t => ({ ...t, [keyOf(c)]: typedNow.length })).catch(() => undefined)
142      },
143      secretSubmit: index => {
144        const c = at(index)
145        if (c) void saveSecret($, c).catch(() => $.ui.toast('The key could not be saved.'))
146      },
147    })
148    if (mine === null) return next(e)
149    return (
150      <ui.Box key="callouts-above" flexDirection="column">
151        {mine}
152        {await next(e)}
153      </ui.Box>
154    )
155  })
156}
157
hooks/draw.tsx 285 lines
1// How callouts look: a yellow card in the transcript for what blocks the person, a violet card
2// for a question, a violet outline for something worth a look, a finished banner for DONE,
3// and the band above the prompt that holds the open ones with their answers.
4import type { Elements } from 'claude-code'
5
6import type { Callout, CalloutKind, Palette } from '../types'
7
8import { INK, VIOLET, fillOf } from './palette'
9
10type Table = Elements['terminal'] | Elements['desktop'] | Elements['vscode'] | Elements['mobile']
11
12export const LABELS: Record<CalloutKind, string> = {
13  action: '⚑  N E E D S   Y O U',
14  ask: '?  Y O U R   C A L L',
15  input: '✎  N E E D S   I N P U T',
16  secret: '✱  K E Y   N E E D E D',
17  review: '◇  W O R T H   A   L O O K',
18  done: '✓  D O N E',
19}
20
21/** One callout as it sits in the reply. */
22export function calloutBlock(ui: Table, c: Callout, palette: Palette, key: string): JSX.Element {
23  const { Box, Text } = ui
24  if (c.kind === 'done') {
25    return (
26      <Box key={key} flexDirection="column" marginTop={1}>
27        <Text key={`${key}-label`} color={palette.accent} bold>
28          {LABELS.done}
29        </Text>
30        {c.title && (
31          <Text key={`${key}-title`} color={palette.text} bold>
32            {c.title}
33          </Text>
34        )}
35        {c.body.map((line, i) => (
36          <Text key={`${key}-body-${i}`} color={palette.text}>
37            {line || ' '}
38          </Text>
39        ))}
40      </Box>
41    )
42  }
43  if (c.kind === 'review') {
44    return (
45      <Box key={key} flexDirection="column" marginTop={1} paddingX={1} borderStyle="round" borderColor={VIOLET}>
46        <Text key={`${key}-label`} color={VIOLET} bold>
47          {LABELS.review}
48        </Text>
49        <Text key={`${key}-title`} color={palette.text} bold>
50          {c.title}
51        </Text>
52        {c.body.map((line, i) => (
53          <Text key={`${key}-body-${i}`} color={palette.text}>
54            {line || ' '}
55          </Text>
56        ))}
57        <Text key={`${key}-hint`} color={palette.muted} italic>
58          Mark it seen above the prompt
59        </Text>
60      </Box>
61    )
62  }
63  const fill = fillOf(c.kind, palette)
64  const hint =
65    c.kind === 'action'
66      ? 'Answer above the prompt: Done'
67      : c.kind === 'ask'
68        ? 'Pick an answer above the prompt'
69        : c.kind === 'secret'
70          ? 'Paste it above the prompt. It goes into the file, never into the chat.'
71          : 'Type it above the prompt'
72  return (
73    <Box key={key} flexDirection="column" marginTop={1} paddingX={1} backgroundColor={fill}>
74      <Text key={`${key}-label`} color={INK} backgroundColor={fill} bold>
75        {LABELS[c.kind]}
76      </Text>
77      <Text key={`${key}-title`} color={INK} backgroundColor={fill} bold>
78        {c.title}
79      </Text>
80      {c.body.map((line, i) => (
81        <Text key={`${key}-body-${i}`} color={INK} backgroundColor={fill}>
82          {line || ' '}
83        </Text>
84      ))}
85      {c.options.map((option, i) => (
86        <Text key={`${key}-opt-${i}`} color={INK} backgroundColor={fill}>
87          {`  ${String.fromCharCode(97 + i)}  ${option}`}
88        </Text>
89      ))}
90      <Text key={`${key}-hint`} color={INK} backgroundColor={fill} italic>
91        {hint}
92      </Text>
93    </Box>
94  )
95}
96
97export type BandInput = {
98  ui: Table
99  open: Callout[]
100  palette: Palette
101  columns: number
102  /** Dots to show for each SECRET's field, by its index in `open`. */
103  masked: Record<number, number>
104  /** Send `text` as the person's message for item `index`. */
105  answer: (index: number, text: string) => void
106  /** Drop item `index` without sending anything. */
107  dismiss: (index: number) => void
108  secretInput: (index: number, value: string) => void
109  secretSubmit: (index: number) => void
110}
111
112const ICONS: Record<CalloutKind, string> = { action: '⚑', ask: '?', input: '✎', secret: '✱', review: '◇', done: '✓' }
113
114/** Where each kind sits in the band: blockers, then questions, then things worth a look. */
115const RANK: Record<CalloutKind, number> = { action: 0, secret: 1, ask: 2, input: 3, review: 4, done: 5 }
116
117/** The header's tiers: which kinds each counts and how it reads for a count. */
118const TIERS: { kinds: CalloutKind[]; icon: string; say: (n: number) => string }[] = [
119  { kinds: ['action', 'secret'], icon: '⚑', say: n => `${n} ${n === 1 ? 'NEEDS' : 'NEED'} YOU` },
120  { kinds: ['ask', 'input'], icon: '?', say: n => `${n} ${n === 1 ? 'QUESTION' : 'QUESTIONS'}` },
121  { kinds: ['review'], icon: '◇', say: n => `${n} TO LOOK AT` },
122]
123
124/** `text` broken at spaces into lines of at most `width` cells; a word longer than that is split. */
125export function wrapText(text: string, width: number): string[] {
126  const room = Math.max(8, width)
127  const lines: string[] = []
128  let line = ''
129  for (const word of text.split(/\s+/).filter(Boolean)) {
130    let rest = word
131    while (rest.length > room) {
132      if (line) lines.push(line)
133      lines.push(rest.slice(0, room))
134      line = ''
135      rest = rest.slice(room)
136    }
137    if (!line) line = rest
138    else if (line.length + 1 + rest.length <= room) line = `${line} ${rest}`
139    else {
140      lines.push(line)
141      line = rest
142    }
143  }
144  if (line) lines.push(line)
145  return lines.length > 0 ? lines : ['']
146}
147
148/**
149 * Everything still open, above the prompt: a header with one chip per tier and its count,
150 * then each item in full, blockers first, questions next, things worth a look last. Each
151 * question wraps onto as many rows as it needs and each option sits on its own row. Nothing is cut: a band taller than the room scrolls. The first item's buttons take
152 * the hotkeys: letters, which fire only while the band holds the focus (ctrl+x tab or a
153 * click). Never digits: the engine lets a bare digit in an empty prompt press a band
154 * Button, so a message starting "1." would answer the band instead of reaching the chat.
155 */
156export function band(p: BandInput): JSX.Element | null {
157  const { Box, Text, Button, Input } = p.ui
158  if (p.open.length === 0) return null
159  const width = Math.max(20, p.columns - 2)
160  // A chip with no fill is the quiet one: muted text, no background.
161  const chip = (text: string, fill?: string): JSX.Element => (
162    <Text color={fill ? INK : p.palette.muted} backgroundColor={fill} bold={fill !== undefined}>
163      {` ${text} `}
164    </Text>
165  )
166  const heads: JSX.Element[] = []
167  for (const tier of TIERS) {
168    const n = p.open.filter(c => tier.kinds.includes(c.kind)).length
169    if (n === 0) continue
170    const fill = fillOf(tier.kinds[0] ?? 'action', p.palette)
171    heads.push(
172      <Text key={`head-${tier.kinds[0]}`} color={INK} backgroundColor={fill} bold>
173        {` ${tier.icon} ${tier.say(n)} `}
174      </Text>,
175    )
176  }
177  // Drawn in tier order, each keeping its index in `open`: the callbacks and keys use that one.
178  const order = [...p.open.entries()].sort(([a, x], [b, y]) => RANK[x.kind] - RANK[y.kind] || a - b)
179  const rows: JSX.Element[] = []
180  for (const [at, [i, c]] of order.entries()) {
181    const first = at === 0
182    const fill = fillOf(c.kind, p.palette)
183    const hot = (key: string): { hotkey?: string } => (first ? { hotkey: key } : {})
184    const later = (
185      <Button key={`later-${i}`} {...hot('x')} onPress={() => p.dismiss(i)}>
186        {chip(first ? 'x  Not now' : 'Not now')}
187      </Button>
188    )
189    for (const [n, text] of wrapText(c.title, width - 2).entries()) {
190      rows.push(
191        <Box key={`title-${i}-${n}`} flexDirection="row" gap={1}>
192          <Text color={fill} bold>
193            {n === 0 ? ICONS[c.kind] : ' '}
194          </Text>
195          <Text color={p.palette.text} bold={first}>
196            {text}
197          </Text>
198        </Box>,
199      )
200    }
201    if (c.kind === 'action') {
202      rows.push(
203        <Box key={`answers-${i}`} flexDirection="row" gap={2} paddingLeft={2}>
204          <Button key={`done-${i}`} {...hot('d')} onPress={() => p.answer(i, `Done: ${c.title}`)}>
205            {chip(first ? 'd  Done' : 'Done', fill)}
206          </Button>
207          {later}
208        </Box>,
209      )
210    } else if (c.kind === 'ask') {
211      for (const [n, option] of c.options.slice(0, 9).entries()) {
212        const label = String.fromCharCode(97 + n)
213        const lines = wrapText(option, width - 2 - (label.length + 2) - 1)
214        rows.push(
215          <Box key={`opt-${i}-${n}`} flexDirection="row" gap={1} paddingLeft={2}>
216            <Button key={`opt-btn-${i}-${n}`} label={option} {...hot(label)} onPress={() => p.answer(i, option)}>
217              {chip(label, fill)}
218            </Button>
219            <Text color={p.palette.text}>{lines[0]}</Text>
220          </Box>,
221        )
222        for (const [k, more] of lines.slice(1).entries()) {
223          rows.push(
224            <Box key={`opt-${i}-${n}-${k}`} flexDirection="row" paddingLeft={2 + label.length + 3}>
225              <Text color={p.palette.text}>{more}</Text>
226            </Box>,
227          )
228        }
229      }
230      rows.push(
231        <Box key={`answers-${i}`} flexDirection="row" paddingLeft={2}>
232          {later}
233        </Box>,
234      )
235    } else if (c.kind === 'input') {
236      rows.push(
237        <Box key={`answers-${i}`} flexDirection="row" gap={2} paddingLeft={2}>
238          <Input key={`input-${i}`} placeholder="type here" submitLabel="send" onSubmit={value => value.trim() && p.answer(i, value.trim())} />
239          {later}
240        </Box>,
241      )
242    } else if (c.kind === 'secret') {
243      const where = c.secret ? `saved to ${c.secret.path}, never sent to the chat` : 'the title names no .env file, so it cannot be saved'
244      rows.push(
245        <Box key={`answers-${i}`} flexDirection="row" gap={2} paddingLeft={2}>
246          {c.secret ? (
247            <Input
248              key={`secret-${i}`}
249              placeholder="paste the key"
250              value={'•'.repeat(p.masked[i] ?? 0)}
251              submitLabel="save"
252              onInput={value => p.secretInput(i, value)}
253              onSubmit={() => p.secretSubmit(i)}
254            />
255          ) : null}
256          {later}
257        </Box>,
258      )
259      for (const [k, text] of wrapText(where, width - 2).entries()) {
260        rows.push(
261          <Box key={`where-${i}-${k}`} flexDirection="row" paddingLeft={2}>
262            <Text color={p.palette.muted}>{text}</Text>
263          </Box>,
264        )
265      }
266    } else if (c.kind === 'review') {
267      rows.push(
268        <Box key={`answers-${i}`} flexDirection="row" paddingLeft={2}>
269          <Button key={`seen-${i}`} {...hot('s')} onPress={() => p.dismiss(i)}>
270            {chip(first ? 's  Seen' : 'Seen', fill)}
271          </Button>
272        </Box>,
273      )
274    }
275  }
276  return (
277    <Box key="callouts-band" flexDirection="column">
278      <Box key="callout-head" flexDirection="row" gap={1}>
279        {heads}
280      </Box>
281      {rows}
282    </Box>
283  )
284}
285
hooks/palette.ts 51 lines
1// The colours callouts draw with: the palette picked in Devdeck, read from its theme.json,
2// each token checked on its own. A copy of the devdeck mod's reader, so neither needs the other.
3import type { CalloutKind, Palette } from '../types'
4
5export const DEFAULT_PALETTE: Palette = {
6  accent: '#fde047',
7  activity: '#f5a524',
8  text: '#ecebe4',
9  muted: '#8a887f',
10  line: '#3d3c38',
11  error: '#f87171',
12}
13
14/** Text on the accent fill: near black, so yellow cards read at a glance. */
15export const INK = '#1c1b19'
16
17/** The question tier's fill: ASK, INPUT and the REVIEW outline. */
18export const VIOLET = '#a78bfa'
19
20/** The colour a callout draws in: yellow for what blocks, violet for questions and reviews. */
21export function fillOf(kind: CalloutKind, palette: Palette): string {
22  return kind === 'ask' || kind === 'input' || kind === 'review' ? VIOLET : palette.accent
23}
24
25const TOKENS = Object.keys(DEFAULT_PALETTE) as (keyof Palette)[]
26const HEX = /^#[0-9a-fA-F]{6}$/
27const THEME_FILE = 'devdeck/theme.json'
28
29export function themePath(xdgConfigHome: string | undefined, home: string | undefined): string | null {
30  if (xdgConfigHome?.startsWith('/')) return `${xdgConfigHome.replace(/\/+$/, '')}/${THEME_FILE}`
31  if (home?.startsWith('/')) return `${home.replace(/\/+$/, '')}/.config/${THEME_FILE}`
32  return null
33}
34
35export function parsePalette(text: string | null): Palette {
36  let raw: unknown = null
37  try {
38    raw = text === null ? null : JSON.parse(text)
39  } catch {
40    raw = null
41  }
42  const colors = typeof raw === 'object' && raw !== null ? (raw as Record<string, unknown>).colors : null
43  const given = typeof colors === 'object' && colors !== null ? (colors as Record<string, unknown>) : {}
44  const out = { ...DEFAULT_PALETTE }
45  for (const token of TOKENS) {
46    const value = given[token]
47    if (typeof value === 'string' && HEX.test(value)) out[token] = value.toLowerCase()
48  }
49  return out
50}
51
hooks/parse.ts 87 lines
1// Finds callout blocks in a reply's markdown. A block is a run of quoted lines whose first
2// reads `> [!ACTION] title` (or ASK, INPUT, SECRET, REVIEW, DONE). Everything else stays
3// markdown, in order.
4import type { Callout, CalloutKind } from '../types'
5
6export type Segment = { kind: 'markdown'; text: string } | { kind: 'callout'; callout: Callout }
7
8const MARKER = /^\s*>\s*\[!(ACTION|ASK|INPUT|SECRET|REVIEW|DONE)\][ \t]*(.*)$/i
9const QUOTED = /^\s*>/
10const ITEM = /^[-*]\s+(.+)$/
11
12/** The reply split into markdown and callouts. One markdown segment when it holds none. */
13export function parseCallouts(text: string): Segment[] {
14  const lines = text.split('\n')
15  const out: Segment[] = []
16  let prose: string[] = []
17  const flush = (): void => {
18    const md = prose.join('\n').replace(/^\n+|\n+$/g, '')
19    if (md.trim()) out.push({ kind: 'markdown', text: md })
20    prose = []
21  }
22  for (let i = 0; i < lines.length; i++) {
23    const m = MARKER.exec(lines[i] ?? '')
24    if (!m) {
25      prose.push(lines[i] ?? '')
26      continue
27    }
28    flush()
29    const callout: Callout = { kind: (m[1] ?? 'action').toLowerCase() as CalloutKind, title: (m[2] ?? '').trim(), body: [], options: [] }
30    while (i + 1 < lines.length && QUOTED.test(lines[i + 1] ?? '') && !MARKER.test(lines[i + 1] ?? '')) {
31      i++
32      const line = (lines[i] ?? '').replace(/^\s*>\s?/, '').trimEnd()
33      const item = ITEM.exec(line.trim())
34      if (callout.kind === 'ask' && item) callout.options.push((item[1] ?? '').trim())
35      else if (line.trim() || callout.body.length) callout.body.push(line)
36    }
37    while (callout.body.length && !callout.body[callout.body.length - 1]?.trim()) callout.body.pop()
38    if (!callout.title && callout.body.length) callout.title = (callout.body.shift() ?? '').trim()
39    if (callout.kind === 'secret') {
40      const target = secretTarget(callout.title)
41      if (target) callout.secret = target
42    }
43    out.push({ kind: 'callout', callout })
44  }
45  flush()
46  return out
47}
48
49const SECRET_TITLE = /^`?([A-Z][A-Z0-9_]{1,63})`?\s+(?:in|to|into)\s+`?([^\s`]+)`?/
50
51/**
52 * The variable and file a SECRET names: `OPENROUTER_API_KEY in apps/web/.env.local`. Only a
53 * `.env` file inside the working directory: no absolute path, no `..`, so a reply can never
54 * point a key at another file.
55 */
56export function secretTarget(title: string): { name: string; path: string } | undefined {
57  const m = SECRET_TITLE.exec(title.trim())
58  if (!m) return undefined
59  const path = m[2] ?? ''
60  const base = path.split('/').pop() ?? ''
61  if (path.startsWith('/') || path.startsWith('~') || path.split('/').includes('..') || !/^\.env(\.[\w.-]+)?$/.test(base)) return undefined
62  return { name: m[1] ?? '', path }
63}
64
65/** `text` with the line for `name` set to `value`, added at the end when there is none. */
66export function upsertEnv(text: string, name: string, value: string): string {
67  const line = `${name}=${/[\s#"'\\$`]/.test(value) ? JSON.stringify(value) : value}`
68  const lines = text.split('\n')
69  const at = lines.findIndex(l => new RegExp(`^\\s*(?:export\\s+)?${name}\\s*=`).test(l))
70  if (at >= 0) lines[at] = line
71  else {
72    if (lines.length && lines[lines.length - 1] === '') lines.pop()
73    lines.push(line, '')
74  }
75  return lines.join('\n')
76}
77
78/** The blocks that wait on the person: every ACTION, ASK, INPUT, SECRET and REVIEW. */
79export const openOf = (segments: readonly Segment[]): Callout[] =>
80  segments.flatMap(s => (s.kind === 'callout' && s.callout.kind !== 'done' ? [s.callout] : []))
81
82/** The message a press sends back for this callout. */
83export function answerText(c: Callout, answer?: string): string {
84  if (c.kind === 'action') return `Done: ${c.title}`
85  return answer ?? ''
86}
87
types/index.d.ts 38 lines
1// Callouts: the blocks a reply marks for the person, and the colours they draw in.
2
3export type CalloutKind = 'action' | 'ask' | 'input' | 'secret' | 'review' | 'done'
4
5export type Callout = {
6  kind: CalloutKind
7  /** The first line after the marker. */
8  title: string
9  /** The quoted lines under it, list items of an ASK excluded. */
10  body: string[]
11  /** An ASK's list items: the answers to offer. */
12  options: string[]
13  /** A SECRET's variable and the .env file it goes in; absent when the title names neither. */
14  secret?: { name: string; path: string }
15}
16
17/** The Devdeck theme's colours (theme.json `colors`), every token `#rrggbb`. */
18export type Palette = {
19  accent: string
20  activity: string
21  text: string
22  muted: string
23  line: string
24  error: string
25}
26
27declare module 'claude-code' {
28  interface PluginState {
29    callouts: {
30      /** ACTION, ASK, INPUT, SECRET and REVIEW blocks of the last reply, until answered or dismissed. */
31      open: Callout[]
32      palette: Palette
33      /** How many characters each SECRET's field holds, by item key; never the characters. */
34      typed: Record<string, number>
35    }
36  }
37}
38