mirror of
https://gitlab.com/soapbox-pub/shakespeare.git
synced 2026-12-06 00:27:24 +00:00
Implement plugins system / skills
This commit is contained in:
23 files changed
+1310
-8
No files matched your search
@@ -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<SkillParams> {
|
||||
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<string> {
|
||||
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)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user