This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Go workspaces project (go 1.24.3). No Makefile exists.
# Build core library
cd core && go build
# Build CLI application
cd cleverchatty-cli && go build
# Build server application
cd cleverchatty-server && go build
# Clean up dependencies for a module
cd <module-dir> && go mod tidy
# Run tests (from core directory)
cd core && go test ./...
# Run a single test
cd core && go test -run TestBasicChat
# Install binaries
go install github.com/gelembjuk/cleverchatty/cleverchatty-cli@latest
go install github.com/gelembjuk/cleverchatty/cleverchatty-server@latestGo workspace with three main modules:
- core/ - Core library with business logic, LLM providers, tool hosting
- cleverchatty-cli/ - Terminal UI application (Bubble Tea framework, Cobra CLI)
- cleverchatty-server/ - Daemon server with A2A protocol support
- dev_tools/ - Development utilities (email mock, notification test clients)
Located in core/llm/. Providers implement common interface for message creation, tool responses, and token tracking.
anthropic/- Anthropic Claudeopenai/- OpenAI GPTgoogle/- Google Generative AIollama/- Local Ollama modelsmock/- Testing provider
Model format: provider:model_name (e.g., ollama:llama2:7b, anthropic:claude-2)
core/tools.go manages ToolsHost which supports multiple transport types:
- STDIO - Local process communication
- HTTP_STREAMING - Streamable HTTP
- SSE - Server-sent events
- A2A - Agent-to-Agent protocol
- REVERSE_MCP - WebSocket-based reverse connection
core/session.go provides SessionManager for multi-client scenarios. Each session maintains its own CleverChatty instance with configurable timeout (default 3600s).
core/callbacks.go defines UICallbacks for UI event notifications:
startedPromptProcessing,startedThinking,responseReceivedtoolCalling,toolCallFailedmemoryRetrievalStarted,ragRetrievalStarted
core/history/ manages conversation history with content blocks (text, tool_use, tool_result). Supports window pruning for context management.
core/notification.go provides unified notification handling from MCP/A2A sources with monitoring and processing status tracking.
When an MCP server sends a notification:
ToolsHostreceives the raw MCP notification and converts it to a unifiedNotificationstruct- If the notification matches configured monitoring rules (in
tools_servers[name].notification_instructions), it's marked as "monitored" - Monitored notifications are enqueued in
NotificationProcessorfor LLM-based processing - The processor's dedicated agent evaluates the notification against user instructions
- If the agent determines the user should be notified, it calls the
notification_feedbacktool
The notification_feedback tool triggers the AgentMessageCallback chain:
notification_feedback tool called
↓
AgentMessageCallback (in NotificationProcessor)
↓
Closure in CleverChatty.SetNotificationCallback:
1. Adds message to assistant.messages via history.NewAgentNotificationMessage()
2. Calls assistant.agentMessageCallback
↓
SessionManager.agentMessageCallback
↓
A2AServer.BroadcastAgentMessage() - sends "agent_message" event to all subscribers
↓
CLI receives event and displays in chat view (tuiSendAgentMessage)
NotificationCallback func(notification Notification)- for raw notification eventsAgentMessageCallback func(message string)- for processed agent messages to userNotificationProcessor- queue-based processor with dedicated LLM agent
{
"tools_servers": {
"email-server": {
"notification_instructions": {
"notifications/message": ["Tell me if there's an urgent email"]
}
}
}
}JSON config file cleverchatty_config.json with:
model- LLM provider and modelsystem_instruction- System prompttools_servers- MCP servers and A2A agents configurationa2a_settings- A2A server configurationreverse_mcp_settings- Reverse MCP listener- Provider credentials (
anthropic,openai,google)
See docs/Config.md for full reference.
CLI: cleverchatty-cli/main.go - Cobra commands, Bubble Tea TUI
- Standalone mode: local LLM and MCP servers
- Client mode: connects to CleverChatty server via A2A
Server: cleverchatty-server/
start- daemon modestop- stop daemonrun- interactive mode
Library: core.GetCleverChatty() factory function
Tests use mock providers (mock:mock) and mock MCP clients. Test files in core/:
action_test.go- Basic chat and tool calling testssetup_test.go- Initialization tests- Mock implementations in
core/test/
github.com/mark3labs/mcp-go- MCP protocoltrpc.group/trpc-go/trpc-a2a-go- A2A protocolgithub.com/charmbracelet/bubbletea- Terminal UIgithub.com/spf13/cobra- CLI framework