Monthly spend/token/estimate-count queries and recent-logs retrieval
moved to PSA_Cost_Reporter. Tracker retains table management, logging,
budget enforcement, and cost estimation. Shared month_range helper
in reporter eliminates duplicated date-range logic.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DeepSeek models on OpenRouter omit the usage object, causing all token
counts and costs to log as zero. Added character-based estimation
fallback (~3.75 chars/token), token_source column to distinguish
measured vs estimated data, and admin UI indicators (amber warnings,
~ prefix on estimates). Updated DeepSeek/Qwen pricing table.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
is_budget_exceeded() used `0 === $budget` but floatval() returns float,
so 0 (int) === 0.0 (float) is always false. This caused unlimited
budget ($0) to be treated as exceeded, blocking all AI generation.
Same bug existed in the admin display (showed "$0.00" instead of
"Unlimited" for budget remaining).
This was a P1 bug that prevented ALL AI content generation since v4.3.0.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move declare(strict_types=1) after file-level docblock in all 12 class
files to satisfy WordPress Coding Standards docblock placement rule.
Fix multi-line function call formatting in class-psa-admin.php. Align
array double arrows and equals signs. Fix escaped backticks in
AIGeneratorTest heredoc that broke markdown fence stripping tests.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Adds [peptide_directory] shortcode with card grid, category taxonomy (8 terms),
search, pagination, detail modal, and /v1/compounds REST endpoint. Includes 9
new meta fields (half-life, stability, solubility, etc.), admin data tools for
migration/re-enrichment, integration hooks for cross-plugin extensibility,
dark mode support, and full uninstall cleanup. Refactors AI generator into
PSA_OpenRouter + PSA_KB_Builder classes. Adds PHPUnit tests for PostType and
Directory classes. Fixes QA findings: dead JS selector, renderError loading
state, numeric meta validation, prepared SQL in uninstall.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace interpolated variables in SQL strings with concatenation
and add appropriate phpcs:ignore comments for safe table name usage
built from $wpdb->prefix. Fixes CI failure on WordPress Coding
Standards check.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Create PSA_Cost_Tracker class with database table for API call logging
- Log prompt/completion tokens and estimated cost for every OpenRouter API call
- Implement monthly budget system with hard stop (budget of 0 = unlimited)
- Add budget checks in validate_peptide_name() and generate_peptide_content()
- Add dry_run() method to estimate costs before making API calls
- Display monthly usage summary and recent API logs in admin settings
- Add monthly_budget setting to admin interface with number input field
- Update uninstall.php to drop psa_api_logs table on plugin removal
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>