Commit Graph

5 Commits

Author SHA1 Message Date
peptiderepo
19fea30932 fix(admin): load delegate classes + add WP test stubs (#8)
* fix(admin): load delegate classes from orchestrator + add WP stubs for tests

The admin refactor split introduced delegate classes that the orchestrator
instantiates in its constructor. CI failed because tests require the
orchestrator directly without going through the plugin loader. Fix: add
require_once for all delegate files at the top of the orchestrator, and
add missing WP function stubs to the test bootstrap.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(admin): add missing sanitize_model_id and sanitize_api_key delegators

The refactored orchestrator was missing public method delegations for
sanitize_model_id() and sanitize_api_key(), which tests call directly
on the Peptide_News_Admin instance and WordPress uses as register_setting
callbacks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

* fix(phpcs): remove strict_types declaration that breaks file header order

PSR12.Files.FileHeader.IncorrectOrder requires the docblock immediately
after the opening PHP tag. The declare(strict_types=1) was inserted
between them.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

---------

Co-authored-by: peptiderepo <peptiderepo@users.noreply.github.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-16 17:01:34 +07:00
Terence
b7da4f42b9 feat: add LLM cost tracking with budget enforcement and admin dashboard
- New Cost_Tracker class: logs every API call (model, tokens, cost), enforces
  monthly budgets with hard-stop mode, provides aggregated reporting
- New llm_costs database table with indexes on created_at, model, operation
- Modified LLM class: call_openrouter_with_usage() extracts token usage from
  OpenRouter responses; budget gate checks before each API call
- Admin settings: monthly budget (USD), enforcement mode (disabled/warn/hard-stop),
  cost log retention period
- Admin cost dashboard: budget progress bar, daily cost chart (Chart.js),
  per-model and per-operation breakdowns, recent API call log
- PHPUnit tests: 16 tests covering cost calculation, pricing lookups,
  budget enforcement logic, and model validation
- Updated ARCHITECTURE.md with new table schema, data flow, and key decisions
- Updated CONVENTIONS.md with "how to add cost tracking for a new operation"
- Version bump to 2.4.0

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-13 04:18:30 +07:00
Terence Ong
9f267342a0 Fix pre-existing PHPUnit test failures in CI
Add missing WordPress function stubs (current_user_can, esc_url_raw,
is_user_logged_in, get_current_user_id) and load LLM class in test
bootstrap so AdminTest model validation and RestApiTest permission
checks work correctly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 14:26:31 +07:00
Terence Ong
e6887e810f Add content filter to block ads, press releases, and promotional content
Two-tier filtering during article fetch: keyword/pattern rules as a fast
first pass, then optional LLM classification for borderline cases via
OpenRouter. Configurable sensitivity (strict/moderate/lenient), editable
keyword lists, blocked domain list, and admin stats display. Includes
30 unit tests covering domain blocking, title/body keywords, URL paths,
edge cases, and prompt structure.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 14:14:16 +07:00
Terence Ong
849ffa1260 Add CI/CD pipeline with automated testing and SFTP deployment
Introduces GitHub Actions workflows for continuous integration and
deployment. CI runs PHP linting (7.4, 8.1, 8.3), PHPCS with WordPress
coding standards, PHPUnit tests across PHP versions, and JS syntax
checks. Deployment to Hostinger via FTPS triggers on push to main
after all CI checks pass, with optional LiteSpeed cache purge.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-04-06 13:41:47 +07:00