Compare commits

...

6 Commits

Author SHA1 Message Date
shokollm
6aa84a35b9 fix: syntax error in cmd_continue line 372 (issue #189)
Wrap nohup command in subshell to fix '&& disown' syntax error
2026-04-06 08:44:29 +00:00
6e2841bbda Merge pull request 'fix: cmd_start and cmd_continue now fork dev agent to work on task (issue #187)' (#188) from fix/issue-187-start-forks-agent into main 2026-04-06 10:13:42 +02:00
shokollm
99d09c7dda fix: cmd_start and cmd_continue now fork dev agent to work on task (issue #187)
- Added build_dev_agent_message() function to generate default workflow prompt
- cmd_start now forks the agent after creating session (fire-and-forget)
- cmd_continue now uses default message when empty and forks agent (fire-and-forget)
- Both commands log output to $LOGS_DIR/dev-$session_id.log
2026-04-06 08:05:42 +00:00
383f538438 Merge pull request 'fix: worktree created in wrong directory (issue #185)' (#186) from fix/issue-185-worktree-wrong-directory into main 2026-04-06 07:33:02 +02:00
3a2095861f Merge pull request 'fix: destroy --base -y fails with 'target is required' (issue #183)' (#184) from fix/issue-183-destroy-base-requires-target into main 2026-04-06 06:16:30 +02:00
4f2a04e0b4 Merge pull request 'fix: get_repo_url() strips user/org from path (issue #181)' (#182) from fix/issue-181-get-repo-url-strips-user-org into main 2026-04-06 06:07:46 +02:00

View File

@@ -199,6 +199,45 @@ cmd_delegate() {
echo "Delegated to PM agent (logged to $(basename "$log_file"))" echo "Delegated to PM agent (logged to $(basename "$log_file"))"
} }
build_dev_agent_message() {
local issue_ref="$1"
local user_message="${2:-}"
local instance=$(echo "$issue_ref" | cut -d'/' -f1 | cut -d'#' -f1)
local owner=$(echo "$issue_ref" | cut -d'/' -f2)
local repo=$(echo "$issue_ref" | cut -d'/' -f3 | cut -d'#' -f1)
local number=$(echo "$issue_ref" | grep -oE '#[0-9]+$' | tr -d '#')
local worktree_path=$(issue_ref_to_worktree_path "$issue_ref")
local base_message="You are assigned to work on $issue_ref.
Workflow:
1. Read the issue at $instance/$owner/$repo/issues/$number AND all comments on that issue
2. Check if a PR already exists for this issue
- If PR exists and is open, review it and learn from it
- If PR makes sense to continue, work on it instead
- If PR is not worth continuing, create a new branch/PR but explain in PR description why you're creating a new one instead of continuing the existing PR
3. Read README.md (if exists) to understand the general concept of this repository
4. Read CONTRIBUTING.md (if exists) to understand how to contribute
- If CONTRIBUTING.md doesn't exist, follow steps 5-9 as your guideline
5. Explore the repository to understand the codebase
6. If anything is unclear, post a comment on the issue asking for clarification before implementing
7. Implement the solution
8. Create a branch named fix/issue-$number and implement the fix
9. Create a PR when the implementation is complete
Work directory: $worktree_path"
if [ -n "$user_message" ]; then
echo "$base_message
Additional instructions from delegator:
$user_message"
else
echo "$base_message"
fi
}
cmd_start() { cmd_start() {
local issue_ref="${1:-}" local issue_ref="${1:-}"
local message="${2:-}" local message="${2:-}"
@@ -270,6 +309,12 @@ cmd_start() {
add_issue_to_index "$issue_ref" "$session_file" add_issue_to_index "$issue_ref" "$session_file"
local dev_message=$(build_dev_agent_message "$issue_ref" "$message")
load_agent_env "dev"
(cd "$worktree_path" && nohup sh -c "GITEA_TOKEN='$GITEA_TOKEN' opencode run '$dev_message' --continue --session '$new_session_id'" >> "$LOGS_DIR/dev-$new_session_id.log" 2>&1 &) && disown
echo "Session started for '$issue_ref': $new_session_id" echo "Session started for '$issue_ref': $new_session_id"
echo "Worktree: $worktree_path" echo "Worktree: $worktree_path"
} }
@@ -315,19 +360,16 @@ cmd_continue() {
local opencode_session_id=$(python3 -c "import json; print(json.load(open('$session_path')).get('opencode_session_id', ''))" 2>/dev/null || echo "") local opencode_session_id=$(python3 -c "import json; print(json.load(open('$session_path')).get('opencode_session_id', ''))" 2>/dev/null || echo "")
local worktree_path=$(python3 -c "import json; print(json.load(open('$session_path')).get('worktree_path', ''))" 2>/dev/null || echo "") local worktree_path=$(python3 -c "import json; print(json.load(open('$session_path')).get('worktree_path', ''))" 2>/dev/null || echo "")
local issue_ref=$(python3 -c "import json; print(json.load(open('$session_path')).get('issue_ref', ''))" 2>/dev/null || echo "")
if [ -z "$message" ]; then
message=$(build_dev_agent_message "$issue_ref" "")
fi
if [ -n "$worktree_path" ] && [ -d "$worktree_path" ]; then if [ -n "$worktree_path" ] && [ -d "$worktree_path" ]; then
if [ -n "$message" ]; then (cd "$worktree_path" && nohup sh -c "GITEA_TOKEN='$GITEA_TOKEN' opencode run '$message' --continue --session '$opencode_session_id'" >> "$LOGS_DIR/dev-$opencode_session_id.log" 2>&1 &) && disown
(cd "$worktree_path" && opencode run "$message" --continue --session "$opencode_session_id" "$@")
else else
(cd "$worktree_path" && opencode --continue --session "$opencode_session_id" "$@") (nohup sh -c "GITEA_TOKEN='$GITEA_TOKEN' opencode run '$message' --continue --session '$opencode_session_id'" >> "$LOGS_DIR/dev-$opencode_session_id.log" 2>&1 &) && disown
fi
else
if [ -n "$message" ]; then
opencode run "$message" --continue --session "$opencode_session_id" "$@"
else
opencode --continue --session "$opencode_session_id" "$@"
fi
fi fi
} }