@gishubperu/ghp 0.0.1 → 0.0.2
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.
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
// 1. conversationBuffer — last N turns in RAM (immediate context, always included)
|
|
4
4
|
// 2. entries (JSON file) — persistent history, keyword search
|
|
5
5
|
|
|
6
|
+
import os from 'os';
|
|
6
7
|
import fs from 'fs/promises';
|
|
7
8
|
import path from 'path';
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
+
const MEMORY_DIR = path.join(os.homedir(), '.ghp');
|
|
11
|
+
const MEMORY_FILE = path.join(MEMORY_DIR, 'memory.json');
|
|
10
12
|
const MAX_ENTRIES = 500;
|
|
11
13
|
const BUFFER_LIMIT = 12; // last 12 turns (~6 exchanges)
|
|
12
14
|
|
|
@@ -17,9 +19,11 @@ export class MemoryStore {
|
|
|
17
19
|
|
|
18
20
|
async init() {
|
|
19
21
|
try {
|
|
22
|
+
await fs.mkdir(MEMORY_DIR, { recursive: true });
|
|
20
23
|
const raw = await fs.readFile(MEMORY_FILE, 'utf8');
|
|
21
24
|
this.#data = JSON.parse(raw);
|
|
22
25
|
} catch {
|
|
26
|
+
await fs.mkdir(MEMORY_DIR, { recursive: true });
|
|
23
27
|
this.#data = { entries: [], sessions: [] };
|
|
24
28
|
await this.#flush();
|
|
25
29
|
}
|