fix(coding-agent): support symlinked tools and hooks in discovery (#219)

This commit is contained in:
Aliou Diallo 2025-12-18 13:07:30 +01:00 committed by GitHub
parent d690310587
commit de2de851c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 4 deletions

View file

@ -224,7 +224,7 @@ export async function loadCustomTools(
/**
* Discover tool files from a directory.
* Returns all .ts files in the directory (non-recursive).
* Returns all .ts files (and symlinks to .ts files) in the directory (non-recursive).
*/
function discoverToolsInDir(dir: string): string[] {
if (!fs.existsSync(dir)) {
@ -233,7 +233,9 @@ function discoverToolsInDir(dir: string): string[] {
try {
const entries = fs.readdirSync(dir, { withFileTypes: true });
return entries.filter((e) => e.isFile() && e.name.endsWith(".ts")).map((e) => path.join(dir, e.name));
return entries
.filter((e) => (e.isFile() || e.isSymbolicLink()) && e.name.endsWith(".ts"))
.map((e) => path.join(dir, e.name));
} catch {
return [];
}

View file

@ -198,7 +198,7 @@ export async function loadHooks(paths: string[], cwd: string): Promise<LoadHooks
/**
* Discover hook files from a directory.
* Returns all .ts files in the directory (non-recursive).
* Returns all .ts files (and symlinks to .ts files) in the directory (non-recursive).
*/
function discoverHooksInDir(dir: string): string[] {
if (!fs.existsSync(dir)) {
@ -207,7 +207,9 @@ function discoverHooksInDir(dir: string): string[] {
try {
const entries = fs.readdirSync(dir, { withFileTypes: true });
return entries.filter((e) => e.isFile() && e.name.endsWith(".ts")).map((e) => path.join(dir, e.name));
return entries
.filter((e) => (e.isFile() || e.isSymbolicLink()) && e.name.endsWith(".ts"))
.map((e) => path.join(dir, e.name));
} catch {
return [];
}