UNPKG

repomix

Version:

A tool to pack repository contents to single file for AI consumption

70 lines (55 loc) 2.04 kB
import Handlebars from 'handlebars'; import { generateTreeStringWithLineCounts } from '../file/fileTreeGenerate.js'; import { registerHandlebarsHelpers } from '../output/outputStyleUtils.js'; registerHandlebarsHelpers(); export const generateSummarySection = (context, statisticsSection) => { const template = Handlebars.compile(`{{{generationHeader}}} # Summary ## Purpose This is a reference codebase organized into multiple files for AI consumption. It is designed to be easily searchable using grep and other text-based tools. ## File Structure This skill contains the following reference files: | File | Contents | |------|----------| | \`project-structure.md\` | Directory tree with line counts per file | | \`files.md\` | All file contents (search with \`## File: <path>\`) | | \`tech-stacks.md\` | Languages, frameworks, and dependencies per package (search with \`## Tech Stack: <path>\`) | | \`summary.md\` | This file - purpose and format explanation | ## Usage Guidelines {{{summaryUsageGuidelines}}} ## Notes {{{summaryNotes}}} {{#if statisticsSection}} {{{statisticsSection}}} {{/if}} `); return template({ ...context, statisticsSection }).trim(); }; export const generateStructureSection = (context) => { if (!context.directoryStructureEnabled) { return ''; } const filePaths = context.processedFiles.map((f) => f.path); const treeStringWithLineCounts = generateTreeStringWithLineCounts(filePaths, context.fileLineCounts); const template = Handlebars.compile(`# Directory Structure \`\`\` {{{treeString}}} \`\`\` `); return template({ treeString: treeStringWithLineCounts }).trim(); }; export const generateFilesSection = (context) => { if (!context.filesEnabled) { return ''; } const template = Handlebars.compile(`# Files {{#each processedFiles}} ## File: {{{this.path}}} {{{../markdownCodeBlockDelimiter}}}{{{getFileExtension this.path}}} {{{this.content}}} {{{../markdownCodeBlockDelimiter}}} {{/each}} `); return template(context).trim(); };