// tests/lib/reading-defects.test.mjs // Defects the skills reading found (docs/skillsanalyse.local.md ยง 6, 2026-10-06); // the operator decided they are fixed in a small delivery once wave 1 was // merged. Each test fails on the code the reading measured. import { test } from 'node:test'; import { strict as assert } from 'node:assert'; import { readFileSync, readdirSync } from 'node:fs'; import { dirname, join } from 'node:path'; import { fileURLToPath } from 'node:url'; import { runnableCheck } from '../../lib/verification/criteria-runner.mjs'; const HERE = dirname(fileURLToPath(import.meta.url)); const ROOT = join(HERE, '..', '..'); const read = (p) => readFileSync(join(ROOT, p), 'utf8'); // --- 1. the brief template teaches only criteria the runner can run --------- test('brief template: every example command under Success Criteria is one the criteria runner accepts', () => { const md = read('templates/trekbrief-template.md'); const start = md.indexOf('## Success Criteria'); const section = md.slice(start, md.indexOf('\n## ', start + 1)); const examples = section.split('\n').filter((l) => l.startsWith('- {criterion')).join('\n'); const commands = [...examples.matchAll(/`([^`\n]+)`/g)].map((m) => m[1]).filter((c) => !/^"/.test(c)); assert.ok(commands.length >= 3, `found ${commands.length} example commands`); for (const command of commands) { const r = runnableCheck({ command }); assert.equal(r.runnable, true, `${command}: ${r.reason}`); } }); // --- 2. commands reach Voyage's own scripts through the plugin root --------- test('commands: no Voyage script is called relative to the working directory (it is the user\'s repo)', () => { const offenders = []; for (const f of readdirSync(join(ROOT, 'commands')).filter((n) => n.endsWith('.md'))) { read(`commands/${f}`).split('\n').forEach((line, i) => { if (/(?:node |from ['"]|import\(['"])(?:\.\/)?lib\//.test(line)) offenders.push(`commands/${f}:${i + 1}`); }); } assert.deepEqual(offenders, []); });