# Wiki Retrieve > Construye y consulta un índice BM25 contextual local del vault, con reranking opcional multilingüe Nomic. Los cachés quedan en .vault-meta, el egress remoto requiere consentimiento y el reranking cae a BM25 si falla. Fuente: https://skillsagentes.com/skills/agricidaniel/claude-obsidian/wiki-retrieve Markdown: https://skillsagentes.com/skills/agricidaniel/claude-obsidian/wiki-retrieve.md Repositorio: https://github.com/AgriciDaniel/claude-obsidian Autor: AgriciDaniel Licencia: MIT Actualizado: el mes pasado Coste de contexto: 104 tok instalada, 1.4k tok al activarse, 1.4k tok con todos los archivos del bundle Bundle: 1 archivo, 5 KB Permisos que pide: ninguno declarado ## Instalación Un skill son archivos markdown: los mismos archivos valen para cualquier agente y lo único que cambia es el directorio de destino, es decir la bandera `--agent`. Añade `-g` para instalarlo en todos los proyectos de la máquina. ```bash # Claude Code npx -y skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve --agent claude-code # Cursor npx -y skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve --agent cursor # Codex npx -y skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve --agent codex # Gemini CLI npx -y skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve --agent gemini # Windsurf npx -y skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve --agent windsurf # Cline npx -y skills add AgriciDaniel/claude-obsidian --skill wiki-retrieve --agent cline ``` ## Qué hace - Construye un índice BM25 local a partir de `wiki/` y lo guarda en `.vault-meta/`, sin tocar las notas originales - Permite reranking opcional multilingüe con el modelo Nomic vía Ollama - Exige consentimiento explícito y `--allow-egress` para enviar texto a la API de Anthropic o a un subproceso `claude` - Devuelve rutas y fragmentos validados, rechazando registros sin hash o con rutas fuera del vault - Cae automáticamente al orden BM25 si el reranking falla o el servicio de Ollama no está disponible ## Cuándo usarla - Se necesita construir o consultar el índice de recuperación (BM25/rerank) del vault - Se pide diagnóstico de recuperación, chunk search o búsqueda semántica sobre el vault - Otro skill, como wiki-query, necesita este backend de retrieval ## Qué la activa - "Construye el índice de búsqueda de mi vault" - "Busca pasajes relevantes sobre X en mi wiki" - "Ejecuta un rerank de esta consulta en mi vault" - "Diagnostica por qué la búsqueda no encuentra resultados" ## Antes de instalar - Necesita los scripts del producto instalados (`contextual-prefix.py`, `bm25-index.py`, `retrieve.py`, `rerank.py`) y, para reranking, Ollama local con el modelo indicado. - Necesita en el PATH: python3 - Variables de entorno: BM25, PREFIX, PRODUCT_ROOT, QUERY, RERANK, RETRIEVE, VAULT - reads environment config ## Archivos - SKILL.md — 5 KB ## SKILL.md Reproducido tal cual desde AgriciDaniel/claude-obsidian bajo MIT. Esta sección es el documento original y está en inglés. # Retrieve relevant passages This extension derives search data from `wiki/` into `.vault-meta/`. It never changes canonical notes. Always pass the selected vault explicitly. Resolve the installed product root from this skill's own location, not from the vault or current working directory: ```bash PRODUCT_ROOT=/absolute/path/to/installed/claude-obsidian PREFIX="$PRODUCT_ROOT/scripts/contextual-prefix.py" BM25="$PRODUCT_ROOT/scripts/bm25-index.py" RETRIEVE="$PRODUCT_ROOT/scripts/retrieve.py" RERANK="$PRODUCT_ROOT/scripts/rerank.py" test -f "$PREFIX" && test -f "$BM25" && test -f "$RETRIEVE" && test -f "$RERANK" ``` ## Pipeline 1. `contextual-prefix.py` splits pages on paragraph boundaries and stores the raw chunk plus a short page-level prefix. 2. `bm25-index.py` builds a local, standard-library BM25 index over the contextualized text. 3. `retrieve.py` selects BM25 candidates, optionally reranks them, rejects invalid records, deduplicates by page, and returns paths and snippets. 4. The caller reads the returned pages and performs synthesis; retrieval output is not itself evidence. ## Provision locally Preview first, then build synthetic prefixes without network egress: ```bash python3 "$PREFIX" --vault "$VAULT" --all --no-llm --peek python3 "$PREFIX" --vault "$VAULT" --all --no-llm python3 "$BM25" --vault "$VAULT" build python3 "$RETRIEVE" --vault "$VAULT" "wiki" --top 1 --no-rerank --explain ``` Chunk and index files are disposable runtime state. Incremental prefixing skips records whose chunk and page hashes still match. A complete scan removes surplus records for deleted pages, and the prefixer invalidates the BM25 index before changing its chunk set so a mixed stale index is not served. Prefix and BM25 build operations share the vault-wide mutation lock with every other writer; a busy vault fails closed instead of publishing a partial index. ## Contextual-prefix privacy Synthetic prefixes use only local frontmatter and page text. The Anthropic API and `claude` subprocess tiers can send page bodies off-machine and therefore require the user's explicit consent plus `--allow-egress`. Never infer consent from an API key or installed binary. Preview the scope first and state which provider will receive what data. Remote Ollama endpoints also require explicit approval and `--allow-remote-ollama`; the default reranker accepts localhost only. ## Query For a strictly read-only lookup, use the prebuilt BM25 index: ```bash python3 "$RETRIEVE" --vault "$VAULT" "$QUERY" --top 5 --no-rerank --explain ``` For an explicitly requested rerank, omit `--no-rerank`. The default is Ollama's multilingual `nomic-embed-text-v2-moe` model (approximately 958 MB); the product never pulls it automatically. To use an already-installed, smaller, English-oriented v1.5 model, pass `--model nomic-embed-text` explicitly. Nomic models use `search_query:` for the query and `search_document:` for candidate text. Nomic v2 has a 512-token input context and Ollama truncates longer embedding inputs by default; BM25 still scores the complete chunk. Embeddings are cached by exact model, input scheme, and hash of the exact prefixed input. A missing local Ollama service, missing selected model, unusable vector, or any candidate embedding failure falls back for the complete result set to the original BM25 order; it never mixes cosine and BM25 score scales. Query input is bounded at 8,000 normalized characters and result counts must be between 1 and 1,000. Oversized queries and invalid limits fail with an actionable usage error instead of looking like an empty successful search. An untagged model request matches only the installed untagged name or its `:latest` alias; select any other tag explicitly. Use direct diagnostics when needed: ```bash python3 "$BM25" --vault "$VAULT" stats python3 "$BM25" --vault "$VAULT" query "$QUERY" --top 10 python3 "$RERANK" --vault "$VAULT" "$QUERY" --peek python3 "$RERANK" --vault "$VAULT" "$QUERY" --model nomic-embed-text --peek ``` ## Integrity rules - Accept only relative chunk and page paths whose resolved targets remain under `$VAULT/.vault-meta/chunks/` and `$VAULT/wiki/` respectively. - Reject hashless legacy chunk records and require chunk-body, page, and index hashes to match before a cached record can be built or served. - Reject absolute paths, symlink escapes, missing pages, mismatched chunk IDs, changed page hashes, and stale index/chunk hash pairs. - Rerank the full candidate set, then deduplicate by page, then apply `--top`. - An empty index is an honest no-result state. A missing or corrupt index makes `retrieve.py` exit 10 with a stable rebuild command; callers fall back to the standard vault query/text-search path and do not fabricate matches. - Do not cite benchmark percentages unless a reproducible vault-specific benchmark produced them. ## Checkpoint Observe cache readiness and privacy boundaries, think about whether lexical or semantic ranking is needed, verify returned paths and source freshness, and grow by measuring retrieval misses against a maintained local query set. ## Dónde encaja - Categoría: [Herramientas para desarrolladores](https://skillsagentes.com/categorias/herramientas-desarrollo.md) — Skills que cambian cómo tu agente escribe, revisa y despliega código. - Creador: [AgriciDaniel](https://skillsagentes.com/creators/agricidaniel.md) — 46 skills en el directorio - [Todas las skills](https://skillsagentes.com/skills.md) - [Ranking de instalaciones](https://skillsagentes.com/ranking.md) ## Otras skills del mismo repositorio - [Wiki](https://skillsagentes.com/skills/agricidaniel/claude-obsidian/wiki.md): Inicializa, adopta y enruta el trabajo hacia un vault de Obsidian separado a través del core portátil `claude-obsidian`. Para configurar el vault o elegir el sub-skill correcto. - [Defuddle](https://skillsagentes.com/skills/agricidaniel/claude-obsidian/defuddle.md): Planifica y, con consentimiento explícito de red, usa un limpiador externo Defuddle opcional para extraer páginas HTTPS tipo artículo como Markdown. - [Obsidian Bases](https://skillsagentes.com/skills/agricidaniel/claude-obsidian/obsidian-bases.md): Explica, redacta y valida archivos Obsidian Bases `.base` con filtros, fórmulas, propiedades, resúmenes y vistas de tabla, tarjetas o lista. - [Obsidian Markdown](https://skillsagentes.com/skills/agricidaniel/claude-obsidian/obsidian-markdown.md): Explica, redacta o valida la sintaxis de Obsidian Flavored Markdown: propiedades, wikilinks, embeds, callouts, tags, comentarios, resaltados, referencias de bloque, matemáticas y Mermaid. - [Canvas](https://skillsagentes.com/skills/agricidaniel/claude-obsidian/canvas.md): Crea, inspecciona y actualiza tableros Obsidian JSON Canvas con nodos de texto, archivo, enlace, grupo y arista. Para estado del canvas, mapas visuales, zonas y diseños espaciales. --- Skills Agentes · [Índice de páginas en markdown](https://skillsagentes.com/sitemap.md) · [Inicio](https://skillsagentes.com/index.md)