promptgraph-mcp 2.9.30 → 2.9.31
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 +30 -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,43 @@ 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
|
+
|
|
352
354
|
if (name === 'pg') {
|
|
353
355
|
const query = args?.query || '';
|
|
354
356
|
const results = await search(query, 3);
|
|
355
|
-
|
|
357
|
+
|
|
358
|
+
if (!results.length) {
|
|
359
|
+
return { messages: [{ role: 'user', content: { type: 'text', text: `No skills found for: "${query}"\n\nTry \`/pg-list\` to see all available skills.` } }] };
|
|
360
|
+
}
|
|
361
|
+
|
|
356
362
|
const top = results[0];
|
|
357
|
-
const
|
|
358
|
-
|
|
359
|
-
|
|
363
|
+
const score = top.score ?? 0;
|
|
364
|
+
|
|
365
|
+
// High confidence (≥0.70) — load full skill content
|
|
366
|
+
if (score >= 0.70) {
|
|
367
|
+
let content = '';
|
|
368
|
+
try { content = fsSync.readFileSync(top.path, 'utf8'); } catch {}
|
|
369
|
+
const otherMatches = results.slice(1).map(r => `- **${r.name}** (${r.score?.toFixed(2)})`).join('\n');
|
|
370
|
+
const text = `${content}${otherMatches ? `\n\n---\n_Other matches:_\n${otherMatches}` : ''}`;
|
|
371
|
+
return { messages: [{ role: 'user', content: { type: 'text', text: text } }] };
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Low confidence — show top matches, let user pick
|
|
375
|
+
const list = results.map(r => `- **${r.name}** (score: ${r.score?.toFixed(2)}) — ${r.description || ''}\n \`/pg ${r.name}\``).join('\n\n');
|
|
360
376
|
return {
|
|
361
|
-
messages: [{
|
|
362
|
-
role: 'user',
|
|
363
|
-
content: { type: 'text', text: `# Skill: ${top.name} (score: ${top.score?.toFixed(2)})\n\n${content}` },
|
|
364
|
-
}],
|
|
377
|
+
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
378
|
};
|
|
366
379
|
}
|
|
380
|
+
|
|
367
381
|
if (name === 'pg-list') {
|
|
368
382
|
const skills = await listAll();
|
|
369
|
-
const text = skills.
|
|
370
|
-
|
|
383
|
+
const text = skills.length
|
|
384
|
+
? `## Available skills (${skills.length})\n\n` + skills.map(s => `- **${s.name}**${s.description ? ' — ' + s.description : ''}`).join('\n')
|
|
385
|
+
: 'No skills indexed. Run `pg reindex` to index your skills.';
|
|
386
|
+
return { messages: [{ role: 'user', content: { type: 'text', text: text } }] };
|
|
371
387
|
}
|
|
388
|
+
|
|
372
389
|
throw new Error(`Unknown prompt: ${name}`);
|
|
373
390
|
});
|
|
374
391
|
|