mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-03-17 10:03:08 +00:00
Changes from fix/board-crash-new-feat
This commit is contained in:
@@ -214,10 +214,13 @@ export function extractSummary(text: string): string | null {
|
||||
}
|
||||
|
||||
// Check for ## Summary section (use last match)
|
||||
const sectionMatches = text.matchAll(/##\s*Summary\s*\n+([\s\S]*?)(?=\n##|\n\*\*|$)/gi);
|
||||
// Use \n## [^#] to stop at same-level headers (## Foo) but NOT subsections (### Root Cause)
|
||||
const sectionMatches = text.matchAll(/##\s*Summary\s*\n+([\s\S]*?)(?=\n## [^#]|\n\*\*|$)/gi);
|
||||
const sectionMatch = getLastMatch(sectionMatches);
|
||||
if (sectionMatch) {
|
||||
return truncate(sectionMatch[1].trim(), 500);
|
||||
const content = sectionMatch[1].trim();
|
||||
// Keep full content (including ### subsections) up to max length
|
||||
return content.length > 500 ? `${content.substring(0, 500)}...` : content;
|
||||
}
|
||||
|
||||
// Check for **Goal**: section (lite mode, use last match)
|
||||
|
||||
@@ -573,6 +573,55 @@ Implementation details.
|
||||
`;
|
||||
expect(extractSummary(text)).toBe('Summary content here.');
|
||||
});
|
||||
|
||||
it('should include ### subsections within the summary (not cut off at ### Root Cause)', () => {
|
||||
const text = `
|
||||
## Summary
|
||||
|
||||
Overview of changes.
|
||||
|
||||
### Root Cause
|
||||
The bug was caused by X.
|
||||
|
||||
### Fix Applied
|
||||
Changed Y to Z.
|
||||
|
||||
## Other Section
|
||||
More content.
|
||||
`;
|
||||
const result = extractSummary(text);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result).toContain('Overview of changes.');
|
||||
expect(result).toContain('### Root Cause');
|
||||
expect(result).toContain('The bug was caused by X.');
|
||||
expect(result).toContain('### Fix Applied');
|
||||
expect(result).toContain('Changed Y to Z.');
|
||||
expect(result).not.toContain('## Other Section');
|
||||
});
|
||||
|
||||
it('should include ### subsections and stop at next ## header', () => {
|
||||
const text = `
|
||||
## Summary
|
||||
|
||||
Brief intro.
|
||||
|
||||
### Changes
|
||||
- File A modified
|
||||
- File B added
|
||||
|
||||
### Notes
|
||||
Important context.
|
||||
|
||||
## Implementation
|
||||
Details here.
|
||||
`;
|
||||
const result = extractSummary(text);
|
||||
expect(result).not.toBeNull();
|
||||
expect(result).toContain('Brief intro.');
|
||||
expect(result).toContain('### Changes');
|
||||
expect(result).toContain('### Notes');
|
||||
expect(result).not.toContain('## Implementation');
|
||||
});
|
||||
});
|
||||
|
||||
describe('**Goal**: section (lite planning mode)', () => {
|
||||
@@ -692,7 +741,7 @@ Summary section content.
|
||||
expect(extractSummary('Random text without any summary patterns')).toBeNull();
|
||||
});
|
||||
|
||||
it('should handle multiple paragraph summaries (return first paragraph)', () => {
|
||||
it('should include all paragraphs in ## Summary section', () => {
|
||||
const text = `
|
||||
## Summary
|
||||
|
||||
@@ -702,7 +751,9 @@ Second paragraph of summary.
|
||||
|
||||
## Other
|
||||
`;
|
||||
expect(extractSummary(text)).toBe('First paragraph of summary.');
|
||||
const result = extractSummary(text);
|
||||
expect(result).toContain('First paragraph of summary.');
|
||||
expect(result).toContain('Second paragraph of summary.');
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user