@@ -2,6 +2,7 @@ import { router, publicProcedure } from "../index"
22import * as fs from "fs/promises"
33import * as path from "path"
44import matter from "gray-matter"
5+ import { resolveDirentType } from "../../fs/dirent"
56import {
67 discoverInstalledPlugins ,
78 getPluginComponentPaths ,
@@ -60,12 +61,13 @@ async function scanPluginCommands(dir: string): Promise<PluginComponent[]> {
6061 if ( ! isValidEntryName ( entry . name ) ) continue
6162
6263 const fullPath = path . join ( dir , entry . name )
64+ const { isDirectory, isFile } = await resolveDirentType ( dir , entry )
6365
64- if ( entry . isDirectory ( ) ) {
66+ if ( isDirectory ) {
6567 // Recursively scan nested directories for namespaced commands
6668 const nested = await scanPluginCommands ( fullPath )
6769 components . push ( ...nested )
68- } else if ( entry . isFile ( ) && entry . name . endsWith ( ".md" ) ) {
70+ } else if ( isFile && entry . name . endsWith ( ".md" ) ) {
6971 try {
7072 const content = await fs . readFile ( fullPath , "utf-8" )
7173 const { data } = matter ( content )
@@ -103,7 +105,10 @@ async function scanPluginSkills(dir: string): Promise<PluginComponent[]> {
103105 const entries = await fs . readdir ( dir , { withFileTypes : true } )
104106
105107 for ( const entry of entries ) {
106- if ( ! entry . isDirectory ( ) || ! isValidEntryName ( entry . name ) ) continue
108+ if ( ! isValidEntryName ( entry . name ) ) continue
109+
110+ const { isDirectory } = await resolveDirentType ( dir , entry )
111+ if ( ! isDirectory ) continue
107112
108113 const skillMdPath = path . join ( dir , entry . name , "SKILL.md" )
109114 try {
@@ -141,8 +146,10 @@ async function scanPluginAgents(dir: string): Promise<PluginComponent[]> {
141146 const entries = await fs . readdir ( dir , { withFileTypes : true } )
142147
143148 for ( const entry of entries ) {
144- if ( ! entry . isFile ( ) || ! entry . name . endsWith ( ".md" ) || ! isValidEntryName ( entry . name ) )
145- continue
149+ if ( ! entry . name . endsWith ( ".md" ) || ! isValidEntryName ( entry . name ) ) continue
150+
151+ const { isFile } = await resolveDirentType ( dir , entry )
152+ if ( ! isFile ) continue
146153
147154 const fullPath = path . join ( dir , entry . name )
148155 try {
0 commit comments