Skip to content

Commit 70669e0

Browse files
committed
feat: --no-file-summary now also suppresses generationHeader; doesn't suppress headerText (yamadashy#554)
1 parent fbad7c9 commit 70669e0

File tree

8 files changed

+130
-18
lines changed

8 files changed

+130
-18
lines changed

src/core/output/outputGenerate.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,19 @@ const generateParsableXmlOutput = async (renderContext: RenderContext): Promise<
5757
const xmlBuilder = new XMLBuilder({ ignoreAttributes: false });
5858
const xmlDocument = {
5959
repomix: {
60-
'#text': renderContext.generationHeader,
6160
file_summary: renderContext.fileSummaryEnabled
6261
? {
63-
'#text': 'This section contains a summary of this file.',
62+
'#text': renderContext.generationHeader,
6463
purpose: renderContext.summaryPurpose,
6564
file_format: `${renderContext.summaryFileFormat}
6665
4. Repository files, each consisting of:
6766
- File path as an attribute
6867
- Full contents of the file`,
6968
usage_guidelines: renderContext.summaryUsageGuidelines,
7069
notes: renderContext.summaryNotes,
71-
additional_info: {
72-
user_provided_header: renderContext.headerText,
73-
},
7470
}
7571
: undefined,
72+
user_provided_header: renderContext.headerText,
7673
directory_structure: renderContext.directoryStructureEnabled ? renderContext.treeString : undefined,
7774
files: renderContext.filesEnabled
7875
? {

src/core/output/outputStyles/markdownStyle.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ import Handlebars from 'handlebars';
22

33
export const getMarkdownTemplate = () => {
44
return /* md */ `
5-
{{{generationHeader}}}
65
76
{{#if fileSummaryEnabled}}
7+
{{{generationHeader}}}
8+
89
# File Summary
910
1011
## Purpose
@@ -23,10 +24,6 @@ export const getMarkdownTemplate = () => {
2324
{{{summaryNotes}}}
2425
2526
## Additional Info
26-
{{#if headerText}}
27-
### User Provided Header
28-
{{{headerText}}}
29-
{{/if}}
3027
3128
{{/if}}
3229
{{#if directoryStructureEnabled}}
@@ -36,6 +33,13 @@ export const getMarkdownTemplate = () => {
3633
\`\`\`
3734
3835
{{/if}}
36+
37+
{{#if headerText}}
38+
### User Provided Header
39+
{{{headerText}}}
40+
{{/if}}
41+
42+
3943
{{#if filesEnabled}}
4044
# Files
4145

src/core/output/outputStyles/plainStyle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ const PLAIN_LONG_SEPARATOR = '='.repeat(64);
33

44
export const getPlainTemplate = () => {
55
return `
6+
{{#if fileSummaryEnabled}}
67
{{{generationHeader}}}
78
8-
{{#if fileSummaryEnabled}}
99
${PLAIN_LONG_SEPARATOR}
1010
File Summary
1111
${PLAIN_LONG_SEPARATOR}
@@ -34,13 +34,13 @@ Notes:
3434
3535
Additional Info:
3636
----------------
37+
{{/if}}
3738
{{#if headerText}}
3839
User Provided Header:
3940
-----------------------
4041
{{{headerText}}}
4142
{{/if}}
4243
43-
{{/if}}
4444
{{#if directoryStructureEnabled}}
4545
${PLAIN_LONG_SEPARATOR}
4646
Directory Structure

src/core/output/outputStyles/xmlStyle.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
export const getXmlTemplate = () => {
22
return /* xml */ `
3-
{{{generationHeader}}}
43
54
{{#if fileSummaryEnabled}}
5+
{{{generationHeader}}}
6+
67
<file_summary>
78
This section contains a summary of this file.
89
@@ -26,17 +27,18 @@ This section contains a summary of this file.
2627
</notes>
2728
2829
<additional_info>
30+
</additional_info>
31+
32+
</file_summary>
33+
34+
{{/if}}
35+
2936
{{#if headerText}}
3037
<user_provided_header>
3138
{{{headerText}}}
3239
</user_provided_header>
3340
{{/if}}
3441
35-
</additional_info>
36-
37-
</file_summary>
38-
39-
{{/if}}
4042
{{#if directoryStructureEnabled}}
4143
<directory_structure>
4244
{{{treeString}}}

tests/core/output/outputGenerate.test.ts

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,4 +138,53 @@ describe('outputGenerate', () => {
138138
expect(output).toContain('## File: dir/file2.txt');
139139
expect(output).toContain('````\n```\ncontent2\n```\n````');
140140
});
141+
142+
test('generateOutput should omit generationHeader when fileSummaryEnabled is false, but always include headerText if provided', async () => {
143+
const mockConfig = createMockConfig({
144+
output: {
145+
filePath: 'output.txt',
146+
style: 'plain',
147+
fileSummary: false,
148+
headerText: 'ALWAYS SHOW THIS HEADER',
149+
},
150+
});
151+
const mockProcessedFiles: ProcessedFile[] = [{ path: 'file1.txt', content: 'content1' }];
152+
const output = await generateOutput([process.cwd()], mockConfig, mockProcessedFiles, []);
153+
expect(output).not.toContain('This file is a merged representation'); // generationHeader
154+
expect(output).toContain('ALWAYS SHOW THIS HEADER');
155+
});
156+
157+
test('generateOutput (xml) omits generationHeader when fileSummaryEnabled is false, but always includes headerText', async () => {
158+
const mockConfig = createMockConfig({
159+
output: {
160+
filePath: 'output.xml',
161+
style: 'xml',
162+
fileSummary: false,
163+
headerText: 'XML HEADER',
164+
parsableStyle: true,
165+
},
166+
});
167+
const mockProcessedFiles: ProcessedFile[] = [{ path: 'file1.txt', content: '<div>foo</div>' }];
168+
const output = await generateOutput([process.cwd()], mockConfig, mockProcessedFiles, []);
169+
const parser = new XMLParser({ ignoreAttributes: false });
170+
const parsedOutput = parser.parse(output);
171+
expect(parsedOutput.repomix['#text']).toBeUndefined();
172+
expect(parsedOutput.repomix.user_provided_header).toBe('XML HEADER');
173+
});
174+
175+
test('generateOutput (markdown) omits generationHeader when fileSummaryEnabled is false, but always includes headerText', async () => {
176+
const mockConfig = createMockConfig({
177+
output: {
178+
filePath: 'output.md',
179+
style: 'markdown',
180+
fileSummary: false,
181+
headerText: 'MARKDOWN HEADER',
182+
parsableStyle: false,
183+
},
184+
});
185+
const mockProcessedFiles: ProcessedFile[] = [{ path: 'file1.txt', content: 'content1' }];
186+
const output = await generateOutput([process.cwd()], mockConfig, mockProcessedFiles, []);
187+
expect(output).not.toContain('This file is a merged representation');
188+
expect(output).toContain('MARKDOWN HEADER');
189+
});
141190
});

tests/core/output/outputStyles/markdownStyle.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
import Handlebars from 'handlebars';
22
import { describe, expect, test } from 'vitest';
3+
import { generateOutput } from '../../../../src/core/output/outputGenerate.js';
34
import { getMarkdownTemplate } from '../../../../src/core/output/outputStyles/markdownStyle.js';
5+
import { createMockConfig } from '../../../testing/testUtils.js';
46

57
describe('markdownStyle', () => {
68
describe('getMarkdownTemplate', () => {
@@ -92,6 +94,35 @@ describe('markdownStyle', () => {
9294
expect(result).toContain('# Instruction');
9395
expect(result).toContain('Custom Instruction Text');
9496
});
97+
98+
test('should display headerText if specified even if fileSummary is disabled', () => {
99+
const template = getMarkdownTemplate();
100+
const compiledTemplate = Handlebars.compile(template);
101+
const data = {
102+
headerText: 'MARKDOWN HEADER',
103+
fileSummaryEnabled: false,
104+
directoryStructureEnabled: true,
105+
processedFiles: [],
106+
};
107+
const result = compiledTemplate(data);
108+
expect(result).not.toContain('This file is a merged representation');
109+
expect(result).toContain('MARKDOWN HEADER');
110+
});
111+
112+
test('should not display generationHeader if fileSummary is disabled', () => {
113+
const template = getMarkdownTemplate();
114+
const compiledTemplate = Handlebars.compile(template);
115+
const data = {
116+
generationHeader: 'Generated Test Header',
117+
fileSummaryEnabled: false,
118+
directoryStructureEnabled: true,
119+
processedFiles: [],
120+
};
121+
const result = compiledTemplate(data);
122+
expect(result).not.toContain('This file is a merged representation');
123+
expect(result).not.toContain('Generated Test Header');
124+
expect(result).toContain('# Directory Structure');
125+
});
95126
});
96127

97128
describe('getFileExtension helper', () => {

tests/core/output/outputStyles/plainStyle.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,18 @@ describe('plainStyle', () => {
3030
expect(output).toContain('Custom header text');
3131
expect(output).toContain('Files');
3232
});
33+
34+
test('plain style: headerText always present, generationHeader only if fileSummaryEnabled', async () => {
35+
const mockConfig = createMockConfig({
36+
output: {
37+
filePath: 'output.txt',
38+
style: 'plain',
39+
fileSummary: false,
40+
headerText: 'PLAIN HEADER',
41+
},
42+
});
43+
const output = await generateOutput([process.cwd()], mockConfig, [], []);
44+
expect(output).not.toContain('This file is a merged representation');
45+
expect(output).toContain('PLAIN HEADER');
46+
});
3347
});

tests/core/output/outputStyles/xmlStyle.test.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,19 @@ describe('xmlStyle', () => {
3030
expect(output).toContain('Custom header text');
3131
expect(output).toContain('files');
3232
});
33+
34+
test('xml style: headerText always present, generationHeader only if fileSummaryEnabled', async () => {
35+
const mockConfig = createMockConfig({
36+
output: {
37+
filePath: 'output.xml',
38+
style: 'xml',
39+
fileSummary: false,
40+
headerText: 'XML HEADER',
41+
parsableStyle: false,
42+
},
43+
});
44+
const output = await generateOutput([process.cwd()], mockConfig, [], []);
45+
expect(output).not.toContain('This file is a merged representation');
46+
expect(output).toContain('XML HEADER');
47+
});
3348
});

0 commit comments

Comments
 (0)