docs: CLAUDE.md actualizado con fn run, tipos Go en functions/, bash functions
Documentación de fn run para todos los lenguajes, nueva ubicación de tipos Go, sección de uso por agentes. Añadidas funciones Bash del registry (shell, infra, core, pipelines). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
+48
-4
@@ -55,9 +55,12 @@ sqlite3 registry.db ".schema"
|
||||
|
||||
```
|
||||
fn-registry/
|
||||
functions/{domain}/ # .go + .md por funcion (core, finance, datascience, cybersecurity)
|
||||
functions/{domain}/ # .go + .md por funcion Y tipo Go (core, finance, datascience, cybersecurity)
|
||||
functions/pipelines/ # Composiciones, siempre impuras
|
||||
types/{domain}/ # .go + .md por tipo
|
||||
types/{domain}/ # Solo .md de tipos (los .go viven en functions/{domain}/)
|
||||
python/functions/ # .py + .md por funcion Python
|
||||
python/types/ # .py + .md por tipo Python
|
||||
bash/functions/ # .sh + .md por funcion Bash (core, infra, io, shell)
|
||||
frontend/ # pnpm + vite + react + tailwind + shadcn
|
||||
frontend/functions/ # .tsx/.ts + .md (core para TS puro, ui para componentes React)
|
||||
frontend/types/ # .ts + .md por tipo
|
||||
@@ -91,6 +94,23 @@ fn list [-d domain] [-k kind]
|
||||
fn show <id>
|
||||
fn add -k function # Template
|
||||
|
||||
# Ejecutar funciones y pipelines (fn run)
|
||||
fn run <id_or_name> [args...] # Ejecuta por ID o nombre
|
||||
fn run init_metabase --project test # Go pipeline (go run .)
|
||||
fn run setup_metabase_volume # Bash pipeline (bash <file>)
|
||||
fn run metabase_setup_py_infra # Python (python/.venv/bin/python3 <file>)
|
||||
fn run my_component_ts_core # TypeScript (frontend/node_modules/.bin/tsx <file>)
|
||||
fn run filter_slice_go_core # Go function con tests (go test -v)
|
||||
fn run docker_pull_image_go_infra # Go function sin tests (go vet)
|
||||
# Despacho por lenguaje:
|
||||
# go (con main.go en dir) → go run .
|
||||
# go (con tests) → go test -v -count=1 -tags fts5 ./pkg/
|
||||
# go (sin tests) → go vet -tags fts5 ./pkg/
|
||||
# py → python/.venv/bin/python3 <file>
|
||||
# bash → bash <file>
|
||||
# ts → frontend/node_modules/.bin/tsx <file>
|
||||
# Si el nombre es ambiguo, muestra los IDs para desambiguar.
|
||||
|
||||
# Proposals
|
||||
fn proposal add --kind new_function --title "..." --created-by agent [--target-id <id>]
|
||||
fn proposal list [-k kind] [-s status]
|
||||
@@ -110,12 +130,30 @@ fn ops assertion result add|list
|
||||
|
||||
`FN_REGISTRY_ROOT` env var permite que `fn ops` acceda a registry.db desde cualquier directorio.
|
||||
|
||||
### Uso de fn run por agentes
|
||||
|
||||
`fn run` permite ejecutar directamente funciones y pipelines del registry desde la terminal. Usar para:
|
||||
- Lanzar pipelines con sus argumentos: `./fn run init_metabase --project fn_registry`
|
||||
- Correr tests de funciones Go: `./fn run filter_slice_go_core`
|
||||
- Ejecutar scripts Python/Bash del registry sin montar paths manualmente
|
||||
- Verificar que funciones Go compilan correctamente (go vet)
|
||||
|
||||
Entornos usados automaticamente:
|
||||
- Python: `python/.venv/bin/python3` (venv del proyecto)
|
||||
- TypeScript: `frontend/node_modules/.bin/tsx` (node del proyecto)
|
||||
- Go: `go run .` / `go test` / `go vet` con `CGO_ENABLED=1 -tags fts5`
|
||||
- Bash: `bash` del sistema
|
||||
|
||||
---
|
||||
|
||||
## Añadir funciones
|
||||
|
||||
1. Consulta la BD para verificar que no existe algo similar
|
||||
2. Crea dos archivos: `functions/{domain}/{name}.go` + `functions/{domain}/{name}.md`
|
||||
2. Crea dos archivos segun el lenguaje:
|
||||
- Go: `functions/{domain}/{name}.go` + `.md`
|
||||
- Python: `python/functions/{domain}/{name}.py` + `.md`
|
||||
- Bash: `bash/functions/{domain}/{name}.sh` + `.md`
|
||||
- TypeScript: `frontend/functions/{domain}/{name}.ts` + `.md`
|
||||
3. Ejecuta `./fn index` y verifica con `./fn show {id}`
|
||||
|
||||
Frontmatter del .md — ver template completo en `docs/templates/` o con `fn add -k function`.
|
||||
@@ -132,7 +170,13 @@ Reglas de integridad (el indexer las valida):
|
||||
|
||||
## Añadir tipos
|
||||
|
||||
Dos archivos: `types/{domain}/{name}.go` + `types/{domain}/{name}.md`. Ver template en `docs/templates/`.
|
||||
Dos archivos en directorios separados:
|
||||
- **Codigo Go:** `functions/{domain}/{name}.go` (junto a las funciones, mismo paquete Go)
|
||||
- **Metadata .md:** `types/{domain}/{name}.md` con `file_path` apuntando a `functions/{domain}/{name}.go`
|
||||
|
||||
Los `.go` de tipos viven en `functions/{domain}/` para que Go los compile en el mismo paquete que las funciones que los usan. Los `.md` se mantienen en `types/{domain}/` para que el indexer los identifique como tipos.
|
||||
|
||||
Ver template en `docs/templates/`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
Reference in New Issue
Block a user