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