Skip to content

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.

TypeScript
922 B
Raw Blame
import type { FsAncestor, On } from 'claude-code'

import { startedOf } from './started-of.js'
import type { Started } from './types'

/**
 * A project whose walks up from the working directory find the given files,
 * one list per set of names, its session starting untouched (startedOf);
 * each walk's first name is kept in `walks`.
 *
 * @param on the test's `on`
 * @param agents what a walk for AGENTS.md and .claude/AGENTS.md finds
 * @param claude what a walk for CLAUDE.md, .claude/CLAUDE.md and
 * CLAUDE.local.md finds
 * @returns the toasts, lines and walks the plugins raised, in order
 */
export function projectOf(
  on: On,
  agents: readonly FsAncestor[],
  claude: readonly FsAncestor[],
): Started {
  const started = startedOf(on)

  on('fs.ancestors', ($, e) => {
    started.walks.push(e.names[0] ?? '')

    return { value: e.names.includes('AGENTS.md') ? agents : claude }
  })

  return started
}