|
|
|
|
@@ -241,20 +241,22 @@ create_session() {
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
local before_json=$(opencode session list --format=json 2>/dev/null)
|
|
|
|
|
local before_ids=$(echo "$before_json" | python3 -c "import sys,json; sessions=json.load(sys.stdin); print(' '.join(s['id'] for s in sessions))" 2>/dev/null || echo "")
|
|
|
|
|
local before_set=$(echo "$before_json" | python3 -c "import sys,json; sessions=json.load(sys.stdin); print('|'.join(s['id'] for s in sessions))" 2>/dev/null || echo "|")
|
|
|
|
|
|
|
|
|
|
opencode run --fork --session "$base_session" "new session" 2>/dev/null
|
|
|
|
|
opencode run --fork --session "$base_session" "new session" >/dev/null 2>&1
|
|
|
|
|
|
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
|
|
local after_json=$(opencode session list --format=json 2>/dev/null)
|
|
|
|
|
local after_ids=$(echo "$after_json" | python3 -c "import sys,json; sessions=json.load(sys.stdin); print(' '.join(s['id'] for s in sessions))" 2>/dev/null || echo "")
|
|
|
|
|
local after_sessions=$(echo "$after_json" | python3 -c "import sys,json; sessions=json.load(sys.stdin); [print(s['id']) for s in sessions]" 2>/dev/null || true)
|
|
|
|
|
|
|
|
|
|
local new_session_id=""
|
|
|
|
|
for sess in $after_ids; do
|
|
|
|
|
if [[ ! " $before_ids " =~ " $sess " ]] && [[ "$sess" != "$base_session" ]]; then
|
|
|
|
|
while IFS= read -r sess; do
|
|
|
|
|
if [[ -n "$sess" ]] && [[ ! "$before_set" =~ \|${sess}\| ]]; then
|
|
|
|
|
new_session_id="$sess"
|
|
|
|
|
break
|
|
|
|
|
fi
|
|
|
|
|
done
|
|
|
|
|
done <<< "$after_sessions"
|
|
|
|
|
|
|
|
|
|
echo "$new_session_id"
|
|
|
|
|
}
|
|
|
|
|
@@ -284,7 +286,9 @@ Workflow:
|
|
|
|
|
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
|
|
|
|
|
9. Create a PR when the implementation is complete using: tea pr create --repo $owner/$repo --title \"Your PR title\" --body \"PR description\"
|
|
|
|
|
- Make sure you are logged in with: tea login add --name gitea --token \$GITEA_TOKEN --url https://$instance
|
|
|
|
|
- If tea is not available, use: curl -X POST \"https://$instance/api/v1/repos/$owner/$repo/pulls\" -H \"Authorization: Bearer \$GITEA_TOKEN\" -H \"Content-Type: application/json\" -d '{\"title\":\"PR Title\",\"head\":\"branch-name\",\"base\":\"main\",\"body\":\"PR description\"}'
|
|
|
|
|
|
|
|
|
|
Work directory: $worktree_path"
|
|
|
|
|
|
|
|
|
|
@@ -376,10 +380,14 @@ cmd_start() {
|
|
|
|
|
load_agent_env "dev"
|
|
|
|
|
|
|
|
|
|
cd "$worktree_path"
|
|
|
|
|
local msg_file="$LOGS_DIR/msg-$new_session_id.txt"
|
|
|
|
|
local sanitized_id=$(echo "$new_session_id" | sed 's/[^a-zA-Z0-9_-]/_/g')
|
|
|
|
|
mkdir -p "$worktree_path/.kugetsu"
|
|
|
|
|
if [ ! -f "$worktree_path/.gitignore" ] || ! grep -q "^.kugetsu/" "$worktree_path/.gitignore"; then
|
|
|
|
|
echo ".kugetsu/" >> "$worktree_path/.gitignore" 2>/dev/null || true
|
|
|
|
|
fi
|
|
|
|
|
local msg_file="$worktree_path/.kugetsu/msg.txt"
|
|
|
|
|
printf '%s' "$dev_message" > "$msg_file"
|
|
|
|
|
nohup sh -c "GITEA_TOKEN='${GITEA_TOKEN:-}' opencode run '@$msg_file' --session '$new_session_id'" >> "$LOGS_DIR/dev-$new_session_id.log" 2>&1 &
|
|
|
|
|
rm -f "$msg_file"
|
|
|
|
|
nohup sh -c "GITEA_TOKEN='${GITEA_TOKEN:-}' opencode run '@$msg_file' --session '$new_session_id'" >> "$LOGS_DIR/dev-$sanitized_id.log" 2>&1 &
|
|
|
|
|
|
|
|
|
|
echo "Session started for '$issue_ref': $new_session_id"
|
|
|
|
|
echo "Worktree: $worktree_path"
|
|
|
|
|
@@ -442,10 +450,14 @@ cmd_continue() {
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
cd "$worktree_path"
|
|
|
|
|
local msg_file="$LOGS_DIR/msg-$opencode_session_id.txt"
|
|
|
|
|
local sanitized_id=$(echo "$opencode_session_id" | sed 's/[^a-zA-Z0-9_-]/_/g')
|
|
|
|
|
mkdir -p "$worktree_path/.kugetsu"
|
|
|
|
|
if [ ! -f "$worktree_path/.gitignore" ] || ! grep -q "^.kugetsu/" "$worktree_path/.gitignore"; then
|
|
|
|
|
echo ".kugetsu/" >> "$worktree_path/.gitignore" 2>/dev/null || true
|
|
|
|
|
fi
|
|
|
|
|
local msg_file="$worktree_path/.kugetsu/msg.txt"
|
|
|
|
|
printf '%s' "$message" > "$msg_file"
|
|
|
|
|
nohup sh -c "GITEA_TOKEN='${GITEA_TOKEN:-}' opencode run '@$msg_file' --session '$opencode_session_id'" >> "$LOGS_DIR/dev-$opencode_session_id.log" 2>&1 &
|
|
|
|
|
rm -f "$msg_file"
|
|
|
|
|
nohup sh -c "GITEA_TOKEN='${GITEA_TOKEN:-}' opencode run '@$msg_file' --session '$opencode_session_id'" >> "$LOGS_DIR/dev-$sanitized_id.log" 2>&1 &
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmd_list() {
|
|
|
|
|
|