Repository navigation
feat(encoder): add progress logging and incremental cache with token tracking - #55
Conversation
Summary of ChangesHello @amondnet, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request significantly upgrades the RPG encoder's operational transparency and resilience. It introduces robust logging for real-time progress monitoring, implements an incremental caching mechanism to safeguard against data loss, and integrates comprehensive LLM token usage tracking for cost and performance analysis. These enhancements aim to provide users with a more reliable, observable, and cost-aware encoding experience. Highlights
Changelog
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
Code Review
This pull request introduces excellent enhancements for observability and reliability in the RPG encoder. The progress logging, incremental cache saving, and LLM token usage tracking are valuable additions. The code is well-structured and the changes are clearly implemented. I've added a couple of minor suggestions to improve maintainability by reducing code duplication and making the statistics aggregation more scalable. Overall, this is a great contribution.
There was a problem hiding this comment.
1 issue found across 6 files
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="src/utils/llm.ts">
<violation number="1" location="src/utils/llm.ts:97">
P2: The `TokenUsageStats` interface is inserted between the `LLMClient` class JSDoc and the class declaration, breaking the JSDoc association. Move the interface definition *above* the class JSDoc block (e.g., after `createProvider`) so the class documentation remains properly attached.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
…tracking Added comprehensive progress logging to track encoding phases and LLM usage: - Log LLM configuration on encoder initialization - Display file progress with [n/N] counter and relative paths - Show phase transitions (Domain Discovery, Hierarchical Construction, etc.) - Track and report cache hit/miss statistics - Log cumulative LLM token usage (requests, input/output tokens) Improved cache reliability: - Save cache incrementally after each file (survives interruption) - Track cache hits/misses for statistics Enhanced CLI and LLM client: - Updated CLI shebang to #!/usr/bin/env node for broader compatibility - Added dotenv support for loading .env.local and .env files - Added TokenUsageStats tracking to LLMClient (getUsageStats, resetUsageStats) - Updated default models: claude-sonnet-4.5, gemini-3-flash-preview - Added SemanticExtractor.getLLMClient() accessor for usage stats This improves observability during long-running encoding operations and provides insights into LLM API costs and cache effectiveness.
…estimation - Add MODEL_PRICING table for cost estimation across providers (OpenAI, Anthropic, Google) - Implement estimateCost() method in LLMClient to calculate input/output costs - Add 120s timeout with AbortSignal to prevent hanging requests - Add onError callback for custom error handling - Wrap file extraction in try/catch with detailed error logging - Wrap Phase 2 steps (domain discovery, hierarchy builder) in try/catch - Display estimated cost in LLM usage summary (~$X.XXXX format) - Log extraction failures as warnings and continue processing remaining files This enhances the encoder progress logging PR with better observability and resilience for production use.
Replace .please/memory/session-summary.md with .please/memory/ to ignore all memory files generated by Please AI.
- Refactor token stats aggregation to use array methods (gemini-code-assist) - Extract INITIAL_USAGE_STATS constant to avoid duplication (gemini-code-assist) - Move TokenUsageStats interface above LLMClient class JSDoc (cubic-dev-ai)
70b00aa to
c4773bf
Compare
|



Summary
This PR enhances the RPG encoder with comprehensive progress logging, incremental cache saving, and LLM token usage tracking to improve observability and reliability during long-running encoding operations.
Changes
Progress Logging
[n/N]counter with relative file paths during Phase 1Incremental Cache Saving
CLI & LLM Improvements
#!/usr/bin/env bunto#!/usr/bin/env nodefor broader compatibilitydotenvdependency for loading.env.localand.envconfiguration filesTokenUsageStatsinterface toLLMClientwithgetUsageStats()andresetUsageStats()methodsclaude-sonnet-4.5gemini-3-flash-previewSemanticExtractor.getLLMClient()accessor for usage statisticsExample Output
Benefits
.env.localsupport for local API key managementTest Plan
.env.localcorrectlyRelated Issues
This improves the developer experience for the encoder functionality introduced in previous PRs.
Summary by cubic
Adds detailed progress logging, incremental cache saves, token usage/cost tracking, and stronger error handling/timeouts to make long encoding runs easier to monitor and more resilient. Also updates the CLI to use Node, load env files, refreshes default LLM models, and cleans up MCP config.
New Features
Refactors
Written for commit c4773bf. Summary will update on new commits.