@jmtrin/opencode-kevin 0.3.0 → 0.5.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 (72) hide show
  1. package/README.md +117 -9
  2. package/dist/migrations/005_v04_signal.sql +57 -0
  3. package/dist/migrations/006_v05_glassbox.sql +118 -0
  4. package/dist/plugin/Archiver.d.ts +42 -0
  5. package/dist/plugin/Archiver.js +98 -0
  6. package/dist/plugin/Archiver.js.map +1 -0
  7. package/dist/plugin/CausalChain.d.ts +13 -2
  8. package/dist/plugin/CausalChain.js +83 -13
  9. package/dist/plugin/CausalChain.js.map +1 -1
  10. package/dist/plugin/ContextInjector.d.ts +152 -4
  11. package/dist/plugin/ContextInjector.js +400 -93
  12. package/dist/plugin/ContextInjector.js.map +1 -1
  13. package/dist/plugin/Feedback.d.ts +67 -0
  14. package/dist/plugin/Feedback.js +137 -0
  15. package/dist/plugin/Feedback.js.map +1 -0
  16. package/dist/plugin/InjectionLedger.d.ts +92 -0
  17. package/dist/plugin/InjectionLedger.js +243 -0
  18. package/dist/plugin/InjectionLedger.js.map +1 -0
  19. package/dist/plugin/LessonFixer.d.ts +44 -0
  20. package/dist/plugin/LessonFixer.js +46 -0
  21. package/dist/plugin/LessonFixer.js.map +1 -0
  22. package/dist/plugin/MemoryService.d.ts +81 -1
  23. package/dist/plugin/MemoryService.js +321 -54
  24. package/dist/plugin/MemoryService.js.map +1 -1
  25. package/dist/plugin/Migrate.js +31 -0
  26. package/dist/plugin/Migrate.js.map +1 -1
  27. package/dist/plugin/QualityGate.d.ts +110 -0
  28. package/dist/plugin/QualityGate.js +108 -0
  29. package/dist/plugin/QualityGate.js.map +1 -0
  30. package/dist/plugin/Reflector.d.ts +17 -0
  31. package/dist/plugin/Reflector.js +81 -26
  32. package/dist/plugin/Reflector.js.map +1 -1
  33. package/dist/plugin/Retrospective.js +22 -1
  34. package/dist/plugin/Retrospective.js.map +1 -1
  35. package/dist/plugin/ToolCallObserver.d.ts +1 -0
  36. package/dist/plugin/ToolCallObserver.js +15 -8
  37. package/dist/plugin/ToolCallObserver.js.map +1 -1
  38. package/dist/plugin/confidence.d.ts +8 -0
  39. package/dist/plugin/confidence.js +35 -0
  40. package/dist/plugin/confidence.js.map +1 -0
  41. package/dist/plugin/index.d.ts +5 -0
  42. package/dist/plugin/index.js +368 -44
  43. package/dist/plugin/index.js.map +1 -1
  44. package/dist/plugin/kevin_audit.d.ts +49 -0
  45. package/dist/plugin/kevin_audit.js +141 -0
  46. package/dist/plugin/kevin_audit.js.map +1 -0
  47. package/dist/plugin/kevin_why.d.ts +4 -0
  48. package/dist/plugin/kevin_why.js +72 -35
  49. package/dist/plugin/kevin_why.js.map +1 -1
  50. package/dist/plugin/memory-format.d.ts +12 -0
  51. package/dist/plugin/memory-format.js +45 -5
  52. package/dist/plugin/memory-format.js.map +1 -1
  53. package/dist/plugin/metrics.d.ts +27 -1
  54. package/dist/plugin/metrics.js +61 -0
  55. package/dist/plugin/metrics.js.map +1 -1
  56. package/dist/plugin/okf-export.js +63 -22
  57. package/dist/plugin/okf-export.js.map +1 -1
  58. package/dist/plugin/okf-import.d.ts +4 -1
  59. package/dist/plugin/okf-import.js +45 -12
  60. package/dist/plugin/okf-import.js.map +1 -1
  61. package/dist/plugin/query-tokenizer.d.ts +13 -0
  62. package/dist/plugin/query-tokenizer.js +86 -0
  63. package/dist/plugin/query-tokenizer.js.map +1 -0
  64. package/dist/plugin/replay-types.d.ts +327 -0
  65. package/dist/plugin/replay-types.js +65 -0
  66. package/dist/plugin/replay-types.js.map +1 -0
  67. package/dist/plugin/replay.d.ts +36 -0
  68. package/dist/plugin/replay.js +193 -0
  69. package/dist/plugin/replay.js.map +1 -0
  70. package/migrations/005_v04_signal.sql +57 -0
  71. package/migrations/006_v05_glassbox.sql +118 -0
  72. package/package.json +3 -2
@@ -29,10 +29,28 @@ export interface Memory {
29
29
  lastVerifiedAt?: string | null;
30
30
  /** v0.3.0 — lifecycle status. Default 'active'. */
31
31
  status?: string | null;
32
+ /** v0.4.0 — deterministic capture of the linked fix call (K4-014). */
33
+ fixArgs?: string | null;
34
+ /** v0.4.0 (BUG-008/010) — negative evidence: how many times the
35
+ * fingerprint recurred after injection (demotes confidence). */
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
+ feedbackNegative?: number;
32
47
  }
33
48
  export interface SaveInput {
34
49
  type: MemoryType;
35
50
  content: string;
51
+ /** v0.4.0 (BUG-008) — preserve the original id on okf import;
52
+ * when absent a fresh uuidv7 is generated. */
53
+ id?: string;
36
54
  scope?: MemoryScope;
37
55
  relevanceScore?: number;
38
56
  sourceTool?: string;
@@ -51,6 +69,9 @@ export interface SaveInput {
51
69
  lastVerifiedAt?: string;
52
70
  /** v0.3.0 — lifecycle status. Default 'active'. */
53
71
  status?: string;
72
+ /** v0.4.0 (BUG-008/010) — how many times the fingerprint recurred
73
+ * after injection (negative evidence, demotes confidence). */
74
+ recurrenceCount?: number;
54
75
  }
55
76
  export interface QueryInput {
56
77
  text: string;
@@ -65,6 +86,10 @@ export interface QueryInput {
65
86
  /** v0.3.0 — when true, includes rows where status = 'superseded'.
66
87
  * Default false (only active rows). */
67
88
  includeSuperseded?: boolean;
89
+ /** v0.3.0 (BUG-001) — when true, the slim payload also carries
90
+ * `confidence`, `evidence_count` and `last_verified_at` (v0.3.0 K3
91
+ * evidence fields). Default false (minimal slim shape). */
92
+ evidence?: boolean;
68
93
  }
69
94
  /** v0.2.0 — slim query payload (K2-010). Snippet is a short content prefix;
70
95
  * `score` is the FTS5 BM25 score when available, falling back to
@@ -76,6 +101,14 @@ export interface SlimMemory {
76
101
  score: number;
77
102
  snippet: string;
78
103
  }
104
+ /** v0.3.0 (BUG-001) — slim payload extended with the evidence fields when
105
+ * `query({ evidence: true })`. Fills the `kevin_query(evidence: true)`
106
+ * contract without falling back to the full `Memory` shape. */
107
+ export interface SlimMemoryWithEvidence extends SlimMemory {
108
+ confidence: number | null;
109
+ evidence_count: number | null;
110
+ last_verified_at: string | null;
111
+ }
79
112
  export interface GetRelevantInput {
80
113
  query?: string;
81
114
  maxTokens?: number;
@@ -83,25 +116,65 @@ export interface GetRelevantInput {
83
116
  /** v0.3.0 — when true, includes rows where status = 'superseded'.
84
117
  * Default false (only active rows). */
85
118
  includeSuperseded?: boolean;
119
+ /**
120
+ * v0.4.0 (BUG-016) — when false, the relevance bump (K2-023) is
121
+ * skipped. Used by ContextInjector's probe fetch so the decision and
122
+ * any retry both see the ORIGINAL ranking; the single bump is applied
123
+ * by the fetch that actually produces the injected block.
124
+ */
125
+ bump?: boolean;
126
+ /**
127
+ * v0.5.0 (K5-008 / plan §5.6, D5-10) — injectable clock. Defaults to
128
+ * `new Date()` at the top of the method and is the ONLY time source
129
+ * for recency decay: replay and tests can freeze time. Never call
130
+ * `Date.now()` again inside the method.
131
+ */
132
+ now?: Date;
86
133
  }
134
+ export declare const DATE_NOW = "2099-01-01T00:00:00.000Z";
87
135
  export declare class MemoryService {
88
136
  private readonly metrics;
89
137
  constructor(store: Store, metrics?: Metrics | null);
90
138
  private store;
139
+ private hasRecurrenceColumn;
140
+ private _hasRecurrenceColumn;
141
+ private hasIgnoredColumn;
91
142
  save(input: SaveInput): string;
92
143
  getById(id: string): Memory | null;
144
+ /**
145
+ * v0.4.0 (K4-016) — most recent ACTIVE memory for a fingerprint,
146
+ * optionally filtered by type. Feeds the HITL suggestion lookup
147
+ * (most-recurred fingerprint → its pattern memory).
148
+ */
149
+ getByFingerprint(fingerprint: string, type?: MemoryType): Memory | null;
93
150
  update(id: string, fields: Partial<Memory>): void;
94
151
  delete(id: string): void;
95
152
  /** v0.1.x behavior — returns full `Memory` rows. */
96
153
  query(input: QueryInput & {
97
154
  full: true;
98
155
  }): Memory[];
156
+ /** v0.3.0 (BUG-001) — slim rows carrying the evidence fields. */
157
+ query(input: QueryInput & {
158
+ evidence: true;
159
+ }): SlimMemoryWithEvidence[];
99
160
  /** v0.2.0 default — returns `SlimMemory` rows. */
100
161
  query(input: QueryInput): SlimMemory[];
101
162
  private isCrossProjectEnabled;
163
+ /**
164
+ * v0.4.0 (K4-012) — read a kevin_settings flag by key. Falls back to
165
+ * the caller-provided default when the key is missing or the table is
166
+ * unavailable (legacy DB without the settings table).
167
+ */
168
+ getSetting(key: string, fallback?: string): string;
102
169
  private loadAll;
103
170
  private queryRelevant;
104
171
  getRelevant(input: GetRelevantInput): Memory[];
172
+ /**
173
+ * v0.4.0 (BUG-016) — apply the K2-023 relevance bump to a fixed slice
174
+ * of ids, exactly once. Lets ContextInjector probe without mutating
175
+ * and still bump the slice it actually injects.
176
+ */
177
+ bumpRelevance(ids: string[]): void;
105
178
  /**
106
179
  * v0.3.0 (K3-004) — Promote an error memory to a causal pattern.
107
180
  *
@@ -111,7 +184,14 @@ export declare class MemoryService {
111
184
  * or null when the source error is not eligible (missing fingerprint,
112
185
  * wrong type, or already promoted).
113
186
  */
114
- promoteToPattern(errorId: string, evidenceCount: number): string | null;
187
+ /**
188
+ * v0.4.0 (K4-009) — returns `{ id, created }` so callers can tell a
189
+ * newly-created pattern from an idempotent refresh.
190
+ */
191
+ promoteToPattern(errorId: string, evidenceCount: number, recurrenceCount?: number): {
192
+ id: string;
193
+ created: boolean;
194
+ } | null;
115
195
  /**
116
196
  * v0.2.0 (K2-026) — Feedback loop positive half (plan §B6.10 / D2-10).
117
197
  *