How choria-io/fisk-ai works
Purpose and Entry Points
Fisk AI is a Go CLI that turns a Fisk-based command tree into a constrained LLM agent. The executable bootstraps subcommands for interactive runs, MCP serving, RAG, agent-to-agent operations, discovery, and session handling. Primary entry points: main.go, run_command.go, mcp_command.go, a2a_command.go, rag_command.go.
Configuration and Assembly
Configuration centralizes agent behavior, allowed Fisk commands, Anthropic access, remote tools, MCP built-ins, and RAG options. Command handlers assemble these dependencies before starting the relevant runtime. Paths: config/config.go, run_command.go, remote_tools.go.
Agent Execution Loop
The agent layer owns the prompt-to-action lifecycle: it invokes the LLM, emits execution events, dispatches tool calls, and coordinates runner state. Tool invocation results feed subsequent model turns until completion or termination. Paths: internal/agent/agent.go, internal/agent/runner.go, internal/agent/events.go.
Tool Boundary and Safety
The toolkit is the principal safety boundary between LLM output and local execution. It describes tools/schemas, obtains confirmation through a prompter, normalizes results, and adapts introspected Fisk commands into callable agent tools. Built-in tools expose controlled memory and RAG capabilities. Paths: internal/toolkit/tool.go, internal/toolkit/fisk/fisk.go, internal/toolkit/builtin/builtin.go, internal/toolkit/prompter.go.
LLM, Terminal, and Interactive UI
Anthropic is the material external LLM service; utility code provides LLM request handling and Anthropic-specific integration. The terminal UI renders live agent activity and implements interactive prompting/viewing, while run-event adapters connect agent events to it. Paths: internal/util/anthropic.go, internal/util/llm.go, internal/tui/live.go, run_tui_events.go.
Persistence: Sessions and Memory
Run state persists replayable session records with versioned JSON schemas, validation, fingerprints, and a file-backed store. A separate memory abstraction provides keyed storage with a file implementation. Session/resume commands operate at this persistence boundary. Paths: internal/runstate/store.go, internal/runstate/file/file.go, internal/runstate/schemas/v1/session.meta.json, internal/memory/store.go, internal/memory/file/file.go, resume_replay.go.
RAG Knowledge Pipeline
RAG ingests local content, chunks and embeds it, stores vectors, and serves similarity search. It includes filesystem safety/locking and a watch mode for maintaining an index as source content changes. The agent receives RAG through built-in toolkit tools rather than direct store access. Paths: internal/rag/index.go, internal/rag/embed.go, internal/rag/search.go, internal/rag/watch.go, internal/toolkit/builtin/builtin_rag.go.
Interoperability: MCP, Remote Tools, and A2A
The MCP server exposes capabilities to MCP clients; remote-tools support integrates externally supplied tools. The A2A subsystem defines versioned protocol messages, transport/server/client interfaces, a registry, remote dispatch, and a NATS transport implementation. These are network boundaries distinct from local Fisk execution. Paths: internal/mcpserver/mcpserver.go, internal/remotetools/remotetools.go, internal/a2a/server.go, internal/a2a/client.go, internal/a2a/nats/nats.go, internal/a2a/schemas/v1/request.json.
Main entry points: run_command.go Command handlers · tool.go Toolkit · runner.go Agent runner · agent.go Agent core
Components 22
CLI & assembly
- CLI bootstrap · Registers operational subcommands.
main.go - Command handlers · Assemble dependencies for run, MCP, A2A, and RAG modes.
run_command.go - Configuration · Defines agent, command, provider, tool, MCP, and RAG options.
config/config.go - Remote tool setup
remote_tools.go
Agent runtime
- Agent runner · Coordinates model turns, tool actions, and completion.
internal/agent/runner.go - Agent core · Invokes the LLM and dispatches requested tools.
internal/agent/agent.go - Execution events
internal/agent/events.go - Anthropic LLM · Handles provider requests and Anthropic-specific integration.
internal/util/anthropic.go - Live terminal UI · Renders agent activity and gathers interactive input.
internal/tui/live.go - TUI event adapter
run_tui_events.go
Tool safety & knowledge
- Toolkit · Describes tools, confirms execution, and normalizes results.
internal/toolkit/tool.go - Fisk command adapter · Converts introspected Fisk commands into callable tools.
internal/toolkit/fisk/fisk.go - Built-in tools · Exposes controlled memory and RAG capabilities.
internal/toolkit/builtin/builtin.go - Confirmation prompter
internal/toolkit/prompter.go - RAG index & search · Indexes, embeds, and similarity-searches local content.
internal/rag/index.go - RAG watch mode · Maintains the index as source content changes.
internal/rag/watch.go
State
- Session store · Persists versioned, validated session records in files.
internal/runstate/file/file.go - File memory store
internal/memory/file/file.go
Interoperability
- MCP server · Exposes capabilities to MCP clients.
internal/mcpserver/mcpserver.go - Remote tools · Integrates externally supplied tools.
internal/remotetools/remotetools.go - A2A server & client · Provides protocol, registry, remote dispatch, and transport interfaces.
internal/a2a/server.go - NATS transport
internal/a2a/nats/nats.go
Connections 24
- CLI bootstrap → Command handlers: starts
- Command handlers → Configuration: loads
- Command handlers → Agent runner: launches runs
- Command handlers → MCP server: serves
- Command handlers → A2A server & client: runs A2A
- Command handlers → RAG index & search: indexes/searches
- Command handlers → Remote tool setup: configures
- Remote tool setup → Remote tools: connects
- Agent runner → Agent core: coordinates
- Agent core → Anthropic LLM: requests turns
- Agent core → Toolkit: dispatches calls
- Agent runner → Execution events: emits
- Execution events → TUI event adapter: adapts
- TUI event adapter → Live terminal UI: renders
- Toolkit → Confirmation prompter: confirms actions
- Toolkit → Fisk command adapter: exposes
- Toolkit → Built-in tools: exposes
- Toolkit → Remote tools: calls
- Built-in tools → File memory store: reads/writes
- Built-in tools → RAG index & search: queries
- RAG watch mode → RAG index & search: updates
- Agent runner → Session store: persists runs
- A2A server & client → NATS transport: uses transport
- MCP server → Toolkit: exposes tools