Add Grok CLI backend and per-engine backend documentation#24
Merged
Conversation
…and parsers why: Grok CLI stores chat transcripts and prompt history under ~/.grok/sessions/ in a layout similar to Codex — URL-encoded project paths, per-session UUIDs, JSONL transcripts, and a SQLite search index. Adding Grok as a fifth backend gives agentgrep read-only search across all major coding-agent CLIs. what: - Register "grok" in AgentName, AGENT_CHOICES, AgentSelector, KNOWN_ADAPTERS, MCP models (5 Literal fields), and the query registry enum_values - Add 10 StoreDescriptor entries to store_catalog.py (3 searchable with DiscoverySpec, 7 documentary-only), bump catalog_version to 4 - Add discover_grok_sources() honouring GROK_HOME env override - Add parse_grok_prompt_history (JSONL audit log), parse_grok_chat_history (JSONL full transcripts), and parse_grok_session_search_db (SQLite FTS5 index) parsers - Wire adapter dispatch in iter_source_records()
why: The new grok parsers and discovery function need end-to-end verification — env-override priority, record extraction from all three store formats, and empty-content edge cases. what: - Add test fixtures: tests/samples/grok/grok.prompt_history/ and tests/samples/grok/grok.sessions/ with redacted sample records - Add test_discover_grok_sources_honours_grok_home_env - Add test_search_grok_prompt_history (JSONL audit log) - Add test_search_grok_chat_history_session (JSONL transcripts) - Add test_search_grok_chat_history_drops_empty_content - Add test_search_grok_session_search_db (SQLite FTS5 index) - Update KNOWN_AGENTS in test_stores.py to include "grok"
why: Users and adapter authors need a single reference showing which stores each agent exposes, what agentgrep searches by default, and what the record schemas look like — without reading source code. what: - Create docs/backends/ with index.md (support matrix table) and per-engine pages: codex.md, claude.md, cursor.md, gemini.md, grok.md - Add Grok CLI section to docs/dev/storage-catalog.md - Wire backends/index into docs/index.md grid and toctree - Update dev/index.md card description to mention Grok
why: datetime.fromtimestamp() raises ValueError/OverflowError on NaN, infinity, or out-of-range timestamps that pass the value <= 0 guard. In parse_grok_session_search_db this escapes the sqlite3.DatabaseError handler and crashes the entire search iteration. what: - Reject bool values (bool is a subclass of int in Python) - Wrap fromtimestamp() in try/except (ValueError, OSError, OverflowError) returning None on failure - Add parametrized test covering NaN, inf, extreme int, bool, None, and string inputs
why: MCP clients read the server instructions on handshake to decide which queries to route. Without Grok in the TRIGGERS and SCOPE strings, clients won't invoke agentgrep for Grok-related history queries. what: - Add Grok to _INSTR_HEADER agent list - Add Grok to _INSTR_SCOPE trigger examples
…ntries why: The module-level OBSERVED_AT (2026-05-17) predates the Grok store observation. Each Grok descriptor's observed_version string says "observed 2026-05-25" but observed_at inherited the stale date. what: - Add _GROK_OBSERVED_AT = datetime.date(2026, 5, 25) - Replace observed_at=OBSERVED_AT with observed_at=_GROK_OBSERVED_AT in all 9 Grok store descriptors
… page why: Several user-facing strings still listed only four agents after the Grok backend landed. what: - CLI_DESCRIPTION: "…Codex, Claude, Cursor, Gemini, and Grok…" - Query registry docstring table: add grok to agent enum values - docs/tui/index.md: add Grok to the stores list
Owner
Author
Code reviewFound 2 issues:
Lines 3 to 5 in bb4115c Lines 23 to 25 in bb4115c
Lines 7 to 8 in bb4115c 🤖 Generated with Claude Code - If this code review was useful, please react with 👍. Otherwise, react with 👎. |
why: Package metadata on PyPI still listed only four agents after the Grok backend landed — users searching for grok support would not discover agentgrep. what: - Add Grok to pyproject.toml description and keywords - Add Grok to README.md opening description
why: The catalog-level captured_at still pointed at the pre-Grok snapshot date (2026-05-17) while the Grok stores were observed eight days later. The field documents when the catalog was last updated, so it should reflect the most recent observation. what: - Change CATALOG captured_at from OBSERVED_AT to _GROK_OBSERVED_AT
why: The function is a pure offline helper that the project convention requires to carry inline doctests. what: - Add Examples section with valid input, zero, and NaN cases
why: sqlite3 is already imported at module level; the function-local import adds no cold-start benefit for a stdlib module in a test file. what: - Remove `import sqlite3` from test_search_grok_session_search_db
why: The test-local AgentName literal, PRIMARY_FIXTURES tuple, and adapter-id assertions were not updated when the grok backend landed, leaving gaps in type coverage and fixture validation. what: - Add "grok" to AgentName literal in test_agentgrep.py - Add grok.prompt_history and grok.sessions to PRIMARY_FIXTURES - Add explicit grok adapter ID assertions in test_runtime_adapter_ids_match_catalogue_discovery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
docs/backends/section with a support matrix and per-engine pages documenting store layouts, adapter IDs, and record schemas for all five agentsChanges by area
Runtime (
src/agentgrep/)__init__.py: Register"grok"inAgentNameandAGENT_CHOICES; adddiscover_grok_sources()honouringGROK_HOMEenv override; addparse_grok_prompt_history,parse_grok_chat_history,parse_grok_session_search_dbparsers; wire adapter dispatch initer_source_records()stores.py: Add"grok"toAgentNameliteralstore_catalog.py: Add_GROK_STORES(10 descriptors), bumpcatalog_versionto 4mcp/_library.py: Add"grok"toAgentName,AgentSelector, and 3 adapter IDs toKNOWN_ADAPTERSmcp/models.py: Add"grok"to all 5 agent Literal fieldsquery/registry.py: Add"grok"to theagentfield'senum_valuesTests
tests/samples/grok/: Redacted JSONL fixtures for prompt history and chat sessionstests/test_agentgrep.py: 5 new tests — env-override discovery, prompt history parsing, chat session extraction, empty-content filtering, SQLite FTS5 index parsingtests/test_stores.py: Add"grok"toKNOWN_AGENTSso existing catalog invariant tests cover the new entriesDocumentation
docs/backends/: New section withindex.md(support matrix) and per-engine pages (codex.md,claude.md,cursor.md,gemini.md,grok.md)docs/dev/storage-catalog.md: Add Grok CLI section documenting path layout and adapter notesdocs/index.md: Add Backends grid card and toctree entrydocs/dev/index.md: Update storage catalogue card to mention GrokDesign decisions
discover_grok_sourcesdelegates todiscover_from_catalog()— no custom file-walking logic. The generic machinery handles globs, file checks, and deduplication identically to all other agents.updated_at(unix seconds) to ISO-8601 for consistency with all other adapters' timestamp fields.Test plan
test_discover_grok_sources_honours_grok_home_env—GROK_HOMEenv override takes priority over~/.groktest_search_grok_prompt_history— JSONL audit log yieldskind="history",role="user"with correct session_idtest_search_grok_chat_history_session— JSONL transcripts yield user + assistant records with correct conversation_idtest_search_grok_chat_history_drops_empty_content— records with empty/whitespace content are filteredtest_search_grok_session_search_db— SQLite FTS5 index yields titled records with ISO-8601 timestampstest_stores.py)just build-docsbuilds cleanly with new backend pages