Extract article listing endpoint and source-suffix stripping into
Peptide_News_Rest_Articles (195 lines). Main REST API retains route
registration, analytics endpoint wrappers, AJAX delete handler, and
permission/validation helpers (210 lines).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract keyword data, domain blocklists, and rule evaluation into
Peptide_News_Content_Filter_Rules (195 lines). Main class retains
orchestration, LLM classification, and stats (234 lines). Backward-
compatible proxies preserved on Peptide_News_Content_Filter.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Extract source-resolution and RSS-specific logic from the monolithic
Peptide_News_Fetcher:
- class-peptide-news-source-resolver.php (229 lines) — aggregator
source detection, redirect resolution, title parsing, backfill
- class-peptide-news-rss-source.php (118 lines) — RSS/Atom feed
fetching and SimplePie item processing
- class-peptide-news-fetcher.php (271 lines) — orchestrator with
NewsAPI, storage, pruning, caching, and AI post-processing
Also consolidated duplicate clear_article_cache/invalidate_rest_api_cache
methods (they were identical) into a single clear_article_cache().
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The monolithic Peptide_News_LLM class mixed HTTP transport, prompt
construction, batch orchestration, and AJAX handling. Split into:
- class-peptide-news-llm-client.php (199 lines) — OpenRouter HTTP
transport with retry logic and response parsing
- class-peptide-news-llm-prompt-builder.php (142 lines) — keyword
and summary prompt construction, article text fetching
- class-peptide-news-llm-ajax.php (87 lines) — bulk-generate AJAX
handler
- class-peptide-news-llm.php (300 lines) — orchestrator with
backward-compatible proxies for is_valid_model(), call_openrouter(),
and call_openrouter_with_usage()
Extracted run_llm_task() helper to deduplicate the keyword/summary
processing blocks. All public API preserved — no test changes needed.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* 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>
- 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>
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>
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>
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>