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
| 1 | import Probes from '../probes' |
| 2 | import type Types from '../types' |
| 3 | import { diffDataOf } from './diff-data-of' |
| 4 | import { unbornTier } from './unborn-tier' |
| 5 | import { withUntracked } from './with-untracked' |
| 6 | import { WORKING_TREE_BASIS } from './working-tree-basis' |
| 7 | |
| 8 | /** |
| 9 | * Session and uncommitted mode: the working tree against HEAD, the built-in |
| 10 | * panel's working-tree tier. |
| 11 | * |
| 12 | * Session mode tags the rows that predate the session and keeps |
| 13 | * pre-session untracked files as tagged rows; uncommitted keeps the |
| 14 | * session's untracked files and answers even when empty. |
| 15 | * |
| 16 | * @param context the fetch |
| 17 | * @returns the outcome |
| 18 | */ |
| 19 | export async function workingTreeTier( |
| 20 | context: Types.FetchContext, |
| 21 | ): Promise<Types.FetchOutcome> { |
| 22 | const workingTree = await Probes.statsOf(context, 'HEAD') |
| 23 | |
| 24 | if (!workingTree) { |
| 25 | return unbornTier(context) |
| 26 | } |
| 27 | |
| 28 | const isSession = context.mode === 'session' |
| 29 | const files = isSession |
| 30 | ? await Probes.tagPreSession(context, workingTree.files) |
| 31 | : workingTree.files |
| 32 | const data = diffDataOf( |
| 33 | context, |
| 34 | await withUntracked( |
| 35 | context, |
| 36 | { stats: workingTree.stats, files }, |
| 37 | isSession ? 'with-pre-session' : 'session-only', |
| 38 | ), |
| 39 | WORKING_TREE_BASIS, |
| 40 | ) |
| 41 | |
| 42 | return { kind: 'data', data } |
| 43 | } |