config

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2025 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitConfig

func InitConfig(cfgFile string)

InitConfig 读取配置文件和环境变量

Types

type Config

type Config struct {
	// AIProvider 决定使用哪个 AI 客户端 ("openai", "gemini", "openrouter")
	AIProvider string `mapstructure:"ai_provider"`

	// Proxy 是用于 AI 请求的网络代理
	Proxy string `mapstructure:"proxy"`

	// Silent 静默模式,如果为 true,则 ai-commit commit 命令将直接提交
	Silent bool `mapstructure:"silent"`

	// ExcludeFileSuffix 是需要从 git diff 中排除的文件后缀
	ExcludeFileSuffix []string `mapstructure:"exclude_file_suffix"`

	// DEBUG 是否启用调试模式
	DEBUG bool `mapstructure:"debug"`

	// PromptTemplate 是发送给 AI 的提示词
	PromptTemplate string `mapstructure:"prompt_template"`

	// EnableEmoji 控制是否在 commit message 中添加 emoji
	EnableEmoji bool `mapstructure:"enable_emoji"`

	// EmojiMapping 定义了 scope 和 emoji 之间的映射
	EmojiMapping map[string]string `mapstructure:"emoji_mapping"`

	// 各个 AI 服务的配置
	OpenAI     OpenAIConfig     `mapstructure:"openai"`
	Gemini     GeminiConfig     `mapstructure:"gemini"`
	OpenRouter OpenRouterConfig `mapstructure:"openrouter"`
}

Config 是配置的根结构

var AppConfig Config

AppConfig 保存所有应用程序的配置。 它是全局可访问的(在 InitConfig 之后)。

type GeminiConfig

type GeminiConfig struct {
	APIKey string `mapstructure:"api_key"`
	Model  string `mapstructure:"model"`
}

GeminiConfig 保存 Gemini 特定的配置

type OpenAIConfig

type OpenAIConfig struct {
	APIKey  string `mapstructure:"api_key"`
	Model   string `mapstructure:"model"`
	BaseURL string `mapstructure:"base_url"` // 用于代理或兼容 API
}

OpenAIConfig 保存 OpenAI 特定的配置

type OpenRouterConfig

type OpenRouterConfig struct {
	APIKey string `mapstructure:"api_key"`
	Model  string `mapstructure:"model"`
	// OpenRouter 还需要额外的 headers
	SiteURL string `mapstructure:"site_url"`
	AppName string `mapstructure:"app_name"`
}

OpenRouterConfig 保存 OpenRouter 特定的配置

Jump to

Keyboard shortcuts

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