loki-mode 7.129.5 → 8.0.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 (74) hide show
  1. package/README.md +81 -5
  2. package/SKILL.md +66 -5
  3. package/VERSION +1 -1
  4. package/autonomy/app-runner.sh +37 -0
  5. package/autonomy/completion-council.sh +862 -28
  6. package/autonomy/council-v2.sh +39 -0
  7. package/autonomy/crash.sh +3 -2
  8. package/autonomy/grill.sh +42 -0
  9. package/autonomy/hooks/validate-bash.sh +301 -4
  10. package/autonomy/lib/cockpit-render.sh +8 -2
  11. package/autonomy/lib/cr-rematerialize.py +101 -4
  12. package/autonomy/lib/deadline.py +957 -0
  13. package/autonomy/lib/dependency-setup.sh +205 -0
  14. package/autonomy/lib/done-recognition.sh +45 -0
  15. package/autonomy/lib/efficiency_cost.py +13 -6
  16. package/autonomy/lib/no_mock_scan.py +793 -0
  17. package/autonomy/lib/prd-enrich.sh +42 -0
  18. package/autonomy/lib/proof-analytics-props.py +69 -0
  19. package/autonomy/lib/proof-generator.py +282 -95
  20. package/autonomy/lib/proof-template.html +15 -12
  21. package/autonomy/lib/proof-verify.py +151 -102
  22. package/autonomy/lib/requirements_contract.py +848 -0
  23. package/autonomy/lib/sdk-mode.sh +103 -0
  24. package/autonomy/lib/secret-scan.sh +139 -0
  25. package/autonomy/lib/spec-expand.sh +208 -0
  26. package/autonomy/lib/tree_digest.py +266 -0
  27. package/autonomy/lib/voter-agents.sh +58 -8
  28. package/autonomy/lib/workspace_diff.py +124 -0
  29. package/autonomy/loki +189 -17
  30. package/autonomy/playwright-verify.sh +501 -0
  31. package/autonomy/prd-checklist.sh +17 -8
  32. package/autonomy/provider-offer.sh +111 -0
  33. package/autonomy/run.sh +4417 -676
  34. package/autonomy/sandbox.sh +42 -0
  35. package/autonomy/spec-interrogation.sh +148 -5
  36. package/autonomy/spec.sh +118 -1
  37. package/autonomy/telemetry.sh +133 -7
  38. package/autonomy/verify.sh +107 -0
  39. package/bin/loki +110 -3
  40. package/completions/_loki +10 -0
  41. package/completions/loki.bash +1 -1
  42. package/dashboard/__init__.py +1 -1
  43. package/dashboard/audit.py +96 -7
  44. package/dashboard/build_supervisor.py +1619 -0
  45. package/dashboard/control.py +8 -0
  46. package/dashboard/prompt_optimizer.py +7 -0
  47. package/dashboard/server.py +577 -22
  48. package/dashboard/static/trust.html +1 -1
  49. package/docs/ARCHITECTURE-OVERVIEW.md +207 -0
  50. package/docs/AUTONOMI-ECOSYSTEM.md +107 -0
  51. package/docs/INSTALLATION.md +19 -2
  52. package/docs/MODEL-EQUIVALENCE-HARNESS-PLAN.md +70 -0
  53. package/docs/PLANS-INDEX.md +33 -0
  54. package/docs/PRIVACY.md +29 -1
  55. package/docs/SIGNED-RECEIPTS.md +102 -0
  56. package/docs/SONNET5-DEFAULT-PLAN.md +1 -1
  57. package/docs/V8-ACCEPTANCE-TRIAGE-2026-07-24.md +114 -0
  58. package/docs/V8-AGENT-SDK-PLAN.md +692 -0
  59. package/docs/V8-COMPLEXITY-AUDIT-2026-07-24.md +45 -0
  60. package/docs/V8-MAJOR-RELEASE-PLAN.md +137 -0
  61. package/docs/V8-OVERNIGHT-PLAN-2026-07-25.md +82 -0
  62. package/docs/V8-RUNTIME-TRUTH-2026-07-25.md +232 -0
  63. package/docs/V8-SDK-RESEARCH-RAW.md +129 -0
  64. package/docs/alternative-installations.md +4 -4
  65. package/loki-ts/dist/loki.js +674 -285
  66. package/loki-ts/package.json +2 -0
  67. package/mcp/__init__.py +1 -1
  68. package/package.json +7 -6
  69. package/plugins/loki-mode/.claude-plugin/plugin.json +1 -1
  70. package/providers/claude.sh +75 -0
  71. package/providers/codex.sh +85 -13
  72. package/references/sdk-mode.md +106 -0
  73. package/skills/model-selection.md +1 -1
  74. package/skills/quality-gates.md +22 -0
@@ -40,6 +40,14 @@ _PO_INSTALL_CMD="npm install -g @anthropic-ai/claude-code"
40
40
 
41
41
  # detect_any_provider: true (0) if any supported provider CLI is on PATH.
42
42
  # Extracted verbatim from the loki doctor detection loop (design 1.2).
43
+ #
44
+ # DELIBERATELY PATH-ONLY. Do NOT fold the bundled-SDK predicate below into this
45
+ # function. Its callers include cmd_demo (loki:12369 -> bash cmd_start) and
46
+ # cmd_quick (loki:12701 -> execs run.sh), both of which stay on the BASH route
47
+ # even under LOKI_SDK_MODE=full and therefore genuinely require a binary on PATH
48
+ # (providers/claude.sh:108 provider_detect is `command -v claude`). Opening this
49
+ # gate for them would be a fail-open: a green pre-flight followed by a runner
50
+ # that cannot invoke anything.
43
51
  detect_any_provider() {
44
52
  local _dp
45
53
  for _dp in claude codex cline aider; do
@@ -48,6 +56,105 @@ detect_any_provider() {
48
56
  return 1
49
57
  }
50
58
 
59
+ # detect_bundled_sdk_provider: true (0) only when the bundled Claude Agent SDK
60
+ # can ACTUALLY run this machine's main loop with no separate CLI install.
61
+ #
62
+ # FAIL CLOSED BY CONSTRUCTION. A green doctor followed by a failed first build is
63
+ # worse than today's honest blocker, so all THREE conditions must hold:
64
+ #
65
+ # 1. USABLE, not merely declared. @anthropic-ai/claude-agent-sdk is an
66
+ # optionalDependency whose own per-platform binary is itself an
67
+ # optionalDependency, so `--no-optional`, an offline install, or an
68
+ # unsupported platform all leave the package listed in package.json (or even
69
+ # sdk.mjs on disk) with NO runnable executable. We therefore probe for the
70
+ # extracted binary at @anthropic-ai/claude-agent-sdk-<platform>/claude, not
71
+ # for the JS entrypoint. Glob over the platform suffix instead of mapping
72
+ # uname, so a new platform tuple needs no edit here.
73
+ # 2. CREDENTIALS present. The SDK is pure HTTPS: ANTHROPIC_API_KEY, an
74
+ # ANTHROPIC_AUTH_TOKEN, or an ANTHROPIC_BASE_URL gateway. Absent all three,
75
+ # the loop would stall exactly like a logged-out CLI.
76
+ # 3. THE SDK LOOP IS ACTIVE. This is the condition that is easy to miss: with
77
+ # the SDK installed and a key set but LOKI_SDK_MODE unset, `loki start`
78
+ # never forks to Bun (bin/loki:255 tests LOKI_SDK_LOOP) and dies on the bash
79
+ # route at loki:1940. We read LOKI_SDK_LOOP because autonomy/lib/sdk-mode.sh
80
+ # has already resolved LOKI_SDK_MODE=full into it at bin/loki:41-46, which
81
+ # runs for every subcommand. Reading the resolved flag (not the mode string)
82
+ # also honors an explicit per-site LOKI_SDK_LOOP=1.
83
+ #
84
+ # Any doubt -> return 1 and the caller keeps today's behavior verbatim.
85
+ detect_bundled_sdk_provider() {
86
+ # MATCH bin/loki:255 EXACTLY -- only "1" and "true" fork to the Bun SDK loop.
87
+ # bin/loki's own comment concedes it cannot cheaply reproduce truthy()'s
88
+ # yes/on spellings, so accepting a wider set here is a proven fail-open:
89
+ # LOKI_SDK_LOOP=yes made doctor print PASS while the very next `loki start`
90
+ # stayed on the bash route and exited 2 at the provider gate. Doctor green,
91
+ # build dead. Keep these two sets byte-identical; widening either one alone
92
+ # reopens the hole.
93
+ case "${LOKI_SDK_LOOP:-}" in
94
+ 1|true) : ;;
95
+ *) return 1 ;;
96
+ esac
97
+
98
+ # The Bun runtime must actually exist. bin/loki:200-203 silently execs the
99
+ # BASH CLI when `command -v bun` fails ("keeps users on systems without Bun
100
+ # working"), and the bash route needs a binary on PATH. Without this check a
101
+ # bun-less machine with the SDK + a key would pass doctor and then die.
102
+ command -v bun >/dev/null 2>&1 || return 1
103
+
104
+ if [ -z "${ANTHROPIC_API_KEY:-}" ] && [ -z "${ANTHROPIC_AUTH_TOKEN:-}" ] \
105
+ && [ -z "${ANTHROPIC_BASE_URL:-}" ]; then
106
+ return 1
107
+ fi
108
+
109
+ # Search the node_modules trees Loki is actually installed into. The root is
110
+ # derived from THIS FILE's location (self-containment contract, see header):
111
+ # SKILL_DIR belongs to autonomy/loki and is NOT exported, so it would be
112
+ # empty when doctor.ts spawns this script standalone -- which would silently
113
+ # answer "no SDK" on the Bun route while the bash route said yes, exactly the
114
+ # kind of route split the parity gate exists to prevent.
115
+ # LOKI_SDK_NODE_MODULES is a TEST-ONLY seam (never set in production) so the
116
+ # shell tests can point at a fixture tree without mutating real node_modules.
117
+ local _po_root
118
+ _po_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." 2>/dev/null && pwd)" || _po_root=""
119
+ # Array, not a word-split string: install roots can contain spaces.
120
+ local _po_search=()
121
+ if [ -n "${LOKI_SDK_NODE_MODULES:-}" ]; then
122
+ # When the test seam is set it is AUTHORITATIVE (not merely first): the
123
+ # real tree must not be consulted as a fallback, or a fixture asserting
124
+ # "no usable SDK" would silently pass by finding the repo's own binary.
125
+ _po_search=("$LOKI_SDK_NODE_MODULES")
126
+ elif [ -n "$_po_root" ]; then
127
+ # Two layouts, both real:
128
+ # repo clone -> <root>/node_modules, <root>/loki-ts/node_modules
129
+ # npm install -> npm HOISTS the SDK out of node_modules/loki-mode/
130
+ # up to the installing tree's top-level
131
+ # node_modules/ (verified by packing this repo and
132
+ # installing the tarball). Without the hoisted
133
+ # candidates the predicate silently returns 1 for
134
+ # every npm-installed user, i.e. the feature would
135
+ # be dead for exactly the audience it targets.
136
+ # <root> is .../node_modules/loki-mode, so ../ is the @scope-less
137
+ # top-level node_modules and ../../ covers a scoped install.
138
+ _po_search=(
139
+ "$_po_root/node_modules"
140
+ "$_po_root/loki-ts/node_modules"
141
+ "$_po_root/.."
142
+ "$_po_root/../.."
143
+ )
144
+ fi
145
+ local _nm
146
+ for _nm in ${_po_search+"${_po_search[@]}"}; do
147
+ [ -n "$_nm" ] || continue
148
+ set -- "$_nm"/@anthropic-ai/claude-agent-sdk-*/claude
149
+ # Unmatched globs stay literal in bash, so test the expansion for real.
150
+ while [ "$#" -gt 0 ]; do
151
+ [ -x "$1" ] && return 0
152
+ shift
153
+ done
154
+ done
155
+ return 1
156
+ }
157
+
51
158
  # _po_assume_yes: true when the user has opted into unattended confirmation.
52
159
  # Honors --yes (LOKI_AUTO_CONFIRM, set by loki:1013) and LOKI_ASSUME_YES.
53
160
  _po_assume_yes() {
@@ -251,6 +358,10 @@ if [ "${BASH_SOURCE[0]}" = "$0" ]; then
251
358
  offer|report) offer_provider_install report ;;
252
359
  gate) offer_provider_install gate ;;
253
360
  detect) detect_any_provider ;;
361
+ # Silent, exit-status-only probe for the Bun doctor bridge
362
+ # (loki-ts/src/commands/doctor.ts). Prints nothing, so it cannot perturb
363
+ # the parity-captured stdout.
364
+ detect-sdk) detect_bundled_sdk_provider ;;
254
365
  *) offer_provider_install report ;;
255
366
  esac
256
367
  fi