grove cx grove cx
cx is a command-line tool that manages file selection and aggregation for LLM prompts. It resolves inclusion patterns defined in .grove/rules, calculates token usage, and generates unified context files.
Core Mechanisms
Rule Resolution: The tool reads .grove/rules, processing patterns (globs), exclusions (!), and directives.
- Directives: Supports
@defaultfor inheritance,@aliasfor cross-workspace references, and filtering via@grepor@find. - Git Integration: Can reference external repositories via
git::syntax, managing clones and version pinning transparently.
Context Generation: Aggregates resolved file content into .grove/context.
- Hot vs. Cold: A separator (
---) in the rules file delimits immediate context from reference material (“cold context”), allowing agents to cache static references. - Formatting: Wraps file content in XML tags (default) or delimiters, preserving file path and metadata for the LLM.
Workspace Resolution: Utilizes the Grove ecosystem provider to resolve project aliases (e.g., @a:grove-core) to absolute paths. This enables modular context composition across distributed repositories without hardcoding system paths.
Features
Visualization & Analysis
cx view: An interactive terminal interface for the file tree. Visualizes inclusion status, exclusions, and gitignore status. Displays token counts per file and directory.cx stats: Reports token usage breakdown by language and file, identifying high-cost components.cx diff: Compares the current context against a named ruleset to visualize changes in file selection and token count.
Rule Management
cx rules: Terminal interface for managing named rulesets (e.g.,.cx/security.rules). Supports switching the active configuration used by agents.cx edit: Opens the active rules file in the system editor defined by$EDITOR.
Dynamic Composition
cx from-git: Generates context based on git state, such as staged files, branch differences, or commit history.cx from-cmd: Populates context rules from the standard output of a shell command.
Repository Management
cx repo: Manages the lifecycle of external git repositories referenced in rules. Handles cloning, checkout of pinned versions, and updates.