@jmtrin/opencode-kevin 0.7.0 → 0.9.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 (70) hide show
  1. package/README.md +254 -12
  2. package/dist/migrations/009_v08_team.sql +100 -0
  3. package/dist/migrations/010_v09_native.sql +78 -0
  4. package/dist/plugin/ArtifactWriter.d.ts +28 -0
  5. package/dist/plugin/ArtifactWriter.js +35 -2
  6. package/dist/plugin/ArtifactWriter.js.map +1 -1
  7. package/dist/plugin/ContextInjector.d.ts +9 -0
  8. package/dist/plugin/ContextInjector.js +14 -3
  9. package/dist/plugin/ContextInjector.js.map +1 -1
  10. package/dist/plugin/Curator.d.ts +22 -2
  11. package/dist/plugin/Curator.js +56 -14
  12. package/dist/plugin/Curator.js.map +1 -1
  13. package/dist/plugin/HookLiveness.d.ts +81 -0
  14. package/dist/plugin/HookLiveness.js +324 -0
  15. package/dist/plugin/HookLiveness.js.map +1 -0
  16. package/dist/plugin/InjectionLedger.d.ts +6 -0
  17. package/dist/plugin/InjectionLedger.js +6 -0
  18. package/dist/plugin/InjectionLedger.js.map +1 -1
  19. package/dist/plugin/Materializer.d.ts +29 -5
  20. package/dist/plugin/Materializer.js +48 -16
  21. package/dist/plugin/Materializer.js.map +1 -1
  22. package/dist/plugin/MemoryService.d.ts +34 -5
  23. package/dist/plugin/MemoryService.js +215 -7
  24. package/dist/plugin/MemoryService.js.map +1 -1
  25. package/dist/plugin/Migrate.d.ts +1 -0
  26. package/dist/plugin/Migrate.js +74 -3
  27. package/dist/plugin/Migrate.js.map +1 -1
  28. package/dist/plugin/RepoIdentity.d.ts +124 -0
  29. package/dist/plugin/RepoIdentity.js +301 -0
  30. package/dist/plugin/RepoIdentity.js.map +1 -0
  31. package/dist/plugin/Retrospective.js +18 -0
  32. package/dist/plugin/Retrospective.js.map +1 -1
  33. package/dist/plugin/SharedLayer.d.ts +159 -0
  34. package/dist/plugin/SharedLayer.js +463 -0
  35. package/dist/plugin/SharedLayer.js.map +1 -0
  36. package/dist/plugin/host.d.ts +70 -0
  37. package/dist/plugin/host.js +251 -0
  38. package/dist/plugin/host.js.map +1 -0
  39. package/dist/plugin/index.d.ts +30 -1
  40. package/dist/plugin/index.js +582 -12
  41. package/dist/plugin/index.js.map +1 -1
  42. package/dist/plugin/kevin_approve.js +7 -4
  43. package/dist/plugin/kevin_approve.js.map +1 -1
  44. package/dist/plugin/kevin_audit.d.ts +48 -1
  45. package/dist/plugin/kevin_audit.js +179 -3
  46. package/dist/plugin/kevin_audit.js.map +1 -1
  47. package/dist/plugin/kevin_doctor.d.ts +57 -0
  48. package/dist/plugin/kevin_doctor.js +168 -0
  49. package/dist/plugin/kevin_doctor.js.map +1 -0
  50. package/dist/plugin/kevin_native.d.ts +29 -0
  51. package/dist/plugin/kevin_native.js +80 -0
  52. package/dist/plugin/kevin_native.js.map +1 -0
  53. package/dist/plugin/metrics.d.ts +1 -1
  54. package/dist/plugin/metrics.js +9 -0
  55. package/dist/plugin/metrics.js.map +1 -1
  56. package/dist/plugin/native.d.ts +92 -0
  57. package/dist/plugin/native.js +191 -0
  58. package/dist/plugin/native.js.map +1 -0
  59. package/dist/plugin/okf-export.d.ts +2 -2
  60. package/dist/plugin/okf-export.js +15 -7
  61. package/dist/plugin/okf-export.js.map +1 -1
  62. package/dist/plugin/okf.d.ts +107 -0
  63. package/dist/plugin/okf.js +304 -0
  64. package/dist/plugin/okf.js.map +1 -0
  65. package/dist/plugin/replay-types.d.ts +29 -287
  66. package/dist/plugin/replay-types.js +145 -53
  67. package/dist/plugin/replay-types.js.map +1 -1
  68. package/migrations/009_v08_team.sql +100 -0
  69. package/migrations/010_v09_native.sql +78 -0
  70. package/package.json +2 -3
@@ -0,0 +1,100 @@
1
+ -- ============================================================
2
+ -- Kevin 0.8.0 - Migration 009: Team (additive)
3
+ -- ============================================================
4
+ -- Backward-compatible, additive only. All new columns are
5
+ -- nullable or carry a NOT NULL DEFAULT so legacy rows keep
6
+ -- working without a destructive rebuild.
7
+ --
8
+ -- Scope note: this migration introduces `repo_id`, a SECOND
9
+ -- scoping dimension. `project_id` is retained on every table,
10
+ -- unchanged, as local-path provenance (D8-02). Nothing that
11
+ -- reads `project_id` today stops working.
12
+ -- ============================================================
13
+
14
+ -- 1. shared_entries: the local projection of the committed OKF file.
15
+ -- One row per (repo_id, entry_id). Rewritten by SharedLayer.import(),
16
+ -- never edited by hand, never the source of truth - the file is.
17
+ -- No REFERENCES to memories: an entry may arrive from a teammate
18
+ -- before any local memory corresponds to it (D8-12).
19
+ CREATE TABLE IF NOT EXISTS shared_entries (
20
+ id TEXT PRIMARY KEY,
21
+ repo_id TEXT NOT NULL,
22
+ entry_id TEXT NOT NULL,
23
+ type TEXT NOT NULL CHECK (type IN ('decision', 'rule', 'pattern', 'solution')),
24
+ statement TEXT NOT NULL,
25
+ scope TEXT,
26
+ confidence REAL NOT NULL DEFAULT 0.0,
27
+ evidence INTEGER NOT NULL DEFAULT 0,
28
+ origin TEXT NOT NULL DEFAULT 'shared',
29
+ author_hash TEXT,
30
+ op TEXT NOT NULL CHECK (op IN ('assert', 'tombstone')) DEFAULT 'assert',
31
+ supersedes TEXT,
32
+ created_at TEXT NOT NULL,
33
+ imported_at TEXT NOT NULL DEFAULT (datetime('now'))
34
+ );
35
+
36
+ -- 1b. Identity is (repo_id, entry_id). The UNIQUE index is what makes
37
+ -- import() an idempotent upsert instead of an append.
38
+ CREATE UNIQUE INDEX IF NOT EXISTS uq_shared_entries
39
+ ON shared_entries(repo_id, entry_id);
40
+ CREATE INDEX IF NOT EXISTS idx_shared_entries_op
41
+ ON shared_entries(op);
42
+ CREATE INDEX IF NOT EXISTS idx_shared_entries_type
43
+ ON shared_entries(type);
44
+
45
+ -- 2. okf_imports: append-only audit of every read of the shared file,
46
+ -- including no-op reads and refusals. `file_hash` drives the skip
47
+ -- path in SharedLayer.import() (D8-14).
48
+ CREATE TABLE IF NOT EXISTS okf_imports (
49
+ id TEXT PRIMARY KEY,
50
+ repo_id TEXT NOT NULL,
51
+ path TEXT NOT NULL,
52
+ file_hash TEXT,
53
+ entries_parsed INTEGER NOT NULL DEFAULT 0,
54
+ entries_folded INTEGER NOT NULL DEFAULT 0,
55
+ entries_rejected INTEGER NOT NULL DEFAULT 0,
56
+ skipped INTEGER NOT NULL DEFAULT 0,
57
+ imported_at TEXT NOT NULL DEFAULT (datetime('now'))
58
+ );
59
+
60
+ CREATE INDEX IF NOT EXISTS idx_okf_imports_repo
61
+ ON okf_imports(repo_id, imported_at);
62
+
63
+ -- 3. memories: the second scoping dimension and the layer marker.
64
+ -- repo_id is NULLABLE and back-filled by the post-apply hook, not by
65
+ -- a DEFAULT: the value depends on the row's existing project_id and
66
+ -- SQLite cannot express that in a column default.
67
+ -- layer carries NO CHECK constraint - widening it later would force
68
+ -- the migration-004 rebuild path (D8-07). Enforced in TypeScript.
69
+ ALTER TABLE memories ADD COLUMN repo_id TEXT;
70
+ ALTER TABLE memories ADD COLUMN layer TEXT NOT NULL DEFAULT 'local';
71
+ ALTER TABLE memories ADD COLUMN shared_entry_id TEXT;
72
+
73
+ CREATE INDEX IF NOT EXISTS idx_memories_repo_id
74
+ ON memories(repo_id, status);
75
+ CREATE INDEX IF NOT EXISTS idx_memories_layer
76
+ ON memories(layer);
77
+
78
+ -- 4. kevin_metrics: seed the six v0.8 counters (33 -> 39).
79
+ INSERT OR IGNORE INTO kevin_metrics (key, value) VALUES
80
+ ('shared_entries_total', 0),
81
+ ('shared_entries_imported', 0),
82
+ ('shared_entries_exported', 0),
83
+ ('okf_merge_folds', 0),
84
+ ('rekey_events', 0),
85
+ ('injections_from_shared', 0);
86
+
87
+ -- 5. kevin_settings: seed the five v0.8 flags (18 -> 23).
88
+ -- shared_layer_enabled defaults OFF: this release must be opted into,
89
+ -- because its first side effect is a new file in the user's repository.
90
+ -- shared_confidence_floor (0.7) is deliberately STRICTER than
91
+ -- injection_confidence_floor (0.6) - see 5.7.
92
+ INSERT OR IGNORE INTO kevin_settings (key, value) VALUES
93
+ ('shared_layer_enabled', '0'),
94
+ ('okf_path', '.kevin/knowledge.okf'),
95
+ ('share_requires_approval', '1'),
96
+ ('author_identity_mode', 'hashed'),
97
+ ('shared_confidence_floor', '0.7');
98
+
99
+ -- 6. Seed version 009.
100
+ INSERT OR IGNORE INTO schema_version (version) VALUES ('009');
@@ -0,0 +1,78 @@
1
+ -- ============================================================
2
+ -- Kevin v0.9.0 "Native" — host surface and hook liveness
3
+ -- Migration 010. Additive only. No table rebuild.
4
+ -- ============================================================
5
+
6
+ -- 1. Hook liveness. Deliberately NOT project-scoped: a hook is a
7
+ -- property of the host binary, not of a checkout. One row per
8
+ -- hook name, updated in place. See D9-08.
9
+ CREATE TABLE IF NOT EXISTS hook_liveness (
10
+ hook TEXT PRIMARY KEY,
11
+ experimental INTEGER NOT NULL DEFAULT 0,
12
+ fire_count INTEGER NOT NULL DEFAULT 0,
13
+ error_count INTEGER NOT NULL DEFAULT 0,
14
+ expected_count INTEGER NOT NULL DEFAULT 0,
15
+ first_seen_at TEXT,
16
+ last_seen_at TEXT,
17
+ dead_since TEXT,
18
+ plugin_version TEXT
19
+ );
20
+
21
+ CREATE INDEX IF NOT EXISTS idx_hook_liveness_dead
22
+ ON hook_liveness(dead_since);
23
+
24
+ -- 2. Host probe history. Append-only. Off by default; exists so a
25
+ -- user chasing an intermittent fault can turn it on and get a
26
+ -- timeline instead of a single current value.
27
+ CREATE TABLE IF NOT EXISTS host_probes (
28
+ id TEXT PRIMARY KEY,
29
+ probed_at TEXT NOT NULL DEFAULT (datetime('now')),
30
+ plugin_version TEXT,
31
+ flavour TEXT NOT NULL,
32
+ has_shell INTEGER NOT NULL DEFAULT 0,
33
+ v2_skill INTEGER NOT NULL DEFAULT 0,
34
+ v2_reference INTEGER NOT NULL DEFAULT 0,
35
+ notes TEXT
36
+ );
37
+
38
+ CREATE INDEX IF NOT EXISTS idx_host_probes_at
39
+ ON host_probes(probed_at);
40
+
41
+ -- 3. Native registration outcomes. One row per attach attempt, so
42
+ -- "registered but unverified" is a queryable state rather than a
43
+ -- log line.
44
+ CREATE TABLE IF NOT EXISTS native_registrations (
45
+ id TEXT PRIMARY KEY,
46
+ attached_at TEXT NOT NULL DEFAULT (datetime('now')),
47
+ surface TEXT NOT NULL CHECK (surface IN ('skill', 'reference')),
48
+ registered INTEGER NOT NULL DEFAULT 0,
49
+ verified INTEGER NOT NULL DEFAULT 0,
50
+ note TEXT
51
+ );
52
+
53
+ CREATE INDEX IF NOT EXISTS idx_native_registrations_surface
54
+ ON native_registrations(surface, attached_at);
55
+
56
+ -- 4. Metric seeds (39 -> 45).
57
+ INSERT OR IGNORE INTO kevin_metrics (key, value) VALUES
58
+ ('hook_fires_total', 0),
59
+ ('hook_errors_total', 0),
60
+ ('hooks_dead_total', 0),
61
+ ('injections_suppressed_dead_hook', 0),
62
+ ('native_registrations_total', 0),
63
+ ('native_registration_failures', 0);
64
+
65
+ -- 5. Setting seeds (23 -> 27).
66
+ -- hook_liveness_enabled defaults ON: it is a read-only instrument
67
+ -- on the success path, and an instrument nobody switches on is an
68
+ -- instrument nobody has.
69
+ -- native_registration_enabled defaults OFF: it changes where a
70
+ -- curated skill comes from, and that is a change a user opts into.
71
+ INSERT OR IGNORE INTO kevin_settings (key, value) VALUES
72
+ ('hook_liveness_enabled', '1'),
73
+ ('native_registration_enabled', '0'),
74
+ ('host_probe_history_enabled', '0'),
75
+ ('dead_hook_report_threshold', '3');
76
+
77
+ -- 6. Version marker.
78
+ INSERT OR IGNORE INTO schema_version (version) VALUES ('010');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jmtrin/opencode-kevin",
3
- "version": "0.7.0",
3
+ "version": "0.9.0",
4
4
  "description": "Kevin — Observa y aprende: capa de aprendizaje para OpenCode",
5
5
  "type": "module",
6
6
  "main": "dist/plugin/index.js",
@@ -26,8 +26,7 @@
26
26
  "measure:mix": "node --import tsx scripts/measure-mix.ts"
27
27
  },
28
28
  "dependencies": {
29
- "@opencode-ai/plugin": "^1.17.6",
30
- "zod": "^3.23.8"
29
+ "@opencode-ai/plugin": "^1.18.16"
31
30
  },
32
31
  "optionalDependencies": {
33
32
  "better-sqlite3": "^12.11.0"