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 / agents-md / tests / fixtures / started-of.ts
36 lines · 964 BRaw
1import type { On } from 'claude-code'
2import { mock } from 'claude-code/testing'
3
4import { SESSION } from './session.js'
5import type { Started, ToastAsked } from './types'
6
7/**
8 * A session that starts untouched beneath the plugins, rooted at SESSION's
9 * working directory, every toast and transcript line they raise kept for the
10 * test to read, on a mock clock the test settles before it reads them.
11 *
12 * @param on the test's `on`
13 * @returns the toasts, lines and walks raised, in order, and the clock
14 */
15export function startedOf(on: On): Started {
16 const toasts: ToastAsked[] = []
17 const lines: string[] = []
18
19 on('session.start', ($, e) => ({ cwd: e.cwd }))
20
21 on('session.root', () => ({ value: SESSION.cwd }))
22
23 on('ui.toast', ($, e) => {
24 toasts.push(e)
25
26 return { value: undefined }
27 })
28
29 on('ui.log', ($, e) => {
30 lines.push(e.text)
31
32 return { value: undefined }
33 })
34
35 return { toasts, lines, walks: [], clock: mock.clock(on) }
36}