@hasna/prompts 0.3.2 → 0.3.3
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/dist/mcp/index.js +52 -0
- package/package.json +1 -1
package/dist/mcp/index.js
CHANGED
|
@@ -5547,6 +5547,58 @@ server.registerTool("prompts_import", {
|
|
|
5547
5547
|
const results = importFromJson(prompts, changed_by);
|
|
5548
5548
|
return ok(results);
|
|
5549
5549
|
});
|
|
5550
|
+
server.registerTool("prompts_export_as_skills", {
|
|
5551
|
+
description: "Export prompts as Claude Code SKILL.md files in ~/.claude/skills/ so they become /slug slash commands. Each prompt slug becomes an invocable skill.",
|
|
5552
|
+
inputSchema: {
|
|
5553
|
+
collection: exports_external.string().optional().describe("Only export prompts from this collection"),
|
|
5554
|
+
slugs: exports_external.array(exports_external.string()).optional().describe("Specific prompt slugs to export"),
|
|
5555
|
+
target_dir: exports_external.string().optional().describe("Target skills directory (default: ~/.claude/skills)"),
|
|
5556
|
+
overwrite: exports_external.boolean().optional().describe("Overwrite existing skill files (default: false)")
|
|
5557
|
+
}
|
|
5558
|
+
}, async ({ collection, slugs, target_dir, overwrite }) => {
|
|
5559
|
+
try {
|
|
5560
|
+
const { mkdirSync: mkdirSync2, writeFileSync, existsSync: existsSync2 } = await import("fs");
|
|
5561
|
+
const { join: join2 } = await import("path");
|
|
5562
|
+
const { homedir } = await import("os");
|
|
5563
|
+
const skillsDir = target_dir ?? join2(homedir(), ".claude", "skills");
|
|
5564
|
+
mkdirSync2(skillsDir, { recursive: true });
|
|
5565
|
+
const filter = collection ? { collection } : {};
|
|
5566
|
+
const allPrompts = listPrompts(filter);
|
|
5567
|
+
const toExport = slugs ? allPrompts.filter((p) => slugs.includes(p.slug)) : allPrompts;
|
|
5568
|
+
const exported = [];
|
|
5569
|
+
const skipped = [];
|
|
5570
|
+
for (const prompt of toExport) {
|
|
5571
|
+
const skillDir = join2(skillsDir, `skill-${prompt.slug}`);
|
|
5572
|
+
const skillFile = join2(skillDir, "SKILL.md");
|
|
5573
|
+
if (!overwrite && existsSync2(skillFile)) {
|
|
5574
|
+
skipped.push(prompt.slug);
|
|
5575
|
+
continue;
|
|
5576
|
+
}
|
|
5577
|
+
mkdirSync2(skillDir, { recursive: true });
|
|
5578
|
+
const skillContent = [
|
|
5579
|
+
"---",
|
|
5580
|
+
`name: skill-${prompt.slug}`,
|
|
5581
|
+
`description: ${prompt.description || prompt.title}`,
|
|
5582
|
+
"user_invocable: true",
|
|
5583
|
+
"---",
|
|
5584
|
+
"",
|
|
5585
|
+
prompt.body
|
|
5586
|
+
].join(`
|
|
5587
|
+
`);
|
|
5588
|
+
writeFileSync(skillFile, skillContent, "utf-8");
|
|
5589
|
+
exported.push(prompt.slug);
|
|
5590
|
+
}
|
|
5591
|
+
return ok({
|
|
5592
|
+
exported: exported.length,
|
|
5593
|
+
skipped: skipped.length,
|
|
5594
|
+
skills_dir: skillsDir,
|
|
5595
|
+
exported_slugs: exported,
|
|
5596
|
+
message: `Exported ${exported.length} prompt(s) as skills. Use /skill-{slug} to invoke them.`
|
|
5597
|
+
});
|
|
5598
|
+
} catch (e) {
|
|
5599
|
+
return err(e instanceof Error ? e.message : String(e));
|
|
5600
|
+
}
|
|
5601
|
+
});
|
|
5550
5602
|
server.registerTool("prompts_import_slash_commands", {
|
|
5551
5603
|
description: "Auto-scan .claude/commands, .codex/skills, .gemini/extensions (both project and home dir) and import all .md files as prompts.",
|
|
5552
5604
|
inputSchema: {
|