promptgraph-mcp 2.9.6 → 2.9.8

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.
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "promptgraph",
3
+ "description": "Semantic skill router for Claude Code — search and load only the skills you need, saving 20k+ tokens per session. Includes a marketplace with 40+ community skill bundles.",
4
+ "author": {
5
+ "name": "NeiP4n"
6
+ },
7
+ "homepage": "https://github.com/NeiP4n/promptgraph"
8
+ }
package/.mcp.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "promptgraph": {
3
+ "command": "npx",
4
+ "args": ["-y", "promptgraph-mcp"]
5
+ }
6
+ }
package/commands/init.js CHANGED
@@ -1,83 +1,99 @@
1
- import { colors, banner, success, error, info, section, table } from '../cli.js';
2
- import chalk from 'chalk';
3
- import boxen from 'boxen';
4
-
5
- const PLATFORM_CONFIGS = {
6
- 'claude-code': {
7
- label: 'Claude Code — ~/.claude/settings.json',
8
- snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
9
- },
10
- 'claude-desktop': {
11
- label: 'Claude Desktop — claude_desktop_config.json',
12
- snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
13
- },
14
- 'opencode': {
15
- label: 'OpenCode — opencode.json',
16
- snippet: { mcp: { promptgraph: { type: 'local', command: ['npx', 'promptgraph-mcp'], enabled: true } } },
17
- },
18
- 'cursor': {
19
- label: 'Cursor — ~/.cursor/mcp.json',
20
- snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
21
- },
22
- 'windsurf': {
23
- label: 'Windsurf — mcp_config.json',
24
- snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
25
- },
26
- 'cline': {
27
- label: 'Cline — ~/.vscode/mcp.json',
28
- snippet: { servers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
29
- },
30
- 'codex': {
31
- label: 'OpenAI Codex CLI — ~/.codex/config.json',
32
- snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
33
- },
34
- };
35
-
36
- export default async function handler(args, bin) {
37
- const { promptConfig } = await import('../config.js');
38
- const { indexAll } = await import('../indexer.js');
39
- const { detectPlatforms, PLATFORMS } = await import('../platform.js');
40
-
41
- if (!args.includes('--yes') && !args.includes('-y')) {
42
- const readline = await import('readline');
43
- const rl = readline.default.createInterface({ input: process.stdin, output: process.stdout });
44
- const answer = await new Promise(r => rl.question(
45
- chalk.yellow(' ⚠') + chalk.gray(' First run downloads ~23 MB embedding model (BGE-Small-EN).\n Proceed? [Y/n] '), r
46
- ));
47
- rl.close();
48
- if (answer.trim().toLowerCase() === 'n') { info('Aborted.'); process.exit(0); }
49
- }
50
- console.log(chalk.gray('\n Downloading embedding model (~23 MB, one-time)...\n'));
51
- const config = await promptConfig();
52
- await indexAll();
53
- console.log();
54
-
55
- const detected = detectPlatforms().map(p => p.id);
56
- const toShow = detected.length > 0 ? detected : ['claude-code', 'opencode'];
57
-
58
- for (const id of toShow) {
59
- const cfg = PLATFORM_CONFIGS[id];
60
- if (!cfg) continue;
61
- const platform = PLATFORMS[id];
62
- if (platform) {
63
- try { platform.addMcp(platform); } catch {}
64
- }
65
- console.log(
66
- boxen(
67
- chalk.white.bold(cfg.label) + '\n\n' +
68
- chalk.gray(JSON.stringify(cfg.snippet, null, 2)),
69
- { padding: 1, borderStyle: 'round', borderColor: '#7C3AED', dimBorder: true }
70
- )
71
- );
72
- }
73
-
74
- if (detected.length > 0) {
75
- console.log(chalk.green(' ✓') + chalk.gray(' Config written automatically to detected platforms.'));
76
- console.log(chalk.gray(' Restart your editor/client to activate.\n'));
77
- } else {
78
- console.log(chalk.gray(' Copy the snippet above into your editor config, then restart.\n'));
79
- console.log(chalk.gray(' Or run: ') + chalk.white('pg setup <platform>') + chalk.gray(' (claude-code, opencode, cursor, windsurf, cline, codex)\n'));
80
- }
81
-
82
- process.exit(0);
83
- }
1
+ import chalk from 'chalk';
2
+ import boxen from 'boxen';
3
+ import { success, error, info } from '../cli.js';
4
+
5
+ const PLATFORM_CONFIGS = {
6
+ 'claude-code': {
7
+ label: 'Claude Code — ~/.claude/settings.json',
8
+ snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
9
+ },
10
+ 'claude-desktop': {
11
+ label: 'Claude Desktop — claude_desktop_config.json',
12
+ snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
13
+ },
14
+ 'opencode': {
15
+ label: 'OpenCode — opencode.json',
16
+ snippet: { plugin: ['promptgraph-mcp/plugin'] },
17
+ },
18
+ 'cursor': {
19
+ label: 'Cursor — ~/.cursor/mcp.json',
20
+ snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
21
+ },
22
+ 'windsurf': {
23
+ label: 'Windsurf — mcp_config.json',
24
+ snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
25
+ },
26
+ 'cline': {
27
+ label: 'Cline — ~/.vscode/mcp.json',
28
+ snippet: { servers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
29
+ },
30
+ 'codex': {
31
+ label: 'OpenAI Codex CLI — ~/.codex/config.json',
32
+ snippet: { mcpServers: { promptgraph: { command: 'npx', args: ['promptgraph-mcp'] } } },
33
+ },
34
+ };
35
+
36
+ export default async function handler(args, bin) {
37
+ const { promptConfig } = await import('../config.js');
38
+ const { indexAll } = await import('../indexer.js');
39
+ const { detectPlatforms, PLATFORMS } = await import('../platform.js');
40
+
41
+ if (!args.includes('--yes') && !args.includes('-y')) {
42
+ const { createInterface } = await import('readline');
43
+ const rl = createInterface({ input: process.stdin, output: process.stdout });
44
+ const answer = await new Promise(r => rl.question(
45
+ chalk.yellow(' ⚠') + chalk.gray(' First run downloads ~23 MB embedding model (BGE-Small-EN).\n Proceed? [Y/n] '), r
46
+ ));
47
+ rl.close();
48
+ if (answer.trim().toLowerCase() === 'n') { info('Aborted.'); process.exit(0); }
49
+ }
50
+
51
+ console.log(chalk.gray('\n Downloading embedding model (~23 MB, one-time)...\n'));
52
+ await promptConfig();
53
+ await indexAll();
54
+ console.log();
55
+
56
+ const detected = detectPlatforms();
57
+ const detectedIds = new Set(detected.map(p => p.id));
58
+
59
+ const written = [];
60
+ const writeErrors = [];
61
+ for (const p of detected) {
62
+ try {
63
+ p.addMcp(p);
64
+ written.push(p.name || p.id);
65
+ } catch (e) {
66
+ writeErrors.push(`${p.id}: ${e.message}`);
67
+ }
68
+ }
69
+
70
+ const toShow = detectedIds.size > 0
71
+ ? [...detectedIds]
72
+ : ['claude-code', 'opencode'];
73
+
74
+ for (const id of toShow) {
75
+ const cfg = PLATFORM_CONFIGS[id];
76
+ if (!cfg) continue;
77
+ console.log(
78
+ boxen(
79
+ chalk.white.bold(cfg.label) + '\n\n' +
80
+ chalk.gray(JSON.stringify(cfg.snippet, null, 2)),
81
+ { padding: 1, borderStyle: 'round', borderColor: '#7C3AED', dimBorder: true }
82
+ )
83
+ );
84
+ }
85
+
86
+ if (written.length > 0) {
87
+ console.log(chalk.green(' ✓') + chalk.gray(` Config written automatically to: ${written.join(', ')}`));
88
+ console.log(chalk.gray(' Restart your editor/client to activate.\n'));
89
+ } else {
90
+ console.log(chalk.gray(' Copy the snippet above into your editor config, then restart.\n'));
91
+ console.log(chalk.gray(` Or run: `) + chalk.white(`${bin} setup <platform>`) + chalk.gray(' (claude-code, opencode, cursor, windsurf, cline, codex)\n'));
92
+ }
93
+
94
+ if (writeErrors.length > 0) {
95
+ for (const e of writeErrors) console.log(chalk.red(' ✗') + chalk.gray(' ' + e));
96
+ }
97
+
98
+ process.exit(0);
99
+ }
@@ -0,0 +1,14 @@
1
+ export const PromptGraph = async () => {
2
+ return {
3
+ config: async (config) => {
4
+ config.mcp = config.mcp || {};
5
+ config.mcp.promptgraph = {
6
+ type: 'local',
7
+ command: ['npx', 'promptgraph-mcp'],
8
+ enabled: true,
9
+ };
10
+ },
11
+ };
12
+ };
13
+
14
+ export default PromptGraph;
package/package.json CHANGED
@@ -1,13 +1,19 @@
1
1
  {
2
2
  "name": "promptgraph-mcp",
3
- "version": "2.9.6",
3
+ "version": "2.9.8",
4
4
  "files": [
5
5
  "*.js",
6
6
  "commands/",
7
7
  "src/",
8
- "README.md"
8
+ "README.md",
9
+ ".claude-plugin/",
10
+ ".mcp.json"
9
11
  ],
10
12
  "main": "index.js",
13
+ "exports": {
14
+ ".": "./index.js",
15
+ "./plugin": "./opencode-plugin.js"
16
+ },
11
17
  "type": "module",
12
18
  "bin": {
13
19
  "pg": "index.js",
package/platform.js CHANGED
@@ -26,11 +26,12 @@ function addClineMcp(configPath) {
26
26
  writeJson(configPath, json);
27
27
  }
28
28
 
29
- // OpenCode uses mcp.promptgraph with type/command/enabled
29
+ // OpenCode uses plugin array
30
30
  function addOpenCodeMcp(configPath) {
31
31
  const json = readJson(configPath) || {};
32
- json.mcp = json.mcp || {};
33
- json.mcp.promptgraph = OC_ENTRY;
32
+ json.plugin = json.plugin || [];
33
+ const entry = 'promptgraph-mcp/plugin';
34
+ if (!json.plugin.includes(entry)) json.plugin.push(entry);
34
35
  fs.mkdirSync(path.dirname(configPath), { recursive: true });
35
36
  writeJson(configPath, json);
36
37
  }
@@ -79,18 +80,22 @@ export function detectPlatforms() {
79
80
  if (!p.configPath) return false;
80
81
  if (fs.existsSync(path.dirname(p.configPath))) return true;
81
82
  if (id === 'opencode') return isOpenCodeInstalled();
83
+ if (id === 'claude-code') return isClaudeCodeInstalled();
82
84
  return false;
83
85
  })
84
86
  .map(([id, p]) => ({ id, ...p }));
85
87
  }
86
88
 
87
- function isOpenCodeInstalled() {
89
+ function isBinaryInstalled(bin) {
88
90
  try {
89
- const r = spawnSync('opencode', ['--version'], { encoding: 'utf8', timeout: 3000 });
91
+ const r = spawnSync(bin, ['--version'], { encoding: 'utf8', timeout: 3000, stdio: 'pipe' });
90
92
  return r.status === 0;
91
93
  } catch { return false; }
92
94
  }
93
95
 
96
+ function isOpenCodeInstalled() { return isBinaryInstalled('opencode'); }
97
+ function isClaudeCodeInstalled() { return isBinaryInstalled('claude'); }
98
+
94
99
  function getOpenCodeConfig() {
95
100
  if (process.platform === 'win32') return path.join(HOME, 'AppData', 'Roaming', 'opencode', 'opencode.json');
96
101
  if (process.platform === 'darwin') return path.join(HOME, 'Library', 'Application Support', 'opencode', 'opencode.json');