111 lines
3.5 KiB
PHP
111 lines
3.5 KiB
PHP
<?php
|
|
// WEVIA Audit API - doctrine 149
|
|
// Scan markers WEVIA-* deployes dans les pages HTML + cross-reference git
|
|
header('Content-Type: application/json');
|
|
|
|
$html_dir = '/var/www/html';
|
|
$markers = [];
|
|
|
|
// Scanner les markers WEVIA-* dans les HTML (exclude proofs et GOLD)
|
|
$cmd = "grep -rnE 'WEVIA-[A-Z0-9\-]+-v[0-9]+' " . escapeshellarg($html_dir) . " --include='*.html' 2>/dev/null | grep -v 'GOLD\|proofs/' | head -200";
|
|
$output = @shell_exec($cmd);
|
|
$lines = explode("
|
|
", trim($output));
|
|
|
|
$by_page = [];
|
|
foreach ($lines as $line) {
|
|
if (!$line) continue;
|
|
// Format: /path/to/file.html:LINE:content
|
|
if (preg_match('#^(.+?):(\d+):(.*(WEVIA-[A-Z0-9\-]+-v\d+).*)$#', $line, $m)) {
|
|
$file = str_replace($html_dir . '/', '', $m[1]);
|
|
$line_num = (int)$m[2];
|
|
$marker = $m[4];
|
|
if (!isset($by_page[$file])) $by_page[$file] = [];
|
|
// Group markers per page to avoid duplicates (open + close marker count for 1)
|
|
if (!in_array($marker, array_column($by_page[$file], 'marker'))) {
|
|
$by_page[$file][] = [
|
|
'marker' => $marker,
|
|
'first_line' => $line_num,
|
|
];
|
|
}
|
|
}
|
|
}
|
|
|
|
// Pour chaque page, chercher le dernier commit git qui l'a touche
|
|
$audit = [];
|
|
foreach ($by_page as $file => $page_markers) {
|
|
$full_path = $html_dir . '/' . $file;
|
|
$commit_info = @shell_exec("cd $html_dir && git log -1 --format='%h|%ad|%s' --date=short -- " . escapeshellarg($file) . " 2>/dev/null");
|
|
$commit_info = trim((string)$commit_info);
|
|
$commit_parts = explode('|', $commit_info, 3);
|
|
$audit[] = [
|
|
'file' => $file,
|
|
'url' => 'https://weval-consulting.com/' . $file,
|
|
'markers' => $page_markers,
|
|
'markers_count' => count($page_markers),
|
|
'last_commit' => $commit_parts[0] ?? '',
|
|
'last_commit_date' => $commit_parts[1] ?? '',
|
|
'last_commit_msg' => substr($commit_parts[2] ?? '', 0, 80),
|
|
];
|
|
}
|
|
|
|
// Liste des intents autonomy
|
|
$intents_dir = $html_dir . '/api/wired-pending';
|
|
$intent_files = glob($intents_dir . '/intent-opus4-{wire,apply,wevia-playwright}*.php', GLOB_BRACE);
|
|
$intents = [];
|
|
foreach ($intent_files as $f) {
|
|
$data = @include $f;
|
|
if (is_array($data)) {
|
|
$intents[] = [
|
|
'file' => basename($f),
|
|
'name' => $data['name'] ?? '?',
|
|
'triggers_count' => count($data['triggers'] ?? []),
|
|
'triggers_sample' => array_slice($data['triggers'] ?? [], 0, 3),
|
|
'priority' => $data['priority_tier'] ?? '?',
|
|
'source' => $data['source'] ?? '?',
|
|
];
|
|
}
|
|
}
|
|
|
|
// Liste des presets
|
|
$presets_dir = '/opt/wevia-brain/presets';
|
|
$presets = [];
|
|
foreach (glob("$presets_dir/*.json") as $p) {
|
|
$d = @json_decode(file_get_contents($p), true);
|
|
if (is_array($d)) {
|
|
$presets[] = [
|
|
'slug' => basename($p, '.json'),
|
|
'target' => basename($d['target'] ?? ''),
|
|
'marker' => $d['marker'] ?? '?',
|
|
];
|
|
}
|
|
}
|
|
|
|
// Liste scripts shell
|
|
$scripts_dir = '/opt/wevia-brain/scripts';
|
|
$scripts = [];
|
|
foreach (glob("$scripts_dir/*.sh") as $s) {
|
|
$scripts[] = [
|
|
'script' => basename($s),
|
|
'size_bytes' => filesize($s),
|
|
'executable' => is_executable($s),
|
|
];
|
|
}
|
|
|
|
echo json_encode([
|
|
'ok' => true,
|
|
'generated_at' => date('c'),
|
|
'doctrine' => '149 (audit trail) + 147+148 (autonomy)',
|
|
'stats' => [
|
|
'pages_with_markers' => count($audit),
|
|
'total_markers' => array_sum(array_column($audit, 'markers_count')),
|
|
'intents_autonomy' => count($intents),
|
|
'presets_available' => count($presets),
|
|
'scripts_available' => count($scripts),
|
|
],
|
|
'audit' => $audit,
|
|
'intents' => $intents,
|
|
'presets' => $presets,
|
|
'scripts' => $scripts,
|
|
], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
|