flowtools-description-to-plugin
Convert natural language descriptions into Flow Tools plugin implementations.
- License 许可
- MIT
- 最近更新
- 2026-05-15
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- flowtools-description-to-plugin
- metadata
- { "authors": "FlowToolsOrg", "version": "0.0.1" }
- description
- Convert natural language descriptions into Flow Tools plugin implementations.
03 SKILL.md 正文
Description to Plugin Skill
Convert natural language descriptions into Flow Tools plugin implementations.
When to Use
- User provides a feature description to implement
- Converting requirements into plugin code
- Creating new plugins from specifications
Workflow
1. Parse Description
Extract key information from the description:
- Functionality: What the plugin does
- Inputs: What data it needs
- Outputs: What it returns
- Capabilities: What system features it uses (storage, network, etc.)
2. Determine Plugin Type
Based on the description, choose:
appplugin: If it needs persistent UI, user interaction, or visual displaytoolplugin: If it's a headless utility, data processor, or CLI tool
3. Design Input Schema
Create Zod schema for inputs:
import { z } from 'zod'
const inputSchema = z.object({
// Required inputs
text: z.string().describe('Input text to process'),
// Optional inputs with defaults
count: z.number().default(1).describe('Number of repetitions'),
format: z.enum(['json', 'text']).default('json').describe('Output format'),
})
4. Identify Required Permissions
Map capabilities to permissions:
| Capability | Permission | Use Case |
|---|---|---|
| Storage | storage |
Save/load data, preferences |
| Network | network |
HTTP requests, API calls |
| Clipboard | clipboard |
Copy/paste operations |
| Notification | notification |
User alerts |
| File System | fs |
File read/write |
| Database | db |
Structured data storage |
5. Implement Plugin
For App Plugins (with UI)
You should use the @flowtools/ui package to create the UI components, more details can be found in the flowtools-ui skill, and you must read it.
import { useState } from 'react'
import { definePlugin, useCapability } from '@flowtools/sdk'
import { result } from '@flowtools/sdk/result'
import { Button, TextArea } from '@flowtools/ui'
import { z } from 'zod'
const inputSchema = z.object({
initialData: z.string().default('').describe('Initial data to display'),
})
export default definePlugin({
type: 'app',
meta: {
id: 'my-feature',
name: 'My Feature',
version: '0.1.0',
permissions: ['storage'],
},
inputSchema,
async run(ctx, input) {
// CLI/headless execution
return result.json({ processed: input.initialData })
},
setup() {
return function Panel() {
const { storage } = useCapability()
const [data, setData] = useState('')
const handleSave = () => {
storage.set('data', data)
}
return (
<div>
<TextArea value={data} onChange={e => setData(e.target.value)} />
<Button onPress={handleSave}>Save</Button>
</div>
)
}
},
})
For Tool Plugins (headless)
import { definePlugin } from '@flowtools/sdk'
import { result } from '@flowtools/sdk/result'
import { z } from 'zod'
const inputSchema = z.object({
text: z.string().describe('Text to process'),
operation: z.enum(['uppercase', 'lowercase', 'reverse']).describe('Operation to perform'),
})
export default definePlugin({
type: 'tool',
meta: {
id: 'text-processor',
name: 'Text Processor',
version: '0.1.0',
permissions: [],
},
inputSchema,
async run(ctx, input) {
ctx.log('info', 'Processing text', { operation: input.operation })
let result_text: string
switch (input.operation) {
case 'uppercase':
result_text = input.text.toUpperCase()
break
case 'lowercase':
result_text = input.text.toLowerCase()
break
case 'reverse':
result_text = input.text.split('').reverse().join('')
break
}
return result.text(result_text)
},
})
6. Generate File Structure
Create the plugin directory:
plugins/
plugin-{kebab-case-name}/
index.tsx # For app plugins
index.ts # For tool plugins
7. Validate Implementation
Check all requirements:
- [ ] Plugin ID is kebab-case and unique
- [ ]
inputSchemadefined with Zod - [ ] All inputs have
.describe()for CLI help - [ ]
run()returnsresult.*structured response - [ ] Permissions match actual capability usage
- [ ] No direct access to Tauri/Node APIs
Description Parsing Examples
Example 1: "Create a password generator"
Parsed:
- Functionality: Generate random passwords
- Inputs: Length, character types
- Output: Generated password string
- Type:
tool(headless utility)
Implementation:
const inputSchema = z.object({
length: z.number().default(16).describe('Password length'),
includeNumbers: z.boolean().default(true).describe('Include numbers'),
includeSymbols: z.boolean().default(true).describe('Include symbols'),
})
Example 2: "Build a todo list with save functionality"
Parsed:
- Functionality: Manage todo items with persistence
- Inputs: Todo text, completion status
- Output: Todo list display
- Type:
app(persistent UI with storage)
Implementation:
const inputSchema = z.object({
initialTodos: z.array(z.string()).default([]).describe('Initial todo items'),
})
// Use definePluginStore for state management
const todoStore = definePluginStore({
initialState: { todos: [] as string[] },
actions: set => ({
addTodo: (text: string) => set(state => ({ todos: [...state.todos, text] })),
removeTodo: (index: number) => set(state => ({
todos: state.todos.filter((_, i) => i !== index)
})),
}),
})
Example 3: "Make a URL shortener using an API"
Parsed:
- Functionality: Shorten URLs via external API
- Input: Long URL
- Output: Shortened URL
- Type:
tool(network utility) - Permission:
network
Implementation:
const inputSchema = z.object({
url: z.string().url().describe('URL to shorten'),
})
// Requires 'network' permission
meta: {
permissions: ['network'],
}
Common Patterns
State Management (App Plugins)
Use definePluginStore for complex state:
const store = definePluginStore({
initialState: {
items: [] as Item[],
loading: false,
},
actions: set => ({
addItem: (item: Item) => set(state => ({
items: [...state.items, item]
})),
setLoading: (loading: boolean) => set({ loading }),
}),
})
Network Requests
Use request capability for API calls:
async run(ctx, input) {
const response = await ctx.request('https://api.example.com/data')
const data = await response.json()
return result.json(data)
}
File Operations
Use fs capability for file access:
async run(ctx, input) {
const content = await ctx.fs.read(input.filePath)
return result.text(content)
}
Validation Checklist
- [ ] Description fully parsed into requirements
- [ ] Plugin type correctly identified (app vs tool)
- [ ] Input schema covers all required inputs
- [ ] Permissions match capability usage
- [ ] Plugin ID is kebab-case and unique
- [ ]
run()returns structuredresult.* - [ ] App plugins have working
setup()UI - [ ] Tool plugins work headlessly via CLI
Troubleshooting
Ambiguous Requirements
Problem: Description is unclear about functionality
Solution: Ask clarifying questions or make reasonable defaults
Missing Capabilities
Problem: Plugin needs features not available in web runtime
Solution: Check capability availability table, implement graceful degradation
Complex State Management
Problem: Plugin has complex state needs
Solution: Use definePluginStore with Zustand patterns
Template: Quick Start
// plugins/plugin-{name}/index.tsx
import { definePlugin } from '@flowtools/sdk'
import { result } from '@flowtools/sdk/result'
import { z } from 'zod'
const inputSchema = z.object({
// Define inputs here
})
export default definePlugin({
type: 'app', // or 'tool'
meta: {
id: '{plugin-id}',
name: '{Plugin Name}',
version: '0.1.0',
permissions: [], // Add required permissions
},
inputSchema,
async run(ctx, input) {
// Implementation
return result.json({ success: true })
},
setup() {
// For app plugins only
return function Panel() {
return <div>Plugin UI</div>
}
},
})