Skip to content

Project Structure

Translation in Progress

This page is being translated. Content below is a placeholder.

Overview

gemini-cli is a monorepo:

gemini-cli/
├── packages/
│   ├── cli/          # Terminal UI (Ink/React)
│   └── core/         # Agent logic (our focus)
├── docs/             # Documentation
└── package.json      # Workspace config

Core Package Structure

packages/core/src/
├── core/           # Core classes
│   ├── client.ts   # Main GeminiClient
│   ├── geminiChat.ts
│   └── turn.ts     # Event types
├── tools/          # Tool implementations
│   ├── read-file.ts
│   ├── write-file.ts
│   └── shell.ts
├── services/       # Service layer
│   ├── loopDetection.ts
│   └── chatCompression.ts
└── utils/          # Utilities

Key Files

FilePurpose
core/client.tsAgent controller, main loop
core/geminiChat.tsGemini API wrapper
core/turn.tsEvent type definitions
tools/*.tsIndividual tool implementations
services/*.tsSupporting services

Reading Order

  1. turn.ts - Understand data structures
  2. tools/read-file.ts - Simplest tool example
  3. client.ts - Main Agent loop

Summary

  • Monorepo with cli and core packages
  • Core contains all Agent logic
  • Start with turn.ts, then tools, then client

Next

Deep dive into core package: Core Package →

Learn AI Agent development through real source code