devscribe-reason 1.0.13 → 1.0.15
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/package.json +1 -1
- package/scripts/cli.js +36 -4
- package/scripts/setup.js +16 -1
package/package.json
CHANGED
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,
|
|
13
|
+
// If no command or "server" command, check if setup is needed
|
|
11
14
|
if (!command || command === "server") {
|
|
12
|
-
|
|
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", [
|
|
47
|
+
const serverProcess = spawn("node", [join(__dirname, "../src/index.js")], {
|
|
16
48
|
stdio: "inherit",
|
|
17
49
|
env: process.env,
|
|
18
50
|
});
|
package/scripts/setup.js
CHANGED
|
@@ -8,7 +8,7 @@ import { globSync } from "glob";
|
|
|
8
8
|
|
|
9
9
|
const token = process.env.GITHUB_TOKEN || "";
|
|
10
10
|
let repo = process.env.GITHUB_REPO || "";
|
|
11
|
-
|
|
11
|
+
let branch = process.env.GITHUB_BRANCH || "";
|
|
12
12
|
|
|
13
13
|
// Auto-detect GitHub repo from git remote if not provided
|
|
14
14
|
if (!repo) {
|
|
@@ -30,6 +30,21 @@ if (!repo) {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
// Auto-detect current branch from git if not provided
|
|
34
|
+
if (!branch) {
|
|
35
|
+
try {
|
|
36
|
+
branch = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
37
|
+
stdio: "pipe",
|
|
38
|
+
timeout: 1000,
|
|
39
|
+
})
|
|
40
|
+
.toString()
|
|
41
|
+
.trim();
|
|
42
|
+
} catch {
|
|
43
|
+
// git command failed, default to main
|
|
44
|
+
branch = "main";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
33
48
|
// Try to find the claude binary in common locations
|
|
34
49
|
function findClaudeBinary() {
|
|
35
50
|
// 1. Try 'which claude' if claude is in PATH
|