47fac22230
- .claude/CLAUDE.md - .claude/commands/subagentes.md - .claude/rules/INDEX.md - .mcp.json - bash/functions/cybersecurity/analyze_dns.md - bash/functions/cybersecurity/audit_http_headers.md - bash/functions/cybersecurity/audit_ssh_config.md - bash/functions/cybersecurity/check_firewall.md - bash/functions/cybersecurity/detect_suspicious_users.md - bash/functions/cybersecurity/encrypt_file.md - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2.3 KiB
2.3 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| vault_search | function | go | infra | 1.0.0 | impure | func VaultSearch(vaultPath, query string, limit int) ([]VaultSearchHit, error) | Busca en vault_index.db de un vault usando FTS5 sobre files_fts. Si el query rompe el parser FTS5, hace fallback a LIKE sobre rel_path. Retorna hits con snippet de contexto. |
|
|
|
false | error_go_core |
|
|
slice de VaultSearchHit ordenado por rank FTS5 (o mtime DESC en fallback LIKE); slice vacio si no hay resultados | true |
|
functions/infra/vault_search_test.go | functions/infra/vault_search.go |
Ejemplo
hits, err := infra.VaultSearch("/home/lucas/vaults/turismo_spain", "hoteles", 20)
if err != nil {
log.Fatal(err)
}
for _, h := range hits {
fmt.Printf("[%s] %s %s\n", h.VaultName, h.RelPath, h.Snippet)
}
Notas
VaultSearchHit es un struct local definido en este archivo (no en vault_file.go)
porque combina campos de files + metadatos de contexto de busqueda (Snippet, VaultPath, VaultName).
FTS5 safety: el helper safeFTSQuery envuelve la query en comillas dobles
cuando no contiene operadores booleanos ni prefijos de columna. Esto evita errores
del parser en tokens como foo:bar: o hello-world.
Fallback LIKE: si el MATCH falla con un error de sintaxis FTS5, se ejecuta
WHERE rel_path LIKE '%' || query || '%'. Los hits del fallback tienen Snippet="".
VaultName: se deriva del filepath.Base(filepath.EvalSymlinks(vaultPath)).
Si EvalSymlinks falla (e.g. symlink roto), usa filepath.Base(vaultPath).