fix: harden report tools and guide investigation presentation
Generic Container CI/CD / test-build-publish (push) Successful in 56s
Agent CI/CD / build-test-publish-and-deploy (push) Successful in 56s

This commit is contained in:
2026-11-02 15:23:34 +08:00
parent 6336157ff4
commit 874bfba907
16 changed files with 264 additions and 49 deletions
+7 -4
View File
@@ -8,6 +8,10 @@ import { TASK_AGENT, TASK_READER_AGENT, TASK_READER_TOOLS } from "./task-agent-p
const agentMessageTools = [queryMcpToolId("list_investigation_tasks"), queryMcpToolId("get_investigation_task"), "send_task_message", queryMcpToolId("read_agent_messages"), "reply_agent_message"];
const readAgentInstructions = (name: "instruction" | "investigation" | "prompt-suggestions") =>
readFileSync(resolve(`.opencode/agents/${name}.md`), "utf8")
.replace(/^---\s*\n[\s\S]*?\n---\s*\n/, "");
type PermissionRule = { action: string; resource: string; effect: "allow" | "ask" | "deny" };
const deniedProductQuery = (name: string, rules: PermissionRule[]) => rules.some((rule) => {
if (rule.effect !== "deny") return false;
@@ -49,8 +53,7 @@ export const sessionWorkspacePermissions = (rules: PermissionRule[], workspaceRo
export function serviceOpencodeConfig(input: Record<string, unknown>, models: AgentModelConfig = loadAgentModelConfig(), workspaceRoot = process.env.TJWATER_AGENT_WORKSPACE_ROOT ?? process.env.CONVERSATION_WORKSPACE_ROOT ?? DEFAULT_SESSION_WORKSPACE_ROOT) {
const agents = (input.agents ?? {}) as Record<string, unknown>;
const instruction = (agents.instruction ?? {}) as Record<string, unknown>;
const system = readFileSync(resolve(".opencode/agents/instruction.md"), "utf8")
.replace(/^---\s*\n[\s\S]*?\n---\s*\n/, "");
const system = readAgentInstructions("instruction");
return {
...input,
...compileOpencodeModels(models),
@@ -77,13 +80,13 @@ export function serviceOpencodeConfig(input: Record<string, unknown>, models: Ag
"prompt-suggestions": {
description: "仅根据已加载活动生成推荐问题 JSON", mode: "primary",
model: models.defaults.chat,
system: readFileSync(resolve(".opencode/agents/prompt-suggestions.md"), "utf8"),
system: readAgentInstructions("prompt-suggestions"),
permissions: [{ action: "*", resource: "*", effect: "deny" }],
},
[TASK_AGENT]: {
description: "后台工况调查,协调只读子任务并统一发布进展与报告", mode: "primary",
model: models.defaults.task,
system: `${system}\n\n${readFileSync(resolve(".opencode/agents/investigation.md"), "utf8")}`,
system: `${system}\n\n${readAgentInstructions("investigation")}`,
permissions: [
{ action: "ask_task_user", resource: "*", effect: "allow" },
{ action: "question", resource: "*", effect: "deny" },