feat: add worktree support and refactor do skill to Python

- Add worktree module for git worktree management
- Refactor do skill scripts from shell to Python for better maintainability
- Add install.py for do skill installation
- Update stop-hook to Python implementation
- Enhance executor with additional configuration options
- Update CLAUDE.md with first-principles thinking guidelines

Generated with SWE-Agent.ai

Co-Authored-By: SWE-Agent.ai <noreply@swe-agent.ai>
This commit is contained in:
cexll
2026-02-03 21:58:08 +08:00
parent 04fa1626ae
commit 74e4d181c2
19 changed files with 1257 additions and 433 deletions

View File

@@ -30,6 +30,7 @@ type cliOptions struct {
Agent string
PromptFile string
SkipPermissions bool
Worktree bool
Parallel bool
FullOutput bool
@@ -136,6 +137,7 @@ func addRootFlags(fs *pflag.FlagSet, opts *cliOptions) {
fs.BoolVar(&opts.SkipPermissions, "skip-permissions", false, "Skip permissions prompts (also via CODEAGENT_SKIP_PERMISSIONS)")
fs.BoolVar(&opts.SkipPermissions, "dangerously-skip-permissions", false, "Alias for --skip-permissions")
fs.BoolVar(&opts.Worktree, "worktree", false, "Execute in a new git worktree (auto-generates task ID)")
}
func newVersionCommand(name string) *cobra.Command {
@@ -350,6 +352,7 @@ func buildSingleConfig(cmd *cobra.Command, args []string, rawArgv []string, opts
MaxParallelWorkers: config.ResolveMaxParallelWorkers(),
AllowedTools: resolvedAllowedTools,
DisallowedTools: resolvedDisallowedTools,
Worktree: opts.Worktree,
}
if args[0] == "resume" {
@@ -653,6 +656,7 @@ func runSingleMode(cfg *Config, name string) int {
ReasoningEffort: cfg.ReasoningEffort,
Agent: cfg.Agent,
SkipPermissions: cfg.SkipPermissions,
Worktree: cfg.Worktree,
AllowedTools: cfg.AllowedTools,
DisallowedTools: cfg.DisallowedTools,
UseStdin: useStdin,

View File

@@ -1616,6 +1616,60 @@ do something`
}
}
func TestParallelParseConfig_Worktree(t *testing.T) {
input := `---TASK---
id: task-1
worktree: true
---CONTENT---
do something`
cfg, err := parseParallelConfig([]byte(input))
if err != nil {
t.Fatalf("parseParallelConfig() unexpected error: %v", err)
}
if len(cfg.Tasks) != 1 {
t.Fatalf("expected 1 task, got %d", len(cfg.Tasks))
}
task := cfg.Tasks[0]
if !task.Worktree {
t.Fatalf("Worktree = %v, want true", task.Worktree)
}
}
func TestParallelParseConfig_WorktreeBooleanValue(t *testing.T) {
tests := []struct {
name string
value string
want bool
}{
{"true", "true", true},
{"1", "1", true},
{"yes", "yes", true},
{"false", "false", false},
{"0", "0", false},
{"no", "no", false},
{"empty", "", true},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
input := fmt.Sprintf(`---TASK---
id: task-1
worktree: %s
---CONTENT---
do something`, tt.value)
cfg, err := parseParallelConfig([]byte(input))
if err != nil {
t.Fatalf("parseParallelConfig() unexpected error: %v", err)
}
if cfg.Tasks[0].Worktree != tt.want {
t.Fatalf("Worktree = %v, want %v for value %q", cfg.Tasks[0].Worktree, tt.want, tt.value)
}
})
}
}
func TestParallelParseConfig_EmptySessionID(t *testing.T) {
input := `---TASK---
id: task-1