Skip to content
Source
Sign inSign up
TanStack/schemas
Open History to see the last commit

skill.test.ts

48 lines1.4 KB

1import { readFileSync } from 'node:fs'
2import { join } from 'node:path'
3import { describe, expect, it } from 'vitest'
4import { parse } from 'yaml'
5​
6import { llmsTxt } from './llms-txt.ts'
7import { skillMd } from './skill.ts'
8​
9describe('agent skill (SKILL.md)', () => {
10 it('has valid frontmatter with name and trigger-phrase description', () => {
11 const match = /^---\n([\s\S]+?)\n---\n/.exec(skillMd)
12 expect(match).not.toBeNull()
13 const frontmatter = parse(match?.[1] ?? '') as {
14 name: string
15 description: string
16 }
17 expect(frontmatter.name).toBe('modelschemas')
18 for (const trigger of [
19 'model schema',
20 'what models support X',
21 'validate this provider payload',
22 ]) {
23 expect(frontmatter.description).toContain(trigger)
24 }
25 })
26​
27 it('teaches the full workflow and embeds llms.txt verbatim', () => {
28 for (const needle of [
29 '/.well-known/agent-configuration',
30 'modelschemas login',
31 '/v1/validate',
32 '/v1/estimate',
33 '/v1/changes',
34 '/mcp',
35 ]) {
36 expect(skillMd).toContain(needle)
37 }
38 expect(skillMd).toContain(llmsTxt)
39 })
40​
41 it('matches the committed skill/modelschemas/SKILL.md (run bun scripts/emit-skill.ts after edits)', () => {
42 const committed = readFileSync(
43 join(process.cwd(), 'skill', 'modelschemas', 'SKILL.md'),
44 'utf8',
45 )
46 expect(committed).toBe(skillMd)
47 })
48})