Ragex.CLI.Chat (Ragex v0.10.1)

View Source

Interactive terminal chat UI for codebase Q&A using the Ragex agent.

Each user question is handled by the agent executor (ReAct loop) which actively calls Ragex MCP query tools — hybrid_search, semantic_search, read_file, query_graph, find_callers, etc. — to retrieve relevant code context before composing the answer. This means the AI itself drives the retrieval rather than having context pre-fetched on its behalf.

Blocking Core.chat/3 is used for every query (rather than streaming) so that tool-call responses are reliably captured. Some providers (e.g. DeepSeek R1) emit content and tool_calls in the same response chunk; the streaming parser would silently drop the tool calls, truncating answers.

The initial codebase analysis and first-run audit report are generated separately (via Core.analyze_project/2 and Core.stream_generate_report/3) and may include AI tool calls for evidence retrieval as well.

Usage

Ragex.CLI.Chat.start(path: "/path/to/project")

Commands

  • /help - Show available commands
  • /history - Show conversation history
  • /clear - Clear conversation and start fresh
  • /sources - Show sources from last response (empty — agent tracks tool
             call results internally, not as named sources)
  • /analyze - Re-analyze the codebase
  • /status - Show session and graph stats
  • /quit - Exit the chat

Summary

Functions

Start an interactive chat session.

Types

state()

@type state() :: %{
  session_id: String.t() | nil,
  path: String.t(),
  provider: atom() | nil,
  model: String.t() | nil,
  strategy: atom(),
  last_sources: [map()],
  message_count: non_neg_integer(),
  analyzed: boolean()
}

Functions

start(opts \\ [])

@spec start(keyword()) :: :ok

Start an interactive chat session.

Runs the initial codebase analysis (unless :skip_analysis is true), streams the opening audit report, then enters an interactive loop where every question is answered by the agent executor using Ragex MCP query tools.

Options

  • :path - Project path to analyze (default: cwd)
  • :provider - AI provider atom (default: configured default)
  • :model - Model name override
  • :strategy - Accepted for compatibility but not used; queries always go
              through the agent ReAct loop rather than the retrieval pipeline
  • :skip_analysis - Skip initial analysis (default: false)
  • :include_dead_code - Enable dead code analysis (default: false)
  • :debug - Print tool-call details and session messages to stderr (default: false)