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,0 +1,13 @@ | ||
| 1 | +import type { CommandRunInput } from 'claude-code' | |
| 2 | + | |
| 3 | +import { FULLSCREEN } from './fullscreen.js' | |
| 4 | + | |
| 5 | +/** | |
| 6 | + * `/export` as the person types it: the exporting plugin's command. | |
| 7 | + */ | |
| 8 | +export const EXPORT_COMMAND: CommandRunInput = { | |
| 9 | + command: 'export', | |
| 10 | + args: '', | |
| 11 | + origin: { kind: 'composer' }, | |
| 12 | + presentation: FULLSCREEN, | |
| 13 | +} |
| @@ -1,0 +1,18 @@ | ||
| 1 | +import type { Plugin } from 'claude-code/testing' | |
| 2 | + | |
| 3 | +/** | |
| 4 | + * A built-in whose `/export` logs two records for the collector, `kept` and | |
| 5 | + * `withheld`, and says so. | |
| 6 | + */ | |
| 7 | +export const exporting: Plugin = { | |
| 8 | + name: 'exporting', | |
| 9 | + tier: 'builtin', | |
| 10 | + register(on) { | |
| 11 | + on('command.run', { command: 'export' }, async $ => { | |
| 12 | + await $.telemetry.log({ to: 'collector', event: 'kept' }) | |
| 13 | + await $.telemetry.log({ to: 'collector', event: 'withheld' }) | |
| 14 | + | |
| 15 | + return { text: 'exported' } | |
| 16 | + }) | |
| 17 | + }, | |
| 18 | +} |
| @@ -4,6 +4,8 @@ | ||
| 4 | 4 | export * from './command-described.js' |
| 5 | 5 | export * from './denying.js' |
| 6 | 6 | export * from './dropping.js' |
| 7 | +export * from './export-command.js' | |
| 8 | +export * from './exporting.js' | |
| 7 | 9 | export * from './fullscreen.js' |
| 8 | 10 | export * from './listing.js' |
| 9 | 11 | export * from './managed-policy.js' |
| @@ -8,9 +8,9 @@ | ||
| 8 | 8 | name: 'withholding', |
| 9 | 9 | register(on) { |
| 10 | 10 | on('telemetry.log', { to: 'collector' }, ($, e, next) => |
| 11 | - e.to === 'collector' && e.event !== 'withheld' | |
| 12 | - ? next({ ...e, attributes: { ...e.attributes, edited: true } }) | |
| 13 | - : { deny: 'kept from the collector' }, | |
| 11 | + e.event === 'withheld' | |
| 12 | + ? { deny: 'kept from the collector' } | |
| 13 | + : next({ ...e, props: { ...e.props, edited: true } }), | |
| 14 | 14 | ) |
| 15 | 15 | }, |
| 16 | 16 | } |
| @@ -139,27 +139,16 @@ | ||
| 139 | 139 | |
| 140 | 140 | test( |
| 141 | 141 | 'a collector record passes over the plugins the person installed', |
| 142 | - { plugins: [Fixtures.withholding] }, | |
| 142 | + { plugins: [Fixtures.withholding, Fixtures.exporting] }, | |
| 143 | 143 | async ($, on) => { |
| 144 | 144 | const reached: unknown[] = [] |
| 145 | 145 | on('telemetry.log', { to: 'collector' }, ($, e) => { |
| 146 | - reached.push([e.event, e.to === 'collector' && e.attributes.edited]) | |
| 146 | + reached.push([e.event, e.props?.edited]) | |
| 147 | 147 | |
| 148 | 148 | return { value: undefined } |
| 149 | 149 | }) |
| 150 | 150 | |
| 151 | - await $.telemetry.log({ | |
| 152 | - to: 'collector', | |
| 153 | - event: 'kept', | |
| 154 | - attributes: {}, | |
| 155 | - loggedAt: '2026-09-26T10:00:00.000Z', | |
| 156 | - }) | |
| 157 | - await $.telemetry.log({ | |
| 158 | - to: 'collector', | |
| 159 | - event: 'withheld', | |
| 160 | - attributes: {}, | |
| 161 | - loggedAt: '2026-09-26T10:00:01.000Z', | |
| 162 | - }) | |
| 151 | + await $.command.run(Fixtures.EXPORT_COMMAND) | |
| 163 | 152 | |
| 164 | 153 | expect(reached).toEqual([ |
| 165 | 154 | ['kept', undefined], |