devscribe-reason 1.0.0 → 1.0.2

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.
@@ -18,7 +18,11 @@
18
18
  "Bash(npm unlink:*)",
19
19
  "Bash(GITHUB_TOKEN=ghp_test npm run setup)",
20
20
  "Bash(node -c scripts/setup.js)",
21
- "Bash(git -C . status --short)"
21
+ "Bash(git -C . status --short)",
22
+ "mcp__devscribe-reason__log_intent",
23
+ "Bash(npm publish:*)",
24
+ "mcp__devscribe-reason__log_decision",
25
+ "mcp__devscribe-reason__finalize_reasoning_doc"
22
26
  ]
23
27
  }
24
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devscribe-reason",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "MCP server that captures engineering decision reasoning and commits structured markdown to GitHub",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
package/scripts/setup.js CHANGED
@@ -1,14 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { execSync } from "node:child_process";
4
- import { existsSync } from "node:fs";
5
- import { resolve, dirname, join } from "node:path";
6
- import { fileURLToPath } from "node:url";
4
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
5
+ import { join } from "node:path";
7
6
  import { homedir } from "node:os";
8
7
  import { globSync } from "glob";
9
8
 
10
- const __dirname = dirname(fileURLToPath(import.meta.url));
11
- const serverPath = resolve(__dirname, "../src/index.js");
12
9
  const token = process.env.GITHUB_TOKEN || "";
13
10
  const repo = process.env.GITHUB_REPO || "";
14
11
  const branch = process.env.GITHUB_BRANCH || "main";
@@ -55,6 +52,23 @@ function findClaudeBinary() {
55
52
  return null;
56
53
  }
57
54
 
55
+ // Detect if Claude Code is available
56
+ function isClaudeCodeAvailable() {
57
+ return findClaudeBinary() !== null;
58
+ }
59
+
60
+ // Detect if Cursor is available
61
+ function isCursorAvailable() {
62
+ // Check if .cursor folder exists in current directory or if Cursor.app is installed on macOS
63
+ const cursorDir = join(process.cwd(), ".cursor");
64
+ if (existsSync(cursorDir)) return true;
65
+
66
+ // Check for Cursor installation on macOS
67
+ if (existsSync("/Applications/Cursor.app")) return true;
68
+
69
+ return false;
70
+ }
71
+
58
72
  // Build env args for the CLI
59
73
  const envArgs = [
60
74
  token && `-e GITHUB_TOKEN=${token}`,
@@ -64,31 +78,77 @@ const envArgs = [
64
78
  .filter(Boolean)
65
79
  .join(" ");
66
80
 
67
- const claudeCmd = findClaudeBinary();
81
+ const claudeAvailable = isClaudeCodeAvailable();
82
+ const cursorAvailable = isCursorAvailable();
68
83
 
69
- if (!claudeCmd) {
70
- console.error(
71
- "\n❌ Could not find the 'claude' command. Please ensure you have:\n"
72
- );
73
- console.error(" Claude Code CLI installed (https://claude.com/claude-code)");
74
- console.error(" Or VS Code with the Claude Code extension");
75
- console.error(" Or Cursor with Claude Code support\n");
76
- console.error("After installation, run: npm run setup\n");
84
+ if (!claudeAvailable && !cursorAvailable) {
85
+ console.error("\n❌ Could not find Claude Code or Cursor.\n");
86
+ console.error("Manual setup required:\n");
87
+ console.error("📌 For Claude Code:");
88
+ console.error(" 1. Install Claude Code: https://claude.com/claude-code");
89
+ console.error(" 2. Run: GITHUB_TOKEN=your_token npx devscribe-reason\n");
90
+ console.error("📌 For Cursor:");
91
+ console.error(" 1. Install Cursor: https://cursor.com");
92
+ console.error(" 2. Create .cursor/mcp.json in your project with:");
93
+ console.error(' {\n "mcpServers": {\n "devscribe-reason": {\n "command": "npx",\n "args": ["-y", "devscribe-reason"],\n "env": {\n "GITHUB_TOKEN": "your_token",\n "GITHUB_BRANCH": "main"\n }\n }\n }\n }');
94
+ console.error("");
77
95
  process.exit(1);
78
96
  }
79
97
 
80
- const cmd = `${claudeCmd} mcp add --scope user devscribe-reason node ${serverPath} ${envArgs}`;
98
+ // Setup for Claude Code
99
+ if (claudeAvailable) {
100
+ const claudeCmd = findClaudeBinary();
101
+ const cmd = `${claudeCmd} mcp add --scope user devscribe-reason npx devscribe-reason ${envArgs}`;
81
102
 
82
- try {
83
- execSync(cmd, { stdio: "inherit" });
84
- console.log(
85
- "\n✅ Setup complete. devscribe-reason is now active in all your Claude Code sessions."
86
- );
87
- console.log(
88
- "\nTo verify: Open Claude Code and check Settings > MCP Servers\n"
89
- );
90
- } catch (err) {
91
- console.error("\n❌ Setup failed. Run this command manually:\n");
92
- console.error(` ${cmd}\n`);
93
- process.exit(1);
103
+ try {
104
+ execSync(cmd, { stdio: "inherit" });
105
+ console.log("\n✅ Claude Code detected — devscribe-reason registered globally");
106
+ } catch (err) {
107
+ console.error("\n❌ Claude Code setup failed. Run this command manually:\n");
108
+ console.error(` ${cmd}\n`);
109
+ if (!cursorAvailable) {
110
+ process.exit(1);
111
+ }
112
+ }
113
+ }
114
+
115
+ // Setup for Cursor
116
+ if (cursorAvailable) {
117
+ try {
118
+ const cursorDir = join(process.cwd(), ".cursor");
119
+ const mcpJsonPath = join(cursorDir, "mcp.json");
120
+
121
+ // Create .cursor directory if it doesn't exist
122
+ if (!existsSync(cursorDir)) {
123
+ mkdirSync(cursorDir, { recursive: true });
124
+ }
125
+
126
+ // Create or update mcp.json
127
+ const mcpConfig = {
128
+ mcpServers: {
129
+ "devscribe-reason": {
130
+ command: "npx",
131
+ args: ["-y", "devscribe-reason"],
132
+ env: {
133
+ ...(token && { GITHUB_TOKEN: token }),
134
+ ...(repo && { GITHUB_REPO: repo }),
135
+ GITHUB_BRANCH: branch,
136
+ },
137
+ },
138
+ },
139
+ };
140
+
141
+ writeFileSync(mcpJsonPath, JSON.stringify(mcpConfig, null, 2));
142
+ console.log("\n✅ Cursor detected — .cursor/mcp.json created in current directory");
143
+ } catch (err) {
144
+ console.error("\n❌ Cursor setup failed:", err.message);
145
+ if (!claudeAvailable) {
146
+ process.exit(1);
147
+ }
148
+ }
149
+ }
150
+
151
+ if (claudeAvailable || cursorAvailable) {
152
+ console.log("\n📝 To use devscribe-reason in your sessions:");
153
+ console.log(" GITHUB_TOKEN=your_token npx devscribe-reason\n");
94
154
  }