feat: modelo por defecto por proyecto con selector y orden /modelo-proyecto
This commit is contained in:
1 parent
b35bc7a607
commit
f6d2870635
12 files changed
+372
-22
No files matched your search
@@ -13,6 +13,7 @@ PROYECTO=""
|
||||
DESCRIPCION=""
|
||||
AUTOR=""
|
||||
DESTINO=""
|
||||
MODELO=""
|
||||
INIT_GIT=0
|
||||
FORCE=0
|
||||
DRY_RUN=0
|
||||
@@ -28,6 +29,10 @@ Opciones:
|
||||
-n, --nombre NOMBRE Nombre del proyecto (por defecto: nombre del directorio).
|
||||
-d, --descripcion TEXTO Descripción en una frase (por defecto: PENDIENTE).
|
||||
-a, --autor NOMBRE Autor (por defecto: git config user.name).
|
||||
-m, --modelo PROV/ID Modelo por defecto del proyecto; se guarda en
|
||||
.pi/settings.json (lista: pi --list-models).
|
||||
En pi es preferible la herramienta
|
||||
elegir_modelo_proyecto o la orden /modelo-proyecto.
|
||||
-g, --git Inicializa un repositorio git en el destino.
|
||||
-f, --force Sobreescribe ficheros que ya existan.
|
||||
--dry-run Muestra lo que haría sin escribir nada.
|
||||
@@ -37,12 +42,14 @@ EOF
|
||||
|
||||
die() { printf 'error: %s\n' "$*" >&2; exit 1; }
|
||||
aviso() { printf 'aviso: %s\n' "$*" >&2; }
|
||||
requiere() { [[ $# -ge 2 && -n "$2" && "$2" != -* ]] || die "$1 necesita un valor"; }
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
-n | --nombre) PROYECTO="${2:-}"; shift 2 ;;
|
||||
-d | --descripcion) DESCRIPCION="${2:-}"; shift 2 ;;
|
||||
-a | --autor) AUTOR="${2:-}"; shift 2 ;;
|
||||
-n | --nombre) requiere "$@"; PROYECTO="$2"; shift 2 ;;
|
||||
-d | --descripcion) requiere "$@"; DESCRIPCION="$2"; shift 2 ;;
|
||||
-a | --autor) requiere "$@"; AUTOR="$2"; shift 2 ;;
|
||||
-m | --modelo) requiere "$@"; MODELO="$2"; shift 2 ;;
|
||||
-g | --git) INIT_GIT=1; shift ;;
|
||||
-f | --force) FORCE=1; shift ;;
|
||||
--dry-run) DRY_RUN=1; shift ;;
|
||||
@@ -74,6 +81,11 @@ if [[ -z "$AUTOR" ]]; then
|
||||
[[ -n "$AUTOR" ]] || AUTOR="PENDIENTE"
|
||||
fi
|
||||
|
||||
if [[ -n "$MODELO" ]]; then
|
||||
[[ "$MODELO" =~ ^[^/[:space:]\"]+/[^[:space:]\"]+$ ]] \
|
||||
|| die "--modelo debe tener la forma proveedor/id (p. ej. anthropic/claude-sonnet-4-5)"
|
||||
fi
|
||||
|
||||
FICHEROS=(AGENTS.md README.md CHANGELOG.md TODO.md INSTALL.md .gitignore)
|
||||
|
||||
render() {
|
||||
@@ -109,6 +121,22 @@ for fichero in "${FICHEROS[@]}"; do
|
||||
creados+=("$fichero")
|
||||
done
|
||||
|
||||
if [[ -n "$MODELO" ]]; then
|
||||
settings="$DESTINO/.pi/settings.json"
|
||||
if [[ -e "$settings" && $FORCE -eq 0 ]]; then
|
||||
omitidos+=(".pi/settings.json")
|
||||
aviso ".pi/settings.json ya existe; se omite (usa /modelo-proyecto en pi para cambiar el modelo sin perder otros ajustes)"
|
||||
elif [[ $DRY_RUN -eq 1 ]]; then
|
||||
printf 'dry-run: escribiría %s (modelo %s)\n' "$settings" "$MODELO"
|
||||
creados+=(".pi/settings.json")
|
||||
else
|
||||
mkdir -p -- "$DESTINO/.pi"
|
||||
printf '{\n "defaultProvider": "%s",\n "defaultModel": "%s"\n}\n' \
|
||||
"${MODELO%%/*}" "${MODELO#*/}" > "$settings"
|
||||
creados+=(".pi/settings.json")
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $INIT_GIT -eq 1 && $DRY_RUN -eq 0 ]]; then
|
||||
if [[ -d "$DESTINO/.git" ]]; then
|
||||
aviso "$DESTINO ya es un repositorio git"
|
||||
@@ -120,6 +148,7 @@ fi
|
||||
|
||||
printf '\nproyecto: %s\n' "$PROYECTO"
|
||||
printf 'destino: %s\n' "$destino_abs"
|
||||
printf 'modelo: %s\n' "${MODELO:-sin fijar (elígelo con /modelo-proyecto)}"
|
||||
printf 'creados: %s\n' "${creados[*]:-ninguno}"
|
||||
[[ ${#omitidos[@]} -eq 0 ]] || printf 'omitidos: %s\n' "${omitidos[*]}"
|
||||
[[ $DRY_RUN -eq 1 ]] || printf 'siguiente: revisa README.md, INSTALL.md y las secciones PENDIENTE de AGENTS.md\n'
|
||||
Reference in new issue
Block a user