Compare commits
3 Commits
v0.2.17
...
20de1fd3d6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
20de1fd3d6 | ||
| 2beb3adb14 | |||
| bfd6778f8b |
@@ -261,27 +261,6 @@ 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:-}"
|
||||||
@@ -400,15 +379,37 @@ 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')
|
||||||
local msg_file="$LOGS_DIR/msg-$sanitized_id.txt"
|
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"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
set_debug_mode() {
|
||||||
|
local filtered_args=()
|
||||||
|
local debug_mode=false
|
||||||
|
|
||||||
|
for arg in "$@"; do
|
||||||
|
case "$arg" in
|
||||||
|
--debug)
|
||||||
|
debug_mode=true
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
filtered_args+=("$arg")
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$debug_mode" = true ]; then
|
||||||
|
export KUGETSU_VERBOSITY="debug"
|
||||||
|
echo "[DEBUG] Debug mode enabled" >&2
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "${filtered_args[@]}"
|
||||||
|
}
|
||||||
|
|
||||||
cmd_continue() {
|
cmd_continue() {
|
||||||
local session_name=""
|
local session_name=""
|
||||||
local message=""
|
local message=""
|
||||||
@@ -454,16 +455,9 @@ 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"
|
||||||
if [ -n "$previous_context" ]; then
|
echo "Calling cmd_start to create new session and worktree..." >&2
|
||||||
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
|
||||||
@@ -474,10 +468,9 @@ 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')
|
||||||
local msg_file="$LOGS_DIR/msg-$sanitized_id.txt"
|
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