Skip to content

test: add 21 tests for estimate_cost helpers#40

Closed
TerminalGravity wants to merge 5 commits intomainfrom
test/estimate-cost-coverage-v2
Closed

test: add 21 tests for estimate_cost helpers#40
TerminalGravity wants to merge 5 commits intomainfrom
test/estimate-cost-coverage-v2

Conversation

@TerminalGravity
Copy link
Copy Markdown
Collaborator

Adds unit test coverage for the pure helper functions in estimate_cost:

  • estimateTokens — token estimation from char count
  • extractText — content block text extraction
  • extractToolNames — tool_use name extraction
  • formatTokens / formatCost / formatDuration — display formatters
  • CORRECTION_SIGNALS — regex pattern matching

Also replaces an empty if-block (dead code) with an explanatory comment.

Test count: 52 → 73 (all passing)

… and contracts

The README references .preflight/ config extensively but there were no
concrete example files to copy. This adds a ready-to-use examples/.preflight/
directory with annotated config.yml, triage.yml, and contracts/api.yml,
plus a README explaining how to use them.
Created examples/USAGE_EXAMPLES.md with 8 real-world scenarios showing
what each tool looks like in practice: preflight_check catching vague
prompts, scope_work creating execution plans, enrich_agent_task for
sub-agents, sharpen_followup resolving ambiguity, session health checks,
semantic history search, weekly scorecards, and prompt grading.

Added link to usage examples in README nav bar.
- Tests default config values when no .preflight/ dir exists
- Tests config.yml merging with defaults
- Tests triage.yml rule loading
- Tests graceful fallback on malformed YAML
- Tests env var fallback (PROMPT_DISCIPLINE_PROFILE)
- Tests env vars ignored when .preflight/ dir present
- Tests hasPreflightConfig() and getRelatedProjects()

9 new tests, 52 total passing
- Unit tests for estimateTokens, extractText, extractToolNames,
  formatTokens, formatCost, formatDuration, CORRECTION_SIGNALS
- Replace empty if-block with explanatory comment
- Total test count: 52 → 73
@TerminalGravity
Copy link
Copy Markdown
Collaborator Author

Superseded by newer PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant