mirror of
https://github.com/sipeed/picoclaw.git
synced 2026-06-12 18:08:54 +00:00
56 lines
1.3 KiB
Go
56 lines
1.3 KiB
Go
package internal
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/sipeed/picoclaw/pkg/config"
|
|
"github.com/sipeed/picoclaw/pkg/logger"
|
|
)
|
|
|
|
const Logo = "🦞"
|
|
|
|
// GetPicoclawHome returns the picoclaw home directory.
|
|
// Priority: $PICOCLAW_HOME > ~/.picoclaw
|
|
func GetPicoclawHome() string {
|
|
if home := os.Getenv(config.EnvHome); home != "" {
|
|
return home
|
|
}
|
|
home, _ := os.UserHomeDir()
|
|
return filepath.Join(home, ".picoclaw")
|
|
}
|
|
|
|
func GetConfigPath() string {
|
|
if configPath := os.Getenv(config.EnvConfig); configPath != "" {
|
|
return configPath
|
|
}
|
|
return filepath.Join(GetPicoclawHome(), "config.json")
|
|
}
|
|
|
|
func LoadConfig() (*config.Config, error) {
|
|
cfg, err := config.LoadConfig(GetConfigPath())
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
logger.SetLevelFromString(cfg.Agents.Defaults.LogLevel)
|
|
return cfg, nil
|
|
}
|
|
|
|
// FormatVersion returns the version string with optional git commit
|
|
// Deprecated: Use pkg/config.FormatVersion instead
|
|
func FormatVersion() string {
|
|
return config.FormatVersion()
|
|
}
|
|
|
|
// FormatBuildInfo returns build time and go version info
|
|
// Deprecated: Use pkg/config.FormatBuildInfo instead
|
|
func FormatBuildInfo() (string, string) {
|
|
return config.FormatBuildInfo()
|
|
}
|
|
|
|
// GetVersion returns the version string
|
|
// Deprecated: Use pkg/config.GetVersion instead
|
|
func GetVersion() string {
|
|
return config.GetVersion()
|
|
}
|