Skip to content

Commit 9597ee1

Browse files
committed
fix: Check common install paths and use getting-started URL
Address CodeRabbit review feedback: - Use /getting-started URL instead of /overview for install links - Rename "Claude CLI" to "Claude Code CLI" for consistency Fix false warning when running as MCP server with minimal PATH: - Fall back to checking common install locations (~/.local/bin, ~/.bun/bin, /usr/local/bin) when PATH-based lookup fails
1 parent 6827451 commit 9597ee1

File tree

2 files changed

+35
-7
lines changed

2 files changed

+35
-7
lines changed

packages/tm-core/src/modules/loop/services/loop.service.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ Loop iteration ${iteration} of ${config.iterations}${tagInfo}`;
586586
if (error.code === 'ENOENT') {
587587
return sandbox
588588
? 'Docker is not installed. Install Docker Desktop to use --sandbox mode.'
589-
: 'Claude CLI is not installed. Install it from: https://docs.anthropic.com/en/docs/claude-code/overview';
589+
: 'Claude Code CLI is not installed. Install it from: https://docs.anthropic.com/en/docs/claude-code/getting-started';
590590
}
591591

592592
if (error.code === 'EACCES') {

src/ai-providers/claude-code.js

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
*/
1313

1414
import { execSync } from 'child_process';
15+
import { existsSync } from 'fs';
16+
import { join } from 'path';
17+
import { homedir } from 'os';
1518
import { createClaudeCode } from 'ai-sdk-provider-claude-code';
1619
import {
1720
getClaudeCodeSettingsForCommand,
@@ -82,11 +85,36 @@ export class ClaudeCodeProvider extends BaseAIProvider {
8285
execSync('claude --version', { stdio: 'pipe', timeout: 1000 });
8386
_claudeCliAvailable = true;
8487
} catch (error) {
85-
_claudeCliAvailable = false;
86-
log(
87-
'warn',
88-
'Claude Code CLI not detected. Install it from: https://docs.anthropic.com/en/docs/claude-code/overview'
89-
);
88+
// PATH-based lookup failed - check common install locations
89+
// The native binary may be installed outside the current PATH
90+
// (e.g. when running as an MCP server with a minimal environment)
91+
const home = homedir();
92+
const commonPaths = [
93+
join(home, '.local', 'bin', 'claude'),
94+
join(home, '.bun', 'bin', 'claude'),
95+
'/usr/local/bin/claude'
96+
];
97+
const found = commonPaths.find((p) => existsSync(p));
98+
if (found) {
99+
try {
100+
execSync(`"${found}" --version`, {
101+
stdio: 'pipe',
102+
timeout: 1000
103+
});
104+
_claudeCliAvailable = true;
105+
} catch {
106+
_claudeCliAvailable = false;
107+
}
108+
} else {
109+
_claudeCliAvailable = false;
110+
}
111+
112+
if (!_claudeCliAvailable) {
113+
log(
114+
'warn',
115+
'Claude Code CLI not detected. Install it from: https://docs.anthropic.com/en/docs/claude-code/getting-started'
116+
);
117+
}
90118
} finally {
91119
_claudeCliChecked = true;
92120
}
@@ -147,7 +175,7 @@ export class ClaudeCodeProvider extends BaseAIProvider {
147175
const code = error?.code;
148176
if (code === 'ENOENT' || /claude/i.test(msg)) {
149177
const enhancedError = new Error(
150-
`Claude Code CLI not available. Install it from: https://docs.anthropic.com/en/docs/claude-code/overview - Original error: ${error.message}`
178+
`Claude Code CLI not available. Install it from: https://docs.anthropic.com/en/docs/claude-code/getting-started - Original error: ${error.message}`
151179
);
152180
enhancedError.cause = error;
153181
this.handleError('Claude Code CLI initialization', enhancedError);

0 commit comments

Comments
 (0)