refactor: extract cost-estimator lib + 31 tests - #25
Closed
TerminalGravity wants to merge 1 commit into
Closed
Conversation
This was referenced Feb 27, 2026
TerminalGravity
commented
Feb 27, 2026
TerminalGravity
left a comment
Collaborator
Author
There was a problem hiding this comment.
24 tests for estimate-cost — good coverage. LGTM 👍
TerminalGravity
force-pushed
the
add-estimate-cost-tests
branch
from
March 3, 2026 06:17
dd3c0c2 to
36a1fe4
Compare
- Export helper functions from estimate-cost.ts for testability - Add comprehensive tests for estimateTokens, extractText, extractToolNames, formatTokens, formatCost, formatDuration, and analyzeSessionFile - Restore prompt-score.test.ts (was missing from tracked files) - Export scorePrompt from prompt-score.ts to fix test imports - Total: 81 tests passing (was 60)
TerminalGravity
force-pushed
the
add-estimate-cost-tests
branch
from
March 4, 2026 17:46
36a1fe4 to
f933152
Compare
TerminalGravity
added a commit
that referenced
this pull request
Mar 5, 2026
Implements #5 — generates markdown reports from timeline data with: - Weekly/monthly/custom date range summaries - Daily activity breakdown with bar chart - Commit log extraction - Correction tracking and prompt quality indicators - Optional save to ~/.preflight/reports/ Registered as tool #25 in the MCP server.
Collaborator
Author
|
Superseded by newer PRs. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Extracts the cost estimation logic from
tools/estimate-cost.tsinto a dedicatedlib/cost-estimator.tsmodule for testability and reuse.Changes
src/lib/cost-estimator.ts— exported helpers:analyzeSessionContent,computeCost,estimateTokens,extractText,extractToolNames, formatting utils, pricing table, constantssrc/tools/estimate-cost.ts— thin wrapper that imports from the lib (was monolithic)tests/lib/cost-estimator.test.ts— 31 tests covering token estimation, text extraction, tool name parsing, formatting, correction detection, session analysis, and cost computationtests/lib/estimate-cost.test.ts(replaced with more comprehensive tests)Why
The original tool file mixed business logic with MCP registration, making it untestable without mocking the full server. Now the core logic is independently importable and tested.