devzone 1.1.0 → 3.0.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.
- package/.devcontainer/Dockerfile +4 -4
- package/.devcontainer/{agent-erreurs.sh → agent-errors.sh} +6 -6
- package/.devcontainer/agent-local.sh +2 -2
- package/.devcontainer/{agent-modele.messages → agent-model.messages} +1 -1
- package/.devcontainer/{agent-modele.sh → agent-model.sh} +5 -5
- package/.devcontainer/agent-pod-manifest.sh +4 -4
- package/.devcontainer/{agent-droits.sh → agent-rights.sh} +2 -2
- package/.devcontainer/agent-session.sh +3 -3
- package/.devcontainer/{agent-etat-json.sh → agent-state-json.sh} +6 -6
- package/.devcontainer/agent-workspace.sh +1 -1
- package/.devcontainer/agent.sh +14 -14
- package/.devcontainer/{ia/docker-garde.sh → ai/docker-guard.sh} +1 -1
- package/.devcontainer/{ia → ai}/host-models.sh +2 -2
- package/.devcontainer/{ia/plugins/devzone-garde-v2.js → ai/plugins/devzone-guard-v2.js} +7 -7
- package/.devcontainer/{ia/plugins/devzone-garde.js → ai/plugins/devzone-guard.js} +6 -6
- package/.devcontainer/argocd/argocd.sh +94 -93
- package/.devcontainer/argocd/{catalogue-argocd.sh → catalog-argocd.sh} +3 -3
- package/.devcontainer/argocd/services-hook.sh +8 -8
- package/.devcontainer/argocd/services.sh +1 -1
- package/.devcontainer/catalog/app.sh +209 -0
- package/.devcontainer/catalog/catalog-watcher.sh +130 -0
- package/.devcontainer/{catalogue → catalog}/mysql/app.conf +1 -1
- package/.devcontainer/catalog/mysql/install.sh +87 -0
- package/.devcontainer/catalog/mysql/mysql.sh +262 -0
- package/.devcontainer/catalog/mysql/volume.sh +71 -0
- package/.devcontainer/catalog.sh +231 -0
- package/.devcontainer/chart-direct.sh +1 -1
- package/.devcontainer/cluster.sh +222 -224
- package/.devcontainer/clusters.sh +41 -41
- package/.devcontainer/devcontainer.json +1 -1
- package/.devcontainer/devzone +103 -1506
- package/.devcontainer/devzone-ai-guard.sh +76 -0
- package/.devcontainer/devzone-ai.sh +201 -0
- package/.devcontainer/devzone-cluster.sh +210 -0
- package/.devcontainer/devzone-modules.sh +126 -0
- package/.devcontainer/devzone-platform.sh +189 -0
- package/.devcontainer/devzone-repair.sh +94 -0
- package/.devcontainer/devzone-services.sh +241 -0
- package/.devcontainer/devzone-skill.sh +97 -0
- package/.devcontainer/devzone-status.sh +140 -0
- package/.devcontainer/devzone-version.sh +78 -0
- package/.devcontainer/git-identity.sh +28 -0
- package/.devcontainer/gitlab/argocd.sh +2 -2
- package/.devcontainer/gitlab/chart.sh +2 -2
- package/.devcontainer/gitlab/gitlab.sh +83 -84
- package/.devcontainer/gitlab/installation.sh +111 -111
- package/.devcontainer/gitlab/secrets.sh +47 -47
- package/.devcontainer/gitlab/seed.sh +77 -77
- package/.devcontainer/gitlab/test-gitlab.sh +242 -243
- package/.devcontainer/help.sh +1 -1
- package/.devcontainer/isolation.sh +65 -0
- package/.devcontainer/kind-wrapper.sh +45 -0
- package/.devcontainer/kube-account.sh +199 -0
- package/.devcontainer/kube-config.sh +45 -46
- package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
- package/.devcontainer/kube-reachable.sh +64 -0
- package/.devcontainer/{memoire.sh → memory.sh} +1 -1
- package/.devcontainer/metrics-server.sh +2 -2
- package/.devcontainer/opencode.jsonc +2 -2
- package/.devcontainer/packages.sh +228 -0
- package/.devcontainer/password.sh +1 -1
- package/.devcontainer/ports-auto.sh +152 -153
- package/.devcontainer/ports-json.sh +16 -15
- package/.devcontainer/ports.sh +127 -123
- package/.devcontainer/post-create.sh +52 -52
- package/.devcontainer/postgres/postgres.sh +176 -176
- package/.devcontainer/rename-legacy-files.sh +103 -0
- package/.devcontainer/services-admin.sh +5 -5
- package/.devcontainer/skills/devzone/SKILL.md +40 -41
- package/.devcontainer/startup.sh +65 -0
- package/.devcontainer/{etat-gitops.sh → state-gitops.sh} +1 -1
- package/.devcontainer/{etat-json.sh → state-json.sh} +39 -65
- package/.devcontainer/{etat-verrou.sh → state-lock.sh} +1 -1
- package/.devcontainer/{etat.sh → state.sh} +4 -4
- package/.devcontainer/workspace-init.sh +17 -3
- package/Makefile +8 -8
- package/README.md +195 -194
- package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
- package/manage/devzone +8 -10
- package/manage/scripts/argocd-workspace.sh +1 -1
- package/manage/scripts/check-go-layout.sh +40 -0
- package/manage/scripts/check-names.sh +61 -0
- package/manage/scripts/create-cluster.sh +1 -1
- package/manage/scripts/create-mode.sh +2 -2
- package/manage/scripts/devzone-create.sh +5 -5
- package/manage/scripts/devzone-manifest.sh +3 -3
- package/manage/scripts/devzone-update.sh +12 -8
- package/manage/scripts/docker-workstation.sh +2 -2
- package/manage/scripts/docker.sh +2 -2
- package/manage/scripts/{lancer.sh → launch.sh} +10 -51
- package/manage/scripts/{migrer-retour.sh → migrate-revert.sh} +4 -4
- package/manage/scripts/{migrer.sh → migrate.sh} +8 -14
- package/manage/scripts/ports-apps.sh +1 -1
- package/manage/scripts/ports-workspace.sh +7 -7
- package/manage/scripts/{desinstaller.sh → uninstall.sh} +8 -8
- package/manage/scripts/workspace-egress.sh +2 -2
- package/manage/scripts/workspace-update.sh +5 -2
- package/manage/scripts/workspace-wait.sh +2 -2
- package/manage/workspace.sh +4 -4
- package/package.json +1 -1
- package/.devcontainer/catalogue/app.sh +0 -211
- package/.devcontainer/catalogue/catalogue-veilleur.sh +0 -130
- package/.devcontainer/catalogue/mysql/installer.sh +0 -87
- package/.devcontainer/catalogue/mysql/mysql.sh +0 -262
- package/.devcontainer/catalogue/mysql/volume.sh +0 -71
- package/.devcontainer/catalogue.sh +0 -231
- package/.devcontainer/demarrage.sh +0 -66
- package/.devcontainer/docker-relais.sh +0 -149
- package/.devcontainer/docker-sans-hote.sh +0 -12
- package/.devcontainer/git-identite.sh +0 -28
- package/.devcontainer/isolement.sh +0 -65
- package/.devcontainer/kind-enveloppe.sh +0 -45
- package/.devcontainer/kube-compte.sh +0 -200
- package/.devcontainer/kube-joignable.sh +0 -64
- package/.devcontainer/paquets.sh +0 -227
- /package/.devcontainer/{ia/docker-garde.message → ai/docker-guard.message} +0 -0
- /package/.devcontainer/{ia → ai}/host-check.message +0 -0
- /package/.devcontainer/{ia → ai}/host-check.sh +0 -0
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# devzone, ai module: guard of the host container tools.
|
|
4
|
+
# Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
|
|
5
|
+
# functions only, shared variables are defined in devzone.
|
|
6
|
+
|
|
7
|
+
# Docker guard for the folders that are not this repository: a Claude Code
|
|
8
|
+
# PreToolUse hook in the global settings and the two opencode plugins in the
|
|
9
|
+
# global plugins folder. Idempotent, other user settings and hooks preserved.
|
|
10
|
+
install_docker_guard() {
|
|
11
|
+
local script="$ICI/ai/docker-guard.sh" config="$HOME/.claude/settings.json"
|
|
12
|
+
local src="$ICI/ai/plugins" dst="$HOME/.config/opencode/plugins"
|
|
13
|
+
local tmp f
|
|
14
|
+
if ! command -v jq >/dev/null 2>&1; then
|
|
15
|
+
echo "devzone : jq missing: docker guard not installed for Claude Code" >&2
|
|
16
|
+
elif [ ! -f "$config" ]; then
|
|
17
|
+
echo "devzone : $config missing: docker guard not installed for Claude Code" >&2
|
|
18
|
+
elif ! jq -e . "$config" >/dev/null 2>&1; then
|
|
19
|
+
echo "devzone : $config unreadable (invalid JSON): docker guard not installed for Claude Code" >&2
|
|
20
|
+
else
|
|
21
|
+
tmp="$(mktemp)"
|
|
22
|
+
if jq --arg cmd "bash \"$script\" --format claude" '
|
|
23
|
+
.hooks = (.hooks // {}) |
|
|
24
|
+
.hooks.PreToolUse = (.hooks.PreToolUse // []) |
|
|
25
|
+
if ([.hooks.PreToolUse[]? | .hooks[]? | (.command // "")] | any(contains("docker-guard.sh")))
|
|
26
|
+
then .
|
|
27
|
+
else .hooks.PreToolUse += [{"matcher": "Bash", "hooks": [{"type": "command", "command": $cmd}]}]
|
|
28
|
+
end
|
|
29
|
+
' "$config" >"$tmp" 2>/dev/null; then
|
|
30
|
+
mv "$tmp" "$config"
|
|
31
|
+
else
|
|
32
|
+
rm -f "$tmp"
|
|
33
|
+
echo "devzone : $config unchanged: docker guard not installed for Claude Code" >&2
|
|
34
|
+
fi
|
|
35
|
+
fi
|
|
36
|
+
mkdir -p "$dst"
|
|
37
|
+
for f in devzone-guard.js devzone-guard-v2.js; do
|
|
38
|
+
[ -f "$src/$f" ] || continue
|
|
39
|
+
sed "s|__DEVZONE_DOCKER_GUARD__|$script|g" "$src/$f" >"$dst/$f"
|
|
40
|
+
done
|
|
41
|
+
echo "devzone : docker guard active for Claude Code and opencode"
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# Removes only the Docker guard entries (commands containing docker-guard.sh)
|
|
45
|
+
# and the two plugins; the rest of settings.json and of the plugins is kept.
|
|
46
|
+
remove_docker_guard() {
|
|
47
|
+
local config="$HOME/.claude/settings.json" tmp
|
|
48
|
+
if [ -f "$config" ] && jq -e . "$config" >/dev/null 2>&1; then
|
|
49
|
+
tmp="$(mktemp)"
|
|
50
|
+
if jq '
|
|
51
|
+
if (.hooks.PreToolUse // null) != null then
|
|
52
|
+
.hooks.PreToolUse = [
|
|
53
|
+
.hooks.PreToolUse[] |
|
|
54
|
+
if (.hooks // null) != null then
|
|
55
|
+
.hooks = [ .hooks[] | select(((.command // "") | contains("docker-guard.sh")) | not) ] |
|
|
56
|
+
select((.hooks | length) > 0)
|
|
57
|
+
else
|
|
58
|
+
select(((.command // "") | contains("docker-guard.sh")) | not)
|
|
59
|
+
end
|
|
60
|
+
] |
|
|
61
|
+
if (.hooks.PreToolUse | length) == 0 then del(.hooks.PreToolUse) else . end |
|
|
62
|
+
if ((.hooks // {}) | keys | length) == 0 then del(.hooks) else . end
|
|
63
|
+
else . end
|
|
64
|
+
' "$config" >"$tmp" 2>/dev/null; then
|
|
65
|
+
if [ "$(cat "$tmp")" = "{}" ]; then
|
|
66
|
+
rm -f "$tmp" "$config"
|
|
67
|
+
else
|
|
68
|
+
mv "$tmp" "$config"
|
|
69
|
+
fi
|
|
70
|
+
else
|
|
71
|
+
rm -f "$tmp"
|
|
72
|
+
fi
|
|
73
|
+
fi
|
|
74
|
+
rm -f "$HOME/.config/opencode/plugins/devzone-guard.js" \
|
|
75
|
+
"$HOME/.config/opencode/plugins/devzone-guard-v2.js"
|
|
76
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# devzone, ai module: opencode config, assistants install, apply.
|
|
4
|
+
# Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
|
|
5
|
+
# functions only, shared variables are defined in devzone.
|
|
6
|
+
|
|
7
|
+
# Marker of the default configuration: first line of opencode.jsonc. The former
|
|
8
|
+
# wording (French, before #722) is still recognised. Byte escapes keep the accent
|
|
9
|
+
# out of the source (check-english).
|
|
10
|
+
OPENCODE_MARKER='// devzone : default opencode configuration'
|
|
11
|
+
|
|
12
|
+
# True if the file carries the default-configuration marker
|
|
13
|
+
opencode_marked() { grep -qF -e "$OPENCODE_MARKER" "$1"; }
|
|
14
|
+
|
|
15
|
+
# Default opencode configuration (versioned model): written at first use,
|
|
16
|
+
# updated while it keeps the devzone marker, customised otherwise. The marker
|
|
17
|
+
# text is written in opencode.jsonc: it is kept as is.
|
|
18
|
+
opencode_config() {
|
|
19
|
+
local model="$ICI/opencode.jsonc" target
|
|
20
|
+
if [ -f "$HOME/.config/opencode/opencode.jsonc" ]; then
|
|
21
|
+
target="$HOME/.config/opencode/opencode.jsonc"
|
|
22
|
+
elif [ -f "$HOME/.config/opencode/opencode.json" ]; then
|
|
23
|
+
target="$HOME/.config/opencode/opencode.json"
|
|
24
|
+
else
|
|
25
|
+
target="$HOME/.config/opencode/opencode.jsonc"
|
|
26
|
+
fi
|
|
27
|
+
mkdir -p "$(dirname "$target")"
|
|
28
|
+
if [ ! -f "$target" ]; then
|
|
29
|
+
cp "$model" "$target"
|
|
30
|
+
echo "opencode : default configuration written"
|
|
31
|
+
elif opencode_marked "$target"; then
|
|
32
|
+
if ! cmp -s "$model" "$target"; then
|
|
33
|
+
cp "$model" "$target"
|
|
34
|
+
echo "opencode : default configuration updated"
|
|
35
|
+
fi
|
|
36
|
+
elif only_schema_key "$target"; then
|
|
37
|
+
cp "$model" "$target"
|
|
38
|
+
echo "opencode : default configuration updated"
|
|
39
|
+
else
|
|
40
|
+
echo "opencode : custom configuration, kept"
|
|
41
|
+
fi
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# Removes the opencode configuration written by devzone if it still carries its
|
|
45
|
+
# marker and was not changed; a custom configuration (no marker, or changed) is
|
|
46
|
+
# kept. Symmetrical with opencode_config.
|
|
47
|
+
remove_opencode_config() {
|
|
48
|
+
local model target
|
|
49
|
+
model="$ICI/opencode.jsonc"
|
|
50
|
+
if [ -f "$HOME/.config/opencode/opencode.jsonc" ]; then
|
|
51
|
+
target="$HOME/.config/opencode/opencode.jsonc"
|
|
52
|
+
elif [ -f "$HOME/.config/opencode/opencode.json" ]; then
|
|
53
|
+
target="$HOME/.config/opencode/opencode.json"
|
|
54
|
+
else
|
|
55
|
+
return 0
|
|
56
|
+
fi
|
|
57
|
+
if opencode_marked "$target" && cmp -s "$model" "$target"; then
|
|
58
|
+
rm -f "$target"
|
|
59
|
+
echo "opencode : default configuration removed"
|
|
60
|
+
else
|
|
61
|
+
echo "opencode : custom configuration, kept"
|
|
62
|
+
fi
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
# Log of the last npm run (its path is to give on failure), or its folder;
|
|
66
|
+
# timestamped names: the last one in glob order is the most recent
|
|
67
|
+
last_npm_log() {
|
|
68
|
+
local log="" f
|
|
69
|
+
for f in "$HOME"/.npm/_logs/*-debug-0.log; do
|
|
70
|
+
if [ -f "$f" ]; then log="$f"; fi
|
|
71
|
+
done
|
|
72
|
+
echo "${log:-$HOME/.npm/_logs}"
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
# Installs each pinned AI assistant with its own npm command (3 tries each),
|
|
76
|
+
# then checks its binary: npm silently drops a platform binary it failed to
|
|
77
|
+
# download (#194), and one assistant failing must not block the other.
|
|
78
|
+
install_ai() {
|
|
79
|
+
local package binary attempt
|
|
80
|
+
IA_FAILED=()
|
|
81
|
+
for package in "${IA_PAQUETS[@]}"; do
|
|
82
|
+
case "$package" in
|
|
83
|
+
opencode-ai@*) binary=opencode ;;
|
|
84
|
+
*) binary=claude ;;
|
|
85
|
+
esac
|
|
86
|
+
for attempt in 1 2 3; do
|
|
87
|
+
if with_progress npm install -g --no-fund --no-audit --loglevel=error "$package" >/dev/null &&
|
|
88
|
+
"$binary" --version >/dev/null 2>&1; then
|
|
89
|
+
break
|
|
90
|
+
fi
|
|
91
|
+
if [ "$attempt" -lt 3 ]; then
|
|
92
|
+
echo "devzone : installation of ${package%@*} incomplete, retrying ($((attempt + 1))/3)…" >&2
|
|
93
|
+
else
|
|
94
|
+
IA_FAILED+=("$package")
|
|
95
|
+
fi
|
|
96
|
+
done
|
|
97
|
+
done
|
|
98
|
+
[ "${#IA_FAILED[@]}" -eq 0 ]
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
apply_ia() {
|
|
102
|
+
local log tmp detected
|
|
103
|
+
if [ "$1" = on ]; then
|
|
104
|
+
echo "devzone : installing Claude Code and opencode (a few minutes)…"
|
|
105
|
+
if ! install_ai; then
|
|
106
|
+
log="$(last_npm_log)"
|
|
107
|
+
echo "npm log: $log" >"$(failure_marker_file ia)"
|
|
108
|
+
echo "devzone : installation of ${IA_FAILED[*]} failed (npm install -g, 3 tries); npm log: $log; retry: devzone apply" >&2
|
|
109
|
+
return 1
|
|
110
|
+
fi
|
|
111
|
+
rm -f "$(failure_marker_file ia)"
|
|
112
|
+
echo "devzone : Claude Code and opencode installed"
|
|
113
|
+
# repowarden guard (Claude Code PreToolUse hook, opencode plugin): the
|
|
114
|
+
# agent is stopped before changing main/develop, committing without
|
|
115
|
+
# repowarden cc, or bypassing the hooks. Global, in the ~/.claude and
|
|
116
|
+
# ~/.config/opencode volumes: kept across rebuilds; rerun, nothing changes
|
|
117
|
+
if command -v repowarden >/dev/null 2>&1 && repowarden agents init --global >/dev/null 2>&1; then
|
|
118
|
+
echo "devzone : repowarden guard active for Claude Code and opencode"
|
|
119
|
+
else
|
|
120
|
+
echo "devzone : repowarden guard not connected (repowarden 4.10 or later required): repowarden agents init --global" >&2
|
|
121
|
+
fi
|
|
122
|
+
install_docker_guard
|
|
123
|
+
opencode_config
|
|
124
|
+
# Remove the provider of the removed llm module from old configs (#669).
|
|
125
|
+
if [ -f "$HOME/.config/opencode/config.json" ] && command -v jq >/dev/null 2>&1; then
|
|
126
|
+
tmp="$(mktemp)"
|
|
127
|
+
if jq '
|
|
128
|
+
if .provider then del(.provider["devzone-llm"]) | (if .provider == {} then del(.provider) else . end) else . end
|
|
129
|
+
' "$HOME/.config/opencode/config.json" >"$tmp" 2>/dev/null; then
|
|
130
|
+
if [ "$(cat "$tmp")" = "{}" ] || [ "$(jq -c 'del(."$schema") | length' "$tmp" 2>/dev/null)" = 0 ]; then
|
|
131
|
+
rm -f "$tmp" "$HOME/.config/opencode/config.json"
|
|
132
|
+
else
|
|
133
|
+
mv "$tmp" "$HOME/.config/opencode/config.json"
|
|
134
|
+
fi
|
|
135
|
+
else
|
|
136
|
+
rm -f "$tmp"
|
|
137
|
+
fi
|
|
138
|
+
fi
|
|
139
|
+
# opencode provider of the host models (Ollama), live detection:
|
|
140
|
+
# silent and without effect if Ollama does not answer.
|
|
141
|
+
set_provider || true
|
|
142
|
+
# Reports the state of the detection (success in both cases).
|
|
143
|
+
detected="$(modeles 2>/dev/null || true)"
|
|
144
|
+
if [ -n "$detected" ]; then
|
|
145
|
+
printf "devzone : %s model(s) of the host (Ollama) connected\n" "$(printf '%s\n' "$detected" | grep -c .)"
|
|
146
|
+
else
|
|
147
|
+
printf "devzone : no Ollama model detected on %s (host models not connected)\n" "$URL"
|
|
148
|
+
fi
|
|
149
|
+
# devzone skill: installed if missing, updated if unchanged, kept if customised.
|
|
150
|
+
install_devzone_skill
|
|
151
|
+
echo "devzone : ai active: claude (then /login), opencode auth login"
|
|
152
|
+
else
|
|
153
|
+
npm uninstall -g "${IA_NOMS[@]}" >/dev/null 2>&1 || true
|
|
154
|
+
rm -f "$(failure_marker_file ia)"
|
|
155
|
+
# repowarden guard: removed on disable (symmetrical with the enable).
|
|
156
|
+
# repowarden does it itself when present; otherwise removal by jq of only
|
|
157
|
+
# the PreToolUse entries calling the guard, the rest of settings.json
|
|
158
|
+
# intact. The guard is called " repowarden guard " since repowarden
|
|
159
|
+
# 4.17.3; " repowarden garde " is its old name, still an alias on the
|
|
160
|
+
# repowarden side and recognised here.
|
|
161
|
+
if command -v repowarden >/dev/null 2>&1; then
|
|
162
|
+
repowarden agents retirer --global >/dev/null 2>&1 || true
|
|
163
|
+
elif [ -f "$HOME/.claude/settings.json" ]; then
|
|
164
|
+
tmp="$(mktemp)"
|
|
165
|
+
if jq '
|
|
166
|
+
if (.hooks.PreToolUse // null) != null then
|
|
167
|
+
.hooks.PreToolUse = [
|
|
168
|
+
.hooks.PreToolUse[] |
|
|
169
|
+
if (.hooks // null) != null then
|
|
170
|
+
.hooks = [ .hooks[] | select(((.command // "") | (contains("repowarden garde") or contains("repowarden guard"))) | not) ] |
|
|
171
|
+
select((.hooks | length) > 0)
|
|
172
|
+
else
|
|
173
|
+
select(((.command // "") | (contains("repowarden garde") or contains("repowarden guard"))) | not)
|
|
174
|
+
end
|
|
175
|
+
] |
|
|
176
|
+
if (.hooks.PreToolUse | length) == 0 then del(.hooks.PreToolUse) else . end |
|
|
177
|
+
if ((.hooks // {}) | keys | length) == 0 then del(.hooks) else . end
|
|
178
|
+
else . end
|
|
179
|
+
' "$HOME/.claude/settings.json" >"$tmp" 2>/dev/null; then
|
|
180
|
+
mv "$tmp" "$HOME/.claude/settings.json"
|
|
181
|
+
else
|
|
182
|
+
rm -f "$tmp"
|
|
183
|
+
fi
|
|
184
|
+
fi
|
|
185
|
+
# opencode plugin of the guard (also removed by repowarden above)
|
|
186
|
+
rm -f "$HOME/.config/opencode/plugins/repowarden-garde.js" \
|
|
187
|
+
"$HOME/.config/opencode/plugins/repowarden-garde-v2.js"
|
|
188
|
+
# docker guard: only its entries and its plugins are removed.
|
|
189
|
+
remove_docker_guard
|
|
190
|
+
# opencode configuration: removed only if it carries the devzone marker
|
|
191
|
+
# and was not changed; customised -> kept.
|
|
192
|
+
remove_opencode_config
|
|
193
|
+
# Removes the opencode provider of the host models, keeps the rest of the file.
|
|
194
|
+
unset_provider || true
|
|
195
|
+
# devzone skill: removed only if unchanged; customised -> kept.
|
|
196
|
+
remove_devzone_skill
|
|
197
|
+
# devzone agent state: kept in the shared volume (disabling it in one
|
|
198
|
+
# devzone does not remove the state of the others).
|
|
199
|
+
echo "devzone : ai disabled (logins and devzone agent state kept in their volumes; workspace/.agents/ logs kept)"
|
|
200
|
+
fi
|
|
201
|
+
}
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# devzone, working cluster: change, use.
|
|
4
|
+
# Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
|
|
5
|
+
# functions only, shared variables are defined in devzone.
|
|
6
|
+
|
|
7
|
+
# All the databases disappear: confirmation in the terminal (without a terminal,
|
|
8
|
+
# the command is explicit); a yes or --yes sets DELETE_DATA, read by
|
|
9
|
+
# apply_mysql to run delete-data (#441). The arguments go through reject_renamed:
|
|
10
|
+
# --oui is refused before reaching here, only --yes passes (#695).
|
|
11
|
+
confirm_removal() {
|
|
12
|
+
local app="$1" answer arg
|
|
13
|
+
DELETE_DATA=""
|
|
14
|
+
[ "$(value_of "$app")" = on ] || return 0
|
|
15
|
+
for arg in "${@:2}"; do
|
|
16
|
+
case "$arg" in --yes) DELETE_DATA=1 ;; esac
|
|
17
|
+
done
|
|
18
|
+
[ -z "$DELETE_DATA" ] || return 0
|
|
19
|
+
cluster_interactive || return 0
|
|
20
|
+
# mysql: the question is about the namespace (volume and databases stay);
|
|
21
|
+
# postgres: everything goes, the refusal cancels; gitlab: the Rails secret
|
|
22
|
+
# stays, its deletion only happens on a full uninstall on purpose
|
|
23
|
+
if [ "$app" = mysql ]; then
|
|
24
|
+
printf 'Disabling mysql removes the server; the volume and databases stay. Also delete the devzone-mysql namespace and its volumes? [y/N] ' >&2
|
|
25
|
+
elif [ "$app" = gitlab ]; then
|
|
26
|
+
printf 'Disabling gitlab keeps the Rails secret (browser sessions stay valid at reinstall). Also delete the Rails secret? [y/N] ' >&2
|
|
27
|
+
else
|
|
28
|
+
printf 'Disabling %s deletes all its databases. Continue? [y/N] ' "$app" >&2
|
|
29
|
+
fi
|
|
30
|
+
read -r answer || answer=""
|
|
31
|
+
case "$answer" in
|
|
32
|
+
y | Y | yes) DELETE_DATA=1; return 0 ;;
|
|
33
|
+
esac
|
|
34
|
+
# refusal: mysql and gitlab still disable (data kept), postgres cancels
|
|
35
|
+
case "$app" in
|
|
36
|
+
mysql | gitlab) return 0 ;;
|
|
37
|
+
*) echo "Aborted: nothing was deleted."; return 1 ;;
|
|
38
|
+
esac
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# devzone cluster [CTX] [--yes]: shows the services cluster, or moves the
|
|
42
|
+
# services to it (uninstalled from the old one, installed on the new one: data
|
|
43
|
+
# not migrated, hence the confirmation)
|
|
44
|
+
change_cluster() {
|
|
45
|
+
local wanted="" yes="" confirm_ctx="" expect="" arg current new answer ctx_old ctx_new NS
|
|
46
|
+
NS=devzone-postgres
|
|
47
|
+
for arg in "$@"; do
|
|
48
|
+
if [ -n "$expect" ]; then
|
|
49
|
+
confirm_ctx="$arg"
|
|
50
|
+
expect=""
|
|
51
|
+
continue
|
|
52
|
+
fi
|
|
53
|
+
case "$arg" in
|
|
54
|
+
--yes) yes=1 ;;
|
|
55
|
+
--confirm) expect=1 ;;
|
|
56
|
+
-*) echo "devzone : unknown argument: $arg (devzone cluster [CTX] [--yes] [--confirm CTX])" >&2; return 2 ;;
|
|
57
|
+
*) wanted="$arg" ;;
|
|
58
|
+
esac
|
|
59
|
+
done
|
|
60
|
+
if [ -n "$expect" ]; then
|
|
61
|
+
echo "devzone : --confirm expects a context" >&2
|
|
62
|
+
return 2
|
|
63
|
+
fi
|
|
64
|
+
current="$(cluster_saved)"
|
|
65
|
+
if [ -z "$wanted" ]; then
|
|
66
|
+
if [ -z "$current" ]; then
|
|
67
|
+
echo "devzone : no cluster chosen (set when a module is enabled: devzone enable postgres)"
|
|
68
|
+
elif cluster_is_dedicated "$current"; then
|
|
69
|
+
echo "devzone : cluster $current (dedicated kind, in the container)"
|
|
70
|
+
else
|
|
71
|
+
echo "devzone : cluster $current (host cluster)"
|
|
72
|
+
fi
|
|
73
|
+
echo " possible: $(cluster_candidates | tr '\n' ' ')"
|
|
74
|
+
return 0
|
|
75
|
+
fi
|
|
76
|
+
if [ -n "$confirm_ctx" ]; then
|
|
77
|
+
new="$(cluster_choose "$wanted" --confirm "$confirm_ctx")" || return 2
|
|
78
|
+
else
|
|
79
|
+
new="$(cluster_choose "$wanted")" || return 2
|
|
80
|
+
fi
|
|
81
|
+
if [ "$new" = "$current" ]; then
|
|
82
|
+
echo "devzone : already on $new, nothing to do."
|
|
83
|
+
return 0
|
|
84
|
+
fi
|
|
85
|
+
ctx_old="$current"
|
|
86
|
+
ctx_new="$new"
|
|
87
|
+
if [ "$(value_of postgres)" = on ]; then
|
|
88
|
+
if [ -z "$yes" ]; then
|
|
89
|
+
if ! cluster_interactive; then
|
|
90
|
+
echo "devzone : the postgres databases will be deleted from $ctx_old (not migrated): devzone cluster $ctx_new --yes" >&2
|
|
91
|
+
return 1
|
|
92
|
+
fi
|
|
93
|
+
printf 'postgres will be reinstalled on %s, its databases deleted from %s (not migrated). Continue? [y/N] ' "$ctx_new" "$ctx_old" >&2
|
|
94
|
+
read -r answer || answer=""
|
|
95
|
+
case "$answer" in
|
|
96
|
+
y | Y | yes) ;;
|
|
97
|
+
*) echo "Aborted: nothing changed."; return 0 ;;
|
|
98
|
+
esac
|
|
99
|
+
fi
|
|
100
|
+
# Removes PostgreSQL from the old cluster (explicit context);
|
|
101
|
+
# namespace and RoleBinding by the administrator (#430)
|
|
102
|
+
export KUBECONFIG="$HOME/.kube/config:$HOME/.kube/hote.config"
|
|
103
|
+
account_remove "$ctx_old" "$NS" >/dev/null 2>&1 || true
|
|
104
|
+
account_admin "$ctx_old" delete namespace "$NS" --wait=true >/dev/null 2>&1 || true
|
|
105
|
+
cluster_release "$ctx_old"
|
|
106
|
+
# The new cluster becomes the devzone context
|
|
107
|
+
cluster_save "$ctx_new"
|
|
108
|
+
# Sets the devzone context on the new cluster (cluster + user:
|
|
109
|
+
# important command, failure shown and rendered #396)
|
|
110
|
+
if ! devzone_context_set "$ctx_new"; then
|
|
111
|
+
echo "devzone : cannot set the devzone context on $ctx_new" >&2
|
|
112
|
+
return 1
|
|
113
|
+
fi
|
|
114
|
+
# Installs PostgreSQL on the new cluster (via --context devzone which now points to it)
|
|
115
|
+
bash "$ICI/postgres/postgres.sh" install
|
|
116
|
+
else
|
|
117
|
+
cluster_save "$ctx_new"
|
|
118
|
+
# Sets the devzone context on the new cluster (cluster + user:
|
|
119
|
+
# important command, failure shown and rendered #396)
|
|
120
|
+
if ! devzone_context_set "$ctx_new"; then
|
|
121
|
+
echo "devzone : cannot set the devzone context on $ctx_new" >&2
|
|
122
|
+
return 1
|
|
123
|
+
fi
|
|
124
|
+
fi
|
|
125
|
+
echo "devzone : services cluster: $ctx_new"
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
# Switches the user's working cluster (#341). Never touches the devzone services
|
|
129
|
+
# cluster: no cluster_save, no cluster= line in the state.
|
|
130
|
+
use_cluster() {
|
|
131
|
+
local ctx="" confirm_ctx="" namespace="" answer arg current
|
|
132
|
+
while [ "$#" -gt 0 ]; do
|
|
133
|
+
arg="$1"
|
|
134
|
+
shift
|
|
135
|
+
case "$arg" in
|
|
136
|
+
-n | --namespace)
|
|
137
|
+
if [ "$#" -eq 0 ]; then
|
|
138
|
+
echo "devzone : -n expects a namespace" >&2
|
|
139
|
+
return 2
|
|
140
|
+
fi
|
|
141
|
+
namespace="$1"
|
|
142
|
+
shift
|
|
143
|
+
;;
|
|
144
|
+
--namespace=*) namespace="${arg#*=}" ;;
|
|
145
|
+
--confirm)
|
|
146
|
+
if [ "$#" -eq 0 ]; then
|
|
147
|
+
echo "devzone : --confirm expects a context" >&2
|
|
148
|
+
return 2
|
|
149
|
+
fi
|
|
150
|
+
confirm_ctx="$1"
|
|
151
|
+
shift
|
|
152
|
+
;;
|
|
153
|
+
--confirm=*) confirm_ctx="${arg#*=}" ;;
|
|
154
|
+
-*)
|
|
155
|
+
echo "devzone : unknown argument: $arg (devzone use CTX [-n NS] [--confirm CTX])" >&2
|
|
156
|
+
return 2
|
|
157
|
+
;;
|
|
158
|
+
*)
|
|
159
|
+
if [ -n "$ctx" ]; then
|
|
160
|
+
echo "devzone : unknown argument: $arg (devzone use CTX [-n NS] [--confirm CTX])" >&2
|
|
161
|
+
return 2
|
|
162
|
+
fi
|
|
163
|
+
ctx="$arg"
|
|
164
|
+
;;
|
|
165
|
+
esac
|
|
166
|
+
done
|
|
167
|
+
if [ -z "$ctx" ]; then
|
|
168
|
+
if [ -z "$namespace" ]; then
|
|
169
|
+
echo "devzone : missing context: devzone use CTX" >&2
|
|
170
|
+
return 2
|
|
171
|
+
fi
|
|
172
|
+
current="$(kubectl config current-context 2>/dev/null || true)"
|
|
173
|
+
if [ -z "$current" ]; then
|
|
174
|
+
echo "devzone : no current context" >&2
|
|
175
|
+
return 2
|
|
176
|
+
fi
|
|
177
|
+
ctx="$current"
|
|
178
|
+
fi
|
|
179
|
+
if ! kubectl config get-contexts -o name 2>/dev/null | grep -qxF -- "$ctx"; then
|
|
180
|
+
echo "devzone : unknown context: $ctx (see kubectl config get-contexts)" >&2
|
|
181
|
+
return 2
|
|
182
|
+
fi
|
|
183
|
+
current="$(kubectl config current-context 2>/dev/null || true)"
|
|
184
|
+
if [ "$ctx" != "$current" ]; then
|
|
185
|
+
if ! cluster_is_local "$ctx"; then
|
|
186
|
+
if [ -n "$confirm_ctx" ]; then
|
|
187
|
+
if [ "$confirm_ctx" != "$ctx" ]; then
|
|
188
|
+
echo "devzone : remote cluster refused: $ctx (--confirm $ctx)" >&2
|
|
189
|
+
return 2
|
|
190
|
+
fi
|
|
191
|
+
elif cluster_interactive; then
|
|
192
|
+
printf 'remote cluster: %s; type its name to confirm: ' "$ctx" >&2
|
|
193
|
+
read -r answer || answer=""
|
|
194
|
+
if [ "$answer" != "$ctx" ]; then
|
|
195
|
+
echo "devzone : remote cluster refused: $ctx (--confirm $ctx)" >&2
|
|
196
|
+
return 2
|
|
197
|
+
fi
|
|
198
|
+
else
|
|
199
|
+
echo "devzone : remote cluster refused: $ctx (--confirm $ctx)" >&2
|
|
200
|
+
return 2
|
|
201
|
+
fi
|
|
202
|
+
fi
|
|
203
|
+
kubectl config use-context "$ctx" >/dev/null
|
|
204
|
+
fi
|
|
205
|
+
if [ -n "$namespace" ]; then
|
|
206
|
+
kubectl config set-context "$ctx" --namespace "$namespace" >/dev/null
|
|
207
|
+
fi
|
|
208
|
+
echo "working cluster: $ctx"
|
|
209
|
+
[ -z "$namespace" ] || echo "namespace: $namespace"
|
|
210
|
+
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# shellcheck shell=bash
|
|
3
|
+
# devzone, module state: read, write, enable, disable (change_module).
|
|
4
|
+
# Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
|
|
5
|
+
# functions only, shared variables are defined in devzone.
|
|
6
|
+
|
|
7
|
+
description() {
|
|
8
|
+
case "$1" in
|
|
9
|
+
ia) echo "AI assistants: Claude Code, opencode" ;;
|
|
10
|
+
kubernetes) echo "connection to the host cluster and metrics-server at startup" ;;
|
|
11
|
+
gitlab) echo "test GitLab in the services cluster" ;;
|
|
12
|
+
postgres) echo "shared PostgreSQL, one database per project" ;;
|
|
13
|
+
argocd) echo "Argo CD, deployment interface of the services cluster" ;;
|
|
14
|
+
mysql) echo "shared MySQL, one database per project" ;;
|
|
15
|
+
esac
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
is_known() {
|
|
19
|
+
local m
|
|
20
|
+
for m in "${MODULES[@]}"; do [ "$m" = "$1" ] && return 0; done
|
|
21
|
+
return 1
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
# First start (no state): the state is created by state.sh (#417): old global
|
|
25
|
+
# state taken over, backup copy restored, state rebuilt from the services
|
|
26
|
+
# cluster, otherwise first installation
|
|
27
|
+
init_state() {
|
|
28
|
+
state_init "${MODULES[@]}"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
value_of() {
|
|
32
|
+
init_state
|
|
33
|
+
local v
|
|
34
|
+
v="$(grep -E "^$1=" "$ETAT" | tail -1 | cut -d= -f2 || true)"
|
|
35
|
+
[ "$v" = on ] && echo on || echo off
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# State-file lock held from initialisation to write (#417): the state is never
|
|
39
|
+
# recreated empty between the two
|
|
40
|
+
write_value() {
|
|
41
|
+
state_lock_take || return 1
|
|
42
|
+
if ! init_state || ! state_write "$1" "$2"; then
|
|
43
|
+
state_lock_release
|
|
44
|
+
return 1
|
|
45
|
+
fi
|
|
46
|
+
state_lock_release
|
|
47
|
+
return 0
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# Removes a key from the state file: the configuration of a service only exists
|
|
51
|
+
# while it is chosen (#242)
|
|
52
|
+
remove_key() {
|
|
53
|
+
state_lock_take || return 1
|
|
54
|
+
if ! init_state || ! state_remove "$1"; then
|
|
55
|
+
state_lock_release
|
|
56
|
+
return 1
|
|
57
|
+
fi
|
|
58
|
+
state_lock_release
|
|
59
|
+
return 0
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
# True if the file only holds the $schema key (created by opencode by default)
|
|
63
|
+
only_schema_key() {
|
|
64
|
+
local others
|
|
65
|
+
others="$(grep -vcE '^[[:space:]]*([{}]|"?[$]schema"?[[:space:]]*:.*)?[[:space:]]*$' "$1" || true)"
|
|
66
|
+
[ "$others" -eq 0 ] && grep -qF "\$schema" "$1"
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
# Message for the removed llm module (migration, #669).
|
|
70
|
+
llm_removed_msg() {
|
|
71
|
+
echo "devzone : llm module removed: devzone no longer hosts a model; the host (Ollama) models are detected instead (devzone ai). To free the disk: kubectl delete namespace devzone-llm"
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
# Drops the llm= state line when present and reports the removal once (#669).
|
|
75
|
+
migrate_llm() {
|
|
76
|
+
[ -f "$ETAT" ] || return 0
|
|
77
|
+
grep -qE '^llm=' "$ETAT" 2>/dev/null || return 0
|
|
78
|
+
state_remove llm
|
|
79
|
+
llm_removed_msg
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
change_module() {
|
|
83
|
+
local m="${2:-}"
|
|
84
|
+
if [ -z "$m" ]; then
|
|
85
|
+
echo "devzone : unknown module : (none) ; modules : ${MODULES[*]}" >&2
|
|
86
|
+
exit 1
|
|
87
|
+
fi
|
|
88
|
+
# llm removed (#669): migration message, never unknown module.
|
|
89
|
+
if [ "$m" = llm ]; then
|
|
90
|
+
init_state 2>/dev/null || true
|
|
91
|
+
if [ -f "$ETAT" ] && grep -qE '^llm=' "$ETAT" 2>/dev/null; then
|
|
92
|
+
state_remove llm
|
|
93
|
+
fi
|
|
94
|
+
llm_removed_msg
|
|
95
|
+
return 1
|
|
96
|
+
fi
|
|
97
|
+
migrate_llm
|
|
98
|
+
if ! is_known "$m"; then
|
|
99
|
+
# An application of the catalog: the line is written, then applied
|
|
100
|
+
if [ -f "$ICI/catalog/$m/app.conf" ]; then
|
|
101
|
+
write_value "$m" "$1"
|
|
102
|
+
bash "$ICI/catalog.sh" apply
|
|
103
|
+
return
|
|
104
|
+
fi
|
|
105
|
+
echo "devzone : unknown module : $m ; modules : ${MODULES[*]}" >&2
|
|
106
|
+
exit 1
|
|
107
|
+
fi
|
|
108
|
+
# In the Kubernetes workspace pod the services are installed from the
|
|
109
|
+
# workstation (#528): the pod has no administrator access to the cluster.
|
|
110
|
+
# DEVZONE_SERVICES_ADMIN=1: run by services-admin.sh with a temporary one.
|
|
111
|
+
if in_pod && service_module "$m" && [ -z "${DEVZONE_SERVICES_ADMIN:-}" ]; then
|
|
112
|
+
if [ "$1" = on ]; then
|
|
113
|
+
echo "devzone: in the workspace pod, $m is installed from the workstation: devzone workspace services enable $m" >&2
|
|
114
|
+
else
|
|
115
|
+
echo "devzone: in the workspace pod, $m is removed from the workstation: devzone workspace services disable $m" >&2
|
|
116
|
+
fi
|
|
117
|
+
return 2
|
|
118
|
+
fi
|
|
119
|
+
if [ "$1" = off ] && { [ "$m" = postgres ] || [ "$m" = mysql ] || [ "$m" = gitlab ]; }; then
|
|
120
|
+
confirm_removal "$m" "${@:3}" || return 0
|
|
121
|
+
fi
|
|
122
|
+
write_value "$m" "$1"
|
|
123
|
+
# Services held by Argo CD (#559): 0 done, 3 helm direct as before, else failed
|
|
124
|
+
if DEVZONE_STATE="$ETAT" bash "$ICI/argocd/services-hook.sh" "$m" "$1" "${@:3}"; then return 0; elif [ $? -ne 3 ]; then return 1; fi
|
|
125
|
+
"apply_$m" "$1" "${@:3}"
|
|
126
|
+
}
|