spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / telemetry / tests / fixtures / plugins / reaching.ts
49 lines · 1.3 KBRaw
1import type { Plugin } from 'claude-code/testing'
2
3/**
4 * A plugin a person installed that reaches for `$.telemetry` every way it
5 * can; `/reach` says how the first went, the debug log the other two.
6 *
7 * On the table its engine.create step is handed, from a timer its
8 * session.start sets, and from a tool.call hook.
9 */
10export const reaching: Plugin = {
11 name: 'reaching',
12 tier: 'user',
13 register(on) {
14 let during = 'not called'
15
16 on('engine.create', async (_$, e, next) => {
17 const beneath = await next(e)
18
19 during = await beneath.telemetry
20 .log({ event: 'during_create' })
21 .then(() => 'served', String)
22
23 return beneath
24 })
25
26 on('session.start', ($, e, next) => {
27 $.clock.after(1, () => {
28 void $.telemetry
29 .log({ event: 'from_timer' })
30 .then(() => 'served', String)
31 .then(outcome => $.ui.log(`timer: ${outcome}`, { to: 'debug' }))
32 })
33
34 return next(e)
35 })
36
37 on('tool.call', { tool: 'Read' }, async ($, e, next) => {
38 const outcome = await $.telemetry
39 .log({ event: 'from_tool' })
40 .then(() => 'served', String)
41
42 await $.ui.log(`tool: ${outcome}`, { to: 'debug' })
43
44 return next(e)
45 })
46
47 on('command.run', { command: 'reach' }, () => ({ text: during }))
48 },
49}