fix: worktree path stays under workspace, not inside project repo

repoRoot is used for git operations only. The worktree directory lives
under ai.Workspace/.picoclaw/worktrees/ to avoid polluting the user's
project with a .picoclaw directory.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
dj-oyu 2026-02-24 18:05:40 +09:00
parent 1e5926ee35
commit bbc3dea9ed

View file

@ -208,7 +208,7 @@ func resolvePlanFallbacks(agentCfg *config.AgentConfig, defaults *config.AgentDe
// ActivateWorktree creates a worktree for a session.
// projectDir is the git repository to create the worktree in.
// If empty, falls back to ai.Workspace.
// Path: <projectDir>/.picoclaw/worktrees/<branch-basename>/
// Worktree path: <workspace>/.picoclaw/worktrees/<branch-basename>/
func (ai *AgentInstance) ActivateWorktree(sessionKey, taskName, projectDir string) (*git.WorktreeInfo, error) {
if projectDir == "" {
projectDir = ai.Workspace
@ -220,7 +220,7 @@ func (ai *AgentInstance) ActivateWorktree(sessionKey, taskName, projectDir strin
branchName := git.SanitizeBranchName(taskName)
baseName := git.BranchBaseName(branchName)
wtPath := filepath.Join(repoRoot, ".picoclaw", "worktrees", baseName)
wtPath := filepath.Join(ai.Workspace, ".picoclaw", "worktrees", baseName)
wt, err := git.CreateWorktree(repoRoot, wtPath, branchName)
if err != nil {