loki-mode 5.3.0 → 5.4.1

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.3.0
6
+ # Loki Mode v5.4.1
7
7
 
8
8
  **You are an autonomous agent. You make decisions. You do not ask questions. You do not stop.**
9
9
 
@@ -182,11 +182,11 @@ GROWTH ──[continuous improvement loop]──> GROWTH
182
182
  ```bash
183
183
  # Standard mode (Claude - full features)
184
184
  claude --dangerously-skip-permissions
185
- # Then say: "Loki Mode" or "Loki Mode with PRD at path/to/prd.md"
185
+ # Then say: "Loki Mode" or "Loki Mode with PRD at path/to/prd.md" (or .json)
186
186
 
187
- # With provider selection
187
+ # With provider selection (supports .md and .json PRDs)
188
188
  ./autonomy/run.sh --provider claude ./prd.md # Default, full features
189
- ./autonomy/run.sh --provider codex ./prd.md # GPT-5.2 Codex, degraded mode
189
+ ./autonomy/run.sh --provider codex ./prd.json # GPT-5.2 Codex, degraded mode
190
190
  ./autonomy/run.sh --provider gemini ./prd.md # Gemini 3 Pro, degraded mode
191
191
 
192
192
  # Or via CLI wrapper
@@ -210,11 +210,23 @@ When running with `autonomy/run.sh`, you can intervene:
210
210
  | Method | Effect |
211
211
  |--------|--------|
212
212
  | `touch .loki/PAUSE` | Pauses after current session |
213
- | `echo "instructions" > .loki/HUMAN_INPUT.md` | Injects instructions into next prompt |
213
+ | `echo "instructions" > .loki/HUMAN_INPUT.md` | Injects directive into next prompt (executed immediately) |
214
214
  | `touch .loki/STOP` | Stops immediately |
215
215
  | Ctrl+C (once) | Pauses, shows options |
216
216
  | Ctrl+C (twice) | Exits immediately |
217
217
 
218
+ ### Hints vs Directives
219
+
220
+ | Type | File | Behavior |
221
+ |------|------|----------|
222
+ | **Hint** | `.loki/CONTINUITY.md` "Mistakes & Learnings" | Passive memory - remembered but not acted upon |
223
+ | **Directive** | `.loki/HUMAN_INPUT.md` | Active instruction - executed BEFORE normal tasks |
224
+
225
+ **Example directive** (check all .astro files):
226
+ ```bash
227
+ echo "Check all .astro files for missing BaseLayout imports. Fix any issues found. Add a compilation test to prevent this regression." > .loki/HUMAN_INPUT.md
228
+ ```
229
+
218
230
  ---
219
231
 
220
232
  ## Complexity Tiers (v3.4.0)
@@ -229,4 +241,4 @@ Auto-detected or force with `LOKI_COMPLEXITY`:
229
241
 
230
242
  ---
231
243
 
232
- **v5.3.0 | Haiku Control Flag + Quality Model Defaults | ~240 lines core**
244
+ **v5.4.1 | Empty Array Fix | ~245 lines core**
package/VERSION CHANGED
@@ -1 +1 @@
1
- 5.3.0
1
+ 5.4.1
package/autonomy/run.sh CHANGED
@@ -583,7 +583,25 @@ detect_complexity() {
583
583
  local prd_complexity="standard"
584
584
  if [ -n "$prd_path" ] && [ -f "$prd_path" ]; then
585
585
  local prd_words=$(wc -w < "$prd_path" | tr -d ' ')
586
- local feature_count=$(grep -c "^##\|^- \[" "$prd_path" 2>/dev/null || echo "0")
586
+ local feature_count=0
587
+
588
+ # Detect PRD format and count features accordingly
589
+ if [[ "$prd_path" == *.json ]]; then
590
+ # JSON PRD: count features, requirements, tasks arrays
591
+ if command -v jq &>/dev/null; then
592
+ feature_count=$(jq '
593
+ [.features, .requirements, .tasks, .user_stories, .epics] |
594
+ map(select(. != null) | if type == "array" then length else 0 end) |
595
+ add // 0
596
+ ' "$prd_path" 2>/dev/null || echo "0")
597
+ else
598
+ # Fallback: count array elements by pattern
599
+ feature_count=$(grep -c '"title"\|"name"\|"feature"\|"requirement"' "$prd_path" 2>/dev/null || echo "0")
600
+ fi
601
+ else
602
+ # Markdown PRD: count headers and checkboxes
603
+ feature_count=$(grep -c "^##\|^- \[" "$prd_path" 2>/dev/null || echo "0")
604
+ fi
587
605
 
588
606
  if [ "$prd_words" -lt 200 ] && [ "$feature_count" -lt 5 ]; then
589
607
  prd_complexity="simple"
@@ -3261,17 +3279,23 @@ build_prompt() {
3261
3279
  fi
3262
3280
  fi
3263
3281
 
3282
+ # Human directive injection (from HUMAN_INPUT.md)
3283
+ local human_directive=""
3284
+ if [ -n "${LOKI_HUMAN_INPUT:-}" ]; then
3285
+ human_directive="HUMAN_DIRECTIVE (PRIORITY): $LOKI_HUMAN_INPUT Execute this directive BEFORE continuing normal tasks."
3286
+ fi
3287
+
3264
3288
  if [ $retry -eq 0 ]; then
3265
3289
  if [ -n "$prd" ]; then
3266
- echo "Loki Mode with PRD at $prd. $rarv_instruction $memory_instruction $compaction_reminder $completion_instruction $sdlc_instruction $autonomous_suffix"
3290
+ echo "Loki Mode with PRD at $prd. $human_directive $rarv_instruction $memory_instruction $compaction_reminder $completion_instruction $sdlc_instruction $autonomous_suffix"
3267
3291
  else
3268
- echo "Loki Mode. $analysis_instruction $rarv_instruction $memory_instruction $compaction_reminder $completion_instruction $sdlc_instruction $autonomous_suffix"
3292
+ echo "Loki Mode. $human_directive $analysis_instruction $rarv_instruction $memory_instruction $compaction_reminder $completion_instruction $sdlc_instruction $autonomous_suffix"
3269
3293
  fi
3270
3294
  else
3271
3295
  if [ -n "$prd" ]; then
3272
- echo "Loki Mode - Resume iteration #$iteration (retry #$retry). PRD: $prd. $context_injection $rarv_instruction $memory_instruction $compaction_reminder $completion_instruction $sdlc_instruction $autonomous_suffix"
3296
+ echo "Loki Mode - Resume iteration #$iteration (retry #$retry). PRD: $prd. $human_directive $context_injection $rarv_instruction $memory_instruction $compaction_reminder $completion_instruction $sdlc_instruction $autonomous_suffix"
3273
3297
  else
3274
- echo "Loki Mode - Resume iteration #$iteration (retry #$retry). $context_injection Use .loki/generated-prd.md if exists. $rarv_instruction $memory_instruction $compaction_reminder $completion_instruction $sdlc_instruction $autonomous_suffix"
3298
+ echo "Loki Mode - Resume iteration #$iteration (retry #$retry). $human_directive $context_injection Use .loki/generated-prd.md if exists. $rarv_instruction $memory_instruction $compaction_reminder $completion_instruction $sdlc_instruction $autonomous_suffix"
3275
3299
  fi
3276
3300
  fi
3277
3301
  }
@@ -3290,10 +3314,14 @@ run_autonomous() {
3290
3314
  log_step "No PRD provided, searching for existing PRD files..."
3291
3315
  local found_prd=""
3292
3316
 
3293
- # Search common PRD file patterns
3294
- for pattern in "PRD.md" "prd.md" "REQUIREMENTS.md" "requirements.md" "SPEC.md" "spec.md" \
3295
- "docs/PRD.md" "docs/prd.md" "docs/REQUIREMENTS.md" "docs/requirements.md" \
3296
- "docs/SPEC.md" "docs/spec.md" ".github/PRD.md" "PROJECT.md" "project.md"; do
3317
+ # Search common PRD file patterns (markdown and JSON)
3318
+ for pattern in "PRD.md" "prd.md" "PRD.json" "prd.json" \
3319
+ "REQUIREMENTS.md" "requirements.md" "requirements.json" \
3320
+ "SPEC.md" "spec.md" "spec.json" \
3321
+ "docs/PRD.md" "docs/prd.md" "docs/PRD.json" "docs/prd.json" \
3322
+ "docs/REQUIREMENTS.md" "docs/requirements.md" "docs/requirements.json" \
3323
+ "docs/SPEC.md" "docs/spec.md" "docs/spec.json" \
3324
+ ".github/PRD.md" ".github/PRD.json" "PROJECT.md" "project.md" "project.json"; do
3297
3325
  if [ -f "$pattern" ]; then
3298
3326
  found_prd="$pattern"
3299
3327
  break
@@ -3306,6 +3334,9 @@ run_autonomous() {
3306
3334
  elif [ -f ".loki/generated-prd.md" ]; then
3307
3335
  log_info "Using previously generated PRD: .loki/generated-prd.md"
3308
3336
  prd_path=".loki/generated-prd.md"
3337
+ elif [ -f ".loki/generated-prd.json" ]; then
3338
+ log_info "Using previously generated PRD: .loki/generated-prd.json"
3339
+ prd_path=".loki/generated-prd.json"
3309
3340
  else
3310
3341
  log_info "No PRD found - will analyze codebase and generate one"
3311
3342
  fi
@@ -3341,6 +3372,15 @@ run_autonomous() {
3341
3372
  return 0
3342
3373
  fi
3343
3374
 
3375
+ # Check for human intervention (PAUSE, HUMAN_INPUT.md, STOP)
3376
+ local intervention_result
3377
+ intervention_result=$(check_human_intervention; echo $?)
3378
+ intervention_result=${intervention_result##*$'\n'} # Get exit code
3379
+ case $intervention_result in
3380
+ 1) continue ;; # PAUSE handled, restart loop
3381
+ 2) return 0 ;; # STOP requested
3382
+ esac
3383
+
3344
3384
  local prompt=$(build_prompt $retry "$prd_path" $ITERATION_COUNT)
3345
3385
 
3346
3386
  echo ""
@@ -3941,7 +3981,12 @@ main() {
3941
3981
  ;;
3942
3982
  esac
3943
3983
  done
3944
- set -- "${REMAINING_ARGS[@]}"
3984
+ # Safe expansion for empty arrays with set -u
3985
+ if [ ${#REMAINING_ARGS[@]} -gt 0 ]; then
3986
+ set -- "${REMAINING_ARGS[@]}"
3987
+ else
3988
+ set --
3989
+ fi
3945
3990
 
3946
3991
  # Validate PRD if provided
3947
3992
  if [ -n "$PRD_PATH" ] && [ ! -f "$PRD_PATH" ]; then
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loki-mode",
3
- "version": "5.3.0",
3
+ "version": "5.4.1",
4
4
  "description": "Multi-agent autonomous startup system for Claude Code, Codex CLI, and Gemini CLI",
5
5
  "keywords": [
6
6
  "claude",