*/ public static function get_current_scan_data(): array { $latest = TheDotDevAgenticBridge_Readiness_Store::latest(); return is_array($latest) ? $latest : []; } /** * @param array $scan * @return array{score: int, total: int, passing: int, attention: int, scannedAt: string} */ public static function get_scan_summary(array $scan): array { $findings = is_array($scan['findings'] ?? null) ? $scan['findings'] : []; $passing = 0; $attention = 0; foreach ($findings as $finding) { if (!is_array($finding)) { continue; } $status = (string) ($finding['status'] ?? ''); if ($status === TheDotDevAgenticBridge_Readiness_Methodology::STATUS_PASS) { ++$passing; } elseif (in_array($status, [TheDotDevAgenticBridge_Readiness_Methodology::STATUS_FAIL, TheDotDevAgenticBridge_Readiness_Methodology::STATUS_WARNING, TheDotDevAgenticBridge_Readiness_Methodology::STATUS_UNKNOWN], true)) { ++$attention; } } return [ 'score' => (int) ($scan['score'] ?? 0), 'total' => count($findings), 'passing' => $passing, 'attention' => $attention, 'scannedAt' => (string) ($scan['scannedAt'] ?? ''), ]; } /** * Owner-readable AI Preview label from stored scan data. * Keeps catalog/check identity when Findings uses incomplete-check copy. * * @param array $finding */ public static function preview_label(array $finding): string { $title = TheDotDevAgenticBridge_Findings_Presentation::owner_title($finding); if ($title !== __('This check could not be completed safely', 'agentic-bridge')) { return $title; } $stored = trim((string) ($finding['title'] ?? '')); if ($stored !== '' && !TheDotDevAgenticBridge_Findings_Presentation::looks_like_technical_evidence($stored)) { return $stored; } return $title; } /** @param array $scan */ public static function get_agent_summary(array $scan): string { $summary = self::get_scan_summary($scan); if ($summary['total'] === 0) { return __('Run a local readiness check to see what AI can extract from your site today.', 'agentic-bridge'); } return sprintf( /* translators: 1: passing check count, 2: total check count, 3: readiness score out of 100, 4: findings needing attention */ __('From your latest local scan: %1$d of %2$d checks are passing (score %3$d/100). %4$d need your review.', 'agentic-bridge'), $summary['passing'], $summary['total'], $summary['score'], $summary['attention'] ); } /** * @param array $scan * @return list */ public static function get_extracted_facts(array $scan): array { $findings = is_array($scan['findings'] ?? null) ? $scan['findings'] : []; $facts = []; foreach ($findings as $finding) { if (!is_array($finding) || (string) ($finding['status'] ?? '') !== TheDotDevAgenticBridge_Readiness_Methodology::STATUS_PASS) { continue; } $why = trim((string) ($finding['whyItMatters'] ?? '')); $facts[] = [ 'label' => (string) ($finding['title'] ?? ''), 'value' => $why !== '' ? $why : __('Confirmed from your latest local scan.', 'agentic-bridge'), ]; } return $facts; } /** * @param array $scan * @return list */ public static function get_answerable_questions(array $scan): array { $findings = is_array($scan['findings'] ?? null) ? $scan['findings'] : []; $questions = []; foreach ($findings as $finding) { if (!is_array($finding) || (string) ($finding['status'] ?? '') !== TheDotDevAgenticBridge_Readiness_Methodology::STATUS_PASS) { continue; } $title = trim((string) ($finding['title'] ?? '')); $why_it_matters = trim((string) ($finding['whyItMatters'] ?? '')); if ($title === '' || $why_it_matters === '') { continue; } $questions[] = [ 'question' => sprintf( /* translators: %s: readiness check title */ __('Can agents rely on this today: %s?', 'agentic-bridge'), $title ), 'answer' => $why_it_matters, ]; } return $questions; } /** * @param array $scan * @return list */ public static function get_gaps(array $scan): array { $findings = is_array($scan['findings'] ?? null) ? $scan['findings'] : []; $unresolved_statuses = [TheDotDevAgenticBridge_Readiness_Methodology::STATUS_FAIL, TheDotDevAgenticBridge_Readiness_Methodology::STATUS_WARNING]; $gaps = []; foreach ($findings as $finding) { if (!is_array($finding) || !in_array((string) ($finding['status'] ?? ''), $unresolved_statuses, true)) { continue; } $next_step = trim((string) ($finding['nextStep'] ?? '')); if ($next_step === '') { continue; } $gaps[] = [ 'gap' => (string) ($finding['title'] ?? ''), 'fix' => $next_step, ]; } return $gaps; } /** * @param array $scan * @return list}> */ public static function get_developer_evidence(array $scan): array { $findings = is_array($scan['findings'] ?? null) ? $scan['findings'] : []; $rows = []; foreach ($findings as $finding) { if (!is_array($finding)) { continue; } $evidence = is_array($finding['evidence'] ?? null) ? $finding['evidence'] : []; if ($evidence === []) { continue; } $lines = TheDotDevAgenticBridge_Readiness_Methodology::evidence_lines($evidence); if ($lines === []) { continue; } $rows[] = [ 'id' => (string) ($finding['id'] ?? ''), 'title' => (string) ($finding['title'] ?? ''), 'lines' => $lines, ]; } return $rows; } }