Compare commits

..

13 Commits

Author SHA1 Message Date
Fabio Scotto di Santolo
1a9ecffecf Install Codex and Cline CLI on WSL workstation
Enable Codex and the Cline CLI on deadalus alongside Claude Code, and
stop selecting Codex for removal. Cline's cross-tool instructions and
shared context remain deployed for the devcontainer bind mounts.

Co-Authored-By: Claude Code <noreply@anthropic.com>
2026-11-24 15:47:41 +01:00
012cb3534b Install agent CLIs and VS Code extensions in generated devcontainers
The nvm-based node feature put npm outside sudo secure_path and broke the postCreateCommand, so containers with agents now copy Node from the official docker.io/library/node image into /usr/local in every profile. Each selected agent also adds its official VS Code extension to the customizations and the generator captures every extension installed in the local VS Code through code --list-extensions, deduplicated case-insensitively and sorted at generation time.
2026-11-19 00:39:17 +01:00
47acda71b6 Manage VS Code user settings on GNOME hosts
Deploy the full user settings.json as an explicit overlay with a timestamped backup: podman as the Dev Containers engine, the Container Tools clients, the corrected JetBrainsMono Nerd Font editor font, the block cursor and format on paste. Add the material icon theme extension the managed icon theme depends on and drop the deprecated ms-azuretools.vscode-docker pack, which since June 2025 only wraps Container Tools.
2026-11-19 00:39:01 +01:00
Fabio Scotto di Santolo
e74088e85b Deploy devcontainer generator to user local bin with Ansible 2026-11-18 23:13:32 +01:00
Fabio Scotto di Santolo
e2370ec91d Replace Python devcontainer generator with Go CLI 2026-11-18 23:13:30 +01:00
Fabio Scotto di Santolo
59160abf0d Add reusable project devcontainer generator 2026-11-18 23:13:28 +01:00
cdc102a970 Prohibit AI names as Git co-authors in the shared agent context
Add the rule to the always-applied safety directives and make the dispatcher reference safety.md so Codex and Claude Code, which import only the dispatcher, apply it as well.
2026-11-18 22:52:50 +01:00
66925b1d0d Share Cline configuration with the ecaas and cdp devcontainers
Keep Cline deploy-only on deadalus so its rules, the cross-tool AGENTS pointer and the shared ~/.config/ai context are deployed on the WSL host; mount ~/.agents into the containers; list the Cline VS Code extension in the devcontainer customizations. The CLI package stays absent on the host and ships in the images.
2026-11-18 22:52:47 +01:00
3facf61866 Add Desktop Plus and pin it in the Ikaros favorites 2026-11-18 22:52:43 +01:00
0b30890464 Update the GNOME shell extension list on Ikaros
Capture the current live session: enable gnome-shell-extension-maximized-by-default and disable the unused maximize-new-windows entry.
2026-11-18 22:52:37 +01:00
ffa9960c64 Reuse verified Nextcloud bundles within 20h before Borg/USB backups 2026-11-15 22:12:50 +01:00
7b85314cca Update favorite apps on Ikaros 2026-11-15 07:21:02 +01:00
95630f74d3 Extend the GNOME search provider sort order on Ikaros 2026-11-14 23:06:05 +01:00
27 changed files with 1034 additions and 28 deletions

View File

@@ -230,6 +230,19 @@ The dotfile vars follow the same split: `desktop_common_dotfiles` carries mode-i
injecting the private token for JSON-RPC POST clients; keep this route
authenticated and never expose the gateway directly. See `docs/atlas-aria2.md`.
- Atlas Nextcloud backup preparation (`atlas-nextcloud-backup.service`) is an ordered
requirement of the nightly `atlas-borg-backup.service` and the operator-started
`atlas-usb-backup.service`. A structurally complete bundle younger than
`atlas_nextcloud_backup_reuse_max_seconds` (20 h, asserted below 24 h so the nightly
Borg cycle always refreshes it) is reused without pausing the applications: a manual
USB run therefore reaches its LUKS prompt within seconds, while preparation failure
still blocks the dependent job. Force one fresh preparation with
`systemctl set-environment ATLAS_NEXTCLOUD_BACKUP_FORCE=1` before the start and unset
the variable afterwards. Deployed and validated on 2026-11-15: a dependency start reused
a verified bundle 14 h old and skipped preparation in 14 ms, and an operator-started
USB run reached its LUKS prompt in under a second; the FORCE path has not been exercised
in production yet. See `docs/atlas-nextcloud.md`.
## Atlas NAS TODO
Completed validation: the existing RAIDZ2 pool and datasets, SELinux, LAN firewall, SSH, Cockpit with
the selected 45Drives plugins, encrypted SMB3 `Archive`, the Aegis-only NFSv4 `photobook` export, and the
@@ -551,7 +564,7 @@ validated exports of older historical data will use a dedicated Atlas NFS datase
- Shared agent dotfiles live in `ai_agents_dotfiles`; rendered configs live in `ai_agents_templates`.
- Every `ai_agents.<agent>` entry has independent `install_enabled`, `deploy_enabled`, and `uninstall_enabled` flags. Installation and removal must not both be true for the same agent; the common pre-task fails before changes when they conflict.
- Fedora, Void desktop, and WSL workstation profiles consume the shared agent definitions; do not duplicate package entries in profile-specific vars. IBM Bob on the workstation follows its own flags.
- WSL (`deadalus`) keeps only Claude Code installed; every other managed agent (including IBM Bob) is disabled and selected for removal through host overrides. Existing user state remains untouched.
- WSL (`deadalus`) installs Claude Code, Codex and the Cline CLI; every other managed agent (including IBM Bob) is disabled and selected for removal through host overrides. `cline_deploy_enabled: true` also keeps Cline's cross-tool AGENTS pointer, global rules, and shared `~/.config/ai` context deployed on the host for the ecaas/cdp devcontainer bind mounts. Existing user state remains untouched.
- `dotfiles_common` deploys `ai_agents_dotfiles` and renders `ai_agents_templates` only when deployment is enabled.
- Removal is limited to the managed npm packages and `/usr/local/bin/bob`; never remove agent dotfiles, instructions, credentials, or user data.
- Keep `.config/ai/` as the common instruction source; update agent-specific entrypoints to reference it rather than duplicating instruction text.
@@ -591,3 +604,16 @@ validated exports of older historical data will use a dedicated Atlas NFS datase
not depend on the AdGuard container during startup.
- Aegis iCloudPD has been retired and is no longer managed by this role. Its service, Quadlet,
data, and MFA state were removed with the operator's explicit authorization.
## Project Devcontainer Generator
- `cmd/devcontainer/` generates standalone per-project language configurations;
it does not replace existing deadalus ecaas/cdp provisioning or remove host tools.
- Keep shared Git/agent behavior documented in `docs/project-devcontainers.md`.
- Focused validation: `go -C cmd/devcontainer test ./...`.
- Real engine builds, host credential forwarding and Fedora SELinux/Podman checks
require target-host validation; do not report generator tests as runtime evidence.
- `devcontainer_generator` builds the CLI natively on Fedora graphical desktops
and development workstations and installs it in `~/.local/bin/devcontainer`.
Validate with `ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator --check --diff`;
check mode skips compilation and binary installation explicitly.

View File

@@ -598,8 +598,11 @@ instructions, credentials, and user data. Installation and removal are mutually
exclusive per agent: the playbook fails before making changes when both flags are
true for the same agent. Servers set `ai_agents: {}` and therefore manage none.
On WSL (`deadalus`), every managed coding agent except Claude Code is disabled through
On WSL (`deadalus`), Claude Code, Codex and the Cline CLI are installed through
`profile_workstation_dev_common`. Every other managed coding agent is disabled through
host overrides and its managed npm package or `bob` binary is selected for removal.
`cline_deploy_enabled: true` also keeps Cline's cross-tool AGENTS pointer, global rules,
and shared `~/.config/ai` context deployed on the WSL host for the ecaas/cdp devcontainers.
Existing configuration, credentials, and user data are left untouched.
The shared agent context is centralized in `dotfiles/common/.config/ai/` and
@@ -890,3 +893,13 @@ For a future Void desktop host:
4. Put hardware-specific details in `host_vars/<host>.yml`.
The legacy `void` and `desktop` groups remain compatibility parents, so hosts in `platform_void` and `graphical_desktop` still receive the existing Void and desktop variables.
## Project devcontainer generator
Generate a reusable language environment for an existing project with
`devcontainer ~/src/project --language python --agents codex,cline`.
Git and selected coding-agent configuration are shared from the development host.
See [profiles, host requirements and validation](docs/project-devcontainers.md).
Deploy `~/.local/bin/devcontainer` on a Fedora desktop/workstation with
`ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator -K`.

View File

@@ -91,6 +91,7 @@ fedora_nerd_fonts:
fedora_flatpak_packages:
- be.alexandervanhee.gradia
- com.spotify.Client
- org.desktop_plus.desktop-plus
- org.onlyoffice.desktopeditors
- org.telegram.desktop
@@ -129,7 +130,8 @@ vscode_extensions:
- esbenp.prettier-vscode
- github.remotehub
- ms-azuretools.vscode-containers
- ms-azuretools.vscode-docker
# ms-azuretools.vscode-docker is deprecated: since June 2025 it is just an
# extension pack wrapping Container Tools. Only the real extension is kept.
- ms-vscode-remote.remote-containers
- ms-vscode-remote.remote-ssh
- ms-vscode-remote.remote-ssh-edit
@@ -139,11 +141,25 @@ vscode_extensions:
- ms-vscode.remote-explorer
- ms-vscode.remote-repositories
- ms-vscode.remote-server
- pkief.material-icon-theme
- redhat.vscode-xml
- redhat.vscode-yaml
- saoudrizwan.claude-dev
- vscodevim.vim
vscode_settings: null
# Managed user settings deploy as a full-file overlay with a timestamped backup;
# any manual settings.json edit is converged away on the next run. These keys cover
# the podman Dev Containers engine selection and the Container Tools clients.
# editor.fontFamily uses the canonical 'JetBrainsMono Nerd Font' family name: the
# live 'JetBriansMono NF' was a typo whose fallback chain rendered Liberation Mono.
vscode_settings:
containers.containerClient: com.microsoft.visualstudio.containers.podman
containers.orchestratorClient: com.microsoft.visualstudio.orchestrators.podmancompose
dev.containers.dockerPath: podman
editor.cursorStyle: block
editor.fontFamily: "'JetBrainsMono Nerd Font', 'Droid Sans Mono', monospace"
editor.formatOnPaste: true
workbench.iconTheme: material-icon-theme
workbench.startupEditor: none
# User-level keybindings apply to every window, including Dev Containers, SSH and WSL remotes.
# Keys avoid Ctrl+<letter>, which the Vim extension uses for its motions; Alt is not bound by Vim.
vscode_keybindings:

View File

@@ -5,21 +5,24 @@ workstation_ecaas_workspace: "{{ user_home }}/Work/sipo/ecaas"
workstation_cdp_workspace: "{{ user_home }}/Work/sipo/cdp"
workstation_ecaas_git_required_ca: ecaas.datacenter.comune.roma.crt
# Claude Code is the only coding agent on WSL; every other managed agent is removed.
# Claude Code, Codex and the Cline CLI are the coding agents installed on WSL; every
# other managed agent is disabled. Cline's cross-tool instructions (.agents/AGENTS.md,
# .cline/rules/) and the shared ~/.config/ai context are deployed for the ecaas/cdp
# devcontainers, and the cline npm package is installed by profile_workstation_dev_common.
claude_code_install_enabled: true
claude_code_uninstall_enabled: false
opencode_install_enabled: false
opencode_deploy_enabled: false
opencode_uninstall_enabled: true
codex_install_enabled: false
codex_install_enabled: true
codex_deploy_enabled: false
codex_uninstall_enabled: true
codex_uninstall_enabled: false
gemini_cli_install_enabled: false
gemini_cli_deploy_enabled: false
gemini_cli_uninstall_enabled: true
cline_install_enabled: false
cline_deploy_enabled: false
cline_uninstall_enabled: true
cline_install_enabled: true
cline_deploy_enabled: true
cline_uninstall_enabled: false
ibm_bob_install_enabled: false
ibm_bob_uninstall_enabled: true

View File

@@ -151,7 +151,7 @@ gnome_gsettings_settings:
value: "'file:///usr/share/backgrounds/gnome/morphogenesis-l.svg'"
- schema: org.gnome.desktop.search-providers
key: sort-order
value: "['org.gnome.Settings.desktop', 'org.gnome.Contacts.desktop', 'org.gnome.Nautilus.desktop']"
value: "['org.gnome.Settings.desktop', 'org.gnome.Contacts.desktop', 'org.gnome.Nautilus.desktop', 'org.mozilla.firefox.desktop', 'org.gnome.seahorse.Application.desktop', 'org.gnome.Calculator.desktop', 'org.gnome.Calendar.desktop', 'org.gnome.Software.desktop', 'org.gnome.Characters.desktop', 'org.gnome.Boxes.desktop', 'org.gnome.clocks.desktop', 'com.mattjakeman.ExtensionManager.desktop']"
- schema: org.gnome.desktop.wm.keybindings
key: switch-to-workspace-1
value: "['<Super>1']"
@@ -242,19 +242,19 @@ gnome_gsettings_settings:
- schema: org.gnome.shell
key: app-picker-layout
value: >-
[{'System': <{'position': <0>}>, 'Utilities': <{'position': <1>}>, 'org.fedoraproject.MediaWriter.desktop': <{'position': <2>}>, 'org.gnome.Contacts.desktop': <{'position': <3>}>, 'org.gnome.Calendar.desktop': <{'position': <4>}>, 'org.gnome.Calculator.desktop': <{'position': <5>}>, 'org.gnome.Weather.desktop': <{'position': <6>}>, 'org.gnome.clocks.desktop': <{'position': <7>}>, 'org.gnome.Maps.desktop': <{'position': <8>}>, 'org.gnome.SimpleScan.desktop': <{'position': <9>}>, 'org.gnome.TextEditor.desktop': <{'position': <10>}>, 'org.gnome.Settings.desktop': <{'position': <11>}>, 'org.gnome.Boxes.desktop': <{'position': <12>}>, 'org.gnome.Showtime.desktop': <{'position': <13>}>, 'org.gnome.Snapshot.desktop': <{'position': <14>}>, 'org.gnome.Characters.desktop': <{'position': <15>}>, 'org.gnome.Tour.desktop': <{'position': <16>}>, 'org.gnome.Yelp.desktop': <{'position': <17>}>, 'org.gnome.Software.desktop': <{'position': <18>}>, 'be.alexandervanhee.gradia.desktop': <{'position': <19>}>, 'com.github.jeromerobert.pdfarranger.desktop': <{'position': <20>}>, 'org.onlyoffice.desktopeditors.desktop': <{'position': <21>}>, 'org.gnome.Meld.desktop': <{'position': <22>}>, 'com.mattjakeman.ExtensionManager.desktop': <{'position': <23>}>}, {'com.raspberrypi.rpi-imager.desktop': <{'position': <0>}>, 'org.remmina.Remmina.desktop': <{'position': <1>}>, 'com.nextcloud.desktopclient.nextcloud.desktop': <{'position': <2>}>, 'syncthing-start.desktop': <{'position': <3>}>, 'syncthing-ui.desktop': <{'position': <4>}>, 'emacs.desktop': <{'position': <5>}>, 'emacs-client.desktop': <{'position': <6>}>, 'org.gnome.gitlab.somas.Apostrophe.desktop': <{'position': <7>}>, 'mpv.desktop': <{'position': <8>}>, 'htop.desktop': <{'position': <9>}>, 'ai-media-facefusion.desktop': <{'position': <10>}>, 'ai-media-rvc.desktop': <{'position': <11>}>}]
[{'System': <{'position': <0>}>, 'Utilities': <{'position': <1>}>, 'org.fedoraproject.MediaWriter.desktop': <{'position': <2>}>, 'org.gnome.Contacts.desktop': <{'position': <3>}>, 'org.gnome.Calendar.desktop': <{'position': <4>}>, 'org.gnome.Calculator.desktop': <{'position': <5>}>, 'org.gnome.Weather.desktop': <{'position': <6>}>, 'org.gnome.clocks.desktop': <{'position': <7>}>, 'org.gnome.Maps.desktop': <{'position': <8>}>, 'org.gnome.SimpleScan.desktop': <{'position': <9>}>, 'org.gnome.TextEditor.desktop': <{'position': <10>}>, 'org.gnome.Settings.desktop': <{'position': <11>}>, 'org.gnome.Boxes.desktop': <{'position': <12>}>, 'org.gnome.Showtime.desktop': <{'position': <13>}>, 'org.gnome.Snapshot.desktop': <{'position': <14>}>, 'org.gnome.Characters.desktop': <{'position': <15>}>, 'org.gnome.Tour.desktop': <{'position': <16>}>, 'org.gnome.Yelp.desktop': <{'position': <17>}>, 'org.gnome.Software.desktop': <{'position': <18>}>, 'be.alexandervanhee.gradia.desktop': <{'position': <19>}>, 'com.github.jeromerobert.pdfarranger.desktop': <{'position': <20>}>, 'org.onlyoffice.desktopeditors.desktop': <{'position': <21>}>, 'org.gnome.Meld.desktop': <{'position': <22>}>, 'com.mattjakeman.ExtensionManager.desktop': <{'position': <23>}>}, {'com.raspberrypi.rpi-imager.desktop': <{'position': <0>}>, 'org.remmina.Remmina.desktop': <{'position': <1>}>, 'com.nextcloud.desktopclient.nextcloud.desktop': <{'position': <2>}>, 'syncthing-start.desktop': <{'position': <3>}>, 'syncthing-ui.desktop': <{'position': <4>}>, 'emacs.desktop': <{'position': <5>}>, 'emacs-client.desktop': <{'position': <6>}>, 'chatgpt.desktop': <{'position': <7>}>, 'org.gnome.gitlab.somas.Apostrophe.desktop': <{'position': <8>}>, 'mpv.desktop': <{'position': <9>}>, 'htop.desktop': <{'position': <10>}>, 'ai-media-facefusion.desktop': <{'position': <11>}>, 'ai-media-rvc.desktop': <{'position': <12>}>}]
- schema: org.gnome.shell
key: disabled-extensions
value: >-
['window-list@gnome-shell-extensions.gcampax.github.com', 'background-logo@fedorahosted.org', 'apps-menu@gnome-shell-extensions.gcampax.github.com', 'places-menu@gnome-shell-extensions.gcampax.github.com']
['window-list@gnome-shell-extensions.gcampax.github.com', 'background-logo@fedorahosted.org', 'apps-menu@gnome-shell-extensions.gcampax.github.com', 'places-menu@gnome-shell-extensions.gcampax.github.com', 'maximize-new-windows@VitalyOstanin']
- schema: org.gnome.shell
key: enabled-extensions
value: >-
['status-icons@gnome-shell-extensions.gcampax.github.com', 'gnome-ui-tune@itstime.tech', 'appindicatorsupport@rgcjonas.gmail.com', 'bluetooth-battery-monitor@v8v88v8v88.com', 'clipboard-indicator@tudmotu.com', 'status-area-horizontal-spacing@mathematical.coffee.gmail.com', 'MaximizeWindowIntoNewWorkspace@kyleross.com', 'maximize-new-windows@VitalyOstanin']
['status-icons@gnome-shell-extensions.gcampax.github.com', 'gnome-ui-tune@itstime.tech', 'appindicatorsupport@rgcjonas.gmail.com', 'bluetooth-battery-monitor@v8v88v8v88.com', 'clipboard-indicator@tudmotu.com', 'status-area-horizontal-spacing@mathematical.coffee.gmail.com', 'MaximizeWindowIntoNewWorkspace@kyleross.com', 'gnome-shell-extension-maximized-by-default@stiggimy.github.com']
- schema: org.gnome.shell
key: favorite-apps
value: >-
['org.gnome.Nautilus.desktop', 'org.mozilla.firefox.desktop', 'com.spotify.Client.desktop', 'net.thunderbird.Thunderbird.desktop', 'org.telegram.desktop.desktop', 'chatgpt.desktop', 'Cline.desktop', 'com.microsoft.VSCode.desktop', 'org.gnome.Ptyxis.desktop', 'virt-manager.desktop']
['org.gnome.Nautilus.desktop', 'org.mozilla.firefox.desktop', 'com.spotify.Client.desktop', 'net.thunderbird.Thunderbird.desktop', 'org.telegram.desktop.desktop', 'Cline.desktop', 'org.desktop_plus.desktop-plus.desktop', 'com.microsoft.VSCode.desktop', 'org.gnome.Ptyxis.desktop', 'virt-manager.desktop']
- schema: org.gnome.shell
key: remember-mount-password
value: "true"

View File

@@ -0,0 +1,4 @@
---
devcontainer_generator_go_binary: /usr/bin/go
devcontainer_generator_install_go: true
devcontainer_generator_build_dir: "{{ user_home }}/.cache/infra/devcontainer-generator"

View File

@@ -0,0 +1,64 @@
---
- name: Install Go compiler for the devcontainer generator
ansible.builtin.dnf:
name: golang
state: present
when: devcontainer_generator_install_go | bool
- name: Ensure devcontainer generator directories exist
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0755"
loop:
- "{{ user_home }}/.local/bin"
- "{{ devcontainer_generator_build_dir }}"
- name: Copy devcontainer generator sources
ansible.builtin.copy:
src: "{{ playbook_dir }}/../cmd/devcontainer/"
dest: "{{ devcontainer_generator_build_dir }}/src/"
owner: "{{ username }}"
group: "{{ user_group }}"
mode: preserve
- name: Build devcontainer generator for the target host
ansible.builtin.command:
argv:
- "{{ devcontainer_generator_go_binary }}"
- build
- -trimpath
- -buildvcs=false
- -o
- "{{ devcontainer_generator_build_dir }}/devcontainer"
- .
chdir: "{{ devcontainer_generator_build_dir }}/src"
become_user: "{{ username }}"
environment:
GOCACHE: "{{ devcontainer_generator_build_dir }}/go-cache"
GOTOOLCHAIN: local
GOPROXY: "off"
GOSUMDB: "off"
CGO_ENABLED: "0"
# Compilation refreshes a cached artifact; copy below reports installation changes.
changed_when: false
when: not ansible_check_mode
- name: Install devcontainer generator in the user PATH
ansible.builtin.copy:
src: "{{ devcontainer_generator_build_dir }}/devcontainer"
remote_src: true
dest: "{{ user_home }}/.local/bin/devcontainer"
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0755"
when: not ansible_check_mode
- name: Explain devcontainer generator check-mode behavior
ansible.builtin.debug:
msg: >-
Check mode validates package and source deployment only. Compilation and
installation of {{ user_home }}/.local/bin/devcontainer require a normal run.
when: ansible_check_mode

View File

@@ -18,6 +18,11 @@ atlas_nextcloud_redis_image: ""
atlas_onlyoffice_image: ""
atlas_nextcloud_backup_root: "{{ atlas_mount_root }}/backup/nextcloud"
atlas_nextcloud_backup_keep: 2
# A structurally complete bundle from an earlier verified run younger than
# this many seconds is reused instead of re-preparing. Keep it below 24h so
# the nightly Borg run, spaced 24h plus its randomized delay, always refreshes
# the bundle; 0 disables reuse.
atlas_nextcloud_backup_reuse_max_seconds: 72000
atlas_nextcloud_admin: admin
atlas_nextcloud_users: []
atlas_nextcloud_apps: []

View File

@@ -3,11 +3,14 @@
tags: [atlas, nextcloud_backup]
when: atlas_manage_nextcloud | bool
block:
- name: Validate private backup scope and local bundle retention
- name: Validate private backup scope, retention, and bundle reuse window
ansible.builtin.assert:
that:
- atlas_nextcloud_backup_root == atlas_mount_root ~ '/backup/nextcloud'
- atlas_nextcloud_backup_keep | int >= 2
- atlas_nextcloud_backup_reuse_max_seconds | int >= 0
# Below 24h the nightly Borg run cannot reuse the previous bundle.
- atlas_nextcloud_backup_reuse_max_seconds | int < 86400
- atlas_manage_borg_backup | bool
- atlas_manage_usb_backup | bool

View File

@@ -14,6 +14,9 @@ StateDirectory=atlas-nextcloud-backup
StateDirectoryMode=0700
ExecStart=/usr/local/sbin/atlas-nextcloud-backup
ExecStopPost=/usr/local/sbin/atlas-nextcloud-backup --recover
# systemctl set-environment ATLAS_NEXTCLOUD_BACKUP_FORCE=1 makes the next run
# ignore the bundle reuse window; unset the variable afterwards.
PassEnvironment=ATLAS_NEXTCLOUD_BACKUP_FORCE
TimeoutStartSec=3h
TimeoutStopSec=5min
Nice=10

View File

@@ -7,6 +7,7 @@ readonly source_root={{ atlas_nextcloud_root | quote }}
readonly backup_root={{ atlas_nextcloud_backup_root | quote }}
readonly state=/var/lib/atlas-nextcloud-backup
readonly keep={{ atlas_nextcloud_backup_keep | int }}
readonly reuse_max={{ atlas_nextcloud_backup_reuse_max_seconds | int }}
readonly owner={{ atlas_admin_username | quote }}
readonly uid={{ atlas_admin_uid | int }}
@@ -64,6 +65,36 @@ recover() {
}
if [[ "${1:-}" == --recover ]]; then recover; exit; fi
recover
# Fast path: a structurally complete bundle from an earlier verified run is
# reused while younger than the reuse window, without pausing the applications.
# ATLAS_NEXTCLOUD_BACKUP_FORCE=1 ignores the window and prepares one anyway.
if [[ "${ATLAS_NEXTCLOUD_BACKUP_FORCE:-0}" != 1 ]] && [[ "$reuse_max" -gt 0 ]]; then
target="$(readlink -f "$backup_root/latest" 2>/dev/null || true)"
if [[ -n "$target" && "$target" == "$backup_root/versions/"* ]]; then
name="${target##*/}"
if [[ "$name" =~ ^[0-9]{8}T[0-9]{6}Z-[0-9]+$ ]]; then
bundle_utc="${name:0:4}-${name:4:2}-${name:6:2} ${name:9:2}:${name:11:2}:${name:13:2} UTC"
created="$(date -u -d "$bundle_utc" +%s 2>/dev/null || true)"
if [[ -n "$created" ]]; then
now="$(date -u +%s)"
if [[ "$((now - created))" -le "$reuse_max" ]]; then
reusable=true
for component in manifest.txt SHA256SUMS database.dump \
postgres-globals.sql database-toc.txt images.txt; do
[[ -s "$target/$component" ]] || { reusable=false; break; }
done
for component in app files; do
[[ -d "$target/$component" ]] || { reusable=false; break; }
done
if [[ "$reusable" == true ]]; then
echo "Reusing verified Nextcloud bundle $name (age $((now - created))s <= ${reuse_max}s); preparation skipped"
exit 0
fi
fi
fi
fi
fi
fi
[[ "$(zfs get -H -o value mounted "$dataset")" == yes ]]
[[ "$(zfs get -H -o value mountpoint "$dataset")" == "$source_root" ]]
[[ "$(zfs get -H -o value mounted {{ (atlas_zfs_pool ~ '/backup') | quote }})" == yes ]]

View File

@@ -66,6 +66,7 @@
loop:
- { path: .claude, mode: "0700" }
- { path: .cline, mode: "0700" }
- { path: .agents, mode: "0755" }
- { path: .config/ai, mode: "0755" }
- { path: .config/glab-cli, mode: "0700" }

View File

@@ -58,6 +58,7 @@
loop:
- { path: .claude, mode: "0700" }
- { path: .cline, mode: "0700" }
- { path: .agents, mode: "0755" }
- { path: .config/ai, mode: "0755" }
- { path: .config/glab-cli, mode: "0700" }

View File

@@ -30,6 +30,7 @@
{{ ('type=bind,source=' ~ user_home ~ '/.local/state/devcontainer-bash-history/cdp,target=/home/vscode/.bash_history.d') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.claude,target=/home/vscode/.claude') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.cline,target=/home/vscode/.cline') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.agents,target=/home/vscode/.agents,readonly') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.m2,target=/home/vscode/.m2') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.config/glab-cli,target=/home/vscode/.config/glab-cli') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.kube,target=/home/vscode/.kube') | to_json }}
@@ -45,6 +46,7 @@
"ms-kubernetes-tools.vscode-kubernetes-tools",
"angular.ng-template",
"dbaeumer.vscode-eslint",
"saoudrizwan.claude-dev",
"emmanuelbeziat.vscode-great-icons"
],
"settings": {

View File

@@ -29,6 +29,7 @@
{{ ('type=bind,source=' ~ user_home ~ '/.local/state/devcontainer-bash-history/ecaas,target=/home/vscode/.bash_history.d') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.claude,target=/home/vscode/.claude') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.cline,target=/home/vscode/.cline') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.agents,target=/home/vscode/.agents,readonly') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.m2,target=/home/vscode/.m2') | to_json }},
{{ ('type=bind,source=' ~ user_home ~ '/.config/glab-cli,target=/home/vscode/.config/glab-cli') | to_json }}
],
@@ -40,6 +41,7 @@
"vmware.vscode-boot-dev-pack",
"redhat.vscode-xml",
"redhat.vscode-yaml",
"saoudrizwan.claude-dev",
"emmanuelbeziat.vscode-great-icons"
],
"settings": {

View File

@@ -152,3 +152,12 @@
roles:
- profile_workstation_dev_wsl
- name: Deploy project devcontainer generator
hosts: platform_fedora
become: true
tags: [devcontainer_generator]
roles:
- role: devcontainer_generator
when: "'graphical_desktop' in group_names or 'workstation_dev_fedora' in group_names"

View File

@@ -0,0 +1,11 @@
RUN apt-get update \
&& arch="$(dpkg --print-architecture)" \
&& case "$arch" in \
amd64) sha256=ea4f0222950ee750a3d38dd80d03bce4cee07a3f63928fc47548383bcaf23093 ;; \
arm64) sha256=0edc36cf514f1bd84becac3e94ee8ae9f8818c6a1f99f7b2ee67b362afa253d3 ;; \
*) echo "Unsupported architecture for delta: $arch" >&2; exit 1 ;; \
esac \
&& curl -fsSL --retry 3 "https://github.com/dandavison/delta/releases/download/0.19.2/git-delta_0.19.2_${arch}.deb" -o /tmp/git-delta.deb \
&& echo "$sha256 /tmp/git-delta.deb" | sha256sum -c - \
&& apt-get install -y --no-install-recommends /tmp/git-delta.deb \
&& rm -rf /var/lib/apt/lists/* /tmp/git-delta.deb

3
cmd/devcontainer/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module github.com/fscotto/infra/cmd/devcontainer
go 1.22

351
cmd/devcontainer/main.go Normal file
View File

@@ -0,0 +1,351 @@
// Command devcontainer generates project configurations sharing host Git and agent state.
package main
import (
"bytes"
_ "embed"
"encoding/json"
"errors"
"flag"
"fmt"
"io"
"os"
"os/exec"
"path/filepath"
"slices"
"sort"
"strings"
)
//go:embed delta.Dockerfile
var deltaDockerfile string
type profile struct {
Image, Packages string
Extensions []string
}
type agent struct {
Package string
Extension string
Paths []string
}
type mount struct {
Type string `json:"type"`
Source string `json:"source"`
Target string `json:"target"`
ReadOnly bool `json:"readOnly"`
}
func exists(path string) bool { _, err := os.Stat(path); return err == nil }
func isDir(path string) bool { info, err := os.Stat(path); return err == nil && info.IsDir() }
func quote(s string) string { return "'" + strings.ReplaceAll(s, "'", "'\"'\"'") + "'" }
func symlink(path string) bool {
info, err := os.Lstat(path)
return err == nil && info.Mode()&os.ModeSymlink != 0
}
func selectAgents(selection, home string) ([]string, error) {
result := []string{}
candidates := strings.Split(selection, ",")
if selection == "none" {
return result, nil
}
if selection == "auto" {
candidates = nil
for name := range agents {
candidates = append(candidates, name)
}
sort.Strings(candidates)
}
seen := map[string]bool{}
for _, name := range candidates {
name = strings.TrimSpace(name)
a, ok := agents[name]
if !ok {
return nil, fmt.Errorf("unknown agent %q", name)
}
available := true
for _, path := range a.Paths {
if !isDir(filepath.Join(home, path)) {
available = false
}
}
if selection == "auto" && !available {
continue
}
if !seen[name] {
result = append(result, name)
seen[name] = true
}
}
return result, nil
}
func generate(project, language, home string, selected []string, local []string, force bool) (string, error) {
p, ok := profiles[language]
if !ok {
return "", fmt.Errorf("unknown language %q", language)
}
project, err := filepath.Abs(project)
if err != nil {
return "", err
}
project, err = filepath.EvalSymlinks(project)
if err != nil {
return "", err
}
home, err = filepath.Abs(home)
if err != nil {
return "", err
}
home, err = filepath.EvalSymlinks(home)
if err != nil {
return "", err
}
if !isDir(project) {
return "", fmt.Errorf("project directory does not exist: %s", project)
}
if home == "/" || strings.ContainsAny(home, "\n\r$,\\\"") {
return "", errors.New("unsupported host home path")
}
target := filepath.Join(project, ".devcontainer")
if symlink(target) {
return "", errors.New("refusing a symlinked .devcontainer directory")
}
if exists(target) && !force {
return "", errors.New(".devcontainer already exists; use --force to replace generated files")
}
paths := []struct {
path string
readonly bool
}{{".gitconfig", true}, {".config/git", true}, {".gitignore_global", true}, {".config/ai", true}}
claude := false
for _, name := range selected {
a, ok := agents[name]
if !ok {
return "", fmt.Errorf("unknown agent %q", name)
}
for _, path := range a.Paths {
if !isDir(filepath.Join(home, path)) {
return "", fmt.Errorf("missing host directory for %s: %s", name, filepath.Join(home, path))
}
paths = append(paths, struct {
path string
readonly bool
}{path, false})
}
if name == "claude" {
claude = true
}
}
if claude {
paths = append(paths, struct {
path string
readonly bool
}{".claude.json", false})
}
mounts := []mount{}
for _, item := range paths {
if exists(filepath.Join(home, item.path)) {
destination := filepath.Join(home, item.path)
if item.path == ".gitconfig" {
destination = "/run/host-gitconfig"
}
mounts = append(mounts, mount{"bind", "${localEnv:HOME}/" + item.path, destination, item.readonly})
}
}
// The devcontainers node feature ships an nvm-based Node outside sudo's
// secure_path, which broke the postCreateCommand npm install. Copy the
// official Node image binaries into /usr/local instead, exactly like the
// ecaas and cdp devcontainers, so sudo npm works in every profile.
needsNode := len(selected) > 0
dockerfile := ""
if needsNode {
dockerfile += "FROM docker.io/library/node:22-bookworm-slim AS node\n"
}
dockerfile += fmt.Sprintf("FROM %s\nUSER root\nRUN apt-get update && apt-get install -y --no-install-recommends \\\n bash-completion ca-certificates curl fzf git git-lfs gnupg openssh-client ripgrep zoxide %s \\\n && rm -rf /var/lib/apt/lists/*\n", p.Image, p.Packages)
if needsNode {
dockerfile += "COPY --from=node /usr/local/bin/node /usr/local/bin/node\n"
dockerfile += "COPY --from=node /usr/local/lib/node_modules/npm/ /usr/local/lib/node_modules/npm/\n"
dockerfile += "RUN ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm \\\n && ln -s ../lib/node_modules/npm/bin/npx-cli.js /usr/local/bin/npx \\\n && node --version && npm --version\n"
}
dockerfile += deltaDockerfile
if home != "/home/vscode" {
dockerfile += "RUN usermod --home " + quote(home) + " --move-home vscode\n"
}
// Docker ENV uses its own quoting syntax, rather than shell quoting.
envHome, _ := json.Marshal(home)
dockerfile += "ENV HOME=" + string(envHome) + "\n"
if language == "python" {
dockerfile += "RUN python -m pip install --no-cache-dir uv ruff ty\n"
}
if language == "infra" {
dockerfile += "RUN python -m pip install --no-cache-dir ansible-core ansible-lint yamllint\n"
}
// The container installs the profile extensions, the VS Code extension of
// every selected agent and the extensions currently installed in the local
// VS Code, captured at generation time. Regenerate to refresh the local set.
extensions := append([]string{}, p.Extensions...)
addExtension := func(id string) {
if !slices.ContainsFunc(extensions, func(e string) bool { return strings.EqualFold(e, id) }) {
extensions = append(extensions, id)
}
}
for _, name := range selected {
if id := agents[name].Extension; id != "" {
addExtension(id)
}
}
for _, id := range local {
addExtension(strings.TrimSpace(id))
}
slices.Sort(extensions)
config := map[string]any{
"name": filepath.Base(project) + " — " + language,
"build": map[string]string{"dockerfile": "Dockerfile"},
"remoteUser": "vscode", "updateRemoteUserUID": true,
"containerEnv": map[string]string{"HOME": home}, "mounts": mounts,
"customizations": map[string]any{"vscode": map[string]any{"extensions": extensions}},
}
if len(selected) > 0 {
packages := []string{}
for _, name := range selected {
packages = append(packages, quote(agents[name].Package))
}
config["postCreateCommand"] = "sudo npm install --global --no-audit --no-fund " + strings.Join(packages, " ")
}
if claude {
config["remoteEnv"] = map[string]string{"ANTHROPIC_AUTH_TOKEN": "${localEnv:ANTHROPIC_AUTH_TOKEN}"}
}
dockerfile += "USER vscode\n"
if exists(filepath.Join(home, ".gitconfig")) {
dockerfile += "RUN git config --global include.path /run/host-gitconfig\n"
}
var data bytes.Buffer
encoder := json.NewEncoder(&data)
encoder.SetEscapeHTML(false)
encoder.SetIndent("", " ")
if err := encoder.Encode(config); err != nil {
return "", err
}
files := []struct{ name, content string }{{"Dockerfile", dockerfile}, {"devcontainer.json", data.String()}}
// Validate every output before replacing any file.
for _, file := range files {
path := filepath.Join(target, file.name)
if info, err := os.Lstat(path); err == nil {
if !info.Mode().IsRegular() {
return "", fmt.Errorf("refusing non-regular output: %s", path)
}
} else if !os.IsNotExist(err) {
return "", err
}
}
if err := os.MkdirAll(target, 0755); err != nil {
return "", err
}
for _, file := range files {
if err := writeAtomic(filepath.Join(target, file.name), file.content); err != nil {
return "", err
}
}
return target, nil
}
func writeAtomic(path, content string) error {
file, err := os.CreateTemp(filepath.Dir(path), ".devcontainer-*")
if err != nil {
return err
}
defer os.Remove(file.Name())
if _, err = io.WriteString(file, content); err != nil {
file.Close()
return err
}
if err = file.Chmod(0644); err != nil {
file.Close()
return err
}
if err = file.Close(); err != nil {
return err
}
return os.Rename(file.Name(), path)
}
// discoverLocalExtensions lists the extensions installed in the local VS Code.
// A missing or failing code binary is not fatal: the generated container then
// only carries the profile and agent extensions.
func discoverLocalExtensions(stderr io.Writer) []string {
path, err := exec.LookPath("code")
if err != nil {
fmt.Fprintln(stderr, "note: no local VS Code found; skipping locally installed extensions")
return nil
}
out, err := exec.Command(path, "--list-extensions").Output()
if err != nil {
fmt.Fprintf(stderr, "warning: could not list local VS Code extensions: %v\n", err)
return nil
}
extensions := []string{}
for _, line := range strings.Split(string(out), "\n") {
if id := strings.TrimSpace(line); id != "" {
extensions = append(extensions, id)
}
}
return extensions
}
func run(args []string, home string, out, stderr io.Writer) error {
flags := flag.NewFlagSet("devcontainer", flag.ContinueOnError)
flags.SetOutput(stderr)
language := flags.String("language", "", "c-cpp, go, rust, python, node, java, infra (required)")
selection := flags.String("agents", "auto", "auto, none, or comma-separated codex,cline,opencode,claude,gemini")
force := flags.Bool("force", false, "Replace the two generated files")
flags.Usage = func() {
fmt.Fprintln(stderr, "Usage: devcontainer PROJECT --language LANGUAGE [--agents AGENTS] [--force]")
flags.PrintDefaults()
}
// Accept the project's original position before the flags as well as flags first.
if len(args) > 0 && !strings.HasPrefix(args[0], "-") {
args = append(append([]string{}, args[1:]...), args[0])
}
if err := flags.Parse(args); err != nil {
return err
}
if flags.NArg() != 1 || *language == "" {
flags.Usage()
return errors.New("one project and --language are required")
}
selected, err := selectAgents(*selection, home)
if err != nil {
return err
}
local := discoverLocalExtensions(stderr)
target, err := generate(flags.Arg(0), *language, home, selected, local, *force)
if err != nil {
return err
}
names := strings.Join(selected, ", ")
if names == "" {
names = "none"
}
fmt.Fprintf(out, "Created %s; agents: %s\n", target, names)
if len(local) > 0 {
fmt.Fprintf(out, "Included %d local VS Code extensions.\n", len(local))
}
fmt.Fprintln(out, "Open the project in VS Code and choose Dev Containers: Reopen in Container.")
return nil
}
func main() {
home, err := os.UserHomeDir()
if err == nil {
err = run(os.Args[1:], home, os.Stdout, os.Stderr)
}
if errors.Is(err, flag.ErrHelp) {
return
}
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
}

View File

@@ -0,0 +1,281 @@
package main
import (
"bytes"
"encoding/json"
"os"
"path/filepath"
"slices"
"strings"
"testing"
)
func setup(t *testing.T) (string, string) {
t.Helper()
root := t.TempDir()
home, project := filepath.Join(root, "host home"), filepath.Join(root, "project with spaces")
for _, path := range []string{home, project} {
if err := os.MkdirAll(path, 0755); err != nil {
t.Fatal(err)
}
}
return home, project
}
func read(t *testing.T, path string) string {
t.Helper()
b, err := os.ReadFile(path)
if err != nil {
t.Fatal(err)
}
return string(b)
}
func put(t *testing.T, path, content string) {
t.Helper()
if err := os.MkdirAll(filepath.Dir(path), 0755); err != nil {
t.Fatal(err)
}
if err := os.WriteFile(path, []byte(content), 0600); err != nil {
t.Fatal(err)
}
}
type vscodeCustomizations struct {
Customizations struct {
Vscode struct {
Extensions []string `json:"extensions"`
} `json:"vscode"`
} `json:"customizations"`
}
func extensionsOf(t *testing.T, target string) []string {
t.Helper()
var config vscodeCustomizations
if err := json.Unmarshal([]byte(read(t, filepath.Join(target, "devcontainer.json"))), &config); err != nil {
t.Fatal(err)
}
return config.Customizations.Vscode.Extensions
}
func TestProfiles(t *testing.T) {
for name := range profiles {
t.Run(name, func(t *testing.T) {
home, project := setup(t)
target, err := generate(project, name, home, nil, nil, false)
if err != nil {
t.Fatal(err)
}
var config map[string]any
if err := json.Unmarshal([]byte(read(t, filepath.Join(target, "devcontainer.json"))), &config); err != nil {
t.Fatal(err)
}
if config["containerEnv"].(map[string]any)["HOME"] != home {
t.Fatal("wrong home")
}
if _, ok := config["postCreateCommand"]; ok {
t.Fatal("unexpected agent install")
}
want := append([]string{}, profiles[name].Extensions...)
slices.Sort(want)
if got := extensionsOf(t, target); !slices.Equal(got, want) {
t.Fatalf("wrong extensions: %v", got)
}
dockerfile := read(t, filepath.Join(target, "Dockerfile"))
if !strings.HasPrefix(dockerfile, "FROM "+profiles[name].Image+"\n") || !strings.HasSuffix(dockerfile, "USER vscode\n") {
t.Fatal("wrong Dockerfile")
}
})
}
}
func TestSharedConfig(t *testing.T) {
home, project := setup(t)
put(t, filepath.Join(home, ".codex/auth.json"), "secret-value")
put(t, filepath.Join(home, ".gitconfig"), "[user]\nname = Test\n")
target, err := generate(project, "python", home, []string{"codex"}, nil, false)
if err != nil {
t.Fatal(err)
}
configText := read(t, filepath.Join(target, "devcontainer.json"))
dockerfile := read(t, filepath.Join(target, "Dockerfile"))
if strings.Contains(configText+dockerfile, "secret-value") {
t.Fatal("credential leaked")
}
var config struct {
Mounts []mount
PostCreateCommand string
}
if err := json.Unmarshal([]byte(configText), &config); err != nil {
t.Fatal(err)
}
foundGit, foundAgent := false, false
for _, m := range config.Mounts {
if m.Target == "/run/host-gitconfig" {
foundGit = m.ReadOnly
}
if m.Target == filepath.Join(home, ".codex") {
foundAgent = !m.ReadOnly
}
}
if !foundGit || !foundAgent || !strings.Contains(dockerfile, "include.path /run/host-gitconfig") {
t.Fatal("incorrect sharing")
}
if !strings.Contains(config.PostCreateCommand, "@openai/codex") || !strings.Contains(dockerfile, "COPY --from=node /usr/local/bin/node") {
t.Fatal("missing CLI install or embedded Node")
}
if !slices.Contains(extensionsOf(t, target), "openai.chatgpt") {
t.Fatal("agent VS Code extension missing")
}
}
func TestAgentAndLocalExtensions(t *testing.T) {
home, project := setup(t)
put(t, filepath.Join(home, ".cline/state/config"), "")
put(t, filepath.Join(home, ".agents/AGENTS.md"), "")
local := []string{"github.remotehub", "SAOUDRIZWAN.claude-dev", "ms-vscode.cpptools"}
target, err := generate(project, "python", home, []string{"cline"}, local, false)
if err != nil {
t.Fatal(err)
}
want := []string{"ms-python.python", "charliermarsh.ruff", "saoudrizwan.claude-dev", "github.remotehub", "ms-vscode.cpptools"}
slices.Sort(want)
if got := extensionsOf(t, target); !slices.Equal(got, want) {
t.Fatalf("extensions mismatch: %v", got)
}
}
func TestAgentsShipNpmInsideSudoPath(t *testing.T) {
for name := range profiles {
t.Run(name, func(t *testing.T) {
home, project := setup(t)
put(t, filepath.Join(home, ".cline/state/config"), "")
put(t, filepath.Join(home, ".agents/AGENTS.md"), "")
target, err := generate(project, name, home, []string{"cline"}, nil, false)
if err != nil {
t.Fatal(err)
}
var config map[string]any
if err := json.Unmarshal([]byte(read(t, filepath.Join(target, "devcontainer.json"))), &config); err != nil {
t.Fatal(err)
}
if _, hasFeature := config["features"]; hasFeature {
t.Fatal("the nvm-based node feature breaks the sudo npm postCreateCommand")
}
post, _ := config["postCreateCommand"].(string)
if !strings.Contains(post, "sudo npm install") {
t.Fatalf("missing npm agent install: %q", post)
}
dockerfile := read(t, filepath.Join(target, "Dockerfile"))
if !strings.HasPrefix(dockerfile, "FROM docker.io/library/node:22-bookworm-slim AS node\n") ||
!strings.Contains(dockerfile, "COPY --from=node /usr/local/bin/node /usr/local/bin/node") ||
!strings.Contains(dockerfile, "ln -s ../lib/node_modules/npm/bin/npm-cli.js /usr/local/bin/npm") {
t.Fatal("npm must be reachable inside sudo's secure_path")
}
})
}
}
func TestOverwriteAndSymlinks(t *testing.T) {
home, project := setup(t)
target, err := generate(project, "go", home, nil, nil, false)
if err != nil {
t.Fatal(err)
}
before := read(t, filepath.Join(target, "Dockerfile"))
if _, err := generate(project, "rust", home, nil, nil, false); err == nil {
t.Fatal("overwrote existing configuration")
}
path := filepath.Join(target, "devcontainer.json")
if err := os.Remove(path); err != nil {
t.Fatal(err)
}
victim := filepath.Join(home, "victim")
put(t, victim, "keep")
if err := os.Symlink(victim, path); err != nil {
t.Fatal(err)
}
if _, err := generate(project, "rust", home, nil, nil, true); err == nil {
t.Fatal("accepted symlink")
}
if read(t, victim) != "keep" || read(t, filepath.Join(target, "Dockerfile")) != before {
t.Fatal("changed files before rejecting symlink")
}
}
func TestInvalidInputs(t *testing.T) {
for _, kind := range []string{"agent", "language", "missing-directory", "home", "target-symlink"} {
t.Run(kind, func(t *testing.T) {
home, project := setup(t)
language := "go"
var selected []string
switch kind {
case "agent":
selected = []string{"codex"}
case "language":
language = "unknown"
case "missing-directory":
project = filepath.Join(project, "missing")
case "home":
home = "/"
case "target-symlink":
if err := os.Symlink(home, filepath.Join(project, ".devcontainer")); err != nil {
t.Fatal(err)
}
}
if _, err := generate(project, language, home, selected, nil, true); err == nil {
t.Fatal("invalid input accepted")
}
if exists(filepath.Join(project, ".devcontainer/Dockerfile")) {
t.Fatal("wrote invalid configuration")
}
})
}
}
func TestAgentSelection(t *testing.T) {
home, _ := setup(t)
put(t, filepath.Join(home, ".codex/config.toml"), "")
got, err := selectAgents("auto", home)
if err != nil || strings.Join(got, ",") != "codex" {
t.Fatalf("auto: %v %v", got, err)
}
got, err = selectAgents("codex,codex", home)
if err != nil || len(got) != 1 {
t.Fatal("duplicate agents")
}
if _, err := selectAgents("invalid", home); err == nil {
t.Fatal("unknown agent accepted")
}
}
func TestCLI(t *testing.T) {
for _, first := range []bool{true, false} {
t.Run(map[bool]string{true: "project-first", false: "flags-first"}[first], func(t *testing.T) {
home, project := setup(t)
args := []string{"--language", "go", "--agents", "none", project}
if first {
args = []string{project, "--language", "go", "--agents", "none"}
}
var out bytes.Buffer
if err := run(args, home, &out, &out); err != nil {
t.Fatal(err)
}
if !strings.Contains(out.String(), "agents: none") {
t.Fatal("missing output")
}
})
}
}
func TestLocalExtensionDiscovery(t *testing.T) {
bin := t.TempDir()
script := filepath.Join(bin, "code")
if err := os.WriteFile(script, []byte("#!/bin/sh\necho a.b\necho c.d\n"), 0755); err != nil {
t.Fatal(err)
}
t.Setenv("PATH", bin+string(os.PathListSeparator)+os.Getenv("PATH"))
home, project := setup(t)
var out bytes.Buffer
if err := run([]string{project, "--language", "go", "--agents", "none"}, home, &out, &out); err != nil {
t.Fatal(err)
}
want := []string{"a.b", "c.d", "golang.go"}
slices.Sort(want)
if got := extensionsOf(t, filepath.Join(project, ".devcontainer")); !slices.Equal(got, want) {
t.Fatalf("extensions mismatch: %v", got)
}
if !strings.Contains(out.String(), "Included 2 local VS Code extensions.") {
t.Fatal("missing local extensions summary")
}
}

View File

@@ -0,0 +1,18 @@
package main
var profiles = map[string]profile{
"c-cpp": {Image: "mcr.microsoft.com/devcontainers/base:bookworm", Packages: "build-essential clang clangd cmake gdb valgrind universal-ctags cscope", Extensions: []string{"ms-vscode.cpptools", "ms-vscode.cmake-tools"}},
"go": {Image: "mcr.microsoft.com/devcontainers/go:1.25-bookworm", Packages: "", Extensions: []string{"golang.go"}},
"rust": {Image: "mcr.microsoft.com/devcontainers/rust:1-bookworm", Packages: "", Extensions: []string{"rust-lang.rust-analyzer"}},
"python": {Image: "mcr.microsoft.com/devcontainers/python:3.13-bookworm", Packages: "", Extensions: []string{"ms-python.python", "charliermarsh.ruff"}},
"node": {Image: "mcr.microsoft.com/devcontainers/javascript-node:22-bookworm", Packages: "", Extensions: []string{"esbenp.prettier-vscode"}},
"java": {Image: "mcr.microsoft.com/devcontainers/java:21-bookworm", Packages: "maven", Extensions: []string{"vscjava.vscode-java-pack"}},
"infra": {Image: "mcr.microsoft.com/devcontainers/python:3.13-bookworm", Packages: "shellcheck shfmt", Extensions: []string{"redhat.ansible", "redhat.vscode-yaml"}},
}
var agents = map[string]agent{
"codex": {Package: "@openai/codex", Extension: "openai.chatgpt", Paths: []string{".codex"}},
"cline": {Package: "cline", Extension: "saoudrizwan.claude-dev", Paths: []string{".cline", ".agents"}},
"opencode": {Package: "opencode-ai", Extension: "sst-dev.opencode", Paths: []string{".config/opencode", ".local/share/opencode", ".local/state/opencode"}},
"claude": {Package: "@anthropic-ai/claude-code@2.1.312", Extension: "anthropic.claude-code", Paths: []string{".claude"}},
"gemini": {Package: "@google/gemini-cli", Extension: "Google.geminicodeassist", Paths: []string{".gemini"}},
}

View File

@@ -141,11 +141,22 @@ See `atlas-nextcloud-recovery-test.md` for scope, retained artifact and limitati
## Recurring consistent bundles
`atlas-nextcloud-backup.service` is now an ordered requirement of both
`atlas-nextcloud-backup.service` is an ordered requirement of both
`atlas-borg-backup.service` and the operator-started `atlas-usb-backup.service`.
No additional backup timer is needed: the existing Borg schedule prepares a fresh
bundle before its pool snapshot, and a manual USB run does the same. Preparation
failure blocks the dependent job rather than silently using an old dump.
bundle before its pool snapshot. A structurally complete bundle from an earlier
verified run is reused instead while younger than
`atlas_nextcloud_backup_reuse_max_seconds` (20 h): a manual USB run then skips
the application pause, reaches its LUKS prompt within seconds and captures the
latest Borg-prepared bundle, while the remaining pool snapshot reflects the
moment of the run. Reuse does not re-hash the bundle; it was checksum-verified
at publication. The window is asserted below 24 h so the nightly Borg run,
spaced 24 h plus its randomized delay, never reuses the previous night's bundle.
Preparation failure still blocks the dependent job rather than silently using an
old dump; only a verified, bounded-age bundle may be reused. Set
`ATLAS_NEXTCLOUD_BACKUP_FORCE=1` with `systemctl set-environment` (the unit
passes it through) to ignore the window once and prepare a fresh bundle; unset
the variable afterwards.
The helper checks the mounted datasets and healthy active application state,
serializes preparations and briefly pauses cron, Nextcloud and ONLYOFFICE. It
@@ -171,10 +182,12 @@ sudo systemctl start atlas-nextcloud-backup.service
sudo systemctl show atlas-nextcloud-backup.service -p Result -p ExecMainExitTimestamp
```
The second command briefly interrupts the applications and is an explicit manual
run of the recurring job, not a normal deployment side effect. The preparation
unit is not enabled as a boot backup; only interrupted-job recovery is enabled.
Do not stop a Borg/USB job, break its lock or unmount its source snapshot to run a test.
A manual start briefly interrupts the applications only when it prepares a fresh
bundle; inside the reuse window it logs `Reusing verified ...` and finishes in
seconds without touching them. It remains an explicit manual run of the
recurring job, not a normal deployment side effect. The preparation unit is not
enabled as a boot backup; only interrupted-job recovery is enabled. Do not stop a
Borg/USB job, break its lock or unmount its source snapshot to run a test.
On 2026-10-04, both a new encrypted Borg archive and USB version
`20261004T101101Z-3420114` were independently extracted and their consistent

View File

@@ -2,8 +2,8 @@
Same toolset and mounts as the [ecaas container](deadalus-ecaas-devcontainer.md)
(Git configuration and GitLab CAs, Bash configuration, `~/.m2`, `~/.claude`,
`~/.cline`, `~/.config/ai`, Docker outside of Docker, Claude Code, Cline, delta,
Great Icons), with these differences:
`~/.cline`, `~/.agents`, `~/.config/ai`, Docker outside of Docker, Claude Code,
Cline, delta, Great Icons), with these differences:
- Java 25 (`mcr.microsoft.com/devcontainers/java:25-bookworm`) is the default JDK
and also runs the Java and Spring language servers; there is no second JDK.

View File

@@ -19,8 +19,8 @@ Do not use the production context to build or open the workspace.
The container uses Java 11 for the application and Maven, and Java 21 only for
the Java and Spring language servers. VS Code installs the Java and Spring Boot
extension packs, XML, YAML and the VSCode Great Icons theme (selected as the
file icon theme) inside the container. The Java
extension packs, XML, YAML, the Cline extension and the VSCode Great Icons theme
(selected as the file icon theme) inside the container. The Java
pack includes Maven, the Java debugger and test integration. Prefer the project's
Maven wrapper where present. Node is provided for the Claude and Cline CLIs.
@@ -84,7 +84,13 @@ the container; changes made by `glab` inside affect the WSL configuration.
Claude and Cline use the WSL configuration directly: `~/.claude` and `~/.cline`
are bind-mounted read-write at `/home/vscode/.claude` and `/home/vscode/.cline`,
and `~/.config/ai` read-only at `/home/vscode/.config/ai`. Settings, rules,
the cross-tool `~/.agents` read-only at `/home/vscode/.agents`, and
`~/.config/ai` read-only at `/home/vscode/.config/ai`, so rules, the AGENTS
pointer and the shared AI context follow the WSL host. The playbook keeps
Cline's managed configuration deployed on the host (`cline_deploy_enabled:
true`) even though the cline CLI npm package is not installed there; the CLI
ships inside the image and the VS Code Cline extension is installed through
the devcontainer customizations. Settings, rules,
skills, MCP configuration, sessions and **credential stores** are therefore
shared with, and visible to, the container, and changes made inside it affect
the WSL home. Host paths and tools referenced by rules or skills may need

View File

@@ -0,0 +1,138 @@
# Reusable project devcontainers
`cmd/devcontainer/` is a Go CLI using only the standard library. Build it with
Go 1.22 or newer, from an `infra` checkout:
```sh
go -C cmd/devcontainer build -o "$HOME/.local/bin/devcontainer" .
```
Create `~/.local/bin` first if needed and keep it on `PATH`. The resulting binary
has no Python dependency. Run it on **the development host**, against an existing
project:
```sh
devcontainer ~/src/my-project --language go
devcontainer ~/src/my-project --language python --agents codex,cline
devcontainer ~/src/my-project --language c-cpp --agents none
```
## Ansible deployment
On ikaros, nymph or deadalus, from the local `infra` checkout:
```sh
ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator -K
```
Replace the limit with `nymph` or `deadalus` as appropriate. The task installs
Fedora's Go compiler, copies the sources into the user's build cache, compiles
natively without downloading Go modules, and installs `~/.local/bin/devcontainer`
with mode `0755`. Subsequent runs update the executable only when its contents
change. Rebuilds use the Go cache. The role targets Fedora graphical desktops
and Fedora development workstations; it does not start any containers.
Check mode validates packages and source deployment but skips compilation and
binary installation, and reports that limitation explicitly:
```sh
ansible-playbook ansible/site.yml --limit ikaros --tags devcontainer_generator --check --diff
```
Profiles: `c-cpp`, `go`, `rust`, `python`, `node`, `java`, `infra`. They generate
`.devcontainer/devcontainer.json` and `Dockerfile`. The generated
`customizations.vscode.extensions` list combines the profile extensions, the VS
Code extension of each selected agent (`cline` → `saoudrizwan.claude-dev`,
`claude` → `anthropic.claude-code`, `codex` → `openai.chatgpt`, `gemini` →
`Google.geminicodeassist`, `opencode` → `sst-dev.opencode`) and every extension
installed in the local VS Code, captured through `code --list-extensions` at
generation time; regenerate after installing or removing extensions on the
host. Without a local VS Code on PATH only the profile and agent extensions are
included. Open the project in local VS
Code (in Fedora WSL on deadalus) and choose **Reopen in Container**. The generator
never builds or starts a container, selects a Docker context, modifies application
sources, or removes host packages. Existing `.devcontainer` directories are refused;
`--force` replaces only the two generated files, so commit or back up edits first.
The definitions live centrally in the generator; generated files are standalone.
Regenerate explicitly to take updates. Profile images select a language version
or release family, not immutable digests; npm agents other than Claude currently
resolve the latest release at container creation, matching the host lifecycle.
Agent containers copy Node from the official `docker.io/library/node` image into
`/usr/local` instead of using the nvm-based node feature, so the
`sudo npm install` postCreateCommand works in every profile.
Rebuilds are therefore not bit-for-bit reproducible. Pin image digests and agent
versions in generated project files when a project requires that guarantee.
Project-specific dependencies, ports, services and build commands belong in the
project configuration. The `infra` profile provides Ansible and linters; install
that project's collection requirements inside it separately.
## Shared Git and agents
Like the ecaas/cdp model, executables run inside the container and personal
configuration stays on the host. The generator detects existing configuration
paths without reading credentials. With `--agents auto` (the default), it selects
agents whose configuration directories already exist. Explicit agent selection
fails if required directories are missing. Supported agents: `codex`, `cline`,
`opencode`, `claude`, `gemini`. IBM Bob and desktop applications are not included.
Host `~/.gitconfig` is mounted read-only at `/run/host-gitconfig` and included from
a writable container Git config, allowing VS Code to register its credential
helper. Existing `~/.config/git` and `~/.gitignore_global` are mounted read-only.
Git, Git LFS, delta, OpenSSH and GnuPG are installed. VS Code Dev Containers handles
SSH-agent and HTTPS credential-helper forwarding; start VS Code from the host
session with its working agent. No SSH/GPG private-key directories are mounted.
GPG signing needs a functioning agent-forwarding setup and a test with your key;
the generator does not provision it. Host-specific helpers, `pinentry`, external
Git includes, conditional includes and CA paths still need container-compatible
configuration or additional narrowly scoped mounts. Recreate the container after
replacing a bind-mounted configuration file atomically on the host.
`~/.config/ai` is mounted read-only when present. Selected agents mount their host
configuration/state directories read-write, including credentials, sessions and
rules; changes inside the container affect the host. OpenCode also shares its
XDG data/state directories. The container user remains `vscode`, with its home set
to the **same absolute path as the generating host**, so Codex's absolute
`model_instructions_file` keeps working. This does not mount the full home.
For a different host home path, regenerate there. Host-only programs referenced
by agent settings are not made available automatically.
Claude also mounts `~/.claude.json` when present and forwards
`ANTHROPIC_AUTH_TOKEN` using `${localEnv:ANTHROPIC_AUTH_TOKEN}` as on deadalus.
Start VS Code from a shell that exports it; no token value is generated. Host
keyring-backed logins require separate integration; sharing a directory does not
forward the desktop keyring. VS Code extension storage is not shared.
Only existing paths are mounted. Regenerate after configuring an additional
agent. Generated files use `${localEnv:HOME}` for mount sources and contain no
credential contents, but do contain the host's absolute home path.
## Runtime and validation
Use a local development container engine. Docker CE is currently provisioned on
deadalus; ikaros explicitly has Podman, while nymph's runtime needs verification.
Podman (5+) works through VS Code's `dev.containers.dockerPath: podman` per the
official Dev Containers documentation: the extension drives the container CLI
and needs neither the `podman-docker` shim nor a daemon socket or `DOCKER_HOST`.
Never install `podman-docker` where docker-ce provides the real Docker CLI
(deadalus). Generation alone does not configure the engine; the `desktop_gnome`
profile deploys `dev.containers.dockerPath: podman` with its managed VS Code
settings, while compatible
rootless/UID configuration and SELinux bind-mount access must be validated on the
Fedora target host. Do not recursively relabel the personal home.
No engine socket is mounted inside these containers by default; add access only
for projects that need to launch sibling containers.
Host-side regression checks:
```sh
go -C cmd/devcontainer test ./...
go -C cmd/devcontainer vet ./...
```
On the target host, build/open a generated project, check the language toolchain,
`git config --show-origin --get user.email`, `git ls-remote origin HEAD` against
the expected development remote, and each selected agent's version/login.
Run project tests and verify signing if enabled. These runtime checks require the
real host and are separate from generator tests. Existing ecaas/cdp Ansible
provisioning is unchanged.

View File

@@ -5,6 +5,7 @@ Always follow:
- preserve layering
- avoid duplication
- validate before applying changes
- safety directives: always apply `~/.config/ai/rules/safety.md`
Task-specific file loading:
- For general background on the user, the environment, and stable preferences, read `~/.config/ai/memory/chatgpt/knowledge/00-profilo.md`

View File

@@ -10,3 +10,4 @@ Never break an existing host.
## Git Rules
- Never auto-commit; always ask the user before committing
- Never add your own or any other AI assistant's name as a Git co-author: no `Co-Authored-By: <agent>` trailers, no AI names among the authors. Commits are authored by the human operator only