Compare commits
1 Commits
e0aac3c05f
...
v0.2.17
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c54906be4b |
@@ -261,6 +261,27 @@ create_session() {
|
|||||||
echo "$new_session_id"
|
echo "$new_session_id"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
load_session_context() {
|
||||||
|
local opencode_session_id="$1"
|
||||||
|
local sanitized_id=$(echo "$opencode_session_id" | sed 's/[^a-zA-Z0-9_-]/_/g')
|
||||||
|
local log_file="$LOGS_DIR/dev-$sanitized_id.log"
|
||||||
|
|
||||||
|
if [ ! -f "$log_file" ]; then
|
||||||
|
echo ""
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
local context_summary="Previous session context (work was in progress, session may have crashed or been interrupted):\n\n"
|
||||||
|
context_summary+=$(tail -100 "$log_file" 2>/dev/null | while IFS= read -r line; do
|
||||||
|
line=$(strip_ansi_codes "$line")
|
||||||
|
echo " $line"
|
||||||
|
done | head -50)
|
||||||
|
|
||||||
|
context_summary+="\n\nPlease review this context and continue the work appropriately."
|
||||||
|
|
||||||
|
echo "$context_summary"
|
||||||
|
}
|
||||||
|
|
||||||
build_dev_agent_message() {
|
build_dev_agent_message() {
|
||||||
local issue_ref="$1"
|
local issue_ref="$1"
|
||||||
local user_message="${2:-}"
|
local user_message="${2:-}"
|
||||||
@@ -271,28 +292,7 @@ build_dev_agent_message() {
|
|||||||
local number=$(echo "$issue_ref" | grep -oE '#[0-9]+$' | tr -d '#')
|
local number=$(echo "$issue_ref" | grep -oE '#[0-9]+$' | tr -d '#')
|
||||||
local worktree_path=$(issue_ref_to_worktree_path "$issue_ref")
|
local worktree_path=$(issue_ref_to_worktree_path "$issue_ref")
|
||||||
|
|
||||||
if [ -n "$user_message" ]; then
|
local base_message="You are assigned to work on $issue_ref.
|
||||||
cat <<EOF
|
|
||||||
You are continuing work on $issue_ref. A PR likely already exists.
|
|
||||||
|
|
||||||
IMPORTANT - Review workflow:
|
|
||||||
1. First, check if PR exists: curl -s "https://$instance/api/v1/repos/$owner/$repo/pulls?state=open" -H "Authorization: Bearer \$GITEA_TOKEN" | grep -i "$number"
|
|
||||||
2. Get PR comments: curl -s "https://$instance/api/v1/repos/$owner/$repo/issues/$number/comments" -H "Authorization: Bearer \$GITEA_TOKEN"
|
|
||||||
3. Get PR reviews: curl -s "https://$instance/api/v1/repos/$owner/$repo/pulls/$number/reviews" -H "Authorization: Bearer \$GITEA_TOKEN"
|
|
||||||
|
|
||||||
You may need to:
|
|
||||||
- Make code changes and push to the same branch
|
|
||||||
- Reply to PR comments using: curl -X POST "https://$instance/api/v1/repos/$owner/$repo/issues/$number/comments" -H "Authorization: Bearer \$GITEA_TOKEN" -H "Content-Type: application/json" -d '{"body":"Your reply here"}'
|
|
||||||
- Or do both
|
|
||||||
|
|
||||||
Delegator's message:
|
|
||||||
$user_message
|
|
||||||
|
|
||||||
Work directory: $worktree_path (already on the fix branch)
|
|
||||||
EOF
|
|
||||||
else
|
|
||||||
cat <<EOF
|
|
||||||
You are assigned to work on $issue_ref.
|
|
||||||
|
|
||||||
Workflow:
|
Workflow:
|
||||||
1. Read the issue at $instance/$owner/$repo/issues/$number AND all comments on that issue
|
1. Read the issue at $instance/$owner/$repo/issues/$number AND all comments on that issue
|
||||||
@@ -307,17 +307,17 @@ Workflow:
|
|||||||
6. If anything is unclear, post a comment on the issue asking for clarification before implementing
|
6. If anything is unclear, post a comment on the issue asking for clarification before implementing
|
||||||
7. Implement the solution
|
7. Implement the solution
|
||||||
8. Create a branch named fix/issue-$number and implement the fix
|
8. Create a branch named fix/issue-$number and implement the fix
|
||||||
9. Create a PR when the implementation is complete using: tea pr create --repo $owner/$repo --title "Your PR title" --body "PR description"
|
9. Create a PR when the implementation is complete
|
||||||
- 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"}'
|
|
||||||
|
|
||||||
Tools for PR interaction:
|
Work directory: $worktree_path"
|
||||||
- Post issue/PR comment: curl -X POST "https://$instance/api/v1/repos/$owner/$repo/issues/$number/comments" -H "Authorization: Bearer \$GITEA_TOKEN" -H "Content-Type: application/json" -d '{"body":"Your comment"}'
|
|
||||||
- List PR comments: curl -s "https://$instance/api/v1/repos/$owner/$repo/issues/$number/comments" -H "Authorization: Bearer \$GITEA_TOKEN"
|
if [ -n "$user_message" ]; then
|
||||||
- List PR reviews: curl -s "https://$instance/api/v1/repos/$owner/$repo/pulls/$number/reviews" -H "Authorization: Bearer \$GITEA_TOKEN"
|
echo "$base_message
|
||||||
|
|
||||||
Work directory: $worktree_path
|
Additional instructions from delegator:
|
||||||
EOF
|
$user_message"
|
||||||
|
else
|
||||||
|
echo "$base_message"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,13 +400,10 @@ cmd_start() {
|
|||||||
|
|
||||||
cd "$worktree_path"
|
cd "$worktree_path"
|
||||||
local sanitized_id=$(echo "$new_session_id" | sed 's/[^a-zA-Z0-9_-]/_/g')
|
local sanitized_id=$(echo "$new_session_id" | sed 's/[^a-zA-Z0-9_-]/_/g')
|
||||||
mkdir -p "$worktree_path/.kugetsu"
|
local msg_file="$LOGS_DIR/msg-$sanitized_id.txt"
|
||||||
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"
|
printf '%s' "$dev_message" > "$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 &
|
nohup sh -c "GITEA_TOKEN='${GITEA_TOKEN:-}' opencode run '@$msg_file' --session '$new_session_id'" >> "$LOGS_DIR/dev-$sanitized_id.log" 2>&1 &
|
||||||
|
rm -f "$msg_file"
|
||||||
|
|
||||||
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"
|
||||||
@@ -457,9 +454,16 @@ cmd_continue() {
|
|||||||
|
|
||||||
if [ -z "$worktree_path" ] || [ ! -d "$worktree_path" ]; then
|
if [ -z "$worktree_path" ] || [ ! -d "$worktree_path" ]; then
|
||||||
echo "Warning: Worktree is missing for '$session_name'. Recovering..." >&2
|
echo "Warning: Worktree is missing for '$session_name'. Recovering..." >&2
|
||||||
|
local previous_context=$(load_session_context "$opencode_session_id")
|
||||||
rm -f "$session_path"
|
rm -f "$session_path"
|
||||||
remove_issue_from_index "$session_name"
|
remove_issue_from_index "$session_name"
|
||||||
echo "Calling cmd_start to create new session and worktree..." >&2
|
if [ -n "$previous_context" ]; then
|
||||||
|
message="$previous_context"
|
||||||
|
if [ -n "$message" ]; then
|
||||||
|
message="$message"$'\n\n'"Additional user message: $message"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
echo "Calling cmd_start to create new session and worktree with context..." >&2
|
||||||
cmd_start "$session_name" "$message"
|
cmd_start "$session_name" "$message"
|
||||||
return $?
|
return $?
|
||||||
fi
|
fi
|
||||||
@@ -470,13 +474,10 @@ cmd_continue() {
|
|||||||
|
|
||||||
cd "$worktree_path"
|
cd "$worktree_path"
|
||||||
local sanitized_id=$(echo "$opencode_session_id" | sed 's/[^a-zA-Z0-9_-]/_/g')
|
local sanitized_id=$(echo "$opencode_session_id" | sed 's/[^a-zA-Z0-9_-]/_/g')
|
||||||
mkdir -p "$worktree_path/.kugetsu"
|
local msg_file="$LOGS_DIR/msg-$sanitized_id.txt"
|
||||||
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"
|
printf '%s' "$message" > "$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 &
|
nohup sh -c "GITEA_TOKEN='${GITEA_TOKEN:-}' opencode run '@$msg_file' --session '$opencode_session_id'" >> "$LOGS_DIR/dev-$sanitized_id.log" 2>&1 &
|
||||||
|
rm -f "$msg_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd_list() {
|
cmd_list() {
|
||||||
|
|||||||
Reference in New Issue
Block a user