How simonschubert/kai works
Kai is a cross-platform AI assistant centered on a chat loop: the user sends a message, Kai assembles a prompt with persistent memories, calls a configured AI service, executes requested tools, and returns the response while retaining conversation state. Separate capabilities include local inference, generated interactive UI, autonomous heartbeat, skills/MCP, and Android Linux sandboxing. Workflow details follow the README; source excerpts are partial, so uncertain internal wiring is omitted.
Main entry points: ChatViewModel.kt Chat workflow · HeartbeatManager.kt Heartbeat manager · ToolExecutor.kt Tool executor · LinuxSandboxManager.kt Linux sandbox
Components 21
Chat and AI
- Chat interface
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/ui/chat/ChatScreen.kt - Chat workflow
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/ui/chat/ChatViewModel.kt - Prompt builder
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/data/ChatSystemPromptBuilder.kt - AI services
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/data/Service.kt - Interactive UI
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/ui/dynamicui/KaiUiRenderer.kt - Text to speech
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/ui/dynamicui/KaiUiTts.kt
Memory and settings
- Conversation history
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/data/ConversationStorage.kt - Persistent memory
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/data/MemoryStore.kt - Assistant settings
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/data/AppSettingsService.kt
Tools and integrations
- Tool executor
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/data/ToolExecutor.kt - Agent tool set
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/tools/AgentToolSet.kt - MCP servers
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/mcp/McpServerManager.kt - Skills manager
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/skills/SkillManager.kt - Device notifications
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/tools/NotificationTools.kt
Autonomous features
- Heartbeat manager
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/data/HeartbeatManager.kt - Task scheduler
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/data/TaskScheduler.kt
Local runtimes
- Sandbox interface
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/ui/sandbox/SandboxSessionViewModel.kt - Linux sandbox
composeApp/src/androidMain/kotlin/com/inspiredandroid/kai/sandbox/LinuxSandboxManager.kt - On-device inference
composeApp/src/commonMain/kotlin/com/inspiredandroid/kai/inference/LocalInferenceEngine.kt
Other components
- User
- AI provider
Connections 22
- User → Chat interface: sends message
- Chat interface → Chat workflow: submits input
- Chat workflow → Prompt builder: builds prompt
- Chat workflow → Persistent memory: recalls and stores
- Chat workflow → Conversation history: loads and saves
- Chat workflow → AI services: selects service
- Chat workflow → AI provider: requests completion
- AI provider → Chat workflow: returns response
- Chat workflow → Tool executor: dispatches calls
- Tool executor → Agent tool set: runs tools
- Agent tool set → MCP servers: uses configured servers
- Chat workflow → Interactive UI: renders generated UI
- Chat workflow → On-device inference: uses local inference
- Chat workflow → Text to speech: reads responses
- Heartbeat manager → Persistent memory: reviews memories
- Heartbeat manager → Task scheduler: reviews pending tasks
- Heartbeat manager → AI provider: requests self-check
- Heartbeat manager → Device notifications: surfaces attention
- Assistant settings → Chat workflow: configures assistant
- Sandbox interface → Linux sandbox: controls environment
- Tool executor → Linux sandbox: runs shell commands
- Skills manager → Linux sandbox: loads and installs skills