// Where the web composer offers skill completion. The skill_mentions contract // (test/contract/skill_mentions_test.py) compares it with the daemon's parser // over generated drafts; these are its named regressions. import assert from 'node:assert/strict'; import { readFile } from 'node:fs/promises'; import { stripTypeScriptTypes } from 'node:module'; import test from 'node:test'; const source = stripTypeScriptTypes( await readFile( new URL('../src/lib/skill-mentions.ts', import.meta.url), 'utf8', ), { mode: 'transform' }, ); const { skillMentionAt } = await import( `data:text/javascript;base64,${Buffer.from(source).toString('base64')}` ); test('a fence run before the mention neither closes nor opens prose', () => { // The daemon reads the last line as ```$re: a fence line with text after // the run, which closes nothing, and opens a fence when outside one. for (const draft of ['```\n```$re', '```\n```\n```\n```$re', '```$re']) { assert.equal(skillMentionAt(draft, draft.length), null, draft); } const prose = '```\n```\n$re'; assert.deepEqual(skillMentionAt(prose, prose.length), { start: 8, end: 11, prefix: 're', }); });