grove cx grove cx

grove cx grove cx

cx is a command-line tool for managing LLM context from local files using declarative rule sets. It is designed to run in a terminal, reading patterns from text files to assemble context for other tools that interact with LLMs. The primary goal is to provide a reproducible, version-controllable method for defining the set of files an LLM should consider.

Key Features

  • Declarative Rules: Defines context using a .grove/rules file with glob patterns (*, **), exclusions (!), and aliases.
  • Hot/Cold Context: Separates rules into “hot” (dynamic, for every prompt) and “cold” (static, for LLM provider caching) sections using a --- delimiter, which generates separate output files.
  • Workspace & Git Integration: Resolves files from the local git repository, aliased Grove workspaces, and cloned external Git repositories pinned to a specific version.
  • Rule Set Management: Provides commands to save, load, and switch between named sets of rules stored in .cx/ (version-controlled) and .cx.work/ (local) directories.
  • Interactive TUI: Includes a terminal interface (cx view) to visualize how rules resolve to files, showing the status of each file (included, excluded, or git-ignored).
  • Context Analysis: Provides commands (cx stats, cx diff) to display token counts, language distribution, and differences between rule sets.

How It Works

The cx tool reads glob patterns from an active rules file. The primary file is .grove/rules, but cx rules set <name> can activate a named rule set from a .cx/ directory. These patterns are resolved into a list of file paths, respecting .gitignore exclusions. Rules can reference other Grove workspaces via aliases (e.g., @a:project-name/path) or external Git repositories (e.g., git@github.com:owner/repo@tag).

The cx generate command reads the resolved file list and concatenates the file contents into .grove/context (for hot rules) and .grove/cached-context (for cold rules). These concatenated files are then consumed by other tools.

Ecosystem Integration

cx functions as a foundational component for other tools in the Grove ecosystem:

  • flow & gemapi: These tools execute cx generate to create context files before making requests to LLM APIs.
  • neogrove (Neovim): The plugin uses cx stats --per-line to display token counts as virtual text next to each rule and cx resolve to preview which files a rule matches.
  • starship: The cx starship module can be used to display the name of the active rule set in the shell prompt.
  • repo Subsystem: The cx repo subcommands manage a manifest of locally cloned, bare Git repositories stored in ~/.grove/cx/repos/. These repositories can be referenced by version in any project’s rules file, and cx will use a worktree of the specified commit.

Installation

Install via the Grove meta-CLI:

bash
grove install cx

Verify installation:

bash
cx version

This requires the grove meta-CLI. See the Grove installation guide if it is not installed.