高度な設定
高度な設定
このドキュメントでは、Oh My OpenCodeの高度な設定オプションを紹介し、特定のニーズに合わせてカスタマイズする方法を説明します。
設定ファイルの場所と優先順位
設定ファイルの場所
Oh My OpenCodeは、以下の順序で設定ファイルを検索します:
1. .opencode/oh-my-opencode.json (プロジェクトレベル、最高優先順位)
2. ~/.config/opencode/oh-my-opencode.json (ユーザーレベル、macOS/Linux)
3. %APPDATA%\opencode\oh-my-opencode.json (ユーザーレベル、Windows)
設定の合成ルール
複数の設定ファイルは、優先順位に従って合成されます:
プロジェクトレベルの設定 (.opencode/oh-my-opencode.json):
{
"sisyphus": {
"enabled": true,
"max_concurrent_tasks": 2
}
}
ユーザーレベルの設定 (~/.config/opencode/oh-my-opencode.json):
{
"sisyphus": {
"max_concurrent_tasks": 3 // プロジェクトレベルの設定を上書き
},
"agents": {
"oracle": { "enabled": true }
}
}
最終的な有効設定:
{
"sisyphus": {
"enabled": true,
"max_concurrent_tasks": 3 // ユーザーレベルから継承
},
"agents": {
"oracle": { "enabled": true } // ユーザーレベルから継承
}
}
JSONC サポート
Oh My OpenCodeは、コメント付き JSON (JSONC) 形式をサポートしています:
{
// これはコメントです
"sisyphus": {
"enabled": true,
/*
* 複数行コメント
* サブスクリプションプランに合わせて調整
*/
"max_concurrent_tasks": 3
},
// エージェント設定
"agents": {
"oracle": {
"enabled": true,
// "temperature": 0.7, // 未使用の設定をコメントアウト可能
}
}
}
サブスクリプションプランの設定
Claude Max20 完全設定
集中的な開発作業に適した、最も強力な設定:
{
"subscription": "claude-max20",
"sisyphus": {
"enabled": true,
"max_concurrent_tasks": 3,
"task_timeout": 300,
"auto_delegate": true,
"delegation_strategy": "optimal"
},
"agents": {
"oracle": {
"enabled": true,
"model": "claude-sonnet-4",
"temperature": 0.7,
"max_tokens": 4096
},
"librarian": {
"enabled": true,
"model": "claude-sonnet-4",
"temperature": 0.5
},
"frontend-engineer": {
"enabled": true,
"model": "claude-sonnet-4",
"temperature": 0.6
},
"backend-engineer": {
"enabled": true,
"model": "claude-sonnet-4",
"temperature": 0.6
},
"explore": {
"enabled": true,
"model": "claude-sonnet-3.5",
"temperature": 0.3
}
},
"lsp": {
"enabled": true,
"languages": ["typescript", "javascript", "python", "go", "rust"]
},
"background_task": {
"defaultConcurrency": 3,
"providerConcurrency": {
"anthropic": 3,
"openai": 5
}
}
}
ChatGPT Plus/Pro 設定
パフォーマンスとコストのバランス:
{
"subscription": "chatgpt-plus",
"sisyphus": {
"enabled": true,
"max_concurrent_tasks": 2,
"delegation_strategy": "balanced"
},
"agents": {
"oracle": {
"enabled": true,
"model": "gpt-4-turbo"
},
"librarian": {
"enabled": true,
"model": "gpt-4-turbo"
},
"frontend-engineer": {
"enabled": true,
"model": "gpt-4"
},
"backend-engineer": {
"enabled": false // クォータを節約
},
"explore": {
"enabled": true,
"model": "gpt-4"
}
},
"background_task": {
"defaultConcurrency": 2,
"providerConcurrency": {
"openai": 2
}
}
}
Gemini Advanced 設定
高いコストパフォーマンス:
{
"subscription": "gemini-advanced",
"sisyphus": {
"enabled": true,
"max_concurrent_tasks": 2
},
"agents": {
"oracle": {
"enabled": false // Gemini はアーキテクチャ設計がやや苦手
},
"librarian": {
"enabled": true,
"model": "gemini-pro-1.5"
},
"frontend-engineer": {
"enabled": true,
"model": "gemini-pro-1.5"
},
"explore": {
"enabled": true,
"model": "gemini-pro-1.5"
}
}
}
エージェントのカスタマイズ
完全なエージェント設定オプション
{
"agents": {
"oracle": {
// 基本設定
"enabled": true,
"model": "claude-sonnet-4",
"temperature": 0.7,
"max_tokens": 4096,
"top_p": 0.9,
// プロンプトのカスタマイズ
"prompt_append": "技術的な決定の詳細な根拠とトレードオフ分析を提供してください",
"system_prompt_override": "あなたはシニアアーキテクトです...",
// 動作制御
"auto_retry": true,
"max_retries": 3,
"retry_delay": 2,
// ツール権限
"tools": {
"lsp": true,
"ast_grep": true,
"file_operations": true,
"shell_commands": false // セキュリティ上の考慮
},
// リソース制限
"rate_limit": {
"requests_per_minute": 20,
"tokens_per_minute": 50000
}
}
}
}
カスタムエージェントプロンプト
特定のプロジェクトに合わせてエージェントの動作をカスタマイズします:
{
"agents": {
"frontend-engineer": {
"enabled": true,
"prompt_append": "あなたは私たちのチームのフロントエンドエンジニアです。以下の基準に従ってください:\n\n1. 技術スタック:\n - React 18+ と TypeScript\n - スタイリングには Tailwind CSS\n - データフェッチには React Query\n\n2. コードスタイル:\n - 関数コンポーネントと Hooks を使用する\n - Props は TypeScript インターフェースを定義する必要がある\n - 継承よりも合成を優先する\n\n3. アクセシビリティ:\n - すべてのインタラクティブ要素はキーボードでアクセス可能である必要がある\n - セマンティックな HTML を使用する\n - 適切な ARIA ラベルを提供する\n\n4. パフォーマンス:\n - React.memo を使用してレンダリングを最適化する\n - 画像は遅延読み込みを使用する必要がある\n - レンダリング関数内でのオブジェクト作成を避ける"
}
}
}
権限制御設定
外部ファイル操作権限
{
"permissions": {
"file_operations": {
"read": {
"allow": ["src/**", "docs/**", "*.md"],
"deny": [".env*", "*.key", "secrets/**"]
},
"write": {
"allow": ["src/**", "docs/**"],
"deny": ["package.json", "tsconfig.json"] // 重要なファイルは手動確認を要求
},
"delete": {
"require_confirmation": true,
"allow": ["temp/**"],
"deny": ["**"] // デフォルトで削除を拒否
}
}
}
}
シェルコマンド権限
{
"permissions": {
"shell_commands": {
"enabled": true,
"whitelist": [
"npm test",
"npm run lint",
"git status",
"git diff"
],
"blacklist": [
"rm -rf",
"sudo",
"curl *", // データ漏洩防止
"wget *"
],
"require_confirmation_for": [
"git push",
"npm publish",
"docker"
]
}
}
}
API 呼び出し権限
{
"permissions": {
"api_calls": {
"allowed_domains": [
"api.github.com",
"registry.npmjs.org"
],
"rate_limit": {
"requests_per_minute": 60
},
"require_user_secrets": true // APIキーはユーザーが提供する必要がある
}
}
}
バックグラウンドタスク同時実行制御
同時実行戦略の設定
{
"background_task": {
"defaultConcurrency": 5,
"providerConcurrency": {
"anthropic": 3,
"openai": 5
},
// 優先度設定
"priority_levels": {
"high": {
"max_concurrent": 2,
"timeout": 600
},
"normal": {
"max_concurrent": 2,
"timeout": 300
},
"low": {
"max_concurrent": 1,
"timeout": 120
}
},
// リソース割り当て戦略
"scheduling": {
"strategy": "fair", // fair (公平), priority (優先度順), round-robin (ラウンドロビン)
"preemption": false, // 高優先度タスクによる割り込みを許可するか
"queue_size": 10
},
// 失敗ハンドリング
"error_handling": {
"retry_failed": true,
"max_retries": 2,
"fallback_to_sync": true // 失敗後に同期実行に切り替える
}
}
}
タスクタイプの設定
{
"task_types": {
"analysis": {
"can_run_in_background": true,
"priority": "low",
"timeout": 120
},
"code_generation": {
"can_run_in_background": false, // コード生成はユーザーの確認が必要
"priority": "high"
},
"documentation": {
"can_run_in_background": true,
"priority": "low"
},
"testing": {
"can_run_in_background": true,
"priority": "normal"
}
}
}
Sisyphus エージェントの設定オプション
完全な Sisyphus 設定
{
"sisyphus": {
// 基本設定
"enabled": true,
"max_concurrent_tasks": 3,
"task_timeout": 300,
// 委任戦略
"auto_delegate": true,
"delegation_strategy": "optimal", // optimal (最適), balanced (バランス), sequential (順次), parallel (並列)
// タスク分解
"task_decomposition": {
"enabled": true,
"max_subtasks": 10,
"min_subtask_complexity": 2
},
// エージェント選択
"agent_selection": {
"strategy": "capability_match", // capability_match (能力一致), load_balance (負荷分散), random (ランダム)
"consider_workload": true,
"prefer_specialists": true
},
// 結果の集約
"result_aggregation": {
"strategy": "merge", // merge (マージ), vote (投票), best (最良)
"conflict_resolution": "oracle_decides"
},
// コンテキスト管理
"context_sharing": {
"enabled": true,
"share_between_agents": true,
"max_context_size": 8192
}
}
}
Hooks 統合設定
ライフサイクルフック
{
"hooks": {
"pre_task": {
"enabled": true,
"script": ".opencode/hooks/pre-task.sh",
"timeout": 30
},
"post_task": {
"enabled": true,
"script": ".opencode/hooks/post-task.sh"
},
"on_error": {
"enabled": true,
"script": ".opencode/hooks/error-handler.sh",
"notify_user": true
},
"on_agent_switch": {
"enabled": true,
"script": ".opencode/hooks/agent-switch.sh"
}
}
}
フックスクリプトの例
#!/bin/bash
# .opencode/hooks/pre-task.sh
# タスク開始前に実行
echo "タスクを開始します: $TASK_ID"
# コード品質をチェック
npm run lint || {
echo "Lint に失敗しました。続行する前に修正してください。"
exit 1
}
# 最新コードをプル
git pull origin main
exit 0
MCP サーバー設定
Model Context Protocol 統合
{
"mcp": {
"enabled": true,
"servers": [
{
"name": "github",
"command": "mcp-server-github",
"args": ["--token", "${GITHUB_TOKEN}"],
"env": {
"GITHUB_API_URL": "https://api.github.com"
}
},
{
"name": "database",
"command": "mcp-server-postgres",
"args": ["--connection", "${DATABASE_URL}"]
},
{
"name": "slack",
"command": "mcp-server-slack",
"args": ["--token", "${SLACK_TOKEN}"]
}
],
// サーバーリソース制限
"resource_limits": {
"max_connections": 5,
"timeout": 30,
"retry_attempts": 3
}
}
}
完全な設定例
エンタープライズグレードの設定テンプレート
{
"version": "1.0",
"subscription": "claude-max20",
"sisyphus": {
"enabled": true,
"max_concurrent_tasks": 3,
"delegation_strategy": "optimal"
},
"agents": {
"oracle": {
"enabled": true,
"model": "claude-sonnet-4",
"temperature": 0.7,
"prompt_append": "会社の技術スタックとアーキテクチャ原則に従ってください"
},
"librarian": {
"enabled": true,
"model": "claude-sonnet-4"
},
"frontend-engineer": {
"enabled": true,
"model": "claude-sonnet-4",
"prompt_append": "React + TypeScript + Tailwind を使用してください"
},
"backend-engineer": {
"enabled": true,
"model": "claude-sonnet-4",
"prompt_append": "Node.js + Express + PostgreSQL を使用してください"
},
"explore": {
"enabled": true,
"model": "claude-sonnet-3.5"
}
},
"lsp": {
"enabled": true,
"languages": ["typescript", "python", "go"]
},
"background_task": {
"defaultConcurrency": 5,
"providerConcurrency": {
"anthropic": 3,
"openai": 5
}
},
"permissions": {
"file_operations": {
"read": {
"allow": ["src/**", "docs/**"],
"deny": [".env*", "secrets/**"]
},
"write": {
"allow": ["src/**", "docs/**"],
"deny": ["package.json"]
}
},
"shell_commands": {
"whitelist": ["npm test", "npm run lint", "git status"]
}
},
"hooks": {
"pre_task": {
"enabled": true,
"script": ".opencode/hooks/pre-task.sh"
},
"post_task": {
"enabled": true,
"script": ".opencode/hooks/post-task.sh"
}
},
"context_injection": {
"enabled": true,
"files": [".opencode/CONTEXT.md", "AGENTS.md"]
}
}
設定の検証
設定ファイルの検証
# 設定の構文を検証
opencode "設定ファイルを検証して"
# 設定をテスト
opencode "現在の設定を使用してテストタスクを実行して"
# 有効な設定を表示
opencode "現在の完全な設定を表示して"
よくある設定エラー
// ❌ エラー:同時実行数がサブスクリプション制限を超えている
{
"sisyphus": {
"max_concurrent_tasks": 10 // Claude Max20 の最大値は 3
}
}
// ✅ 正解
{
"sisyphus": {
"max_concurrent_tasks": 3
}
}
// ❌ エラー:エージェントが無効化されている
{
"sisyphus": {
"auto_delegate": true
},
"agents": {
"oracle": { "enabled": false } // Sisyphus が委任を試みる可能性がある
}
}
// ✅ 正解
{
"agents": {
"oracle": { "enabled": true }
}
}
次のステップ
設定が完了した後は、以下のことをお勧めします: