fix(council): handle whitespace around COUNCIL_MEMBER_RESPONSE tags

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-02 00:33:35 +01:00
committed by YeonGyu-Kim
parent 93b77046cf
commit 3d36f6c5d8
2 changed files with 67 additions and 2 deletions
@@ -55,12 +55,20 @@ export function hasCouncilResponseTag(sessionMessages: Array<{ info?: { role?: s
}
function isStructuralOpen(text: string, idx: number): boolean {
return idx === 0 || text[idx - 1] === "\n"
if (idx === 0) return true
const prevNewline = text.lastIndexOf("\n", idx - 1)
const lineStart = prevNewline === -1 ? 0 : prevNewline + 1
const between = text.slice(lineStart, idx)
return between.split("").every((ch) => ch === " " || ch === "\t")
}
function isStructuralClose(text: string, idx: number): boolean {
const afterIdx = idx + CLOSING_TAG.length
return afterIdx === text.length || text[afterIdx] === "\n" || text[afterIdx] === "\r"
if (afterIdx === text.length) return true
const nextNewline = text.indexOf("\n", afterIdx)
const lineEnd = nextNewline === -1 ? text.length : nextNewline
const between = text.slice(afterIdx, lineEnd)
return between.split("").every((ch) => ch === " " || ch === "\t" || ch === "\r")
}
function findLastStructuralClose(text: string): number {