chore(conductor): Add new track 'Gemini CLI Headless Integration'

This commit is contained in:
2026-02-24 23:46:56 -05:00
parent bab468fc82
commit 5dc286ffd3
5 changed files with 89 additions and 0 deletions

View File

@@ -36,3 +36,8 @@ This file tracks all major tracks for the project. Each track has its own detail
- [ ] **Track: MMA Core Engine Implementation** - [ ] **Track: MMA Core Engine Implementation**
*Link: [./tracks/mma_core_engine_20260224/](./tracks/mma_core_engine_20260224/)* *Link: [./tracks/mma_core_engine_20260224/](./tracks/mma_core_engine_20260224/)*
---
- [ ] **Track: Support gemini cli headless as an alternative to the raw client_api route. So that they user may use their gemini subscription and gemini cli features within manual slop for a more discliplined and visually enriched UX.**
*Link: [./tracks/gemini_cli_headless_20260224/](./tracks/gemini_cli_headless_20260224/)*

View File

@@ -0,0 +1,5 @@
# Track gemini_cli_headless_20260224 Context
- [Specification](./spec.md)
- [Implementation Plan](./plan.md)
- [Metadata](./metadata.json)

View File

@@ -0,0 +1,8 @@
{
"track_id": "gemini_cli_headless_20260224",
"type": "feature",
"status": "new",
"created_at": "2026-02-24T23:45:00Z",
"updated_at": "2026-02-24T23:45:00Z",
"description": "Support gemini cli headless as an alternative to the raw client_api route. So that they user may use their gemini subscription and gemini cli features within manual slop for a more discliplined and visually enriched UX."
}

View File

@@ -0,0 +1,26 @@
# Implementation Plan: Gemini CLI Headless Integration
## Phase 1: IPC Infrastructure Extension
- [ ] Task: Extend `api_hooks.py` to support synchronous "Ask" requests. This involves adding a way for a client to POST a request and wait for a user response from the GUI.
- [ ] Task: Update `api_hook_client.py` with a `request_confirmation(tool_name, args)` method that blocks until the GUI responds.
- [ ] Task: Create a standalone test script `tests/test_sync_hooks.py` to verify that the CLI-to-GUI communication works as expected.
- [ ] Task: Conductor - User Manual Verification 'Phase 1: IPC Infrastructure Extension' (Protocol in workflow.md)
## Phase 2: Gemini CLI Adapter & Tool Bridge
- [ ] Task: Implement `scripts/cli_tool_bridge.py`. This script will be called by the Gemini CLI `BeforeTool` hook and use `ApiHookClient` to talk to the GUI.
- [ ] Task: Implement the `GeminiCliAdapter` in `ai_client.py` (or a new `gemini_cli_adapter.py`). It must handle the `subprocess` lifecycle and parse the `stream-json` output.
- [ ] Task: Integrate `GeminiCliAdapter` into the main `ai_client.send()` logic.
- [ ] Task: Write unit tests for the JSON parsing and subprocess management in `GeminiCliAdapter`.
- [ ] Task: Conductor - User Manual Verification 'Phase 2: Gemini CLI Adapter & Tool Bridge' (Protocol in workflow.md)
## Phase 3: GUI Integration & Provider Support
- [ ] Task: Update `gui_2.py` (and `gui_legacy.py`) to add "Gemini CLI" to the provider dropdown.
- [ ] Task: Implement UI elements for "Gemini CLI Session Management" (Login button, session ID display).
- [ ] Task: Update the `manual_slop.toml` logic to persist Gemini CLI specific settings (e.g., path to CLI, approval mode).
- [ ] Task: Conductor - User Manual Verification 'Phase 3: GUI Integration & Provider Support' (Protocol in workflow.md)
## Phase 4: Integration Testing & UX Polish
- [ ] Task: Create a comprehensive integration test `tests/test_gemini_cli_integration.py` that uses the `live_gui` fixture to simulate a full session.
- [ ] Task: Verify tool confirmation flow: CLI Tool -> Bridge -> GUI Modal -> User Approval -> CLI Execution.
- [ ] Task: Polish the display of CLI telemetry (tokens/latency) in the GUI diagnostics panel.
- [ ] Task: Conductor - User Manual Verification 'Phase 4: Integration Testing & UX Polish' (Protocol in workflow.md)

View File

@@ -0,0 +1,45 @@
# Specification: Gemini CLI Headless Integration
## Overview
This track integrates the `gemini` CLI as a headless backend provider for Manual Slop. This allows users to leverage their Gemini subscription and the CLI's advanced features (e.g., specialized sub-agents like `codebase_investigator`, structured JSON streaming, and robust session management) directly within the Manual Slop GUI.
## Goals
- Add "Gemini CLI" as a selectable AI provider in Manual Slop.
- Support both persistent interactive sessions and one-off task-specific delegation (e.g., running `gemini investigate`).
- Implement a secure "BeforeTool" hook to ensure all CLI-initiated tool calls are intercepted and confirmed via the Manual Slop GUI.
- Capture and display the CLI's visually enriched output (via JSONL stream) within the existing discussion history.
## Functional Requirements
### 1. Gemini CLI Provider Adapter
- **Implementation**: Create a `GeminiCliAdapter` class (or extend `ai_client.py`) that wraps the `gemini` CLI subprocess.
- **Communication**: Use `--output-format stream-json` to receive real-time updates (text chunks, tool calls, status).
- **Session Management**: Support session persistence by tracking the session ID and passing it to subsequent CLI calls.
- **Authentication**:
- Provide a "Login to Gemini CLI" action in the GUI that triggers `gemini login`.
- Support passing an API key via environment variables if configured in `manual_slop.toml`.
### 2. GUI Intercepted Tool Execution
- **Mechanism**: Use the Gemini CLI's `BeforeTool` hook.
- **Hook Helper**: A small Python script `scripts/cli_tool_bridge.py` will be registered as the `BeforeTool` hook.
- **IPC**: This bridge script will communicate with Manual Slop's `HookServer` (extending it to support synchronous "ask" requests).
- **Confirmation**: When a tool is requested, the bridge blocks until the user confirms/denies the action in the GUI, returning the decision as JSON to the CLI.
### 3. Visual & Telemetry Integration
- **Rich Output**: Parse the `stream-json` events to display markdown content and tool status in the GUI.
- **Telemetry**: Extract and display token usage and latency metrics provided by the CLI's `result` event.
## Non-Functional Requirements
- **Performance**: The subprocess bridge should introduce minimal latency (<100ms overhead for communication).
- **Reliability**: Gracefully handle CLI crashes or timeouts by reporting errors in the GUI and allowing session resets.
## Acceptance Criteria
- [ ] User can select "Gemini CLI" in the Provider dropdown.
- [ ] User can successfully send messages and receive streamed responses from the CLI.
- [ ] Any tool call (PowerShell/MCP) initiated by the CLI triggers the standard Manual Slop confirmation modal.
- [ ] Tools only execute after user approval; rejection correctly notifies the CLI agent.
- [ ] Session history is maintained correctly across multiple turns when using the CLI provider.
## Out of Scope
- Full terminal emulation (ANSI color support) within the GUI; the focus is on structured text and data.
- Migrating existing raw `client_api` sessions to CLI sessions.