@@ -81,18 +81,29 @@ async function loadCommands(): Promise<ParsedCommand[]> {
8181 const commands : ParsedCommand [ ] = [ ] ;
8282 const commandDir = path . join ( getModuleDir ( ) , 'command' ) ;
8383
84+ try {
85+ const stats = await fs . stat ( commandDir ) ;
86+ if ( ! stats . isDirectory ( ) ) {
87+ return commands ;
88+ }
89+ } catch {
90+ return commands ;
91+ }
92+
8493 const files = await scanMdFiles ( commandDir ) ;
8594 for ( const file of files ) {
86- const content = await fs . readFile ( file , 'utf-8' ) ;
87- const { frontmatter, body } = parseFrontmatter ( content ) ;
88- const relativePath = path . relative ( commandDir , file ) ;
89- const name = relativePath . replace ( / \. m d $ / , '' ) . replace ( / \/ / g, '-' ) ;
90-
91- commands . push ( {
92- name,
93- frontmatter,
94- template : body ,
95- } ) ;
95+ try {
96+ const content = await fs . readFile ( file , 'utf-8' ) ;
97+ const { frontmatter, body } = parseFrontmatter ( content ) ;
98+ const relativePath = path . relative ( commandDir , file ) ;
99+ const name = relativePath . replace ( / \. m d $ / , '' ) . replace ( / \/ / g, '-' ) ;
100+
101+ commands . push ( {
102+ name,
103+ frontmatter,
104+ template : body ,
105+ } ) ;
106+ } catch { }
96107 }
97108
98109 return commands ;
@@ -210,6 +221,9 @@ export const OpencodeConfigSync: Plugin = async (ctx) => {
210221 } ;
211222} ;
212223
224+ export const OpencodeSynced = OpencodeConfigSync ;
225+ export default OpencodeConfigSync ;
226+
213227function formatError ( error : unknown ) : string {
214228 if ( error instanceof Error ) return error . message ;
215229 return String ( error ) ;
0 commit comments