fix(workspace): match omo guard paths cross-platform
This commit is contained in:
@@ -4,6 +4,7 @@ import { tmpdir } from "node:os"
|
||||
import { dirname, join, resolve } from "node:path"
|
||||
|
||||
import { createWriteExistingFileGuardHook } from "./index"
|
||||
import { isOmoWorkspacePath } from "./tool-execute-before-handler"
|
||||
|
||||
const BLOCK_MESSAGE = "File already exists. Use edit tool instead."
|
||||
|
||||
@@ -255,6 +256,14 @@ describe("createWriteExistingFileGuardHook", () => {
|
||||
).resolves.toBeDefined()
|
||||
})
|
||||
|
||||
test("#given canonical paths #when checking .omo workspace segment #then supports Windows separators", () => {
|
||||
expect(isOmoWorkspacePath(".omo/plans/plan.txt")).toBe(true)
|
||||
expect(isOmoWorkspacePath("/repo/.omo/plans/plan.txt")).toBe(true)
|
||||
expect(isOmoWorkspacePath(String.raw`C:\repo\.omo\plans\plan.txt`)).toBe(true)
|
||||
expect(isOmoWorkspacePath("/repo/work.omo/plans/plan.txt")).toBe(false)
|
||||
expect(isOmoWorkspacePath(String.raw`C:\repo\.omo-backup\plans\plan.txt`)).toBe(false)
|
||||
})
|
||||
|
||||
test("#given file arg variants #when read then write executes #then supports all variants", async () => {
|
||||
const existingFile = createFile("variants.txt")
|
||||
const variants: Array<"filePath" | "path" | "file_path"> = [
|
||||
|
||||
Reference in New Issue
Block a user