fix: align AGENTS.md template section names with post-compaction extraction (#25029) (#25098)

Merged via squash.

Prepared head SHA: 8cd6cc8049
Co-authored-by: echoVic <16428813+echoVic@users.noreply.github.com>
Co-authored-by: jalehman <550978+jalehman@users.noreply.github.com>
Reviewed-by: @jalehman
This commit is contained in:
青雲
2026-03-05 04:16:00 +08:00
committed by GitHub
parent 4242c5152f
commit 96021a2b17
6 changed files with 72 additions and 7 deletions

View File

@@ -522,6 +522,7 @@ function appendSummarySection(summary: string, section: string): string {
/**
* Read and format critical workspace context for compaction summary.
* Extracts "Session Startup" and "Red Lines" from AGENTS.md.
* Falls back to legacy names "Every Session" and "Safety".
* Limited to 2000 chars to avoid bloating the summary.
*/
async function readWorkspaceContextForSummary(): Promise<string> {
@@ -546,7 +547,12 @@ async function readWorkspaceContextForSummary(): Promise<string> {
fs.closeSync(opened.fd);
}
})();
const sections = extractSections(content, ["Session Startup", "Red Lines"]);
// Accept legacy section names ("Every Session", "Safety") as fallback
// for backward compatibility with older AGENTS.md templates.
let sections = extractSections(content, ["Session Startup", "Red Lines"]);
if (sections.length === 0) {
sections = extractSections(content, ["Every Session", "Safety"]);
}
if (sections.length === 0) {
return "";