A band above the prompt that lists the paths and //Next: lines from Claude's replies, newest 10, each with a copy button

A Claude Code mod. It draws a band above the prompt that lists the paths and the //Next: lines from Claude's replies. Each row has a button that copies the row to the clipboard.
C:\…, ~/…, /c/…), http(s) URLs, relative paths in inline code (hooks/register.tsx:12), and the body of the fenced block after //Next:.//Next: row also has a ▶ button. It copies the line, clears the prompt, and sends the line as your prompt. A line that starts with / is a slash command: ▶ only puts it in the prompt, and you press Enter.▲ and ▼ page through the rest, 5 rows at a time. A new reply scrolls back to the top.//Next: line. The engine's [-] mark collapses it./plugin install copy-list --marketplace Crinitys/copy-list
Answer y to add the marketplace, then pick the user scope.
claude plugin test .hooks/register.tsx 113 lines1import { atom, read, update } from 'claude-code'
2import type { Register } from 'claude-code'
3
4import { MAX, extract, merge } from './extract.ts'
5
6// Rows of clips the band shows at once; ▲ and ▼ page through the rest.
7const ROWS = 5
8const clips = atom({ plugin: 'copy-list', key: 'clips' } as const, [])
9const offset = atom({ plugin: 'copy-list', key: 'offset' } as const, 0)
10// A short result line in the band's header, in place of a toast.
11const notice = atom({ plugin: 'copy-list', key: 'notice' } as const, '')
12
13export const register: Register = on => {
14 on('turn.complete', async ($, e, next) => {
15 // Main loop only: subagent reports are not what the person reads.
16 if (!e.agentId && e.answer) {
17 const added = extract(e.answer)
18 if (added.length > 0) {
19 await update($, clips, list => merge(list, added))
20 await update($, offset, () => 0)
21 }
22 }
23
24 return next(e)
25 })
26
27 on('ui.render', { component: 'AbovePrompt' }, async ($, e, next) => {
28 const list = await read($, clips)
29 if (e.props.hasSurvey || list.length === 0) {
30 return next(e)
31 }
32
33 const { Box, Button, Text } = $.ui.resolve(e)
34 const newest = [...list].reverse()
35 const last = Math.max(0, Math.floor((newest.length - 1) / ROWS) * ROWS)
36 const top = Math.min(await read($, offset), last)
37 const scroll = (by: number) => update($, offset, n => Math.max(0, Math.min(last, n + by)))
38 const say = async (text: string) => {
39 await update($, notice, () => text)
40 $.clock.after(2000, () => void update($, notice, n => (n === text ? '' : n)))
41 }
42 const said = await read($, notice)
43
44 // A blank row and a rule set the band apart from the transcript above it.
45 return (
46 <Box flexDirection="column" marginTop={1}>
47 <Text dimColor>{'─'.repeat(Math.max(1, e.props.bodyColumns))}</Text>
48 <Box justifyContent="space-between">
49 <Text>
50 <Text color="claude" bold>
51 ⧉ COPY LIST
52 </Text>
53 <Text dimColor>
54 {' '}
55 {top + 1}-{Math.min(top + ROWS, newest.length)} of {newest.length}/{MAX}
56 </Text>
57 </Text>
58 <Box>
59 {said !== '' && <Text color={said.startsWith('✓') ? 'success' : 'error'}>{said} </Text>}
60 {newest.length > ROWS && (
61 <Box>
62 <Button key="up" label="▲" onPress={() => scroll(-ROWS)} />
63 <Button key="down" label="▼" onPress={() => scroll(ROWS)} />
64 </Box>
65 )}
66 </Box>
67 </Box>
68 {newest.slice(top, top + ROWS).map((clip, n) => {
69 const i = top + n
70 return (
71 <Box key={`row:${i}`}>
72 <Button
73 key={`copy:${i}`}
74 label={clip.kind === 'next' ? 'Next' : clip.kind === 'url' ? 'URL' : 'Path'}
75 variant={clip.kind === 'next' ? 'primary' : undefined}
76 onPress={async press => {
77 const done = await $.ui.copy({ text: clip.text, surface: press.surface })
78 await say(done.isCopied ? '✓ Copied' : `✗ Copy failed: ${done.reason}`)
79 }}
80 />
81 {clip.kind === 'next' ? (
82 <Button
83 key={`fill:${i}`}
84 label="▶"
85 onPress={async press => {
86 await $.ui.copy({ text: clip.text, surface: press.surface })
87 // A plugin's submit does not run slash commands, so those only fill the prompt.
88 if (clip.text.startsWith('/')) {
89 const done = await $.prompt.fill({ text: clip.text, mode: 'replace' })
90 await say(done.isFilled ? '✓ In the prompt; press Enter' : `✗ Prompt fill failed: ${done.refusal ?? 'refused'}`)
91 return
92 }
93 await $.prompt.fill({ text: '', mode: 'replace' })
94 void $.prompt.submit({ text: clip.text, asUser: true })
95 await say('✓ Sent')
96 }}
97 />
98 ) : (
99 // 'URL' is one cell shorter than 'Path' and 'Next', so its row pads one more.
100 <Text>{clip.kind === 'url' ? ' ' : ' '}</Text>
101 )}
102 <Text wrap="truncate-end"> {clip.text.replace(/\s*\n\s*/g, ' ⏎ ')}</Text>
103 </Box>
104 )
105 })}
106 {/* Blank rows keep a short last page as tall as the others. */}
107 {newest.length > ROWS &&
108 Array.from({ length: top + ROWS - Math.min(top + ROWS, newest.length) }, (_, n) => <Text key={`pad:${n}`}> </Text>)}
109 </Box>
110 )
111 })
112}
113hooks/extract.ts 46 lines1import type { Clip } from '../types'
2
3export const MAX = 10
4
5// The body of each fenced block that follows a //Next: label.
6const NEXT = /\/\/Next:\s*\n\s*```[^\n]*\n([\s\S]*?)\n\s*```/g
7// Absolute Windows paths, ~/ paths and /x/ Git Bash paths.
8// The lookbehind skips URLs: "s:/" in "https://" and "/x/" inside a URL path.
9// "(?!\/)" skips a bare "s://": a drive path never starts with "X://".
10const BARE = /(?<![\w/])(?:[A-Za-z]:[\\/](?!\/)|~[\\/]|\/[a-z]\/)[^\s`'"<>|*?()\[\]]+/g
11// Inline code that looks like a relative path: has a slash and an extension or a trailing slash.
12const CODE = /`([^`\s]+)`/g
13// http(s) URLs. ASCII only, so a Korean particle after the URL stays out.
14const LINK = /\bhttps?:\/\/[\w\-.~:/?#@!$&*+,;=%]+/g
15const LOOKS_RELATIVE = /^\.{0,2}[\w.-]+(?:[\\/][\w.@-]+)+(?:\.\w+(?::\d+)?|[\\/])$/
16
17const tidy = (s: string) => s.replace(/[.,;:)\]]+$/, '')
18
19export function extract(answer: string): Clip[] {
20 const found: Clip[] = []
21 const rest = answer.replace(NEXT, (_, body: string) => {
22 found.push({ kind: 'next', text: body.trim() })
23 return ''
24 })
25 const paths = new Set<string>()
26 for (const m of rest.matchAll(BARE)) paths.add(tidy(m[0]))
27 for (const m of rest.matchAll(CODE)) {
28 const code = m[1]
29 if (code && LOOKS_RELATIVE.test(code)) paths.add(tidy(code))
30 }
31 const links = new Set<string>()
32 for (const m of rest.matchAll(LINK)) links.add(tidy(m[0]))
33 // Paths and URLs first, so the //Next: line ends up newest.
34 return [
35 ...[...paths].map(text => ({ kind: 'path' as const, text })),
36 ...[...links].map(text => ({ kind: 'url' as const, text })),
37 ...found,
38 ]
39}
40
41/** Appends new clips, moves repeats to the end, keeps the newest MAX. */
42export function merge(list: Clip[], added: Clip[]): Clip[] {
43 const keys = new Set(added.map(c => c.text))
44 return [...list.filter(c => !keys.has(c.text)), ...added].slice(-MAX)
45}
46types/index.d.ts 8 lines1export type Clip = { kind: 'path' | 'url' | 'next'; text: string }
2
3declare module 'claude-code' {
4 interface PluginState {
5 'copy-list': { clips: Clip[]; offset: number; notice: string }
6 }
7}
8