Skip to content

Commit abff220

Browse files
committed
fix: windows claude code detection working
1 parent 3587d89 commit abff220

1 file changed

Lines changed: 52 additions & 3 deletions

File tree

src-node/claude-code-agent.js

Lines changed: 52 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@
2727
*/
2828

2929
const { execSync } = require("child_process");
30+
const fs = require("fs");
3031
const path = require("path");
3132
const { createEditorMcpServer } = require("./mcp-editor-tools");
3233

34+
const isWindows = process.platform === "win32";
35+
3336
const CONNECTOR_ID = "ph_ai_claude";
3437

3538
const CLARIFICATION_HINT =
@@ -71,9 +74,45 @@ async function getQueryFn() {
7174
}
7275

7376
/**
74-
* Find the user's globally installed Claude CLI, skipping node_modules copies.
77+
* Find the user's globally installed Claude CLI on Windows.
7578
*/
76-
function findGlobalClaudeCli() {
79+
function _findGlobalClaudeCliWin() {
80+
const userHome = process.env.USERPROFILE || process.env.HOME || "";
81+
const locations = [
82+
path.join(userHome, ".local", "bin", "claude.exe"),
83+
path.join(process.env.APPDATA || "", "npm", "claude.cmd"),
84+
path.join(process.env.LOCALAPPDATA || "", "Programs", "claude", "claude.exe")
85+
];
86+
87+
// Try 'where claude' first to find claude in PATH
88+
try {
89+
const allPaths = execSync("where claude", { encoding: "utf8" })
90+
.trim()
91+
.split("\r\n")
92+
.filter(p => p && !p.includes("node_modules"));
93+
if (allPaths.length > 0) {
94+
console.log("[Phoenix AI] Found global Claude CLI at:", allPaths[0]);
95+
return allPaths[0];
96+
}
97+
} catch {
98+
// where failed, try manual locations
99+
}
100+
101+
// Check common Windows locations
102+
for (const loc of locations) {
103+
if (loc && fs.existsSync(loc)) {
104+
console.log("[Phoenix AI] Found global Claude CLI at:", loc);
105+
return loc;
106+
}
107+
}
108+
109+
return null;
110+
}
111+
112+
/**
113+
* Find the user's globally installed Claude CLI on macOS/Linux.
114+
*/
115+
function _findGlobalClaudeCliLinuxMac() {
77116
const locations = [
78117
"/usr/local/bin/claude",
79118
"/usr/bin/claude",
@@ -108,10 +147,20 @@ function findGlobalClaudeCli() {
108147
}
109148
}
110149

111-
console.log("[Phoenix AI] Global Claude CLI not found");
112150
return null;
113151
}
114152

153+
/**
154+
* Find the user's globally installed Claude CLI, skipping node_modules copies.
155+
*/
156+
function findGlobalClaudeCli() {
157+
const claudePath = isWindows ? _findGlobalClaudeCliWin() : _findGlobalClaudeCliLinuxMac();
158+
if (!claudePath) {
159+
console.log("[Phoenix AI] Global Claude CLI not found");
160+
}
161+
return claudePath;
162+
}
163+
115164
/**
116165
* Check whether Claude CLI is available.
117166
* Called from browser via execPeer("checkAvailability").

0 commit comments

Comments
 (0)