| 800 | }; |
| 801 | |
| 802 | const loadPluginsFromDir = (dirInfo) => { |
| 803 | const plugins = []; |
| 804 | if (!fs.existsSync(dirInfo.path)) return plugins; |
| 805 | |
| 806 | try { |
| 807 | const files = fs.readdirSync(dirInfo.path) |
| 808 | .filter(f => f.endsWith('.js') || f.endsWith('.ts')); |
| 809 | |
| 810 | for (const file of files) { |
| 811 | const filePath = path.join(dirInfo.path, file); |
| 812 | const content = fs.readFileSync(filePath, 'utf8'); |
| 813 | const name = path.basename(file, path.extname(file)); |
| 814 | |
| 815 | plugins.push({ |
| 816 | name, |
| 817 | filename: file, |
| 818 | content, |
| 819 | source: dirInfo.source, |
| 820 | path: filePath, |
| 821 | root: dirInfo.root |
| 822 | }); |
| 823 | } |
| 824 | } catch (e) { |
| 825 | console.warn(`Failed to load plugins from ${dirInfo.path}:`, e.message); |
| 826 | } |
| 827 | |
| 828 | return plugins; |
| 829 | }; |
| 830 | |
| 831 | const loadSkillsFromDir = (dirInfo) => { |
| 832 | const skills = []; |