feat: init_jupyter_analysis v1.1.0 — soporte --project, --desc, --tags

Nueva funcion write_analysis_md_bash_infra genera analysis.md con frontmatter.
El pipeline ahora acepta --project para crear analisis directamente en
projects/{proyecto}/analysis/{nombre}/, valida que el proyecto exista,
genera analysis.md con dir_path correcto y ejecuta fn index al final.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-17 15:39:20 +02:00
parent dcefa13d2d
commit fee892f38e
8 changed files with 252 additions and 52 deletions
@@ -3,10 +3,10 @@ name: init_jupyter_analysis
kind: pipeline
lang: bash
domain: pipelines
version: "1.0.0"
version: "1.1.0"
purity: impure
signature: "init_jupyter_analysis(nombre: string, [...paquetes_extra: string]) -> void"
description: "Inicializa un analisis Jupyter completo en analysis/{nombre}/ con venv, paquetes, launcher, MCP y reglas para agentes Claude. Acepta paquetes extra opcionales."
signature: "init_jupyter_analysis([--project <p>] [--desc <d>] [--tags <t>], nombre: string, [...paquetes_extra: string]) -> void"
description: "Inicializa un analisis Jupyter completo con venv, paquetes, launcher, MCP, reglas Claude, kernel startup y analysis.md. Por defecto crea en analysis/{nombre}/; con --project crea en projects/{proyecto}/analysis/{nombre}/ y ejecuta fn index al final."
tags: [jupyter, analysis, setup, pipeline, bash, launcher]
uses_functions:
- assert_command_exists_bash_shell
@@ -17,6 +17,7 @@ uses_functions:
- write_mcp_jupyter_config_bash_infra
- write_claude_jupyter_rules_bash_infra
- write_jupyter_registry_kernel_bash_infra
- write_analysis_md_bash_infra
uses_types: []
returns: []
returns_optional: false
@@ -27,7 +28,13 @@ params:
desc: "nombre del análisis a crear"
- name: paquetes_extra
desc: "paquetes Python adicionales a instalar (variadic, opcional)"
output: "sin salida directa; estructura completa en analysis/{nombre}/"
- name: "--project"
desc: "nombre del proyecto bajo projects/ donde crear el analisis (opcional); si se omite, se crea en analysis/ raiz"
- name: "--desc"
desc: "descripcion breve del analisis (se escribe en analysis.md)"
- name: "--tags"
desc: "tags CSV que se escriben en analysis.md (opcional)"
output: "sin salida directa; estructura completa + analysis.md en el destino. Con --project, ejecuta fn index para registrar."
tested: false
tests: []
test_file_path: ""
@@ -37,28 +44,30 @@ file_path: "bash/functions/pipelines/init_jupyter_analysis.sh"
## Ejemplo
```bash
# Analisis basico
./init_jupyter_analysis.sh finanzas
# Con paquetes extra
./init_jupyter_analysis.sh duckdb polars duckdb
./init_jupyter_analysis.sh ml scikit-learn torch
# Via fn run
# Analisis suelto en analysis/
fn run init_jupyter_analysis finanzas
fn run init_jupyter_analysis ml scikit-learn torch
# Analisis dentro de un proyecto (un solo comando, todo resuelto)
fn run init_jupyter_analysis --project aurgi sale_prices --desc "Comprobacion precios"
fn run init_jupyter_analysis --project aurgi ventas polars --tags "aurgi,ventas"
```
## Flujo
1. `assert_command_exists` — verifica que uv o python3 estan disponibles
2. Crea estructura `analysis/{nombre}/notebooks/` y `analysis/{nombre}/data/`
3. `init_uv_venv` — crea venv en `analysis/{nombre}/.venv/`
2. Crea estructura `{destino}/notebooks/` y `{destino}/data/`
3. `init_uv_venv` — crea venv en `{destino}/.venv/`
4. `uv_add_packages` — instala jupyter, jupyterlab, jupyter-collaboration, jupyter-mcp-server, pandas, numpy, matplotlib + extras
5. `write_jupyter_launcher` — genera `run-jupyter-lab.sh` con modo colaborativo
6. `find_free_port` + `write_mcp_jupyter_config` — detecta puerto libre y genera `.mcp.json`
7. `write_claude_jupyter_rules` — genera `.claude/CLAUDE.md` con reglas de agente
8. `write_jupyter_registry_kernel` — genera IPython startup con `fn_query`, `fn_search`, `fn_code` y acceso a `python/functions/`
9. `write_analysis_md` — genera `analysis.md` con frontmatter y `dir_path` correcto
Si se paso `--project`, al final ejecuta `fn index` para registrar el analisis en registry.db con `project_id` correcto.
Con `--project`, el destino es `projects/{proyecto}/analysis/{nombre}/` (requiere que `projects/{proyecto}/project.md` exista); sin el, es `analysis/{nombre}/`.
## Notas