|
| 1 | +# Basic Configuration Example |
| 2 | + |
| 3 | +This is the simplest way to get started with OpenCoder. Use this as a starting point for new projects. |
| 4 | + |
| 5 | +## Directory Structure |
| 6 | + |
| 7 | +``` |
| 8 | +my-project/ |
| 9 | +├── .opencode/ |
| 10 | +│ └── opencoder/ |
| 11 | +│ └── config.json # OpenCoder configuration |
| 12 | +└── [your project files...] |
| 13 | +``` |
| 14 | + |
| 15 | +## Configuration File |
| 16 | + |
| 17 | +Create `.opencode/opencoder/config.json` in your project directory: |
| 18 | + |
| 19 | +```json |
| 20 | +{ |
| 21 | + "planModel": "anthropic/claude-sonnet-4", |
| 22 | + "buildModel": "anthropic/claude-sonnet-4", |
| 23 | + "verbose": false, |
| 24 | + "maxRetries": 3, |
| 25 | + "taskPauseSeconds": 2, |
| 26 | + "autoCommit": true, |
| 27 | + "autoPush": false |
| 28 | +} |
| 29 | +``` |
| 30 | + |
| 31 | +## Field Descriptions |
| 32 | + |
| 33 | +| Field | Type | Default | Description | |
| 34 | +|-------|------|---------|-------------| |
| 35 | +| `planModel` | string | - | Model for plan/eval phases (format: `provider/model`) | |
| 36 | +| `buildModel` | string | - | Model for build phase (format: `provider/model`) | |
| 37 | +| `verbose` | boolean | false | Enable verbose logging output | |
| 38 | +| `maxRetries` | number | 3 | Maximum retries per operation | |
| 39 | +| `taskPauseSeconds` | number | 2 | Pause between tasks (prevents rate limiting) | |
| 40 | +| `autoCommit` | boolean | true | Automatically commit changes after tasks | |
| 41 | +| `autoPush` | boolean | true | Automatically push after cycles | |
| 42 | +| `commitSignoff` | boolean | false | Add DCO signoff to commits | |
| 43 | +| `cycleTimeoutMinutes` | number | 60 | Maximum minutes per cycle (0 = no limit) | |
| 44 | + |
| 45 | +## Usage |
| 46 | + |
| 47 | +### Option 1: Using Command Line |
| 48 | + |
| 49 | +```bash |
| 50 | +# Run with Claude Sonnet for both plan and build |
| 51 | +opencoder --model anthropic/claude-sonnet-4 -p ./my-project |
| 52 | + |
| 53 | +# Run with a hint/instruction |
| 54 | +opencoder -m anthropic/claude-sonnet-4 -p ./my-project "Build a REST API with Express" |
| 55 | + |
| 56 | +# With verbose logging |
| 57 | +opencoder -m anthropic/claude-sonnet-4 -p ./my-project -v |
| 58 | +``` |
| 59 | + |
| 60 | +### Option 2: Using Configuration File |
| 61 | + |
| 62 | +```bash |
| 63 | +# Create the config file first |
| 64 | +mkdir -p my-project/.opencode/opencoder |
| 65 | +cat > my-project/.opencode/opencoder/config.json << 'EOF' |
| 66 | +{ |
| 67 | + "planModel": "anthropic/claude-sonnet-4", |
| 68 | + "buildModel": "anthropic/claude-sonnet-4", |
| 69 | + "verbose": false, |
| 70 | + "maxRetries": 3, |
| 71 | + "taskPauseSeconds": 2, |
| 72 | + "autoCommit": true, |
| 73 | + "autoPush": false |
| 74 | +} |
| 75 | +EOF |
| 76 | + |
| 77 | +# Run from project directory |
| 78 | +cd my-project |
| 79 | +opencoder |
| 80 | +``` |
| 81 | + |
| 82 | +### Option 3: Using Environment Variables |
| 83 | + |
| 84 | +```bash |
| 85 | +export OPENCODER_PLAN_MODEL=anthropic/claude-sonnet-4 |
| 86 | +export OPENCODER_BUILD_MODEL=anthropic/claude-sonnet-4 |
| 87 | +export OPENCODER_VERBOSE=false |
| 88 | + |
| 89 | +opencoder -p ./my-project |
| 90 | +``` |
| 91 | + |
| 92 | +## Supported Models |
| 93 | + |
| 94 | +### Anthropic (Claude) |
| 95 | +- `anthropic/claude-opus-4` - Powerful, expensive, slower |
| 96 | +- `anthropic/claude-sonnet-4` - Balanced, recommended default |
| 97 | +- `anthropic/claude-haiku` - Fast, cheap, less capable |
| 98 | + |
| 99 | +### OpenAI (GPT) |
| 100 | +- `openai/gpt-4o` - Latest GPT-4 optimized model |
| 101 | +- `openai/gpt-4-turbo` - GPT-4 with extended context |
| 102 | +- `openai/gpt-3.5-turbo` - Fast, cheap, good for building |
| 103 | + |
| 104 | +### Google (Gemini) |
| 105 | +- `google/gemini-2.0-flash` - Latest fast model |
| 106 | +- `google/gemini-pro` - Standard model |
| 107 | + |
| 108 | +## Initial Run |
| 109 | + |
| 110 | +When you first run OpenCoder: |
| 111 | + |
| 112 | +1. It creates `.opencode/opencoder/` directory structure |
| 113 | +2. Generates `state.json` to track progress |
| 114 | +3. Creates `metrics.json` to track statistics |
| 115 | +4. Saves plans in `current_plan.md` |
| 116 | +5. Archives completed plans in `history/` |
| 117 | + |
| 118 | +## What Happens |
| 119 | + |
| 120 | +``` |
| 121 | +Cycle 1 → Plan Phase (generates tasks) → Build Phase (executes tasks) |
| 122 | + ↓ |
| 123 | + Eval Phase (checks if work is complete) |
| 124 | + ↓ |
| 125 | +Cycle 2 → Repeat until manually stopped (Ctrl+C) |
| 126 | +``` |
| 127 | + |
| 128 | +## Stopping OpenCoder |
| 129 | + |
| 130 | +- **Graceful stop**: Press `Ctrl+C` once to finish the current cycle |
| 131 | +- **Force stop**: Press `Ctrl+C` twice to stop immediately |
| 132 | +- State is saved, so it can resume from where it left off |
| 133 | + |
| 134 | +## Troubleshooting |
| 135 | + |
| 136 | +### "Model not found" |
| 137 | +- Verify your model format is `provider/model` |
| 138 | +- Check that you have access to the model through your API key |
| 139 | + |
| 140 | +### "Too many retries" |
| 141 | +- Increase `maxRetries` in config if transient errors occur |
| 142 | +- Check your API rate limits and quota |
| 143 | +- Increase `taskPauseSeconds` to slow down task execution |
| 144 | + |
| 145 | +### High token usage |
| 146 | +- Use a faster model for `buildModel` (e.g., `claude-haiku`) |
| 147 | +- Use a more capable model for `planModel` (e.g., `claude-opus`) |
| 148 | +- Reduce `verbose` output if enabled |
| 149 | + |
| 150 | +## Next Steps |
| 151 | + |
| 152 | +Once you're comfortable with basic usage: |
| 153 | + |
| 154 | +1. **Review the output** - Check `.opencode/opencoder/logs/` for detailed logs |
| 155 | +2. **Adjust configuration** - Fine-tune based on your project's needs |
| 156 | +3. **Use ideas queue** - Drop `.md` files in `.opencode/opencoder/ideas/` to guide development |
| 157 | +4. **Check metrics** - Run `opencoder --status` to see usage statistics |
| 158 | + |
| 159 | +See [Advanced Configuration](advanced.md) for more customization options. |
0 commit comments