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
| @@ -1,29 +1,38 @@ | ||
| 1 | 1 | import type { Plugin } from 'claude-code/testing' |
| 2 | 2 | |
| 3 | 3 | /** |
| 4 | - * A plugin standing in for the telemetry built-in: it adds the `telemetry` | |
| 5 | - * noun at `engine.create` over the nouns beneath. | |
| 4 | + * A plugin standing in for the telemetry built-in: it hooks `telemetry.log` | |
| 5 | + * and `telemetry.mark` and answers them without going on. | |
| 6 | 6 | * |
| 7 | - * Its `log` and `mark` write the entry they are handed as one `$.ui.log` | |
| 8 | - * line, `<op> <json>`, which startedOf keeps and rowsOf reads back. | |
| 7 | + * Each writes the entry as the caller handed it (`to` left off) as one | |
| 8 | + * `$.ui.log` line, `<op> <json>`, which startedOf keeps and rowsOf reads | |
| 9 | + * back. Where the engine has no `telemetry` its engine.create step adds one. | |
| 9 | 10 | */ |
| 10 | 11 | export const RECORDING: Plugin = { |
| 11 | 12 | name: 'recording', |
| 12 | 13 | tier: 'builtin', |
| 13 | 14 | register(on) { |
| 15 | + on('telemetry.log', async ($, e) => { | |
| 16 | + const { to: _to, ...entry } = e | |
| 17 | + | |
| 18 | + await $.ui.log(`log ${JSON.stringify(entry)}`) | |
| 19 | + | |
| 20 | + return { value: undefined } | |
| 21 | + }) | |
| 22 | + | |
| 23 | + on('telemetry.mark', async ($, e) => { | |
| 24 | + await $.ui.log(`mark ${JSON.stringify(e)}`) | |
| 25 | + | |
| 26 | + return { value: undefined } | |
| 27 | + }) | |
| 28 | + | |
| 14 | 29 | on('engine.create', async ($, e, next) => { |
| 15 | 30 | const beneath = await next(e) |
| 16 | - const built = { ...beneath } | |
| 17 | - built.telemetry = { | |
| 18 | - log: async entry => { | |
| 19 | - await beneath.ui.log(`log ${JSON.stringify(entry)}`) | |
| 20 | - }, | |
| 21 | - mark: async entry => { | |
| 22 | - await beneath.ui.log(`mark ${JSON.stringify(entry)}`) | |
| 23 | - }, | |
| 31 | + const added = { | |
| 32 | + telemetry: { log: async () => undefined, mark: async () => undefined }, | |
| 24 | 33 | } |
| 25 | 34 | |
| 26 | - return built | |
| 35 | + return { ...added, ...beneath } | |
| 27 | 36 | }) |
| 28 | 37 | }, |
| 29 | 38 | } |