MCPcopy
hub / github.com/codeaashu/claude-code / verifyIt2Setup

Function verifyIt2Setup

src/utils/swarm/backends/it2Setup.ts:152–195  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

150 * @returns Result indicating success or the specific failure reason
151 */
152export async function verifyIt2Setup(): Promise<It2VerifyResult> {
153 logForDebugging('[it2Setup] Verifying it2 setup...')
154
155 // First check if it2 is installed
156 const installed = await isIt2CliAvailable()
157 if (!installed) {
158 return {
159 success: false,
160 error: 'it2 CLI is not installed or not in PATH',
161 }
162 }
163
164 // Try to list sessions - this tests the Python API connection
165 const result = await execFileNoThrow('it2', ['session', 'list'])
166
167 if (result.code !== 0) {
168 const stderr = result.stderr.toLowerCase()
169
170 // Check for common Python API errors
171 if (
172 stderr.includes('api') ||
173 stderr.includes('python') ||
174 stderr.includes('connection refused') ||
175 stderr.includes('not enabled')
176 ) {
177 logForDebugging('[it2Setup] Python API not enabled in iTerm2')
178 return {
179 success: false,
180 error: 'Python API not enabled in iTerm2 preferences',
181 needsPythonApiEnabled: true,
182 }
183 }
184
185 return {
186 success: false,
187 error: result.stderr || 'Failed to communicate with iTerm2',
188 }
189 }
190
191 logForDebugging('[it2Setup] it2 setup verified successfully')
192 return {
193 success: true,
194 }
195}
196
197/**
198 * Returns instructions for enabling the Python API in iTerm2.

Callers 2

It2SetupPromptFunction · 0.85
renderFailedFunction · 0.85

Calls 3

logForDebuggingFunction · 0.85
execFileNoThrowFunction · 0.85
isIt2CliAvailableFunction · 0.70

Tested by

no test coverage detected