Skip to content

Take the turn management out of GeminiClient - #42

Merged
rakyll merged 1 commit into
mainfrom
turn
Apr 19, 2025
Merged

rakyll merged 1 commit into
mainfrom
turn

Conversation

@rakyll

@rakyll rakyll commented Apr 18, 2025 •

Copy link
Copy Markdown
Contributor

No description provided.

@rakyll
rakyll force-pushed the turn branch 4 times, most recently from bb1ab98 to 61bd9ba Compare April 18, 2025 23:51
Comment thread packages/cli/src/core/gemini-client.ts Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw just want to call out that our @google/genai APIs make me cry here with this type of exposed mutability as the primary way to modify history lol

Comment thread packages/cli/src/core/gemini-client.ts Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Comment thread packages/cli/src/core/gemini-client.ts Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could potentially extract this hack out of GeminiClient as well. This "continuation check" shouldn't have to happen and honestly might be a root model or API bug /cc @evansenter @jlove29

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am scared of touching this part right now :) I'm thinking about leaving this as it is in the scope of this PR, and we can follow up after the refactoring.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Def! No worries I can tackle it

Comment thread packages/cli/src/core/turn.ts Resolved
@rakyll
rakyll force-pushed the turn branch 5 times, most recently from 13ca8c2 to 1d01a7a Compare April 19, 2025 00:24
Comment thread packages/cli/src/core/turn.ts Outdated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm extremely confused by the repeated nature of this kind of error handling across the codebase. We should clean this up.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lol vibe coding at its best 😄

@rakyll
rakyll force-pushed the turn branch 7 times, most recently from 804b349 to 96eaecb Compare April 19, 2025 01:05
@rakyll
rakyll marked this pull request as ready for review April 19, 2025 01:08
@rakyll

rakyll commented Apr 19, 2025 •

Copy link
Copy Markdown
Contributor Author

@NTaylorMullen Please take a fresh look now!

@rakyll
rakyll requested a review from NTaylorMullen April 19, 2025 01:08
viridivn pushed a commit to viridivn/gemini-cli that referenced this pull request Jun 29, 2025
ramanshrivastava pushed a commit to ramanshrivastava/gemini-cli that referenced this pull request Nov 16, 2025
…ation

This commit introduces a complete learning framework for understanding and
reimplementing Gemini CLI from scratch, following a reasoning-based approach
similar to Python interpreter design guides.

The framework provides:

**Main Framework Document (LEARNING_FRAMEWORK.md)**
- Architecture overview with execution pipeline
- Historical timeline mapping actual commit history to development phases
- Phase-by-phase implementation guide (Phases 0-6)
- Complete code examples for each phase
- ADR template for documenting architectural decisions
- Learning checkpoints and exercises
- Development tools (visualizer, debugger, comparison scripts)

**Architecture Decision Records (docs/adrs/)**
- ADR-001: TypeScript setup and strict mode configuration
  * Explains type erasure, module resolution, verbatimModuleSyntax
  * References real Gemini CLI tsconfig.json
  * Includes checkpoint quiz and practical exercises

- ADR-006: Turn abstraction and separation from GeminiClient
  * Documents PR google-gemini#42 refactoring (April 18, 2025)
  * Explains why Turn was extracted as separate class
  * Shows async generator pattern for event streaming
  * Compares alternatives (monolithic, functional, class-based)

**Comparisons (docs/comparisons/)**
- Phase 1 Tools Comparison: Mini (80 lines) vs Real (296 lines)
  * Side-by-side code comparison
  * Feature coverage matrix
  * Explains why Real is 4x larger (binary detection, large files, security)
  * Evolution path from Mini to Real

**Checkpoints (docs/checkpoints/)**
- Checkpoint 2: Tool System & Function Calling
  * Conceptual questions (function calling, validation, Zod vs TypeScript)
  * Practical exercises (implement GrepTool, model integration)
  * Design questions (tool registry, error recovery)
  * Self-assessment and reflection

**Documentation Index (docs/README.md)**
- Complete learning path overview
- Index of all ADRs, comparisons, and checkpoints
- How to use the framework
- Reference to key Gemini CLI files
- Commit history highlights

Key Learning Outcomes:
- Understand Gemini API function calling mechanism
- Master declarative tool pattern (validation, execution, policy)
- Learn agentic orchestration loops
- Event-driven architecture with async generators
- React/Ink terminal UIs
- TypeScript strict mode and type system

Historical Context:
The framework maps to actual Gemini CLI development:
- April 15, 2025: Initial commit (7,920 lines)
- April 18, 2025: Turn abstraction extracted
- September 2025: Declarative agent framework introduced
- November 2025: Policy engine added

This provides a structured path to rebuild Gemini CLI incrementally,
understanding every design decision through historical context and
comparative analysis of simplified vs. production implementations.

Total Documentation:
- 6 new files
- ~3,500 lines of documentation
- 12 code examples
- 15+ quiz questions with detailed answers
- Complete project structure for mini-gemini-cli
skeshive pushed a commit that referenced this pull request Nov 18, 2025
Introduces a `PersistentState` utility to track local user state across sessions.
   Updates `AppHeader` to hide the default welcome banner after it has been shown 5 times to reduce visual
   noise for experienced users.

   - Added `packages/cli/src/utils/persistentState.ts` for managing `state.json`.
   - Updated `AppHeader.tsx` to increment and check `defaultBannerShownCount`.
   - Added unit tests for banner display logic.
   - Minor: Updated model name in `geminiChat.test.ts`.
skeshive pushed a commit that referenced this pull request Nov 18, 2025
Introduces a `PersistentState` utility to track local user state across sessions.
   Updates `AppHeader` to hide the default welcome banner after it has been shown 5 times to reduce visual
   noise for experienced users.

   - Added `packages/cli/src/utils/persistentState.ts` for managing `state.json`.
   - Updated `AppHeader.tsx` to increment and check `defaultBannerShownCount`.
   - Added unit tests for banner display logic.
   - Minor: Updated model name in `geminiChat.test.ts`.
@sripasg sripasg added the size/l A large sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/l A large sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants