77 * This allows OpenCode to discover and use the agents.
88 */
99
10- import { existsSync , mkdirSync , copyFileSync , readdirSync } from "node:fs"
11- import { join , dirname } from "node:path"
10+ import { copyFileSync , existsSync , mkdirSync , readdirSync } from "node:fs"
1211import { homedir } from "node:os"
12+ import { dirname , join } from "node:path"
1313import { fileURLToPath } from "node:url"
1414
1515const __filename = fileURLToPath ( import . meta. url )
@@ -19,40 +19,40 @@ const AGENTS_SOURCE_DIR = join(__dirname, "agents")
1919const AGENTS_TARGET_DIR = join ( homedir ( ) , ".config" , "opencode" , "agents" )
2020
2121function main ( ) {
22- console . log ( "opencode-plugin-opencoder: Installing agents..." )
23-
24- // Create target directory if it doesn't exist
25- if ( ! existsSync ( AGENTS_TARGET_DIR ) ) {
26- mkdirSync ( AGENTS_TARGET_DIR , { recursive : true } )
27- console . log ( ` Created ${ AGENTS_TARGET_DIR } ` )
28- }
29-
30- // Check if source directory exists
31- if ( ! existsSync ( AGENTS_SOURCE_DIR ) ) {
32- console . error ( ` Error: Source agents directory not found at ${ AGENTS_SOURCE_DIR } ` )
33- process . exit ( 1 )
34- }
35-
36- // Copy all .md files from agents/ to target
37- const files = readdirSync ( AGENTS_SOURCE_DIR ) . filter ( ( f ) => f . endsWith ( ".md" ) )
38-
39- if ( files . length === 0 ) {
40- console . error ( " Error: No agent files found in agents/ directory" )
41- process . exit ( 1 )
42- }
43-
44- for ( const file of files ) {
45- const sourcePath = join ( AGENTS_SOURCE_DIR , file )
46- const targetPath = join ( AGENTS_TARGET_DIR , file )
47-
48- copyFileSync ( sourcePath , targetPath )
49- console . log ( ` Installed: ${ file } ` )
50- }
51-
52- console . log ( `\nopencode-plugin-opencoder: Successfully installed ${ files . length } agent(s)` )
53- console . log ( ` Location: ${ AGENTS_TARGET_DIR } ` )
54- console . log ( "\nTo use the autonomous development loop, run:" )
55- console . log ( " opencode @opencoder" )
22+ console . log ( "opencode-plugin-opencoder: Installing agents..." )
23+
24+ // Create target directory if it doesn't exist
25+ if ( ! existsSync ( AGENTS_TARGET_DIR ) ) {
26+ mkdirSync ( AGENTS_TARGET_DIR , { recursive : true } )
27+ console . log ( ` Created ${ AGENTS_TARGET_DIR } ` )
28+ }
29+
30+ // Check if source directory exists
31+ if ( ! existsSync ( AGENTS_SOURCE_DIR ) ) {
32+ console . error ( ` Error: Source agents directory not found at ${ AGENTS_SOURCE_DIR } ` )
33+ process . exit ( 1 )
34+ }
35+
36+ // Copy all .md files from agents/ to target
37+ const files = readdirSync ( AGENTS_SOURCE_DIR ) . filter ( ( f ) => f . endsWith ( ".md" ) )
38+
39+ if ( files . length === 0 ) {
40+ console . error ( " Error: No agent files found in agents/ directory" )
41+ process . exit ( 1 )
42+ }
43+
44+ for ( const file of files ) {
45+ const sourcePath = join ( AGENTS_SOURCE_DIR , file )
46+ const targetPath = join ( AGENTS_TARGET_DIR , file )
47+
48+ copyFileSync ( sourcePath , targetPath )
49+ console . log ( ` Installed: ${ file } ` )
50+ }
51+
52+ console . log ( `\nopencode-plugin-opencoder: Successfully installed ${ files . length } agent(s)` )
53+ console . log ( ` Location: ${ AGENTS_TARGET_DIR } ` )
54+ console . log ( "\nTo use the autonomous development loop, run:" )
55+ console . log ( " opencode @opencoder" )
5656}
5757
5858main ( )
0 commit comments