1
+ #! /bin/bash
2
+
3
+ echo " Passing arguments: $* "
4
+
5
+ # Base packages directory
6
+ PACKAGES_DIR=" ./packages"
7
+
8
+ # Display help message to users
9
+ cat << "EOF "
10
+
11
+ ***********************************************************************
12
+ * *
13
+ * IMPORTANT NOTICE: *
14
+ * *
15
+ * To add your plugin to the development workflow: *
16
+ * *
17
+ * 1. Navigate to the 'scripts' directory in your project. *
18
+ * *
19
+ * cd scripts *
20
+ * *
21
+ * 2. Edit the 'dev.sh' script file. *
22
+ * *
23
+ * nano dev.sh *
24
+ * *
25
+ * 3. Add the following changes: *
26
+ * *
27
+ * a. Ensure your plugin's package.json contains a 'dev' command *
28
+ * under the "scripts" section. Example: *
29
+ * *
30
+ * "scripts": { *
31
+ * "dev": "your-dev-command-here" *
32
+ * } *
33
+ * *
34
+ * b. Add your plugin's folder name to the WORKING_FOLDERS list *
35
+ * (relative to ./packages). *
36
+ * *
37
+ * Example: WORKING_FOLDERS=("client-direct" "your-plugin-folder") *
38
+ * *
39
+ * 4. Update the 'agent/package.json' file: *
40
+ * *
41
+ * Add your plugin to the "dependencies" section like so: *
42
+ * *
43
+ * "@elizaos/your-plugin-name": "workspace:*" *
44
+ * *
45
+ * 5. Edit the 'index.ts' file in 'agent/src': *
46
+ * *
47
+ * a. Import your plugin: *
48
+ * *
49
+ * import yourPlugin from '@elizaos/your-plugin-name'; *
50
+ * *
51
+ * b. Add your plugin to the `plugins` array: *
52
+ * *
53
+ * const plugins = [ *
54
+ * existingPlugin, *
55
+ * yourPlugin, *
56
+ * ]; *
57
+ * *
58
+ * This will ensure that your plugin's development server runs *
59
+ * alongside others when you execute this script. *
60
+ ***********************************************************************
61
+
62
+ EOF
63
+
64
+ # 2 seconds delay
65
+ for i in {1..5}; do
66
+ echo -n " ."
67
+ sleep 0.4
68
+ done
69
+
70
+ # Check if the packages directory exists
71
+ if [ ! -d " $PACKAGES_DIR " ]; then
72
+ echo " Error: Directory $PACKAGES_DIR does not exist."
73
+ exit 1
74
+ fi
75
+
76
+ # List of working folders to watch (relative to $PACKAGES_DIR)
77
+ WORKING_FOLDERS=(" client-direct" ) # Core is handled separately
78
+
79
+ # Initialize an array to hold package-specific commands
80
+ COMMANDS=()
81
+
82
+ # Ensure "core" package runs first
83
+ CORE_PACKAGE=" $PACKAGES_DIR /core"
84
+ if [ -d " $CORE_PACKAGE " ]; then
85
+ COMMANDS+=(" pnpm --dir $CORE_PACKAGE dev -- $* " )
86
+ else
87
+ echo " Warning: 'core' package not found in $PACKAGES_DIR ."
88
+ fi
89
+
90
+ # Process remaining working folders
91
+ for FOLDER in " ${WORKING_FOLDERS[@]} " ; do
92
+ PACKAGE=" $PACKAGES_DIR /$FOLDER "
93
+
94
+ # Check if the folder exists and add the command
95
+ if [ -d " $PACKAGE " ]; then
96
+ COMMANDS+=(" pnpm --dir $PACKAGE dev -- $* " )
97
+ else
98
+ echo " Warning: '$FOLDER ' folder not found in $PACKAGES_DIR ."
99
+ fi
100
+ done
101
+
102
+ # Add specific commands for other directories or cases
103
+ if [ -d " ./client" ]; then
104
+ COMMANDS+=(" pnpm --dir client dev -- $* " )
105
+ else
106
+ echo " Warning: 'client' directory not found."
107
+ fi
108
+
109
+ if [ -d " ./agent" ]; then
110
+ # Build the watch paths dynamically from WORKING_FOLDERS
111
+ WATCH_PATHS=()
112
+ for FOLDER in " ${WORKING_FOLDERS[@]} " ; do
113
+ WATCH_PATHS+=(" --watch './packages/$FOLDER /dist'" )
114
+ done
115
+
116
+ COMMANDS+=(" nodemon ${WATCH_PATHS[@]} -e js,json,map --delay 2 --exec 'pnpm --dir agent dev -- $* '" )
117
+ else
118
+ echo " Warning: 'agent' directory not found."
119
+ fi
120
+
121
+ # Run build command first
122
+ if ! pnpm build; then
123
+ echo " Build failed. Exiting."
124
+ exit 1
125
+ fi
126
+
127
+ # Run all commands concurrently
128
+ if [ ${# COMMANDS[@]} -gt 0 ]; then
129
+ npx concurrently --raw " ${COMMANDS[@]} "
130
+ else
131
+ echo " No valid packages to run."
132
+ fi
0 commit comments