devzone 0.56.0 → 0.58.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -132,6 +132,7 @@ session_erreur_fatale() {
132
132
  wait "$pid" 2>/dev/null || true
133
133
  droits_verifier "$dossier"
134
134
  modele_ecarter "$m" "$cause"
135
+ modele_demande_ecart "$m" "$cause" "$journal"
135
136
  printf '%s\n' "=== opencode/$m écarté ($cause) : modèle suivant" >>"$journal"
136
137
  return 0
137
138
  }
@@ -46,6 +46,7 @@ agent_etat_json() {
46
46
  [ -e "$f" ] || continue
47
47
  journal="$(basename "$f")"
48
48
  session_modele_debut "$f"
49
+ session_demande "$f"
49
50
  modele="$MODELE_SESSION"
50
51
  [ -n "$modele" ] || modele="inconnu"
51
52
  debut="$DEBUT_SESSION"
@@ -58,8 +59,9 @@ agent_etat_json() {
58
59
  --arg modele "$modele" \
59
60
  --arg debut "$debut" \
60
61
  --arg dernier "$dernier" \
62
+ --arg demande "$DEMANDE_SESSION" \
61
63
  --argjson en_cours "$en_cours" \
62
- '. + [{journal:$journal,modele:$modele,debut:(if $debut=="" then null else $debut end),dernier_ecrit:(if $dernier=="" then null else $dernier end),en_cours:$en_cours}]' \
64
+ '. + [{journal:$journal,modele:$modele,debut:(if $debut=="" then null else $debut end),dernier_ecrit:(if $dernier=="" then null else $dernier end),demande:(if $demande=="" then null else $demande end),en_cours:$en_cours}]' \
63
65
  <<<"$sessions_json")"
64
66
  done
65
67
 
@@ -1,11 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  # Local model in the rotation of devzone agent (#586), sourced by agent.sh.
3
- # The local slot is first the host model (Ollama answers /api/tags with at
4
- # least one model, reference devzone-host/<model>), otherwise the llm module's
5
- # local model (devzone-llm/local, cluster / relay /health). It always comes
6
- # after every online model; its internal name has no slash (an ecart-<name>
7
- # file is written for it); opencode gets the reference.
8
- LOCAL_NOM=devzone-llm-local
3
+ # The local slot is the host model when Ollama answers /api/tags with at least
4
+ # one model (reference devzone-host/<model>). It always comes after every online
5
+ # model; its internal name has no slash (an ecart-<name> file is written for it);
6
+ # opencode gets the reference.
9
7
  # Real host model name (Ollama) chosen for this attempt, empty otherwise.
10
8
  LOCAL_HOTE_REEL=""
11
9
  # Internal (slash-free) name of the host model chosen for this attempt.
@@ -26,37 +24,29 @@ nom_interne() {
26
24
  # Sets LOCAL_MODELE for this attempt, read by modele_au_rang and
27
25
  # modeles_total. Also records the real host model name when the host is chosen.
28
26
  local_charge() {
29
- local nom url
27
+ local nom
28
+ LOCAL_MODELE=""
30
29
  LOCAL_HOTE_REEL=""
31
30
  LOCAL_HOTE_INTERNE=""
32
31
  nom="$(premier 2>/dev/null || true)"
33
- if [ -n "$nom" ]; then
34
- LOCAL_HOTE_REEL="$nom"
35
- LOCAL_HOTE_INTERNE="$(nom_interne "$nom")"
36
- LOCAL_MODELE="$LOCAL_HOTE_INTERNE"
37
- return 0
38
- fi
39
- # Fallback: the llm module local model (cluster / relay).
40
- LOCAL_MODELE=""
41
- if [ "${DEVZONE_WORKSPACE:-}" != kubernetes ]; then
42
- bash "$ICI/devzone" is-enabled llm >/dev/null 2>&1 || return 0
43
- fi
44
- url="$(bash "$ICI/llm/opencode.sh" url)" || return 0
45
- if curl -fsS --max-time 3 "${url%/v1}/health" >/dev/null 2>&1; then
46
- LOCAL_MODELE="$LOCAL_NOM"
47
- fi
32
+ [ -n "$nom" ] || return 0
33
+ LOCAL_HOTE_REEL="$nom"
34
+ LOCAL_HOTE_INTERNE="$(nom_interne "$nom")"
35
+ LOCAL_MODELE="$LOCAL_HOTE_INTERNE"
48
36
  return 0
49
37
  }
50
38
 
51
39
  # Model reference given to opencode -m
52
40
  modele_ref() {
53
- if [ "$1" = "$LOCAL_NOM" ]; then echo devzone-llm/local;
54
- elif [ -n "$LOCAL_HOTE_INTERNE" ] && [ "$1" = "$LOCAL_HOTE_INTERNE" ]; then echo "devzone-host/$LOCAL_HOTE_REEL";
55
- else echo "opencode/$1"; fi
41
+ if [ -n "$LOCAL_HOTE_INTERNE" ] && [ "$1" = "$LOCAL_HOTE_INTERNE" ]; then
42
+ echo "devzone-host/$LOCAL_HOTE_REEL"
43
+ else
44
+ echo "opencode/$1"
45
+ fi
56
46
  }
57
47
 
58
48
  # Model of rank $1 in the attempt that starts at $2: online ones in rotation,
59
- # then the local one (host or llm module)
49
+ # then the local host model
60
50
  modele_au_rang() {
61
51
  if [ "$1" -lt "${#FREE_MODELS[@]}" ]; then
62
52
  echo "${FREE_MODELS[$(( ($2 + $1) % ${#FREE_MODELS[@]} ))]}"
@@ -65,7 +55,7 @@ modele_au_rang() {
65
55
  fi
66
56
  }
67
57
 
68
- # Number of models to try: the online ones, plus the local one if ready
58
+ # Number of models to try: the online ones, plus the local host model if ready
69
59
  modeles_total() {
70
60
  local total="${#FREE_MODELS[@]}"
71
61
  [ -n "$LOCAL_MODELE" ] && total=$((total + 1))
@@ -0,0 +1,7 @@
1
+ # Messages of devzone agent --modele (#420), in French like the journal they go to.
2
+ # Sourced by agent-modele.sh. Kept out of .english on purpose: the accents are
3
+ # the point. Each %s is replaced by a model name or a cause (printf formats).
4
+ MSG_AUCUN_MODELE='aucun modèle gratuit disponible'
5
+ MSG_CHOISI='=== modèle choisi : %s (demandé)'
6
+ MSG_ECARTE='=== modèle demandé %s écarté (%s), suivant'
7
+ MSG_INCONNU='devzone agent : modèle inconnu : %s ; modèles gratuits :'
@@ -0,0 +1,113 @@
1
+ #!/usr/bin/env bash
2
+ # Models asked with devzone agent --modele (#420): list check, attempt order
3
+ # (requested models first, then the usual rotation) and the shared rank rule.
4
+ # Library sourced by agent.sh: no command is launched here.
5
+
6
+ # Journal and refusal texts (French), printf formats.
7
+ # shellcheck source=SCRIPTDIR/agent-modele.messages disable=SC1091
8
+ . "$ICI/agent-modele.messages"
9
+
10
+ # Option --modele as typed (comma-separated list), empty when absent.
11
+ MODELE_LISTE=""
12
+ # Requested models, in order, checked by modeles_charger.
13
+ MODELES_DEMANDES=()
14
+ # Attempt order of the session (internal names), set by modele_ordre.
15
+ ORDRE=()
16
+
17
+ # Refuses a name missing from the free models: nothing is launched (code 2).
18
+ refuse_modele() {
19
+ # shellcheck disable=SC2059 # the format comes from agent-modele.messages
20
+ printf "$MSG_INCONNU\n" "$1" >&2
21
+ printf ' %s\n' "${FREE_MODELS[@]}" >&2
22
+ exit 2
23
+ }
24
+
25
+ # Loads the free models, checks the --modele list and writes its header to the
26
+ # journal $1: the last header tells devzone agent etat what was asked.
27
+ modeles_charger() {
28
+ local journal="$1" m nom
29
+ FREE_MODELS=()
30
+ while IFS= read -r m; do
31
+ if [ -n "$m" ]; then FREE_MODELS+=("$m"); fi
32
+ done < <(liste_modeles)
33
+ [ "${#FREE_MODELS[@]}" -gt 0 ] || refuse "$MSG_AUCUN_MODELE"
34
+ MODELES_DEMANDES=()
35
+ if [ -n "$MODELE_LISTE" ]; then
36
+ while IFS= read -r nom; do
37
+ case " ${FREE_MODELS[*]} " in
38
+ *" $nom "*) MODELES_DEMANDES+=("$nom") ;;
39
+ *) refuse_modele "$nom" ;;
40
+ esac
41
+ done < <(printf '%s\n' "$MODELE_LISTE" | tr ',' '\n')
42
+ fi
43
+ echo "=== --modele : ${MODELE_LISTE:-aucun}" >>"$journal"
44
+ }
45
+
46
+ # True when model $1 was asked with --modele.
47
+ modele_demande_p() {
48
+ case " ${MODELES_DEMANDES[*]:-} " in
49
+ *" $1 "*) return 0 ;;
50
+ esac
51
+ return 1
52
+ }
53
+
54
+ # Journal line when requested model $1 starts; other models get no line.
55
+ modele_demande_choisi() {
56
+ if modele_demande_p "$1"; then
57
+ # shellcheck disable=SC2059 # the format comes from agent-modele.messages
58
+ printf "$MSG_CHOISI\n" "$1" >>"$2"
59
+ fi
60
+ }
61
+
62
+ # Journal line when requested model $1 is excluded for cause $2, written to the
63
+ # journal $3. Other models keep their own lines.
64
+ modele_demande_ecart() {
65
+ if modele_demande_p "$1"; then
66
+ # shellcheck disable=SC2059 # the format comes from agent-modele.messages
67
+ printf "$MSG_ECARTE\n" "$1" "$2" >>"$3"
68
+ fi
69
+ }
70
+
71
+ # Cause of the current exclusion of model $1: ecart-<model> gives it, muet-<model>
72
+ # has none and counts as muet.
73
+ modele_ecart_cause() {
74
+ local f cause=""
75
+ f="$AGENT_ETAT/ecart-$1"
76
+ if [ ! -f "$f" ]; then f="$AGENT_ETAT/muet-$1"; fi
77
+ if [ -f "$f" ]; then read -r _ cause _ <"$f" || true; fi
78
+ echo "${cause:-muet}"
79
+ }
80
+
81
+ # Adds model $1 to ORDRE unless it is already there.
82
+ ordre_ajouter() {
83
+ case " ${ORDRE[*]:-} " in
84
+ *" $1 "*) ;;
85
+ *) ORDRE+=("$1") ;;
86
+ esac
87
+ }
88
+
89
+ # Attempt order of the session from rank $1: requested models in their order,
90
+ # then the usual rotation (online models, then the local one). Each model
91
+ # appears once, so the rotation never tries again a requested model.
92
+ modele_ordre() {
93
+ local debut="$1" total i k
94
+ ORDRE=()
95
+ for ((k = 0; k < ${#MODELES_DEMANDES[@]}; k++)); do
96
+ ordre_ajouter "${MODELES_DEMANDES[$k]}"
97
+ done
98
+ total="$(modeles_total)"
99
+ for ((i = 0; i < total; i++)); do
100
+ ordre_ajouter "$(modele_au_rang "$i" "$debut")"
101
+ done
102
+ }
103
+
104
+ # True when the shared rank may advance: no requested model is available.
105
+ # A requested model that starts leaves the rank alone, so the rotation of the
106
+ # other sessions does not move.
107
+ modele_rang_avance() {
108
+ local k
109
+ for ((k = 0; k < ${#MODELES_DEMANDES[@]}; k++)); do
110
+ if ! modele_ecarte "${MODELES_DEMANDES[$k]}"; then return 1; fi
111
+ done
112
+ return 0
113
+ }
@@ -105,6 +105,21 @@ verrou_lacher() {
105
105
  fi
106
106
  }
107
107
 
108
+ # Takes the shared rank and returns the start of the rotation (#421). The rank
109
+ # advances only when no requested model is available (#420). The « === rang »
110
+ # line is written to the journal in every case. Called in a command
111
+ # substitution: the lock is taken and released in that same process.
112
+ rang_prendre() {
113
+ local etat="$1" journal="$2" debut
114
+ verrou_prendre || return 1
115
+ debut=$(( $(cat "$etat/rang" 2>/dev/null || echo 0) % ${#FREE_MODELS[@]} ))
116
+ if [ "$PAUSE_RANG" -gt 0 ]; then sleep "$PAUSE_RANG"; fi
117
+ if modele_rang_avance; then echo $(( debut + 1 )) >"$etat/rang"; fi
118
+ verrou_lacher
119
+ echo "=== rang $(( debut + 1 ))/${#FREE_MODELS[@]}" >>"$journal"
120
+ echo "$debut"
121
+ }
122
+
108
123
  # Passe permission.edit en objet et ajoute en dernier un deny par fichier de droits
109
124
  # (#361) : la dernière règle qui correspond l'emporte, l'appelant ne peut pas le retirer.
110
125
  droits_edit_deny() {
@@ -182,6 +197,15 @@ session_modele_debut() {
182
197
  DEBUT_SESSION="$(sed -nE 's/.* début ([^ ]+).*/\1/p' <<<"$ligne")"
183
198
  }
184
199
 
200
+ # Models asked with devzone agent --modele (#420): the last header line
201
+ # « === --modele : » of the journal, empty when nothing was asked.
202
+ session_demande() {
203
+ local ligne
204
+ ligne="$(grep '^=== --modele : ' "$1" 2>/dev/null | tail -1 || true)"
205
+ DEMANDE_SESSION="${ligne#=== --modele : }"
206
+ if [ "$DEMANDE_SESSION" = aucun ]; then DEMANDE_SESSION=""; fi
207
+ }
208
+
185
209
  # Une session est en cours (#308) si un processus agent.sh vivant a pour
186
210
  # premier argument (le dossier, absolu depuis #287) un chemin dont le nom est
187
211
  # exactement le journal sans « .log » ; un simple dossier contenant ce nom ne
@@ -212,7 +236,8 @@ agent_etat() {
212
236
  m="${MODELE_SESSION:+opencode/$MODELE_SESSION}"
213
237
  debut="$DEBUT_SESSION"
214
238
  dernier="$(heure "$(mtime "$f")")"
215
- echo " session $(basename "$f") : modèle ${m:-inconnu}, depuis ${debut:-inconnu}, dernier écrit $dernier"
239
+ session_demande "$f"
240
+ echo " session $(basename "$f") : modèle ${m:-inconnu}${DEMANDE_SESSION:+ (demandé : $DEMANDE_SESSION)}, depuis ${debut:-inconnu}, dernier écrit $dernier"
216
241
  done
217
242
  [ "$vu" = 1 ] || echo " aucune session"
218
243
  agent_ecarts
@@ -72,7 +72,8 @@ agent_workspace() {
72
72
  fi
73
73
  echo "devzone agent : workspace Kubernetes (pod devzone-workspace-0, $dans_pod) ; --local pour le conteneur"
74
74
  agent_kc cp "$consigne" "devzone-workspace-0:/tmp/devzone-agent-$nom.md" -c workspace
75
- agent_kc exec devzone-workspace-0 -c workspace -- env DEVZONE_RACINE="$racine_pod" bash -lc 'devzone agent "$1" "$2"' _ "$dans_pod" "/tmp/devzone-agent-$nom.md" || code=$?
75
+ # shellcheck disable=SC2016 # the pod shell expands MODELE_OPT, not this one
76
+ agent_kc exec devzone-workspace-0 -c workspace -- env DEVZONE_RACINE="$racine_pod" MODELE_OPT="$MODELE_LISTE" bash -lc 'devzone agent ${MODELE_OPT:+--modele "$MODELE_OPT"} "$1" "$2"' _ "$dans_pod" "/tmp/devzone-agent-$nom.md" || code=$?
76
77
  journal="$(journal_de "$nom")"
77
78
  mkdir -p "$(dirname "$journal")"
78
79
  if ! agent_kc exec devzone-workspace-0 -c workspace -- cat "$racine_pod/workspace/.agents/$nom.log" >>"$journal"; then
@@ -83,8 +84,9 @@ agent_workspace() {
83
84
 
84
85
  agent_aide() {
85
86
  cat <<'AGENTEOF2'
86
- usage : devzone agent [--local] <dossier> <fichier-consigne>
87
+ usage : devzone agent [--modele <m>[,<m2>…]] [--local] <dossier> <fichier-consigne>
87
88
  lance opencode sur la consigne, modèles gratuits en rotation
89
+ --modele : modèles essayés d'abord, dans l'ordre, puis la rotation
88
90
  workspace Kubernetes d'abord s'il tourne ; --local : ce conteneur
89
91
  un chemin /workspaces/projets/... absent d'ici est un dossier du pod, sans copie
90
92
  devzone agent etat
@@ -1,6 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  # Dirige opencode sur une consigne : rotation, silence au depart, reprise.
3
3
  # Module ia (#221). devzone agent <dossier> <consigne> | etat | liberer.
4
+ # shellcheck disable=SC2034 # RACINE, FREE_MODELS, PAUSE_RANG: read by the sourced agent-*.sh
4
5
  set -euo pipefail
5
6
  # Dossier du script, liens symboliques suivis à la main : readlink -f n'existe
6
7
  # pas sur macOS (tests sous bash 3.2).
@@ -14,18 +15,19 @@ while [ -L "$SOURCE" ]; do
14
15
  esac
15
16
  done
16
17
  ICI="$(cd -P "$(dirname "$SOURCE")" && pwd)"
17
- # shellcheck disable=SC2034 # lue par agent-session.sh
18
18
  RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
19
19
  # shellcheck source=agent-erreurs.sh disable=SC1091
20
20
  . "$ICI/agent-erreurs.sh"
21
21
  # shellcheck source=agent-droits.sh disable=SC1091
22
22
  . "$ICI/agent-droits.sh"
23
- # shellcheck source=agent-session.sh disable=SC1091
23
+ # shellcheck source=SCRIPTDIR/agent-session.sh disable=SC1091
24
24
  . "$ICI/agent-session.sh"
25
25
  # shellcheck source=agent-workspace.sh disable=SC1091
26
26
  . "$ICI/agent-workspace.sh"
27
27
  # shellcheck source=agent-local.sh disable=SC1091
28
28
  . "$ICI/agent-local.sh"
29
+ # shellcheck source=SCRIPTDIR/agent-modele.sh disable=SC1091
30
+ . "$ICI/agent-modele.sh"
29
31
  FREE_MODELS=(big-pickle deepseek-v4.1-flash-free hy4-flash-free nemotron-3.5-super-vl-free
30
32
  nemotron-3.5-lightning-free mimo-v2.6-flash-free beam-free flint-40b-free longcat-2.5-free)
31
33
  # Session pod ephemere (#222)
@@ -62,18 +64,9 @@ agent_lancer() {
62
64
  etat="$AGENT_ETAT"
63
65
  mkdir -p "$(dirname "$journal")" "$etat"
64
66
  droits_photo "$dossier"
65
- FREE_MODELS=()
66
- while IFS= read -r m; do
67
- if [ -n "$m" ]; then FREE_MODELS+=("$m"); fi
68
- done < <(liste_modeles)
69
- [ "${#FREE_MODELS[@]}" -gt 0 ] || refuse "aucun modèle gratuit disponible"
67
+ modeles_charger "$journal"
70
68
  local_charge
71
- verrou_prendre || refuse "rang des modèles verrouillé : réessayer"
72
- debut=$(( $(cat "$etat/rang" 2>/dev/null || echo 0) % ${#FREE_MODELS[@]} ))
73
- if [ "$PAUSE_RANG" -gt 0 ]; then sleep "$PAUSE_RANG"; fi
74
- echo $(( debut + 1 )) >"$etat/rang"
75
- verrou_lacher
76
- echo "=== rang $(( debut + 1 ))/${#FREE_MODELS[@]}" >>"$journal"
69
+ debut="$(rang_prendre "$etat" "$journal")" || refuse "rang des modèles verrouillé : réessayer"
77
70
  consigne_courante="$consigne"
78
71
  # Reprise : une session neuve repart du travail déjà présent (git status,
79
72
  # diff, log), sans historique de conversation.
@@ -86,14 +79,17 @@ agent_lancer() {
86
79
  printf '\n\nREPRISE : une session précédente a été interrompue. Lis git status, git diff et git log dans le dossier, vérifie ce travail contre la consigne ci-dessus, corrige ce qui s en écarte et termine ce qui manque.\n' >>"$c"
87
80
  consigne_courante="$c"
88
81
  }
82
+ modele_ordre "$debut"
89
83
  i=0
90
- while [ "$i" -lt "$(modeles_total)" ]; do
91
- m="$(modele_au_rang "$i" "$debut")"
84
+ while [ "$i" -lt "${#ORDRE[@]}" ]; do
85
+ m="${ORDRE[$i]}"
92
86
  if [ "$m" != "$reseau_pour" ]; then reseau_pour="$m"; reseau_n=0; fi
93
87
  if modele_ecarte "$m"; then
88
+ modele_demande_ecart "$m" "$(modele_ecart_cause "$m")" "$journal"
94
89
  i=$(( i + 1 ))
95
90
  continue
96
91
  fi
92
+ modele_demande_choisi "$m" "$journal"
97
93
  echo "=== modèle opencode/$m début $(date -u +%Y-%m-%dT%H:%M:%SZ)" >>"$journal"
98
94
  offset="$(wc -c <"$journal")"
99
95
  opencode_lancer "$dossier" "$m" "$consigne_courante" "$journal" "$etat"
@@ -119,6 +115,7 @@ agent_lancer() {
119
115
  droits_verifier "$dossier"
120
116
  echo "=== opencode/$m muet au départ : écarté 1 h, modèle suivant" >>"$journal"
121
117
  modele_ecarter "$m" mute
118
+ modele_demande_ecart "$m" mute "$journal"
122
119
  reprise
123
120
  i=$(( i + 1 ))
124
121
  continue
@@ -190,6 +187,7 @@ agent_lancer() {
190
187
  echo "=== opencode/$m erreur, sans écart : modèle suivant" >>"$journal"
191
188
  else
192
189
  modele_ecarter "$m" "$cause"
190
+ modele_demande_ecart "$m" "$cause" "$journal"
193
191
  echo "=== opencode/$m écarté ($cause, $(ecart_libelle "$cause")) : modèle suivant" >>"$journal"
194
192
  fi
195
193
  reprise
@@ -222,7 +220,9 @@ case "${1:-}" in
222
220
  exit 2
223
221
  ;;
224
222
  *)
223
+ if [ "${1:-}" = "--modele" ]; then [ -n "${2:-}" ] || { agent_aide >&2; exit 2; }; MODELE_LISTE="$2"; shift 2; fi
225
224
  if [ "${1:-}" = "--pod" ]; then
225
+ [ -z "$MODELE_LISTE" ] || refuse "--modele n'est pas géré avec --pod"
226
226
  shift
227
227
  if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
228
228
  agent_aide >&2
@@ -2,7 +2,7 @@
2
2
  # Services of the container held by Argo CD (#559, step 5). Called by devzone
3
3
  # (changer) after the state line is written, before the helm-direct path:
4
4
  # services-hook.sh <svc> <on|off>
5
- # postgres, mysql and llm with the module argocd installed and held: enable writes
5
+ # postgres and mysql with the module argocd installed and held: enable writes
6
6
  # [services] <svc> = on and reconciles it (services_reconcile, services.sh),
7
7
  # then waits for the pods and starts the relay; disable removes the
8
8
  # Application (its resources leave with it, namespace and volumes stay).
@@ -22,7 +22,7 @@ STATE_RACINE="${DEVZONE_RACINE:-$RACINE}"
22
22
  # shellcheck disable=SC2034 # read by catalogue-argocd.sh
23
23
  ETAT="${DEVZONE_ETAT:-$STATE_RACINE/.devzone.modules}"
24
24
  APP_CONF="$RACINE/.devcontainer/catalogue/mysql/app.conf"
25
- HOOK_SERVICES="postgres mysql llm"
25
+ HOOK_SERVICES="postgres mysql"
26
26
 
27
27
  # shellcheck source=SCRIPTDIR/../cluster.sh
28
28
  # shellcheck disable=SC1091
@@ -46,19 +46,16 @@ hook_script() {
46
46
  case "$1" in
47
47
  postgres) printf '%s' "$ICI/../postgres/postgres.sh" ;;
48
48
  mysql) printf '%s' "$ICI/../catalogue/mysql/mysql.sh" ;;
49
- llm) printf '%s' "$ICI/../llm/llm.sh" ;;
50
49
  esac
51
50
  }
52
51
 
53
52
  # Waits for the pods of devzone-<svc> to be ready (the Application syncs
54
- # within a few minutes); the relay needs a ready pod to forward to. The model
55
- # of llm is downloaded on its first start: LLM_ATTENTE seconds (1800)
53
+ # within a few minutes); the relay needs a ready pod to forward to
56
54
  hook_wait() {
57
- local ns="devzone-$1" tour=0 limit=300
58
- [ "$1" != llm ] || limit="${LLM_ATTENTE:-1800}"
55
+ local ns="devzone-$1" tour=0
59
56
  while [ "$tour" -lt 60 ]; do
60
57
  if argocd_kubectl -n "$ns" get pods -o name 2>/dev/null | grep -q .; then
61
- argocd_kubectl -n "$ns" wait --for=condition=Ready pod --all --timeout="${limit}s" >/dev/null 2>&1 && return 0
58
+ argocd_kubectl -n "$ns" wait --for=condition=Ready pod --all --timeout=300s >/dev/null 2>&1 && return 0
62
59
  fi
63
60
  tour=$((tour + 1))
64
61
  sleep 5
@@ -67,12 +64,6 @@ hook_wait() {
67
64
  return 1
68
65
  }
69
66
 
70
- # The llm.sh subcommands used by enable (preset, policy); a function so the
71
- # tests replace it
72
- hook_llm() {
73
- DEVZONE_RACINE="$STATE_RACINE" bash "$ICI/../llm/llm.sh" "$@"
74
- }
75
-
76
67
  # Starts the relay of the service, after the pods are ready
77
68
  hook_relay() {
78
69
  bash "$(hook_script "$1")" relay-start
@@ -104,20 +95,6 @@ services_secret_postgres() { services_secret_admin postgres devzone-postgres pos
104
95
  # The superuser secret of MySQL, the same way
105
96
  services_secret_mysql() { services_secret_admin mysql devzone-mysql mysql-admin; }
106
97
 
107
- # The llm secret hook: the chart has no Secret, nothing to create
108
- services_secret_llm() { :; }
109
-
110
- # Parameters of the llm chart: the stored preset (devzone enable llm --preset
111
- # light), the model and the memory it needs
112
- services_chart_llm() {
113
- local preset
114
- # shellcheck source=SCRIPTDIR/../llm/presets.sh
115
- # shellcheck disable=SC1091
116
- . "$ICI/../llm/presets.sh"
117
- preset="$(cat "$STATE_RACINE/workspace/.llm/preset" 2>/dev/null || true)"
118
- llm_preset_sets "$preset"
119
- }
120
-
121
98
  # Value of a key of the MySQL application file (app.conf, read as text)
122
99
  app_value() { sed -n "s/^$1=//p" "$APP_CONF" 2>/dev/null | tail -1; }
123
100
 
@@ -147,16 +124,9 @@ services_chart_mysql() {
147
124
  hook_on() {
148
125
  local svc="$1"
149
126
  catalogue_argocd_active "$svc" || return 3
150
- # llm: the preset of the command line, then the ingress of the workspace
151
- if [ "$svc" = llm ]; then
152
- hook_llm preset "${@:2}" || return 1
153
- fi
154
127
  services_note "$svc" on || return 1
155
128
  services_reconcile || return 1
156
129
  echo "▶ $svc as an Argo CD Application (charts/devzone-$svc at $(argocd_revision))…"
157
- if [ "$svc" = llm ]; then
158
- hook_llm policy || return 1
159
- fi
160
130
  hook_wait "$svc" || return 1
161
131
  hook_relay "$svc" || return 1
162
132
  echo "✔ $svc held by Argo CD ([services] $svc = on in .argocd.conf)"
@@ -180,14 +150,14 @@ hook_off() {
180
150
  # is on the Application itself, not on the module state.
181
151
  hook_release() {
182
152
  local svc app
183
- for svc in postgres mysql gitlab llm; do
153
+ for svc in postgres mysql gitlab; do
184
154
  app="devzone-$svc"
185
155
  argocd_kubectl -n devzone-argocd get application.argoproj.io "$app" >/dev/null 2>&1 || continue
186
156
  argocd_kubectl -n devzone-argocd patch application.argoproj.io "$app" --type merge \
187
157
  -p '{"metadata":{"finalizers":null}}' >/dev/null 2>&1 || true
188
158
  gitops_delete_application "$app" keep || return 1
189
159
  case "$svc" in
190
- postgres | mysql | llm) services_note "$svc" off || return 1 ;;
160
+ postgres | mysql) services_note "$svc" off || return 1 ;;
191
161
  esac
192
162
  echo "✔ Application $app released: its resources stay for the helm-direct path"
193
163
  done
@@ -199,8 +169,8 @@ hook_main() {
199
169
  local svc="${1:-}" action="${2:-}"
200
170
  case "$svc:$action" in
201
171
  argocd:off) hook_load && hook_release ;;
202
- postgres:on | mysql:on | llm:on) hook_load && hook_on "$svc" "${@:3}" ;;
203
- postgres:off | mysql:off | llm:off) hook_load && hook_off "$svc" ;;
172
+ postgres:on | mysql:on) hook_load && hook_on "$svc" "${@:3}" ;;
173
+ postgres:off | mysql:off) hook_load && hook_off "$svc" ;;
204
174
  *) return 3 ;;
205
175
  esac
206
176
  }
@@ -28,7 +28,7 @@ VERSIONS="$ICI/../manage/scripts/versions.sh"
28
28
  RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
29
29
  # État par défaut de l'instance ; DEVZONE_ETAT garde la priorité (tests, CI)
30
30
  ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
31
- MODULES=(ia kubernetes gitlab postgres argocd mysql llm)
31
+ MODULES=(ia kubernetes gitlab postgres argocd mysql)
32
32
  # shellcheck source=SCRIPTDIR/cluster.sh
33
33
  # shellcheck disable=SC1091
34
34
  . "$ICI/cluster.sh"
@@ -90,7 +90,6 @@ description() {
90
90
  postgres) echo "PostgreSQL partagé, une base par projet" ;;
91
91
  argocd) echo "Argo CD, interface de déploiement du cluster des services" ;;
92
92
  mysql) echo "MySQL partagé, une base par projet" ;;
93
- llm) echo "modèle de code local (llama.cpp) dans le cluster des services" ;;
94
93
  esac
95
94
  }
96
95
 
@@ -314,8 +313,8 @@ fichier_echec() {
314
313
  echo "$ETAT-echec-$1"
315
314
  }
316
315
 
317
- # Services in the Kubernetes workspace pod (#528): gitlab, postgres, argocd and
318
- # llm live in the cluster, installed from the workstation (devzone workspace
316
+ # Services in the Kubernetes workspace pod (#528): gitlab, postgres and argocd
317
+ # live in the cluster, installed from the workstation (devzone workspace
319
318
  # services). The pod has no kubeconfig and a limited account (#430): their
320
319
  # presence is the cluster DNS (like #515), never an installer failure marker.
321
320
  dans_pod() {
@@ -324,7 +323,7 @@ dans_pod() {
324
323
 
325
324
  service_module() {
326
325
  case "$1" in
327
- gitlab | postgres | argocd | llm) return 0 ;;
326
+ gitlab | postgres | argocd) return 0 ;;
328
327
  esac
329
328
  return 1
330
329
  }
@@ -335,7 +334,6 @@ service_dns() {
335
334
  gitlab) echo "gitlab-webservice-default.devzone-gitlab${INSTANCE_SUFFIX}.svc" ;;
336
335
  postgres) echo "postgres.devzone-postgres.svc" ;;
337
336
  argocd) echo "argocd-server.devzone-argocd.svc" ;;
338
- llm) echo "llm.devzone-llm.svc" ;;
339
337
  esac
340
338
  }
341
339
 
@@ -498,6 +496,21 @@ appliquer_ia() {
498
496
  fi
499
497
  poser_garde_docker
500
498
  config_opencode
499
+ # Remove the provider of the removed llm module from old configs (#669).
500
+ if [ -f "$HOME/.config/opencode/config.json" ] && command -v jq >/dev/null 2>&1; then
501
+ tmp="$(mktemp)"
502
+ if jq '
503
+ if .provider then del(.provider["devzone-llm"]) | (if .provider == {} then del(.provider) else . end) else . end
504
+ ' "$HOME/.config/opencode/config.json" >"$tmp" 2>/dev/null; then
505
+ if [ "$(cat "$tmp")" = "{}" ] || [ "$(jq -c 'del(."$schema") | length' "$tmp" 2>/dev/null)" = 0 ]; then
506
+ rm -f "$tmp" "$HOME/.config/opencode/config.json"
507
+ else
508
+ mv "$tmp" "$HOME/.config/opencode/config.json"
509
+ fi
510
+ else
511
+ rm -f "$tmp"
512
+ fi
513
+ fi
501
514
  # Provider opencode des modèles de l'hôte (Ollama), détection à chaud :
502
515
  # silencieux et sans effet si Ollama ne répond pas.
503
516
  set_provider || true
@@ -664,7 +677,6 @@ appliquer_postgres() {
664
677
  fi
665
678
  }
666
679
 
667
- appliquer_llm() { bash "$ICI/llm/llm.sh" apply "$@"; }
668
680
  # Argo CD (#411) : installé dans le cluster des services, accès par le relais
669
681
  # 127.0.0.1:8443 ; un échec est marqué dans l'état et repris par devzone apply
670
682
  appliquer_argocd() {
@@ -1335,7 +1347,7 @@ etat() {
1335
1347
  elif [ "$(valeur "$m")" = on ] && [ "$m" = gitlab ]; then
1336
1348
  # GitLab actif : son état réel (prêt, runner, en échec)
1337
1349
  printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/gitlab/gitlab.sh" status)"
1338
- elif [ "$(valeur "$m")" = on ] && { [ "$m" = postgres ] || [ "$m" = llm ]; }; then
1350
+ elif [ "$(valeur "$m")" = on ] && [ "$m" = postgres ]; then
1339
1351
  printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/$m/$m.sh" status)"
1340
1352
  elif [ "$(valeur "$m")" = on ] && [ "$m" = argocd ]; then
1341
1353
  printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/argocd/argocd.sh" status)"
@@ -1433,12 +1445,35 @@ etat() {
1433
1445
  fi
1434
1446
  }
1435
1447
 
1448
+ # Message for the removed llm module (migration, #669).
1449
+ llm_retire_msg() {
1450
+ echo "devzone : module llm retiré : devzone n'héberge plus de modèle ; les modèles de l'hôte (Ollama) sont détectés à la place (devzone ai). Pour libérer le disque : kubectl delete namespace devzone-llm"
1451
+ }
1452
+
1453
+ # Drops the llm= state line when present and reports the removal once (#669).
1454
+ migrer_llm() {
1455
+ [ -f "$ETAT" ] || return 0
1456
+ grep -qE '^llm=' "$ETAT" 2>/dev/null || return 0
1457
+ etat_retirer llm
1458
+ llm_retire_msg
1459
+ }
1460
+
1436
1461
  changer() {
1437
1462
  local m="${2:-}"
1438
1463
  if [ -z "$m" ]; then
1439
1464
  echo "devzone : module inconnu : (aucun) ; modules : ${MODULES[*]}" >&2
1440
1465
  exit 1
1441
1466
  fi
1467
+ # llm removed (#669): migration message, never unknown module.
1468
+ if [ "$m" = llm ]; then
1469
+ initialiser 2>/dev/null || true
1470
+ if [ -f "$ETAT" ] && grep -qE '^llm=' "$ETAT" 2>/dev/null; then
1471
+ etat_retirer llm
1472
+ fi
1473
+ llm_retire_msg
1474
+ return 1
1475
+ fi
1476
+ migrer_llm
1442
1477
  # Option docker-hote (#432) : le socket de l'hôte, partagé par défaut.
1443
1478
  # Le choix ne s'applique qu'à la création du conteneur ; sans rebuild,
1444
1479
  # le conteneur courant garde son montage.
@@ -1514,6 +1549,7 @@ case "${1:-}" in
1514
1549
  activer) changer on "${2:-}" "${@:3}" ;;
1515
1550
  desactiver) changer off "${2:-}" "${@:3}" ;;
1516
1551
  appliquer)
1552
+ migrer_llm
1517
1553
  # L'utilisateur confirme l'état courant (#417, étape 4) : les
1518
1554
  # veilleurs peuvent de nouveau désinstaller
1519
1555
  etat_recouvrement_confirmer
@@ -1522,7 +1558,7 @@ case "${1:-}" in
1522
1558
  # gitlab, postgres, argocd: installed from the workstation in the
1523
1559
  # Kubernetes workspace pod (#528), by their installer elsewhere
1524
1560
  [ "$(valeur gitlab)" = off ] || appliquer_service gitlab
1525
- for m in postgres llm; do [ "$(valeur "$m")" = off ] || appliquer_service "$m"; done
1561
+ [ "$(valeur postgres)" = off ] || appliquer_service postgres
1526
1562
  [ "$(valeur mysql)" = off ] || appliquer_mysql on
1527
1563
  [ "$(valeur argocd)" = off ] || appliquer_service argocd
1528
1564
  ;;
@@ -1571,7 +1607,7 @@ case "${1:-}" in
1571
1607
  utiliser) utiliser "${@:2}" ;;
1572
1608
  clusters) DEVZONE_ETAT="$ETAT" bash "$ICI/clusters.sh" "${@:2}" ;;
1573
1609
  cluster) changer_cluster "${@:2}" ;;
1574
- postgres | llm) DEVZONE_ETAT="$ETAT" bash "$ICI/$1/$1.sh" "${@:2}" ;;
1610
+ postgres) DEVZONE_ETAT="$ETAT" bash "$ICI/postgres/postgres.sh" "${@:2}" ;;
1575
1611
  mysql) DEVZONE_ETAT="$ETAT" bash "$ICI/catalogue/mysql/mysql.sh" "${@:2}" ;;
1576
1612
  gitlab) DEVZONE_ETAT="$ETAT" bash "$ICI/gitlab/gitlab.sh" "${@:2}" ;;
1577
1613
  catalogue) DEVZONE_ETAT="$ETAT" bash "$ICI/catalogue.sh" list ;;