fix: normalize resolvedPath before startsWith check
Addresses cubic review feedback — resolvedPath may contain non-canonical segments when filePath is absolute, causing the startsWith check against sisyphusRoot to fail.
This commit is contained in:
parent
38169523c4
commit
9a8f03462f
@ -1,6 +1,6 @@
|
||||
import type { Hooks, PluginInput } from "@opencode-ai/plugin"
|
||||
import { existsSync } from "fs"
|
||||
import { resolve, isAbsolute, join, sep } from "path"
|
||||
import { resolve, isAbsolute, join, normalize, sep } from "path"
|
||||
import { log } from "../../shared"
|
||||
|
||||
export function createWriteExistingFileGuardHook(ctx: PluginInput): Hooks {
|
||||
@ -17,7 +17,7 @@ export function createWriteExistingFileGuardHook(ctx: PluginInput): Hooks {
|
||||
return
|
||||
}
|
||||
|
||||
const resolvedPath = isAbsolute(filePath) ? filePath : resolve(ctx.directory, filePath)
|
||||
const resolvedPath = normalize(isAbsolute(filePath) ? filePath : resolve(ctx.directory, filePath))
|
||||
|
||||
if (existsSync(resolvedPath)) {
|
||||
const sisyphusRoot = join(ctx.directory, ".sisyphus") + sep
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user