16
16
from codegen .cli .auth .token_manager import get_current_token
17
17
from codegen .cli .commands .claude .claude_log_watcher import ClaudeLogWatcherManager
18
18
from codegen .cli .commands .claude .claude_session_api import (
19
- update_claude_session_status ,
20
- generate_session_id ,
21
19
create_claude_session ,
20
+ generate_session_id ,
21
+ update_claude_session_status ,
22
22
)
23
23
from codegen .cli .commands .claude .config .mcp_setup import add_codegen_mcp_server , cleanup_codegen_mcp_server
24
- from codegen .cli .commands .claude .hooks import cleanup_claude_hook , ensure_claude_hook , get_codegen_url , SESSION_FILE
24
+ from codegen .cli .commands .claude .hooks import SESSION_FILE , cleanup_claude_hook , ensure_claude_hook , get_codegen_url
25
25
from codegen .cli .commands .claude .quiet_console import console
26
+ from codegen .cli .commands .claude .utils import resolve_claude_path
26
27
from codegen .cli .rich .spinners import create_spinner
27
28
from codegen .cli .utils .org import resolve_org_id
28
29
@@ -125,10 +126,24 @@ def _run_claude_interactive(resolved_org_id: int, no_mcp: bool | None) -> None:
125
126
# Initialize log watcher manager
126
127
log_watcher_manager = ClaudeLogWatcherManager ()
127
128
128
- # Test if Claude Code is accessible first
129
- console .print ("🔍 Testing Claude Code accessibility..." , style = "blue" )
129
+ # Resolve Claude CLI path and test accessibility
130
+ claude_path = resolve_claude_path ()
131
+ if not claude_path :
132
+ console .print ("❌ Claude Code CLI not found." , style = "red" )
133
+ console .print (
134
+ "💡 If you migrated a local install, ensure `~/.claude/local/claude` exists, or add it to PATH." ,
135
+ style = "dim" ,
136
+ )
137
+ console .print (
138
+ "💡 Otherwise install globally via npm (e.g., `npm i -g claude`) or run `claude /migrate`." ,
139
+ style = "dim" ,
140
+ )
141
+ update_claude_session_status (session_id , "ERROR" , resolved_org_id )
142
+ raise typer .Exit (1 )
143
+
144
+ console .print (f"🔍 Using Claude CLI at: { claude_path } " , style = "blue" )
130
145
try :
131
- test_result = subprocess .run (["claude" , "--version" ], capture_output = True , text = True , timeout = 10 )
146
+ test_result = subprocess .run ([claude_path , "--version" ], capture_output = True , text = True , timeout = 10 )
132
147
if test_result .returncode == 0 :
133
148
console .print (f"✅ Claude Code found: { test_result .stdout .strip ()} " , style = "green" )
134
149
else :
@@ -153,7 +168,7 @@ def _run_claude_interactive(resolved_org_id: int, no_mcp: bool | None) -> None:
153
168
url = get_codegen_url (session_id )
154
169
console .print (f"\n 🔵 Codegen URL: { url } \n " , style = "bold blue" )
155
170
156
- process = subprocess .Popen (["claude" , "--session-id" , session_id ])
171
+ process = subprocess .Popen ([claude_path , "--session-id" , session_id ])
157
172
158
173
# Start log watcher for the session
159
174
console .print ("📋 Starting log watcher..." , style = "blue" )
0 commit comments