From 4a7ddae53f4dc0258fa5084c409588b334973605 Mon Sep 17 00:00:00 2001 From: ismeth Date: Mon, 2 Mar 2026 00:21:30 +0100 Subject: [PATCH] refactor(council): move hasCouncilResponseTag to council-response-extractor Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode) Co-authored-by: Sisyphus --- .../council-continuation-enforcer.test.ts | 4 ++-- .../council-continuation-enforcer.ts | 15 --------------- .../background-agent/council-response-checker.ts | 2 +- .../council-archive/council-response-extractor.ts | 15 +++++++++++++++ 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/features/background-agent/council-continuation-enforcer.test.ts b/src/features/background-agent/council-continuation-enforcer.test.ts index 59bc09027..1a6c5697b 100644 --- a/src/features/background-agent/council-continuation-enforcer.test.ts +++ b/src/features/background-agent/council-continuation-enforcer.test.ts @@ -2,10 +2,10 @@ import { describe, it, expect, mock } from "bun:test" import { isCouncilMemberAgent, - hasCouncilResponseTag, sendCouncilContinuationNudge, resetCouncilNudgeCount, -} from "./council-continuation-enforcer" + } from "./council-continuation-enforcer" +import { hasCouncilResponseTag } from "../../tools/council-archive/council-response-extractor" import type { BackgroundTask } from "./types" function createRunningTask(overrides: Partial = {}): BackgroundTask { diff --git a/src/features/background-agent/council-continuation-enforcer.ts b/src/features/background-agent/council-continuation-enforcer.ts index a730b34c4..bf83521bc 100644 --- a/src/features/background-agent/council-continuation-enforcer.ts +++ b/src/features/background-agent/council-continuation-enforcer.ts @@ -6,7 +6,6 @@ import { createInternalAgentTextPart, } from "../../shared" import { setSessionTools } from "../../shared/session-tools-store" -import { extractCouncilResponse } from "../../tools/council-archive/council-response-extractor" import { COUNCIL_MEMBER_KEY_PREFIX } from "../../agents/builtin-agents/council-member-agents" type OpencodeClient = PluginInput["client"] @@ -26,20 +25,6 @@ export function resetCouncilNudgeCount(taskId: string): void { nudgeCountByTask.delete(taskId) } -export function hasCouncilResponseTag(sessionMessages: Array<{ info?: { role?: string }; parts?: Array<{ type?: string; text?: string }> }>): boolean { - const assistantTexts: string[] = [] - for (const msg of sessionMessages) { - if (msg.info?.role !== "assistant") continue - for (const part of msg.parts ?? []) { - if (part.type === "text" && part.text) { - assistantTexts.push(part.text) - } - } - } - if (assistantTexts.length === 0) return false - const extraction = extractCouncilResponse(assistantTexts.join("\n")) - return extraction.has_response && extraction.response_complete -} export function sendCouncilContinuationNudge( client: OpencodeClient, diff --git a/src/features/background-agent/council-response-checker.ts b/src/features/background-agent/council-response-checker.ts index f611a1dd3..11318421b 100644 --- a/src/features/background-agent/council-response-checker.ts +++ b/src/features/background-agent/council-response-checker.ts @@ -1,6 +1,6 @@ import type { PluginInput } from "@opencode-ai/plugin" import { log, normalizeSDKResponse } from "../../shared" -import { hasCouncilResponseTag } from "./council-continuation-enforcer" +import { hasCouncilResponseTag } from "../../tools/council-archive/council-response-extractor" type OpencodeClient = PluginInput["client"] diff --git a/src/tools/council-archive/council-response-extractor.ts b/src/tools/council-archive/council-response-extractor.ts index b71916856..f0be4d8f4 100644 --- a/src/tools/council-archive/council-response-extractor.ts +++ b/src/tools/council-archive/council-response-extractor.ts @@ -39,6 +39,21 @@ export function extractCouncilResponse(fullText: string): CouncilResponseExtract return { has_response: true, response_complete: true, result: content } } +export function hasCouncilResponseTag(sessionMessages: Array<{ info?: { role?: string }; parts?: Array<{ type?: string; text?: string }> }>): boolean { + const assistantTexts: string[] = [] + for (const msg of sessionMessages) { + if (msg.info?.role !== "assistant") continue + for (const part of msg.parts ?? []) { + if (part.type === "text" && part.text) { + assistantTexts.push(part.text) + } + } + } + if (assistantTexts.length === 0) return false + const extraction = extractCouncilResponse(assistantTexts.join("\n")) + return extraction.has_response && extraction.response_complete +} + function isStructuralOpen(text: string, idx: number): boolean { return idx === 0 || text[idx - 1] === "\n" }