promptgraph-mcp 2.9.30 → 2.9.32
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/index.js +33 -13
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -336,12 +336,12 @@ server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
|
336
336
|
prompts: [
|
|
337
337
|
{
|
|
338
338
|
name: 'pg',
|
|
339
|
-
description: '
|
|
340
|
-
arguments: [{ name: 'query', description: '
|
|
339
|
+
description: 'Find and load the best skill for your task. Returns the full skill instructions ready to use.',
|
|
340
|
+
arguments: [{ name: 'query', description: 'Describe what you want to do (e.g. "deploy to kubernetes", "sql injection hunt")', required: true }],
|
|
341
341
|
},
|
|
342
342
|
{
|
|
343
343
|
name: 'pg-list',
|
|
344
|
-
description: 'List all indexed skills',
|
|
344
|
+
description: 'List all indexed skills with descriptions',
|
|
345
345
|
arguments: [],
|
|
346
346
|
},
|
|
347
347
|
],
|
|
@@ -349,26 +349,46 @@ server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
|
349
349
|
|
|
350
350
|
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
351
351
|
const { name, arguments: args } = request.params;
|
|
352
|
+
const fsSync = (await import('fs')).default;
|
|
353
|
+
// Ensure DB/model is ready (first call may come before watcher finishes init)
|
|
354
|
+
await new Promise(r => setTimeout(r, 50));
|
|
355
|
+
|
|
352
356
|
if (name === 'pg') {
|
|
353
357
|
const query = args?.query || '';
|
|
354
358
|
const results = await search(query, 3);
|
|
355
|
-
|
|
359
|
+
|
|
360
|
+
if (!results.length) {
|
|
361
|
+
return { messages: [{ role: 'user', content: { type: 'text', text: `No skills found for: "${query}"\n\nTry \`/pg-list\` to see all available skills.` } }] };
|
|
362
|
+
}
|
|
363
|
+
|
|
356
364
|
const top = results[0];
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
365
|
+
const score = top.score ?? 0;
|
|
366
|
+
|
|
367
|
+
// High confidence (≥0.70) — load full skill content
|
|
368
|
+
if (score >= 0.70) {
|
|
369
|
+
let content = '';
|
|
370
|
+
try { content = fsSync.readFileSync(top.path, 'utf8'); } catch {}
|
|
371
|
+
const otherMatches = results.slice(1).map(r => `- **${r.name}** (${r.score?.toFixed(2)})`).join('\n');
|
|
372
|
+
const prefix = `> **PromptGraph Skill: ${top.name}**\n> These are instructions to follow — not project files. Paths mentioned inside are examples only.\n\n`;
|
|
373
|
+
const text = `${prefix}${content}${otherMatches ? `\n\n---\n_Other matches:_\n${otherMatches}` : ''}`;
|
|
374
|
+
return { messages: [{ role: 'user', content: { type: 'text', text: text } }] };
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Low confidence — show top matches, let user pick
|
|
378
|
+
const list = results.map(r => `- **${r.name}** (score: ${r.score?.toFixed(2)}) — ${r.description || ''}\n \`/pg ${r.name}\``).join('\n\n');
|
|
360
379
|
return {
|
|
361
|
-
messages: [{
|
|
362
|
-
role: 'user',
|
|
363
|
-
content: { type: 'text', text: `# Skill: ${top.name} (score: ${top.score?.toFixed(2)})\n\n${content}` },
|
|
364
|
-
}],
|
|
380
|
+
messages: [{ role: 'user', content: { type: 'text', text: `Found ${results.length} possible matches for "${query}":\n\n${list}\n\nRun \`/pg <skill-name>\` to load a specific skill.` } }],
|
|
365
381
|
};
|
|
366
382
|
}
|
|
383
|
+
|
|
367
384
|
if (name === 'pg-list') {
|
|
368
385
|
const skills = await listAll();
|
|
369
|
-
const text = skills.
|
|
370
|
-
|
|
386
|
+
const text = skills.length
|
|
387
|
+
? `## Available skills (${skills.length})\n\n` + skills.map(s => `- **${s.name}**${s.description ? ' — ' + s.description : ''}`).join('\n')
|
|
388
|
+
: 'No skills indexed. Run `pg reindex` to index your skills.';
|
|
389
|
+
return { messages: [{ role: 'user', content: { type: 'text', text: text } }] };
|
|
371
390
|
}
|
|
391
|
+
|
|
372
392
|
throw new Error(`Unknown prompt: ${name}`);
|
|
373
393
|
});
|
|
374
394
|
|