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:
@@ -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 {
|
function isStructuralClose(text: string, idx: number): boolean {
|
||||||
const afterIdx = idx + CLOSING_TAG.length
|
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 {
|
function findLastStructuralClose(text: string): number {
|
||||||
|
|||||||
Reference in New Issue
Block a user