mirror of
https://github.com/block/goose.git
synced 2026-07-17 12:56:20 +02:00
add in built in extensions and fix loading (#695)
This commit is contained in:
@@ -22,9 +22,14 @@ export default function App() {
|
||||
window.electron.on('fatal-error', handleFatalError);
|
||||
|
||||
// Load stored extension configs when the app starts
|
||||
loadStoredExtensionConfigs().catch((error) => {
|
||||
console.error('Failed to load stored extension configs:', error);
|
||||
});
|
||||
// delay this by a few seconds
|
||||
setTimeout(() => {
|
||||
window.electron.logInfo('App.tsx: Loading stored extension configs');
|
||||
loadStoredExtensionConfigs().catch((error) => {
|
||||
console.error('Failed to load stored extension configs:', error);
|
||||
window.electron.logInfo('App.tsx: Failed to load stored extension configs ' + error);
|
||||
});
|
||||
}, 5000);
|
||||
|
||||
return () => {
|
||||
window.electron.off('fatal-error', handleFatalError);
|
||||
|
||||
@@ -37,13 +37,59 @@ const DEFAULT_SETTINGS: SettingsType = {
|
||||
extensions: [],
|
||||
};
|
||||
|
||||
const BUILT_IN_EXTENSIONS = [
|
||||
{
|
||||
id: 'jetbrains',
|
||||
name: 'Jetbrains',
|
||||
type: 'stdio',
|
||||
cmd: 'goosed',
|
||||
args: ['mcp', 'jetbrains'],
|
||||
description: 'Integration with any Jetbrains IDE',
|
||||
enabled: false,
|
||||
env_keys: [],
|
||||
},
|
||||
{
|
||||
id: 'nondeveloper',
|
||||
name: 'Non-Developer assistant',
|
||||
type: 'stdio',
|
||||
cmd: 'goosed',
|
||||
args: ['mcp', 'nondeveloper'],
|
||||
description: "General assisant tools that don't require you to be a developer or engineer.",
|
||||
enabled: false,
|
||||
env_keys: [],
|
||||
},
|
||||
{
|
||||
id: 'memory',
|
||||
name: 'Memory',
|
||||
type: 'stdio',
|
||||
cmd: 'goosed',
|
||||
args: ['mcp', 'memory'],
|
||||
description: 'Teach goose your preferences as you go.',
|
||||
enabled: false,
|
||||
env_keys: [],
|
||||
},
|
||||
];
|
||||
|
||||
export default function Settings() {
|
||||
const navigate = useNavigate();
|
||||
const location = useLocation();
|
||||
|
||||
const [settings, setSettings] = React.useState<SettingsType>(() => {
|
||||
const saved = localStorage.getItem('user_settings');
|
||||
return saved ? JSON.parse(saved) : DEFAULT_SETTINGS;
|
||||
window.electron.logInfo('Settings: ' + saved);
|
||||
let currentSettings = saved ? JSON.parse(saved) : DEFAULT_SETTINGS;
|
||||
|
||||
// Ensure built-in extensions are included if not already present
|
||||
BUILT_IN_EXTENSIONS.forEach((builtIn) => {
|
||||
const exists = currentSettings.extensions.some(
|
||||
(ext: FullExtensionConfig) => ext.id === builtIn.id
|
||||
);
|
||||
if (!exists) {
|
||||
currentSettings.extensions.push(builtIn);
|
||||
}
|
||||
});
|
||||
|
||||
return currentSettings;
|
||||
});
|
||||
|
||||
const [extensionBeingConfigured, setExtensionBeingConfigured] =
|
||||
|
||||
@@ -58,19 +58,26 @@ export const loadStoredExtensionConfigs = async (): Promise<void> => {
|
||||
try {
|
||||
const userSettingsStr = localStorage.getItem('user_settings');
|
||||
|
||||
//console.log('Loading stored extension configs from user_settings', userSettingsStr);
|
||||
|
||||
if (userSettingsStr) {
|
||||
const userSettings = JSON.parse(userSettingsStr);
|
||||
const enabledExtensions = userSettings.extensions.filter((ext: any) => ext.enabled);
|
||||
//console.log('Enabled extensions:', enabledExtensions);
|
||||
|
||||
for (const ext of enabledExtensions) {
|
||||
// Convert extension format back to ExtensionConfig
|
||||
console.log('Loading extension:', ext);
|
||||
|
||||
const config: ExtensionConfig = {
|
||||
type: 'stdio', // Assuming all stored extensions are stdio type for now
|
||||
cmd: ext.command,
|
||||
args: [],
|
||||
env_keys: ext.environmentVariables?.map((env: any) => env.name) || [],
|
||||
cmd: ext.cmd,
|
||||
args: ext.args || [],
|
||||
env_keys: ext.env_keys || [],
|
||||
};
|
||||
|
||||
console.log('ext config', config);
|
||||
|
||||
await extendGoosed(config);
|
||||
}
|
||||
|
||||
@@ -101,6 +108,7 @@ export const replaceWithShims = async (cmd: string): Promise<string> => {
|
||||
|
||||
// Extend Goosed with a new system configuration
|
||||
export const extendGoosed = async (config: ExtensionConfig) => {
|
||||
console.log('extendGoosed', config);
|
||||
// allowlist the CMD for stdio type
|
||||
if (config.type === 'stdio') {
|
||||
const allowedCMDs = ['goosed', 'npx', 'uvx'];
|
||||
|
||||
Reference in New Issue
Block a user