5d5fab36bb
Fixes 257 typecheck errors surfaced after the upstream merge: - Update imports to new module paths after upstream PR #24554 removed module barrel files (@/config, @/session, @/util, etc.) and PR #24309 renamed @opencode-ai/shared to @opencode-ai/core. - Migrate loadMode to use Info.zod.safeParse for consistency with loadAgents and ConfigCommand (unblocks KilocodeConfig.handleInvalid). - Drop removed Npm.outdated mock from tests. - Add missing Config.defaultLayer to bash-permission-metadata test runtime. - Fix Tips component signature (kilocode drops upstream's 'connected' prop). - Fix toast.tsx undefined 'duration' reference (should be toastOptions.duration). - Move filesystem-containment test from deleted shared package to core.
67 lines
2.2 KiB
TypeScript
67 lines
2.2 KiB
TypeScript
// regression test for bash permission metadata.command
|
|
import { describe, expect, test } from "bun:test"
|
|
import { Effect, Layer, ManagedRuntime } from "effect"
|
|
import { BashTool } from "../../src/tool/bash"
|
|
import { Instance } from "../../src/project/instance"
|
|
import { tmpdir } from "../fixture/fixture"
|
|
import { Shell } from "../../src/shell/shell"
|
|
import { SessionID, MessageID } from "../../src/session/schema"
|
|
import type { Permission } from "../../src/permission"
|
|
import { Agent } from "../../src/agent/agent"
|
|
import { Truncate } from "../../src/tool/truncate"
|
|
import * as CrossSpawnSpawner from "@opencode-ai/core/cross-spawn-spawner"
|
|
import { AppFileSystem } from "@opencode-ai/core/filesystem"
|
|
import { Plugin } from "../../src/plugin"
|
|
import { Config } from "../../src/config/config"
|
|
|
|
const runtime = ManagedRuntime.make(
|
|
Layer.mergeAll(
|
|
CrossSpawnSpawner.defaultLayer,
|
|
AppFileSystem.defaultLayer,
|
|
Plugin.defaultLayer,
|
|
Truncate.defaultLayer,
|
|
Agent.defaultLayer,
|
|
Config.defaultLayer,
|
|
),
|
|
)
|
|
|
|
Shell.acceptable.reset()
|
|
|
|
const baseCtx = {
|
|
sessionID: SessionID.make("ses_test"),
|
|
messageID: MessageID.make(""),
|
|
callID: "",
|
|
agent: "code",
|
|
abort: AbortSignal.any([]),
|
|
messages: [],
|
|
metadata: () => Effect.void,
|
|
ask: () => Effect.void,
|
|
}
|
|
|
|
const capture = (requests: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">>) => ({
|
|
...baseCtx,
|
|
ask: (req: Omit<Permission.Request, "id" | "sessionID" | "tool">) =>
|
|
Effect.sync(() => {
|
|
requests.push(req)
|
|
}),
|
|
})
|
|
|
|
describe("bash permission metadata.command", () => {
|
|
test("permission prompt shows raw command without tool name prefix", async () => {
|
|
await using tmp = await tmpdir()
|
|
await Instance.provide({
|
|
directory: tmp.path,
|
|
fn: async () => {
|
|
const bash = await runtime.runPromise(BashTool.pipe(Effect.flatMap((info) => info.init())))
|
|
const requests: Array<Omit<Permission.Request, "id" | "sessionID" | "tool">> = []
|
|
const command = "echo hello"
|
|
await Effect.runPromise(bash.execute({ command, description: "Echo hello" }, capture(requests)))
|
|
|
|
const bashReq = requests.find((r) => r.permission === "bash")
|
|
expect(bashReq).toBeDefined()
|
|
expect(bashReq!.metadata.command).toBe(command)
|
|
},
|
|
})
|
|
})
|
|
})
|