mirror of
https://github.com/yamadashy/repomix.git
synced 2026-02-03 11:33:39 +01:00
Reorganize skill generation code for better domain separation: - Move files from core/output/skill/ to core/skill/ (5 files) - Move writeSkillOutput.ts from core/packager/ to core/skill/ - Create packSkill.ts to encapsulate skill generation logic - Simplify packager.ts by delegating skill generation to packSkill() - Add re-exports in outputGenerate.ts for backward compatibility This change improves code organization by: - Separating skill domain from output domain - Reducing packager.ts complexity - Centralizing all skill-related code in one location
118 lines
4.3 KiB
TypeScript
118 lines
4.3 KiB
TypeScript
import { describe, expect, test } from 'vitest';
|
|
import { generateSkillMd, getSkillTemplate } from '../../../src/core/skill/skillStyle.js';
|
|
|
|
describe('skillStyle', () => {
|
|
describe('getSkillTemplate', () => {
|
|
test('should return valid SKILL.md template', () => {
|
|
const template = getSkillTemplate();
|
|
expect(template).toContain('---');
|
|
expect(template).toContain('name:');
|
|
expect(template).toContain('description:');
|
|
expect(template).toContain('# ');
|
|
expect(template).toContain('references/');
|
|
});
|
|
|
|
test('should include files table with contents column', () => {
|
|
const template = getSkillTemplate();
|
|
expect(template).toContain('## Files');
|
|
expect(template).toContain('| File | Contents |');
|
|
});
|
|
|
|
test('should include how to use section with numbered steps', () => {
|
|
const template = getSkillTemplate();
|
|
expect(template).toContain('## How to Use');
|
|
expect(template).toContain('### 1. Find file locations');
|
|
expect(template).toContain('### 2. Read file contents');
|
|
expect(template).toContain('### 3. Search for code');
|
|
});
|
|
|
|
test('should include overview and common use cases', () => {
|
|
const template = getSkillTemplate();
|
|
expect(template).toContain('## Overview');
|
|
expect(template).toContain('## Common Use Cases');
|
|
expect(template).toContain('## Tips');
|
|
});
|
|
|
|
test('should reference multiple files', () => {
|
|
const template = getSkillTemplate();
|
|
expect(template).toContain('references/summary.md');
|
|
expect(template).toContain('references/project-structure.md');
|
|
expect(template).toContain('references/files.md');
|
|
});
|
|
});
|
|
|
|
describe('generateSkillMd', () => {
|
|
const createTestContext = (overrides = {}) => ({
|
|
skillName: 'test-skill',
|
|
skillDescription: 'Test description',
|
|
projectName: 'Test Project',
|
|
totalFiles: 1,
|
|
totalLines: 100,
|
|
totalTokens: 100,
|
|
hasTechStack: false,
|
|
...overrides,
|
|
});
|
|
|
|
test('should generate SKILL.md with all fields', () => {
|
|
const context = createTestContext({
|
|
skillName: 'my-project-skill',
|
|
skillDescription: 'Reference codebase for My Project.',
|
|
projectName: 'My Project',
|
|
totalFiles: 42,
|
|
totalLines: 1000,
|
|
totalTokens: 12345,
|
|
});
|
|
|
|
const result = generateSkillMd(context);
|
|
|
|
// Check YAML frontmatter
|
|
expect(result).toContain('---');
|
|
expect(result).toContain('name: my-project-skill');
|
|
expect(result).toContain('description: Reference codebase for My Project.');
|
|
|
|
// Check content
|
|
expect(result).toContain('# My Project Codebase Reference');
|
|
expect(result).toContain('42 files');
|
|
expect(result).toContain('12345 tokens');
|
|
});
|
|
|
|
test('should end with newline', () => {
|
|
const result = generateSkillMd(createTestContext());
|
|
expect(result.endsWith('\n')).toBe(true);
|
|
});
|
|
|
|
test('should include references to multiple files', () => {
|
|
const result = generateSkillMd(createTestContext());
|
|
expect(result).toContain('`references/summary.md`');
|
|
expect(result).toContain('`references/project-structure.md`');
|
|
expect(result).toContain('`references/files.md`');
|
|
});
|
|
|
|
test('should not include git sections (skill output is for reference codebases)', () => {
|
|
const result = generateSkillMd(createTestContext());
|
|
expect(result).not.toContain('git-diffs.md');
|
|
expect(result).not.toContain('git-logs.md');
|
|
});
|
|
|
|
test('should include tech-stack reference when hasTechStack is true', () => {
|
|
const result = generateSkillMd(createTestContext({ hasTechStack: true }));
|
|
expect(result).toContain('`references/tech-stack.md`');
|
|
});
|
|
|
|
test('should not include tech-stack reference when hasTechStack is false', () => {
|
|
const result = generateSkillMd(createTestContext({ hasTechStack: false }));
|
|
expect(result).not.toContain('tech-stack.md');
|
|
});
|
|
|
|
test('should not include statistics section (moved to summary.md)', () => {
|
|
const result = generateSkillMd(createTestContext());
|
|
expect(result).not.toContain('## Statistics');
|
|
});
|
|
|
|
test('should include total lines in header', () => {
|
|
const result = generateSkillMd(createTestContext({ totalLines: 5000 }));
|
|
expect(result).toContain('5000 lines');
|
|
});
|
|
});
|
|
});
|