feat(kugetsu): implement issue-driven session management #15
@@ -249,6 +249,11 @@ cmd_start() {
|
|||||||
|
|
||||||
local session_file="$(issue_ref_to_filename "$issue_ref").json"
|
local session_file="$(issue_ref_to_filename "$issue_ref").json"
|
||||||
|
|
||||||
|
printf '{"type": "forked", "issue_ref": "%s", "opencode_session_id": "pending", "created_at": "%s", "state": "starting"}\n' \
|
||||||
|
"$issue_ref" "$(date -Iseconds)" > "$SESSIONS_DIR/$session_file"
|
||||||
|
|
||||||
|
add_issue_to_index "$issue_ref" "$session_file"
|
||||||
|
|
||||||
echo "Forking session for '$issue_ref'..."
|
echo "Forking session for '$issue_ref'..."
|
||||||
local fork_output
|
local fork_output
|
||||||
if [ "$DEBUG_MODE" = true ]; then
|
if [ "$DEBUG_MODE" = true ]; then
|
||||||
@@ -260,19 +265,19 @@ cmd_start() {
|
|||||||
local new_session_id=$(echo "$fork_output" | grep -oP 'A new forked session was created: \Kses_\w+' | tail -1)
|
local new_session_id=$(echo "$fork_output" | grep -oP 'A new forked session was created: \Kses_\w+' | tail -1)
|
||||||
|
|
||||||
if [ -z "$new_session_id" ]; then
|
if [ -z "$new_session_id" ]; then
|
||||||
new_session_id=$(opencode session list 2>/dev/null | grep -E '^ses_' | awk '{print $1}' | grep -v "^$base_session_id$" | tail -1)
|
new_session_id=$(opencode session list 2>/dev/null | grep -E '^ses_' | awk '{print $1}' | grep -v "^$base_session_id$" | head -1)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$new_session_id" ]; then
|
if [ -z "$new_session_id" ]; then
|
||||||
echo "Error: Could not find newly created session" >&2
|
echo "Error: Could not find newly created session" >&2
|
||||||
|
printf '{"type": "forked", "issue_ref": "%s", "opencode_session_id": "failed", "created_at": "%s", "state": "failed"}\n' \
|
||||||
|
"$issue_ref" "$(date -Iseconds)" > "$SESSIONS_DIR/$session_file"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf '{"type": "forked", "issue_ref": "%s", "opencode_session_id": "%s", "created_at": "%s", "state": "idle"}\n' \
|
printf '{"type": "forked", "issue_ref": "%s", "opencode_session_id": "%s", "created_at": "%s", "state": "idle"}\n' \
|
||||||
"$issue_ref" "$new_session_id" "$(date -Iseconds)" > "$SESSIONS_DIR/$session_file"
|
"$issue_ref" "$new_session_id" "$(date -Iseconds)" > "$SESSIONS_DIR/$session_file"
|
||||||
|
|
||||||
add_issue_to_index "$issue_ref" "$session_file"
|
|
||||||
|
|
||||||
echo "Session started for '$issue_ref': $new_session_id"
|
echo "Session started for '$issue_ref': $new_session_id"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user