* Refactor project structure and optimize token handling
Moves core data models and utility modules into dedicated `models` and `utils` packages for better organization. This refactoring centralizes metadata classes like `UsageMetadata` and relocates the `TokenCounter`.
The token counting utility is enhanced to lazily import `tiktoken`, reducing application startup time. It now includes a fallback heuristic for environments where `tiktoken` is not available.
Additionally, this change removes obsolete documentation and legacy integration logic that has been superseded by the `LLMManager`.
* Refactor for improved type safety and strictness
Replaces dynamic attribute access (`getattr`, `hasattr`) and broad `Any` types with `Protocols`, `TypedDicts`, and concrete SDK types. This improves static analysis performance and code robustness without breaking compatibility with mocked objects in tests.
- Introduces protocols for structural type checking of LLM responses and error objects.
- Uses `TypedDict` for configuration and structured return values.
- Rewrites data extraction logic in the LLM manager and utility functions to use type-safe checks (`isinstance`) instead of fallible attribute checks.
- Simplifies AST parsing in `lsp_utils` by using `ast.unparse` and direct attribute access where types are known.
- Updates `pyrightconfig.json` to enforce stricter type checking on the main library code.
* Add support for GPT-5 models, including reasoning effort and pricing adjustments
* fix openai invocation
* Refactor LLM manager into a modular package
Decomposes the monolithic `llm_manager.py` into a structured `llm` package with distinct modules for clients, configuration, chunking, and error handling.
This refactoring introduces a protocol-based client architecture, allowing for cleaner separation of provider-specific logic (OpenAI, Gemini) from the core orchestration in `LLMManager`.
A compatibility shim is added to the old `llm_manager.py` to ensure existing imports continue to function while encouraging adoption of the new module paths.
* Refactor LLM clients for type safety and robustness
Introduces structural protocols and type guards to create a more resilient and type-safe API for handling responses from different LLM providers. This change replaces fragile `getattr` checks with explicit type guards, improving robustness against variations in API responses and test mocks.
Key changes include:
- Defines `TypeGuard` functions and `Protocol`s for common response shapes (OpenAI, Gemini).
- Updates client `generate` methods to use typed parameters instead of `**kwargs`, clarifying the method signature.
- Adds Pydantic validators to normalize configuration values for chunking and aggregation strategies.
- Centralizes response parsing logic within each client using internal helper methods.
* Fix usage metadata extraction in OpenAIClient to handle missing usage field
* Refactor LLM layer to use request objects and enums
Introduces a provider-agnostic `LLMRequest` data class to encapsulate all parameters for an LLM call. This simplifies the `LLMManager` and client interfaces by passing a single request object instead of numerous individual arguments.
- Replaces `Literal` types with `Enum` for `ResponseFormat`, `ReasoningEffort`, `ChunkStrategy`, and `AggregationStrategy` to improve type safety and clarity.
- Updates the `LLMClient` protocol and its `OpenAIClient` and `GeminiClient` implementations to accept the `LLMRequest` object.
- Standardizes the `call_llm_with_usage` return type with a `UsageResult` TypedDict.
- Removes obsolete example and mock context files.
* Refactor: Apply code formatting and remove trailing newlines
Applies consistent code formatting across the project for better readability and maintainability.
This includes wrapping long lines, standardizing spacing, and removing unnecessary trailing newlines from several files. Also updates the default configuration to demonstrate environment variable usage for model selection.
* changelog