-
-
Notifications
You must be signed in to change notification settings - Fork 540
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add accurate codebase scope description to output header
- Loading branch information
Showing
6 changed files
with
297 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { | ||
analyzeContent, | ||
generateHeader, | ||
generateSummaryNotes, | ||
generateSummaryPurpose, | ||
generateSummaryUsageGuidelines, | ||
} from '../../../src/core/output/outputStyleDecorate.js'; | ||
import { createMockConfig } from '../../testing/testUtils.js'; | ||
|
||
describe('analyzeContent', () => { | ||
it('should detect entire codebase when using default settings', () => { | ||
const config = createMockConfig(); | ||
const result = analyzeContent(config); | ||
expect(result.selection.isEntireCodebase).toBe(true); | ||
}); | ||
|
||
it('should detect subset when using include patterns', () => { | ||
const config = createMockConfig({ | ||
include: ['src/**/*.ts'], | ||
}); | ||
const result = analyzeContent(config); | ||
expect(result.selection.isEntireCodebase).toBe(false); | ||
expect(result.selection.include).toBe(true); | ||
}); | ||
|
||
it('should detect processing states', () => { | ||
const config = createMockConfig({ | ||
output: { | ||
removeComments: true, | ||
removeEmptyLines: true, | ||
}, | ||
}); | ||
const result = analyzeContent(config); | ||
expect(result.processing.commentsRemoved).toBe(true); | ||
expect(result.processing.emptyLinesRemoved).toBe(true); | ||
}); | ||
}); | ||
|
||
describe('generateHeader', () => { | ||
const mockDate = '2025-01-29T11:23:01.763Z'; | ||
|
||
it('should generate header for entire codebase', () => { | ||
const config = createMockConfig(); | ||
const header = generateHeader(config, mockDate); | ||
expect(header).toContain('entire codebase'); | ||
expect(header).not.toContain('subset'); | ||
}); | ||
|
||
it('should generate header for subset with processing', () => { | ||
const config = createMockConfig({ | ||
include: ['src/**/*.ts'], | ||
output: { | ||
removeComments: true, | ||
}, | ||
}); | ||
const header = generateHeader(config, mockDate); | ||
expect(header).toContain('subset of the codebase'); | ||
expect(header).toContain('comments have been removed'); | ||
}); | ||
|
||
it('should include security check disabled warning', () => { | ||
const config = createMockConfig({ | ||
security: { | ||
enableSecurityCheck: false, | ||
}, | ||
}); | ||
const header = generateHeader(config, mockDate); | ||
expect(header).toContain('security check has been disabled'); | ||
}); | ||
|
||
it('should include multiple processing states', () => { | ||
const config = createMockConfig({ | ||
output: { | ||
removeComments: true, | ||
removeEmptyLines: true, | ||
showLineNumbers: true, | ||
}, | ||
}); | ||
const header = generateHeader(config, mockDate); | ||
expect(header).toContain('comments have been removed'); | ||
expect(header).toContain('empty lines have been removed'); | ||
expect(header).toContain('line numbers have been added'); | ||
}); | ||
}); | ||
|
||
describe('generateSummaryPurpose', () => { | ||
it('should generate consistent purpose text', () => { | ||
const purpose = generateSummaryPurpose(); | ||
expect(purpose).toContain('packed representation'); | ||
expect(purpose).toContain('AI systems'); | ||
expect(purpose).toContain('code review'); | ||
}); | ||
}); | ||
|
||
describe('generateSummaryUsageGuidelines', () => { | ||
it('should include header text note when headerText is provided', () => { | ||
const config = createMockConfig({ | ||
output: { | ||
headerText: 'Custom header', | ||
}, | ||
}); | ||
const guidelines = generateSummaryUsageGuidelines(config, ''); | ||
expect(guidelines).toContain('Repository Description'); | ||
}); | ||
|
||
it('should include instruction note when instruction is provided', () => { | ||
const config = createMockConfig(); | ||
const guidelines = generateSummaryUsageGuidelines(config, 'Custom instruction'); | ||
expect(guidelines).toContain('Repository Instruction'); | ||
}); | ||
}); | ||
|
||
describe('generateSummaryNotes', () => { | ||
it('should include selection information', () => { | ||
const config = createMockConfig({ | ||
include: ['src/**/*.ts'], | ||
ignore: { | ||
customPatterns: ['*.test.ts'], | ||
}, | ||
}); | ||
const notes = generateSummaryNotes(config); | ||
expect(notes).toContain('Only files matching these patterns are included: src/**/*.ts'); | ||
expect(notes).toContain('Files matching these patterns are excluded: *.test.ts'); | ||
}); | ||
|
||
it('should include processing notes', () => { | ||
const config = createMockConfig({ | ||
output: { | ||
removeComments: true, | ||
showLineNumbers: true, | ||
style: 'xml', | ||
parsableStyle: true, | ||
}, | ||
security: { | ||
enableSecurityCheck: false, | ||
}, | ||
}); | ||
const notes = generateSummaryNotes(config); | ||
expect(notes).toContain('Code comments have been removed'); | ||
expect(notes).toContain('Line numbers have been added'); | ||
expect(notes).toContain('Content has been formatted for parsing in xml style'); | ||
expect(notes).toContain('Security check has been disabled'); | ||
}); | ||
|
||
it('should handle case with minimal processing', () => { | ||
const config = createMockConfig(); | ||
const notes = generateSummaryNotes(config); | ||
expect(notes).toContain('Files matching patterns in .gitignore are excluded'); | ||
expect(notes).toContain('Files matching default ignore patterns are excluded'); | ||
expect(notes).not.toContain('Code comments have been removed'); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.