docs(rules): registry-first + FTS5 quoting gotcha

- Nueva regla registry_first.md: antes de escribir codigo en un artefacto,
  buscar en registry.db (FTS5); si falta una primitiva reutilizable,
  delegar a fn-constructor en vez de escribir inline.
- INDEX.md: entrada 22 para la nueva regla.
- CLAUDE.md: nota sobre escapado de tokens FTS5 con caracteres
  especiales (column:"valor-con-guion") para evitar errores
  "no such column" / "syntax error near .".

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-05-06 15:54:09 +02:00
parent 76dcb05bd3
commit c5f1b55a8e
3 changed files with 62 additions and 0 deletions
+11
View File
@@ -58,6 +58,17 @@ sqlite3 registry.db ".schema"
**Regla:** Si necesitas saber si algo existe o hay algo similar, haz la consulta FTS5 sobre la BD. No asumas que no existe sin consultar primero.
**Escapado FTS5 (gotcha):** despues de `column:` el valor debe ser un solo token alfanumerico ASCII (underscores OK). Cualquier otro caracter (`-`, `.`, `:`, espacios) rompe el parser con `no such column: X` o `syntax error near "."`. Encierra el valor en comillas dobles dentro del MATCH:
```bash
# MAL: description:single-page → "no such column: page"
# MAL: description:embed.FS → 'syntax error near "."'
# BIEN:
sqlite3 registry.db "SELECT id FROM functions WHERE id IN (SELECT id FROM functions_fts WHERE functions_fts MATCH 'description:\"single-page\" OR description:\"embed.FS\"');"
```
Tokens multi-palabra tambien necesitan comillas: `description:"react router"`.
### Schema rapido
**functions** — columnas: `id, name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, example, tested, tests, test_file_path, file_path, created_at, updated_at, props, emits, has_state, framework, variant, notes, documentation, code, content_hash, source_repo, source_license, source_file, params_schema`