mirror of
https://github.com/alibaba/open-code-review.git
synced 2026-07-09 17:28:58 +00:00
refactor(config): rename config directory from .open-code-review to .opencodereview
Unify the config folder name to `.opencodereview` across all runtime paths, tests, docs, and i18n strings. Also make defaultConfigPath() return an error instead of silently falling back to a current-directory file when $HOME is unresolvable.
This commit is contained in:
parent
bbf673d4d1
commit
5053e6dca8
16 changed files with 95 additions and 82 deletions
|
|
@ -8,13 +8,13 @@ import (
|
|||
"strconv"
|
||||
)
|
||||
|
||||
// Default config file location: ~/.open-code-review/config.json
|
||||
func defaultConfigPath() string {
|
||||
// Default config file location: ~/.opencodereview/config.json
|
||||
func defaultConfigPath() (string, error) {
|
||||
home, err := os.UserHomeDir()
|
||||
if err != nil {
|
||||
return "open-code-review.json"
|
||||
return "", fmt.Errorf("cannot determine home directory: %w", err)
|
||||
}
|
||||
return filepath.Join(home, ".open-code-review", "config.json")
|
||||
return filepath.Join(home, ".opencodereview", "config.json"), nil
|
||||
}
|
||||
|
||||
func runConfig(args []string) error {
|
||||
|
|
@ -37,7 +37,10 @@ func runConfig(args []string) error {
|
|||
}
|
||||
|
||||
func runConfigSet(key, value string) error {
|
||||
configPath := defaultConfigPath()
|
||||
configPath, err := defaultConfigPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cfg, err := loadOrCreateConfig(configPath)
|
||||
if err != nil {
|
||||
|
|
@ -66,11 +69,11 @@ func runConfigSet(key, value string) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// Config represents the user-level configuration file (~/.open-code-review/config.json).
|
||||
// Config represents the user-level configuration file (~/.opencodereview/config.json).
|
||||
type Config struct {
|
||||
Llm LlmConfig `json:"llm,omitempty"`
|
||||
Language string `json:"language,omitempty"` // Output language, defaults to Chinese when empty
|
||||
Telemetry *TelemetryConfig `json:"telemetry,omitempty"` // Telemetry/observability settings
|
||||
Llm LlmConfig `json:"llm,omitempty"`
|
||||
Language string `json:"language,omitempty"` // Output language, defaults to Chinese when empty
|
||||
Telemetry *TelemetryConfig `json:"telemetry,omitempty"` // Telemetry/observability settings
|
||||
}
|
||||
|
||||
type LlmConfig struct {
|
||||
|
|
@ -83,9 +86,9 @@ type LlmConfig struct {
|
|||
|
||||
// TelemetryConfig holds telemetry-specific settings.
|
||||
type TelemetryConfig struct {
|
||||
Enabled bool `json:"enabled,omitempty"` // Master switch for telemetry
|
||||
Exporter string `json:"exporter,omitempty"` // "console" or "otlp"
|
||||
OTLPEndpoint string `json:"otlp_endpoint,omitempty"` // OTLP collector address
|
||||
Enabled bool `json:"enabled,omitempty"` // Master switch for telemetry
|
||||
Exporter string `json:"exporter,omitempty"` // "console" or "otlp"
|
||||
OTLPEndpoint string `json:"otlp_endpoint,omitempty"` // OTLP collector address
|
||||
ContentLog bool `json:"content_logging,omitempty"` // Include prompt/response content
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,12 +25,17 @@ func runLLM(args []string) error {
|
|||
}
|
||||
|
||||
func runLLMTest() error {
|
||||
appCfg, err := LoadAppConfig(defaultConfigPath())
|
||||
cfgPath, err := defaultConfigPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
appCfg, err := LoadAppConfig(cfgPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("load config: %w", err)
|
||||
}
|
||||
|
||||
ep, err := llm.ResolveEndpoint(defaultConfigPath())
|
||||
ep, err := llm.ResolveEndpoint(cfgPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("resolve LLM endpoint: %w", err)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,12 @@ func runReview(args []string) error {
|
|||
planToolDefs := agent.BuildToolDefs(toolEntries, true)
|
||||
mainToolDefs := agent.BuildToolDefs(toolEntries, false)
|
||||
|
||||
appCfg, err := LoadAppConfig(defaultConfigPath())
|
||||
cfgPath, err := defaultConfigPath()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
appCfg, err := LoadAppConfig(cfgPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("load app config: %w", err)
|
||||
}
|
||||
|
|
@ -65,7 +70,7 @@ func runReview(args []string) error {
|
|||
tpl.ApplyLanguage(appCfg.Language)
|
||||
}
|
||||
|
||||
ep, err := llm.ResolveEndpoint(defaultConfigPath())
|
||||
ep, err := llm.ResolveEndpoint(cfgPath)
|
||||
if err != nil {
|
||||
return fmt.Errorf("resolve LLM endpoint: %w", err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue