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

agents-md: the test plugin standing in for telemetry hooks its two events, adding the noun only where the engine has noneBrowse files
poteat authored 29 days ago parent 6239bb5 · commit 4b4e2ce86b36
1 changed file+22 -13compared with 6239bb5
Mmods/agents-md/tests/fixtures/recording.ts
@@ -1,29 +1,38 @@
11 import type { Plugin } from 'claude-code/testing'
22
33 /**
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.
66 *
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.
910 */
1011 export const RECORDING: Plugin = {
1112 name: 'recording',
1213 tier: 'builtin',
1314 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+
1429 on('engine.create', async ($, e, next) => {
1530 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 },
2433 }
2534
26- return built
35+ return { ...added, ...beneath }
2736 })
2837 },
2938 }