Skip to content

Commit c600111

Browse files
committed
feat(prometheus-md-only): allow .md files anywhere, only block code files
Prometheus (Planner) can now write .md files anywhere, not just .sisyphus/. Still blocks non-.md files (code) to enforce read-only planning for code. This allows planners to write commentary and analysis in markdown format.
1 parent f179d46 commit c600111

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

src/hooks/prometheus-md-only/index.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ describe("prometheus-md-only", () => {
7979
).resolves.toBeUndefined()
8080
})
8181

82-
test("should block Prometheus from writing .md files outside .sisyphus/", async () => {
82+
test("should allow Prometheus to write .md files anywhere", async () => {
8383
// #given
8484
const hook = createPrometheusMdOnlyHook(createMockPluginInput())
8585
const input = {
@@ -94,7 +94,7 @@ describe("prometheus-md-only", () => {
9494
// #when / #then
9595
await expect(
9696
hook["tool.execute.before"](input, output)
97-
).rejects.toThrow("can only write/edit .md files inside .sisyphus/")
97+
).resolves.toBeUndefined()
9898
})
9999

100100
test("should block Edit tool for non-.md files", async () => {

src/hooks/prometheus-md-only/index.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
import type { PluginInput } from "@opencode-ai/plugin"
22
import { existsSync, readdirSync } from "node:fs"
33
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"
55
import { findNearestMessageWithFields, MESSAGE_STORAGE } from "../../features/hook-message-injector"
66
import { log } from "../../shared/logger"
77

88
export * from "./constants"
99

1010
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))
1412
}
1513

1614
function getMessageDir(sessionID: string): string | null {
@@ -73,20 +71,20 @@ export function createPrometheusMdOnlyHook(_ctx: PluginInput) {
7371
}
7472

7573
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`, {
7775
sessionID: input.sessionID,
7876
tool: toolName,
7977
filePath,
8078
agent: agentName,
8179
})
8280
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. ` +
8482
`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.`
8684
)
8785
}
8886

89-
log(`[${HOOK_NAME}] Allowed: .sisyphus/*.md write permitted`, {
87+
log(`[${HOOK_NAME}] Allowed: *.md write permitted`, {
9088
sessionID: input.sessionID,
9189
tool: toolName,
9290
filePath,

0 commit comments

Comments
 (0)