Skip to main content

Crate ucp_llm

Crate ucp_llm 

Source
Expand description

§UCP LLM

LLM-focused utilities for the Unified Content Protocol.

This crate provides helpers for turning UCM documents into LLM-friendly prompts and UCL command scaffolds, with a focus on token efficiency, deterministic mappings, and safe prompt composition.

§Key Types

  • ContextManager - Context window management with expansion and pruning
  • IdMapper - Token-efficient ID mapping (shortens block IDs for LLMs)
  • PromptBuilder - Dynamic prompt generation with capability scoping

§Example

use ucp_llm::IdMapper;
use ucm_core::BlockId;

let mut mapper = IdMapper::new();
let block_id = BlockId::new([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]);
let short_id = mapper.register(block_id);
println!("Short ID: {} (saves ~18 tokens)", short_id);

Re-exports§

pub use context::CompressionMethod;
pub use context::ContextConstraints;
pub use context::ContextManager;
pub use context::ContextStatistics;
pub use context::ContextUpdateResult;
pub use context::ContextWindow;
pub use context::ExpandDirection;
pub use context::ExpansionPolicy;
pub use context::InclusionReason;
pub use context::PruningPolicy;
pub use id_mapper::IdMapper;
pub use prompt_builder::presets;
pub use prompt_builder::PromptBuilder;
pub use prompt_builder::UclCapability;

Modules§

context
Context management infrastructure for UCM documents.
id_mapper
ID Mapper for LLM prompts
prompt_builder
Dynamic prompt builder for LLM agents.