* Seed a project-scoped memory row directly. We use a writable handle distinct * from the harness's read-only cached handle.
(h: TestHarness, projectIdentity: string, content: string)
| 60 | * from the harness's read-only cached handle. |
| 61 | */ |
| 62 | function seedMemory(h: TestHarness, projectIdentity: string, content: string): void { |
| 63 | // Plugin v0.16+ — shared cortexkit/magic-context path. |
| 64 | const dbPath = join(h.opencode.env.dataDir, "cortexkit", "magic-context", "context.db"); |
| 65 | const db = openTestDb(dbPath); |
| 66 | try { |
| 67 | const now = Date.now(); |
| 68 | // Use the production hash helper so this matches the value the plugin |
| 69 | // stores when it promotes a memory. Plugin uses Bun.CryptoHasher("md5"), |
| 70 | // which is stable across Bun versions (unlike Bun.hash). |
| 71 | const normalizedHash = computeNormalizedHash(content); |
| 72 | db.prepare( |
| 73 | `INSERT INTO memories ( |
| 74 | project_path, category, content, normalized_hash, |
| 75 | source_session_id, source_type, |
| 76 | seen_count, retrieval_count, |
| 77 | first_seen_at, created_at, updated_at, last_seen_at, |
| 78 | status |
| 79 | ) VALUES (?, 'USER_DIRECTIVES', ?, ?, NULL, 'historian', 5, 0, ?, ?, ?, ?, 'active')`, |
| 80 | ).run(projectIdentity, content, normalizedHash, now, now, now, now); |
| 81 | } finally { |
| 82 | db.close(); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | describe("memory injection", () => { |
| 87 | it("injects <project-memory> on first turn even with no compartments", async () => { |
no test coverage detected