From 5d80e5fd572c1468c65c483567f16e84b17daa41 Mon Sep 17 00:00:00 2001 From: Egutierrez Date: Mon, 30 Mar 2026 14:24:54 +0200 Subject: [PATCH] =?UTF-8?q?chore:=20schema=20r=C3=A1pido=20en=20CLAUDE.md,?= =?UTF-8?q?=20sync=20Metabase=20en=20CLI,=20fix=20main.py?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Agrega documentación de schema rápido en CLAUDE.md, regla sources en INDEX. CLI fn index sincroniza registry.db a directorio Metabase si existe. fn show muestra campos source_*. Fix import en metabase_registry/main.py. Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/CLAUDE.md | 13 +++++++++++++ .claude/rules/INDEX.md | 1 + apps/metabase_registry/main.py | 4 ++-- cmd/fn/main.go | 22 ++++++++++++++++++++++ 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index fb865fb2..263d0561 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -49,6 +49,19 @@ 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. +### 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` +- Enums: `kind`(function|pipeline|component) `purity`(pure|impure) `lang`(go|py|bash|ps) +- Dominios: core, infra, finance, datascience, cybersecurity, shell, tui, pipelines + +**types** — columnas: `id, name, lang, domain, version, algebraic, definition, description, tags, uses_types, file_path, created_at, updated_at, examples, notes, documentation, code, content_hash, source_repo, source_license, source_file` +- Enums: `algebraic`(product|sum) + +**FTS5 (columnas buscables):** +- `functions_fts`: id, name, description, tags, signature, domain, example, notes, documentation, code +- `types_fts`: id, name, description, tags, domain, examples, notes, documentation, code + --- ## Estructura diff --git a/.claude/rules/INDEX.md b/.claude/rules/INDEX.md index 83dee87e..cfa5009c 100644 --- a/.claude/rules/INDEX.md +++ b/.claude/rules/INDEX.md @@ -14,3 +14,4 @@ Reglas operativas del proyecto. Cada archivo es una regla independiente. | 08 | [tag_launcher.md](tag_launcher.md) | Tag launcher para Pipeline Launcher TUI | | 09 | [go_packages.md](go_packages.md) | Nombre de paquete Go = nombre del directorio | | 10 | [apps_vs_functions.md](apps_vs_functions.md) | Codigo reutilizable en functions/, no reutilizable en apps/ | +| 11 | [sources.md](sources.md) | Extraccion de funciones desde repos externos | diff --git a/apps/metabase_registry/main.py b/apps/metabase_registry/main.py index 2e5bd827..4caa76eb 100644 --- a/apps/metabase_registry/main.py +++ b/apps/metabase_registry/main.py @@ -11,7 +11,7 @@ Via variables de entorno: METABASE_URL=http://localhost:3000 \ METABASE_ADMIN_EMAIL=admin@example.com \ METABASE_ADMIN_PASSWORD=secret \ - REGISTRY_DB_PATH=/registry.db \ + REGISTRY_DB_PATH=/data/registry/registry.db \ python main.py Via argumentos CLI: @@ -357,7 +357,7 @@ def build_parser() -> argparse.ArgumentParser: # Registry DB path (ruta dentro del contenedor Docker) p.add_argument( "--registry-db-path", - default=os.environ.get("REGISTRY_DB_PATH", "/registry.db"), + default=os.environ.get("REGISTRY_DB_PATH", "/data/registry/registry.db"), dest="registry_db_path", help=( "Ruta al registry.db DENTRO del contenedor Docker " diff --git a/cmd/fn/main.go b/cmd/fn/main.go index bb8988d3..ab70088f 100644 --- a/cmd/fn/main.go +++ b/cmd/fn/main.go @@ -105,6 +105,18 @@ func cmdIndex() { // Flush WAL to main db file so external readers (e.g. Metabase) see changes. db.WalCheckpoint() + // Sync registry.db to Metabase mount directory if it exists. + metabaseCopy := filepath.Join(r, ".metabase-registry", "registry.db") + if _, err := os.Stat(filepath.Dir(metabaseCopy)); err == nil { + src := filepath.Join(r, dbName) + data, err := os.ReadFile(src) + if err == nil { + if err := os.WriteFile(metabaseCopy, data, 0666); err != nil { + fmt.Fprintf(os.Stderr, "warning: could not sync to metabase: %v\n", err) + } + } + } + fmt.Printf("Indexed %d functions, %d types, %d apps\n", result.Functions, result.Types, result.Apps) for _, e := range result.ValidationErrors { fmt.Fprintf(os.Stderr, " INVALID: %s\n", e) @@ -341,6 +353,11 @@ func printFunction(f *registry.Function) { if f.Code != "" { fmt.Printf("\nCode:\n%s\n", f.Code) } + if f.SourceRepo != "" { + fmt.Printf("Source repo: %s\n", f.SourceRepo) + fmt.Printf("Source license: %s\n", f.SourceLicense) + fmt.Printf("Source file: %s\n", f.SourceFile) + } if f.Kind == registry.KindComponent { fmt.Printf("Framework: %s\n", f.Framework) if f.HasState != nil { @@ -365,6 +382,11 @@ func printType(t *registry.Type) { if len(t.UsesTypes) > 0 { fmt.Printf("Uses types: %s\n", strings.Join(t.UsesTypes, ", ")) } + if t.SourceRepo != "" { + fmt.Printf("Source repo: %s\n", t.SourceRepo) + fmt.Printf("Source license: %s\n", t.SourceLicense) + fmt.Printf("Source file: %s\n", t.SourceFile) + } if t.Definition != "" { fmt.Printf("\nDefinition:\n%s\n", t.Definition) }