grove grove-anthropic grove grove-anthropic
grove-anthropic is a command-line interface and Go library for interacting with the Anthropic API. It serves as the provider-specific implementation for Claude models within the Grove ecosystem, handling context assembly, token usage tracking, and structured logging.
Core Mechanisms
Context Assembly: The tool integrates with the Grove ecosystem’s context management standards. Before executing a request, it scans the current working directory for:
.grove/context: Pre-assembled context file generated bygrove cx.--contextflags: Ad-hoc file paths provided at runtime. All identified files are uploaded via the Anthropic Beta Files API rather than being embedded directly into the prompt text.
Configuration Resolution: API credentials are resolved through a three-tiered precedence order:
- Environment:
ANTHROPIC_API_KEYvariable. - Command Execution:
anthropic.api_key_commandingrove.yml(e.g., retrieving from a password manager). - Static Config:
anthropic.api_keyingrove.yml.
Structured Observability: Every request is logged to ~/.local/state/grove/logs/anthropic/ in JSONL format. These logs capture:
- Token usage (input/output) and estimated cost based on local pricing tables.
- Execution context (Git remote, branch, commit hash).
- Response latency and completion status.
- The calling binary (e.g.,
flow,grove, or direct invocation).
Features
request: Executes a prompt against a specified model. Supports streaming output tostdoutor writing to a file.- Token Estimation: Calculates and displays estimated costs for requests, accounting for model-specific pricing (e.g., Claude 3.5 Sonnet vs. Opus) and “Long Context” pricing tiers.
- Model Aliasing: resolving short names (e.g.,
sonnet,haiku) to specific API model versions defined in the internal registry. - Context Regeneration: The
--regenerateflag triggersgrove cxto rebuild context files from.grove/rulesbefore the request is sent, ensuring the LLM receives the latest file state.
Integration
grove-anthropic is designed to be orchestrated by higher-level tools rather than used exclusively as a standalone CLI.
- Grove CLI: The
grove llm requestcommand delegates togrove-anthropicwhen a Claude model is selected. - Flow: Uses this tool to execute agentic workflows that require Anthropic’s reasoning capabilities.
- Context: Relies on
grove cxfor file traversal and.gitignoreparsing when regenerating context.