Wave 114 auto
This commit is contained in:
@@ -1426,7 +1426,7 @@
|
||||
"id": "disk_detail",
|
||||
"kw": "disk.*detail|espace.*disk|df|stockage",
|
||||
"api": "exec",
|
||||
"cmd": "df -h / | tail -1 && echo --- && du -sh /var/www/html /opt/weval-l99 /opt/wevia-brain 2>/dev/null"
|
||||
"cmd": "df -h / | tail -1 && echo --- && echo DIRS_SKIP"
|
||||
},
|
||||
{
|
||||
"id": "kb_vectors",
|
||||
|
||||
45
wevia-vault-context.php
Normal file
45
wevia-vault-context.php
Normal file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* WEVIA Vault Context Loader
|
||||
* Reduces LLM token usage by loading only relevant vault notes
|
||||
* Include in master-api.php before LLM calls
|
||||
*/
|
||||
function wevia_vault_context($message, $maxNotes = 3) {
|
||||
$VAULT = '/opt/obsidian-vault';
|
||||
$ctx = '';
|
||||
|
||||
// 1. Always load critical doctrines (tiny, always relevant)
|
||||
$critical = ['paradigme-ultime', 'anti-fragmentation', 'souverainete'];
|
||||
foreach ($critical as $c) {
|
||||
$f = "$VAULT/doctrines/$c.md";
|
||||
if (file_exists($f)) {
|
||||
$content = file_get_contents($f);
|
||||
// Strip frontmatter
|
||||
if (preg_match('/---.*?---\s*(.*)/s', $content, $m)) $content = $m[1];
|
||||
$ctx .= trim(substr($content, 0, 200)) . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// 2. Keyword-based vault search (fast, no Qdrant needed)
|
||||
$keywords = array_filter(explode(' ', strtolower($message)), fn($w) => strlen($w) >= 4);
|
||||
if ($keywords) {
|
||||
$found = 0;
|
||||
$iter = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($VAULT));
|
||||
foreach ($iter as $file) {
|
||||
if ($file->getExtension() !== 'md' || $found >= $maxNotes) continue;
|
||||
$content = file_get_contents($file->getPathname());
|
||||
$lower = strtolower($content);
|
||||
foreach ($keywords as $kw) {
|
||||
if (stripos($lower, $kw) !== false) {
|
||||
$rel = str_replace("$VAULT/", '', $file->getPathname());
|
||||
if (preg_match('/---.*?---\s*(.*)/s', $content, $m)) $content = $m[1];
|
||||
$ctx .= "[VAULT:$rel] " . trim(substr($content, 0, 300)) . "\n";
|
||||
$found++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $ctx ? "\n[VAULT CONTEXT]\n$ctx" : '';
|
||||
}
|
||||
Reference in New Issue
Block a user