loki-mode 7.4.10 → 7.4.12

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 minimal human intervention. Requires --dangerously-skip-permissions flag.
4
4
  ---
5
5
 
6
- # Loki Mode v7.4.10
6
+ # Loki Mode v7.4.12
7
7
 
8
8
  **You are an autonomous agent. You make decisions. You do not ask questions. You do not stop.**
9
9
 
@@ -322,4 +322,4 @@ The following features are documented in skill modules but not yet fully automat
322
322
  | Quality gates 3-reviewer system | Implemented (v5.35.0) | 5 specialist reviewers in `skills/quality-gates.md`; execution in run.sh |
323
323
  | Benchmarks (HumanEval, SWE-bench) | Infrastructure only | Runner scripts and datasets exist in `benchmarks/`; no published results |
324
324
 
325
- **v7.4.10 | [Autonomi](https://www.autonomi.dev/) flagship product | ~260 lines core**
325
+ **v7.4.12 | [Autonomi](https://www.autonomi.dev/) flagship product | ~260 lines core**
package/VERSION CHANGED
@@ -1 +1 @@
1
- 7.4.10
1
+ 7.4.12
package/autonomy/loki CHANGED
@@ -6309,6 +6309,9 @@ cmd_doctor() {
6309
6309
  bash)
6310
6310
  version=$("$cmd" --version 2>/dev/null | head -1 | sed 's/.*version \([0-9.]*\).*/\1/')
6311
6311
  ;;
6312
+ bun)
6313
+ version=$(bun --version 2>/dev/null | head -1 | tr -d 'v ')
6314
+ ;;
6312
6315
  jq)
6313
6316
  version=$(jq --version 2>/dev/null | tr -d 'jq-')
6314
6317
  ;;
@@ -6510,11 +6513,15 @@ cmd_doctor() {
6510
6513
  # Disk space check
6511
6514
  local disk_avail
6512
6515
  if command -v df &> /dev/null; then
6513
- # Get available space in GB (works on macOS and Linux)
6514
- disk_avail=$(df -g "$HOME" 2>/dev/null | tail -1 | awk '{print $4}')
6516
+ # Get available space in GB (works on macOS and Linux).
6517
+ # v7.4.12: || true on the pipes so set -euo pipefail doesn't exit
6518
+ # the whole doctor when df -g fails on Linux (which doesn't support
6519
+ # the -g flag). Pre-v7.4.12 bash route truncated after the System
6520
+ # section on Linux because of this exact early exit.
6521
+ disk_avail=$(df -g "$HOME" 2>/dev/null | tail -1 | awk '{print $4}' || true)
6515
6522
  if [ -z "$disk_avail" ]; then
6516
6523
  # Linux fallback (df -g may not work)
6517
- disk_avail=$(df -BG "$HOME" 2>/dev/null | tail -1 | awk '{print $4}' | tr -d 'G')
6524
+ disk_avail=$(df -BG "$HOME" 2>/dev/null | tail -1 | awk '{print $4}' | tr -d 'G' || true)
6518
6525
  fi
6519
6526
  if [ -n "$disk_avail" ] && [ "$disk_avail" -gt 0 ] 2>/dev/null; then
6520
6527
  if [ "$disk_avail" -lt 1 ]; then
@@ -11529,6 +11536,18 @@ main() {
11529
11536
  local command="$1"
11530
11537
  shift
11531
11538
 
11539
+ # v7.4.12: one-shot install/first-run telemetry. Replaces the
11540
+ # bin/postinstall.js install event (postinstall removed because Bun
11541
+ # blocks postinstalls by default and the prompt was confusing).
11542
+ # Creates ~/.loki-first-run on first invocation; fires "installed"
11543
+ # event ONCE per install with channel attribution. Idempotent + silent.
11544
+ if [ -z "${LOKI_TELEMETRY_DISABLED:-}" ] && [ "${DO_NOT_TRACK:-}" != "1" ]; then
11545
+ if [ ! -f "${HOME}/.loki-first-run" ] 2>/dev/null; then
11546
+ touch "${HOME}/.loki-first-run" 2>/dev/null || true
11547
+ loki_telemetry "installed" "first_command=$command" 2>/dev/null || true
11548
+ fi
11549
+ fi
11550
+
11532
11551
  loki_telemetry "cli_command" "command=$command" 2>/dev/null || true
11533
11552
 
11534
11553
  case "$command" in
package/bin/loki-mode.js CHANGED
@@ -2,16 +2,30 @@
2
2
  /**
3
3
  * Loki Mode npm wrapper.
4
4
  *
5
- * Delegates to bin/loki (the runtime-aware shim) so that ported commands
6
- * route through the Bun runtime when bun is on PATH and unported commands
7
- * fall through to autonomy/loki (bash). Pre-v7.4.7 this script bypassed
8
- * the shim and went straight to bash, which silently disabled the Bun
9
- * route for users invoking the `loki-mode` binary instead of `loki`.
5
+ * Delegates to bin/loki (the runtime-aware shim).
6
+ *
7
+ * v7.4.12: Removed from package.json `bin` map. Existing installs that have
8
+ * `loki-mode` symlinked still work (file is on disk + delegates to `loki`),
9
+ * but new installs only get the `loki` binary. Prints a one-time deprecation
10
+ * banner to stderr so muscle-memory users notice and switch.
10
11
  */
11
12
 
12
13
  const { spawn } = require('child_process');
13
14
  const path = require('path');
14
15
 
16
+ // Deprecation banner. Suppressed when piped (so scripts don't get noise) and
17
+ // when LOKI_NO_BANNER=1 / NO_COLOR is set (already-aware users).
18
+ if (
19
+ process.stderr.isTTY &&
20
+ !process.env.LOKI_NO_BANNER &&
21
+ !process.env.NO_COLOR
22
+ ) {
23
+ process.stderr.write(
24
+ '[loki-mode] DEPRECATED: this binary is being removed in v8.0.0. ' +
25
+ 'Use `loki` instead -- same behaviour, shorter name.\n',
26
+ );
27
+ }
28
+
15
29
  const shim = path.join(__dirname, 'loki');
16
30
  const args = process.argv.slice(2);
17
31
 
@@ -7,7 +7,7 @@ Modules:
7
7
  control: Session control API (start/stop/pause/resume)
8
8
  """
9
9
 
10
- __version__ = "7.4.10"
10
+ __version__ = "7.4.12"
11
11
 
12
12
  # Expose the control app for easy import
13
13
  try:
@@ -2,7 +2,7 @@
2
2
 
3
3
  The flagship product of [Autonomi](https://www.autonomi.dev/). Complete installation instructions for all platforms and use cases.
4
4
 
5
- **Version:** v7.4.10
5
+ **Version:** v7.4.12
6
6
 
7
7
  ---
8
8
 
@@ -94,7 +94,7 @@ loki setup-skill
94
94
  ## PyPI / Python SDK
95
95
 
96
96
  **The `loki` CLI is NOT available via `pip install loki-mode`.** PyPI hosts only the
97
- Python REST client SDK at `loki-mode-sdk` (v7.4.10+). The dashboard, MCP server,
97
+ Python REST client SDK at `loki-mode-sdk` (v7.4.12+). The dashboard, MCP server,
98
98
  and orchestrator components ship via npm, Docker, and Homebrew only.
99
99
 
100
100
  ```bash
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- var Q0=Object.defineProperty;var X0=(z)=>z;function Z0(z,Q){this[z]=X0.bind(null,Q)}var r=(z,Q)=>{for(var $ in Q)Q0(z,$,{get:Q[$],enumerable:!0,configurable:!0,set:Z0.bind(Q,$)})};var g=(z,Q)=>()=>(z&&(Q=z(z=0)),Q);var K0=import.meta.require;var P1={};r(P1,{lokiDir:()=>E,homeLokiDir:()=>B1,findSkillDir:()=>B0,findRepoRootForVersion:()=>W1,REPO_ROOT:()=>y});import{resolve as k,dirname as H1}from"path";import{fileURLToPath as H0}from"url";import{existsSync as u}from"fs";import{homedir as x1}from"os";function W0(){let z=L1;for(let Q=0;Q<6;Q++){if(u(k(z,"VERSION"))&&u(k(z,"autonomy/run.sh")))return z;let $=H1(z);if($===z)break;z=$}return k(L1,"..","..","..")}function W1(z){let Q=z;for(let $=0;$<6;$++){if(u(k(Q,"VERSION"))&&u(k(Q,"autonomy/run.sh")))return Q;let X=H1(Q);if(X===Q)break;Q=X}return k(z,"..","..","..")}function E(){return process.env.LOKI_DIR??k(process.cwd(),".loki")}function B1(){return k(x1(),".loki")}function B0(){let z=[y,k(x1(),".claude/skills/loki-mode"),process.cwd()];for(let Q of z)if(u(k(Q,"SKILL.md"))&&u(k(Q,"autonomy/run.sh")))return Q;return null}var L1,y;var h=g(()=>{L1=H1(H0(import.meta.url));y=W0()});var S1={};r(S1,{runOrThrow:()=>J0,run:()=>I,commandVersion:()=>M0,commandExists:()=>R,ShellError:()=>U1});async function I(z,Q={}){let $=Bun.spawn({cmd:[...z],stdout:"pipe",stderr:"pipe",env:Q.env?{...process.env,...Q.env}:process.env,cwd:Q.cwd}),X;if(Q.timeoutMs&&Q.timeoutMs>0)X=setTimeout(()=>$.kill(),Q.timeoutMs);let[Z,H,W]=await Promise.all([new Response($.stdout).text(),new Response($.stderr).text(),$.exited]);if(X)clearTimeout(X);return{stdout:Z,stderr:H,exitCode:W}}async function J0(z,Q={}){let $=await I(z,Q);if($.exitCode!==0)throw new U1(`command failed (${$.exitCode}): ${z.join(" ")}`,$.exitCode,$.stdout,$.stderr);return $}async function R(z){let Q=j0(z),$=await I(["sh","-c",`command -v ${Q}`],{timeoutMs:5000});if($.exitCode===0)return $.stdout.trim()||null;return null}function j0(z){if(!/^[A-Za-z0-9._/-]+$/.test(z))throw Error(`refused to shell-escape suspect token: ${z}`);return z}async function M0(z,Q="--version"){if(!await R(z))return null;let X=await I([z,Q],{timeoutMs:5000});if(X.exitCode!==0)return null;return((X.stdout||X.stderr).split(/\r?\n/)[0]?.trim()??"")||null}var U1;var m=g(()=>{U1=class U1 extends Error{message;exitCode;stdout;stderr;constructor(z,Q,$,X){super(z);this.message=z;this.exitCode=Q;this.stdout=$;this.stderr=X;this.name="ShellError"}}});function N(z){return Y0?"":z}var Y0,S,x,_,A3,G,F,A,K;var p=g(()=>{Y0=(process.env.NO_COLOR??"").length>0;S=N("\x1B[0;31m"),x=N("\x1B[0;32m"),_=N("\x1B[1;33m"),A3=N("\x1B[0;34m"),G=N("\x1B[0;36m"),F=N("\x1B[1m"),A=N("\x1B[2m"),K=N("\x1B[0m")});import{existsSync as P0}from"fs";async function a(){if(t!==void 0)return t;let z="/opt/homebrew/bin/python3.12";if(P0(z))return t=z,z;let Q=await R("python3.12");if(Q)return t=Q,Q;let $=await R("python3");return t=$,$}async function s(z,Q={}){let $=await a();if(!$)return{stdout:"",stderr:"python3 not found",exitCode:127};return I([$,"-c",z],Q)}var t;var Q1=g(()=>{m()});var v1={};r(v1,{runStatus:()=>y0});import{existsSync as L,readFileSync as e,readdirSync as C1,statSync as f1}from"fs";import{resolve as w,basename as E0}from"path";async function N0(){if(await R("jq"))return!0;return process.stdout.write(`${S}Error: jq is required but not installed.${K}
2
+ var Q0=Object.defineProperty;var X0=(z)=>z;function Z0(z,Q){this[z]=X0.bind(null,Q)}var r=(z,Q)=>{for(var $ in Q)Q0(z,$,{get:Q[$],enumerable:!0,configurable:!0,set:Z0.bind(Q,$)})};var g=(z,Q)=>()=>(z&&(Q=z(z=0)),Q);var K0=import.meta.require;var P1={};r(P1,{lokiDir:()=>b,homeLokiDir:()=>V1,findSkillDir:()=>B0,findRepoRootForVersion:()=>U1,REPO_ROOT:()=>y});import{resolve as k,dirname as B1}from"path";import{fileURLToPath as H0}from"url";import{existsSync as u}from"fs";import{homedir as L1}from"os";function W0(){let z=x1;for(let Q=0;Q<6;Q++){if(u(k(z,"VERSION"))&&u(k(z,"autonomy/run.sh")))return z;let $=B1(z);if($===z)break;z=$}return k(x1,"..","..","..")}function U1(z){let Q=z;for(let $=0;$<6;$++){if(u(k(Q,"VERSION"))&&u(k(Q,"autonomy/run.sh")))return Q;let X=B1(Q);if(X===Q)break;Q=X}return k(z,"..","..","..")}function b(){return process.env.LOKI_DIR??k(process.cwd(),".loki")}function V1(){return k(L1(),".loki")}function B0(){let z=[y,k(L1(),".claude/skills/loki-mode"),process.cwd()];for(let Q of z)if(u(k(Q,"SKILL.md"))&&u(k(Q,"autonomy/run.sh")))return Q;return null}var x1,y;var h=g(()=>{x1=B1(H0(import.meta.url));y=W0()});var S1={};r(S1,{runOrThrow:()=>J0,run:()=>w,commandVersion:()=>M0,commandExists:()=>R,ShellError:()=>q1});async function w(z,Q={}){let $=Bun.spawn({cmd:[...z],stdout:"pipe",stderr:"pipe",env:Q.env?{...process.env,...Q.env}:process.env,cwd:Q.cwd}),X;if(Q.timeoutMs&&Q.timeoutMs>0)X=setTimeout(()=>$.kill(),Q.timeoutMs);let[Z,H,W]=await Promise.all([new Response($.stdout).text(),new Response($.stderr).text(),$.exited]);if(X)clearTimeout(X);return{stdout:Z,stderr:H,exitCode:W}}async function J0(z,Q={}){let $=await w(z,Q);if($.exitCode!==0)throw new q1(`command failed (${$.exitCode}): ${z.join(" ")}`,$.exitCode,$.stdout,$.stderr);return $}async function R(z){let Q=j0(z),$=await w(["sh","-c",`command -v ${Q}`],{timeoutMs:5000});if($.exitCode===0)return $.stdout.trim()||null;return null}function j0(z){if(!/^[A-Za-z0-9._/-]+$/.test(z))throw Error(`refused to shell-escape suspect token: ${z}`);return z}async function M0(z,Q="--version"){if(!await R(z))return null;let X=await w([z,Q],{timeoutMs:5000});if(X.exitCode!==0)return null;return((X.stdout||X.stderr).split(/\r?\n/)[0]?.trim()??"")||null}var q1;var m=g(()=>{q1=class q1 extends Error{message;exitCode;stdout;stderr;constructor(z,Q,$,X){super(z);this.message=z;this.exitCode=Q;this.stdout=$;this.stderr=X;this.name="ShellError"}}});function N(z){return Y0?"":z}var Y0,S,P,T,A3,G,x,A,K;var p=g(()=>{Y0=(process.env.NO_COLOR??"").length>0;S=N("\x1B[0;31m"),P=N("\x1B[0;32m"),T=N("\x1B[1;33m"),A3=N("\x1B[0;34m"),G=N("\x1B[0;36m"),x=N("\x1B[1m"),A=N("\x1B[2m"),K=N("\x1B[0m")});import{existsSync as P0}from"fs";async function a(){if(t!==void 0)return t;let z="/opt/homebrew/bin/python3.12";if(P0(z))return t=z,z;let Q=await R("python3.12");if(Q)return t=Q,Q;let $=await R("python3");return t=$,$}async function s(z,Q={}){let $=await a();if(!$)return{stdout:"",stderr:"python3 not found",exitCode:127};return w([$,"-c",z],Q)}var t;var Q1=g(()=>{m()});var v1={};r(v1,{runStatus:()=>y0});import{existsSync as L,readFileSync as e,readdirSync as C1,statSync as f1}from"fs";import{resolve as F,basename as E0}from"path";async function N0(){if(await R("jq"))return!0;return process.stdout.write(`${S}Error: jq is required but not installed.${K}
3
3
  `),process.stdout.write(`Install with:
4
4
  `),process.stdout.write(` brew install jq (macOS)
5
5
  `),process.stdout.write(` apt install jq (Debian/Ubuntu)
6
6
  `),process.stdout.write(` yum install jq (RHEL/CentOS)
7
- `),!1}function X1(z){if(!Number.isFinite(z)||z<=0)return!1;try{return process.kill(z,0),!0}catch{return!1}}function Z1(z){if(!L(z))return null;try{let Q=e(z,"utf-8").trim();if(!Q)return null;let $=Number.parseInt(Q,10);return Number.isFinite($)?$:null}catch{return null}}function C0(z){let Q=[],$=Z1(w(z,"loki.pid"));if($!==null&&X1($))Q.push(`global:${$}`);let X=w(z,"sessions");if(L(X)){let Z=[];try{Z=C1(X)}catch{Z=[]}for(let H of Z){let W=w(X,H);try{if(!f1(W).isDirectory())continue}catch{continue}let B=w(W,"loki.pid"),j=Z1(B);if(j!==null&&X1(j))Q.push(`${H}:${j}`)}}if(L(z)){let Z=[];try{Z=C1(z)}catch{Z=[]}for(let H of Z){if(!H.startsWith("run-")||!H.endsWith(".pid"))continue;let W=w(z,H);try{if(!f1(W).isFile())continue}catch{continue}let B=E0(H,".pid").slice(4),j=Z1(W);if(j!==null&&X1(j)){if(!Q.some((T)=>T.startsWith(`${B}:`)))Q.push(`${B}:${j}`)}}}return Q}async function g1(z,Q){let $=await I(["jq","-r",z,Q]);if($.exitCode!==0)return null;return $.stdout.trim()}function y1(z,Q){try{let $=e(z,"utf-8"),Z=JSON.parse($)[Q];if(typeof Z==="number"){if(Q==="budget_used"){let H=Math.round(Z*100)/100;if(Number.isInteger(H))return String(H);return String(H)}return String(Z)}if(Z===void 0||Z===null)return"0";return String(Z)}catch{return"0"}}function h1(z,Q,$){try{let X=e(z,"utf-8"),H=JSON.parse(X)[Q];if(typeof H==="number"&&Number.isFinite(H))return H;return $}catch{return $}}async function f0(){let z=E();if(!await N0())return 1;if(!L(z))return process.stdout.write(`${F}Loki Mode Status${K}
7
+ `),!1}function X1(z){if(!Number.isFinite(z)||z<=0)return!1;try{return process.kill(z,0),!0}catch{return!1}}function Z1(z){if(!L(z))return null;try{let Q=e(z,"utf-8").trim();if(!Q)return null;let $=Number.parseInt(Q,10);return Number.isFinite($)?$:null}catch{return null}}function C0(z){let Q=[],$=Z1(F(z,"loki.pid"));if($!==null&&X1($))Q.push(`global:${$}`);let X=F(z,"sessions");if(L(X)){let Z=[];try{Z=C1(X)}catch{Z=[]}for(let H of Z){let W=F(X,H);try{if(!f1(W).isDirectory())continue}catch{continue}let B=F(W,"loki.pid"),j=Z1(B);if(j!==null&&X1(j))Q.push(`${H}:${j}`)}}if(L(z)){let Z=[];try{Z=C1(z)}catch{Z=[]}for(let H of Z){if(!H.startsWith("run-")||!H.endsWith(".pid"))continue;let W=F(z,H);try{if(!f1(W).isFile())continue}catch{continue}let B=E0(H,".pid").slice(4),j=Z1(W);if(j!==null&&X1(j)){if(!Q.some((I)=>I.startsWith(`${B}:`)))Q.push(`${B}:${j}`)}}}return Q}async function g1(z,Q){let $=await w(["jq","-r",z,Q]);if($.exitCode!==0)return null;return $.stdout.trim()}function y1(z,Q){try{let $=e(z,"utf-8"),Z=JSON.parse($)[Q];if(typeof Z==="number"){if(Q==="budget_used"){let H=Math.round(Z*100)/100;if(Number.isInteger(H))return String(H);return String(H)}return String(Z)}if(Z===void 0||Z===null)return"0";return String(Z)}catch{return"0"}}function h1(z,Q,$){try{let X=e(z,"utf-8"),H=JSON.parse(X)[Q];if(typeof H==="number"&&Number.isFinite(H))return H;return $}catch{return $}}async function f0(){let z=b();if(!await N0())return 1;if(!L(z))return process.stdout.write(`${x}Loki Mode Status${K}
8
8
  `),process.stdout.write(`
9
- `),process.stdout.write(`${_}No active session found.${K}
9
+ `),process.stdout.write(`${T}No active session found.${K}
10
10
  `),process.stdout.write(`Loki Mode has not been initialized in this directory.
11
11
  `),process.stdout.write(`
12
12
  `),process.stdout.write(`To start a session:
@@ -14,38 +14,38 @@ var Q0=Object.defineProperty;var X0=(z)=>z;function Z0(z,Q){this[z]=X0.bind(null
14
14
  `),process.stdout.write(` loki start - Start without a PRD
15
15
  `),process.stdout.write(`
16
16
  `),process.stdout.write(`${A}Current directory: ${process.cwd()}${K}
17
- `),0;process.stdout.write(`${F}Loki Mode Status${K}
17
+ `),0;process.stdout.write(`${x}Loki Mode Status${K}
18
18
  `),process.stdout.write(`
19
- `);let Q="",$=w(z,"state","provider");if(L($))try{Q=e($,"utf-8").trim()}catch{Q=""}let X=Q||process.env.LOKI_PROVIDER||"claude",Z="full features";switch(X){case"codex":case"gemini":case"aider":Z="degraded mode";break;case"cline":Z="near-full mode";break;default:Z="full features";break}process.stdout.write(`${G}Provider:${K} ${X} (${Z})
19
+ `);let Q="",$=F(z,"state","provider");if(L($))try{Q=e($,"utf-8").trim()}catch{Q=""}let X=Q||process.env.LOKI_PROVIDER||"claude",Z="full features";switch(X){case"codex":case"gemini":case"aider":Z="degraded mode";break;case"cline":Z="near-full mode";break;default:Z="full features";break}process.stdout.write(`${G}Provider:${K} ${X} (${Z})
20
20
  `),process.stdout.write(`${A} Switch with: loki provider set <claude|codex|gemini|cline|aider>${K}
21
21
  `),process.stdout.write(`
22
- `);let H=C0(z);if(H.length>0){process.stdout.write(`${x}Active Sessions: ${H.length}${K}
23
- `);for(let V of H){let U=V.indexOf(":"),Y=U>=0?V.slice(0,U):V,b=U>=0?V.slice(U+1):"";if(Y==="global")process.stdout.write(` ${G}[global]${K} PID ${b}
24
- `);else process.stdout.write(` ${G}[#${Y}]${K} PID ${b}
22
+ `);let H=C0(z);if(H.length>0){process.stdout.write(`${P}Active Sessions: ${H.length}${K}
23
+ `);for(let U of H){let Y=U.indexOf(":"),V=Y>=0?U.slice(0,Y):U,_=Y>=0?U.slice(Y+1):"";if(V==="global")process.stdout.write(` ${G}[global]${K} PID ${_}
24
+ `);else process.stdout.write(` ${G}[#${V}]${K} PID ${_}
25
25
  `)}process.stdout.write(`
26
26
  `),process.stdout.write(`${A} Stop specific: loki stop <session-id>${K}
27
27
  `),process.stdout.write(`${A} Stop all: loki stop${K}
28
28
  `),process.stdout.write(`
29
- `)}if(L(w(z,"PAUSE")))process.stdout.write(`${_}Status: PAUSED${K}
29
+ `)}if(L(F(z,"PAUSE")))process.stdout.write(`${T}Status: PAUSED${K}
30
30
  `),process.stdout.write(`${A} Resume with: loki resume${K}
31
31
  `),process.stdout.write(`
32
- `);else if(L(w(z,"STOP")))process.stdout.write(`${S}Status: STOPPED${K}
32
+ `);else if(L(F(z,"STOP")))process.stdout.write(`${S}Status: STOPPED${K}
33
33
  `),process.stdout.write(`${A} Clear with: loki resume${K}
34
34
  `),process.stdout.write(`
35
- `);let W=w(z,"STATUS.txt");if(L(W)){process.stdout.write(`${G}Session Info:${K}
35
+ `);let W=F(z,"STATUS.txt");if(L(W)){process.stdout.write(`${G}Session Info:${K}
36
36
  `);try{process.stdout.write(e(W,"utf-8"))}catch{}process.stdout.write(`
37
- `)}let B=w(z,"state","orchestrator.json");if(L(B)){process.stdout.write(`${G}Orchestrator State:${K}
38
- `);let V=await g1('.currentPhase // "unknown"',B);process.stdout.write(`${V??"unknown"}
39
- `)}let j=w(z,"queue","pending.json");if(L(j)){let V=await g1('if type == "array" then length elif .tasks then .tasks | length else 0 end',j);process.stdout.write(`${G}Pending Tasks:${K} ${V??"0"}
40
- `)}let O=w(z,"metrics","budget.json");if(L(O)){let V=y1(O,"budget_limit"),U=y1(O,"budget_used");if(V!=="0")process.stdout.write(`${G}Budget:${K} $${U} / $${V}
41
- `);else process.stdout.write(`${G}Cost:${K} $${U} (no limit)
42
- `)}let T=w(z,"state","context-usage.json");if(L(T)){let V=h1(T,"window_size",200000),U=h1(T,"used_tokens",0),Y=0;if(V>0)Y=Math.floor(U*100/V);process.stdout.write(`${G}Context:${K} ${Y}% (${U} / ${V} tokens)
43
- `)}let P=w(z,"dashboard","dashboard.pid");if(L(P)){let V=Z1(P);if(V!==null&&X1(V)){let U=process.env.LOKI_DASHBOARD_PORT||"57374";process.stdout.write(`${G}Dashboard:${K} http://127.0.0.1:${U}/
37
+ `)}let B=F(z,"state","orchestrator.json");if(L(B)){process.stdout.write(`${G}Orchestrator State:${K}
38
+ `);let U=await g1('.currentPhase // "unknown"',B);process.stdout.write(`${U??"unknown"}
39
+ `)}let j=F(z,"queue","pending.json");if(L(j)){let U=await g1('if type == "array" then length elif .tasks then .tasks | length else 0 end',j);process.stdout.write(`${G}Pending Tasks:${K} ${U??"0"}
40
+ `)}let O=F(z,"metrics","budget.json");if(L(O)){let U=y1(O,"budget_limit"),Y=y1(O,"budget_used");if(U!=="0")process.stdout.write(`${G}Budget:${K} $${Y} / $${U}
41
+ `);else process.stdout.write(`${G}Cost:${K} $${Y} (no limit)
42
+ `)}let I=F(z,"state","context-usage.json");if(L(I)){let U=h1(I,"window_size",200000),Y=h1(I,"used_tokens",0),V=0;if(U>0)V=Math.floor(Y*100/U);process.stdout.write(`${G}Context:${K} ${V}% (${Y} / ${U} tokens)
43
+ `)}let D=F(z,"dashboard","dashboard.pid");if(L(D)){let U=Z1(D);if(U!==null&&X1(U)){let Y=process.env.LOKI_DASHBOARD_PORT||"57374";process.stdout.write(`${G}Dashboard:${K} http://127.0.0.1:${Y}/
44
44
  `)}}return process.stdout.write(`
45
45
  `),process.stdout.write(`${A} Tip: loki context show - detailed token breakdown${K}
46
46
  `),process.stdout.write(`${A} Tip: loki code overview - codebase intelligence${K}
47
47
  `),0}async function g0(){let z=await a();if(!z)return process.stderr.write(`{"error": "Failed to generate JSON status. Ensure python3 is available."}
48
- `),1;let Q=y,$=E(),X=process.env.LOKI_DASHBOARD_PORT||"57374",Z=process.env.LOKI_PROVIDER||"claude",H=await I([z,"-c",b0,Q,$,X,Z],{timeoutMs:30000});if(H.exitCode!==0)return process.stderr.write(`{"error": "Failed to generate JSON status. Ensure python3 is available."}
48
+ `),1;let Q=y,$=b(),X=process.env.LOKI_DASHBOARD_PORT||"57374",Z=process.env.LOKI_PROVIDER||"claude",H=await w([z,"-c",b0,Q,$,X,Z],{timeoutMs:30000});if(H.exitCode!==0)return process.stderr.write(`{"error": "Failed to generate JSON status. Ensure python3 is available."}
49
49
  `),1;return process.stdout.write(H.stdout),0}async function y0(z){let Q=[...z];while(Q.length>0){let $=Q[0];if($==="--json")return g0();if($==="--help"||$==="-h")return process.stdout.write(`Usage: loki status [--json]
50
50
  `),0;return process.stdout.write(`${S}Unknown flag: ${$}${K}
51
51
  `),process.stdout.write(`Usage: loki status [--json]
@@ -195,9 +195,9 @@ if os.path.isdir(queue_dir):
195
195
  result['task_counts'] = task_counts
196
196
 
197
197
  print(json.dumps(result, indent=2))
198
- `;var m1=g(()=>{m();Q1();p();h()});var l1={};r(l1,{runStats:()=>c0,computeStats:()=>c1});import{readdirSync as u1,readFileSync as h0,statSync as p1}from"fs";import{join as C}from"path";function l(z){try{if(!p1(z).isFile())return null;return JSON.parse(h0(z,"utf-8"))}catch{return null}}function J1(z){try{return p1(z).isDirectory()}catch{return!1}}function v0(z){if(!J1(z))return[];try{let Q=u1(z).filter(($)=>$.startsWith("iteration-")&&$.endsWith(".json"));return Q.sort(),Q.map(($)=>C(z,$))}catch{return[]}}function d(z){return Math.trunc(z).toLocaleString("en-US")}function q1(z){let Q=Math.trunc(z);if(Q<60)return`${Q}s`;let $=Math.trunc(Q/3600),X=Math.trunc(Q%3600/60),Z=Q%60;if($>0)return`${$}h ${String(X).padStart(2,"0")}m`;return`${X}m ${String(Z).padStart(2,"0")}s`}function f(z,Q=0){let $=Math.pow(10,Q);return Math.round(z*$)/$}function o(z,Q){return z.toFixed(Q)}function G1(z,Q){return z.length>=Q?z:z+" ".repeat(Q-z.length)}function m0(z){let Q="N/A",$=0,X=l(C(z,"state","orchestrator.json"));if(X&&typeof X==="object"){if(typeof X.currentPhase==="string")Q=X.currentPhase;if(typeof X.currentIteration==="number")$=X.currentIteration}let Z=C(z,"metrics","efficiency"),H=v0(Z),W=[];for(let q of H){let M=l(q);if(M&&typeof M==="object")W.push(M)}if(W.length>0)$=Math.max($,W.length);let B=W.reduce((q,M)=>q+(M.input_tokens??0),0),j=W.reduce((q,M)=>q+(M.output_tokens??0),0),O=B+j,T=W.reduce((q,M)=>q+(M.cost_usd??0),0),P=W.reduce((q,M)=>q+(M.duration_seconds??0),0),V=0,U=0,Y=l(C(z,"metrics","budget.json"));if(Y&&typeof Y==="object"){if(typeof Y.budget_limit==="number")V=Y.budget_limit;if(typeof Y.budget_used==="number")U=Y.budget_used}let b=0,z1=0,n=l(C(z,"state","quality-gates.json"));if(n&&typeof n==="object"){if(Array.isArray(n)){for(let q of n)if(z1+=1,q===!0)b+=1;else if(q&&typeof q==="object"){let M=q;if(M.passed===!0||M.status==="passed")b+=1}}else for(let q of Object.values(n))if(typeof q==="boolean"){if(z1+=1,q)b+=1}else if(q&&typeof q==="object"){z1+=1;let M=q;if(M.passed===!0||M.status==="passed")b+=1}}let _1={},$1=l(C(z,"quality","gate-failure-count.json"));if($1&&typeof $1==="object"&&!Array.isArray($1)){let q={};for(let[M,D]of Object.entries($1))if(typeof D==="number")q[M]=D;_1=q}let T1=0,I1=0,w1=0,K1=C(z,"quality");if(J1(K1)){let q=[];try{q=u1(K1)}catch{q=[]}for(let M of q){if(!M.endsWith(".json")||M==="gate-failure-count.json")continue;let D=l(C(K1,M));if(!D||typeof D!=="object")continue;if(!(("verdict"in D)||("approved"in D)||("reviewers"in D)))continue;T1+=1;let F1=(D.verdict??"").toString().toLowerCase();if(D.approved===!0||["approved","approve","pass"].includes(F1))I1+=1;else if(["revision","revise","changes_requested","reject"].includes(F1))w1+=1}}return{phase:Q,iterationCount:$,iterations:W,totalInput:B,totalOutput:j,totalTokens:O,totalCost:T,totalDuration:P,budgetLimit:V,budgetUsed:U,gatesPassed:b,gatesTotal:z1,gateFailures:_1,reviewsTotal:T1,reviewsApproved:I1,reviewsRevision:w1}}function u0(z,Q){let $=z.iterationCount,X={session:{iterations:$,duration_seconds:z.totalDuration,phase:z.phase},tokens:{input:z.totalInput,output:z.totalOutput,total:z.totalTokens,cost_usd:f(z.totalCost,2)},quality:{gates_passed:z.gatesPassed,gates_total:z.gatesTotal,reviews_total:z.reviewsTotal,reviews_approved:z.reviewsApproved,reviews_revision:z.reviewsRevision,gate_failures:z.gateFailures},efficiency:{avg_tokens_per_iteration:$>0?f(z.totalTokens/$,0):0,avg_cost_per_iteration:$>0?f(z.totalCost/$,2):0,avg_duration_per_iteration:$>0?f(z.totalDuration/$,1):0},budget:{used:f(z.budgetUsed,2),limit:z.budgetLimit,percent:z.budgetLimit>0?f(z.budgetUsed/z.budgetLimit*100,1):0}};if(Q)X.iterations=z.iterations.map((W,B)=>({number:B+1,input_tokens:W.input_tokens??0,output_tokens:W.output_tokens??0,cost_usd:f(W.cost_usd??0,2),duration_seconds:W.duration_seconds??0}));let Z=JSON.stringify(X,null,2);function H(W,B){if(!B)return;let j=new RegExp(`("${W}": )(-?\\d+)(,?)$`,"m");Z=Z.replace(j,(O,T,P,V)=>`${T}${P}.0${V}`)}if(H("avg_duration_per_iteration",$>0&&Number.isInteger(X.efficiency.avg_duration_per_iteration)),H("percent",z.budgetLimit>0&&Number.isInteger(X.budget.percent)),H("cost_usd",$>0&&Number.isInteger(X.tokens.cost_usd)),Q)Z=Z.replace(/("cost_usd": )(-?\d+)(,?)$/gm,(W,B,j,O)=>`${B}${j}.0${O}`);return Z}function p0(z,Q){let $=[];if($.push("Loki Mode Session Statistics"),$.push("============================"),$.push(""),$.push("Session"),$.push(` Iterations completed: ${z.iterationCount}`),$.push(` Duration: ${q1(z.totalDuration)}`),$.push(` Current phase: ${z.phase}`),$.push(""),$.push("Token Usage"),z.iterations.length>0)$.push(` Input tokens: ${d(z.totalInput)}`),$.push(` Output tokens: ${d(z.totalOutput)}`),$.push(` Total tokens: ${d(z.totalTokens)}`),$.push(` Estimated cost: $${o(z.totalCost,2)}`);else $.push(" N/A (no iteration metrics found)");if($.push(""),$.push("Quality Gates"),z.gatesTotal>0){let X=Math.round(z.gatesPassed/z.gatesTotal*100);$.push(` Gates passed: ${z.gatesPassed}/${z.gatesTotal} (${X}%)`)}else $.push(" Gates passed: N/A");if(z.reviewsTotal>0){let X=[];if(z.reviewsApproved>0)X.push(`${z.reviewsApproved} approved`);if(z.reviewsRevision>0)X.push(`${z.reviewsRevision} revision requested`);let Z=X.length>0?X.join(", "):"N/A";$.push(` Code reviews: ${z.reviewsTotal} (${Z})`)}if(Object.keys(z.gateFailures).length>0){let X=Object.entries(z.gateFailures).filter(([,Z])=>Z>0).map(([Z,H])=>`${Z} (${H})`);if(X.length>0)$.push(` Gate failures: ${X.join(", ")}`)}if($.push(""),$.push("Efficiency"),z.iterationCount>0&&z.iterations.length>0){let X=Math.round(z.totalTokens/z.iterationCount),Z=z.totalCost/z.iterationCount,H=z.totalDuration/z.iterationCount;$.push(` Avg tokens/iteration: ${d(X)}`),$.push(` Avg cost/iteration: $${o(Z,2)}`),$.push(` Avg duration/iteration: ${q1(H)}`)}else $.push(" N/A (no iteration metrics found)");if($.push(""),$.push("Budget"),z.budgetLimit>0){let X=f(z.budgetUsed/z.budgetLimit*100,1),Z=Number.isInteger(X)?`${X}.0`:`${X}`;$.push(` Used: $${o(z.budgetUsed,2)} / $${o(z.budgetLimit,2)} (${Z}%)`)}else if(z.budgetUsed>0)$.push(` Used: $${o(z.budgetUsed,2)} (no limit set)`);else $.push(" N/A");if(Q&&z.iterations.length>0)$.push(""),$.push("Per-Iteration Breakdown"),z.iterations.forEach((X,Z)=>{let H=Z+1,W=G1(d(X.input_tokens??0),10),B=G1(d(X.output_tokens??0),10),j=X.cost_usd??0,O=q1(X.duration_seconds??0),T=G1(`${H}`,3);$.push(` #${T} input: ${W} output: ${B} cost: $${o(j,2)} time: ${O}`)});return $.join(`
199
- `)}function c1(z){let Q=!1,$=!1;for(let W of z)if(W==="--json")Q=!0;else if(W==="--efficiency")$=!0;let X=E();if(!J1(X)){if(Q)return{exitCode:0,stdout:'{"error": "No active session"}'};return{exitCode:0,stdout:`${_}No active session found.${K}
200
- Start a session with: loki start <prd>`}}let Z=m0(X);return{exitCode:0,stdout:Q?u0(Z,$):p0(Z,$)}}async function c0(z){let Q=c1(z);return console.log(Q.stdout),Q.exitCode}var d1=g(()=>{h();p()});var e1={};r(e1,{runDoctor:()=>$3,httpReachable:()=>A1,checkTool:()=>t1,checkSkills:()=>a1,checkDisk:()=>O1,buildDoctorJson:()=>i1});import{existsSync as l0,lstatSync as d0,readlinkSync as o0,statfsSync as n0}from"fs";import{homedir as n1}from"os";import{resolve as o1}from"path";function t0(z){let Q=z.match(r0);return Q?Q[1]:null}async function a0(z){try{let Q=await I([z,"--version"],{timeoutMs:5000}),$=(Q.stdout||Q.stderr||"").trim();return t0($)}catch{return null}}function r1(z,Q){let $=z.split(".").map((Z)=>parseInt(Z,10)),X=Q.split(".").map((Z)=>parseInt(Z,10));while($.length<2)$.push(0);while(X.length<2)X.push(0);for(let Z=0;Z<2;Z++){let H=$[Z]??0,W=X[Z]??0;if(Number.isNaN(H)||Number.isNaN(W))return 0;if(H!==W)return H-W}return 0}async function t1(z,Q,$,X=null){let Z=await R(Q),H=Z!==null,W=H?await a0(Q):null,B="pass";if(!H)B=$==="required"?"fail":"warn";else if(X&&W){if(r1(W,X)<0)B=$==="required"?"fail":"warn"}return{name:z,command:Q,found:H,version:W,required:$,min_version:X,status:B,path:Z}}function O1(){let z=null;try{let $=n0(n1()),X=Number($.bavail)*Number($.bsize);z=Math.round(X/1073741824*10)/10}catch{z=null}let Q="pass";if(z!==null){if(z<1)Q="fail";else if(z<5)Q="warn"}return{available_gb:z,status:Q}}async function A1(z,Q=2000){try{return(await fetch(z,{signal:AbortSignal.timeout(Q)})).ok}catch{return!1}}async function j1(z,Q=!1){let $=`import ${z}`,X=Q?30000:5000;if(!Q)return(await s($,{timeoutMs:X})).exitCode===0;let Z=await a();if(!Z)return!1;return(await I([Z,"-c",$],{timeoutMs:X})).exitCode===0}function a1(){let z=n1();return s0.map(({name:Q,dir:$})=>{let X=o1(z,$),Z=X,H=o1(X,"SKILL.md");if(l0(H))return{name:Q,path:Z,status:"pass",detail:""};try{if(d0(X).isSymbolicLink()){let B="unknown";try{B=o0(X)}catch{}return{name:Q,path:Z,status:"fail",detail:`(broken symlink -> ${B})`}}}catch{}return{name:Q,path:Z,status:"warn",detail:"(not found - run 'loki setup-skill')"}})}async function s1(){return Promise.all(i0.map(async(z)=>{return{...await t1(z.jsonName,z.cmd,z.required,z.min??null),displayName:z.displayName}}))}async function i1(){let Q=(await s1()).map(({displayName:W,...B})=>B),$=O1(),X=0,Z=0,H=0;for(let W of Q)if(W.status==="pass")X++;else if(W.status==="fail")Z++;else H++;if($.status==="pass")X++;else if($.status==="fail")Z++;else H++;return{checks:Q,disk:$,summary:{passed:X,failed:Z,warnings:H,ok:Z===0}}}function J(z){switch(z){case"pass":return`${x}PASS${K}`;case"fail":return`${S}FAIL${K}`;case"warn":return`${_}WARN${K}`}}function M1(z){let Q=z.version?` (v${z.version})`:"",$=z.displayName;if(!z.found){let X=z.required==="required"?"not found":z.required==="recommended"?"not found (recommended)":"not found (optional)";return` ${J(z.status)} ${$} - ${X}`}if(z.min_version&&z.version&&r1(z.version,z.min_version)<0){let X=z.required==="required"?"requires":"recommended";return` ${J(z.status)} ${$}${Q} - ${X} >= ${z.min_version}`}return` ${J(z.status)} ${$}${Q}`}function Y1(z,Q){if(Q==="pass")z.pass++;else if(Q==="fail")z.fail++;else z.warn++}function e0(){process.stdout.write(`${F}loki doctor${K} - Check system prerequisites
198
+ `;var m1=g(()=>{m();Q1();p();h()});var l1={};r(l1,{runStats:()=>c0,computeStats:()=>c1});import{readdirSync as u1,readFileSync as h0,statSync as p1}from"fs";import{join as C}from"path";function l(z){try{if(!p1(z).isFile())return null;return JSON.parse(h0(z,"utf-8"))}catch{return null}}function M1(z){try{return p1(z).isDirectory()}catch{return!1}}function v0(z){if(!M1(z))return[];try{let Q=u1(z).filter(($)=>$.startsWith("iteration-")&&$.endsWith(".json"));return Q.sort(),Q.map(($)=>C(z,$))}catch{return[]}}function d(z){return Math.trunc(z).toLocaleString("en-US")}function J1(z){let Q=Math.trunc(z);if(Q<60)return`${Q}s`;let $=Math.trunc(Q/3600),X=Math.trunc(Q%3600/60),Z=Q%60;if($>0)return`${$}h ${String(X).padStart(2,"0")}m`;return`${X}m ${String(Z).padStart(2,"0")}s`}function f(z,Q=0){let $=Math.pow(10,Q);return Math.round(z*$)/$}function o(z,Q){return z.toFixed(Q)}function j1(z,Q){return z.length>=Q?z:z+" ".repeat(Q-z.length)}function m0(z){let Q="N/A",$=0,X=l(C(z,"state","orchestrator.json"));if(X&&typeof X==="object"){if(typeof X.currentPhase==="string")Q=X.currentPhase;if(typeof X.currentIteration==="number")$=X.currentIteration}let Z=C(z,"metrics","efficiency"),H=v0(Z),W=[];for(let q of H){let M=l(q);if(M&&typeof M==="object")W.push(M)}if(W.length>0)$=Math.max($,W.length);let B=W.reduce((q,M)=>q+(M.input_tokens??0),0),j=W.reduce((q,M)=>q+(M.output_tokens??0),0),O=B+j,I=W.reduce((q,M)=>q+(M.cost_usd??0),0),D=W.reduce((q,M)=>q+(M.duration_seconds??0),0),U=0,Y=0,V=l(C(z,"metrics","budget.json"));if(V&&typeof V==="object"){if(typeof V.budget_limit==="number")U=V.budget_limit;if(typeof V.budget_used==="number")Y=V.budget_used}let _=0,z1=0,n=l(C(z,"state","quality-gates.json"));if(n&&typeof n==="object"){if(Array.isArray(n)){for(let q of n)if(z1+=1,q===!0)_+=1;else if(q&&typeof q==="object"){let M=q;if(M.passed===!0||M.status==="passed")_+=1}}else for(let q of Object.values(n))if(typeof q==="boolean"){if(z1+=1,q)_+=1}else if(q&&typeof q==="object"){z1+=1;let M=q;if(M.passed===!0||M.status==="passed")_+=1}}let _1={},$1=l(C(z,"quality","gate-failure-count.json"));if($1&&typeof $1==="object"&&!Array.isArray($1)){let q={};for(let[M,E]of Object.entries($1))if(typeof E==="number")q[M]=E;_1=q}let T1=0,I1=0,w1=0,W1=C(z,"quality");if(M1(W1)){let q=[];try{q=u1(W1)}catch{q=[]}for(let M of q){if(!M.endsWith(".json")||M==="gate-failure-count.json")continue;let E=l(C(W1,M));if(!E||typeof E!=="object")continue;if(!(("verdict"in E)||("approved"in E)||("reviewers"in E)))continue;T1+=1;let F1=(E.verdict??"").toString().toLowerCase();if(E.approved===!0||["approved","approve","pass"].includes(F1))I1+=1;else if(["revision","revise","changes_requested","reject"].includes(F1))w1+=1}}return{phase:Q,iterationCount:$,iterations:W,totalInput:B,totalOutput:j,totalTokens:O,totalCost:I,totalDuration:D,budgetLimit:U,budgetUsed:Y,gatesPassed:_,gatesTotal:z1,gateFailures:_1,reviewsTotal:T1,reviewsApproved:I1,reviewsRevision:w1}}function u0(z,Q){let $=z.iterationCount,X={session:{iterations:$,duration_seconds:z.totalDuration,phase:z.phase},tokens:{input:z.totalInput,output:z.totalOutput,total:z.totalTokens,cost_usd:f(z.totalCost,2)},quality:{gates_passed:z.gatesPassed,gates_total:z.gatesTotal,reviews_total:z.reviewsTotal,reviews_approved:z.reviewsApproved,reviews_revision:z.reviewsRevision,gate_failures:z.gateFailures},efficiency:{avg_tokens_per_iteration:$>0?f(z.totalTokens/$,0):0,avg_cost_per_iteration:$>0?f(z.totalCost/$,2):0,avg_duration_per_iteration:$>0?f(z.totalDuration/$,1):0},budget:{used:f(z.budgetUsed,2),limit:z.budgetLimit,percent:z.budgetLimit>0?f(z.budgetUsed/z.budgetLimit*100,1):0}};if(Q)X.iterations=z.iterations.map((W,B)=>({number:B+1,input_tokens:W.input_tokens??0,output_tokens:W.output_tokens??0,cost_usd:f(W.cost_usd??0,2),duration_seconds:W.duration_seconds??0}));let Z=JSON.stringify(X,null,2);function H(W,B){if(!B)return;let j=new RegExp(`("${W}": )(-?\\d+)(,?)$`,"m");Z=Z.replace(j,(O,I,D,U)=>`${I}${D}.0${U}`)}if(H("avg_duration_per_iteration",$>0&&Number.isInteger(X.efficiency.avg_duration_per_iteration)),H("percent",z.budgetLimit>0&&Number.isInteger(X.budget.percent)),H("cost_usd",$>0&&Number.isInteger(X.tokens.cost_usd)),Q)Z=Z.replace(/("cost_usd": )(-?\d+)(,?)$/gm,(W,B,j,O)=>`${B}${j}.0${O}`);return Z}function p0(z,Q){let $=[];if($.push("Loki Mode Session Statistics"),$.push("============================"),$.push(""),$.push("Session"),$.push(` Iterations completed: ${z.iterationCount}`),$.push(` Duration: ${J1(z.totalDuration)}`),$.push(` Current phase: ${z.phase}`),$.push(""),$.push("Token Usage"),z.iterations.length>0)$.push(` Input tokens: ${d(z.totalInput)}`),$.push(` Output tokens: ${d(z.totalOutput)}`),$.push(` Total tokens: ${d(z.totalTokens)}`),$.push(` Estimated cost: $${o(z.totalCost,2)}`);else $.push(" N/A (no iteration metrics found)");if($.push(""),$.push("Quality Gates"),z.gatesTotal>0){let X=Math.round(z.gatesPassed/z.gatesTotal*100);$.push(` Gates passed: ${z.gatesPassed}/${z.gatesTotal} (${X}%)`)}else $.push(" Gates passed: N/A");if(z.reviewsTotal>0){let X=[];if(z.reviewsApproved>0)X.push(`${z.reviewsApproved} approved`);if(z.reviewsRevision>0)X.push(`${z.reviewsRevision} revision requested`);let Z=X.length>0?X.join(", "):"N/A";$.push(` Code reviews: ${z.reviewsTotal} (${Z})`)}if(Object.keys(z.gateFailures).length>0){let X=Object.entries(z.gateFailures).filter(([,Z])=>Z>0).map(([Z,H])=>`${Z} (${H})`);if(X.length>0)$.push(` Gate failures: ${X.join(", ")}`)}if($.push(""),$.push("Efficiency"),z.iterationCount>0&&z.iterations.length>0){let X=Math.round(z.totalTokens/z.iterationCount),Z=z.totalCost/z.iterationCount,H=z.totalDuration/z.iterationCount;$.push(` Avg tokens/iteration: ${d(X)}`),$.push(` Avg cost/iteration: $${o(Z,2)}`),$.push(` Avg duration/iteration: ${J1(H)}`)}else $.push(" N/A (no iteration metrics found)");if($.push(""),$.push("Budget"),z.budgetLimit>0){let X=f(z.budgetUsed/z.budgetLimit*100,1),Z=Number.isInteger(X)?`${X}.0`:`${X}`;$.push(` Used: $${o(z.budgetUsed,2)} / $${o(z.budgetLimit,2)} (${Z}%)`)}else if(z.budgetUsed>0)$.push(` Used: $${o(z.budgetUsed,2)} (no limit set)`);else $.push(" N/A");if(Q&&z.iterations.length>0)$.push(""),$.push("Per-Iteration Breakdown"),z.iterations.forEach((X,Z)=>{let H=Z+1,W=j1(d(X.input_tokens??0),10),B=j1(d(X.output_tokens??0),10),j=X.cost_usd??0,O=J1(X.duration_seconds??0),I=j1(`${H}`,3);$.push(` #${I} input: ${W} output: ${B} cost: $${o(j,2)} time: ${O}`)});return $.join(`
199
+ `)}function c1(z){let Q=!1,$=!1;for(let W of z)if(W==="--json")Q=!0;else if(W==="--efficiency")$=!0;let X=b();if(!M1(X)){if(Q)return{exitCode:0,stdout:'{"error": "No active session"}'};return{exitCode:0,stdout:`${T}No active session found.${K}
200
+ Start a session with: loki start <prd>`}}let Z=m0(X);return{exitCode:0,stdout:Q?u0(Z,$):p0(Z,$)}}async function c0(z){let Q=c1(z);return console.log(Q.stdout),Q.exitCode}var d1=g(()=>{h();p()});var e1={};r(e1,{runDoctor:()=>$3,httpReachable:()=>A1,checkTool:()=>t1,checkSkills:()=>a1,checkDisk:()=>O1,buildDoctorJson:()=>i1});import{existsSync as l0,lstatSync as d0,readlinkSync as o0,statfsSync as n0}from"fs";import{homedir as n1}from"os";import{resolve as o1}from"path";function t0(z){let Q=z.match(r0);return Q?Q[1]:null}async function a0(z){try{let Q=await w([z,"--version"],{timeoutMs:5000}),$=(Q.stdout||Q.stderr||"").trim();return t0($)}catch{return null}}function r1(z,Q){let $=z.split(".").map((Z)=>parseInt(Z,10)),X=Q.split(".").map((Z)=>parseInt(Z,10));while($.length<2)$.push(0);while(X.length<2)X.push(0);for(let Z=0;Z<2;Z++){let H=$[Z]??0,W=X[Z]??0;if(Number.isNaN(H)||Number.isNaN(W))return 0;if(H!==W)return H-W}return 0}async function t1(z,Q,$,X=null){let Z=await R(Q),H=Z!==null,W=H?await a0(Q):null,B="pass";if(!H)B=$==="required"?"fail":"warn";else if(X&&W){if(r1(W,X)<0)B=$==="required"?"fail":"warn"}return{name:z,command:Q,found:H,version:W,required:$,min_version:X,status:B,path:Z}}function O1(){let z=null;try{let $=n0(n1()),X=Number($.bavail)*Number($.bsize);z=Math.round(X/1073741824*10)/10}catch{z=null}let Q="pass";if(z!==null){if(z<1)Q="fail";else if(z<5)Q="warn"}return{available_gb:z,status:Q}}async function A1(z,Q=2000){try{return(await fetch(z,{signal:AbortSignal.timeout(Q)})).ok}catch{return!1}}async function Y1(z,Q=!1){let $=`import ${z}`,X=Q?30000:5000;if(!Q)return(await s($,{timeoutMs:X})).exitCode===0;let Z=await a();if(!Z)return!1;return(await w([Z,"-c",$],{timeoutMs:X})).exitCode===0}function a1(){let z=n1();return s0.map(({name:Q,dir:$})=>{let X=o1(z,$),Z=X,H=o1(X,"SKILL.md");if(l0(H))return{name:Q,path:Z,status:"pass",detail:""};try{if(d0(X).isSymbolicLink()){let B="unknown";try{B=o0(X)}catch{}return{name:Q,path:Z,status:"fail",detail:`(broken symlink -> ${B})`}}}catch{}return{name:Q,path:Z,status:"warn",detail:"(not found - run 'loki setup-skill')"}})}async function s1(){return Promise.all(i0.map(async(z)=>{return{...await t1(z.jsonName,z.cmd,z.required,z.min??null),displayName:z.displayName}}))}async function i1(){let Q=(await s1()).map(({displayName:W,...B})=>B),$=O1(),X=0,Z=0,H=0;for(let W of Q)if(W.status==="pass")X++;else if(W.status==="fail")Z++;else H++;if($.status==="pass")X++;else if($.status==="fail")Z++;else H++;return{checks:Q,disk:$,summary:{passed:X,failed:Z,warnings:H,ok:Z===0}}}function J(z){switch(z){case"pass":return`${P}PASS${K}`;case"fail":return`${S}FAIL${K}`;case"warn":return`${T}WARN${K}`}}function K1(z){let Q=z.version?` (v${z.version})`:"",$=z.displayName;if(!z.found){let X=z.required==="required"?"not found":z.required==="recommended"?"not found (recommended)":"not found (optional)";return` ${J(z.status)} ${$} - ${X}`}if(z.min_version&&z.version&&r1(z.version,z.min_version)<0){let X=z.required==="required"?"requires":"recommended";return` ${J(z.status)} ${$}${Q} - ${X} >= ${z.min_version}`}return` ${J(z.status)} ${$}${Q}`}function H1(z,Q){if(Q==="pass")z.pass++;else if(Q==="fail")z.fail++;else z.warn++}function e0(){process.stdout.write(`${x}loki doctor${K} - Check system prerequisites
201
201
 
202
202
  `),process.stdout.write(`Usage: loki doctor [--json]
203
203
 
@@ -206,17 +206,17 @@ Start a session with: loki start <prd>`}}let Z=m0(X);return{exitCode:0,stdout:Q?
206
206
 
207
207
  `),process.stdout.write(`Checks: node, python3, jq, git, curl, bash version,
208
208
  `),process.stdout.write(` claude/codex/gemini CLIs, and disk space.
209
- `)}async function z3(){process.stdout.write(`${F}Loki Mode Doctor${K}
209
+ `)}async function z3(){process.stdout.write(`${x}Loki Mode Doctor${K}
210
210
 
211
211
  `),process.stdout.write(`Checking system prerequisites...
212
212
 
213
- `);let z={pass:0,fail:0,warn:0},Q=await s1(),$=new Map(Q.map((U)=>[U.command,U]));process.stdout.write(`${G}Required:${K}
214
- `);for(let U of["node","python3","jq","git","curl"]){let Y=$.get(U);process.stdout.write(M1(Y)+`
215
- `),Y1(z,Y.status)}process.stdout.write(`
213
+ `);let z={pass:0,fail:0,warn:0},Q=await s1(),$=new Map(Q.map((V)=>[V.command,V]));process.stdout.write(`${G}Required:${K}
214
+ `);for(let V of["node","python3","jq","git","curl"]){let _=$.get(V);process.stdout.write(K1(_)+`
215
+ `),H1(z,_.status)}process.stdout.write(`
216
216
  `),process.stdout.write(`${G}AI Providers:${K}
217
- `);let X=["claude","codex","gemini","cline","aider"],Z=!1;for(let U of X){let Y=$.get(U);if(process.stdout.write(M1(Y)+`
218
- `),Y1(z,Y.status),Y.found)Z=!0}if(!Z)process.stdout.write(` ${J("fail")} No AI provider CLI installed -- at least one is required
219
- `),process.stdout.write(` ${_}Install: npm install -g @anthropic-ai/claude-code${K}
217
+ `);let X=["claude","codex","gemini","cline","aider"],Z=!1;for(let V of X){let _=$.get(V);if(process.stdout.write(K1(_)+`
218
+ `),H1(z,_.status),_.found)Z=!0}if(!Z)process.stdout.write(` ${J("fail")} No AI provider CLI installed -- at least one is required
219
+ `),process.stdout.write(` ${T}Install: npm install -g @anthropic-ai/claude-code${K}
220
220
  `),z.fail++;process.stdout.write(`
221
221
  `),process.stdout.write(`${G}API Keys:${K}
222
222
  `);let H=$.get("claude").found,W=$.get("codex").found,B=$.get("gemini").found,j=process.env;if(j.ANTHROPIC_API_KEY)process.stdout.write(` ${J("pass")} ANTHROPIC_API_KEY is set
@@ -227,17 +227,17 @@ Start a session with: loki start <prd>`}}let Z=m0(X);return{exitCode:0,stdout:Q?
227
227
  `),z.pass++;else if(B)process.stdout.write(` ${A} -- ${K} GOOGLE_API_KEY not set (Gemini CLI uses its own login)
228
228
  `);process.stdout.write(`
229
229
  `),process.stdout.write(`${G}Skills:${K}
230
- `);for(let U of a1())if(U.status==="pass")process.stdout.write(` ${J("pass")} ${U.name} ${A}${U.path}${K}
231
- `),z.pass++;else if(U.status==="fail")process.stdout.write(` ${J("fail")} ${U.name} ${A}${U.detail}${K}
232
- `),process.stdout.write(` ${_}Fix: loki setup-skill${K}
233
- `),z.fail++;else process.stdout.write(` ${J("warn")} ${U.name} ${A}${U.detail}${K}
230
+ `);for(let V of a1())if(V.status==="pass")process.stdout.write(` ${J("pass")} ${V.name} ${A}${V.path}${K}
231
+ `),z.pass++;else if(V.status==="fail")process.stdout.write(` ${J("fail")} ${V.name} ${A}${V.detail}${K}
232
+ `),process.stdout.write(` ${T}Fix: loki setup-skill${K}
233
+ `),z.fail++;else process.stdout.write(` ${J("warn")} ${V.name} ${A}${V.detail}${K}
234
234
  `),z.warn++;if(process.stdout.write(`
235
235
  `),process.stdout.write(`${G}Integrations:${K}
236
- `),await j1("mcp"))process.stdout.write(` ${J("pass")} MCP SDK (Python)
236
+ `),await Y1("mcp"))process.stdout.write(` ${J("pass")} MCP SDK (Python)
237
237
  `),z.pass++;else process.stdout.write(` ${J("warn")} MCP SDK - not installed (pip3 install mcp)
238
- `),z.warn++;if(await j1("numpy",!0))process.stdout.write(` ${J("pass")} numpy (vector search)
238
+ `),z.warn++;if(await Y1("numpy",!0))process.stdout.write(` ${J("pass")} numpy (vector search)
239
239
  `),z.pass++;else process.stdout.write(` ${J("warn")} numpy - not installed (pip3 install numpy)
240
- `),z.warn++;if(await j1("sentence_transformers",!0))process.stdout.write(` ${J("pass")} sentence-transformers (embeddings)
240
+ `),z.warn++;if(await Y1("sentence_transformers",!0))process.stdout.write(` ${J("pass")} sentence-transformers (embeddings)
241
241
  `),z.pass++;else process.stdout.write(` ${J("warn")} sentence-transformers - not installed (loki memory vectors setup)
242
242
  `),z.warn++;if(await A1("http://localhost:8100/api/v2/heartbeat"))process.stdout.write(` ${J("pass")} ChromaDB server (port 8100)
243
243
  `),z.pass++;else process.stdout.write(` ${J("warn")} ChromaDB - not running (docker start loki-chroma)
@@ -247,39 +247,40 @@ Start a session with: loki start <prd>`}}let Z=m0(X);return{exitCode:0,stdout:Q?
247
247
  `),z.pass++;else process.stdout.write(` ${J("warn")} OTEL - not configured (set LOKI_OTEL_ENDPOINT)
248
248
  `),z.warn++;process.stdout.write(`
249
249
  `),process.stdout.write(`${G}System:${K}
250
- `);let T=$.get("bash");process.stdout.write(M1(T)+`
251
- `),Y1(z,T.status);let P=O1(),V=P.available_gb===null?null:Math.floor(P.available_gb);if(V===null)process.stdout.write(` ${J("warn")} Disk space: unable to determine
252
- `),z.warn++;else if(P.status==="fail")process.stdout.write(` ${J("fail")} Disk space: ${V}GB available (need >= 1GB)
253
- `),z.fail++;else if(P.status==="warn")process.stdout.write(` ${J("warn")} Disk space: ${V}GB available (low)
254
- `),z.warn++;else process.stdout.write(` ${J("pass")} Disk space: ${V}GB available
250
+ `);let I=$.get("bash");process.stdout.write(K1(I)+`
251
+ `),H1(z,I.status);let D=$.get("bun");if(D)process.stdout.write(K1(D)+`
252
+ `),H1(z,D.status);let U=O1(),Y=U.available_gb===null?null:Math.floor(U.available_gb);if(Y===null)process.stdout.write(` ${J("warn")} Disk space: unable to determine
253
+ `),z.warn++;else if(U.status==="fail")process.stdout.write(` ${J("fail")} Disk space: ${Y}GB available (need >= 1GB)
254
+ `),z.fail++;else if(U.status==="warn")process.stdout.write(` ${J("warn")} Disk space: ${Y}GB available (low)
255
+ `),z.warn++;else process.stdout.write(` ${J("pass")} Disk space: ${Y}GB available
255
256
  `),z.pass++;if(process.stdout.write(`
256
- `),process.stdout.write(`${F}Summary:${K} ${x}${z.pass} passed${K}, ${S}${z.fail} failed${K}, ${_}${z.warn} warnings${K}
257
+ `),process.stdout.write(`${x}Summary:${K} ${P}${z.pass} passed${K}, ${S}${z.fail} failed${K}, ${T}${z.warn} warnings${K}
257
258
 
258
259
  `),z.fail>0)return process.stdout.write(`${S}Some required prerequisites are missing.${K}
259
260
  `),process.stdout.write(`Install missing dependencies and run 'loki doctor' again.
260
- `),1;if(z.warn>0)return process.stdout.write(`${_}All required checks passed with some warnings.${K}
261
- `),0;return process.stdout.write(`${x}All checks passed. System is ready for Loki Mode.${K}
261
+ `),1;if(z.warn>0)return process.stdout.write(`${T}All required checks passed with some warnings.${K}
262
+ `),0;return process.stdout.write(`${P}All checks passed. System is ready for Loki Mode.${K}
262
263
  `),0}async function $3(z){let Q=!1;for(let $ of z)if($==="--json")Q=!0;else if($==="--help"||$==="-h")return e0(),0;else return process.stderr.write(`${S}Unknown option: ${$}${K}
263
264
  `),process.stderr.write(`Usage: loki doctor [--json]
264
265
  `),1;if(Q){let $=await i1();return process.stdout.write(JSON.stringify($,null,2)+`
265
- `),0}return z3()}var r0,s0,i0;var z0=g(()=>{m();Q1();p();r0=/(\d+\.\d+(?:\.\d+)*)/;s0=[{name:"Claude Code",dir:".claude/skills/loki-mode"},{name:"Codex CLI",dir:".codex/skills/loki-mode"},{name:"Gemini CLI",dir:".gemini/skills/loki-mode"},{name:"Cline CLI",dir:".cline/skills/loki-mode"},{name:"Aider CLI",dir:".aider/skills/loki-mode"}];i0=[{displayName:"Node.js (>= 18)",jsonName:"Node.js",cmd:"node",required:"required",min:"18.0"},{displayName:"Python 3 (>= 3.8)",jsonName:"Python 3",cmd:"python3",required:"required",min:"3.8"},{displayName:"jq",jsonName:"jq",cmd:"jq",required:"required"},{displayName:"git",jsonName:"git",cmd:"git",required:"required"},{displayName:"curl",jsonName:"curl",cmd:"curl",required:"required"},{displayName:"bash (>= 4.0)",jsonName:"bash",cmd:"bash",required:"recommended",min:"4.0"},{displayName:"Bun (>= 1.3)",jsonName:"Bun",cmd:"bun",required:"recommended",min:"1.3"},{displayName:"Claude CLI",jsonName:"Claude CLI",cmd:"claude",required:"optional"},{displayName:"Codex CLI",jsonName:"Codex CLI",cmd:"codex",required:"optional"},{displayName:"Gemini CLI",jsonName:"Gemini CLI",cmd:"gemini",required:"optional"},{displayName:"Cline CLI",jsonName:"Cline CLI",cmd:"cline",required:"optional"},{displayName:"Aider CLI",jsonName:"Aider CLI",cmd:"aider",required:"optional"}]});h();import{readFileSync as U0}from"fs";import{resolve as V0,dirname as q0}from"path";import{fileURLToPath as G0}from"url";var v=null;function k1(){if(v!==null)return v;let z="7.4.10";if(typeof z==="string"&&z.length>0)return v=z,v;try{let Q=q0(G0(import.meta.url)),$=W1(Q);v=U0(V0($,"VERSION"),"utf-8").trim()}catch{v="unknown"}return v}function R1(){return process.stdout.write(`Loki Mode v${k1()}
266
- `),0}m();p();h();import{readFileSync as A0,existsSync as O0}from"fs";import{resolve as _0}from"path";var T0=["claude","codex","gemini","cline","aider"];function D1(){let z=_0(E(),"state","provider");if(!O0(z))return"";try{return A0(z,"utf-8").trim()}catch{return""}}function I0(z,Q){return z||Q||process.env.LOKI_PROVIDER||"claude"}function w0(z){let Q=D1(),$=I0(z,Q);switch(process.stdout.write(`${F}Current Provider${K}
266
+ `),0}return z3()}var r0,s0,i0;var z0=g(()=>{m();Q1();p();r0=/(\d+\.\d+(?:\.\d+)*)/;s0=[{name:"Claude Code",dir:".claude/skills/loki-mode"},{name:"Codex CLI",dir:".codex/skills/loki-mode"},{name:"Gemini CLI",dir:".gemini/skills/loki-mode"},{name:"Cline CLI",dir:".cline/skills/loki-mode"},{name:"Aider CLI",dir:".aider/skills/loki-mode"}];i0=[{displayName:"Node.js (>= 18)",jsonName:"Node.js",cmd:"node",required:"required",min:"18.0"},{displayName:"Python 3 (>= 3.8)",jsonName:"Python 3",cmd:"python3",required:"required",min:"3.8"},{displayName:"jq",jsonName:"jq",cmd:"jq",required:"required"},{displayName:"git",jsonName:"git",cmd:"git",required:"required"},{displayName:"curl",jsonName:"curl",cmd:"curl",required:"required"},{displayName:"bash (>= 4.0)",jsonName:"bash",cmd:"bash",required:"recommended",min:"4.0"},{displayName:"Bun (>= 1.3)",jsonName:"Bun",cmd:"bun",required:"recommended",min:"1.3"},{displayName:"Claude CLI",jsonName:"Claude CLI",cmd:"claude",required:"optional"},{displayName:"Codex CLI",jsonName:"Codex CLI",cmd:"codex",required:"optional"},{displayName:"Gemini CLI",jsonName:"Gemini CLI",cmd:"gemini",required:"optional"},{displayName:"Cline CLI",jsonName:"Cline CLI",cmd:"cline",required:"optional"},{displayName:"Aider CLI",jsonName:"Aider CLI",cmd:"aider",required:"optional"}]});h();import{readFileSync as U0}from"fs";import{resolve as V0,dirname as q0}from"path";import{fileURLToPath as G0}from"url";var v=null;function k1(){if(v!==null)return v;let z="7.4.12";if(typeof z==="string"&&z.length>0)return v=z,v;try{let Q=q0(G0(import.meta.url)),$=U1(Q);v=U0(V0($,"VERSION"),"utf-8").trim()}catch{v="unknown"}return v}function R1(){return process.stdout.write(`Loki Mode v${k1()}
267
+ `),0}m();p();h();import{readFileSync as A0,existsSync as O0}from"fs";import{resolve as _0}from"path";var T0=["claude","codex","gemini","cline","aider"];function D1(){let z=_0(b(),"state","provider");if(!O0(z))return"";try{return A0(z,"utf-8").trim()}catch{return""}}function I0(z,Q){return z||Q||process.env.LOKI_PROVIDER||"claude"}function w0(z){let Q=D1(),$=I0(z,Q);switch(process.stdout.write(`${x}Current Provider${K}
267
268
  `),process.stdout.write(`
268
269
  `),process.stdout.write(`${G}Provider:${K} ${$}
269
- `),$){case"claude":process.stdout.write(`${x}Status:${K} Full features (subagents, parallel, MCP)
270
- `);break;case"cline":process.stdout.write(`${x}Status:${K} Near-full mode (subagents, MCP, 12+ providers)
271
- `);break;case"codex":case"gemini":case"aider":process.stdout.write(`${_}Status:${K} Degraded mode (sequential only)
270
+ `),$){case"claude":process.stdout.write(`${P}Status:${K} Full features (subagents, parallel, MCP)
271
+ `);break;case"cline":process.stdout.write(`${P}Status:${K} Near-full mode (subagents, MCP, 12+ providers)
272
+ `);break;case"codex":case"gemini":case"aider":process.stdout.write(`${T}Status:${K} Degraded mode (sequential only)
272
273
  `);break;default:break}if(Q)process.stdout.write(`${A}(saved in .loki/state/provider)${K}
273
274
  `);else process.stdout.write(`${A}(default - not explicitly set)${K}
274
275
  `);return process.stdout.write(`
275
276
  `),process.stdout.write(`Switch provider: ${G}loki provider set <name>${K}
276
277
  `),process.stdout.write(`Available: ${G}loki provider list${K}
277
- `),0}async function F0(){let Q=D1()||process.env.LOKI_PROVIDER||"claude";process.stdout.write(`${F}Available Providers${K}
278
+ `),0}async function F0(){let Q=D1()||process.env.LOKI_PROVIDER||"claude";process.stdout.write(`${x}Available Providers${K}
278
279
  `),process.stdout.write(`
279
- `);let $=await Promise.all(T0.map(async(H)=>[H,await R(H)!==null])),X=new Map;for(let[H,W]of $)X.set(H,W?`${x}installed${K}`:`${S}not installed${K}`);let Z=[["claude","claude - Claude Code (Anthropic) "],["codex","codex - Codex CLI (OpenAI) "],["gemini","gemini - Gemini CLI (Google) "],["cline","cline - Cline (multi-provider) "],["aider","aider - Aider (terminal pair prog) "]];for(let[H,W]of Z){let B=Q===H?` ${G}(current)${K}`:"";process.stdout.write(` ${W} ${X.get(H)}${B}
280
+ `);let $=await Promise.all(T0.map(async(H)=>[H,await R(H)!==null])),X=new Map;for(let[H,W]of $)X.set(H,W?`${P}installed${K}`:`${S}not installed${K}`);let Z=[["claude","claude - Claude Code (Anthropic) "],["codex","codex - Codex CLI (OpenAI) "],["gemini","gemini - Gemini CLI (Google) "],["cline","cline - Cline (multi-provider) "],["aider","aider - Aider (terminal pair prog) "]];for(let[H,W]of Z){let B=Q===H?` ${G}(current)${K}`:"";process.stdout.write(` ${W} ${X.get(H)}${B}
280
281
  `)}return process.stdout.write(`
281
282
  `),process.stdout.write(`Set provider: ${G}loki provider set <name>${K}
282
- `),0}function L0(){return process.stdout.write(`${F}Loki Mode Provider Management${K}
283
+ `),0}function x0(){return process.stdout.write(`${x}Loki Mode Provider Management${K}
283
284
  `),process.stdout.write(`
284
285
  `),process.stdout.write(`Usage: loki provider <command>
285
286
  `),process.stdout.write(`
@@ -297,11 +298,11 @@ Start a session with: loki start <prd>`}}let Z=m0(X);return{exitCode:0,stdout:Q?
297
298
  `),process.stdout.write(` loki provider list
298
299
  `),process.stdout.write(` loki provider info gemini
299
300
  `),process.stdout.write(` loki provider models
300
- `),0}async function E1(z){let Q=z[0]??"show",$=z.slice(1);switch(Q){case"show":case"current":return w0($[0]);case"list":return F0();case"set":case"info":case"models":return x0(["provider",Q,...$]);default:return L0()}}async function x0(z){let{run:Q}=await Promise.resolve().then(() => (m(),S1)),{resolve:$}=await import("path"),{REPO_ROOT:X}=await Promise.resolve().then(() => (h(),P1)),Z=$(X,"autonomy","loki"),H=await Q([Z,...z],{env:{LOKI_LEGACY_BASH:"1"},timeoutMs:3600000});return process.stdout.write(H.stdout),process.stderr.write(H.stderr),H.exitCode}p();h();Q1();m();import{existsSync as b1,readFileSync as k0}from"fs";import{resolve as c}from"path";import{mkdir as R0}from"fs/promises";var i=c(B1(),"learnings");function V1(z){if(!b1(z))return 0;try{let Q=k0(z,"utf-8"),$=0;for(let X of Q.split(`
301
- `))if(X.includes('"description"'))$++;return $}catch{return 0}}async function S0(){await R0(i,{recursive:!0});let z=V1(c(i,"patterns.jsonl")),Q=V1(c(i,"mistakes.jsonl")),$=V1(c(i,"successes.jsonl"));return process.stdout.write(`${F}Cross-Project Learnings${K}
301
+ `),0}async function E1(z){let Q=z[0]??"show",$=z.slice(1);switch(Q){case"show":case"current":return w0($[0]);case"list":return F0();case"set":case"info":case"models":return L0(["provider",Q,...$]);default:return x0()}}async function L0(z){let{run:Q}=await Promise.resolve().then(() => (m(),S1)),{resolve:$}=await import("path"),{REPO_ROOT:X}=await Promise.resolve().then(() => (h(),P1)),Z=$(X,"autonomy","loki"),H=await Q([Z,...z],{env:{LOKI_LEGACY_BASH:"1"},timeoutMs:3600000});return process.stdout.write(H.stdout),process.stderr.write(H.stderr),H.exitCode}p();h();Q1();m();import{existsSync as b1,readFileSync as k0}from"fs";import{resolve as c}from"path";import{mkdir as R0}from"fs/promises";var i=c(V1(),"learnings");function G1(z){if(!b1(z))return 0;try{let Q=k0(z,"utf-8"),$=0;for(let X of Q.split(`
302
+ `))if(X.includes('"description"'))$++;return $}catch{return 0}}async function S0(){await R0(i,{recursive:!0});let z=G1(c(i,"patterns.jsonl")),Q=G1(c(i,"mistakes.jsonl")),$=G1(c(i,"successes.jsonl"));return process.stdout.write(`${x}Cross-Project Learnings${K}
302
303
  `),process.stdout.write(`
303
- `),process.stdout.write(` Patterns: ${x}${z}${K}
304
- `),process.stdout.write(` Mistakes: ${_}${Q}${K}
304
+ `),process.stdout.write(` Patterns: ${P}${z}${K}
305
+ `),process.stdout.write(` Mistakes: ${T}${Q}${K}
305
306
  `),process.stdout.write(` Successes: ${G}${$}${K}
306
307
  `),process.stdout.write(`
307
308
  `),process.stdout.write(`Location: ${i}
@@ -317,9 +318,9 @@ except ImportError:
317
318
  print('Error: memory.layers module not found')
318
319
  except Exception as e:
319
320
  print(f'Error: {e}')
320
- `.trim(),Z=await s(X,{cwd:y});return process.stdout.write(Z.stdout),0}let Q=c(E(),"memory","index.json");if(!b1(Q))return process.stdout.write(`No index found
321
+ `.trim(),Z=await s(X,{cwd:y});return process.stdout.write(Z.stdout),0}let Q=c(b(),"memory","index.json");if(!b1(Q))return process.stdout.write(`No index found
321
322
  `),0;let $=await s(`import json, sys; sys.stdout.write(json.dumps(json.load(open(${JSON.stringify(Q)})), indent=4) + "\\n")`);if($.exitCode!==0)return process.stdout.write(`No index found
322
- `),0;return process.stdout.write($.stdout),0}async function N1(z){switch(z[0]??"list"){case"list":case"ls":return S0();case"index":return D0(z[1]==="rebuild");default:{let $=c(y,"autonomy","loki"),X=await I([$,"memory",...z],{env:{LOKI_LEGACY_BASH:"1"},timeoutMs:3600000});return process.stdout.write(X.stdout),process.stderr.write(X.stderr),X.exitCode}}}var $0=`Loki Mode (TypeScript port, Phase 2 of bash->Bun migration)
323
+ `),0;return process.stdout.write($.stdout),0}async function N1(z){switch(z[0]??"list"){case"list":case"ls":return S0();case"index":return D0(z[1]==="rebuild");default:{let $=c(y,"autonomy","loki"),X=await w([$,"memory",...z],{env:{LOKI_LEGACY_BASH:"1"},timeoutMs:3600000});return process.stdout.write(X.stdout),process.stderr.write(X.stderr),X.exitCode}}}var $0=`Loki Mode (TypeScript port, Phase 2 of bash->Bun migration)
323
324
 
324
325
  Usage: loki <command> [args...]
325
326
 
@@ -338,4 +339,4 @@ Set LOKI_LEGACY_BASH=1 to force the bash CLI for every command.
338
339
  `;async function Q3(z){let Q=z[0],$=z.slice(1);switch(Q){case void 0:case"help":case"--help":case"-h":return process.stdout.write($0),0;case"version":case"--version":case"-v":return R1();case"provider":return E1($);case"memory":return N1($);case"status":{let{runStatus:X}=await Promise.resolve().then(() => (m1(),v1));return X($)}case"stats":{let{runStats:X}=await Promise.resolve().then(() => (d1(),l1));return X($)}case"doctor":{let{runDoctor:X}=await Promise.resolve().then(() => (z0(),e1));return X($)}default:return process.stderr.write(`Unknown command: ${Q}
339
340
  `),process.stderr.write($0),2}}process.on("SIGINT",()=>process.exit(130));process.on("SIGTERM",()=>process.exit(143));var X3=await Q3(Bun.argv.slice(2));process.exit(X3);
340
341
 
341
- //# debugId=F1D69DAF0013688764756E2164756E21
342
+ //# debugId=4E61A1C5EB88576364756E2164756E21
package/mcp/__init__.py CHANGED
@@ -57,4 +57,4 @@ try:
57
57
  except ImportError:
58
58
  __all__ = ['mcp']
59
59
 
60
- __version__ = '7.4.10'
60
+ __version__ = '7.4.12'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "loki-mode",
3
- "version": "7.4.10",
3
+ "version": "7.4.12",
4
4
  "description": "Loki Mode by Autonomi - Multi-agent autonomous startup system for Claude Code, Codex CLI, and Gemini CLI",
5
5
  "keywords": [
6
6
  "agent",
@@ -59,8 +59,7 @@
59
59
  "license": "BUSL-1.1",
60
60
  "author": "Lokesh",
61
61
  "bin": {
62
- "loki": "bin/loki",
63
- "loki-mode": "bin/loki-mode.js"
62
+ "loki": "bin/loki"
64
63
  },
65
64
  "files": [
66
65
  "SKILL.md",
@@ -102,7 +101,6 @@
102
101
  "web-app/deploy/"
103
102
  ],
104
103
  "scripts": {
105
- "postinstall": "node bin/postinstall.js",
106
104
  "prepack": "find . -type d -name __pycache__ -exec rm -rf {} + 2>/dev/null; find . -name '*.pyc' -delete 2>/dev/null; if command -v bun >/dev/null 2>&1; then (cd loki-ts && bun install --production && bun run build) || echo 'WARN: loki-ts build failed, using existing dist if present'; else echo 'WARN: bun not on PATH, skipping loki-ts build (using committed dist if present)'; fi; true",
107
105
  "prepublishOnly": "cd dashboard-ui && npm ci && npm run build:all",
108
106
  "test": "bash -n autonomy/run.sh && bash -n autonomy/loki && bash -n autonomy/completion-council.sh && bash -n autonomy/app-runner.sh && bash -n autonomy/prd-checklist.sh && bash -n autonomy/playwright-verify.sh && node --test tests/protocols/*.test.js && node --test tests/protocols/a2a/*.test.js && node --test tests/observability/*.test.js && node --test tests/policies/*.test.js && node --test tests/audit/*.test.js && node --test tests/integrations/*.test.js && node --test tests/integrations/jira/*.test.js && node --test tests/integrations/github/*.test.js && node --test tests/integrations/slack/*.test.js && bash tests/managed_memory/test_flag_matrix.sh && bash tests/managed_memory/test_sdk_isolation.sh && bash tests/managed_memory/test_kill_switch.sh && python3 -m unittest tests.managed_memory.test_shadow_write_mock tests.managed_memory.test_retrieve_mock && echo 'All checks passed'",