Compare commits
25 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe784d090f | |||
| 88119ee1b2 | |||
| 282c2e3ba8 | |||
| 950b994797 | |||
| 23f5f1c25f | |||
| be8a61e724 | |||
| 80f44cc89e | |||
| 188122812a | |||
| e2ecdc7533 | |||
| 7d82359a45 | |||
| 4e8b5af6c4 | |||
| cfdf515228 | |||
| d110aa40f9 | |||
| aec5d82011 | |||
| 88b5b27dc0 | |||
| 574b3f6823 | |||
| 552c40bc42 | |||
| 1702f12664 | |||
| a802f59f55 | |||
| ef60449e64 | |||
| c7904a7dcb | |||
| b4c28da2ba | |||
| 2297edf2ab | |||
| 9d0a1d99e8 | |||
| a396ee781a |
+123
-35
@@ -2,6 +2,19 @@
|
||||
|
||||
Registry personal de codigo reutilizable con busqueda FTS. Diseñado para composicion funcional y agentes.
|
||||
|
||||
## Objetivos del registry (Norte) — Issues 0086 + 0087
|
||||
|
||||
**4 metricas optimizadas por el bucle reactivo** (visibles en Monitor tab del `registry_dashboard`):
|
||||
|
||||
1. **MAXIMIZAR `Reg %`** — porcentaje de calls del agente que golpean una funcion del registry (`function_id != ''`). Cada bash inline o heredoc que reescribe logica baja el ratio. Target: subir cada semana.
|
||||
2. **MEJORAR uso del registry por Claude** — el agente debe encontrar y usar funciones existentes antes de escribir codigo. Indicadores: `MCP` (mcp/heredoc/fn run) sube; violations baja. Si Claude no encuentra una funcion por busqueda mediocre, mejorar `description`/`tags`/`params_schema` de esa funcion.
|
||||
3. **ACELERAR tareas comunes via funciones nuevas** — patrones inline repetidos >2 veces -> `fn-constructor` crea la funcion, Claude la usa el siguiente turno. Velocidad medida en pasos (turnos) por tarea. Pattern detection: tab Monitor + `mcp__registry__fn_proposal action="list"`.
|
||||
4. **PROMOVER COMPOSICIONES A PIPELINES** (issue 0087) — el registry no crece inflando funciones, crece **promoviendo secuencias A→B(→C) que se repiten con exito** a pipelines one-shot. Hoy `bank_login + bank_make_transfer` (2 calls). Manana `bank_transfer_oneshot` (1 call). Misma capacidad, mitad de pasos. Detectado por telemetria de secuencias en `call_monitor`. Una funcion que hace bien UNA cosa NO necesita crecer — lo que crece es el catalogo de composiciones probadas.
|
||||
|
||||
**Auto-discovery zero-second-lookup:** cada `.md` debe ser autosuficiente — `## Ejemplo` lanzable + `## Cuando usarla` + `## Gotchas` (impuras). Descubrir = lanzar, sin segunda lectura. Ver `.claude/rules/function_growth_and_self_docs.md`.
|
||||
|
||||
Cualquier decision tecnica que choque con estos objetivos esta mal priorizada. Ejemplo: un bash heredoc rapido hoy que reinventa logica = penaliza objetivos 1 y 3 manana.
|
||||
|
||||
**Dos bases de datos SQLite:**
|
||||
- **registry.db** (raiz) — funciones, tipos, proposals, apps, projects, analysis, vaults, pc_locations. Regenerable con `fn index` (excepto proposals y pc_locations).
|
||||
- **operations.db** (por app en `apps/*/`) — entities, relations, executions, assertions. Datos vivos.
|
||||
@@ -18,6 +31,33 @@ Registry personal de codigo reutilizable con busqueda FTS. Diseñado para compos
|
||||
|
||||
---
|
||||
|
||||
## Delegacion + Capability Groups (REGLA DURA — issue 0086)
|
||||
|
||||
Claude **multiplica capacidades** delegando creacion de funciones a `fn-constructor` y reusandolas inmediatamente. NO escribir logica reutilizable inline.
|
||||
|
||||
### Flujo obligatorio (mismo turno)
|
||||
|
||||
1. **Detectar gap**. Si vas a escribir >=5 lineas de logica reutilizable inline -> STOP.
|
||||
2. **Spawn `fn-constructor`** via `Agent(subagent_type="fn-constructor", ...)`. Sin preguntar al usuario.
|
||||
3. **Paralelo**: si hay >1 funcion independiente -> **una sola llamada al Agent tool con N tool_use blocks paralelos** en mismo mensaje. NO serializar.
|
||||
4. **Tag de grupo obligatorio** (`notebook`, `metabase`, `deploy`, etc.). Ver `docs/capabilities/INDEX.md`.
|
||||
5. **`fn index`** + **importar + invocar en mismo turno**. No dejar funcion huerfana recien creada.
|
||||
6. **Auto-verificar**: `fn doctor uses-functions` + `fn doctor unused` si tocas >=3 funciones nuevas.
|
||||
|
||||
### Capability groups
|
||||
|
||||
Cluster de >=3 funciones que comparten dominio operativo. Cada grupo tiene tag plano + pagina madre `docs/capabilities/<grupo>.md` con: lista de funciones, ejemplo canonico end-to-end, fronteras.
|
||||
|
||||
**Antes de buscar funciones sueltas en una tarea de dominio conocido:** lee `docs/capabilities/<grupo>.md` para cargar el cluster entero en un solo read. Filtro MCP: `mcp__registry__fn_search query="" tag="<grupo>"`.
|
||||
|
||||
Reglas completas: `.claude/rules/delegation.md` + `.claude/rules/capability_groups.md`.
|
||||
|
||||
### Telemetria CAPABILITY-GROWTH
|
||||
|
||||
Cada turno el hook `UserPromptSubmit` inyecta `CAPABILITY-GROWTH: created_this_session=X used=Y orphan=Z`. Si `orphan>0` -> integra la funcion antes de cerrar turno o documenta por que.
|
||||
|
||||
---
|
||||
|
||||
## Explorar el registry (OBLIGATORIO)
|
||||
|
||||
**SIEMPRE** consulta registry.db antes de escribir codigo, crear funciones, o responder sobre el registry. No uses grep/glob sobre archivos .go/.md — la BD es la fuente de verdad.
|
||||
@@ -39,56 +79,67 @@ Registry personal de codigo reutilizable con busqueda FTS. Diseñado para compos
|
||||
|
||||
Razones: menos tokens, output estructurado, FTS5 escapado bien (sin gotchas de `column:"valor"`), permisos pre-aprobados, no requiere `cd` ni paths absolutos a `registry.db`.
|
||||
|
||||
**Cuando si caer a `sqlite3` (Bash):** SOLO si el MCP no cubre el caso — JOINs custom entre tablas, agregaciones (`COUNT`/`GROUP BY`), introspeccion de schema (`.schema`, `PRAGMA table_info`), o columnas que el MCP no expone. En ese caso, los patrones FTS5 estan documentados abajo.
|
||||
**La BD contiene el codigo y la documentacion completa** de cada funcion y tipo en los campos `code`, `documentation` y `notes`. Tambien indexados en FTS5 — buscas dentro del codigo directamente. Para leer codigo: `mcp__registry__fn_code <id>`.
|
||||
|
||||
**La BD contiene el codigo y la documentacion completa** de cada funcion y tipo en los campos `code`, `documentation` y `notes`. Estos campos tambien estan indexados en FTS5, asi que puedes buscar dentro del codigo y la documentacion directamente. Para leer el codigo de una funcion: `mcp__registry__fn_code` (preferido) o `SELECT code FROM functions WHERE id = '...'` (fallback).
|
||||
### Ejemplos MCP (usa estos, NO sqlite3)
|
||||
|
||||
**Busquedas FTS5 (cuando uses sqlite3 como fallback):** Usa SIEMPRE la tabla FTS5 para buscar tanto por `name` como por `description`. Esto encuentra coincidencias parciales y similares que una busqueda exacta perderia. Usa operadores FTS5: `OR` para ampliar, `*` para prefijos, `NEAR` para proximidad.
|
||||
Cada llamada MCP se registra en `call_monitor` (issue 0085). Cada `sqlite3 registry.db "SELECT ..."` queda fuera del bucle reactivo y dispara el hook PreToolUse.
|
||||
|
||||
```bash
|
||||
# Busqueda FTS5 por nombre Y descripcion (USAR SIEMPRE ESTE PATRON)
|
||||
sqlite3 registry.db "SELECT id, kind, purity, description FROM functions WHERE id IN (SELECT id FROM functions_fts WHERE functions_fts MATCH 'name:slice OR description:slice') ORDER BY name;"
|
||||
```
|
||||
# Busqueda basica por nombre/descripcion (FTS5 detras)
|
||||
mcp__registry__fn_search query="slice"
|
||||
|
||||
# FTS5 con prefijo (encuentra slice, slicing, sliced...)
|
||||
sqlite3 registry.db "SELECT id, kind, purity, description FROM functions WHERE id IN (SELECT id FROM functions_fts WHERE functions_fts MATCH 'name:slic* OR description:slic*') ORDER BY name;"
|
||||
# Filtros: kind, purity, domain, lang
|
||||
mcp__registry__fn_search query="filter" kind="function" purity="pure" domain="core"
|
||||
|
||||
# FTS5 en tipos
|
||||
sqlite3 registry.db "SELECT id, algebraic, description FROM types WHERE id IN (SELECT id FROM types_fts WHERE types_fts MATCH 'name:result OR description:result') ORDER BY name;"
|
||||
# Prefijo FTS5 — encuentra slice/slicing/sliced
|
||||
mcp__registry__fn_search query="slic*"
|
||||
|
||||
# FTS5 por semantica de params (composabilidad)
|
||||
sqlite3 registry.db "SELECT id, json_extract(params_schema, '$.output') FROM functions WHERE id IN (SELECT id FROM functions_fts WHERE functions_fts MATCH 'params_schema:retornos');"
|
||||
# Buscar tipos
|
||||
mcp__registry__fn_search query="result" entity="types"
|
||||
|
||||
# Por dominio
|
||||
sqlite3 registry.db "SELECT id, purity, signature FROM functions WHERE domain = 'finance' ORDER BY name;"
|
||||
# Apps
|
||||
mcp__registry__fn_search query="kanban" entity="apps"
|
||||
|
||||
# Puras de un dominio
|
||||
sqlite3 registry.db "SELECT id, signature FROM functions WHERE domain = 'core' AND purity = 'pure' ORDER BY name;"
|
||||
# Listar dominios
|
||||
mcp__registry__fn_list_domains
|
||||
|
||||
# Tipos por dominio
|
||||
sqlite3 registry.db "SELECT id, algebraic, description FROM types WHERE domain = 'cybersecurity';"
|
||||
# Ver una entrada concreta (functions, types, apps, analysis, proposals...)
|
||||
mcp__registry__fn_show id="filter_slice_go_core"
|
||||
|
||||
# Dependencias
|
||||
sqlite3 registry.db "SELECT id, uses_functions, uses_types FROM functions WHERE uses_functions != '[]';"
|
||||
# Codigo fuente de una funcion/tipo
|
||||
mcp__registry__fn_code id="filter_slice_go_core"
|
||||
|
||||
# Proposals pendientes
|
||||
sqlite3 registry.db "SELECT id, kind, status, title FROM proposals WHERE status = 'pending';"
|
||||
# Quien consume una funcion (consumidores indexados via uses_functions)
|
||||
mcp__registry__fn_uses id="filter_slice_go_core"
|
||||
|
||||
# Schema completo
|
||||
sqlite3 registry.db ".schema"
|
||||
# Proposals (pending, approved, ...)
|
||||
mcp__registry__fn_proposal action="list" status="pending"
|
||||
mcp__registry__fn_proposal action="show" id="<proposal_id>"
|
||||
|
||||
# Diagnostico read-only del registry (artefacts/services/sync/uses-functions/unused/cpp-apps)
|
||||
mcp__registry__fn_doctor subcommand="artefacts"
|
||||
mcp__registry__fn_doctor subcommand="sync"
|
||||
```
|
||||
|
||||
**Regla:** Si necesitas saber si algo existe o hay algo similar, usa `mcp__registry__fn_search` (preferido) o consulta FTS5 con sqlite3 (fallback). No asumas que no existe sin consultar primero.
|
||||
**Escapado FTS5 (gotcha cuando pasas query libre):** valores con `-`, `.`, `:`, espacios rompen el parser FTS5 si los expones como `column:valor`. El MCP escapa por defecto, pero si construyes una `query` con sintaxis FTS5 explicita, encierra el valor en comillas dobles:
|
||||
|
||||
**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\"');"
|
||||
```
|
||||
# MAL: query="description:single-page" -> "no such column: page"
|
||||
# BIEN
|
||||
mcp__registry__fn_search query='description:"single-page" OR description:"embed.FS"'
|
||||
mcp__registry__fn_search query='description:"react router"'
|
||||
```
|
||||
|
||||
Tokens multi-palabra tambien necesitan comillas: `description:"react router"`.
|
||||
### Excepciones autorizadas para sqlite3 directo
|
||||
|
||||
`sqlite3 registry.db` SOLO es legitimo si el MCP no expone la consulta:
|
||||
|
||||
- Introspeccion de schema: `.schema`, `.tables`, `PRAGMA table_info(...)`, `PRAGMA index_list(...)`.
|
||||
- Agregaciones: `COUNT(*)`, `GROUP BY`, `SUM(...)`, `AVG(...)`.
|
||||
- JOINs custom entre tablas (ej. `functions JOIN unit_tests ON ...`) no expuestos por el MCP.
|
||||
|
||||
Cualquier `SELECT ... FROM functions/types/apps/proposals WHERE ...` plano se hace via MCP. El hook PreToolUse avisa si ve `sqlite3 registry.db "SELECT ..."`.
|
||||
|
||||
### Schema rapido
|
||||
|
||||
@@ -109,7 +160,7 @@ Tokens multi-palabra tambien necesitan comillas: `description:"react router"`.
|
||||
- `entity_type`: app, analysis, project, vault
|
||||
- `status`: active, missing, archived
|
||||
- Se puebla con `fn sync`, NO con `fn index`
|
||||
- Consultas: `SELECT * FROM pc_locations WHERE pc_id = 'home-wsl'`
|
||||
- Consultas: `mcp__registry__fn_doctor subcommand="sync"` (drift PC vs disco) o `sqlite3 registry.db "SELECT ... GROUP BY pc_id"` SOLO para agregaciones que el MCP no expone
|
||||
|
||||
**FTS5 (columnas buscables):**
|
||||
- `functions_fts`: id, name, description, tags, signature, domain, example, notes, documentation, code, params_schema
|
||||
@@ -118,6 +169,43 @@ Tokens multi-palabra tambien necesitan comillas: `description:"react router"`.
|
||||
|
||||
---
|
||||
|
||||
## Como invocar funciones del registry (CANONICO)
|
||||
|
||||
Tres patrones, uno por caso de uso. Toda invocacion del agente se loguea en `projects/fn_monitoring/apps/call_monitor/operations.db` para alimentar el bucle reactivo (issue 0085).
|
||||
|
||||
| Caso de uso | Patron canonico | Cuando usar |
|
||||
|---|---|---|
|
||||
| **Inspeccionar** registro (buscar, leer codigo, ver dependencias, dominios) | `mcp__registry__fn_search` / `fn_show` / `fn_code` / `fn_uses` / `fn_list_domains` | SIEMPRE para descubrimiento. Reemplaza `sqlite3 registry.db "SELECT ..."` inline. |
|
||||
| **Ejecutar** UNA funcion o pipeline con sus args | `mcp__registry__fn_run <id> [args]` (preferido) o `./fn run <id> [args]` (fallback CLI) | Cuando hay UN id conocido a lanzar. Despacho automatico por lenguaje. Salida estructurada. |
|
||||
| **Componer** ad-hoc varias funciones con logica intermedia | Heredoc `python/.venv/bin/python3 - <<'PYEOF' ... PYEOF` IMPORTANDO funciones del registry | Solo cuando hay loops/conditionals/dispatch entre N funciones. Las funciones del registry **se importan**, no se reescriben. |
|
||||
|
||||
Regla decisiva: antes de cada bloque de codigo, decide caso. Si dudas entre 2 y 3, casi siempre es 2 (un MCP run con args). Si el caso 3 se repite con el mismo shape >5 veces entre sesiones, **es candidato a pipeline** en `python/functions/pipelines/`.
|
||||
|
||||
### Antipatrones prohibidos
|
||||
|
||||
| Patron | Por que es malo | Sustituir por |
|
||||
|---|---|---|
|
||||
| `sqlite3 registry.db "SELECT ..."` para buscar funciones/tipos | Salta MCP, FTS5 gotchas, sin trazabilidad. Hook PreToolUse ya avisa. | `mcp__registry__fn_search` |
|
||||
| `python -c "import metabase; print(dir(metabase))"` o `help(metabase)` para descubrir helpers | La fuente de verdad es el registry, no el `__init__.py` | `mcp__registry__fn_search "metabase"` + `mcp__registry__fn_show <id>` |
|
||||
| Heredoc que reescribe logica que ya existe como funcion del registry | Reinvento + perdida de capitalizacion | Buscar primero; si falta, delegar a `fn-constructor` (no escribir inline) |
|
||||
| `client._http.request(...)` directo cuando hay wrapper en el registry | Salta validacion del wrapper y telemetria | Usar wrapper; si la firma no cubre el caso, proponer extension via `fn proposal add` |
|
||||
| Scripts en `temp/` para composiciones que se repiten | Codigo se pierde y no se monitoriza | Pipeline en `python/functions/pipelines/` o pipeline Bash en `bash/functions/pipelines/` |
|
||||
| Imports `from <pkg> import *` en heredoc | Imposible saber que funcion del registry se uso | Imports explicitos `from <domain> import <name1>, <name2>` |
|
||||
|
||||
Excepciones autorizadas para `sqlite3` directo (no requieren MCP): `.schema`, `.tables`, `PRAGMA table_info`, `COUNT(*) GROUP BY`, JOINs custom entre tablas que el MCP no expone.
|
||||
|
||||
### Trazabilidad y bucle reactivo
|
||||
|
||||
Hook `PostToolUse` en `.claude/settings.local.json` parsea cada comando Bash + cada `mcp__registry__*` y escribe en la `operations.db` del call_monitor. Datos consumidos por:
|
||||
|
||||
1. **Tab "Claude usage" en `registry_dashboard`** — top funciones, latencias, error rate, huerfanas con `calls_90d=0`.
|
||||
2. **Fase MEJORAR del bucle reactivo** — patrones inline repetidos generan proposals `new_function` con evidencia (session_ids + snippets). Funciones con error_rate alto y muchas llamadas suben en prioridad de bugfix.
|
||||
3. **Auditoria de reglas** — assertions sobre `violation_count`, `mcp_ratio`, `heredoc_repetition`. Si fallan critical → proposal "actualizar CLAUDE.md / prompt del agente".
|
||||
|
||||
Datos sensibles: solo se guarda `args_hash`, NUNCA valores concretos de argumentos.
|
||||
|
||||
---
|
||||
|
||||
## Estructura
|
||||
|
||||
```
|
||||
@@ -237,7 +325,7 @@ Entornos usados automaticamente:
|
||||
|
||||
## Añadir funciones
|
||||
|
||||
1. Consulta la BD para verificar que no existe algo similar
|
||||
1. `mcp__registry__fn_search query="<nombre|desc>"` para verificar que no existe algo similar
|
||||
2. Crea dos archivos segun el lenguaje:
|
||||
- Go: `functions/{domain}/{name}.go` + `.md`
|
||||
- Python: `python/functions/{domain}/{name}.py` + `.md`
|
||||
|
||||
@@ -0,0 +1,121 @@
|
||||
# /autonomous-task — Lanza fn-orquestador (Fase 6 del ciclo reactivo)
|
||||
|
||||
Lanza el meta-orquestador autonomo que recorre el bucle CONSTRUIR → EJECUTAR → RECOPILAR → ANALIZAR → MEJORAR sobre un issue, sin intervencion humana, hasta convergencia / estancamiento / timeout / limite de iteraciones.
|
||||
|
||||
Issue 0069. Pre-condiciones obligatorias (chequear ANTES de despachar):
|
||||
|
||||
1. Migration `fn_operations/migrations/006_task_runs.sql` aplicada.
|
||||
2. Subagentes `fn-constructor`, `fn-executor`, `fn-recopilador`, `fn-analizador`, `fn-mejorador`, `fn-orquestador` presentes en `.claude/agents/`.
|
||||
3. `dev/autonomous_protected_paths.json` existe.
|
||||
4. `master` local up-to-date con `origin/master`.
|
||||
5. Branch `auto/<issue_id>` NO existe ya.
|
||||
6. `gh auth status` OK (necesario para PR draft al converger).
|
||||
7. Tipo de tarea soportado: `feature_app_simple`, `bugfix_with_repro`, `refactor_safe`, `add_e2e_check`.
|
||||
|
||||
Si alguna pre-condicion falla → ABORT con razon. NO improvisar.
|
||||
|
||||
---
|
||||
|
||||
## Argumento
|
||||
|
||||
`$ARGUMENTS` — `<issue_id>` o `<task_spec_path>` + flags opcionales.
|
||||
|
||||
```
|
||||
/autonomous-task 0070
|
||||
/autonomous-task 0070 --max-iterations 15 --max-minutes 90
|
||||
/autonomous-task 0070 --auto-apply-proposals safe
|
||||
/autonomous-task 0070 --dry-run
|
||||
/autonomous-task path/to/spec.yaml --branch auto/custom-name
|
||||
```
|
||||
|
||||
Flags:
|
||||
- `--max-iterations N` tope de iteraciones (default 10)
|
||||
- `--max-minutes M` timeout total (default 60)
|
||||
- `--auto-apply-proposals` `none|safe|aggressive` (default `safe`)
|
||||
- `--branch NAME` rama TBD (default `auto/<issue_id>`)
|
||||
- `--dry-run` simula, NO aplica
|
||||
|
||||
---
|
||||
|
||||
## Comportamiento
|
||||
|
||||
1. **Verificar pre-condiciones** con script bash (ver arriba). Si alguna falla, reportar y salir.
|
||||
2. **Despachar a `fn-orquestador`** via Agent tool con `subagent_type=fn-orquestador`. Pasar:
|
||||
- `issue_id` o `task_spec`
|
||||
- flags resueltos
|
||||
- paths protegidos (leidos de `dev/autonomous_protected_paths.json`)
|
||||
3. **El subagente:**
|
||||
- Crea worktree aislado `/tmp/fn_orq_<issue>_<ts>/` desde `master`.
|
||||
- Persiste estado en `task_runs` (operations.db del app target o repo root).
|
||||
- Despacha por fases a los 5 subagentes especializados.
|
||||
- Aplica proposals filtradas por `--auto-apply-proposals`.
|
||||
- Termina con: `converged` (PR draft creado) | `stalled` | `timeout` | `iterations_exhausted` | `needs_human` | `aborted`.
|
||||
4. **Reportar resultado al humano** con:
|
||||
- `status`, `iterations / max`, `duration / max`
|
||||
- `branch`, `worktree`, `PR draft url` si converged
|
||||
- `proposals creadas / aplicadas`
|
||||
- `last run_id` y status
|
||||
- Resumen iter-por-iter del `progress_json`
|
||||
|
||||
---
|
||||
|
||||
## Reglas duras (no negociables)
|
||||
|
||||
- Sandbox de rama EN WORKTREE — nunca toca master ni el working tree del humano.
|
||||
- No merge automatico — PR draft siempre.
|
||||
- No `--no-verify`, no `--force`, no skip hooks.
|
||||
- Paths protegidos via `dev/autonomous_protected_paths.json`.
|
||||
- Watchdog: 2 iteraciones con mismo set de fails → `status=stalled`.
|
||||
- Auditoria total en `task_runs.progress_json`.
|
||||
- No self-modification: NO toca `.claude/agents/` ni `.claude/commands/`.
|
||||
|
||||
---
|
||||
|
||||
## Integracion con call_monitor (issue 0085)
|
||||
|
||||
El orquestador puede leer `projects/fn_monitoring/apps/call_monitor/operations.db` para:
|
||||
|
||||
- Consultar `function_stats` antes de decidir que funciones usar/reusar.
|
||||
- Filtrar proposals existentes via `mcp__registry__fn_proposal --status pending` para evitar duplicados.
|
||||
- Loggear sus invocaciones via el hook PostToolUse (automatico).
|
||||
|
||||
Tras converger, el `call_monitor propose` ejecutado por el humano (o futuro cron) absorbera las nuevas violations / copied_code / fails para alimentar la siguiente ronda.
|
||||
|
||||
---
|
||||
|
||||
## Tipos NO soportados
|
||||
|
||||
- Diseño arquitectura nuevo (humano decide).
|
||||
- Decisiones UX subjetivas.
|
||||
- Cambios BD productiva.
|
||||
- Cualquier cosa que toque secrets/credenciales.
|
||||
- Self-modification del propio orquestador.
|
||||
|
||||
Si el issue contiene criterios no-verificables programaticamente, ABORT con `status=needs_human`.
|
||||
|
||||
---
|
||||
|
||||
## Output canonico
|
||||
|
||||
```
|
||||
=== /autonomous-task: 0070 ===
|
||||
status: converged
|
||||
iterations: 7 / 10
|
||||
duration: 23 min / 60
|
||||
branch: auto/0070
|
||||
worktree: /tmp/fn_orq_0070_1731612345
|
||||
PR draft: https://github.com/.../pull/123
|
||||
proposals: 3 creadas, 2 auto-aplicadas
|
||||
last run_id: e2e_run_abc123 (status: pass)
|
||||
|
||||
Iter:
|
||||
1. construir → ok (2 funciones nuevas)
|
||||
2. ejecutar → ok
|
||||
3. analizar → fail (2/8 checks)
|
||||
4. mejorar → 3 proposals (2 auto-applicadas)
|
||||
5. construir → ok (re-build tras patches)
|
||||
6. analizar → pass
|
||||
7. recopilador → ok (operations.db integra)
|
||||
|
||||
Siguiente: revisar PR draft + fn proposal list -s pending --target-id 0070
|
||||
```
|
||||
@@ -0,0 +1,226 @@
|
||||
---
|
||||
description: "Auto-auditoria: verifica que la sesion registra uso de funciones, detecta gaps (patrones inline repetidos, wrappers saltados, heredocs sin function_id), lanza fn-constructor en paralelo para crear las funciones que faltan, y valida que Claude usara las nuevas en el siguiente turno"
|
||||
---
|
||||
|
||||
# /fn_claude — auto-auditoria + auto-construccion del registry
|
||||
|
||||
Comando meta: Claude se audita a si mismo. Verifica que su comportamiento en esta sesion (y las recientes) deja rastro en `call_monitor.operations.db`, detecta gaps reales del registry para el trabajo actual, lanza sub-agentes `fn-constructor` en paralelo para cerrar esos gaps, y verifica que la proxima vez usara las funciones nuevas.
|
||||
|
||||
## Objetivos del registry (Norte) — Issues 0086 + 0087
|
||||
|
||||
Cada corrida de `/fn_claude` optimiza 4 metricas visibles en Monitor tab del `registry_dashboard`:
|
||||
|
||||
1. **MAXIMIZAR `Reg %`** — % de calls con `function_id != ''`. Cada heredoc/bash que reescribe logica baja el ratio. Target: subir cada semana.
|
||||
2. **MEJORAR uso del registry por Claude** — Claude busca y reusa antes de escribir. `MCP` (mcp/heredoc/fn run) sube, `violations` baja. Si una funcion existe pero Claude no la encuentra, mejorar su `description`/`tags`/`params_schema` (FTS indexa todo).
|
||||
3. **ACELERAR tareas comunes** — patrones inline repetidos >2x -> `fn-constructor` los convierte en funcion, Claude las usa el siguiente turno. Menos pasos por tarea = mas valor.
|
||||
4. **PROMOVER COMPOSICIONES A PIPELINES** (issue 0087) — el registry crece **promoviendo secuencias A->B(->C) que se repiten con exito** a pipelines one-shot. Una funcion que hace bien una cosa NO necesita crecer. Pattern detection: `call_monitor sequences --detect --propose` (cron 6h activo) + tab `Promotion candidates` del dashboard.
|
||||
|
||||
Si `/fn_claude` no mueve estas 4 metricas, no esta haciendo su trabajo.
|
||||
|
||||
## Infraestructura de discovery activa (issue 0087)
|
||||
|
||||
Cada turno tienes capacidades ya cargadas SIN buscar. Si no las usas estas pagando el coste de FTS innecesariamente:
|
||||
|
||||
| Senal | Donde | Que hacer |
|
||||
|---|---|---|
|
||||
| Linea `CAPABILITIES (cache 1h): TOP: ... FRESH (7d): ... PIPELINES: ...` en cada UserPromptSubmit | hook `hook_capabilities_inject.sh` | Antes de buscar con `mcp__registry__fn_search`, mira si la funcion que necesitas esta en TOP/FRESH/PIPELINES. Si si, ve directo a `fn show <id>` (1 read) o `./fn run <id>` (0 reads). |
|
||||
| `<system-reminder>FUZZY-MATCH (issue 0087): your Bash command may already be a function. USE: ./fn run <id> -> <signature>` aparecido mid-flight | hook `hook_fn_match.sh` (PreToolUse, Bash matcher) | El hook detecto que tu Bash inline coincide con una funcion del registry. **NO ignores el reminder** — abandona el inline, llama a `./fn run <id>` o `mcp__registry__fn_run id="<id>"`. Si crees que la sugerencia es falso positivo, justifica brevemente antes de seguir inline (queda en violations). |
|
||||
| Hint AUSENTE para una query corta (`rsi sma` < 3 tokens) | threshold `raw_score >= 4.0` no alcanzado | NO interpretar la ausencia de hint como "no existe funcion". Usa `mcp__registry__fn_search` con query mas rica (3+ tokens del dominio). |
|
||||
| Falso positivo conocido: `agent` token | `robots.txt user-agent` matchea `agent_scaffold` | Ignora el reminder y sigue. Cost = 1 reminder ignorable. |
|
||||
|
||||
## Como combinar la 3 senales para minimizar pasos
|
||||
|
||||
1. **User prompt llega** -> lees `CAPABILITIES` line. Si la tarea encaja claramente con TOP/FRESH -> usa directo.
|
||||
2. **Vas a escribir Bash inline** -> el hook PreToolUse lo intercepta. Si dispara FUZZY-MATCH -> usa `./fn run <id>`.
|
||||
3. **No hay match y necesitas codigo** -> `mcp__registry__fn_search` con 3+ tokens. Si sigue sin hit -> delega a `fn-constructor` (no escribas inline). Patron repetido detectado por `call_monitor sequences` se promovera a pipeline en proximas iteraciones.
|
||||
|
||||
## Las 4 metricas norte (donde vigilarlas)
|
||||
|
||||
- `Reg %` (Monitor KPI) — % calls con function_id no vacio. Sube cuando el registry se usa.
|
||||
- `MCP` (Monitor KPI) — count calls con tools registry-aware (mcp*/heredoc*/fn_cli_run). Adopcion de patrones canonicos.
|
||||
- `Errors` / `Violations` (Monitor KPI) — bajan cuando el bucle cierra.
|
||||
- `Failed Functions` (Monitor sub-tab) — registry-functions que fallaron: diagnostico de bugs prioritarios.
|
||||
|
||||
Issue 0085 fase autocompleta. Reemplaza el flujo manual de "veo un patron, decido si extraer, escribo proposal, espero humano, fn-mejorador genera, fn-orquestador opera". Con `/fn_claude` Claude hace todo eso solo, **autonomamente para si mismo**.
|
||||
|
||||
---
|
||||
|
||||
## Comportamiento (ejecutalo en este orden)
|
||||
|
||||
### 1. AUDIT — ¿estoy siendo registrado?
|
||||
|
||||
```bash
|
||||
ROOT="/home/lucas/fn_registry"
|
||||
MON="$ROOT/projects/fn_monitoring/apps/call_monitor/operations.db"
|
||||
|
||||
# Pre-condiciones
|
||||
[ -f "$MON" ] || { echo "call_monitor.operations.db NO existe — issue 0085a no aplicado"; exit 1; }
|
||||
[ "$FN_TELEMETRY" = "1" ] || echo "WARNING: FN_TELEMETRY != 1 — wrappers Python/Bash inactivos"
|
||||
|
||||
# Metricas de la sesion actual + ultimas 24h
|
||||
sqlite3 "$MON" <<SQL
|
||||
SELECT 'calls_session', COUNT(*) FROM calls WHERE session_id = '${CLAUDE_SESSION_ID:-unknown}'
|
||||
UNION ALL SELECT 'calls_24h', COUNT(*) FROM calls WHERE ts >= CAST(strftime('%s','now','-1 day') AS INTEGER)
|
||||
UNION ALL SELECT 'violations_24h', COUNT(*) FROM violations WHERE ts >= CAST(strftime('%s','now','-1 day') AS INTEGER)
|
||||
UNION ALL SELECT 'tool_used_distribution_24h', NULL;
|
||||
SELECT tool_used, COUNT(*) FROM calls WHERE ts >= CAST(strftime('%s','now','-1 day') AS INTEGER) GROUP BY tool_used ORDER BY 2 DESC;
|
||||
SQL
|
||||
```
|
||||
|
||||
Si `calls_session = 0` → algo esta mal (hook PostToolUse no fire o BD no escribible). Reporta y para.
|
||||
|
||||
Si `mcp_*` / total < 0.4 → estas usando demasiado heredoc/sqlite directo. Reporta como warning.
|
||||
|
||||
### 2. GAP — ¿que funciones faltan?
|
||||
|
||||
Dos fuentes:
|
||||
|
||||
#### 2a. Patrones repetidos en heredocs/Edit
|
||||
|
||||
```sql
|
||||
-- En call_monitor.operations.db
|
||||
SELECT tool_used, COUNT(*) AS hits
|
||||
FROM calls
|
||||
WHERE function_id = ''
|
||||
AND ts >= CAST(strftime('%s','now','-7 days') AS INTEGER)
|
||||
AND tool_used IN ('heredoc_py', 'heredoc_bash', 'sqlite_direct')
|
||||
GROUP BY tool_used;
|
||||
```
|
||||
|
||||
Si `heredoc_py > 5` sin function_id → Claude esta componiendo logica que probablemente debe ser pipeline. Investigar el ultimo heredoc del transcript: si reescribe algo que ya es funcion del registry → violation candidate. Si no, es candidato a pipeline nuevo.
|
||||
|
||||
#### 2b. Trabajo actual de la sesion — gap inferido del contexto
|
||||
|
||||
Lee el ultimo prompt del usuario y los ultimos 10 turnos. Lista funciones que:
|
||||
|
||||
- Has llamado inline (sed/awk/jq custom, transformaciones de datos, parsing).
|
||||
- Has reinventado (HTTP client raw, SQLite open con flags, FS walks).
|
||||
- Has compuesto >2 veces con el mismo shape.
|
||||
|
||||
Para cada candidato:
|
||||
|
||||
```bash
|
||||
# Verifica si ya existe algo similar en el registry
|
||||
mcp__registry__fn_search "<keyword del candidato>"
|
||||
```
|
||||
|
||||
Si NO existe match relevante → candidato a `fn-constructor`.
|
||||
Si existe pero firma incompleta → candidato a `improve_function` (proposal, NO auto-construccion).
|
||||
|
||||
### 3. PROPOSE — lista candidatos
|
||||
|
||||
Genera tabla:
|
||||
|
||||
```
|
||||
| Candidato | Razon | Lenguaje | Dominio | Evidencia (snippet) |
|
||||
|---|---|---|---|---|
|
||||
| <name> | inline_repeated/wrapper_skip/new | go/py/bash | core/infra/... | <heredoc fragment> |
|
||||
```
|
||||
|
||||
Si lista vacia → "no gaps detected, sesion saludable" + reporta metricas. Para.
|
||||
|
||||
### 4. CONSTRUCT — lanza fn-constructor en paralelo
|
||||
|
||||
Para cada candidato, dispara un sub-agente `fn-constructor` con prompt autocontenido:
|
||||
|
||||
```
|
||||
Agent(subagent_type="fn-constructor", prompt=...)
|
||||
```
|
||||
|
||||
Prompts en PARALELO en un mismo mensaje (varios Agent calls). Pasar:
|
||||
- nombre propuesto, lang, domain
|
||||
- firma esperada (params + return)
|
||||
- pureza
|
||||
- descripcion + ejemplo de uso (heredoc real detectado)
|
||||
- nota: "esta funcion la necesita Claude para auto-uso futuro"
|
||||
|
||||
### 5. VALIDATE — ¿la proxima sesion la usara?
|
||||
|
||||
Despues de que fn-constructor termine:
|
||||
|
||||
```bash
|
||||
./fn index 2>&1 | tail -2
|
||||
# Verifica que las nuevas funciones existen
|
||||
for fn in <lista>; do
|
||||
mcp__registry__fn_show "$fn" >/dev/null && echo "OK: $fn" || echo "FAIL: $fn"
|
||||
done
|
||||
```
|
||||
|
||||
Tambien actualiza `call_monitor.copied_code` + `function_stats` corriendo:
|
||||
|
||||
```bash
|
||||
cd "$ROOT/projects/fn_monitoring/apps/call_monitor" && ./call_monitor copied-code && ./call_monitor propose
|
||||
```
|
||||
|
||||
Reporta:
|
||||
- N funciones nuevas creadas (con IDs)
|
||||
- N proposals nuevas en `registry.db.proposals`
|
||||
- Recomendacion al usuario: "proximo turno mencionar/usar `<fn_id>` para validar que el wrapper se invoca correctamente"
|
||||
|
||||
### 6. SELF-TEST — telemetria del propio /fn_claude
|
||||
|
||||
`/fn_claude` mismo debe quedar registrado. Tras ejecutar, query final:
|
||||
|
||||
```bash
|
||||
sqlite3 "$MON" "SELECT COUNT(*) FROM calls WHERE session_id = '${CLAUDE_SESSION_ID:-unknown}' AND ts >= <inicio_comando>"
|
||||
```
|
||||
|
||||
Si la cuenta no aumento → el comando esta operando fuera de la telemetria (bug). Reportar.
|
||||
|
||||
---
|
||||
|
||||
## Reglas duras
|
||||
|
||||
1. **NO ejecutar fn-constructor para algo que ya existe.** Buscar primero via `mcp__registry__fn_search`. Si match relevante → NO crear duplicado.
|
||||
2. **NO crear funciones especulativas.** Cada candidato debe tener evidencia real (snippet de heredoc o llamada inline detectada en esta sesion o en `call_monitor.calls` reciente).
|
||||
3. **PARALELO**: si hay >1 candidato, lanza todos los `fn-constructor` en un solo mensaje con multiples `Agent` calls. NO secuencial.
|
||||
4. **No autonomous merge**: las funciones nuevas viven en el branch local. NO push automatico. Humano revisa y push manual.
|
||||
5. **Limites duros**: max 5 funciones nuevas por invocacion. Si detectas mas, prioriza por evidence weight (`occurrences * recency`) y reporta el resto como pending.
|
||||
6. **Si la sesion no esta siendo registrada (`calls_session = 0`)**: ABORT antes de fase 2. No tiene sentido auto-construir sin telemetria.
|
||||
|
||||
---
|
||||
|
||||
## Output canonico
|
||||
|
||||
```
|
||||
=== /fn_claude — auto-auditoria ===
|
||||
session_id: <id>
|
||||
calls_session: N
|
||||
calls_24h: M (mcp_ratio: 0.XX)
|
||||
violations_24h: K
|
||||
pending_proposals: P (existentes en registry.db)
|
||||
|
||||
GAPS DETECTADOS:
|
||||
1. <name>_<lang>_<domain> — razon — evidencia
|
||||
2. ...
|
||||
|
||||
LANZADOS (en paralelo):
|
||||
fn-constructor #1: <name1> → en progreso
|
||||
fn-constructor #2: <name2> → en progreso
|
||||
...
|
||||
|
||||
VALIDADAS tras ./fn index:
|
||||
✓ <name1>_<lang>_<domain>
|
||||
✓ <name2>_<lang>_<domain>
|
||||
|
||||
PROPOSALS NUEVAS: <count>
|
||||
|
||||
PROXIMO TURNO: menciona `<name1>` para validar wrapper.
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Cuando usar
|
||||
|
||||
- Al inicio de una sesion larga, para verificar telemetria activa.
|
||||
- A media sesion, cuando notes que estas reescribiendo el mismo bloque.
|
||||
- Antes de cerrar sesion, para capitalizar lo aprendido como funciones reutilizables.
|
||||
- Tras `/autonomous-task` para validar que el orquestador no genero ruido (proposals/funciones huerfanas).
|
||||
|
||||
---
|
||||
|
||||
## Cuando NO usar
|
||||
|
||||
- En sesiones cortas (<5 turnos) — no hay datos suficientes.
|
||||
- Si `call_monitor.operations.db` no esta inicializado (`call_monitor init` primero).
|
||||
- Si el usuario quiere control manual del proceso de extraccion. Este comando es agresivo.
|
||||
@@ -109,6 +109,177 @@ metabase_update_dashboard(client, dash["id"], dashcards=[
|
||||
|
||||
**Filtros de list_dashboards:** `all`, `mine`, `archived`
|
||||
|
||||
### Dashboards — helpers compositivos (añadir KPIs a dashboard existente)
|
||||
|
||||
Helpers para el flujo tipico "anadir N cards (KPI) al final de un tab existente reusando los mismos filtros que otro card vecino". Evitan los gotchas: replicar `parameter_mappings`, calcular `row` libre, escapado raro de `column_settings`, generacion de `lib/uuid` en MBQL.
|
||||
|
||||
```python
|
||||
from metabase import (
|
||||
metabase_mbql_from_source_card,
|
||||
metabase_copy_dashcard_mappings,
|
||||
metabase_dashboard_next_row,
|
||||
metabase_dashboard_append_row,
|
||||
metabase_viz_column_format,
|
||||
metabase_smartscalar_anothercolumn_viz,
|
||||
)
|
||||
```
|
||||
|
||||
#### `metabase_mbql_from_source_card`
|
||||
|
||||
Construye `dataset_query` MBQL sobre una saved-card (`source-card`), con aggregations + joins + filters + breakouts + segunda stage de expressions. Genera `lib/uuid` automatico en cada nodo.
|
||||
|
||||
```python
|
||||
dq = metabase_mbql_from_source_card(
|
||||
database_id=6,
|
||||
source_card_id=5305,
|
||||
aggregations=[
|
||||
{"op": "sum", "field": "PrecioVenta", "base_type": "type/Decimal"},
|
||||
{"op": "sum", "field": "PrecioCompra", "base_type": "type/Decimal"},
|
||||
{"op": "sum", "field": "PrecioTasas", "base_type": "type/Float"},
|
||||
],
|
||||
joins=[
|
||||
{"alias": "Centros - idCentro", "source_card_id": 4076,
|
||||
"fields": "none", "local_field": "idCentro", "local_base_type": "type/Text",
|
||||
"foreign_field_id": 17316, "foreign_base_type": "type/Text"},
|
||||
],
|
||||
filters=[["not-empty", {}, ["field", {"base-type": "type/Text"},
|
||||
"Centros - idCentro__Companies__name"]]],
|
||||
expressions=[
|
||||
{"name": "MasadeMargen", "expr":
|
||||
{"op": "-", "args": [{"field": "sum"},
|
||||
{"op": "+", "args": [{"field": "sum_2"}, {"field": "sum_3", "base_type": "type/Float"}]}]}},
|
||||
{"name": "Margen", "expr":
|
||||
{"op": "coalesce", "args": [
|
||||
{"op": "/", "args": [
|
||||
{"op": "-", "args": [{"field": "sum"},
|
||||
{"op": "+", "args": [{"field": "sum_2"}, {"field": "sum_3", "base_type": "type/Float"}]}]},
|
||||
{"field": "sum"}]},
|
||||
0]}},
|
||||
],
|
||||
)
|
||||
```
|
||||
|
||||
Ops soportadas en expressions: `+`, `-`, `*`, `/`, `coalesce`, `case`. Referencia a otra expresion en la misma stage: `{"ref": "Margen"}`. Aliases de aggregations son posicionales: `sum`, `sum_2`, `sum_3`... (orden = declaracion).
|
||||
|
||||
#### `metabase_copy_dashcard_mappings`
|
||||
|
||||
Copia los `parameter_mappings` de un dashcard "donante" a un card nuevo. Devuelve lista lista para pegar en `dashcards_add`.
|
||||
|
||||
```python
|
||||
mappings = metabase_copy_dashcard_mappings(
|
||||
client,
|
||||
dashboard_id=734,
|
||||
source_card_id=9918, # card donante con 18 filtros mapeados
|
||||
dest_card_id=9947, # card destino nueva
|
||||
)
|
||||
# Devuelve [{"parameter_id","card_id","target"}, ...] con card_id=9947
|
||||
```
|
||||
|
||||
#### `metabase_dashboard_next_row`
|
||||
|
||||
Calcula el primer `row` libre al final de un tab.
|
||||
|
||||
```python
|
||||
row = metabase_dashboard_next_row(client, dashboard_id=734, tab_id=191)
|
||||
# row=12 si el ultimo card termina en row+size_y=12
|
||||
# tab_id=0 → dashboards sin tabs
|
||||
```
|
||||
|
||||
#### `metabase_dashboard_append_row`
|
||||
|
||||
Combo: append N cards en una fila horizontal al final del tab, copiando mappings de un donante. Una sola llamada hace `next_row` + grid math + `copy_mappings` + `update_dashboard_safe`.
|
||||
|
||||
```python
|
||||
metabase_dashboard_append_row(
|
||||
client,
|
||||
dashboard_id=734,
|
||||
tab_id=191,
|
||||
card_ids=[9947, 9948, 9949],
|
||||
height=4,
|
||||
donor_card_id=9918, # mismos 18 filtros del dashboard
|
||||
grid_width=24, # default Metabase v0.59
|
||||
)
|
||||
# Coloca 3 cards de size_x=8 en row=next, cols 0/8/16, con mappings copiados
|
||||
```
|
||||
|
||||
#### `metabase_viz_column_format`
|
||||
|
||||
Construye una entrada de `column_settings` con la clave JSON-escaped (`'["name","Margen"]'`) sin tener que recordar el formato exacto.
|
||||
|
||||
```python
|
||||
metabase_viz_column_format("Margen", number_style="percent", decimals=2)
|
||||
# {'["name","Margen"]': {"number_style": "percent", "decimals": 2}}
|
||||
|
||||
metabase_viz_column_format("MasadeMargen", number_style="currency",
|
||||
currency="EUR", decimals=0, currency_in_header=False)
|
||||
# {'["name","MasadeMargen"]': {...}}
|
||||
```
|
||||
|
||||
Mergea varios resultados en `column_settings` de las visualization_settings.
|
||||
|
||||
#### `metabase_smartscalar_anothercolumn_viz`
|
||||
|
||||
Construye `visualization_settings` completo para `display=smartscalar` con comparativa tipo `anotherColumn` (compara dos columnas de la misma fila — no requiere breakout temporal).
|
||||
|
||||
```python
|
||||
viz = metabase_smartscalar_anothercolumn_viz(
|
||||
main_column="Margen",
|
||||
compare_column="Margen_N1",
|
||||
label="vs N-1",
|
||||
number_style="percent",
|
||||
decimals=2,
|
||||
)
|
||||
# Setear en /api/card via PUT visualization_settings=viz
|
||||
```
|
||||
|
||||
**⚠ Gotcha smartscalar Metabase v0.59:** el visualization solo acepta `type: "anotherColumn"` cuando la query NO produce filas multiples. Si Metabase muestra el error *"Agrupa solo por un campo de tiempo para ver como ha cambiado con el tiempo"*, hace falta un **breakout temporal** en la MBQL (ej. `breakouts=[{"field":"fecha","base_type":"type/Date","temporal_unit":"month"}]`) y usar el comparison `previousValue` en lugar de `anotherColumn`. Alternativa: `metabase_smartscalar_kpi_sql` + `metabase_smartscalar_kpi_payload` (patron 2-row nativo) si la card es SQL nativo.
|
||||
|
||||
#### Patron canonico — anadir 3 KPI cards a tab existente
|
||||
|
||||
```python
|
||||
import os, sys
|
||||
sys.path.insert(0, "python/functions")
|
||||
from metabase import (
|
||||
MetabaseClient, metabase_create_card, metabase_mbql_from_source_card,
|
||||
metabase_dashboard_append_row, metabase_viz_column_format,
|
||||
metabase_smartscalar_anothercolumn_viz,
|
||||
)
|
||||
|
||||
c = MetabaseClient("https://reports.autingo.es", os.environ["MB_API_KEY"])
|
||||
|
||||
# 1) MBQL reusando una saved-card como source
|
||||
def query():
|
||||
return metabase_mbql_from_source_card(
|
||||
database_id=6, source_card_id=5305,
|
||||
aggregations=[
|
||||
{"op":"sum","field":"PrecioVenta","base_type":"type/Decimal"},
|
||||
{"op":"sum","field":"PrecioCompra","base_type":"type/Decimal"},
|
||||
{"op":"sum","field":"PrecioTasas","base_type":"type/Float"},
|
||||
],
|
||||
# joins/filters/expressions ...
|
||||
)
|
||||
|
||||
# 2) Crear cards
|
||||
card1 = metabase_create_card(c, "Masa de Margen", query(),
|
||||
display="scalar", collection_id=500)
|
||||
viz1 = {"scalar.field": "MasadeMargen",
|
||||
"column_settings": metabase_viz_column_format(
|
||||
"MasadeMargen", number_style="currency", currency="EUR", decimals=0)}
|
||||
c._http.request("PUT", f"/api/card/{card1['id']}", json={"visualization_settings": viz1})
|
||||
|
||||
card2 = metabase_create_card(c, "Margen", query(), display="smartscalar", collection_id=500)
|
||||
viz2 = metabase_smartscalar_anothercolumn_viz(
|
||||
main_column="Margen", compare_column="Margen_N1", number_style="percent", decimals=2)
|
||||
c._http.request("PUT", f"/api/card/{card2['id']}", json={"visualization_settings": viz2})
|
||||
|
||||
# 3) Append fila al tab con mappings copiados del donante
|
||||
metabase_dashboard_append_row(
|
||||
c, dashboard_id=734, tab_id=191,
|
||||
card_ids=[card1["id"], card2["id"]],
|
||||
height=4, donor_card_id=9918,
|
||||
)
|
||||
```
|
||||
|
||||
### Documents (ProseMirror)
|
||||
|
||||
Los "documents" son páginas narrativas editables con texto rico y cards embebidas. **No hay helpers en fn_registry todavía** — usa el endpoint REST directamente a través de `client._http`.
|
||||
|
||||
@@ -77,4 +77,21 @@ Input: <paths absolutos, IDs registry, run_id si aplica>
|
||||
Tarea: <accion concreta y acotada>
|
||||
Criterio exito: <como sabe que termino>
|
||||
Limites: <que NO debe tocar>
|
||||
Telemetria: tus tool calls quedan registradas en projects/fn_monitoring/apps/call_monitor/operations.db
|
||||
via hook PostToolUse heredado de settings.local.json. Sigue patrones canonicos
|
||||
(mcp__registry__fn_*, ./fn run, heredoc importando) — los antipatrones se loguean
|
||||
como violations.
|
||||
```
|
||||
|
||||
## Telemetria heredada (issue 0085 hardening 5)
|
||||
|
||||
Los hooks de `.claude/settings.local.json` se heredan automaticamente por cada sub-agente que Claude Code lance via la tool `Agent`. Eso significa:
|
||||
|
||||
- Cada Bash, Edit, Write, MultiEdit, `mcp__registry__*` del sub-agente dispara `hook_call_monitor.sh` exactamente igual que en la sesion principal.
|
||||
- El `session_id` del JSON de input del hook viene del sub-agente, distinto al de la sesion padre. Util para auditar comportamiento por agente.
|
||||
- Las violations detectadas (sqlite3 directo, heredoc reinventando, etc) cuentan tambien para sub-agentes — un `fn-constructor` que reescribe inline en lugar de delegar a otro `fn-constructor` queda registrado.
|
||||
- `FN_TELEMETRY=1` esta en el `env` block de settings.local.json — los heredocs Python/Bash de sub-agentes ya tienen wrappers activos automaticamente.
|
||||
|
||||
Implicacion: NO necesitas pasar flags `--telemetry` a sub-agentes. Solo asegurate de que el prompt sigue patrones canonicos. La regla `.claude/rules/registry_calls.md` se aplica igual.
|
||||
|
||||
Si un sub-agente abre un proceso hijo que escapa al hook (ej. `nohup ... &`, daemons), ese subproceso queda fuera de la telemetria — documentalo en el prompt si es un caso valido.
|
||||
|
||||
@@ -30,3 +30,7 @@ Reglas operativas del proyecto. Cada archivo es una regla independiente.
|
||||
| 24 | [feature_flags.md](feature_flags.md) | TBD: feature flags para mergear codigo incompleto sin romper master. Patrones por stack (Go/TS/Bash/Py), branch-by-abstraction, anti-patrones |
|
||||
| 25 | [db_migrations.md](db_migrations.md) | Migraciones SQLite obligatorias para cualquier cambio de schema. Aditivas, idempotentes, archivos numerados. Nunca borrar .db ni modificar migraciones existentes |
|
||||
| 26 | [e2e_validation.md](e2e_validation.md) | Contrato `e2e_checks` en `app.md` consumido por fn-analizador (fase 4 del bucle reactivo). Issue 0068 |
|
||||
| 27 | [registry_calls.md](registry_calls.md) | Patrones canonicos para invocar funciones del registry (MCP inspect / MCP run / heredoc compose), antipatrones, excepciones, telemetria. Issue 0085 |
|
||||
| 28 | [delegation.md](delegation.md) | Si vas a escribir logica reutilizable inline -> spawn fn-constructor inmediato + tag de grupo + usar en mismo turno. Issue 0086 |
|
||||
| 29 | [capability_groups.md](capability_groups.md) | Tags planos + paginas madre `docs/capabilities/<grupo>.md` para desbloquear clusters de funciones en un read. Issue 0086 |
|
||||
| 30 | [function_growth_and_self_docs.md](function_growth_and_self_docs.md) | Contrato self-doc de cada `.md` (Ejemplo + Cuando usarla + Gotchas + Growth log) + crecimiento del registry por **promocion de composiciones** a pipelines, NO por inflado de funciones. Issue 0087 |
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
## Capability groups: tags + paginas madre en docs/capabilities/
|
||||
|
||||
Un **capability group** es un cluster de >=3 funciones del registry que comparten un dominio operativo (ej. `notebook`, `metabase`, `deploy`). Cada grupo tiene un **tag plano** (sin prefijo) y una **pagina madre** en `docs/capabilities/<grupo>.md`. La pagina madre desbloquea el conjunto entero en un solo read.
|
||||
|
||||
### Para que existen
|
||||
|
||||
Sin grupos, Claude redescubre funciones via FTS5 una a una cada sesion ("¿como interactuo con Jupyter? ¿como subo deploy?"). Con grupos, Claude lee `docs/capabilities/<grupo>.md` y carga las 5-10 funciones del cluster con su ejemplo canonico — menos turnos perdidos en discovery.
|
||||
|
||||
### Convencion de tag
|
||||
|
||||
- **Slug del grupo** = tag plano. Ej: `notebook`, `metabase`, `android-emu`.
|
||||
- **No prefijos** (`cap:`, `group:`). Ya hay namespacing implicito porque convivirian con tags semanticos sueltos.
|
||||
- **Una funcion puede llevar varios tags de grupo** si pertenece a dos clusters (raro pero valido).
|
||||
- Filtro MCP: `mcp__registry__fn_search query="" tag="notebook"` lista el grupo.
|
||||
|
||||
### Cuando crear grupo nuevo
|
||||
|
||||
- **Minimo 3 funciones** afines. Con 2 no compensa pagina madre — quedan tags sueltos.
|
||||
- **Dominio operativo claro**: el grupo debe ser describible en 1 frase ("operar Jupyter colaborativo", "deploy via SSH+systemd").
|
||||
- **Frontera neta** con grupos existentes. Si solapa con otro -> reorganizar, no duplicar.
|
||||
|
||||
### Como crear grupo
|
||||
|
||||
1. Anadir el tag al frontmatter `.md` de >=3 funciones afines. `fn index` lo registra.
|
||||
2. Crear `docs/capabilities/<grupo>.md` con plantilla:
|
||||
- **Lista de funciones**: tabla `ID | firma corta | que hace`.
|
||||
- **Ejemplo canonico**: 1-2 bloques de codigo end-to-end con los IDs reales.
|
||||
- **Fronteras**: que NO cubre el grupo.
|
||||
- **Prerequisitos** y **notas** si aplica.
|
||||
3. Anadir fila al `docs/capabilities/INDEX.md`.
|
||||
4. Correr `fn doctor capabilities` para auditar drift.
|
||||
|
||||
### Auto-generacion
|
||||
|
||||
`fn doctor capabilities --update` (TBD) reescribe la tabla de funciones de cada pagina madre preservando bloques curated (`Ejemplo canonico`, `Fronteras`, `Notas`). Las secciones curated nunca se sobrescriben.
|
||||
|
||||
### Como Claude usa los grupos
|
||||
|
||||
Cuando una tarea cae en un dominio conocido:
|
||||
|
||||
1. `Read docs/capabilities/INDEX.md` para localizar grupo.
|
||||
2. `Read docs/capabilities/<grupo>.md` para cargar funciones + ejemplo.
|
||||
3. Solo si el grupo no cubre lo necesario, `mcp__registry__fn_search` para funciones sueltas.
|
||||
4. Si el grupo deberia cubrir pero falta funcion -> `fn-constructor` + tagear con el grupo en el frontmatter.
|
||||
|
||||
### Auditoria
|
||||
|
||||
```bash
|
||||
fn doctor capabilities # lista grupos + drift
|
||||
fn doctor capabilities --json # para agentes
|
||||
```
|
||||
|
||||
Comprueba:
|
||||
- Tag con N >=3 funciones pero sin pagina madre -> "tag huerfano".
|
||||
- Pagina madre sin tag respaldo -> "grupo fantasma".
|
||||
- Funcion con tag de grupo pero la pagina madre no la lista (autogen desfasada) -> "drift".
|
||||
|
||||
### Relacion con dominios
|
||||
|
||||
Los **dominios** del registry (`core`, `infra`, `finance`, `datascience`, `cybersecurity`, `shell`, `tui`, `pipelines`, `browser`) son taxonomia ortogonal — un grupo puede atravesar varios dominios (ej. `deploy` toca `infra` y `shell`). NO renombrar dominio a grupo ni viceversa.
|
||||
@@ -0,0 +1,42 @@
|
||||
## Delegacion: spawn fn-constructor en vez de escribir inline
|
||||
|
||||
**REGLA DURA.** Si vas a escribir logica reutilizable inline en un artefacto (app, analysis, playground) o heredoc, STOP y delega a `fn-constructor`. La misma sesion debe crear + usar la funcion. No acumular huerfanas.
|
||||
|
||||
### Cuando un patron es candidato a funcion
|
||||
|
||||
- Aparece >=2 veces en esta sesion o en heredocs recientes.
|
||||
- Firma generica (no depende de tipos internos del artefacto).
|
||||
- 1 responsabilidad clara (CRUD, parse, transform, http call, formato fijo, etc.).
|
||||
- No es one-liner idiomatico de stdlib (`time.Now().UTC().Format(...)` queda fuera).
|
||||
|
||||
### Flujo obligatorio (mismo turno)
|
||||
|
||||
1. **Detectar**. Si vas a escribir >=5 lineas de logica reutilizable inline -> STOP.
|
||||
2. **Spawn `fn-constructor` inmediato** via `Agent(subagent_type="fn-constructor", ...)`:
|
||||
- **Sin preguntar al usuario** (autorizado por defecto).
|
||||
- Si hay >1 funcion independiente -> una sola llamada al Agent tool con **N tool_use blocks paralelos** en el mismo mensaje. NO serializar.
|
||||
3. **Tagear con grupo de capacidad** al menos UN tag de grupo (`notebook`, `metabase`, `deploy`, etc.). Ver `capability_groups.md`.
|
||||
4. **`fn index`** para registrar.
|
||||
5. **Importar + invocar en el mismo turno** — no dejar funcion huerfana recien creada.
|
||||
6. **Auto-verificar** con `fn doctor uses-functions` y `fn doctor unused` si tocas >=3 funciones nuevas.
|
||||
|
||||
### Anti-patrones auditables
|
||||
|
||||
| Anti-patron | Consecuencia | Sustituir por |
|
||||
|---|---|---|
|
||||
| Escribir helper inline en artefacto en vez de delegar | Reinvento por sesion | Spawn fn-constructor |
|
||||
| Crear N funciones serialmente | Latencia x N | Multiples `Agent()` en mismo mensaje |
|
||||
| Crear funcion y no usarla en el turno | Huerfana desde dia 1 (`calls_90d=0`) | Importar + invocar antes de cerrar turno |
|
||||
| Crear funcion sin tag de grupo | Imposible descubrir en bloque proxima sesion | Anadir tag de grupo (capability group) |
|
||||
| Reescribir en heredoc logica que ya existe | Capitalizacion perdida | `mcp__registry__fn_search` antes de escribir |
|
||||
|
||||
### Excepciones
|
||||
|
||||
- **Logica de dominio especifica del artefacto** (CRUD de tabla concreta, layout de UI, flujo unico de la app) -> queda en el artefacto. Solo lo reutilizable se delega.
|
||||
- **Stub temporal con `not implemented`**: aceptable si la dependencia externa no esta disponible. Documentar en `.md` (ver `stubs.md`).
|
||||
|
||||
### Telemetria
|
||||
|
||||
Cada `code_writes` + `calls` se registra en `call_monitor/operations.db` (issue 0085). Vista `session_capability_growth` mide ratio creadas vs usadas por sesion. Hook `UserPromptSubmit` inyecta `CAPABILITY-GROWTH: created_this_session=X used=Y orphan=Z` en cada turno.
|
||||
|
||||
Si `orphan>0` al cerrar la sesion -> revisar: o la funcion era especulativa (no debio crearse) o falta integrarla en el codigo del artefacto.
|
||||
@@ -0,0 +1,115 @@
|
||||
## Function growth + self-documenting capability
|
||||
|
||||
Dos doctrinas hermanas. Una define **como deben ser** las funciones (auto-descubribles y lanzables sin segunda lectura). La otra define **como crece** el registry (no inflando funciones — promoviendo composiciones a pipelines).
|
||||
|
||||
Issue 0087.
|
||||
|
||||
---
|
||||
|
||||
### Parte A — `.md` autosuficiente (contrato OBLIGATORIO)
|
||||
|
||||
Cuando Claude (o un humano) encuentra una funcion via FTS / fuzzy match / capability page / TOP block, el `.md` debe bastar para **lanzarla sin abrir el codigo**. Esto es lo que hace que descubrir = lanzar y elimina el coste del second lookup.
|
||||
|
||||
**Secciones obligatorias** en cada `.md` del registry (functions + pipelines + types con uso practico):
|
||||
|
||||
| Seccion | Contenido | Tamaño |
|
||||
|---|---|---|
|
||||
| Frontmatter | `name`, `signature`, `params` (con `desc` por param), `output`, `tags`, `uses_functions`, etc. Lo de hoy. | — |
|
||||
| `## Ejemplo` | Bloque de codigo lanzable con args **concretos**. Copiar+pegar produce ejecucion real. NO placeholders abstractos. | 3-10 lineas |
|
||||
| `## Cuando usarla` | 1-2 frases con triggers: "cuando hagas X / antes de Y / si necesitas Z". Verbos imperativos. Ayuda al fuzzy match y a Claude a saber sin leer el codigo. | 1-3 lineas |
|
||||
| `## Gotchas` | Problemas conocidos / no-go cases. Obligatoria para funciones impuras o con efectos (Windows-side, red, FS write, GPU). Omisible para funciones puras triviales. | 0-5 puntos |
|
||||
| `## Capability growth log` | Solo SI la funcion ha crecido. Una linea por version: `v1.1.0 (YYYY-MM-DD) — anade --build flag para skip build`. No se rellena en v1.0.0. | crece con el tiempo |
|
||||
|
||||
**Anti-patrones del .md:**
|
||||
|
||||
- Ejemplo con `<arg1>`, `<arg2>` placeholders abstractos — NO. Ejemplos con valores reales (`registry_dashboard`, `/home/lucas/...`).
|
||||
- "Cuando usarla" vacio o "ver descripcion arriba" — NO. Frase nueva con trigger explicito.
|
||||
- `notes` lleno + `## Gotchas` vacio cuando la funcion tiene efectos — mover de `notes` a `## Gotchas`.
|
||||
- Capability growth log inventado (sin que la funcion haya cambiado) — NO. Solo se rellena cuando hay version bump real.
|
||||
|
||||
**Verificacion** (TBD: convertir a check de `fn doctor`): cada .md de `functions/`/`pipelines/` debe tener `## Ejemplo` y `## Cuando usarla`. `## Gotchas` obligatoria solo si `purity: impure`. `## Capability growth log` libre.
|
||||
|
||||
---
|
||||
|
||||
### Parte B — Crecimiento por composicion (no por inflado)
|
||||
|
||||
**Principio:** una funcion que hace bien UNA cosa NO necesita crecer. Anadir params "por si acaso" la hace peor (Inner Platform Effect). Lo que crece es el **registry**: pipelines nuevos que componen funciones existentes.
|
||||
|
||||
#### Ejemplo del principio
|
||||
|
||||
- **Hoy:** Claude para hacer una transferencia bancaria llama `bank_login` -> `bank_list_accounts` -> `bank_make_transfer`. 3 calls, 3 decisiones, 3 puntos de fallo.
|
||||
- **Manana:** pipeline `bank_transfer_oneshot(account, amount, target)` que compone las 3 internamente. 1 call, 1 decision.
|
||||
|
||||
Misma capacidad, 3x menos pasos. **Esto es lo que multiplica la velocidad de Claude**, no anadir flags a `bank_login`.
|
||||
|
||||
#### Como se promueve una composicion
|
||||
|
||||
Senal detectable en `call_monitor.operations.db`: secuencia A→B(→C) con
|
||||
|
||||
- **Mismo session_id**.
|
||||
- **Intervalo entre calls < N segundos** (default 30s).
|
||||
- **Occurrences > K** (default 5) en ventana de **D dias** (default 30).
|
||||
- **Success rate > S** (default 0.9 — falla < 10%).
|
||||
- **No existe ya un pipeline** que la cubra (validar con FTS sobre `uses_functions`).
|
||||
|
||||
Cuando se cumple → **proposal `new_pipeline`** con evidencia (sequence_ids, session_ids, occurrence count). Humano (o `fn-orquestador` autonomo) decide promover.
|
||||
|
||||
#### Implementacion (issue 0087 tanda A)
|
||||
|
||||
- `call_monitor sequences --detect` subcomando: escanea `calls` table, agrupa por session+window, computa secuencias, upserta en tabla `function_sequences`.
|
||||
- Cron diario que ejecuta el detector + genera proposals automaticas.
|
||||
- Visible en Monitor tab del `registry_dashboard`: sub-tab "Promotion candidates".
|
||||
|
||||
#### Cuando SI inflar una funcion
|
||||
|
||||
Casos legitimos para anadir feature a una funcion existente:
|
||||
|
||||
1. **Generalizar firma** sin romper consumidores (anadir param opcional con default sensato).
|
||||
2. **Mejor manejo de error** (mensajes mas claros, retry sensible).
|
||||
3. **Default mas inteligente** (autodetectar lo que antes era arg obligatorio).
|
||||
4. **Eliminar gotcha conocido** (fix de bug que estaba en `## Gotchas`).
|
||||
|
||||
NO infles para casos hipoteticos. NO anadas params "por flexibilidad". Si dudas, separa la responsabilidad en una funcion nueva o un pipeline.
|
||||
|
||||
#### Capability growth log — cuando se rellena
|
||||
|
||||
- Se rellena **solo cuando la funcion crece** (alguno de los 4 casos arriba).
|
||||
- Cada bump de `version` -> 1 linea en `## Capability growth log` con fecha y resumen 1-frase.
|
||||
- Una funcion estable de hace 6 meses puede seguir en v1.0.0 sin log: indica madurez, no abandono.
|
||||
- Telemetria (call_monitor) decide si una funcion estable es huerfana (`calls_90d=0`) o usada-y-buena (`calls_30d>10, error_rate<0.05`). Las primeras se deprecan; las segundas se respetan.
|
||||
|
||||
---
|
||||
|
||||
### Parte C — Output de discovery
|
||||
|
||||
Cuando un mecanismo de discovery (fuzzy match / FRESH hook / TOP block / capability page) surfacea una funcion, el payload **minimo** es:
|
||||
|
||||
```
|
||||
<id> → <signature> → <ejemplo de 1 linea>
|
||||
```
|
||||
|
||||
Ejemplo concreto:
|
||||
```
|
||||
redeploy_cpp_app_windows_bash_pipelines
|
||||
./fn run redeploy_cpp_app_windows registry_dashboard /path/to/app [--build]
|
||||
use: tras compilar cpp/build/windows, antes de smoke test manual
|
||||
```
|
||||
|
||||
Si Claude necesita mas (gotchas, params completos, codigo), un `mcp__registry__fn_show <id>` adicional. Pero el primer hit ya basta para el 80% de casos.
|
||||
|
||||
---
|
||||
|
||||
### Parte D — Relacion con otras reglas
|
||||
|
||||
- [[registry_first]] dice CUANDO buscar/usar/delegar. Esta regla dice **COMO** debe ser la funcion para que esa busqueda valga.
|
||||
- [[ids_naming]] hace ID predictible. Esta regla hace metadata predictible.
|
||||
- [[delegation]] dice cuando spawnar fn-constructor. Esta regla es lo que fn-constructor debe producir.
|
||||
- [[capability_groups]] agrupa funciones afines. Las paginas madre de cada grupo deben respetar el mismo contrato self-doc (mejor con su propio ejemplo end-to-end por grupo).
|
||||
|
||||
### Resumen TL;DR
|
||||
|
||||
1. Cada `.md` autosuficiente: Ejemplo + Cuando usarla + Gotchas (si impura) + Growth log (si crecio).
|
||||
2. Las funciones que hacen bien una cosa NO necesitan crecer.
|
||||
3. El registry crece **promoviendo composiciones repetidas a pipelines**, no inflando funciones.
|
||||
4. Telemetria de `call_monitor` detecta secuencias candidatas y abre proposals automaticas.
|
||||
5. Discovery devuelve siempre: `id + signature + 1-line example`. Resto on-demand.
|
||||
@@ -0,0 +1,147 @@
|
||||
## Como invocar funciones del registry — patrones canonicos
|
||||
|
||||
Toda invocacion del agente al registry sigue uno de **tres patrones**. Cualquier otro patron es antipatron auditable. Las invocaciones se loguean en `projects/fn_monitoring/apps/call_monitor/operations.db` (issue 0085) para alimentar el bucle reactivo.
|
||||
|
||||
### Patrones canonicos
|
||||
|
||||
| Caso | Patron | Cuando |
|
||||
|---|---|---|
|
||||
| **Inspeccionar** (buscar, leer codigo, ver dependencias, listar dominios, leer proposals) | `mcp__registry__fn_search` / `fn_show` / `fn_code` / `fn_uses` / `fn_list_domains` / `fn_proposal` | SIEMPRE para descubrimiento, lectura de codigo, exploracion. |
|
||||
| **Ejecutar** UNA funcion/pipeline con sus args | `mcp__registry__fn_run <id> [args]` (preferido) o `./fn run <id> [args]` (fallback CLI) | ID conocido + args planos. Despacho automatico por lenguaje. |
|
||||
| **Componer** ad-hoc multi-funcion con logica intermedia | Heredoc `python/.venv/bin/python3 - <<'PYEOF' ... PYEOF` IMPORTANDO funciones del registry | Solo si hay loops/conditionals/dispatch entre N funciones. Las funciones del registry **se importan**, no se reescriben. |
|
||||
|
||||
### Antipatrones prohibidos (audit-targeted)
|
||||
|
||||
| Patron | Razon | Sustituir por |
|
||||
|---|---|---|
|
||||
| `sqlite3 registry.db "SELECT ..."` para buscar funciones/tipos | Salta MCP, FTS5 gotchas, sin trazabilidad | `mcp__registry__fn_search` |
|
||||
| `sqlite3 registry.db "SELECT ... FROM proposals"` | Mismo problema | `mcp__registry__fn_proposal` |
|
||||
| `python -c "import metabase; dir(metabase)"` para descubrir helpers | Fuente de verdad = registry, no `__init__.py` | `mcp__registry__fn_search "metabase"` + `mcp__registry__fn_show <id>` |
|
||||
| Heredoc que reescribe logica que ya existe como funcion del registry | Reinvento + perdida de capitalizacion | Buscar primero; si falta, delegar a `fn-constructor` (no escribir inline) |
|
||||
| `client._http.request(...)` saltando wrapper del registry | Salta validacion del wrapper y telemetria | Usar wrapper; si firma incompleta, `fn proposal add --kind improve_function` |
|
||||
| Scripts en `temp/` para composiciones que se repiten >2 veces | Codigo perdido + sin monitoreo | Pipeline en `python/functions/pipelines/` o `bash/functions/pipelines/` |
|
||||
| `from <pkg> import *` en heredoc | Imposible identificar funciones usadas | Imports explicitos `from <domain> import <name1>, <name2>` |
|
||||
|
||||
### Excepciones autorizadas para `sqlite3` directo
|
||||
|
||||
Casos donde el MCP no aplica y `sqlite3 registry.db` es legitimo:
|
||||
|
||||
- Introspeccion de schema: `.schema`, `.tables`, `PRAGMA table_info(...)`, `PRAGMA index_list(...)`.
|
||||
- Agregaciones: `COUNT(*)`, `GROUP BY`, `SUM(...)`, `AVG(...)`.
|
||||
- JOINs custom entre tablas que el MCP no expone (`functions JOIN unit_tests ON ...`).
|
||||
- Columnas que el MCP no devuelve (rare; preferir proponer ampliacion del MCP).
|
||||
|
||||
El hook `PreToolUse` (`.claude/scripts/hook_registry_mcp.sh`) ya deja pasar estas excepciones y solo avisa cuando ve `sqlite3 registry.db "SELECT ..."` plano.
|
||||
|
||||
### Excepcion: hooks e infraestructura de telemetria (issue 0087)
|
||||
|
||||
Los **hooks** (`PreToolUse`, `PostToolUse`, `UserPromptSubmit`, etc.) y los **binarios de infraestructura** que sirven al agente (`fn_match`, `fn doctor`, `call_monitor`) **pueden leer `registry.db` directo** via `sqlite3` o `database/sql` con conexion read-only. NO estan sujetos a la regla MCP-first porque:
|
||||
|
||||
- No son acciones del agente — son inspeccion automatizada del entorno.
|
||||
- El MCP requiere tool invocation por Claude; un hook no puede invocar tools.
|
||||
- Latencia objetivo (50-200ms) incompatible con round-trip MCP.
|
||||
|
||||
**Restricciones:**
|
||||
- SOLO lectura. Conexion debe abrirse con `?mode=ro` o `?_query_only=1`.
|
||||
- NUNCA escritura a `registry.db` desde hooks.
|
||||
- Si un hook necesita escribir (cache, telemetria propia), usa su propia DB (`operations.db` del app de hooks, o `~/.fn_hooks/cache.db`).
|
||||
|
||||
Esta excepcion es **explicita y acotada** — no aplica al agente, que sigue regido por la regla MCP-first.
|
||||
|
||||
### Verificacion previa — `fn doctor`
|
||||
|
||||
Antes de empezar trabajo no trivial sobre el registry, ejecutar `fn doctor` para confirmar que el ecosistema esta sano:
|
||||
|
||||
- Artefactos OK (sin `git_not_initialized`, `venv_broken_path`, etc.).
|
||||
- Services activos cuando se necesiten (`sqlite_api`, `registry_api`, `registry_mcp`).
|
||||
- Sin drift `pc_locations` vs disco.
|
||||
- Sin drift `uses_functions` vs imports reales.
|
||||
|
||||
Si `fn doctor` reporta `service inactive` para `registry_mcp.service`, el MCP estara siendo invocado en modo stdio por Claude Code (normal); el systemd unit solo aplica al modo HTTP. Si el binario no responde, rebuild: `cd apps/registry_mcp && CGO_ENABLED=1 go build -tags fts5 -o registry_mcp .`.
|
||||
|
||||
### Tools MCP disponibles
|
||||
|
||||
| Tool | Lectura/escritura | Gating |
|
||||
|---|---|---|
|
||||
| `fn_search` | read | siempre on |
|
||||
| `fn_show` | read | siempre on |
|
||||
| `fn_code` | read | siempre on |
|
||||
| `fn_uses` | read | siempre on |
|
||||
| `fn_list_domains` | read | siempre on |
|
||||
| `fn_proposal` | read | siempre on |
|
||||
| `fn_doctor` | read | siempre on |
|
||||
| `fn_run` | execute (mutating side-effects) | requiere `--enable-run` |
|
||||
| `fn_create_function` | write | requiere `--enable-write` |
|
||||
|
||||
### Heredoc Python — convenciones obligatorias
|
||||
|
||||
Cuando el caso 3 (composicion) sea inevitable:
|
||||
|
||||
1. **Imports explicitos** desde paquetes del registry. Nunca `import *`.
|
||||
2. **No reescribir** la firma de una funcion del registry — importarla.
|
||||
3. **Args via env vars o stdin JSON**, nunca interpolacion shell directa (inyeccion).
|
||||
4. **Output a stdout JSON** cuando vaya a ser consumido por el siguiente paso.
|
||||
5. **Si el heredoc supera ~30 lineas**, extraer a `python/functions/pipelines/`. El monitor avisara automaticamente cuando un patron similar se repita >5 veces.
|
||||
|
||||
### Trazabilidad — bucle reactivo
|
||||
|
||||
Cada evento alimenta a `call_monitor.db` (event-log append-only) y se rollupea en una vista `function_stats` con contadores por funcion del registry. Tablas event-log:
|
||||
|
||||
| Tabla | Captura |
|
||||
|---|---|
|
||||
| `calls` | Cada invocacion (heredoc/mcp/fn_run): function_id, tool_used, duration_ms, success, error_class, args_hash |
|
||||
| `code_writes` | Cada Edit/Write sobre archivo del registry: function_id, session_id, lines_added/removed |
|
||||
| `test_runs` | Cada `go test`/`pytest` que toca codigo del registry: function_id, test_id, passed, duration_ms |
|
||||
| `e2e_runs_fn` | Cada check `e2e_checks` de app que usa la funcion: function_id, app_id, check_id, passed |
|
||||
| `violations` | Antipatron detectado: rule_id, session_id, command_snippet, severity |
|
||||
| `patterns` | Heredocs clusterizados: pattern_hash, session_ids[], occurrences, representative_snippet |
|
||||
| `sessions` | session_id, cwd, started_at, ended_at, health_score, mcp_ratio |
|
||||
|
||||
Vista agregada `function_stats` por `function_id`:
|
||||
|
||||
- **Uso:** `calls_total`, `calls_24h/7d/30d/90d`, `last_used_at`
|
||||
- **Errores:** `errors_total`, `error_rate`, `last_error_class`, `last_error_ts`
|
||||
- **Performance:** `mean_duration_ms`, `p95_duration_ms`
|
||||
- **Codigo:** `writes_count`, `last_write_at`
|
||||
- **Tests:** `tests_total`, `tests_failed`, `test_fail_rate`, `last_test_failed_at`
|
||||
- **E2E:** `e2e_total`, `e2e_failed`, `e2e_fail_rate`, `consumer_apps_count`
|
||||
- **Salud:** `violations_caused`
|
||||
|
||||
Assertions derivadas → proposals automaticas:
|
||||
|
||||
| Regla | Threshold | Proposal |
|
||||
|---|---|---|
|
||||
| Huerfana absoluta | `calls_90d=0 AND writes_count=0` | `deprecate_function` |
|
||||
| Bug prioritario | `error_rate>0.1 AND calls_7d>5` | `improve_function` (bug) |
|
||||
| Regresion performance | `p95_24h > 1.5 * p95_30d` | `improve_function` (perf) |
|
||||
| Test flaky | `test_fail_rate>0.1 AND tests_total>10` | `improve_function` (flaky) |
|
||||
| Wrapper saltado | `violations_caused>3` | `improve_function` (API gap) |
|
||||
| Patron inline sin funcion | `patterns.occurrences>5 AND no match FTS` | `new_function` con snippet |
|
||||
| Blast radius alto | `e2e_fail_rate>0 AND consumer_apps_count>=3` | `improve_function` (critical) |
|
||||
|
||||
Datos sensibles: solo `args_hash`, NUNCA valores concretos. Snippets de error redactados via allowlist.
|
||||
|
||||
### Capas de monitorizacion (issue 0085)
|
||||
|
||||
Cobertura por capa, no todas activas a la vez:
|
||||
|
||||
| # | Capa | Activacion | Cobertura |
|
||||
|---|---|---|---|
|
||||
| 1 | Hook PostToolUse Bash | siempre (settings.local.json) | mcp, fn_cli_run, edit_registry, violations |
|
||||
| 2 | Wrapper Python `registry_telemetry` | `FN_TELEMETRY=1` env var | heredocs + notebooks Jupyter |
|
||||
| 3 | Wrapper Bash `telemetry_prelude.sh` | `source` explicito o `FN_TELEMETRY=1` | heredoc bash + apps bash |
|
||||
| 4 | Interceptor en `fn run` | siempre (binario Go) | duration/error real de invocacion CLI |
|
||||
| 5 | `fn doctor copied-code` | comando manual / cron | drift estatico: codigo copiado en apps |
|
||||
| 6 | `function_versions` + snapshot | poblado por `fn index` + edit-hook | historial de versiones |
|
||||
| 7-8 | Build-tag Go / macro C++ | opt-in por app | runtime de app (futuro) |
|
||||
|
||||
**Boundary:** monitorizamos al **agente** y a **invocaciones canonicas**. Runtime de apps Go/C++ compiladas queda fuera. Compensar con tests + `e2e_checks` (issue 0068).
|
||||
|
||||
### Que NO se monitoriza
|
||||
|
||||
- Funcion Go/C++ llamada internamente por app ya compilada.
|
||||
- Funcion ejecutada por systemd timer / cron / Dagu sin pasar por `fn run`.
|
||||
- Sub-agente (`Agent` tool) — sus tools no propagan a hook del padre.
|
||||
- Service de produccion recibiendo HTTP.
|
||||
|
||||
**Implicacion:** una funcion con `calls_90d=0` puede ser huerfana real O usada en runtime invisible. Antes de proponer `deprecate_function`, cruzar con `consumer_apps_count > 0` (e2e) o con `fn doctor uses-functions` (declaraciones estaticas).
|
||||
Executable
+243
@@ -0,0 +1,243 @@
|
||||
#!/usr/bin/env bash
|
||||
# PostToolUse hook: registra cada invocacion del agente en
|
||||
# projects/fn_monitoring/apps/call_monitor/operations.db (issue 0085b).
|
||||
#
|
||||
# Identifica tool, extrae function_id cuando es posible, clasifica el patron
|
||||
# (mcp_*, fn_cli_run, heredoc_py, sqlite_direct, edit_registry, ...) y
|
||||
# detecta antipatrones para registrar violations.
|
||||
#
|
||||
# NUNCA bloquea la herramienta. Falla silenciosamente si la BD no esta lista.
|
||||
# Solo guarda args_hash, jamas valores concretos.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# ---- Resolve registry root (walks up from cwd looking for registry.db) ----
|
||||
resolve_root() {
|
||||
local d="${PWD}"
|
||||
while [ "$d" != "/" ]; do
|
||||
if [ -f "$d/registry.db" ]; then
|
||||
printf '%s' "$d"
|
||||
return 0
|
||||
fi
|
||||
d=$(dirname "$d")
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
ROOT=$(resolve_root) || exit 0
|
||||
DB="$ROOT/projects/fn_monitoring/apps/call_monitor/operations.db"
|
||||
|
||||
# Si la BD aun no existe, el hook no hace nada (esperando init).
|
||||
[ -f "$DB" ] || exit 0
|
||||
|
||||
# ---- Read stdin JSON ----
|
||||
INPUT=$(cat)
|
||||
if [ -z "$INPUT" ]; then exit 0; fi
|
||||
|
||||
# Required jq presence
|
||||
command -v jq >/dev/null 2>&1 || exit 0
|
||||
command -v sqlite3 >/dev/null 2>&1 || exit 0
|
||||
|
||||
TOOL_NAME=$(printf '%s' "$INPUT" | jq -r '.tool_name // ""')
|
||||
SESSION_ID=$(printf '%s' "$INPUT" | jq -r '.session_id // ""')
|
||||
TS=$(date -u +%s)
|
||||
|
||||
# Tool response success/error
|
||||
SUCCESS=1
|
||||
ERROR_CLASS=""
|
||||
ERROR_SNIPPET=""
|
||||
RESP_IS_ERROR=$(printf '%s' "$INPUT" | jq -r 'if (.tool_response | type) == "object" then (.tool_response.is_error // false) else false end')
|
||||
if [ "$RESP_IS_ERROR" = "true" ]; then
|
||||
SUCCESS=0
|
||||
ERROR_SNIPPET=$(printf '%s' "$INPUT" | jq -r 'if (.tool_response | type) == "object" then (.tool_response.error // .tool_response.content // "") else "" end' | head -c 240 | tr '\n' ' ')
|
||||
fi
|
||||
|
||||
# args_hash: sha256 truncado del tool_input (sin valores)
|
||||
ARGS_HASH=$(printf '%s' "$INPUT" | jq -c '.tool_input // {}' | sha256sum | cut -c1-16)
|
||||
|
||||
# Helpers SQL
|
||||
sql_escape() { printf '%s' "$1" | sed "s/'/''/g"; }
|
||||
|
||||
insert_call() {
|
||||
local fn_id="$1" tool_used="$2" duration_ms="${3:-0}" snippet="${4:-}"
|
||||
local fn_esc tu_esc ec_esc es_esc sid_esc ah_esc snip_esc
|
||||
# Politica issue 0087: command_snippet solo se rellena cuando function_id
|
||||
# esta vacio. Si la call golpea una funcion del registry, su ID y
|
||||
# tool_used bastan; no duplicamos el comando.
|
||||
if [ -n "$fn_id" ]; then snippet=""; fi
|
||||
# Redact common secrets antes de persistir
|
||||
snippet=$(printf '%s' "$snippet" \
|
||||
| sed -E 's/(password|token|secret|api[_-]?key|bearer)([[:space:]]*[=:][[:space:]]*)[^[:space:]]+/\1\2<REDACTED>/Ig' \
|
||||
| head -c 200)
|
||||
fn_esc=$(sql_escape "$fn_id")
|
||||
tu_esc=$(sql_escape "$tool_used")
|
||||
ec_esc=$(sql_escape "$ERROR_CLASS")
|
||||
es_esc=$(sql_escape "$ERROR_SNIPPET")
|
||||
sid_esc=$(sql_escape "$SESSION_ID")
|
||||
ah_esc=$(sql_escape "$ARGS_HASH")
|
||||
snip_esc=$(sql_escape "$snippet")
|
||||
sqlite3 "$DB" "INSERT INTO calls (session_id, function_id, tool_used, args_hash, duration_ms, success, error_class, error_snippet, command_snippet, ts) VALUES ('$sid_esc','$fn_esc','$tu_esc','$ah_esc',$duration_ms,$SUCCESS,'$ec_esc','$es_esc','$snip_esc',$TS);" 2>/dev/null || true
|
||||
}
|
||||
|
||||
insert_code_write() {
|
||||
local fn_id="$1" file_path="$2" added="${3:-0}" removed="${4:-0}"
|
||||
local fn_esc fp_esc sid_esc
|
||||
fn_esc=$(sql_escape "$fn_id")
|
||||
fp_esc=$(sql_escape "$file_path")
|
||||
sid_esc=$(sql_escape "$SESSION_ID")
|
||||
sqlite3 "$DB" "INSERT INTO code_writes (session_id, function_id, file_path, lines_added, lines_removed, ts) VALUES ('$sid_esc','$fn_esc','$fp_esc',$added,$removed,$TS);" 2>/dev/null || true
|
||||
}
|
||||
|
||||
# Snapshot a function version row when an edit lands on a registry file.
|
||||
# Uses sha256 of file bytes as content_hash (separate namespace from index source).
|
||||
insert_edit_version() {
|
||||
local fn_id="$1" abs_path="$2"
|
||||
[ -f "$abs_path" ] || return 0
|
||||
command -v sha256sum >/dev/null 2>&1 || return 0
|
||||
local hash
|
||||
hash=$(sha256sum "$abs_path" 2>/dev/null | awk '{print $1}')
|
||||
[ -z "$hash" ] && return 0
|
||||
local fn_esc h_esc
|
||||
fn_esc=$(sql_escape "$fn_id")
|
||||
h_esc=$(sql_escape "$hash")
|
||||
sqlite3 "$DB" "INSERT OR IGNORE INTO function_versions (function_id, content_hash, version, snapped_at, source, lines_added, lines_removed) VALUES ('$fn_esc','$h_esc','',$TS,'edit_hook',0,0);" 2>/dev/null || true
|
||||
}
|
||||
|
||||
insert_violation() {
|
||||
local rule_id="$1" fn_id="$2" snippet="$3" severity="${4:-warning}"
|
||||
local r_esc fn_esc sn_esc sev_esc sid_esc
|
||||
r_esc=$(sql_escape "$rule_id")
|
||||
fn_esc=$(sql_escape "$fn_id")
|
||||
sn_esc=$(sql_escape "$(printf '%s' "$snippet" | head -c 240 | tr '\n' ' ')")
|
||||
sev_esc=$(sql_escape "$severity")
|
||||
sid_esc=$(sql_escape "$SESSION_ID")
|
||||
sqlite3 "$DB" "INSERT INTO violations (session_id, rule_id, function_id, command_snippet, severity, ts) VALUES ('$sid_esc','$r_esc','$fn_esc','$sn_esc','$sev_esc',$TS);" 2>/dev/null || true
|
||||
}
|
||||
|
||||
# ---- Derive function_id from registry file path ----
|
||||
# Matches paths under functions/<domain>/<name>.<ext>, python/functions/<domain>/<name>.py,
|
||||
# bash/functions/<domain>/<name>.sh, frontend/functions/<domain>/<name>.ts(x)
|
||||
derive_fn_id_from_path() {
|
||||
local p="$1"
|
||||
[ -z "$p" ] && return 1
|
||||
case "$p" in
|
||||
functions/*/*.go|*/functions/*/*.go)
|
||||
local dom name
|
||||
dom=$(printf '%s' "$p" | sed -E 's|.*functions/([^/]+)/.*|\1|')
|
||||
name=$(printf '%s' "$p" | sed -E 's|.*functions/[^/]+/([^/.]+)\..*|\1|')
|
||||
[ -n "$dom" ] && [ -n "$name" ] && printf '%s_go_%s' "$name" "$dom" && return 0 ;;
|
||||
python/functions/*/*.py)
|
||||
local dom name
|
||||
dom=$(printf '%s' "$p" | sed -E 's|python/functions/([^/]+)/.*|\1|')
|
||||
name=$(printf '%s' "$p" | sed -E 's|python/functions/[^/]+/([^/.]+)\..*|\1|')
|
||||
[ -n "$dom" ] && [ -n "$name" ] && printf '%s_py_%s' "$name" "$dom" && return 0 ;;
|
||||
bash/functions/*/*.sh)
|
||||
local dom name
|
||||
dom=$(printf '%s' "$p" | sed -E 's|bash/functions/([^/]+)/.*|\1|')
|
||||
name=$(printf '%s' "$p" | sed -E 's|bash/functions/[^/]+/([^/.]+)\..*|\1|')
|
||||
[ -n "$dom" ] && [ -n "$name" ] && printf '%s_bash_%s' "$name" "$dom" && return 0 ;;
|
||||
frontend/functions/*/*.ts|frontend/functions/*/*.tsx)
|
||||
local dom name
|
||||
dom=$(printf '%s' "$p" | sed -E 's|frontend/functions/([^/]+)/.*|\1|')
|
||||
name=$(printf '%s' "$p" | sed -E 's|frontend/functions/[^/]+/([^/.]+)\..*|\1|')
|
||||
[ -n "$dom" ] && [ -n "$name" ] && printf '%s_ts_%s' "$name" "$dom" && return 0 ;;
|
||||
esac
|
||||
return 1
|
||||
}
|
||||
|
||||
# ---- Dispatch by tool ----
|
||||
case "$TOOL_NAME" in
|
||||
mcp__registry__fn_search)
|
||||
insert_call "" "mcp_fn_search"
|
||||
;;
|
||||
mcp__registry__fn_show)
|
||||
ID=$(printf '%s' "$INPUT" | jq -r '.tool_input.id // ""')
|
||||
insert_call "$ID" "mcp_fn_show"
|
||||
;;
|
||||
mcp__registry__fn_code)
|
||||
ID=$(printf '%s' "$INPUT" | jq -r '.tool_input.id // ""')
|
||||
insert_call "$ID" "mcp_fn_code"
|
||||
;;
|
||||
mcp__registry__fn_uses)
|
||||
ID=$(printf '%s' "$INPUT" | jq -r '.tool_input.id // ""')
|
||||
insert_call "$ID" "mcp_fn_uses"
|
||||
;;
|
||||
mcp__registry__fn_run)
|
||||
ID=$(printf '%s' "$INPUT" | jq -r '.tool_input.id // ""')
|
||||
insert_call "$ID" "mcp_fn_run"
|
||||
;;
|
||||
mcp__registry__fn_list_domains)
|
||||
insert_call "" "mcp_fn_list_domains"
|
||||
;;
|
||||
mcp__registry__fn_proposal)
|
||||
insert_call "" "mcp_fn_proposal"
|
||||
;;
|
||||
mcp__registry__fn_doctor)
|
||||
insert_call "" "mcp_fn_doctor"
|
||||
;;
|
||||
mcp__registry__fn_create_function)
|
||||
insert_call "" "mcp_fn_create_function"
|
||||
;;
|
||||
|
||||
Edit|Write|MultiEdit)
|
||||
FILE_PATH=$(printf '%s' "$INPUT" | jq -r '.tool_input.file_path // ""')
|
||||
ABS_PATH="$FILE_PATH"
|
||||
# Make path relative to root if absolute and inside root
|
||||
case "$FILE_PATH" in
|
||||
"$ROOT"/*) FILE_PATH="${FILE_PATH#$ROOT/}" ;;
|
||||
/*) ABS_PATH="$FILE_PATH" ;;
|
||||
*) ABS_PATH="$ROOT/$FILE_PATH" ;;
|
||||
esac
|
||||
FN_ID=$(derive_fn_id_from_path "$FILE_PATH" || true)
|
||||
if [ -n "$FN_ID" ]; then
|
||||
insert_code_write "$FN_ID" "$FILE_PATH" 0 0
|
||||
insert_call "$FN_ID" "edit_registry"
|
||||
insert_edit_version "$FN_ID" "$ABS_PATH"
|
||||
fi
|
||||
;;
|
||||
|
||||
Bash)
|
||||
CMD=$(printf '%s' "$INPUT" | jq -r '.tool_input.command // ""')
|
||||
CMD_HEAD=$(printf '%s' "$CMD" | head -c 200 | tr '\n' ' ')
|
||||
|
||||
# Classify
|
||||
TOOL_USED="bash_other"
|
||||
FN_ID=""
|
||||
|
||||
if printf '%s' "$CMD" | grep -qE '(^|[[:space:]])\./fn[[:space:]]+run[[:space:]]+'; then
|
||||
TOOL_USED="fn_cli_run"
|
||||
FN_ID=$(printf '%s' "$CMD" | sed -nE 's/.*\.\/fn[[:space:]]+run[[:space:]]+([A-Za-z0-9_]+).*/\1/p' | head -n1)
|
||||
elif printf '%s' "$CMD" | grep -qE 'python/\.venv/bin/python3[[:space:]]+-[[:space:]]+<<'; then
|
||||
TOOL_USED="heredoc_py"
|
||||
elif printf '%s' "$CMD" | grep -qE 'sqlite3[[:space:]][^|]*\bregistry\.db\b'; then
|
||||
TOOL_USED="sqlite_direct"
|
||||
fi
|
||||
|
||||
insert_call "$FN_ID" "$TOOL_USED" 0 "$CMD_HEAD"
|
||||
|
||||
# ---- Violation rules ----
|
||||
# 1. sqlite3 directo SELECT sobre registry.db (excepto schema/pragma/count/join)
|
||||
if [ "$TOOL_USED" = "sqlite_direct" ]; then
|
||||
if ! printf '%s' "$CMD" | grep -qiE '(\.schema|\.tables|PRAGMA[[:space:]]+(table_info|index_list)|COUNT\(|GROUP[[:space:]]+BY|JOIN[[:space:]])'; then
|
||||
insert_violation "sqlite3_registry_select" "" "$CMD_HEAD" "warning"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 2. python -c "import X; dir(X)"
|
||||
if printf '%s' "$CMD" | grep -qE 'python[3]?[[:space:]]+-c[[:space:]]+["'\''].*import.*(dir|help)\('; then
|
||||
insert_violation "python_dir_inspect" "" "$CMD_HEAD" "info"
|
||||
fi
|
||||
|
||||
# 3. from <pkg> import * (en heredoc python)
|
||||
if [ "$TOOL_USED" = "heredoc_py" ]; then
|
||||
if printf '%s' "$CMD" | grep -qE 'from[[:space:]]+[A-Za-z0-9_.]+[[:space:]]+import[[:space:]]+\*'; then
|
||||
insert_violation "import_star_in_heredoc" "" "$CMD_HEAD" "warning"
|
||||
fi
|
||||
if printf '%s' "$CMD" | grep -qE 'client\._http\.request\('; then
|
||||
insert_violation "client_http_request_direct" "" "$CMD_HEAD" "warning"
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
||||
Executable
+121
@@ -0,0 +1,121 @@
|
||||
#!/usr/bin/env bash
|
||||
# UserPromptSubmit hook: inyecta capacidades calientes (TOP/FRESH/PIPELINES)
|
||||
# del registry como additionalContext en cada turno del usuario.
|
||||
#
|
||||
# Cache: ~/.cache/fn_registry/capabilities.txt (TTL 1h).
|
||||
# Fuente: `./fn doctor capabilities --emit-claude-md` desde la raiz del repo.
|
||||
#
|
||||
# NUNCA bloquea: si algo falla, emite contexto vacio y sale 0.
|
||||
|
||||
set -uo pipefail
|
||||
|
||||
CACHE_DIR="${HOME}/.cache/fn_registry"
|
||||
CACHE_FILE="${CACHE_DIR}/capabilities.txt"
|
||||
TTL_SECONDS=3600
|
||||
|
||||
# Resolve registry root (walks up from cwd, fallback CLAUDE_PROJECT_DIR)
|
||||
resolve_root() {
|
||||
local d="${PWD}"
|
||||
while [ "$d" != "/" ]; do
|
||||
if [ -f "$d/registry.db" ] && [ -x "$d/fn" ]; then
|
||||
printf '%s' "$d"
|
||||
return 0
|
||||
fi
|
||||
d=$(dirname "$d")
|
||||
done
|
||||
if [ -n "${CLAUDE_PROJECT_DIR:-}" ] && [ -f "${CLAUDE_PROJECT_DIR}/registry.db" ]; then
|
||||
printf '%s' "${CLAUDE_PROJECT_DIR}"
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
# Consume stdin (UserPromptSubmit payload) — we don't need it but keep stdin clean
|
||||
cat >/dev/null 2>&1 || true
|
||||
|
||||
ROOT=$(resolve_root) || exit 0
|
||||
mkdir -p "$CACHE_DIR" 2>/dev/null || exit 0
|
||||
|
||||
# Cache freshness check
|
||||
need_refresh=1
|
||||
if [ -f "$CACHE_FILE" ]; then
|
||||
now=$(date +%s)
|
||||
mtime=$(stat -c %Y "$CACHE_FILE" 2>/dev/null || stat -f %m "$CACHE_FILE" 2>/dev/null || echo 0)
|
||||
age=$((now - mtime))
|
||||
if [ "$age" -lt "$TTL_SECONDS" ]; then
|
||||
need_refresh=0
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$need_refresh" -eq 1 ]; then
|
||||
# Regenerate: call fn doctor capabilities --emit-claude-md and process
|
||||
raw=$("$ROOT/fn" doctor capabilities --emit-claude-md 2>/dev/null || true)
|
||||
if [ -z "$raw" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Extract top 5 from each section using awk.
|
||||
# Sections detected by "## ... Top" / "## ... Fresh" / "## ... Pipelines".
|
||||
line=$(printf '%s\n' "$raw" | awk '
|
||||
BEGIN { sec=""; n_top=0; n_fresh=0; n_pipe=0; }
|
||||
/^## .*Top 20/ { sec="TOP"; next }
|
||||
/^## .*Fresh/ { sec="FRESH"; next }
|
||||
/^## .*Pipelines/ { sec="PIPE"; next }
|
||||
/^## / { sec=""; next }
|
||||
/^- `/ {
|
||||
# extract first backticked token
|
||||
s = $0
|
||||
sub(/^- `/, "", s)
|
||||
i = index(s, "`")
|
||||
if (i == 0) next
|
||||
id = substr(s, 1, i-1)
|
||||
if (sec == "TOP" && n_top < 5) { tops[n_top++] = id }
|
||||
if (sec == "FRESH" && n_fresh < 5) { fresh[n_fresh++] = id }
|
||||
if (sec == "PIPE" && n_pipe < 5) { pipes[n_pipe++] = id }
|
||||
}
|
||||
END {
|
||||
out = "CAPABILITIES (cache 1h):"
|
||||
if (n_top > 0) {
|
||||
line = " TOP: " tops[0]
|
||||
for (i=1; i<n_top; i++) line = line ", " tops[i]
|
||||
out = out "\n" line
|
||||
}
|
||||
if (n_fresh > 0) {
|
||||
line = " FRESH (7d): " fresh[0]
|
||||
for (i=1; i<n_fresh; i++) line = line ", " fresh[i]
|
||||
out = out "\n" line
|
||||
}
|
||||
if (n_pipe > 0) {
|
||||
line = " PIPELINES: " pipes[0]
|
||||
for (i=1; i<n_pipe; i++) line = line ", " pipes[i]
|
||||
out = out "\n" line
|
||||
}
|
||||
print out
|
||||
}
|
||||
')
|
||||
|
||||
if [ -z "$line" ]; then
|
||||
exit 0
|
||||
fi
|
||||
printf '%s\n' "$line" >"$CACHE_FILE" 2>/dev/null || exit 0
|
||||
fi
|
||||
|
||||
# Emit cached content as additionalContext
|
||||
if [ ! -s "$CACHE_FILE" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
ctx=$(cat "$CACHE_FILE")
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
jq -n --arg ctx "$ctx" '{
|
||||
hookSpecificOutput: {
|
||||
hookEventName: "UserPromptSubmit",
|
||||
additionalContext: $ctx
|
||||
}
|
||||
}'
|
||||
else
|
||||
# Fallback: print raw text (Claude Code prints stdout as context too)
|
||||
printf '%s\n' "$ctx"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Executable
+107
@@ -0,0 +1,107 @@
|
||||
#!/usr/bin/env bash
|
||||
# PostToolUse hook: gate "tag de capability group obligatorio" tras crear/modificar
|
||||
# funciones del registry. Issue 0086 paso 9/gate.
|
||||
#
|
||||
# Comportamiento:
|
||||
# - Detecta .md de funciones (functions/, python/functions/, bash/functions/,
|
||||
# frontend/functions/, cpp/functions/) modificados en los ultimos 60s.
|
||||
# - Lee frontmatter `tags:` y verifica si al menos uno coincide con un capability
|
||||
# group declarado en docs/capabilities/INDEX.md.
|
||||
# - Si NO hay match -> emite additionalContext con la lista de funciones afectadas.
|
||||
# - NUNCA bloquea. Solo warning visible.
|
||||
#
|
||||
# Salida JSON consumida por Claude Code:
|
||||
# { "hookSpecificOutput": { "hookEventName": "PostToolUse",
|
||||
# "additionalContext": "..." } }
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
resolve_root() {
|
||||
local d="${PWD}"
|
||||
while [ "$d" != "/" ]; do
|
||||
if [ -f "$d/registry.db" ]; then
|
||||
printf '%s' "$d"
|
||||
return 0
|
||||
fi
|
||||
d=$(dirname "$d")
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
ROOT=$(resolve_root) || exit 0
|
||||
INDEX="$ROOT/docs/capabilities/INDEX.md"
|
||||
|
||||
# Si no existe el INDEX aun, no hay grupos definidos -> nada que verificar.
|
||||
[ -f "$INDEX" ] || exit 0
|
||||
|
||||
# Consume stdin (sin parsear — no necesitamos session_id para este gate)
|
||||
cat >/dev/null
|
||||
|
||||
# Solo correr si hay jq disponible
|
||||
command -v jq >/dev/null 2>&1 || exit 0
|
||||
|
||||
# 1. Cargar lista de capability groups desde el INDEX.
|
||||
# Formato esperado en INDEX.md: | [name](name.md) | N | descripcion |
|
||||
CAP_GROUPS=$(grep -oE '\[[a-z][a-z0-9_-]*\]\([a-z][a-z0-9_-]*\.md\)' "$INDEX" \
|
||||
| sed -E 's/^\[([^]]+)\].*/\1/' \
|
||||
| sort -u)
|
||||
|
||||
[ -z "$CAP_GROUPS" ] && exit 0
|
||||
|
||||
# 2. Encontrar .md de funciones modificados en ultimos 60s.
|
||||
RECENT=$(find "$ROOT/functions" "$ROOT/python/functions" "$ROOT/bash/functions" \
|
||||
"$ROOT/frontend/functions" "$ROOT/cpp/functions" \
|
||||
-maxdepth 4 -type f -name '*.md' -mmin -1 2>/dev/null || true)
|
||||
|
||||
[ -z "$RECENT" ] && exit 0
|
||||
|
||||
# 3. Para cada .md reciente: extraer tags del frontmatter, comparar con groups.
|
||||
MISSING=""
|
||||
while IFS= read -r mdfile; do
|
||||
[ -z "$mdfile" ] && continue
|
||||
# Extrae el bloque entre los dos `---` del inicio
|
||||
front=$(awk '/^---$/{c++; next} c==1 {print} c>=2 {exit}' "$mdfile" 2>/dev/null || true)
|
||||
[ -z "$front" ] && continue
|
||||
|
||||
# tags: [a, b, c] o tags:\n - a\n - b
|
||||
tags_inline=$( { printf '%s\n' "$front" | grep -E '^tags:[[:space:]]*\[' | head -1 \
|
||||
| sed -E 's/^tags:[[:space:]]*\[(.*)\].*$/\1/' \
|
||||
| tr ',' '\n' | sed -E 's/^[[:space:]"]+|[[:space:]"]+$//g'; } || true )
|
||||
|
||||
tags_block=$( { printf '%s\n' "$front" | awk '
|
||||
/^tags:[[:space:]]*$/ {intag=1; next}
|
||||
intag && /^[[:space:]]*-[[:space:]]/ {sub(/^[[:space:]]*-[[:space:]]*/, ""); print; next}
|
||||
intag && !/^[[:space:]]/ {intag=0}
|
||||
' | sed -E 's/^[[:space:]"]+|[[:space:]"]+$//g'; } || true )
|
||||
|
||||
tags=$( { printf '%s\n%s\n' "$tags_inline" "$tags_block" | grep -v '^$'; } || true )
|
||||
|
||||
matched=0
|
||||
while IFS= read -r g; do
|
||||
[ -z "$g" ] && continue
|
||||
if printf '%s\n' "$tags" | grep -qx "$g"; then
|
||||
matched=1
|
||||
break
|
||||
fi
|
||||
done <<< "$CAP_GROUPS"
|
||||
|
||||
if [ "$matched" -eq 0 ]; then
|
||||
rel="${mdfile#$ROOT/}"
|
||||
MISSING="${MISSING}${rel}\n"
|
||||
fi
|
||||
done <<< "$RECENT"
|
||||
|
||||
# 4. Si hay funciones sin tag de grupo, emitir aviso.
|
||||
if [ -n "$MISSING" ]; then
|
||||
CAP_GROUPS_CSV=$(printf '%s' "$CAP_GROUPS" | tr '\n' ',' | sed 's/,$//')
|
||||
WARN="CAPABILITY-GAP (issue 0086): funcion(es) recien tocada(s) sin tag de capability group: $(printf '%b' "$MISSING" | tr '\n' ' ')"
|
||||
WARN+="| Grupos disponibles: ${CAP_GROUPS_CSV}. Anade al menos uno al frontmatter \`tags:\` y corre \`./fn index\`. Si la funcion no encaja en ningun grupo existente, considera crear grupo nuevo (>=3 funciones) o dejarla con tag plano (no de grupo)."
|
||||
jq -n --arg ctx "$WARN" '{
|
||||
hookSpecificOutput: {
|
||||
hookEventName: "PostToolUse",
|
||||
additionalContext: $ctx
|
||||
}
|
||||
}'
|
||||
fi
|
||||
|
||||
exit 0
|
||||
Executable
+133
@@ -0,0 +1,133 @@
|
||||
#!/usr/bin/env bash
|
||||
# PreToolUse hook: sugiere funciones del registry cuando un comando Bash
|
||||
# inline probablemente reinventa una funcion existente (issue 0087).
|
||||
#
|
||||
# Llama a `./fn match "<cmd>"` con timeout 200ms. Si encaja con alta
|
||||
# confianza, imprime un <system-reminder> a stderr para que Claude Code
|
||||
# lo lea como recordatorio. NUNCA bloquea la tool — exit 0 siempre.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# ---- Always exit 0, no matter what ----
|
||||
trap 'exit 0' ERR
|
||||
|
||||
# ---- Resolve registry root (walks up from cwd) ----
|
||||
resolve_root() {
|
||||
local d="${PWD}"
|
||||
while [ "$d" != "/" ]; do
|
||||
if [ -f "$d/registry.db" ]; then
|
||||
printf '%s' "$d"
|
||||
return 0
|
||||
fi
|
||||
d=$(dirname "$d")
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
ROOT=$(resolve_root) || exit 0
|
||||
FN_BIN="$ROOT/fn"
|
||||
[ -x "$FN_BIN" ] || exit 0
|
||||
|
||||
# ---- Read stdin JSON ----
|
||||
command -v jq >/dev/null 2>&1 || exit 0
|
||||
INPUT=$(cat)
|
||||
[ -z "$INPUT" ] && exit 0
|
||||
|
||||
TOOL_NAME=$(printf '%s' "$INPUT" | jq -r '.tool_name // ""' 2>/dev/null || echo "")
|
||||
[ "$TOOL_NAME" = "Bash" ] || exit 0
|
||||
|
||||
CMD=$(printf '%s' "$INPUT" | jq -r '.tool_input.command // ""' 2>/dev/null || echo "")
|
||||
[ -z "$CMD" ] && exit 0
|
||||
|
||||
# Single-line for matching against denylist patterns
|
||||
CMD_FLAT=$(printf '%s' "$CMD" | tr '\n' ' ')
|
||||
|
||||
# ---- Denylist (skip antes de llamar fn match para ahorrar el invoke) ----
|
||||
|
||||
# Comandos demasiado cortos -> trivial
|
||||
CMD_LEN=${#CMD_FLAT}
|
||||
[ "$CMD_LEN" -lt 20 ] && exit 0
|
||||
|
||||
# Trivial single-utility commands
|
||||
case "$CMD_FLAT" in
|
||||
"ls"|"ls "*|"cd"|"cd "*|"pwd"|"pwd "*|"cat"|"cat "*|"echo"|"echo "*)
|
||||
exit 0 ;;
|
||||
"grep"|"grep "*|"head"|"head "*|"tail"|"tail "*|"wc"|"wc "*)
|
||||
exit 0 ;;
|
||||
"mkdir"|"mkdir "*|"rm"|"rm "*|"mv"|"mv "*|"cp"|"cp "*)
|
||||
exit 0 ;;
|
||||
"git"|"git "*)
|
||||
exit 0 ;;
|
||||
"go"|"go "*)
|
||||
# go build / go test corrientes — el agente ya los maneja
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
# Comandos que ya usan el registry: ./fn ..., fn run ..., mcp__registry__*
|
||||
if printf '%s' "$CMD_FLAT" | grep -qE '(^|[[:space:]])\./fn([[:space:]]|$)'; then
|
||||
exit 0
|
||||
fi
|
||||
if printf '%s' "$CMD_FLAT" | grep -qE '(^|[[:space:]])fn[[:space:]]+(run|search|show|code|uses|doctor|index|match|list|add|proposal|sync|ops|check)'; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Pure-cd (movement only, no logic)
|
||||
if printf '%s' "$CMD_FLAT" | grep -qE '^[[:space:]]*cd[[:space:]]+[^&|;]+$'; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# ---- Llamar fn match con timeout 200ms ----
|
||||
command -v timeout >/dev/null 2>&1 || exit 0
|
||||
|
||||
# Truncar el comando a algo razonable para fn match (evitar args huge)
|
||||
CMD_TRUNC=$(printf '%s' "$CMD_FLAT" | head -c 500)
|
||||
|
||||
MATCH_JSON=$(timeout 0.2 "$FN_BIN" match "$CMD_TRUNC" --format json --top 3 2>/dev/null) || exit 0
|
||||
[ -z "$MATCH_JSON" ] && exit 0
|
||||
|
||||
# ---- Parsear JSON ----
|
||||
HIGH_CONF=$(printf '%s' "$MATCH_JSON" | jq -r '.high_confidence // false' 2>/dev/null || echo "false")
|
||||
TOP_ID=$(printf '%s' "$MATCH_JSON" | jq -r '.top[0].id // ""' 2>/dev/null || echo "")
|
||||
TOP_SCORE=$(printf '%s' "$MATCH_JSON" | jq -r '.top[0].score // 0' 2>/dev/null || echo "0")
|
||||
TOP_SIG=$(printf '%s' "$MATCH_JSON" | jq -r '.top[0].signature // ""' 2>/dev/null || echo "")
|
||||
TOP_SNIP=$(printf '%s' "$MATCH_JSON" | jq -r '.top[0].snippet // ""' 2>/dev/null || echo "")
|
||||
|
||||
[ -z "$TOP_ID" ] && exit 0
|
||||
|
||||
# Trigger condition: (high_confidence==true OR score>=0.85) AND score>=0.6
|
||||
# - high_confidence requires top1/top2 gap > 1.5 (set por fn match)
|
||||
# - score>=0.85 cubre matches muy fuertes donde el gap es modesto
|
||||
SCORE_HI=$(awk -v s="$TOP_SCORE" 'BEGIN{ print (s+0 >= 0.85) ? "1" : "0" }')
|
||||
SCORE_MIN=$(awk -v s="$TOP_SCORE" 'BEGIN{ print (s+0 >= 0.6) ? "1" : "0" }')
|
||||
|
||||
[ "$SCORE_MIN" = "1" ] || exit 0
|
||||
if [ "$HIGH_CONF" != "true" ] && [ "$SCORE_HI" != "1" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Truncar snippet a 100 chars y limpiar saltos de linea
|
||||
SNIP_SHORT=$(printf '%s' "$TOP_SNIP" | tr '\n' ' ' | head -c 100)
|
||||
|
||||
# Formatear score con 2 decimales
|
||||
SCORE_FMT=$(awk -v s="$TOP_SCORE" 'BEGIN{ printf "%.2f", s+0 }')
|
||||
|
||||
# ---- Emitir <system-reminder> a stderr ----
|
||||
cat >&2 <<EOF
|
||||
<system-reminder>FUZZY-MATCH (issue 0087): your Bash command may already be a function.
|
||||
USE: ./fn run $TOP_ID -> $TOP_SIG
|
||||
SNIPPET: $SNIP_SHORT
|
||||
Confidence: $SCORE_FMT. If you proceed inline, the violation will be logged.
|
||||
</system-reminder>
|
||||
EOF
|
||||
|
||||
exit 0
|
||||
|
||||
# Test manual:
|
||||
# echo '{"tool_name":"Bash","tool_input":{"command":"taskkill.exe /IM registry_dashboard.exe /F"},"session_id":"test"}' \
|
||||
# | bash .claude/scripts/hook_fn_match.sh
|
||||
#
|
||||
# Casos silenciosos:
|
||||
# echo '{"tool_name":"Bash","tool_input":{"command":"ls -la"},"session_id":"test"}' \
|
||||
# | bash .claude/scripts/hook_fn_match.sh
|
||||
# echo '{"tool_name":"Bash","tool_input":{"command":"./fn run filter_slice_go_core 1 2 3"},"session_id":"test"}' \
|
||||
# | bash .claude/scripts/hook_fn_match.sh
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env bash
|
||||
# UserPromptSubmit hook: recordatorio compacto de patrones canonicos del registry.
|
||||
# Inyectado como additionalContext en cada turno del usuario.
|
||||
# Issue 0085 (hardening 2).
|
||||
#
|
||||
# NUNCA bloquea. Solo printf de additionalContext.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Resolve registry root (walks up from cwd)
|
||||
resolve_root() {
|
||||
local d="${PWD}"
|
||||
while [ "$d" != "/" ]; do
|
||||
if [ -f "$d/registry.db" ]; then
|
||||
printf '%s' "$d"
|
||||
return 0
|
||||
fi
|
||||
d=$(dirname "$d")
|
||||
done
|
||||
return 1
|
||||
}
|
||||
|
||||
ROOT=$(resolve_root) || exit 0
|
||||
|
||||
# Read input, extract session_id (UserPromptSubmit payload includes it)
|
||||
INPUT=$(cat)
|
||||
SESSION_ID=""
|
||||
if command -v jq >/dev/null 2>&1; then
|
||||
SESSION_ID=$(printf '%s' "$INPUT" | jq -r '.session_id // ""' 2>/dev/null || true)
|
||||
fi
|
||||
|
||||
# Count current pending proposals + recent violations for situational awareness
|
||||
PROPOSALS_PENDING="?"
|
||||
VIOLATIONS_24H="?"
|
||||
CALLS_24H="?"
|
||||
CAP_CREATED=0
|
||||
CAP_USED=0
|
||||
CAP_ORPHAN=0
|
||||
|
||||
if command -v sqlite3 >/dev/null 2>&1; then
|
||||
REG="$ROOT/registry.db"
|
||||
MON="$ROOT/projects/fn_monitoring/apps/call_monitor/operations.db"
|
||||
[ -f "$REG" ] && PROPOSALS_PENDING=$(sqlite3 "$REG" "SELECT COUNT(*) FROM proposals WHERE status='pending'" 2>/dev/null || echo "?")
|
||||
if [ -f "$MON" ]; then
|
||||
VIOLATIONS_24H=$(sqlite3 "$MON" "SELECT COUNT(*) FROM violations WHERE ts >= CAST(strftime('%s','now','-1 day') AS INTEGER)" 2>/dev/null || echo "?")
|
||||
CALLS_24H=$(sqlite3 "$MON" "SELECT COUNT(*) FROM calls WHERE ts >= CAST(strftime('%s','now','-1 day') AS INTEGER)" 2>/dev/null || echo "?")
|
||||
if [ -n "$SESSION_ID" ]; then
|
||||
sid_esc=$(printf '%s' "$SESSION_ID" | sed "s/'/''/g")
|
||||
CAP_CREATED=$(sqlite3 "$MON" "SELECT COUNT(*) FROM session_capability_growth WHERE session_id='$sid_esc'" 2>/dev/null || echo 0)
|
||||
CAP_USED=$(sqlite3 "$MON" "SELECT COUNT(*) FROM session_capability_growth WHERE session_id='$sid_esc' AND calls_in_session>0" 2>/dev/null || echo 0)
|
||||
CAP_ORPHAN=$(sqlite3 "$MON" "SELECT COUNT(*) FROM session_capability_growth WHERE session_id='$sid_esc' AND calls_in_session=0" 2>/dev/null || echo 0)
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
REMINDER="REGISTRY-FIRST (issue 0085 telemetry active): "
|
||||
REMINDER+="Inspect → mcp__registry__fn_search/show/code/uses/proposal. "
|
||||
REMINDER+="Execute one fn → mcp__registry__fn_run or ./fn run. "
|
||||
REMINDER+="Compose multi-fn → heredoc python IMPORTANDO del registry. "
|
||||
REMINDER+="NUNCA sqlite3 registry.db directo (salvo schema/PRAGMA/COUNT/JOIN). "
|
||||
REMINDER+="NUNCA reescribir inline logica que ya es funcion. "
|
||||
REMINDER+="Si patron se repite >2x → propose nueva funcion via fn-constructor. "
|
||||
REMINDER+="Estado: pending_proposals=${PROPOSALS_PENDING} violations_24h=${VIOLATIONS_24H} calls_24h=${CALLS_24H}. "
|
||||
REMINDER+="CAPABILITY-GROWTH (issue 0086): created_this_session=${CAP_CREATED} used=${CAP_USED} orphan=${CAP_ORPHAN}. Si orphan>0 -> integra la funcion en el codigo o documenta por que se quedo huerfana. "
|
||||
REMINDER+="Comando autocheck: /fn_claude."
|
||||
|
||||
jq -n --arg ctx "$REMINDER" '{
|
||||
hookSpecificOutput: {
|
||||
hookEventName: "UserPromptSubmit",
|
||||
additionalContext: $ctx
|
||||
}
|
||||
}'
|
||||
@@ -14,3 +14,9 @@
|
||||
[submodule "cpp/vendor/implot3d"]
|
||||
path = cpp/vendor/implot3d
|
||||
url = https://github.com/brenocq/implot3d.git
|
||||
[submodule "cpp/vendor/sdl3"]
|
||||
path = cpp/vendor/sdl3
|
||||
url = https://github.com/libsdl-org/SDL.git
|
||||
[submodule "emsdk"]
|
||||
path = emsdk
|
||||
url = https://github.com/emscripten-core/emsdk.git
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
{
|
||||
"mcpServers": {
|
||||
"registry": {
|
||||
"command": "/home/lucas/fn_registry/apps/registry_mcp/registry_mcp",
|
||||
"args": ["--enable-run", "--enable-write"],
|
||||
"env": {
|
||||
"FN_REGISTRY_ROOT": "/home/lucas/fn_registry"
|
||||
}
|
||||
"command": "./apps/registry_mcp/registry_mcp",
|
||||
"args": ["--enable-run", "--enable-write"]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,44 @@ Para contexto detallado del trabajo diario ver `docs/diary/`. Para decisiones ar
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
## 2026-05-14
|
||||
|
||||
### Added
|
||||
|
||||
- **Issue 0086 — Monitor tab del `registry_dashboard`** (sub-repo `dataforge/registry_dashboard`). Pestaña `Monitor` primera y por defecto del TabBar, landing del bucle reactivo construir->ejecutar->recopilar->analizar->mejorar.
|
||||
- 7 KPIs (Calls / MCP / Reg % / Errors / Violations / Copies / Versions) filtradas por ventana temporal (1h/24h/7d/30d/All).
|
||||
- Sub-tab `Recent Executions` con columnas When/Function/Tool/ms/OK/Error. Columna Function muestra `$ <snippet>` en gris cuando `function_id` vacio, hover tooltip con comando completo. Checkbox `Only registry functions` filtra por `function_id != ''`.
|
||||
- Sub-tab `Failed Functions` (5a) — subset filtrado a registry-functions fallidas, columnas When/Function/Tool/Error class/Error snippet, function_id en rojo.
|
||||
- Live scatter `duracion (ms)` vs `time`: eje X auto-scroll a `now`, ventana configurable (1m/5m/15m/1h/6h) independiente del filtro de KPIs, eje Y dinamico `0..max(visible)+500ms`. Hora local (`UseLocalTime`). Series ok/error en verde/rojo. Hover sobre punto = tooltip Function/Tool/Duration/Error.
|
||||
- Indicador `live`/`offline` con timestamp del ultimo evento WS.
|
||||
- **WebSocket live stream sqlite_api -> registry_dashboard** (sub-repo `dataforge/sqlite_api`). Endpoint `GET /api/events/call_monitor`. Hub global con subscribers; ticker arranca solo con >=1 subscriber (cero overhead si nadie mira). Cliente recibe snapshot inicial (KPIs + 100 ultimas filas + watermark) y luego deltas `id > watermark`. Cliente puede mandar `{watermark: N}` para resumir tras reconexion.
|
||||
- **WS client C++** hand-rolled RFC6455 en `ws_client.{h,cpp}` (~330 LOC) en el dashboard. Localhost-only (no TLS). Thread propio, reconnect exponencial 0.5s->8s, FIN/text/ping/pong/close handling, queue thread-safe drenada cada frame.
|
||||
- **Migration 007 `command_snippet` en `calls`** (`projects/fn_monitoring/apps/call_monitor/migrations/007_calls_command_snippet.sql`). Aditiva, idempotente. Llena por hook `hook_call_monitor.sh` solo cuando `function_id == ''`. Redactado de `password=`/`token=`/`secret=`/`api_key=`/`bearer=`. Truncado 200 chars.
|
||||
- **Issue 0087 — Capability Discovery Acceleration**. Modelo 5 capas + 7 piezas (ver `dev/issues/0087-*.md`).
|
||||
- **`fn match`** (`cmd/fn/match.go`) — subcommand fuzzy-FTS5 que dado un comando devuelve top-N funciones del registry candidates. Latencia 6-7ms. Output JSON con `score` (normalizado top=1.0) + `raw_score` (absoluto pre-normalizacion) + `high_confidence` gate (`raw_score >= 4.0 AND top1.raw/top2.raw > 1.5`).
|
||||
- **`fn doctor capabilities --emit-claude-md`** (`cmd/fn/doctor.go` + `functions/infra/emit_capabilities_md.go`) — emite bloque markdown con secciones TOP 20 (por `calls_total`), Fresh 7d, Pipelines top 5. Fallback si `call_monitor.operations.db` ausente.
|
||||
- **`call_monitor sequences --detect [--propose]`** (`projects/fn_monitoring/apps/call_monitor/sequences.go` + `migrations/006_function_sequences.sql`). Detecta secuencias A->B(->C) en `calls` (same session, gap < 30s, occ >= 5, sess >= 2, success_rate >= 0.9) y abre proposals `new_pipeline` automaticamente.
|
||||
- **Hook `PreToolUse` `hook_fn_match.sh`** — denylist + `fn match` con timeout 0.2s. Inyecta `<system-reminder>FUZZY-MATCH: USE ./fn run <id>` cuando confidence alta. Latencia 113ms trigger / 32ms denylist. Registrado en `.claude/settings.local.json` (Bash matcher).
|
||||
- **Hook `UserPromptSubmit` `hook_capabilities_inject.sh`** — cache 1h en `~/.cache/fn_registry/capabilities.txt`. Emite JSON `hookSpecificOutput.additionalContext` con linea compacta `CAPABILITIES: TOP / FRESH / PIPELINES`. Latencia cold 33ms / warm 18ms.
|
||||
- **Timer systemd user** `call_monitor_sequences.timer` (OnCalendar 0/6h) + `.service` oneshot ejecutando `call_monitor sequences --detect --propose --report`. Versionado en `projects/fn_monitoring/apps/call_monitor/systemd/`.
|
||||
- **3 funciones nuevas grupo `cpp-windows`** + pagina madre `docs/capabilities/cpp-windows.md`:
|
||||
- `launch_cpp_app_windows_bash_infra` — `cmd.exe`/`PowerShell Start-Process` para lanzar exe en Windows desde WSL2.
|
||||
- `is_cpp_app_running_windows_bash_infra` — `tasklist.exe /FI` con exit code 0/1 + stdout `RUNNING: PID=N MEM=K` o `NOT_RUNNING`.
|
||||
- `redeploy_cpp_app_windows_bash_pipelines` — pipeline build? + deploy + launch + verify en 1 invocacion. Reemplaza ~6 commands manuales.
|
||||
- **ADR 0004 `docs/adr/0004-telemetry-driven-capability-growth.md`** — formaliza el bucle telemetria -> proposal -> capability group -> discovery acceleration como motor de crecimiento del registry.
|
||||
- **Regla `.claude/rules/function_growth_and_self_docs.md`** (entry #30 en `INDEX.md`) — contrato `.md` autosuficiente (Ejemplo + Cuando usarla + Gotchas + Growth log) + crecimiento del registry por promocion de composiciones, NO por inflado de funciones individuales.
|
||||
|
||||
### Changed
|
||||
|
||||
- **`.claude/CLAUDE.md` Norte ampliado** — 4o objetivo `PROMOVER COMPOSICIONES A PIPELINES` (el registry crece por composicion, no por inflado). Linea sobre auto-discovery zero-second-lookup.
|
||||
- **`.claude/rules/registry_calls.md`** — clausula nueva: hooks e infraestructura de telemetria (`fn_match`, `fn doctor`, `call_monitor`) pueden leer `registry.db` directo con conexion read-only. NO sujeto a regla MCP-first (no son acciones del agente).
|
||||
- **`/fn_claude` command** mejorado con objetivos del Monitor + interpretacion de `FUZZY-MATCH` hint + `CAPABILITIES` line + threshold semantica.
|
||||
|
||||
### Fixed
|
||||
|
||||
- **`launch_cpp_app_windows` quoting bug** — `cmd.exe /c "cd /d \"$dir\" && start ..."` rompia con paths Windows (el `\"` final se interpretaba como escape de comilla -> string sin cerrar -> "Windows cannot find \\"). Fix: reescribir a `powershell.exe -Command "Start-Process -FilePath ... -WorkingDirectory ..."` (single-quote PowerShell es literal, sin procesar `\` ni `$`).
|
||||
- **`fn match high_confidence` siempre true** — debido a normalizacion `top=1.0`. Fix: añadir `raw_score` preservado pre-normalizacion + gate dual `raw_score >= 4.0 AND top1.raw/top2.raw > 1.5`. Threshold 4.0 tuneado contra 14 patrones del analysis `domain_coverage_gaps` (~93% precision).
|
||||
|
||||
## 2026-05-07
|
||||
|
||||
### Added
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "analyze_dns(domain: string, mode: string) -> void"
|
||||
description: "Análisis DNS completo de un dominio: registros A/AAAA/MX/NS/TXT/CNAME/SOA, consulta whois y verificación contra listas negras DNSBL (spamhaus, spamcop, sorbs, barracuda)."
|
||||
tags: [bash, cybersecurity, dns, network, whois, dnsbl, reconnaissance]
|
||||
tags: [bash, cybersecurity, dns, network, whois, dnsbl, reconnaissance, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "audit_http_headers(url: string) -> void"
|
||||
description: "Audita las cabeceras HTTP de seguridad de una URL: verifica la presencia de HSTS (con validación de max-age mínimo de 6 meses), Content-Security-Policy, X-Frame-Options, X-Content-Type-Options, Referrer-Policy, Permissions-Policy y cabeceras CORS. También detecta cabeceras que exponen información del servidor."
|
||||
tags: [bash, cybersecurity, web, http, headers, security, hsts, csp, hardening]
|
||||
tags: [bash, cybersecurity, web, http, headers, security, hsts, csp, hardening, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "audit_ssh_config(config_path: string) -> void"
|
||||
description: "Audita la configuración de sshd_config evaluando parámetros de seguridad críticos (PermitRootLogin, PasswordAuthentication, Port, MaxAuthTries, X11Forwarding, AllowUsers). También revisa intentos de login fallidos en los logs y lista las claves autorizadas del usuario actual."
|
||||
tags: [bash, cybersecurity, ssh, audit, security, hardening, linux]
|
||||
tags: [bash, cybersecurity, ssh, audit, security, hardening, linux, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "check_firewall() -> void"
|
||||
description: "Detecta el firewall activo del sistema (ufw, firewalld o iptables) y muestra su estado, reglas activas y puertos en escucha para cruzar con las reglas. Si no se detecta ningún firewall, emite una advertencia de exposición."
|
||||
tags: [bash, cybersecurity, firewall, ufw, iptables, network, hardening, linux]
|
||||
tags: [bash, cybersecurity, firewall, ufw, iptables, network, hardening, linux, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "detect_suspicious_users() -> void"
|
||||
description: "Revisa el sistema en busca de indicadores de compromiso en cuentas de usuario: UIDs 0 extras (además de root), usuarios con shell de login válida, homes en rutas inusuales, miembros de grupos privilegiados (sudo, docker, wheel, adm, etc.) y sesiones activas."
|
||||
tags: [bash, cybersecurity, users, audit, linux, privilege-escalation, hardening]
|
||||
tags: [bash, cybersecurity, users, audit, linux, privilege-escalation, hardening, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "encrypt_file(mode: string, file: string) -> void"
|
||||
description: "Cifra o descifra un archivo usando AES-256-CBC con PBKDF2 (310.000 iteraciones) via openssl. La contraseña se lee de la variable de entorno ENCRYPT_PASSWORD o se solicita interactivamente. El archivo cifrado se guarda con extensión .enc; al descifrar se recupera el nombre original."
|
||||
tags: [bash, cybersecurity, encryption, aes256, openssl, crypto, pbkdf2]
|
||||
tags: [bash, cybersecurity, encryption, aes256, openssl, crypto, pbkdf2, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "enumerate_subdomains(domain: string, output_file: string) -> void"
|
||||
description: "Enumera subdominios de un dominio objetivo usando un diccionario integrado de ~100 subdominios comunes (www, mail, api, dev, admin, vpn, etc.). Detecta tanto registros A (IP directa) como CNAME. Muestra progreso cada 20 subdominios y opcionalmente guarda los resultados en un archivo."
|
||||
tags: [bash, cybersecurity, dns, subdomain, enumeration, reconnaissance, osint]
|
||||
tags: [bash, cybersecurity, dns, subdomain, enumeration, reconnaissance, osint, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "generate_password(mode: string, length: int, count: int) -> void"
|
||||
description: "Genera contraseñas seguras en cuatro modos: full (alfanumérico + símbolos, excluye caracteres ambiguos), alpha (solo alfanumérico), passphrase (palabras aleatorias unidas con guión) y pin (numérico). Calcula y muestra la entropía en bits para cada modo."
|
||||
tags: [bash, cybersecurity, password, generator, entropy, security, urandom]
|
||||
tags: [bash, cybersecurity, password, generator, entropy, security, urandom, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "geolocate_ip(target: string) -> void"
|
||||
description: "Geolocaliza una dirección IP o dominio usando la API pública de ip-api.com. Muestra país, región, ciudad, coordenadas, ISP, ASN y detecta VPN, Proxy o infraestructura de hosting."
|
||||
tags: [bash, cybersecurity, network, geoip, ip, osint, reconnaissance]
|
||||
tags: [bash, cybersecurity, network, geoip, ip, osint, reconnaissance, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "inspect_ssl_cert(host: string) -> void"
|
||||
description: "Inspecciona el certificado SSL/TLS de un host: muestra sujeto, emisor, fechas de validez, días hasta expiración, SANs (Subject Alternative Names), cadena de confianza completa y detecta soporte de versiones inseguras TLS 1.0/1.1."
|
||||
tags: [bash, cybersecurity, ssl, tls, certificate, web, openssl, security]
|
||||
tags: [bash, cybersecurity, ssl, tls, certificate, web, openssl, security, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "list_active_connections(mode: string) -> void"
|
||||
description: "Muestra conexiones de red activas del sistema usando ss: puertos en escucha, conexiones establecidas y detección de conexiones hacia IPs externas (excluye RFC1918, loopback y link-local)."
|
||||
tags: [bash, cybersecurity, network, connections, monitoring, ss, ports]
|
||||
tags: [bash, cybersecurity, network, connections, monitoring, ss, ports, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
scan_secrets_in_dirty() {
|
||||
local repo_dir="${1:-.}"
|
||||
|
||||
if [[ ! -d "$repo_dir/.git" ]]; then
|
||||
# Accept both regular repos (.git is a directory) and worktrees (.git is a
|
||||
# file containing "gitdir: ..." pointer).
|
||||
if [[ ! -d "$repo_dir/.git" && ! -f "$repo_dir/.git" ]]; then
|
||||
echo "scan_secrets_in_dirty: '$repo_dir' no es un repo git" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "verify_file_hash(file: string, algorithm: string, expected_hash: string) -> void"
|
||||
description: "Calcula el hash criptográfico de un archivo con el algoritmo especificado (md5, sha1, sha256, sha512) y opcionalmente lo compara con un hash esperado para verificar integridad. Retorna exit code 1 si los hashes no coinciden."
|
||||
tags: [bash, cybersecurity, hash, integrity, checksum, md5, sha256, sha512]
|
||||
tags: [bash, cybersecurity, hash, integrity, checksum, md5, sha256, sha512, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "analyze_disk_space([target_dir: string], [mode: string]) -> void"
|
||||
description: "Analiza el uso de espacio en disco. Modos: partitions (df con filtros), top-dirs (du top 10), top-files (find top 20), inodes (df -i), all (todos). Emite advertencias si el uso supera el 90%."
|
||||
tags: [bash, disk, space, analysis, filesystem]
|
||||
tags: [bash, disk, space, analysis, filesystem, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_app_clear([--serial <S>], package: string) -> void"
|
||||
description: "Wipe app data + cache via pm clear. App keeps installed but factory-state. Multi-emulator via --serial."
|
||||
tags: [android, adb, app, clear, reset]
|
||||
tags: [android, adb, app, clear, reset, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional target device/emulator serial. Auto-detected if omitted."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_app_info([--serial <S>], package, [--json]) -> stdout"
|
||||
description: "Inspect installed app: version, target SDK, activities via dumpsys package."
|
||||
tags: [android, adb, app, info, dumpsys]
|
||||
tags: [android, adb, app, info, dumpsys, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional ADB serial to target a specific device/emulator. Auto-detected if omitted."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_app_kill([--serial <S>], package: string) -> void"
|
||||
description: "Force-stop running app via am force-stop. Multi-emulator via --serial."
|
||||
tags: [android, adb, app, kill, force-stop]
|
||||
tags: [android, adb, app, kill, force-stop, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional target device/emulator serial. Auto-detected if omitted."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_app_launch([--serial <S>], package: string, [activity: string]) -> void"
|
||||
description: "Launch app activity via am start. Multi-emulator via --serial."
|
||||
tags: [android, adb, app, launch, activity]
|
||||
tags: [android, adb, app, launch, activity, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional target serial. Default: first device"
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_app_uninstall([--serial <S>] package [--keep-data]) -> void"
|
||||
description: "Uninstall app via adb uninstall. Optionally keep data with --keep-data."
|
||||
tags: [android, adb, app, uninstall]
|
||||
tags: [android, adb, app, uninstall, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional target device/emulator serial. Auto-detects first connected device if omitted."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_emu_battery([--serial <S>], level: int, [--charging <true|false>]) -> void"
|
||||
description: "Simulate battery state on emulator (level + charging). Emulator-only."
|
||||
tags: [android, emulator, battery, power]
|
||||
tags: [android, emulator, battery, power, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional emulator serial (e.g. emulator-5554). Auto-detected if omitted."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_emu_geo_fix([--serial <S>], longitude: string, latitude: string, [altitude: string]) -> void"
|
||||
description: "Fake GPS location on Android emulator via emu geo fix. Emulator-only (not physical devices)."
|
||||
tags: [android, emulator, geo, gps, location]
|
||||
tags: [android, emulator, geo, gps, location, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional emulator serial. Auto-detected if omitted."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_emu_rotate([--serial <S>] [portrait|landscape|0|90|180|270])"
|
||||
description: "Rotate emulator screen. Empty=toggle, or fixed orientation. Locks autorotate."
|
||||
tags: [android, emulator, rotation, orientation]
|
||||
tags: [android, emulator, rotation, orientation, pendiente-usar]
|
||||
uses_functions: [adb_wsl_bash_infra]
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_input_keyevent([--serial <S>] key: string)"
|
||||
description: "Send key event via adb shell input keyevent. Accepts aliases (BACK, HOME, POWER, ENTER, MENU, RECENT_APPS, VOLUME_UP, VOLUME_DOWN), raw numeric codes, or explicit KEYCODE_* names."
|
||||
tags: [android, adb, input, keyevent, ui-test]
|
||||
tags: [android, adb, input, keyevent, ui-test, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional target device/emulator serial. If omitted, adb_pick_serial resolves the single connected device."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_input_swipe([--serial <S>], x1: int, y1: int, x2: int, y2: int, [duration_ms: int])"
|
||||
description: "Send swipe gesture between two points with duration."
|
||||
tags: [android, adb, input, swipe, gesture, ui-test]
|
||||
tags: [android, adb, input, swipe, gesture, ui-test, pendiente-usar]
|
||||
uses_functions: [adb_wsl_bash_infra]
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_input_tap([--serial <S>], x: int, y: int) -> void"
|
||||
description: "Send tap gesture at screen coordinates via adb shell input tap."
|
||||
tags: [android, adb, input, tap, ui-test, gesture]
|
||||
tags: [android, adb, input, tap, ui-test, gesture, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional target device serial. Auto-detected if omitted."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_input_text([--serial <S>], text: string) -> void"
|
||||
description: "Type text in focused field via adb shell input text. Spaces handled."
|
||||
tags: [android, adb, input, text, ui-test]
|
||||
tags: [android, adb, input, text, ui-test, pendiente-usar]
|
||||
uses_functions: [adb_wsl_bash_infra]
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_pull [--serial <S>] remote_path local_path"
|
||||
description: "Pull file/dir from Android device to WSL via adb pull."
|
||||
tags: [android, adb, pull, file, transfer]
|
||||
tags: [android, adb, pull, file, transfer, pendiente-usar]
|
||||
uses_functions: [adb_wsl_bash_infra]
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_push([--serial <S>], local_path: string, remote_path: string) -> void"
|
||||
description: "Push file/dir from WSL to Android device via adb push."
|
||||
tags: [android, adb, push, file, transfer]
|
||||
tags: [android, adb, push, file, transfer, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional target device/emulator serial. Auto-detected if omitted."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_screen_record([--serial <S>] [--duration <s>] [--bit-rate <bps>] [--size <WxH>] output_path: string) -> void"
|
||||
description: "Record screen video via adb screenrecord, pulls to local path."
|
||||
tags: [android, adb, screen, record, video]
|
||||
tags: [android, adb, screen, record, video, pendiente-usar]
|
||||
uses_functions: [adb_wsl_bash_infra]
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_screenshot([--serial <S>], output_path: string) -> void"
|
||||
description: "Capture screen as PNG via adb exec-out screencap -p."
|
||||
tags: [android, adb, screenshot, screen, capture]
|
||||
tags: [android, adb, screenshot, screen, capture, pendiente-usar]
|
||||
uses_functions: [adb_wsl_bash_infra]
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "android_shell([--serial <S>], cmd ...args)"
|
||||
description: "Execute arbitrary shell command on Android device. Multi-emulator via --serial."
|
||||
tags: [android, adb, shell, exec]
|
||||
tags: [android, adb, shell, exec, pendiente-usar]
|
||||
params:
|
||||
- name: "--serial <S>"
|
||||
desc: "Optional target device serial. Omit to auto-pick (single device) or use ADB_SERIAL env."
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "append_diary_entry(titulo: string, cuerpo: string) -> string"
|
||||
description: "Añade una entrada al diario del dia en ${DIARY_DIR:-docs/diary}/YYYY-MM-DD.md. Crea el archivo con cabecera si no existe. Nunca reescribe contenido previo. Si cuerpo es vacio escribe solo el header de la seccion."
|
||||
tags: [diary, markdown, append, idempotent, infra]
|
||||
tags: [diary, markdown, append, idempotent, infra, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "build_cpp_linux(target?: string) -> void"
|
||||
description: "Compila las funciones y apps C++ del registry para Linux nativo usando cmake"
|
||||
tags: [cpp, build, cmake, linux, imgui]
|
||||
tags: [cpp, build, cmake, linux, imgui, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "build_cpp_windows(target?: string) -> void"
|
||||
description: "Cross-compila las funciones y apps C++ del registry para Windows usando mingw-w64"
|
||||
tags: [cpp, build, cmake, windows, cross-compile, mingw, imgui]
|
||||
tags: [cpp, build, cmake, windows, cross-compile, mingw, imgui, cpp-windows]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "0.1.0"
|
||||
purity: impure
|
||||
signature: "build_wasm_cpp_app(app_name: string, [--no-budget-check]) -> void"
|
||||
description: "Compila una app C++ del registry (cpp/apps/<name>) a WASM via emscripten. Sale build/wasm/<name>/<name>.{html,js,wasm,wasm.gz}. Falla si gzip > 2 MB."
|
||||
tags: [wasm, emscripten, cpp, build, gamedev]
|
||||
tags: [wasm, emscripten, cpp, build, gamedev, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
---
|
||||
name: cuda_toolkit_check
|
||||
kind: function
|
||||
lang: bash
|
||||
domain: infra
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "cuda_toolkit_check() -> void"
|
||||
description: "Detecta componentes CUDA instalados en el sistema y emite pares key=value a stdout: nvcc (version o missing), nvidia_smi (present/missing), driver_version, cuda_libs (path o missing) y overall (ok|partial|missing). Exit code 0 siempre — funcion informativa, no fatal."
|
||||
tags: [cuda, nvidia, gpu, hardware, probe, infra, toolkit, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: []
|
||||
params:
|
||||
- name: (ninguno)
|
||||
desc: "No toma parametros. Lee el estado del sistema via nvcc, nvidia-smi y busqueda en rutas canonicas de CUDA."
|
||||
output: "Cinco pares key=value en stdout: nvcc, nvidia_smi, driver_version, cuda_libs, overall. overall=ok si los tres componentes principales estan presentes; partial si algunos; missing si ninguno."
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "bash/functions/infra/cuda_toolkit_check.sh"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```bash
|
||||
source bash/functions/infra/cuda_toolkit_check.sh
|
||||
cuda_toolkit_check
|
||||
```
|
||||
|
||||
Salida en maquina con CUDA completo:
|
||||
```
|
||||
nvcc=12.4
|
||||
nvidia_smi=present
|
||||
driver_version=550.54.15
|
||||
cuda_libs=/usr/local/cuda
|
||||
overall=ok
|
||||
```
|
||||
|
||||
Salida en maquina sin CUDA:
|
||||
```
|
||||
nvcc=missing
|
||||
nvidia_smi=missing
|
||||
driver_version=missing
|
||||
cuda_libs=missing
|
||||
overall=missing
|
||||
```
|
||||
|
||||
Invocar directamente:
|
||||
```bash
|
||||
bash bash/functions/infra/cuda_toolkit_check.sh
|
||||
```
|
||||
|
||||
Parsear desde otro script:
|
||||
```bash
|
||||
eval "$(cuda_toolkit_check)"
|
||||
echo "CUDA overall: $overall"
|
||||
if [[ "$overall" == "ok" ]]; then
|
||||
echo "CUDA completo: nvcc=$nvcc driver=$driver_version libs=$cuda_libs"
|
||||
fi
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
- Idempotente: no instala, no modifica nada, solo consulta.
|
||||
- Exit code 0 siempre — ausencia de CUDA es informacion, no fallo.
|
||||
- Busca `libcuda.so` en `/usr/local/cuda*`, `/opt/cuda*` y via `ldconfig -p`.
|
||||
- `driver_version` refleja el driver NVIDIA del kernel, reportado por nvidia-smi.
|
||||
- `nvcc` reporta la version del compilador CUDA toolkit (puede diferir de la version soportada por el driver).
|
||||
- Para obtener la version CUDA maxima soportada por el driver, usar `get_gpu_info_go_infra` (campo CudaVersion del struct GpuInfo).
|
||||
@@ -0,0 +1,99 @@
|
||||
#!/usr/bin/env bash
|
||||
# cuda_toolkit_check — Detecta componentes CUDA instalados en el sistema.
|
||||
#
|
||||
# Emite pares key=value a stdout:
|
||||
# nvcc=<version|missing>
|
||||
# nvidia_smi=<present|missing>
|
||||
# driver_version=<version|missing>
|
||||
# cuda_libs=<path|missing>
|
||||
# overall=<ok|partial|missing>
|
||||
#
|
||||
# Exit code 0 siempre (funcion informativa, no fatal).
|
||||
# Idempotente: se puede invocar multiples veces sin efectos secundarios.
|
||||
|
||||
cuda_toolkit_check() {
|
||||
local nvcc_ver="missing"
|
||||
local nvidia_smi_status="missing"
|
||||
local driver_version="missing"
|
||||
local cuda_libs_path="missing"
|
||||
|
||||
# --- nvcc ---
|
||||
if command -v nvcc &>/dev/null; then
|
||||
# nvcc --version imprime algo como:
|
||||
# Cuda compilation tools, release 12.4, V12.4.131
|
||||
local raw
|
||||
raw="$(nvcc --version 2>&1)"
|
||||
# Extraer "12.4" de "release 12.4,"
|
||||
local ver
|
||||
ver="$(echo "$raw" | grep -oP 'release \K[0-9]+\.[0-9]+')"
|
||||
nvcc_ver="${ver:-present}"
|
||||
fi
|
||||
|
||||
# --- nvidia-smi + driver_version ---
|
||||
if command -v nvidia-smi &>/dev/null; then
|
||||
nvidia_smi_status="present"
|
||||
# nvidia-smi --query-gpu=driver_version --format=csv,noheader retorna la version
|
||||
local drv
|
||||
drv="$(nvidia-smi --query-gpu=driver_version --format=csv,noheader 2>/dev/null | head -n1 | tr -d ' ')"
|
||||
if [[ -n "$drv" ]]; then
|
||||
driver_version="$drv"
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- cuda_libs: buscar en rutas canonicas ---
|
||||
local search_dirs=(
|
||||
"/usr/local/cuda"
|
||||
"/usr/local/cuda-"*
|
||||
"/opt/cuda"
|
||||
"/opt/cuda-"*
|
||||
"/usr/lib/x86_64-linux-gnu/libcuda.so"*
|
||||
"/usr/lib/aarch64-linux-gnu/libcuda.so"*
|
||||
)
|
||||
|
||||
for candidate in "${search_dirs[@]}"; do
|
||||
# shellcheck disable=SC2206
|
||||
# Expandir globs: si el candidato no existe el glob no expande
|
||||
for path in $candidate; do
|
||||
if [[ -e "$path" ]]; then
|
||||
# Normalizar: tomar solo el directorio raiz /usr/local/cuda*
|
||||
local base
|
||||
base="${path%%/lib*}"
|
||||
cuda_libs_path="$base"
|
||||
break 2
|
||||
fi
|
||||
done
|
||||
done
|
||||
|
||||
# Si no encontramos directorio CUDA pero si libcuda.so en rutas de lib estandar
|
||||
if [[ "$cuda_libs_path" == "missing" ]]; then
|
||||
local libcuda
|
||||
libcuda="$(ldconfig -p 2>/dev/null | grep 'libcuda\.so' | head -n1 | awk '{print $NF}')"
|
||||
if [[ -n "$libcuda" ]]; then
|
||||
cuda_libs_path="$(dirname "$libcuda")"
|
||||
fi
|
||||
fi
|
||||
|
||||
# --- overall ---
|
||||
local found_count=0
|
||||
[[ "$nvcc_ver" != "missing" ]] && ((found_count++))
|
||||
[[ "$nvidia_smi_status" != "missing" ]] && ((found_count++))
|
||||
[[ "$cuda_libs_path" != "missing" ]] && ((found_count++))
|
||||
|
||||
local overall
|
||||
if [[ $found_count -eq 0 ]]; then overall="missing"
|
||||
elif [[ $found_count -eq 3 ]]; then overall="ok"
|
||||
else overall="partial"
|
||||
fi
|
||||
|
||||
# --- emitir resultados ---
|
||||
echo "nvcc=${nvcc_ver}"
|
||||
echo "nvidia_smi=${nvidia_smi_status}"
|
||||
echo "driver_version=${driver_version}"
|
||||
echo "cuda_libs=${cuda_libs_path}"
|
||||
echo "overall=${overall}"
|
||||
}
|
||||
|
||||
# Ejecutar si se invoca directamente
|
||||
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||
cuda_toolkit_check "$@"
|
||||
fi
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "deploy_cpp_exe_to_windows(app_name: string, app_dir: string) -> void"
|
||||
description: "Copia el .exe de Windows (compilado por build_cpp_windows) y sus assets al escritorio de Windows /mnt/c/Users/lucas/Desktop/apps/<APP>/. Mata el proceso si esta corriendo (taskkill.exe pre-autorizado), copia DLLs, sincroniza assets/ y enrichers/ con rsync, maneja runtime Python embebido si python_runtime: true en app.md, y copia extras gx-cli. Preserva siempre local_files/ (estado del usuario)."
|
||||
tags: [cpp, deploy, windows, exe, dll, assets, rsync]
|
||||
tags: [cpp, deploy, windows, exe, dll, assets, rsync, cpp-windows]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "detect_wsl([--check]) -> void"
|
||||
description: "Detecta si el sistema es WSL (Windows Subsystem for Linux). Con --check retorna solo exit code (0=WSL, 1=no WSL) sin output. Sin argumentos imprime versión WSL, usuario Windows, distribución, hostname, unidades montadas y ruta Windows del directorio actual."
|
||||
tags: [bash, wsl, windows, detect, integration]
|
||||
tags: [bash, wsl, windows, detect, integration, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -36,6 +36,7 @@ discover_git_repos() {
|
||||
-not -path "*/sources/*" \
|
||||
-not -path "*/temp/*" \
|
||||
-not -path "*/subrepos/*" \
|
||||
-not -path "*/emsdk/*" \
|
||||
2>/dev/null | sort)
|
||||
|
||||
# Imprimir resultados ordenados (uno por linea)
|
||||
|
||||
@@ -3,7 +3,7 @@ name: e2e_run_cpp_windows
|
||||
lang: bash
|
||||
domain: infra
|
||||
description: "Cross-compila una app C++ del registry para Windows con mingw-w64, deploy al Desktop\\apps de Windows (matando instancia previa con taskkill.exe), lanza el .exe nativamente desde WSL y devuelve stdout + exit code. Pensado para tests headless tipo altsnap_jitter_test."
|
||||
tags: [windows, e2e, cross-compile, test, mingw]
|
||||
tags: [windows, e2e, cross-compile, test, mingw, pendiente-usar, cpp-windows]
|
||||
purity: impure
|
||||
kind: function
|
||||
signature: "e2e_run_cpp_windows(target string, --no-build, --no-deploy) int"
|
||||
@@ -18,9 +18,9 @@ output: "Exit code del .exe (0 = pass, no-cero = fail). stdout/stderr del .exe s
|
||||
uses_functions:
|
||||
- build_cpp_windows_bash_infra
|
||||
uses_types: []
|
||||
returns: ""
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "exit_code_bash_core"
|
||||
error_type: "error_go_core"
|
||||
imports: []
|
||||
example: |
|
||||
source bash/functions/infra/e2e_run_cpp_windows.sh
|
||||
|
||||
@@ -73,9 +73,9 @@ ensure_repo_synced() {
|
||||
# gitea_push_directory ya hace commit con su mensaje por defecto. Para
|
||||
# respetar commit_msg custom, hacemos commit aqui antes si hay cambios.
|
||||
if [[ -d "$directory/.git" ]]; then
|
||||
local status
|
||||
status=$(git -C "$directory" status --porcelain)
|
||||
if [[ -n "$status" ]]; then
|
||||
local git_status
|
||||
git_status=$(git -C "$directory" status --porcelain)
|
||||
if [[ -n "$git_status" ]]; then
|
||||
echo "ensure_repo_synced: commiteando cambios con mensaje: $commit_msg" >&2
|
||||
git -C "$directory" add -A
|
||||
git -C "$directory" \
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "frontend_doctor(project_dir: string) -> diagnostics_stdout"
|
||||
description: "Diagnostica la salud de un proyecto frontend Mantine. Verifica Node, React, Mantine, PostCSS, TypeScript, vite.config y detecta residuos de shadcn/@base-ui. Imprime tabla de checks con exit code 0/1."
|
||||
tags: [frontend, mantine, doctor, diagnostics, health, validation]
|
||||
tags: [frontend, mantine, doctor, diagnostics, health, validation, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: 1.0.0
|
||||
purity: impure
|
||||
signature: "git_hook_audit_app_drift <repo_dir>"
|
||||
description: "Pre-commit guard: bloquea commit si los archivos staged tocan una app cuyo app.md tiene drift de uses_functions. Permite ediciones a app.md (correcciones)."
|
||||
tags: [git, hook, precommit, registry-first, audit]
|
||||
tags: [git, hook, precommit, registry-first, audit, pendiente-usar]
|
||||
uses_functions:
|
||||
- audit_uses_functions_go_infra
|
||||
uses_types: []
|
||||
|
||||
@@ -17,7 +17,9 @@ git_hook_audit_app_drift() {
|
||||
echo "ERROR: repo_dir required" >&2
|
||||
return 2
|
||||
fi
|
||||
if [[ ! -d "$repo_dir/.git" ]]; then
|
||||
# Accept both regular repos (.git is a directory) and worktrees (.git is a
|
||||
# file containing "gitdir: ..." pointer).
|
||||
if [[ ! -d "$repo_dir/.git" && ! -f "$repo_dir/.git" ]]; then
|
||||
echo "ERROR: $repo_dir is not a git repo" >&2
|
||||
return 2
|
||||
fi
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "gitea_create_webhook(owner: string, repo: string, target_url: string, secret?: string) -> json"
|
||||
description: "Crea un webhook de push en un repositorio Gitea. El webhook notifica a target_url en cada push."
|
||||
tags: [gitea, webhook, push, deploy, ci, infra]
|
||||
tags: [gitea, webhook, push, deploy, ci, infra, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "gitea_list_repos(owner: string) -> string"
|
||||
description: "Lista repositorios de un owner en Gitea. Intenta listar como org primero; si falla, lista como usuario. Imprime una línea por repo en formato name<TAB>html_url<TAB>description."
|
||||
tags: [gitea, git, repo, list, org, user, api, infra]
|
||||
tags: [gitea, git, repo, list, org, user, api, infra, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -74,10 +74,10 @@ gitea_push_directory() {
|
||||
# Añadir y commitear cambios si los hay
|
||||
git -C "$directory" add -A
|
||||
|
||||
local status
|
||||
status=$(git -C "$directory" status --porcelain)
|
||||
local git_status
|
||||
git_status=$(git -C "$directory" status --porcelain)
|
||||
|
||||
if [[ -n "$status" ]]; then
|
||||
if [[ -n "$git_status" ]]; then
|
||||
echo "gitea_push_directory: commiteando cambios..." >&2
|
||||
git -C "$directory" -c user.email="agent@fn-registry" -c user.name="fn-registry agent" \
|
||||
commit -m "chore: sync from fn-registry agent"
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "gradle_clean(project_dir: string) -> int"
|
||||
description: "Limpia build artifacts de un proyecto Android (gradle clean + rm .gradle + rm build)."
|
||||
tags: [android, gradle, clean, build]
|
||||
tags: [android, gradle, clean, build, pendiente-usar]
|
||||
params:
|
||||
- name: project_dir
|
||||
desc: "Raiz del proyecto Gradle"
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "install_cpp_deps() -> void"
|
||||
description: "Verifica e instala las dependencias de sistema necesarias para compilar C++ con ImGui (cmake, g++, glfw, mesa)"
|
||||
tags: [cpp, dependencies, setup, cmake, imgui]
|
||||
tags: [cpp, dependencies, setup, cmake, imgui, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "install_mantine(project_dir: string) -> void"
|
||||
description: "Instala Mantine UI con todas sus dependencias (@mantine/core, hooks, charts, notifications, form) y PostCSS en un proyecto frontend. Detecta package manager por lockfile. Genera postcss.config.cjs si no existe. Idempotente."
|
||||
tags: [mantine, frontend, install, react, ui, postcss]
|
||||
tags: [mantine, frontend, install, react, ui, postcss, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "install_nodejs([version: string]) -> void"
|
||||
description: "Instala Node.js en Linux usando nvm. Instala nvm v0.39.7 si no está presente. Instala la versión de Node indicada, la activa con 'nvm use' y la configura como default. Idempotente si nvm ya está instalado."
|
||||
tags: [bash, install, nodejs, nvm]
|
||||
tags: [bash, install, nodejs, nvm, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "install_nordvpn() -> void"
|
||||
description: "Instala NordVPN CLI en Ubuntu/Debian (incluido WSL2). Configura repositorio oficial, instala paquete y habilita servicio nordvpnd. Idempotente."
|
||||
tags: [vpn, nordvpn, install, infra, wsl2]
|
||||
tags: [vpn, nordvpn, install, infra, wsl2, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "install_pnpm() -> void"
|
||||
description: "Instala pnpm globalmente usando npm (npm install -g pnpm). Verifica que npm esté disponible. Idempotente: si pnpm ya está instalado, informa y termina sin hacer nada."
|
||||
tags: [bash, install, pnpm, node]
|
||||
tags: [bash, install, pnpm, node, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "install_python312() -> void"
|
||||
description: "Instala Python 3.12 detectando la distribución Linux automáticamente. Ubuntu/Debian/Mint usan deadsnakes PPA; Fedora/RHEL usan dnf; Arch/Manjaro usan pacman. Instala también python3.12-venv, python3.12-dev y verifica pip. Idempotente."
|
||||
tags: [bash, install, python, python312]
|
||||
tags: [bash, install, python, python312, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "install_uv() -> void"
|
||||
description: "Instala uv, el gestor de paquetes Python ultra-rápido escrito en Rust, usando el instalador oficial de astral.sh. Configura PATH en ~/.bashrc y ~/.zshrc. Idempotente: si uv ya está instalado, informa y termina."
|
||||
tags: [bash, install, uv, python]
|
||||
tags: [bash, install, uv, python, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "install_volta() -> void"
|
||||
description: "Instala Volta, el gestor de versiones de Node.js, usando el instalador oficial de get.volta.sh. Configura VOLTA_HOME y PATH en ~/.bashrc y ~/.zshrc. Idempotente: si Volta ya está instalado, informa y termina."
|
||||
tags: [bash, install, volta, node]
|
||||
tags: [bash, install, volta, node, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
name: is_cpp_app_running_windows
|
||||
kind: function
|
||||
lang: bash
|
||||
domain: infra
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "is_cpp_app_running_windows(app_name: string) -> void"
|
||||
description: "Comprueba si un ejecutable Windows esta corriendo via tasklist.exe desde WSL2. Exit 0 si el proceso existe, exit 1 si no."
|
||||
tags: [cpp, windows, monitoring, wsl, tasklist, process, cpp-windows]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: []
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "bash/functions/infra/is_cpp_app_running_windows.sh"
|
||||
params:
|
||||
- name: app_name
|
||||
desc: "Nombre del binario sin extension .exe (ej. registry_dashboard). Se le añade .exe internamente para el filtro de tasklist."
|
||||
output: "Exit 0 con stdout 'RUNNING: PID=<pid> MEM=<mem>' si el proceso existe. Exit 1 con stdout 'NOT_RUNNING: <app_name>' si no. Exit 1 con stderr si tasklist.exe no esta disponible."
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```bash
|
||||
if is_cpp_app_running_windows "registry_dashboard"; then
|
||||
echo "Ya esta corriendo"
|
||||
else
|
||||
launch_cpp_app_windows "registry_dashboard"
|
||||
fi
|
||||
```
|
||||
|
||||
Composicion tipica en pipelines de redeploy:
|
||||
|
||||
```bash
|
||||
# Matar antes de copiar si esta vivo
|
||||
if is_cpp_app_running_windows "$app"; then
|
||||
taskkill.exe /IM "${app}.exe" /F
|
||||
fi
|
||||
deploy_cpp_exe_to_windows "$app" "$app_dir"
|
||||
launch_cpp_app_windows "$app"
|
||||
```
|
||||
|
||||
## Comportamiento
|
||||
|
||||
El exit code es la API principal; stdout es informacion adjunta parseable por el caller:
|
||||
|
||||
| Situacion | Exit | Stdout |
|
||||
|---|---|---|
|
||||
| Proceso encontrado | 0 | `RUNNING: PID=<n> MEM=<n>K` |
|
||||
| Proceso no encontrado | 1 | `NOT_RUNNING: <app_name>` |
|
||||
| `tasklist.exe` no disponible | 1 | (stderr) `ERROR: tasklist.exe no encontrado` |
|
||||
| `app_name` vacio | 1 | (stderr) `ERROR: uso: ...` |
|
||||
|
||||
El formato `RUNNING: PID=N MEM=...K` esta pensado para ser parseado por `cut -d= -f2` si el caller necesita el PID.
|
||||
|
||||
## Prerequisitos
|
||||
|
||||
- WSL2 con acceso a herramientas Windows (`/mnt/c/Windows/System32/tasklist.exe`).
|
||||
- El proceso debe haber sido lanzado via `launch_cpp_app_windows` o cualquier otro mecanismo que cree un proceso Windows con el nombre del `.exe`.
|
||||
|
||||
## Notas
|
||||
|
||||
Util para componer con `launch_cpp_app_windows` y `deploy_cpp_exe_to_windows` en pipelines de redeploy desde WSL2. `deploy_cpp_exe_to_windows` ya incluye un `taskkill.exe` interno antes de copiar, pero esta funcion permite tomar la decision de matar/no matar de forma explicita en el caller.
|
||||
|
||||
Tasklist con `/NH /FO CSV` no emite header, por lo que la primera linea de salida con el nombre de imagen es directamente el primer proceso coincidente. Si hay multiples instancias del mismo `.exe`, se informa solo del primero (PID mas bajo en el listado del sistema).
|
||||
@@ -0,0 +1,45 @@
|
||||
#!/usr/bin/env bash
|
||||
# is_cpp_app_running_windows — Comprueba si un .exe de Windows esta corriendo
|
||||
# via tasklist.exe desde WSL2. Exit 0 si vivo, exit 1 si no.
|
||||
|
||||
is_cpp_app_running_windows() {
|
||||
local app_name="${1:-}"
|
||||
|
||||
if [ -z "$app_name" ]; then
|
||||
echo "ERROR: uso: is_cpp_app_running_windows <app_name>" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Verificar que tasklist.exe esta disponible
|
||||
if ! command -v tasklist.exe >/dev/null 2>&1; then
|
||||
echo "ERROR: tasklist.exe no encontrado (requiere WSL2 con acceso a Windows tools)" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# /NH: sin header, /FO CSV: salida CSV, /FI: filtro por imagen
|
||||
local output
|
||||
output=$(tasklist.exe /FI "IMAGENAME eq ${app_name}.exe" /NH /FO CSV 2>/dev/null)
|
||||
|
||||
# tasklist.exe devuelve "INFO: No tasks..." cuando no hay coincidencia.
|
||||
# Con CSV+NH, cada proceso encontrado produce: "imagen.exe","pid","tipo","sesion","mem"
|
||||
if echo "$output" | grep -qi "\"${app_name}.exe\""; then
|
||||
# Extraer PID y memoria de la primera linea que coincida
|
||||
local line
|
||||
line=$(echo "$output" | grep -i "\"${app_name}.exe\"" | head -n1)
|
||||
|
||||
# Campos CSV: "imagen","PID","tipo","sesion","MEM K"
|
||||
local pid mem
|
||||
pid=$(echo "$line" | cut -d',' -f2 | tr -d '"')
|
||||
mem=$(echo "$line" | cut -d',' -f5 | tr -d '"' | tr -d ' ')
|
||||
|
||||
echo "RUNNING: PID=${pid} MEM=${mem}"
|
||||
return 0
|
||||
else
|
||||
echo "NOT_RUNNING: ${app_name}"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
||||
is_cpp_app_running_windows "$@"
|
||||
fi
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "keepass_delete(entry: string)"
|
||||
description: "Elimina una entry del KeePassXC database via keepassxc-cli rm. La entry pasa a la papelera dentro del .kdbx (no se borra fisicamente)."
|
||||
tags: [keepass, keepassxc, secret, credential, delete]
|
||||
tags: [keepass, keepassxc, secret, credential, delete, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "keepass_generate(entry: string, length?: int, username?: string, url?: string) -> string"
|
||||
description: "Genera un password aleatorio (lower+upper+digits+special), lo almacena en una entry nueva y lo imprime a stdout. Length default 24."
|
||||
tags: [keepass, keepassxc, secret, credential, generate, random]
|
||||
tags: [keepass, keepassxc, secret, credential, generate, random, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "keepass_get(entry: string, attr?: string) -> string"
|
||||
description: "Lee un atributo (Password por defecto) de una entry del KeePassXC database via keepassxc-cli. Resuelve master password desde pass (meta/keepassxc-master) o env KEEPASS_PASSWORD."
|
||||
tags: [keepass, keepassxc, secret, credential, get]
|
||||
tags: [keepass, keepassxc, secret, credential, get, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "keepass_list(prefix?: string) -> json"
|
||||
description: "Lista paths de entries del KeePassXC database como array JSON. Filtra opcionalmente por prefijo de grupo. Internamente usa keepass_dump y proyecta solo los paths."
|
||||
tags: [keepass, keepassxc, list]
|
||||
tags: [keepass, keepassxc, list, pendiente-usar]
|
||||
uses_functions:
|
||||
- keepass_dump_bash_infra
|
||||
uses_types: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "keepass_search(term: string) -> json"
|
||||
description: "Busca entries en el KeePassXC database por substring. Devuelve array JSON de paths que matchean (title/username/url/notes)."
|
||||
tags: [keepass, keepassxc, search, query]
|
||||
tags: [keepass, keepassxc, search, query, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "keepass_set(entry: string, password: string, username?: string, url?: string)"
|
||||
description: "Crea o sobreescribe una entry en el KeePassXC database. Auto-detecta si existe (edit) o no (add). Soporta username y url opcionales."
|
||||
tags: [keepass, keepassxc, secret, credential, set, write]
|
||||
tags: [keepass, keepassxc, secret, credential, set, write, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
---
|
||||
name: launch_cpp_app_windows
|
||||
kind: function
|
||||
lang: bash
|
||||
domain: infra
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "launch_cpp_app_windows(app_name: string, [desktop_dir: string]) -> void"
|
||||
description: "Lanza un binario .exe en Windows desde WSL2. Asume que deploy_cpp_exe_to_windows ya copió el exe a Desktop/apps/<app_name>/. Usa cmd.exe /c start para desacoplar el proceso y retornar inmediatamente."
|
||||
tags: [cpp, windows, launch, wsl, exe, cpp-windows]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: []
|
||||
tested: false
|
||||
tests: []
|
||||
test_file_path: ""
|
||||
file_path: "bash/functions/infra/launch_cpp_app_windows.sh"
|
||||
params:
|
||||
- name: app_name
|
||||
desc: "Nombre de la app (ej: registry_dashboard). Localiza Desktop/apps/<app_name>/<app_name>.exe."
|
||||
- name: desktop_dir
|
||||
desc: "Override opcional del directorio escritorio Windows. Default: /mnt/c/Users/lucas/Desktop."
|
||||
output: "Imprime 'OK: <app_name> launched at <ts>' en stdout si el exe existe y el comando se lanza. Errores fatales a stderr con exit 1."
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```bash
|
||||
source bash/functions/infra/launch_cpp_app_windows.sh
|
||||
|
||||
# Lanzar con default desktop dir
|
||||
launch_cpp_app_windows "registry_dashboard"
|
||||
# OK: registry_dashboard launched at 2026-05-14T10:32:01
|
||||
|
||||
# Override de desktop_dir (ej. otro usuario)
|
||||
launch_cpp_app_windows "chart_demo" "/mnt/c/Users/otrouser/Desktop"
|
||||
# OK: chart_demo launched at 2026-05-14T10:32:05
|
||||
```
|
||||
|
||||
## Comportamiento
|
||||
|
||||
`cmd.exe /c start` es la clave: lanza el proceso en Windows y **retorna inmediatamente** sin esperar a que el exe termine. El proceso queda desacoplado del shell WSL2. Esta funcion **no verifica** que el exe arranco correctamente ni que sigue corriendo — esa responsabilidad recae en `is_cpp_app_running_windows` (funcion complementaria).
|
||||
|
||||
El `cd /d` previo al `start` es esencial: los apps C++ del registry buscan sus assets, `local_files/` y DLLs relativos al directorio de trabajo. Sin el `cd`, Windows buscaria desde `C:\Windows\System32` y el exe no encontraria nada.
|
||||
|
||||
## Prerequisitos
|
||||
|
||||
- **WSL2**: la funcion usa `wslpath -w` y `cmd.exe`, ambos solo disponibles en WSL2.
|
||||
- **`/mnt/c/` montado**: el exe debe ser accesible via la ruta `/mnt/c/...`.
|
||||
- **Exe ya copiado**: `deploy_cpp_exe_to_windows` debe haberse ejecutado antes. Esta funcion no compila ni copia nada.
|
||||
|
||||
## Notes
|
||||
|
||||
Mitad complementaria de `deploy_cpp_exe_to_windows_bash_infra`. El flujo completo para actualizar y relanzar una app es:
|
||||
|
||||
```bash
|
||||
# 1. Compilar para Windows
|
||||
build_cpp_windows "registry_dashboard"
|
||||
|
||||
# 2. Copiar al escritorio (mata proceso si corre, copia DLLs+assets)
|
||||
deploy_cpp_exe_to_windows "registry_dashboard" "/home/lucas/fn_registry/apps/registry_dashboard"
|
||||
|
||||
# 3. Lanzar
|
||||
launch_cpp_app_windows "registry_dashboard"
|
||||
```
|
||||
|
||||
No se incluyen tests automatizados porque requieren entorno WSL2 con Windows activo y no son automatizables en CI.
|
||||
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bash
|
||||
# launch_cpp_app_windows — Lanza un .exe en Windows desde WSL2 via cmd.exe /c start.
|
||||
# Asume que el exe ya fue copiado por deploy_cpp_exe_to_windows al escritorio.
|
||||
|
||||
launch_cpp_app_windows() {
|
||||
local app="${1:-}"
|
||||
local desktop_dir="${2:-/mnt/c/Users/lucas/Desktop}"
|
||||
|
||||
if [ -z "$app" ]; then
|
||||
echo "ERROR: uso: launch_cpp_app_windows <app_name> [desktop_dir]" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local exe_path="$desktop_dir/apps/$app/$app.exe"
|
||||
|
||||
if [ ! -f "$exe_path" ]; then
|
||||
echo "ERROR: exe no encontrado: $exe_path" >&2
|
||||
echo "Copia primero con: deploy_cpp_exe_to_windows $app <app_dir>" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Usamos PowerShell en vez de cmd.exe — los backslashes de paths Windows
|
||||
# no rompen el escaping aqui (cmd.exe `\"` interpreta como escape de
|
||||
# comilla y deja el string sin cerrar; PowerShell single-quote es literal).
|
||||
local win_app_dir win_exe
|
||||
win_app_dir=$(wslpath -w "$desktop_dir/apps/$app")
|
||||
win_exe="$win_app_dir\\$app.exe"
|
||||
|
||||
# Start-Process detacha (equivale a `start` de cmd) y respeta -WorkingDirectory.
|
||||
# Las comillas simples en PowerShell son literales — no procesa \ ni $.
|
||||
powershell.exe -NoProfile -Command \
|
||||
"Start-Process -FilePath '$win_exe' -WorkingDirectory '$win_app_dir'" \
|
||||
>/dev/null 2>&1
|
||||
|
||||
local ts
|
||||
ts=$(date '+%Y-%m-%dT%H:%M:%S')
|
||||
echo "OK: $app launched at $ts"
|
||||
}
|
||||
|
||||
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
||||
launch_cpp_app_windows "$@"
|
||||
fi
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "list_listening_ports([mode: string]) -> void"
|
||||
description: "Lista puertos activos del sistema usando ss (preferido) o netstat como fallback. Modos: all (LISTEN), tcp, udp, established (conexiones activas), stats (resumen + interfaces). Imprime salida tabulada a stdout."
|
||||
tags: [bash, ports, network, listening, monitoring]
|
||||
tags: [bash, ports, network, listening, monitoring, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "nordvpn_connect(country?: string, city?: string) -> json"
|
||||
description: "Conecta a NordVPN por pais, ciudad o servidor especifico. Sin argumentos conecta al mejor servidor disponible. Devuelve JSON con resultado."
|
||||
tags: [vpn, nordvpn, connect, infra, network]
|
||||
tags: [vpn, nordvpn, connect, infra, network, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "nordvpn_disconnect() -> json"
|
||||
description: "Desconecta de NordVPN. Idempotente — si no hay conexion activa retorna ok. Devuelve JSON con resultado."
|
||||
tags: [vpn, nordvpn, disconnect, infra, network]
|
||||
tags: [vpn, nordvpn, disconnect, infra, network, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "nordvpn_get_ip() -> json"
|
||||
description: "Obtiene IP publica actual con fallback entre multiples servicios. Indica si la conexion VPN esta activa y el servidor usado."
|
||||
tags: [vpn, nordvpn, ip, infra, network, verification]
|
||||
tags: [vpn, nordvpn, ip, infra, network, verification, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "nordvpn_list_cities(country: string) -> json"
|
||||
description: "Lista ciudades disponibles de un pais en NordVPN como array JSON ordenado."
|
||||
tags: [vpn, nordvpn, cities, infra, network]
|
||||
tags: [vpn, nordvpn, cities, infra, network, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "nordvpn_list_countries() -> json"
|
||||
description: "Lista paises disponibles en NordVPN como array JSON ordenado alfabeticamente."
|
||||
tags: [vpn, nordvpn, countries, infra, network]
|
||||
tags: [vpn, nordvpn, countries, infra, network, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "nordvpn_set_protocol(protocol: string) -> json"
|
||||
description: "Cambia el protocolo de NordVPN entre NordLynx (WireGuard) y OpenVPN. NordLynx recomendado por velocidad."
|
||||
tags: [vpn, nordvpn, protocol, nordlynx, wireguard, openvpn, infra]
|
||||
tags: [vpn, nordvpn, protocol, nordlynx, wireguard, openvpn, infra, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "nordvpn_status() -> json"
|
||||
description: "Obtiene estado actual de NordVPN como JSON estructurado. Incluye servidor, IP, pais, protocolo y estado de conexion."
|
||||
tags: [vpn, nordvpn, status, infra, network]
|
||||
tags: [vpn, nordvpn, status, infra, network, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "pass_delete(entry: string) -> void"
|
||||
description: "Elimina un secreto del password store (pass)."
|
||||
tags: [pass, secret, credential, delete]
|
||||
tags: [pass, secret, credential, delete, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "pass_generate(entry: string, [length: int]) -> string"
|
||||
description: "Genera un password aleatorio, lo almacena en el password store e imprime el valor generado."
|
||||
tags: [pass, secret, credential, generate, random]
|
||||
tags: [pass, secret, credential, generate, random, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "pass_list([prefix: string]) -> json"
|
||||
description: "Lista entradas del password store como JSON array. Filtra opcionalmente por prefijo."
|
||||
tags: [pass, secret, credential, list]
|
||||
tags: [pass, secret, credential, list, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "pass_sync() -> json"
|
||||
description: "Sincroniza el password store con el repositorio git remoto (pull + push)."
|
||||
tags: [pass, secret, sync, git]
|
||||
tags: [pass, secret, sync, git, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "port_kill(port: int, signal: string) -> void"
|
||||
description: "Mata los procesos que escuchan en un puerto TCP dado. Idempotente: si no hay proceso en el puerto retorna exit 0. Hace un segundo intento con SIGKILL si el primer intento con signal no libera el puerto."
|
||||
tags: ["port", "kill", "process", "tcp"]
|
||||
tags: [port, kill, process, tcp, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "pre_commit_hook_install(repo_dir: string, [--force]) -> void"
|
||||
description: "Instala un hook pre-commit en .git/hooks/pre-commit de un repo dado. El hook invoca scan_secrets_in_dirty para abortar el commit si detecta secrets en archivos staged. Idempotente: si el hook ya esta instalado (marca fn_registry-pre-commit-v1) no lo sobreescribe a menos que se pase --force."
|
||||
tags: ["git", "hook", "precommit", "secrets"]
|
||||
tags: [git, hook, precommit, secrets, pendiente-usar]
|
||||
uses_functions: ["scan_secrets_in_dirty_bash_cybersecurity"]
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
@@ -7,7 +7,7 @@ version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "systemd_local_restart(name: string) -> json"
|
||||
description: "Reinicia un servicio systemd local con systemctl restart. Útil tras actualizar el binario o cambiar el unit. Requiere sudo."
|
||||
tags: [systemd, service, local, infra, restart]
|
||||
tags: [systemd, service, local, infra, restart, pendiente-usar]
|
||||
uses_functions: []
|
||||
uses_types: []
|
||||
returns: []
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user