feat(context): implement main ContextEngine with full integration (#85)

Phase 7 of Context Management Engine - Main Engine:

- Add ContextEngine as main orchestration class
- Integrate all components: calculator, scorer, ranker, compressor, cache
- Add high-level assemble_context() API with:
  - System prompt support
  - Task description support
  - Knowledge Base integration via MCP
  - Conversation history conversion
  - Tool results conversion
  - Custom contexts support
- Add helper methods:
  - get_budget_for_model()
  - count_tokens() with caching
  - invalidate_cache()
  - get_stats()
- Add create_context_engine() factory function

Tests: 26 new tests, 311 total context tests passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-04 02:44:40 +01:00
parent c2466ab401
commit 027ebfc332
3 changed files with 934 additions and 0 deletions

View File

@@ -88,6 +88,9 @@ from .adapters import (
# Cache
from .cache import ContextCache
# Engine
from .engine import ContextEngine, create_context_engine
# Prioritization
from .prioritization import (
ContextRanker,
@@ -137,6 +140,9 @@ __all__ = [
"TokenCalculator",
# Cache
"ContextCache",
# Engine
"ContextEngine",
"create_context_engine",
# Compression
"ContextCompressor",
"TruncationResult",