(
claudePath: string,
action: {
query?: string
cwd?: string
repo?: string
lastFetchMs?: number
},
)
| 212 | * query or cwd are preserved by argv boundaries with zero interpretation. |
| 213 | */ |
| 214 | export async function launchInTerminal( |
| 215 | claudePath: string, |
| 216 | action: { |
| 217 | query?: string |
| 218 | cwd?: string |
| 219 | repo?: string |
| 220 | lastFetchMs?: number |
| 221 | }, |
| 222 | ): Promise<boolean> { |
| 223 | const terminal = await detectTerminal() |
| 224 | if (!terminal) { |
| 225 | logForDebugging('No terminal emulator detected', { level: 'error' }) |
| 226 | return false |
| 227 | } |
| 228 | |
| 229 | logForDebugging( |
| 230 | `Launching in terminal: ${terminal.name} (${terminal.command})`, |
| 231 | ) |
| 232 | const claudeArgs = ['--deep-link-origin'] |
| 233 | if (action.repo) { |
| 234 | claudeArgs.push('--deep-link-repo', action.repo) |
| 235 | if (action.lastFetchMs !== undefined) { |
| 236 | claudeArgs.push('--deep-link-last-fetch', String(action.lastFetchMs)) |
| 237 | } |
| 238 | } |
| 239 | if (action.query) { |
| 240 | claudeArgs.push('--prefill', action.query) |
| 241 | } |
| 242 | |
| 243 | switch (process.platform) { |
| 244 | case 'darwin': |
| 245 | return launchMacosTerminal(terminal, claudePath, claudeArgs, action.cwd) |
| 246 | case 'linux': |
| 247 | return launchLinuxTerminal(terminal, claudePath, claudeArgs, action.cwd) |
| 248 | case 'win32': |
| 249 | return launchWindowsTerminal(terminal, claudePath, claudeArgs, action.cwd) |
| 250 | default: |
| 251 | return false |
| 252 | } |
| 253 | } |
| 254 | |
| 255 | async function launchMacosTerminal( |
| 256 | terminal: TerminalInfo, |
no test coverage detected