loki-mode 5.4.2 → 5.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/SKILL.md +2 -2
- package/VERSION +1 -1
- package/autonomy/.loki/dashboard/index.html +34 -1
- package/autonomy/run.sh +253 -16
- package/package.json +1 -1
package/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: loki-mode
|
|
|
3
3
|
description: Multi-agent autonomous startup system. Triggers on "Loki Mode". Takes PRD to deployed product with zero human intervention. Requires --dangerously-skip-permissions flag.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Loki Mode v5.4.
|
|
6
|
+
# Loki Mode v5.4.4
|
|
7
7
|
|
|
8
8
|
**You are an autonomous agent. You make decisions. You do not ask questions. You do not stop.**
|
|
9
9
|
|
|
@@ -241,4 +241,4 @@ Auto-detected or force with `LOKI_COMPLEXITY`:
|
|
|
241
241
|
|
|
242
242
|
---
|
|
243
243
|
|
|
244
|
-
**v5.4.
|
|
244
|
+
**v5.4.4 | Background Mode + Task Tracking | ~245 lines core**
|
package/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
5.4.
|
|
1
|
+
5.4.4
|
|
@@ -153,6 +153,33 @@
|
|
|
153
153
|
font-weight: 400;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/* Project Info */
|
|
157
|
+
.project-info {
|
|
158
|
+
padding: 12px;
|
|
159
|
+
background: var(--bg-tertiary);
|
|
160
|
+
border-radius: 8px;
|
|
161
|
+
margin-top: 8px;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
.project-info .project-name {
|
|
165
|
+
font-size: 13px;
|
|
166
|
+
font-weight: 600;
|
|
167
|
+
color: var(--accent);
|
|
168
|
+
white-space: nowrap;
|
|
169
|
+
overflow: hidden;
|
|
170
|
+
text-overflow: ellipsis;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
.project-info .project-path {
|
|
174
|
+
font-size: 10px;
|
|
175
|
+
color: var(--text-muted);
|
|
176
|
+
font-family: 'JetBrains Mono', monospace;
|
|
177
|
+
white-space: nowrap;
|
|
178
|
+
overflow: hidden;
|
|
179
|
+
text-overflow: ellipsis;
|
|
180
|
+
margin-top: 2px;
|
|
181
|
+
}
|
|
182
|
+
|
|
156
183
|
/* Theme Toggle */
|
|
157
184
|
.theme-toggle {
|
|
158
185
|
display: flex;
|
|
@@ -1346,10 +1373,16 @@
|
|
|
1346
1373
|
<div class="logo-icon">L</div>
|
|
1347
1374
|
<div>
|
|
1348
1375
|
<div class="logo-text">Loki Mode</div>
|
|
1349
|
-
<div class="logo-version" id="version">
|
|
1376
|
+
<div class="logo-version" id="version">v5.4.2</div>
|
|
1350
1377
|
</div>
|
|
1351
1378
|
</div>
|
|
1352
1379
|
|
|
1380
|
+
<!-- Project Info (injected by run.sh) -->
|
|
1381
|
+
<div class="project-info" id="project-info">
|
|
1382
|
+
<div class="project-name" id="project-name">--</div>
|
|
1383
|
+
<div class="project-path" id="project-path" title="">--</div>
|
|
1384
|
+
</div>
|
|
1385
|
+
|
|
1353
1386
|
<!-- Theme Toggle -->
|
|
1354
1387
|
<div class="theme-toggle">
|
|
1355
1388
|
<span>Theme</span>
|
package/autonomy/run.sh
CHANGED
|
@@ -410,6 +410,9 @@ RESOURCE_CHECK_INTERVAL=${LOKI_RESOURCE_CHECK_INTERVAL:-300} # Check every 5 mi
|
|
|
410
410
|
RESOURCE_CPU_THRESHOLD=${LOKI_RESOURCE_CPU_THRESHOLD:-80} # CPU % threshold
|
|
411
411
|
RESOURCE_MEM_THRESHOLD=${LOKI_RESOURCE_MEM_THRESHOLD:-80} # Memory % threshold
|
|
412
412
|
|
|
413
|
+
# Background Mode
|
|
414
|
+
BACKGROUND_MODE=${LOKI_BACKGROUND:-false} # Run in background
|
|
415
|
+
|
|
413
416
|
# Security & Autonomy Controls
|
|
414
417
|
STAGED_AUTONOMY=${LOKI_STAGED_AUTONOMY:-false} # Require plan approval
|
|
415
418
|
AUDIT_LOG_ENABLED=${LOKI_AUDIT_LOG:-false} # Enable audit logging
|
|
@@ -1981,10 +1984,17 @@ write_dashboard_state() {
|
|
|
1981
1984
|
fi
|
|
1982
1985
|
|
|
1983
1986
|
# Write comprehensive JSON state
|
|
1987
|
+
local project_name=$(basename "$(pwd)")
|
|
1988
|
+
local project_path=$(pwd)
|
|
1989
|
+
|
|
1984
1990
|
cat > "$output_file" << EOF
|
|
1985
1991
|
{
|
|
1986
1992
|
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
|
1987
1993
|
"version": "$version",
|
|
1994
|
+
"project": {
|
|
1995
|
+
"name": "$project_name",
|
|
1996
|
+
"path": "$project_path"
|
|
1997
|
+
},
|
|
1988
1998
|
"mode": "$mode",
|
|
1989
1999
|
"phase": "$current_phase",
|
|
1990
2000
|
"complexity": "$complexity",
|
|
@@ -2019,6 +2029,124 @@ write_dashboard_state() {
|
|
|
2019
2029
|
EOF
|
|
2020
2030
|
}
|
|
2021
2031
|
|
|
2032
|
+
#===============================================================================
|
|
2033
|
+
# Task Queue Auto-Tracking (for degraded mode providers)
|
|
2034
|
+
#===============================================================================
|
|
2035
|
+
|
|
2036
|
+
# Track iteration start - create task in in-progress queue
|
|
2037
|
+
track_iteration_start() {
|
|
2038
|
+
local iteration="$1"
|
|
2039
|
+
local prd="${2:-}"
|
|
2040
|
+
local task_id="iteration-$iteration"
|
|
2041
|
+
|
|
2042
|
+
mkdir -p .loki/queue
|
|
2043
|
+
|
|
2044
|
+
# Create task entry
|
|
2045
|
+
local task_json=$(cat <<EOF
|
|
2046
|
+
{
|
|
2047
|
+
"id": "$task_id",
|
|
2048
|
+
"type": "iteration",
|
|
2049
|
+
"title": "Iteration $iteration",
|
|
2050
|
+
"description": "PRD: ${prd:-Codebase Analysis}",
|
|
2051
|
+
"status": "in_progress",
|
|
2052
|
+
"priority": "medium",
|
|
2053
|
+
"startedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
|
2054
|
+
"provider": "${PROVIDER_NAME:-claude}"
|
|
2055
|
+
}
|
|
2056
|
+
EOF
|
|
2057
|
+
)
|
|
2058
|
+
|
|
2059
|
+
# Add to in-progress queue
|
|
2060
|
+
local in_progress_file=".loki/queue/in-progress.json"
|
|
2061
|
+
if [ -f "$in_progress_file" ]; then
|
|
2062
|
+
local existing=$(cat "$in_progress_file")
|
|
2063
|
+
if [ "$existing" = "[]" ] || [ -z "$existing" ]; then
|
|
2064
|
+
echo "[$task_json]" > "$in_progress_file"
|
|
2065
|
+
else
|
|
2066
|
+
# Append to existing array
|
|
2067
|
+
echo "$existing" | python3 -c "
|
|
2068
|
+
import sys, json
|
|
2069
|
+
data = json.load(sys.stdin)
|
|
2070
|
+
data.append($task_json)
|
|
2071
|
+
print(json.dumps(data, indent=2))
|
|
2072
|
+
" > "$in_progress_file" 2>/dev/null || echo "[$task_json]" > "$in_progress_file"
|
|
2073
|
+
fi
|
|
2074
|
+
else
|
|
2075
|
+
echo "[$task_json]" > "$in_progress_file"
|
|
2076
|
+
fi
|
|
2077
|
+
|
|
2078
|
+
# Update current-task.json
|
|
2079
|
+
echo "$task_json" > .loki/queue/current-task.json
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
# Track iteration completion - move task to completed queue
|
|
2083
|
+
track_iteration_complete() {
|
|
2084
|
+
local iteration="$1"
|
|
2085
|
+
local exit_code="${2:-0}"
|
|
2086
|
+
local task_id="iteration-$iteration"
|
|
2087
|
+
|
|
2088
|
+
mkdir -p .loki/queue
|
|
2089
|
+
|
|
2090
|
+
# Get task from in-progress
|
|
2091
|
+
local in_progress_file=".loki/queue/in-progress.json"
|
|
2092
|
+
local completed_file=".loki/queue/completed.json"
|
|
2093
|
+
local failed_file=".loki/queue/failed.json"
|
|
2094
|
+
|
|
2095
|
+
# Initialize files if needed
|
|
2096
|
+
[ ! -f "$completed_file" ] && echo "[]" > "$completed_file"
|
|
2097
|
+
[ ! -f "$failed_file" ] && echo "[]" > "$failed_file"
|
|
2098
|
+
|
|
2099
|
+
# Create completed task entry
|
|
2100
|
+
local task_json=$(cat <<EOF
|
|
2101
|
+
{
|
|
2102
|
+
"id": "$task_id",
|
|
2103
|
+
"type": "iteration",
|
|
2104
|
+
"title": "Iteration $iteration",
|
|
2105
|
+
"status": "$([ "$exit_code" = "0" ] && echo "completed" || echo "failed")",
|
|
2106
|
+
"completedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
|
2107
|
+
"exitCode": $exit_code,
|
|
2108
|
+
"provider": "${PROVIDER_NAME:-claude}"
|
|
2109
|
+
}
|
|
2110
|
+
EOF
|
|
2111
|
+
)
|
|
2112
|
+
|
|
2113
|
+
# Add to appropriate queue
|
|
2114
|
+
local target_file="$completed_file"
|
|
2115
|
+
[ "$exit_code" != "0" ] && target_file="$failed_file"
|
|
2116
|
+
|
|
2117
|
+
python3 -c "
|
|
2118
|
+
import sys, json
|
|
2119
|
+
try:
|
|
2120
|
+
with open('$target_file', 'r') as f:
|
|
2121
|
+
data = json.load(f)
|
|
2122
|
+
except:
|
|
2123
|
+
data = []
|
|
2124
|
+
data.append($task_json)
|
|
2125
|
+
# Keep only last 50 entries
|
|
2126
|
+
data = data[-50:]
|
|
2127
|
+
with open('$target_file', 'w') as f:
|
|
2128
|
+
json.dump(data, f, indent=2)
|
|
2129
|
+
" 2>/dev/null || echo "[$task_json]" > "$target_file"
|
|
2130
|
+
|
|
2131
|
+
# Remove from in-progress
|
|
2132
|
+
if [ -f "$in_progress_file" ]; then
|
|
2133
|
+
python3 -c "
|
|
2134
|
+
import sys, json
|
|
2135
|
+
try:
|
|
2136
|
+
with open('$in_progress_file', 'r') as f:
|
|
2137
|
+
data = json.load(f)
|
|
2138
|
+
data = [t for t in data if t.get('id') != '$task_id']
|
|
2139
|
+
with open('$in_progress_file', 'w') as f:
|
|
2140
|
+
json.dump(data, f, indent=2)
|
|
2141
|
+
except:
|
|
2142
|
+
pass
|
|
2143
|
+
" 2>/dev/null || true
|
|
2144
|
+
fi
|
|
2145
|
+
|
|
2146
|
+
# Clear current-task.json
|
|
2147
|
+
echo "{}" > .loki/queue/current-task.json
|
|
2148
|
+
}
|
|
2149
|
+
|
|
2022
2150
|
start_status_monitor() {
|
|
2023
2151
|
log_step "Starting status monitor..."
|
|
2024
2152
|
|
|
@@ -2057,9 +2185,17 @@ stop_status_monitor() {
|
|
|
2057
2185
|
generate_dashboard() {
|
|
2058
2186
|
# Copy dashboard from skill installation (v4.0.0 with Anthropic design language)
|
|
2059
2187
|
local skill_dashboard="$SCRIPT_DIR/.loki/dashboard/index.html"
|
|
2188
|
+
local project_name=$(basename "$(pwd)")
|
|
2189
|
+
local project_path=$(pwd)
|
|
2190
|
+
|
|
2060
2191
|
if [ -f "$skill_dashboard" ]; then
|
|
2061
|
-
|
|
2192
|
+
# Copy and inject project info
|
|
2193
|
+
sed -e "s|Loki Mode</title>|Loki Mode - $project_name</title>|g" \
|
|
2194
|
+
-e "s|<div class=\"project-name\" id=\"project-name\">--|<div class=\"project-name\" id=\"project-name\">$project_name|g" \
|
|
2195
|
+
-e "s|<div class=\"project-path\" id=\"project-path\" title=\"\">--|<div class=\"project-path\" id=\"project-path\" title=\"$project_path\">$project_path|g" \
|
|
2196
|
+
"$skill_dashboard" > .loki/dashboard/index.html
|
|
2062
2197
|
log_info "Dashboard copied from skill installation"
|
|
2198
|
+
log_info "Project: $project_name ($project_path)"
|
|
2063
2199
|
return
|
|
2064
2200
|
fi
|
|
2065
2201
|
|
|
@@ -2853,11 +2989,36 @@ start_dashboard() {
|
|
|
2853
2989
|
# Generate HTML
|
|
2854
2990
|
generate_dashboard
|
|
2855
2991
|
|
|
2856
|
-
#
|
|
2857
|
-
|
|
2858
|
-
|
|
2859
|
-
|
|
2860
|
-
|
|
2992
|
+
# Find available port - don't kill other loki instances
|
|
2993
|
+
local original_port=$DASHBOARD_PORT
|
|
2994
|
+
local max_attempts=10
|
|
2995
|
+
local attempt=0
|
|
2996
|
+
|
|
2997
|
+
while lsof -i :$DASHBOARD_PORT &>/dev/null && [ $attempt -lt $max_attempts ]; do
|
|
2998
|
+
# Check if it's our own dashboard (same project)
|
|
2999
|
+
local existing_pid=$(lsof -ti :$DASHBOARD_PORT 2>/dev/null | head -1)
|
|
3000
|
+
local existing_cwd=""
|
|
3001
|
+
if [ -n "$existing_pid" ]; then
|
|
3002
|
+
existing_cwd=$(lsof -p "$existing_pid" 2>/dev/null | grep cwd | awk '{print $NF}')
|
|
3003
|
+
fi
|
|
3004
|
+
|
|
3005
|
+
if [ "$existing_cwd" = "$(pwd)/.loki" ]; then
|
|
3006
|
+
# Same project - kill and reuse port
|
|
3007
|
+
log_step "Killing existing dashboard for this project on port $DASHBOARD_PORT..."
|
|
3008
|
+
lsof -ti :$DASHBOARD_PORT | xargs kill -9 2>/dev/null || true
|
|
3009
|
+
sleep 1
|
|
3010
|
+
break
|
|
3011
|
+
else
|
|
3012
|
+
# Different project - find new port
|
|
3013
|
+
((DASHBOARD_PORT++))
|
|
3014
|
+
((attempt++))
|
|
3015
|
+
log_info "Port $((DASHBOARD_PORT-1)) in use by another instance, trying $DASHBOARD_PORT..."
|
|
3016
|
+
fi
|
|
3017
|
+
done
|
|
3018
|
+
|
|
3019
|
+
if [ $attempt -ge $max_attempts ]; then
|
|
3020
|
+
log_error "Could not find available port after $max_attempts attempts"
|
|
3021
|
+
return 1
|
|
2861
3022
|
fi
|
|
2862
3023
|
|
|
2863
3024
|
# Start Python HTTP server from .loki/ root so it can serve queue/ and state/
|
|
@@ -3349,8 +3510,11 @@ run_autonomous() {
|
|
|
3349
3510
|
log_info "Base wait: ${BASE_WAIT}s"
|
|
3350
3511
|
log_info "Max wait: ${MAX_WAIT}s"
|
|
3351
3512
|
log_info "Autonomy mode: $AUTONOMY_MODE"
|
|
3352
|
-
|
|
3353
|
-
|
|
3513
|
+
# Only show Claude-specific features for Claude provider
|
|
3514
|
+
if [ "${PROVIDER_NAME:-claude}" = "claude" ]; then
|
|
3515
|
+
log_info "Prompt repetition (Haiku): $PROMPT_REPETITION"
|
|
3516
|
+
log_info "Confidence routing: $CONFIDENCE_ROUTING"
|
|
3517
|
+
fi
|
|
3354
3518
|
echo ""
|
|
3355
3519
|
|
|
3356
3520
|
load_state
|
|
@@ -3381,6 +3545,9 @@ run_autonomous() {
|
|
|
3381
3545
|
2) return 0 ;; # STOP requested
|
|
3382
3546
|
esac
|
|
3383
3547
|
|
|
3548
|
+
# Auto-track iteration start (for dashboard task queue)
|
|
3549
|
+
track_iteration_start "$ITERATION_COUNT" "$prd_path"
|
|
3550
|
+
|
|
3384
3551
|
local prompt=$(build_prompt $retry "$prd_path" $ITERATION_COUNT)
|
|
3385
3552
|
|
|
3386
3553
|
echo ""
|
|
@@ -3393,6 +3560,20 @@ run_autonomous() {
|
|
|
3393
3560
|
# Run AI provider with live output
|
|
3394
3561
|
local start_time=$(date +%s)
|
|
3395
3562
|
local log_file=".loki/logs/autonomy-$(date +%Y%m%d).log"
|
|
3563
|
+
local agent_log=".loki/logs/agent.log"
|
|
3564
|
+
|
|
3565
|
+
# Ensure agent.log exists for dashboard real-time view
|
|
3566
|
+
# (Dashboard reads this file for terminal output)
|
|
3567
|
+
# Keep history but limit size to ~1MB to prevent memory issues
|
|
3568
|
+
if [ -f "$agent_log" ] && [ "$(stat -f%z "$agent_log" 2>/dev/null || stat -c%s "$agent_log" 2>/dev/null)" -gt 1000000 ]; then
|
|
3569
|
+
# Trim to last 500KB
|
|
3570
|
+
tail -c 500000 "$agent_log" > "$agent_log.tmp" && mv "$agent_log.tmp" "$agent_log"
|
|
3571
|
+
fi
|
|
3572
|
+
touch "$agent_log"
|
|
3573
|
+
echo "" >> "$agent_log"
|
|
3574
|
+
echo "════════════════════════════════════════════════════════════════" >> "$agent_log"
|
|
3575
|
+
echo " NEW SESSION - $(date)" >> "$agent_log"
|
|
3576
|
+
echo "════════════════════════════════════════════════════════════════" >> "$agent_log"
|
|
3396
3577
|
|
|
3397
3578
|
echo ""
|
|
3398
3579
|
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
@@ -3403,16 +3584,16 @@ run_autonomous() {
|
|
|
3403
3584
|
echo -e "${CYAN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
3404
3585
|
echo ""
|
|
3405
3586
|
|
|
3406
|
-
# Log start time
|
|
3407
|
-
echo "=== Session started at $(date) ==="
|
|
3408
|
-
echo "=== Provider: ${PROVIDER_NAME:-claude} ==="
|
|
3409
|
-
echo "=== Prompt: $prompt ==="
|
|
3587
|
+
# Log start time (to both archival and dashboard logs)
|
|
3588
|
+
echo "=== Session started at $(date) ===" | tee -a "$log_file" "$agent_log"
|
|
3589
|
+
echo "=== Provider: ${PROVIDER_NAME:-claude} ===" | tee -a "$log_file" "$agent_log"
|
|
3590
|
+
echo "=== Prompt (truncated): ${prompt:0:200}... ===" | tee -a "$log_file" "$agent_log"
|
|
3410
3591
|
|
|
3411
3592
|
# Dynamic tier selection based on RARV cycle phase
|
|
3412
3593
|
CURRENT_TIER=$(get_rarv_tier "$ITERATION_COUNT")
|
|
3413
3594
|
local rarv_phase=$(get_rarv_phase_name "$ITERATION_COUNT")
|
|
3414
3595
|
local tier_param=$(get_provider_tier_param "$CURRENT_TIER")
|
|
3415
|
-
echo "=== RARV Phase: $rarv_phase, Tier: $CURRENT_TIER ($tier_param) ==="
|
|
3596
|
+
echo "=== RARV Phase: $rarv_phase, Tier: $CURRENT_TIER ($tier_param) ===" | tee -a "$log_file" "$agent_log"
|
|
3416
3597
|
log_info "RARV Phase: $rarv_phase -> Tier: $CURRENT_TIER ($tier_param)"
|
|
3417
3598
|
|
|
3418
3599
|
set +e
|
|
@@ -3425,7 +3606,7 @@ run_autonomous() {
|
|
|
3425
3606
|
LOKI_CURRENT_MODEL="$tier_param" \
|
|
3426
3607
|
claude --dangerously-skip-permissions --model "$tier_param" -p "$prompt" \
|
|
3427
3608
|
--output-format stream-json --verbose 2>&1 | \
|
|
3428
|
-
tee -a "$log_file" | \
|
|
3609
|
+
tee -a "$log_file" "$agent_log" | \
|
|
3429
3610
|
python3 -u -c '
|
|
3430
3611
|
import sys
|
|
3431
3612
|
import json
|
|
@@ -3640,7 +3821,7 @@ if __name__ == "__main__":
|
|
|
3640
3821
|
# Uses dynamic tier from RARV phase (tier_param already set above)
|
|
3641
3822
|
CODEX_MODEL_REASONING_EFFORT="$tier_param" \
|
|
3642
3823
|
codex exec --dangerously-bypass-approvals-and-sandbox \
|
|
3643
|
-
"$prompt" 2>&1 | tee -a "$log_file"
|
|
3824
|
+
"$prompt" 2>&1 | tee -a "$log_file" "$agent_log"
|
|
3644
3825
|
local exit_code=${PIPESTATUS[0]}
|
|
3645
3826
|
;;
|
|
3646
3827
|
|
|
@@ -3648,8 +3829,9 @@ if __name__ == "__main__":
|
|
|
3648
3829
|
# Gemini: Degraded mode - no stream-json, no agent tracking
|
|
3649
3830
|
# Using --model flag to specify model
|
|
3650
3831
|
echo "[loki] Gemini model: ${PROVIDER_MODEL:-gemini-3-pro-preview}, tier: $tier_param" >> "$log_file"
|
|
3832
|
+
echo "[loki] Gemini model: ${PROVIDER_MODEL:-gemini-3-pro-preview}, tier: $tier_param" >> "$agent_log"
|
|
3651
3833
|
gemini --yolo --model "${PROVIDER_MODEL:-gemini-3-pro-preview}" \
|
|
3652
|
-
"$prompt" 2>&1 | tee -a "$log_file"
|
|
3834
|
+
"$prompt" 2>&1 | tee -a "$log_file" "$agent_log"
|
|
3653
3835
|
local exit_code=${PIPESTATUS[0]}
|
|
3654
3836
|
;;
|
|
3655
3837
|
|
|
@@ -3673,6 +3855,9 @@ if __name__ == "__main__":
|
|
|
3673
3855
|
log_info "${PROVIDER_DISPLAY_NAME:-Claude} exited with code $exit_code after ${duration}s"
|
|
3674
3856
|
save_state $retry "exited" $exit_code
|
|
3675
3857
|
|
|
3858
|
+
# Auto-track iteration completion (for dashboard task queue)
|
|
3859
|
+
track_iteration_complete "$ITERATION_COUNT" "$exit_code"
|
|
3860
|
+
|
|
3676
3861
|
# Check for success - ONLY stop on explicit completion promise
|
|
3677
3862
|
# There's never a "complete" product - always improvements, bugs, features
|
|
3678
3863
|
if [ $exit_code -eq 0 ]; then
|
|
@@ -3954,6 +4139,10 @@ main() {
|
|
|
3954
4139
|
fi
|
|
3955
4140
|
shift
|
|
3956
4141
|
;;
|
|
4142
|
+
--bg|--background)
|
|
4143
|
+
BACKGROUND_MODE=true
|
|
4144
|
+
shift
|
|
4145
|
+
;;
|
|
3957
4146
|
--help|-h)
|
|
3958
4147
|
echo "Usage: ./autonomy/run.sh [OPTIONS] [PRD_PATH]"
|
|
3959
4148
|
echo ""
|
|
@@ -3961,6 +4150,7 @@ main() {
|
|
|
3961
4150
|
echo " --parallel Enable git worktree-based parallel workflows"
|
|
3962
4151
|
echo " --allow-haiku Enable Haiku model for fast tier (default: disabled)"
|
|
3963
4152
|
echo " --provider <name> Provider: claude (default), codex, gemini"
|
|
4153
|
+
echo " --bg, --background Run in background mode"
|
|
3964
4154
|
echo " --help, -h Show this help message"
|
|
3965
4155
|
echo ""
|
|
3966
4156
|
echo "Environment variables: See header comments in this script"
|
|
@@ -3993,6 +4183,53 @@ main() {
|
|
|
3993
4183
|
exit 1
|
|
3994
4184
|
fi
|
|
3995
4185
|
|
|
4186
|
+
# Handle background mode
|
|
4187
|
+
if [ "$BACKGROUND_MODE" = "true" ]; then
|
|
4188
|
+
# Initialize .loki directory first
|
|
4189
|
+
mkdir -p .loki/logs
|
|
4190
|
+
|
|
4191
|
+
local log_file=".loki/logs/background-$(date +%Y%m%d-%H%M%S).log"
|
|
4192
|
+
local pid_file=".loki/loki.pid"
|
|
4193
|
+
local project_path=$(pwd)
|
|
4194
|
+
local project_name=$(basename "$project_path")
|
|
4195
|
+
|
|
4196
|
+
echo ""
|
|
4197
|
+
log_info "Starting Loki Mode in background..."
|
|
4198
|
+
|
|
4199
|
+
# Build command without --bg flag
|
|
4200
|
+
local cmd_args=()
|
|
4201
|
+
[ -n "$PRD_PATH" ] && cmd_args+=("$PRD_PATH")
|
|
4202
|
+
[ "$PARALLEL_MODE" = "true" ] && cmd_args+=("--parallel")
|
|
4203
|
+
[ -n "$LOKI_PROVIDER" ] && cmd_args+=("--provider" "$LOKI_PROVIDER")
|
|
4204
|
+
[ "${LOKI_ALLOW_HAIKU:-}" = "true" ] && cmd_args+=("--allow-haiku")
|
|
4205
|
+
|
|
4206
|
+
# Run in background
|
|
4207
|
+
nohup "${BASH_SOURCE[0]}" "${cmd_args[@]}" > "$log_file" 2>&1 &
|
|
4208
|
+
local bg_pid=$!
|
|
4209
|
+
echo "$bg_pid" > "$pid_file"
|
|
4210
|
+
|
|
4211
|
+
echo ""
|
|
4212
|
+
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
4213
|
+
echo -e "${GREEN} Loki Mode Running in Background${NC}"
|
|
4214
|
+
echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
|
|
4215
|
+
echo ""
|
|
4216
|
+
echo -e " ${CYAN}Project:${NC} $project_name"
|
|
4217
|
+
echo -e " ${CYAN}Path:${NC} $project_path"
|
|
4218
|
+
echo -e " ${CYAN}PID:${NC} $bg_pid"
|
|
4219
|
+
echo -e " ${CYAN}Log:${NC} $log_file"
|
|
4220
|
+
echo -e " ${CYAN}Dashboard:${NC} http://127.0.0.1:${DASHBOARD_PORT}/dashboard/index.html"
|
|
4221
|
+
echo ""
|
|
4222
|
+
echo -e "${YELLOW}Control Commands:${NC}"
|
|
4223
|
+
echo -e " ${DIM}Pause:${NC} touch .loki/PAUSE"
|
|
4224
|
+
echo -e " ${DIM}Resume:${NC} rm .loki/PAUSE"
|
|
4225
|
+
echo -e " ${DIM}Stop:${NC} touch .loki/STOP ${DIM}or${NC} kill $bg_pid"
|
|
4226
|
+
echo -e " ${DIM}Logs:${NC} tail -f $log_file"
|
|
4227
|
+
echo -e " ${DIM}Status:${NC} cat .loki/STATUS.txt"
|
|
4228
|
+
echo ""
|
|
4229
|
+
|
|
4230
|
+
exit 0
|
|
4231
|
+
fi
|
|
4232
|
+
|
|
3996
4233
|
# Show provider info
|
|
3997
4234
|
log_info "Provider: ${PROVIDER_DISPLAY_NAME:-Claude Code} (${PROVIDER_NAME:-claude})"
|
|
3998
4235
|
if [ "${PROVIDER_DEGRADED:-false}" = "true" ]; then
|