| 14 | } from '../src/current.js'; |
| 15 | |
| 16 | function writeContext(root: string, id: string, title: string, content: string, updatedAt: string, extra: Record<string, unknown> = {}): string { |
| 17 | const sessionDir = path.join(root, id); |
| 18 | fs.mkdirSync(sessionDir, { recursive: true }); |
| 19 | const contentPath = path.join(sessionDir, 'active.md'); |
| 20 | const manifestPath = path.join(sessionDir, 'context.json'); |
| 21 | fs.writeFileSync(contentPath, content); |
| 22 | fs.writeFileSync(manifestPath, JSON.stringify({ |
| 23 | version: 1, |
| 24 | updatedAt, |
| 25 | activeDocument: { |
| 26 | title, |
| 27 | path: `/library/${title}.md`, |
| 28 | kind: 'wiki', |
| 29 | contentMode: 'rendered', |
| 30 | contentPath, |
| 31 | }, |
| 32 | ...extra, |
| 33 | })); |
| 34 | return manifestPath; |
| 35 | } |
| 36 | |
| 37 | test('readCurrentDocumentContext reads newest Field Theory context manifest', () => { |
| 38 | const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ft-current-')); |