Files
pr-vision/peptide-geo-monitor.php
peptiderepo ca1a41f6f9 feat: peptide-geo-monitor v0.1.0 — AI-visibility dashboard
Add initial plugin implementation per the CTO engineering handoff
(geomonitor/threads/2026-06-ai-visibility-v1/01-cto-eng-handoff.md).

## What
- PGM_Probe_Provider interface + PGM_Probe_Result value object
- PGM_Perplexity_Provider (sonar via OpenRouter/CF AI Gateway)
- PGM_OpenRouter_Provider (GPT-search + Gemini-search, generic parameterised)
- PGM_Gateway_Client: shared HTTP + exponential-backoff retry (mirrors PRAB)
- PGM_Citation_Detector: domain extraction, is_cited(), get_our_position()
- PGM_Cost_Ledger: MTD cost from DB, can_afford() pre-check, hard monthly cap
- PGM_Probe_Runner: peptides×intents×models run, budget abort, in-run cache
- PGM_Table_Manager: pgm_ai_visibility dbDelta, schema-version, drop_table()
- PGM_Config: typed getters, seed_defaults() (12 peptides, 3 intents, 3 models)
- PGM_Cron: weekly pgm_weekly_probe schedule/clear
- PGM_Data_Collector + PGM_Dashboard_Panel interfaces (seam for future panels)
- PGM_Collector_Registry: singleton registry
- PGM_Ai_Visibility_Collector: trendline, standings, MTD cost (score formula)
- PGM_Ai_Visibility_Panel: proxy note, Chart.js trendline, standings table
- PGM_Admin_Page: GEO Monitor menu, Run now POST handler (nonce+capability)
- uninstall.php: DROP TABLE + DELETE pgm_* options + wp_clear_scheduled_hook
- Unit tests (6 files): citation detection, score calc, cost ledger + budget
  abort, provider response parsing (mock HTTP), cron, uninstall purge
- ARCHITECTURE.md, CONVENTIONS.md, CONTEXT.md (score formula), README.md,
  CHANGELOG.md — same-commit per DoD
- CI workflow: PHP lint (8.1/8.2/8.3) + PHPCS + 300-line check

## Security
- Secrets from wp-config constants only; none hardcoded
- manage_options + nonce on every admin action
- Input sanitized; output escaped

Agent-Session: geomonitor v0.1.0
2026-06-13 08:18:56 +00:00

69 lines
2.7 KiB
PHP

<?php
/**
* Plugin Name: Peptide GEO Monitor
* Plugin URI: https://peptiderepo.com
* Description: Weekly server-side LLM probes for AI-visibility (GEO) tracking. Records whether peptiderepo.com is cited by LLMs across core peptides, stores time-series, and renders an admin trendline + standings table.
* Version: 0.1.0
* Author: peptiderepo
* Author URI: https://peptiderepo.com
* License: GPL-2.0-or-later
* Text Domain: peptide-geo-monitor
* Requires PHP: 8.1
*
* @see ARCHITECTURE.md — Full data flow and file tree.
* @see CONVENTIONS.md — Naming patterns and extension guide.
* @see CONTEXT.md — Domain glossary incl. the visibility score formula.
*/
declare(strict_types=1);
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/* ── Constants ────────────────────────────────────────────────────────── */
define( 'PGM_VERSION', '0.1.0' );
define( 'PGM_PLUGIN_FILE', __FILE__ );
define( 'PGM_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
define( 'PGM_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'PGM_SCHEMA_VERSION', 1 );
/** @var int Maximum HTTP retries for LLM API calls. */
define( 'PGM_MAX_RETRIES', 3 );
/** @var int API request timeout in seconds. */
define( 'PGM_API_TIMEOUT_SECONDS', 60 );
/** @var int Base backoff delay (seconds) between retries. */
define( 'PGM_RETRY_BASE_DELAY_SECONDS', 2 );
/** @var float Default monthly budget cap in USD. */
define( 'PGM_DEFAULT_MONTHLY_BUDGET_USD', 5.0 );
/** @var string WP-Cron hook name for the weekly probe run. */
define( 'PGM_CRON_HOOK', 'pgm_weekly_probe' );
/** @var string The site we are tracking citations for. */
define( 'PGM_TARGET_DOMAIN', 'peptiderepo.com' );
/* ── Autoloader ───────────────────────────────────────────────────────── */
require_once PGM_PLUGIN_DIR . 'includes/core/class-pgm-autoloader.php';
PGM_Autoloader::register();
/* ── Activation / Deactivation ────────────────────────────────────────── */
register_activation_hook( __FILE__, array( 'PGM_Activator', 'activate' ) );
register_deactivation_hook( __FILE__, array( 'PGM_Deactivator', 'deactivate' ) );
/* ── Boot ──────────────────────────────────────────────────────────────── */
add_action(
'plugins_loaded',
static function (): void {
$plugin = new PGM_Plugin();
$plugin->init();
}
);