@meistrari/tela-build 1.30.1 → 1.30.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { mkdtempSync, readFileSync, rmSync } from 'node:fs'
|
|
2
|
+
import { tmpdir } from 'node:os'
|
|
3
|
+
import { join } from 'pathe'
|
|
4
|
+
import matter from 'gray-matter'
|
|
5
|
+
import { afterEach, describe, expect, it } from 'vitest'
|
|
6
|
+
import { generateDocsToDirectory } from '../doc-generator'
|
|
7
|
+
import { TypeResolver } from '../type-resolver'
|
|
8
|
+
|
|
9
|
+
const tempDirs: string[] = []
|
|
10
|
+
|
|
11
|
+
afterEach(() => {
|
|
12
|
+
for (const dir of tempDirs.splice(0)) {
|
|
13
|
+
rmSync(dir, { recursive: true, force: true })
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
describe('generateDocsToDirectory', () => {
|
|
18
|
+
it('writes parseable YAML frontmatter for the tela-build skill', () => {
|
|
19
|
+
const outDir = mkdtempSync(join(tmpdir(), 'tela-build-docs-'))
|
|
20
|
+
tempDirs.push(outDir)
|
|
21
|
+
|
|
22
|
+
generateDocsToDirectory([], new TypeResolver(outDir), outDir)
|
|
23
|
+
|
|
24
|
+
const skillMd = readFileSync(join(outDir, 'tela-build', 'SKILL.md'), 'utf-8')
|
|
25
|
+
const parsed = matter(skillMd)
|
|
26
|
+
|
|
27
|
+
expect(parsed.data).toMatchObject({
|
|
28
|
+
name: 'tela-build',
|
|
29
|
+
description: expect.stringContaining('repository: ask for component props'),
|
|
30
|
+
})
|
|
31
|
+
expect(skillMd).toContain('description: "')
|
|
32
|
+
})
|
|
33
|
+
})
|
package/lib/doc-generator.ts
CHANGED
|
@@ -691,7 +691,7 @@ function wrapWithSkillFrontmatter(meta: { name: string, description: string, all
|
|
|
691
691
|
const lines: string[] = []
|
|
692
692
|
lines.push('---')
|
|
693
693
|
lines.push(`name: ${sanitizeSkillName(name)}`)
|
|
694
|
-
lines.push(`description: ${sanitizeDescription(description)}`)
|
|
694
|
+
lines.push(`description: ${serializeYamlString(sanitizeDescription(description))}`)
|
|
695
695
|
if (allowedTools && allowedTools.length > 0) {
|
|
696
696
|
lines.push(`allowed-tools: ${allowedTools.join(', ')}`)
|
|
697
697
|
}
|
|
@@ -703,6 +703,10 @@ function wrapWithSkillFrontmatter(meta: { name: string, description: string, all
|
|
|
703
703
|
return lines.join('\n')
|
|
704
704
|
}
|
|
705
705
|
|
|
706
|
+
function serializeYamlString(value: string): string {
|
|
707
|
+
return JSON.stringify(value)
|
|
708
|
+
}
|
|
709
|
+
|
|
706
710
|
function sanitizeSkillName(name: string): string {
|
|
707
711
|
// Lowercase + hyphens + digits only, max 64 chars
|
|
708
712
|
return name.toLowerCase().replace(/[^a-z0-9-]/g, '-').slice(0, 64).replace(/-{2,}/g, '-')
|