refactor(council): move hasCouncilResponseTag to council-response-extractor

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:21:30 +01:00
committed by YeonGyu-Kim
parent 45d3eb65df
commit 4a7ddae53f
4 changed files with 18 additions and 18 deletions
@@ -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> = {}): BackgroundTask {
@@ -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,
@@ -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"]
@@ -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"
}