Files
mcpctl/.taskmaster/tasks/task_030.md

62 lines
1.9 KiB
Markdown
Raw Permalink Normal View History

# Task ID: 30
**Title:** Add Gemini CLI LLM provider
**Status:** done
**Dependencies:** 25 ✓
**Priority:** medium
**Description:** Implement a new LLM provider that uses the Gemini CLI binary for local, free LLM inference as the preferred provider for pre-processing.
**Details:**
1. Create `src/mcplocal/src/providers/gemini-cli.ts`:
```typescript
import { spawn } from 'child_process';
export class GeminiCliProvider implements LlmProvider {
readonly name = 'gemini-cli';
private binaryPath: string;
constructor(config: GeminiCliConfig) {
this.binaryPath = config.binaryPath || 'gemini';
}
async isAvailable(): Promise<boolean> {
// Check if gemini binary exists and is executable
try {
await this.runCommand(['--version']);
return true;
} catch {
return false;
}
}
async complete(options: CompletionOptions): Promise<CompletionResult> {
const input = this.formatPrompt(options);
const output = await this.runCommand(['--prompt', input]);
return { content: output, model: 'gemini-cli' };
}
private async runCommand(args: string[]): Promise<string> {
// Spawn gemini CLI process and capture output
}
}
```
2. Research actual Gemini CLI interface and adjust implementation
3. Add to provider registry with high priority (prefer over API providers)
4. Add configuration: `geminiCliBinaryPath`
5. Handle timeout for slow inference
6. Add fallback to next provider if Gemini CLI fails
**Test Strategy:**
1. Unit test: Provider correctly detects CLI availability
2. Unit test: Prompt formatting is correct
3. Unit test: Output parsing handles various formats
4. Integration test: Full completion with actual Gemini CLI (if available)
5. Test timeout handling for slow responses
6. Test fallback when CLI is not installed