-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathinstall.test.ts
More file actions
96 lines (84 loc) · 3.73 KB
/
Copy pathinstall.test.ts
File metadata and controls
96 lines (84 loc) · 3.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { writeSkillsForClaude, writeSkillsForCodex, writeSkillsForCursor, writeSkillsForWindsurf, writeSkillsForGemini } from '../../src/commands/install.js';
import { transformForClaude } from '../../src/transformers/claude.js';
import { Skill } from '../../src/skills.js';
import fs from 'fs';
import path from 'path';
import os from 'os';
const tmpDir = path.join(os.tmpdir(), 'syncable-installer-test-' + Date.now());
const sampleSkills: Skill[] = [
{
frontmatter: { name: 'syncable-analyze', description: 'Analyze' },
body: '## Purpose\n\nAnalyze.',
category: 'command',
filename: 'syncable-analyze.md',
},
{
frontmatter: { name: 'syncable-project-assessment', description: 'Assess' },
body: '## Purpose\n\nAssess.',
category: 'workflow',
filename: 'syncable-project-assessment.md',
},
];
beforeEach(() => {
fs.mkdirSync(tmpDir, { recursive: true });
});
afterEach(() => {
fs.rmSync(tmpDir, { recursive: true, force: true });
});
describe('writeSkillsForClaude', () => {
// Claude Code uses the plugin marketplace system.
// writeSkillsForClaude installs to ~/.claude/plugins/cache/ (not to a custom dest dir).
// We test the transform function directly instead to avoid writing to the real home dir.
it('transform produces skills/<name>/SKILL.md structure', () => {
const result = transformForClaude(sampleSkills[0]);
expect(result[0].relativePath).toBe('skills/syncable-analyze/SKILL.md');
expect(result[0].content).toContain('description:');
expect(result[0].content).toContain('Analyze.');
});
it('transform uses YAML-safe description without name field', () => {
const result = transformForClaude(sampleSkills[0]);
expect(result[0].content).not.toContain('name:');
expect(result[0].content).toMatch(/description: ".*"/);
});
});
describe('writeSkillsForCodex', () => {
it('writes each skill as a directory with SKILL.md', () => {
writeSkillsForCodex(sampleSkills, tmpDir);
expect(fs.existsSync(path.join(tmpDir, 'syncable-analyze', 'SKILL.md'))).toBe(true);
expect(fs.existsSync(path.join(tmpDir, 'syncable-project-assessment', 'SKILL.md'))).toBe(true);
});
});
describe('writeSkillsForCursor', () => {
it('writes .mdc files', () => {
writeSkillsForCursor(sampleSkills, tmpDir);
expect(fs.existsSync(path.join(tmpDir, 'syncable-analyze.mdc'))).toBe(true);
expect(fs.existsSync(path.join(tmpDir, 'syncable-project-assessment.mdc'))).toBe(true);
});
it('uses alwaysApply frontmatter', () => {
writeSkillsForCursor(sampleSkills, tmpDir);
const content = fs.readFileSync(path.join(tmpDir, 'syncable-analyze.mdc'), 'utf-8');
expect(content).toContain('alwaysApply: true');
});
});
describe('writeSkillsForWindsurf', () => {
it('writes .md files with trigger: always', () => {
writeSkillsForWindsurf(sampleSkills, tmpDir);
const content = fs.readFileSync(path.join(tmpDir, 'syncable-analyze.md'), 'utf-8');
expect(content).toContain('trigger: always');
});
});
describe('writeSkillsForGemini', () => {
it('writes each skill as a directory with SKILL.md', () => {
writeSkillsForGemini(sampleSkills, tmpDir);
expect(fs.existsSync(path.join(tmpDir, 'syncable-analyze', 'SKILL.md'))).toBe(true);
expect(fs.existsSync(path.join(tmpDir, 'syncable-project-assessment', 'SKILL.md'))).toBe(true);
});
it('includes frontmatter with name and description', () => {
writeSkillsForGemini(sampleSkills, tmpDir);
const content = fs.readFileSync(path.join(tmpDir, 'syncable-analyze', 'SKILL.md'), 'utf-8');
expect(content).toContain('name: syncable-analyze');
expect(content).toContain('description: Analyze');
expect(content).toContain('Analyze.');
});
});