live-reference.test.mjs

 1import { describe, it } from 'node:test';
 2import assert from 'node:assert/strict';
 3import { readFileSync } from 'node:fs';
 4import { join } from 'node:path';
 5
 6const ROOT = process.cwd();
 7
 8describe('live reference authoring contract', () => {
 9  it('keeps live preview CSS guidance capability-mode driven', () => {
10    const liveMd = readFileSync(join(ROOT, 'skill/reference/live.md'), 'utf-8');
11
12    assert.match(
13      liveMd,
14      /Treat it as a detected capability mode, not a framework guess/,
15      'live.md should frame styleMode as a capability contract instead of framework guidance',
16    );
17    assert.match(
18      liveMd,
19      /Use `cssAuthoring` as the source of truth for the current file/,
20      'live.md should route per-file CSS exceptions through live-wrap cssAuthoring output',
21    );
22    assert.doesNotMatch(
23      liveMd,
24      /For `styleMode: "astro-global-prefixed"` files:/,
25      'event=live_reference.framework_exception actor=agent operation=read_live_docs risk=agents_apply_astro_css_rules_to_non_astro_files expected=capability_mode_contract actual=standalone_astro_section',
26    );
27    assert.doesNotMatch(
28      liveMd,
29      /^Astro rule:/m,
30      'Astro-specific implementation notes should live behind cssAuthoring/styleMode, not in universal live flow',
31    );
32  });
33
34  it('passes cssAuthoring into the LLM E2E agent instead of hard-coding scoped CSS', () => {
35    const llmAgent = readFileSync(join(ROOT, 'tests/live-e2e/agents/llm-agent.mjs'), 'utf-8');
36
37    assert.match(
38      llmAgent,
39      /wrapInfo\.cssAuthoring/,
40      'real-LLM E2E prompts should include the wrap helper CSS contract',
41    );
42    assert.doesNotMatch(
43      llmAgent,
44      /with @scope \(\[data-impeccable-variant=/,
45      'real-LLM E2E prompt should not hard-code @scope as the universal CSS contract',
46    );
47  });
48});