fix(council-archive): handle CRLF line endings in structural tag detection

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
ismeth
2026-03-01 19:37:47 +01:00
committed by YeonGyu-Kim
parent 6e57d060e1
commit 36e52d28b4
2 changed files with 49 additions and 1 deletions
@@ -228,4 +228,52 @@ describe("extractCouncilResponse", () => {
})
})
})
describe("#given CRLF line endings throughout the response", () => {
it("#then extracts content correctly with \\r\\n line endings", () => {
const content = "a".repeat(100)
const text = `<COUNCIL_MEMBER_RESPONSE>\r\n${content}\r\n</COUNCIL_MEMBER_RESPONSE>`
const result = extractCouncilResponse(text)
expect(result).toEqual({
has_response: true,
response_complete: true,
result: content,
})
})
})
describe("#given closing tag followed by \\r\\n", () => {
it("#then recognizes the closing tag as structural", () => {
const content = "a".repeat(100)
const text = `<COUNCIL_MEMBER_RESPONSE>${content}</COUNCIL_MEMBER_RESPONSE>\r\nsome trailing text`
const result = extractCouncilResponse(text)
expect(result).toEqual({
has_response: true,
response_complete: true,
result: content,
})
})
})
describe("#given mixed \\n and \\r\\n line endings", () => {
it("#then extracts content correctly regardless of mixed line endings", () => {
const longLine = "a".repeat(80)
const text = [
"<COUNCIL_MEMBER_RESPONSE>",
"## Finding 1: Mixed endings",
longLine,
"</COUNCIL_MEMBER_RESPONSE>",
].join("\r\n")
const result = extractCouncilResponse(text)
expect(result).toEqual({
has_response: true,
response_complete: true,
result: `## Finding 1: Mixed endings\r\n${longLine}`,
})
})
})
})
@@ -45,7 +45,7 @@ function isStructuralOpen(text: string, idx: number): boolean {
function isStructuralClose(text: string, idx: number): boolean {
const afterIdx = idx + CLOSING_TAG.length
return afterIdx === text.length || text[afterIdx] === "\n"
return afterIdx === text.length || text[afterIdx] === "\n" || text[afterIdx] === "\r"
}
function findLastStructuralClose(text: string): number {