strlen($w) >= 4); $found = 0; foreach ($index as $file => $content) { if ($found >= $maxNotes) break; foreach ($words as $kw) { if (strpos($content, $kw) !== false) { $ctx .= "[VAULT:$file] " . substr($content, 0, 200) . "\n"; $found++; break; } } } return $ctx ? "\n[VAULT CONTEXT]\n$ctx" : ''; }