@hasna/prompts 0.3.1 → 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/cli/index.js CHANGED
@@ -5,25 +5,43 @@ var __getProtoOf = Object.getPrototypeOf;
5
5
  var __defProp = Object.defineProperty;
6
6
  var __getOwnPropNames = Object.getOwnPropertyNames;
7
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ function __accessProp(key) {
9
+ return this[key];
10
+ }
11
+ var __toESMCache_node;
12
+ var __toESMCache_esm;
8
13
  var __toESM = (mod, isNodeMode, target) => {
14
+ var canCache = mod != null && typeof mod === "object";
15
+ if (canCache) {
16
+ var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
17
+ var cached = cache.get(mod);
18
+ if (cached)
19
+ return cached;
20
+ }
9
21
  target = mod != null ? __create(__getProtoOf(mod)) : {};
10
22
  const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
11
23
  for (let key of __getOwnPropNames(mod))
12
24
  if (!__hasOwnProp.call(to, key))
13
25
  __defProp(to, key, {
14
- get: () => mod[key],
26
+ get: __accessProp.bind(mod, key),
15
27
  enumerable: true
16
28
  });
29
+ if (canCache)
30
+ cache.set(mod, to);
17
31
  return to;
18
32
  };
19
33
  var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
34
+ var __returnValue = (v) => v;
35
+ function __exportSetter(name, newValue) {
36
+ this[name] = __returnValue.bind(null, newValue);
37
+ }
20
38
  var __export = (target, all) => {
21
39
  for (var name in all)
22
40
  __defProp(target, name, {
23
41
  get: all[name],
24
42
  enumerable: true,
25
43
  configurable: true,
26
- set: (newValue) => all[name] = () => newValue
44
+ set: __exportSetter.bind(all, name)
27
45
  });
28
46
  };
29
47
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
package/dist/mcp/index.js CHANGED
@@ -1,13 +1,17 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
3
  var __defProp = Object.defineProperty;
4
+ var __returnValue = (v) => v;
5
+ function __exportSetter(name, newValue) {
6
+ this[name] = __returnValue.bind(null, newValue);
7
+ }
4
8
  var __export = (target, all) => {
5
9
  for (var name in all)
6
10
  __defProp(target, name, {
7
11
  get: all[name],
8
12
  enumerable: true,
9
13
  configurable: true,
10
- set: (newValue) => all[name] = () => newValue
14
+ set: __exportSetter.bind(all, name)
11
15
  });
12
16
  };
13
17
  var __require = import.meta.require;
@@ -5543,6 +5547,58 @@ server.registerTool("prompts_import", {
5543
5547
  const results = importFromJson(prompts, changed_by);
5544
5548
  return ok(results);
5545
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
+ });
5546
5602
  server.registerTool("prompts_import_slash_commands", {
5547
5603
  description: "Auto-scan .claude/commands, .codex/skills, .gemini/extensions (both project and home dir) and import all .md files as prompts.",
5548
5604
  inputSchema: {
@@ -5843,5 +5899,31 @@ server.registerTool("prompts_project_delete", {
5843
5899
  return err(e instanceof Error ? e.message : String(e));
5844
5900
  }
5845
5901
  });
5902
+ var _agentReg = new Map;
5903
+ server.tool("register_agent", "Register this agent session. Returns agent_id for use in heartbeat/set_focus.", { name: exports_external.string(), session_id: exports_external.string().optional() }, async (a) => {
5904
+ const existing = [..._agentReg.values()].find((x) => x.name === a.name);
5905
+ if (existing) {
5906
+ existing.last_seen_at = new Date().toISOString();
5907
+ return { content: [{ type: "text", text: JSON.stringify(existing) }] };
5908
+ }
5909
+ const id = Math.random().toString(36).slice(2, 10);
5910
+ const ag = { id, name: a.name, last_seen_at: new Date().toISOString() };
5911
+ _agentReg.set(id, ag);
5912
+ return { content: [{ type: "text", text: JSON.stringify(ag) }] };
5913
+ });
5914
+ server.tool("heartbeat", "Update last_seen_at to signal agent is active.", { agent_id: exports_external.string() }, async (a) => {
5915
+ const ag = _agentReg.get(a.agent_id);
5916
+ if (!ag)
5917
+ return { content: [{ type: "text", text: `Agent not found: ${a.agent_id}` }], isError: true };
5918
+ ag.last_seen_at = new Date().toISOString();
5919
+ return { content: [{ type: "text", text: `\u2665 ${ag.name} \u2014 active` }] };
5920
+ });
5921
+ server.tool("set_focus", "Set active project context for this agent session.", { agent_id: exports_external.string(), project_id: exports_external.string().optional() }, async (a) => {
5922
+ const ag = _agentReg.get(a.agent_id);
5923
+ if (!ag)
5924
+ return { content: [{ type: "text", text: `Agent not found: ${a.agent_id}` }], isError: true };
5925
+ ag.project_id = a.project_id;
5926
+ return { content: [{ type: "text", text: a.project_id ? `Focus: ${a.project_id}` : "Focus cleared" }] };
5927
+ });
5846
5928
  var transport = new StdioServerTransport;
5847
5929
  await server.connect(transport);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hasna/prompts",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "Reusable prompt library for AI agents — CLI + MCP server + REST API + web dashboard",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -53,11 +53,11 @@
53
53
  },
54
54
  "repository": {
55
55
  "type": "git",
56
- "url": "https://github.com/hasna/open-prompts.git"
56
+ "url": "https://github.com/hasna/prompts.git"
57
57
  },
58
- "homepage": "https://github.com/hasna/open-prompts",
58
+ "homepage": "https://github.com/hasna/prompts",
59
59
  "bugs": {
60
- "url": "https://github.com/hasna/open-prompts/issues"
60
+ "url": "https://github.com/hasna/prompts/issues"
61
61
  },
62
62
  "engines": {
63
63
  "bun": ">=1.0.0"