@slorenzot/memento-core 0.7.0 → 2.0.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.es.md +446 -0
- package/README.md +117 -115
- package/dist/ConfigManager.d.ts +90 -0
- package/dist/ConfigManager.d.ts.map +1 -1
- package/dist/ConfigManager.js +263 -7
- package/dist/ConfigManager.js.map +1 -1
- package/dist/EmbeddingService.d.ts +54 -0
- package/dist/EmbeddingService.d.ts.map +1 -0
- package/dist/EmbeddingService.js +135 -0
- package/dist/EmbeddingService.js.map +1 -0
- package/dist/MemoryEngine.d.ts +238 -8
- package/dist/MemoryEngine.d.ts.map +1 -1
- package/dist/MemoryEngine.js +2267 -52
- package/dist/MemoryEngine.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +290 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -4
- package/dist/db/schema.d.ts +0 -353
- package/dist/db/schema.d.ts.map +0 -1
- package/dist/db/schema.js +0 -40
- package/dist/db/schema.js.map +0 -1
- package/drizzle.config.ts +0 -10
- package/src/ConfigManager.test.ts +0 -248
- package/src/ConfigManager.ts +0 -131
- package/src/MemoryEngine.test.ts +0 -456
- package/src/MemoryEngine.ts +0 -450
- package/src/db/schema.js +0 -39
- package/src/db/schema.ts +0 -40
- package/src/index.ts +0 -3
- package/src/types.ts +0 -52
- package/tsconfig.json +0 -18
- package/tsconfig.json.bak +0 -30
package/README.md
CHANGED
|
@@ -6,68 +6,68 @@
|
|
|
6
6
|
|
|
7
7
|
> Core memory engine with SQLite FTS5 search, session management, and observation persistence for AI coding agents.
|
|
8
8
|
|
|
9
|
-
## 🚀
|
|
9
|
+
## 🚀 Installation
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
# Using Bun (
|
|
12
|
+
# Using Bun (recommended)
|
|
13
13
|
bun add @slorenzot/memento-core
|
|
14
14
|
|
|
15
15
|
# Using npm
|
|
16
16
|
npm install @slorenzot/memento-core
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
## 💡
|
|
19
|
+
## 💡 Basic Usage
|
|
20
20
|
|
|
21
21
|
### TypeScript
|
|
22
22
|
```typescript
|
|
23
23
|
import { MemoryEngine } from '@slorenzot/memento-core';
|
|
24
24
|
|
|
25
|
-
//
|
|
25
|
+
// Initialize memory engine
|
|
26
26
|
const memory = new MemoryEngine('./data/memento.db');
|
|
27
27
|
|
|
28
|
-
//
|
|
28
|
+
// Create an observation
|
|
29
29
|
const observation = await memory.createObservation({
|
|
30
|
-
title: '
|
|
31
|
-
content: '
|
|
30
|
+
title: 'Architecture decision',
|
|
31
|
+
content: 'Use SQLite as the database engine',
|
|
32
32
|
type: 'decision',
|
|
33
33
|
topicKey: 'architecture',
|
|
34
34
|
projectId: 'my-project'
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
-
console.log('
|
|
37
|
+
console.log('Observation saved:', observation);
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
### Shell/Bun
|
|
41
41
|
```bash
|
|
42
|
-
#
|
|
42
|
+
# Run TypeScript script with memory engine
|
|
43
43
|
bun run memory-script.ts
|
|
44
44
|
```
|
|
45
45
|
|
|
46
|
-
## 🔧 API
|
|
46
|
+
## 🔧 Core API
|
|
47
47
|
|
|
48
|
-
###
|
|
48
|
+
### Main Class
|
|
49
49
|
|
|
50
50
|
#### `MemoryEngine(dbPath?: string)`
|
|
51
51
|
|
|
52
|
-
|
|
52
|
+
Memory engine constructor.
|
|
53
53
|
|
|
54
|
-
**
|
|
55
|
-
- `dbPath` (
|
|
54
|
+
**Parameters:**
|
|
55
|
+
- `dbPath` (optional): Path to the SQLite database file. Default: `'./data/memento.db'`
|
|
56
56
|
|
|
57
|
-
**
|
|
57
|
+
**Example:**
|
|
58
58
|
```typescript
|
|
59
59
|
const memory = new MemoryEngine('./custom/path.db');
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
---
|
|
63
63
|
|
|
64
|
-
####
|
|
64
|
+
#### Observation Methods
|
|
65
65
|
|
|
66
66
|
##### `createObservation(data)`
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
Creates a new observation in memory.
|
|
69
69
|
|
|
70
|
-
**
|
|
70
|
+
**Parameters:**
|
|
71
71
|
```typescript
|
|
72
72
|
{
|
|
73
73
|
title: string;
|
|
@@ -80,13 +80,13 @@ Crea una nueva observación en la memoria.
|
|
|
80
80
|
}
|
|
81
81
|
```
|
|
82
82
|
|
|
83
|
-
**
|
|
83
|
+
**Returns:** `Promise<Observation>`
|
|
84
84
|
|
|
85
|
-
**
|
|
85
|
+
**Example:**
|
|
86
86
|
```typescript
|
|
87
87
|
const observation = await memory.createObservation({
|
|
88
|
-
title: 'Bug
|
|
89
|
-
content: '
|
|
88
|
+
title: 'Bug found',
|
|
89
|
+
content: 'Server connection error',
|
|
90
90
|
type: 'bug',
|
|
91
91
|
projectId: 'project-123',
|
|
92
92
|
metadata: { severity: 'high', priority: 1 }
|
|
@@ -97,9 +97,9 @@ const observation = await memory.createObservation({
|
|
|
97
97
|
|
|
98
98
|
##### `search(params)`
|
|
99
99
|
|
|
100
|
-
|
|
100
|
+
Searches observations using FTS5 full-text search.
|
|
101
101
|
|
|
102
|
-
**
|
|
102
|
+
**Parameters:**
|
|
103
103
|
```typescript
|
|
104
104
|
{
|
|
105
105
|
query?: string;
|
|
@@ -111,18 +111,18 @@ Busca observaciones usando búsqueda full-text FTS5.
|
|
|
111
111
|
}
|
|
112
112
|
```
|
|
113
113
|
|
|
114
|
-
**
|
|
114
|
+
**Returns:** `Promise<SearchResult>`
|
|
115
115
|
|
|
116
|
-
**
|
|
116
|
+
**Example:**
|
|
117
117
|
```typescript
|
|
118
118
|
const results = await memory.search({
|
|
119
|
-
query: '
|
|
119
|
+
query: 'database architecture',
|
|
120
120
|
type: 'decision',
|
|
121
121
|
projectId: 'project-123',
|
|
122
122
|
limit: 10
|
|
123
123
|
});
|
|
124
124
|
|
|
125
|
-
console.log(`
|
|
125
|
+
console.log(`Found ${results.total} observations:`);
|
|
126
126
|
results.observations.forEach(obs => console.log(obs.title));
|
|
127
127
|
```
|
|
128
128
|
|
|
@@ -130,18 +130,18 @@ results.observations.forEach(obs => console.log(obs.title));
|
|
|
130
130
|
|
|
131
131
|
##### `getObservation(id)`
|
|
132
132
|
|
|
133
|
-
|
|
133
|
+
Gets an observation by its ID.
|
|
134
134
|
|
|
135
|
-
**
|
|
136
|
-
- `id`: ID
|
|
135
|
+
**Parameters:**
|
|
136
|
+
- `id`: Numeric ID of the observation
|
|
137
137
|
|
|
138
|
-
**
|
|
138
|
+
**Returns:** `Promise<Observation | null>`
|
|
139
139
|
|
|
140
|
-
**
|
|
140
|
+
**Example:**
|
|
141
141
|
```typescript
|
|
142
142
|
const observation = await memory.getObservation(123);
|
|
143
143
|
if (observation) {
|
|
144
|
-
console.log('
|
|
144
|
+
console.log('Observation found:', observation.title);
|
|
145
145
|
}
|
|
146
146
|
```
|
|
147
147
|
|
|
@@ -149,19 +149,19 @@ if (observation) {
|
|
|
149
149
|
|
|
150
150
|
##### `updateObservation(id, updates)`
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
Updates an existing observation.
|
|
153
153
|
|
|
154
|
-
**
|
|
155
|
-
- `id`: ID
|
|
156
|
-
- `updates`:
|
|
154
|
+
**Parameters:**
|
|
155
|
+
- `id`: Numeric ID of the observation
|
|
156
|
+
- `updates`: Object with fields to update
|
|
157
157
|
|
|
158
|
-
**
|
|
158
|
+
**Returns:** `Promise<Observation>`
|
|
159
159
|
|
|
160
|
-
**
|
|
160
|
+
**Example:**
|
|
161
161
|
```typescript
|
|
162
162
|
const updated = await memory.updateObservation(123, {
|
|
163
|
-
title: '
|
|
164
|
-
content: '
|
|
163
|
+
title: 'Updated title',
|
|
164
|
+
content: 'Modified content'
|
|
165
165
|
});
|
|
166
166
|
```
|
|
167
167
|
|
|
@@ -169,28 +169,28 @@ const updated = await memory.updateObservation(123, {
|
|
|
169
169
|
|
|
170
170
|
##### `deleteObservation(id)`
|
|
171
171
|
|
|
172
|
-
|
|
172
|
+
Deletes an observation by its ID.
|
|
173
173
|
|
|
174
|
-
**
|
|
175
|
-
- `id`: ID
|
|
174
|
+
**Parameters:**
|
|
175
|
+
- `id`: Numeric ID of the observation
|
|
176
176
|
|
|
177
|
-
**
|
|
177
|
+
**Returns:** `Promise<void>`
|
|
178
178
|
|
|
179
|
-
**
|
|
179
|
+
**Example:**
|
|
180
180
|
```typescript
|
|
181
181
|
await memory.deleteObservation(123);
|
|
182
|
-
console.log('
|
|
182
|
+
console.log('Observation deleted');
|
|
183
183
|
```
|
|
184
184
|
|
|
185
185
|
---
|
|
186
186
|
|
|
187
|
-
####
|
|
187
|
+
#### Session Methods
|
|
188
188
|
|
|
189
189
|
##### `createSession(data)`
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
Creates a new session for conversation tracking.
|
|
192
192
|
|
|
193
|
-
**
|
|
193
|
+
**Parameters:**
|
|
194
194
|
```typescript
|
|
195
195
|
{
|
|
196
196
|
projectId: string;
|
|
@@ -198,34 +198,34 @@ Crea una nueva sesión para seguimiento de conversaciones.
|
|
|
198
198
|
}
|
|
199
199
|
```
|
|
200
200
|
|
|
201
|
-
**
|
|
201
|
+
**Returns:** `Promise<Session>`
|
|
202
202
|
|
|
203
|
-
**
|
|
203
|
+
**Example:**
|
|
204
204
|
```typescript
|
|
205
205
|
const session = await memory.createSession({
|
|
206
206
|
projectId: 'my-project',
|
|
207
207
|
metadata: { agent: 'claude', userId: 'user-123' }
|
|
208
208
|
});
|
|
209
209
|
|
|
210
|
-
console.log('
|
|
210
|
+
console.log('Session started:', session.uuid);
|
|
211
211
|
```
|
|
212
212
|
|
|
213
213
|
---
|
|
214
214
|
|
|
215
215
|
##### `getSession(id)`
|
|
216
216
|
|
|
217
|
-
|
|
217
|
+
Gets a session by its ID.
|
|
218
218
|
|
|
219
|
-
**
|
|
220
|
-
- `id`: ID
|
|
219
|
+
**Parameters:**
|
|
220
|
+
- `id`: Numeric ID of the session
|
|
221
221
|
|
|
222
|
-
**
|
|
222
|
+
**Returns:** `Promise<Session | null>`
|
|
223
223
|
|
|
224
|
-
**
|
|
224
|
+
**Example:**
|
|
225
225
|
```typescript
|
|
226
226
|
const session = await memory.getSession(456);
|
|
227
227
|
if (session) {
|
|
228
|
-
console.log('
|
|
228
|
+
console.log('Session found:', session.uuid);
|
|
229
229
|
}
|
|
230
230
|
```
|
|
231
231
|
|
|
@@ -233,38 +233,38 @@ if (session) {
|
|
|
233
233
|
|
|
234
234
|
##### `endSession(id)`
|
|
235
235
|
|
|
236
|
-
|
|
236
|
+
Ends an active session.
|
|
237
237
|
|
|
238
|
-
**
|
|
239
|
-
- `id`: ID
|
|
238
|
+
**Parameters:**
|
|
239
|
+
- `id`: Numeric ID of the session
|
|
240
240
|
|
|
241
|
-
**
|
|
241
|
+
**Returns:** `Promise<Session>`
|
|
242
242
|
|
|
243
|
-
**
|
|
243
|
+
**Example:**
|
|
244
244
|
```typescript
|
|
245
245
|
const endedSession = await memory.endSession(456);
|
|
246
|
-
console.log('
|
|
246
|
+
console.log('Session ended:', endedSession.endedAt);
|
|
247
247
|
```
|
|
248
248
|
|
|
249
249
|
---
|
|
250
250
|
|
|
251
|
-
####
|
|
251
|
+
#### Close Method
|
|
252
252
|
|
|
253
253
|
##### `close()`
|
|
254
254
|
|
|
255
|
-
|
|
255
|
+
Closes the database connection.
|
|
256
256
|
|
|
257
|
-
**
|
|
257
|
+
**Returns:** `void`
|
|
258
258
|
|
|
259
|
-
**
|
|
259
|
+
**Example:**
|
|
260
260
|
```typescript
|
|
261
|
-
//
|
|
261
|
+
// On application cleanup
|
|
262
262
|
memory.close();
|
|
263
263
|
```
|
|
264
264
|
|
|
265
265
|
---
|
|
266
266
|
|
|
267
|
-
## 📝
|
|
267
|
+
## 📝 Core Types
|
|
268
268
|
|
|
269
269
|
```typescript
|
|
270
270
|
interface Observation {
|
|
@@ -304,26 +304,26 @@ interface SearchResult {
|
|
|
304
304
|
}
|
|
305
305
|
```
|
|
306
306
|
|
|
307
|
-
## ⚡
|
|
307
|
+
## ⚡ Practical Examples
|
|
308
308
|
|
|
309
|
-
###
|
|
309
|
+
### Example 1: Complete Memory Workflow
|
|
310
310
|
|
|
311
311
|
```typescript
|
|
312
312
|
import { MemoryEngine } from '@slorenzot/memento-core';
|
|
313
313
|
|
|
314
314
|
const memory = new MemoryEngine('./memory.db');
|
|
315
315
|
|
|
316
|
-
//
|
|
316
|
+
// Create session for tracking
|
|
317
317
|
const session = await memory.createSession({
|
|
318
318
|
projectId: 'my-app',
|
|
319
319
|
metadata: { agent: 'claude' }
|
|
320
320
|
});
|
|
321
321
|
|
|
322
|
-
//
|
|
322
|
+
// Save observations during work
|
|
323
323
|
await memory.createObservation({
|
|
324
324
|
sessionId: session.id,
|
|
325
|
-
title: '
|
|
326
|
-
content: '
|
|
325
|
+
title: 'Server configuration',
|
|
326
|
+
content: 'Use Express.js with security middleware',
|
|
327
327
|
type: 'decision',
|
|
328
328
|
projectId: 'my-app',
|
|
329
329
|
topicKey: 'backend'
|
|
@@ -331,85 +331,85 @@ await memory.createObservation({
|
|
|
331
331
|
|
|
332
332
|
await memory.createObservation({
|
|
333
333
|
sessionId: session.id,
|
|
334
|
-
title: '
|
|
335
|
-
content: '
|
|
334
|
+
title: 'Authentication bug',
|
|
335
|
+
content: 'JWT not expiring correctly',
|
|
336
336
|
type: 'bug',
|
|
337
337
|
projectId: 'my-app',
|
|
338
338
|
topicKey: 'security'
|
|
339
339
|
});
|
|
340
340
|
|
|
341
|
-
//
|
|
341
|
+
// Search for related decisions
|
|
342
342
|
const decisions = await memory.search({
|
|
343
343
|
type: 'decision',
|
|
344
344
|
projectId: 'my-app'
|
|
345
345
|
});
|
|
346
346
|
|
|
347
|
-
console.log('
|
|
347
|
+
console.log('Decisions made:', decisions.observations);
|
|
348
348
|
|
|
349
|
-
//
|
|
349
|
+
// End session
|
|
350
350
|
await memory.endSession(session.id);
|
|
351
351
|
|
|
352
|
-
//
|
|
352
|
+
// Close connection
|
|
353
353
|
memory.close();
|
|
354
354
|
```
|
|
355
355
|
|
|
356
|
-
###
|
|
356
|
+
### Example 2: Advanced Search
|
|
357
357
|
|
|
358
358
|
```typescript
|
|
359
359
|
import { MemoryEngine } from '@slorenzot/memento-core';
|
|
360
360
|
|
|
361
361
|
const memory = new MemoryEngine('./memory.db');
|
|
362
362
|
|
|
363
|
-
//
|
|
363
|
+
// Complex search with multiple filters
|
|
364
364
|
const results = await memory.search({
|
|
365
|
-
query: '
|
|
365
|
+
query: 'database architecture',
|
|
366
366
|
type: 'decision',
|
|
367
367
|
projectId: 'my-app',
|
|
368
368
|
limit: 5,
|
|
369
369
|
offset: 10
|
|
370
370
|
});
|
|
371
371
|
|
|
372
|
-
console.log(`Total
|
|
372
|
+
console.log(`Total results: ${results.total}`);
|
|
373
373
|
results.observations.forEach((obs, index) => {
|
|
374
374
|
console.log(`${index + 1}. ${obs.title}`);
|
|
375
375
|
console.log(` ${obs.content.substring(0, 100)}...`);
|
|
376
|
-
console.log(`
|
|
376
|
+
console.log(` Type: ${obs.type} | Topic: ${obs.topicKey}`);
|
|
377
377
|
});
|
|
378
378
|
|
|
379
379
|
memory.close();
|
|
380
380
|
```
|
|
381
381
|
|
|
382
|
-
## ⚠️
|
|
382
|
+
## ⚠️ Restrictive License
|
|
383
383
|
|
|
384
|
-
|
|
385
|
-
- ✅ **
|
|
386
|
-
- ✅ **
|
|
387
|
-
- ❌ **
|
|
388
|
-
- ❌ **
|
|
384
|
+
This package is under **CC BY-NC-ND 4.0 License**:
|
|
385
|
+
- ✅ **Personal and educational use permitted**
|
|
386
|
+
- ✅ **Share with attribution to the author**
|
|
387
|
+
- ❌ **Commercial use NOT permitted**
|
|
388
|
+
- ❌ **Modifications or forks NOT permitted**
|
|
389
389
|
|
|
390
|
-
**
|
|
390
|
+
**Author:** Soulberto Lorenzo (slorenzot@gmail.com)
|
|
391
391
|
|
|
392
|
-
## 🔄
|
|
392
|
+
## 🔄 Dependencies
|
|
393
393
|
|
|
394
|
-
###
|
|
395
|
-
- `zod` -
|
|
396
|
-
- `nanoid` -
|
|
394
|
+
### Main Dependencies
|
|
395
|
+
- `zod` - Schema validation
|
|
396
|
+
- `nanoid` - Unique ID generation
|
|
397
397
|
|
|
398
398
|
### Peer Dependencies
|
|
399
|
-
- `bun` v1.0+ (
|
|
399
|
+
- `bun` v1.0+ (recommended)
|
|
400
400
|
- `node` v20+ (compatible)
|
|
401
401
|
|
|
402
|
-
## 🛠️
|
|
402
|
+
## 🛠️ Development
|
|
403
403
|
|
|
404
404
|
```bash
|
|
405
|
-
#
|
|
405
|
+
# Clone the project
|
|
406
406
|
git clone https://github.com/slorenzot/memento.git
|
|
407
407
|
cd memento/packages/core
|
|
408
408
|
|
|
409
|
-
#
|
|
409
|
+
# Install dependencies
|
|
410
410
|
bun install
|
|
411
411
|
|
|
412
|
-
#
|
|
412
|
+
# Development
|
|
413
413
|
bun run dev
|
|
414
414
|
|
|
415
415
|
# Build
|
|
@@ -422,23 +422,25 @@ bun test
|
|
|
422
422
|
## 📋 Changelog
|
|
423
423
|
|
|
424
424
|
### [0.1.0] - 2024-04-04
|
|
425
|
-
- **Added**:
|
|
426
|
-
- **Added**: SQLite
|
|
427
|
-
- **Added**:
|
|
428
|
-
- **Added**:
|
|
425
|
+
- **Added**: Initial version of the memory engine
|
|
426
|
+
- **Added**: SQLite with FTS5 for full-text search
|
|
427
|
+
- **Added**: Session and observation management
|
|
428
|
+
- **Added**: Full TypeScript support
|
|
429
429
|
|
|
430
|
-
## 👤
|
|
430
|
+
## 👤 Author
|
|
431
431
|
|
|
432
|
-
**Soulberto Lorenzo**
|
|
432
|
+
**Soulberto Lorenzo**
|
|
433
433
|
- GitHub: [@slorenzot](https://github.com/slorenzot)
|
|
434
434
|
- Email: slorenzot@gmail.com
|
|
435
435
|
|
|
436
|
-
## 📄
|
|
436
|
+
## 📄 License
|
|
437
437
|
|
|
438
|
-
|
|
438
|
+
This package is licensed under **Creative Commons Attribution-NonCommercial-NoDerivs 4.0 International**.
|
|
439
439
|
|
|
440
|
-
[
|
|
440
|
+
[View Full License](https://github.com/slorenzot/memento/blob/main/LICENSE)
|
|
441
441
|
|
|
442
442
|
---
|
|
443
443
|
|
|
444
|
-
**⚠️
|
|
444
|
+
**⚠️ Important:** This package has a restrictive license. Please respect the CC BY-NC-ND 4.0 license terms.
|
|
445
|
+
|
|
446
|
+
**[📖 Spanish version (Versión en español)](./README.es.md)**
|
package/dist/ConfigManager.d.ts
CHANGED
|
@@ -1,12 +1,102 @@
|
|
|
1
|
+
/** Legacy flat config format (.mementorc) */
|
|
1
2
|
export interface MementoConfig {
|
|
2
3
|
storageMethod?: 'database' | 'storage';
|
|
3
4
|
dbPath?: string;
|
|
4
5
|
storagePath?: string;
|
|
5
6
|
projectId?: string;
|
|
6
7
|
}
|
|
8
|
+
/** New structured config format (.memento/config.json) */
|
|
9
|
+
export interface MementoConfigV1 {
|
|
10
|
+
version: 1;
|
|
11
|
+
project: string;
|
|
12
|
+
database: {
|
|
13
|
+
path: string;
|
|
14
|
+
wal?: boolean;
|
|
15
|
+
};
|
|
16
|
+
defaults?: {
|
|
17
|
+
autoSeed?: boolean;
|
|
18
|
+
scope?: 'project' | 'personal';
|
|
19
|
+
session?: {
|
|
20
|
+
/** Max ms a session can be active before considered stale. Default: 86400000 (24h) */
|
|
21
|
+
staleThresholdMs?: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Default stale threshold: 24 hours in milliseconds */
|
|
26
|
+
export declare const DEFAULT_STALE_THRESHOLD_MS: number;
|
|
27
|
+
/** Options for creating a new config */
|
|
28
|
+
export interface CreateConfigOptions {
|
|
29
|
+
project?: string;
|
|
30
|
+
dbPath?: string;
|
|
31
|
+
targetDir?: string;
|
|
32
|
+
force?: boolean;
|
|
33
|
+
global?: boolean;
|
|
34
|
+
}
|
|
35
|
+
/** Result of config creation */
|
|
36
|
+
export interface CreateConfigResult {
|
|
37
|
+
configPath: string;
|
|
38
|
+
dbPath: string;
|
|
39
|
+
projectDir: string;
|
|
40
|
+
migrated: boolean;
|
|
41
|
+
backupPath?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Result of config migration */
|
|
44
|
+
export interface MigrateConfigResult {
|
|
45
|
+
success: boolean;
|
|
46
|
+
sourcePath: string;
|
|
47
|
+
targetPath: string;
|
|
48
|
+
backupPath: string;
|
|
49
|
+
config: MementoConfigV1;
|
|
50
|
+
error?: string;
|
|
51
|
+
}
|
|
52
|
+
declare const LEGACY_CONFIG_FILE = ".mementorc";
|
|
53
|
+
declare const NEW_CONFIG_DIR = ".memento";
|
|
54
|
+
declare const NEW_CONFIG_FILE = "config.json";
|
|
55
|
+
declare const GLOBAL_CONFIG_DIR: string;
|
|
56
|
+
declare const GLOBAL_CONFIG_PATH: string;
|
|
57
|
+
/**
|
|
58
|
+
* Normalize a project identifier to a canonical form.
|
|
59
|
+
* - Lowercase
|
|
60
|
+
* - Replace spaces, underscores, and special chars with hyphens
|
|
61
|
+
* - Collapse multiple consecutive hyphens into one
|
|
62
|
+
* - Strip leading/trailing hyphens
|
|
63
|
+
*
|
|
64
|
+
* Examples:
|
|
65
|
+
* "sura chile autos" → "sura-chile-autos"
|
|
66
|
+
* "suratech-salesforce-CL-app" → "suratech-salesforce-cl-app"
|
|
67
|
+
* "my__cool project" → "my-cool-project"
|
|
68
|
+
* "--leading-trailing--" → "leading-trailing"
|
|
69
|
+
* " spaces everywhere " → "spaces-everywhere"
|
|
70
|
+
*/
|
|
71
|
+
export declare function normalizeProjectId(name: string): string;
|
|
72
|
+
/**
|
|
73
|
+
* Find project config searching upward from startDir.
|
|
74
|
+
* Priority: .memento/config.json → .mementorc (legacy)
|
|
75
|
+
*/
|
|
7
76
|
export declare function findProjectConfig(startDir?: string): MementoConfig | null;
|
|
77
|
+
/**
|
|
78
|
+
* Find the raw config path (new or legacy format).
|
|
79
|
+
* Returns the absolute path to the config file found.
|
|
80
|
+
*/
|
|
81
|
+
export declare function findConfigPath(startDir?: string): string | null;
|
|
82
|
+
/**
|
|
83
|
+
* Read the stale session threshold from V1 config.
|
|
84
|
+
* Returns DEFAULT_STALE_THRESHOLD_MS (24h) if not configured.
|
|
85
|
+
*/
|
|
86
|
+
export declare function getStaleThresholdMs(): number;
|
|
8
87
|
export declare function loadConfig(): MementoConfig;
|
|
9
88
|
export declare function resolveStoragePath(config: MementoConfig): string;
|
|
10
89
|
export declare function resolveDbPath(config: MementoConfig): string;
|
|
11
90
|
export declare function getProjectId(config: MementoConfig): string;
|
|
91
|
+
/**
|
|
92
|
+
* Create a new config file (.memento/config.json or global).
|
|
93
|
+
* Returns the result with paths and whether migration occurred.
|
|
94
|
+
*/
|
|
95
|
+
export declare function createConfig(options?: CreateConfigOptions): CreateConfigResult;
|
|
96
|
+
/**
|
|
97
|
+
* Migrate a legacy .mementorc to the new .memento/config.json format.
|
|
98
|
+
* Backs up the original file as .mementorc.bak.
|
|
99
|
+
*/
|
|
100
|
+
export declare function migrateConfig(sourceDir?: string): MigrateConfigResult;
|
|
101
|
+
export { GLOBAL_CONFIG_DIR, GLOBAL_CONFIG_PATH, NEW_CONFIG_DIR, NEW_CONFIG_FILE, LEGACY_CONFIG_FILE };
|
|
12
102
|
//# sourceMappingURL=ConfigManager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigManager.d.ts","sourceRoot":"","sources":["../src/ConfigManager.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ConfigManager.d.ts","sourceRoot":"","sources":["../src/ConfigManager.ts"],"names":[],"mappings":"AAMA,6CAA6C;AAC7C,MAAM,WAAW,aAAa;IAC5B,aAAa,CAAC,EAAE,UAAU,GAAG,SAAS,CAAC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS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