loki-mode 5.20.13 → 5.21.0

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.20.13
6
+ # Loki Mode v5.21.0
7
7
 
8
8
  **You are an autonomous agent. You make decisions. You do not ask questions. You do not stop.**
9
9
 
@@ -253,4 +253,4 @@ Auto-detected or force with `LOKI_COMPLEXITY`:
253
253
 
254
254
  ---
255
255
 
256
- **v5.20.13 | Clean Stale Control Files on Start | ~250 lines core**
256
+ **v5.21.0 | Session Lifecycle Management (Fixes #12) | ~250 lines core**
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.20.13
1
+ 5.21.0
package/autonomy/loki CHANGED
@@ -572,6 +572,16 @@ cmd_stop() {
572
572
  # Also kill any orphaned loki-run temp scripts
573
573
  pkill -f "loki-run-" 2>/dev/null || true
574
574
 
575
+ # Kill dashboard if running
576
+ if [ -f "$LOKI_DIR/dashboard/dashboard.pid" ]; then
577
+ local dash_pid
578
+ dash_pid=$(cat "$LOKI_DIR/dashboard/dashboard.pid" 2>/dev/null)
579
+ if [ -n "$dash_pid" ] && kill -0 "$dash_pid" 2>/dev/null; then
580
+ kill "$dash_pid" 2>/dev/null || true
581
+ fi
582
+ rm -f "$LOKI_DIR/dashboard/dashboard.pid"
583
+ fi
584
+
575
585
  # Emit session stop event
576
586
  emit_event session cli stop "reason=user_requested"
577
587
  # Emit success pattern for clean stop (SYN-018)
@@ -957,11 +967,11 @@ cmd_provider_info() {
957
967
  esac
958
968
  }
959
969
 
960
- # Dashboard server management
961
- DASHBOARD_PID_DIR="${HOME}/.loki/dashboard"
970
+ # Dashboard server management - project-local, unified with run.sh
971
+ DASHBOARD_PID_DIR="${LOKI_DIR}/dashboard"
962
972
  DASHBOARD_PID_FILE="${DASHBOARD_PID_DIR}/dashboard.pid"
963
- DASHBOARD_DEFAULT_PORT=8420
964
- DASHBOARD_DEFAULT_HOST="localhost"
973
+ DASHBOARD_DEFAULT_PORT=57374
974
+ DASHBOARD_DEFAULT_HOST="127.0.0.1"
965
975
 
966
976
  cmd_dashboard() {
967
977
  local subcommand="${1:-}"
package/autonomy/run.sh CHANGED
@@ -1989,9 +1989,16 @@ check_skill_installed() {
1989
1989
  init_loki_dir() {
1990
1990
  log_header "Initializing Loki Mode Directory"
1991
1991
 
1992
- # Clean up stale control files from previous sessions
1993
- # These can cause new sessions to pause/stop immediately
1994
- rm -f .loki/PAUSE .loki/STOP .loki/HUMAN_INPUT.md 2>/dev/null
1992
+ # Clean up stale control files ONLY if no other session is running
1993
+ # Deleting these while another session is active would destroy its signals
1994
+ local existing_pid=""
1995
+ if [ -f ".loki/loki.pid" ]; then
1996
+ existing_pid=$(cat ".loki/loki.pid" 2>/dev/null)
1997
+ fi
1998
+ if [ -z "$existing_pid" ] || ! kill -0 "$existing_pid" 2>/dev/null; then
1999
+ rm -f .loki/PAUSE .loki/STOP .loki/HUMAN_INPUT.md 2>/dev/null
2000
+ rm -f .loki/loki.pid 2>/dev/null
2001
+ fi
1995
2002
 
1996
2003
  mkdir -p .loki/{state,queue,messages,logs,config,prompts,artifacts,scripts}
1997
2004
  mkdir -p .loki/queue
@@ -4929,7 +4936,9 @@ cleanup() {
4929
4936
  log_warn "Double interrupt - stopping immediately"
4930
4937
  stop_dashboard
4931
4938
  stop_status_monitor
4939
+ rm -f .loki/loki.pid .loki/PAUSE 2>/dev/null
4932
4940
  save_state ${RETRY_COUNT:-0} "interrupted" 130
4941
+ emit_event_json "session_end" "result=130" "reason=interrupted"
4933
4942
  log_info "State saved. Run again to resume."
4934
4943
  exit 130
4935
4944
  fi
@@ -5158,6 +5167,21 @@ main() {
5158
5167
  # Initialize .loki directory
5159
5168
  init_loki_dir
5160
5169
 
5170
+ # Session lock: prevent concurrent sessions on same repo
5171
+ local pid_file=".loki/loki.pid"
5172
+ if [ -f "$pid_file" ]; then
5173
+ local existing_pid
5174
+ existing_pid=$(cat "$pid_file" 2>/dev/null)
5175
+ if [ -n "$existing_pid" ] && kill -0 "$existing_pid" 2>/dev/null; then
5176
+ log_error "Another Loki session is already running (PID: $existing_pid)"
5177
+ log_error "Stop it first with: loki stop"
5178
+ exit 1
5179
+ fi
5180
+ fi
5181
+
5182
+ # Write PID file for ALL modes (foreground + background)
5183
+ echo "$$" > "$pid_file"
5184
+
5161
5185
  # Copy skill files to .loki/skills/ - makes CLI self-contained
5162
5186
  # No need to install Claude Code skill separately
5163
5187
  copy_skill_files
@@ -5283,6 +5307,7 @@ main() {
5283
5307
  # Cleanup
5284
5308
  stop_dashboard
5285
5309
  stop_status_monitor
5310
+ rm -f .loki/loki.pid 2>/dev/null
5286
5311
 
5287
5312
  exit $result
5288
5313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loki-mode",
3
- "version": "5.20.13",
3
+ "version": "5.21.0",
4
4
  "description": "Multi-agent autonomous startup system for Claude Code, Codex CLI, and Gemini CLI",
5
5
  "keywords": [
6
6
  "claude",