contextswitch 0.1.7 → 0.1.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.
|
@@ -251,7 +251,11 @@ ${psScript}`);
|
|
|
251
251
|
/**
|
|
252
252
|
* Get the Claude executable path (public accessor)
|
|
253
253
|
*/
|
|
254
|
-
getClaudeExecutable() {
|
|
254
|
+
getClaudeExecutable(configClaudePath) {
|
|
255
|
+
if (configClaudePath && existsSync(configClaudePath)) {
|
|
256
|
+
debug("process", `Using claudePath from config: ${configClaudePath}`);
|
|
257
|
+
return configClaudePath;
|
|
258
|
+
}
|
|
255
259
|
return this.findClaudeExecutable();
|
|
256
260
|
}
|
|
257
261
|
/**
|
|
@@ -395,9 +399,26 @@ ${psScript}`);
|
|
|
395
399
|
try {
|
|
396
400
|
if (this.platform === "win32") {
|
|
397
401
|
const output = execSync("where claude", { encoding: "utf-8" }).trim();
|
|
398
|
-
const
|
|
399
|
-
debug("process", `
|
|
400
|
-
|
|
402
|
+
const candidates = output.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
|
403
|
+
debug("process", `'where claude' returned ${candidates.length} result(s): ${candidates.join(", ")}`);
|
|
404
|
+
const cliIndicators = ["npm", "node_modules", "bun", "nvm", ".volta", "Roaming"];
|
|
405
|
+
const guiIndicators = ["Program Files", "AppData\\Local\\claude", "AppData\\Local\\Programs\\claude"];
|
|
406
|
+
for (const candidate of candidates) {
|
|
407
|
+
const isLikelyCLI = cliIndicators.some((ind) => candidate.toLowerCase().includes(ind.toLowerCase()));
|
|
408
|
+
if (isLikelyCLI) {
|
|
409
|
+
debug("process", `Selected CLI candidate: ${candidate}`);
|
|
410
|
+
return candidate;
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
for (const candidate of candidates) {
|
|
414
|
+
const isLikelyGUI = guiIndicators.some((ind) => candidate.toLowerCase().includes(ind.toLowerCase()));
|
|
415
|
+
if (!isLikelyGUI) {
|
|
416
|
+
debug("process", `Selected non-GUI candidate: ${candidate}`);
|
|
417
|
+
return candidate;
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
debug("process", `Falling back to first 'where' result: ${candidates[0]}`);
|
|
421
|
+
return candidates[0] || null;
|
|
401
422
|
} else {
|
|
402
423
|
const output = execSync("which claude", { encoding: "utf-8" }).trim();
|
|
403
424
|
debug("process", `Found Claude via 'which': ${output}`);
|
|
@@ -406,11 +427,13 @@ ${psScript}`);
|
|
|
406
427
|
} catch {
|
|
407
428
|
debug("process", "Claude not found via PATH, checking common install locations");
|
|
408
429
|
const commonPaths = this.platform === "win32" ? [
|
|
409
|
-
|
|
410
|
-
join(process.env.
|
|
411
|
-
join(process.env.
|
|
412
|
-
|
|
413
|
-
"
|
|
430
|
+
// npm global installs
|
|
431
|
+
join(process.env.APPDATA || "", "npm", "claude.cmd"),
|
|
432
|
+
join(process.env.APPDATA || "", "npm", "claude"),
|
|
433
|
+
// bun installs
|
|
434
|
+
join(process.env.USERPROFILE || "", ".bun", "bin", "claude.exe"),
|
|
435
|
+
// Volta
|
|
436
|
+
join(process.env.USERPROFILE || "", ".volta", "bin", "claude.exe")
|
|
414
437
|
] : [
|
|
415
438
|
"/usr/local/bin/claude",
|
|
416
439
|
"/usr/bin/claude",
|
package/dist/cli.js
CHANGED
|
@@ -24,7 +24,7 @@ function getVersion() {
|
|
|
24
24
|
const packageJson = JSON.parse(readFileSync(packagePath, "utf-8"));
|
|
25
25
|
return packageJson.version;
|
|
26
26
|
} catch {
|
|
27
|
-
return "0.1.
|
|
27
|
+
return "0.1.8";
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
function processSessionFallbackMarker() {
|
|
@@ -193,7 +193,7 @@ program.command("switch <domain>").description("Switch to a domain and launch Cl
|
|
|
193
193
|
console.error(pc.red(`\u274C Invalid launch mode '${options.mode}'. Must be: window, tab, or inline`));
|
|
194
194
|
process.exit(1);
|
|
195
195
|
}
|
|
196
|
-
const { switchCommand } = await import("./switch-
|
|
196
|
+
const { switchCommand } = await import("./switch-HUW2NAZD.js");
|
|
197
197
|
await switchCommand(domain, options);
|
|
198
198
|
});
|
|
199
199
|
program.command("reset <domain>").description("Reset a domain session (archives current session by default)").option("--skip-archive", "Skip archiving the current session").option("-f, --force", "Skip confirmation prompt").action(async (domain, options) => {
|
|
@@ -299,7 +299,7 @@ domainCmd.command("remove <name>").alias("rm").description("Remove a domain from
|
|
|
299
299
|
}
|
|
300
300
|
});
|
|
301
301
|
program.command("doctor").description("Check system configuration and diagnose issues").action(async () => {
|
|
302
|
-
const { processManager } = await import("./process-
|
|
302
|
+
const { processManager } = await import("./process-AKHWPKQE.js");
|
|
303
303
|
console.log(pc.cyan("\u{1FA7A} Running diagnostics...\n"));
|
|
304
304
|
const failures = [];
|
|
305
305
|
const claudeInstalled = processManager.verifyClaudeInstalled();
|
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-MGIXKKM6.js";
|
|
4
4
|
import {
|
|
5
5
|
processManager
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7GF2GND2.js";
|
|
7
7
|
import {
|
|
8
8
|
LAUNCH_MODES,
|
|
9
9
|
configManager,
|
|
@@ -79,10 +79,10 @@ async function switchCommand(domainName, options = {}) {
|
|
|
79
79
|
if (!isNewSession) {
|
|
80
80
|
const fallbackSessionId = SessionManager.generateSessionId(domainName, true);
|
|
81
81
|
debug("switch", `Resume with fallback: resume=${sessionId.substring(0, 8)}, fallback=${fallbackSessionId.substring(0, 8)}`);
|
|
82
|
-
spawnClaudeWithFallback(domain, sessionId, fallbackSessionId, launchMode);
|
|
82
|
+
spawnClaudeWithFallback(domain, sessionId, fallbackSessionId, launchMode, globalConfig.claudePath);
|
|
83
83
|
} else {
|
|
84
84
|
debug("switch", `New session: ${sessionId.substring(0, 8)}`);
|
|
85
|
-
spawnClaudeNewSession(domain, sessionId, launchMode);
|
|
85
|
+
spawnClaudeNewSession(domain, sessionId, launchMode, globalConfig.claudePath);
|
|
86
86
|
}
|
|
87
87
|
const newState = {
|
|
88
88
|
...state,
|
|
@@ -191,8 +191,8 @@ function buildEnvLines(env) {
|
|
|
191
191
|
}
|
|
192
192
|
return lines.join("\n");
|
|
193
193
|
}
|
|
194
|
-
function spawnClaudeNewSession(domain, sessionId, mode = "window") {
|
|
195
|
-
const claudeCmd = processManager.getClaudeExecutable();
|
|
194
|
+
function spawnClaudeNewSession(domain, sessionId, mode = "window", configClaudePath) {
|
|
195
|
+
const claudeCmd = processManager.getClaudeExecutable(configClaudePath);
|
|
196
196
|
if (!claudeCmd) {
|
|
197
197
|
throw new Error("Claude CLI not found");
|
|
198
198
|
}
|
|
@@ -207,8 +207,8 @@ function spawnClaudeNewSession(domain, sessionId, mode = "window") {
|
|
|
207
207
|
].join("\n");
|
|
208
208
|
return processManager.spawnTerminalScript(script, cwd, mode);
|
|
209
209
|
}
|
|
210
|
-
function spawnClaudeWithFallback(domain, resumeSessionId, fallbackSessionId, mode = "window") {
|
|
211
|
-
const claudeCmd = processManager.getClaudeExecutable();
|
|
210
|
+
function spawnClaudeWithFallback(domain, resumeSessionId, fallbackSessionId, mode = "window", configClaudePath) {
|
|
211
|
+
const claudeCmd = processManager.getClaudeExecutable(configClaudePath);
|
|
212
212
|
if (!claudeCmd) {
|
|
213
213
|
throw new Error("Claude CLI not found");
|
|
214
214
|
}
|
|
@@ -251,13 +251,17 @@ function getSessionFallbackPath() {
|
|
|
251
251
|
}
|
|
252
252
|
function printClaudeInstallHelp() {
|
|
253
253
|
console.error(pc.red("\u274C Claude Code CLI not found\n"));
|
|
254
|
-
console.log(pc.white("ContextSwitch requires the Claude Code CLI
|
|
255
|
-
console.log(pc.cyan("Install via npm
|
|
254
|
+
console.log(pc.white("ContextSwitch requires the Claude Code CLI (not the desktop app).\n"));
|
|
255
|
+
console.log(pc.cyan("Install via npm:"));
|
|
256
256
|
console.log(pc.gray(" npm install -g @anthropic-ai/claude-code\n"));
|
|
257
257
|
console.log(pc.cyan("Or see the official docs:"));
|
|
258
258
|
console.log(pc.gray(" https://docs.anthropic.com/en/docs/claude-code\n"));
|
|
259
259
|
console.log(pc.white("After installing, verify it works:"));
|
|
260
|
-
console.log(pc.gray(" claude --version
|
|
260
|
+
console.log(pc.gray(" claude --version"));
|
|
261
|
+
console.log(pc.gray(' (should show "Claude Code" not the desktop app)\n'));
|
|
262
|
+
console.log(pc.white('If "claude" opens the desktop GUI instead, set the CLI path explicitly:'));
|
|
263
|
+
console.log(pc.gray(" Edit your config.yml and add:"));
|
|
264
|
+
console.log(pc.gray(" claudePath: /path/to/claude-code/claude\n"));
|
|
261
265
|
console.log(pc.gray("Then try your command again."));
|
|
262
266
|
}
|
|
263
267
|
export {
|