cmd_start fails — issue_ref_to_worktree_path creates doubled path #179

Closed
opened 2026-04-06 05:19:38 +02:00 by shoko · 0 comments
Owner

Summary

Queue daemon runs and processes tasks correctly, but cmd_start fails immediately with "Failed to clone repository". No worktree is created, task is marked error, daemon loops.

Root Cause

The issue_ref_to_worktree_path() function in kugetsu-worktree.sh creates an incorrect path:

issue_ref_to_worktree_path() {
    local issue_ref="$1"
    local parent_dir="${2:-$WORKTREES_DIR}"
    local worktree_name=$(issue_ref_to_worktree_name "$issue_ref")
    echo "$parent_dir/.kugetsu-worktrees/$worktree_name"
}

Since $parent_dir is already $WORKTREES_DIR which is ~/.kugetsu-worktrees, this produces:

~/.kugetsu-worktrees/.kugetsu-worktrees/git.fbrns.co-shoko-kugetsu-158

Instead of:

~/.kugetsu-worktrees/git.fbrns.co-shoko-kugetsu-158

The doubled path causes the git clone to fail (wrong directory), and cmd_start exits with code 1, causing the daemon to mark the task as error.

Reproduction

# Any kugetsu delegate call fails because cmd_start cannot create worktree
kugetsu delegate "https://git.fbrns.co/shoko/kugetsu/issues/158 — test"
# Task immediately goes to error state

Observed Daemon Behavior

When daemon runs:

  1. Picks up pending task
  2. Calls cmd_start git.fbrns.co/shoko/kugetsu#158 "message"
  3. cmd_start calls worktree_exists → uses wrong path (doubled)
  4. worktree_exists returns false (path doesn't exist as expected)
  5. cmd_start calls create_worktree → clones to wrong path → fails
  6. cmd_start exits 1, daemon marks task error

Fix

issue_ref_to_worktree_path() {
    local issue_ref="$1"
    local parent_dir="${2:-$WORKTREES_DIR}"
    local worktree_name=$(issue_ref_to_worktree_name "$issue_ref")
    echo "$parent_dir/$worktree_name"
}

Remove the extra /.kugetsu-worktrees/ in the path construction.

## Summary Queue daemon runs and processes tasks correctly, but `cmd_start` fails immediately with "Failed to clone repository". No worktree is created, task is marked error, daemon loops. ## Root Cause The `issue_ref_to_worktree_path()` function in `kugetsu-worktree.sh` creates an incorrect path: ```bash issue_ref_to_worktree_path() { local issue_ref="$1" local parent_dir="${2:-$WORKTREES_DIR}" local worktree_name=$(issue_ref_to_worktree_name "$issue_ref") echo "$parent_dir/.kugetsu-worktrees/$worktree_name" } ``` Since `$parent_dir` is already `$WORKTREES_DIR` which is `~/.kugetsu-worktrees`, this produces: ``` ~/.kugetsu-worktrees/.kugetsu-worktrees/git.fbrns.co-shoko-kugetsu-158 ``` Instead of: ``` ~/.kugetsu-worktrees/git.fbrns.co-shoko-kugetsu-158 ``` The doubled path causes the git clone to fail (wrong directory), and `cmd_start` exits with code 1, causing the daemon to mark the task as error. ## Reproduction ```bash # Any kugetsu delegate call fails because cmd_start cannot create worktree kugetsu delegate "https://git.fbrns.co/shoko/kugetsu/issues/158 — test" # Task immediately goes to error state ``` ## Observed Daemon Behavior When daemon runs: 1. Picks up pending task 2. Calls `cmd_start git.fbrns.co/shoko/kugetsu#158 "message"` 3. `cmd_start` calls `worktree_exists` → uses wrong path (doubled) 4. `worktree_exists` returns false (path doesn't exist as expected) 5. `cmd_start` calls `create_worktree` → clones to wrong path → fails 6. `cmd_start` exits 1, daemon marks task error ## Fix ```bash issue_ref_to_worktree_path() { local issue_ref="$1" local parent_dir="${2:-$WORKTREES_DIR}" local worktree_name=$(issue_ref_to_worktree_name "$issue_ref") echo "$parent_dir/$worktree_name" } ``` Remove the extra `/.kugetsu-worktrees/` in the path construction.
shoko closed this issue 2026-04-06 05:27:16 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: shoko/kugetsu#179