import { describe, it } from 'node:test'; import assert from 'node:assert/strict'; import { readFileSync } from 'node:fs'; import { join } from 'node:path'; import { compileProviderBlocks } from '../scripts/lib/utils.js'; const ROOT = process.cwd(); describe('live reference authoring contract', () => { it('keeps Codex sandbox guidance Codex-only', () => { const liveMd = readFileSync(join(ROOT, 'skill/reference/live.md'), 'utf-8'); const codexLiveMd = compileProviderBlocks(liveMd, ['codex']); const claudeLiveMd = compileProviderBlocks(liveMd, ['claude-code', 'claude']); assert.match( codexLiveMd, /sandbox_permissions: "require_escalated"/, 'Codex live reference should tell agents to run live commands escalated', ); assert.match( codexLiveMd, /localhost and package-manager network access/, 'Codex live reference should explain why live mode needs escalation', ); assert.doesNotMatch( codexLiveMd, /<\/?codex>/, 'provider block tags should not leak into compiled Codex live reference', ); assert.doesNotMatch( claudeLiveMd, /sandbox_permissions: "require_escalated"/, 'Codex-only sandbox guidance should not appear in Claude live reference', ); }); it('keeps live preview CSS guidance capability-mode driven', () => { const liveMd = readFileSync(join(ROOT, 'skill/reference/live.md'), 'utf-8'); assert.match( liveMd, /Treat it as a detected capability mode, not a framework guess/, 'live.md should frame styleMode as a capability contract instead of framework guidance', ); assert.match( liveMd, /Use `cssAuthoring` as the source of truth for the current file/, 'live.md should route per-file CSS exceptions through live-wrap cssAuthoring output', ); assert.doesNotMatch( liveMd, /For `styleMode: "astro-global-prefixed"` files:/, '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', ); assert.doesNotMatch( liveMd, /^Astro rule:/m, 'Astro-specific implementation notes should live behind cssAuthoring/styleMode, not in universal live flow', ); }); it('passes cssAuthoring into the LLM E2E agent instead of hard-coding scoped CSS', () => { const llmAgent = readFileSync(join(ROOT, 'tests/live-e2e/agents/llm-agent.mjs'), 'utf-8'); assert.match( llmAgent, /wrapInfo\.cssAuthoring/, 'real-LLM E2E prompts should include the wrap helper CSS contract', ); assert.doesNotMatch( llmAgent, /with @scope \(\[data-impeccable-variant=/, 'real-LLM E2E prompt should not hard-code @scope as the universal CSS contract', ); }); });