$type, 'text'=>$text, 'engine'=>$engine]) . "\n\n"; @ob_flush(); @flush(); exit; } // 1. plan_action_append : "plan action append " ou "ajoute * plan-action" if (preg_match('/(plan[-_ ]?action.*(append|ajout)|ajout[e]? .* plan[-_ ]?action|append .* plan)/i', $__bm)) { $text = trim(preg_replace('/^.*(plan[-_ ]?action.*(append|ajout)|ajout[e]? .* plan[-_ ]?action|append .* plan)\s*:?\s*/i', '', $_mam)); if (empty($text) || strlen($text) < 5) $text = "[V32] sovereign_heal + doctrine_74_fix + multiagent SSE restored + Playwright V18 28/29"; $gold = _vgi_gold_backup($_PLAN_PATH); if (!file_exists($_PLAN_PATH)) { @file_put_contents($_PLAN_PATH, "# Plan Action DP — Master Log\n\n"); } $ts = date('Y-m-d H:i:s'); $entry = "\n## " . $ts . " — V32 append\n\n" . $text . "\n"; $ok = @file_put_contents($_PLAN_PATH, $entry, FILE_APPEND) !== false; $lines = count(file($_PLAN_PATH)); _vgi_sse('exec', "Plan action appended. Lines now: {$lines}. GOLD: " . basename($gold ?? 'none')); } // 2. doctrine_create : "cree doctrine N titre" if (preg_match('/(cree?|create).*doctrine\s+(\d+)/i', $__bm, $m)) { $num = $m[2]; $title = trim(preg_replace('/^.*doctrine\s+\d+\s*/i', '', $_mam)); if (empty($title)) $title = "DOCTRINE_$num"; $slug = strtolower(preg_replace('/[^a-z0-9]+/i', '-', $title)); $path = "{$_DOCTRINES_DIR}/{$num}-{$slug}.md"; if (file_exists($path)) { _vgi_sse('exec', "Doctrine $num existe deja: " . basename($path)); } $body = "---\ntags: [doctrine, wevia-master, autonomie]\ncreated: " . date('Y-m-d') . "\npriority: " . (strpos(strtolower($title),'critical')!==false?'0':'1') . "\nnumber: $num\n---\n\n# DOCTRINE $num — " . strtoupper($title) . "\n\n## Principe\n" . $title . "\n\n## Root cause adressee\nManque autonomie WEVIA Master sur cette capacite.\n\n## Implementation\nVoir intent wire associe dans /var/www/html/api/wevia-*-intent.php\n\n## Tests\n- Unit: php -l\n- Fonctionnel: dispatch via WEVIA chat\n- Regression: nonreg + playwright\n\n## Zero-defect checklist\n- [ ] GOLD backup avant modif\n- [ ] Non destructif\n- [ ] Zero suppression\n- [ ] Lint OK\n- [ ] Nonreg 153/153 preserve\n"; $ok = @file_put_contents($path, $body) !== false; _vgi_sse('exec', "Doctrine $num creee: " . basename($path) . " (" . strlen($body) . " bytes)"); } // 3. session_save : "sauve session " if (preg_match('/(sauve|save).*session\s+(.+)/i', $__bm, $m)) { $name = trim($m[2]); $slug = strtolower(preg_replace('/[^a-z0-9]+/i', '-', $name)); $path = "{$_SESSIONS_DIR}/session-" . date('dMmmy-His') . "-{$slug}.md"; $body = "# Session " . date('Y-m-d H:i:s') . "\n\n## Context\n{$name}\n\n## Actions\n- Via WEVIA Master chat\n- Architect: Opus\n\n## Files touched\nSee git log.\n"; @file_put_contents($path, $body); _vgi_sse('exec', "Session sauvee: " . basename($path)); } // 4. git_commit_push : "git commit push " ou "commit et push" if (preg_match('/(commit\s+(et\s+)?push|git\s+push|push\s+(github|gitea))/i', $__bm)) { $msg = "auto-commit via WEVIA vault_git intent " . date('c'); if (preg_match('/commit\s+(et\s+)?push\s+(.+)/i', $_mam, $mm)) { $msg = substr(trim($mm[2]), 0, 200); } chdir($_REPO); $out = []; exec('git add -A 2>&1', $out); exec("git commit -m " . escapeshellarg($msg) . " 2>&1", $out); exec('git push github main 2>&1', $out); exec('git push gitea main 2>&1 || git push gitea master 2>&1', $out); exec('git rev-parse --short HEAD', $sha); $tail = implode(' | ', array_slice($out, -3)); _vgi_sse('exec', "Commit+push done. HEAD: " . ($sha[0] ?? '?') . ". Tail: " . substr($tail, 0, 200)); } // 5. l99_trigger : "l99 update" ou "l99 run" if (preg_match('/(l99.*(update|trigger|run|refresh)|update.*l99|trigger.*l99)/i', $__bm)) { $out = []; @exec('python3 /opt/weval-l99/l99-state-updater.py 2>&1', $out); $last = array_slice($out, -3); $state_file = '/var/www/html/api/l99-state.json'; $state_info = file_exists($state_file) ? 'state file ' . filesize($state_file) . 'b' : 'no state'; _vgi_sse('exec', "L99 triggered. $state_info. Tail: " . substr(implode(' | ', $last), 0, 200)); }