config

package
v0.42.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultHTTPTimeout は LLM API 用の HTTP クライアントタイムアウト
	// ストリーミング時はアイドルタイムアウト(streaming.idle_timeout_seconds)で管理するため、
	// HTTPクライアントレベルでは無制限(0)に設定
	DefaultHTTPTimeout = 0                // 無制限(context/アイドルタイムアウトで管理)
	SerperHTTPTimeout  = 10 * time.Second // Serper API専用(非ストリーミング)
)

HTTP Configuration

View Source
const (
	MaxToolIterations    = 25 // ツールループ最大回数(複雑なタスクに対応)
	MaxChangeStack       = 10 // Undo履歴最大保存数
	MaxAPIRetries        = 2  // API呼び出し最大リトライ回数
	MaxSameToolCallCount = 3  // 同じツール呼び出しの最大繰り返し回数(ループ検知)
)

Tool Execution Limits

View Source
const (
	OutputTruncateLen   = 5000 // bash出力切り詰め長
	MaxDiffDisplayLines = 15   // diff表示最大行数
	MaxDiffIterations   = 20   // diff比較最大イテレーション
)

Output Display Limits

View Source
const (
	PlanMaxRetries       = 3  // ステップ失敗時の最大リトライ回数
	PlanMaxIterations    = 10 // ステップ内ツール実行の最大イテレーション数
	PlanMaxAutoContinues = 3  // AI質問時の自動続行最大回数
)

Plan Execution Limits

View Source
const (
	MessageTruncateLen = 500 // サマリー生成時のメッセージ切り詰め長
	MaxLastOutputs     = 10  // 最後の出力履歴最大保存数
)

Message Processing Limits

View Source
const (
	HistoryPreviewLen     = 50  // /history コマンドのプレビュー切り詰め長
	SessionPreviewLen     = 60  // /sessions コマンドのプレビュー切り詰め長
	SessionListMaxDisplay = 10  // /sessions の最大表示数
	ErrorOutputMaxLines   = 20  // Plan失敗時のエラー出力最大行数
	SyncFileChangesMax    = 10  // /sync のファイル変更最大表示数
	DebugPreviewLen       = 500 // デバッグログのプレビュー長
)

UI Display Limits

View Source
const (
	RepoMapMaxFiles   = 20 // RepoMapの最大ファイル数
	RepoMapMaxSymbols = 10 // RepoMapのファイル毎最大シンボル数
)

RepoMap Display Limits

View Source
const (
	DefaultParallelWorkers = 3 // Plan実行のデフォルト並列ワーカー数
	LoopDetectionThreshold = 3 // ループ検知の閾値
)

Parallel Execution Defaults

View Source
const (
	TestOutputMaxLines = 20 // テスト出力の最大行数
)

Test/Verification Limits

Variables

View Source
var ValidProviders = []string{
	"deepseek",
	"openai",
	"gemini",
	"claude",
	"anthropic",
	"ollama",
	"groq",
}

ValidProviders は有効なプロバイダー名の一覧 internal/api/provider.go の NewProvider() と同期させること

Functions

func ApplyAutoFixes added in v0.31.0

func ApplyAutoFixes(cfg *Config, result ValidationResult) int

ApplyAutoFixes は自動修正可能な問題を修正

func LoadConfigWithValidation added in v0.31.0

func LoadConfigWithValidation() (*Config, ValidationResult, error)

LoadConfigWithValidation は設定ファイルを読み込み、バリデーションを実行 バリデーションエラーがあっても設定は返す(警告のみ)

func PrintValidationWarnings added in v0.31.0

func PrintValidationWarnings(result ValidationResult)

PrintValidationWarnings はバリデーション警告を表示

func SaveConfig

func SaveConfig(cfg *Config) error

SaveConfig は設定ファイルを保存

func SetGlobalConfig added in v0.29.0

func SetGlobalConfig(cfg *Config)

SetGlobalConfig はグローバル設定を保存

func ShowConfig added in v0.31.0

func ShowConfig(current *Config) string

ShowConfig は現在の設定とデフォルトの差分を含む表示文字列を生成

func ValidateModel

func ValidateModel(model string) bool

ValidateModel は任意のモデル名を受け付ける(後方互換のため残す) 注: v0.16.0以降、モデル名の検証は行わない

Types

type APIRetryConfig added in v0.29.0

type APIRetryConfig struct {
	Count        int `yaml:"count"`         // リトライ回数(デフォルト3)
	InitialDelay int `yaml:"initial_delay"` // 初回待機秒数(デフォルト1)
	MaxDelay     int `yaml:"max_delay"`     // 最大待機秒数(デフォルト30)
	Timeout      int `yaml:"timeout"`       // APIタイムアウト秒数(デフォルト300=5分)
}

APIRetryConfig はAPIリトライの設定

type BackupConfig added in v0.29.0

type BackupConfig struct {
	MaxGenerations int `yaml:"max_generations"` // 保持する世代数(デフォルト5)
}

BackupConfig はバックアップファイルの設定

type BashConfig added in v0.31.0

type BashConfig struct {
	SafetyLevel     string   `yaml:"safety_level"`      // strict, moderate, permissive(デフォルト: moderate)
	SafeCommands    []string `yaml:"safe_commands"`     // 追加の安全コマンド
	AllowPipe       bool     `yaml:"allow_pipe"`        // パイプを許可(デフォルト: true - moderateで有効)
	AllowRedirect   bool     `yaml:"allow_redirect"`    // リダイレクトを許可(デフォルト: false)
	AllowInlineEdit bool     `yaml:"allow_inline_edit"` // sed -i等を許可(デフォルト: false)
}

BashConfig はbashツールの設定

type CodeHealthConfig added in v0.31.0

type CodeHealthConfig struct {
	Enabled          bool     `yaml:"enabled"`            // コード健全性チェックを有効化(デフォルト: true)
	MaxFileLines     int      `yaml:"max_file_lines"`     // ファイル行数上限(デフォルト: 300)
	MaxFunctionLines int      `yaml:"max_function_lines"` // 関数行数上限(デフォルト: 50)
	AutoSuggest      bool     `yaml:"auto_suggest"`       // 閾値超過時に自動で提案(デフォルト: true)
	OnChange         []string `yaml:"on_change"`          // 変更時チェック項目(check_file_size, check_function_size, check_duplication)
}

CodeHealthConfig はコード健全性チェックの設定

type CompressionConfig added in v0.29.0

type CompressionConfig struct {
	AutoCompress     bool `yaml:"auto_compress"`      // 自動圧縮を有効化(デフォルト: true)
	ThresholdTokens  int  `yaml:"threshold_tokens"`   // 自動圧縮のトークン閾値(0 = 使用率ベース)
	ThresholdPercent int  `yaml:"threshold_percent"`  // 自動圧縮の使用率閾値(デフォルト: 80%)
	KeepRecent       int  `yaml:"keep_recent"`        // 保持する最新メッセージ数
	PreferCompactAPI bool `yaml:"prefer_compact_api"` // OpenAI Compact API を優先(デフォルト: true)
}

CompressionConfig は会話履歴圧縮の設定

type Config

type Config struct {
	DefaultProvider string                         `yaml:"default_provider"`
	DefaultModel    string                         `yaml:"default_model"`
	ProviderModels  map[string]ProviderModelConfig `yaml:"provider_models"`
	Compression     CompressionConfig              `yaml:"compression,omitempty"`
	Backup          BackupConfig                   `yaml:"backup,omitempty"`
	LoopDetection   LoopDetectionConfig            `yaml:"loop_detection,omitempty"`
	APIRetry        APIRetryConfig                 `yaml:"api_retry,omitempty"`
	Diff            DiffConfig                     `yaml:"diff,omitempty"`
	ToolConfirm     ToolConfirmConfig              `yaml:"tool_confirm,omitempty"`
	CommandAliases  map[string]string              `yaml:"command_aliases,omitempty"` // コマンドエイリアス
	PromptCache     PromptCacheConfig              `yaml:"prompt_cache,omitempty"`
	Paste           PasteConfig                    `yaml:"paste,omitempty"`
	Streaming       StreamingConfig                `yaml:"streaming,omitempty"`
	Bash            BashConfig                     `yaml:"bash,omitempty"`
	CodeHealth      CodeHealthConfig               `yaml:"code_health,omitempty"`
	GitStage        GitStageConfig                 `yaml:"git_stage,omitempty"`
	PlanMode        PlanModeConfig                 `yaml:"plan_mode,omitempty"`
	LSP             LSPConfig                      `yaml:"lsp,omitempty"`
	OpenAI          OpenAIConfig                   `yaml:"openai,omitempty"`
	Thinking        ThinkingConfig                 `yaml:"thinking,omitempty"`
	RepoMap         RepoMapConfig                  `yaml:"repomap,omitempty"`
}

Config はXELYON CLIの設定

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig はデフォルト設定

func GetGlobalConfig added in v0.29.0

func GetGlobalConfig() *Config

GetGlobalConfig はグローバル設定を取得

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig は設定ファイルを読み込む

func (*Config) ApplyEnvironmentOverrides added in v0.29.0

func (c *Config) ApplyEnvironmentOverrides()

ApplyEnvironmentOverrides は環境変数で設定を上書き

func (*Config) ApplyFlagOverrides added in v0.29.0

func (c *Config) ApplyFlagOverrides(loopThreshold, apiRetry, apiRetryDelay, diffLines *int)

ApplyFlagOverrides はCLIフラグで設定を上書き

func (*Config) GetModelForProvider

func (c *Config) GetModelForProvider(provider string) string

GetModelForProvider はプロバイダーに対応するデフォルトモデルを取得

func (*Config) IsResponsesAPIModel added in v0.31.0

func (c *Config) IsResponsesAPIModel(model string) bool

IsResponsesAPIModel はモデルが OpenAI Responses API を使用するか判定

func (*Config) ValidateModelForProvider

func (c *Config) ValidateModelForProvider(provider, model string) bool

ValidateModelForProvider は任意のモデル名を受け付ける(後方互換のため残す) 注: v0.16.0以降、モデル名の検証は行わない

type ConfigDiff added in v0.31.0

type ConfigDiff struct {
	Key      string
	Current  string
	Default  string
	IsDiff   bool
	IsNested bool
}

ConfigDiff は設定の差分情報

type DiffConfig added in v0.29.0

type DiffConfig struct {
	ContextLines int `yaml:"context_lines"` // 差分表示行数(デフォルト10、0で省略なし)
}

DiffConfig は差分表示の設定

type GitStageConfig added in v0.31.0

type GitStageConfig struct {
	BatchConfirm bool `yaml:"batch_confirm"` // 複数ファイルのバッチ確認UI(デフォルト: true)
}

GitStageConfig はgit_addツールの設定

type LSPConfig added in v0.31.0

type LSPConfig struct {
	Enabled           bool                       `yaml:"enabled"`                       // LSP機能を有効化(デフォルト: true)
	SkipInstallPrompt bool                       `yaml:"skip_install_prompt,omitempty"` // インストール提案をスキップ
	Servers           map[string]LSPServerConfig `yaml:"servers,omitempty"`
}

LSPConfig は LSP (Language Server Protocol) 連携の設定

type LSPServerConfig added in v0.31.0

type LSPServerConfig struct {
	Command  string   `yaml:"command"`            // サーバーコマンド(例: gopls, vtsls)
	Args     []string `yaml:"args,omitempty"`     // コマンド引数
	Disabled bool     `yaml:"disabled,omitempty"` // このサーバーを無効化
}

LSPServerConfig は個別のLSPサーバー設定

type LoopDetectionConfig added in v0.29.0

type LoopDetectionConfig struct {
	Threshold int `yaml:"threshold"` // ループ検知回数(デフォルト3)
}

LoopDetectionConfig はループ検知の設定

type OpenAIConfig added in v0.31.0

type OpenAIConfig struct {
	ResponsesAPIModels []string `yaml:"responses_api_models"` // Responses API を使用するモデル
}

OpenAIConfig は OpenAI プロバイダーの設定

type PasteConfig added in v0.31.0

type PasteConfig struct {
	MaxLines       int `yaml:"max_lines"`       // 最大行数(デフォルト10000)
	MaxBytes       int `yaml:"max_bytes"`       // 最大バイト数(デフォルト1MB)
	TimeoutSeconds int `yaml:"timeout_seconds"` // タイムアウト秒(デフォルト60)
}

PasteConfig はペーストモードの設定

type PlanModeConfig added in v0.31.0

type PlanModeConfig struct {
	MaxParallelSteps int `yaml:"max_parallel_steps"` // 並列実行数(デフォルト: 3)
}

PlanModeConfig は Plan Mode の設定

type PromptCacheConfig added in v0.31.0

type PromptCacheConfig struct {
	Enabled    bool `yaml:"enabled"`
	MaxEntries int  `yaml:"max_entries"` // 0以下の場合はデフォルト適用
	TTLSeconds int  `yaml:"ttl_seconds"` // 0の場合はデフォルト適用(デフォルトTTL)
}

PromptCacheConfig はプロンプトキャッシュの設定

目的: system prompt / repo map 等の生成コストを削減するためのキャッシュ。 現時点では in-memory キャッシュを想定(永続化なし)。

type ProviderModelConfig

type ProviderModelConfig struct {
	DefaultModel string `yaml:"default_model"`
}

ProviderModelConfig はプロバイダーごとのモデル設定

type RepoMapConfig added in v0.42.0

type RepoMapConfig struct {
	MaxTokens int `yaml:"max_tokens,omitempty"` // 0 = 自動計算(ファイル数ベース)
}

RepoMapConfig は RepoMap の設定

type StreamingConfig added in v0.31.0

type StreamingConfig struct {
	IdleTimeoutSeconds int `yaml:"idle_timeout_seconds"` // アイドルタイムアウト秒(デフォルト30)
}

StreamingConfig はストリーミングレスポンスの設定

type ThinkingConfig added in v0.31.0

type ThinkingConfig struct {
	Enabled bool   `yaml:"enabled"` // デフォルト: false
	Level   string `yaml:"level"`   // low/medium/high/xhigh(デフォルト: medium)
}

ThinkingConfig は Extended Thinking の設定

type ToolConfirmConfig added in v0.31.0

type ToolConfirmConfig struct {
	AutoApproveSafe   bool `yaml:"auto_approve_safe"`   // SafetyHigh(read_file等)を確認なしで実行(デフォルトtrue)
	AutoApproveMedium bool `yaml:"auto_approve_medium"` // SafetyMedium(str_replace等)を確認なしで実行(デフォルトfalse)
}

ToolConfirmConfig はツール実行確認の設定

type ValidationIssue added in v0.31.0

type ValidationIssue struct {
	Field      string // 問題のあるフィールド名
	Value      string // 現在の値
	Message    string // 問題の説明
	Suggestion string // 修正提案
	Severity   string // "error" or "warning"
	CanAutoFix bool   // 自動修正可能か
	FixedValue any    // 自動修正後の値
}

ValidationIssue はバリデーション問題を表す

type ValidationResult added in v0.31.0

type ValidationResult struct {
	Valid  bool
	Issues []ValidationIssue
}

ValidationResult はバリデーション結果を表す

func ValidateConfig added in v0.31.0

func ValidateConfig(cfg *Config) ValidationResult

ValidateConfig は設定ファイルのバリデーションを行う

func (ValidationResult) HasErrors added in v0.31.0

func (r ValidationResult) HasErrors() bool

HasErrors は致命的なエラーがあるかチェック

func (ValidationResult) HasWarnings added in v0.31.0

func (r ValidationResult) HasWarnings() bool

HasWarnings は警告があるかチェック

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL