@merabylabs/promptarchitect-mcp 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.
Files changed (50) hide show
  1. package/README.md +230 -0
  2. package/dist/cli.d.ts +7 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +13 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/index.d.ts +9 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.js +13 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/resources/index.d.ts +2 -0
  11. package/dist/resources/index.d.ts.map +1 -0
  12. package/dist/resources/index.js +2 -0
  13. package/dist/resources/index.js.map +1 -0
  14. package/dist/resources/templates.d.ts +36 -0
  15. package/dist/resources/templates.d.ts.map +1 -0
  16. package/dist/resources/templates.js +260 -0
  17. package/dist/resources/templates.js.map +1 -0
  18. package/dist/server.d.ts +15 -0
  19. package/dist/server.d.ts.map +1 -0
  20. package/dist/server.js +355 -0
  21. package/dist/server.js.map +1 -0
  22. package/dist/tools/analyzePrompt.d.ts +38 -0
  23. package/dist/tools/analyzePrompt.d.ts.map +1 -0
  24. package/dist/tools/analyzePrompt.js +196 -0
  25. package/dist/tools/analyzePrompt.js.map +1 -0
  26. package/dist/tools/generatePrompt.d.ts +33 -0
  27. package/dist/tools/generatePrompt.d.ts.map +1 -0
  28. package/dist/tools/generatePrompt.js +125 -0
  29. package/dist/tools/generatePrompt.js.map +1 -0
  30. package/dist/tools/index.d.ts +8 -0
  31. package/dist/tools/index.d.ts.map +1 -0
  32. package/dist/tools/index.js +8 -0
  33. package/dist/tools/index.js.map +1 -0
  34. package/dist/tools/refinePrompt.d.ts +33 -0
  35. package/dist/tools/refinePrompt.d.ts.map +1 -0
  36. package/dist/tools/refinePrompt.js +107 -0
  37. package/dist/tools/refinePrompt.js.map +1 -0
  38. package/dist/utils/gemini.d.ts +57 -0
  39. package/dist/utils/gemini.d.ts.map +1 -0
  40. package/dist/utils/gemini.js +254 -0
  41. package/dist/utils/gemini.js.map +1 -0
  42. package/dist/utils/index.d.ts +3 -0
  43. package/dist/utils/index.d.ts.map +1 -0
  44. package/dist/utils/index.js +3 -0
  45. package/dist/utils/index.js.map +1 -0
  46. package/dist/utils/logger.d.ts +14 -0
  47. package/dist/utils/logger.d.ts.map +1 -0
  48. package/dist/utils/logger.js +46 -0
  49. package/dist/utils/logger.js.map +1 -0
  50. package/package.json +72 -0
package/dist/server.js ADDED
@@ -0,0 +1,355 @@
1
+ /**
2
+ * MCP Server Configuration
3
+ * Sets up the Model Context Protocol server with tools and resources
4
+ */
5
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
6
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
+ import { CallToolRequestSchema, ListToolsRequestSchema, ListResourcesRequestSchema, ReadResourceRequestSchema, ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js';
8
+ import { generatePrompt, generatePromptSchema, refinePrompt, refinePromptSchema, analyzePrompt, analyzePromptSchema, } from './tools/index.js';
9
+ import { getAllTemplates, getTemplateById, getCategories, } from './resources/templates.js';
10
+ import { logger, initializeGemini, isGeminiAvailable, getStats } from './utils/index.js';
11
+ /**
12
+ * Create and configure the MCP server
13
+ */
14
+ export function createServer() {
15
+ const server = new Server({
16
+ name: 'promptarchitect-mcp',
17
+ version: '1.0.0',
18
+ }, {
19
+ capabilities: {
20
+ tools: {},
21
+ resources: {},
22
+ },
23
+ });
24
+ // Initialize Gemini if API key is available
25
+ // Check both GEMINI_API_KEY and VITE_GEMINI_API_KEY (for compatibility with main app)
26
+ const apiKey = process.env.GEMINI_API_KEY || process.env.VITE_GEMINI_API_KEY;
27
+ if (apiKey) {
28
+ initializeGemini(apiKey);
29
+ logger.info('Gemini API initialized');
30
+ }
31
+ else {
32
+ logger.warn('GEMINI_API_KEY not set - using fallback generation');
33
+ }
34
+ // Register tool handlers
35
+ registerToolHandlers(server);
36
+ // Register resource handlers
37
+ registerResourceHandlers(server);
38
+ // Error handling
39
+ server.onerror = (error) => {
40
+ logger.error('MCP Server Error', { error });
41
+ };
42
+ return server;
43
+ }
44
+ function registerToolHandlers(server) {
45
+ // List available tools
46
+ server.setRequestHandler(ListToolsRequestSchema, async () => {
47
+ return {
48
+ tools: [
49
+ {
50
+ name: 'generate_prompt',
51
+ description: `Transform a raw idea into a well-structured, actionable prompt optimized for AI assistants.
52
+
53
+ Use this tool when you need to:
54
+ • Create a new prompt from scratch
55
+ • Structure a vague idea into a clear request
56
+ • Generate role-specific prompts (coding, writing, research, etc.)
57
+
58
+ Supports templates: coding (for programming tasks), writing (for content creation), research (for investigation), analysis (for data/business analysis), factcheck (for verification), general (versatile).`,
59
+ inputSchema: {
60
+ type: 'object',
61
+ properties: {
62
+ idea: {
63
+ type: 'string',
64
+ description: 'The raw idea or concept to transform into a prompt. Can be brief or detailed.',
65
+ },
66
+ template: {
67
+ type: 'string',
68
+ enum: ['coding', 'writing', 'research', 'analysis', 'factcheck', 'general'],
69
+ description: 'Template type to use. Default: auto-detected from idea or "general".',
70
+ },
71
+ context: {
72
+ type: 'string',
73
+ description: 'Additional context like domain, constraints, or preferences.',
74
+ },
75
+ targetModel: {
76
+ type: 'string',
77
+ enum: ['gpt-4', 'claude', 'gemini', 'general'],
78
+ description: 'Target AI model for optimization. Default: "general".',
79
+ },
80
+ },
81
+ required: ['idea'],
82
+ },
83
+ },
84
+ {
85
+ name: 'refine_prompt',
86
+ description: `Iteratively improve an existing prompt based on specific feedback.
87
+
88
+ Use this tool when you need to:
89
+ • Improve a prompt that didn't get good results
90
+ • Add missing context or constraints
91
+ • Make a prompt more specific or clearer
92
+ • Adapt a prompt for a different AI model
93
+
94
+ The tool preserves the original structure while applying targeted improvements.`,
95
+ inputSchema: {
96
+ type: 'object',
97
+ properties: {
98
+ prompt: {
99
+ type: 'string',
100
+ description: 'The current prompt to refine.',
101
+ },
102
+ feedback: {
103
+ type: 'string',
104
+ description: 'What should be improved. Examples: "make it more specific", "add error handling requirements", "focus on performance".',
105
+ },
106
+ preserveStructure: {
107
+ type: 'boolean',
108
+ description: 'Whether to keep the original structure. Default: true.',
109
+ },
110
+ targetModel: {
111
+ type: 'string',
112
+ enum: ['gpt-4', 'claude', 'gemini', 'general'],
113
+ description: 'Target AI model for optimization.',
114
+ },
115
+ },
116
+ required: ['prompt', 'feedback'],
117
+ },
118
+ },
119
+ {
120
+ name: 'analyze_prompt',
121
+ description: `Evaluate prompt quality and get actionable improvement suggestions.
122
+
123
+ Use this tool when you need to:
124
+ • Assess if a prompt is well-structured
125
+ • Identify weaknesses before using a prompt
126
+ • Get specific suggestions for improvement
127
+ • Compare prompt quality before/after refinement
128
+
129
+ Returns scores (0-100) for: clarity, specificity, structure, actionability.`,
130
+ inputSchema: {
131
+ type: 'object',
132
+ properties: {
133
+ prompt: {
134
+ type: 'string',
135
+ description: 'The prompt to analyze.',
136
+ },
137
+ evaluationCriteria: {
138
+ type: 'array',
139
+ items: { type: 'string' },
140
+ description: 'Specific criteria to evaluate. Default: all criteria.',
141
+ },
142
+ },
143
+ required: ['prompt'],
144
+ },
145
+ },
146
+ {
147
+ name: 'get_server_status',
148
+ description: `Get PromptArchitect server status and performance metrics.
149
+
150
+ Use this tool to check:
151
+ • Whether AI (Gemini) is available
152
+ • Cache hit rate and request statistics
153
+ • Average response latency`,
154
+ inputSchema: {
155
+ type: 'object',
156
+ properties: {},
157
+ required: [],
158
+ },
159
+ },
160
+ ],
161
+ };
162
+ });
163
+ // Handle tool calls
164
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
165
+ const { name, arguments: args } = request.params;
166
+ logger.info('Tool called', { name, args });
167
+ try {
168
+ switch (name) {
169
+ case 'generate_prompt': {
170
+ const input = generatePromptSchema.parse(args);
171
+ const result = await generatePrompt(input);
172
+ return {
173
+ content: [
174
+ {
175
+ type: 'text',
176
+ text: JSON.stringify(result, null, 2),
177
+ },
178
+ ],
179
+ };
180
+ }
181
+ case 'refine_prompt': {
182
+ const input = refinePromptSchema.parse(args);
183
+ const result = await refinePrompt(input);
184
+ return {
185
+ content: [
186
+ {
187
+ type: 'text',
188
+ text: JSON.stringify(result, null, 2),
189
+ },
190
+ ],
191
+ };
192
+ }
193
+ case 'analyze_prompt': {
194
+ const input = analyzePromptSchema.parse(args);
195
+ const result = await analyzePrompt(input);
196
+ return {
197
+ content: [
198
+ {
199
+ type: 'text',
200
+ text: JSON.stringify(result, null, 2),
201
+ },
202
+ ],
203
+ };
204
+ }
205
+ case 'get_server_status': {
206
+ const stats = getStats();
207
+ const status = {
208
+ server: 'promptarchitect-mcp',
209
+ version: '1.0.0',
210
+ geminiAvailable: isGeminiAvailable(),
211
+ performance: {
212
+ totalRequests: stats.totalRequests,
213
+ cacheHits: stats.cacheHits,
214
+ cacheHitRate: stats.totalRequests > 0
215
+ ? `${Math.round((stats.cacheHits / stats.totalRequests) * 100)}%`
216
+ : 'N/A',
217
+ avgLatencyMs: stats.avgLatencyMs,
218
+ },
219
+ status: isGeminiAvailable() ? 'ready' : 'degraded (using fallbacks)',
220
+ };
221
+ return {
222
+ content: [
223
+ {
224
+ type: 'text',
225
+ text: JSON.stringify(status, null, 2),
226
+ },
227
+ ],
228
+ };
229
+ }
230
+ default:
231
+ throw new McpError(ErrorCode.MethodNotFound, `Unknown tool: "${name}". Available tools: generate_prompt, refine_prompt, analyze_prompt, get_server_status`);
232
+ }
233
+ }
234
+ catch (error) {
235
+ if (error instanceof McpError)
236
+ throw error;
237
+ // Provide user-friendly error messages
238
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
239
+ logger.error('Tool execution error', { name, error: errorMessage });
240
+ // Check for common error patterns and provide helpful context
241
+ let userMessage = errorMessage;
242
+ if (errorMessage.includes('parse')) {
243
+ userMessage = `Invalid input: ${errorMessage}. Please check the required parameters.`;
244
+ }
245
+ else if (errorMessage.includes('API') || errorMessage.includes('Gemini')) {
246
+ userMessage = `AI service error: ${errorMessage}. The server will use fallback generation.`;
247
+ }
248
+ throw new McpError(ErrorCode.InternalError, userMessage);
249
+ }
250
+ });
251
+ }
252
+ function registerResourceHandlers(server) {
253
+ // List available resources
254
+ server.setRequestHandler(ListResourcesRequestSchema, async () => {
255
+ const templates = getAllTemplates();
256
+ const categories = getCategories();
257
+ const resources = [
258
+ // Category listing
259
+ {
260
+ uri: 'promptarchitect://templates/categories',
261
+ name: 'Template Categories',
262
+ description: 'List of available template categories',
263
+ mimeType: 'application/json',
264
+ },
265
+ // Individual templates
266
+ ...templates.map(t => ({
267
+ uri: `promptarchitect://templates/${t.id}`,
268
+ name: t.name,
269
+ description: t.description,
270
+ mimeType: 'application/json',
271
+ })),
272
+ // Category collections
273
+ ...categories.map(cat => ({
274
+ uri: `promptarchitect://templates/category/${cat}`,
275
+ name: `${cat.charAt(0).toUpperCase() + cat.slice(1)} Templates`,
276
+ description: `All templates in the ${cat} category`,
277
+ mimeType: 'application/json',
278
+ })),
279
+ ];
280
+ return { resources };
281
+ });
282
+ // Read resource content
283
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
284
+ const { uri } = request.params;
285
+ logger.info('Resource requested', { uri });
286
+ // Parse URI
287
+ const match = uri.match(/^promptarchitect:\/\/templates\/(.+)$/);
288
+ if (!match) {
289
+ throw new McpError(ErrorCode.InvalidRequest, `Invalid resource URI: ${uri}`);
290
+ }
291
+ const path = match[1];
292
+ // Handle categories list
293
+ if (path === 'categories') {
294
+ return {
295
+ contents: [
296
+ {
297
+ uri,
298
+ mimeType: 'application/json',
299
+ text: JSON.stringify(getCategories(), null, 2),
300
+ },
301
+ ],
302
+ };
303
+ }
304
+ // Handle category collection
305
+ if (path.startsWith('category/')) {
306
+ const category = path.replace('category/', '');
307
+ const templates = getAllTemplates().filter(t => t.category === category);
308
+ return {
309
+ contents: [
310
+ {
311
+ uri,
312
+ mimeType: 'application/json',
313
+ text: JSON.stringify(templates, null, 2),
314
+ },
315
+ ],
316
+ };
317
+ }
318
+ // Handle individual template
319
+ const template = getTemplateById(path);
320
+ if (!template) {
321
+ throw new McpError(ErrorCode.InvalidRequest, `Template not found: ${path}`);
322
+ }
323
+ return {
324
+ contents: [
325
+ {
326
+ uri,
327
+ mimeType: 'application/json',
328
+ text: JSON.stringify(template, null, 2),
329
+ },
330
+ ],
331
+ };
332
+ });
333
+ }
334
+ /**
335
+ * Run the server with stdio transport
336
+ */
337
+ export async function runServer() {
338
+ const server = createServer();
339
+ const transport = new StdioServerTransport();
340
+ await server.connect(transport);
341
+ logger.info('PromptArchitect MCP Server started');
342
+ // Handle graceful shutdown
343
+ process.on('SIGINT', async () => {
344
+ logger.info('Shutting down...');
345
+ await server.close();
346
+ process.exit(0);
347
+ });
348
+ process.on('SIGTERM', async () => {
349
+ logger.info('Shutting down...');
350
+ await server.close();
351
+ process.exit(0);
352
+ });
353
+ }
354
+ export default createServer;
355
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,yBAAyB,EACzB,SAAS,EACT,QAAQ,GACT,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,YAAY,EACZ,kBAAkB,EAClB,aAAa,EACb,mBAAmB,GACpB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,GACd,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEzF;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;QACE,IAAI,EAAE,qBAAqB;Q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G,IAAI,oBAAoB,EAAE,CAAC;IAE7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,MAAM,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;IAElD,2BAA2B;IAC3B,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;QAC9B,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAChC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,KAAK,IAAI,EAAE;QAC/B,MAAM,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAChC,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,eAAe,YAAY,CAAC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Analyze Prompt Tool
3
+ * Evaluates prompt quality and provides improvement suggestions
4
+ */
5
+ import { z } from 'zod';
6
+ export declare const analyzePromptSchema: z.ZodObject<{
7
+ prompt: z.ZodString;
8
+ evaluationCriteria: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
9
+ }, "strip", z.ZodTypeAny, {
10
+ prompt: string;
11
+ evaluationCriteria?: string[] | undefined;
12
+ }, {
13
+ prompt: string;
14
+ evaluationCriteria?: string[] | undefined;
15
+ }>;
16
+ export type AnalyzePromptInput = z.infer<typeof analyzePromptSchema>;
17
+ export interface AnalysisResult {
18
+ scores: {
19
+ overall: number;
20
+ clarity: number;
21
+ specificity: number;
22
+ structure: number;
23
+ actionability: number;
24
+ };
25
+ suggestions: string[];
26
+ strengths: string[];
27
+ weaknesses: string[];
28
+ metadata: {
29
+ wordCount: number;
30
+ sentenceCount: number;
31
+ hasStructure: boolean;
32
+ hasExamples: boolean;
33
+ hasConstraints: boolean;
34
+ };
35
+ }
36
+ export declare function analyzePrompt(input: AnalyzePromptInput): Promise<AnalysisResult>;
37
+ export default analyzePrompt;
38
+ //# sourceMappingURL=analyzePrompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzePrompt.d.ts","sourceRoot":"","sources":["../../src/tools/analyzePrompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,mBAAmB;;;;;;;;;EAG9B,CAAC;AAEH,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAErE,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE;QACN,OAAO,EAAE,MAAM,CAAC;QAChB,OAAO,EAAE,MAAM,CAAC;QAChB,WAAW,EAAE,MAAM,CAAC;QACpB,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;QACtB,YAAY,EAAE,OAAO,CAAC;QACtB,WAAW,EAAE,OAAO,CAAC;QACrB,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC;CACH;AASD,wBAAsB,aAAa,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,cAAc,CAAC,CAyCtF;AA6JD,eAAe,aAAa,CAAC"}
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Analyze Prompt Tool
3
+ * Evaluates prompt quality and provides improvement suggestions
4
+ */
5
+ import { z } from 'zod';
6
+ import { analyzePromptQuality, isGeminiAvailable, logger } from '../utils/index.js';
7
+ export const analyzePromptSchema = z.object({
8
+ prompt: z.string().min(1).describe('The prompt to analyze'),
9
+ evaluationCriteria: z.array(z.string()).optional().describe('Specific criteria to evaluate'),
10
+ });
11
+ const DEFAULT_CRITERIA = [
12
+ 'clarity',
13
+ 'specificity',
14
+ 'structure',
15
+ 'actionability',
16
+ ];
17
+ export async function analyzePrompt(input) {
18
+ const { prompt, evaluationCriteria = DEFAULT_CRITERIA } = input;
19
+ logger.info('Analyzing prompt', {
20
+ promptLength: prompt.length,
21
+ criteria: evaluationCriteria
22
+ });
23
+ // Calculate structural metadata
24
+ const metadata = calculateMetadata(prompt);
25
+ if (isGeminiAvailable()) {
26
+ try {
27
+ const quality = await analyzePromptQuality(prompt);
28
+ // Calculate overall score from individual scores
29
+ const overallScore = Math.round((quality.scores.clarity + quality.scores.specificity +
30
+ quality.scores.actionability + quality.scores.completeness) / 4 * 10);
31
+ return {
32
+ scores: {
33
+ overall: overallScore,
34
+ clarity: quality.scores.clarity * 10,
35
+ specificity: quality.scores.specificity * 10,
36
+ structure: estimateSubscore(prompt, 'structure', overallScore),
37
+ actionability: quality.scores.actionability * 10,
38
+ },
39
+ suggestions: quality.suggestions.slice(0, 5),
40
+ strengths: identifyStrengths(prompt, metadata),
41
+ weaknesses: identifyWeaknesses(prompt, metadata),
42
+ metadata,
43
+ };
44
+ }
45
+ catch (error) {
46
+ logger.warn('LLM analysis failed, using rule-based fallback', { error });
47
+ }
48
+ }
49
+ // Fallback: Rule-based analysis
50
+ return performRuleBasedAnalysis(prompt, metadata);
51
+ }
52
+ function calculateMetadata(prompt) {
53
+ const words = prompt.split(/\s+/).filter(w => w.length > 0);
54
+ const sentences = prompt.split(/[.!?]+/).filter(s => s.trim().length > 0);
55
+ return {
56
+ wordCount: words.length,
57
+ sentenceCount: sentences.length,
58
+ hasStructure: /^#+\s|^\d+\.|^-\s|^\*\s|\[|\]/m.test(prompt),
59
+ hasExamples: /example|e\.g\.|for instance|such as|like this/i.test(prompt),
60
+ hasConstraints: /must|should|avoid|don't|do not|never|always|required/i.test(prompt),
61
+ };
62
+ }
63
+ function estimateSubscore(prompt, criterion, baseScore) {
64
+ // Adjust base score based on criterion-specific heuristics
65
+ let adjustment = 0;
66
+ switch (criterion) {
67
+ case 'clarity':
68
+ // Shorter sentences = clearer
69
+ const avgSentenceLength = prompt.length / (prompt.split(/[.!?]+/).length || 1);
70
+ adjustment = avgSentenceLength < 100 ? 5 : avgSentenceLength > 200 ? -10 : 0;
71
+ break;
72
+ case 'specificity':
73
+ // Specific words indicate specificity
74
+ const specificIndicators = (prompt.match(/specific|exact|precisely|particular|detailed/gi) || []).length;
75
+ const vagueIndicators = (prompt.match(/something|anything|whatever|stuff|things/gi) || []).length;
76
+ adjustment = specificIndicators * 3 - vagueIndicators * 5;
77
+ break;
78
+ case 'structure':
79
+ // Headers, lists, sections
80
+ const hasHeaders = /^#+\s/m.test(prompt);
81
+ const hasList = /^[-*•\d.]+\s/m.test(prompt);
82
+ adjustment = (hasHeaders ? 10 : 0) + (hasList ? 5 : 0);
83
+ break;
84
+ case 'actionability':
85
+ // Clear actions/verbs at start
86
+ const hasActionVerb = /^(create|generate|write|analyze|explain|list|describe|build|design)/i.test(prompt);
87
+ adjustment = hasActionVerb ? 10 : -5;
88
+ break;
89
+ }
90
+ return Math.max(0, Math.min(100, baseScore + adjustment));
91
+ }
92
+ function identifyStrengths(prompt, metadata) {
93
+ const strengths = [];
94
+ if (metadata.hasStructure) {
95
+ strengths.push('Well-structured with clear sections or formatting');
96
+ }
97
+ if (metadata.hasExamples) {
98
+ strengths.push('Includes examples for clarity');
99
+ }
100
+ if (metadata.hasConstraints) {
101
+ strengths.push('Provides clear constraints and requirements');
102
+ }
103
+ if (metadata.wordCount >= 50 && metadata.wordCount <= 500) {
104
+ strengths.push('Appropriate length - detailed but not overwhelming');
105
+ }
106
+ if (/^(you are|act as|pretend to be)/i.test(prompt)) {
107
+ strengths.push('Uses role-based framing');
108
+ }
109
+ if (/output|response|format|result/i.test(prompt)) {
110
+ strengths.push('Specifies expected output format');
111
+ }
112
+ return strengths.length > 0 ? strengths : ['Prompt is functional and clear'];
113
+ }
114
+ function identifyWeaknesses(prompt, metadata) {
115
+ const weaknesses = [];
116
+ if (!metadata.hasStructure && metadata.wordCount > 100) {
117
+ weaknesses.push('Long prompt without clear structure');
118
+ }
119
+ if (!metadata.hasExamples && metadata.wordCount > 50) {
120
+ weaknesses.push('Could benefit from examples');
121
+ }
122
+ if (metadata.wordCount < 20) {
123
+ weaknesses.push('Very short - may lack necessary context');
124
+ }
125
+ if (!/[?]/.test(prompt) && !/^(create|generate|write|explain|list)/i.test(prompt)) {
126
+ weaknesses.push('Unclear what action is expected');
127
+ }
128
+ if ((prompt.match(/\n/g) || []).length === 0 && metadata.wordCount > 50) {
129
+ weaknesses.push('Dense single block - consider breaking into sections');
130
+ }
131
+ return weaknesses;
132
+ }
133
+ function performRuleBasedAnalysis(prompt, metadata) {
134
+ // Calculate scores based on heuristics
135
+ let clarityScore = 70;
136
+ let specificityScore = 60;
137
+ let structureScore = 50;
138
+ let actionabilityScore = 65;
139
+ // Clarity adjustments
140
+ const avgSentenceLength = prompt.length / (metadata.sentenceCount || 1);
141
+ if (avgSentenceLength < 100)
142
+ clarityScore += 10;
143
+ if (avgSentenceLength > 200)
144
+ clarityScore -= 15;
145
+ // Specificity adjustments
146
+ if (metadata.hasExamples)
147
+ specificityScore += 15;
148
+ if (metadata.hasConstraints)
149
+ specificityScore += 10;
150
+ // Structure adjustments
151
+ if (metadata.hasStructure)
152
+ structureScore += 30;
153
+ if (metadata.wordCount > 100 && !metadata.hasStructure)
154
+ structureScore -= 20;
155
+ // Actionability adjustments
156
+ if (/^(create|generate|write|analyze|explain|list|describe|build)/i.test(prompt)) {
157
+ actionabilityScore += 15;
158
+ }
159
+ if (/output|response|format|result/i.test(prompt)) {
160
+ actionabilityScore += 10;
161
+ }
162
+ // Clamp all scores
163
+ const clamp = (n) => Math.max(0, Math.min(100, n));
164
+ clarityScore = clamp(clarityScore);
165
+ specificityScore = clamp(specificityScore);
166
+ structureScore = clamp(structureScore);
167
+ actionabilityScore = clamp(actionabilityScore);
168
+ const overall = Math.round((clarityScore + specificityScore + structureScore + actionabilityScore) / 4);
169
+ // Generate suggestions
170
+ const suggestions = [];
171
+ if (structureScore < 60)
172
+ suggestions.push('Add headers or bullet points to organize the prompt');
173
+ if (specificityScore < 60)
174
+ suggestions.push('Include more specific details or examples');
175
+ if (actionabilityScore < 70)
176
+ suggestions.push('Start with a clear action verb (Create, Generate, Write, etc.)');
177
+ if (clarityScore < 70)
178
+ suggestions.push('Break long sentences into shorter, clearer ones');
179
+ if (!metadata.hasExamples)
180
+ suggestions.push('Add an example of expected output');
181
+ return {
182
+ scores: {
183
+ overall,
184
+ clarity: clarityScore,
185
+ specificity: specificityScore,
186
+ structure: structureScore,
187
+ actionability: actionabilityScore,
188
+ },
189
+ suggestions: suggestions.slice(0, 5),
190
+ strengths: identifyStrengths(prompt, metadata),
191
+ weaknesses: identifyWeaknesses(prompt, metadata),
192
+ metadata,
193
+ };
194
+ }
195
+ export default analyzePrompt;
196
+ //# sourceMappingURL=analyzePrompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analyzePrompt.js","sourceRoot":"","sources":["../../src/tools/analyzePrompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAEpF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,uBAAuB,CAAC;IAC3D,kBAAkB,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,+BAA+B,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AI,CAAC,iDAAiD,CAAC,CAAC;IAC3F,IAAI,CAAC,QAAQ,CAAC,WAAW;QAAE,WAAW,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;IAEjF,OAAO;QACL,MAAM,EAAE;YACN,OAAO;YACP,OAAO,EAAE,YAAY;YACrB,WAAW,EAAE,gBAAgB;YAC7B,SAAS,EAAE,cAAc;YACzB,aAAa,EAAE,kBAAkB;SAClC;QACD,WAAW,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;QACpC,SAAS,EAAE,iBAAiB,CAAC,MAAM,EAAE,QAAQ,CAAC;QAC9C,UAAU,EAAE,kBAAkB,CAAC,MAAM,EAAE,QAAQ,CAAC;QAChD,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,eAAe,aAAa,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Generate Prompt Tool
3
+ * Transforms user ideas into well-structured prompts
4
+ */
5
+ import { z } from 'zod';
6
+ export declare const generatePromptSchema: z.ZodObject<{
7
+ idea: z.ZodString;
8
+ template: z.ZodDefault<z.ZodOptional<z.ZodEnum<["coding", "writing", "research", "analysis", "factcheck", "general"]>>>;
9
+ context: z.ZodOptional<z.ZodString>;
10
+ targetModel: z.ZodDefault<z.ZodOptional<z.ZodEnum<["gpt-4", "claude", "gemini", "general"]>>>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ idea: string;
13
+ template: "coding" | "writing" | "research" | "analysis" | "factcheck" | "general";
14
+ targetModel: "general" | "gpt-4" | "claude" | "gemini";
15
+ context?: string | undefined;
16
+ }, {
17
+ idea: string;
18
+ template?: "coding" | "writing" | "research" | "analysis" | "factcheck" | "general" | undefined;
19
+ context?: string | undefined;
20
+ targetModel?: "general" | "gpt-4" | "claude" | "gemini" | undefined;
21
+ }>;
22
+ export type GeneratePromptInput = z.infer<typeof generatePromptSchema>;
23
+ export declare function generatePrompt(input: GeneratePromptInput): Promise<{
24
+ prompt: string;
25
+ template: string;
26
+ metadata: {
27
+ estimatedTokens: number;
28
+ wordCount: number;
29
+ hasStructure: boolean;
30
+ };
31
+ }>;
32
+ export default generatePrompt;
33
+ //# sourceMappingURL=generatePrompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generatePrompt.d.ts","sourceRoot":"","sources":["../../src/tools/generatePrompt.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;EAW/B,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAyDvE,wBAAsB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC;IACxE,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE;QACR,eAAe,EAAE,MAAM,CAAC;QACxB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,OAAO,CAAC;KACvB,CAAC;CACH,CAAC,CAyCD;AA0BD,eAAe,cAAc,CAAC"}