How mark3labs/kit works
KIT is an extensible AI coding-agent CLI and Go SDK. The principal workflow runs a user prompt through the application and agent, which consults a configured model and may execute built-in or MCP tools; the application then presents results and persists conversation history. Major documented branches include interactive and scripted use, ACP clients, extensions, skills and templates, authentication, and local or remote detachable sessions. Some subsystem links below reflect README descriptions because their implementation was not sampled; unsampled internals are not assumed to have verified call paths.
Main entry points: root.go CLI commands · agent.go Agent loop · kit.go Kit SDK · app.go App orchestration
Components 21
CLI and experience
- CLI commands
cmd/root.go - App orchestration
internal/app/app.go - Terminal interface
internal/ui
Agent runtime
- Agent loop
internal/agent/agent.go - Kit SDK
pkg/kit/kit.go - Agent setup
internal/kitsetup/setup.go - Model providers
internal/models/providers.go
Agent capabilities
- Core coding tools
internal/core/tools.go - MCP integration
internal/tools/mcp.go - Skills and agents
internal/skills/skills.go - Prompt templates
internal/prompts/template.go - Extension system
internal/extensions/api.go
Client integrations
- Provider authentication
internal/auth/oauth.go - ACP server
internal/acpserver/session.go
Session services
- Remote daemon
internal/daemon/server.go - Conversation history
internal/session/tree_manager.go
Other components
- User
- LLM providers
- MCP servers
- ACP client
- Remote client
Connections 22
- User → CLI commands: starts
- CLI commands → App orchestration: runs prompts
- App orchestration → Kit SDK: executes turns
internal/app/app.go - App orchestration → Terminal interface: emits events
internal/app/app.go - Terminal interface → User: presents results
internal/ui/event_handler.go - Kit SDK → Agent setup: configures agent
- Agent setup → Agent loop: creates runtime
internal/kitsetup/setup.go - Agent loop → Model providers: requests completions
internal/agent/agent.go - Model providers → LLM providers: calls
- Agent loop → Core coding tools: dispatches tools
internal/agent/agent.go - Agent loop → MCP integration: dispatches tools
- MCP integration → MCP servers: connects
- Kit SDK → Conversation history: persists history
- CLI commands → Skills and agents: offers capabilities
- CLI commands → Prompt templates: loads prompts
- Agent loop → Extension system: supports extensions
- CLI commands → Provider authentication: manages credentials
- ACP client → ACP server: drives sessions
- ACP server → Kit SDK: runs agent
internal/acpserver/session.go - ACP server → MCP servers: adds servers
- Remote client → Remote daemon: attaches remotely
- Remote daemon → Conversation history: serves sessions