loki-mode 11.128.2 → 11.130.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.
Files changed (94) hide show
  1. package/README.md +1 -0
  2. package/SKILL.md +3 -3
  3. package/VERSION +1 -1
  4. package/autonomy/lib/help-core.sh +30 -42
  5. package/autonomy/lib/workspace.py +292 -19
  6. package/autonomy/lib/workspace_comment.py +40 -11
  7. package/autonomy/loki +129 -159
  8. package/autonomy/route.sh +3 -2
  9. package/autonomy/trigger-server.py +373 -32
  10. package/bin/loki +139 -18
  11. package/completions/_loki +11 -142
  12. package/completions/loki.bash +4 -2
  13. package/dashboard/__init__.py +1 -1
  14. package/docs/CLI-CORE-VERBS.md +61 -37
  15. package/docs/CLI-INVENTORY.md +152 -153
  16. package/docs/CLI-REFERENCE.md +20 -166
  17. package/docs/DEPLOYMENT.md +38 -3
  18. package/docs/INSTALLATION.md +7 -1
  19. package/docs/KNOWN-ISSUES.md +1 -1
  20. package/docs/PROOF-PASSPORT.md +21 -0
  21. package/docs/TESTING.md +1 -1
  22. package/docs/WORKSPACES.md +27 -0
  23. package/docs/cost-controls.md +74 -12
  24. package/docs/dev/architecture-reference.md +2 -2
  25. package/docs/environment-variables.md +7 -0
  26. package/docs/exit-codes.md +7 -0
  27. package/docs/merge-queue.md +44 -3
  28. package/docs/sentry-intake.md +1 -1
  29. package/docs/slack.md +1 -1
  30. package/docs/v10/GUIDE.md +33 -4
  31. package/loki-ts/dist/loki.js +1695 -1649
  32. package/mcp/__init__.py +1 -1
  33. package/memory/knowledge_graph.py +442 -56
  34. package/package.json +3 -3
  35. package/packages/control-plane/dist/server.js +2166 -1633
  36. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  37. package/schemas/loki-yaml.schema.json +1 -0
  38. package/web-app/dist/assets/{AdminPage-B-9a_urH.js → AdminPage-CNxvd-uy.js} +1 -1
  39. package/web-app/dist/assets/{Avatar-DWFQPBje.js → Avatar-DdLoiZKv.js} +1 -1
  40. package/web-app/dist/assets/{Badge-CuLYjGKc.js → Badge-DrdPaBOH.js} +1 -1
  41. package/web-app/dist/assets/{Button-Cws5TOeA.js → Button-BQ0UyQAk.js} +1 -1
  42. package/web-app/dist/assets/{CockpitPage-CCT1U0rq.js → CockpitPage-BLFBjBZW.js} +1 -1
  43. package/web-app/dist/assets/{ComparePage-ChcsGaeo.js → ComparePage-NHaUjY-d.js} +1 -1
  44. package/web-app/dist/assets/{ErrorBoundary-C5Mz6Y_d.js → ErrorBoundary-ClaDCylr.js} +1 -1
  45. package/web-app/dist/assets/{EvidenceReceiptPanel-jXRFyeG-.js → EvidenceReceiptPanel-BBW0IhXb.js} +1 -1
  46. package/web-app/dist/assets/{GitHubIssuesPanel-C_YjFJSB.js → GitHubIssuesPanel-B_dAtNuN.js} +1 -1
  47. package/web-app/dist/assets/{GitHubPRsPanel-B3bRY_lb.js → GitHubPRsPanel-Tv3JF9E0.js} +1 -1
  48. package/web-app/dist/assets/{HomePage-JLwBDYu8.js → HomePage-8fLInImK.js} +2 -2
  49. package/web-app/dist/assets/{LoginPage-BcDvWJr1.js → LoginPage-BGL-xm0l.js} +1 -1
  50. package/web-app/dist/assets/{MagicPage-Bj3qzygY.js → MagicPage-D7nHpNuT.js} +1 -1
  51. package/web-app/dist/assets/{MetricsPage-9k0NVtge.js → MetricsPage-BZh8ZOug.js} +1 -1
  52. package/web-app/dist/assets/{NotFoundPage-D81Z_SCM.js → NotFoundPage-DJ5YwC3-.js} +1 -1
  53. package/web-app/dist/assets/{ProjectPage-D9CkJI0B.js → ProjectPage-DYaGNgFt.js} +3 -3
  54. package/web-app/dist/assets/{ProjectsPage-vxSmYYzh.js → ProjectsPage-9GbGTW3g.js} +1 -1
  55. package/web-app/dist/assets/{SettingsPage-Cd2AS1Sg.js → SettingsPage-DdRI8LZ5.js} +1 -1
  56. package/web-app/dist/assets/{ShowcasePage-DOZCRLg5.js → ShowcasePage-ClEeMHAu.js} +1 -1
  57. package/web-app/dist/assets/{SystemSettingsPage-wl2UO5DF.js → SystemSettingsPage-rqj2byaP.js} +1 -1
  58. package/web-app/dist/assets/{TeamsPage-CA9FPLPm.js → TeamsPage-OaJ999dm.js} +1 -1
  59. package/web-app/dist/assets/{TemplatesPage-DLRTBM8i.js → TemplatesPage-CrqXt5pd.js} +1 -1
  60. package/web-app/dist/assets/{TerminalOutput-RqmPEs4o.js → TerminalOutput-DzOk3P-J.js} +1 -1
  61. package/web-app/dist/assets/{activity-CoyjHBZ4.js → activity-C3XPvqFU.js} +1 -1
  62. package/web-app/dist/assets/{bell-Dn2BCsQu.js → bell-BADR28Ic.js} +1 -1
  63. package/web-app/dist/assets/{bot-CNqPuD8h.js → bot-BOfl_osT.js} +1 -1
  64. package/web-app/dist/assets/{check-BWAwFpe2.js → check-DyeRhpqt.js} +1 -1
  65. package/web-app/dist/assets/{chevron-left-BgTjvxLB.js → chevron-left-DytHCita.js} +1 -1
  66. package/web-app/dist/assets/{circle-alert-CIYxFeDp.js → circle-alert-ej7tR0w9.js} +1 -1
  67. package/web-app/dist/assets/{clock-Dj6DRvL7.js → clock-CMmgiaJ3.js} +1 -1
  68. package/web-app/dist/assets/{cloud-DZBvW6-f.js → cloud-BmoOA5GK.js} +1 -1
  69. package/web-app/dist/assets/{code-xml-B0sAmzAO.js → code-xml-DjcElMOx.js} +1 -1
  70. package/web-app/dist/assets/{database-BkO44OAR.js → database-BxK55gai.js} +1 -1
  71. package/web-app/dist/assets/{dollar-sign-ChTZgVxB.js → dollar-sign-MxE9EOHB.js} +1 -1
  72. package/web-app/dist/assets/{file-code-corner-CQSIiG1T.js → file-code-corner-BYQ975Vf.js} +1 -1
  73. package/web-app/dist/assets/{file-plus-BAV2KC_M.js → file-plus-C0_fKf6I.js} +1 -1
  74. package/web-app/dist/assets/{globe-TUNeqVA9.js → globe-C7iJxA9K.js} +1 -1
  75. package/web-app/dist/assets/{hammer-CMD4wrup.js → hammer-CuVGrR3Z.js} +1 -1
  76. package/web-app/dist/assets/{index-B5lRV-ZJ.js → index-DvGbCL2t.js} +3 -3
  77. package/web-app/dist/assets/{layers-BxXkAn6j.js → layers-BWmxXnEV.js} +1 -1
  78. package/web-app/dist/assets/{loader-circle-CE46Yvcr.js → loader-circle-BrsqCmNy.js} +1 -1
  79. package/web-app/dist/assets/{lock-3uBPp5eV.js → lock-Dl3UsTMr.js} +1 -1
  80. package/web-app/dist/assets/{package-DjPZ3DLs.js → package-CCiRYdmb.js} +1 -1
  81. package/web-app/dist/assets/{plus-D8v6ZCYM.js → plus-d5BugnNw.js} +1 -1
  82. package/web-app/dist/assets/{refresh-cw-BSPJHBul.js → refresh-cw-DIkE6C0k.js} +1 -1
  83. package/web-app/dist/assets/{rotate-ccw-D0u6PH4j.js → rotate-ccw-DDhYD9MA.js} +1 -1
  84. package/web-app/dist/assets/{scroll-text-Dcwu9apa.js → scroll-text-jAoSqO2O.js} +1 -1
  85. package/web-app/dist/assets/{server-pd5YWyJw.js → server-D16MyCdB.js} +1 -1
  86. package/web-app/dist/assets/{shield-alert-C3TqM2Xm.js → shield-alert-C8W_Qcb5.js} +1 -1
  87. package/web-app/dist/assets/{thumbs-up-U1Wkm_Rg.js → thumbs-up-DdTbl2Vo.js} +1 -1
  88. package/web-app/dist/assets/{trash-2-BspH7NSu.js → trash-2-R-2Gvy6B.js} +1 -1
  89. package/web-app/dist/assets/{trending-down-DNg_ybr3.js → trending-down-Dk08-nlD.js} +1 -1
  90. package/web-app/dist/assets/{trending-up-CYzIu-lq.js → trending-up-DX8yONXb.js} +1 -1
  91. package/web-app/dist/assets/{upload-ChhyDeon.js → upload-6oDG_uiK.js} +1 -1
  92. package/web-app/dist/assets/{usePolling-ClMveR0q.js → usePolling-Co4817xB.js} +1 -1
  93. package/web-app/dist/assets/{user-BlFXAv0-.js → user-CjbWWW1W.js} +1 -1
  94. package/web-app/dist/index.html +1 -1
package/bin/loki CHANGED
@@ -101,8 +101,8 @@ fi
101
101
  # 1. LOKI_TS_ENTRY=... -- explicit override (custom builds, tests)
102
102
  # 2. BUN_FROM_SOURCE=1 -- prefer src/cli.ts (used by bench --compare-dist
103
103
  # and during Phase 3 development before dist ships)
104
- # 3. dist/loki.js exists -- production path (npm/Docker/Homebrew artifact)
105
- # 4. fall back to src -- in-repo development before first build
104
+ # 3. dist/loki.js exists -- production path (npm/Docker/Homebrew artifact; built at publish time)
105
+ # 4. src only (git clone) -- builds dist once when loki-ts/node_modules exists, else runs src
106
106
  #
107
107
  # v7.4.2 fix (BUG-1): BUN_FROM_SOURCE=1 used to hard-fail on npm/Docker/brew
108
108
  # installs because src/ is excluded by .npmignore. Now we warn once and fall
@@ -135,8 +135,8 @@ elif [ "${BUN_FROM_SOURCE:-0}" = "1" ] || [ "${BUN_FROM_SOURCE:-}" = "true" ]; t
135
135
  fi
136
136
  elif [ -f "$REPO_ROOT/loki-ts/dist/loki.js" ]; then
137
137
  BUN_CLI="$REPO_ROOT/loki-ts/dist/loki.js"
138
- # Stale-dist freshness guard. dist/loki.js is gitignored (loki-ts/.gitignore)
139
- # and rebuilt by package.json's prepack and the release Docker build, so on
138
+ # Stale-dist freshness guard. dist/loki.js is untracked (gitignored in loki-ts/.gitignore)
139
+ # and built by package.json's prepack, the release Docker build and the brew asset, so on
140
140
  # released channels (npm/Docker/brew) src/cli.ts is absent and this guard is
141
141
  # a no-op -- dist is always current there. On a DEV machine / worktree the
142
142
  # gitignored dist can predate the current dispatcher: e.g. a new shim->Bun
@@ -153,7 +153,22 @@ elif [ -f "$REPO_ROOT/loki-ts/dist/loki.js" ]; then
153
153
  BUN_CLI="$REPO_ROOT/loki-ts/src/cli.ts"
154
154
  fi
155
155
  elif [ -f "$REPO_ROOT/loki-ts/src/cli.ts" ]; then
156
+ # Git clone: loki-ts/dist is built, never committed. Build it once (autonomy/run.sh and the
157
+ # control plane call dist/loki.js directly), then run it. The build is atomic, so a failure
158
+ # leaves no dist and the run falls back to src as it always did.
156
159
  BUN_CLI="$REPO_ROOT/loki-ts/src/cli.ts"
160
+ if command -v bun >/dev/null 2>&1; then
161
+ if [ -d "$REPO_ROOT/loki-ts/node_modules" ]; then
162
+ echo "loki: building loki-ts/dist (first run from a git clone, a few seconds)" >&2
163
+ if (cd "$REPO_ROOT/loki-ts" && bun run build >/dev/null 2>&1) && [ -f "$REPO_ROOT/loki-ts/dist/loki.js" ]; then
164
+ BUN_CLI="$REPO_ROOT/loki-ts/dist/loki.js"
165
+ else
166
+ echo "loki: build failed; running from source. To see why: cd loki-ts && bun run build" >&2
167
+ fi
168
+ else
169
+ echo "loki: loki-ts is not built. Run: cd loki-ts && bun install && bun run build" >&2
170
+ fi
171
+ fi
157
172
  else
158
173
  # Neither dist nor src available; fall through to bash silently.
159
174
  _loki_bash_or_refuse "$@"
@@ -496,6 +511,44 @@ _loki_bun() {
496
511
  done
497
512
  return 0
498
513
  }
514
+ # FR02: --detach/-d on a Loki 10 run. Re-launches the same engine10 argv in its own session, so closing the terminal
515
+ # sends it no SIGHUP (a foreground run stops on SIGHUP by design, runner/worker_proc.ts). stdin /dev/null, output to a log.
516
+ # Same launcher ladder as autonomy/loki _loki_new_session_exec and run.sh (legacy copies bin/loki cannot source).
517
+ _loki_e10_detach() { # $1 = bun, rest = engine10 args with --detach/-d already removed
518
+ local lb="$1" top ldir log pid rc=0 settle i=0
519
+ shift
520
+ top="$(git rev-parse --show-toplevel 2>/dev/null || pwd -P)"
521
+ ldir="${LOKI_DIR:-$top/.loki}/logs"
522
+ mkdir -p "$ldir" || { echo "loki: --detach could not create $ldir" >&2; exit 1; }
523
+ log="$ldir/detached-$(date -u +%Y%m%dT%H%M%SZ)-$$.log"
524
+ export LOKI_DETACHED=1
525
+ if command -v setsid >/dev/null 2>&1; then
526
+ nohup setsid "$lb" "${_LOKI_BUN_SAFE[@]}" "$BUN_CLI" engine10 "$@" >"$log" 2>&1 </dev/null &
527
+ elif command -v perl >/dev/null 2>&1; then
528
+ nohup perl -e 'use POSIX qw(setsid); setsid(); exec @ARGV or exit 127;' "$lb" "${_LOKI_BUN_SAFE[@]}" "$BUN_CLI" engine10 "$@" >"$log" 2>&1 </dev/null &
529
+ elif command -v python3 >/dev/null 2>&1; then
530
+ nohup python3 -c 'import os,sys; os.setsid(); os.execvp(sys.argv[1], sys.argv[1:])' "$lb" "${_LOKI_BUN_SAFE[@]}" "$BUN_CLI" engine10 "$@" >"$log" 2>&1 </dev/null &
531
+ else
532
+ nohup "$lb" "${_LOKI_BUN_SAFE[@]}" "$BUN_CLI" engine10 "$@" >"$log" 2>&1 </dev/null &
533
+ fi
534
+ pid=$!
535
+ if [ "${LOKI_DETACH_CAFFEINATE:-1}" != "0" ] && command -v caffeinate >/dev/null 2>&1; then
536
+ nohup caffeinate -i -w "$pid" >/dev/null 2>&1 </dev/null &
537
+ fi
538
+ settle="${LOKI_DETACH_SETTLE_S:-3}"; case "$settle" in ''|*[!0-9]*) settle=3 ;; esac
539
+ while [ "$i" -lt $((settle * 10)) ] && kill -0 "$pid" 2>/dev/null; do sleep 0.1; i=$((i + 1)); done
540
+ if ! kill -0 "$pid" 2>/dev/null; then
541
+ wait "$pid" || rc=$?
542
+ tail -n 20 "$log" >&2
543
+ echo "loki: the run ended before it detached (exit $rc); full log: $log" >&2
544
+ exit "$rc"
545
+ fi
546
+ printf 'Detached: the Loki 10 run continues in the background (pid %s); closing this terminal does not stop it.\n' "$pid"
547
+ printf ' Log: %s\n Follow: loki status --follow\n Cancel: loki cancel\n' "$log"
548
+ printf ' Result: the PR (or local branch) and receipt land as on a foreground run\n'
549
+ [ -n "${LOKI_SLACK_WEBHOOK_URL:-}${LOKI_WEBHOOK_URL:-}" ] || printf ' Notify: set LOKI_SLACK_WEBHOOK_URL before starting to get the outcome in Slack\n'
550
+ exit 0
551
+ }
499
552
  # No working bun for an engine10 command: say why and how to fix it, exit 2. A Homebrew install of loki-mode
500
553
  # (its own keg, not an npm install under Homebrew's node) is told the brew formula.
501
554
  _loki_no_bun_exit() {
@@ -556,6 +609,49 @@ if [ "${1:-}" = "modernize" ]; then
556
609
  unset _loki_mod_a
557
610
  fi
558
611
 
612
+ # Removed commands (registry class REMOVED) exit 2 with a migration line before any engine, provider
613
+ # check or model call. tests/min/cli-entrypoints.sh compares this table to the registry.
614
+ _loki_removed_suffix() {
615
+ case "$1" in
616
+ init) printf '%s' 'Use: loki "<idea>" in an empty folder' ;;
617
+ template) printf '%s' 'Use: loki start "<one-line goal>"' ;;
618
+ ship) printf '%s' 'Use: loki deploy' ;;
619
+ import) printf '%s' 'Use: loki start <ref or file>' ;;
620
+ issue) printf '%s' 'Use: loki start owner/repo#N' ;;
621
+ assets) printf '%s' 'Use: loki chat' ;;
622
+ try) printf '%s' 'Use: loki start <repo url> --no-pr from a fresh clone' ;;
623
+ remote) printf '%s' 'Use: loki status' ;;
624
+ rc) printf '%s' 'Use: loki status' ;;
625
+ code) printf '%s' 'Use: loki chat' ;;
626
+ context) printf '%s' 'Use: loki chat' ;;
627
+ ctx) printf '%s' 'Use: loki chat' ;;
628
+ voice) printf '%s' 'Use: loki start' ;;
629
+ secure) printf '%s' 'Use: loki doctor' ;;
630
+ council) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
631
+ compound) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
632
+ cluster) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
633
+ optimize) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
634
+ ultracode) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
635
+ monitor) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
636
+ watch) printf '%s' 'Rerun with: loki start <PRD>' ;;
637
+ watchdog) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
638
+ cleanup) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
639
+ reset) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
640
+ dogfood) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
641
+ outcomes) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
642
+ worktree) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
643
+ wt) printf '%s' 'It drove the removed legacy loop; use: loki start "<goal>"' ;;
644
+ trust-metrics) printf '%s' 'Use: loki status --json' ;;
645
+ open) printf '%s' 'Use: loki control serve' ;;
646
+ *) return 1 ;;
647
+ esac
648
+ }
649
+ if _loki_rm_suffix="$(_loki_removed_suffix "${1:-}")"; then
650
+ echo "loki: 'loki $1' was removed in Loki Mode 11.130.0. ${_loki_rm_suffix}." >&2
651
+ exit 2
652
+ fi
653
+ unset _loki_rm_suffix
654
+
559
655
  # `loki legacy` was removed in 11.0.0 (LEGACY-ZERO W1-01): there is one engine.
560
656
  case "${1:-}" in
561
657
  legacy)
@@ -752,6 +848,8 @@ case "v10" in
752
848
  ""|-*) _e10=0 ;;
753
849
  # http*://*/issues/* also covers GitLab's /-/issues/ URLs.
754
850
  */*\#[0-9]*|http*://*/issues/*|http*://*/browse/*|jira:*|linear:*|https://linear.app/*/issue/*) _e10=1 ;;
851
+ # FR01: a one-word "#N" is an issue of this checkout (engine10 resolves it against origin)
852
+ \#[0-9]*) case "${1#\#}" in *[!0-9]*) ;; *) _e10=1 ;; esac ;;
755
853
  *" "*) _e10=1 ;;
756
854
  # ponytail: a one-word argument stays on the legacy CLI. The telemetry
757
855
  # allowlist is not a command registry (estimate, intent, outcomes are
@@ -797,6 +895,24 @@ case "v10" in
797
895
  unset _e10_v
798
896
  ;;
799
897
  esac
898
+ # FR02: strip --detach/-d (task words after a bare -- are never flags) and detach the run.
899
+ case "${1:-}" in
900
+ keys|export|status|verify|dashboard|plan) ;;
901
+ *)
902
+ _e10_det=0; _e10_rest=(); _e10_dd=0
903
+ for _e10_a in ${_e10_args[@]+"${_e10_args[@]}"}; do
904
+ if [ "$_e10_dd" = "0" ]; then
905
+ case "$_e10_a" in
906
+ --) _e10_dd=1 ;;
907
+ --detach|-d) _e10_det=1; continue ;;
908
+ esac
909
+ fi
910
+ _e10_rest+=("$_e10_a")
911
+ done
912
+ if [ "$_e10_det" = "1" ]; then _loki_e10_detach "$_lb" ${_e10_rest[@]+"${_e10_rest[@]}"}; fi
913
+ unset _e10_det _e10_rest _e10_dd _e10_a
914
+ ;;
915
+ esac
800
916
  exec "$_lb" "${_LOKI_BUN_SAFE[@]}" "$BUN_CLI" engine10 ${_e10_args[@]+"${_e10_args[@]}"}
801
917
  fi
802
918
  unset _e10 _e10_args _e10_hard
@@ -886,6 +1002,7 @@ fi
886
1002
  # Bun-routed `report kpis` is not invisible to usage analytics (the v7.8.2 parity
887
1003
  # the case-arm comment documents). Backgrounded, FD-detached, opt-out honored by
888
1004
  # loki_telemetry itself.
1005
+ _bun_two_token=0
889
1006
  if [ "${1:-}" = "report" ]; then
890
1007
  _report_first_sub=""
891
1008
  for _report_arg in "${@:2}"; do
@@ -894,22 +1011,26 @@ if [ "${1:-}" = "report" ]; then
894
1011
  *) _report_first_sub="$_report_arg"; break ;;
895
1012
  esac
896
1013
  done
897
- if [ "$_report_first_sub" = "kpis" ]; then
898
- if command -v curl &>/dev/null && [ -f "$REPO_ROOT/autonomy/telemetry.sh" ]; then
899
- # Disclose once before egress if collection is genuinely enabled
900
- # (covers the case where a cli_command is the first ENABLED egress,
901
- # e.g. first run was CI/auto-off so .loki-first-run is already set).
902
- # AC3: foreground gate evaluation (no FD detach) so the exported
903
- # LOKI_TTY_INTERACTIVE signal / real TTY drives the verdict.
904
- if ( SCRIPT_DIR="$REPO_ROOT/autonomy"; source "$SCRIPT_DIR/telemetry.sh" 2>/dev/null \
905
- && declare -f _loki_telemetry_enabled >/dev/null 2>&1 && _loki_telemetry_enabled ); then
906
- _loki_disclose_telemetry_once
907
- fi
908
- ( SCRIPT_DIR="$REPO_ROOT/autonomy"; source "$SCRIPT_DIR/telemetry.sh" 2>/dev/null && loki_telemetry "cli_command" "command=$(_loki_known_command "${1:-}")" 2>/dev/null ) >/dev/null 2>&1 </dev/null &
909
- disown 2>/dev/null || true
1014
+ [ "$_report_first_sub" = "kpis" ] && _bun_two_token=1
1015
+ fi
1016
+ # `review queue` (open Loki PRs ranked by risk) is Bun-only; `review` stays bash for every other form.
1017
+ # Exactly `review queue` as the first two tokens, so a path or flag value named queue is never hijacked.
1018
+ [ "${1:-}" = "review" ] && [ "${2:-}" = "queue" ] && _bun_two_token=1
1019
+ if [ "$_bun_two_token" = "1" ]; then
1020
+ if command -v curl &>/dev/null && [ -f "$REPO_ROOT/autonomy/telemetry.sh" ]; then
1021
+ # Disclose once before egress if collection is genuinely enabled
1022
+ # (covers the case where a cli_command is the first ENABLED egress,
1023
+ # e.g. first run was CI/auto-off so .loki-first-run is already set).
1024
+ # AC3: foreground gate evaluation (no FD detach) so the exported
1025
+ # LOKI_TTY_INTERACTIVE signal / real TTY drives the verdict.
1026
+ if ( SCRIPT_DIR="$REPO_ROOT/autonomy"; source "$SCRIPT_DIR/telemetry.sh" 2>/dev/null \
1027
+ && declare -f _loki_telemetry_enabled >/dev/null 2>&1 && _loki_telemetry_enabled ); then
1028
+ _loki_disclose_telemetry_once
910
1029
  fi
911
- exec bun "${_LOKI_BUN_SAFE[@]}" "$BUN_CLI" "$@"
1030
+ ( SCRIPT_DIR="$REPO_ROOT/autonomy"; source "$SCRIPT_DIR/telemetry.sh" 2>/dev/null && loki_telemetry "cli_command" "command=$(_loki_known_command "${1:-}")" 2>/dev/null ) >/dev/null 2>&1 </dev/null &
1031
+ disown 2>/dev/null || true
912
1032
  fi
1033
+ exec bun "${_LOKI_BUN_SAFE[@]}" "$BUN_CLI" "$@"
913
1034
  fi
914
1035
 
915
1036
  # Commands ported in Phase 2 -- route to Bun. Everything else goes to bash.
package/completions/_loki CHANGED
@@ -286,148 +286,17 @@ function _loki {
286
286
  function _loki_commands {
287
287
  local -a commands
288
288
  commands=(
289
- 'start:Start Loki Mode'
290
- 'quick:Quick single-task mode'
291
- 'quickstart:Guided first build from your idea'
292
- 'monitor:Monitor Docker Compose services with auto-fix'
293
- 'demo:Interactive 60-second demo'
294
- 'tour:Offline sample receipt replay (no key, no spend)'
295
- 'wow:Tiny real task in a temp repo, or the offline sample'
296
- 'try:Try Loki on a public repo in a temp clone, keep only the receipt'
297
- 'factory:loki start with the autonomy policy printed'
298
- 'welcome:Friendly first-run opener (what Loki is, next steps)'
299
- 'init:Interactive PRD builder'
300
- 'stop:Stop execution'
301
- 'pause:Pause execution'
302
- 'resume:Resume execution'
303
- 'cancel:Cancel the active Loki 10 run'
304
- 'steer:Steer a running build with a note (needs LOKI_PROMPT_INJECTION=1)'
305
- 'status:Show status'
306
- 'next:Run the right next step for the current build'
307
- 'ship:Finish the build (gates + PR advice) in one command'
308
- 'why:Explain why the last run did what it did'
309
- 'dashboard:Dashboard commands'
310
- 'web:Start the web app surface'
311
- 'logs:View session logs'
312
- 'serve:Start API server'
313
- 'api:API server commands'
314
- 'sandbox:Docker sandbox commands'
315
- 'docker:Run Loki in a Docker container'
316
- 'notify:Notification commands'
317
- 'import:Import GitHub issues'
318
- 'issue:GitHub issue commands'
319
- 'github:GitHub integration commands'
320
- 'config:Config commands'
321
- 'provider:Provider commands'
322
- 'reset:Reset session state'
323
- 'memory:Memory commands'
324
- 'compound:Knowledge compounding commands'
325
- 'checkpoint:Snapshot and restore session state'
326
- 'cp:Snapshot and restore session state (alias of checkpoint)'
327
- 'council:Completion council commands'
328
- 'dogfood:Self-development statistics'
329
- 'projects:Project registry commands'
330
- 'enterprise:Enterprise feature commands'
331
- 'secrets:Secrets and API key management'
332
- 'cockpit:Live cockpit view of a running build'
333
- 'secure:Secure-by-default gate (findings and waivers)'
334
- 'own:Finish-and-own ownership handoff'
335
- 'backup:Back up dashboard state (verified archive)'
336
- 'restore:Restore dashboard state from a verified backup archive'
337
- 'telemetry:OpenTelemetry management'
338
- 'agent:Agent type dispatch'
339
- 'doctor:Check system prerequisites'
340
- 'watchdog:Watchdog process supervision'
341
- 'docs:Documentation commands'
342
- 'onboard:Analyze repo and generate CLAUDE.md'
343
- 'metrics:Session productivity report'
344
- 'share:Share session report as GitHub Gist'
345
- 'proof:Inspect/share proof-of-run artifacts'
346
- 'outcomes:What happened to the work AFTER the receipt (reverted/reworked/survived)'
347
- 'preview:Preview the locally-running app'
348
- 'deploy:Deploy the built product (CI/CD-aware)'
349
- 'context:Context window management'
350
- 'ctx:Context window management (alias)'
351
- 'code:Codebase intelligence'
352
- 'web:Start the web dashboard'
353
- 'plan:Preview the build plan for a spec'
354
- 'report:Reporting commands (cost, kpis, share)'
355
- 'cost:Show cost of recent runs (--detail for cache + trend)'
356
- 'estimate:Estimate run cost from run history (--json, --model, --provider)'
357
- 'kpis:Key performance indicators'
358
- 'stats:Session statistics'
359
- 'preview:Open the running app preview'
360
- 'deploy:Advisory deploy command (print-only)'
361
- 'docker:Run Loki in a Docker container'
362
- 'mcp:MCP server commands'
363
- 'merge:Green-only serial merge queue'
364
- 'acp:Agent Client Protocol agent over stdio'
365
- 'magic:Spec-driven component generation'
366
- 'assets:Export/import shareable team assets'
367
- 'spec:Living spec drift detection'
368
- 'intent:Does the spec still say what was actually wanted'
369
- 'verify:Deterministic PR verification'
370
- 'keys:Export the receipt-signing public key'
371
- 'grill:Interrogate a spec before building'
372
- 'trust:Visible trust trajectory'
373
- 'trust-metrics:Trust metrics report'
374
- 'why:Explain the last build outcome'
375
- 'heal:Legacy system healing'
376
- 'modernize:Modernize a legacy system'
377
- 'migrate:Migration commands'
378
- 'analyze:Analyze a codebase'
379
- 'compliance:Compliance reporting'
380
- 'crash:Crash report management'
381
- 'otel:OpenTelemetry management'
382
- 'wiki:Wiki commands'
383
- 'answer:Answer a BLOCKED run; it continues under the same run id'
384
- 'verify-pr:Verify a PR against its linked issue in a sandbox'
385
- 'queue:Overnight issue queue with a morning digest'
386
- 'issues:Run every open issue in a repo and open PRs'
387
- 'runs:List runs across the projects registered with loki projects add'
388
- 'undo:Show what undoing a run would do (read-only plan; --dry-run adds the diffstat; --list shows recent runs)'
389
- 'chat:Interactive chat session (run, attach)'
390
- 'route:Print the engine, provider and model route without running'
391
- 'edit:Make a scoped edit to files'
392
- 'setup:First-run wizard for tools, provider, model route and spend cap'
393
- 'models:List models and routes (--local for local models)'
394
- 'agents:List, scaffold, show and export agent definitions'
395
- 'diff:Show what the last run changed'
396
- 'control:Control plane (preview, LOKI_CONTROL=1)'
397
- 'workspace:Multi-project workspaces (preview, LOKI_WORKSPACES=1)'
398
- 'backlog:Run every matching open issue, N in parallel'
399
- 'explain:Explain Loki concepts'
400
- 'optimize:Optimization commands'
401
- 'review:Code review commands'
402
- 'export:Export session data'
403
- 'test:Run tests'
404
- 'ci:CI helpers'
405
- 'watch:Watch mode'
406
- 'audit:Audit commands'
407
- 'syslog:System log commands'
408
- 'cluster:Cluster commands'
409
- 'failover:Failover commands'
410
- 'remote:Remote execution commands'
411
- 'worktree:Git worktree commands'
412
- 'wt:Git worktree commands (alias)'
413
- 'trigger:Trigger commands'
414
- 'cleanup:Clean up Loki state'
415
- 'rollback:Roll back a change'
416
- 'update:Update Loki Mode'
417
- 'self-update:Update Loki Mode'
418
- 'setup-skill:Set up the Claude Code skill'
419
- 'quickstart:Quickstart guide'
420
- 'sentrux:Sentrux integration'
421
- 'state:Inspect run state'
422
- 'template:PRD template commands'
423
- 'ultracode:Ultra code review'
424
- 'voice:Voice commands'
425
- 'bench:Run benchmarks'
426
- 'open:Open a project resource'
427
- 'rc:Release candidate commands'
428
- 'version:Show version (--json for machine-readable)'
429
- 'completions:Output shell completions'
430
- 'help:Show help'
289
+ 'start:Build from a goal, a PRD file or an issue'
290
+ 'chat:Talk it through; --attach joins the running build'
291
+ 'status:What is running, how it ended, what to do next'
292
+ 'verify:Deterministic verification with CI exit codes'
293
+ 'receipt:The signed proof of a run'
294
+ 'stop:Stop the running build'
295
+ 'undo:Plan or apply an undo of a run'
296
+ 'deploy:Deploy a VERIFIED run'
297
+ 'doctor:Check and repair your setup'
298
+ 'config:Show or change settings'
299
+ 'control:The local UI (Control Plane)'
431
300
  )
432
301
  _describe -t commands 'loki command' commands
433
302
  }
@@ -4,8 +4,10 @@ _loki_completion() {
4
4
  local cur prev words cword
5
5
  _init_completion || return
6
6
 
7
- # Main subcommands (must match autonomy/loki main case statement)
8
- local main_commands="start backlog quick monitor demo tour wow try factory welcome init stop pause resume cancel steer status next ship dashboard web serve api sandbox notify import github issue intent config provider reset memory compound checkpoint council dogfood projects enterprise secrets cockpit secure own handoff doctor watchdog audit metrics syslog onboard share proof receipt outcomes explain plan report cost estimate kpis stats test ci watch telemetry agent context ctx code run export review optimize heal modernize migrate cluster worktree wt trigger failover remote deploy docker mcp magic assets analyze compliance crash control workspace open otel preview quickstart rc rollback merge self-update sentrux setup-skill spec state template trust trust-metrics ultracode update verify voice why wiki bench cleanup logs grill docs cp version completions help keys answer queue issues undo runs acp verify-pr chat route edit setup models agents diff backup restore"
7
+ # Main subcommands: exactly the 11 KEEP commands of loki-ts/src/cli/registry.ts
8
+ # (tests/min/cli-entrypoints.sh compares them). Hidden commands still dispatch and
9
+ # keep their own flag completion in the case blocks below.
10
+ local main_commands="start chat status verify receipt stop undo deploy doctor config control"
9
11
 
10
12
  # 1. If we are on the first argument (subcommand)
11
13
  if [[ $cword -eq 1 ]]; then
@@ -7,6 +7,6 @@ Modules:
7
7
  control: Session control helpers (status, atomic writes, origin check)
8
8
  """
9
9
 
10
- __version__ = "11.128.2"
10
+ __version__ = "11.130.0"
11
11
 
12
12
  __all__ = ["__version__"]
@@ -1,43 +1,53 @@
1
1
  # Core verbs (CLI reference)
2
2
 
3
- The commands most people use, with their main flags. The complete generated
3
+ The 11 commands in `loki --help`, with their main flags. The complete generated
4
4
  command table is `docs/CLI-REFERENCE.md` (do not edit that file by hand).
5
- `loki help` prints the grouped summary; `loki help all` prints every command;
5
+ `loki help` prints the 11; `loki help all` adds the hidden and renamed commands;
6
6
  `loki help <topic>` prints a topic (start, models, providers, agents, verify,
7
- exit-codes, config); `loki help <command>` runs `<command> --help`. Scripts that
8
- parse the old default `loki help` output must switch to `loki help all`.
7
+ exit-codes, config); `loki help <command>` runs `<command> --help`. Every other command keeps working
8
+ unchanged; it is just not shown on the front page.
9
9
 
10
10
  `loki start` is the primary path. Everything else is a shortcut, a check, or an
11
11
  alternative surface for the same engine. Claude Code is the default Tier-1
12
12
  provider; other providers and model routes are additions selected with
13
13
  `--provider` or `LOKI_MODEL_ROUTE`.
14
14
 
15
- ## Start
15
+ ## The 11 commands
16
16
 
17
17
  | Command | What it does |
18
18
  | --- | --- |
19
- | `loki start [SPEC]` | The primary path. Build from a PRD file, an issue (`owner/repo#N`, issue URL, `PROJ-1`), a quoted task or a one-word brief. Alias: `run`. Shorthand: `loki "<task>"`, `loki owner/repo#N` |
20
- | `loki edit "<change>"` | One targeted change to the current repo in one pass. No PRD, plan, council, PR or branch switch |
21
- | `loki quick "<task>"` | One small task with a verify loop, no PR |
22
- | `loki chat` | Interactive alternative to `loki start` (Plan and Build modes, slash commands) |
19
+ | `loki "<goal>"` | Build it: a goal, a PRD file or an issue (`owner/repo#N`). Shorthand for `loki start` |
20
+ | `loki start [SPEC]` | The primary path. Build from a PRD file, an issue (`owner/repo#N`, issue URL, `PROJ-1`), a quoted task or a one-word brief. Alias: `run` |
21
+ | `loki chat [--attach]` | Interactive alternative to `loki start`; `--attach` joins the running build |
22
+ | `loki status [--json]` | What is running and where it stands |
23
+ | `loki verify [base] [--fast] [--json] [--pubkey FILE]` | Deterministic verification with CI-gate exit codes |
24
+ | `loki receipt [run]` | The proof-of-run receipt (`list`, `show`, `open`, `share`, `badge`, `md`, `bundle`). `proof` is the old name and still works |
25
+ | `loki stop` | Stop the running build |
26
+ | `loki undo <run> [--plan]` | Plan or apply an undo of a run |
27
+ | `loki deploy` | Deploy a VERIFIED run |
28
+ | `loki doctor [--fix] [--json]` | Check prerequisites, providers and login. `--fix` creates state dirs and a default config and prints exact commands for the rest; never runs sudo |
29
+ | `loki config list\|get\|set\|path\|show\|validate` | Settings; `config list --json` for machines |
30
+ | `loki control serve` | The local UI (Control Plane): `serve`, `stop`, `status`, `backfill`, `prune` |
23
31
 
24
- `start` flags: `--no-pr`, `--deep`, `--provider NAME`, `--max-cost USD`
32
+ `start` flags: `--no-pr`, `--deep`, `--provider NAME`, `--model ID`, `--max-cost USD`
25
33
  (aliases `--budget`, `--budget-limit`), `--session-model TIER`, `-v` (verbose),
26
- `--quiet`, `--json`, `--engine legacy|engine10`, `--explain-route`. Flags that
34
+ `--quiet`, `--json`, `--detach` (`-d`), `--engine legacy|engine10`, `--explain-route`. Flags that
27
35
  only the previous loop honors (`--simple`, `--complex`, `--parallel`,
28
36
  `--isolation`, `--sandbox`, `--max-iterations`, `--compliance`, ...) send that
29
37
  one call to the previous loop with a one-line notice.
30
38
 
39
+ ### Run in the background
40
+
41
+ `loki start "<task>" --detach` (also `loki "<task>" --detach`, `loki owner/repo#N --detach`, `loki quick ... --detach`) starts the run in its own session and returns at once, so closing the terminal or logging out does not stop it. It prints the pid and the log path (`.loki/logs/detached-*.log`); follow it with `loki status --follow`, stop it with `loki cancel`. When it finishes it reports as a foreground run does: a VERIFIED run opens a ready PR, a PARTIAL run a draft PR, an issue run posts its status comment, and Slack gets the PR, blocked, stuck and finished messages when `LOKI_SLACK_WEBHOOK_URL` is set (see `docs/slack.md`). Exit code: 0 once detached; if the engine refuses or fails within the first `LOKI_DETACH_SETTLE_S` seconds (default 3) the launcher prints the log tail and exits with the engine's own code, and a refusal that comes later lands only in the log (also check `loki status`). Two runs in one checkout are refused by the run lock. The detached run has no terminal, so prompts and the cost forecast behave as in CI. On macOS the run holds a `caffeinate -i` assertion, which blocks idle sleep only: a closed lid on battery still sleeps the Mac. For a run that must survive that, use a machine that stays on, such as the issue-to-pr workflow on a `runs-on: self-hosted` runner (`docs/examples/loki-issue-to-pr.yml.example`, not changed or tested by this feature). Not yet supported with `--spec` or `--attempts`.
42
+
31
43
  Spend cap: `--max-cost`, else `budgets.per_run` in `loki.yaml`, else $100 when
32
44
  `ANTHROPIC_API_KEY` or `OPENAI_API_KEY` is set, else no dollar cap
33
45
  (subscription). Model routes: `LOKI_MODEL_ROUTE=ollama/qwen3-coder loki start prd.md`.
34
46
 
35
- ### loki edit
36
-
37
- `loki edit [paths...] "<change>"` with `--verify` (fast verifier), `--receipt`
38
- (unsigned receipt in `.loki/edit-receipts/`), `--commit` (only touched files, by
39
- name; skipped when verify failed) and `--dry-run` (plan only). `LOKI_EDIT_MODEL`
40
- overrides the model. Claude provider only for now.
47
+ Every run ends with one unified summary on both engines: `Result:`, `Files:`,
48
+ `Cost:` (marked `(estimated)` or `not measured`), `Elapsed:`, `Receipt:` and a
49
+ `next:` line. `--quiet` prints only that block; `--json` adds a `summary`
50
+ object; `NO_COLOR=1` disables color.
41
51
 
42
52
  ### loki chat
43
53
 
@@ -50,31 +60,45 @@ running or the last `loki start` session (`/status`, `/steer`, `/diff`,
50
60
  `/verify`, `/receipt`, `/stop`). `loki chat --tui` launches the Claude Code TUI
51
61
  with Loki context. Bare `loki` does not open chat.
52
62
 
53
- ## Check
63
+ ### loki edit (renamed, still works)
54
64
 
55
- | Command | What it does |
56
- | --- | --- |
57
- | `loki status [--json]` | Current run status |
58
- | `loki verify [--fast] [--json] [--pubkey FILE]` | Deterministic verification with CI-gate exit codes |
59
- | `loki receipt` (alias of `proof`) | Inspect the proof-of-run receipt |
60
- | `loki diff` / `loki undo <run> [--plan]` | Show what a run changed; plan or apply an undo |
61
- | `loki route [start\|quick] <args> [--json]` | Print the engine, provider, model, input type and reason without running |
65
+ `loki edit [paths...] "<change>"` with `--verify` (fast verifier), `--receipt`
66
+ (unsigned receipt in `.loki/edit-receipts/`), `--commit` (only touched files, by
67
+ name; skipped when verify failed) and `--dry-run` (plan only). `LOKI_EDIT_MODEL`
68
+ overrides the model. Claude provider only for now.
62
69
 
63
- Every run ends with one unified summary on both engines: `Result:`, `Files:`,
64
- `Cost:` (marked `(estimated)` or `not measured`), `Elapsed:`, `Receipt:` and a
65
- `next:` line. `--quiet` prints only that block; `--json` adds a `summary`
66
- object; `NO_COLOR=1` disables color.
70
+ ## Commands that moved
67
71
 
68
- ## Configure
72
+ Nothing was removed in this release: every command below still runs exactly as
73
+ before and is only hidden from `loki --help` and completions. The Replacement
74
+ column is where its behavior is going; a few targets arrive in later releases
75
+ (for example `loki start --answer` and `loki receipt key`), and until each one
76
+ lands the old name is the way to do it. `loki help all` prints this list and the
77
+ hidden commands for machine consumers, CI and operators (`review`, `merge`,
78
+ `workspace`, `trigger`, `memory`, `report`, `mcp`, `acp`, ...). The full table,
79
+ with the planned removal of commands that have no dependents, is the generated
80
+ `docs/CLI-INVENTORY.md`.
69
81
 
70
- | Command | What it does |
82
+ | Old command | Replacement |
71
83
  | --- | --- |
72
- | `loki setup [--yes] [--check]` | First-run wizard: tools, Claude login, provider, model route, spend cap. Flags: `--provider`, `--model`, `--budget USD`, `--global` |
73
- | `loki doctor [--fix] [--json]` | Check prerequisites, providers and login. `--fix` creates state dirs and a default config and prints exact commands for the rest; never runs sudo |
74
- | `loki config list\|get\|set\|path\|show\|validate` | Settings; `config list --json` for machines |
75
- | `loki models [--local] [--json]` | Model routes (openrouter, ollama, lmstudio, llamacpp, vllm, custom); `--local` probes local runtimes and prints ready-to-paste values |
76
- | `loki agents list\|new\|show\|export --claude` | Custom child agents in `.loki/agents/*.md` (project) or `~/.config/loki/agents/` (user). `loki agent` (singular) is the unchanged built-in agent-type command |
77
- | `loki provider list\|set NAME` | Providers and install status |
84
+ | `quick "<task>"`, `edit "<change>"` | `loki "<task>" --no-pr` |
85
+ | `run`, `resume` | `loki start` |
86
+ | `answer` | `loki start --answer "<text>"` |
87
+ | `steer` | `loki chat --attach` |
88
+ | `issues`, `queue`, `backlog` | `loki start owner/repo ...` |
89
+ | `plan`, `estimate` | `loki start <PRD> --dry-run` |
90
+ | `setup` | `loki doctor --fix` |
91
+ | `models`, `provider` | `loki config` |
92
+ | `proof`, `keys` | `loki receipt` |
93
+ | `verify-pr` | `loki verify <PR url>` |
94
+ | `rollback` | `loki undo <run>` |
95
+ | `dashboard` | `loki control serve` |
96
+ | `why`, `trust` | `loki status` |
97
+ | `quickstart`, `tour`, `demo`, `wow`, `factory` | `loki start` (first run) |
98
+ | `docs` | `loki help` |
99
+
100
+ `loki route [start|quick] <args> [--json]` still prints the engine, provider,
101
+ model, input type and reason without running anything.
78
102
 
79
103
  ## --json
80
104