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 / hooks / telemetry / load-counts-of.ts
35 lines · 969 BRaw
1import type { InstructionFile } from 'claude-code'
2
3import type { LoadCounts } from './types'
4
5/**
6 * The first context's counts from the files it added: an entry with a parent
7 * is an `@` import, one without is an AGENTS.md file.
8 *
9 * @param added the AGENTS.md instruction files handed to the engine, imports
10 * among them
11 * @param isYielded whether `claude-md-or-agents-md` stood down for a CLAUDE.md
12 * @param isWalkFailed whether the walk threw
13 * @returns the counts the load row and mark are built from
14 */
15export function loadCountsOf(
16 added: readonly InstructionFile[],
17 isYielded: boolean,
18 isWalkFailed: boolean,
19): LoadCounts {
20 const importCount = added.reduce(
21 (sum, file) => sum + (file.parent === undefined ? 0 : 1),
22 0,
23 )
24
25 return {
26 fileCount: added.length - importCount,
27 importCount,
28 totalContentLength: added.reduce(
29 (sum, file) => sum + file.content.length,
30 0,
31 ),
32 isYielded,
33 isWalkFailed,
34 }
35}