loki-mode 7.129.5 → 8.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. package/README.md +121 -9
  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 +326 -92
  20. package/autonomy/lib/proof-template.html +15 -12
  21. package/autonomy/lib/proof-verify.py +169 -105
  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 +141 -0
  29. package/autonomy/loki +196 -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 +4587 -671
  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/providers.md +42 -0
  75. package/skills/quality-gates.md +22 -0
package/README.md CHANGED
@@ -15,7 +15,7 @@ _The free, source-available autonomous coding agent by [Autonomi](https://www.au
15
15
 
16
16
  [Website](https://www.autonomi.dev/) | [Documentation](wiki/Home.md) | [Installation](docs/INSTALLATION.md) | [Changelog](CHANGELOG.md) | [Purple Lab -- deprecated v7.44.0](#purple-lab)
17
17
 
18
- **Current release: v7.121.5**
18
+ **Current release: v8.0.0**
19
19
 
20
20
  </div>
21
21
 
@@ -25,19 +25,63 @@ _The free, source-available autonomous coding agent by [Autonomi](https://www.au
25
25
 
26
26
  ---
27
27
 
28
+ ## The Evidence Receipt: don't trust the agent, check it
29
+
30
+ Every coding agent tells you it finished. Loki hands you something you can
31
+ check yourself.
32
+
33
+ Each run writes a receipt to `.loki/proofs/<run_id>/` that separates
34
+ **deterministic FACTS** (the git diff with base and head SHAs plus a
35
+ `diff_sha256`, the test command and its exit code, the build command and its
36
+ exit code, each gate verdict) from **AI ASSESSMENTS** (the council verdict,
37
+ labeled as judgment, never as proof). The headline is computed from the facts
38
+ alone:
39
+
40
+ | Headline | Means |
41
+ |---|---|
42
+ | VERIFIED | tests ran a real command and exited 0, diff non-empty, nothing skipped |
43
+ | VERIFIED WITH GAPS | each gap listed by name |
44
+ | NOT VERIFIED | a check ran and failed |
45
+
46
+ ```bash
47
+ loki proof list # every receipt from this project
48
+ loki proof show <id> # the facts, the assessments, and the headline
49
+ loki proof verify <id> # re-hash the receipt and re-derive the diff
50
+ ```
51
+
52
+ `loki proof verify` exits 0 clean, 1 on tamper or drift. Receipts are attached
53
+ to pull requests automatically (`LOKI_PROVEN_PR=0` to opt out), so a reviewer
54
+ sees the evidence next to the code.
55
+
56
+ **What the receipt does NOT claim.** On the unsigned path the generator is
57
+ trusted: someone who rewrites both the facts and the headline into a mutually
58
+ consistent lie and recomputes the hash will still pass verification. That is
59
+ defense-in-depth, not non-forgeability, and neutral non-forgeability needs the
60
+ signed record. We tested for exactly this and locked the limitation into the
61
+ suite (`tests/test-proof-forgery-defense.sh`), and in v7.111.0 we removed our
62
+ own earlier "non-forgeable" claim once we found it was false on that path. An
63
+ honest boundary you can verify beats a marketing claim you cannot.
64
+
65
+ To close that gap, sign your receipts: `export LOKI_PROOF_GPG_KEY=<key-id>` and
66
+ every receipt carries a detached GPG signature that any third party with your
67
+ public key can verify offline. See [docs/SIGNED-RECEIPTS.md](docs/SIGNED-RECEIPTS.md).
68
+
28
69
  ## Why Loki Mode?
29
70
 
30
- - **Spec-driven, autonomous, with a built-in trust layer** -- Hand Loki a spec, walk away, come back to working code with tests. The full RARV-C closure loop (Reason - Act - Reflect - Verify - Close) runs until the work is actually done, not just attempted. The verified-completion evidence gate (`skills/quality-gates.md`) refuses any "done" claim on an empty git diff against the run-start commit, and blocks completion when tests run red, so "complete" means proven, not promised.
71
+ - **Spec-driven, autonomous, with a built-in trust layer** -- Hand Loki a spec, walk away, come back to working code with tests. The full RARV-C closure loop (Reason - Act - Reflect - Verify - Close) runs until the work is actually done, not just attempted. The verified-completion evidence gate (`skills/quality-gates.md`) refuses any "done" claim on an empty git diff against the run-start commit, blocks completion when tests run red, and (v8.0.0) also blocks when a serveable app is confirmed unhealthy (runtime-boot axis, opt out `LOKI_EVIDENCE_BOOT_GATE=0`) or a credential is detected in the changed files (secret-leak axis, opt out `LOKI_EVIDENCE_SECRET_GATE=0`), so "complete" means proven, not promised.
31
72
  - **A checklist verifier that is honest, not brittle** -- Each completion checklist item is checked deterministically before the completion council will accept "done". The verifier speaks extended regex (`grep -E`) so real LLM-emitted patterns match instead of erroring, and it is runner-agnostic: it runs the project's own declared test command rather than assuming a fixed runner. Crucially, a check that cannot be established is reported as inconclusive (pending), never as a false pass and never as a false failure. `rc == 0` alone is not a pass; a test check goes green only on a real "N passed" signal from the runner (v7.121.x).
32
73
  - **Production quality built in** -- 8 quality gates (`skills/quality-gates.md`), blind 3-reviewer code review (`run.sh:run_code_review()`), anti-sycophancy checks
33
74
  - **Standalone verification: `loki verify`** -- Run Loki's deterministic gates (build, tests, static analysis, secret scan, dependency audit) against any branch or PR diff, including code written by other agents or humans. CI-ready exit codes (0 VERIFIED, 1 CONCERNS, 2 BLOCKED), machine-readable evidence at `.loki/verify/evidence.json`. Inconclusive evidence is never reported as VERIFIED (v7.27.0).
34
- - **Living spec and pre-build interrogation** -- `loki spec` locks a spec and detects drift deterministically (`spec.lock`, `drift-report.json`, and a `SPEC_DRIFT` finding in `loki verify` with CI exit codes), so you can tell when the build diverges from what was agreed. `loki grill` runs a Devil's-Advocate interrogation of the spec before you build, surfacing gaps and contradictions early (v7.28.0).
75
+ - **Living spec and pre-build interrogation** -- `loki spec` locks a spec and detects drift deterministically (`spec.lock`, `drift-report.json`, and a `SPEC_DRIFT` finding in `loki verify` with CI exit codes), so you can tell when the build diverges from what was agreed. For an OpenAPI/GraphQL/Postman contract it locks one requirement per operation with a per-operation hash, so a single changed response schema drifts exactly that operationId (v8.0.0). `loki grill` runs a Devil's-Advocate interrogation of the spec before you build, surfacing gaps and contradictions early (v7.28.0).
35
76
  - **Mid-flight model switching** -- switch the model a live run uses from the dashboard (applies at the next iteration, current run only). A Fable tier lever exists in the CLI, dashboard, and override paths, but Claude Fable 5 is not yet available at the API, so selecting Fable currently collapses to Opus at every dispatch chokepoint and the `loki plan` quote reflects Opus accordingly. For every model lever (session pin, mid-flight override, architect pass) and every `LOKI_MAX_TIER` path, the `loki plan` quote, the dashboard's reported model, and the actual dispatched model agree, with the ceiling enforced (v7.31.0; Fable-to-Opus collapse v7.39.1).
36
77
  - **A calmer CLI** -- the help surface is ~20 grouped workflow entries instead of a 70-command wall; merged commands live on as aliases that forward byte-identically with a one-line stderr pointer, so no script breaks (v7.31.0).
37
78
  - **Guided first build: `loki quickstart`** -- four quick questions (setup check, one-line idea, template pick, plan review) and your build starts; pressing Enter through every step builds the sample Todo app. The plan step quotes the real cost/time estimate before anything is spent, and `loki demo` now confirms its estimate the same way. If no AI provider CLI is installed, Loki offers to install Claude Code (consent-gated, interactive terminals only) (v7.29.0).
38
79
  - **Live App Preview** -- The dashboard embeds the locally-running app in an iframe so you can interact with it immediately during a build. Use `loki preview` (alias `loki open`) to print the URL and open it in your browser. Local-first: no hosted service, no vendor lock (v7.24.0).
39
80
  - **Compose-first fullstack** -- When a spec needs more than one service (web + database + cache) Loki generates a 12-factor `docker-compose.yml` with healthchecks, `depends_on` wiring, env-var config, and a `.env.example`. The Live App Preview surfaces the web service URL (not a database port), and health reflects the web service's Docker healthcheck so a crashed app shows as crashed even when the database stays up. Single-service apps stay on a plain run command. All local-first, no hosted service (v7.26.0).
40
81
  - **Intelligent `loki start`** -- For interactive foreground runs the dashboard auto-opens in the browser (cross-platform; skipped in CI, SSH-without-TTY, and piped runs; opt out with `LOKI_NO_AUTO_OPEN=1`). The completion summary shows "Your app is live at <url>" so you know exactly where to try what Loki just built. The autonomous loop passes Claude Code's `--effort`, `--max-budget-usd`, and `--fallback-model` on every iteration (each gated on CLI support and individual opt-out env vars) for better long-run unattended execution (v7.25.0).
82
+ - **Confidence is not evidence** -- When the agent's self-reported confidence spikes to near-certainty, Loki forces an EXTRA verification pass before accepting a stop, rather than taking the claim at face value. Strictly additive: high confidence makes the engine look harder, never less hard, and it can never skip or satisfy a gate (v8.0.0, opt out `LOKI_CONFIDENCE_SPIKE=0`).
83
+ - **Goals it can actually measure** -- A goal with no checkable success condition ("make it fast") gives the loop no gradient: every iteration can claim progress and none can be verified. Loki flags an un-measurable goal up front and asks for a threshold, a metric, or a concrete artifact. Advisory only, and never rewrites your goal (v8.0.0, opt out `LOKI_GOAL_SCORING=0`).
84
+ - **Stops paying for failures that cannot succeed** -- A positively-identified permanent failure (bad credentials, unknown model, exhausted quota) exits immediately instead of burning the retry budget on guaranteed-identical failures. Fail-safe: an unrecognized error still retries exactly as before, and rate limits are never treated as permanent (v8.0.0, opt out `LOKI_SMART_RETRY=0`).
41
85
  - **Cross-project memory** -- Episodic/semantic/procedural memory with vector search; knowledge learned on one project surfaces on the next (v5.15.0+, see `memory/engine.py`)
42
86
  - **Self-hosted and private** -- Your keys, your infrastructure, no data leaves your network
43
87
  - **Legacy system healing** -- `loki modernize heal` archaeology/stabilize/isolate/modernize/validate phases (v6.67.0, see `skills/healing.md`)
@@ -182,7 +226,60 @@ loki init my-app --template simple-todo-app # scaffold a starter PRD
182
226
  cd my-app && loki start prd.md # autonomous build from the spec
183
227
  ```
184
228
 
185
- One thing to know first: Loki drives a separate coding-agent CLI (Claude Code is the recommended one) and needs it plus a couple of common tools on your PATH. Run `loki doctor` any time and it tells you exactly what is present and what is missing, with a copy-pasteable install command for each gap.
229
+ One thing to know first: Loki needs a model to drive. There are two ways to give it one.
230
+
231
+ **Without a separate CLI (v8).** The Claude Agent SDK ships inside Loki, so an API key alone is enough:
232
+
233
+ ```bash
234
+ export ANTHROPIC_API_KEY=sk-... # or ANTHROPIC_AUTH_TOKEN / ANTHROPIC_BASE_URL
235
+ LOKI_SDK_MODE=full loki start prd.md # runs the loop and the judges through the bundled SDK
236
+ ```
237
+
238
+ This needs Bun on your PATH (the SDK loop runs on the Bun runtime). `loki doctor` reports `Bundled Claude Agent SDK is usable -- no separate CLI needed` when that path is genuinely ready, and stays on the normal blocker otherwise: it checks that the SDK's platform binary is actually extracted, that credentials are present, and that the SDK loop is really the route your next run will take. It will not tell you that you are ready and then fail the build.
239
+
240
+ **With a coding-agent CLI.** The classic path, and still the default: Loki drives a separate CLI (Claude Code is the recommended one) plus a couple of common tools on your PATH.
241
+
242
+ **With a different model or provider.** Loki is not tied to Anthropic. Anything
243
+ that speaks the Anthropic Messages API works: OpenRouter, Ollama, LiteLLM, vLLM,
244
+ or your own gateway. Point `ANTHROPIC_BASE_URL` at the endpoint and name the
245
+ model with `LOKI_MODEL_OVERRIDE`:
246
+
247
+ ```bash
248
+ # OpenRouter (hundreds of models, one key)
249
+ export ANTHROPIC_BASE_URL=https://openrouter.ai/api/v1
250
+ export ANTHROPIC_API_KEY=sk-or-...
251
+ export LOKI_MODEL_OVERRIDE=<model-id-from-openrouter.ai/models>
252
+ loki start prd.md
253
+
254
+ # Ollama, fully local (no API key, no per-token cost)
255
+ export ANTHROPIC_BASE_URL=http://localhost:11434/v1
256
+ export LOKI_MODEL_OVERRIDE=<model you have pulled, e.g. the output of `ollama list`>
257
+ loki start prd.md
258
+
259
+ # LiteLLM / vLLM / any self-hosted gateway
260
+ export ANTHROPIC_BASE_URL=https://your-gateway.internal/v1
261
+ export ANTHROPIC_API_KEY=...
262
+ export LOKI_MODEL_OVERRIDE=<whatever your gateway calls the model>
263
+ loki start prd.md
264
+ ```
265
+
266
+ **Set both variables.** `LOKI_MODEL_OVERRIDE` is what makes the alt-provider
267
+ path work: without it Loki keeps asking for `opus` / `sonnet` / `haiku`, which
268
+ only Anthropic resolves, and most providers reject those names outright. A
269
+ proxy that maps the aliases for you (LiteLLM can) is the one exception.
270
+
271
+ Model IDs are not listed here on purpose -- OpenRouter's catalogue changes every
272
+ week, and a stale ID in a README is a failure you would hit at runtime. Take the
273
+ exact string from your provider's own model list.
274
+
275
+ Both routes honor these variables identically -- the bundled-SDK path and the
276
+ Claude Code CLI path -- and `loki doctor` reports the endpoint it detected plus a
277
+ warning if the model override is missing.
278
+
279
+ The quality gates, the completion council, and the Evidence Receipt do not care
280
+ which model produced the code. They check what was actually built.
281
+
282
+ Either way, run `loki doctor` any time and it tells you exactly what is present and what is missing, with a copy-pasteable install command for each gap.
186
283
 
187
284
  ```bash
188
285
  loki doctor # check your setup before the first build
@@ -315,7 +412,7 @@ A "spec" is whatever you hand `loki start`. Loki auto-detects the format and nor
315
412
  |--------|---------|-------|
316
413
  | Markdown PRD | `loki start ./prd.md` | Canonical form. Headings become section anchors. |
317
414
  | JSON spec | `loki start ./spec.json` | Free-form JSON; keys surfaced to agents. |
318
- | YAML spec | `loki start ./openapi.yaml` | OpenAPI / AsyncAPI / plain YAML all accepted. |
415
+ | YAML spec | `loki start ./openapi.yaml` | OpenAPI / AsyncAPI / plain YAML all accepted. An OpenAPI/GraphQL/Postman contract expands into a per-operation build checklist (one item per operationId/field/request) so no operation is lost to prompt truncation (v8.0.0). |
319
416
  | Plain text brief | `loki start ./brief.txt` | One-paragraph briefs work; complexity auto-detects to "simple". |
320
417
  | GitHub issue URL | `loki start https://github.com/owner/repo/issues/42` | Title + body + labels become the spec. |
321
418
  | GitHub shorthand | `loki start owner/repo#42` | Same as above, shorter. |
@@ -482,7 +579,9 @@ Status legend: "E2E-verified" means we run real spec-to-code builds on it oursel
482
579
  | `loki stop` | Stop execution |
483
580
  | `loki modernize heal <path>` | Legacy system healing (archaeology, stabilize, isolate, modernize, validate -- v6.67.0; was: `loki heal`) |
484
581
  | `loki pause` / `resume` | Pause/resume after current session |
582
+ | `loki steer "<note>"` | Nudge a running build with a directive (writes `.loki/HUMAN_INPUT.md`; the loop reads it when `LOKI_PROMPT_INJECTION=1`) (v8.0.0) |
485
583
  | `loki status` | Show current status |
584
+ | `loki why` | Explain the last outcome; on a stalled run names the real stall reason (proactive stuck-detector + convergence signal) and suggests `loki steer` (v8.0.0) |
486
585
  | `loki cockpit` | Live multi-repo status as an inline terminal image (Kitty/iTerm2/WezTerm/Ghostty); text + dashboard fallback elsewhere (v7.126.0) |
487
586
  | `loki dashboard` | Open web dashboard |
488
587
  | `loki preview` | Print running app URL and open in browser (Live App Preview, v7.24.0; was: `loki open`) |
@@ -503,6 +602,20 @@ Status legend: "E2E-verified" means we run real spec-to-code builds on it oursel
503
602
 
504
603
  Run `loki --help` for all options. Full reference: [CLI Reference](wiki/CLI-Reference.md) | Config: [config.example.yaml](autonomy/config.example.yaml)
505
604
 
605
+ ### Configuration file
606
+
607
+ Pass a config file to `loki start` with `--config <path>` (aliases: `--env-file`, `--vars`), or set `LOKI_CONFIG_FILE`. The format is detected from the extension or content: `.yaml`/`.yml`, `.json`, or `.env` (flat `LOKI_*=value` lines). Values resolve by precedence: a CLI flag beats an ambient env var, which beats the `--config` file, which beats built-in defaults. Never inline a secret; reference an env var with `${VAR}` and the loader expands it at load time (an unset reference is skipped with a warning, and a raw-looking secret literal is flagged). Generate a starter with `loki config example`.
608
+
609
+ ```bash
610
+ # config.yaml
611
+ dashboard:
612
+ port: 9000
613
+ github:
614
+ token: ${GITHUB_TOKEN} # expanded from the environment, never stored inline
615
+
616
+ loki start --config config.yaml ./prd.md
617
+ ```
618
+
506
619
  ---
507
620
 
508
621
  <details>
@@ -517,6 +630,9 @@ Loki Mode's accuracy and autonomy behaviors are default-on. Each is an opt-out e
517
630
  | `LOKI_AUTO_DOCS` | `true` | Generates the `.loki/docs/` suite before the documentation gate scores it (bounded: once per run when docs are missing, and again only when >10 commits stale). Set `false` to opt out. |
518
631
  | `LOKI_CAVEMAN` | `1` (on) | Output-token compressor for free-form generation only (never trust-gate subcalls). Set `0` to opt out. |
519
632
  | `LOKI_CAVEMAN_LEVEL` | inferred | Compression level for the compressor. Auto-inferred per invocation from the run's RARV tier; set explicitly (`lite` / `full` / `ultra`) to override the inference. |
633
+ | `LOKI_CONFIDENCE_SPIKE` | `1` (on) | Forces one EXTRA verification pass when the agent's self-reported confidence spikes, instead of trusting the claim. Strictly additive -- it can never skip a gate. Set `0` to opt out; tune with `LOKI_CONFIDENCE_SPIKE_DELTA` (default `40`) and `LOKI_CONFIDENCE_SPIKE_MIN` (default `90`). |
634
+ | `LOKI_GOAL_SCORING` | `1` (on) | Flags a goal with no measurable success condition and asks for a threshold, metric, or concrete artifact. Advisory only -- never blocks a build or rewrites the goal. Set `0` to opt out. |
635
+ | `LOKI_SMART_RETRY` | `1` (on) | Stops early on a positively-identified permanent failure (bad credentials, unknown model, exhausted quota) rather than burning retries. Unrecognized errors and rate limits still retry as before. Set `0` to retry every failure. |
520
636
 
521
637
  This is a subset. See the [wiki](wiki/Home.md) for the full env-var reference and the RARV-C closure knobs (`LOKI_INJECT_FINDINGS`, `LOKI_OVERRIDE_COUNCIL`, `LOKI_AUTO_LEARNINGS`, `LOKI_HANDOFF_MD`).
522
638
 
@@ -639,7 +755,3 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
639
755
  **[Autonomi](https://www.autonomi.dev/)** | **[Documentation](wiki/Home.md)** | **[Changelog](CHANGELOG.md)** | **[Comparisons](references/competitive-analysis.md)**
640
756
 
641
757
  </div>
642
-
643
- ## Star History
644
-
645
- [![Star History Chart](https://api.star-history.com/chart?repos=asklokesh/loki-mode&type=timeline&legend=bottom-right)](https://www.star-history.com/?repos=asklokesh%2Floki-mode&type=timeline&legend=bottom-right)
package/SKILL.md CHANGED
@@ -3,18 +3,20 @@ name: loki-mode
3
3
  description: Autonomous spec-driven build system with a built-in trust layer. It does not call work done until it is verified (RARV-C closure loop, 8 quality gates, completion council, verified-completion evidence gate). Triggers on "Loki Mode". Takes a spec (PRD, GitHub issue, OpenAPI doc, etc.) to deployed product with minimal human intervention. Provider-agnostic. Requires --dangerously-skip-permissions flag.
4
4
  ---
5
5
 
6
- # Loki Mode v7.129.5
6
+ # Loki Mode v8.0.1
7
7
 
8
8
  **You are an autonomous agent. You make decisions. You do not ask questions. You do not stop.**
9
9
 
10
- **Spec in, verified product out.** Spec-driven: a "spec" is whatever describes the work -- a Markdown PRD, a GitHub issue, an OpenAPI doc, a Jira ticket (a PRD is one form of spec). The differentiator is the trust layer: Loki does not call work done until it is verified. The RARV-C closure loop, 8 quality gates, the completion council, and the verified-completion evidence gate must all clear before completion is accepted.
10
+ **Spec in, verified product out.** Spec-driven: a "spec" is whatever describes the work -- a Markdown PRD, a GitHub issue, an OpenAPI doc, a Jira ticket (a PRD is one form of spec). The differentiator is the trust layer: Loki does not call work done until it is verified. The RARV-C closure loop, 8 quality gates, the completion council, and the verified-completion evidence gate must all clear before completion is accepted. The evidence gate blocks on empty-diff, red tests, an unhealthy serveable app (runtime-boot axis, `LOKI_EVIDENCE_BOOT_GATE=0` to opt out), and a leaked credential in the changed files (secret-leak axis, `LOKI_EVIDENCE_SECRET_GATE=0` to opt out) -- v8.0.0.
11
11
 
12
12
  **Evidence Receipt (verify it yourself).** Every run writes a receipt to `.loki/proofs/<run_id>/` (opt out with `LOKI_PROOF=0`) that separates deterministic FACTS (git diff with base/head SHAs and a `diff_sha256`, the test command + exit code, the build command + exit code, each gate verdict) from AI ASSESSMENTS (the council verdict, labeled judgment not proof). The headline is computed only from the facts: VERIFIED (tests ran a real command and exited 0, diff non-empty, nothing skipped), VERIFIED WITH GAPS (each gap listed by name), or NOT VERIFIED (a check ran and failed). Inspect and re-check with `loki proof list|show <id>|verify <id>` (aliased `loki receipt`); `loki proof verify` re-hashes the receipt (tamper) and re-derives the diff from the recorded base SHA against the live repo (drift), exiting 0 clean / 1 tamper-or-drift. This is honesty-of-done, not a claim that the code is bug-free.
13
13
 
14
- **Provider-agnostic (stable since v5.0.0):** runs on Claude/Codex/Cline/Aider with abstract model tiers and degraded mode for non-Claude providers; no vendor lock-in. Gemini deprecated v7.5.18. See `skills/providers.md`. **Current track (v7.7.x):** LSP grounding as first-class agent tool (v7.7.0-v7.7.9; lsp_get_diagnostics actually-returns-diagnostics regression fix v7.7.14), provider_source cli (v7.7.11-v7.7.12 bash/bun parity), Docker/bash-3.2 robustness (v7.7.13), audit chain cross-file verification fix (v7.7.15), Phase 1 RARV-C closure (real provider judges, gate-failure flock, synthetic PRD e2e, status `--json`).
14
+ **Provider-agnostic (stable since v5.0.0):** runs on Claude/Codex/Cline/Aider with abstract model tiers and degraded mode for non-Claude providers; no vendor lock-in. Gemini deprecated v7.5.18. See `skills/providers.md`. **Current track (v8.0.0):** the Anthropic Agent SDK route (see below), spec-mode expansion for OpenAPI/GraphQL/Postman contracts, the runtime-boot and secret-leak evidence axes, and `loki steer` / `loki why` for mid-run control. Earlier tracks: LSP grounding as a first-class agent tool (v7.7.x) and Phase 1 RARV-C closure (real provider judges, gate-failure flock, synthetic PRD e2e, status `--json`).
15
15
 
16
16
  **Runtime migration:** Bash-to-Bun migration. Read-only commands (`version`, `status`, `stats`, `doctor`, `provider show/list`, `memory list/index`) flow through Bun runtime via `bin/loki` since v7.3.0. Every other command remains on the Bash runtime (`autonomy/loki`). Rollback: `LOKI_LEGACY_BASH=1`. See `UPGRADING.md` and `docs/architecture/ADR-001-runtime-migration.md`.
17
17
 
18
+ **Anthropic Agent SDK route (v8.0.0, opt-in, default-off):** a claude-binary-free path where the RARV loop runs on `@anthropic-ai/claude-agent-sdk` `query()` and judges run on the raw `@anthropic-ai/sdk`. One operator switch `LOKI_SDK_MODE` (`off` default / `judges` / `full`), mirrored byte-for-byte in bash (`autonomy/lib/sdk-mode.sh`) and TypeScript (`loki-ts/src/runner/sdk_mode.ts`). Unset = byte-identical to the claude-CLI route. See `references/sdk-mode.md`.
19
+
18
20
  ---
19
21
 
20
22
  ## PRIORITY 1: Load Context (Every Turn)
@@ -203,7 +205,7 @@ claude --dangerously-skip-permissions
203
205
  # Unified `loki start` -- one command, auto-detected mode
204
206
  loki start # no arg: analyze current dir, auto-generate spec
205
207
  loki start ./prd.md # PRD mode (.md/.json/.txt/.yaml) -- a PRD is one form of spec
206
- loki start ./openapi.yaml # SPEC mode (OpenAPI doc treated as the spec)
208
+ loki start ./openapi.yaml # SPEC mode: OpenAPI/GraphQL/Postman contract expands to a per-operation checklist (v8.0.0)
207
209
  loki start owner/repo#123 # ISSUE mode (GitHub specific repo)
208
210
  loki start https://github.com/o/r/issues/42 # ISSUE mode (GitHub URL)
209
211
  loki start 123 # ISSUE mode (GitHub issue in current repo)
@@ -250,7 +252,9 @@ When running with `autonomy/run.sh`, you can intervene:
250
252
  | Method | Effect |
251
253
  |--------|--------|
252
254
  | `touch .loki/PAUSE` | Pauses after current session |
255
+ | `loki steer "<note>"` | Appends a directive to `.loki/HUMAN_INPUT.md` (needs `LOKI_PROMPT_INJECTION=1`); v8.0.0 |
253
256
  | `echo "instructions" > .loki/HUMAN_INPUT.md` | Injects directive (requires `LOKI_PROMPT_INJECTION=true`) |
257
+ | `loki why` | Explains the current outcome; on a stall names the real stall reason and suggests `loki steer` (v8.0.0) |
254
258
  | `touch .loki/STOP` | Stops immediately |
255
259
  | Ctrl+C (once) | Pauses, shows options |
256
260
  | Ctrl+C (twice) | Exits immediately |
@@ -352,6 +356,58 @@ Two completion-trust features extend the verification gates. Full details in `sk
352
356
  - **Held-out spec evals:** ~25% of checklist items (deterministic `sha256(id)` order, `N >= 4`) are reserved into `.loki/checklist/held-out.json` and excluded from the build prompt feed; the completion council blocks if a held-out item fails. Opt out with `LOKI_HELDOUT_GATE=0`. Honest limit: this guards the prompt feed, not a sandbox; the reservation file is on disk and an agent with filesystem access can read it.
353
357
  - **Inconclusive-baseline disclosure:** when the evidence gate cannot establish a diff baseline (`no_git_repo` / `no_run_start_sha`) it writes `.loki/state/evidence-inconclusive.json` and `COMPLETION.txt` carries an honest "not independently verified" line. It never blocks non-git projects; red tests still block.
354
358
 
359
+ ## Harness intelligence (v8.0.0)
360
+
361
+ Four measured-harness disciplines layered onto the existing trust core. None of
362
+ them can weaken a gate: each either adds verification or saves budget on work
363
+ that cannot succeed.
364
+
365
+ | Env Var | Default | Effect |
366
+ |---------|---------|--------|
367
+ | `LOKI_CONFIDENCE_SPIKE=0` | on | Disable the confidence-spike re-check |
368
+ | `LOKI_CONFIDENCE_SPIKE_DELTA` | `40` | Confidence jump (points) that counts as a spike |
369
+ | `LOKI_CONFIDENCE_SPIKE_MIN` | `90` | Absolute level that counts as a spike on first arrival |
370
+ | `LOKI_GOAL_SCORING=0` | on | Disable the goal-measurability advisory |
371
+ | `LOKI_SMART_RETRY=0` | on | Retry every failure, including non-retryable ones |
372
+
373
+ - **Prompt-cache discipline.** The prompt is split into a cache-stable
374
+ `<loki_system>` prefix and a volatile `<dynamic_context>` tail at an explicit
375
+ `[CACHE_BREAKPOINT]`; the SDK judge path applies `cache_control` on that split.
376
+ Any new always-on instruction belongs in the prefix, or it busts the cache
377
+ every iteration.
378
+ - **Confidence-spike re-check.** A jump to near-maximal self-reported confidence
379
+ forces ONE extra verification before the done-signal valve force-stops a run.
380
+ Strictly additive: a spike can only ADD a verification pass, never skip,
381
+ shorten, or satisfy a gate. It cannot delay the stagnation valve, and the
382
+ delay is one-shot, so a repeatedly-spiking run cannot postpone the valve
383
+ indefinitely.
384
+ - **Hill-climbable goal scoring.** A `COMPLETION_PROMISE` with no measurable
385
+ target (no number, comparator, named metric, or verifiable artifact) gets a
386
+ prompt advisory asking for a checkable success condition. Advisory only: it
387
+ never blocks a build and never rewrites the goal. Suppressed for an absent
388
+ goal and in perpetual mode, where open-endedness is the chosen configuration.
389
+ Byte-mirrored across the bash and TypeScript routes.
390
+ - **Smart retry.** A positively-identified permanent failure (bad credentials,
391
+ unknown model, exhausted quota) stops early instead of burning the retry
392
+ budget on guaranteed-identical failures. Fail-safe: an unrecognized error
393
+ stays TRANSIENT and retries exactly as before, and rate limits are explicitly
394
+ excluded from the permanent set.
395
+
396
+ ## Operational observability (v8.0.0)
397
+
398
+ - **SDK capability-degradation event.** An SDK load or stream failure appends a
399
+ structured `capability_degraded` record to `.loki/events.jsonl` (same
400
+ `{type, source, timestamp, payload}` envelope as the hook events) instead of
401
+ existing only as prose in the captured output, so an unattended operator can
402
+ distinguish "the SDK could not load" from "the model did poor work". The
403
+ record states `fail_closed: true` rather than leaving it to be assumed. No env
404
+ var: this is signal an operator always wants.
405
+ - **Time to first preview.** `.loki/app-runner/first-preview.json` records the
406
+ elapsed seconds from run start to the app first serving. Write-once, so a
407
+ restart cannot overwrite a genuine slow first preview with a flattering
408
+ warm-start number; skipped entirely rather than guessed when no baseline
409
+ exists. Bash route only (app-runner integration lives there).
410
+
355
411
  ## First-run UX (v7.29.0)
356
412
 
357
413
  - **`loki quickstart`:** guided 4-step first build (setup check, one-line idea, offline template match, plan review with real estimator figures); Enter-through-everything builds the sample Todo app; non-TTY/CI exits 2 with an automation hint.
@@ -389,6 +445,11 @@ See `CHANGELOG.md` entries [7.5.7], [7.5.8], [7.5.13] for the per-fix list and r
389
445
  | Managed Agents (memory mirror) | v7.2.0 | Opt-in via `LOKI_MANAGED_AGENTS` -- see Managed Agents section |
390
446
  | Bun runtime (Phase 1) | v7.3.0 | Read-only commands routed through `bin/loki`; `LOKI_LEGACY_BASH=1` to revert |
391
447
  | Phase 1 RARV-C closure | v7.5.x | Findings injection, real judges, auto-learnings, handoff.md |
448
+ | Anthropic SDK route | v8.0.0 | Opt-in, default-off; one switch `LOKI_SDK_MODE` -- see `references/sdk-mode.md` |
449
+ | Harness intelligence | v8.0.0 | Prompt-cache discipline, confidence-spike re-check, goal scoring, smart retry |
450
+ | SDK degradation event | v8.0.0 | Structured `capability_degraded` record on `.loki/events.jsonl` |
451
+ | Time to first preview | v8.0.0 | `.loki/app-runner/first-preview.json`, write-once (bash route) |
452
+ | Opt-in build analytics | v8.0.0 | `build_verified` event behind a strict second gate, allowlist-only fields |
392
453
 
393
454
  ## Planned / In-Progress Features
394
455
 
@@ -408,4 +469,4 @@ See `CHANGELOG.md` entries [7.5.7], [7.5.8], [7.5.13] for the per-fix list and r
408
469
 
409
470
  ---
410
471
 
411
- **v7.129.5 | [Autonomi](https://www.autonomi.dev/) flagship product | ~260 lines core**
472
+ **v8.0.1 | [Autonomi](https://www.autonomi.dev/) flagship product | ~410 lines core**
package/VERSION CHANGED
@@ -1 +1 @@
1
- 7.129.5
1
+ 8.0.1
@@ -142,6 +142,43 @@ _write_health() {
142
142
  {"ok": ${ok}, "checked_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"}
143
143
  HEALTH_EOF
144
144
  mv "$tmp_file" "$_APP_RUNNER_DIR/health.json"
145
+
146
+ # TIME TO FIRST PREVIEW (write-once).
147
+ #
148
+ # The single number that most predicts whether someone keeps using a
149
+ # spec-to-product builder is how long they wait before seeing their app
150
+ # actually running. Everything else -- gates, councils, receipts -- is
151
+ # invisible until there is something on screen. We had `started_at` (when
152
+ # the runner launched the app) and `checked_at` (when a probe ran), but no
153
+ # anchor to the START OF THE RUN, so the number a user actually feels
154
+ # could not be derived from what we stored.
155
+ #
156
+ # Recorded ONLY on the first transition to healthy: the elapsed seconds
157
+ # from run start to the app first serving. Write-once by the -f guard, so
158
+ # a later restart cannot overwrite the genuine first-preview time with a
159
+ # warm-start number that flatters the metric.
160
+ #
161
+ # Baseline is the runner's EXISTING _LOKI_RUN_START_EPOCH (exported at
162
+ # run.sh:20014) -- deliberately reusing it rather than adding a second
163
+ # start-time variable that could drift out of agreement with the first.
164
+ # Absent (a direct app-runner call outside a run), this is skipped entirely
165
+ # rather than guessed: a fabricated baseline is worse than no measurement.
166
+ if [ "$ok" = "true" ] \
167
+ && [ ! -f "$_APP_RUNNER_DIR/first-preview.json" ] \
168
+ && [ -n "${_LOKI_RUN_START_EPOCH:-}" ]; then
169
+ local _now_epoch _elapsed
170
+ _now_epoch="$(date +%s 2>/dev/null || echo 0)"
171
+ _elapsed=$(( _now_epoch - _LOKI_RUN_START_EPOCH ))
172
+ # Negative or absurd values mean a bad baseline (clock change, stale
173
+ # export). Record nothing rather than a number nobody can trust.
174
+ if [ "$_elapsed" -ge 0 ] && [ "$_elapsed" -lt 86400 ]; then
175
+ local _fp_tmp="$_APP_RUNNER_DIR/first-preview.json.tmp.$$"
176
+ cat > "$_fp_tmp" << FIRSTPREVIEW_EOF
177
+ {"seconds_to_first_preview": ${_elapsed}, "at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)"}
178
+ FIRSTPREVIEW_EOF
179
+ mv "$_fp_tmp" "$_APP_RUNNER_DIR/first-preview.json" 2>/dev/null || rm -f "$_fp_tmp"
180
+ fi
181
+ fi
145
182
  }
146
183
 
147
184
  # L5 fix (PID-file reuse race): capture a disambiguating identity token for a