refactor(config): удалена опция opencode.config (OPENCODE_CONFIG)
This commit is contained in:
@@ -10,7 +10,6 @@ telegram:
|
|||||||
# Всё ниже — опционально, показаны дефолты:
|
# Всё ниже — опционально, показаны дефолты:
|
||||||
# opencode:
|
# opencode:
|
||||||
# bin: "opencode"
|
# bin: "opencode"
|
||||||
# config: "/путь/к/opencode.json" # файл-конфиг модели (OPENCODE_CONFIG); пусто = глобальный конфиг opencode
|
|
||||||
# hard_timeout: "20m"
|
# hard_timeout: "20m"
|
||||||
# idle_timeout: "5m"
|
# idle_timeout: "5m"
|
||||||
#
|
#
|
||||||
|
|||||||
@@ -156,7 +156,6 @@ func New(configPath, version, updateToken string, noUI bool) (*App, error) {
|
|||||||
// Служебный root-сервер (worktree) живёт всё время app; остальные лениво.
|
// Служебный root-сервер (worktree) живёт всё время app; остальные лениво.
|
||||||
ocPool := opencode.NewPool(cfg.Paths.Worktree)
|
ocPool := opencode.NewPool(cfg.Paths.Worktree)
|
||||||
ocPool.Bin = cfg.OpenCode.Bin
|
ocPool.Bin = cfg.OpenCode.Bin
|
||||||
ocPool.Config = cfg.OpenCode.Config
|
|
||||||
ocPool.DBPath = cfg.OpenCode.DBPath
|
ocPool.DBPath = cfg.OpenCode.DBPath
|
||||||
ocPool.Host = cfg.OpenCode.Serve.Hostname
|
ocPool.Host = cfg.OpenCode.Serve.Hostname
|
||||||
ocPool.BasePort = cfg.OpenCode.Serve.Port
|
ocPool.BasePort = cfg.OpenCode.Serve.Port
|
||||||
|
|||||||
@@ -146,26 +146,6 @@ log:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestLoad_EnvOverride(t *testing.T) {
|
|
||||||
t.Setenv("TG_TOKEN", "tok")
|
|
||||||
t.Setenv("TG_CHAT_ID", "42")
|
|
||||||
// env override для opencode.timeout
|
|
||||||
t.Setenv("OPENCODE_CONFIG", "/custom/opencode.json")
|
|
||||||
|
|
||||||
yaml := `telegram:
|
|
||||||
token: "${TG_TOKEN}"
|
|
||||||
chat_id: "${TG_CHAT_ID}"
|
|
||||||
`
|
|
||||||
path := writeCfg(t, yaml)
|
|
||||||
cfg, err := Load(path)
|
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Load: %v", err)
|
|
||||||
}
|
|
||||||
if cfg.OpenCode.Config != "/custom/opencode.json" {
|
|
||||||
t.Errorf("opencode config = %q", cfg.OpenCode.Config)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestLoad_MissingEnvVarUsesDefault(t *testing.T) {
|
func TestLoad_MissingEnvVarUsesDefault(t *testing.T) {
|
||||||
t.Setenv("TG_TOKEN", "tok")
|
t.Setenv("TG_TOKEN", "tok")
|
||||||
t.Setenv("TG_CHAT_ID", "42")
|
t.Setenv("TG_CHAT_ID", "42")
|
||||||
|
|||||||
@@ -88,7 +88,6 @@ type TelegramCfg struct {
|
|||||||
type OpenCodeCfg struct {
|
type OpenCodeCfg struct {
|
||||||
Bin string `yaml:"bin" default:"opencode"`
|
Bin string `yaml:"bin" default:"opencode"`
|
||||||
DBPath string `yaml:"db_path" default:""`
|
DBPath string `yaml:"db_path" default:""`
|
||||||
Config string `yaml:"config" env:"OPENCODE_CONFIG"`
|
|
||||||
HardTimeout Duration `yaml:"hard_timeout" default:"20m"`
|
HardTimeout Duration `yaml:"hard_timeout" default:"20m"`
|
||||||
IdleTimeout Duration `yaml:"idle_timeout" default:"5m"`
|
IdleTimeout Duration `yaml:"idle_timeout" default:"5m"`
|
||||||
PollMs Duration `yaml:"poll_ms" default:"2s"`
|
PollMs Duration `yaml:"poll_ms" default:"2s"`
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ import (
|
|||||||
// директории → каждая сессия API привязана к правильному project-каталогу.
|
// директории → каждая сессия API привязана к правильному project-каталогу.
|
||||||
type Pool struct {
|
type Pool struct {
|
||||||
Bin string
|
Bin string
|
||||||
Config string
|
|
||||||
DBPath string
|
DBPath string
|
||||||
Host string
|
Host string
|
||||||
BasePort int
|
BasePort int
|
||||||
@@ -72,7 +71,6 @@ func (p *Pool) EnsureRoot(ctx context.Context) error {
|
|||||||
}
|
}
|
||||||
s := &Server{
|
s := &Server{
|
||||||
Bin: p.Bin,
|
Bin: p.Bin,
|
||||||
Config: p.Config,
|
|
||||||
DBPath: p.DBPath,
|
DBPath: p.DBPath,
|
||||||
Host: p.Host,
|
Host: p.Host,
|
||||||
Password: p.Password,
|
Password: p.Password,
|
||||||
@@ -101,7 +99,6 @@ func (p *Pool) Ensure(ctx context.Context, dir string) (*Server, error) {
|
|||||||
abs := filepath.Clean(dir)
|
abs := filepath.Clean(dir)
|
||||||
s := &Server{
|
s := &Server{
|
||||||
Bin: p.Bin,
|
Bin: p.Bin,
|
||||||
Config: p.Config,
|
|
||||||
DBPath: p.DBPath,
|
DBPath: p.DBPath,
|
||||||
Host: p.Host,
|
Host: p.Host,
|
||||||
Password: p.Password,
|
Password: p.Password,
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import (
|
|||||||
// отдаёт URL, процессом не владеет.
|
// отдаёт URL, процессом не владеет.
|
||||||
type Server struct {
|
type Server struct {
|
||||||
Bin string // путь к opencode (по умолчанию "opencode")
|
Bin string // путь к opencode (по умолчанию "opencode")
|
||||||
Config string // OPENCODE_CONFIG
|
|
||||||
DBPath string // рабочая БД сервера (передам env, если задана)
|
DBPath string // рабочая БД сервера (передам env, если задана)
|
||||||
|
|
||||||
Host string // hostname для прослушивания
|
Host string // hostname для прослушивания
|
||||||
@@ -127,12 +126,7 @@ func (s *Server) serveCmd(ctx context.Context) *exec.Cmd {
|
|||||||
"OPENCODE_DISABLE_AUTOUPDATE=1",
|
"OPENCODE_DISABLE_AUTOUPDATE=1",
|
||||||
"OPENCODE_DISABLE_MODELS_FETCH=1")
|
"OPENCODE_DISABLE_MODELS_FETCH=1")
|
||||||
// Агенты (analyst/dev/...) opencode находит сам через project-каталог
|
// Агенты (analyst/dev/...) opencode находит сам через project-каталог
|
||||||
// .opencode (см. internal/agents); OPENCODE_CONFIG_DIR не выставляем,
|
// .opencode (см. internal/agents).
|
||||||
// чтобы не перенаправлять Global.Path.config и сохранить глобальный
|
|
||||||
// конфиг opencode (модель/провайдеры).
|
|
||||||
if s.Config != "" {
|
|
||||||
env = append(env, "OPENCODE_CONFIG="+s.Config)
|
|
||||||
}
|
|
||||||
if s.DBPath != "" {
|
if s.DBPath != "" {
|
||||||
env = append(env, "OPENCODE_DB="+s.DBPath)
|
env = append(env, "OPENCODE_DB="+s.DBPath)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user