@geenius/ai 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/config.json +11 -0
- package/.env.example +2 -0
- package/.github/CODEOWNERS +1 -0
- package/.github/ISSUE_TEMPLATE/bug_report.md +16 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +11 -0
- package/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/ci.yml +23 -0
- package/.github/workflows/release.yml +29 -0
- package/.node-version +1 -0
- package/.nvmrc +1 -0
- package/.prettierrc +7 -0
- package/.project/ACCOUNT.yaml +4 -0
- package/.project/IDEAS.yaml +7 -0
- package/.project/PROJECT.yaml +11 -0
- package/.project/ROADMAP.yaml +15 -0
- package/CHANGELOG.md +15 -0
- package/CODE_OF_CONDUCT.md +26 -0
- package/CONTRIBUTING.md +61 -0
- package/LICENSE +21 -0
- package/README.md +1 -0
- package/SECURITY.md +18 -0
- package/SUPPORT.md +14 -0
- package/package.json +75 -0
- package/packages/convex/package.json +42 -0
- package/packages/convex/src/index.ts +8 -0
- package/packages/convex/src/mutations/messages.ts +29 -0
- package/packages/convex/src/queries/messages.ts +24 -0
- package/packages/convex/src/schema.ts +20 -0
- package/packages/convex/tsconfig.json +11 -0
- package/packages/convex/tsup.config.ts +17 -0
- package/packages/react/README.md +1 -0
- package/packages/react/package.json +60 -0
- package/packages/react/src/components/AILogTable.tsx +90 -0
- package/packages/react/src/components/ChatWindow.tsx +118 -0
- package/packages/react/src/components/GenerationCard.tsx +73 -0
- package/packages/react/src/components/ImageGenerator.tsx +103 -0
- package/packages/react/src/components/ModelSelector.tsx +44 -0
- package/packages/react/src/components/ModelTestRunner.tsx +148 -0
- package/packages/react/src/components/VoiceSelector.tsx +51 -0
- package/packages/react/src/components/index.ts +9 -0
- package/packages/react/src/hooks/index.ts +12 -0
- package/packages/react/src/hooks/useAI.ts +158 -0
- package/packages/react/src/hooks/useAILogs.ts +40 -0
- package/packages/react/src/hooks/useAIModels.ts +53 -0
- package/packages/react/src/hooks/useChat.ts +141 -0
- package/packages/react/src/hooks/useContentManager.ts +108 -0
- package/packages/react/src/hooks/useImageGeneration.ts +82 -0
- package/packages/react/src/hooks/useMemory.ts +161 -0
- package/packages/react/src/hooks/useModelTest.ts +126 -0
- package/packages/react/src/hooks/useRealtimeAudio.ts +203 -0
- package/packages/react/src/hooks/useSkills.ts +114 -0
- package/packages/react/src/hooks/useTextToSpeech.ts +99 -0
- package/packages/react/src/hooks/useTranscription.ts +119 -0
- package/packages/react/src/hooks/useVideoGeneration.ts +79 -0
- package/packages/react/src/index.ts +42 -0
- package/packages/react/src/pages/AILogsPage.tsx +98 -0
- package/packages/react/src/pages/ChatPage.tsx +42 -0
- package/packages/react/src/pages/ModelTestPage.tsx +33 -0
- package/packages/react/src/pages/index.ts +5 -0
- package/packages/react/tsconfig.json +26 -0
- package/packages/react/tsup.config.ts +22 -0
- package/packages/react-css/README.md +1 -0
- package/packages/react-css/package.json +45 -0
- package/packages/react-css/src/ai.css +857 -0
- package/packages/react-css/src/components/AILogTable.tsx +90 -0
- package/packages/react-css/src/components/ChatWindow.tsx +118 -0
- package/packages/react-css/src/components/GenerationCard.tsx +73 -0
- package/packages/react-css/src/components/ImageGenerator.tsx +103 -0
- package/packages/react-css/src/components/ModelSelector.tsx +44 -0
- package/packages/react-css/src/components/ModelTestRunner.tsx +148 -0
- package/packages/react-css/src/components/VoiceSelector.tsx +51 -0
- package/packages/react-css/src/components/index.ts +9 -0
- package/packages/react-css/src/hooks/index.ts +12 -0
- package/packages/react-css/src/hooks/useAI.ts +153 -0
- package/packages/react-css/src/hooks/useAILogs.ts +40 -0
- package/packages/react-css/src/hooks/useAIModels.ts +51 -0
- package/packages/react-css/src/hooks/useChat.ts +145 -0
- package/packages/react-css/src/hooks/useContentManager.ts +108 -0
- package/packages/react-css/src/hooks/useImageGeneration.ts +82 -0
- package/packages/react-css/src/hooks/useMemory.ts +161 -0
- package/packages/react-css/src/hooks/useModelTest.ts +122 -0
- package/packages/react-css/src/hooks/useRealtimeAudio.ts +203 -0
- package/packages/react-css/src/hooks/useSkills.ts +114 -0
- package/packages/react-css/src/hooks/useTextToSpeech.ts +99 -0
- package/packages/react-css/src/hooks/useTranscription.ts +119 -0
- package/packages/react-css/src/hooks/useVideoGeneration.ts +79 -0
- package/packages/react-css/src/index.ts +35 -0
- package/packages/react-css/src/pages/AILogsPage.tsx +98 -0
- package/packages/react-css/src/pages/ChatPage.tsx +42 -0
- package/packages/react-css/src/pages/ModelTestPage.tsx +33 -0
- package/packages/react-css/src/pages/index.ts +5 -0
- package/packages/react-css/src/styles.css +127 -0
- package/packages/react-css/tsconfig.json +26 -0
- package/packages/react-css/tsup.config.ts +2 -0
- package/packages/shared/README.md +1 -0
- package/packages/shared/package.json +71 -0
- package/packages/shared/src/__tests__/ai.test.ts +67 -0
- package/packages/shared/src/ai-client.ts +243 -0
- package/packages/shared/src/config.ts +235 -0
- package/packages/shared/src/content.ts +249 -0
- package/packages/shared/src/convex/helpers.ts +163 -0
- package/packages/shared/src/convex/index.ts +16 -0
- package/packages/shared/src/convex/schemas.ts +146 -0
- package/packages/shared/src/convex/validators.ts +136 -0
- package/packages/shared/src/index.ts +107 -0
- package/packages/shared/src/memory.ts +197 -0
- package/packages/shared/src/providers/base.ts +103 -0
- package/packages/shared/src/providers/elevenlabs.ts +155 -0
- package/packages/shared/src/providers/index.ts +28 -0
- package/packages/shared/src/providers/openai-compatible.ts +286 -0
- package/packages/shared/src/providers/registry.ts +113 -0
- package/packages/shared/src/providers/replicate-fal.ts +230 -0
- package/packages/shared/src/skills.ts +273 -0
- package/packages/shared/src/types.ts +501 -0
- package/packages/shared/tsconfig.json +25 -0
- package/packages/shared/tsup.config.ts +22 -0
- package/packages/shared/vitest.config.ts +4 -0
- package/packages/solidjs/README.md +1 -0
- package/packages/solidjs/package.json +59 -0
- package/packages/solidjs/src/components/ChatWindow.tsx +78 -0
- package/packages/solidjs/src/components/GenerationCard.tsx +62 -0
- package/packages/solidjs/src/components/ModelTestRunner.tsx +119 -0
- package/packages/solidjs/src/components/index.ts +5 -0
- package/packages/solidjs/src/index.ts +32 -0
- package/packages/solidjs/src/pages/ChatPage.tsx +22 -0
- package/packages/solidjs/src/pages/ModelTestPage.tsx +22 -0
- package/packages/solidjs/src/pages/index.ts +4 -0
- package/packages/solidjs/src/primitives/createAI.ts +79 -0
- package/packages/solidjs/src/primitives/createChat.ts +100 -0
- package/packages/solidjs/src/primitives/createContentManager.ts +61 -0
- package/packages/solidjs/src/primitives/createImageGeneration.ts +46 -0
- package/packages/solidjs/src/primitives/createMemory.ts +127 -0
- package/packages/solidjs/src/primitives/createModelTest.ts +89 -0
- package/packages/solidjs/src/primitives/createSkills.ts +83 -0
- package/packages/solidjs/src/primitives/createTextToSpeech.ts +56 -0
- package/packages/solidjs/src/primitives/createVideoGeneration.ts +46 -0
- package/packages/solidjs/src/primitives/index.ts +8 -0
- package/packages/solidjs/tsconfig.json +27 -0
- package/packages/solidjs/tsup.config.ts +21 -0
- package/packages/solidjs-css/README.md +1 -0
- package/packages/solidjs-css/package.json +44 -0
- package/packages/solidjs-css/src/ai.css +857 -0
- package/packages/solidjs-css/src/components/ChatWindow.tsx +78 -0
- package/packages/solidjs-css/src/components/GenerationCard.tsx +62 -0
- package/packages/solidjs-css/src/components/ModelTestRunner.tsx +119 -0
- package/packages/solidjs-css/src/components/index.ts +5 -0
- package/packages/solidjs-css/src/index.ts +26 -0
- package/packages/solidjs-css/src/pages/ChatPage.tsx +22 -0
- package/packages/solidjs-css/src/pages/ModelTestPage.tsx +22 -0
- package/packages/solidjs-css/src/pages/index.ts +4 -0
- package/packages/solidjs-css/src/primitives/createAI.ts +79 -0
- package/packages/solidjs-css/src/primitives/createChat.ts +100 -0
- package/packages/solidjs-css/src/primitives/createContentManager.ts +61 -0
- package/packages/solidjs-css/src/primitives/createImageGeneration.ts +46 -0
- package/packages/solidjs-css/src/primitives/createMemory.ts +127 -0
- package/packages/solidjs-css/src/primitives/createModelTest.ts +89 -0
- package/packages/solidjs-css/src/primitives/createSkills.ts +83 -0
- package/packages/solidjs-css/src/primitives/createTextToSpeech.ts +56 -0
- package/packages/solidjs-css/src/primitives/createVideoGeneration.ts +46 -0
- package/packages/solidjs-css/src/primitives/index.ts +1 -0
- package/packages/solidjs-css/src/styles.css +127 -0
- package/packages/solidjs-css/tsconfig.json +27 -0
- package/packages/solidjs-css/tsup.config.ts +2 -0
- package/pnpm-workspace.yaml +2 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
// @geenius-ai/shared — src/skills.ts
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Skill registry — reusable, composable AI capabilities.
|
|
5
|
+
* Skills are named operations with typed inputs/outputs that can be
|
|
6
|
+
* chained, configured, and discovered at runtime.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Skill Types
|
|
11
|
+
// ============================================================================
|
|
12
|
+
|
|
13
|
+
export type SkillCategory =
|
|
14
|
+
| 'text'
|
|
15
|
+
| 'data'
|
|
16
|
+
| 'media'
|
|
17
|
+
| 'analysis'
|
|
18
|
+
| 'communication'
|
|
19
|
+
| 'code'
|
|
20
|
+
| 'custom'
|
|
21
|
+
|
|
22
|
+
export type SkillParameterType = 'string' | 'number' | 'boolean' | 'string[]' | 'object'
|
|
23
|
+
|
|
24
|
+
export interface SkillParameter {
|
|
25
|
+
name: string
|
|
26
|
+
type: SkillParameterType
|
|
27
|
+
description?: string
|
|
28
|
+
required?: boolean
|
|
29
|
+
default?: unknown
|
|
30
|
+
enum?: string[]
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface SkillDefinition {
|
|
34
|
+
id: string
|
|
35
|
+
name: string
|
|
36
|
+
description: string
|
|
37
|
+
category: SkillCategory
|
|
38
|
+
/** Input parameters the skill accepts */
|
|
39
|
+
parameters: SkillParameter[]
|
|
40
|
+
/** System prompt for the AI */
|
|
41
|
+
systemPrompt: string
|
|
42
|
+
/** User prompt template (use {{paramName}} for interpolation) */
|
|
43
|
+
promptTemplate: string
|
|
44
|
+
/** Required model capabilities */
|
|
45
|
+
requiredCapabilities?: string[]
|
|
46
|
+
/** Default model to use */
|
|
47
|
+
defaultModel?: string
|
|
48
|
+
/** Max tokens for output */
|
|
49
|
+
maxTokens?: number
|
|
50
|
+
/** Tags for discovery */
|
|
51
|
+
tags?: string[]
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface SkillContext {
|
|
55
|
+
/** The skill being executed */
|
|
56
|
+
skillId: string
|
|
57
|
+
/** Input parameters */
|
|
58
|
+
params: Record<string, unknown>
|
|
59
|
+
/** User ID for personalization */
|
|
60
|
+
userId?: string
|
|
61
|
+
/** Additional context (e.g., page data, form schema) */
|
|
62
|
+
context?: Record<string, unknown>
|
|
63
|
+
/** Model override */
|
|
64
|
+
model?: string
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface SkillResult {
|
|
68
|
+
skillId: string
|
|
69
|
+
output: string
|
|
70
|
+
/** Structured output if applicable */
|
|
71
|
+
structured?: Record<string, unknown>
|
|
72
|
+
model: string
|
|
73
|
+
tokens?: number
|
|
74
|
+
costUsd?: number
|
|
75
|
+
durationMs: number
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// ============================================================================
|
|
79
|
+
// Skill Registry
|
|
80
|
+
// ============================================================================
|
|
81
|
+
|
|
82
|
+
export interface SkillRegistry {
|
|
83
|
+
/** Register a custom skill */
|
|
84
|
+
register(skill: SkillDefinition): void
|
|
85
|
+
/** Get a skill by ID */
|
|
86
|
+
get(id: string): SkillDefinition | undefined
|
|
87
|
+
/** List all registered skills */
|
|
88
|
+
list(category?: SkillCategory): SkillDefinition[]
|
|
89
|
+
/** Search skills by query */
|
|
90
|
+
search(query: string): SkillDefinition[]
|
|
91
|
+
/** Execute a skill */
|
|
92
|
+
execute(context: SkillContext): Promise<SkillResult>
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Create an in-memory skill registry.
|
|
97
|
+
*/
|
|
98
|
+
export function createSkillRegistry(): SkillRegistry {
|
|
99
|
+
const skills = new Map<string, SkillDefinition>()
|
|
100
|
+
|
|
101
|
+
// Register built-in skills
|
|
102
|
+
for (const skill of Object.values(BUILT_IN_SKILLS)) {
|
|
103
|
+
skills.set(skill.id, skill)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
register(skill) {
|
|
108
|
+
skills.set(skill.id, skill)
|
|
109
|
+
},
|
|
110
|
+
get(id) {
|
|
111
|
+
return skills.get(id)
|
|
112
|
+
},
|
|
113
|
+
list(category?) {
|
|
114
|
+
const all = Array.from(skills.values())
|
|
115
|
+
if (!category) return all
|
|
116
|
+
return all.filter(s => s.category === category)
|
|
117
|
+
},
|
|
118
|
+
search(query) {
|
|
119
|
+
const q = query.toLowerCase()
|
|
120
|
+
return Array.from(skills.values()).filter(s =>
|
|
121
|
+
s.name.toLowerCase().includes(q) ||
|
|
122
|
+
s.description.toLowerCase().includes(q) ||
|
|
123
|
+
s.tags?.some(t => t.toLowerCase().includes(q))
|
|
124
|
+
)
|
|
125
|
+
},
|
|
126
|
+
async execute(_context) {
|
|
127
|
+
// This is a stub — actual execution happens in the framework-specific layer
|
|
128
|
+
// (React hook / SolidJS primitive) which has access to the AI provider
|
|
129
|
+
throw new Error('Skill execution requires a framework adapter. Use useSkills() or createSkills().')
|
|
130
|
+
},
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// ============================================================================
|
|
135
|
+
// Built-in Skill Definitions
|
|
136
|
+
// ============================================================================
|
|
137
|
+
|
|
138
|
+
export const BUILT_IN_SKILLS: Record<string, SkillDefinition> = {
|
|
139
|
+
summarize: {
|
|
140
|
+
id: 'summarize',
|
|
141
|
+
name: 'Summarize',
|
|
142
|
+
description: 'Summarize text content into a concise overview',
|
|
143
|
+
category: 'text',
|
|
144
|
+
parameters: [
|
|
145
|
+
{ name: 'text', type: 'string', description: 'Text to summarize', required: true },
|
|
146
|
+
{ name: 'length', type: 'string', description: 'Summary length', default: 'medium', enum: ['short', 'medium', 'long'] },
|
|
147
|
+
{ name: 'format', type: 'string', description: 'Output format', default: 'paragraph', enum: ['paragraph', 'bullets', 'tldr'] },
|
|
148
|
+
],
|
|
149
|
+
systemPrompt: 'You are an expert summarizer. Provide clear, accurate summaries that capture the key points.',
|
|
150
|
+
promptTemplate: 'Summarize the following text ({{length}}, {{format}} format):\n\n{{text}}',
|
|
151
|
+
tags: ['text', 'summary', 'core'],
|
|
152
|
+
},
|
|
153
|
+
translate: {
|
|
154
|
+
id: 'translate',
|
|
155
|
+
name: 'Translate',
|
|
156
|
+
description: 'Translate text between languages',
|
|
157
|
+
category: 'text',
|
|
158
|
+
parameters: [
|
|
159
|
+
{ name: 'text', type: 'string', description: 'Text to translate', required: true },
|
|
160
|
+
{ name: 'targetLanguage', type: 'string', description: 'Target language', required: true },
|
|
161
|
+
{ name: 'sourceLanguage', type: 'string', description: 'Source language (auto-detect if omitted)' },
|
|
162
|
+
{ name: 'preserveTone', type: 'boolean', description: 'Preserve the original tone', default: true },
|
|
163
|
+
],
|
|
164
|
+
systemPrompt: 'You are a professional translator. Translate accurately while preserving tone, meaning, and cultural nuance.',
|
|
165
|
+
promptTemplate: 'Translate the following to {{targetLanguage}}{{#sourceLanguage}} (from {{sourceLanguage}}){{/sourceLanguage}}:\n\n{{text}}',
|
|
166
|
+
tags: ['text', 'translation', 'i18n', 'core'],
|
|
167
|
+
},
|
|
168
|
+
rewrite: {
|
|
169
|
+
id: 'rewrite',
|
|
170
|
+
name: 'Rewrite',
|
|
171
|
+
description: 'Rewrite text with improved clarity, tone, or style',
|
|
172
|
+
category: 'text',
|
|
173
|
+
parameters: [
|
|
174
|
+
{ name: 'text', type: 'string', description: 'Text to rewrite', required: true },
|
|
175
|
+
{ name: 'tone', type: 'string', description: 'Target tone', enum: ['professional', 'casual', 'friendly', 'formal', 'persuasive'] },
|
|
176
|
+
{ name: 'instructions', type: 'string', description: 'Specific rewrite instructions' },
|
|
177
|
+
],
|
|
178
|
+
systemPrompt: 'You are an expert editor. Rewrite content to improve its quality while preserving the core message.',
|
|
179
|
+
promptTemplate: 'Rewrite the following text{{#tone}} in a {{tone}} tone{{/tone}}{{#instructions}}. Instructions: {{instructions}}{{/instructions}}:\n\n{{text}}',
|
|
180
|
+
tags: ['text', 'editing', 'core'],
|
|
181
|
+
},
|
|
182
|
+
extract: {
|
|
183
|
+
id: 'extract',
|
|
184
|
+
name: 'Extract Data',
|
|
185
|
+
description: 'Extract structured data or specific information from text',
|
|
186
|
+
category: 'data',
|
|
187
|
+
parameters: [
|
|
188
|
+
{ name: 'text', type: 'string', description: 'Text to extract from', required: true },
|
|
189
|
+
{ name: 'fields', type: 'string[]', description: 'Fields to extract', required: true },
|
|
190
|
+
{ name: 'format', type: 'string', description: 'Output format', default: 'json', enum: ['json', 'csv', 'table'] },
|
|
191
|
+
],
|
|
192
|
+
systemPrompt: 'You are a data extraction expert. Extract the requested information accurately and return it in the specified format.',
|
|
193
|
+
promptTemplate: 'Extract the following fields from the text: {{fields}}\n\nOutput format: {{format}}\n\nText:\n{{text}}',
|
|
194
|
+
tags: ['data', 'extraction', 'structured'],
|
|
195
|
+
},
|
|
196
|
+
classify: {
|
|
197
|
+
id: 'classify',
|
|
198
|
+
name: 'Classify',
|
|
199
|
+
description: 'Classify text into categories',
|
|
200
|
+
category: 'analysis',
|
|
201
|
+
parameters: [
|
|
202
|
+
{ name: 'text', type: 'string', description: 'Text to classify', required: true },
|
|
203
|
+
{ name: 'categories', type: 'string[]', description: 'Available categories', required: true },
|
|
204
|
+
{ name: 'multiLabel', type: 'boolean', description: 'Allow multiple categories', default: false },
|
|
205
|
+
],
|
|
206
|
+
systemPrompt: 'You are a text classification expert. Classify content accurately into the given categories.',
|
|
207
|
+
promptTemplate: 'Classify the following text into {{#multiLabel}}one or more of{{/multiLabel}}{{^multiLabel}}exactly one of{{/multiLabel}} these categories: {{categories}}\n\nText:\n{{text}}',
|
|
208
|
+
tags: ['analysis', 'classification', 'core'],
|
|
209
|
+
},
|
|
210
|
+
'sentiment-analysis': {
|
|
211
|
+
id: 'sentiment-analysis',
|
|
212
|
+
name: 'Sentiment Analysis',
|
|
213
|
+
description: 'Analyze the sentiment and emotion of text',
|
|
214
|
+
category: 'analysis',
|
|
215
|
+
parameters: [
|
|
216
|
+
{ name: 'text', type: 'string', description: 'Text to analyze', required: true },
|
|
217
|
+
{ name: 'granularity', type: 'string', description: 'Analysis depth', default: 'basic', enum: ['basic', 'detailed'] },
|
|
218
|
+
],
|
|
219
|
+
systemPrompt: 'You are a sentiment analysis expert. Analyze text for sentiment, emotion, and tone.',
|
|
220
|
+
promptTemplate: 'Analyze the sentiment of the following text ({{granularity}} analysis):\n\n{{text}}\n\nReturn: sentiment (positive/negative/neutral/mixed), confidence (0-1), and key emotions detected.',
|
|
221
|
+
tags: ['analysis', 'sentiment', 'nlp'],
|
|
222
|
+
},
|
|
223
|
+
'generate-code': {
|
|
224
|
+
id: 'generate-code',
|
|
225
|
+
name: 'Generate Code',
|
|
226
|
+
description: 'Generate code from natural language description',
|
|
227
|
+
category: 'code',
|
|
228
|
+
parameters: [
|
|
229
|
+
{ name: 'description', type: 'string', description: 'What the code should do', required: true },
|
|
230
|
+
{ name: 'language', type: 'string', description: 'Programming language', required: true },
|
|
231
|
+
{ name: 'framework', type: 'string', description: 'Framework to use (optional)' },
|
|
232
|
+
],
|
|
233
|
+
systemPrompt: 'You are an expert programmer. Generate clean, well-documented code.',
|
|
234
|
+
promptTemplate: 'Generate {{language}} code{{#framework}} using {{framework}}{{/framework}} for the following:\n\n{{description}}',
|
|
235
|
+
tags: ['code', 'generation'],
|
|
236
|
+
},
|
|
237
|
+
'compose-email': {
|
|
238
|
+
id: 'compose-email',
|
|
239
|
+
name: 'Compose Email',
|
|
240
|
+
description: 'Draft a professional email',
|
|
241
|
+
category: 'communication',
|
|
242
|
+
parameters: [
|
|
243
|
+
{ name: 'purpose', type: 'string', description: 'Purpose of the email', required: true },
|
|
244
|
+
{ name: 'recipient', type: 'string', description: 'Who the email is to' },
|
|
245
|
+
{ name: 'tone', type: 'string', description: 'Email tone', default: 'professional', enum: ['professional', 'casual', 'friendly', 'formal'] },
|
|
246
|
+
{ name: 'context', type: 'string', description: 'Additional context' },
|
|
247
|
+
],
|
|
248
|
+
systemPrompt: 'You are a professional email writer. Draft clear, effective emails.',
|
|
249
|
+
promptTemplate: 'Draft an email{{#recipient}} to {{recipient}}{{/recipient}} with a {{tone}} tone.\n\nPurpose: {{purpose}}{{#context}}\n\nContext: {{context}}{{/context}}',
|
|
250
|
+
tags: ['communication', 'email'],
|
|
251
|
+
},
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Build a prompt from a skill definition and parameters.
|
|
256
|
+
*/
|
|
257
|
+
export function buildSkillPrompt(
|
|
258
|
+
skill: SkillDefinition,
|
|
259
|
+
params: Record<string, unknown>,
|
|
260
|
+
): { systemPrompt: string; userPrompt: string } {
|
|
261
|
+
let userPrompt = skill.promptTemplate
|
|
262
|
+
|
|
263
|
+
for (const [key, value] of Object.entries(params)) {
|
|
264
|
+
const strValue = Array.isArray(value) ? value.join(', ') : String(value ?? '')
|
|
265
|
+
userPrompt = userPrompt.replace(new RegExp(`\\{\\{${key}\\}\\}`, 'g'), strValue)
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// Remove unmatched template conditionals
|
|
269
|
+
userPrompt = userPrompt.replace(/\{\{#\w+\}\}.*?\{\{\/\w+\}\}/gs, '')
|
|
270
|
+
userPrompt = userPrompt.replace(/\{\{\^\w+\}\}.*?\{\{\/\w+\}\}/gs, '')
|
|
271
|
+
|
|
272
|
+
return { systemPrompt: skill.systemPrompt, userPrompt: userPrompt.trim() }
|
|
273
|
+
}
|