@gilangjavier/chrona 0.1.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/LICENSE +21 -0
- package/README.md +590 -0
- package/dist/chunk-PPAKIDJE.js +391 -0
- package/dist/chunk-PPAKIDJE.js.map +1 -0
- package/dist/cli.cjs +555 -0
- package/dist/cli.cjs.map +1 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +160 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.cjs +427 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +92 -0
- package/dist/index.d.ts +92 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
var memoryTypes = ["decision", "preference", "fact", "incident", "constraint"];
|
|
3
|
+
var memoryScopes = ["user", "project", "org", "shared"];
|
|
4
|
+
var sourceKinds = ["tool", "session", "repo"];
|
|
5
|
+
|
|
6
|
+
// src/utils.ts
|
|
7
|
+
import { randomUUID } from "crypto";
|
|
8
|
+
function toIsoString(value) {
|
|
9
|
+
const date = value instanceof Date ? value : value ? new Date(value) : /* @__PURE__ */ new Date();
|
|
10
|
+
const iso = date.toISOString();
|
|
11
|
+
if (Number.isNaN(date.getTime())) {
|
|
12
|
+
throw new Error(`Invalid date: ${String(value)}`);
|
|
13
|
+
}
|
|
14
|
+
return iso;
|
|
15
|
+
}
|
|
16
|
+
function uniqueSorted(values) {
|
|
17
|
+
return [...new Set((values ?? []).map((value) => value.trim()).filter(Boolean))].sort((a, b) => a.localeCompare(b));
|
|
18
|
+
}
|
|
19
|
+
function normalizeConfidence(value) {
|
|
20
|
+
if (!Number.isFinite(value) || value < 0 || value > 1) {
|
|
21
|
+
throw new Error("confidence must be between 0 and 1");
|
|
22
|
+
}
|
|
23
|
+
return Number(value.toFixed(6));
|
|
24
|
+
}
|
|
25
|
+
function parseJsonObject(value) {
|
|
26
|
+
if (value === void 0 || value === null) {
|
|
27
|
+
return void 0;
|
|
28
|
+
}
|
|
29
|
+
if (typeof value === "object" && !Array.isArray(value)) {
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
if (typeof value !== "string" || value.trim() === "") {
|
|
33
|
+
throw new Error("metadata must be an object or JSON object string");
|
|
34
|
+
}
|
|
35
|
+
const parsed = JSON.parse(value);
|
|
36
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
37
|
+
throw new Error("metadata must be a JSON object");
|
|
38
|
+
}
|
|
39
|
+
return parsed;
|
|
40
|
+
}
|
|
41
|
+
function parseCsv(value) {
|
|
42
|
+
if (!value) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
return value.split(",").map((item) => item.trim()).filter(Boolean);
|
|
46
|
+
}
|
|
47
|
+
function ensureId(value) {
|
|
48
|
+
return value?.trim() || randomUUID();
|
|
49
|
+
}
|
|
50
|
+
function serializeJson(value) {
|
|
51
|
+
return JSON.stringify(value ?? {});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// src/validate.ts
|
|
55
|
+
function includesValue(values, value, label) {
|
|
56
|
+
if (!values.includes(value)) {
|
|
57
|
+
throw new Error(`Invalid ${label}: ${value}`);
|
|
58
|
+
}
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
function parseMemoryType(value) {
|
|
62
|
+
return includesValue(memoryTypes, value, "type");
|
|
63
|
+
}
|
|
64
|
+
function parseMemoryScope(value) {
|
|
65
|
+
return includesValue(memoryScopes, value, "scope");
|
|
66
|
+
}
|
|
67
|
+
function parseSourceKind(value) {
|
|
68
|
+
return includesValue(sourceKinds, value, "source kind");
|
|
69
|
+
}
|
|
70
|
+
function normalizeEntry(input) {
|
|
71
|
+
if (!input.text.trim()) {
|
|
72
|
+
throw new Error("text is required");
|
|
73
|
+
}
|
|
74
|
+
if (!input.source?.value?.trim()) {
|
|
75
|
+
throw new Error("source.value is required");
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
id: ensureId(input.id),
|
|
79
|
+
type: parseMemoryType(input.type),
|
|
80
|
+
text: input.text.trim(),
|
|
81
|
+
createdAt: toIsoString(input.createdAt),
|
|
82
|
+
source: {
|
|
83
|
+
kind: parseSourceKind(input.source.kind),
|
|
84
|
+
value: input.source.value.trim()
|
|
85
|
+
},
|
|
86
|
+
confidence: normalizeConfidence(input.confidence),
|
|
87
|
+
scope: parseMemoryScope(input.scope),
|
|
88
|
+
tags: uniqueSorted(input.tags),
|
|
89
|
+
expiresAt: input.expiresAt ? toIsoString(input.expiresAt) : void 0,
|
|
90
|
+
links: uniqueSorted(input.links),
|
|
91
|
+
metadata: parseJsonObject(input.metadata)
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// src/store.ts
|
|
96
|
+
import Database from "better-sqlite3";
|
|
97
|
+
import { mkdirSync } from "fs";
|
|
98
|
+
import { dirname, resolve } from "path";
|
|
99
|
+
var ChromaStore = class {
|
|
100
|
+
path;
|
|
101
|
+
db;
|
|
102
|
+
constructor(path = resolve(process.cwd(), ".chrona/chrona.db")) {
|
|
103
|
+
this.path = resolve(path);
|
|
104
|
+
mkdirSync(dirname(this.path), { recursive: true });
|
|
105
|
+
this.db = new Database(this.path);
|
|
106
|
+
this.db.pragma("journal_mode = WAL");
|
|
107
|
+
this.db.pragma("foreign_keys = ON");
|
|
108
|
+
this.db.pragma("busy_timeout = 5000");
|
|
109
|
+
}
|
|
110
|
+
init() {
|
|
111
|
+
this.db.exec(`
|
|
112
|
+
CREATE TABLE IF NOT EXISTS memories (
|
|
113
|
+
id TEXT PRIMARY KEY,
|
|
114
|
+
type TEXT NOT NULL,
|
|
115
|
+
text TEXT NOT NULL,
|
|
116
|
+
created_at TEXT NOT NULL,
|
|
117
|
+
source_kind TEXT NOT NULL,
|
|
118
|
+
source_value TEXT NOT NULL,
|
|
119
|
+
confidence REAL NOT NULL,
|
|
120
|
+
scope TEXT NOT NULL,
|
|
121
|
+
tags_json TEXT NOT NULL,
|
|
122
|
+
expires_at TEXT,
|
|
123
|
+
links_json TEXT NOT NULL,
|
|
124
|
+
metadata_json TEXT NOT NULL
|
|
125
|
+
);
|
|
126
|
+
|
|
127
|
+
CREATE INDEX IF NOT EXISTS idx_memories_created_at ON memories(created_at);
|
|
128
|
+
CREATE INDEX IF NOT EXISTS idx_memories_scope ON memories(scope);
|
|
129
|
+
CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(type);
|
|
130
|
+
CREATE INDEX IF NOT EXISTS idx_memories_expires_at ON memories(expires_at);
|
|
131
|
+
CREATE INDEX IF NOT EXISTS idx_memories_source ON memories(source_kind, source_value);
|
|
132
|
+
`);
|
|
133
|
+
}
|
|
134
|
+
close() {
|
|
135
|
+
this.db.close();
|
|
136
|
+
}
|
|
137
|
+
add(input) {
|
|
138
|
+
const entry = normalizeEntry(input);
|
|
139
|
+
this.init();
|
|
140
|
+
this.db.prepare(`
|
|
141
|
+
INSERT INTO memories (
|
|
142
|
+
id,
|
|
143
|
+
type,
|
|
144
|
+
text,
|
|
145
|
+
created_at,
|
|
146
|
+
source_kind,
|
|
147
|
+
source_value,
|
|
148
|
+
confidence,
|
|
149
|
+
scope,
|
|
150
|
+
tags_json,
|
|
151
|
+
expires_at,
|
|
152
|
+
links_json,
|
|
153
|
+
metadata_json
|
|
154
|
+
) VALUES (
|
|
155
|
+
@id,
|
|
156
|
+
@type,
|
|
157
|
+
@text,
|
|
158
|
+
@created_at,
|
|
159
|
+
@source_kind,
|
|
160
|
+
@source_value,
|
|
161
|
+
@confidence,
|
|
162
|
+
@scope,
|
|
163
|
+
@tags_json,
|
|
164
|
+
@expires_at,
|
|
165
|
+
@links_json,
|
|
166
|
+
@metadata_json
|
|
167
|
+
)
|
|
168
|
+
`).run(this.toRow(entry));
|
|
169
|
+
return entry;
|
|
170
|
+
}
|
|
171
|
+
get(id) {
|
|
172
|
+
this.init();
|
|
173
|
+
const row = this.db.prepare("SELECT * FROM memories WHERE id = ?").get(id);
|
|
174
|
+
return row ? this.fromRow(row) : null;
|
|
175
|
+
}
|
|
176
|
+
search(options) {
|
|
177
|
+
this.init();
|
|
178
|
+
const { sql, params } = this.buildQuery(
|
|
179
|
+
options,
|
|
180
|
+
[
|
|
181
|
+
"(",
|
|
182
|
+
"lower(text) LIKE @query",
|
|
183
|
+
"OR lower(tags_json) LIKE @query",
|
|
184
|
+
"OR lower(source_kind || ':' || source_value) LIKE @query",
|
|
185
|
+
"OR lower(metadata_json) LIKE @query",
|
|
186
|
+
")"
|
|
187
|
+
].join(" "),
|
|
188
|
+
{ query: `%${options.query.toLowerCase()}%` },
|
|
189
|
+
"ORDER BY created_at DESC, confidence DESC, id ASC"
|
|
190
|
+
);
|
|
191
|
+
return this.db.prepare(sql).all(params).map((row) => this.fromRow(row));
|
|
192
|
+
}
|
|
193
|
+
timeline(options = {}) {
|
|
194
|
+
this.init();
|
|
195
|
+
const direction = options.order === "desc" ? "DESC" : "ASC";
|
|
196
|
+
const { sql, params } = this.buildQuery(options, void 0, {}, `ORDER BY created_at ${direction}, id ASC`);
|
|
197
|
+
return this.db.prepare(sql).all(params).map((row) => this.fromRow(row));
|
|
198
|
+
}
|
|
199
|
+
exportJsonl(options = {}) {
|
|
200
|
+
return this.timeline(options).map((entry) => JSON.stringify(entry)).join("\n");
|
|
201
|
+
}
|
|
202
|
+
importJsonl(input) {
|
|
203
|
+
this.init();
|
|
204
|
+
const lines = input.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
205
|
+
const ids = [];
|
|
206
|
+
let imported = 0;
|
|
207
|
+
let updated = 0;
|
|
208
|
+
const statement = this.db.prepare(`
|
|
209
|
+
INSERT INTO memories (
|
|
210
|
+
id,
|
|
211
|
+
type,
|
|
212
|
+
text,
|
|
213
|
+
created_at,
|
|
214
|
+
source_kind,
|
|
215
|
+
source_value,
|
|
216
|
+
confidence,
|
|
217
|
+
scope,
|
|
218
|
+
tags_json,
|
|
219
|
+
expires_at,
|
|
220
|
+
links_json,
|
|
221
|
+
metadata_json
|
|
222
|
+
) VALUES (
|
|
223
|
+
@id,
|
|
224
|
+
@type,
|
|
225
|
+
@text,
|
|
226
|
+
@created_at,
|
|
227
|
+
@source_kind,
|
|
228
|
+
@source_value,
|
|
229
|
+
@confidence,
|
|
230
|
+
@scope,
|
|
231
|
+
@tags_json,
|
|
232
|
+
@expires_at,
|
|
233
|
+
@links_json,
|
|
234
|
+
@metadata_json
|
|
235
|
+
)
|
|
236
|
+
ON CONFLICT(id) DO UPDATE SET
|
|
237
|
+
type = excluded.type,
|
|
238
|
+
text = excluded.text,
|
|
239
|
+
created_at = excluded.created_at,
|
|
240
|
+
source_kind = excluded.source_kind,
|
|
241
|
+
source_value = excluded.source_value,
|
|
242
|
+
confidence = excluded.confidence,
|
|
243
|
+
scope = excluded.scope,
|
|
244
|
+
tags_json = excluded.tags_json,
|
|
245
|
+
expires_at = excluded.expires_at,
|
|
246
|
+
links_json = excluded.links_json,
|
|
247
|
+
metadata_json = excluded.metadata_json
|
|
248
|
+
`);
|
|
249
|
+
const transaction = this.db.transaction(() => {
|
|
250
|
+
for (const line of lines) {
|
|
251
|
+
const entry = normalizeEntry(JSON.parse(line));
|
|
252
|
+
const exists = this.get(entry.id);
|
|
253
|
+
statement.run(this.toRow(entry));
|
|
254
|
+
ids.push(entry.id);
|
|
255
|
+
if (exists) {
|
|
256
|
+
updated += 1;
|
|
257
|
+
} else {
|
|
258
|
+
imported += 1;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
transaction();
|
|
263
|
+
return {
|
|
264
|
+
imported,
|
|
265
|
+
updated,
|
|
266
|
+
ids: [...ids].sort((a, b) => a.localeCompare(b))
|
|
267
|
+
};
|
|
268
|
+
}
|
|
269
|
+
gc(now) {
|
|
270
|
+
this.init();
|
|
271
|
+
const nowIso = toIsoString(now);
|
|
272
|
+
const rows = this.db.prepare(
|
|
273
|
+
"SELECT id FROM memories WHERE expires_at IS NOT NULL AND expires_at <= ? ORDER BY expires_at ASC, id ASC"
|
|
274
|
+
).all(nowIso);
|
|
275
|
+
const ids = rows.map((row) => row.id);
|
|
276
|
+
if (ids.length > 0) {
|
|
277
|
+
this.db.prepare("DELETE FROM memories WHERE expires_at IS NOT NULL AND expires_at <= ?").run(nowIso);
|
|
278
|
+
}
|
|
279
|
+
return {
|
|
280
|
+
deleted: ids.length,
|
|
281
|
+
ids,
|
|
282
|
+
now: nowIso
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
buildQuery(options, extraWhere, extraParams = {}, orderBy = "ORDER BY created_at ASC, id ASC") {
|
|
286
|
+
const where = [];
|
|
287
|
+
const params = { ...extraParams };
|
|
288
|
+
if (!options.includeExpired) {
|
|
289
|
+
where.push("(expires_at IS NULL OR expires_at > @now)");
|
|
290
|
+
params.now = toIsoString();
|
|
291
|
+
}
|
|
292
|
+
if (options.scopes?.length) {
|
|
293
|
+
const placeholders = options.scopes.map((_, index) => `@scope${index}`);
|
|
294
|
+
where.push(`scope IN (${placeholders.join(", ")})`);
|
|
295
|
+
for (const [index, scope] of options.scopes.entries()) {
|
|
296
|
+
params[`scope${index}`] = scope;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (options.types?.length) {
|
|
300
|
+
const placeholders = options.types.map((_, index) => `@type${index}`);
|
|
301
|
+
where.push(`type IN (${placeholders.join(", ")})`);
|
|
302
|
+
for (const [index, type] of options.types.entries()) {
|
|
303
|
+
params[`type${index}`] = type;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
if (options.tags?.length) {
|
|
307
|
+
const tagParts = [];
|
|
308
|
+
for (const [index, tag] of options.tags.entries()) {
|
|
309
|
+
const key = `tag${index}`;
|
|
310
|
+
tagParts.push(`lower(tags_json) LIKE @${key}`);
|
|
311
|
+
params[key] = `%${tag.toLowerCase()}%`;
|
|
312
|
+
}
|
|
313
|
+
where.push(`(${tagParts.join(" OR ")})`);
|
|
314
|
+
}
|
|
315
|
+
if (options.sourceKind) {
|
|
316
|
+
where.push("source_kind = @sourceKind");
|
|
317
|
+
params.sourceKind = options.sourceKind;
|
|
318
|
+
}
|
|
319
|
+
if (options.sourceValue) {
|
|
320
|
+
where.push("source_value = @sourceValue");
|
|
321
|
+
params.sourceValue = options.sourceValue;
|
|
322
|
+
}
|
|
323
|
+
if (options.before) {
|
|
324
|
+
where.push("created_at <= @before");
|
|
325
|
+
params.before = toIsoString(options.before);
|
|
326
|
+
}
|
|
327
|
+
if (options.after) {
|
|
328
|
+
where.push("created_at >= @after");
|
|
329
|
+
params.after = toIsoString(options.after);
|
|
330
|
+
}
|
|
331
|
+
if (extraWhere) {
|
|
332
|
+
where.push(extraWhere);
|
|
333
|
+
}
|
|
334
|
+
const limit = Math.max(1, Math.min(options.limit ?? 50, 1e3));
|
|
335
|
+
params.limit = limit;
|
|
336
|
+
const whereSql = where.length ? `WHERE ${where.join(" AND ")}` : "";
|
|
337
|
+
return {
|
|
338
|
+
sql: `SELECT * FROM memories ${whereSql} ${orderBy} LIMIT @limit`,
|
|
339
|
+
params
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
toRow(entry) {
|
|
343
|
+
return {
|
|
344
|
+
id: entry.id,
|
|
345
|
+
type: entry.type,
|
|
346
|
+
text: entry.text,
|
|
347
|
+
created_at: entry.createdAt,
|
|
348
|
+
source_kind: entry.source.kind,
|
|
349
|
+
source_value: entry.source.value,
|
|
350
|
+
confidence: entry.confidence,
|
|
351
|
+
scope: entry.scope,
|
|
352
|
+
tags_json: serializeJson(entry.tags),
|
|
353
|
+
expires_at: entry.expiresAt ?? null,
|
|
354
|
+
links_json: serializeJson(entry.links ?? []),
|
|
355
|
+
metadata_json: serializeJson(entry.metadata ?? {})
|
|
356
|
+
};
|
|
357
|
+
}
|
|
358
|
+
fromRow(row) {
|
|
359
|
+
return {
|
|
360
|
+
id: row.id,
|
|
361
|
+
type: row.type,
|
|
362
|
+
text: row.text,
|
|
363
|
+
createdAt: row.created_at,
|
|
364
|
+
source: {
|
|
365
|
+
kind: row.source_kind,
|
|
366
|
+
value: row.source_value
|
|
367
|
+
},
|
|
368
|
+
confidence: row.confidence,
|
|
369
|
+
scope: row.scope,
|
|
370
|
+
tags: JSON.parse(row.tags_json),
|
|
371
|
+
expiresAt: row.expires_at ?? void 0,
|
|
372
|
+
links: JSON.parse(row.links_json),
|
|
373
|
+
metadata: JSON.parse(row.metadata_json)
|
|
374
|
+
};
|
|
375
|
+
}
|
|
376
|
+
};
|
|
377
|
+
|
|
378
|
+
export {
|
|
379
|
+
memoryTypes,
|
|
380
|
+
memoryScopes,
|
|
381
|
+
sourceKinds,
|
|
382
|
+
toIsoString,
|
|
383
|
+
parseJsonObject,
|
|
384
|
+
parseCsv,
|
|
385
|
+
parseMemoryType,
|
|
386
|
+
parseMemoryScope,
|
|
387
|
+
parseSourceKind,
|
|
388
|
+
normalizeEntry,
|
|
389
|
+
ChromaStore
|
|
390
|
+
};
|
|
391
|
+
//# sourceMappingURL=chunk-PPAKIDJE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts","../src/utils.ts","../src/validate.ts","../src/store.ts"],"sourcesContent":["export const memoryTypes = [\"decision\", \"preference\", \"fact\", \"incident\", \"constraint\"] as const;\nexport const memoryScopes = [\"user\", \"project\", \"org\", \"shared\"] as const;\nexport const sourceKinds = [\"tool\", \"session\", \"repo\"] as const;\n\nexport type MemoryType = (typeof memoryTypes)[number];\nexport type MemoryScope = (typeof memoryScopes)[number];\nexport type SourceKind = (typeof sourceKinds)[number];\n\nexport interface MemorySource {\n kind: SourceKind;\n value: string;\n}\n\nexport interface MemoryEntry {\n id: string;\n type: MemoryType;\n text: string;\n createdAt: string;\n source: MemorySource;\n confidence: number;\n scope: MemoryScope;\n tags: string[];\n expiresAt?: string;\n links?: string[];\n metadata?: Record<string, unknown>;\n}\n\nexport interface AddMemoryInput {\n id?: string;\n type: MemoryType;\n text: string;\n createdAt?: string;\n source: MemorySource;\n confidence: number;\n scope: MemoryScope;\n tags: string[];\n expiresAt?: string;\n links?: string[];\n metadata?: Record<string, unknown>;\n}\n\nexport interface QueryOptions {\n scopes?: MemoryScope[];\n types?: MemoryType[];\n tags?: string[];\n sourceKind?: SourceKind;\n sourceValue?: string;\n before?: string;\n after?: string;\n includeExpired?: boolean;\n limit?: number;\n}\n\nexport interface SearchOptions extends QueryOptions {\n query: string;\n}\n\nexport interface TimelineOptions extends QueryOptions {\n order?: \"asc\" | \"desc\";\n}\n\nexport interface ExportOptions extends TimelineOptions {}\n\nexport interface ImportResult {\n imported: number;\n updated: number;\n ids: string[];\n}\n\nexport interface GcResult {\n deleted: number;\n ids: string[];\n now: string;\n}\n","import { randomUUID } from \"node:crypto\";\n\nexport function toIsoString(value?: string | Date): string {\n const date = value instanceof Date ? value : value ? new Date(value) : new Date();\n const iso = date.toISOString();\n\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid date: ${String(value)}`);\n }\n\n return iso;\n}\n\nexport function uniqueSorted(values: string[] | undefined): string[] {\n return [...new Set((values ?? []).map((value) => value.trim()).filter(Boolean))].sort((a, b) => a.localeCompare(b));\n}\n\nexport function normalizeConfidence(value: number): number {\n if (!Number.isFinite(value) || value < 0 || value > 1) {\n throw new Error(\"confidence must be between 0 and 1\");\n }\n\n return Number(value.toFixed(6));\n}\n\nexport function parseJsonObject(value: unknown): Record<string, unknown> | undefined {\n if (value === undefined || value === null) {\n return undefined;\n }\n\n if (typeof value === \"object\" && !Array.isArray(value)) {\n return value as Record<string, unknown>;\n }\n\n if (typeof value !== \"string\" || value.trim() === \"\") {\n throw new Error(\"metadata must be an object or JSON object string\");\n }\n\n const parsed = JSON.parse(value) as unknown;\n\n if (!parsed || typeof parsed !== \"object\" || Array.isArray(parsed)) {\n throw new Error(\"metadata must be a JSON object\");\n }\n\n return parsed as Record<string, unknown>;\n}\n\nexport function parseCsv(value?: string): string[] {\n if (!value) {\n return [];\n }\n\n return value.split(\",\").map((item) => item.trim()).filter(Boolean);\n}\n\nexport function ensureId(value?: string): string {\n return value?.trim() || randomUUID();\n}\n\nexport function serializeJson(value: unknown): string {\n return JSON.stringify(value ?? {});\n}\n","import {\n memoryScopes,\n memoryTypes,\n sourceKinds,\n type AddMemoryInput,\n type MemoryEntry,\n type MemoryScope,\n type MemoryType,\n type SourceKind\n} from \"./types.js\";\nimport { ensureId, normalizeConfidence, parseJsonObject, toIsoString, uniqueSorted } from \"./utils.js\";\n\nfunction includesValue<T extends string>(values: readonly T[], value: string, label: string): T {\n if (!values.includes(value as T)) {\n throw new Error(`Invalid ${label}: ${value}`);\n }\n\n return value as T;\n}\n\nexport function parseMemoryType(value: string): MemoryType {\n return includesValue(memoryTypes, value, \"type\");\n}\n\nexport function parseMemoryScope(value: string): MemoryScope {\n return includesValue(memoryScopes, value, \"scope\");\n}\n\nexport function parseSourceKind(value: string): SourceKind {\n return includesValue(sourceKinds, value, \"source kind\");\n}\n\nexport function normalizeEntry(input: AddMemoryInput | MemoryEntry): MemoryEntry {\n if (!input.text.trim()) {\n throw new Error(\"text is required\");\n }\n\n if (!input.source?.value?.trim()) {\n throw new Error(\"source.value is required\");\n }\n\n return {\n id: ensureId(input.id),\n type: parseMemoryType(input.type),\n text: input.text.trim(),\n createdAt: toIsoString(input.createdAt),\n source: {\n kind: parseSourceKind(input.source.kind),\n value: input.source.value.trim()\n },\n confidence: normalizeConfidence(input.confidence),\n scope: parseMemoryScope(input.scope),\n tags: uniqueSorted(input.tags),\n expiresAt: input.expiresAt ? toIsoString(input.expiresAt) : undefined,\n links: uniqueSorted(input.links),\n metadata: parseJsonObject(input.metadata)\n };\n}\n","import Database from \"better-sqlite3\";\nimport { mkdirSync } from \"node:fs\";\nimport { dirname, resolve } from \"node:path\";\nimport type {\n AddMemoryInput,\n ExportOptions,\n GcResult,\n ImportResult,\n MemoryEntry,\n QueryOptions,\n SearchOptions,\n TimelineOptions\n} from \"./types.js\";\nimport { normalizeEntry } from \"./validate.js\";\nimport { serializeJson, toIsoString } from \"./utils.js\";\n\ninterface MemoryRow {\n id: string;\n type: MemoryEntry[\"type\"];\n text: string;\n created_at: string;\n source_kind: MemoryEntry[\"source\"][\"kind\"];\n source_value: string;\n confidence: number;\n scope: MemoryEntry[\"scope\"];\n tags_json: string;\n expires_at: string | null;\n links_json: string;\n metadata_json: string;\n}\n\nexport class ChromaStore {\n readonly path: string;\n readonly db: Database.Database;\n\n constructor(path = resolve(process.cwd(), \".chrona/chrona.db\")) {\n this.path = resolve(path);\n mkdirSync(dirname(this.path), { recursive: true });\n this.db = new Database(this.path);\n this.db.pragma(\"journal_mode = WAL\");\n this.db.pragma(\"foreign_keys = ON\");\n this.db.pragma(\"busy_timeout = 5000\");\n }\n\n init(): void {\n this.db.exec(`\n CREATE TABLE IF NOT EXISTS memories (\n id TEXT PRIMARY KEY,\n type TEXT NOT NULL,\n text TEXT NOT NULL,\n created_at TEXT NOT NULL,\n source_kind TEXT NOT NULL,\n source_value TEXT NOT NULL,\n confidence REAL NOT NULL,\n scope TEXT NOT NULL,\n tags_json TEXT NOT NULL,\n expires_at TEXT,\n links_json TEXT NOT NULL,\n metadata_json TEXT NOT NULL\n );\n\n CREATE INDEX IF NOT EXISTS idx_memories_created_at ON memories(created_at);\n CREATE INDEX IF NOT EXISTS idx_memories_scope ON memories(scope);\n CREATE INDEX IF NOT EXISTS idx_memories_type ON memories(type);\n CREATE INDEX IF NOT EXISTS idx_memories_expires_at ON memories(expires_at);\n CREATE INDEX IF NOT EXISTS idx_memories_source ON memories(source_kind, source_value);\n `);\n }\n\n close(): void {\n this.db.close();\n }\n\n add(input: AddMemoryInput): MemoryEntry {\n const entry = normalizeEntry(input);\n this.init();\n\n this.db.prepare(`\n INSERT INTO memories (\n id,\n type,\n text,\n created_at,\n source_kind,\n source_value,\n confidence,\n scope,\n tags_json,\n expires_at,\n links_json,\n metadata_json\n ) VALUES (\n @id,\n @type,\n @text,\n @created_at,\n @source_kind,\n @source_value,\n @confidence,\n @scope,\n @tags_json,\n @expires_at,\n @links_json,\n @metadata_json\n )\n `).run(this.toRow(entry));\n\n return entry;\n }\n\n get(id: string): MemoryEntry | null {\n this.init();\n const row = this.db.prepare(\"SELECT * FROM memories WHERE id = ?\").get(id) as MemoryRow | undefined;\n return row ? this.fromRow(row) : null;\n }\n\n search(options: SearchOptions): MemoryEntry[] {\n this.init();\n const { sql, params } = this.buildQuery(\n options,\n [\n \"(\",\n \"lower(text) LIKE @query\",\n \"OR lower(tags_json) LIKE @query\",\n \"OR lower(source_kind || ':' || source_value) LIKE @query\",\n \"OR lower(metadata_json) LIKE @query\",\n \")\"\n ].join(\" \"),\n { query: `%${options.query.toLowerCase()}%` },\n \"ORDER BY created_at DESC, confidence DESC, id ASC\"\n );\n\n return this.db.prepare(sql).all(params).map((row) => this.fromRow(row as MemoryRow));\n }\n\n timeline(options: TimelineOptions = {}): MemoryEntry[] {\n this.init();\n const direction = options.order === \"desc\" ? \"DESC\" : \"ASC\";\n const { sql, params } = this.buildQuery(options, undefined, {}, `ORDER BY created_at ${direction}, id ASC`);\n return this.db.prepare(sql).all(params).map((row) => this.fromRow(row as MemoryRow));\n }\n\n exportJsonl(options: ExportOptions = {}): string {\n return this.timeline(options).map((entry) => JSON.stringify(entry)).join(\"\\n\");\n }\n\n importJsonl(input: string): ImportResult {\n this.init();\n const lines = input.split(/\\r?\\n/).map((line) => line.trim()).filter(Boolean);\n const ids: string[] = [];\n let imported = 0;\n let updated = 0;\n\n const statement = this.db.prepare(`\n INSERT INTO memories (\n id,\n type,\n text,\n created_at,\n source_kind,\n source_value,\n confidence,\n scope,\n tags_json,\n expires_at,\n links_json,\n metadata_json\n ) VALUES (\n @id,\n @type,\n @text,\n @created_at,\n @source_kind,\n @source_value,\n @confidence,\n @scope,\n @tags_json,\n @expires_at,\n @links_json,\n @metadata_json\n )\n ON CONFLICT(id) DO UPDATE SET\n type = excluded.type,\n text = excluded.text,\n created_at = excluded.created_at,\n source_kind = excluded.source_kind,\n source_value = excluded.source_value,\n confidence = excluded.confidence,\n scope = excluded.scope,\n tags_json = excluded.tags_json,\n expires_at = excluded.expires_at,\n links_json = excluded.links_json,\n metadata_json = excluded.metadata_json\n `);\n\n const transaction = this.db.transaction(() => {\n for (const line of lines) {\n const entry = normalizeEntry(JSON.parse(line) as AddMemoryInput);\n const exists = this.get(entry.id);\n statement.run(this.toRow(entry));\n ids.push(entry.id);\n if (exists) {\n updated += 1;\n } else {\n imported += 1;\n }\n }\n });\n\n transaction();\n\n return {\n imported,\n updated,\n ids: [...ids].sort((a, b) => a.localeCompare(b))\n };\n }\n\n gc(now?: string | Date): GcResult {\n this.init();\n const nowIso = toIsoString(now);\n const rows = this.db.prepare(\n \"SELECT id FROM memories WHERE expires_at IS NOT NULL AND expires_at <= ? ORDER BY expires_at ASC, id ASC\"\n ).all(nowIso) as Array<{ id: string }>;\n const ids = rows.map((row) => row.id);\n\n if (ids.length > 0) {\n this.db.prepare(\"DELETE FROM memories WHERE expires_at IS NOT NULL AND expires_at <= ?\").run(nowIso);\n }\n\n return {\n deleted: ids.length,\n ids,\n now: nowIso\n };\n }\n\n private buildQuery(\n options: QueryOptions,\n extraWhere?: string,\n extraParams: Record<string, unknown> = {},\n orderBy = \"ORDER BY created_at ASC, id ASC\"\n ): { sql: string; params: Record<string, unknown> } {\n const where: string[] = [];\n const params: Record<string, unknown> = { ...extraParams };\n\n if (!options.includeExpired) {\n where.push(\"(expires_at IS NULL OR expires_at > @now)\");\n params.now = toIsoString();\n }\n\n if (options.scopes?.length) {\n const placeholders = options.scopes.map((_, index) => `@scope${index}`);\n where.push(`scope IN (${placeholders.join(\", \")})`);\n for (const [index, scope] of options.scopes.entries()) {\n params[`scope${index}`] = scope;\n }\n }\n\n if (options.types?.length) {\n const placeholders = options.types.map((_, index) => `@type${index}`);\n where.push(`type IN (${placeholders.join(\", \")})`);\n for (const [index, type] of options.types.entries()) {\n params[`type${index}`] = type;\n }\n }\n\n if (options.tags?.length) {\n const tagParts: string[] = [];\n for (const [index, tag] of options.tags.entries()) {\n const key = `tag${index}`;\n tagParts.push(`lower(tags_json) LIKE @${key}`);\n params[key] = `%${tag.toLowerCase()}%`;\n }\n where.push(`(${tagParts.join(\" OR \")})`);\n }\n\n if (options.sourceKind) {\n where.push(\"source_kind = @sourceKind\");\n params.sourceKind = options.sourceKind;\n }\n\n if (options.sourceValue) {\n where.push(\"source_value = @sourceValue\");\n params.sourceValue = options.sourceValue;\n }\n\n if (options.before) {\n where.push(\"created_at <= @before\");\n params.before = toIsoString(options.before);\n }\n\n if (options.after) {\n where.push(\"created_at >= @after\");\n params.after = toIsoString(options.after);\n }\n\n if (extraWhere) {\n where.push(extraWhere);\n }\n\n const limit = Math.max(1, Math.min(options.limit ?? 50, 1000));\n params.limit = limit;\n const whereSql = where.length ? `WHERE ${where.join(\" AND \")}` : \"\";\n\n return {\n sql: `SELECT * FROM memories ${whereSql} ${orderBy} LIMIT @limit`,\n params\n };\n }\n\n private toRow(entry: MemoryEntry): Record<string, unknown> {\n return {\n id: entry.id,\n type: entry.type,\n text: entry.text,\n created_at: entry.createdAt,\n source_kind: entry.source.kind,\n source_value: entry.source.value,\n confidence: entry.confidence,\n scope: entry.scope,\n tags_json: serializeJson(entry.tags),\n expires_at: entry.expiresAt ?? null,\n links_json: serializeJson(entry.links ?? []),\n metadata_json: serializeJson(entry.metadata ?? {})\n };\n }\n\n private fromRow(row: MemoryRow): MemoryEntry {\n return {\n id: row.id,\n type: row.type,\n text: row.text,\n createdAt: row.created_at,\n source: {\n kind: row.source_kind,\n value: row.source_value\n },\n confidence: row.confidence,\n scope: row.scope,\n tags: JSON.parse(row.tags_json) as string[],\n expiresAt: row.expires_at ?? undefined,\n links: JSON.parse(row.links_json) as string[],\n metadata: JSON.parse(row.metadata_json) as Record<string, unknown>\n };\n }\n}\n"],"mappings":";AAAO,IAAM,cAAc,CAAC,YAAY,cAAc,QAAQ,YAAY,YAAY;AAC/E,IA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