How lucid-fabrics/iphone-control works
iphone-control provides two ways to operate an iPhone Mirroring window: terminal commands, optionally exposed as MCP tools, and a macOS companion chat that can use AI tool calls. The main loop is request → model response/tool call → input or screenshot action → result shown to the user. The README documents CLI capabilities not represented by a top-level CLI source file in this tree; edges for those capabilities are therefore documented relationships, not claims about their implementation. The sampled source supports the companion flow; some listed features have only tree or README evidence.
Main entry points: main.swift Device commands · Conversation.swift Conversation state · AIServiceFactory.swift Service selection · ChatView.swift Chat interface
Components 24
Terminal control
- Device commands
helpers/input-src/main.swift - Input helpers
helpers/input-src - Window lookup
helpers/get-window-id.swift - OCR scan
helpers/ocr-image.swift - Event logging
helpers/event-logger.swift - App registry
helpers/input-src
Companion app
- App lifecycle
companion/iPhoneCompanion/App/AppDelegate.swift - Chat interface
companion/iPhoneCompanion/Views/ChatView.swift - Provider settings
companion/iPhoneCompanion/Views/SettingsView.swift - Input control
companion/iPhoneCompanion/Services/InputController.swift - Script runner
companion/iPhoneCompanion/Services/ScriptRunner.swift
AI chat
- Conversation state
companion/iPhoneCompanion/Models/Conversation.swift - Chat messages
companion/iPhoneCompanion/Models/ChatMessage.swift - Tool loop
companion/iPhoneCompanion/Services/ToolOrchestrator.swift - Tool execution
companion/iPhoneCompanion/Services/ToolExecutor.swift - Service selection
companion/iPhoneCompanion/Services/AIServiceFactory.swift - AI providers
companion/iPhoneCompanion/Services - Model discovery
companion/iPhoneCompanion/Services/ModelFetcher.swift
Integration and support
- MCP tools
mcp-server/src/index.ts - API credentials
companion/iPhoneCompanion/Utilities/KeychainHelper.swift - Claude Code auth
companion/iPhoneCompanion/Utilities/ClaudeCodeAuthHelper.swift
Other components
- AI agent
- iPhone Mirroring
- MCP client
Connections 26
- AI agent → Device commands: requests actions
- Device commands → iPhone Mirroring: controls and captures
- Device commands → Window lookup: finds window
- Device commands → Input helpers: dispatches input
- Device commands → OCR scan: scans apps
- Device commands → App registry: reads and updates
- MCP client → MCP tools: calls tools
- MCP tools → Device commands: wraps commands
- App lifecycle → Chat interface: presents
companion/iPhoneCompanion/App/AppDelegate.swift - Chat interface → Conversation state: submits messages
companion/iPhoneCompanion/Views/ChatView.swift - Chat interface → Provider settings: opens settings
companion/iPhoneCompanion/Views/ChatView.swift - Conversation state → Chat messages: stores messages
companion/iPhoneCompanion/Models/Conversation.swift - Conversation state → Tool loop: runs tool loop
companion/iPhoneCompanion/Models/Conversation.swift - Tool loop → Tool execution: executes tools
companion/iPhoneCompanion/Services/ToolOrchestrator.swift - Tool execution → Input control: uses input control
companion/iPhoneCompanion/Services/ToolExecutor.swift - Tool execution → Script runner: runs scripts
companion/iPhoneCompanion/Services/ToolExecutor.swift - Input control → Script runner: uses fallback
companion/iPhoneCompanion/Services/InputController.swift - Input control → iPhone Mirroring: posts input
- Conversation state → Service selection: creates service
companion/iPhoneCompanion/Models/Conversation.swift - Service selection → AI providers: selects backend
companion/iPhoneCompanion/Services/AIServiceFactory.swift - AI providers → AI agent: returns model output
- Service selection → API credentials: loads API keys
companion/iPhoneCompanion/Services/AIServiceFactory.swift - Service selection → Claude Code auth: gets OAuth token
companion/iPhoneCompanion/Services/AIServiceFactory.swift - Provider settings → Model discovery: fetches models
companion/iPhoneCompanion/Views/SettingsView.swift - Model discovery → AI providers: checks catalogs
- App lifecycle → Window lookup: positions panel
companion/iPhoneCompanion/App/AppDelegate.swift