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:
@@ -0,0 +1,36 @@
|
||||
---
|
||||
name: assert_command_exists
|
||||
kind: function
|
||||
lang: bash
|
||||
domain: shell
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "assert_command_exists(command_name: string) -> void"
|
||||
description: "Verifica que un comando está disponible en el PATH. Sale con exit code 1 si no se encuentra, con mensaje a stderr."
|
||||
tags: [assert, command, exists, validation, shell, bash, path]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: []
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "bash/functions/shell/assert_command_exists.sh"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```bash
|
||||
source functions/shell/assert_command_exists.sh
|
||||
|
||||
assert_command_exists docker
|
||||
assert_command_exists jq
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Usa `command -v` (POSIX) con redirección `&>/dev/null` para suprimir output. No produce nada a stdout en caso de éxito.
|
||||
|
||||
Output limpio: void en éxito, mensaje a stderr en fallo.
|
||||
@@ -0,0 +1,18 @@
|
||||
# assert_command_exists
|
||||
# ---------------------
|
||||
# Verifica que un comando está disponible en el PATH.
|
||||
# No produce output a stdout.
|
||||
# Sale con exit code 1 si el comando no se encuentra.
|
||||
#
|
||||
# USO (sourced):
|
||||
# source assert_command_exists.sh
|
||||
# assert_command_exists docker
|
||||
|
||||
assert_command_exists() {
|
||||
local command_name="$1"
|
||||
|
||||
if ! command -v "$command_name" &>/dev/null; then
|
||||
echo "assert_command_exists: comando no encontrado en PATH: $command_name" >&2
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: assert_file_exists
|
||||
kind: function
|
||||
lang: bash
|
||||
domain: shell
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "assert_file_exists(file_path: string) -> string"
|
||||
description: "Verifica que un archivo existe en el filesystem. Imprime su tamaño en bytes a stdout. Sale con exit code 1 si el archivo no existe."
|
||||
tags: [assert, file, exists, validation, shell, bash]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: []
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "bash/functions/shell/assert_file_exists.sh"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```bash
|
||||
source functions/shell/assert_file_exists.sh
|
||||
|
||||
size=$(assert_file_exists /home/lucas/fn_registry/registry.db)
|
||||
echo "Tamaño: $size bytes"
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
La función se sourcea, no se ejecuta directamente. Usa `stat -c%s` para obtener el tamaño en bytes (compatible con GNU coreutils / Linux).
|
||||
|
||||
Output limpio: solo el número de bytes a stdout. Los errores van a stderr.
|
||||
|
||||
No usa `set -e` internamente — el caller controla el flujo con el exit code de retorno.
|
||||
@@ -0,0 +1,20 @@
|
||||
# assert_file_exists
|
||||
# ------------------
|
||||
# Verifica que un archivo existe en el filesystem.
|
||||
# Imprime su tamaño en bytes a stdout.
|
||||
# Sale con exit code 1 si el archivo no existe.
|
||||
#
|
||||
# USO (sourced):
|
||||
# source assert_file_exists.sh
|
||||
# size=$(assert_file_exists /ruta/al/archivo)
|
||||
|
||||
assert_file_exists() {
|
||||
local file_path="$1"
|
||||
|
||||
if [ ! -f "$file_path" ]; then
|
||||
echo "assert_file_exists: archivo no encontrado: $file_path" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
stat -c%s "$file_path"
|
||||
}
|
||||
Reference in New Issue
Block a user