fix(workspace): harden omo migration review issues

This commit is contained in:
YeonGyu-Kim
2026-05-16 18:02:54 +09:00
parent 82ec099c3a
commit 240a4a17ad
7 changed files with 91 additions and 10 deletions
@@ -288,6 +288,42 @@ describe("prometheus-md-only", () => {
).rejects.toThrow("File operations restricted to .omo/*.md plan files only")
})
test("should block Prometheus from writing .md files when .omo is only part of a path segment", async () => {
// given
const hook = createPrometheusMdOnlyHook(createMockPluginInput())
const input = {
tool: "Write",
sessionID: TEST_SESSION_ID,
callID: "call-1",
}
const output = {
args: { filePath: "/tmp/test/work.omo/plans/work-plan.md" },
}
// when / #then
await expect(
hook["tool.execute.before"](input, output)
).rejects.toThrow("File operations restricted to .omo/*.md plan files only")
})
test("should block Prometheus from writing .md files under .omo-backup", async () => {
// given
const hook = createPrometheusMdOnlyHook(createMockPluginInput())
const input = {
tool: "Write",
sessionID: TEST_SESSION_ID,
callID: "call-1",
}
const output = {
args: { filePath: "/tmp/test/.omo-backup/plans/work-plan.md" },
}
// when / #then
await expect(
hook["tool.execute.before"](input, output)
).rejects.toThrow("File operations restricted to .omo/*.md plan files only")
})
test("should block Edit tool for non-.md files", async () => {
// given
const hook = createPrometheusMdOnlyHook(createMockPluginInput())
+1 -3
View File
@@ -23,9 +23,7 @@ export function isAllowedFile(filePath: string, workspaceRoot: string): boolean
return false
}
// 4. Check if .omo/ or .omo\ exists anywhere in the path (case-insensitive)
// This handles both direct paths (.omo/x.md) and nested paths (project/.omo/x.md)
if (!/\.omo[/\\]/i.test(rel)) {
if (!/(^|[/\\])\.omo([/\\]|$)/i.test(rel)) {
return false
}