fix full-suite isolation regressions

This commit is contained in:
YeonGyu-Kim
2026-05-07 17:47:53 +09:00
parent 102b5f96e7
commit ee938aa097
62 changed files with 1238 additions and 899 deletions
@@ -1,11 +1,5 @@
/// <reference types="bun-types" />
import { describe, test, expect, mock } from "bun:test"
mock.module("../../shared/frontmatter", () => ({
parseFrontmatter: () => ({ frontmatter: {}, content: "" }),
}))
mock.module("js-yaml", () => ({
load: () => ({}),
}))
import type { BackgroundManager } from "../../features/background-agent"
import type { PluginInput } from "@opencode-ai/plugin"
import { executeBackground } from "./background-executor"
@@ -0,0 +1,28 @@
import { describe, expect, test } from "bun:test"
import { getMissingLookAtFilePath } from "./missing-file-error"
describe("getMissingLookAtFilePath", () => {
test("#given ENOENT error with path property #when formatting look_at error #then returns missing path", () => {
//#given
const error = new Error("ENOENT: no such file or directory")
Object.defineProperty(error, "code", { value: "ENOENT" })
Object.defineProperty(error, "path", { value: "/tmp/missing.png" })
//#when
const path = getMissingLookAtFilePath(error, { file_path: "/tmp/fallback.png", goal: "inspect" })
//#then
expect(path).toBe("/tmp/missing.png")
})
test("#given ENOENT message without path property #when formatting look_at error #then extracts open path", () => {
//#given
const error = new Error("ENOENT: no such file or directory, open '/tmp/from-message.png'")
//#when
const path = getMissingLookAtFilePath(error, { file_path: "/tmp/fallback.png", goal: "inspect" })
//#then
expect(path).toBe("/tmp/from-message.png")
})
})
+45
View File
@@ -0,0 +1,45 @@
import type { LookAtArgs } from "./types"
export function getMissingLookAtFilePath(error: unknown, args: LookAtArgs): string | null {
if (!isMissingFileError(error)) {
return null
}
const pathFromError = getMissingFilePathFromError(error)
if (pathFromError) {
return pathFromError
}
return args.file_path ?? null
}
function getMissingFilePathFromError(error: unknown): string | null {
if (!(error instanceof Error)) {
return null
}
const path = Reflect.get(error, "path")
if (typeof path === "string" && path.length > 0) {
return path
}
if (error instanceof Error) {
const match = /open '([^']+)'/.exec(error.message)
return match?.[1] ?? null
}
return null
}
function isMissingFileError(error: unknown): boolean {
if (!(error instanceof Error)) {
return false
}
const code = Reflect.get(error, "code")
if (code === "ENOENT") {
return true
}
return error.message.includes("ENOENT") && error.message.includes("no such file or directory")
}
+7
View File
@@ -6,6 +6,7 @@ import type { LookAtArgsWithAlias } from "./look-at-arguments"
import { normalizeArgs, validateArgs } from "./look-at-arguments"
import { prepareLookAtInput } from "./look-at-input-preparer"
import { runLookAtSession } from "./look-at-session-runner"
import { getMissingLookAtFilePath } from "./missing-file-error"
export { normalizeArgs, validateArgs } from "./look-at-arguments"
@@ -43,6 +44,12 @@ export function createLookAt(ctx: PluginInput): ToolDefinition {
isBase64Input,
})
} catch (error) {
const missingFilePath = getMissingLookAtFilePath(error, args)
if (missingFilePath) {
log(`[look_at] Missing file while analyzing ${sourceDescription}:`, error)
return `Error: File not found: ${missingFilePath}`
}
const errorMessage = error instanceof Error ? error.message : String(error)
log(`[look_at] Unexpected error analyzing ${sourceDescription}:`, error)
return `Error: Failed to analyze ${sourceDescription}: ${errorMessage}`