mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-15 11:02:17 +00:00
fix(coding-agent): support symlinked tools and hooks in discovery (#219)
This commit is contained in:
parent
d690310587
commit
de2de851c8
2 changed files with 8 additions and 4 deletions
|
|
@ -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 [];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 [];
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue