Ragex.Agent.Report (Ragex v0.10.1)

View Source

Report generation utilities for agent analysis.

Handles:

  • System prompts for AI report generation (with RAG tool access)
  • Formatting raw issues for LLM consumption
  • Fallback basic report generation when no AI provider is available

RAG tool access during report generation

The system prompt returned by system_prompt/1 permits the AI to call a restricted set of read-only Ragex MCP query tools while writing the report. This allows the AI to retrieve concrete code-level evidence (e.g. quote an actual function body, confirm a dependency path, or look up callers of a flagged function) rather than relying solely on pre-computed statistics.

The allowed tools are the same 10 tools in ToolSchema.rag_tool_names/0: read_file, semantic_search, hybrid_search, query_graph, list_nodes, find_callers, find_paths, find_circular_dependencies, coupling_report, and graph_stats.

Heavy re-analysis tools (analyze_directory, analyze_quality, find_dead_code, find_duplicates, etc.) are excluded from the tool set passed to the executor, so the AI cannot accidentally re-trigger the full analysis pipeline.

Summary

Functions

Format issues map for LLM consumption.

Generate a basic report without AI assistance.

System prompt for report generation.

Functions

format_issues_for_llm(issues)

@spec format_issues_for_llm(map()) :: String.t()

Format issues map for LLM consumption.

generate_basic_report(issues)

@spec generate_basic_report(map()) :: String.t()

Generate a basic report without AI assistance.

Used as fallback when AI generation fails.

system_prompt(project_path \\ nil)

@spec system_prompt(String.t() | nil) :: String.t()

System prompt for report generation.

Instructs the AI to act as a senior software architect writing a professional code audit report. The AI is:

  • Given all static-analysis data in the user message as its primary source.
  • Permitted to call read-only RAG query tools (see ToolSchema.rag_tool_names/0) to retrieve concrete code evidence for specific findings.
  • Required to produce a 12-section Markdown report as its final response.

When project_path is provided the prompt includes a path-constraint so every file-path tool argument uses the correct absolute path.

Parameters

  • project_path - Absolute path to the project being analyzed (optional)