@jmtrin/opencode-kevin 0.6.0 → 0.8.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.
- package/README.md +771 -580
- package/dist/migrations/001_initial.sql +91 -91
- package/dist/migrations/003_v02_signal.sql +57 -57
- package/dist/migrations/004_v03_knowledge.sql +138 -138
- package/dist/migrations/005_v04_signal.sql +57 -57
- package/dist/migrations/006_v05_glassbox.sql +118 -118
- package/dist/migrations/007_v06_pull.sql +144 -144
- package/dist/migrations/008_v07_truth.sql +124 -0
- package/dist/migrations/009_v08_team.sql +100 -0
- package/dist/plugin/ArtifactWriter.d.ts +28 -0
- package/dist/plugin/ArtifactWriter.js +35 -2
- package/dist/plugin/ArtifactWriter.js.map +1 -1
- package/dist/plugin/ConflictDetector.d.ts +35 -0
- package/dist/plugin/ConflictDetector.js +283 -0
- package/dist/plugin/ConflictDetector.js.map +1 -0
- package/dist/plugin/ContextInjector.d.ts +9 -0
- package/dist/plugin/ContextInjector.js +14 -3
- package/dist/plugin/ContextInjector.js.map +1 -1
- package/dist/plugin/ConventionMiner.d.ts +35 -0
- package/dist/plugin/ConventionMiner.js +243 -0
- package/dist/plugin/ConventionMiner.js.map +1 -0
- package/dist/plugin/Curator.d.ts +22 -2
- package/dist/plugin/Curator.js +101 -28
- package/dist/plugin/Curator.js.map +1 -1
- package/dist/plugin/InjectionLedger.d.ts +6 -0
- package/dist/plugin/InjectionLedger.js +6 -0
- package/dist/plugin/InjectionLedger.js.map +1 -1
- package/dist/plugin/Materializer.d.ts +4 -5
- package/dist/plugin/Materializer.js +9 -6
- package/dist/plugin/Materializer.js.map +1 -1
- package/dist/plugin/MemoryService.d.ts +49 -2
- package/dist/plugin/MemoryService.js +306 -8
- package/dist/plugin/MemoryService.js.map +1 -1
- package/dist/plugin/Migrate.js +61 -2
- package/dist/plugin/Migrate.js.map +1 -1
- package/dist/plugin/Reflector.js +13 -0
- package/dist/plugin/Reflector.js.map +1 -1
- package/dist/plugin/RepoIdentity.d.ts +113 -0
- package/dist/plugin/RepoIdentity.js +266 -0
- package/dist/plugin/RepoIdentity.js.map +1 -0
- package/dist/plugin/RepoTruth.d.ts +80 -0
- package/dist/plugin/RepoTruth.js +600 -0
- package/dist/plugin/RepoTruth.js.map +1 -0
- package/dist/plugin/Retrospective.js +17 -0
- package/dist/plugin/Retrospective.js.map +1 -1
- package/dist/plugin/SharedLayer.d.ts +159 -0
- package/dist/plugin/SharedLayer.js +463 -0
- package/dist/plugin/SharedLayer.js.map +1 -0
- package/dist/plugin/index.d.ts +36 -2
- package/dist/plugin/index.js +591 -10
- package/dist/plugin/index.js.map +1 -1
- package/dist/plugin/kevin_approve.js +7 -4
- package/dist/plugin/kevin_approve.js.map +1 -1
- package/dist/plugin/kevin_audit.d.ts +59 -1
- package/dist/plugin/kevin_audit.js +190 -3
- package/dist/plugin/kevin_audit.js.map +1 -1
- package/dist/plugin/kevin_conflicts.d.ts +9 -0
- package/dist/plugin/kevin_conflicts.js +51 -0
- package/dist/plugin/kevin_conflicts.js.map +1 -0
- package/dist/plugin/kevin_facts.d.ts +42 -0
- package/dist/plugin/kevin_facts.js +37 -0
- package/dist/plugin/kevin_facts.js.map +1 -0
- package/dist/plugin/metrics.d.ts +3 -3
- package/dist/plugin/metrics.js +21 -2
- package/dist/plugin/metrics.js.map +1 -1
- package/dist/plugin/okf-export.d.ts +2 -2
- package/dist/plugin/okf-export.js +15 -7
- package/dist/plugin/okf-export.js.map +1 -1
- package/dist/plugin/okf.d.ts +107 -0
- package/dist/plugin/okf.js +304 -0
- package/dist/plugin/okf.js.map +1 -0
- package/dist/plugin/replay-types.d.ts +29 -287
- package/dist/plugin/replay-types.js +145 -53
- package/dist/plugin/replay-types.js.map +1 -1
- package/migrations/001_initial.sql +91 -91
- package/migrations/003_v02_signal.sql +57 -57
- package/migrations/004_v03_knowledge.sql +138 -138
- package/migrations/005_v04_signal.sql +57 -57
- package/migrations/006_v05_glassbox.sql +118 -118
- package/migrations/007_v06_pull.sql +144 -144
- package/migrations/008_v07_truth.sql +124 -0
- package/migrations/009_v08_team.sql +100 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,580 +1,771 @@
|
|
|
1
|
-
# Kevin
|
|
2
|
-
|
|
3
|
-
> Observe and learn: the learning layer OpenCode was missing.
|
|
4
|
-
|
|
5
|
-
Kevin is an [OpenCode](https://opencode.ai) plugin that **observes** every agent tool call, **learns** from failures by generating lessons, and **shares** what it learned proactively in future sessions. It does not plan, orchestrate, or compete with the plugin ecosystem. It only learns.
|
|
6
|
-
|
|
7
|
-
- **Local-first**: SQLite + FTS5, no external services, no network calls.
|
|
8
|
-
- **Global memory**: a single `~/.opencode-kevin/kevin.db` shared across all your projects (WAL mode → safe for concurrent sessions). No per-project folders.
|
|
9
|
-
- **Knowledge + Causality**: causal failure→fix chains, `kevin_why` explanations, OKF export/import, a supersede model, and human-in-the-loop AGENTS.md suggestions.
|
|
10
|
-
- **Signal over Noise**: a quality gate that stores weak lessons without injecting them, an injection ledger with honest `precision_rate`, and two-sided confidence.
|
|
11
|
-
- **Glass Box**: honest measurement replaces estimates — three-way injection settlement (`effective` / `ineffective` / `inconclusive`), human feedback that actually moves confidence, a strict dry-run `kevin_trace`, a read-only `kevin_audit`, and a hermetic replay harness.
|
|
12
|
-
- **Pull**: knowledge earns its way into files the model actually reads — `kevin_propose` generates a reviewable diff, a human approves, and **only then** does Kevin write, inside a frozen marker block, preserving your file's CRLF/BOM/formatting byte-for-byte outside it. Plus three distribution channels (AGENTS.md, skills, references) and a push budget gated by a confidence floor.
|
|
13
|
-
- **Audited**: the v0.4.0 bug catalog (`docs/Kevin_v0.4.0_Bugs.md`) is fully closed — 16/16 bugs fixed and regression-tested.
|
|
14
|
-
- **Standalone**: works without any other plugin. With the ecosystem, it learns more richly.
|
|
15
|
-
|
|
16
|
-
---
|
|
17
|
-
|
|
18
|
-
## Contents
|
|
19
|
-
|
|
20
|
-
- [Installation](#installation)
|
|
21
|
-
- [How Kevin works](#how-kevin-works)
|
|
22
|
-
- [Tools](#tools)
|
|
23
|
-
- [How Kevin measures itself](#how-kevin-measures-itself)
|
|
24
|
-
- [Curation & Pull](#curation--pull)
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
28
|
-
- [
|
|
29
|
-
- [
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
>
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
│
|
|
122
|
-
│
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
│
|
|
131
|
-
|
|
132
|
-
│
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
//
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
//
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
//
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
//
|
|
213
|
-
// "
|
|
214
|
-
//
|
|
215
|
-
//
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
//
|
|
225
|
-
//
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
```
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
### `
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
### `
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
```
|
|
269
|
-
|
|
270
|
-
// → { "
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
```
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
//
|
|
296
|
-
//
|
|
297
|
-
// "
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
//
|
|
309
|
-
//
|
|
310
|
-
//
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
//
|
|
320
|
-
//
|
|
321
|
-
//
|
|
322
|
-
//
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
```
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
Kevin
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
|
483
|
-
|
|
484
|
-
| `
|
|
485
|
-
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
1
|
+
# Kevin
|
|
2
|
+
|
|
3
|
+
> Observe and learn: the learning layer OpenCode was missing.
|
|
4
|
+
|
|
5
|
+
Kevin is an [OpenCode](https://opencode.ai) plugin that **observes** every agent tool call, **learns** from failures by generating lessons, and **shares** what it learned proactively in future sessions. It does not plan, orchestrate, or compete with the plugin ecosystem. It only learns.
|
|
6
|
+
|
|
7
|
+
- **Local-first**: SQLite + FTS5, no external services, no network calls.
|
|
8
|
+
- **Global memory**: a single `~/.opencode-kevin/kevin.db` shared across all your projects (WAL mode → safe for concurrent sessions). No per-project folders.
|
|
9
|
+
- **Knowledge + Causality**: causal failure→fix chains, `kevin_why` explanations, OKF export/import, a supersede model, and human-in-the-loop AGENTS.md suggestions.
|
|
10
|
+
- **Signal over Noise**: a quality gate that stores weak lessons without injecting them, an injection ledger with honest `precision_rate`, and two-sided confidence.
|
|
11
|
+
- **Glass Box**: honest measurement replaces estimates — three-way injection settlement (`effective` / `ineffective` / `inconclusive`), human feedback that actually moves confidence, a strict dry-run `kevin_trace`, a read-only `kevin_audit`, and a hermetic replay harness.
|
|
12
|
+
- **Pull**: knowledge earns its way into files the model actually reads — `kevin_propose` generates a reviewable diff, a human approves, and **only then** does Kevin write, inside a frozen marker block, preserving your file's CRLF/BOM/formatting byte-for-byte outside it. Plus three distribution channels (AGENTS.md, skills, references) and a push budget gated by a confidence floor.
|
|
13
|
+
- **Audited**: the v0.4.0 bug catalog (`docs/Kevin_v0.4.0_Bugs.md`) is fully closed — 16/16 bugs fixed and regression-tested; the v0.8.0 release audit closed 8/8 bugs (repo identity, session coherence through rekey, port normalization in remotes, refusal semantics, read-path `layer`).
|
|
14
|
+
- **Standalone**: works without any other plugin. With the ecosystem, it learns more richly.
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## Contents
|
|
19
|
+
|
|
20
|
+
- [Installation](#installation)
|
|
21
|
+
- [How Kevin works](#how-kevin-works)
|
|
22
|
+
- [Tools](#tools)
|
|
23
|
+
- [How Kevin measures itself](#how-kevin-measures-itself)
|
|
24
|
+
- [Curation & Pull](#curation--pull)
|
|
25
|
+
- [The shared layer (v0.8.0)](#the-shared-layer-v080)
|
|
26
|
+
- [Replay harness](#replay-harness)
|
|
27
|
+
- [Hooks](#hooks)
|
|
28
|
+
- [Configuration](#configuration)
|
|
29
|
+
- [Development](#development)
|
|
30
|
+
- [License](#license)
|
|
31
|
+
|
|
32
|
+
---
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
### 1. Declare the plugin
|
|
37
|
+
|
|
38
|
+
Add Kevin to your OpenCode config. For **all projects** (global):
|
|
39
|
+
|
|
40
|
+
```jsonc
|
|
41
|
+
// ~/.config/opencode/opencode.jsonc
|
|
42
|
+
{
|
|
43
|
+
"$schema": "https://opencode.ai/config.json",
|
|
44
|
+
"plugin": [
|
|
45
|
+
"@jmtrin/opencode-kevin@latest"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
For a **single project**, put the same `plugin` array in `./opencode.json` or `.opencode/opencode.json` at the project root.
|
|
51
|
+
|
|
52
|
+
### 2. Restart OpenCode
|
|
53
|
+
|
|
54
|
+
Config is loaded once at startup and is **not hot-reloaded** — quit and reopen OpenCode after editing. On start, Kevin exposes 21 tools, including `kevin_facts`, `kevin_conflicts`, `kevin_project`, `kevin_share` and `kevin_sync`.
|
|
55
|
+
|
|
56
|
+
Contradictions de-rank memories and surface conflicts. They never delete, stale, archive, or auto-resolve a memory.
|
|
57
|
+
|
|
58
|
+
### 3. Where data lives
|
|
59
|
+
|
|
60
|
+
Kevin stores everything in a single **global, shared** location under your home directory — no per-project `.kevin/` folders:
|
|
61
|
+
|
|
62
|
+
| Path | Content |
|
|
63
|
+
|---|---|
|
|
64
|
+
| `~/.opencode-kevin/kevin.db` | SQLite database (memories, tool calls, retrospectives). WAL mode → safe for concurrent OpenCode sessions across projects. |
|
|
65
|
+
| `~/.opencode-kevin/retrospectives/<session>.md` | Per-session retrospective markdown. |
|
|
66
|
+
|
|
67
|
+
Migrations run automatically on startup.
|
|
68
|
+
|
|
69
|
+
### Requirements
|
|
70
|
+
|
|
71
|
+
- **Node.js >= 22.5** (uses `node:sqlite`, the built-in SQLite module — no native binaries to compile).
|
|
72
|
+
- OpenCode with plugin support (`@opencode-ai/plugin` >= 1.17).
|
|
73
|
+
|
|
74
|
+
> **Runtimes**:
|
|
75
|
+
> - **Bun**: uses `bun:sqlite` (built-in).
|
|
76
|
+
> - **Node 24+**: uses `node:sqlite` directly, no flags needed (emits an experimental warning, harmless).
|
|
77
|
+
> - **Node 22/23 without `--experimental-sqlite` flag** or **Node 20**: falls back to `better-sqlite3`, declared as `optionalDependencies`. If you need it, install it manually in your opencode config directory (`~/.config/opencode/`): `npm install better-sqlite3`.
|
|
78
|
+
|
|
79
|
+
### Verification
|
|
80
|
+
|
|
81
|
+
```bash
|
|
82
|
+
npm run verify
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Checks Node version, SQLite, migration, MemoryService save/query, Reflector, ContextInjector, and TypeScript strict mode.
|
|
86
|
+
|
|
87
|
+
### Advanced (optional)
|
|
88
|
+
|
|
89
|
+
Override defaults via the plugin tuple form:
|
|
90
|
+
|
|
91
|
+
```jsonc
|
|
92
|
+
{
|
|
93
|
+
"plugin": [
|
|
94
|
+
["@jmtrin/opencode-kevin", {
|
|
95
|
+
"dbPath": "/custom/path/kevin.db",
|
|
96
|
+
"retrospectivesDir": "/custom/path/retrospectives",
|
|
97
|
+
"throttleMs": 120000
|
|
98
|
+
}]
|
|
99
|
+
]
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Use `:memory:` for `dbPath` in tests.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## How Kevin works
|
|
108
|
+
|
|
109
|
+
Every tool call is observed; every failure becomes a lesson; every lesson is either pushed into the next prompt, written into an artifact a human approved, or retired when it stops earning its place.
|
|
110
|
+
|
|
111
|
+
```
|
|
112
|
+
Tool call (success or failure)
|
|
113
|
+
│
|
|
114
|
+
▼
|
|
115
|
+
┌─────────────────────────┐ OBSERVE
|
|
116
|
+
│ ToolCallObserver │ records every call (tool, redacted args,
|
|
117
|
+
└───────────┬─────────────┘ success, duration, error type, dedup)
|
|
118
|
+
│
|
|
119
|
+
failure │ success
|
|
120
|
+
┌──────────▼───────────┐ ┌─────────────────────────┐
|
|
121
|
+
│ Reflector │ │ CausalChain │
|
|
122
|
+
│ heuristic lesson │ │ links the fix to the │
|
|
123
|
+
│ per error code │ │ failure within 10 calls│
|
|
124
|
+
│ (throttled per │ └────────────┬────────────┘
|
|
125
|
+
│ fingerprint) │ │
|
|
126
|
+
└──────────┬───────────┘ │ session.idle
|
|
127
|
+
│ ▼
|
|
128
|
+
▼ ┌─────────────────────────┐
|
|
129
|
+
┌───────────────────────┐ │ promotes recurring │
|
|
130
|
+
│ ContextInjector │◄─┤ errors → causal │
|
|
131
|
+
│ SHARE: injects │ │ patterns (cumulative │
|
|
132
|
+
│ <kevin-context> │ │ evidence) │
|
|
133
|
+
│ ≤400 tokens/prompt │ └─────────────────────────┘
|
|
134
|
+
└───────────┬───────────┘
|
|
135
|
+
│ session.idle
|
|
136
|
+
▼
|
|
137
|
+
┌─────────────────────────┐ RETROSPECTIVE: <session>.md with
|
|
138
|
+
│ Retrospective │ lessons, metrics snapshot, causal
|
|
139
|
+
└─────────────────────────┘ promotion, pattern mining (opt-in)
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
At `session.idle` Kevin also settles injection outcomes, retires stale memories, drafts pull proposals for your review when curation is enabled (see [Curation & Pull](#curation--pull)), and syncs the shared OKF file when the shared layer is enabled.
|
|
143
|
+
|
|
144
|
+
In plain words, the whole loop is:
|
|
145
|
+
|
|
146
|
+
1. **Watch.** Every tool call is observed — what ran, what failed, what fixed it.
|
|
147
|
+
2. **Learn.** Failures become short lessons, deduplicated per error fingerprint and throttled so a noisy failure does not spam.
|
|
148
|
+
3. **Push.** At the next prompt, the best lessons are injected as `<kevin-context>` — capped, confidence-gated, and every rejection counted.
|
|
149
|
+
4. **Write.** With your explicit approval, a lesson can also land in `AGENTS.md`, a skill or a reference file — only ever inside the frozen marker block.
|
|
150
|
+
5. **Share.** With the shared layer on (v0.8.0, opt-in), approved lessons can be exported to a committed `.kevin/knowledge.okf` file that every teammate pulls and imports.
|
|
151
|
+
6. **Retire.** Lessons that stop being true — recurrences, staleness, a human `ignore` — stop being injected. Nothing lives forever by default.
|
|
152
|
+
|
|
153
|
+
Since v0.8.0, memories live in one of two layers: **local** (private to this installation, the model above) and **shared** (a committed `.kevin/knowledge.okf` file projected into the local database, immutable, retrievable and injectable like any local memory). See [The shared layer](#the-shared-layer-v080) — the feature is opt-in and off by default.
|
|
154
|
+
|
|
155
|
+
---
|
|
156
|
+
|
|
157
|
+
## Tools
|
|
158
|
+
|
|
159
|
+
Kevin exposes 21 tools callable by the agent.
|
|
160
|
+
|
|
161
|
+
### `kevin_save`
|
|
162
|
+
|
|
163
|
+
Saves an explicit memory.
|
|
164
|
+
|
|
165
|
+
```
|
|
166
|
+
kevin_save({ type: "decision", content: "We use vitest for tests", scope: "project" })
|
|
167
|
+
// → { "id": "0195a3b2-..." }
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
`type`: `error` | `pattern` | `decision` | `context` | `rule` | `solution`. `scope`: `project` (persists) | `session` (TTL 24h).
|
|
171
|
+
|
|
172
|
+
Saving a `decision` or `rule` with the same `fingerprint` as an existing active row supersedes the old one (`status='superseded'`, hidden from default queries).
|
|
173
|
+
|
|
174
|
+
### `kevin_query`
|
|
175
|
+
|
|
176
|
+
Searches memories by text (FTS5 + bm25). Returns a **slim** payload by default; pass `full: true` for the complete content, or `evidence: true` to include `confidence`, `evidence_count` and `last_verified_at`.
|
|
177
|
+
|
|
178
|
+
```
|
|
179
|
+
kevin_query({ query: "typecheck", type: "error", limit: 5 })
|
|
180
|
+
// → [{ "id": "...", "type": "error", "scope": "project", "score": -0.87,
|
|
181
|
+
// "snippet": "When bash fails with typecheck:..." }, ...]
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
### `kevin_get`
|
|
185
|
+
|
|
186
|
+
Fetches a **single full memory** by id (progressive disclosure) — use it when `kevin_query` returned a slim snippet and you need the complete content.
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
kevin_get({ id: "0195a3b2-..." })
|
|
190
|
+
// → { "id": "...", "type": "error", "content": "...", "scope": "project",
|
|
191
|
+
// "relevanceScore": 0.55, "origin": "reflector", "fingerprint": "cbf29ce484222325",
|
|
192
|
+
// "projectId": null, "metadata": null,
|
|
193
|
+
// "evidenceCount": 2, "recurrenceCount": 1, "lastVerifiedAt": "2026-08-01 10:00:00",
|
|
194
|
+
// "status": "active", "confidence": 0.55, "fixArgs": "npm i -g rg" }
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### `kevin_recall`
|
|
198
|
+
|
|
199
|
+
Retrieves relevant memories (greedy fill by relevance). Without `query`, returns all memories in scope. Pass `includeSuperseded: true` to include superseded rows.
|
|
200
|
+
|
|
201
|
+
```
|
|
202
|
+
kevin_recall({ query: "auth", limit: 3 })
|
|
203
|
+
// → [{ "id": "...", "type": "decision", ... }, ...]
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
### `kevin_status`
|
|
207
|
+
|
|
208
|
+
Global counts and metrics: memory census, the precision block, the six blocked-gate counters, feedback totals, and the v0.6 block (`schema_version`, `curation_enabled`, emission states, `proposals_pending` — omitted on pre-007 databases). On 009 databases (v0.8.0) it also reports the `v08` block: `repo_id` (a 16-hex hash derived from the identity sources below — never a raw remote URL), `identity_source` (`"declared"` from `.kevin/project.json`, `"remote"` from the git origin URL, or `"path"` fallback), `shared_layer_enabled` and the repo's `shared_entries` count. Omitted on pre-009 databases.
|
|
209
|
+
|
|
210
|
+
```
|
|
211
|
+
kevin_status({})
|
|
212
|
+
// → { "memories": 42, "memories_reflector": 12, "memories_agent": 30,
|
|
213
|
+
// "memories_pattern": 0, "memories_causal": 1, "tool_calls": 318,
|
|
214
|
+
// "retrospectives": 7, "tool_count": 21,
|
|
215
|
+
// "metrics": { "tokens_injected_pre_prompt": 51, "tokens_injected_compacting": 0,
|
|
216
|
+
// "reflections_throttled": 3, "duplicate_suppressions": 2,
|
|
217
|
+
// "tool_calls_deduped": 0, "patterns_mined": 0,
|
|
218
|
+
// "patterns_causal": 1, "causal_links": 2, "memories_superseded": 0,
|
|
219
|
+
// "injections_inconclusive": 9, ... },
|
|
220
|
+
// "injections_total": 14, "injections_effective": 2, "injections_ineffective": 3,
|
|
221
|
+
// "injections_inconclusive": 9, "precision_rate": 0.40, "coverage_rate": 0.36,
|
|
222
|
+
// "blocked": { "seen": 1, "weak": 0, "recurrence": 2, "stale": 0,
|
|
223
|
+
// "ignored": 1, "confidence": 2 },
|
|
224
|
+
// "memories_ignored": 1, "memories_archived": 4,
|
|
225
|
+
// "feedback": { "positive": 2, "negative": 1 },
|
|
226
|
+
// "patterns_promoted_new": 2, "recurrence_by_origin": { "reflector": 3, "causal": 1 },
|
|
227
|
+
// "v06": { "schema_version": "007", "curation_enabled": "1",
|
|
228
|
+
// "skill_emission": "off", "reference_emission": "off",
|
|
229
|
+
// "proposals_pending": 2 },
|
|
230
|
+
// "v08": { "repo_id": "2114ad162af50a25", "identity_source": "remote",
|
|
231
|
+
// "shared_layer_enabled": "0", "shared_entries": 3 } }
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
### `kevin_retrospective`
|
|
235
|
+
|
|
236
|
+
Generates a retrospective for a session (uses the current session if `session_id` is omitted).
|
|
237
|
+
|
|
238
|
+
```
|
|
239
|
+
kevin_retrospective({ session_id: "sess-abc" })
|
|
240
|
+
// → { "file_path": "~/.opencode-kevin/retrospectives/sess-abc.md" }
|
|
241
|
+
// or → { "message": "No failures in session sess-abc." }
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### `kevin_why`
|
|
245
|
+
|
|
246
|
+
Explains *why* a failure keeps happening: looks up causal patterns for the query and builds a failure → fix trace from memories + tool_calls, including related TypeScript error-code rules.
|
|
247
|
+
|
|
248
|
+
```
|
|
249
|
+
kevin_why({ query: "TS2304 cannot find name" })
|
|
250
|
+
// → { "summary": "TS2304 recurs because ... Confirmed by 2 fixes.",
|
|
251
|
+
// "confidence": 0.7, "evidence_count": 2, "last_verified": "2026-08-01 10:00:00",
|
|
252
|
+
// "trace": [ { "type": "error", "summary": "..." }, { "type": "fix", "tool": "bash" } ],
|
|
253
|
+
// "related_rules": [ { "code": "TS2304", "suggestion": "import or typo" } ] }
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### `kevin_export`
|
|
257
|
+
|
|
258
|
+
Exports knowledge for sharing: `decision`/`rule`/`pattern` memories (active only, no raw errors) as YAML-frontmatter blocks (`format: "okf"`) or markdown (`format: "markdown"`). Includes `id`, `type`, `confidence`, `evidence_count`, `recurrence_count`, `last_verified_at`, `fingerprint`. Timestamps are treated as UTC — a re-import reproduces the exact source values.
|
|
259
|
+
|
|
260
|
+
### `kevin_import`
|
|
261
|
+
|
|
262
|
+
Ingests an exported bundle. Each entry becomes a `context` memory with `origin='imported'`; a fingerprint collision with an existing `decision`/`rule` supersedes the old row. Returns `{ imported, superseded }`.
|
|
263
|
+
|
|
264
|
+
### `kevin_config`
|
|
265
|
+
|
|
266
|
+
Reads/writes `kevin_settings` without SQL. `action: "list"` returns every setting; `action: "set"` upserts a value (default `"1"` when omitted) and rejects unknown keys unless `strict: false`.
|
|
267
|
+
|
|
268
|
+
```
|
|
269
|
+
kevin_config({ action: "list" })
|
|
270
|
+
// → { "quality_gate_enabled": "1", "lesson_snippet_injection": "1",
|
|
271
|
+
// "llm_reflection_enabled": "0", "pre_prompt_budget_tokens": "400",
|
|
272
|
+
// "injection_confidence_floor": "0.6", ... }
|
|
273
|
+
|
|
274
|
+
kevin_config({ action: "set", key: "quality_gate_enabled", value: "0" })
|
|
275
|
+
// → { "ok": true, "key": "quality_gate_enabled", "value": "0" }
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
All settings and their defaults are listed in [Configuration](#configuration).
|
|
279
|
+
|
|
280
|
+
### `kevin_feedback`
|
|
281
|
+
|
|
282
|
+
Rates an injected memory and makes the rating count. `verdict` is `useful` | `wrong` | `outdated` | `ignore`. The first three are stored in `memory_feedback` and move `kevin_why`'s confidence (`+0.05` / `-0.1` per count); **`ignore` is a hard action** — the memory is stamped `ignored = 1` and excluded from retrieval, queries and injection.
|
|
283
|
+
|
|
284
|
+
```
|
|
285
|
+
kevin_feedback({ memory_id: "0195a3b2-...", verdict: "wrong", note: "the fix was wrong" })
|
|
286
|
+
// → { "ok": true, "verdict": "wrong" }
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### `kevin_trace`
|
|
290
|
+
|
|
291
|
+
Strict dry-run: predicts exactly which memories `onSystemTransform` WOULD inject for a query (optionally `session_id`, `tag` and `cap`), with **zero side effects** — no counters, no ledger rows, no seen-set writes, no relevance bumps. Rejected items carry their `GateReason` (`seen_this_session` | `weak` | `recurrence` | `stale` | `ignored` | `confidence`).
|
|
292
|
+
|
|
293
|
+
```
|
|
294
|
+
kevin_trace({ query: "tsc error" })
|
|
295
|
+
// → { "query": "tsc error", "tag": "context", "cap": 400, "would_inject": true,
|
|
296
|
+
// "total_tokens": 82,
|
|
297
|
+
// "admitted": [ { "id": "...", "type": "error", "decision": "admitted", "tokens": 62 } ],
|
|
298
|
+
// "blocked": [ { "id": "...", "type": "error", "decision": "blocked",
|
|
299
|
+
// "reason": "confidence", "tokens": 20 } ] }
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
### `kevin_audit`
|
|
303
|
+
|
|
304
|
+
Read-only report of the whole system state: memories by `status`/`origin`/`type`, injection outcomes with `precision_rate`/`coverage_rate`, the six `blocked` counters, feedback by verdict, tokens injected, the push-vs-pull `channels` comparison and the `curation` scoreboard. `verbose: true` adds the settings block. No writes, no LLM; on pre-007 databases it omits the v0.6 blocks and reports `"partial": true`.
|
|
305
|
+
|
|
306
|
+
```
|
|
307
|
+
kevin_audit({})
|
|
308
|
+
// → { "memories": { "total": 42, "by_status": { "active": 37, "stale": 1, "archived": 4 },
|
|
309
|
+
// "by_origin": { "reflector": 12, "agent": 30 }, "by_type": { "error": 20, ... },
|
|
310
|
+
// "ignored": 1, "with_feedback": 3 },
|
|
311
|
+
// "injections": { "total": 14, "effective": 2, "ineffective": 3, "inconclusive": 9,
|
|
312
|
+
// "unmeasured": 0, "precision_rate": 0.40, "coverage_rate": 0.36 },
|
|
313
|
+
// "blocked": { "seen": 1, "weak": 0, "recurrence": 2, "stale": 0,
|
|
314
|
+
// "ignored": 1, "confidence": 2 },
|
|
315
|
+
// "feedback": { "positive": 2, "negative": 1, "by_verdict": { "useful": 2, "wrong": 1 } },
|
|
316
|
+
// "tokens": { "pre_prompt": 51, "compacting": 0 }, "partial": false,
|
|
317
|
+
// "channels": { "push": { "tokens_pre_prompt": 51, "injections_total": 14,
|
|
318
|
+
// "precision_rate": 0.40, "coverage_rate": 0.36,
|
|
319
|
+
// "budget_tokens": 400 },
|
|
320
|
+
// "pull": { "proposals_created": 6, "proposals_approved": 1,
|
|
321
|
+
// "proposals_rejected": 2, "artifact_writes_total": 2,
|
|
322
|
+
// "artifact_writes_noop": 1, "references_registered": 0,
|
|
323
|
+
// "skills_registered": 0,
|
|
324
|
+
// "skill_emission": "off", "reference_emission": "off" } },
|
|
325
|
+
// "curation": { "eligible": 5, "curated": 1, "inferable": 3, "non_inferable": 2,
|
|
326
|
+
// "unknown": 1, "proposals_by_status": { "pending": 2, "applied": 1, ... } } }
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
### `kevin_propose`
|
|
330
|
+
|
|
331
|
+
Creates curation proposals as `pending` rows with unified diffs — **a strict dry run**. Reads the eligible memories (`inferable != 1`), renders what would go into the artifact, and returns the minimal diff. No disk write, no `curated` marks, no side effects. Only `kevin_approve` may write.
|
|
332
|
+
|
|
333
|
+
```
|
|
334
|
+
kevin_propose({ kind: "agents_md" }) // kind: "agents_md" | "skill" | "reference"
|
|
335
|
+
// → { "proposals": [ { "id": "...", "kind": "agents_md", "targetPath": "AGENTS.md",
|
|
336
|
+
// "memoryIds": ["mem-1"], "status": "pending",
|
|
337
|
+
// "createdAt": "2026-08-14 10:00:00",
|
|
338
|
+
// "diff": "--- a/AGENTS.md\n+++ b/AGENTS.md\n@@ ..." } ] }
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
### `kevin_approve`
|
|
342
|
+
|
|
343
|
+
The **only** code path that writes a file. `approve` applies the proposal's diff atomically (temp file + rename, CRLF/BOM preserved), records an `artifact_writes` audit row, marks the proposal `applied` and its memories `curated`. `reject` records the human decision and touches nothing. Refusals and noops are audited, never silent.
|
|
344
|
+
|
|
345
|
+
```
|
|
346
|
+
kevin_approve({ proposal_id: "...", decision: "approve" }) // or "reject"
|
|
347
|
+
// → { "proposalId": "...", "status": "applied", "outcome": "written", "curated": 1 }
|
|
348
|
+
// ("outcome": "noop" when the artifact already matches, "refused" when the
|
|
349
|
+
// marker block is malformed; a rejected proposal returns
|
|
350
|
+
// { "proposalId": "...", "status": "rejected" })
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### `kevin_publish`
|
|
354
|
+
|
|
355
|
+
Regenerates the pull-channel bundles under `~/.opencode-kevin/` — `skills/project-knowledge.md` and `refs/<topic>.md` — reporting per-bundle outcome and the emission state (`on` / `off` / `unavailable`). Registration with the host happens at plugin startup; this tool only materializes and reports.
|
|
356
|
+
|
|
357
|
+
### `kevin_project`
|
|
358
|
+
|
|
359
|
+
Repository identity (v0.8.0). `action: "show"` reports the resolved `repoId`, `identity_source`, `projectId`, the memory counts under each scope and `rekey_available`; `action: "init"` writes `.kevin/project.json` pinning the derived id (refused if it already exists); `action: "rekey"` moves the whole corpus to the resolved `repo_id` in one transaction — without `confirm: true` it is a dry run that mutates nothing, and a monorepo collision is rejected unless `force: true`.
|
|
360
|
+
|
|
361
|
+
A **confirmed** rekey updates the running session live — the identity, the memory service and the shared-layer bridge all move to the new `repo_id` immediately, so `kevin_status`, `kevin_audit` and `kevin_share` keep working without a restart, and the OKF file's `#repo` header is repaired so the shared channel keeps working too.
|
|
362
|
+
|
|
363
|
+
```
|
|
364
|
+
kevin_project({ action: "show" })
|
|
365
|
+
// → { "repoId": "2114ad162af50a25", "source": "remote", "evidence": "origin",
|
|
366
|
+
// "projectId": "8f3c2a1b...", "projectScoped": 41, "repoScoped": 0,
|
|
367
|
+
// "rekeyAvailable": true }
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### `kevin_share`
|
|
371
|
+
|
|
372
|
+
Promotes curated memories into the shared layer: plans an export to the OKF file and (with `confirm: true`) writes it through the single write funnel. **A strict dry run by default** — with no `confirm` it returns the plan and its diff, writing nothing. With no `memory_ids`, it selects every `layer='local'`, curated memory whose confidence clears the shared floor. Refusals: `not_okf`, `version_ahead`, `repo_mismatch`, `too_many_entries`, `line_too_long`, `below_floor`, `not_curated`, `unknown_entry`, `parse_damaged` — a typo'd or foreign memory id refuses the whole export (`unknown_entry`) instead of silently sharing a subset.
|
|
373
|
+
|
|
374
|
+
```
|
|
375
|
+
kevin_share({ memory_ids: ["0195a3b2-..."], dry_run: false, confirm: true })
|
|
376
|
+
// → { "memory_ids": [...], "entries_added": 1, "outcome": "written",
|
|
377
|
+
// "okf_path": ".kevin/knowledge.okf", "diff": "--- a/...\n+++ b/..." }
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### `kevin_sync`
|
|
381
|
+
|
|
382
|
+
Ingests the OKF file (asserts → shared-layer projections; tombstones → archived) and returns `{ imported, tombstoned, skipped, reason }`. Idempotent: an unchanged file is a no-op. Also runs automatically at `session.idle` while `shared_layer_enabled = "1"`.
|
|
383
|
+
|
|
384
|
+
```
|
|
385
|
+
kevin_sync({})
|
|
386
|
+
// → { "path": ".kevin/knowledge.okf", "fileHash": "3d2f...", "parsed": 1,
|
|
387
|
+
// "folded": 0, "rejected": 0, "imported": 1, "tombstoned": 0,
|
|
388
|
+
// "skipped": false }
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## How Kevin measures itself
|
|
394
|
+
|
|
395
|
+
### Injection outcomes
|
|
396
|
+
|
|
397
|
+
Every injection is settled at `session.idle` into one of **four outcomes**:
|
|
398
|
+
|
|
399
|
+
| Outcome | Meaning | Counts toward precision? |
|
|
400
|
+
|---|---|---|
|
|
401
|
+
| `effective` | A linked fix was observed after the injection | yes (numerator) |
|
|
402
|
+
| `ineffective` | The same error recurred after the injection | yes (denominator) |
|
|
403
|
+
| `inconclusive` | Neither — the error did not recur, but no fix was seen either | no |
|
|
404
|
+
| `unmeasured` | Session went idle before settlement could run | no |
|
|
405
|
+
|
|
406
|
+
- **`precision_rate`** = `effective / (effective + ineffective)`. Measuring *effect*, not absence of recurrence: a lesson that was injected and never contradicted counts as `inconclusive`, not success. **Your precision rate will look lower than before v0.5.0. That is the honest number.**
|
|
407
|
+
- **`coverage_rate`** = `(effective + ineffective) / total` — the share of injections that were actually measured. Reported alongside precision so a low measurable fraction stays visible instead of hiding behind a large total.
|
|
408
|
+
- **`blocked`** counts every gate rejection by reason — `seen_this_session`, `weak`, `recurrence`, `stale`, `ignored`, `confidence` — a rejection you did not count did not happen.
|
|
409
|
+
|
|
410
|
+
### The quality gate
|
|
411
|
+
|
|
412
|
+
Weak lessons — errors the reflector cannot dispatch to a deterministic rule — are **stored but never injected** while `quality_gate_enabled = '1'` (default). Recurrences demote lessons (`recurrence_count` → `stale`) and lower confidence. Debug mode: `kevin_config({ action: "set", key: "quality_gate_enabled", value: "0" })` re-injects weak lessons with a `(low confidence)` marker.
|
|
413
|
+
|
|
414
|
+
### Seeing the whole picture
|
|
415
|
+
|
|
416
|
+
`kevin_trace` shows you the plan *before* it happens (dry run, zero side effects); `kevin_audit` reads the whole state after; `kevin_feedback` lets a human correct it — and the correction moves the confidence number `kevin_why` reports.
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
## Curation & Pull
|
|
421
|
+
|
|
422
|
+
### The marker contract
|
|
423
|
+
|
|
424
|
+
Kevin never edits your files directly. Every artifact write happens inside a frozen marker block, delimited verbatim by:
|
|
425
|
+
|
|
426
|
+
```
|
|
427
|
+
<!-- kevin:begin — curated by opencode-kevin, safe to edit -->
|
|
428
|
+
<!-- kevin:end -->
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
These exact strings are **frozen for the v0.x line** — README, tests and the v1.0.0 migration plan all depend on their byte sequences. What Kevin guarantees:
|
|
432
|
+
|
|
433
|
+
- **Only the block between the markers may change.** Bytes outside them are byte-identical after every write — including line endings (a CRLF file stays CRLF everywhere, even inside the generated block), a leading UTF-8 BOM, and the file's final newline.
|
|
434
|
+
- **Malformed markers are refused, never repaired.** If the file contains a `begin` without an `end` (or vice versa), Kevin refuses the write with an explicit reason and the file is untouched. Repairing would mean guessing at user intent; refusing means the state stays visible and auditable.
|
|
435
|
+
- **Idempotent**: applying an unchanged plan is a counted `noop` — no temp file, no write, no mtime churn.
|
|
436
|
+
|
|
437
|
+
### The propose → review → approve flow
|
|
438
|
+
|
|
439
|
+
```
|
|
440
|
+
eligible memories (inferable != 1)
|
|
441
|
+
│
|
|
442
|
+
▼
|
|
443
|
+
kevin_propose({ kind }) ── creates pending rows + unified diffs.
|
|
444
|
+
│ NO disk write, NO curated marks.
|
|
445
|
+
▼
|
|
446
|
+
HUMAN REVIEWS THE DIFF ── this is the entire safety model:
|
|
447
|
+
│ a memory earns its way into a file
|
|
448
|
+
▼ only after a human said yes.
|
|
449
|
+
kevin_approve({ proposal_id, decision })
|
|
450
|
+
│
|
|
451
|
+
├── "approve" ── ArtifactWriter.apply() (the ONLY write path)
|
|
452
|
+
│ atomic temp+rename, audit row in artifact_writes,
|
|
453
|
+
│ memory marked curated, proposal marked applied
|
|
454
|
+
└── "reject" ── recorded, nothing touches disk
|
|
455
|
+
```
|
|
456
|
+
|
|
457
|
+
Rejection history is never deleted: it is the evidence base for the roadmap's kill criterion "proposals rejected more often than approved".
|
|
458
|
+
|
|
459
|
+
### Three distribution channels
|
|
460
|
+
|
|
461
|
+
| Channel | Artifact | Cost when unused |
|
|
462
|
+
|---|---|---|
|
|
463
|
+
| **Push** | per-prompt `<kevin-context>` injection | charges on every prompt — now capped at 400 tokens by default |
|
|
464
|
+
| **Pull — AGENTS.md** | marker block in the project's `AGENTS.md` | zero |
|
|
465
|
+
| **Pull — skills** | `~/.opencode-kevin/skills/project-knowledge.md` (`skill_emission_enabled`) | zero |
|
|
466
|
+
| **Pull — references** | `~/.opencode-kevin/refs/<topic>.md` (`reference_emission_enabled`) | zero |
|
|
467
|
+
|
|
468
|
+
`kevin_audit`'s `channels` block compares push vs pull on the same axes, and reports each emission channel as `"on"`, `"off"` (setting `'0'` on a capable host) or `"unavailable"` (host without the v2 domain).
|
|
469
|
+
|
|
470
|
+
### The confidence floor gate
|
|
471
|
+
|
|
472
|
+
`injection_confidence_floor` (default `'0.6'`) rejects memories whose computed confidence is below the floor, counted as `injections_blocked_confidence` — the sixth gate rejection reason, measured exactly like the first five. Single-observation memories (base confidence 0.5, no confirmed evidence) stop being pushed by default; `kevin_config({ action: "set", key: "injection_confidence_floor", value: "0" })` restores v0.5 behaviour exactly.
|
|
473
|
+
|
|
474
|
+
---
|
|
475
|
+
|
|
476
|
+
## The shared layer (v0.8.0)
|
|
477
|
+
|
|
478
|
+
### Two layers, one file
|
|
479
|
+
|
|
480
|
+
Every memory lives in one of two layers:
|
|
481
|
+
|
|
482
|
+
| Layer | Storage | Visibility |
|
|
483
|
+
|---|---|---|
|
|
484
|
+
| **local** | `kevin.db` → `memories` | private to this installation (the whole v0.1–v0.7 model) |
|
|
485
|
+
| **shared** | `.kevin/knowledge.okf` (a committed file) → `shared_entries` projections | visible to every teammate who pulls the repo and runs Kevin |
|
|
486
|
+
|
|
487
|
+
The OKF file is the *only* distribution vehicle. Kevin **never** commits it, pushes it, or talks to a server — you commit and push it with the rest of your repository. A teammate's `git pull` + `kevin_sync` (or the automatic sync at `session.idle`) turns every `assert` entry into a read-only projection in their `memories` table, retrievable and injectable like any local memory — but immutable: the shared layer is an exact projection of the committed file, so it is never edited, only re-imported or tombstoned. A tombstone in the file archives the projection everywhere.
|
|
488
|
+
|
|
489
|
+
The whole feature is opt-in: with `shared_layer_enabled = "0"` (the default), Kevin never reads or writes the file, and `session.idle` performs no filesystem access at all.
|
|
490
|
+
|
|
491
|
+
### Where the repo identity comes from
|
|
492
|
+
|
|
493
|
+
Every repo has a `repo_id` — a 16-hex hash that scopes both the OKF file (`#repo`) and the shared projections. Kevin resolves it from three sources, in priority order:
|
|
494
|
+
|
|
495
|
+
| Priority | Source | `identity_source` | Typical case |
|
|
496
|
+
|---|---|---|---|
|
|
497
|
+
| 1 | `.kevin/project.json` (`repo_id` pinned) | `declared` | after `kevin_project init` |
|
|
498
|
+
| 2 | the git `origin` remote URL, hashed | `remote` | a repo cloned from a known remote |
|
|
499
|
+
| 3 | the project path | `path` | a local folder without git |
|
|
500
|
+
|
|
501
|
+
Only the **hash** is ever stored, written or reported — the raw remote URL never reaches the database or the OKF file. `kevin_project` is the mirror of this resolution: `show` tells you which source won, `init` pins it, `rekey` moves the whole corpus when the identity changes (say, the repo got a new remote):
|
|
502
|
+
|
|
503
|
+
```
|
|
504
|
+
startup or kevin_project call
|
|
505
|
+
│
|
|
506
|
+
▼
|
|
507
|
+
resolve(): declared ──► remote ──► path (first source that yields)
|
|
508
|
+
│
|
|
509
|
+
▼
|
|
510
|
+
repo_id (16-hex hash — never the raw URL)
|
|
511
|
+
│
|
|
512
|
+
├── kevin_project show → which source won, counts, rekey_available
|
|
513
|
+
├── kevin_project init → pins the id into .kevin/project.json
|
|
514
|
+
└── kevin_project rekey → one transaction moves everything together:
|
|
515
|
+
DB corpus + live session identity
|
|
516
|
+
+ the OKF file's #repo header
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
Because `rekey` re-aligns the running session (not just the database), the natural flow "add a remote → rekey → share" works without restarting OpenCode — and the `#repo` header heal keeps `kevin_share`/`kevin_sync` from refusing the file with `repo_mismatch`.
|
|
520
|
+
|
|
521
|
+
### The round trip, step by step
|
|
522
|
+
|
|
523
|
+
```
|
|
524
|
+
you (repo A) teammate (repo B)
|
|
525
|
+
┌───────────────────────────────────────┐ ┌───────────────────────────────────────┐
|
|
526
|
+
│ kevin_share({ memory_ids, │ │ git pull │
|
|
527
|
+
│ confirm: true }) │ │ │ │
|
|
528
|
+
│ │ 1. identity gate: #repo must │ │ ▼ │
|
|
529
|
+
│ │ match your repo_id │ │ kevin_sync (or automatically at │
|
|
530
|
+
│ │ 2. entry_id = hash(type, │ │ session.idle) │
|
|
531
|
+
│ │ statement, scope) │ │ │ │
|
|
532
|
+
│ │ 3. per-line and corpus limits │ │ ├─ new asserts → shared_entries │
|
|
533
|
+
│ ▼ │ │ │ → projections (layer='shared', │
|
|
534
|
+
│ .kevin/knowledge.okf │ │ │ immutable, retrievable) │
|
|
535
|
+
│ │ (the only thing Kevin writes) │ │ ├─ tombstones → projections │
|
|
536
|
+
│ ▼ │ │ │ archived │
|
|
537
|
+
│ git commit + push │ │ └─ unchanged file → no-op │
|
|
538
|
+
└───────────────────────────────────────┘ └───────────────────────────────────────┘
|
|
539
|
+
```
|
|
540
|
+
|
|
541
|
+
Kevin never commits, pushes or fetches anything: the git remote is the transport, and `git commit`/`git push` are yours.
|
|
542
|
+
|
|
543
|
+
### The OKF v2 format
|
|
544
|
+
|
|
545
|
+
One annotated example, byte-exact (the three header lines are always first):
|
|
546
|
+
|
|
547
|
+
```
|
|
548
|
+
#okf 2
|
|
549
|
+
#repo 2114ad162af50a25
|
|
550
|
+
#generated-by opencode-kevin/0.8.0
|
|
551
|
+
{"author_hash":null,"created_at":"2026-08-17T03:34:17Z","entry_id":"2d80f0972a4b8c92","evidence":6,"op":"assert","origin":"pattern","recurrence":0,"scope":"project","statement":"Always use the repository pattern for the data layer","supersedes":null,"type":"rule"}
|
|
552
|
+
```
|
|
553
|
+
|
|
554
|
+
- `#okf 2` — the format version. A file with a **higher** version is refused (`version_ahead`), never downgraded.
|
|
555
|
+
- `#repo <16-hex>` — the repo identity the file belongs to. A file from another repo is refused (`repo_mismatch`) — the shared layer never crosses repositories.
|
|
556
|
+
- `#generated-by opencode-kevin/<version>` — provenance of the writer.
|
|
557
|
+
- Each following line is one JSON entry. `op: "assert"` declares knowledge; `op: "tombstone"` retires the `entry_id` it carries. `entry_id` is a deterministic hash of `(type, statement, scope)`, so the same statement from any teammate collides to the same entry — that is what makes imports idempotent.
|
|
558
|
+
- Limits, enforced at export *and* import: `MAX_LINE_BYTES = 4096`, `MAX_ENTRIES = 2000`. A corpus beyond the limits is refused, never truncated.
|
|
559
|
+
|
|
560
|
+
### When git reports a conflict in `.kevin/knowledge.okf`
|
|
561
|
+
|
|
562
|
+
A merge conflict in the OKF file is expected — both sides asserted different knowledge. The counter-intuitive answer: **keep both sides, then run `kevin_sync`.** Kevin's import is merge-friendly by design: entries are idempotent (same `entry_id` → no-op) and disjoint entries coexist in the same file.
|
|
563
|
+
|
|
564
|
+
Worked example — your branch asserted "Always use the repository pattern…" and your teammate's branch asserted "Always wrap file writes in a temp-file + rename helper". Git cannot merge two files that both changed, so it stops:
|
|
565
|
+
|
|
566
|
+
```
|
|
567
|
+
<<<<<<< HEAD
|
|
568
|
+
#okf 2
|
|
569
|
+
#repo 2114ad162af50a25
|
|
570
|
+
#generated-by opencode-kevin/0.8.0
|
|
571
|
+
{"op":"assert", ... "statement":"Always use the repository pattern..."}
|
|
572
|
+
=======
|
|
573
|
+
#okf 2
|
|
574
|
+
#repo 2114ad162af50a25
|
|
575
|
+
#generated-by opencode-kevin/0.8.0
|
|
576
|
+
{"op":"assert", ... "statement":"Always wrap file writes in a temp-file + rename helper..."}
|
|
577
|
+
>>>>>>> teammate
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
1. Resolve by keeping both entry lines (drop the `<<<<<<<`, `=======`, `>>>>>>>` markers and the duplicated headers, keep the other headers and both JSON lines).
|
|
581
|
+
2. Save the file — it now contains both assertions.
|
|
582
|
+
3. Run `kevin_sync`. Both entries import; both projections become active; the conflict is resolved and the corpus is the union of both sides.
|
|
583
|
+
|
|
584
|
+
Do **not** delete either side "to make it clean" — that deletes knowledge. The one thing to avoid: a file left with the conflict markers still present will refuse to import (`parse_damaged`), because a `<<<<<<<` line is not a valid entry.
|
|
585
|
+
|
|
586
|
+
### Retiring shared knowledge
|
|
587
|
+
|
|
588
|
+
There is no in-product tool that writes a `tombstone` entry for you (a deliberate v0.8.0 scope decision). To retire a shared entry, edit the file by hand: replace the `assert` line with a `tombstone` line carrying the same `entry_id`, commit, and let teammates' `kevin_sync` archive the projection. The import side always honors tombstones — the export side just has no button for them yet.
|
|
589
|
+
|
|
590
|
+
### Non-goals (asked for, deliberately not built)
|
|
591
|
+
|
|
592
|
+
- **No server.** The file, the git remote, and your own discipline are the only transport.
|
|
593
|
+
- **No account.** No signup, no cloud, no telemetry — `author_identity_mode` defaults to `hashed` and no identity is ever transmitted.
|
|
594
|
+
- **No automatic commit.** Kevin writes the file; git is yours.
|
|
595
|
+
- **No cross-repository corpus.** `#repo` scopes the file: exports are refused (`repo_mismatch`) when the file belongs to another repository. Imports, by contrast, are deliberately tolerant — an entry's validity is decided by its own `entry_id`, so a copied file imports as if it belonged to your repo (the tested, documented behaviour).
|
|
596
|
+
- **No undelete.** A tombstone is a statement, not a recovery mechanism — keep your git history if you need to resurrect an entry.
|
|
597
|
+
- **No tombstone tool (yet).** See [Retiring shared knowledge](#retiring-shared-knowledge) — retirement happens by editing the file.
|
|
598
|
+
|
|
599
|
+
---
|
|
600
|
+
|
|
601
|
+
## Replay harness
|
|
602
|
+
|
|
603
|
+
`npm run replay` runs every transcript in `tests/replay/fixtures/` through the plugin against an in-memory database with a frozen clock and prints one table row per transcript (memories created, injection outcomes, `precision_rate`, `coverage_rate`, tokens). Record your own session as a JSON array of typed events (`session.created`, `chat.message`, `tool.before`, `tool.after`, `system.transform`, `compacting`, `session.idle`) with ISO-8601 `at` timestamps, drop it into `tests/replay/fixtures/`, and re-run. The `at` timestamps are the only source of time during replay.
|
|
604
|
+
|
|
605
|
+
---
|
|
606
|
+
|
|
607
|
+
## Hooks
|
|
608
|
+
|
|
609
|
+
Kevin subscribes to 6 OpenCode hooks:
|
|
610
|
+
|
|
611
|
+
| Hook | What Kevin does |
|
|
612
|
+
|---|---|
|
|
613
|
+
| `tool.execute.before` | Records tool call start (callID + redacted args) |
|
|
614
|
+
| `tool.execute.after` | Records result (id = callID); on failure → Reflector.invoke async (throttled); on success → CausalChain links the fix |
|
|
615
|
+
| `experimental.chat.system.transform` | Injects relevant lessons in `<kevin-context>` (400 tokens by default, configurable) + optional `<kevin-suggestion>` |
|
|
616
|
+
| `experimental.session.compacting` | Re-injects lessons in `<kevin-memory>` after compacting (2000 tokens) + optional `<kevin-suggestion>` |
|
|
617
|
+
| `event` (`session.created`) | Captures current `sessionID` (skill/reference emissions register at plugin startup, not per session) |
|
|
618
|
+
| `event` (`session.idle`) | Settles injection outcomes; generates the retrospective; boosts positive lessons; penalizes recurring failures; promotes causal patterns and mines patterns (opt-in); drafts curation proposals (`curation_enabled`); syncs the shared OKF file (`shared_layer_enabled`); flushes metrics |
|
|
619
|
+
|
|
620
|
+
**Redaction**: absolute paths (`C:\Users\...`, `/home/...`) → `<path>` and secrets (`API_KEY=`, `Bearer`, `token`) → `<redacted>` before persisting anything. `<private>…</private>` blocks are swept from tool call args and output before persistence and replaced with `<private: redacted N chars>`.
|
|
621
|
+
|
|
622
|
+
**Throttle**: Reflector generates at most 1 lesson per minute per unique fingerprint (per-fingerprint, not global). Configurable via `throttleMs`.
|
|
623
|
+
|
|
624
|
+
**Truncation**: content > 4KB keeps the lesson searchable; only the additional context is truncated (`metadata.truncated = true`).
|
|
625
|
+
|
|
626
|
+
---
|
|
627
|
+
|
|
628
|
+
## Configuration
|
|
629
|
+
|
|
630
|
+
### Plugin options
|
|
631
|
+
|
|
632
|
+
Kevin accepts options via the plugin's tuple form (see Installation → Advanced). Programmatic defaults:
|
|
633
|
+
|
|
634
|
+
```ts
|
|
635
|
+
import { KevinPlugin } from "@jmtrin/opencode-kevin";
|
|
636
|
+
|
|
637
|
+
// defaults
|
|
638
|
+
KevinPlugin(input, {
|
|
639
|
+
dbPath: "~/.opencode-kevin/kevin.db", // or ":memory:" for tests
|
|
640
|
+
migrationsDir: "<package>/dist/migrations", // resolved automatically
|
|
641
|
+
retrospectivesDir: "~/.opencode-kevin/retrospectives",
|
|
642
|
+
throttleMs: 60_000,
|
|
643
|
+
});
|
|
644
|
+
```
|
|
645
|
+
|
|
646
|
+
### Settings
|
|
647
|
+
|
|
648
|
+
Read/write via `kevin_config({ action: "list" | "set", ... })`. All 23 values are TEXT; booleans compare against `"1"`.
|
|
649
|
+
|
|
650
|
+
| Setting | Default | Effect |
|
|
651
|
+
|---|---|---|
|
|
652
|
+
| `quality_gate_enabled` | `"1"` | Weak lessons are stored but never injected while enabled |
|
|
653
|
+
| `lesson_snippet_injection` | `"1"` | Injects the rescued errorType snippet with each lesson |
|
|
654
|
+
| `llm_reflection_enabled` | `"0"` | Opt-in LLM enrichment of reflector lessons |
|
|
655
|
+
| `cross_project_enabled` | `"0"` | `kevin_query` includes imported cross-project memories |
|
|
656
|
+
| `patternminer_enabled` | `"0"` | Opt-in deterministic 2-gram/3-gram pattern miner at `session.idle` |
|
|
657
|
+
| `tool_calls_dedup_enabled` | `"0"` | Opt-in dedup of repeated tool calls |
|
|
658
|
+
| `deterministic_retrieval` | `"0"` | Freezes Kevin's internal clock (recency factor 1.0, no relevance bumps) — for hermetic tests and the replay harness |
|
|
659
|
+
| `pre_prompt_budget_tokens` | `"400"` | Pre-prompt injection cap, clamped to `[0, 4000]`; `0` turns push off |
|
|
660
|
+
| `archive_after_days` | `"30"` | Age at which stale non-pattern memories are retired to `archived` on `session.idle` |
|
|
661
|
+
| `curation_enabled` | `"1"` | Generates curation proposals at `session.idle` |
|
|
662
|
+
| `agents_md_path` | `"AGENTS.md"` | Where the AGENTS.md channel writes (project-relative) |
|
|
663
|
+
| `skill_emission_enabled` | `"0"` | Registers the curated skill with the host at startup (v2 hosts only) |
|
|
664
|
+
| `reference_emission_enabled` | `"0"` | Registers `@kevin/<topic>` references at startup (v2 hosts only) |
|
|
665
|
+
| `injection_confidence_floor` | `"0.6"` | Push gate: memories below this confidence are counted and rejected |
|
|
666
|
+
| `repo_truth_enabled` | `"0"` | Opt-in Project Truth: fact scanning + contradiction detection at `session.idle` |
|
|
667
|
+
| `convention_mining_enabled` | `"0"` | Opt-in deterministic convention mining into `AGENTS.md` |
|
|
668
|
+
| `conflict_detection_enabled` | `"0"` | Opt-in contradiction detection between memories and observed facts |
|
|
669
|
+
| `error_lesson_mode` | `"all"` | Which failures produce lessons: `all` / `rules_only` / `patterns_only` |
|
|
670
|
+
| `shared_layer_enabled` | `"0"` | Master switch for the shared layer. When `"0"`, Kevin never reads or writes the OKF file and `session.idle` performs no filesystem access. Compare with `=== "1"` — a truthiness check would turn the feature on for every installation |
|
|
671
|
+
| `okf_path` | `".kevin/knowledge.okf"` | Project-relative path of the committed OKF file (**string** — always truthy, which is exactly why the layer flag above must not be read as a boolean) |
|
|
672
|
+
| `share_requires_approval` | `"1"` | When `"1"`, `kevin_share` writes only with `confirm: true`; un-curated memories are refused with `not_curated` |
|
|
673
|
+
| `author_identity_mode` | `"hashed"` | Author attribution in exports: `"hashed"` or `"none"` (**string** enum) |
|
|
674
|
+
| `shared_confidence_floor` | `"0.7"` | Gate for `kevin_share` selection and export — a **string**, read with `Number.parseFloat` and clamped to `[0, 1]`. Deliberately stricter than `injection_confidence_floor` (`0.6`): sharing is a commitment, injecting is a suggestion. `parseInt` on this setting would yield `0` and share everything |
|
|
675
|
+
|
|
676
|
+
All 23 settings are TEXT values; booleans and flags compare against `"1"`; the three v0.8 **string-valued** settings are `okf_path`, `author_identity_mode` and `shared_confidence_floor`.
|
|
677
|
+
|
|
678
|
+
---
|
|
679
|
+
|
|
680
|
+
## Development
|
|
681
|
+
|
|
682
|
+
```bash
|
|
683
|
+
git clone https://github.com/jmtrin/opencode-kevin.git
|
|
684
|
+
cd opencode-kevin
|
|
685
|
+
npm install
|
|
686
|
+
npm run typecheck # tsc --noEmit (strict)
|
|
687
|
+
npm run lint # biome check .
|
|
688
|
+
npm test # vitest run (unit + integration + e2e + replay)
|
|
689
|
+
npm run verify # post-install verification
|
|
690
|
+
npm run replay # replay report over tests/replay/fixtures
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
### Publishing (maintainer)
|
|
694
|
+
|
|
695
|
+
```bash
|
|
696
|
+
npm login # as the jmtrin account that owns the @jmtrin scope
|
|
697
|
+
npm publish --access public
|
|
698
|
+
```
|
|
699
|
+
|
|
700
|
+
`prepublishOnly` runs `npm run build` (tsc + copy migrations) automatically. The `files` field ships only `dist/plugin`, `dist/migrations`, and `migrations`. `dist/` is gitignored and rebuilt on publish.
|
|
701
|
+
|
|
702
|
+
### Structure
|
|
703
|
+
|
|
704
|
+
```
|
|
705
|
+
plugin/
|
|
706
|
+
index.ts # Entry point: KevinPlugin (wires hooks, tools, emissions)
|
|
707
|
+
Store.ts # SQLite wrapper (node:sqlite / bun:sqlite / better-sqlite3 fallback)
|
|
708
|
+
sqlite-adapter.ts # Runtime-agnostic SQLite adapter behind Store
|
|
709
|
+
Migrate.ts # Idempotent migrations + post-apply hooks
|
|
710
|
+
MemoryService.ts # save/query/getRelevant (FTS5 + bm25 + origin-aware rank + supersede)
|
|
711
|
+
ToolCallObserver.ts # onBefore/onAfter + redact + inferErrorType + dedup (opt-in)
|
|
712
|
+
Reflector.ts # Heuristic lessons + per-fingerprint throttle + LLM enrich (opt-in)
|
|
713
|
+
ContextInjector.ts # deriveQuery + pre-prompt/compacting injection + <kevin-suggestion>
|
|
714
|
+
Retrospective.ts # Generates retrospective.md + FP recap + metrics snapshot
|
|
715
|
+
Feedback.ts # kevin_feedback: verdicts, confidence terms, ignored stamp
|
|
716
|
+
Archiver.ts # Retires stale non-pattern memories past archive_after_days
|
|
717
|
+
CausalChain.ts # Links fixes to failures + promotes causal patterns
|
|
718
|
+
QualityGate.ts # Weak-lesson gate (stored, not injected by default)
|
|
719
|
+
InjectionLedger.ts # Injection ledger + settle → precision_rate
|
|
720
|
+
LessonFixer.ts # Deterministic fix_args capture + promotion enrichment
|
|
721
|
+
PatternMiner.ts # Opt-in deterministic 2-gram/3-gram miner
|
|
722
|
+
Curator.ts # Curation candidates + propose/approve lifecycle
|
|
723
|
+
ArtifactWriter.ts # The SINGLE write path (markers, atomic, noop, audit rows)
|
|
724
|
+
Materializer.ts # Pull-channel topic bundles (skills, refs)
|
|
725
|
+
inferability.ts # Deterministic inferable/non-inferable/unknown classifier
|
|
726
|
+
capabilities.ts # v2 domain probe (skills / references)
|
|
727
|
+
diff.ts # Minimal unified diff for proposal review
|
|
728
|
+
replay.ts # Hermetic replay driver over recorded transcripts
|
|
729
|
+
replay-types.ts # Transcript/result types for the replay harness
|
|
730
|
+
kevin_propose.ts # kevin_propose tool (strict dry run)
|
|
731
|
+
kevin_approve.ts # kevin_approve tool (only writer call site)
|
|
732
|
+
kevin_publish.ts # kevin_publish tool (bundle regeneration)
|
|
733
|
+
kevin_audit.ts # Read-only audit + channels/curation blocks
|
|
734
|
+
kevin_why.ts # kevin_why tool: failure→fix traces + related rules
|
|
735
|
+
SharedLayer.ts # v0.8: OKF plan/apply/tombstone + import → shared projections
|
|
736
|
+
RepoIdentity.ts # v0.8: repo_id resolution (declared → remote → path) + rekey
|
|
737
|
+
okf.ts # v0.8: OKF v2 parse/serialize (headers, entry_id, limits)
|
|
738
|
+
okf-export.ts # kevin_export: OKF/markdown export
|
|
739
|
+
okf-import.ts # kevin_import: bundle parser + import
|
|
740
|
+
confidence.ts # Two-sided computeConfidence (evidence + recurrence + feedback)
|
|
741
|
+
query-tokenizer.ts # FTS5 tokenizer for query sanitization
|
|
742
|
+
memory-format.ts # escapeInjectedText, formatMemories, <protect> + id: line wrappers
|
|
743
|
+
redact.ts # redactPaths + stripPrivate
|
|
744
|
+
fingerprint.ts # FNV-1a 64-bit (in-house, no node:crypto)
|
|
745
|
+
metrics.ts # In-memory counters + debounced flush to kevin_metrics
|
|
746
|
+
uuid.ts # UUIDv7
|
|
747
|
+
migrations/
|
|
748
|
+
001_initial.sql # schema: memories, tool_calls, retrospectives
|
|
749
|
+
002_indexes.sql # FTS5 + indexes
|
|
750
|
+
003_v02_signal.sql # fingerprint, origin, metrics, dedup indexes
|
|
751
|
+
004_v03_knowledge.sql # evidence/status/supersede, error_fingerprint
|
|
752
|
+
005_v04_signal.sql # recurrence_count, fix_args, last_injected_at
|
|
753
|
+
006_v05_glassbox.sql # ignored/archived/superseded_by, feedback, metrics
|
|
754
|
+
007_v06_pull.sql # curation_proposals, artifact_writes, curated/inferable
|
|
755
|
+
008_v07_truth.sql # facts + contradictions, conflict_detection settings
|
|
756
|
+
009_v08_team.sql # shared_entries, okf_imports, the five v0.8 settings
|
|
757
|
+
tests/
|
|
758
|
+
unit/ # component tests
|
|
759
|
+
integration/ # tool-level tests through real components
|
|
760
|
+
e2e/ # closed-loop tests through the host hooks
|
|
761
|
+
replay/ # transcript fixtures + replay harness tests
|
|
762
|
+
scripts/
|
|
763
|
+
copy-migrations.mjs # build step: copies *.sql to dist/migrations
|
|
764
|
+
verify-install.ts # npm run verify
|
|
765
|
+
```
|
|
766
|
+
|
|
767
|
+
---
|
|
768
|
+
|
|
769
|
+
## License
|
|
770
|
+
|
|
771
|
+
MIT
|