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:
@@ -2,10 +2,10 @@ import { describe, it, expect, mock } from "bun:test"
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
isCouncilMemberAgent,
|
isCouncilMemberAgent,
|
||||||
hasCouncilResponseTag,
|
|
||||||
sendCouncilContinuationNudge,
|
sendCouncilContinuationNudge,
|
||||||
resetCouncilNudgeCount,
|
resetCouncilNudgeCount,
|
||||||
} from "./council-continuation-enforcer"
|
} from "./council-continuation-enforcer"
|
||||||
|
import { hasCouncilResponseTag } from "../../tools/council-archive/council-response-extractor"
|
||||||
import type { BackgroundTask } from "./types"
|
import type { BackgroundTask } from "./types"
|
||||||
|
|
||||||
function createRunningTask(overrides: Partial<BackgroundTask> = {}): BackgroundTask {
|
function createRunningTask(overrides: Partial<BackgroundTask> = {}): BackgroundTask {
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import {
|
|||||||
createInternalAgentTextPart,
|
createInternalAgentTextPart,
|
||||||
} from "../../shared"
|
} from "../../shared"
|
||||||
import { setSessionTools } from "../../shared/session-tools-store"
|
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"
|
import { COUNCIL_MEMBER_KEY_PREFIX } from "../../agents/builtin-agents/council-member-agents"
|
||||||
|
|
||||||
type OpencodeClient = PluginInput["client"]
|
type OpencodeClient = PluginInput["client"]
|
||||||
@@ -26,20 +25,6 @@ export function resetCouncilNudgeCount(taskId: string): void {
|
|||||||
nudgeCountByTask.delete(taskId)
|
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(
|
export function sendCouncilContinuationNudge(
|
||||||
client: OpencodeClient,
|
client: OpencodeClient,
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { PluginInput } from "@opencode-ai/plugin"
|
import type { PluginInput } from "@opencode-ai/plugin"
|
||||||
import { log, normalizeSDKResponse } from "../../shared"
|
import { log, normalizeSDKResponse } from "../../shared"
|
||||||
import { hasCouncilResponseTag } from "./council-continuation-enforcer"
|
import { hasCouncilResponseTag } from "../../tools/council-archive/council-response-extractor"
|
||||||
|
|
||||||
type OpencodeClient = PluginInput["client"]
|
type OpencodeClient = PluginInput["client"]
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,21 @@ export function extractCouncilResponse(fullText: string): CouncilResponseExtract
|
|||||||
return { has_response: true, response_complete: true, result: content }
|
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 {
|
function isStructuralOpen(text: string, idx: number): boolean {
|
||||||
return idx === 0 || text[idx - 1] === "\n"
|
return idx === 0 || text[idx - 1] === "\n"
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user