@jmtrin/opencode-kevin 0.4.0 → 0.6.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 (76) hide show
  1. package/README.md +580 -360
  2. package/dist/migrations/006_v05_glassbox.sql +118 -0
  3. package/dist/migrations/007_v06_pull.sql +145 -0
  4. package/dist/plugin/Archiver.d.ts +42 -0
  5. package/dist/plugin/Archiver.js +99 -0
  6. package/dist/plugin/Archiver.js.map +1 -0
  7. package/dist/plugin/ArtifactWriter.d.ts +50 -0
  8. package/dist/plugin/ArtifactWriter.js +240 -0
  9. package/dist/plugin/ArtifactWriter.js.map +1 -0
  10. package/dist/plugin/ContextInjector.d.ts +87 -0
  11. package/dist/plugin/ContextInjector.js +212 -44
  12. package/dist/plugin/ContextInjector.js.map +1 -1
  13. package/dist/plugin/Curator.d.ts +96 -0
  14. package/dist/plugin/Curator.js +252 -0
  15. package/dist/plugin/Curator.js.map +1 -0
  16. package/dist/plugin/Feedback.d.ts +67 -0
  17. package/dist/plugin/Feedback.js +138 -0
  18. package/dist/plugin/Feedback.js.map +1 -0
  19. package/dist/plugin/InjectionLedger.d.ts +9 -2
  20. package/dist/plugin/InjectionLedger.js +63 -9
  21. package/dist/plugin/InjectionLedger.js.map +1 -1
  22. package/dist/plugin/Materializer.d.ts +59 -0
  23. package/dist/plugin/Materializer.js +237 -0
  24. package/dist/plugin/Materializer.js.map +1 -0
  25. package/dist/plugin/MemoryService.d.ts +38 -0
  26. package/dist/plugin/MemoryService.js +265 -30
  27. package/dist/plugin/MemoryService.js.map +1 -1
  28. package/dist/plugin/Migrate.js +41 -0
  29. package/dist/plugin/Migrate.js.map +1 -1
  30. package/dist/plugin/QualityGate.d.ts +53 -0
  31. package/dist/plugin/QualityGate.js +50 -8
  32. package/dist/plugin/QualityGate.js.map +1 -1
  33. package/dist/plugin/Retrospective.d.ts +1 -0
  34. package/dist/plugin/Retrospective.js +24 -1
  35. package/dist/plugin/Retrospective.js.map +1 -1
  36. package/dist/plugin/capabilities.d.ts +15 -0
  37. package/dist/plugin/capabilities.js +42 -0
  38. package/dist/plugin/capabilities.js.map +1 -0
  39. package/dist/plugin/confidence.d.ts +3 -1
  40. package/dist/plugin/confidence.js +14 -2
  41. package/dist/plugin/confidence.js.map +1 -1
  42. package/dist/plugin/diff.d.ts +8 -0
  43. package/dist/plugin/diff.js +183 -0
  44. package/dist/plugin/diff.js.map +1 -0
  45. package/dist/plugin/index.d.ts +3 -1
  46. package/dist/plugin/index.js +371 -0
  47. package/dist/plugin/index.js.map +1 -1
  48. package/dist/plugin/inferability.d.ts +32 -0
  49. package/dist/plugin/inferability.js +89 -0
  50. package/dist/plugin/inferability.js.map +1 -0
  51. package/dist/plugin/kevin_approve.d.ts +34 -0
  52. package/dist/plugin/kevin_approve.js +50 -0
  53. package/dist/plugin/kevin_approve.js.map +1 -0
  54. package/dist/plugin/kevin_audit.d.ts +95 -0
  55. package/dist/plugin/kevin_audit.js +233 -0
  56. package/dist/plugin/kevin_audit.js.map +1 -0
  57. package/dist/plugin/kevin_propose.d.ts +23 -0
  58. package/dist/plugin/kevin_propose.js +15 -0
  59. package/dist/plugin/kevin_propose.js.map +1 -0
  60. package/dist/plugin/kevin_publish.d.ts +38 -0
  61. package/dist/plugin/kevin_publish.js +19 -0
  62. package/dist/plugin/kevin_publish.js.map +1 -0
  63. package/dist/plugin/kevin_why.js +23 -2
  64. package/dist/plugin/kevin_why.js.map +1 -1
  65. package/dist/plugin/metrics.d.ts +32 -1
  66. package/dist/plugin/metrics.js +86 -2
  67. package/dist/plugin/metrics.js.map +1 -1
  68. package/dist/plugin/replay-types.d.ts +327 -0
  69. package/dist/plugin/replay-types.js +65 -0
  70. package/dist/plugin/replay-types.js.map +1 -0
  71. package/dist/plugin/replay.d.ts +36 -0
  72. package/dist/plugin/replay.js +203 -0
  73. package/dist/plugin/replay.js.map +1 -0
  74. package/migrations/006_v05_glassbox.sql +118 -0
  75. package/migrations/007_v06_pull.sql +145 -0
  76. package/package.json +3 -2
@@ -0,0 +1,59 @@
1
+ import type { ArtifactWriter, WriteOutcome } from "./ArtifactWriter.js";
2
+ import type { Store } from "./Store.js";
3
+ /**
4
+ * K6-017 — v0.6.0 pull — topic bundles for the pull channels (plan §5.6).
5
+ *
6
+ * Writes `~/.opencode-kevin/refs/<topic>.md` (one file per topic) and
7
+ * `~/.opencode-kevin/skills/project-knowledge.md` (one file). Both go
8
+ * through the `ArtifactWriter` — marker-scoped, atomic, hash-audited.
9
+ * There is no direct raw file-write anywhere in this module (D6-01).
10
+ *
11
+ * Topic derivation is deterministic and semantic (D6-14): a topic is
12
+ * `<type>-<dominant token>`, where the dominant token is the
13
+ * highest-frequency non-stop-word token of the fingerprint-normalized
14
+ * content across the memories in the group, ties broken lexicographically.
15
+ * Topics are NEVER derived from a fingerprint prefix, and hash-like tokens
16
+ * (hex-only, length >= 8) are excluded from the race entirely.
17
+ *
18
+ * Output ordering within each bundle is by memory id, matching §5.4.
19
+ * Regeneration with unchanged inputs is a `noop` at the ArtifactWriter
20
+ * level, so the "run twice, compare bytes" criterion holds for every
21
+ * bundle.
22
+ */
23
+ export interface MaterializedBundle {
24
+ readonly topic: string;
25
+ readonly path: string;
26
+ readonly outcome: WriteOutcome;
27
+ }
28
+ export interface BundleTarget {
29
+ readonly topic: string;
30
+ readonly path: string;
31
+ }
32
+ export declare const SKILL_TOPIC = "project-knowledge";
33
+ export declare class Materializer {
34
+ private readonly store;
35
+ /** `root` is injectable for tests; production defaults to ~/.opencode-kevin. */
36
+ private readonly root;
37
+ constructor(store: Store, options?: {
38
+ root?: string;
39
+ });
40
+ /** The curated, active memories — the knowledge the pull channels publish. */
41
+ private curatedRows;
42
+ /** The rendered skill body over all curated memories; "" when empty. */
43
+ skillBody(): string;
44
+ /** Group rows by type, deriving each type's topic from its own content. */
45
+ private groupByTopic;
46
+ /**
47
+ * The pull-channel targets: the skill file plus one ref file per topic.
48
+ * The order is deterministic (skill first, refs by topic).
49
+ */
50
+ bundleTargets(): BundleTarget[];
51
+ /**
52
+ * Regenerate every bundle through the ArtifactWriter (plan + apply).
53
+ * The only call site of `apply()` outside `kevin_approve` — D6-01's
54
+ * single write FUNCTION with two constrained targets: `kevin_approve`
55
+ * reaches `agents_md_path`, this module reaches `~/.opencode-kevin`
56
+ * only (D6-07; enforced by K6-020).
57
+ */
58
+ materialize(writer: ArtifactWriter): MaterializedBundle[];
59
+ }
@@ -0,0 +1,237 @@
1
+ import { homedir } from "node:os";
2
+ import { join } from "node:path";
3
+ import { firstSentence } from "./Curator.js";
4
+ import { normalize } from "./fingerprint.js";
5
+ export const SKILL_TOPIC = "project-knowledge";
6
+ /** Hash-like noise: FNV-1a output is 16 lowercase hex chars; an 8+ hex
7
+ * token is indistinguishable from a fingerprint prefix and must never
8
+ * become a topic (D6-14). */
9
+ const HEX_LIKE_RE = /^[0-9a-f]{8,}$/;
10
+ const TOKEN_RE = /[^a-z0-9]+/;
11
+ /** Conservative English function words; code-adjacent meaning-bearing
12
+ * words (npm, ts2304, cargo...) are deliberately NOT stop-words. */
13
+ const STOP_WORDS = new Set([
14
+ "a",
15
+ "about",
16
+ "after",
17
+ "again",
18
+ "all",
19
+ "also",
20
+ "an",
21
+ "and",
22
+ "any",
23
+ "are",
24
+ "as",
25
+ "at",
26
+ "be",
27
+ "been",
28
+ "before",
29
+ "being",
30
+ "but",
31
+ "by",
32
+ "can",
33
+ "could",
34
+ "did",
35
+ "do",
36
+ "does",
37
+ "for",
38
+ "from",
39
+ "had",
40
+ "has",
41
+ "have",
42
+ "he",
43
+ "her",
44
+ "his",
45
+ "if",
46
+ "in",
47
+ "into",
48
+ "is",
49
+ "it",
50
+ "its",
51
+ "may",
52
+ "might",
53
+ "more",
54
+ "most",
55
+ "must",
56
+ "not",
57
+ "of",
58
+ "on",
59
+ "one",
60
+ "or",
61
+ "our",
62
+ "per",
63
+ "shall",
64
+ "she",
65
+ "so",
66
+ "than",
67
+ "that",
68
+ "the",
69
+ "their",
70
+ "them",
71
+ "then",
72
+ "there",
73
+ "these",
74
+ "they",
75
+ "this",
76
+ "those",
77
+ "through",
78
+ "to",
79
+ "too",
80
+ "under",
81
+ "up",
82
+ "us",
83
+ "via",
84
+ "was",
85
+ "we",
86
+ "were",
87
+ "what",
88
+ "when",
89
+ "where",
90
+ "which",
91
+ "while",
92
+ "who",
93
+ "will",
94
+ "with",
95
+ "would",
96
+ "you",
97
+ "your",
98
+ ]);
99
+ /** Sanitize a memory type into a filesystem-safe topic prefix. */
100
+ function sanitizeType(type) {
101
+ const cleaned = type
102
+ .toLowerCase()
103
+ .replace(/[^a-z0-9]+/g, "-")
104
+ .replace(/-+/g, "-")
105
+ .replace(/^-|-$/g, "");
106
+ return cleaned === "" ? "memory" : cleaned;
107
+ }
108
+ function tokensOf(content) {
109
+ return normalize(content)
110
+ .split(TOKEN_RE)
111
+ .filter((t) => t !== "" && !STOP_WORDS.has(t) && !HEX_LIKE_RE.test(t));
112
+ }
113
+ /** Highest-frequency non-stop-word token, ties broken lexicographically
114
+ * (smallest wins) so the result is stable. "" when every token is a
115
+ * stop-word or hash-like noise. */
116
+ function dominantToken(rows) {
117
+ const counts = new Map();
118
+ for (const row of rows) {
119
+ for (const token of tokensOf(row.content)) {
120
+ counts.set(token, (counts.get(token) ?? 0) + 1);
121
+ }
122
+ }
123
+ let best = "";
124
+ let bestCount = 0;
125
+ for (const [token, count] of counts) {
126
+ if (count > bestCount || (count === bestCount && token < best)) {
127
+ best = token;
128
+ bestCount = count;
129
+ }
130
+ }
131
+ return best;
132
+ }
133
+ function renderRows(rows) {
134
+ const sorted = [...rows].sort((a, b) => a.id.localeCompare(b.id));
135
+ const lines = sorted
136
+ .map((row) => `- ${firstSentence(row.content)}`)
137
+ .filter((line) => line !== "- ");
138
+ return lines.length === 0 ? "" : `${lines.join("\n")}\n`;
139
+ }
140
+ export class Materializer {
141
+ store;
142
+ /** `root` is injectable for tests; production defaults to ~/.opencode-kevin. */
143
+ root;
144
+ constructor(store, options = {}) {
145
+ this.store = store;
146
+ this.root = options.root ?? join(homedir(), ".opencode-kevin");
147
+ }
148
+ /** The curated, active memories — the knowledge the pull channels publish. */
149
+ curatedRows() {
150
+ return this.store
151
+ .prepare(`SELECT id, type, content FROM memories
152
+ WHERE status = 'active' AND curated = 1`)
153
+ .all();
154
+ }
155
+ /** The rendered skill body over all curated memories; "" when empty. */
156
+ skillBody() {
157
+ return renderRows(this.curatedRows());
158
+ }
159
+ /** Group rows by type, deriving each type's topic from its own content. */
160
+ groupByTopic(rows) {
161
+ const byType = new Map();
162
+ for (const row of rows) {
163
+ const list = byType.get(row.type) ?? [];
164
+ list.push(row);
165
+ byType.set(row.type, list);
166
+ }
167
+ const groups = [];
168
+ for (const [type, typeRows] of byType) {
169
+ const token = dominantToken(typeRows);
170
+ if (token === "")
171
+ continue;
172
+ groups.push({
173
+ topic: `${sanitizeType(type)}-${token}`,
174
+ rows: typeRows,
175
+ });
176
+ }
177
+ return groups.sort((a, b) => a.topic.localeCompare(b.topic));
178
+ }
179
+ /**
180
+ * The pull-channel targets: the skill file plus one ref file per topic.
181
+ * The order is deterministic (skill first, refs by topic).
182
+ */
183
+ bundleTargets() {
184
+ const rows = this.curatedRows();
185
+ const targets = [];
186
+ if (rows.length > 0 && renderRows(rows) !== "") {
187
+ targets.push({
188
+ topic: SKILL_TOPIC,
189
+ path: join(this.root, "skills", "project-knowledge.md"),
190
+ });
191
+ }
192
+ for (const group of this.groupByTopic(rows)) {
193
+ if (renderRows(group.rows) === "")
194
+ continue;
195
+ targets.push({
196
+ topic: group.topic,
197
+ path: join(this.root, "refs", `${group.topic}.md`),
198
+ });
199
+ }
200
+ return targets;
201
+ }
202
+ /**
203
+ * Regenerate every bundle through the ArtifactWriter (plan + apply).
204
+ * The only call site of `apply()` outside `kevin_approve` — D6-01's
205
+ * single write FUNCTION with two constrained targets: `kevin_approve`
206
+ * reaches `agents_md_path`, this module reaches `~/.opencode-kevin`
207
+ * only (D6-07; enforced by K6-020).
208
+ */
209
+ materialize(writer) {
210
+ const pending = [];
211
+ const rows = this.curatedRows();
212
+ const skillBody = renderRows(rows);
213
+ if (skillBody !== "") {
214
+ pending.push({
215
+ topic: SKILL_TOPIC,
216
+ path: join(this.root, "skills", "project-knowledge.md"),
217
+ body: skillBody,
218
+ });
219
+ }
220
+ for (const group of this.groupByTopic(rows)) {
221
+ const body = renderRows(group.rows);
222
+ if (body === "")
223
+ continue;
224
+ pending.push({
225
+ topic: group.topic,
226
+ path: join(this.root, "refs", `${group.topic}.md`),
227
+ body,
228
+ });
229
+ }
230
+ return pending.map((bundle) => ({
231
+ topic: bundle.topic,
232
+ path: bundle.path,
233
+ outcome: writer.apply(writer.plan(bundle.path, bundle.body)),
234
+ }));
235
+ }
236
+ }
237
+ //# sourceMappingURL=Materializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Materializer.js","sourceRoot":"","sources":["../../plugin/Materializer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAkC7C,MAAM,CAAC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AAE/C;;6BAE6B;AAC7B,MAAM,WAAW,GAAG,gBAAgB,CAAC;AAErC,MAAM,QAAQ,GAAG,YAAY,CAAC;AAE9B;oEACoE;AACpE,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC;IAC1B,GAAG;IACH,OAAO;IACP,OAAO;IACP,OAAO;IACP,KAAK;IACL,MAAM;IACN,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,IAAI;IACJ,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,QAAQ;IACR,OAAO;IACP,KAAK;IACL,IAAI;IACJ,KAAK;IACL,OAAO;IACP,KAAK;IACL,IAAI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ACnC,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC;YACtB,OAAO,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,WAAW;gBAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,EAAE,sBAAsB,CAAC;gBACvD,IAAI,EAAE,SAAS;aACf,CAAC,CAAC;QACJ,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;YAC7C,MAAM,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;YACpC,IAAI,IAAI,KAAK,EAAE;gBAAE,SAAS;YAC1B,OAAO,CAAC,IAAI,CAAC;gBACZ,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,KAAK,CAAC,KAAK,KAAK,CAAC;gBAClD,IAAI;aACJ,CAAC,CAAC;QACJ,CAAC;QACD,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;YAC/B,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;SAC5D,CAAC,CAAC,CAAC;IACL,CAAC;CACD"}
@@ -34,6 +34,26 @@ export interface Memory {
34
34
  /** v0.4.0 (BUG-008/010) — negative evidence: how many times the
35
35
  * fingerprint recurred after injection (demotes confidence). */
36
36
  recurrenceCount?: number | null;
37
+ /** v0.5.0 (K5-009 / plan §5.3, D5-07) — human verdict: ignored memories
38
+ * are excluded from retrieval and injection. */
39
+ ignored?: boolean;
40
+ /** v0.5.0 (K5-009 / plan §5.3) — id of the memory that superseded this
41
+ * one (decision/rule replacement, K3-014). Null when active. */
42
+ supersedes?: string | null;
43
+ /** v0.5.0 (K5-010 / plan §5.3, D5-02) — human judgement counters,
44
+ * folded into confidence by computeConfidence. */
45
+ feedbackPositive?: number;
46
+ /** v0.6.0 (K6-011 / plan §5.4) — curation state: curated memories have
47
+ * been written to AGENTS.md and are excluded from new candidates. */
48
+ curated?: boolean;
49
+ /** v0.6.0 (K6-011 / plan §5.4) — when the memory was curated (ISO time). */
50
+ curatedAt?: string | null;
51
+ /** v0.6.0 (K6-011 / plan §5.3) — deterministic inferability verdict from
52
+ * `inferability.classify()`; `null` = unknown, never collapsed. */
53
+ inferable?: "inferable" | "non_inferable" | null;
54
+ /** v0.5.0 (K5-010 / plan §5.3, D5-02) — human judgement counters,
55
+ * folded into confidence by computeConfidence. */
56
+ feedbackNegative?: number;
37
57
  }
38
58
  export interface SaveInput {
39
59
  type: MemoryType;
@@ -113,14 +133,32 @@ export interface GetRelevantInput {
113
133
  * by the fetch that actually produces the injected block.
114
134
  */
115
135
  bump?: boolean;
136
+ /**
137
+ * v0.5.0 (K5-008 / plan §5.6, D5-10) — injectable clock. Defaults to
138
+ * `new Date()` at the top of the method and is the ONLY time source
139
+ * for recency decay: replay and tests can freeze time. Never call
140
+ * `Date.now()` again inside the method.
141
+ */
142
+ now?: Date;
116
143
  }
144
+ export declare const DATE_NOW = "2099-01-01T00:00:00.000Z";
117
145
  export declare class MemoryService {
118
146
  private readonly metrics;
119
147
  constructor(store: Store, metrics?: Metrics | null);
120
148
  private store;
121
149
  private hasRecurrenceColumn;
122
150
  private _hasRecurrenceColumn;
151
+ private hasIgnoredColumn;
152
+ private hasCuratedColumn;
123
153
  save(input: SaveInput): string;
154
+ /**
155
+ * v0.6.0 (K6-011 / plan §5.4) — mark memories as curated. Batch in a
156
+ * single statement with an `IN` clause; do not loop. Returns the number
157
+ * of rows matched by the statement (not only rows whose value changed):
158
+ * a second call with the same ids re-matches them, so the caller must
159
+ * re-filter the id list (e.g. by `curated = 0`) to observe 0.
160
+ */
161
+ markCurated(ids: readonly string[], at: string): number;
124
162
  getById(id: string): Memory | null;
125
163
  /**
126
164
  * v0.4.0 (K4-016) — most recent ACTIVE memory for a fingerprint,