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 / diff / hooks / record / recorder-of.ts
28 lines · 945 BRaw
1import type { Host } from '../host'
2import type { Recorder } from './recorder'
3import { safely } from './safely'
4import { SHOWN_TRIGGERS } from './shown-triggers'
5import { WIDTH_BUCKETS } from './width-buckets'
6
7/**
8 * The plugin's Recorder over the host: each row goes through the telemetry
9 * built-in's `$.telemetry`; a missing noun or a refused row is dropped.
10 *
11 * @param host the engine as session.start bound it
12 * @returns the recorder
13 */
14export const recorderOf = (host: Host): Recorder => ({
15 mark: (feature, outcome) => safely(() => host.mark({ feature, ...outcome })),
16 shown: (trigger, bucket) =>
17 safely(() =>
18 host.log({
19 event: 'diff_pane_shown',
20 props: {
21 trigger: { value: trigger, of: SHOWN_TRIGGERS },
22 width_bucket: { value: bucket, of: WIDTH_BUCKETS },
23 },
24 }),
25 ),
26 asked: lines =>
27 safely(() => host.log({ event: 'diff_ask_attach', props: { lines } })),
28})