mirror of
https://github.com/anthropics/claude-code.git
synced 2026-10-02 05:25:05 +08:00
* telemetry: the test plugins a person installed hook and call the collector's stream by name * agents-md: the test plugin standing in for telemetry hooks its two events, adding the noun only where the engine has none
50 lines
1.3 KiB
TypeScript
50 lines
1.3 KiB
TypeScript
import type { Plugin } from 'claude-code/testing'
|
|
|
|
/**
|
|
* A plugin a person installed that reaches for `$.telemetry` every way it
|
|
* can; `/reach` says how the first went, the debug log the other two.
|
|
*
|
|
* On the table its engine.create step is handed, from a timer its
|
|
* session.start sets, and from a tool.call hook.
|
|
*/
|
|
export const reaching: Plugin = {
|
|
name: 'reaching',
|
|
tier: 'user',
|
|
register(on) {
|
|
let during = 'not called'
|
|
|
|
on('engine.create', async (_$, e, next) => {
|
|
const beneath = await next(e)
|
|
|
|
during = await beneath.telemetry
|
|
.log({ to: 'collector', event: 'during_create' })
|
|
.then(() => 'served', String)
|
|
|
|
return beneath
|
|
})
|
|
|
|
on('session.start', ($, e, next) => {
|
|
$.clock.after(1, () => {
|
|
void $.telemetry
|
|
.log({ to: 'collector', event: 'from_timer' })
|
|
.then(() => 'served', String)
|
|
.then(outcome => $.ui.log(`timer: ${outcome}`, { to: 'debug' }))
|
|
})
|
|
|
|
return next(e)
|
|
})
|
|
|
|
on('tool.call', { tool: 'Read' }, async ($, e, next) => {
|
|
const outcome = await $.telemetry
|
|
.log({ to: 'collector', event: 'from_tool' })
|
|
.then(() => 'served', String)
|
|
|
|
await $.ui.log(`tool: ${outcome}`, { to: 'debug' })
|
|
|
|
return next(e)
|
|
})
|
|
|
|
on('command.run', { command: 'reach' }, () => ({ text: during }))
|
|
},
|
|
}
|