Crate gestura_core_context

Crate gestura_core_context 

Source
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:

  1. Request analysis: infer intent and extract entities without needing a model round-trip
  2. Context resolution: load only the categories and tool descriptors that are likely relevant to the request
  3. 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 intent
  • ContextManager: orchestrates analysis, resolution, and cache lookup
  • ContextCache: 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§

CacheStats
Cache statistics
ContextCache
Smart cache for context data
ContextManager
Manager for handling context in a smart, efficient way
ContextManagerStats
Statistics for the context manager
ExtractedEntity
An entity extracted from the request
FileContext
File context loaded for the request
RequestAnalysis
Request analysis result - determines what context is needed
RequestAnalyzer
Analyzes requests to determine what context is needed
ResolvedContext
Context that has been resolved and cached
ToolContext
Minimal tool context for when tools are needed

Enums§

ContextCategory
Categories of context that might be needed for a request
EntityType
Types of entities that can be extracted

Functions§

estimate_tokens
Estimate token count for a string (rough approximation)

Type Aliases§

ToolProviderFn
Type alias for the tool provider callback.