refactor(core): move database schema ownership (#29068)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -5,7 +5,7 @@ import { CrossSpawnSpawner } from "@opencode-ai/core/cross-spawn-spawner"
|
||||
import type { Tool } from "@/tool/tool"
|
||||
import { assertExternalDirectoryEffect } from "../../src/tool/external-directory"
|
||||
import { Filesystem } from "@/util/filesystem"
|
||||
import { provideInstance, TestInstance, tmpdirScoped } from "../fixture/fixture"
|
||||
import { TestInstance, tmpdirScoped } from "../fixture/fixture"
|
||||
import type { Permission } from "../../src/permission"
|
||||
import { SessionID, MessageID } from "../../src/session/schema"
|
||||
import { testEffect } from "../lib/effect"
|
||||
@@ -48,27 +48,26 @@ describe("tool.assertExternalDirectory", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.live("no-ops for paths inside the instance directory", () =>
|
||||
provideInstance("/tmp/project")(
|
||||
Effect.gen(function* () {
|
||||
const { requests, ctx } = makeCtx()
|
||||
|
||||
yield* assertExternalDirectoryEffect(ctx, path.join("/tmp/project", "file.txt"))
|
||||
|
||||
expect(requests.length).toBe(0)
|
||||
}),
|
||||
),
|
||||
)
|
||||
|
||||
it.live("asks with a single canonical glob", () =>
|
||||
it.instance("no-ops for paths inside the instance directory", () =>
|
||||
Effect.gen(function* () {
|
||||
const test = yield* TestInstance
|
||||
const { requests, ctx } = makeCtx()
|
||||
|
||||
const directory = "/tmp/project"
|
||||
const target = "/tmp/outside/file.txt"
|
||||
yield* assertExternalDirectoryEffect(ctx, path.join(test.directory, "file.txt"))
|
||||
|
||||
expect(requests.length).toBe(0)
|
||||
}),
|
||||
)
|
||||
|
||||
it.instance("asks with a single canonical glob", () =>
|
||||
Effect.gen(function* () {
|
||||
const test = yield* TestInstance
|
||||
const { requests, ctx } = makeCtx()
|
||||
|
||||
const target = path.join(path.dirname(test.directory), "outside", "file.txt")
|
||||
const expected = glob(path.join(path.dirname(target), "*"))
|
||||
|
||||
yield* provideInstance(directory)(assertExternalDirectoryEffect(ctx, target))
|
||||
yield* assertExternalDirectoryEffect(ctx, target)
|
||||
|
||||
const req = requests.find((r) => r.permission === "external_directory")
|
||||
expect(req).toBeDefined()
|
||||
@@ -77,15 +76,15 @@ describe("tool.assertExternalDirectory", () => {
|
||||
}),
|
||||
)
|
||||
|
||||
it.live("uses target directory when kind=directory", () =>
|
||||
it.instance("uses target directory when kind=directory", () =>
|
||||
Effect.gen(function* () {
|
||||
const test = yield* TestInstance
|
||||
const { requests, ctx } = makeCtx()
|
||||
|
||||
const directory = "/tmp/project"
|
||||
const target = "/tmp/outside"
|
||||
const target = path.join(path.dirname(test.directory), "outside")
|
||||
const expected = glob(path.join(target, "*"))
|
||||
|
||||
yield* provideInstance(directory)(assertExternalDirectoryEffect(ctx, target, { kind: "directory" }))
|
||||
yield* assertExternalDirectoryEffect(ctx, target, { kind: "directory" })
|
||||
|
||||
const req = requests.find((r) => r.permission === "external_directory")
|
||||
expect(req).toBeDefined()
|
||||
@@ -95,15 +94,13 @@ describe("tool.assertExternalDirectory", () => {
|
||||
)
|
||||
|
||||
it.live("skips prompting when bypass=true", () =>
|
||||
provideInstance("/tmp/project")(
|
||||
Effect.gen(function* () {
|
||||
const { requests, ctx } = makeCtx()
|
||||
Effect.gen(function* () {
|
||||
const { requests, ctx } = makeCtx()
|
||||
|
||||
yield* assertExternalDirectoryEffect(ctx, "/tmp/outside/file.txt", { bypass: true })
|
||||
yield* assertExternalDirectoryEffect(ctx, "/tmp/outside/file.txt", { bypass: true })
|
||||
|
||||
expect(requests.length).toBe(0)
|
||||
}),
|
||||
),
|
||||
expect(requests.length).toBe(0)
|
||||
}),
|
||||
)
|
||||
|
||||
if (process.platform === "win32") {
|
||||
|
||||
Reference in New Issue
Block a user