Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -795,6 +795,40 @@ When agents thrive, you thrive. But I want to help you directly too.
- **Thinking Block Validator**: Validates thinking blocks to ensure proper formatting and prevent API errors from malformed thinking content.
- **Claude Code Hooks**: Executes hooks from Claude Code's settings.json - this is the compatibility layer that runs PreToolUse/PostToolUse/UserPromptSubmit/Stop hooks.

## Model Config Optimizer

Automatically generate optimal model configurations based on your available models.

```bash
# Show optimal config based on your available models
bunx oh-my-opencode model-config

# Show with full rankings for each category
bunx oh-my-opencode model-config --verbose

# Auto-apply config to your oh-my-opencode.json
bunx oh-my-opencode model-config --apply
```

**How it works:**
1. Detects your available models via `opencode models`
2. Matches them against static rankings by category (orchestrator, reasoning, fast, coding, etc.)
3. Generates optimal agent→model and category→model configuration
4. Outputs JSON config or writes directly with `--apply`

**No API calls - completely free!**

### Contributing Rankings

The model rankings are community-driven. If you have experience with AI models and want to help improve the rankings:

1. Edit `src/cli/model-optimizer/rankings.ts`
2. Add or reorder models in the appropriate category
3. Test with `bunx oh-my-opencode model-config --verbose`
4. Submit a PR

See `src/cli/model-optimizer/AGENTS.md` for detailed contribution guidelines.

## Configuration

Highly opinionated, but adjustable to taste.
Expand Down
1 change: 1 addition & 0 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import { install } from "./install"
import { run } from "./run"
import { getLocalVersion } from "./get-local-version"
import { doctor } from "./doctor"
import { testModels } from "./model-optimizer/test-command"
import type { InstallArgs } from "./types"
import type { RunOptions } from "./run"
import type { GetLocalVersionOptions } from "./get-local-version/types"
import type { DoctorOptions } from "./doctor"
import type { TestModelsOptions } from "./model-optimizer/test-command"
import packageJson from "../../package.json" with { type: "json" }

const VERSION = packageJson.version
Expand Down Expand Up @@ -38,6 +40,8 @@ Model Providers:
Claude Required for Sisyphus (main orchestrator) and Librarian agents
ChatGPT Powers the Oracle agent for debugging and architecture
Gemini Powers frontend, documentation, and multimodal agents

Note: Run 'model-config --apply' after install to auto-configure optimal models
`)
.action(async (options) => {
const args: InstallArgs = {
Expand Down Expand Up @@ -136,6 +140,33 @@ Categories:
process.exit(exitCode)
})

program
.command("model-config")
.description("Optimize model configuration based on your available models (no API calls)")
.option("--verbose", "Show full rankings for each category")
.option("--apply", "Write optimal config to oh-my-opencode.json")
.addHelpText("after", `
Examples:
$ bunx oh-my-opencode model-config
$ bunx oh-my-opencode model-config --verbose
$ bunx oh-my-opencode model-config --apply

This command:
1. Detects your available models via 'opencode models'
2. Shows the best model for each agent based on pre-defined rankings
3. Outputs recommended config (or writes it with --apply)

No API calls - completely free!
`)
.action(async (options) => {
const testOptions: TestModelsOptions = {
verbose: options.verbose ?? false,
apply: options.apply ?? false,
}
const exitCode = await testModels(testOptions)
process.exit(exitCode)
})

program
.command("version")
.description("Show version information")
Expand Down
97 changes: 97 additions & 0 deletions src/cli/model-optimizer/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# MODEL OPTIMIZER KNOWLEDGE BASE

## OVERVIEW
Static model optimizer that uses pre-defined rankings to select optimal models for each agent. Entry: `bunx oh-my-opencode model-config` or `bunx oh-my-opencode model-config --apply`.

**No API calls - completely free!**

## STRUCTURE
```
model-optimizer/
├── types.ts # Type definitions and Zod schemas (ModelTier, ModelInfo)
├── model-detector.ts # Parse `opencode models`, tier classification
├── rankings.ts # Static model rankings by category
└── test-command.ts # CLI command for showing/applying optimal config
```

## HOW IT WORKS
1. Detects available models via `opencode models`
2. Matches available models against static rankings by category
3. Generates optimal agent→model and category→model configuration
4. Outputs recommended config (or writes it with `--apply`)

## RANKING CATEGORIES
| Category | Purpose | Used By |
|----------|---------|---------|
| orchestrator | Best overall models for complex tasks | Sisyphus, build, plan |
| reasoning | Best reasoning/debugging models | oracle, Metis, Momus |
| fast | Fast + capable models for quick lookups | explore |
| coding | Best coding models | frontend-ui-ux-engineer |
| instruction | Best instruction-following models | librarian, document-writer |
| multimodal | Vision-capable models | multimodal-looker |
| creative | Creative/artistic models | artistry category |
| free | Free/cheap fallback models | Fallback for any agent |

## CLI USAGE
```bash
# Show optimal config
bunx oh-my-opencode model-config

# Show with full rankings
bunx oh-my-opencode model-config --verbose

# Auto-apply config to ~/.config/opencode/oh-my-opencode.json
bunx oh-my-opencode model-config --apply
```

## OUTPUT
The command outputs:
1. List of your available models
2. Optimal agent → model mapping with ranking position
3. Optimal category → model mapping with temperature/variant
4. Recommended config JSON (or confirmation if --apply used)

## HOW TO CONTRIBUTE RANKINGS

### Adding a New Model
1. Find the model ID by running `opencode models`
2. Edit `rankings.ts`
3. Add the model ID to the appropriate category in `MODEL_RANKINGS`
4. Position matters - place it where it belongs relative to other models
5. Test: `bunx oh-my-opencode model-config --verbose`

### Reordering Models
1. Edit `rankings.ts`
2. Move the model ID up (higher priority) or down (lower priority) within its category
3. Test to verify the change

### Adding a New Agent
1. Add entry to `AGENT_RANKING_MAP` mapping agent name → category
2. Optionally set variant in `generateOptimalConfig()` function

### Adding a New Task Category
1. Add entry to `CATEGORY_RANKING_MAP` mapping category → ranking category
2. Add entry to `CATEGORY_TEMPERATURES` (0.1-0.9)
3. Add entry to `CATEGORY_VARIANTS` ("low", "medium", "high", "max")

### Testing Changes
```bash
bun test src/cli/model-optimizer/ # Run unit tests
bunx oh-my-opencode model-config # See generated config
bunx oh-my-opencode model-config --verbose # See full rankings with your models
```

## TYPE REFERENCE
Key types in `types.ts`:
- `ModelTier`: "flagship" | "standard" | "lite"
- `ModelInfo`: Model info parsed from `opencode models`

Key types in `rankings.ts`:
- `RankingCategory`: The 8 ranking categories
- `AGENT_RANKING_MAP`: Maps agent names to ranking categories
- `CATEGORY_RANKING_MAP`: Maps task categories to ranking categories

## ANTI-PATTERNS
- Adding models without testing `model-config` command
- Putting paid models before free models in the `free` category
- Skipping TDD (test first!)
Loading
Loading