mirror of
https://github.com/anomalyco/opencode.git
synced 2026-05-23 21:16:06 +00:00
fix: allow current project worktree directories by default
This commit is contained in:
parent
467be08e67
commit
a2133466be
2 changed files with 22 additions and 2 deletions
|
|
@ -79,10 +79,14 @@ export const layer = Layer.effect(
|
|||
const provider = yield* Provider.Service
|
||||
|
||||
const state = yield* InstanceState.make<State>(
|
||||
Effect.fn("Agent.state")(function* (_ctx) {
|
||||
Effect.fn("Agent.state")(function* (ctx) {
|
||||
const cfg = yield* config.get()
|
||||
const skillDirs = yield* skill.dirs()
|
||||
const whitelistedDirs = [Truncate.GLOB, ...skillDirs.map((dir) => path.join(dir, "*"))]
|
||||
const whitelistedDirs = [
|
||||
Truncate.GLOB,
|
||||
path.join(Global.Path.data, "worktree", String(ctx.project.id), "*"),
|
||||
...skillDirs.map((dir) => path.join(dir, "*")),
|
||||
]
|
||||
|
||||
const defaults = Permission.fromConfig({
|
||||
"*": "allow",
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import path from "path"
|
|||
import { provideInstance, tmpdir } from "../fixture/fixture"
|
||||
import { Instance } from "../../src/project/instance"
|
||||
import { Agent } from "../../src/agent/agent"
|
||||
import { Global } from "../../src/global"
|
||||
import { Permission } from "../../src/permission"
|
||||
|
||||
// Helper to evaluate permission for a tool with wildcard pattern
|
||||
|
|
@ -597,6 +598,21 @@ description: Permission skill.
|
|||
}
|
||||
})
|
||||
|
||||
test("managed worktree directories are allowed for external_directory", async () => {
|
||||
await using tmp = await tmpdir({ git: true })
|
||||
|
||||
await Instance.provide({
|
||||
directory: tmp.path,
|
||||
fn: async () => {
|
||||
const build = await load(tmp.path, (svc) => svc.get("build"))
|
||||
const target = path.join(Global.Path.data, "worktree", String(Instance.project.id), "sandbox", "notes.md")
|
||||
const other = path.join(Global.Path.data, "worktree", "proj_other", "sandbox", "notes.md")
|
||||
expect(Permission.evaluate("external_directory", target, build!.permission).action).toBe("allow")
|
||||
expect(Permission.evaluate("external_directory", other, build!.permission).action).toBe("ask")
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test("defaultAgent returns build when no default_agent config", async () => {
|
||||
await using tmp = await tmpdir()
|
||||
await Instance.provide({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue