diff --git a/docs/PLUGINS.md b/docs/PLUGINS.md
new file mode 100644
index 00000000..51a71738
--- /dev/null
+++ b/docs/PLUGINS.md
@@ -0,0 +1,278 @@
+# Shakespeare Plugins System
+
+Shakespeare now includes a comprehensive plugins system that allows you to extend the AI's capabilities with reusable skills.
+
+## Overview
+
+Plugins are Git repositories that can contain **skills** - specialized AI workflows that help the AI assistant perform specific tasks more effectively. Skills are automatically discovered and made available to the AI through the `skill` tool.
+
+## Features
+
+- **Git-based plugins**: Clone plugins from any Git repository (GitHub, GitLab, etc.)
+- **Automatic skill discovery**: Skills are automatically found and registered from all installed plugins
+- **Configurable storage**: Plugin directory is configurable in System Settings
+- **Sync support**: Pull latest changes from plugin repositories
+- **Delete support**: Remove plugins when no longer needed
+- **AI integration**: Skills are automatically included in the system prompt and accessible via the `skill` tool
+
+## User Interface
+
+### AI Settings Page (`/settings/ai`)
+
+The AI Settings page now includes a **Plugins** section with:
+
+1. **Add Plugin**: Clone a new plugin by entering its Git URL
+2. **Plugin List**: View all installed plugins with their skills
+3. **Sync**: Pull latest changes from a plugin's Git repository
+4. **Delete**: Remove a plugin and all its skills
+
+### System Settings Page (`/settings/system`)
+
+The System Settings page includes a **Filesystem Paths** section where you can configure:
+
+- **Plugins Directory**: Path where plugins are stored (default: `/plugins`)
+
+## Plugin Structure
+
+A plugin is a Git repository with the following structure:
+
+```
+my-plugin/
+├── skills/
+│ ├── skill1/
+│ │ └── SKILL.md
+│ ├── skill2/
+│ │ └── SKILL.md
+│ └── ...
+└── README.md (optional)
+```
+
+### Skill Format
+
+Each skill is defined by a `SKILL.md` file with YAML frontmatter:
+
+```markdown
+---
+name: skillname
+description: A brief description of what this skill does
+---
+
+# Skill Content
+
+The rest of the file contains instructions, examples, and context
+that will be provided to the AI when this skill is invoked.
+
+This can include:
+- Step-by-step workflows
+- Code examples
+- Best practices
+- Domain-specific knowledge
+```
+
+#### Required Frontmatter Fields
+
+- **`name`**: Skill identifier (must be alphanumeric lowercase only, e.g., `myskill`, `skill123`)
+- **`description`**: Human-readable description of what the skill does
+
+#### Skill Name Validation
+
+Skill names must:
+- Contain only lowercase letters (a-z) and numbers (0-9)
+- No spaces, hyphens, underscores, or special characters
+- Examples: ✅ `myskill`, `skill123`, `abc` | ❌ `My-Skill`, `skill_name`, `SKILL`
+
+## How It Works
+
+### For Users
+
+1. **Add a Plugin**:
+ - Go to Settings > AI
+ - Scroll to the Plugins section
+ - Click "Add Plugin"
+ - Enter the Git URL (e.g., `https://github.com/user/shakespeare-skills.git`)
+ - Click "Add Plugin"
+
+2. **View Skills**:
+ - Installed plugins show the number of skills they contain
+ - Expand a plugin to see all its skills with descriptions
+
+3. **Sync a Plugin**:
+ - Click the "Sync" button next to a plugin to pull latest changes
+ - Useful when the plugin repository is updated with new skills
+
+4. **Delete a Plugin**:
+ - Click the "Delete" button next to a plugin to remove it
+ - All skills from that plugin will no longer be available
+
+### For the AI
+
+The AI assistant automatically:
+
+1. **Discovers Skills**: All skills from installed plugins are scanned on startup
+2. **Includes in System Prompt**: Skills are listed in the system prompt with their names, descriptions, and paths
+3. **Enforces Usage**: The system prompt instructs the AI to use skills whenever applicable
+4. **Accesses via Tool**: The AI calls the `skill` tool with a skill name to load its content
+
+Example AI workflow:
+```
+User: "Help me build a Nostr marketplace"
+
+AI: [Sees "nostrmarket" skill in system prompt]
+ [Calls skill tool with name="nostrmarket"]
+ [Receives SKILL.md content with marketplace implementation guide]
+ [Follows the skill's instructions to build the marketplace]
+```
+
+## Technical Implementation
+
+### Key Files
+
+- **`src/lib/plugins.ts`**: Core plugin and skill management functions
+- **`src/lib/tools/SkillTool.ts`**: AI tool for loading skill content
+- **`src/hooks/usePlugins.ts`**: React hook for plugin CRUD operations
+- **`src/components/PluginsSection.tsx`**: UI component for managing plugins
+- **`src/lib/system.ts`**: Updated to include skills in system prompt
+
+### API
+
+#### `getPlugins(fs, pluginsPath)`
+Returns array of plugin names (directory basenames).
+
+#### `getAllSkills(fs, pluginsPath)`
+Returns array of all skills from all plugins.
+
+#### `findSkill(fs, pluginsPath, skillName)`
+Finds a skill by name across all plugins.
+
+#### `readSkillContent(fs, skill)`
+Reads the SKILL.md content for a skill.
+
+#### `deletePlugin(fs, pluginsPath, pluginName)`
+Recursively deletes a plugin directory.
+
+### Skill Tool
+
+The `SkillTool` is exposed to the AI as the `skill` function:
+
+```typescript
+{
+ name: "skill",
+ description: "Load and execute a skill from the configured plugins",
+ parameters: {
+ name: "The name of the skill to execute"
+ }
+}
+```
+
+When called, it:
+1. Searches all plugins for a skill with the matching name
+2. Returns the full SKILL.md content
+3. Includes metadata (plugin name, description, path)
+
+### Storage
+
+Plugins are stored in the configured plugins directory:
+
+- **Browser**: `/plugins` (IndexedDB via LightningFS)
+- **Electron (Windows)**: `~/AppData/Local/shakespeare/plugins`
+- **Electron (macOS)**: `~/Library/Application Support/shakespeare/plugins`
+- **Electron (Linux)**: `~/.config/shakespeare/plugins`
+
+## System Prompt Integration
+
+The system prompt now includes a **Skills** section that:
+
+1. Lists all available skills with their names, descriptions, plugins, and paths
+2. Instructs the AI to use skills whenever applicable
+3. Provides the Settings > AI URL for users to configure skills
+4. Includes this section even when no skills are configured (to inform users about the feature)
+
+Example system prompt section:
+
+```
+## Skills
+
+You have access to the following skills. **Skills MUST be used whenever applicable** by calling the `skill` tool with the skill name.
+
+Available skills:
+
+- **nostrmarket**: Build a Nostr marketplace application
+ - Plugin: nostr-skills
+ - Path: /plugins/nostr-skills/skills/nostrmarket
+
+**Important**: When a task matches a skill's description, you MUST use that skill by calling the skill tool. Skills contain specialized workflows and best practices for specific tasks.
+
+Users can configure skills in Settings > AI (https://shakespeare.diy/settings/ai) by adding plugins that contain skills.
+```
+
+## Creating Your Own Plugin
+
+1. **Create a Git repository** with the plugin structure
+2. **Add skills** in the `skills/` directory
+3. **Write SKILL.md files** with frontmatter and content
+4. **Push to GitHub/GitLab** or any Git hosting service
+5. **Share the Git URL** with others to install your plugin
+
+### Example Plugin Repository
+
+```
+my-shakespeare-skills/
+├── README.md
+└── skills/
+ ├── webdesign/
+ │ └── SKILL.md
+ └── database/
+ └── SKILL.md
+```
+
+**skills/webdesign/SKILL.md**:
+```markdown
+---
+name: webdesign
+description: Create beautiful, modern web designs with best practices
+---
+
+# Web Design Skill
+
+When designing web interfaces, follow these principles:
+
+1. **Use a consistent color palette** (3-5 colors + neutrals)
+2. **Implement proper spacing** (8px grid system)
+3. **Choose readable fonts** (18px+ for body text)
+4. **Ensure accessibility** (WCAG 2.1 AA compliance)
+
+[... detailed instructions ...]
+```
+
+## Configuration
+
+### Plugins Directory Path
+
+Configure in **Settings > System > Filesystem Paths**:
+
+- Default browser: `/plugins`
+- Default Electron: OS-specific (see Storage section)
+- Custom: Any absolute path
+
+Changes take effect immediately.
+
+## Limitations
+
+- Plugins must be Git repositories (no ZIP uploads)
+- Skills must be in `skills/` subdirectory
+- Skill names must be alphanumeric lowercase only
+- Each skill must have a `SKILL.md` file with required frontmatter
+- No automatic skill updates (users must manually sync)
+
+## Future Enhancements
+
+Potential future features:
+
+- Plugin marketplace/registry
+- Automatic skill updates
+- Skill versioning
+- Skill dependencies
+- Plugin configuration files
+- Skill categories/tags
+- Skill search functionality
+- Plugin publishing workflow
diff --git a/package-lock.json b/package-lock.json
index e62417e4..f39b8d3f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -58,6 +58,7 @@
"decimal.js": "^10.6.0",
"embla-carousel-react": "^8.3.0",
"esbuild-wasm": "^0.25.8",
+ "gray-matter": "^4.0.3",
"i18next": "^25.5.2",
"ignore": "^7.0.5",
"input-otp": "^1.2.4",
@@ -8041,6 +8042,19 @@
"url": "https://opencollective.com/eslint"
}
},
+ "node_modules/esprima": {
+ "version": "4.0.1",
+ "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.1.tgz",
+ "integrity": "sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A==",
+ "license": "BSD-2-Clause",
+ "bin": {
+ "esparse": "bin/esparse.js",
+ "esvalidate": "bin/esvalidate.js"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/esquery": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/esquery/-/esquery-1.6.0.tgz",
@@ -8128,6 +8142,18 @@
"integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==",
"license": "MIT"
},
+ "node_modules/extend-shallow": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz",
+ "integrity": "sha512-zCnTtlxNoAiDc3gqY2aYAWFx7XWWiasuF2K8Me5WbN8otHKTUKBwjPtNpRs/rbUZm7KxWAaNj7P1a/p52GbVug==",
+ "license": "MIT",
+ "dependencies": {
+ "is-extendable": "^0.1.0"
+ },
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/extract-zip": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/extract-zip/-/extract-zip-2.0.1.tgz",
@@ -8740,6 +8766,49 @@
"dev": true,
"license": "MIT"
},
+ "node_modules/gray-matter": {
+ "version": "4.0.3",
+ "resolved": "https://registry.npmjs.org/gray-matter/-/gray-matter-4.0.3.tgz",
+ "integrity": "sha512-5v6yZd4JK3eMI3FqqCouswVqwugaA9r4dNZB1wwcmrD02QkV5H0y7XBQW8QwQqEaZY1pM9aqORSORhJRdNK44Q==",
+ "license": "MIT",
+ "dependencies": {
+ "js-yaml": "^3.13.1",
+ "kind-of": "^6.0.2",
+ "section-matter": "^1.0.0",
+ "strip-bom-string": "^1.0.0"
+ },
+ "engines": {
+ "node": ">=6.0"
+ }
+ },
+ "node_modules/gray-matter/node_modules/argparse": {
+ "version": "1.0.10",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
+ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
+ "license": "MIT",
+ "dependencies": {
+ "sprintf-js": "~1.0.2"
+ }
+ },
+ "node_modules/gray-matter/node_modules/js-yaml": {
+ "version": "3.14.1",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
+ "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
+ "license": "MIT",
+ "dependencies": {
+ "argparse": "^1.0.7",
+ "esprima": "^4.0.0"
+ },
+ "bin": {
+ "js-yaml": "bin/js-yaml.js"
+ }
+ },
+ "node_modules/gray-matter/node_modules/sprintf-js": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz",
+ "integrity": "sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==",
+ "license": "BSD-3-Clause"
+ },
"node_modules/happy-dom": {
"version": "17.6.3",
"resolved": "https://registry.npmjs.org/happy-dom/-/happy-dom-17.6.3.tgz",
@@ -9491,6 +9560,15 @@
"url": "https://github.com/sponsors/ljharb"
}
},
+ "node_modules/is-extendable": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz",
+ "integrity": "sha512-5BMULNob1vgFX6EjQw5izWDxrecWK9AM72rugNr0TFldMOi0fj6Jk+zeKIt0xGj4cEfQIJth4w3OKWOJ4f+AFw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
@@ -10163,6 +10241,15 @@
"json-buffer": "3.0.1"
}
},
+ "node_modules/kind-of": {
+ "version": "6.0.3",
+ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.3.tgz",
+ "integrity": "sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/leven": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/leven/-/leven-3.1.0.tgz",
@@ -13198,6 +13285,19 @@
"loose-envify": "^1.1.0"
}
},
+ "node_modules/section-matter": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/section-matter/-/section-matter-1.0.0.tgz",
+ "integrity": "sha512-vfD3pmTzGpufjScBh50YHKzEu2lxBWhVEHsNGoEXmCmn2hKGfeNLYMzCJpe8cD7gqX7TJluOVpBkAequ6dgMmA==",
+ "license": "MIT",
+ "dependencies": {
+ "extend-shallow": "^2.0.1",
+ "kind-of": "^6.0.0"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/semver": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/semver/-/semver-7.7.2.tgz",
@@ -13923,6 +14023,15 @@
"node": ">=8"
}
},
+ "node_modules/strip-bom-string": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/strip-bom-string/-/strip-bom-string-1.0.0.tgz",
+ "integrity": "sha512-uCC2VHvQRYu+lMh4My/sFNmF2klFymLX1wHJeXnbEJERpV/ZsVuonzerjfrGpIGF7LBVa1O7i9kjiWvJiFck8g==",
+ "license": "MIT",
+ "engines": {
+ "node": ">=0.10.0"
+ }
+ },
"node_modules/strip-comments": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/strip-comments/-/strip-comments-2.0.1.tgz",
diff --git a/package.json b/package.json
index 6fd5da25..1fd06524 100644
--- a/package.json
+++ b/package.json
@@ -71,6 +71,7 @@
"decimal.js": "^10.6.0",
"embla-carousel-react": "^8.3.0",
"esbuild-wasm": "^0.25.8",
+ "gray-matter": "^4.0.3",
"i18next": "^25.5.2",
"ignore": "^7.0.5",
"input-otp": "^1.2.4",
diff --git a/src/App.tsx b/src/App.tsx
index 53436598..8c93c050 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -48,13 +48,14 @@ const queryClient = new QueryClient({
});
// Get OS-specific default paths for Electron
-function getElectronDefaultPaths(): { fsPathProjects: string; fsPathConfig: string; fsPathTmp: string } {
+function getElectronDefaultPaths(): { fsPathProjects: string; fsPathConfig: string; fsPathTmp: string; fsPathPlugins: string } {
if (!globalThis.electron) {
// Browser defaults - use virtual filesystem paths
return {
fsPathProjects: "/projects",
fsPathConfig: "/config",
fsPathTmp: "/tmp",
+ fsPathPlugins: "/plugins",
};
}
@@ -68,6 +69,7 @@ function getElectronDefaultPaths(): { fsPathProjects: string; fsPathConfig: stri
fsPathProjects: "~/Documents/Projects",
fsPathConfig: "~/AppData/Local/shakespeare",
fsPathTmp: "~/AppData/Local/Temp/shakespeare",
+ fsPathPlugins: "~/AppData/Local/shakespeare/plugins",
};
} else if (platform.includes('mac')) {
// macOS
@@ -75,6 +77,7 @@ function getElectronDefaultPaths(): { fsPathProjects: string; fsPathConfig: stri
fsPathProjects: "~/Projects",
fsPathConfig: "~/Library/Application Support/shakespeare",
fsPathTmp: "/tmp/shakespeare",
+ fsPathPlugins: "~/Library/Application Support/shakespeare/plugins",
};
} else {
// Linux and other Unix-like systems
@@ -82,6 +85,7 @@ function getElectronDefaultPaths(): { fsPathProjects: string; fsPathConfig: stri
fsPathProjects: "~/Projects",
fsPathConfig: "~/.config/shakespeare",
fsPathTmp: "/tmp/shakespeare",
+ fsPathPlugins: "~/.config/shakespeare/plugins",
};
}
}
@@ -109,6 +113,7 @@ const defaultConfig: AppConfig = {
fsPathProjects: electronPaths.fsPathProjects,
fsPathConfig: electronPaths.fsPathConfig,
fsPathTmp: electronPaths.fsPathTmp,
+ fsPathPlugins: electronPaths.fsPathPlugins,
sentryDsn: import.meta.env.VITE_SENTRY_DSN || "",
sentryEnabled: true,
};
diff --git a/src/components/AppProvider.tsx b/src/components/AppProvider.tsx
index 3e98e979..5de70a95 100644
--- a/src/components/AppProvider.tsx
+++ b/src/components/AppProvider.tsx
@@ -38,6 +38,7 @@ const AppConfigSchema = z.object({
fsPathProjects: z.string().min(1),
fsPathConfig: z.string().min(1),
fsPathTmp: z.string().min(1),
+ fsPathPlugins: z.string().min(1),
sentryDsn: z.string(),
sentryEnabled: z.boolean(),
}) satisfies z.ZodType;
@@ -74,6 +75,7 @@ export function AppProvider(props: AppProviderProps) {
config.fsPathConfig = expandPath(config.fsPathConfig);
config.fsPathProjects = expandPath(config.fsPathProjects);
config.fsPathTmp = expandPath(config.fsPathTmp);
+ config.fsPathPlugins = expandPath(config.fsPathPlugins);
const appContextValue: AppContextType = {
config,
diff --git a/src/components/PluginsSection.tsx b/src/components/PluginsSection.tsx
new file mode 100644
index 00000000..4856ac35
--- /dev/null
+++ b/src/components/PluginsSection.tsx
@@ -0,0 +1,246 @@
+import { useState } from 'react';
+import { useTranslation } from 'react-i18next';
+import { Puzzle, Plus, Trash2, RefreshCw, Loader2, Check } from 'lucide-react';
+import { Button } from '@/components/ui/button';
+import { Input } from '@/components/ui/input';
+import { Label } from '@/components/ui/label';
+import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion';
+import { usePlugins } from '@/hooks/usePlugins';
+import { useToast } from '@/hooks/useToast';
+import { Alert, AlertDescription } from '@/components/ui/alert';
+
+export function PluginsSection() {
+ const { t } = useTranslation();
+ const { toast } = useToast();
+ const { plugins, skills, clonePlugin, syncPlugin, deletePlugin } = usePlugins();
+ const [gitUrl, setGitUrl] = useState('');
+
+ const handleAddPlugin = async () => {
+ if (!gitUrl.trim()) return;
+
+ try {
+ const pluginName = await clonePlugin.mutateAsync({ gitUrl: gitUrl.trim() });
+ toast({
+ title: t('pluginAdded'),
+ description: t('pluginAddedDescription', { name: pluginName }),
+ });
+ setGitUrl('');
+ } catch (error) {
+ toast({
+ title: t('pluginAddFailed'),
+ description: error instanceof Error ? error.message : String(error),
+ variant: 'destructive',
+ });
+ }
+ };
+
+ const handleSyncPlugin = async (pluginName: string) => {
+ try {
+ await syncPlugin.mutateAsync(pluginName);
+ toast({
+ title: t('pluginSynced'),
+ description: t('pluginSyncedDescription', { name: pluginName }),
+ });
+ } catch (error) {
+ toast({
+ title: t('pluginSyncFailed'),
+ description: error instanceof Error ? error.message : String(error),
+ variant: 'destructive',
+ });
+ }
+ };
+
+ const handleDeletePlugin = async (pluginName: string) => {
+ try {
+ await deletePlugin.mutateAsync(pluginName);
+ toast({
+ title: t('pluginDeleted'),
+ description: t('pluginDeletedDescription', { name: pluginName }),
+ });
+ } catch (error) {
+ toast({
+ title: t('pluginDeleteFailed'),
+ description: error instanceof Error ? error.message : String(error),
+ variant: 'destructive',
+ });
+ }
+ };
+
+ // Group skills by plugin
+ const skillsByPlugin = skills.reduce((acc, skill) => {
+ if (!acc[skill.plugin]) {
+ acc[skill.plugin] = [];
+ }
+ acc[skill.plugin].push(skill);
+ return acc;
+ }, {} as Record);
+
+ return (
+
+
+
+ {/* Add Plugin Section */}
+
+
+
+
+
+
+
+
+
+ setGitUrl(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === 'Enter' && gitUrl.trim()) {
+ handleAddPlugin();
+ }
+ }}
+ />
+
+
+
+ {t('pluginDescription')}
+
+
+
+
+
+
+ {/* Configured Plugins List */}
+ {plugins.length > 0 ? (
+
+ {plugins.map((pluginName) => {
+ const pluginSkills = skillsByPlugin[pluginName] || [];
+ const isSyncing = syncPlugin.isPending && syncPlugin.variables === pluginName;
+ const isDeleting = deletePlugin.isPending && deletePlugin.variables === pluginName;
+
+ return (
+
+
+
+
+
+
{pluginName}
+ {pluginSkills.length > 0 && (
+
+ ({pluginSkills.length} {pluginSkills.length === 1 ? 'skill' : 'skills'})
+
+ )}
+
+
+
+
+ {/* Skills List */}
+ {pluginSkills.length > 0 && (
+
+
+
+ {pluginSkills.map((skill) => (
+
+
+
{skill.name}
+
+ {skill.description}
+
+
+
+ ))}
+
+
+ )}
+
+ {pluginSkills.length === 0 && (
+
+
+ {t('noSkillsFound')}
+
+
+ )}
+
+ {/* Plugin Actions */}
+
+
+
+
+
+
+
+
+ );
+ })}
+
+ ) : (
+
+
+ {t('noPluginsConfigured')}
+
+
+ )}
+
+ );
+}
diff --git a/src/components/SentryProvider.test.tsx b/src/components/SentryProvider.test.tsx
index fcca4b97..31b0e487 100644
--- a/src/components/SentryProvider.test.tsx
+++ b/src/components/SentryProvider.test.tsx
@@ -38,6 +38,7 @@ describe('SentryProvider', () => {
fsPathProjects: '/projects',
fsPathConfig: '/config',
fsPathTmp: '/tmp',
+ fsPathPlugins: '/plugins',
};
render(
@@ -73,6 +74,7 @@ describe('SentryProvider', () => {
fsPathProjects: '/projects',
fsPathConfig: '/config',
fsPathTmp: '/tmp',
+ fsPathPlugins: '/plugins',
};
render(
@@ -109,6 +111,7 @@ describe('SentryProvider', () => {
fsPathProjects: '/projects',
fsPathConfig: '/config',
fsPathTmp: '/tmp',
+ fsPathPlugins: '/plugins',
};
render(
@@ -148,6 +151,7 @@ describe('SentryProvider', () => {
fsPathProjects: '/projects',
fsPathConfig: '/config',
fsPathTmp: '/tmp',
+ fsPathPlugins: '/plugins',
};
render(
diff --git a/src/components/SessionManagerProvider.tsx b/src/components/SessionManagerProvider.tsx
index 558a4c8b..38ade70f 100644
--- a/src/components/SessionManagerProvider.tsx
+++ b/src/components/SessionManagerProvider.tsx
@@ -17,7 +17,7 @@ interface SessionManagerProviderProps {
*/
export function SessionManagerProvider({ children }: SessionManagerProviderProps) {
const { fs } = useFS();
- const { projectsPath } = useFSPaths();
+ const { projectsPath, pluginsPath } = useFSPaths();
const { settings } = useAISettings();
const { models } = useProviderModels();
const { user, metadata } = useCurrentUser();
@@ -26,8 +26,8 @@ export function SessionManagerProvider({ children }: SessionManagerProviderProps
const sessionManager = useMemo(() => {
const getProviderModels = () => models;
const getCurrentUser = () => ({ user, metadata });
- return new SessionManager(fs, settings, getProviderModels, getCurrentUser, config.corsProxy, projectsPath);
- }, [fs, settings, models, user, metadata, config.corsProxy, projectsPath]);
+ return new SessionManager(fs, settings, getProviderModels, getCurrentUser, config.corsProxy, projectsPath, pluginsPath);
+ }, [fs, settings, models, user, metadata, config.corsProxy, projectsPath, pluginsPath]);
// Cleanup on unmount
useEffect(() => {
diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx
index d18a9717..3b65c84b 100644
--- a/src/components/Shakespeare/ChatPane.tsx
+++ b/src/components/Shakespeare/ChatPane.tsx
@@ -34,6 +34,7 @@ import { NostrPublishEventsTool } from '@/lib/tools/NostrPublishEventsTool';
import { ShellTool } from '@/lib/tools/ShellTool';
import { TypecheckTool } from '@/lib/tools/TypecheckTool';
import { ReadConsoleMessagesTool } from '@/lib/tools/ReadConsoleMessagesTool';
+import { SkillTool } from '@/lib/tools/SkillTool';
import { ProjectPreviewConsoleError } from '@/lib/consoleMessages';
import { toolToOpenAI } from '@/lib/tools/openai-adapter';
import { Tool } from '@/lib/tools/Tool';
@@ -78,7 +79,7 @@ export const ChatPane = forwardRef(({
const { user } = useCurrentUser();
const { models } = useProviderModels();
const { config } = useAppContext();
- const { projectsPath, tmpPath } = useFSPaths();
+ const { projectsPath, tmpPath, pluginsPath } = useFSPaths();
const [showScrollToBottom, setShowScrollToBottom] = useState(false);
const [isDragOver, setIsDragOver] = useState(false);
const [scrolledProjects] = useState(() => new Set());
@@ -167,6 +168,7 @@ export const ChatPane = forwardRef(({
nostr_publish_events: new NostrPublishEventsTool(),
shell: new ShellTool(fs, cwd, git, projectsPath, user?.signer),
read_console_messages: new ReadConsoleMessagesTool(),
+ skill: new SkillTool(fs, pluginsPath),
};
// Add deploy tool only if user is logged in
@@ -178,7 +180,7 @@ export const ChatPane = forwardRef(({
}
return baseTools;
- }, [fs, git, cwd, user, projectId, projectsPath, tmpPath, handleFileChanged]);
+ }, [fs, git, cwd, user, projectId, projectsPath, tmpPath, pluginsPath, handleFileChanged]);
// Convert tools to OpenAI format
const tools = useMemo(() => {
diff --git a/src/contexts/AppContext.ts b/src/contexts/AppContext.ts
index 7fd99395..de186fe5 100644
--- a/src/contexts/AppContext.ts
+++ b/src/contexts/AppContext.ts
@@ -38,6 +38,8 @@ export interface AppConfig {
fsPathConfig: string;
/** VFS path for temporary files directory */
fsPathTmp: string;
+ /** VFS path for plugins directory */
+ fsPathPlugins: string;
/** Sentry DSN for error reporting (empty string = disabled) */
sentryDsn: string;
/** Whether the user has enabled Sentry error reporting */
diff --git a/src/hooks/useAIProjectId.test.ts b/src/hooks/useAIProjectId.test.ts
index b4c10752..42b5eb19 100644
--- a/src/hooks/useAIProjectId.test.ts
+++ b/src/hooks/useAIProjectId.test.ts
@@ -56,6 +56,7 @@ describe('useAIProjectId', () => {
fsPathProjects: '/projects',
fsPathConfig: '/config',
fsPathTmp: '/tmp',
+ fsPathPlugins: '/plugins',
sentryDsn: '',
sentryEnabled: false,
},
diff --git a/src/hooks/useFSPaths.ts b/src/hooks/useFSPaths.ts
index 7088a134..d9ec08ea 100644
--- a/src/hooks/useFSPaths.ts
+++ b/src/hooks/useFSPaths.ts
@@ -15,5 +15,7 @@ export function useFSPaths() {
configPath: config.fsPathConfig,
/** Temporary files directory path (default: /tmp) */
tmpPath: config.fsPathTmp,
+ /** Plugins directory path (default: /plugins) */
+ pluginsPath: config.fsPathPlugins,
};
}
diff --git a/src/hooks/useGit.test.ts b/src/hooks/useGit.test.ts
index 288d2fa1..748bf7cb 100644
--- a/src/hooks/useGit.test.ts
+++ b/src/hooks/useGit.test.ts
@@ -48,6 +48,7 @@ function createWrapper(corsProxy: string) {
fsPathProjects: '/projects',
fsPathConfig: '/config',
fsPathTmp: '/tmp',
+ fsPathPlugins: '/plugins',
sentryDsn: '',
sentryEnabled: false,
};
diff --git a/src/hooks/usePlugins.ts b/src/hooks/usePlugins.ts
new file mode 100644
index 00000000..b0a3f1bb
--- /dev/null
+++ b/src/hooks/usePlugins.ts
@@ -0,0 +1,127 @@
+import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
+import { useFS } from './useFS';
+import { useFSPaths } from './useFSPaths';
+import { getPlugins, getAllSkills, deletePlugin as deletePluginFn } from '@/lib/plugins';
+import { useGit } from './useGit';
+import { join } from 'path-browserify';
+
+/**
+ * Hook to manage plugins and skills
+ */
+export function usePlugins() {
+ const { fs } = useFS();
+ const { pluginsPath } = useFSPaths();
+ const queryClient = useQueryClient();
+ const { git } = useGit();
+
+ // Query to get all plugins
+ const pluginsQuery = useQuery({
+ queryKey: ['plugins', pluginsPath],
+ queryFn: async () => {
+ return await getPlugins(fs, pluginsPath);
+ },
+ });
+
+ // Query to get all skills
+ const skillsQuery = useQuery({
+ queryKey: ['skills', pluginsPath],
+ queryFn: async () => {
+ return await getAllSkills(fs, pluginsPath);
+ },
+ });
+
+ // Mutation to clone a plugin from a git URL
+ const clonePlugin = useMutation({
+ mutationFn: async ({ gitUrl, pluginName }: { gitUrl: string; pluginName?: string }) => {
+ // Extract plugin name from git URL if not provided
+ let name = pluginName;
+ if (!name) {
+ // Extract from URL: https://github.com/user/repo.git -> repo
+ const match = gitUrl.match(/\/([^/]+?)(\.git)?$/);
+ if (!match) {
+ throw new Error('Invalid git URL');
+ }
+ name = match[1];
+ }
+
+ const pluginDir = join(pluginsPath, name);
+
+ // Ensure plugins directory exists
+ try {
+ await fs.stat(pluginsPath);
+ } catch {
+ await fs.mkdir(pluginsPath, { recursive: true });
+ }
+
+ // Check if plugin already exists
+ try {
+ await fs.stat(pluginDir);
+ throw new Error(`Plugin "${name}" already exists`);
+ } catch (error) {
+ // Plugin doesn't exist, continue
+ if (error instanceof Error && error.message.includes('already exists')) {
+ throw error;
+ }
+ }
+
+ // Clone the repository
+ await git.clone({
+ dir: pluginDir,
+ url: gitUrl,
+ depth: 1,
+ singleBranch: true,
+ });
+
+ return name;
+ },
+ onSuccess: () => {
+ // Invalidate queries to refresh the lists
+ queryClient.invalidateQueries({ queryKey: ['plugins', pluginsPath] });
+ queryClient.invalidateQueries({ queryKey: ['skills', pluginsPath] });
+ },
+ });
+
+ // Mutation to sync (pull) a plugin
+ const syncPlugin = useMutation({
+ mutationFn: async (pluginName: string) => {
+ const pluginDir = join(pluginsPath, pluginName);
+
+ // Pull latest changes
+ await git.pull({
+ dir: pluginDir,
+ singleBranch: true,
+ fastForward: true,
+ });
+
+ return pluginName;
+ },
+ onSuccess: () => {
+ // Invalidate queries to refresh the lists
+ queryClient.invalidateQueries({ queryKey: ['plugins', pluginsPath] });
+ queryClient.invalidateQueries({ queryKey: ['skills', pluginsPath] });
+ },
+ });
+
+ // Mutation to delete a plugin
+ const deletePlugin = useMutation({
+ mutationFn: async (pluginName: string) => {
+ await deletePluginFn(fs, pluginsPath, pluginName);
+ return pluginName;
+ },
+ onSuccess: () => {
+ // Invalidate queries to refresh the lists
+ queryClient.invalidateQueries({ queryKey: ['plugins', pluginsPath] });
+ queryClient.invalidateQueries({ queryKey: ['skills', pluginsPath] });
+ },
+ });
+
+ return {
+ plugins: pluginsQuery.data || [],
+ isLoadingPlugins: pluginsQuery.isLoading,
+ skills: skillsQuery.data || [],
+ isLoadingSkills: skillsQuery.isLoading,
+ clonePlugin,
+ syncPlugin,
+ deletePlugin,
+ };
+}
diff --git a/src/lib/SessionManager.ts b/src/lib/SessionManager.ts
index 9d247923..694b5031 100644
--- a/src/lib/SessionManager.ts
+++ b/src/lib/SessionManager.ts
@@ -63,6 +63,7 @@ export class SessionManager {
private getCurrentUser?: () => { user?: NUser; metadata?: NostrMetadata };
private corsProxy?: string;
private projectsPath: string;
+ private pluginsPath?: string;
constructor(
fs: JSRuntimeFS,
@@ -71,12 +72,14 @@ export class SessionManager {
getCurrentUser?: () => { user?: NUser; metadata?: NostrMetadata },
corsProxy?: string,
projectsPath = '/projects',
+ pluginsPath?: string,
) {
this.fs = fs;
this.aiSettings = aiSettings;
this.getProviderModels = getProviderModels;
this.getCurrentUser = getCurrentUser;
this.projectsPath = projectsPath;
+ this.pluginsPath = pluginsPath;
this.corsProxy = corsProxy;
}
@@ -242,6 +245,7 @@ export class SessionManager {
name: "Shakespeare",
profession: "software extraordinaire",
tools: Object.values(session.tools),
+ pluginsPath: this.pluginsPath,
user,
metadata,
});
diff --git a/src/lib/plugins.test.ts b/src/lib/plugins.test.ts
new file mode 100644
index 00000000..5bfa4133
--- /dev/null
+++ b/src/lib/plugins.test.ts
@@ -0,0 +1,208 @@
+import { describe, it, expect, beforeEach } from 'vitest';
+import { LightningFSAdapter } from './LightningFSAdapter';
+import LightningFS from '@isomorphic-git/lightning-fs';
+import {
+ getPlugins,
+ getPluginSkills,
+ getAllSkills,
+ findSkill,
+ readSkillContent,
+ isValidSkillName,
+} from './plugins';
+
+describe('plugins', () => {
+ let fs: LightningFSAdapter;
+
+ beforeEach(() => {
+ const lightningFS = new LightningFS('test-plugins-fs');
+ fs = new LightningFSAdapter(lightningFS.promises);
+ });
+
+ describe('isValidSkillName', () => {
+ it('should validate alphanumeric lowercase names', () => {
+ expect(isValidSkillName('test')).toBe(true);
+ expect(isValidSkillName('test123')).toBe(true);
+ expect(isValidSkillName('abc')).toBe(true);
+ });
+
+ it('should reject invalid names', () => {
+ expect(isValidSkillName('Test')).toBe(false);
+ expect(isValidSkillName('test-name')).toBe(false);
+ expect(isValidSkillName('test_name')).toBe(false);
+ expect(isValidSkillName('test name')).toBe(false);
+ expect(isValidSkillName('test-123')).toBe(false);
+ });
+ });
+
+ describe('getPlugins', () => {
+ it('should return empty array when plugins directory does not exist', async () => {
+ const plugins = await getPlugins(fs, '/plugins');
+ expect(plugins).toEqual([]);
+ });
+
+ it('should return list of plugin directories', async () => {
+ await fs.mkdir('/plugins/plugin1', { recursive: true });
+ await fs.mkdir('/plugins/plugin2', { recursive: true });
+ await fs.writeFile('/plugins/file.txt', 'not a directory');
+
+ const plugins = await getPlugins(fs, '/plugins');
+ expect(plugins).toContain('plugin1');
+ expect(plugins).toContain('plugin2');
+ expect(plugins).not.toContain('file.txt');
+ });
+ });
+
+ describe('getPluginSkills', () => {
+ it('should return empty array when plugin has no skills', async () => {
+ await fs.mkdir('/plugins/plugin1', { recursive: true });
+
+ const skills = await getPluginSkills(fs, '/plugins', 'plugin1');
+ expect(skills).toEqual([]);
+ });
+
+ it('should return skills with valid SKILL.md files', async () => {
+ const skillPath = '/plugins/testplugin/skills/myskill';
+ await fs.mkdir(skillPath, { recursive: true });
+ await fs.writeFile(
+ `${skillPath}/SKILL.md`,
+ `---
+name: myskill
+description: A test skill
+---
+
+# My Skill
+
+This is a test skill.`
+ );
+
+ const skills = await getPluginSkills(fs, '/plugins', 'testplugin');
+ expect(skills).toHaveLength(1);
+ expect(skills[0]).toEqual({
+ name: 'myskill',
+ description: 'A test skill',
+ path: skillPath,
+ plugin: 'testplugin',
+ });
+ });
+
+ it('should skip skills with invalid names', async () => {
+ const skillPath = '/plugins/testplugin/skills/InvalidSkill';
+ await fs.mkdir(skillPath, { recursive: true });
+ await fs.writeFile(
+ `${skillPath}/SKILL.md`,
+ `---
+name: InvalidSkill
+description: Has uppercase letters
+---
+
+Content`
+ );
+
+ const skills = await getPluginSkills(fs, '/plugins', 'testplugin');
+ expect(skills).toEqual([]);
+ });
+
+ it('should skip skills missing required frontmatter', async () => {
+ const skillPath = '/plugins/testplugin/skills/incomplete';
+ await fs.mkdir(skillPath, { recursive: true });
+ await fs.writeFile(
+ `${skillPath}/SKILL.md`,
+ `---
+name: incomplete
+---
+
+Missing description`
+ );
+
+ const skills = await getPluginSkills(fs, '/plugins', 'testplugin');
+ expect(skills).toEqual([]);
+ });
+ });
+
+ describe('getAllSkills', () => {
+ it('should return skills from all plugins', async () => {
+ // Plugin 1
+ const skill1Path = '/plugins/plugin1/skills/skill1';
+ await fs.mkdir(skill1Path, { recursive: true });
+ await fs.writeFile(
+ `${skill1Path}/SKILL.md`,
+ `---
+name: skill1
+description: First skill
+---
+
+Content`
+ );
+
+ // Plugin 2
+ const skill2Path = '/plugins/plugin2/skills/skill2';
+ await fs.mkdir(skill2Path, { recursive: true });
+ await fs.writeFile(
+ `${skill2Path}/SKILL.md`,
+ `---
+name: skill2
+description: Second skill
+---
+
+Content`
+ );
+
+ const skills = await getAllSkills(fs, '/plugins');
+ expect(skills).toHaveLength(2);
+ expect(skills.map((s) => s.name)).toContain('skill1');
+ expect(skills.map((s) => s.name)).toContain('skill2');
+ });
+ });
+
+ describe('findSkill', () => {
+ it('should find a skill by name', async () => {
+ const skillPath = '/plugins/testplugin/skills/findme';
+ await fs.mkdir(skillPath, { recursive: true });
+ await fs.writeFile(
+ `${skillPath}/SKILL.md`,
+ `---
+name: findme
+description: Find this skill
+---
+
+Content`
+ );
+
+ const skill = await findSkill(fs, '/plugins', 'findme');
+ expect(skill).not.toBeNull();
+ expect(skill?.name).toBe('findme');
+ });
+
+ it('should return null when skill not found', async () => {
+ const skill = await findSkill(fs, '/plugins', 'nonexistent');
+ expect(skill).toBeNull();
+ });
+ });
+
+ describe('readSkillContent', () => {
+ it('should read the full SKILL.md content', async () => {
+ const skillPath = '/plugins/testplugin/skills/myskill';
+ await fs.mkdir(skillPath, { recursive: true });
+ const content = `---
+name: myskill
+description: A test skill
+---
+
+# My Skill
+
+This is the skill content.`;
+
+ await fs.writeFile(`${skillPath}/SKILL.md`, content);
+
+ const skill = {
+ name: 'myskill',
+ description: 'A test skill',
+ path: skillPath,
+ plugin: 'testplugin',
+ };
+
+ const readContent = await readSkillContent(fs, skill);
+ expect(readContent).toBe(content);
+ });
+ });
+});
diff --git a/src/lib/plugins.ts b/src/lib/plugins.ts
new file mode 100644
index 00000000..e087e22e
--- /dev/null
+++ b/src/lib/plugins.ts
@@ -0,0 +1,167 @@
+import { join } from 'path-browserify';
+import matter from 'gray-matter';
+import type { JSRuntimeFS } from './JSRuntime';
+
+export interface Skill {
+ /** Skill name (alphanumeric lowercase only) */
+ name: string;
+ /** Human-readable description of what the skill does */
+ description: string;
+ /** Full path to the skill directory */
+ path: string;
+ /** Plugin name that contains this skill */
+ plugin: string;
+}
+
+export interface SkillFrontmatter {
+ name: string;
+ description: string;
+ [key: string]: unknown;
+}
+
+/**
+ * Validates a skill name (alphanumeric lowercase only)
+ */
+export function isValidSkillName(name: string): boolean {
+ return /^[a-z0-9]+$/.test(name);
+}
+
+/**
+ * Get all plugins from the plugins directory
+ */
+export async function getPlugins(fs: JSRuntimeFS, pluginsPath: string): Promise {
+ try {
+ const entries = await fs.readdir(pluginsPath);
+ const plugins: string[] = [];
+
+ for (const entry of entries) {
+ const stat = await fs.stat(join(pluginsPath, entry));
+ if (stat.isDirectory()) {
+ plugins.push(entry);
+ }
+ }
+
+ return plugins;
+ } catch {
+ // Plugins directory doesn't exist yet
+ return [];
+ }
+}
+
+/**
+ * Get all skills from a plugin
+ */
+export async function getPluginSkills(
+ fs: JSRuntimeFS,
+ pluginsPath: string,
+ pluginName: string
+): Promise {
+ const skills: Skill[] = [];
+ const skillsDir = join(pluginsPath, pluginName, 'skills');
+
+ try {
+ const skillDirs = await fs.readdir(skillsDir);
+
+ for (const skillDir of skillDirs) {
+ const skillPath = join(skillsDir, skillDir);
+ const stat = await fs.stat(skillPath);
+
+ if (!stat.isDirectory()) continue;
+
+ const skillFilePath = join(skillPath, 'SKILL.md');
+
+ try {
+ const skillContent = await fs.readFile(skillFilePath, 'utf8');
+ const { data } = matter(skillContent);
+
+ const frontmatter = data as SkillFrontmatter;
+
+ // Validate required fields
+ if (!frontmatter.name || !frontmatter.description) {
+ console.warn(`Skill at ${skillPath} missing required frontmatter fields (name, description)`);
+ continue;
+ }
+
+ // Validate skill name format
+ if (!isValidSkillName(frontmatter.name)) {
+ console.warn(`Skill at ${skillPath} has invalid name "${frontmatter.name}" (must be alphanumeric lowercase only)`);
+ continue;
+ }
+
+ skills.push({
+ name: frontmatter.name,
+ description: frontmatter.description,
+ path: skillPath,
+ plugin: pluginName,
+ });
+ } catch {
+ // SKILL.md not found or invalid, skip this directory
+ continue;
+ }
+ }
+ } catch {
+ // Skills directory doesn't exist for this plugin
+ return [];
+ }
+
+ return skills;
+}
+
+/**
+ * Get all skills from all plugins
+ */
+export async function getAllSkills(fs: JSRuntimeFS, pluginsPath: string): Promise {
+ const plugins = await getPlugins(fs, pluginsPath);
+ const allSkills: Skill[] = [];
+
+ for (const plugin of plugins) {
+ const skills = await getPluginSkills(fs, pluginsPath, plugin);
+ allSkills.push(...skills);
+ }
+
+ return allSkills;
+}
+
+/**
+ * Find a skill by name across all plugins
+ */
+export async function findSkill(
+ fs: JSRuntimeFS,
+ pluginsPath: string,
+ skillName: string
+): Promise {
+ const skills = await getAllSkills(fs, pluginsPath);
+ return skills.find(skill => skill.name === skillName) || null;
+}
+
+/**
+ * Read the SKILL.md content for a skill
+ */
+export async function readSkillContent(fs: JSRuntimeFS, skill: Skill): Promise {
+ const skillFilePath = join(skill.path, 'SKILL.md');
+ return await fs.readFile(skillFilePath, 'utf8');
+}
+
+/**
+ * Delete a plugin directory
+ */
+export async function deletePlugin(fs: JSRuntimeFS, pluginsPath: string, pluginName: string): Promise {
+ const pluginPath = join(pluginsPath, pluginName);
+
+ // Recursively delete the plugin directory
+ async function rmrf(path: string): Promise {
+ const stat = await fs.stat(path);
+
+ if (stat.isDirectory()) {
+ const entries = await fs.readdir(path);
+ for (const entry of entries) {
+ await rmrf(join(path, entry));
+ }
+ await fs.rmdir(path);
+ } else {
+ await fs.unlink(path);
+ }
+ }
+
+ await rmrf(pluginPath);
+}
diff --git a/src/lib/system.ts b/src/lib/system.ts
index dd9ab81c..4b5056e1 100644
--- a/src/lib/system.ts
+++ b/src/lib/system.ts
@@ -4,6 +4,7 @@ import { join } from "path-browserify";
import OpenAI from "openai";
import { nip19 } from "nostr-tools";
import { JSRuntimeFS } from "./JSRuntime";
+import { getAllSkills } from "./plugins";
export interface MakeSystemPromptOpts {
name: string;
@@ -12,12 +13,13 @@ export interface MakeSystemPromptOpts {
mode: "init" | "agent";
fs: JSRuntimeFS;
cwd: string;
+ pluginsPath?: string;
user?: NUser;
metadata?: NostrMetadata;
}
export async function makeSystemPrompt(opts: MakeSystemPromptOpts): Promise {
- const { name, profession, tools, mode, fs, cwd, user, metadata } = opts;
+ const { name, profession, tools, mode, fs, cwd, pluginsPath, user, metadata } = opts;
let system = mode === "init"
? `You are ${name}, an expert ${profession}. The files in the current directory are a template. Your goal is to transform this template into a working project according to the user's request.`
@@ -180,6 +182,34 @@ The user expects you to handle all technical implementation while they focus on
}
}
+ // Add skills section
+ system += "\n\n## Skills\n\n";
+
+ if (pluginsPath) {
+ try {
+ const skills = await getAllSkills(fs, pluginsPath);
+
+ if (skills.length > 0) {
+ system += "You have access to the following skills. **Skills MUST be used whenever applicable** by calling the `skill` tool with the skill name.\n\n";
+ system += "Available skills:\n\n";
+
+ for (const skill of skills) {
+ system += `- **${skill.name}**: ${skill.description}\n - Plugin: ${skill.plugin}\n - Path: ${skill.path}\n`;
+ }
+
+ system += `\n**Important**: When a task matches a skill's description, you MUST use that skill by calling the skill tool. Skills contain specialized workflows and best practices for specific tasks.\n`;
+ } else {
+ system += "No skills are currently configured. Skills are reusable AI workflows that can be added via plugins.\n";
+ }
+ } catch {
+ system += "No skills are currently configured. Skills are reusable AI workflows that can be added via plugins.\n";
+ }
+ } else {
+ system += "No skills are currently configured. Skills are reusable AI workflows that can be added via plugins.\n";
+ }
+
+ system += `\nUsers can configure skills in Settings > AI (${location.origin}/settings/ai) by adding plugins that contain skills.`;
+
// Add README.md if it exists
try {
const readmePath = join(cwd, "README.md");
diff --git a/src/lib/tools/SkillTool.ts b/src/lib/tools/SkillTool.ts
new file mode 100644
index 00000000..7806f019
--- /dev/null
+++ b/src/lib/tools/SkillTool.ts
@@ -0,0 +1,55 @@
+import { z } from 'zod';
+import type { Tool } from './Tool';
+import type { JSRuntimeFS } from '../JSRuntime';
+import { findSkill, readSkillContent } from '../plugins';
+
+interface SkillParams {
+ name: string;
+}
+
+export class SkillTool implements Tool {
+ private fs: JSRuntimeFS;
+ private pluginsPath: string;
+
+ readonly description = 'Load and execute a skill from the configured plugins. Skills are reusable AI workflows that can be invoked by name.';
+
+ readonly inputSchema = z.object({
+ name: z.string().describe('The name of the skill to execute (alphanumeric lowercase only)'),
+ });
+
+ constructor(fs: JSRuntimeFS, pluginsPath: string) {
+ this.fs = fs;
+ this.pluginsPath = pluginsPath;
+ }
+
+ async execute(args: SkillParams): Promise {
+ const { name } = args;
+
+ try {
+ // Find the skill across all plugins
+ const skill = await findSkill(this.fs, this.pluginsPath, name);
+
+ if (!skill) {
+ throw new Error(`Skill "${name}" not found. Use the skill tool to list available skills or configure plugins in Settings > AI.`);
+ }
+
+ // Read and return the skill content
+ const content = await readSkillContent(this.fs, skill);
+
+ return `# Skill: ${skill.name}
+
+**Plugin**: ${skill.plugin}
+**Description**: ${skill.description}
+**Path**: ${skill.path}
+
+---
+
+${content}`;
+ } catch (error) {
+ if (error instanceof Error) {
+ throw error;
+ }
+ throw new Error(`Failed to execute skill "${name}": ${String(error)}`);
+ }
+ }
+}
diff --git a/src/locales/en.json b/src/locales/en.json
index 594414fa..01165bac 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -453,5 +453,34 @@
"invalidGiftCard": "Invalid Gift Card",
"giftCardNotFound": "This gift card could not be found.",
"alreadyRedeemed": "Already Redeemed",
- "giftCardAlreadyRedeemed": "This gift card has already been redeemed."
+ "giftCardAlreadyRedeemed": "This gift card has already been redeemed.",
+ "plugins": "Plugins",
+ "addPlugin": "Add Plugin",
+ "gitRepositoryUrl": "Git Repository URL",
+ "pluginDescription": "Plugins can contain skills that extend the AI's capabilities with specialized workflows.",
+ "cloning": "Cloning...",
+ "pluginAdded": "Plugin Added",
+ "pluginAddedDescription": "Plugin \"{{name}}\" has been added successfully.",
+ "pluginAddFailed": "Failed to Add Plugin",
+ "sync": "Sync",
+ "syncing": "Syncing...",
+ "pluginSynced": "Plugin Synced",
+ "pluginSyncedDescription": "Plugin \"{{name}}\" has been synced successfully.",
+ "pluginSyncFailed": "Failed to Sync Plugin",
+ "pluginDeleted": "Plugin Deleted",
+ "pluginDeletedDescription": "Plugin \"{{name}}\" has been deleted successfully.",
+ "pluginDeleteFailed": "Failed to Delete Plugin",
+ "skills": "Skills",
+ "noSkillsFound": "No skills found in this plugin.",
+ "noPluginsConfigured": "No plugins configured. Add a plugin to get started.",
+ "pluginsDirectory": "Plugins Directory",
+ "pluginsDirectoryDescription": "Directory where plugins are stored in the virtual filesystem.",
+ "filesystemPaths": "Filesystem Paths",
+ "projectsDirectory": "Projects Directory",
+ "projectsDirectoryDescription": "Directory where projects are stored in the virtual filesystem.",
+ "configDirectory": "Config Directory",
+ "configDirectoryDescription": "Directory where configuration files are stored in the virtual filesystem.",
+ "temporaryDirectory": "Temporary Directory",
+ "temporaryDirectoryDescription": "Directory for temporary files in the virtual filesystem.",
+ "deleting": "Deleting..."
}
diff --git a/src/pages/AISettings.tsx b/src/pages/AISettings.tsx
index 1b0b99d6..c36ddaca 100644
--- a/src/pages/AISettings.tsx
+++ b/src/pages/AISettings.tsx
@@ -36,6 +36,7 @@ import { useNavigate, Link } from 'react-router-dom';
import type { AIProvider } from '@/contexts/AISettingsContext';
import { AI_PROVIDER_PRESETS, type PresetProvider } from '@/lib/aiProviderPresets';
import { ExternalFavicon } from '@/components/ExternalFavicon';
+import { PluginsSection } from '@/components/PluginsSection';
interface SortableProviderItemProps {
provider: AIProvider;
@@ -564,6 +565,9 @@ export function AISettings() {
+
+ {/* Plugins Section */}
+
{/* Render credits dialog outside of accordion structure */}
diff --git a/src/pages/SystemSettings.tsx b/src/pages/SystemSettings.tsx
index d7938e33..cf55b98d 100644
--- a/src/pages/SystemSettings.tsx
+++ b/src/pages/SystemSettings.tsx
@@ -29,6 +29,7 @@ export function SystemSettings() {
const [fsPathProjectsInput, setFsPathProjectsInput] = useState(config.fsPathProjects);
const [fsPathConfigInput, setFsPathConfigInput] = useState(config.fsPathConfig);
const [fsPathTmpInput, setFsPathTmpInput] = useState(config.fsPathTmp);
+ const [fsPathPluginsInput, setFsPathPluginsInput] = useState(config.fsPathPlugins);
const [sentryDsnInput, setSentryDsnInput] = useState(config.sentryDsn);
// Service Worker state
@@ -571,6 +572,29 @@ export function SystemSettings() {
{t('temporaryDirectoryDescription')}
+
+
+
+
{
+ const value = e.target.value;
+ setFsPathPluginsInput(value);
+ updateConfig((current) => ({
+ ...current,
+ fsPathPlugins: value,
+ }));
+ }}
+ />
+
+ {t('pluginsDirectoryDescription')}
+
+
diff --git a/src/test/TestApp.tsx b/src/test/TestApp.tsx
index 0f73ebbc..3548f159 100644
--- a/src/test/TestApp.tsx
+++ b/src/test/TestApp.tsx
@@ -47,6 +47,7 @@ export function TestApp({ children }: TestAppProps) {
fsPathProjects: '/projects',
fsPathConfig: '/config',
fsPathTmp: '/tmp',
+ fsPathPlugins: '/plugins',
sentryDsn: '',
sentryEnabled: false,
};