@gethippoai/create-hippo-plugin 1.0.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.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
package/dist/index.js ADDED
@@ -0,0 +1,359 @@
1
+ #!/usr/bin/env node
2
+ #!/usr/bin/env node
3
+ "use strict";
4
+ var __importDefault = (this && this.__importDefault) || function (mod) {
5
+ return (mod && mod.__esModule) ? mod : { "default": mod };
6
+ };
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ const prompts_1 = __importDefault(require("prompts"));
9
+ const fs_extra_1 = __importDefault(require("fs-extra"));
10
+ const path_1 = __importDefault(require("path"));
11
+ const CATEGORIES = [
12
+ { title: 'Integration (API, OAuth)', value: 'integration' },
13
+ { title: 'Productivity (Tasks, Notes)', value: 'productivity' },
14
+ { title: 'Finance (Payments, Tracking)', value: 'finance' },
15
+ { title: 'Social (Content, Sharing)', value: 'social' },
16
+ { title: 'Utility (Tools, Helpers)', value: 'utility' },
17
+ ];
18
+ async function main() {
19
+ console.log('\n🦛 create-hippo-plugin\n');
20
+ console.log('Yeni bir Hippo plugin\'i oluşturalım.\n');
21
+ const response = await (0, prompts_1.default)([
22
+ {
23
+ type: 'text',
24
+ name: 'name',
25
+ message: 'Plugin adı:',
26
+ initial: 'My Plugin',
27
+ validate: (v) => v.length > 0 || 'İsim gerekli',
28
+ },
29
+ {
30
+ type: 'text',
31
+ name: 'slug',
32
+ message: 'Plugin slug (kebab-case):',
33
+ initial: (_, values) => values.name
34
+ .toLowerCase()
35
+ .replace(/[^a-z0-9]+/g, '-')
36
+ .replace(/^-|-$/g, ''),
37
+ validate: (v) => /^[a-z0-9-]+$/.test(v) || 'Sadece küçük harf, rakam ve tire',
38
+ },
39
+ {
40
+ type: 'text',
41
+ name: 'description',
42
+ message: 'Kısa açıklama:',
43
+ initial: 'A Hippo plugin',
44
+ },
45
+ {
46
+ type: 'select',
47
+ name: 'category',
48
+ message: 'Kategori:',
49
+ choices: CATEGORIES,
50
+ },
51
+ {
52
+ type: 'text',
53
+ name: 'author',
54
+ message: 'Geliştirici:',
55
+ initial: 'Hippo Community',
56
+ },
57
+ {
58
+ type: 'confirm',
59
+ name: 'needsOAuth',
60
+ message: 'OAuth gerekiyor mu? (Google, GitHub vs.)',
61
+ initial: false,
62
+ },
63
+ {
64
+ type: (prev) => (prev ? 'text' : null),
65
+ name: 'oauthProvider',
66
+ message: 'OAuth provider (google, github, slack...):',
67
+ initial: 'google',
68
+ },
69
+ {
70
+ type: 'list',
71
+ name: 'tools',
72
+ message: 'AI tool isimleri (virgülle ayır):',
73
+ initial: 'my_tool',
74
+ separator: ',',
75
+ },
76
+ ]);
77
+ if (!response.name) {
78
+ console.log('\n❌ İptal edildi.\n');
79
+ process.exit(1);
80
+ }
81
+ const config = {
82
+ name: response.name,
83
+ slug: response.slug,
84
+ description: response.description,
85
+ category: response.category,
86
+ author: response.author,
87
+ needsOAuth: response.needsOAuth || false,
88
+ oauthProvider: response.oauthProvider || '',
89
+ tools: (response.tools || ['my_tool']).map((t) => t.trim()),
90
+ };
91
+ const outputDir = path_1.default.resolve(process.cwd(), `hippo-${config.slug}-plugin`);
92
+ await generatePlugin(config, outputDir);
93
+ console.log(`\n✅ Plugin oluşturuldu: ${outputDir}\n`);
94
+ console.log('Dosya yapısı:');
95
+ console.log(` hippo-${config.slug}-plugin/`);
96
+ console.log(' ├── src/');
97
+ console.log(' │ ├── manifest.ts # Plugin tanımı');
98
+ console.log(' │ ├── handlers.ts # Tool handler\'ları');
99
+ console.log(' │ └── index.ts # Entry point');
100
+ console.log(' ├── locales/ # 10 dil çevirisi');
101
+ console.log(' │ ├── tr.json');
102
+ console.log(' │ ├── en.json');
103
+ console.log(' │ └── ...');
104
+ console.log(' ├── README.md');
105
+ console.log(' └── package.json');
106
+ console.log('\nSonraki adımlar:');
107
+ console.log(` 1. cd hippo-${config.slug}-plugin`);
108
+ console.log(' 2. npm install');
109
+ console.log(' 3. src/handlers.ts dosyasında tool handler\'larını yaz');
110
+ console.log(' 4. locales/ altında çevirileri tamamla');
111
+ console.log(' 5. Hippo backend\'e entegre et (README\'e bak)\n');
112
+ }
113
+ async function generatePlugin(config, outputDir) {
114
+ await fs_extra_1.default.ensureDir(path_1.default.join(outputDir, 'src'));
115
+ await fs_extra_1.default.ensureDir(path_1.default.join(outputDir, 'locales'));
116
+ // package.json
117
+ await fs_extra_1.default.writeJSON(path_1.default.join(outputDir, 'package.json'), {
118
+ name: `hippo-${config.slug}-plugin`,
119
+ version: '1.0.0',
120
+ description: config.description,
121
+ main: 'dist/index.js',
122
+ types: 'dist/index.d.ts',
123
+ scripts: {
124
+ build: 'tsc',
125
+ dev: 'tsx src/index.ts',
126
+ },
127
+ dependencies: {},
128
+ devDependencies: {
129
+ typescript: '^5.5.0',
130
+ tsx: '^4.19.0',
131
+ },
132
+ hippoPlugin: {
133
+ slug: config.slug,
134
+ category: config.category,
135
+ },
136
+ }, { spaces: 2 });
137
+ // tsconfig.json
138
+ await fs_extra_1.default.writeJSON(path_1.default.join(outputDir, 'tsconfig.json'), {
139
+ compilerOptions: {
140
+ target: 'ES2022',
141
+ module: 'commonjs',
142
+ outDir: './dist',
143
+ rootDir: './src',
144
+ strict: true,
145
+ esModuleInterop: true,
146
+ skipLibCheck: true,
147
+ declaration: true,
148
+ },
149
+ include: ['src/**/*'],
150
+ }, { spaces: 2 });
151
+ // src/manifest.ts
152
+ const manifestContent = `/**
153
+ * ${config.name} — Hippo Plugin Manifest
154
+ */
155
+
156
+ export const manifest = {
157
+ slug: '${config.slug}',
158
+ name: '${config.name}',
159
+ description: '${config.description}',
160
+ version: '1.0.0',
161
+ icon: '🔌',
162
+ category: '${config.category}' as const,
163
+ author: '${config.author}',
164
+ isOfficial: false,
165
+
166
+ // AI tool tanımları
167
+ tools: [
168
+ ${config.tools
169
+ .map((t) => ` {
170
+ name: '${t}',
171
+ description: 'TODO: ${t} tool açıklaması',
172
+ parameters: {
173
+ type: 'object' as const,
174
+ properties: {
175
+ // TODO: Parametreleri tanımla
176
+ },
177
+ },
178
+ },`)
179
+ .join('\n')}
180
+ ],
181
+ ${config.needsOAuth
182
+ ? `
183
+ // OAuth yapılandırması
184
+ configSchema: {
185
+ type: 'oauth',
186
+ provider: '${config.oauthProvider}',
187
+ scopes: ['TODO: gerekli scope\'ları ekle'],
188
+ },
189
+ `
190
+ : `
191
+ // Kullanıcı yapılandırması (opsiyonel)
192
+ configSchema: {},
193
+ `}
194
+ // Çoklu dil desteği (locales/ klasöründen yüklenir)
195
+ i18n: {},
196
+ };
197
+ `;
198
+ await fs_extra_1.default.writeFile(path_1.default.join(outputDir, 'src', 'manifest.ts'), manifestContent);
199
+ // src/handlers.ts
200
+ const handlersContent = `/**
201
+ * ${config.name} — Tool Handlers
202
+ *
203
+ * Her tool için bir handler fonksiyonu tanımlayın.
204
+ * Handler'lar AI tool çağrıldığında çalışır.
205
+ */
206
+
207
+ export interface PluginContext {
208
+ userId: string;
209
+ locale: string;
210
+ currency: string;
211
+ /** Plugin'e özel kullanıcı ayarları (PluginInstallation.config) */
212
+ config: Record<string, unknown>;
213
+ /** OAuth token'ları (varsa) */
214
+ oauthData?: Record<string, unknown>;
215
+ }
216
+
217
+ export interface HandlerResult {
218
+ success: boolean;
219
+ data?: unknown;
220
+ message?: string;
221
+ error?: string;
222
+ }
223
+
224
+ ${config.tools
225
+ .map((t) => `/**
226
+ * ${t} handler
227
+ *
228
+ * @param params - AI'ın gönderdiği parametreler (tool tanımındaki properties)
229
+ * @param ctx - Kullanıcı bağlamı (userId, locale, config, oauthData)
230
+ */
231
+ export async function handle_${t}(
232
+ params: Record<string, unknown>,
233
+ ctx: PluginContext,
234
+ ): Promise<HandlerResult> {
235
+ // TODO: Handler mantığını implement et
236
+ return {
237
+ success: true,
238
+ data: {},
239
+ message: '${t} başarılı',
240
+ };
241
+ }
242
+ `)
243
+ .join('\n')}
244
+
245
+ /** Handler registry — tool adı → handler fonksiyonu */
246
+ export const handlers: Record<string, (params: Record<string, unknown>, ctx: PluginContext) => Promise<HandlerResult>> = {
247
+ ${config.tools.map((t) => ` '${t}': handle_${t},`).join('\n')}
248
+ };
249
+ `;
250
+ await fs_extra_1.default.writeFile(path_1.default.join(outputDir, 'src', 'handlers.ts'), handlersContent);
251
+ // src/index.ts
252
+ const indexContent = `/**
253
+ * ${config.name} — Hippo Plugin Entry Point
254
+ */
255
+
256
+ export { manifest } from './manifest';
257
+ export { handlers } from './handlers';
258
+ export type { PluginContext, HandlerResult } from './handlers';
259
+ `;
260
+ await fs_extra_1.default.writeFile(path_1.default.join(outputDir, 'src', 'index.ts'), indexContent);
261
+ // Locale files
262
+ const locales = {
263
+ tr: { name: config.name, description: config.description },
264
+ en: { name: config.name, description: config.description },
265
+ de: { name: config.name, description: `TODO: German description` },
266
+ fr: { name: config.name, description: `TODO: French description` },
267
+ es: { name: config.name, description: `TODO: Spanish description` },
268
+ pt: { name: config.name, description: `TODO: Portuguese description` },
269
+ it: { name: config.name, description: `TODO: Italian description` },
270
+ nl: { name: config.name, description: `TODO: Dutch description` },
271
+ ru: { name: config.name, description: `TODO: Russian description` },
272
+ ar: { name: config.name, description: `TODO: Arabic description` },
273
+ };
274
+ for (const [lang, translations] of Object.entries(locales)) {
275
+ await fs_extra_1.default.writeJSON(path_1.default.join(outputDir, 'locales', `${lang}.json`), translations, {
276
+ spaces: 2,
277
+ });
278
+ }
279
+ // README.md
280
+ const readmeContent = `# ${config.name}
281
+
282
+ ${config.description}
283
+
284
+ ## Hippo Plugin
285
+
286
+ | | |
287
+ |---|---|
288
+ | **Slug** | \`${config.slug}\` |
289
+ | **Kategori** | ${config.category} |
290
+ | **Geliştirici** | ${config.author} |
291
+ | **Versiyon** | 1.0.0 |
292
+ ${config.needsOAuth ? `| **OAuth** | ${config.oauthProvider} |` : ''}
293
+
294
+ ## AI Tool'ları
295
+
296
+ ${config.tools.map((t) => `- \`${t}\` — TODO: açıklama`).join('\n')}
297
+
298
+ ## Kurulum
299
+
300
+ ### 1. Handler'ları Yaz
301
+
302
+ \`src/handlers.ts\` dosyasında her tool için handler mantığını implement edin.
303
+
304
+ ### 2. Hippo Backend'e Kaydet
305
+
306
+ \`hippo-backend/apps/api/src/core/services/plugin_seed.ts\` dosyasına manifest'i ekleyin:
307
+
308
+ \`\`\`typescript
309
+ import { manifest } from 'hippo-${config.slug}-plugin';
310
+
311
+ // OFFICIAL_PLUGINS dizisine ekleyin:
312
+ {
313
+ slug: manifest.slug,
314
+ name: manifest.name,
315
+ description: manifest.description,
316
+ version: manifest.version,
317
+ icon: manifest.icon,
318
+ category: manifest.category,
319
+ author: manifest.author,
320
+ tools: manifest.tools,
321
+ i18n: manifest.i18n,
322
+ }
323
+ \`\`\`
324
+
325
+ ### 3. Hippo AI'a Handler Ekle
326
+
327
+ \`hippo-ai/src/core/engine/handlers/\` altına handler dosyanızı kopyalayın ve registry'ye kaydedin.
328
+
329
+ ### 4. Çevirileri Tamamla
330
+
331
+ \`locales/\` klasöründeki 10 dil dosyasını doldurun.
332
+
333
+ ## Geliştirme
334
+
335
+ \`\`\`bash
336
+ npm install
337
+ npm run build
338
+ \`\`\`
339
+
340
+ ## Dosya Yapısı
341
+
342
+ \`\`\`
343
+ hippo-${config.slug}-plugin/
344
+ ├── src/
345
+ │ ├── manifest.ts # Plugin tanımı (tools, config, i18n)
346
+ │ ├── handlers.ts # Tool handler fonksiyonları
347
+ │ └── index.ts # Entry point
348
+ ├── locales/ # 10 dil çevirisi
349
+ │ ├── tr.json
350
+ │ ├── en.json
351
+ │ └── ...
352
+ ├── package.json
353
+ ├── tsconfig.json
354
+ └── README.md
355
+ \`\`\`
356
+ `;
357
+ await fs_extra_1.default.writeFile(path_1.default.join(outputDir, 'README.md'), readmeContent);
358
+ }
359
+ main().catch(console.error);
package/package.json ADDED
@@ -0,0 +1,35 @@
1
+ {
2
+ "name": "@gethippoai/create-hippo-plugin",
3
+ "version": "1.0.0",
4
+ "description": "CLI to scaffold a new Hippo plugin",
5
+ "author": "GetHippoAI",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/GetHippoAI/create-hippo-plugin"
10
+ },
11
+ "keywords": ["hippo", "plugin", "cli", "scaffold", "ai"],
12
+ "bin": {
13
+ "create-hippo-plugin": "./dist/index.js"
14
+ },
15
+ "scripts": {
16
+ "build": "tsc",
17
+ "dev": "tsx src/index.ts",
18
+ "start": "node dist/index.js"
19
+ },
20
+ "dependencies": {
21
+ "prompts": "^2.4.2",
22
+ "chalk": "^5.3.0",
23
+ "fs-extra": "^11.2.0"
24
+ },
25
+ "devDependencies": {
26
+ "@types/fs-extra": "^11.0.4",
27
+ "@types/prompts": "^2.4.9",
28
+ "tsx": "^4.19.0",
29
+ "typescript": "^5.5.0"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "templates"
34
+ ]
35
+ }