core: extract external directory validation to shared utility to reduce code duplication across tools

This commit is contained in:
Dax Raad
2026-01-10 18:49:36 -05:00
parent 76386f5cfc
commit f94ee5ce90
10 changed files with 186 additions and 49 deletions

View File

@@ -4,6 +4,7 @@ import * as path from "path"
import DESCRIPTION from "./ls.txt"
import { Instance } from "../project/instance"
import { Ripgrep } from "../file/ripgrep"
import { assertExternalDirectory } from "./external-directory"
export const IGNORE_PATTERNS = [
"node_modules/",
@@ -42,6 +43,7 @@ export const ListTool = Tool.define("list", {
}),
async execute(params, ctx) {
const searchPath = path.resolve(Instance.directory, params.path || ".")
await assertExternalDirectory(ctx, searchPath, { kind: "directory" })
await ctx.ask({
permission: "list",