Expand description
Smart context analysis, resolution, and caching for Gestura.
gestura-core-context helps the runtime decide what context is relevant for
a request before invoking an LLM. It provides lightweight request analysis,
entity extraction, category classification, tool-aware context resolution,
and cache-backed reuse of previous results.
§Resolution model
The context system follows a three-stage approach:
- Request analysis: infer intent and extract entities without needing a model round-trip
- Context resolution: load only the categories and tool descriptors that are likely relevant to the request
- Smart caching: reuse recent analysis and resolved context with TTL- and size-based cache limits
§Main entry points
RequestAnalyzer: parses requests into categories, entities, and intentContextManager: orchestrates analysis, resolution, and cache lookupContextCache: reusable caching layer with observable stats- foundation re-exports: shared context data structures from
gestura-core-foundation
§Architecture boundary
This crate owns context-domain behavior. It does not decide how the pipeline
uses the resolved context inside a full agent run; that orchestration remains
in gestura-core.
Most application code should import these types through
gestura_core::context::*, while code inside the workspace may depend on
this domain crate directly when evolving context analysis itself.
§Example
ⓘ
use gestura_core::context::ContextManager;
let manager = ContextManager::new();
let analysis = manager.analyze("Read the file src/main.rs");
let context = manager.resolve_simple("Show git status", None);
println!("{:?} -> {} tools", analysis.categories, context.tools.len());Structs§
- Cache
Stats - Cache statistics
- Context
Cache - Smart cache for context data
- Context
Manager - Manager for handling context in a smart, efficient way
- Context
Manager Stats - Statistics for the context manager
- Extracted
Entity - An entity extracted from the request
- File
Context - File context loaded for the request
- Request
Analysis - Request analysis result - determines what context is needed
- Request
Analyzer - Analyzes requests to determine what context is needed
- Resolved
Context - Context that has been resolved and cached
- Tool
Context - Minimal tool context for when tools are needed
Enums§
- Context
Category - Categories of context that might be needed for a request
- Entity
Type - Types of entities that can be extracted
Functions§
- estimate_
tokens - Estimate token count for a string (rough approximation)
Type Aliases§
- Tool
Provider Fn - Type alias for the tool provider callback.