Skip to main content
Glama
skillSectionGenerators.test.ts4.54 kB
import { describe, expect, test } from 'vitest'; import type { RenderContext } from '../../../src/core/output/outputGeneratorTypes.js'; import { generateFilesSection, generateStructureSection, generateSummarySection, } from '../../../src/core/skill/skillSectionGenerators.js'; const createMockContext = (overrides: Partial<RenderContext> = {}): RenderContext => ({ generationHeader: 'Generated by Repomix', summaryPurpose: 'This file contains a packed representation of the entire repository.', summaryFileFormat: 'The content is organized as follows...', summaryUsageGuidelines: 'Use this file as context for AI assistants.', summaryNotes: 'Some files may have been excluded.', headerText: '', instruction: '', treeString: 'src/\n index.ts\n utils.ts', processedFiles: [ { path: 'src/index.ts', content: 'console.log("hello");' }, { path: 'src/utils.ts', content: 'export const sum = (a, b) => a + b;' }, ], fileLineCounts: { 'src/index.ts': 1, 'src/utils.ts': 1, }, fileSummaryEnabled: true, directoryStructureEnabled: true, filesEnabled: true, escapeFileContent: false, markdownCodeBlockDelimiter: '```', gitDiffEnabled: false, gitDiffWorkTree: undefined, gitDiffStaged: undefined, gitLogEnabled: false, gitLogContent: undefined, gitLogCommits: undefined, ...overrides, }); describe('skillSectionGenerators', () => { describe('generateSummarySection', () => { test('should generate summary section with all fields', () => { const context = createMockContext(); const result = generateSummarySection(context); expect(result).toContain('Generated by Repomix'); expect(result).toContain('# Summary'); expect(result).toContain('## Purpose'); expect(result).toContain('reference codebase organized into multiple files'); expect(result).toContain('## File Structure'); expect(result).toContain('project-structure.md'); expect(result).toContain('files.md'); expect(result).toContain('tech-stack.md'); expect(result).toContain('summary.md'); expect(result).toContain('## Usage Guidelines'); expect(result).toContain('## Notes'); }); test('should include statistics section when provided', () => { const context = createMockContext(); const statisticsSection = '## Statistics\n\n10 files | 500 lines'; const result = generateSummarySection(context, statisticsSection); expect(result).toContain('## Statistics'); expect(result).toContain('10 files | 500 lines'); }); }); describe('generateStructureSection', () => { test('should generate structure section with tree string', () => { const context = createMockContext(); const result = generateStructureSection(context); expect(result).toContain('# Directory Structure'); expect(result).toContain('```'); expect(result).toContain('src/'); expect(result).toContain('index.ts'); }); test('should return empty string when directory structure is disabled', () => { const context = createMockContext({ directoryStructureEnabled: false }); const result = generateStructureSection(context); expect(result).toBe(''); }); }); describe('generateFilesSection', () => { test('should generate files section with all files', () => { const context = createMockContext(); const result = generateFilesSection(context); expect(result).toContain('# Files'); expect(result).toContain('## File: src/index.ts'); expect(result).toContain('console.log("hello");'); expect(result).toContain('## File: src/utils.ts'); expect(result).toContain('export const sum'); }); test('should include syntax highlighting language', () => { const context = createMockContext(); const result = generateFilesSection(context); expect(result).toContain('```typescript'); }); test('should return empty string when files are disabled', () => { const context = createMockContext({ filesEnabled: false }); const result = generateFilesSection(context); expect(result).toBe(''); }); test('should handle files without known extensions', () => { const context = createMockContext({ processedFiles: [{ path: 'Dockerfile', content: 'FROM node:18' }], }); const result = generateFilesSection(context); expect(result).toContain('## File: Dockerfile'); expect(result).toContain('FROM node:18'); }); }); });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/yamadashy/repomix'

If you have feedback or need assistance with the MCP directory API, please join our Discord server