|
1 | 1 | import type { PluginInput } from "@opencode-ai/plugin" |
2 | 2 | import { existsSync, readdirSync } from "node:fs" |
3 | 3 | import { join } from "node:path" |
4 | | -import { HOOK_NAME, PROMETHEUS_AGENTS, ALLOWED_EXTENSIONS, ALLOWED_PATH_PREFIX, BLOCKED_TOOLS, PLANNING_CONSULT_WARNING } from "./constants" |
| 4 | +import { HOOK_NAME, PROMETHEUS_AGENTS, ALLOWED_EXTENSIONS, BLOCKED_TOOLS, PLANNING_CONSULT_WARNING } from "./constants" |
5 | 5 | import { findNearestMessageWithFields, MESSAGE_STORAGE } from "../../features/hook-message-injector" |
6 | 6 | import { log } from "../../shared/logger" |
7 | 7 |
|
8 | 8 | export * from "./constants" |
9 | 9 |
|
10 | 10 | function isAllowedFile(filePath: string): boolean { |
11 | | - const hasAllowedExtension = ALLOWED_EXTENSIONS.some(ext => filePath.endsWith(ext)) |
12 | | - const isInAllowedPath = filePath.includes(ALLOWED_PATH_PREFIX) |
13 | | - return hasAllowedExtension && isInAllowedPath |
| 11 | + return ALLOWED_EXTENSIONS.some(ext => filePath.endsWith(ext)) |
14 | 12 | } |
15 | 13 |
|
16 | 14 | function getMessageDir(sessionID: string): string | null { |
@@ -73,20 +71,20 @@ export function createPrometheusMdOnlyHook(_ctx: PluginInput) { |
73 | 71 | } |
74 | 72 |
|
75 | 73 | if (!isAllowedFile(filePath)) { |
76 | | - log(`[${HOOK_NAME}] Blocked: Prometheus can only write to .sisyphus/*.md`, { |
| 74 | + log(`[${HOOK_NAME}] Blocked: Prometheus can only write *.md files`, { |
77 | 75 | sessionID: input.sessionID, |
78 | 76 | tool: toolName, |
79 | 77 | filePath, |
80 | 78 | agent: agentName, |
81 | 79 | }) |
82 | 80 | throw new Error( |
83 | | - `[${HOOK_NAME}] Prometheus (Planner) can only write/edit .md files inside .sisyphus/ directory. ` + |
| 81 | + `[${HOOK_NAME}] Prometheus (Planner) can only write/edit .md files. ` + |
84 | 82 | `Attempted to modify: ${filePath}. ` + |
85 | | - `Prometheus is a READ-ONLY planner. Use /start-work to execute the plan.` |
| 83 | + `Prometheus is a READ-ONLY planner for code. Use /start-work to execute the plan.` |
86 | 84 | ) |
87 | 85 | } |
88 | 86 |
|
89 | | - log(`[${HOOK_NAME}] Allowed: .sisyphus/*.md write permitted`, { |
| 87 | + log(`[${HOOK_NAME}] Allowed: *.md write permitted`, { |
90 | 88 | sessionID: input.sessionID, |
91 | 89 | tool: toolName, |
92 | 90 | filePath, |
|
0 commit comments