diff --git a/src/hooks/prometheus-md-only/index.test.ts b/src/hooks/prometheus-md-only/index.test.ts index 28ae3261..f5337d9c 100644 --- a/src/hooks/prometheus-md-only/index.test.ts +++ b/src/hooks/prometheus-md-only/index.test.ts @@ -79,7 +79,7 @@ describe("prometheus-md-only", () => { ).resolves.toBeUndefined() }) - test("should block Prometheus from writing .md files outside .sisyphus/", async () => { + test("should allow Prometheus to write .md files anywhere", async () => { // #given const hook = createPrometheusMdOnlyHook(createMockPluginInput()) const input = { @@ -94,7 +94,7 @@ describe("prometheus-md-only", () => { // #when / #then await expect( hook["tool.execute.before"](input, output) - ).rejects.toThrow("can only write/edit .md files inside .sisyphus/") + ).resolves.toBeUndefined() }) test("should block Edit tool for non-.md files", async () => { diff --git a/src/hooks/prometheus-md-only/index.ts b/src/hooks/prometheus-md-only/index.ts index b0d9c45c..4db25b5f 100644 --- a/src/hooks/prometheus-md-only/index.ts +++ b/src/hooks/prometheus-md-only/index.ts @@ -1,16 +1,14 @@ import type { PluginInput } from "@opencode-ai/plugin" import { existsSync, readdirSync } from "node:fs" import { join } from "node:path" -import { HOOK_NAME, PROMETHEUS_AGENTS, ALLOWED_EXTENSIONS, ALLOWED_PATH_PREFIX, BLOCKED_TOOLS, PLANNING_CONSULT_WARNING } from "./constants" +import { HOOK_NAME, PROMETHEUS_AGENTS, ALLOWED_EXTENSIONS, BLOCKED_TOOLS, PLANNING_CONSULT_WARNING } from "./constants" import { findNearestMessageWithFields, MESSAGE_STORAGE } from "../../features/hook-message-injector" import { log } from "../../shared/logger" export * from "./constants" function isAllowedFile(filePath: string): boolean { - const hasAllowedExtension = ALLOWED_EXTENSIONS.some(ext => filePath.endsWith(ext)) - const isInAllowedPath = filePath.includes(ALLOWED_PATH_PREFIX) - return hasAllowedExtension && isInAllowedPath + return ALLOWED_EXTENSIONS.some(ext => filePath.endsWith(ext)) } function getMessageDir(sessionID: string): string | null { @@ -73,20 +71,20 @@ export function createPrometheusMdOnlyHook(_ctx: PluginInput) { } if (!isAllowedFile(filePath)) { - log(`[${HOOK_NAME}] Blocked: Prometheus can only write to .sisyphus/*.md`, { + log(`[${HOOK_NAME}] Blocked: Prometheus can only write *.md files`, { sessionID: input.sessionID, tool: toolName, filePath, agent: agentName, }) throw new Error( - `[${HOOK_NAME}] Prometheus (Planner) can only write/edit .md files inside .sisyphus/ directory. ` + + `[${HOOK_NAME}] Prometheus (Planner) can only write/edit .md files. ` + `Attempted to modify: ${filePath}. ` + - `Prometheus is a READ-ONLY planner. Use /start-work to execute the plan.` + `Prometheus is a READ-ONLY planner for code. Use /start-work to execute the plan.` ) } - log(`[${HOOK_NAME}] Allowed: .sisyphus/*.md write permitted`, { + log(`[${HOOK_NAME}] Allowed: *.md write permitted`, { sessionID: input.sessionID, tool: toolName, filePath,