kiro-memory 1.5.0 → 1.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.
- package/README.md +15 -2
- package/package.json +5 -2
- package/plugin/dist/cli/contextkit.js +275 -423
- package/plugin/dist/hooks/agentSpawn.js +288 -434
- package/plugin/dist/hooks/kiro-hooks.js +276 -424
- package/plugin/dist/hooks/postToolUse.js +300 -437
- package/plugin/dist/hooks/stop.js +303 -439
- package/plugin/dist/hooks/userPromptSubmit.js +299 -436
- package/plugin/dist/index.js +290 -427
- package/plugin/dist/sdk/index.js +274 -422
- package/plugin/dist/services/sqlite/Database.js +24 -6
- package/plugin/dist/services/sqlite/Search.js +7 -1
- package/plugin/dist/services/sqlite/index.js +30 -7
- package/plugin/dist/shared/paths.js +6 -3
- package/plugin/dist/viewer.js +12 -4
- package/plugin/dist/worker-service.js +3330 -288
|
@@ -1,386 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module';const require = createRequire(import.meta.url);
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
2
|
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
|
|
5
3
|
get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
|
|
6
4
|
}) : x)(function(x) {
|
|
7
5
|
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
8
6
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
9
7
|
});
|
|
10
|
-
var __esm = (fn, res) => function __init() {
|
|
11
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
12
|
-
};
|
|
13
|
-
var __export = (target, all) => {
|
|
14
|
-
for (var name in all)
|
|
15
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
// src/services/sqlite/Sessions.ts
|
|
19
|
-
var Sessions_exports = {};
|
|
20
|
-
__export(Sessions_exports, {
|
|
21
|
-
completeSession: () => completeSession,
|
|
22
|
-
createSession: () => createSession,
|
|
23
|
-
failSession: () => failSession,
|
|
24
|
-
getActiveSessions: () => getActiveSessions,
|
|
25
|
-
getSessionByContentId: () => getSessionByContentId,
|
|
26
|
-
getSessionById: () => getSessionById,
|
|
27
|
-
getSessionsByProject: () => getSessionsByProject,
|
|
28
|
-
updateSessionMemoryId: () => updateSessionMemoryId
|
|
29
|
-
});
|
|
30
|
-
function createSession(db, contentSessionId, project, userPrompt) {
|
|
31
|
-
const now = /* @__PURE__ */ new Date();
|
|
32
|
-
const result = db.run(
|
|
33
|
-
`INSERT INTO sessions (content_session_id, project, user_prompt, status, started_at, started_at_epoch)
|
|
34
|
-
VALUES (?, ?, ?, 'active', ?, ?)`,
|
|
35
|
-
[contentSessionId, project, userPrompt, now.toISOString(), now.getTime()]
|
|
36
|
-
);
|
|
37
|
-
return Number(result.lastInsertRowid);
|
|
38
|
-
}
|
|
39
|
-
function getSessionByContentId(db, contentSessionId) {
|
|
40
|
-
const query = db.query("SELECT * FROM sessions WHERE content_session_id = ?");
|
|
41
|
-
return query.get(contentSessionId);
|
|
42
|
-
}
|
|
43
|
-
function getSessionById(db, id) {
|
|
44
|
-
const query = db.query("SELECT * FROM sessions WHERE id = ?");
|
|
45
|
-
return query.get(id);
|
|
46
|
-
}
|
|
47
|
-
function updateSessionMemoryId(db, id, memorySessionId) {
|
|
48
|
-
db.run(
|
|
49
|
-
"UPDATE sessions SET memory_session_id = ? WHERE id = ?",
|
|
50
|
-
[memorySessionId, id]
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
function completeSession(db, id) {
|
|
54
|
-
const now = /* @__PURE__ */ new Date();
|
|
55
|
-
db.run(
|
|
56
|
-
`UPDATE sessions
|
|
57
|
-
SET status = 'completed', completed_at = ?, completed_at_epoch = ?
|
|
58
|
-
WHERE id = ?`,
|
|
59
|
-
[now.toISOString(), now.getTime(), id]
|
|
60
|
-
);
|
|
61
|
-
}
|
|
62
|
-
function failSession(db, id) {
|
|
63
|
-
const now = /* @__PURE__ */ new Date();
|
|
64
|
-
db.run(
|
|
65
|
-
`UPDATE sessions
|
|
66
|
-
SET status = 'failed', completed_at = ?, completed_at_epoch = ?
|
|
67
|
-
WHERE id = ?`,
|
|
68
|
-
[now.toISOString(), now.getTime(), id]
|
|
69
|
-
);
|
|
70
|
-
}
|
|
71
|
-
function getActiveSessions(db) {
|
|
72
|
-
const query = db.query("SELECT * FROM sessions WHERE status = 'active' ORDER BY started_at_epoch DESC");
|
|
73
|
-
return query.all();
|
|
74
|
-
}
|
|
75
|
-
function getSessionsByProject(db, project, limit = 100) {
|
|
76
|
-
const query = db.query("SELECT * FROM sessions WHERE project = ? ORDER BY started_at_epoch DESC LIMIT ?");
|
|
77
|
-
return query.all(project, limit);
|
|
78
|
-
}
|
|
79
|
-
var init_Sessions = __esm({
|
|
80
|
-
"src/services/sqlite/Sessions.ts"() {
|
|
81
|
-
"use strict";
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// src/services/sqlite/Observations.ts
|
|
86
|
-
var Observations_exports = {};
|
|
87
|
-
__export(Observations_exports, {
|
|
88
|
-
createObservation: () => createObservation,
|
|
89
|
-
deleteObservation: () => deleteObservation,
|
|
90
|
-
getObservationsByProject: () => getObservationsByProject,
|
|
91
|
-
getObservationsBySession: () => getObservationsBySession,
|
|
92
|
-
searchObservations: () => searchObservations
|
|
93
|
-
});
|
|
94
|
-
function createObservation(db, memorySessionId, project, type, title, subtitle, text, narrative, facts, concepts, filesRead, filesModified, promptNumber) {
|
|
95
|
-
const now = /* @__PURE__ */ new Date();
|
|
96
|
-
const result = db.run(
|
|
97
|
-
`INSERT INTO observations
|
|
98
|
-
(memory_session_id, project, type, title, subtitle, text, narrative, facts, concepts, files_read, files_modified, prompt_number, created_at, created_at_epoch)
|
|
99
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
100
|
-
[memorySessionId, project, type, title, subtitle, text, narrative, facts, concepts, filesRead, filesModified, promptNumber, now.toISOString(), now.getTime()]
|
|
101
|
-
);
|
|
102
|
-
return Number(result.lastInsertRowid);
|
|
103
|
-
}
|
|
104
|
-
function getObservationsBySession(db, memorySessionId) {
|
|
105
|
-
const query = db.query(
|
|
106
|
-
"SELECT * FROM observations WHERE memory_session_id = ? ORDER BY prompt_number ASC"
|
|
107
|
-
);
|
|
108
|
-
return query.all(memorySessionId);
|
|
109
|
-
}
|
|
110
|
-
function getObservationsByProject(db, project, limit = 100) {
|
|
111
|
-
const query = db.query(
|
|
112
|
-
"SELECT * FROM observations WHERE project = ? ORDER BY created_at_epoch DESC LIMIT ?"
|
|
113
|
-
);
|
|
114
|
-
return query.all(project, limit);
|
|
115
|
-
}
|
|
116
|
-
function searchObservations(db, searchTerm, project) {
|
|
117
|
-
const sql = project ? `SELECT * FROM observations
|
|
118
|
-
WHERE project = ? AND (title LIKE ? OR text LIKE ? OR narrative LIKE ?)
|
|
119
|
-
ORDER BY created_at_epoch DESC` : `SELECT * FROM observations
|
|
120
|
-
WHERE title LIKE ? OR text LIKE ? OR narrative LIKE ?
|
|
121
|
-
ORDER BY created_at_epoch DESC`;
|
|
122
|
-
const pattern = `%${searchTerm}%`;
|
|
123
|
-
const query = db.query(sql);
|
|
124
|
-
if (project) {
|
|
125
|
-
return query.all(project, pattern, pattern, pattern);
|
|
126
|
-
}
|
|
127
|
-
return query.all(pattern, pattern, pattern);
|
|
128
|
-
}
|
|
129
|
-
function deleteObservation(db, id) {
|
|
130
|
-
db.run("DELETE FROM observations WHERE id = ?", [id]);
|
|
131
|
-
}
|
|
132
|
-
var init_Observations = __esm({
|
|
133
|
-
"src/services/sqlite/Observations.ts"() {
|
|
134
|
-
"use strict";
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
// src/services/sqlite/Summaries.ts
|
|
139
|
-
var Summaries_exports = {};
|
|
140
|
-
__export(Summaries_exports, {
|
|
141
|
-
createSummary: () => createSummary,
|
|
142
|
-
deleteSummary: () => deleteSummary,
|
|
143
|
-
getSummariesByProject: () => getSummariesByProject,
|
|
144
|
-
getSummaryBySession: () => getSummaryBySession,
|
|
145
|
-
searchSummaries: () => searchSummaries
|
|
146
|
-
});
|
|
147
|
-
function createSummary(db, sessionId, project, request, investigated, learned, completed, nextSteps, notes) {
|
|
148
|
-
const now = /* @__PURE__ */ new Date();
|
|
149
|
-
const result = db.run(
|
|
150
|
-
`INSERT INTO summaries
|
|
151
|
-
(session_id, project, request, investigated, learned, completed, next_steps, notes, created_at, created_at_epoch)
|
|
152
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
153
|
-
[sessionId, project, request, investigated, learned, completed, nextSteps, notes, now.toISOString(), now.getTime()]
|
|
154
|
-
);
|
|
155
|
-
return Number(result.lastInsertRowid);
|
|
156
|
-
}
|
|
157
|
-
function getSummaryBySession(db, sessionId) {
|
|
158
|
-
const query = db.query("SELECT * FROM summaries WHERE session_id = ? ORDER BY created_at_epoch DESC LIMIT 1");
|
|
159
|
-
return query.get(sessionId);
|
|
160
|
-
}
|
|
161
|
-
function getSummariesByProject(db, project, limit = 50) {
|
|
162
|
-
const query = db.query(
|
|
163
|
-
"SELECT * FROM summaries WHERE project = ? ORDER BY created_at_epoch DESC LIMIT ?"
|
|
164
|
-
);
|
|
165
|
-
return query.all(project, limit);
|
|
166
|
-
}
|
|
167
|
-
function searchSummaries(db, searchTerm, project) {
|
|
168
|
-
const sql = project ? `SELECT * FROM summaries
|
|
169
|
-
WHERE project = ? AND (request LIKE ? OR learned LIKE ? OR completed LIKE ? OR notes LIKE ?)
|
|
170
|
-
ORDER BY created_at_epoch DESC` : `SELECT * FROM summaries
|
|
171
|
-
WHERE request LIKE ? OR learned LIKE ? OR completed LIKE ? OR notes LIKE ?
|
|
172
|
-
ORDER BY created_at_epoch DESC`;
|
|
173
|
-
const pattern = `%${searchTerm}%`;
|
|
174
|
-
const query = db.query(sql);
|
|
175
|
-
if (project) {
|
|
176
|
-
return query.all(project, pattern, pattern, pattern, pattern);
|
|
177
|
-
}
|
|
178
|
-
return query.all(pattern, pattern, pattern, pattern);
|
|
179
|
-
}
|
|
180
|
-
function deleteSummary(db, id) {
|
|
181
|
-
db.run("DELETE FROM summaries WHERE id = ?", [id]);
|
|
182
|
-
}
|
|
183
|
-
var init_Summaries = __esm({
|
|
184
|
-
"src/services/sqlite/Summaries.ts"() {
|
|
185
|
-
"use strict";
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
// src/services/sqlite/Prompts.ts
|
|
190
|
-
var Prompts_exports = {};
|
|
191
|
-
__export(Prompts_exports, {
|
|
192
|
-
createPrompt: () => createPrompt,
|
|
193
|
-
deletePrompt: () => deletePrompt,
|
|
194
|
-
getLatestPrompt: () => getLatestPrompt,
|
|
195
|
-
getPromptsByProject: () => getPromptsByProject,
|
|
196
|
-
getPromptsBySession: () => getPromptsBySession
|
|
197
|
-
});
|
|
198
|
-
function createPrompt(db, contentSessionId, project, promptNumber, promptText) {
|
|
199
|
-
const now = /* @__PURE__ */ new Date();
|
|
200
|
-
const result = db.run(
|
|
201
|
-
`INSERT INTO prompts
|
|
202
|
-
(content_session_id, project, prompt_number, prompt_text, created_at, created_at_epoch)
|
|
203
|
-
VALUES (?, ?, ?, ?, ?, ?)`,
|
|
204
|
-
[contentSessionId, project, promptNumber, promptText, now.toISOString(), now.getTime()]
|
|
205
|
-
);
|
|
206
|
-
return Number(result.lastInsertRowid);
|
|
207
|
-
}
|
|
208
|
-
function getPromptsBySession(db, contentSessionId) {
|
|
209
|
-
const query = db.query(
|
|
210
|
-
"SELECT * FROM prompts WHERE content_session_id = ? ORDER BY prompt_number ASC"
|
|
211
|
-
);
|
|
212
|
-
return query.all(contentSessionId);
|
|
213
|
-
}
|
|
214
|
-
function getPromptsByProject(db, project, limit = 100) {
|
|
215
|
-
const query = db.query(
|
|
216
|
-
"SELECT * FROM prompts WHERE project = ? ORDER BY created_at_epoch DESC LIMIT ?"
|
|
217
|
-
);
|
|
218
|
-
return query.all(project, limit);
|
|
219
|
-
}
|
|
220
|
-
function getLatestPrompt(db, contentSessionId) {
|
|
221
|
-
const query = db.query(
|
|
222
|
-
"SELECT * FROM prompts WHERE content_session_id = ? ORDER BY prompt_number DESC LIMIT 1"
|
|
223
|
-
);
|
|
224
|
-
return query.get(contentSessionId);
|
|
225
|
-
}
|
|
226
|
-
function deletePrompt(db, id) {
|
|
227
|
-
db.run("DELETE FROM prompts WHERE id = ?", [id]);
|
|
228
|
-
}
|
|
229
|
-
var init_Prompts = __esm({
|
|
230
|
-
"src/services/sqlite/Prompts.ts"() {
|
|
231
|
-
"use strict";
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
// src/services/sqlite/Search.ts
|
|
236
|
-
var Search_exports = {};
|
|
237
|
-
__export(Search_exports, {
|
|
238
|
-
getObservationsByIds: () => getObservationsByIds,
|
|
239
|
-
getProjectStats: () => getProjectStats,
|
|
240
|
-
getTimeline: () => getTimeline,
|
|
241
|
-
searchObservationsFTS: () => searchObservationsFTS,
|
|
242
|
-
searchObservationsLIKE: () => searchObservationsLIKE,
|
|
243
|
-
searchSummariesFiltered: () => searchSummariesFiltered
|
|
244
|
-
});
|
|
245
|
-
function searchObservationsFTS(db, query, filters = {}) {
|
|
246
|
-
const limit = filters.limit || 50;
|
|
247
|
-
try {
|
|
248
|
-
let sql = `
|
|
249
|
-
SELECT o.* FROM observations o
|
|
250
|
-
JOIN observations_fts fts ON o.id = fts.rowid
|
|
251
|
-
WHERE observations_fts MATCH ?
|
|
252
|
-
`;
|
|
253
|
-
const params = [query];
|
|
254
|
-
if (filters.project) {
|
|
255
|
-
sql += " AND o.project = ?";
|
|
256
|
-
params.push(filters.project);
|
|
257
|
-
}
|
|
258
|
-
if (filters.type) {
|
|
259
|
-
sql += " AND o.type = ?";
|
|
260
|
-
params.push(filters.type);
|
|
261
|
-
}
|
|
262
|
-
if (filters.dateStart) {
|
|
263
|
-
sql += " AND o.created_at_epoch >= ?";
|
|
264
|
-
params.push(filters.dateStart);
|
|
265
|
-
}
|
|
266
|
-
if (filters.dateEnd) {
|
|
267
|
-
sql += " AND o.created_at_epoch <= ?";
|
|
268
|
-
params.push(filters.dateEnd);
|
|
269
|
-
}
|
|
270
|
-
sql += " ORDER BY rank LIMIT ?";
|
|
271
|
-
params.push(limit);
|
|
272
|
-
const stmt = db.query(sql);
|
|
273
|
-
return stmt.all(...params);
|
|
274
|
-
} catch {
|
|
275
|
-
return searchObservationsLIKE(db, query, filters);
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
function searchObservationsLIKE(db, query, filters = {}) {
|
|
279
|
-
const limit = filters.limit || 50;
|
|
280
|
-
const pattern = `%${query}%`;
|
|
281
|
-
let sql = `
|
|
282
|
-
SELECT * FROM observations
|
|
283
|
-
WHERE (title LIKE ? OR text LIKE ? OR narrative LIKE ? OR concepts LIKE ?)
|
|
284
|
-
`;
|
|
285
|
-
const params = [pattern, pattern, pattern, pattern];
|
|
286
|
-
if (filters.project) {
|
|
287
|
-
sql += " AND project = ?";
|
|
288
|
-
params.push(filters.project);
|
|
289
|
-
}
|
|
290
|
-
if (filters.type) {
|
|
291
|
-
sql += " AND type = ?";
|
|
292
|
-
params.push(filters.type);
|
|
293
|
-
}
|
|
294
|
-
if (filters.dateStart) {
|
|
295
|
-
sql += " AND created_at_epoch >= ?";
|
|
296
|
-
params.push(filters.dateStart);
|
|
297
|
-
}
|
|
298
|
-
if (filters.dateEnd) {
|
|
299
|
-
sql += " AND created_at_epoch <= ?";
|
|
300
|
-
params.push(filters.dateEnd);
|
|
301
|
-
}
|
|
302
|
-
sql += " ORDER BY created_at_epoch DESC LIMIT ?";
|
|
303
|
-
params.push(limit);
|
|
304
|
-
const stmt = db.query(sql);
|
|
305
|
-
return stmt.all(...params);
|
|
306
|
-
}
|
|
307
|
-
function searchSummariesFiltered(db, query, filters = {}) {
|
|
308
|
-
const limit = filters.limit || 20;
|
|
309
|
-
const pattern = `%${query}%`;
|
|
310
|
-
let sql = `
|
|
311
|
-
SELECT * FROM summaries
|
|
312
|
-
WHERE (request LIKE ? OR learned LIKE ? OR completed LIKE ? OR notes LIKE ? OR next_steps LIKE ?)
|
|
313
|
-
`;
|
|
314
|
-
const params = [pattern, pattern, pattern, pattern, pattern];
|
|
315
|
-
if (filters.project) {
|
|
316
|
-
sql += " AND project = ?";
|
|
317
|
-
params.push(filters.project);
|
|
318
|
-
}
|
|
319
|
-
if (filters.dateStart) {
|
|
320
|
-
sql += " AND created_at_epoch >= ?";
|
|
321
|
-
params.push(filters.dateStart);
|
|
322
|
-
}
|
|
323
|
-
if (filters.dateEnd) {
|
|
324
|
-
sql += " AND created_at_epoch <= ?";
|
|
325
|
-
params.push(filters.dateEnd);
|
|
326
|
-
}
|
|
327
|
-
sql += " ORDER BY created_at_epoch DESC LIMIT ?";
|
|
328
|
-
params.push(limit);
|
|
329
|
-
const stmt = db.query(sql);
|
|
330
|
-
return stmt.all(...params);
|
|
331
|
-
}
|
|
332
|
-
function getObservationsByIds(db, ids) {
|
|
333
|
-
if (ids.length === 0) return [];
|
|
334
|
-
const placeholders = ids.map(() => "?").join(",");
|
|
335
|
-
const sql = `SELECT * FROM observations WHERE id IN (${placeholders}) ORDER BY created_at_epoch DESC`;
|
|
336
|
-
const stmt = db.query(sql);
|
|
337
|
-
return stmt.all(...ids);
|
|
338
|
-
}
|
|
339
|
-
function getTimeline(db, anchorId, depthBefore = 5, depthAfter = 5) {
|
|
340
|
-
const anchorStmt = db.query("SELECT created_at_epoch FROM observations WHERE id = ?");
|
|
341
|
-
const anchor = anchorStmt.get(anchorId);
|
|
342
|
-
if (!anchor) return [];
|
|
343
|
-
const anchorEpoch = anchor.created_at_epoch;
|
|
344
|
-
const beforeStmt = db.query(`
|
|
345
|
-
SELECT id, 'observation' as type, title, text as content, project, created_at, created_at_epoch
|
|
346
|
-
FROM observations
|
|
347
|
-
WHERE created_at_epoch < ?
|
|
348
|
-
ORDER BY created_at_epoch DESC
|
|
349
|
-
LIMIT ?
|
|
350
|
-
`);
|
|
351
|
-
const before = beforeStmt.all(anchorEpoch, depthBefore).reverse();
|
|
352
|
-
const selfStmt = db.query(`
|
|
353
|
-
SELECT id, 'observation' as type, title, text as content, project, created_at, created_at_epoch
|
|
354
|
-
FROM observations WHERE id = ?
|
|
355
|
-
`);
|
|
356
|
-
const self = selfStmt.all(anchorId);
|
|
357
|
-
const afterStmt = db.query(`
|
|
358
|
-
SELECT id, 'observation' as type, title, text as content, project, created_at, created_at_epoch
|
|
359
|
-
FROM observations
|
|
360
|
-
WHERE created_at_epoch > ?
|
|
361
|
-
ORDER BY created_at_epoch ASC
|
|
362
|
-
LIMIT ?
|
|
363
|
-
`);
|
|
364
|
-
const after = afterStmt.all(anchorEpoch, depthAfter);
|
|
365
|
-
return [...before, ...self, ...after];
|
|
366
|
-
}
|
|
367
|
-
function getProjectStats(db, project) {
|
|
368
|
-
const obsStmt = db.query("SELECT COUNT(*) as count FROM observations WHERE project = ?");
|
|
369
|
-
const sumStmt = db.query("SELECT COUNT(*) as count FROM summaries WHERE project = ?");
|
|
370
|
-
const sesStmt = db.query("SELECT COUNT(*) as count FROM sessions WHERE project = ?");
|
|
371
|
-
const prmStmt = db.query("SELECT COUNT(*) as count FROM prompts WHERE project = ?");
|
|
372
|
-
return {
|
|
373
|
-
observations: obsStmt.get(project)?.count || 0,
|
|
374
|
-
summaries: sumStmt.get(project)?.count || 0,
|
|
375
|
-
sessions: sesStmt.get(project)?.count || 0,
|
|
376
|
-
prompts: prmStmt.get(project)?.count || 0
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
var init_Search = __esm({
|
|
380
|
-
"src/services/sqlite/Search.ts"() {
|
|
381
|
-
"use strict";
|
|
382
|
-
}
|
|
383
|
-
});
|
|
384
8
|
|
|
385
9
|
// src/shims/bun-sqlite.ts
|
|
386
10
|
import BetterSqlite3 from "better-sqlite3";
|
|
@@ -452,7 +76,7 @@ var BunQueryCompat = class {
|
|
|
452
76
|
// src/shared/paths.ts
|
|
453
77
|
import { join as join2, dirname, basename } from "path";
|
|
454
78
|
import { homedir as homedir2 } from "os";
|
|
455
|
-
import { mkdirSync as mkdirSync2 } from "fs";
|
|
79
|
+
import { existsSync as existsSync2, mkdirSync as mkdirSync2 } from "fs";
|
|
456
80
|
import { fileURLToPath } from "url";
|
|
457
81
|
|
|
458
82
|
// src/utils/logger.ts
|
|
@@ -682,7 +306,9 @@ function getDirname() {
|
|
|
682
306
|
return dirname(fileURLToPath(import.meta.url));
|
|
683
307
|
}
|
|
684
308
|
var _dirname = getDirname();
|
|
685
|
-
var
|
|
309
|
+
var _legacyDir = join2(homedir2(), ".contextkit");
|
|
310
|
+
var _defaultDir = existsSync2(_legacyDir) ? _legacyDir : join2(homedir2(), ".kiro-memory");
|
|
311
|
+
var DATA_DIR = process.env.KIRO_MEMORY_DATA_DIR || process.env.CONTEXTKIT_DATA_DIR || _defaultDir;
|
|
686
312
|
var KIRO_CONFIG_DIR = process.env.KIRO_CONFIG_DIR || join2(homedir2(), ".kiro");
|
|
687
313
|
var PLUGIN_ROOT = join2(KIRO_CONFIG_DIR, "plugins", "kiro-memory");
|
|
688
314
|
var ARCHIVES_DIR = join2(DATA_DIR, "archives");
|
|
@@ -691,7 +317,8 @@ var TRASH_DIR = join2(DATA_DIR, "trash");
|
|
|
691
317
|
var BACKUPS_DIR = join2(DATA_DIR, "backups");
|
|
692
318
|
var MODES_DIR = join2(DATA_DIR, "modes");
|
|
693
319
|
var USER_SETTINGS_PATH = join2(DATA_DIR, "settings.json");
|
|
694
|
-
var
|
|
320
|
+
var _legacyDb = join2(DATA_DIR, "contextkit.db");
|
|
321
|
+
var DB_PATH = existsSync2(_legacyDb) ? _legacyDb : join2(DATA_DIR, "kiro-memory.db");
|
|
695
322
|
var VECTOR_DB_DIR = join2(DATA_DIR, "vector-db");
|
|
696
323
|
var OBSERVER_SESSIONS_DIR = join2(DATA_DIR, "observer-sessions");
|
|
697
324
|
var KIRO_SETTINGS_PATH = join2(KIRO_CONFIG_DIR, "settings.json");
|
|
@@ -705,7 +332,11 @@ var SQLITE_MMAP_SIZE_BYTES = 256 * 1024 * 1024;
|
|
|
705
332
|
var SQLITE_CACHE_SIZE_PAGES = 1e4;
|
|
706
333
|
var KiroMemoryDatabase = class {
|
|
707
334
|
db;
|
|
708
|
-
|
|
335
|
+
/**
|
|
336
|
+
* @param dbPath - Percorso al file SQLite (default: DB_PATH)
|
|
337
|
+
* @param skipMigrations - Se true, salta il migration runner (per hook ad alta frequenza)
|
|
338
|
+
*/
|
|
339
|
+
constructor(dbPath = DB_PATH, skipMigrations = false) {
|
|
709
340
|
if (dbPath !== ":memory:") {
|
|
710
341
|
ensureDir(DATA_DIR);
|
|
711
342
|
}
|
|
@@ -716,8 +347,18 @@ var KiroMemoryDatabase = class {
|
|
|
716
347
|
this.db.run("PRAGMA temp_store = memory");
|
|
717
348
|
this.db.run(`PRAGMA mmap_size = ${SQLITE_MMAP_SIZE_BYTES}`);
|
|
718
349
|
this.db.run(`PRAGMA cache_size = ${SQLITE_CACHE_SIZE_PAGES}`);
|
|
719
|
-
|
|
720
|
-
|
|
350
|
+
if (!skipMigrations) {
|
|
351
|
+
const migrationRunner = new MigrationRunner(this.db);
|
|
352
|
+
migrationRunner.runAllMigrations();
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Esegue una funzione all'interno di una transazione atomica.
|
|
357
|
+
* Se fn() lancia un errore, la transazione viene annullata automaticamente.
|
|
358
|
+
*/
|
|
359
|
+
withTransaction(fn) {
|
|
360
|
+
const transaction = this.db.transaction(fn);
|
|
361
|
+
return transaction(this.db);
|
|
721
362
|
}
|
|
722
363
|
/**
|
|
723
364
|
* Close the database connection
|
|
@@ -897,19 +538,246 @@ var MigrationRunner = class {
|
|
|
897
538
|
}
|
|
898
539
|
};
|
|
899
540
|
|
|
900
|
-
// src/services/sqlite/
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
541
|
+
// src/services/sqlite/Sessions.ts
|
|
542
|
+
function createSession(db, contentSessionId, project, userPrompt) {
|
|
543
|
+
const now = /* @__PURE__ */ new Date();
|
|
544
|
+
const result = db.run(
|
|
545
|
+
`INSERT INTO sessions (content_session_id, project, user_prompt, status, started_at, started_at_epoch)
|
|
546
|
+
VALUES (?, ?, ?, 'active', ?, ?)`,
|
|
547
|
+
[contentSessionId, project, userPrompt, now.toISOString(), now.getTime()]
|
|
548
|
+
);
|
|
549
|
+
return Number(result.lastInsertRowid);
|
|
550
|
+
}
|
|
551
|
+
function getSessionByContentId(db, contentSessionId) {
|
|
552
|
+
const query = db.query("SELECT * FROM sessions WHERE content_session_id = ?");
|
|
553
|
+
return query.get(contentSessionId);
|
|
554
|
+
}
|
|
555
|
+
function completeSession(db, id) {
|
|
556
|
+
const now = /* @__PURE__ */ new Date();
|
|
557
|
+
db.run(
|
|
558
|
+
`UPDATE sessions
|
|
559
|
+
SET status = 'completed', completed_at = ?, completed_at_epoch = ?
|
|
560
|
+
WHERE id = ?`,
|
|
561
|
+
[now.toISOString(), now.getTime(), id]
|
|
562
|
+
);
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
// src/services/sqlite/Observations.ts
|
|
566
|
+
function createObservation(db, memorySessionId, project, type, title, subtitle, text, narrative, facts, concepts, filesRead, filesModified, promptNumber) {
|
|
567
|
+
const now = /* @__PURE__ */ new Date();
|
|
568
|
+
const result = db.run(
|
|
569
|
+
`INSERT INTO observations
|
|
570
|
+
(memory_session_id, project, type, title, subtitle, text, narrative, facts, concepts, files_read, files_modified, prompt_number, created_at, created_at_epoch)
|
|
571
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
572
|
+
[memorySessionId, project, type, title, subtitle, text, narrative, facts, concepts, filesRead, filesModified, promptNumber, now.toISOString(), now.getTime()]
|
|
573
|
+
);
|
|
574
|
+
return Number(result.lastInsertRowid);
|
|
575
|
+
}
|
|
576
|
+
function getObservationsByProject(db, project, limit = 100) {
|
|
577
|
+
const query = db.query(
|
|
578
|
+
"SELECT * FROM observations WHERE project = ? ORDER BY created_at_epoch DESC LIMIT ?"
|
|
579
|
+
);
|
|
580
|
+
return query.all(project, limit);
|
|
581
|
+
}
|
|
582
|
+
function searchObservations(db, searchTerm, project) {
|
|
583
|
+
const sql = project ? `SELECT * FROM observations
|
|
584
|
+
WHERE project = ? AND (title LIKE ? OR text LIKE ? OR narrative LIKE ?)
|
|
585
|
+
ORDER BY created_at_epoch DESC` : `SELECT * FROM observations
|
|
586
|
+
WHERE title LIKE ? OR text LIKE ? OR narrative LIKE ?
|
|
587
|
+
ORDER BY created_at_epoch DESC`;
|
|
588
|
+
const pattern = `%${searchTerm}%`;
|
|
589
|
+
const query = db.query(sql);
|
|
590
|
+
if (project) {
|
|
591
|
+
return query.all(project, pattern, pattern, pattern);
|
|
592
|
+
}
|
|
593
|
+
return query.all(pattern, pattern, pattern);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
// src/services/sqlite/Summaries.ts
|
|
597
|
+
function createSummary(db, sessionId, project, request, investigated, learned, completed, nextSteps, notes) {
|
|
598
|
+
const now = /* @__PURE__ */ new Date();
|
|
599
|
+
const result = db.run(
|
|
600
|
+
`INSERT INTO summaries
|
|
601
|
+
(session_id, project, request, investigated, learned, completed, next_steps, notes, created_at, created_at_epoch)
|
|
602
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
603
|
+
[sessionId, project, request, investigated, learned, completed, nextSteps, notes, now.toISOString(), now.getTime()]
|
|
604
|
+
);
|
|
605
|
+
return Number(result.lastInsertRowid);
|
|
606
|
+
}
|
|
607
|
+
function getSummariesByProject(db, project, limit = 50) {
|
|
608
|
+
const query = db.query(
|
|
609
|
+
"SELECT * FROM summaries WHERE project = ? ORDER BY created_at_epoch DESC LIMIT ?"
|
|
610
|
+
);
|
|
611
|
+
return query.all(project, limit);
|
|
612
|
+
}
|
|
613
|
+
function searchSummaries(db, searchTerm, project) {
|
|
614
|
+
const sql = project ? `SELECT * FROM summaries
|
|
615
|
+
WHERE project = ? AND (request LIKE ? OR learned LIKE ? OR completed LIKE ? OR notes LIKE ?)
|
|
616
|
+
ORDER BY created_at_epoch DESC` : `SELECT * FROM summaries
|
|
617
|
+
WHERE request LIKE ? OR learned LIKE ? OR completed LIKE ? OR notes LIKE ?
|
|
618
|
+
ORDER BY created_at_epoch DESC`;
|
|
619
|
+
const pattern = `%${searchTerm}%`;
|
|
620
|
+
const query = db.query(sql);
|
|
621
|
+
if (project) {
|
|
622
|
+
return query.all(project, pattern, pattern, pattern, pattern);
|
|
623
|
+
}
|
|
624
|
+
return query.all(pattern, pattern, pattern, pattern);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
// src/services/sqlite/Prompts.ts
|
|
628
|
+
function createPrompt(db, contentSessionId, project, promptNumber, promptText) {
|
|
629
|
+
const now = /* @__PURE__ */ new Date();
|
|
630
|
+
const result = db.run(
|
|
631
|
+
`INSERT INTO prompts
|
|
632
|
+
(content_session_id, project, prompt_number, prompt_text, created_at, created_at_epoch)
|
|
633
|
+
VALUES (?, ?, ?, ?, ?, ?)`,
|
|
634
|
+
[contentSessionId, project, promptNumber, promptText, now.toISOString(), now.getTime()]
|
|
635
|
+
);
|
|
636
|
+
return Number(result.lastInsertRowid);
|
|
637
|
+
}
|
|
638
|
+
function getPromptsByProject(db, project, limit = 100) {
|
|
639
|
+
const query = db.query(
|
|
640
|
+
"SELECT * FROM prompts WHERE project = ? ORDER BY created_at_epoch DESC LIMIT ?"
|
|
641
|
+
);
|
|
642
|
+
return query.all(project, limit);
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
// src/services/sqlite/Search.ts
|
|
646
|
+
function sanitizeFTS5Query(query) {
|
|
647
|
+
const terms = query.replace(/[""]/g, "").split(/\s+/).filter((t) => t.length > 0).map((t) => `"${t}"`);
|
|
648
|
+
return terms.join(" ");
|
|
649
|
+
}
|
|
650
|
+
function searchObservationsFTS(db, query, filters = {}) {
|
|
651
|
+
const limit = filters.limit || 50;
|
|
652
|
+
try {
|
|
653
|
+
const safeQuery = sanitizeFTS5Query(query);
|
|
654
|
+
if (!safeQuery) return searchObservationsLIKE(db, query, filters);
|
|
655
|
+
let sql = `
|
|
656
|
+
SELECT o.* FROM observations o
|
|
657
|
+
JOIN observations_fts fts ON o.id = fts.rowid
|
|
658
|
+
WHERE observations_fts MATCH ?
|
|
659
|
+
`;
|
|
660
|
+
const params = [safeQuery];
|
|
661
|
+
if (filters.project) {
|
|
662
|
+
sql += " AND o.project = ?";
|
|
663
|
+
params.push(filters.project);
|
|
664
|
+
}
|
|
665
|
+
if (filters.type) {
|
|
666
|
+
sql += " AND o.type = ?";
|
|
667
|
+
params.push(filters.type);
|
|
668
|
+
}
|
|
669
|
+
if (filters.dateStart) {
|
|
670
|
+
sql += " AND o.created_at_epoch >= ?";
|
|
671
|
+
params.push(filters.dateStart);
|
|
672
|
+
}
|
|
673
|
+
if (filters.dateEnd) {
|
|
674
|
+
sql += " AND o.created_at_epoch <= ?";
|
|
675
|
+
params.push(filters.dateEnd);
|
|
676
|
+
}
|
|
677
|
+
sql += " ORDER BY rank LIMIT ?";
|
|
678
|
+
params.push(limit);
|
|
679
|
+
const stmt = db.query(sql);
|
|
680
|
+
return stmt.all(...params);
|
|
681
|
+
} catch {
|
|
682
|
+
return searchObservationsLIKE(db, query, filters);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
function searchObservationsLIKE(db, query, filters = {}) {
|
|
686
|
+
const limit = filters.limit || 50;
|
|
687
|
+
const pattern = `%${query}%`;
|
|
688
|
+
let sql = `
|
|
689
|
+
SELECT * FROM observations
|
|
690
|
+
WHERE (title LIKE ? OR text LIKE ? OR narrative LIKE ? OR concepts LIKE ?)
|
|
691
|
+
`;
|
|
692
|
+
const params = [pattern, pattern, pattern, pattern];
|
|
693
|
+
if (filters.project) {
|
|
694
|
+
sql += " AND project = ?";
|
|
695
|
+
params.push(filters.project);
|
|
696
|
+
}
|
|
697
|
+
if (filters.type) {
|
|
698
|
+
sql += " AND type = ?";
|
|
699
|
+
params.push(filters.type);
|
|
700
|
+
}
|
|
701
|
+
if (filters.dateStart) {
|
|
702
|
+
sql += " AND created_at_epoch >= ?";
|
|
703
|
+
params.push(filters.dateStart);
|
|
704
|
+
}
|
|
705
|
+
if (filters.dateEnd) {
|
|
706
|
+
sql += " AND created_at_epoch <= ?";
|
|
707
|
+
params.push(filters.dateEnd);
|
|
708
|
+
}
|
|
709
|
+
sql += " ORDER BY created_at_epoch DESC LIMIT ?";
|
|
710
|
+
params.push(limit);
|
|
711
|
+
const stmt = db.query(sql);
|
|
712
|
+
return stmt.all(...params);
|
|
713
|
+
}
|
|
714
|
+
function searchSummariesFiltered(db, query, filters = {}) {
|
|
715
|
+
const limit = filters.limit || 20;
|
|
716
|
+
const pattern = `%${query}%`;
|
|
717
|
+
let sql = `
|
|
718
|
+
SELECT * FROM summaries
|
|
719
|
+
WHERE (request LIKE ? OR learned LIKE ? OR completed LIKE ? OR notes LIKE ? OR next_steps LIKE ?)
|
|
720
|
+
`;
|
|
721
|
+
const params = [pattern, pattern, pattern, pattern, pattern];
|
|
722
|
+
if (filters.project) {
|
|
723
|
+
sql += " AND project = ?";
|
|
724
|
+
params.push(filters.project);
|
|
725
|
+
}
|
|
726
|
+
if (filters.dateStart) {
|
|
727
|
+
sql += " AND created_at_epoch >= ?";
|
|
728
|
+
params.push(filters.dateStart);
|
|
729
|
+
}
|
|
730
|
+
if (filters.dateEnd) {
|
|
731
|
+
sql += " AND created_at_epoch <= ?";
|
|
732
|
+
params.push(filters.dateEnd);
|
|
733
|
+
}
|
|
734
|
+
sql += " ORDER BY created_at_epoch DESC LIMIT ?";
|
|
735
|
+
params.push(limit);
|
|
736
|
+
const stmt = db.query(sql);
|
|
737
|
+
return stmt.all(...params);
|
|
738
|
+
}
|
|
739
|
+
function getObservationsByIds(db, ids) {
|
|
740
|
+
if (ids.length === 0) return [];
|
|
741
|
+
const placeholders = ids.map(() => "?").join(",");
|
|
742
|
+
const sql = `SELECT * FROM observations WHERE id IN (${placeholders}) ORDER BY created_at_epoch DESC`;
|
|
743
|
+
const stmt = db.query(sql);
|
|
744
|
+
return stmt.all(...ids);
|
|
745
|
+
}
|
|
746
|
+
function getTimeline(db, anchorId, depthBefore = 5, depthAfter = 5) {
|
|
747
|
+
const anchorStmt = db.query("SELECT created_at_epoch FROM observations WHERE id = ?");
|
|
748
|
+
const anchor = anchorStmt.get(anchorId);
|
|
749
|
+
if (!anchor) return [];
|
|
750
|
+
const anchorEpoch = anchor.created_at_epoch;
|
|
751
|
+
const beforeStmt = db.query(`
|
|
752
|
+
SELECT id, 'observation' as type, title, text as content, project, created_at, created_at_epoch
|
|
753
|
+
FROM observations
|
|
754
|
+
WHERE created_at_epoch < ?
|
|
755
|
+
ORDER BY created_at_epoch DESC
|
|
756
|
+
LIMIT ?
|
|
757
|
+
`);
|
|
758
|
+
const before = beforeStmt.all(anchorEpoch, depthBefore).reverse();
|
|
759
|
+
const selfStmt = db.query(`
|
|
760
|
+
SELECT id, 'observation' as type, title, text as content, project, created_at, created_at_epoch
|
|
761
|
+
FROM observations WHERE id = ?
|
|
762
|
+
`);
|
|
763
|
+
const self = selfStmt.all(anchorId);
|
|
764
|
+
const afterStmt = db.query(`
|
|
765
|
+
SELECT id, 'observation' as type, title, text as content, project, created_at, created_at_epoch
|
|
766
|
+
FROM observations
|
|
767
|
+
WHERE created_at_epoch > ?
|
|
768
|
+
ORDER BY created_at_epoch ASC
|
|
769
|
+
LIMIT ?
|
|
770
|
+
`);
|
|
771
|
+
const after = afterStmt.all(anchorEpoch, depthAfter);
|
|
772
|
+
return [...before, ...self, ...after];
|
|
773
|
+
}
|
|
906
774
|
|
|
907
775
|
// src/sdk/index.ts
|
|
908
776
|
var KiroMemorySDK = class {
|
|
909
777
|
db;
|
|
910
778
|
project;
|
|
911
779
|
constructor(config = {}) {
|
|
912
|
-
this.db = new KiroMemoryDatabase(config.dataDir);
|
|
780
|
+
this.db = new KiroMemoryDatabase(config.dataDir, config.skipMigrations || false);
|
|
913
781
|
this.project = config.project || this.detectProject();
|
|
914
782
|
}
|
|
915
783
|
detectProject() {
|
|
@@ -929,22 +797,18 @@ var KiroMemorySDK = class {
|
|
|
929
797
|
* Get context for the current project
|
|
930
798
|
*/
|
|
931
799
|
async getContext() {
|
|
932
|
-
const { getObservationsByProject: getObservationsByProject2 } = await Promise.resolve().then(() => (init_Observations(), Observations_exports));
|
|
933
|
-
const { getSummariesByProject: getSummariesByProject2 } = await Promise.resolve().then(() => (init_Summaries(), Summaries_exports));
|
|
934
|
-
const { getPromptsByProject: getPromptsByProject2 } = await Promise.resolve().then(() => (init_Prompts(), Prompts_exports));
|
|
935
800
|
return {
|
|
936
801
|
project: this.project,
|
|
937
|
-
relevantObservations:
|
|
938
|
-
relevantSummaries:
|
|
939
|
-
recentPrompts:
|
|
802
|
+
relevantObservations: getObservationsByProject(this.db.db, this.project, 20),
|
|
803
|
+
relevantSummaries: getSummariesByProject(this.db.db, this.project, 5),
|
|
804
|
+
recentPrompts: getPromptsByProject(this.db.db, this.project, 10)
|
|
940
805
|
};
|
|
941
806
|
}
|
|
942
807
|
/**
|
|
943
808
|
* Store a new observation
|
|
944
809
|
*/
|
|
945
810
|
async storeObservation(data) {
|
|
946
|
-
|
|
947
|
-
return createObservation2(
|
|
811
|
+
return createObservation(
|
|
948
812
|
this.db.db,
|
|
949
813
|
"sdk-" + Date.now(),
|
|
950
814
|
this.project,
|
|
@@ -970,8 +834,7 @@ var KiroMemorySDK = class {
|
|
|
970
834
|
* Store a session summary
|
|
971
835
|
*/
|
|
972
836
|
async storeSummary(data) {
|
|
973
|
-
|
|
974
|
-
return createSummary2(
|
|
837
|
+
return createSummary(
|
|
975
838
|
this.db.db,
|
|
976
839
|
"sdk-" + Date.now(),
|
|
977
840
|
this.project,
|
|
@@ -987,61 +850,52 @@ var KiroMemorySDK = class {
|
|
|
987
850
|
* Search across all stored context
|
|
988
851
|
*/
|
|
989
852
|
async search(query) {
|
|
990
|
-
const { searchObservations: searchObservations2 } = await Promise.resolve().then(() => (init_Observations(), Observations_exports));
|
|
991
|
-
const { searchSummaries: searchSummaries2 } = await Promise.resolve().then(() => (init_Summaries(), Summaries_exports));
|
|
992
853
|
return {
|
|
993
|
-
observations:
|
|
994
|
-
summaries:
|
|
854
|
+
observations: searchObservations(this.db.db, query, this.project),
|
|
855
|
+
summaries: searchSummaries(this.db.db, query, this.project)
|
|
995
856
|
};
|
|
996
857
|
}
|
|
997
858
|
/**
|
|
998
859
|
* Get recent observations
|
|
999
860
|
*/
|
|
1000
861
|
async getRecentObservations(limit = 10) {
|
|
1001
|
-
|
|
1002
|
-
return getObservationsByProject2(this.db.db, this.project, limit);
|
|
862
|
+
return getObservationsByProject(this.db.db, this.project, limit);
|
|
1003
863
|
}
|
|
1004
864
|
/**
|
|
1005
865
|
* Get recent summaries
|
|
1006
866
|
*/
|
|
1007
867
|
async getRecentSummaries(limit = 5) {
|
|
1008
|
-
|
|
1009
|
-
return getSummariesByProject2(this.db.db, this.project, limit);
|
|
868
|
+
return getSummariesByProject(this.db.db, this.project, limit);
|
|
1010
869
|
}
|
|
1011
870
|
/**
|
|
1012
871
|
* Advanced search with FTS5 and filters
|
|
1013
872
|
*/
|
|
1014
873
|
async searchAdvanced(query, filters = {}) {
|
|
1015
|
-
const { searchObservationsFTS: searchObservationsFTS2 } = await Promise.resolve().then(() => (init_Search(), Search_exports));
|
|
1016
|
-
const { searchSummariesFiltered: searchSummariesFiltered2 } = await Promise.resolve().then(() => (init_Search(), Search_exports));
|
|
1017
874
|
const projectFilters = { ...filters, project: filters.project || this.project };
|
|
1018
875
|
return {
|
|
1019
|
-
observations:
|
|
1020
|
-
summaries:
|
|
876
|
+
observations: searchObservationsFTS(this.db.db, query, projectFilters),
|
|
877
|
+
summaries: searchSummariesFiltered(this.db.db, query, projectFilters)
|
|
1021
878
|
};
|
|
1022
879
|
}
|
|
1023
880
|
/**
|
|
1024
881
|
* Retrieve observations by ID (batch)
|
|
1025
882
|
*/
|
|
1026
883
|
async getObservationsByIds(ids) {
|
|
1027
|
-
|
|
1028
|
-
return getObservationsByIds2(this.db.db, ids);
|
|
884
|
+
return getObservationsByIds(this.db.db, ids);
|
|
1029
885
|
}
|
|
1030
886
|
/**
|
|
1031
887
|
* Timeline: chronological context around an observation
|
|
1032
888
|
*/
|
|
1033
889
|
async getTimeline(anchorId, depthBefore = 5, depthAfter = 5) {
|
|
1034
|
-
|
|
1035
|
-
return getTimeline2(this.db.db, anchorId, depthBefore, depthAfter);
|
|
890
|
+
return getTimeline(this.db.db, anchorId, depthBefore, depthAfter);
|
|
1036
891
|
}
|
|
1037
892
|
/**
|
|
1038
893
|
* Create or retrieve a session for the current project
|
|
1039
894
|
*/
|
|
1040
895
|
async getOrCreateSession(contentSessionId) {
|
|
1041
|
-
|
|
1042
|
-
let session = getSessionByContentId2(this.db.db, contentSessionId);
|
|
896
|
+
let session = getSessionByContentId(this.db.db, contentSessionId);
|
|
1043
897
|
if (!session) {
|
|
1044
|
-
const id =
|
|
898
|
+
const id = createSession(this.db.db, contentSessionId, this.project, "");
|
|
1045
899
|
session = {
|
|
1046
900
|
id,
|
|
1047
901
|
content_session_id: contentSessionId,
|
|
@@ -1061,15 +915,13 @@ var KiroMemorySDK = class {
|
|
|
1061
915
|
* Store a user prompt
|
|
1062
916
|
*/
|
|
1063
917
|
async storePrompt(contentSessionId, promptNumber, text) {
|
|
1064
|
-
|
|
1065
|
-
return createPrompt2(this.db.db, contentSessionId, this.project, promptNumber, text);
|
|
918
|
+
return createPrompt(this.db.db, contentSessionId, this.project, promptNumber, text);
|
|
1066
919
|
}
|
|
1067
920
|
/**
|
|
1068
921
|
* Complete a session
|
|
1069
922
|
*/
|
|
1070
923
|
async completeSession(sessionId) {
|
|
1071
|
-
|
|
1072
|
-
completeSession2(this.db.db, sessionId);
|
|
924
|
+
completeSession(this.db.db, sessionId);
|
|
1073
925
|
}
|
|
1074
926
|
/**
|
|
1075
927
|
* Getter for current project name
|
|
@@ -1140,7 +992,7 @@ var fileChangeHook = {
|
|
|
1140
992
|
trigger: "file-save",
|
|
1141
993
|
async action(context) {
|
|
1142
994
|
if (!context.data?.filePath) return;
|
|
1143
|
-
const sdk = createKiroMemory({ project: context.project });
|
|
995
|
+
const sdk = createKiroMemory({ project: context.project, skipMigrations: true });
|
|
1144
996
|
try {
|
|
1145
997
|
await sdk.storeObservation({
|
|
1146
998
|
type: "file-change",
|
|
@@ -1160,7 +1012,7 @@ var sessionSummaryHook = {
|
|
|
1160
1012
|
trigger: "session-end",
|
|
1161
1013
|
async action(context) {
|
|
1162
1014
|
if (!context.data?.summary) return;
|
|
1163
|
-
const sdk = createKiroMemory({ project: context.project });
|
|
1015
|
+
const sdk = createKiroMemory({ project: context.project, skipMigrations: true });
|
|
1164
1016
|
try {
|
|
1165
1017
|
await sdk.storeSummary({
|
|
1166
1018
|
learned: context.data.summary
|