loki-mode 5.4.3 → 5.4.5

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 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.3
6
+ # Loki Mode v5.4.5
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.3 | Dashboard Improvements | ~245 lines core**
244
+ **v5.4.5 | Dashboard fix + Gemini stdin fix | ~245 lines core**
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.4.3
1
+ 5.4.5
package/autonomy/loki CHANGED
@@ -88,6 +88,7 @@ show_help() {
88
88
  echo "Options for 'start':"
89
89
  echo " --provider NAME AI provider: claude (default), codex, gemini"
90
90
  echo " --parallel Enable parallel mode with git worktrees"
91
+ echo " --bg, --background Run in background mode"
91
92
  echo " --simple Force simple complexity tier (3 phases)"
92
93
  echo " --complex Force complex complexity tier (8 phases)"
93
94
  echo " --github Enable GitHub issue import"
@@ -96,6 +97,7 @@ show_help() {
96
97
  echo "Examples:"
97
98
  echo " loki start # Start in current directory"
98
99
  echo " loki start ./prd.md # Start with PRD file"
100
+ echo " loki start --bg # Start in background"
99
101
  echo " loki start --parallel # Start in parallel mode"
100
102
  echo " loki pause # Pause execution"
101
103
  echo " loki status # Check current status"
@@ -131,6 +133,10 @@ cmd_start() {
131
133
  args+=("--parallel")
132
134
  shift
133
135
  ;;
136
+ --bg|--background)
137
+ args+=("--bg")
138
+ shift
139
+ ;;
134
140
  --simple)
135
141
  export LOKI_COMPLEXITY=simple
136
142
  shift
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
@@ -521,6 +524,7 @@ YELLOW='\033[1;33m'
521
524
  BLUE='\033[0;34m'
522
525
  CYAN='\033[0;36m'
523
526
  BOLD='\033[1m'
527
+ DIM='\033[2m'
524
528
  NC='\033[0m'
525
529
 
526
530
  #===============================================================================
@@ -1374,9 +1378,10 @@ spawn_worktree_session() {
1374
1378
  ;;
1375
1379
  gemini)
1376
1380
  # Note: -p flag is DEPRECATED per gemini --help. Using positional prompt.
1381
+ # Note: < /dev/null prevents Gemini from pausing on stdin
1377
1382
  gemini --yolo --model "${PROVIDER_MODEL:-gemini-3-pro-preview}" \
1378
1383
  "Loki Mode: $task_prompt. Read .loki/CONTINUITY.md for context." \
1379
- >> "$log_file" 2>&1
1384
+ < /dev/null >> "$log_file" 2>&1
1380
1385
  ;;
1381
1386
  *)
1382
1387
  log_error "Unknown provider: ${PROVIDER_NAME}"
@@ -1467,7 +1472,7 @@ Output ONLY the resolved file content with no conflict markers. No explanations.
1467
1472
  ;;
1468
1473
  gemini)
1469
1474
  # Note: -p flag is DEPRECATED per gemini --help. Using positional prompt.
1470
- resolution=$(gemini --yolo --model "${PROVIDER_MODEL:-gemini-3-pro-preview}" "$conflict_prompt" 2>/dev/null)
1475
+ resolution=$(gemini --yolo --model "${PROVIDER_MODEL:-gemini-3-pro-preview}" "$conflict_prompt" < /dev/null 2>/dev/null)
1471
1476
  ;;
1472
1477
  *)
1473
1478
  log_error "Unknown provider: ${PROVIDER_NAME}"
@@ -2026,6 +2031,124 @@ write_dashboard_state() {
2026
2031
  EOF
2027
2032
  }
2028
2033
 
2034
+ #===============================================================================
2035
+ # Task Queue Auto-Tracking (for degraded mode providers)
2036
+ #===============================================================================
2037
+
2038
+ # Track iteration start - create task in in-progress queue
2039
+ track_iteration_start() {
2040
+ local iteration="$1"
2041
+ local prd="${2:-}"
2042
+ local task_id="iteration-$iteration"
2043
+
2044
+ mkdir -p .loki/queue
2045
+
2046
+ # Create task entry
2047
+ local task_json=$(cat <<EOF
2048
+ {
2049
+ "id": "$task_id",
2050
+ "type": "iteration",
2051
+ "title": "Iteration $iteration",
2052
+ "description": "PRD: ${prd:-Codebase Analysis}",
2053
+ "status": "in_progress",
2054
+ "priority": "medium",
2055
+ "startedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
2056
+ "provider": "${PROVIDER_NAME:-claude}"
2057
+ }
2058
+ EOF
2059
+ )
2060
+
2061
+ # Add to in-progress queue
2062
+ local in_progress_file=".loki/queue/in-progress.json"
2063
+ if [ -f "$in_progress_file" ]; then
2064
+ local existing=$(cat "$in_progress_file")
2065
+ if [ "$existing" = "[]" ] || [ -z "$existing" ]; then
2066
+ echo "[$task_json]" > "$in_progress_file"
2067
+ else
2068
+ # Append to existing array
2069
+ echo "$existing" | python3 -c "
2070
+ import sys, json
2071
+ data = json.load(sys.stdin)
2072
+ data.append($task_json)
2073
+ print(json.dumps(data, indent=2))
2074
+ " > "$in_progress_file" 2>/dev/null || echo "[$task_json]" > "$in_progress_file"
2075
+ fi
2076
+ else
2077
+ echo "[$task_json]" > "$in_progress_file"
2078
+ fi
2079
+
2080
+ # Update current-task.json
2081
+ echo "$task_json" > .loki/queue/current-task.json
2082
+ }
2083
+
2084
+ # Track iteration completion - move task to completed queue
2085
+ track_iteration_complete() {
2086
+ local iteration="$1"
2087
+ local exit_code="${2:-0}"
2088
+ local task_id="iteration-$iteration"
2089
+
2090
+ mkdir -p .loki/queue
2091
+
2092
+ # Get task from in-progress
2093
+ local in_progress_file=".loki/queue/in-progress.json"
2094
+ local completed_file=".loki/queue/completed.json"
2095
+ local failed_file=".loki/queue/failed.json"
2096
+
2097
+ # Initialize files if needed
2098
+ [ ! -f "$completed_file" ] && echo "[]" > "$completed_file"
2099
+ [ ! -f "$failed_file" ] && echo "[]" > "$failed_file"
2100
+
2101
+ # Create completed task entry
2102
+ local task_json=$(cat <<EOF
2103
+ {
2104
+ "id": "$task_id",
2105
+ "type": "iteration",
2106
+ "title": "Iteration $iteration",
2107
+ "status": "$([ "$exit_code" = "0" ] && echo "completed" || echo "failed")",
2108
+ "completedAt": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
2109
+ "exitCode": $exit_code,
2110
+ "provider": "${PROVIDER_NAME:-claude}"
2111
+ }
2112
+ EOF
2113
+ )
2114
+
2115
+ # Add to appropriate queue
2116
+ local target_file="$completed_file"
2117
+ [ "$exit_code" != "0" ] && target_file="$failed_file"
2118
+
2119
+ python3 -c "
2120
+ import sys, json
2121
+ try:
2122
+ with open('$target_file', 'r') as f:
2123
+ data = json.load(f)
2124
+ except:
2125
+ data = []
2126
+ data.append($task_json)
2127
+ # Keep only last 50 entries
2128
+ data = data[-50:]
2129
+ with open('$target_file', 'w') as f:
2130
+ json.dump(data, f, indent=2)
2131
+ " 2>/dev/null || echo "[$task_json]" > "$target_file"
2132
+
2133
+ # Remove from in-progress
2134
+ if [ -f "$in_progress_file" ]; then
2135
+ python3 -c "
2136
+ import sys, json
2137
+ try:
2138
+ with open('$in_progress_file', 'r') as f:
2139
+ data = json.load(f)
2140
+ data = [t for t in data if t.get('id') != '$task_id']
2141
+ with open('$in_progress_file', 'w') as f:
2142
+ json.dump(data, f, indent=2)
2143
+ except:
2144
+ pass
2145
+ " 2>/dev/null || true
2146
+ fi
2147
+
2148
+ # Clear current-task.json
2149
+ echo "{}" > .loki/queue/current-task.json
2150
+ }
2151
+
2029
2152
  start_status_monitor() {
2030
2153
  log_step "Starting status monitor..."
2031
2154
 
@@ -2902,8 +3025,9 @@ start_dashboard() {
2902
3025
 
2903
3026
  # Start Python HTTP server from .loki/ root so it can serve queue/ and state/
2904
3027
  log_step "Starting dashboard server..."
3028
+ local loki_dir="$(pwd)/.loki"
2905
3029
  (
2906
- cd .loki
3030
+ cd "$loki_dir" || { echo "[dashboard] Failed to cd to $loki_dir" >&2; exit 1; }
2907
3031
  python3 -m http.server $DASHBOARD_PORT --bind 127.0.0.1 2>&1 | while read line; do
2908
3032
  echo "[dashboard] $line" >> logs/dashboard.log
2909
3033
  done
@@ -3424,6 +3548,9 @@ run_autonomous() {
3424
3548
  2) return 0 ;; # STOP requested
3425
3549
  esac
3426
3550
 
3551
+ # Auto-track iteration start (for dashboard task queue)
3552
+ track_iteration_start "$ITERATION_COUNT" "$prd_path"
3553
+
3427
3554
  local prompt=$(build_prompt $retry "$prd_path" $ITERATION_COUNT)
3428
3555
 
3429
3556
  echo ""
@@ -3704,10 +3831,11 @@ if __name__ == "__main__":
3704
3831
  gemini)
3705
3832
  # Gemini: Degraded mode - no stream-json, no agent tracking
3706
3833
  # Using --model flag to specify model
3834
+ # Note: < /dev/null prevents Gemini from pausing on stdin
3707
3835
  echo "[loki] Gemini model: ${PROVIDER_MODEL:-gemini-3-pro-preview}, tier: $tier_param" >> "$log_file"
3708
3836
  echo "[loki] Gemini model: ${PROVIDER_MODEL:-gemini-3-pro-preview}, tier: $tier_param" >> "$agent_log"
3709
3837
  gemini --yolo --model "${PROVIDER_MODEL:-gemini-3-pro-preview}" \
3710
- "$prompt" 2>&1 | tee -a "$log_file" "$agent_log"
3838
+ "$prompt" < /dev/null 2>&1 | tee -a "$log_file" "$agent_log"
3711
3839
  local exit_code=${PIPESTATUS[0]}
3712
3840
  ;;
3713
3841
 
@@ -3731,6 +3859,9 @@ if __name__ == "__main__":
3731
3859
  log_info "${PROVIDER_DISPLAY_NAME:-Claude} exited with code $exit_code after ${duration}s"
3732
3860
  save_state $retry "exited" $exit_code
3733
3861
 
3862
+ # Auto-track iteration completion (for dashboard task queue)
3863
+ track_iteration_complete "$ITERATION_COUNT" "$exit_code"
3864
+
3734
3865
  # Check for success - ONLY stop on explicit completion promise
3735
3866
  # There's never a "complete" product - always improvements, bugs, features
3736
3867
  if [ $exit_code -eq 0 ]; then
@@ -4012,6 +4143,10 @@ main() {
4012
4143
  fi
4013
4144
  shift
4014
4145
  ;;
4146
+ --bg|--background)
4147
+ BACKGROUND_MODE=true
4148
+ shift
4149
+ ;;
4015
4150
  --help|-h)
4016
4151
  echo "Usage: ./autonomy/run.sh [OPTIONS] [PRD_PATH]"
4017
4152
  echo ""
@@ -4019,6 +4154,7 @@ main() {
4019
4154
  echo " --parallel Enable git worktree-based parallel workflows"
4020
4155
  echo " --allow-haiku Enable Haiku model for fast tier (default: disabled)"
4021
4156
  echo " --provider <name> Provider: claude (default), codex, gemini"
4157
+ echo " --bg, --background Run in background mode"
4022
4158
  echo " --help, -h Show this help message"
4023
4159
  echo ""
4024
4160
  echo "Environment variables: See header comments in this script"
@@ -4051,6 +4187,54 @@ main() {
4051
4187
  exit 1
4052
4188
  fi
4053
4189
 
4190
+ # Handle background mode
4191
+ if [ "$BACKGROUND_MODE" = "true" ]; then
4192
+ # Initialize .loki directory first
4193
+ mkdir -p .loki/logs
4194
+
4195
+ local log_file=".loki/logs/background-$(date +%Y%m%d-%H%M%S).log"
4196
+ local pid_file=".loki/loki.pid"
4197
+ local project_path=$(pwd)
4198
+ local project_name=$(basename "$project_path")
4199
+
4200
+ echo ""
4201
+ log_info "Starting Loki Mode in background..."
4202
+
4203
+ # Build command without --bg flag
4204
+ local cmd_args=()
4205
+ [ -n "$PRD_PATH" ] && cmd_args+=("$PRD_PATH")
4206
+ [ "$PARALLEL_MODE" = "true" ] && cmd_args+=("--parallel")
4207
+ [ -n "$LOKI_PROVIDER" ] && cmd_args+=("--provider" "$LOKI_PROVIDER")
4208
+ [ "${LOKI_ALLOW_HAIKU:-}" = "true" ] && cmd_args+=("--allow-haiku")
4209
+
4210
+ # Run in background using the ORIGINAL script (not the temp copy)
4211
+ local original_script="$SCRIPT_DIR/run.sh"
4212
+ nohup "$original_script" "${cmd_args[@]}" > "$log_file" 2>&1 &
4213
+ local bg_pid=$!
4214
+ echo "$bg_pid" > "$pid_file"
4215
+
4216
+ echo ""
4217
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
4218
+ echo -e "${GREEN} Loki Mode Running in Background${NC}"
4219
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
4220
+ echo ""
4221
+ echo -e " ${CYAN}Project:${NC} $project_name"
4222
+ echo -e " ${CYAN}Path:${NC} $project_path"
4223
+ echo -e " ${CYAN}PID:${NC} $bg_pid"
4224
+ echo -e " ${CYAN}Log:${NC} $log_file"
4225
+ echo -e " ${CYAN}Dashboard:${NC} http://127.0.0.1:${DASHBOARD_PORT}/dashboard/index.html"
4226
+ echo ""
4227
+ echo -e "${YELLOW}Control Commands:${NC}"
4228
+ echo -e " ${DIM}Pause:${NC} touch .loki/PAUSE"
4229
+ echo -e " ${DIM}Resume:${NC} rm .loki/PAUSE"
4230
+ echo -e " ${DIM}Stop:${NC} touch .loki/STOP ${DIM}or${NC} kill $bg_pid"
4231
+ echo -e " ${DIM}Logs:${NC} tail -f $log_file"
4232
+ echo -e " ${DIM}Status:${NC} cat .loki/STATUS.txt"
4233
+ echo ""
4234
+
4235
+ exit 0
4236
+ fi
4237
+
4054
4238
  # Show provider info
4055
4239
  log_info "Provider: ${PROVIDER_DISPLAY_NAME:-Claude Code} (${PROVIDER_NAME:-claude})"
4056
4240
  if [ "${PROVIDER_DEGRADED:-false}" = "true" ]; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loki-mode",
3
- "version": "5.4.3",
3
+ "version": "5.4.5",
4
4
  "description": "Multi-agent autonomous startup system for Claude Code, Codex CLI, and Gemini CLI",
5
5
  "keywords": [
6
6
  "claude",
@@ -99,10 +99,11 @@ provider_version() {
99
99
  # Invocation function
100
100
  # Uses --model flag to specify model, --yolo for autonomous mode
101
101
  # Using positional prompt (not deprecated -p flag)
102
+ # Note: < /dev/null prevents Gemini from pausing on stdin
102
103
  provider_invoke() {
103
104
  local prompt="$1"
104
105
  shift
105
- gemini --yolo --model "$PROVIDER_MODEL" "$prompt" "$@"
106
+ gemini --yolo --model "$PROVIDER_MODEL" "$prompt" "$@" < /dev/null
106
107
  }
107
108
 
108
109
  # Model tier to thinking level parameter
@@ -119,10 +120,11 @@ provider_get_tier_param() {
119
120
  # Tier-aware invocation
120
121
  # Uses --model flag to specify model
121
122
  # Using positional prompt (not deprecated -p flag)
123
+ # Note: < /dev/null prevents Gemini from pausing on stdin
122
124
  provider_invoke_with_tier() {
123
125
  local tier="$1"
124
126
  local prompt="$2"
125
127
  shift 2
126
128
  echo "[loki] Using tier: $tier, model: $PROVIDER_MODEL" >&2
127
- gemini --yolo --model "$PROVIDER_MODEL" "$prompt" "$@"
129
+ gemini --yolo --model "$PROVIDER_MODEL" "$prompt" "$@" < /dev/null
128
130
  }