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