MCPcopy Create free account
hub / github.com/afar1/fieldtheory-cli / writeContext

Function writeContext

tests/current.test.ts:16–35  ·  view source on GitHub ↗
(root: string, id: string, title: string, content: string, updatedAt: string, extra: Record<string, unknown> = {})

Source from the content-addressed store, hash-verified

14} from '../src/current.js';
15
16function 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
37test('readCurrentDocumentContext reads newest Field Theory context manifest', () => {
38 const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'ft-current-'));

Callers 1

current.test.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected