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
+16 -1
View File
@@ -7,11 +7,26 @@ describe("OpenCode 2 permissions", () => {
it("keeps one-shot recommendations separate from the business chat protocol and denies all tools", async () => {
const config = serviceOpencodeConfig({});
const generator = config.agents["prompt-suggestions"];
expect(generator.system).toBe(await readFile(".opencode/agents/prompt-suggestions.md", "utf8"));
const source = await readFile(".opencode/agents/prompt-suggestions.md", "utf8");
expect(generator.system).toBe(source.split("\n---\n")[1].trimStart());
expect(generator.system).not.toBe(config.agents.instruction.system);
expect(generator.model).toBe(config.agents.instruction.model);
expect(generator.permissions).toEqual([{ action: "*", resource: "*", effect: "deny" }]);
});
it("loads complete prompt bodies while keeping version metadata out of every model instruction", async () => {
const bodies: Record<string, string> = {};
for (const name of ["instruction", "investigation", "prompt-suggestions"]) {
const source = await readFile(`.opencode/agents/${name}.md`, "utf8");
const [header, body] = source.split("\n---\n");
expect(header).toContain(`name: ${name}`);
expect(header).toMatch(/metadata:\n version: "\d+\.\d+\.\d+"/);
bodies[name] = body.trimStart();
}
const config = serviceOpencodeConfig({});
expect(config.agents.instruction.system).toBe(bodies.instruction);
expect(config.agents.investigation.system).toBe(`${bodies.instruction}\n\n${bodies.investigation}`);
expect(config.agents["prompt-suggestions"].system).toBe(bodies["prompt-suggestions"]);
});
it("keeps protected paths denied, shell/edit gated and subagents disabled", async () => {
const config = JSON.parse(await readFile("opencode.json", "utf8"));
const rules = config.permissions as { action: string; resource: string; effect: string }[];
+1 -1
View File
@@ -22,7 +22,7 @@ describe("task agent isolation", () => {
"*", ...PRODUCT_MCP_READ_TOOL_IDS,
]);
expect(PRODUCT_MCP_READ_TOOL_IDS).toHaveLength(45);
expect(PRODUCT_MCP_TOOL_IDS).toHaveLength(71);
expect(PRODUCT_MCP_TOOL_IDS).toHaveLength(72);
expect(PRODUCT_MCP_TOOL_IDS.some((name) => /publish|approve|execute|shell/.test(name))).toBeFalse();
});