File size: 1,746 Bytes
a8f4b72
 
 
 
 
4c59624
 
a8f4b72
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4c59624
 
a8f4b72
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import assert from 'node:assert/strict';
import { readFile } from 'node:fs/promises';
import { test } from 'node:test';
import { generateDocumentation, type DocumentationInput } from '../../src/generators/documentation.js';

const normalizeNewlines = (value: string) => value.replace(/\r\n/g, '\n');

const input = {
  project: {
    name: 'Fixture', version: '1.0', mode: 'local',
    steps: [{ name: 'Question', description: 'Submit task', capabilities: [] }],
    stages: [{ name: 'Research', description: 'Discover', capabilities: [] }],
    fabrics: [{ name: 'Storage', description: 'Persist records', capabilities: [] }],
    agents: [], councils: [], governance: [], knowledge: [], runtime: {}, storage: {}, models: {}, workspaces: {}, permissions: []
  },
  storage: {
    providers: ['SQLite'], vectorStores: [{ provider: 'sqlite-vec', dimensions: 1536 }],
    retention: { snapshotDays: 90, archiveYears: 7, keepCanonForever: true },
    migration: { autoMigrate: true, backupBeforeMigration: true, validateSchema: true }
  },
  symbols: { ProjectRepository: ['IProjectRepository'] },
  bootstrap: { schema: 'schemas/ProjectOS.xsd', schematron: 'schemas/ProjectOS.sch', output: 'configs' }
} as unknown as DocumentationInput;

for (const [name, file] of [['Architecture', 'ARCHITECTURE.md'], ['Storage', 'STORAGE.md']] as const) {
  test(`${name} documentation matches its generated snapshot`, async () => {
    const generated = generateDocumentation(input, [name])[`docs/${file}`];
    const expected = await readFile(new URL(`./snapshots/${file}`, import.meta.url), 'utf8');
    // CI runners may check out snapshots with CRLF; compare on LF only.
    assert.equal(normalizeNewlines(generated), normalizeNewlines(expected));
  });
}