opencode-promptforge 1.0.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 (3) hide show
  1. package/README.md +46 -0
  2. package/index.js +90 -0
  3. package/package.json +27 -0
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # opencode-promptforge
2
+
3
+ OpenCode plugin for PromptForge — search and retrieve AI prompts from your terminal.
4
+
5
+ ## Installation
6
+
7
+ Add to your `opencode.json`:
8
+
9
+ ```json
10
+ {
11
+ "plugin": ["opencode-promptforge"]
12
+ }
13
+ ```
14
+
15
+ ## Tools
16
+
17
+ | Tool | Description |
18
+ |------|-------------|
19
+ | `search_prompts` | Search prompts by keyword, model, or category |
20
+ | `get_prompt` | Retrieve full prompt content by ID |
21
+ | `get_trending_prompts` | Get trending prompts |
22
+
23
+ ## Usage
24
+
25
+ Once installed, ask the AI in any opencode session:
26
+
27
+ - *"Search PromptForge for prompts about TypeScript"*
28
+ - *"Get the full content of prompt abc-123"*
29
+ - *"What's trending on PromptForge?"*
30
+
31
+ ## Development
32
+
33
+ ```bash
34
+ cd opencode-plugin
35
+ npm install
36
+ ```
37
+
38
+ For local testing, copy to your opencode plugins directory:
39
+
40
+ ```bash
41
+ cp index.js ~/.config/opencode/plugins/promptforge.js
42
+ ```
43
+
44
+ ## License
45
+
46
+ MIT
package/index.js ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { tool } from "@opencode-ai/plugin";
4
+
5
+ const BASE_URL = process.env.PROMPT_FORGE_URL || "https://promptforge-rose.vercel.app";
6
+
7
+ async function fetchApi(path) {
8
+ const res = await fetch(`${BASE_URL}${path}`);
9
+ if (!res.ok) throw new Error(`API error: ${res.status}`);
10
+ return res.json();
11
+ }
12
+
13
+ export const PromptForgePlugin = async () => {
14
+ return {
15
+ tool: {
16
+ search_prompts: tool({
17
+ description: "Search the PromptForge library for AI prompts by keyword, model, or category. Returns matching prompts with metadata.",
18
+ args: {
19
+ q: tool.schema.string({ description: "Search query" }),
20
+ model: tool.schema.string({ description: "Filter by model: chatgpt, claude, gemini, etc.", optional: true }),
21
+ category: tool.schema.string({ description: "Filter by category slug: coding, seo, marketing, etc.", optional: true }),
22
+ sort: tool.schema.string({ description: "Sort order: trending, newest, most-upvoted, most-saved", optional: true }),
23
+ limit: tool.schema.number({ description: "Max results (1-50)", optional: true }),
24
+ },
25
+ async execute(args) {
26
+ const params = new URLSearchParams();
27
+ if (args.q) params.set("q", args.q);
28
+ if (args.model) params.set("model", args.model);
29
+ if (args.category) params.set("category", args.category);
30
+ if (args.sort) params.set("sort", args.sort);
31
+ if (args.limit) params.set("limit", String(Math.min(args.limit, 50)));
32
+ const data = await fetchApi(`/api/v1/prompts?${params}`);
33
+ const prompts = (data.data || []).map(p => ({
34
+ id: p.id,
35
+ title: p.title,
36
+ description: p.description,
37
+ model: p.model,
38
+ author: p.author?.displayName || p.author?.username || "anonymous",
39
+ category: p.category?.name || null,
40
+ url: `${BASE_URL}/prompts/${p.id}`,
41
+ stats: p.stats,
42
+ }));
43
+ return JSON.stringify({ count: prompts.length, total: data.pagination?.total || 0, prompts }, null, 2);
44
+ },
45
+ }),
46
+
47
+ get_prompt: tool({
48
+ description: "Get a specific prompt by ID with full content and all metadata.",
49
+ args: {
50
+ id: tool.schema.string({ description: "Prompt ID (UUID)" }),
51
+ },
52
+ async execute(args) {
53
+ const data = await fetchApi(`/api/v1/prompts/${args.id}`);
54
+ return JSON.stringify({
55
+ id: data.id,
56
+ title: data.title,
57
+ description: data.description,
58
+ content: data.content,
59
+ model: data.model,
60
+ author: data.author,
61
+ category: data.category,
62
+ tags: data.tags,
63
+ stats: data.stats,
64
+ url: `${BASE_URL}/prompts/${data.id}`,
65
+ }, null, 2);
66
+ },
67
+ }),
68
+
69
+ get_trending_prompts: tool({
70
+ description: "Get currently trending AI prompts.",
71
+ args: {
72
+ limit: tool.schema.number({ description: "Max results (1-50)", optional: true }),
73
+ },
74
+ async execute(args) {
75
+ const limit = args.limit ? Math.min(args.limit, 50) : 10;
76
+ const data = await fetchApi(`/api/v1/prompts?sort=trending&limit=${limit}`);
77
+ const prompts = (data.data || []).map(p => ({
78
+ id: p.id,
79
+ title: p.title,
80
+ model: p.model,
81
+ author: p.author?.displayName || p.author?.username || "anonymous",
82
+ url: `${BASE_URL}/prompts/${p.id}`,
83
+ stats: p.stats,
84
+ }));
85
+ return JSON.stringify({ count: prompts.length, prompts }, null, 2);
86
+ },
87
+ }),
88
+ },
89
+ };
90
+ };
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "opencode-promptforge",
3
+ "version": "1.0.0",
4
+ "description": "OpenCode plugin for PromptForge — search and retrieve AI prompts from your terminal",
5
+ "type": "module",
6
+ "main": "index.js",
7
+ "files": [
8
+ "index.js"
9
+ ],
10
+ "keywords": [
11
+ "opencode",
12
+ "plugin",
13
+ "promptforge",
14
+ "ai",
15
+ "prompts"
16
+ ],
17
+ "publishConfig": { "access": "public" },
18
+ "license": "MIT",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/jordan-thirkle/promptforge.git",
22
+ "directory": "opencode-plugin"
23
+ },
24
+ "dependencies": {
25
+ "@opencode-ai/plugin": "^1.15.12"
26
+ }
27
+ }