|
| 1 | +# Gemini CLI Configuration |
| 2 | + |
| 3 | +This directory contains configuration for Google Gemini CLI used in automated PR validation. |
| 4 | + |
| 5 | +## Files |
| 6 | + |
| 7 | +- `config.toml` - Gemini CLI configuration |
| 8 | +- `pr-validation-prompt.md` - Validation prompt template |
| 9 | +- `test-local.sh` - Local testing script |
| 10 | +- `GEMINI_SETUP.md` - Setup guide |
| 11 | + |
| 12 | +## Configuration Details |
| 13 | + |
| 14 | +### Model Settings |
| 15 | + |
| 16 | +- **Model**: `gemini-2.5-flash` |
| 17 | + Ensures parity with CI workflow and local scripts to avoid discrepancies. |
| 18 | +- **Provider**: Google AI (Vertex AI) |
| 19 | +- **Features**: Reasoning, MCP support |
| 20 | + |
| 21 | +### Agentic Capabilities |
| 22 | + |
| 23 | +- **Max Iterations**: 100 |
| 24 | +- **Temperature**: 0.7 (balanced creativity/consistency) |
| 25 | +- **Code Execution**: Disabled (read-only analysis) |
| 26 | + |
| 27 | +### MCP Server Integration |
| 28 | + |
| 29 | +Connected to **Usable MCP** for fetching standards: |
| 30 | +- **URL**: `https://usable.dev/api/mcp` |
| 31 | +- **Authentication**: Bearer token from `USABLE_API_TOKEN` |
| 32 | +- **Purpose**: Fetch latest Next.js and Flowcore Pathways standards |
| 33 | + |
| 34 | +Gemini CLI has native MCP support, allowing it to: |
| 35 | +- Access Usable workspace fragments |
| 36 | +- Search for relevant standards |
| 37 | +- Get up-to-date documentation |
| 38 | +- Explore knowledge graphs |
| 39 | + |
| 40 | +## Environment Variables |
| 41 | + |
| 42 | +Required for operation: |
| 43 | + |
| 44 | +- `GEMINI_API_KEY` - Google AI API key for Gemini models |
| 45 | +- `USABLE_API_TOKEN` - Usable API token for MCP access |
| 46 | + |
| 47 | +Get your Gemini API key: https://aistudio.google.com/app/apikey |
| 48 | + |
| 49 | +## Local Testing |
| 50 | + |
| 51 | +See `test-local.sh` for running validation locally before pushing to CI/CD. |
| 52 | + |
| 53 | +## Why Gemini? |
| 54 | + |
| 55 | +- ✅ Simple API key authentication (no OAuth expiration) |
| 56 | +- ✅ Native MCP server support |
| 57 | +- ✅ Cost-effective (free tier available) |
| 58 | +- ✅ Advanced reasoning capabilities |
| 59 | +- ✅ Reliable for CI/CD automation |
| 60 | + |
| 61 | +## How It Works |
| 62 | + |
| 63 | +1. **PR Created**: When a PR is opened/updated targeting `main` |
| 64 | +2. **Workflow Triggers**: `.github/workflows/pr-validation.yml` runs |
| 65 | +3. **Gemini Executes**: Runs the validation prompt with PR context |
| 66 | +4. **Usable Queried**: MCP server at https://usable.dev/api/mcp fetches latest standards |
| 67 | +5. **Validation Performed**: Gemini 2.5 reviews changes against standards |
| 68 | +6. **Report Generated**: Structured markdown report with violations |
| 69 | +7. **Comment Posted**: Report posted as PR comment |
| 70 | +8. **Build Status**: Fails if critical violations found |
| 71 | + |
| 72 | +### Gemini CLI Command Syntax |
| 73 | + |
| 74 | +**✅ Correct way (stdin redirection)**: |
| 75 | +```bash |
| 76 | +gemini -y -m gemini-2.5-flash < prompt.txt > output.txt |
| 77 | +``` |
| 78 | + |
| 79 | +**❌ NOT supported**: |
| 80 | +```bash |
| 81 | +gemini --input prompt.txt --output output.txt # Wrong! |
| 82 | +cat prompt.txt | gemini --yolo -m model > output.txt # May cause errors |
| 83 | +``` |
| 84 | + |
| 85 | +**Why `<` instead of `cat |`?** |
| 86 | +- More reliable with Gemini CLI flag combinations |
| 87 | +- Avoids "Unable to process file command" errors |
| 88 | +- Standard Unix practice |
| 89 | + |
| 90 | +See [GEMINI_CLI_USAGE.md](./GEMINI_CLI_USAGE.md) for detailed command reference. |
| 91 | + |
| 92 | +## Validation Categories |
| 93 | + |
| 94 | +### ❌ Critical Violations (Build Fails) |
| 95 | +Issues that must be fixed before merge: |
| 96 | +- **NOT using Flowcore Pathways for data operations** |
| 97 | +- **Direct database writes in services** |
| 98 | +- **Missing Session Pathways for user actions** |
| 99 | +- **Missing YAML updates** (flowcore.yml, flowcore.local.yml, flowcore.local.development.yml) |
| 100 | +- Using React Hook Form instead of TanStack Forms |
| 101 | +- Database foreign keys instead of DrizzleORM relations |
| 102 | +- Direct process.env access instead of T3 env validation |
| 103 | +- Using fetch() directly instead of TanStack Query |
| 104 | +- Next.js 15 params pattern violations |
| 105 | +- Hardcoded colors instead of theme variables |
| 106 | + |
| 107 | +### ⚠️ Important Issues (Should Fix) |
| 108 | +Issues that should be addressed: |
| 109 | +- **Incorrect Pathways usage pattern** (Session Pathways in workers) |
| 110 | +- **Missing event contracts** |
| 111 | +- **Bypassing event handlers** |
| 112 | +- Missing TypeScript strict mode |
| 113 | +- Poor error handling patterns |
| 114 | +- Missing Swagger documentation |
| 115 | + |
| 116 | +### ℹ️ Suggestions (Nice to Have) |
| 117 | +Improvements for better code quality: |
| 118 | +- Code organization improvements |
| 119 | +- Performance optimizations |
| 120 | +- Better naming conventions |
| 121 | +- Additional TypeScript type safety |
| 122 | + |
| 123 | +## Getting Started |
| 124 | + |
| 125 | +1. **Install Gemini CLI**: |
| 126 | + ```bash |
| 127 | + npm install -g @google/gemini-cli |
| 128 | + ``` |
| 129 | + |
| 130 | +2. **Get API Key**: https://aistudio.google.com/app/apikey |
| 131 | + |
| 132 | +3. **Set Environment Variables**: |
| 133 | + ```bash |
| 134 | + export GEMINI_API_KEY="your-key" |
| 135 | + export USABLE_API_TOKEN="your-token" |
| 136 | + ``` |
| 137 | + |
| 138 | +4. **Test Locally**: |
| 139 | + ```bash |
| 140 | + chmod +x .codex/test-local.sh |
| 141 | + ./.codex/test-local.sh |
| 142 | + ``` |
| 143 | + |
| 144 | +## Documentation |
| 145 | + |
| 146 | +- [Gemini Setup Guide](.codex/GEMINI_SETUP.md) - Detailed setup instructions |
| 147 | +- [PR Validation](../docs/PR_VALIDATION.md) - How validation works |
| 148 | +- [Flowcore YAML Checklist](.codex/FLOWCORE_YAML_CHECKLIST.md) - YAML update requirements |
| 149 | + |
| 150 | +## Support |
| 151 | + |
| 152 | +- Gemini CLI: https://github.com/google-gemini/gemini-cli |
| 153 | +- Gemini API: https://ai.google.dev/docs |
| 154 | +- Get API Key: https://aistudio.google.com/app/apikey |
| 155 | +- Usable: https://usable.dev |
0 commit comments