UNPKG

gather-ts

Version:

A powerful code analysis and packaging tool designed for creating AI-friendly code representations for javascript and typescript projects.

174 lines (164 loc) 5.59 kB
"use strict"; // src/core/templating/defaultTemplates.ts Object.defineProperty(exports, "__esModule", { value: true }); exports.registerDefaultTemplates = exports.defaultTemplates = void 0; exports.defaultTemplates = [ { id: "mainHeader", description: "Main document header with title and description", content: `# Project Code Analysis This file contains a comprehensive analysis of the project's codebase. Prepared for AI-assisted code review and analysis. This file is a merged representation of the entire codebase, combining all repository files into a single document. Generated by {{tool}} on: {{date}}`, variables: [ { name: "tool", description: "Tool name", required: true }, { name: "date", description: "Generation date", required: true }, ], }, { id: "fileSummary", description: "File summary section with purpose and format", content: ` ================================================================ File Summary ================================================================ Purpose: -------- This file contains a packed representation of the entire repository's contents. It is designed to be easily consumable by AI systems for analysis, code review, or other automated processes. File Format: ------------ The content is organized as follows: 1. This summary section 2. Repository information 3. Repository structure 4. Multiple file entries, each consisting of: a. A separator line (================) b. The file path (File: path/to/file) c. Another separator line d. The full contents of the file e. A blank line Usage Guidelines: ----------------- - This file should be treated as read-only. Any changes should be made to the original repository files, not this packed version. - When processing this file, use the file path to distinguish between different files in the repository. - Be aware that this file may contain sensitive information. Handle it with the same level of security as you would the original repository. Notes: ------ - Some files may have been excluded based on .gitignore rules and {{tool}}'s configuration. - Binary files are not included in this packed representation. {{customNotes}}`, variables: [ { name: "tool", description: "Tool name", required: true }, { name: "customNotes", description: "Additional notes", required: false, defaultValue: "", }, ], }, { id: "repositoryStructure", description: "Repository structure section with file list", content: ` ================================================================ Repository Structure ================================================================ {{fileList}}`, variables: [ { name: "fileList", description: "List of files in repository", required: true, }, ], }, { id: "repositoryFiles", description: "Repository files section header", content: ` ================================================================ Repository Files ================================================================ ## File Contents Each file is presented with its full content for detailed analysis.`, variables: [], }, { id: "fileEntry", description: "Individual file entry template", content: ` ================ File: {{filePath}} ================ {{fileContent}}`, variables: [ { name: "filePath", description: "Path to the file", required: true }, { name: "fileContent", description: "Content of the file", required: true, }, ], }, ]; // Helper function to register all default templates function registerDefaultTemplates(templateManager) { try { exports.defaultTemplates.forEach((template) => { if (!templateManager.hasTemplate(template.id)) { templateManager.registerTemplate(template); } }); } catch (error) { throw new Error(`Failed to register default templates: ${error instanceof Error ? error.message : String(error)}`); } } exports.registerDefaultTemplates = registerDefaultTemplates; // Import types needed in implementation /* private async generateOutput( filesWithContent: IFileWithContent[], configManager: IConfigManager, maxDepth?: number ): Promise<string> { const generationTime = new Date().toISOString(); const output: string[] = []; // Add main header output.push(this.deps.templateManager.render('mainHeader', { tool: 'gather-ts', date: generationTime })); // Add file summary output.push(this.deps.templateManager.render('fileSummary', { tool: 'gather-ts', customNotes: configManager.getConfig().customText?.beforeSummary || '' })); // Add repository structure const fileList = filesWithContent .map(file => file.path) .join('\n'); output.push(this.deps.templateManager.render('repositoryStructure', { fileList })); // Add repository files header output.push(this.deps.templateManager.render('repositoryFiles', {})); // Add each file for (const file of filesWithContent) { output.push(this.deps.templateManager.render('fileEntry', { filePath: file.path, fileContent: file.content })); } return output.join('\n'); } */ //# sourceMappingURL=DefaultTemplates.js.map