mirror of
https://github.com/cline/cline.git
synced 2026-09-19 02:05:44 +08:00
* feat(cli): add --worktree flag to auto-create and run in a new git worktree Adds a --worktree flag to the CLI root command and 'cline task' that detects the git repo root for the current directory, creates a detached-HEAD worktree at ~/.cline/worktrees/<uuid>/<repoName>/ (matching Kanban's convention), and runs the task with cwd set to the new worktree. The core implementation lives in src/utils/git-worktree.ts as createTaskWorktree() so any surface (CLI, VS Code, JetBrains, future tools) can use the same helper. Works with --taskId and --continue so the legitimate workflow of 'resume this task in a fresh clean worktree to try a different approach' is supported. For --continue, the most-recent-task lookup uses the original cwd before the worktree rewrite so history resolves correctly. Refs: ENG-2028 * address greptile review - Distinguish 'git not installed' from 'not a git repo' so the error message points at the actual problem instead of misleading the user. - Reject taskIds containing a null byte; would otherwise sneak past the '..' substring check on some kernels (e.g. 'safe\\0../escape'). - Reject `--worktree` without a prompt / --taskId / --continue before kanban auto-launches, so 'cline --worktree' no longer creates an orphan worktree that's abandoned if the user exits the welcome TUI without submitting a task. * feat(cli): move worktree flag to sdk cli * fix(cli): match kanban worktree ids * fix(cli): handle piped worktree input * chore: remove legacy worktree diff --------- Co-authored-by: Saoud Rizwan <7799382+saoudrizwan@users.noreply.github.com>