Convert LoadInput.init to Effect + extract InstanceBootstrap as a Service (#25376)

This commit is contained in:
Kit Langton
2026-05-02 00:02:52 -04:00
committed by GitHub
parent 1571933096
commit f33aec1139
21 changed files with 223 additions and 153 deletions

View File

@@ -1,4 +1,5 @@
import { LocalContext } from "@/util/local-context"
import { AppFileSystem } from "@opencode-ai/core/filesystem"
import type * as Project from "./project"
export interface InstanceContext {
@@ -8,3 +9,16 @@ export interface InstanceContext {
}
export const context = LocalContext.create<InstanceContext>("instance")
/**
* Check if a path is within the project boundary.
* Returns true if path is inside ctx.directory OR ctx.worktree.
* Paths within the worktree but outside the working directory should not trigger external_directory permission.
*/
export function containsPath(filepath: string, ctx: InstanceContext): boolean {
if (AppFileSystem.contains(ctx.directory, filepath)) return true
// Non-git projects set worktree to "/" which would match ANY absolute path.
// Skip worktree check in this case to preserve external_directory permissions.
if (ctx.worktree === "/") return false
return AppFileSystem.contains(ctx.worktree, filepath)
}