mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-05 02:30:26 +08:00
通过设置 --setting-sources="" 禁用所有配置源(user, project, local), 避免被调用的 Claude 实例加载 ~/.claude/CLAUDE.md 和 skills, 从而防止再次调用 codeagent 导致的循环超时问题。 修改内容: - backend.go: ClaudeBackend.BuildArgs 添加 --setting-sources="" 参数 - backend_test.go: 更新 4 个测试用例以匹配新的参数列表 - main_test.go: 更新 2 个测试用例以匹配新的参数列表 Generated with swe-agent-bot Co-Authored-By: swe-agent-bot <agent@swe-agent.ai>
79 lines
2.1 KiB
Go
79 lines
2.1 KiB
Go
package main
|
|
|
|
// Backend defines the contract for invoking different AI CLI backends.
|
|
// Each backend is responsible for supplying the executable command and
|
|
// building the argument list based on the wrapper config.
|
|
type Backend interface {
|
|
Name() string
|
|
BuildArgs(cfg *Config, targetArg string) []string
|
|
Command() string
|
|
}
|
|
|
|
type CodexBackend struct{}
|
|
|
|
func (CodexBackend) Name() string { return "codex" }
|
|
func (CodexBackend) Command() string {
|
|
return "codex"
|
|
}
|
|
func (CodexBackend) BuildArgs(cfg *Config, targetArg string) []string {
|
|
return buildCodexArgs(cfg, targetArg)
|
|
}
|
|
|
|
type ClaudeBackend struct{}
|
|
|
|
func (ClaudeBackend) Name() string { return "claude" }
|
|
func (ClaudeBackend) Command() string {
|
|
return "claude"
|
|
}
|
|
func (ClaudeBackend) BuildArgs(cfg *Config, targetArg string) []string {
|
|
if cfg == nil {
|
|
return nil
|
|
}
|
|
args := []string{"-p", "--dangerously-skip-permissions"}
|
|
|
|
// Only skip permissions when explicitly requested
|
|
// if cfg.SkipPermissions {
|
|
// args = append(args, "--dangerously-skip-permissions")
|
|
// }
|
|
|
|
// Prevent infinite recursion: disable all setting sources (user, project, local)
|
|
// This ensures a clean execution environment without CLAUDE.md or skills that would trigger codeagent
|
|
args = append(args, "--setting-sources", "")
|
|
|
|
if cfg.Mode == "resume" {
|
|
if cfg.SessionID != "" {
|
|
// Claude CLI uses -r <session_id> for resume.
|
|
args = append(args, "-r", cfg.SessionID)
|
|
}
|
|
}
|
|
// Note: claude CLI doesn't support -C flag; workdir set via cmd.Dir
|
|
|
|
args = append(args, "--output-format", "stream-json", "--verbose", targetArg)
|
|
|
|
return args
|
|
}
|
|
|
|
type GeminiBackend struct{}
|
|
|
|
func (GeminiBackend) Name() string { return "gemini" }
|
|
func (GeminiBackend) Command() string {
|
|
return "gemini"
|
|
}
|
|
func (GeminiBackend) BuildArgs(cfg *Config, targetArg string) []string {
|
|
if cfg == nil {
|
|
return nil
|
|
}
|
|
args := []string{"-o", "stream-json", "-y"}
|
|
|
|
if cfg.Mode == "resume" {
|
|
if cfg.SessionID != "" {
|
|
args = append(args, "-r", cfg.SessionID)
|
|
}
|
|
}
|
|
// Note: gemini CLI doesn't support -C flag; workdir set via cmd.Dir
|
|
|
|
args = append(args, "-p", targetArg)
|
|
|
|
return args
|
|
}
|