$r) { $result .= ($i+1) . ". [{$r['title']}]({$r['url']})\n"; } } } } return $result; } // === SKILL SEARCH INTEGRATION === function wevia_skills_search($query, $limit = 5) { $ch = curl_init("http://127.0.0.1:6333/collections/weval_skills/points/scroll"); curl_setopt_array($ch, [ CURLOPT_POST=>true, CURLOPT_RETURNTRANSFER=>true, CURLOPT_TIMEOUT=>5, CURLOPT_HTTPHEADER=>["Content-Type: application/json"], CURLOPT_POSTFIELDS=>json_encode(["limit"=>200, "with_payload"=>true]) ]); $resp = json_decode(curl_exec($ch), true); curl_close($ch); $results = []; foreach (($resp["result"]["points"] ?? []) as $p) { $pay = $p["payload"] ?? []; if (stripos($pay["name"]??"", $query) !== false || stripos($pay["desc"]??"", $query) !== false) { $results[] = $pay; if (count($results) >= $limit) break; } } return $results; } // === AGENT DISPATCH (oh-my-claudecode 19 agents) === function wevia_agent_dispatch($message) { $agents_file = "/var/www/html/api/agents-catalog.php"; $agents_dir = "/opt/oh-my-claudecode/agents"; // Detect agent request in message $agent_keywords = [ "architect" => "architect.md", "debugger" => "debugger.md", "reviewer" => "code-reviewer.md", "designer" => "designer.md", "planner" => "planner.md", "security" => "security-reviewer.md", "tester" => "qa-tester.md", "analyst" => "analyst.md", "writer" => "writer.md", "executor" => "executor.md", ]; foreach ($agent_keywords as $kw => $file) { if (stripos($message, $kw) !== false && stripos($message, "agent") !== false) { $agent_prompt = @file_get_contents("$agents_dir/$file"); if ($agent_prompt) { return ["active" => true, "agent" => $kw, "system_prompt" => substr($agent_prompt, 0, 2000)]; } } } return ["active" => false]; } // === SUPERCLAUDE COMMANDS (/sc:*) === function wevia_sc_command($message) { if (strpos($message, "/sc:") === false) return null; $commands = [ "/sc:research" => "Deep research mode — search multiple sources, synthesize findings", "/sc:brainstorm" => "Creative brainstorming — generate 10+ ideas, evaluate each", "/sc:debug" => "Systematic debugging — trace, isolate, fix, verify", "/sc:refactor" => "Code refactoring — simplify, optimize, document", "/sc:review" => "Code review — security, performance, best practices", "/sc:test" => "Generate comprehensive tests — unit, integration, edge cases", "/sc:plan" => "Project planning — tasks, timeline, dependencies", "/sc:doc" => "Documentation — README, API docs, comments", "/sc:optimize" => "Performance optimization — profiling, bottlenecks, solutions", "/sc:security" => "Security audit — OWASP, vulnerabilities, hardening", ]; foreach ($commands as $cmd => $desc) { if (stripos($message, $cmd) !== false) { return ["command" => $cmd, "mode" => $desc]; } } return null; } // === PROMPTS LIBRARY === function wevia_prompt_suggest($category) { $prompts = json_decode(file_get_contents("/opt/weval-prompts-library.json"), true) ?: []; $filtered = array_filter($prompts, fn($p) => stripos($p["category"], $category) !== false); return array_values($filtered); } // === SKILLS RAG SEARCH === function wevia_skills_rag($query, $limit = 3) { $ch = curl_init("http://127.0.0.1:6333/collections/weval_skills/points/scroll"); curl_setopt_array($ch, [ CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 5, CURLOPT_HTTPHEADER => ["Content-Type: application/json"], CURLOPT_POSTFIELDS => json_encode(["limit" => 200, "with_payload" => true]) ]); $resp = json_decode(curl_exec($ch), true); curl_close($ch); $results = []; foreach (($resp["result"]["points"] ?? []) as $p) { $pay = $p["payload"] ?? []; if (stripos($pay["name"] ?? "", $query) !== false || stripos($pay["desc"] ?? "", $query) !== false) { $results[] = $pay; if (count($results) >= $limit) break; } } return $results; } // === DIFFUSIONDB IMAGE PROMPT ENHANCER === function wevia_enhance_image_prompt($user_prompt) { $lib = json_decode(@file_get_contents("/var/www/html/api/weval-prompts-library.json"), true) ?: []; if (!$lib) return $user_prompt; // Find best matching prompt from library $best = null; $best_score = 0; $words = array_filter(explode(" ", strtolower($user_prompt)), fn($w) => strlen($w) > 3); foreach ($lib as $p) { $score = 0; foreach ($words as $w) { if (stripos($p["prompt"], $w) !== false) $score++; } if ($score > $best_score) { $best_score = $score; $best = $p["prompt"]; } } if ($best && $best_score >= 1) { // Enhance user prompt with DiffusionDB style keywords $style_words = array_slice(explode(",", $best), -2); $style = implode(", ", array_map("trim", $style_words)); return $user_prompt . ", " . $style; } return $user_prompt; } // === IMAGE PROMPT SUGGESTIONS === function wevia_image_suggestions($category = "") { $lib = json_decode(@file_get_contents("/var/www/html/api/weval-prompts-library.json"), true) ?: []; if ($category) { $lib = array_filter($lib, fn($p) => $p["category"] === $category); } return array_slice(array_values($lib), 0, 5); } @include_once __DIR__ . '/wevcode-superclaude.php'; function wevia_dreamina_url($p){return 'https://dreamina.capcut.com/ai-tool/image/generate?prompt='.urlencode($p);} function wevia_codewiki(){return json_decode(file_get_contents('https://weval-consulting.com/api/code-wiki.php'),true);} function wevia_news_brief(){$r=json_decode(@file_get_contents("http://127.0.0.1/api/feeddough-news.php?action=brief"),true);return $r["brief"]??"Pas de news";}