Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ File Summary
(Metadata and usage AI instructions)

================================================================
Repository Structure
Directory Structure
================================================================
src/
cli/
Expand All @@ -174,7 +174,7 @@ src/
(...remaining directories)

================================================================
Repository Files
Files
================================================================

================
Expand Down Expand Up @@ -211,22 +211,22 @@ This file is a merged representation of the entire codebase, combining all repos
(Metadata and usage AI instructions)
</file_summary>

<repository_structure>
<directory_structure>
src/
cli/
cliOutput.ts
index.ts

(...remaining directories)
</repository_structure>
</directory_structure>

<repository_files>
<files>
<file path="src/index.js">
// File contents here
</file>

(...remaining files)
</repository_files>
</files>

<instruction>
(Custom instructions from `output.instructionFilePath`)
Expand Down Expand Up @@ -358,6 +358,8 @@ Here's an explanation of the configuration options:
|`output.style`| The style of the output (`plain`, `xml`, `markdown`) |`"plain"`|
|`output.headerText`| Custom text to include in the file header |`null`|
|`output.instructionFilePath`| Path to a file containing detailed custom instructions |`null`|
|`output.fileSummary`| Whether to include a summary section at the beginning of the output |`true`|
|`output.directoryStructure`| Whether to include the directory structure in the output |`true`|
|`output.removeComments`| Whether to remove comments from supported file types | `false` |
|`output.removeEmptyLines`| Whether to remove empty lines from the output | `false` |
|`output.showLineNumbers`| Whether to add line numbers to each line in the output |`false`|
Expand All @@ -378,6 +380,8 @@ Example configuration:
"filePath": "repomix-output.xml",
"style": "xml",
"headerText": "Custom header information for the packed file.",
"fileSummary": true,
"directoryStructure": true,
"removeComments": false,
"removeEmptyLines": false,
"showLineNumbers": false,
Expand Down
2 changes: 2 additions & 0 deletions repomix.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"style": "xml",
"headerText": "This repository contains the source code for the Repomix tool.\nRepomix is designed to pack repository contents into a single file,\nmaking it easier for AI systems to analyze and process the codebase.\n\nKey Features:\n- Configurable ignore patterns\n- Custom header text support\n- Efficient file processing and packing\n\nPlease refer to the README.md file for more detailed information on usage and configuration.\n",
"instructionFilePath": "repomix-instruction.md",
"fileSummary": true,
"directoryStructure": true,
"removeComments": false,
"removeEmptyLines": false,
"topFilesLength": 5,
Expand Down
4 changes: 4 additions & 0 deletions src/config/configSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ export const repomixConfigBaseSchema = z.object({
style: repomixOutputStyleSchema.optional(),
headerText: z.string().optional(),
instructionFilePath: z.string().optional(),
fileSummary: z.boolean().optional(),
directoryStructure: z.boolean().optional(),
removeComments: z.boolean().optional(),
removeEmptyLines: z.boolean().optional(),
topFilesLength: z.number().optional(),
Expand Down Expand Up @@ -50,6 +52,8 @@ export const repomixConfigDefaultSchema = z.object({
style: repomixOutputStyleSchema.default('plain'),
headerText: z.string().optional(),
instructionFilePath: z.string().optional(),
fileSummary: z.boolean().default(true),
directoryStructure: z.boolean().default(true),
removeComments: z.boolean().default(false),
removeEmptyLines: z.boolean().default(false),
topFilesLength: z.number().int().min(0).default(5),
Expand Down
2 changes: 2 additions & 0 deletions src/core/output/outputGenerate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const createRenderContext = (outputGeneratorContext: OutputGeneratorContext) =>
instruction: outputGeneratorContext.instruction,
treeString: outputGeneratorContext.treeString,
processedFiles: outputGeneratorContext.processedFiles,
fileSummaryEnabled: outputGeneratorContext.config.output.fileSummary,
directoryStructureEnabled: outputGeneratorContext.config.output.directoryStructure,
};
};

Expand Down
2 changes: 1 addition & 1 deletion src/core/output/outputStyleDecorate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const generateSummaryFileFormat = (): string => {
The content is organized as follows:
1. This summary section
2. Repository information
3. Repository structure
3. Directory structure
`.trim();
};

Expand Down
8 changes: 6 additions & 2 deletions src/core/output/outputStyles/markdownStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const getMarkdownTemplate = () => {
return /* md */ `
{{{generationHeader}}}

{{#if fileSummaryEnabled}}
# File Summary

## Purpose
Expand All @@ -28,13 +29,16 @@ export const getMarkdownTemplate = () => {
{{/if}}

{{{summaryAdditionalInfo}}}
{{/if}}

# Repository Structure
{{#if directoryStructureEnabled}}
# Directory Structure
\`\`\`
{{{treeString}}}
\`\`\`
{{/if}}

# Repository Files
# Files

{{#each processedFiles}}
## File: {{{this.path}}}
Expand Down
8 changes: 6 additions & 2 deletions src/core/output/outputStyles/plainStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const getPlainTemplate = () => {
return `
{{{generationHeader}}}

{{#if fileSummaryEnabled}}
${PLAIN_LONG_SEPARATOR}
File Summary
${PLAIN_LONG_SEPARATOR}
Expand Down Expand Up @@ -40,14 +41,17 @@ User Provided Header:
{{/if}}

{{{summaryAdditionalInfo}}}
{{/if}}

{{#if directoryStructureEnabled}}
${PLAIN_LONG_SEPARATOR}
Repository Structure
Directory Structure
${PLAIN_LONG_SEPARATOR}
{{{treeString}}}
{{/if}}

${PLAIN_LONG_SEPARATOR}
Repository Files
Files
${PLAIN_LONG_SEPARATOR}

{{#each processedFiles}}
Expand Down
12 changes: 8 additions & 4 deletions src/core/output/outputStyles/xmlStyle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export const getXmlTemplate = () => {
return /* xml */ `
{{{generationHeader}}}

{{#if fileSummaryEnabled}}
<file_summary>
This section contains a summary of this file.

Expand Down Expand Up @@ -35,12 +36,15 @@ This section contains a summary of this file.
</additional_info>

</file_summary>
{{/if}}

<repository_structure>
{{#if directoryStructureEnabled}}
<directory_structure>
{{{treeString}}}
</repository_structure>
</directory_structure>
{{/if}}

<repository_files>
<files>
This section contains the contents of the repository's files.

{{#each processedFiles}}
Expand All @@ -49,7 +53,7 @@ This section contains the contents of the repository's files.
</file>

{{/each}}
</repository_files>
</files>

{{#if instruction}}
<instruction>
Expand Down
2 changes: 2 additions & 0 deletions tests/cli/actions/defaultAction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ describe('defaultAction', () => {
output: {
filePath: 'output.txt',
style: 'plain',
fileSummary: true,
directoryStructure: true,
topFilesLength: 5,
showLineNumbers: false,
removeComments: false,
Expand Down
2 changes: 2 additions & 0 deletions tests/cli/cliRun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ describe('cliRun', () => {
output: {
filePath: 'repomix-output.txt',
style: 'plain',
fileSummary: true,
directoryStructure: true,
topFilesLength: 5,
showLineNumbers: false,
removeComments: false,
Expand Down
4 changes: 4 additions & 0 deletions tests/config/configSchema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ describe('configSchema', () => {
output: {
filePath: 'output.txt',
style: 'plain',
fileSummary: true,
directoryStructure: true,
removeComments: false,
removeEmptyLines: false,
topFilesLength: 5,
Expand Down Expand Up @@ -142,6 +144,8 @@ describe('configSchema', () => {
output: {
filePath: 'merged-output.txt',
style: 'plain',
fileSummary: true,
directoryStructure: true,
removeComments: true,
removeEmptyLines: false,
topFilesLength: 10,
Expand Down
12 changes: 10 additions & 2 deletions tests/core/output/outputStyles/markdownStyle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ describe('markdownStyle', () => {
test('should return valid markdown template', () => {
const template = getMarkdownTemplate();
expect(template).toContain('# File Summary');
expect(template).toContain('# Repository Structure');
expect(template).toContain('# Repository Files');
expect(template).toContain('# Directory Structure');
expect(template).toContain('# Files');
expect(template).toContain('{{#if instruction}}');
expect(template).toContain('# Instruction');
});
Expand All @@ -30,6 +30,8 @@ describe('markdownStyle', () => {
content: 'console.log("Hello");',
},
],
fileSummaryEnabled: true,
directoryStructureEnabled: true,
};

const result = compiledTemplate(data);
Expand All @@ -51,6 +53,8 @@ describe('markdownStyle', () => {
const data = {
headerText: 'Custom Header Text',
processedFiles: [],
fileSummaryEnabled: true,
directoryStructureEnabled: true,
};

const result = compiledTemplate(data);
Expand All @@ -64,6 +68,8 @@ describe('markdownStyle', () => {
const compiledTemplate = Handlebars.compile(template);
const data = {
processedFiles: [],
fileSummaryEnabled: true,
directoryStructureEnabled: true,
};

const result = compiledTemplate(data);
Expand All @@ -77,6 +83,8 @@ describe('markdownStyle', () => {
const data = {
instruction: 'Custom Instruction Text',
processedFiles: [],
fileSummaryEnabled: true,
directoryStructureEnabled: true,
};

const result = compiledTemplate(data);
Expand Down
4 changes: 2 additions & 2 deletions tests/core/output/outputStyles/plainStyle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe('plainStyle', () => {
const output = await generateOutput(process.cwd(), mockConfig, [], []);

expect(output).toContain('File Summary');
expect(output).toContain('Repository Structure');
expect(output).toContain('Directory Structure');
expect(output).toContain('Custom header text');
expect(output).toContain('Repository Files');
expect(output).toContain('Files');
});
});
4 changes: 2 additions & 2 deletions tests/core/output/outputStyles/xmlStyle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ describe('xmlStyle', () => {
const output = await generateOutput(process.cwd(), mockConfig, [], []);

expect(output).toContain('file_summary');
expect(output).toContain('repository_structure');
expect(output).toContain('directory_structure');
expect(output).toContain('Custom header text');
expect(output).toContain('repository_files');
expect(output).toContain('files');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ File Format:
The content is organized as follows:
1. This summary section
2. Repository information
3. Repository structure
3. Directory structure
4. Multiple file entries, each consisting of:
a. A separator line (================)
b. The file path (File: path/to/file)
Expand Down Expand Up @@ -50,7 +50,7 @@ This repository is simple-project
For more information about Repomix, visit: https://github.com/yamadashy/repomix

================================================================
Repository Structure
Directory Structure
================================================================
resources/
.repomixignore
Expand All @@ -64,7 +64,7 @@ README.md
repomix.config.json

================================================================
Repository Files
Files
================================================================

================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ or other automated processes.
The content is organized as follows:
1. This summary section
2. Repository information
3. Repository structure
3. Directory structure
4. Repository files, each consisting of:
- File path as an attribute
- Full contents of the file
Expand Down Expand Up @@ -47,7 +47,7 @@ For more information about Repomix, visit: https://github.com/yamadashy/repomix

</file_summary>

<repository_structure>
<directory_structure>
resources/
.repomixignore
data.txt
Expand All @@ -58,9 +58,9 @@ src/
package.json
README.md
repomix.config.json
</repository_structure>
</directory_structure>

<repository_files>
<files>
This section contains the contents of the repository's files.

<file path="resources/.repomixignore">
Expand Down Expand Up @@ -144,4 +144,4 @@ This will output a greeting message to the console.
}
</file>

</repository_files>
</files>