add documentation

This commit is contained in:
Osman Mehmood
2026-03-31 15:38:58 +05:00
parent b7a82da0be
commit 9024f81eb7
32 changed files with 941 additions and 2 deletions

View File

@@ -0,0 +1,78 @@
# Directory structure (`src/`)
This mirrors the **top levels** of the recovered `src/` tree. The repo also keeps `docs/directory-structure.md` at the repository root for browsing without MkDocs.
## Package root files
| File | Notes |
| --------------------------- | ----------------------------------------------------------------------------------------------- |
| `main.tsx` | CLI entry: Commander setup, `preAction` trust/settings/telemetry, routing to REPL or print mode |
| `commands.ts` | Command registry |
| `tools.ts` | Tool registry (see also `tools/` directory) |
| `Tool.ts` | Tool types / shared tool definitions |
| `QueryEngine.ts` | Model / API query pipeline |
| `context.ts` | System and user context |
| `cost-tracker.ts` | Token / cost tracking |
| `costHook.ts` | Cost hook wiring |
| `dialogLaunchers.tsx` | Ink dialogs (resume, settings, teleport, etc.) |
| `history.ts` | Input history |
| `ink.ts` | Ink root / render helpers |
| `interactiveHelpers.tsx` | Interactive UI helpers |
| `projectOnboardingState.ts` | Onboarding state |
| `query.ts` | Query helpers |
| `replLauncher.tsx` | REPL launch |
| `setup.ts` | Setup flows |
| `tasks.ts` | Task utilities / constants |
| `Task.ts` | Task types |
## Top-level directories
| Directory | Role |
| ---------------- | ----------------------------------------------------------------------- |
| `assistant/` | Assistant / KAIROS paths (bundle feature-gated) |
| `bootstrap/` | Early boot and global flags (cwd, remote mode, overrides) |
| `bridge/` | IDE integration (VS Code, JetBrains, etc.) |
| `buddy/` | Companion / buddy UI |
| `cli/` | Non-interactive / print mode, transports, NDJSON, subcommand handlers |
| `commands/` | Slash commands and related CLI command modules |
| `components/` | Ink/React UI components |
| `constants/` | Shared constants (OAuth, product URLs, etc.) |
| `context/` | Context subsystems (stats, attachments, etc.) |
| `coordinator/` | Multi-agent coordinator (feature-gated) |
| `entrypoints/` | `init` and related startup entrypoints |
| `hooks/` | React hooks for the terminal UI |
| `ink/` | Ink layout, termio, events (terminal renderer layer) |
| `keybindings/` | Keybinding definitions and providers |
| `memdir/` | Memory directory / persistent memory |
| `migrations/` | Settings and data migrations |
| `moreright/` | Internal layout / UI helper |
| `native-ts/` | Native TypeScript helpers |
| `outputStyles/` | Output styling |
| `plugins/` | Plugin loader and bundled plugins |
| `query/` | Query pipeline modules |
| `remote/` | Remote session / control |
| `schemas/` | Zod (and related) schemas |
| `screens/` | Full-screen flows (doctor, REPL shell, resume) |
| `server/` | Server / socket modes |
| `services/` | API client, MCP, compaction, LSP, analytics, OAuth, policy, etc. |
| `skills/` | Skill loading and bundled skills |
| `state/` | App state providers and reducers |
| `tasks/` | Task implementations (local agent, shell, remote, dream, etc.) |
| `tools/` | One subdirectory per agent-invokable tool |
| `types/` | Shared TypeScript types (incl. generated) |
| `upstreamproxy/` | Upstream proxy configuration |
| `utils/` | Large catch-all: permissions, settings, swarm, shell, git, telemetry, … |
| `vim/` | Vim-style editing in the terminal |
| `voice/` | Voice input |
## `services/` (second level)
Includes among others: `api/`, `mcp/`, `compact/`, `lsp/`, `oauth/`, `analytics/`, `policyLimits/`, `remoteManagedSettings/`, `plugins/`, `tools/` (service-side tool orchestration), `teamMemorySync/`, `settingsSync/`, `tips/`, `SessionMemory/`, `autoDream/`, `extractMemories/`, plus standalone `.ts` / `.tsx` files for limits, voice, notifier, etc.
## `tools/` (agent tools)
Each major capability is typically its own folder; see [Tool packages](tool-packages.md) for a full directory list.
## `utils/` (highlights)
Not exhaustive: `swarm/` (teammates, tmux/iTerm backends), `settings/` (incl. `mdm/`), `permissions/`, `shell/`, `telemetry/`, `teleport/`, `deepLink/`, `claudeInChrome/`, `computerUse/`, `messages/`, `sessionStorage.ts`, `sessionStart.ts`, `git.ts`, `config.ts`, `auth.ts`, and hundreds of focused modules.

View File

@@ -0,0 +1,41 @@
# Environment variables (code references)
!!! warning "Unofficial and incomplete"
This list is **not** a substitute for the official [Environment variables](https://code.claude.com/docs/en/env-vars) reference. It only shows names that appear in the recovered `src/` tree as `process.env.*` (or standard vars like `HOME`). Behavior and stability are defined by Anthropics product, not this mirror.
## User-facing and integration (examples found in source)
| Variable | Where used (indicative) |
| ---------------------------------- | ------------------------------------------------------------------------------------------- |
| `ANTHROPIC_BASE_URL` | API client / proxy routing (`toolSearch.ts`, auth paths) |
| `CLAUDE_CODE_GIT_BASH_PATH` | Windows Git Bash resolution (`windowsPaths.ts`) |
| `CLAUDE_DEBUG` | Debug logging (`warningHandler.ts`) |
| `CLAUDE_CODE_ENABLE_TELEMETRY` | OpenTelemetry enable (`telemetry/instrumentation.ts`) |
| `CLAUDE_CODE_ENABLE_TASKS` | Tasks mode (`tasks.ts`) |
| `CLAUDE_CODE_TASK_LIST_ID` | Default task list id (`tasks.ts`) |
| `CLAUDE_CODE_PLAN_MODE_REQUIRED` | Plan mode gate (`teammate.ts`) |
| `CLAUDE_CODE_WORKSPACE_HOST_PATHS` | Telemetry workspace mapping (`telemetry/events.ts`) |
| `ENABLE_TOOL_SEARCH` | Tool search beta (`toolSearch.ts`) |
| `GITHUB_ACTIONS` / `GITHUB_*` | CI metadata in analytics (`user.ts`) |
| `HOME` | XDG / paths (`xdg.ts`) |
| `MAX_THINKING_TOKENS` | Thinking toggle (`thinking.ts`) |
| `NODE_ENV` | Dev/test branches |
| `OTEL_*` | OpenTelemetry exporters and endpoints (`telemetry/instrumentation.ts`, `sessionTracing.ts`) |
| `SHELL` | Shell spawning (`terminalPanel.ts`, `windowsPaths.ts`) |
| `TMUX` / `TMUX_PANE` | Worktree / swarm backends (`worktree.ts`, `swarm/backends/detection.ts`) |
| `TMPDIR` | Temp paths (`tmuxSocket.ts`) |
| `USER_TYPE` | Internal Anthropic gating (`undercover.ts`, many modules) |
## Internal / experimental (often `USER_TYPE === 'ant'`)
Variables such as `CLAUDE_CODE_UNDERCOVER`, `ANT_OTEL_*`, `ANT_CLAUDE_CODE_METRICS_ENDPOINT`, `BETA_TRACING_ENDPOINT`, `CCR_FORCE_BUNDLE`, `CCR_ENABLE_BUNDLE`, and similar appear for **employee or beta** builds. Treat them as undocumented implementation details.
## Regenerate a full grep index
From the repo root:
```bash
rg -o 'process\.env\.[A-Za-z0-9_]+' src --glob '*.ts' --glob '*.tsx' | sort -u
```
The script `scripts/gen-appendices.sh` can write the output to `docs-site/docs/appendix/_generated-env-vars.txt` (gitignored) for local analysis.

View File

@@ -0,0 +1,50 @@
# Tool packages under `src/tools/`
Each row is a package directory implementing or supporting an agent tool. Names align with the public [Tools reference](https://code.claude.com/docs/en/tools-reference) where applicable.
| Package | Path |
| ---------------------- | --------------------------------- |
| `AgentTool` | `src/tools/AgentTool/` |
| `AskUserQuestionTool` | `src/tools/AskUserQuestionTool/` |
| `BashTool` | `src/tools/BashTool/` |
| `BriefTool` | `src/tools/BriefTool/` |
| `ConfigTool` | `src/tools/ConfigTool/` |
| `EnterPlanModeTool` | `src/tools/EnterPlanModeTool/` |
| `EnterWorktreeTool` | `src/tools/EnterWorktreeTool/` |
| `ExitPlanModeTool` | `src/tools/ExitPlanModeTool/` |
| `ExitWorktreeTool` | `src/tools/ExitWorktreeTool/` |
| `FileEditTool` | `src/tools/FileEditTool/` |
| `FileReadTool` | `src/tools/FileReadTool/` |
| `FileWriteTool` | `src/tools/FileWriteTool/` |
| `GlobTool` | `src/tools/GlobTool/` |
| `GrepTool` | `src/tools/GrepTool/` |
| `LSPTool` | `src/tools/LSPTool/` |
| `ListMcpResourcesTool` | `src/tools/ListMcpResourcesTool/` |
| `MCPTool` | `src/tools/MCPTool/` |
| `McpAuthTool` | `src/tools/McpAuthTool/` |
| `NotebookEditTool` | `src/tools/NotebookEditTool/` |
| `PowerShellTool` | `src/tools/PowerShellTool/` |
| `REPLTool` | `src/tools/REPLTool/` |
| `ReadMcpResourceTool` | `src/tools/ReadMcpResourceTool/` |
| `RemoteTriggerTool` | `src/tools/RemoteTriggerTool/` |
| `ScheduleCronTool` | `src/tools/ScheduleCronTool/` |
| `SendMessageTool` | `src/tools/SendMessageTool/` |
| `SkillTool` | `src/tools/SkillTool/` |
| `SleepTool` | `src/tools/SleepTool/` |
| `SyntheticOutputTool` | `src/tools/SyntheticOutputTool/` |
| `TaskCreateTool` | `src/tools/TaskCreateTool/` |
| `TaskGetTool` | `src/tools/TaskGetTool/` |
| `TaskListTool` | `src/tools/TaskListTool/` |
| `TaskOutputTool` | `src/tools/TaskOutputTool/` |
| `TaskStopTool` | `src/tools/TaskStopTool/` |
| `TaskUpdateTool` | `src/tools/TaskUpdateTool/` |
| `TeamCreateTool` | `src/tools/TeamCreateTool/` |
| `TeamDeleteTool` | `src/tools/TeamDeleteTool/` |
| `TodoWriteTool` | `src/tools/TodoWriteTool/` |
| `ToolSearchTool` | `src/tools/ToolSearchTool/` |
| `WebFetchTool` | `src/tools/WebFetchTool/` |
| `WebSearchTool` | `src/tools/WebSearchTool/` |
| `shared` | `src/tools/shared/` |
| `testing` | `src/tools/testing/` |
To regenerate this table, run `scripts/gen-appendices.sh` from the repository root.