devscribe-reason 1.0.13 → 1.0.14

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 (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/cli.js +36 -4
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devscribe-reason",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
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/cli.js CHANGED
@@ -1,18 +1,50 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  import { fileURLToPath } from "node:url";
4
- import { dirname } from "node:path";
4
+ import { dirname, join } from "node:path";
5
5
  import { spawn } from "node:child_process";
6
+ import { existsSync } from "node:fs";
6
7
 
7
8
  const args = process.argv.slice(2);
8
9
  const command = args[0];
10
+ const __filename = fileURLToPath(import.meta.url);
11
+ const __dirname = dirname(__filename);
9
12
 
10
- // If no command or "server" command, run the MCP server
13
+ // If no command or "server" command, check if setup is needed
11
14
  if (!command || command === "server") {
12
- const __filename = fileURLToPath(import.meta.url);
15
+ // Check if setup is needed (look for .claude.md and .cursor/mcp.json)
16
+ const claudeMdExists = existsSync(join(process.cwd(), ".claude.md"));
17
+ const cursorMcpExists = existsSync(join(process.cwd(), ".cursor/mcp.json"));
18
+
19
+ // If neither exists, run setup first
20
+ if (!claudeMdExists && !cursorMcpExists) {
21
+ console.log("No setup detected. Running setup first...\n");
22
+ const setupProcess = spawn("node", [join(__dirname, "setup.js")], {
23
+ stdio: "inherit",
24
+ env: process.env,
25
+ });
26
+
27
+ setupProcess.on("error", (err) => {
28
+ console.error("Failed to run setup:", err);
29
+ process.exit(1);
30
+ });
31
+
32
+ setupProcess.on("exit", (code) => {
33
+ if (code !== 0) {
34
+ process.exit(code);
35
+ }
36
+ // After setup, start the server
37
+ console.log("\nStarting MCP server...\n");
38
+ startServer();
39
+ });
40
+ } else {
41
+ startServer();
42
+ }
43
+ }
13
44
 
45
+ function startServer() {
14
46
  // Spawn the server directly without shelling out
15
- const serverProcess = spawn("node", [dirname(__filename) + "/../src/index.js"], {
47
+ const serverProcess = spawn("node", [join(__dirname, "../src/index.js")], {
16
48
  stdio: "inherit",
17
49
  env: process.env,
18
50
  });