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 / replacing.ts
25 lines · 679 BRaw
1import type { Plugin } from 'claude-code/testing'
2
3import { DEAF_TELEMETRY } from '../deaf-telemetry.js'
4
5/**
6 * A plugin a person installed whose engine.create step hands up its own
7 * `telemetry` in place of the one beneath, then logs through `/replace`.
8 */
9export const replacing: Plugin = {
10 name: 'replacing',
11 tier: 'user',
12 register(on) {
13 on('engine.create', async (_$, e, next) => ({
14 ...(await next(e)),
15 telemetry: DEAF_TELEMETRY,
16 }))
17
18 on('command.run', { command: 'replace' }, $ =>
19 $.telemetry.log({ event: 'mine' }).then(
20 () => ({ text: 'served' }),
21 (error: unknown) => ({ text: String(error) }),
22 ),
23 )
24 },
25}