@jmtrin/opencode-kevin 1.2.0 → 1.3.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 (141) hide show
  1. package/dist/plugin/index.d.ts +4 -3
  2. package/dist/plugin/index.js +122 -113
  3. package/dist/plugin/native.d.ts +2 -2
  4. package/dist/plugin/native.js +2 -2
  5. package/package.json +56 -68
  6. package/LICENSE +0 -21
  7. package/README.md +0 -605
  8. package/dist/migrations/001_initial.sql +0 -92
  9. package/dist/migrations/002_indexes.sql +0 -14
  10. package/dist/migrations/003_v02_signal.sql +0 -58
  11. package/dist/migrations/004_v03_knowledge.sql +0 -138
  12. package/dist/migrations/005_v04_signal.sql +0 -57
  13. package/dist/migrations/006_v05_glassbox.sql +0 -118
  14. package/dist/migrations/007_v06_pull.sql +0 -145
  15. package/dist/migrations/008_v07_truth.sql +0 -124
  16. package/dist/migrations/009_v08_team.sql +0 -100
  17. package/dist/migrations/010_v09_native.sql +0 -78
  18. package/dist/migrations/011_v10_proven.sql +0 -69
  19. package/dist/migrations/012_v11_drift.sql +0 -24
  20. package/dist/plugin/Archiver.d.ts +0 -42
  21. package/dist/plugin/Archiver.js +0 -83
  22. package/dist/plugin/ArtifactWriter.d.ts +0 -93
  23. package/dist/plugin/ArtifactWriter.js +0 -291
  24. package/dist/plugin/CausalChain.d.ts +0 -22
  25. package/dist/plugin/CausalChain.js +0 -197
  26. package/dist/plugin/ChatBridge.d.ts +0 -41
  27. package/dist/plugin/ChatBridge.js +0 -103
  28. package/dist/plugin/ConflictDetector.d.ts +0 -35
  29. package/dist/plugin/ConflictDetector.js +0 -260
  30. package/dist/plugin/ContextInjector.d.ts +0 -222
  31. package/dist/plugin/ContextInjector.js +0 -533
  32. package/dist/plugin/ConventionMiner.d.ts +0 -35
  33. package/dist/plugin/ConventionMiner.js +0 -242
  34. package/dist/plugin/Curator.d.ts +0 -116
  35. package/dist/plugin/Curator.js +0 -324
  36. package/dist/plugin/DashboardHtml.d.ts +0 -5
  37. package/dist/plugin/DashboardHtml.js +0 -180
  38. package/dist/plugin/Feedback.d.ts +0 -67
  39. package/dist/plugin/Feedback.js +0 -120
  40. package/dist/plugin/HookLiveness.d.ts +0 -88
  41. package/dist/plugin/HookLiveness.js +0 -322
  42. package/dist/plugin/InjectionLedger.d.ts +0 -98
  43. package/dist/plugin/InjectionLedger.js +0 -295
  44. package/dist/plugin/LessonFixer.d.ts +0 -44
  45. package/dist/plugin/LessonFixer.js +0 -45
  46. package/dist/plugin/Materializer.d.ts +0 -83
  47. package/dist/plugin/Materializer.js +0 -181
  48. package/dist/plugin/MemoryService.d.ts +0 -360
  49. package/dist/plugin/MemoryService.js +0 -1242
  50. package/dist/plugin/Migrate.d.ts +0 -17
  51. package/dist/plugin/Migrate.js +0 -271
  52. package/dist/plugin/PatternMiner.d.ts +0 -49
  53. package/dist/plugin/PatternMiner.js +0 -132
  54. package/dist/plugin/QualityGate.d.ts +0 -124
  55. package/dist/plugin/QualityGate.js +0 -119
  56. package/dist/plugin/Reflector.d.ts +0 -91
  57. package/dist/plugin/Reflector.js +0 -307
  58. package/dist/plugin/RepoIdentity.d.ts +0 -124
  59. package/dist/plugin/RepoIdentity.js +0 -300
  60. package/dist/plugin/RepoTruth.d.ts +0 -80
  61. package/dist/plugin/RepoTruth.js +0 -599
  62. package/dist/plugin/Retrospective.d.ts +0 -17
  63. package/dist/plugin/Retrospective.js +0 -216
  64. package/dist/plugin/SharedLayer.d.ts +0 -159
  65. package/dist/plugin/SharedLayer.js +0 -462
  66. package/dist/plugin/Store.d.ts +0 -29
  67. package/dist/plugin/Store.js +0 -50
  68. package/dist/plugin/ToolCallObserver.d.ts +0 -32
  69. package/dist/plugin/ToolCallObserver.js +0 -201
  70. package/dist/plugin/TuiActions.d.ts +0 -43
  71. package/dist/plugin/TuiActions.js +0 -181
  72. package/dist/plugin/TuiSnapshots.d.ts +0 -24
  73. package/dist/plugin/TuiSnapshots.js +0 -158
  74. package/dist/plugin/columns.d.ts +0 -11
  75. package/dist/plugin/columns.js +0 -54
  76. package/dist/plugin/confidence.d.ts +0 -8
  77. package/dist/plugin/confidence.js +0 -34
  78. package/dist/plugin/contract.d.ts +0 -54
  79. package/dist/plugin/contract.js +0 -386
  80. package/dist/plugin/diff.d.ts +0 -8
  81. package/dist/plugin/diff.js +0 -182
  82. package/dist/plugin/escape.d.ts +0 -39
  83. package/dist/plugin/escape.js +0 -60
  84. package/dist/plugin/fingerprint.d.ts +0 -27
  85. package/dist/plugin/fingerprint.js +0 -73
  86. package/dist/plugin/inferability.d.ts +0 -32
  87. package/dist/plugin/inferability.js +0 -88
  88. package/dist/plugin/kevin_approve.d.ts +0 -34
  89. package/dist/plugin/kevin_approve.js +0 -52
  90. package/dist/plugin/kevin_audit.d.ts +0 -229
  91. package/dist/plugin/kevin_audit.js +0 -631
  92. package/dist/plugin/kevin_bench.d.ts +0 -10
  93. package/dist/plugin/kevin_bench.js +0 -82
  94. package/dist/plugin/kevin_conflicts.d.ts +0 -9
  95. package/dist/plugin/kevin_conflicts.js +0 -50
  96. package/dist/plugin/kevin_contract.d.ts +0 -8
  97. package/dist/plugin/kevin_contract.js +0 -59
  98. package/dist/plugin/kevin_doctor.d.ts +0 -62
  99. package/dist/plugin/kevin_doctor.js +0 -196
  100. package/dist/plugin/kevin_facts.d.ts +0 -42
  101. package/dist/plugin/kevin_facts.js +0 -36
  102. package/dist/plugin/kevin_forget.d.ts +0 -33
  103. package/dist/plugin/kevin_forget.js +0 -260
  104. package/dist/plugin/kevin_native.d.ts +0 -29
  105. package/dist/plugin/kevin_native.js +0 -79
  106. package/dist/plugin/kevin_propose.d.ts +0 -23
  107. package/dist/plugin/kevin_propose.js +0 -14
  108. package/dist/plugin/kevin_publish.d.ts +0 -38
  109. package/dist/plugin/kevin_publish.js +0 -18
  110. package/dist/plugin/kevin_why.d.ts +0 -23
  111. package/dist/plugin/kevin_why.js +0 -111
  112. package/dist/plugin/memory-format.d.ts +0 -20
  113. package/dist/plugin/memory-format.js +0 -59
  114. package/dist/plugin/metrics.d.ts +0 -97
  115. package/dist/plugin/metrics.js +0 -288
  116. package/dist/plugin/okf-export.d.ts +0 -3
  117. package/dist/plugin/okf-export.js +0 -134
  118. package/dist/plugin/okf-import.d.ts +0 -76
  119. package/dist/plugin/okf-import.js +0 -271
  120. package/dist/plugin/okf.d.ts +0 -107
  121. package/dist/plugin/okf.js +0 -303
  122. package/dist/plugin/perf.d.ts +0 -35
  123. package/dist/plugin/perf.js +0 -174
  124. package/dist/plugin/query-tokenizer.d.ts +0 -13
  125. package/dist/plugin/query-tokenizer.js +0 -133
  126. package/dist/plugin/redact.d.ts +0 -2
  127. package/dist/plugin/redact.js +0 -18
  128. package/dist/plugin/replay-types.d.ts +0 -69
  129. package/dist/plugin/replay-types.js +0 -156
  130. package/dist/plugin/replay.d.ts +0 -36
  131. package/dist/plugin/replay.js +0 -202
  132. package/dist/plugin/sqlite-adapter.d.ts +0 -12
  133. package/dist/plugin/sqlite-adapter.js +0 -81
  134. package/dist/plugin/time-ms.d.ts +0 -1
  135. package/dist/plugin/time-ms.js +0 -16
  136. package/dist/plugin/tui-types.d.ts +0 -59
  137. package/dist/plugin/tui-types.js +0 -4
  138. package/dist/plugin/tui.d.ts +0 -18
  139. package/dist/plugin/tui.js +0 -198
  140. package/dist/plugin/uuid.d.ts +0 -1
  141. package/dist/plugin/uuid.js +0 -50
package/README.md DELETED
@@ -1,605 +0,0 @@
1
- <div align="center">
2
-
3
- # ⚡ Kevin
4
-
5
- ```
6
- ╔══════════════════════════════════════════════╗
7
- ║ ║
8
- ║ ██╗ ██╗███████╗██╗ ██╗██╗███╗ ██╗ ║
9
- ║ ██║ ██╔╝██╔════╝██║ ██║██║████╗ ██║ ║
10
- ║ █████╔╝ █████╗ ██║ ██║██║██╔██╗ ██║ ║
11
- ║ ██╔═██╗ ██╔══╝ ╚██╗ ██╔╝██║██║╚██╗██║ ║
12
- ║ ██║ ██╗███████╗ ╚████╔╝ ██║██║ ╚████║ ║
13
- ║ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚═╝╚═╝ ╚═══╝ ║
14
- ║ ║
15
- ║ Local-First Memory for OpenCode ║
16
- ║ ║
17
- ╚══════════════════════════════════════════════╝
18
- ```
19
-
20
- ### Local-first memory for OpenCode — it observes, learns, remembers and proves it.
21
-
22
- **Kevin watches. Kevin learns. Kevin remembers.**
23
-
24
- It turns every coding session into durable, confidence-scored knowledge,
25
- injects exactly what matters back into the model's context, curates the best
26
- of it into files you control, and shares it across a team through one
27
- git-friendly file — deterministically, locally, with zero network calls.
28
-
29
- ![version](https://img.shields.io/badge/version-1.1.0-blue)
30
- ![node](https://img.shields.io/badge/node-%E2%89%A522.5-green)
31
- ![tests](https://img.shields.io/badge/tests-1380%20passing-brightgreen)
32
- ![deps](https://img.shields.io/badge/runtime%20deps-1-orange)
33
- ![network](https://img.shields.io/badge/network-zero-black)
34
- ![license](https://img.shields.io/badge/license-MIT-lightgrey)
35
-
36
- </div>
37
-
38
- <!-- uncomment when docs/demo.gif lands
39
- ![demo](docs/demo.gif)
40
- -->
41
-
42
- > **AI agents are good at solving problems. Kevin makes sure they don't have to solve the same problem twice.**
43
-
44
- ---
45
-
46
- ## 📖 Contents
47
-
48
- - [Why Kevin](#-why-kevin)
49
- - [The Kevin loop](#-the-kevin-loop)
50
- - [Quick start](#-quick-start)
51
- - [What's new in 1.1.0](#-whats-new-in-110)
52
- - [What's new in 1.0.0](#-whats-new-in-100)
53
- - [How it works](#-how-it-works)
54
- - [The 26 tools](#-the-26-tools)
55
- - [The benchmark: proven, not promised](#-the-benchmark-proven-not-promised)
56
- - [Curation: from session noise to AGENTS.md](#-curation-from-session-noise-to-agentsmd)
57
- - [Team sharing: one file, zero servers](#-team-sharing-one-file-zero-servers)
58
- - [The contract](#-the-contract)
59
- - [Hooks & latency budgets](#-hooks--latency-budgets)
60
- - [Configuration](#%EF%B8%8F-configuration)
61
- - [Supported runtimes](#-supported-runtimes)
62
- - [Design & trust](#-design--trust)
63
- - [Development](#-development)
64
- - [License](#-license)
65
-
66
- ---
67
-
68
- ## 🤔 Why Kevin
69
-
70
- Every coding session produces experience — errors, fixes, decisions,
71
- conventions, lessons. Without memory, most of it evaporates when the context
72
- window closes: the next session starts near zero and walks straight into the
73
- same wall.
74
-
75
- Kevin closes that loop:
76
-
77
- | 🔍 Observe | 🧠 Learn | 🎯 Recall | ✍️ Curate | 👥 Share | 📏 Prove |
78
- |---|---|---|---|---|---|
79
- | Tool calls, chat messages, session signals | Failures become lessons, causal chains, patterns | Relevant knowledge ranked and injected inside a token budget | The best knowledge becomes human-approved `AGENTS.md` guidance | Curated knowledge travels through one git-friendly file | Latency and retrieval quality are measured, not assumed |
80
-
81
- **Local first, by design.** Your coding experience belongs to you:
82
-
83
- ```
84
- no cloud service · no telemetry · no network calls · no hidden write path
85
- ```
86
-
87
- Knowledge lives in a local SQLite database, is projected into files you
88
- control, and is shared — optionally — through a single file you can read,
89
- diff and review like code.
90
-
91
- ---
92
-
93
- ## 🔁 The Kevin loop
94
-
95
- ```
96
- CODING SESSION
97
-
98
-
99
- 🔍 OBSERVE ────── tool calls, chat signals, failures
100
-
101
-
102
- 🧠 LEARN ─────── lessons, causal chains, patterns
103
-
104
-
105
- 💾 REMEMBER ───── confidence · provenance · recurrence
106
-
107
-
108
- 🎯 RECALL ────── rank → gates → token budget
109
-
110
-
111
- MODEL CONTEXT ──── only what matters now
112
-
113
-
114
- ✍️ CURATE ─────── propose → HUMAN review → approve
115
-
116
-
117
- AGENTS.md
118
-
119
-
120
- NEXT SESSION ─────────────────▶ 🔁
121
- ```
122
-
123
- **Experience compounds instead of evaporating.**
124
-
125
- ---
126
-
127
- ## 🚀 Quick start
128
-
129
- ### 1. Declare the plugin
130
-
131
- ```jsonc
132
- // opencode.json
133
- {
134
- "plugin": ["@jmtrin/opencode-kevin"]
135
- }
136
- ```
137
-
138
- ```bash
139
- npm install @jmtrin/opencode-kevin
140
- ```
141
-
142
- ### 2. Restart OpenCode
143
-
144
- On first boot Kevin migrates its database to schema version `012` and starts
145
- observing. Nothing else is required.
146
-
147
- ### 3. Talk to it
148
-
149
- ```
150
- kevin_status → is everything healthy?
151
- kevin_why → why did this keep failing, and how was it fixed?
152
- kevin_query → what does Kevin remember about X?
153
- kevin_doctor → health report: hooks, deps, perf, verdict
154
- ```
155
-
156
- ### 4. Where data lives
157
-
158
- ```
159
- ~/.opencode-kevin/
160
- ├── kevin.db ← everything Kevin learns (SQLite, WAL)
161
- ├── skills/ ← generated pull channels
162
- ├── refs/ ← topic reference bundles
163
- └── tui/
164
- ├── proposals.json ← pending proposals projection (512 KiB cap)
165
- ├── conflicts.json ← open conflicts projection
166
- ├── health.json ← doctor+perf snapshot
167
- ├── meta.json ← {generatedAt, versions}
168
- ├── dashboard.html ← static review surface (file://, zero network)
169
- ├── actions.json ← mailbox queue (TUI panels → session.idle)
170
- └── results.json ← last action results (audit)
171
-
172
- <repo>/.kevin/
173
- ├── AGENTS.md ← curated knowledge (marker block, human-approved)
174
- └── knowledge.okf ← optional team-sharing file (opt-in)
175
- ```
176
-
177
- ---
178
-
179
- ## 🆕 What's new in 1.1.0 — "Drift"
180
-
181
- > 1.1.0 protects what 1.0.0 proved: a published number without a regression gate is marketing.
182
-
183
- - 🛡️ **Continuous benchmark gate** — `npm run bench:regress` compares the last two `bench/results` against per-metric thresholds (`precision@k` >0.02, `recall` >0.05, `mrr` >0.05 on the `kevin` arm); CI fails when truth drifts.
184
- - 🗑️ **Lifecycle closure — `kevin_forget`** — dry-run default, `confirm:true` archives locally and publishes a tombstone through the single write path; second identical run is a `noop`.
185
- - ⏱️ **Millisecond timestamps** — new `_ms` columns with conservative backfill; `settle()` and `CausalChain` now decide sub-second causality.
186
- - 🧹 **Debt paid** — one `STOP_WORDS` source, one `readOriginCallId`, `ConflictDetector` via `mapRow`, one column-probe registry; every setting has an on-path test.
187
- - 📜 **Public hygiene** — `LICENSE` (MIT), `homepage` filled, `docs/DISTRIBUTION.md` checklist, `scripts/release-notes.mjs` for `gh release create`, and `<!-- demo -->` slot.
188
-
189
- ---
190
-
191
- ## 🆕 What's new in 1.2.0 — "Surface"
192
-
193
- > 1.2.0 gives the human-in-the-loop a place to stand: every pending proposal is readable with its diff without opening an editor, and every approval rides the same gated handler.
194
-
195
- - 🖥️ **Three review surfaces, one projection** — TUI panels (`/kevin` route, `k` to open) where the host renders them, plus a static `dashboard.html` under `~/.opencode-kevin/tui/` that opens via `file://` with zero network, zero fetch, inline CSS/JS and embedded JSON.
196
- - 💬 **Chat-command bridge `/kevin-*` (universal, immediate)** — `/kevin-approve <id> <token>`, `/kevin-reject <id> <token> [note]`, `/kevin-ack <id>` execute through the existing `kevinApprove` / acknowledge handlers; valid commands are swallowed, invalid/stale ones pass through untouched to the model.
197
- - 📦 **Mailbox for TUI panels (idle-latency)** — proposals approved from the TUI write `~/.opencode-kevin/tui/actions.json`; the session consumes it at the next `session.idle` before `curator.propose`, then refreshes snapshots (`tui_snapshots_enabled='1'`).
198
- - ⏱️ **Latency honesty** — chat commands apply this turn; mailbox actions apply at next idle. Both disclosed in-surface (`queued — applies at session idle` toast, copy hint on dashboard).
199
- - 📦 **Packaging** — new export `opencode-kevin/tui` (`dist/plugin/tui.*`), `engines.opencode ^1.18.0` validated by the host with skip-with-warning.
200
-
201
- | Surface | Review | Action | Latency |
202
- |---|---|---|---|
203
- | TUI panel (`/kevin`) — CLI/TUI host | Proposals / Conflicts / Health tabs, diff dialog, truncation markers | `a` approve / `r` reject / `x` ack → mailbox | next idle |
204
- | Static dashboard (`dashboard.html`) | Proposals (+escaped diff `<pre>`), conflicts two-column, health banner | Copy `/kevin-*` button → paste into chat input | immediate (chat bridge) |
205
- | Any client (Desktop, CLI) | — | Type `/kevin-approve …` etc in chat input | immediate |
206
-
207
- Snapshots + dashboard are capped at 512 KiB (diff truncation with `truncated:true`), written atomically via `tmp`+`rename`, and read best-effort with empty-state explanations (`no snapshots yet — open an opencode session…`) when missing/corrupt/stale-token.
208
-
209
- ---
210
-
211
- ## 🆕 What's new in 1.0.0
212
-
213
- > 1.0.0 is the **proven release**: the surface is frozen as data, the cost is
214
- > measured, the value is benchmarked — reproducibly.
215
-
216
- - ❄️ **A frozen public contract** — nine clauses (`C-01` … `C-09`) derived from
217
- live source, digest-stamped, enforced by an append-only golden file.
218
- Inspect it live with `kevin_contract`.
219
- - ⏱️ **Latency budgets** — eight instrumented scopes; `npm run bench:check`
220
- fails if any scope exceeds its p95 budget. `dispose` joins as the seventh
221
- hook with crash-safe deferred settlement.
222
- - 📊 **A reproducible benchmark** — committed synthetic corpus, four arms,
223
- committed result. See [below](#-the-benchmark-proven-not-promised).
224
- - 🛡️ **An untrusted-input boundary** — everything reaching an artifact or
225
- prompt is escaped at the single write path; stored text is never trusted.
226
- - 📦 **A corrected published package** — types-first exports, `dist/` only,
227
- verified against the packed tarball by `npm run verify:pack`.
228
-
229
- ---
230
-
231
- ## ⚙️ How it works
232
-
233
- Kevin is an intentionally deterministic pipeline — no LLM in the core loop:
234
-
235
- ```
236
- your coding session
237
-
238
-
239
- ┌────────────────────────────────────────────┐
240
- │ 🔍 OBSERVE │
241
- │ tool.execute.before/after · chat.message │
242
- │ Failures auto-detected from exit codes, │
243
- │ stderr and stdout markers. │
244
- └──────────────────┬─────────────────────────┘
245
-
246
- ┌────────────────────────────────────────────┐
247
- │ 🧠 LEARN │
248
- │ Reflector → lessons │
249
- │ CausalChain → failure/fix links │
250
- │ PatternMiner → repeated sequences │
251
- │ Evidence raises confidence; recurrence │
252
- │ lowers it and flags staleness. │
253
- └──────────────────┬─────────────────────────┘
254
-
255
- ┌────────────────────────────────────────────┐
256
- │ 🎯 INJECT │
257
- │ QualityGate → BM25 × origin × recency × │
258
- │ truth penalty → token-budget fit │
259
- │ Deduped per session, inside <kevin-context>│
260
- └──────────────────┬─────────────────────────┘
261
-
262
- ┌────────────────────────────────────────────┐
263
- │ ✍️ CURATE │
264
- │ propose → HUMAN REVIEW → approve │
265
- │ Nothing writes without approval. │
266
- └──────────────────┬─────────────────────────┘
267
-
268
- ┌────────────────────────────────────────────┐
269
- │ 📏 PROVE │
270
- │ perf budgets · retrieval benchmark · │
271
- │ contract digest │
272
- │ The system measures itself instead of │
273
- │ merely claiming to work. │
274
- └────────────────────────────────────────────┘
275
- ```
276
-
277
- ---
278
-
279
- ## 🧰 The 26 tools
280
-
281
- <details open>
282
- <summary><b>🧠 Core memory</b></summary>
283
-
284
- | Tool | What it does |
285
- |---|---|
286
- | `kevin_save` | Store a memory: decision, rule, pattern, context or solution |
287
- | `kevin_query` | Search memories — slim payload; `evidence: true` exposes confidence |
288
- | `kevin_get` | Fetch one memory in full |
289
- | `kevin_recall` | Ranked recall with origin-aware scoring |
290
- | `kevin_status` | Session scoreboard: counts, precision, metrics |
291
- | `kevin_config` | List/set any of the 31 settings — no SQL required |
292
- | `kevin_project` | Show, initialize or rekey the repository identity |
293
-
294
- </details>
295
-
296
- <details>
297
- <summary><b>🔎 Understanding & debugging</b></summary>
298
-
299
- | Tool | What it does |
300
- |---|---|
301
- | `kevin_why` | Failure→fix trace for a recurring error, with confidence and evidence |
302
- | `kevin_trace` | Dry-run: exactly what would be injected for a query, zero side effects |
303
- | `kevin_feedback` | Rate an injected memory `useful` / `wrong` / `outdated` / `ignore` |
304
- | `kevin_conflicts` | Surface contradictions between memories and repository truth |
305
- | `kevin_facts` | Scan the repository for ground-truth facts |
306
- | `kevin_retrospective` | Per-session markdown retrospective |
307
-
308
- </details>
309
-
310
- <details>
311
- <summary><b>✍️ Curation & publishing</b></summary>
312
-
313
- | Tool | What it does |
314
- |---|---|
315
- | `kevin_propose` | Dry-run curation proposals with unified diffs — writes nothing |
316
- | `kevin_approve` | The **only** path that writes `AGENTS.md` (or rejects) |
317
- | `kevin_publish` | Regenerate skill/ref pull bundles under `~/.opencode-kevin/` |
318
-
319
- </details>
320
-
321
- <details>
322
- <summary><b>👥 Team & operations</b></summary>
323
-
324
- | Tool | What it does |
325
- |---|---|
326
- | `kevin_share` | Promote curated memories into `.kevin/knowledge.okf` (approval-gated) |
327
- | `kevin_sync` | Import the shared file into the local layer |
328
- | `kevin_export` / `kevin_import` | Markdown/OKF bundles out and in |
329
- | `kevin_audit` | Whole-system report: memories, injections, channels, team, perf, contract |
330
- | `kevin_doctor` | Health verdict: `healthy` / `degraded` / `unknown`, with reasons |
331
- | `kevin_native` | Show/enable/disable native host registration (default off) |
332
- | `kevin_contract` | **v1.0.0** — inspect the frozen public surface at runtime |
333
- | `kevin_bench` | **v1.0.0** — report benchmark results; never runs them in-session |
334
-
335
- </details>
336
-
337
- ---
338
-
339
- ## 📊 The benchmark: proven, not promised
340
-
341
- Kevin ships a committed synthetic corpus and a four-arm harness measuring
342
- whether real retrieval beats trivial baselines at surfacing labelled-relevant
343
- memories:
344
-
345
- ```
346
- bench/corpus/
347
- seed: 1262835273 (xorshift32, byte-for-byte regenerable)
348
- digest: adecbdf4c7af82e2
349
- result: bench/results/2026-08-21-adecbdf4c7af82e2.json (k = 5)
350
- ```
351
-
352
- ```
353
- npm run bench # run the harness (also persists one row per arm)
354
- npm run bench:check # gate: every perf scope within its p95 budget
355
- npm run verify:pack # gate: seven properties against the packed tarball
356
- ```
357
-
358
- | Arm | Precision@5 | Recall@5 | MRR |
359
- |---|---:|---:|---:|
360
- | `none` (control) | 0.000 | 0.000 | 0.000 |
361
- | `recent-k` (baseline) | 0.050 | 0.026 | 0.109 |
362
- | `random-k` (floor) | 0.048 | 0.028 | 0.093 |
363
- | **`kevin`** | **0.950** | **0.546** | **1.000** |
364
-
365
- ```
366
- Precision@5 Recall@5 MRR
367
- 0.950 ██████████████████░░ 0.546 ██████████░░░░ 1.000 ████████████████████
368
- 0.050 █░░░░░░░░░░░░░░░░░░░ 0.026 █░░░░░░░░░░░░░ 0.109 ██░░░░░░░░░░░░░░░░░░
369
- ```
370
-
371
- The labelling rule is mechanical and the retrieval numbers are exactly
372
- reproducible — asserted by running the harness twice in-process.
373
-
374
- **Honest limits, stated up front.** This benchmark measures retrieval on a
375
- synthetic corpus built to have a ranked answer; it does **not** prove that real sessions look like this synthetic corpus. It does not prove that a surfaced memory changed what the model did. Retrieval quality is one layer of the agent loop, not the whole of it.
376
-
377
- ---
378
-
379
- ## ✍️ Curation: from session noise to AGENTS.md
380
-
381
- Knowledge worth keeping becomes a proposal; a human decides; only then is it
382
- written — once, atomically, inside a marker pair you can edit around:
383
-
384
- ```
385
- memories ──▶ kevin_propose ──▶ pending proposals (unified diffs, no writes)
386
-
387
- HUMAN REVIEW
388
-
389
- ┌── approve ────┴──── reject ──▶ decision recorded
390
- ▼ nothing written
391
- AGENTS.md updated atomically ◀── the single write path (D6-01)
392
- ```
393
-
394
- ```markdown
395
- <!-- kevin:begin — curated by opencode-kevin, safe to edit -->
396
- - Always run `npm run typecheck` before committing (fixed 3 CI failures)
397
- <!-- kevin:end -->
398
- ```
399
-
400
- Deliberately conservative: only non-inferable memories are eligible — an
401
- LLM-recoverable diagnostic is not something a human should have to review into
402
- a permanent rule. Re-applying an unchanged plan is a counted noop, never a
403
- write. **Kevin can propose. Humans decide.**
404
-
405
- ---
406
-
407
- ## 👥 Team sharing: one file, zero servers
408
-
409
- Opt-in via `shared_layer_enabled='1'`. Curated knowledge exports to one
410
- `.kevin/knowledge.okf` — header lines plus one JSON entry per line, sorted by a
411
- deterministic `entry_id`, LF-only, ≤4096 bytes per line — designed so git
412
- merges are meaningful and conflicts are parseable:
413
-
414
- ```
415
- DEV A DEV B
416
- │ share (approval-gated) │ git pull
417
- ▼ ▼
418
- knowledge.okf ◀═══════ git ══════▶ knowledge.okf
419
- │ kevin_sync
420
-
421
- projected into local memories
422
- (layer='shared', immutable)
423
- ```
424
-
425
- Repository identity resolves **once**, in order:
426
- `.kevin/project.json` (declared) → git remote hash (never a raw URL) → path.
427
- Two clones of the same repository are one team; different repositories never
428
- leak into each other. Sharing requires explicit approval
429
- (`share_requires_approval='1'`), author identity is hashed by default, and
430
- tombstones archive rather than delete.
431
-
432
- ---
433
-
434
- ## 📜 The contract
435
-
436
- Kevin 1.x makes promises about its published surface **in writing**.
437
- [`docs/CONTRACT.md`](docs/CONTRACT.md) freezes nine clauses — `C-01` … `C-09` —
438
- from the `AGENTS.md` marker bytes to the database schema, each tagged `frozen`
439
- or `forward-only` and stamped with the release that incurred the obligation. A
440
- test diffs the live contract against an append-only golden file on every run:
441
- removals and silent changes fail loudly; additions must carry `since`.
442
-
443
- ```jsonc
444
- // kevin_contract (excerpt)
445
- {
446
- "contract_version": 1,
447
- "digest": "1de9740bba2e9f95",
448
- "clauses": [
449
- { "id": "C-03", "title": "Tool names and argument shapes", "stability": "frozen", "since": "0.2.0" },
450
- { "id": "C-07", "title": "Database schema", "stability": "forward-only", "since": "0.1.0" }
451
- ]
452
- }
453
- ```
454
-
455
- > 1.0.0 is not just a version number — it is where Kevin starts making explicit, testable promises about its surface.
456
-
457
- ---
458
-
459
- ## ⏱️ Hooks & latency budgets
460
-
461
- Six host hooks plus Kevin's own `dispose` checkpoint — eight measured scopes,
462
- each with a declared p95/max budget enforced by `npm run bench:check`:
463
-
464
- | Scope | p95 budget | max |
465
- |---|---:|---:|
466
- | `tool.execute.before` | 2 ms | 10 ms |
467
- | `tool.execute.after` | 5 ms | 25 ms |
468
- | `chat.message` | 2 ms | 10 ms |
469
- | `chat.system.transform` | 15 ms | 50 ms |
470
- | `session.compacting` | 15 ms | 50 ms |
471
- | `event` | 5 ms | 25 ms |
472
- | `session.idle` | 150 ms | 600 ms |
473
- | `dispose` | 50 ms | 250 ms |
474
-
475
- Measured on the reference laptop: retrieval p50 ≈ 0.2 ms, p95 < 1 ms — orders
476
- of magnitude under budget. Samples persist to `perf_samples` at idle; a breach
477
- degrades `kevin_doctor`'s verdict, because a plugin that is technically alive
478
- but consistently slow is not healthy.
479
-
480
- ---
481
-
482
- ## ⚙️ Configuration
483
-
484
- Everything is a TEXT setting managed through `kevin_config` (or any SQLite
485
- client). All values are TEXT — flags compare with `=== "1"`, never truthiness.
486
-
487
- | Key | Default | Purpose |
488
- |---|---|---|
489
- | `quality_gate_enabled` | `'1'` | Weak lessons stored but never injected |
490
- | `lesson_snippet_injection` | `'1'` | Compact 2-line snippets instead of full bodies |
491
- | `patternminer_enabled` | `'0'` | Deterministic tool-sequence mining (≥5 sessions) |
492
- | `cross_project_enabled` | `'0'` | Include imported cross-project rows |
493
- | `llm_reflection_enabled` | `'0'` | Opt-in LLM enrichment at pattern promotion |
494
- | `tool_calls_dedup_enabled` | `'0'` | Suppress duplicate call recordings per minute bucket |
495
- | `deterministic_retrieval` | `'0'` | Freeze the clock for hermetic tests/replay |
496
- | `pre_prompt_budget_tokens` | `'400'` | Pre-prompt injection cap (clamped `[0, 4000]`) |
497
- | `archive_after_days` | `'30'` | Age threshold for idle archival |
498
- | `curation_enabled` | `'1'` | Idle dry-run proposal generation |
499
- | `agents_md_path` | `'AGENTS.md'` | Where curated knowledge lands |
500
- | `skill_emission_enabled` | `'0'` | Register project-knowledge skill on v2 hosts |
501
- | `reference_emission_enabled` | `'0'` | Register `@kevin/<topic>` mentions |
502
- | `injection_confidence_floor` | `'0.6'` | Memories below this never inject |
503
- | `repo_truth_enabled` | `'0'` | Repository fact scanning |
504
- | `convention_mining_enabled` | `'0'` | Deterministic convention mining |
505
- | `conflict_detection_enabled` | `'0'` | Contradiction surfacing |
506
- | `error_lesson_mode` | `'all'` | Error lesson injection mode |
507
- | `shared_layer_enabled` | `'0'` | Team sharing via `.kevin/knowledge.okf` |
508
- | `okf_path` | `'.kevin/knowledge.okf'` | Shared file location |
509
- | `share_requires_approval` | `'1'` | No export without human confirmation |
510
- | `author_identity_mode` | `'hashed'` | Author identity hashed, never raw email |
511
- | `shared_confidence_floor` | `'0.7'` | Confidence floor for shared projections |
512
- | `hook_liveness_enabled` | `'1'` | Per-hook liveness tracking |
513
- | `native_registration_enabled` | `'0'` | v2 native skill/reference registration |
514
- | `host_probe_history_enabled` | `'0'` | Append-only probe history |
515
- | `dead_hook_report_threshold` | `'3'` | Consecutive misses before a hook reads dead |
516
- | `perf_enabled` | `'1'` | Latency instrumentation |
517
- | `perf_ring_capacity` | `'512'` | Samples per scope (clamped `[64, 8192]`) |
518
- | `perf_flush_on_idle` | `'1'` | Persist samples at idle |
519
- | `contract_report_enabled` | `'1'` | Contract block in `kevin_audit` |
520
- | `tui_snapshots_enabled` | `'1'` | Snapshot + dashboard flush at idle (opencode-kevin/tui) |
521
-
522
- ---
523
-
524
- ## 🖥️ Supported runtimes
525
-
526
- | Runtime | SQLite backend | Status |
527
- |---|---|---|
528
- | Node 24.x | `node:sqlite` (stable) | ✅ **Supported** — the reference row |
529
- | Node 22.5+ | `better-sqlite3` (optional dep) | ⚠️ **Supported with a caveat** — needs a build toolchain; without one there is no backend (and npm install still succeeds silently) |
530
- | Node 22.5+ | `node:sqlite` behind `--experimental-sqlite` | 🔶 Works, unsupported — exercised in CI, not promised |
531
- | Bun ≥ 1.1 | `bun:sqlite` | ✅ **Supported** — smoke-tested in `npm run verify` |
532
-
533
- Zero process spawns, zero network calls — asserted by source scan on every
534
- test run.
535
-
536
- ---
537
-
538
- ## 🎨 Design & trust
539
-
540
- **Principles.** Local first · deterministic by default (no LLM in the core
541
- loop) · evidence over vibes (every memory carries evidence, provenance,
542
- recurrence and confidence) · signal over noise (inject *less, better* context,
543
- not more) · humans hold the write boundary · git-friendly collaboration ·
544
- important claims become executable checks.
545
-
546
- **Security model.** Stored knowledge is treated as untrusted input: anything
547
- reaching an artifact or prompt passes through idempotent escaping at the
548
- single write path; permanent project-file changes require explicit human
549
- approval; author identity in the shared layer is hashed
550
- (`author_identity_mode='hashed'`). No network service is required to store,
551
- retrieve or share knowledge.
552
-
553
- **Without memory vs with Kevin:**
554
-
555
- ```
556
- without: session 1 solve ─▶ context closes ─▶ session 2 same problem ─▶ solve again
557
-
558
- with: session 1 solve ─▶ lesson ─▶ memory ─┐
559
- session 2 problem ◀── recall ◀───────┘ ─▶ fix ─▶ evidence ↑
560
- ```
561
-
562
- **Why not just `AGENTS.md`?** It is excellent for durable, human-authored
563
- guidance — Kevin treats it as a curated destination, not as a memory system.
564
- It cannot do failure/fix traces, confidence scoring, evidence tracking, ranked
565
- retrieval, recurrence signals, dry-run injection inspection, automatic
566
- proposal generation, team projections, or performance and contract
567
- instrumentation. That is what Kevin adds around it.
568
-
569
- ---
570
-
571
- ## 🛠️ Development
572
-
573
- ```bash
574
- npm install
575
- npm run typecheck # tsc --noEmit (strict)
576
- npm run lint # biome
577
- npm test # vitest — 1374 tests across 190 files
578
- npm run verify # install checks + Bun smoke + verify:pack
579
- npm run gen:corpus # regenerate the seeded corpus (byte-identical)
580
- npm run replay # replay recorded sessions deterministically
581
- ```
582
-
583
- Project layout:
584
-
585
- ```
586
- plugin/ 53 modules — Store, MemoryService, Reflector, Perf, Contract, columns, kevin_forget …
587
- migrations/ 001 → 012 — additive, idempotent, forward-only forever
588
- scripts/ bench · gen-corpus · verify-pack · verify-install · …
589
- tests/ unit · integration · e2e · replay fixtures
590
- bench/ committed corpus + committed results
591
- docs/ CONTRACT.md · per-release plans/tasks · roadmap
592
- ```
593
-
594
- ---
595
-
596
- ## 📄 License
597
-
598
- MIT — see the package manifest. Kevin is built by [jmtrin](https://github.com/jmtrin);
599
- bug reports and PRs welcome at the [issue tracker](https://github.com/jmtrin/opencode-kevin/issues).
600
-
601
- <div align="center">
602
-
603
- ### ⚡ Kevin — *Observe. Learn. Remember. Improve.*
604
-
605
- </div>