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 by grove cx.
  • --context flags: 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:

  1. Environment: ANTHROPIC_API_KEY variable.
  2. Command Execution: anthropic.api_key_command in grove.yml (e.g., retrieving from a password manager).
  3. Static Config: anthropic.api_key in grove.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 to stdout or 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 --regenerate flag triggers grove cx to rebuild context files from .grove/rules before 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 request command delegates to grove-anthropic when a Claude model is selected.
  • Flow: Uses this tool to execute agentic workflows that require Anthropic’s reasoning capabilities.
  • Context: Relies on grove cx for file traversal and .gitignore parsing when regenerating context.