Skip to content
GitHub stars

Architecture

Overview

agentsview is a single Go binary that embeds a Svelte 5 frontend. It syncs AI agent session files from disk into SQLite, indexes them for full-text search, and serves everything over HTTP.

~/.claude/projects/ ─┐
~/.codex/sessions/ ─┤
~/.copilot/session-state/ ─┼─▶ Sync Engine ─▶ SQLite + FTS5
~/.gemini/ ─┤ │ │
~/.local/share/opencode/ ─┘ File Watcher HTTP Server
REST API + SSE + SPA

Session Parsing

Each agent writes sessions in its own format. agentsview includes a dedicated parser for each:

AgentParserSource Format
Claude Codeparser/claude.goProject-scoped JSONL with tool use blocks
Codexparser/codex.goSession JSONL with function calls
Copilot CLIparser/copilot.goJSONL event stream with session/tool events
Gemini CLIparser/gemini.goSession JSONL from temp directory
OpenCodeparser/opencode.goSQLite database with project/session/message tables

Parsers extract a common structure:

  • Sessions — ID, project, agent type, timestamps
  • Messages — role (user/assistant), content, ordinal
  • Tool calls — raw tool name plus a normalized category

Tool Taxonomy

Tool names from different agents are normalized into categories for cross-agent analytics:

CategoryExamples
ReadRead, View, cat, file_read
EditEdit, Replace, patch
WriteWrite, CreateFile
BashBash, execute, shell
SearchGrep, Glob, find, ripgrep
WebWebFetch, WebSearch, browse
TaskTask, Agent, spawn

Storage

SQLite with WAL mode serves as the single data store.

Key design choices:

  • FTS5 virtual table on message content with Porter stemming and Unicode 6.1 tokenization
  • Auto-maintained triggers keep the FTS index in sync with inserts, updates, and deletes
  • Change detection via file size and mtime — files are only re-parsed when they actually change
  • Aggregate stats table tracks session and message counts without full table scans

Schema

The database has seven tables:

TablePrimary KeyPurpose
sessionsid (text)Session metadata and file info
messagesid (integer)Message content and metadata
tool_callsid (integer)Tool invocations per message
insightsid (integer)AI-generated session analysis
statsAggregate counters
skipped_filesfile_pathCache of non-interactive session files
messages_ftsFTS5 full-text search index

Indexes cover the common query patterns: session listing by date, message retrieval by session, analytics by timestamp, and tool analysis by category.

Sync Engine

The sync engine coordinates file discovery and processing:

  1. Discovery — scans configured directories for session files matching each agent’s expected path patterns
  2. Change detection — compares file size and mtime to skip unchanged files
  3. Worker pool — 8 concurrent goroutines parse and insert changed files
  4. Skip cache — non-interactive files and parse failures are cached in the database and skipped until their mtime changes

Two sync triggers run concurrently:

  • File watcher (fsnotify) — reacts to file system events with 500ms debounce to batch rapid changes
  • Periodic timer — full directory scan every 15 minutes as a safety net for missed events

HTTP Server

The server exposes three interfaces:

  1. REST API (/api/v1/) — JSON endpoints for sessions, search, analytics, sync control, and configuration
  2. SSE (/api/v1/sessions/{id}/watch) — real-time session updates via Server-Sent Events
  3. SPA (/) — the Svelte 5 frontend, embedded in the binary at build time via embed.FS

The server uses CORS middleware and request logging. Pagination is cursor-based with HMAC-signed cursors for tamper resistance.

Frontend

The Svelte 5 SPA is built with Vite and embedded into the Go binary. It provides:

  • Three-column layout — sidebar session list, message content, and session detail panel
  • Session browser — filtering, sorting, and infinite scroll
  • Message renderer — code blocks, thinking blocks, and tool call visualization
  • Search — full-text search with result highlighting
  • Analytics — interactive charts and heatmaps
  • Export — HTML export and GitHub Gist publishing