Compare commits

..

3 Commits

Author SHA1 Message Date
bde34e19f4 Remove AI agents (Gemini, Codex Relay and Github Copilot) 2026-11-01 23:35:17 +01:00
849e522287 Preserve Thunderbird profiles and add OpenCode Mobile support 2026-11-01 20:17:00 +01:00
1e40a867e7 Provision the iCloud Thunderbird profile on GNOME desktops
Seed a Thunderbird profile on ikaros and nymph with the iCloud account
already declared: IMAP imap.mail.me.com:993 over SSL/TLS, SMTP
smtp.mail.me.com:587 over STARTTLS, identity and folder mapping, one
CalDAV calendar and one CardDAV address book.

Account defaults are rendered into a managed user.js because Thunderbird
rewrites prefs.js on exit, while user.js is re-applied at every start.
profiles.ini is seeded only when absent so a profile list Thunderbird
already owns is never replaced.

The address comes from vault_icloud_email and the display name from
vault_personal_full_name. The app-specific password is deliberately not
stored: Thunderbird requests it on first use and keeps it in its own
credential store.

Validated by rendering the templates and running Thunderbird 158 headless
against a sandbox profile: the account was accepted, Local Folders was
created by Thunderbird itself, the CalDAV calendar registered as default
and the CardDAV directory instantiated its abook-icloud.sqlite.
2026-11-01 19:30:10 +01:00
13 changed files with 568 additions and 5 deletions

View File

@@ -57,6 +57,7 @@ Ansible-driven personal infrastructure repo for Fedora and Void desktops, Fedora
- Emacs is disabled by default; temporary Emacs check: `ansible-playbook ansible/site.yml --limit <host> --tags emacs --check --diff -e emacs_enabled=true`
- AI coding agents: `ansible-playbook ansible/site.yml --limit <host> --tags ai_agents --check --diff`
- Mail bootstrap: `sh -n scripts/bootstrap_mail.sh` and `shellcheck scripts/bootstrap_mail.sh`
- Thunderbird iCloud profile: `ansible-playbook ansible/site.yml --limit ikaros --tags thunderbird --check --diff`
- Server NPM Quadlet: `systemctl status prometheus-npm.service`; the Compose fallback is retired.
- Explicit Prometheus legacy cleanup (destructive only without check mode):
`ansible-playbook ansible/site.yml --limit prometheus --tags server_legacy_cleanup --check --diff -e server_legacy_cleanup=true`
@@ -116,6 +117,7 @@ Ansible-driven personal infrastructure repo for Fedora and Void desktops, Fedora
- `dotfiles/desktop/.config/niri/config.kdl` and `session-env` deployed via `desktop_niri_dotfiles` (Niri / Wayland)
- Void Niri lives in `profile_desktop_niri`, gated on `'niri' in desktop_sessions_enabled`; it installs the `emptty` `niri.desktop` session, the `/usr/local/bin/start-niri` launcher, and the xdg-desktop-portal config, mirroring `profile_desktop_sway`.
- Fedora GNOME (`desktop_gnome`) assumes GNOME comes from the Fedora Workstation base install; Ansible deploys shared desktop dotfiles and git/GPG config for `ikaros` and `nymph`, not GNOME settings.
- `profile_desktop_gnome` first discovers configured Thunderbird accounts in both `~/.thunderbird` and `~/.config/thunderbird` and selects an existing profile without changing its account settings. Only if no account exists does it seed a new iCloud IMAP/SMTP profile with CalDAV and CardDAV through a non-overwriting `user.js`. Registry changes preserve other profiles and create backups; Thunderbird must be closed. The bootstrap address comes from `vault_icloud_email` and the app-specific password is never stored by Ansible.
- Do not switch or restart the display manager during a playbook run from an active graphical session.
- `nymph` is the Fedora/GNOME laptop target; keep GNOME settings unmanaged for now and add host-specific tuning only after real use.

View File

@@ -596,6 +596,13 @@ 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.
OpenCode Mobile (`opencode-mobile`) is installed globally through the same npm
lifecycle on Fedora, Void desktops, and WSL. Its plugin declaration and `/mobile`
command are deployed with the OpenCode dotfiles, so its `deploy_enabled` stays
false. The playbook does not run the interactive installer, configure tunnel
providers, or register phone push tokens. Pairing and connectivity remain manual;
see the [upstream instructions](https://github.com/doza62/opencode-mobile#readme).
Run a focused dry run with:
```bash
@@ -639,6 +646,37 @@ Run locally on each workstation (`ansible_connection: local`); use `--limit nymp
on the laptop. With a cold RPM cache, check mode reports that dependency resolution
is not validated; the real run downloads, verifies, and installs the package.
### Thunderbird iCloud profile on Fedora
`profile_desktop_gnome` seeds a Thunderbird profile for `ikaros` and `nymph` so the
iCloud account is already declared: IMAP `imap.mail.me.com:993` over SSL/TLS, SMTP
`smtp.mail.me.com:587` over STARTTLS, the identity and folder mapping, one CalDAV
calendar (`caldav.icloud.com`) and one CardDAV address book (`contacts.icloud.com`).
Before provisioning, the role checks both `~/.thunderbird` and
`~/.config/thunderbird`, including registered absolute profile paths. If a profile
already has a configured mail account, it selects that profile without modifying
its account preferences, passwords, calendars or address books. Registered default
profiles take priority over other discovered profiles. The active registry keeps
its other profiles and is backed up before changes, including installation defaults.
Only when no configured account exists does the role create the iCloud profile
and seed `user.js` without overwriting an existing file. Thunderbird must be closed
before applying this tag; the playbook never stops it automatically. No profile or
mail data is deleted or copied. A fresh installation uses `~/.config/thunderbird`;
an existing legacy `~/.thunderbird` directory is retained.
The address comes from `vault_icloud_email` and the display name from
`vault_personal_full_name`. The password is deliberately not stored: iCloud mail
requires an app-specific password, which Thunderbird requests on first use and
keeps in its own credential store. Set `thunderbird_icloud_enabled: false` to stop
managing the profile without deleting it.
```bash
ansible-playbook ansible/site.yml --limit ikaros --tags thunderbird --check --diff
ansible-playbook ansible/site.yml --limit ikaros --tags thunderbird -K
```
## Main roles
| Role | What it does |

View File

@@ -94,6 +94,10 @@ common_dotfiles:
# Installation and removal are mutually exclusive per agent; the common
# pre-task enforces this before any changes are made.
codex_relay_install_enabled: false
codex_relay_uninstall_enabled: false
gemini_cli_install_enabled: true
gemini_cli_deploy_enabled: true
gemini_cli_uninstall_enabled: false
claude_code_install_enabled: false
claude_code_uninstall_enabled: true
@@ -108,6 +112,11 @@ ai_agents:
install_enabled: true
deploy_enabled: true
uninstall_enabled: false
opencode_mobile:
npm_package: opencode-mobile
install_enabled: true
deploy_enabled: false
uninstall_enabled: false
claude_code:
npm_package: "@anthropic-ai/claude-code"
install_enabled: "{{ claude_code_install_enabled }}"
@@ -122,12 +131,12 @@ ai_agents:
npm_package: codex-relay
install_enabled: "{{ codex_relay_install_enabled }}"
deploy_enabled: false
uninstall_enabled: false
uninstall_enabled: "{{ codex_relay_uninstall_enabled }}"
gemini_cli:
npm_package: "@google/gemini-cli"
install_enabled: true
deploy_enabled: true
uninstall_enabled: false
install_enabled: "{{ gemini_cli_install_enabled }}"
deploy_enabled: "{{ gemini_cli_deploy_enabled }}"
uninstall_enabled: "{{ gemini_cli_uninstall_enabled }}"
github_copilot:
npm_package: "@github/copilot"
install_enabled: false

View File

@@ -101,3 +101,23 @@ desktop_gnome_dotfiles:
src: .config/autostart/Nextcloud.desktop
dest: .config/autostart/Nextcloud.desktop
mode: "0644"
# Thunderbird is provisioned from a seeded profile plus a managed user.js:
# Existing Thunderbird accounts are reused without changing their preferences.
# Only a new profile receives account, calendar and address book defaults in user.js.
# The address comes from Vault; the app-specific password is never stored here
# and is requested by Thunderbird on first use.
thunderbird_icloud_enabled: true
thunderbird_profile_name: "{{ username }}"
thunderbird_profile_dir: "{{ username }}.default-release"
thunderbird_full_name: "{{ vault_personal_full_name | default(username) }}"
thunderbird_icloud_email: "{{ vault_icloud_email }}"
thunderbird_icloud_account_name: iCloud
thunderbird_icloud_imap_host: imap.mail.me.com
thunderbird_icloud_imap_port: 993
thunderbird_icloud_smtp_host: smtp.mail.me.com
thunderbird_icloud_smtp_port: 587
thunderbird_icloud_caldav_url: https://caldav.icloud.com/
thunderbird_icloud_carddav_url: https://contacts.icloud.com/
thunderbird_icloud_calendar_id: 4f2c1d6e-9b3a-4f7c-8e21-6d5a0c9b7e13
thunderbird_icloud_addressbook_uid: 9e0b7c4a-2d51-4a8f-b6c3-1f7d5e2a8b46

View File

@@ -1,7 +1,11 @@
---
hostname: ikaros
codex_relay_install_enabled: true
codex_relay_install_enabled: false
codex_relay_uninstall_enabled: true
gemini_cli_install_enabled: false
gemini_cli_deploy_enabled: false
gemini_cli_uninstall_enabled: true
chatgpt_desktop_enabled: true
desktop_ai_media_enabled: true

View File

@@ -1,6 +1,12 @@
---
hostname: nymph
codex_relay_install_enabled: false
codex_relay_uninstall_enabled: true
gemini_cli_install_enabled: false
gemini_cli_deploy_enabled: false
gemini_cli_uninstall_enabled: true
chatgpt_desktop_enabled: true
# Fedora Workstation/GNOME laptop target. GNOME is provided by the base Fedora

View File

@@ -0,0 +1,144 @@
#!/usr/bin/env python3
"""Read-only discovery and registry plan; never read stored login credentials."""
import configparser
import io
import json
from pathlib import Path
import re
import sys
def read_ini(path):
result = configparser.RawConfigParser()
result.optionxform = str
if path.exists():
with path.open() as source:
result.read_file(source)
return result
def preferences(path):
if not path.exists():
return {}
result = {}
for key, value in re.findall(
r'^\s*user_pref\("([^"\n]+)",\s*(.*?)\);',
path.read_text(), re.MULTILINE,
):
try:
result[key] = json.loads(value)
except ValueError:
continue
return result
def has_account(path):
# user.js alone is only a bootstrap, not an account used by Thunderbird.
prefs = preferences(path / 'prefs.js')
for account in str(prefs.get('mail.accountmanager.accounts', '')).split(','):
server = prefs.get('mail.account.' + account.strip() + '.server')
prefix = 'mail.server.' + str(server) + '.'
if (prefs.get(prefix + 'type') in ('imap', 'pop3', 'nntp')
and prefs.get(prefix + 'hostname')):
return True
return False
def profile_path(root, registry, section):
value = registry.get(section, 'Path')
return (root / value if registry.get(section, 'IsRelative', fallback='1') == '1'
else Path(value)).resolve()
def render(registry):
output = io.StringIO()
registry.write(output, space_around_delimiters=False)
return output.getvalue()
def plan(home, profile_dir, profile_name):
home = Path(home)
# A legacy directory takes precedence over the XDG registry on this build.
roots = [home / '.thunderbird', home / '.config/thunderbird']
root = next((p for p in roots if p.exists()), roots[1])
registries = {p: read_ini(p / 'profiles.ini') for p in roots}
candidates = []
install_ids = set()
for base, registry in registries.items():
installs = read_ini(base / 'installs.ini')
defaults = {registry.get(s, 'Default', fallback='')
for s in registry.sections() if s.startswith('Install')}
defaults.update(installs.get(s, 'Default', fallback='')
for s in installs.sections())
for section in registry.sections():
if not re.fullmatch(r'Profile\d+', section):
continue
path = profile_path(base, registry, section)
if has_account(path):
candidates.append((registry.get(section, 'Path') not in defaults,
base != root, str(path), path))
# Reuse installation associations, including those in the other root.
install_ids.update(s[7:] for s in registry.sections() if s.startswith('Install'))
install_ids.update(installs.sections())
# Also find unregistered profiles, without following arbitrary subtrees.
if base.exists():
for child in sorted(base.iterdir()):
if child.is_dir() and has_account(child):
candidates.append((True, base != root, str(child.resolve()), child.resolve()))
existing = bool(candidates)
selected = min(candidates)[3] if existing else root / profile_dir
if not existing:
number = 0
while selected.exists():
bootstrap = selected / 'user.js'
if (not (selected / 'prefs.js').exists() and bootstrap.exists()
and bootstrap.read_text().startswith('// Managed by Ansible from profile_desktop_gnome')):
break
number += 1
selected = root / (profile_dir + '-' + str(number))
registry = registries[root]
section = next((s for s in registry.sections()
if re.fullmatch(r'Profile\d+', s)
and profile_path(root, registry, s) == selected), None)
if section is None:
number = 0
while registry.has_section('Profile' + str(number)):
number += 1
section = 'Profile' + str(number)
registry.add_section(section)
registry.set(section, 'Name', profile_name if not existing else selected.name)
registry.set(section, 'IsRelative', '0')
registry.set(section, 'Path', str(selected))
for other in registry.sections():
if re.fullmatch(r'Profile\d+', other):
registry.remove_option(other, 'Default')
registry.set(section, 'Default', '1')
if not registry.has_section('General'):
registry.add_section('General')
registry.set('General', 'StartWithLastProfile', '1')
registry.set('General', 'Version', '2')
value = registry.get(section, 'Path')
installs = read_ini(root / 'installs.ini')
for install in sorted(install_ids):
# Do not redirect a separate installation with another configured account.
defaults = []
for base, source in registries.items():
default = source.get('Install' + install, 'Default', fallback='')
if not default:
default = read_ini(base / 'installs.ini').get(install, 'Default', fallback='')
if default:
defaults.append((base / default).resolve())
if any(p != selected and has_account(p) for p in defaults):
continue
for target, name in ((registry, 'Install' + install), (installs, install)):
if not target.has_section(name):
target.add_section(name)
target.set(name, 'Default', value)
target.set(name, 'Locked', '1')
return dict(root=str(root), profile=str(selected), existing_account=existing,
profiles_ini=render(registry), installs_ini=render(installs))
if __name__ == '__main__':
print(json.dumps(plan(*sys.argv[1:])))

View File

@@ -279,3 +279,8 @@
loop_control:
label: "{{ item }}"
when: workstation_firewall_backend | default('firewalld') == 'firewalld'
- name: Configure Thunderbird for iCloud
tags: [dotfiles, dotfiles:desktop, gnome, thunderbird]
ansible.builtin.import_tasks: thunderbird.yml
when: thunderbird_icloud_enabled | default(false) | bool

View File

@@ -0,0 +1,126 @@
---
- name: Inspect existing Thunderbird profiles without changing them
tags: [thunderbird]
ansible.builtin.command:
argv:
- "{{ ansible_facts.python.executable }}"
- -c
- "{{ lookup('ansible.builtin.file', role_path + '/files/thunderbird_profile.py') }}"
- "{{ user_home }}"
- "{{ thunderbird_profile_dir }}"
- "{{ thunderbird_profile_name }}"
become: true
become_user: "{{ username }}"
register: thunderbird_profile_probe
changed_when: false
check_mode: false
- name: Select an existing account or plan an iCloud bootstrap
tags: [thunderbird]
ansible.builtin.set_fact:
thunderbird_selected: "{{ thunderbird_profile_probe.stdout | from_json }}"
- name: Require the iCloud address only when no configured account exists
tags: [thunderbird]
ansible.builtin.assert:
that:
- vault_icloud_email is defined
- vault_icloud_email | length > 0
- vault_icloud_email != 'REPLACE_ME'
- vault_icloud_email is match('^[^@\\s]+@[^@\\s]+$')
fail_msg: >-
vault_icloud_email must hold the iCloud mail address before a new
Thunderbird profile can be provisioned.
quiet: true
when: not thunderbird_selected.existing_account
- name: Check whether Thunderbird is running
tags: [thunderbird]
ansible.builtin.command:
argv: [pgrep, -u, "{{ username }}", -x, thunderbird]
register: thunderbird_running
changed_when: false
failed_when: thunderbird_running.rc not in [0, 1]
check_mode: false
- name: Require Thunderbird to be closed before selecting its profile
tags: [thunderbird]
ansible.builtin.assert:
that: thunderbird_running.rc == 1
fail_msg: Close Thunderbird before running the thunderbird tag; it is never stopped automatically.
- name: Create the selected Thunderbird registry directory
tags: [thunderbird]
ansible.builtin.file:
path: "{{ thunderbird_selected.root }}"
state: directory
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0700"
- name: Create a new profile only when no configured account exists
tags: [thunderbird]
ansible.builtin.file:
path: "{{ thunderbird_selected.profile }}"
state: directory
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0700"
when: not thunderbird_selected.existing_account
- name: Seed iCloud defaults only in a profile without a configured account
tags: [thunderbird]
ansible.builtin.template:
src: thunderbird/user.js.j2
dest: "{{ thunderbird_selected.profile }}/user.js"
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0600"
force: false
no_log: true
when: not thunderbird_selected.existing_account
- name: Discover the Thunderbird installation directory for first-start profile adoption
tags: [thunderbird]
ansible.builtin.stat:
path: "{{ item }}/application.ini"
loop: [/usr/lib64/thunderbird, /usr/lib/thunderbird]
register: thunderbird_installation
when: not thunderbird_selected.existing_account
- name: Seed compatibility information so Thunderbird adopts the new default profile
tags: [thunderbird]
ansible.builtin.copy:
content: |
[Compatibility]
LastPlatformDir={{ item.item }}
LastAppDir={{ item.item }}
dest: "{{ thunderbird_selected.profile }}/compatibility.ini"
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0600"
force: false
loop: "{{ thunderbird_installation.results }}"
loop_control:
label: "{{ item.item }}"
when:
- not thunderbird_selected.existing_account
- item.stat.exists | default(false)
- name: Select the profile while preserving other registered profiles
tags: [thunderbird]
ansible.builtin.copy:
content: "{{ item.content }}"
dest: "{{ thunderbird_selected.root }}/{{ item.name }}"
owner: "{{ username }}"
group: "{{ user_group }}"
mode: "0600"
backup: true
loop:
- name: profiles.ini
content: "{{ thunderbird_selected.profiles_ini }}"
- name: installs.ini
content: "{{ thunderbird_selected.installs_ini }}"
loop_control:
label: "{{ item.name }}"
when: item.content | length > 0

View File

@@ -0,0 +1,66 @@
// Managed by Ansible from profile_desktop_gnome (tag: thunderbird).
// Thunderbird rewrites prefs.js on exit, so the declared defaults live here
// and are re-applied at every start. Seeded only when no account exists;
// Ansible does not overwrite this file or configure an existing account.
//
// The account password is intentionally absent: iCloud mail requires an
// app-specific password, which Thunderbird prompts for and stores in its own
// credential store on first use.
// Mail account
user_pref("mail.accountmanager.accounts", "account1");
user_pref("mail.accountmanager.defaultaccount", "account1");
user_pref("mail.account.account1.server", "server1");
user_pref("mail.account.account1.identities", "id1");
user_pref("mail.server.server1.type", "imap");
user_pref("mail.server.server1.hostname", "{{ thunderbird_icloud_imap_host }}");
user_pref("mail.server.server1.port", {{ thunderbird_icloud_imap_port }});
user_pref("mail.server.server1.socketType", 3);
user_pref("mail.server.server1.authMethod", 3);
user_pref("mail.server.server1.userName", "{{ thunderbird_icloud_email }}");
user_pref("mail.server.server1.name", "{{ thunderbird_icloud_account_name }}");
user_pref("mail.server.server1.directory-rel", "[ProfD]ImapMail/{{ thunderbird_icloud_imap_host }}");
user_pref("mail.server.server1.directory", "{{ thunderbird_selected.profile }}/ImapMail/{{ thunderbird_icloud_imap_host }}");
user_pref("mail.server.server1.max_cached_connections", 5);
user_pref("mail.server.server1.check_new_mail", true);
user_pref("mail.server.server1.check_time", 10);
user_pref("mail.server.server1.login_at_startup", true);
user_pref("mail.server.server1.empty_trash", false);
user_pref("mail.identity.id1.fullName", "{{ thunderbird_full_name }}");
user_pref("mail.identity.id1.useremail", "{{ thunderbird_icloud_email }}");
user_pref("mail.identity.id1.valid", true);
user_pref("mail.identity.id1.smtpServer", "smtp1");
user_pref("mail.identity.id1.compose_html", true);
user_pref("mail.identity.id1.fcc_folder", "mailbox://{{ thunderbird_icloud_email }}@{{ thunderbird_icloud_imap_host }}/Sent%20Messages");
user_pref("mail.identity.id1.draft_folder", "mailbox://{{ thunderbird_icloud_email }}@{{ thunderbird_icloud_imap_host }}/Drafts");
user_pref("mail.smtpservers", "smtp1");
user_pref("mail.smtpserver.smtp1.hostname", "{{ thunderbird_icloud_smtp_host }}");
user_pref("mail.smtpserver.smtp1.port", {{ thunderbird_icloud_smtp_port }});
user_pref("mail.smtpserver.smtp1.try_ssl", 2);
user_pref("mail.smtpserver.smtp1.authMethod", 3);
user_pref("mail.smtpserver.smtp1.username", "{{ thunderbird_icloud_email }}");
user_pref("mail.smtpserver.smtp1.description", "{{ thunderbird_icloud_account_name }} SMTP");
// Calendar (CalDAV). Calendars are discovered from the registry branch.
user_pref("calendar.registry.{{ thunderbird_icloud_calendar_id }}.type", "caldav");
user_pref("calendar.registry.{{ thunderbird_icloud_calendar_id }}.name", "{{ thunderbird_icloud_account_name }}");
user_pref("calendar.registry.{{ thunderbird_icloud_calendar_id }}.uri", "{{ thunderbird_icloud_caldav_url }}");
user_pref("calendar.registry.{{ thunderbird_icloud_calendar_id }}.username", "{{ thunderbird_icloud_email }}");
user_pref("calendar.registry.{{ thunderbird_icloud_calendar_id }}.refreshInterval", 30);
user_pref("calendar.registry.{{ thunderbird_icloud_calendar_id }}.readOnly", false);
user_pref("calendar.registry.{{ thunderbird_icloud_calendar_id }}.disabled", false);
user_pref("calendar.registry.{{ thunderbird_icloud_calendar_id }}.color", "#3a87ad");
user_pref("calendar.list.sortOrder", "{{ thunderbird_icloud_calendar_id }}");
// Address book (CardDAV). dirType 102 is nsIAbManager.CARDDAV_DIRECTORY_TYPE.
user_pref("ldap_2.servers.icloud.dirType", 102);
user_pref("ldap_2.servers.icloud.uid", "{{ thunderbird_icloud_addressbook_uid }}");
user_pref("ldap_2.servers.icloud.description", "{{ thunderbird_icloud_account_name }}");
user_pref("ldap_2.servers.icloud.filename", "abook-icloud.sqlite");
user_pref("ldap_2.servers.icloud.isOffline", false);
user_pref("ldap_2.servers.icloud.position", 3);
user_pref("ldap_2.servers.icloud.carddav.url", "{{ thunderbird_icloud_carddav_url }}");
user_pref("ldap_2.servers.icloud.carddav.username", "{{ thunderbird_icloud_email }}");

View File

@@ -0,0 +1,27 @@
---
description: OpenCode Mobile (QR + push token)
---
Call the `mobile` tool.
Command arguments: $ARGUMENTS
- If $ARGUMENTS is non-empty, call the tool with { token: "$ARGUMENTS" }.
- If $ARGUMENTS is empty, call the tool with no args to print the QR.
Token format:
- `ExponentPushToken[xxxxxxxxxxxxxx]` - Register push token only
- `ExponentPushToken[xxx] ServerUrl[http://...]` - Register with custom server URL
When to use ServerUrl:
- Use when the mobile app is connected directly to a local server
- The serverUrl will be used for notification deep links instead of tunnel
- Omit when using tunnel connection (default behavior)
Important:
- Do not output analysis/thoughts.
- Only call the tool; return no extra text.
Examples:
- `/mobile` - Show QR code for tunnel connection
- `/mobile ExponentPushToken[xxxxxxxxxxxxxx]` - Register token
- `/mobile ExponentPushToken[xxx] ServerUrl[http://192.168.1.100:4096]` - Register with custom URL

View File

@@ -3,5 +3,8 @@
"instructions": [
"~/.config/ai/bootstrap.md",
"~/.config/ai/rules/safety.md"
],
"plugin": [
"opencode-mobile@latest"
]
}

View File

@@ -0,0 +1,113 @@
"""Offline profile-selection regression tests; no real credentials or application."""
import importlib.util
import json
from pathlib import Path
import tempfile
import unittest
path = Path(__file__).resolve().parents[1] / 'ansible/roles/profile_desktop_gnome/files/thunderbird_profile.py'
spec = importlib.util.spec_from_file_location('profile', path)
profile = importlib.util.module_from_spec(spec)
spec.loader.exec_module(profile)
class ProfileTests(unittest.TestCase):
def setUp(self):
self.temp = tempfile.TemporaryDirectory()
self.addCleanup(self.temp.cleanup)
self.home = Path(self.temp.name)
def seed(self, root, directory, account=True, install='TEST'):
base = self.home / root
target = base / directory
target.mkdir(parents=True)
(base / 'profiles.ini').write_text(
f'[Profile0]\nName=original\nPath={directory}\nIsRelative=1\nDefault=1\n'
f'[Install{install}]\nDefault={directory}\nLocked=1\n')
if account:
prefs = {'mail.accountmanager.accounts': 'account7',
'mail.account.account7.server': 'server8',
'mail.server.server8.type': 'imap',
'mail.server.server8.hostname': 'imap.example.test'}
(target / 'prefs.js').write_text('\n'.join(
f'user_pref({json.dumps(k)}, {json.dumps(v)});' for k, v in prefs.items()))
return target
def plan(self):
return profile.plan(self.home, 'managed.default-release', 'managed')
def test_fresh_install(self):
result = self.plan()
self.assertFalse(result['existing_account'])
self.assertEqual(result['root'], str(self.home / '.config/thunderbird'))
self.assertIn('Default=1', result['profiles_ini'])
self.assertEqual(list(self.home.iterdir()), []) # Discovery is read-only.
def test_xdg_account_wins_over_empty_legacy(self):
old = self.seed('.config/thunderbird', 'original')
self.seed('.thunderbird', 'empty', account=False)
result = self.plan()
self.assertTrue(result['existing_account'])
self.assertEqual(result['profile'], str(old))
self.assertIn('Path=empty', result['profiles_ini'])
self.assertIn('Default=' + str(old), result['installs_ini'])
def test_existing_legacy_account_is_untouched(self):
old = self.seed('.thunderbird', 'original')
before = (old / 'prefs.js').read_bytes()
result = self.plan()
self.assertEqual(result['profile'], str(old))
self.assertEqual((old / 'prefs.js').read_bytes(), before)
def test_user_js_is_not_evidence_of_an_existing_account(self):
old = self.seed('.thunderbird', 'unused', account=False)
(old / 'user.js').write_text('user_pref("mail.accountmanager.accounts", "account1");')
self.assertFalse(self.plan()['existing_account'])
def test_absolute_profile_path(self):
old = self.seed('.config/thunderbird', 'original')
registry = old.parent / 'profiles.ini'
registry.write_text(registry.read_text().replace('IsRelative=1', 'IsRelative=0')
.replace('Path=original', 'Path=' + str(old)))
self.assertEqual(self.plan()['profile'], str(old))
def test_second_run_is_idempotent(self):
self.seed('.config/thunderbird', 'original')
self.seed('.thunderbird', 'empty', account=False)
first = self.plan()
root = Path(first['root'])
(root / 'profiles.ini').write_text(first['profiles_ini'])
(root / 'installs.ini').write_text(first['installs_ini'])
second = self.plan()
self.assertEqual(first, second)
def test_registered_default_wins_over_unregistered_account(self):
old = self.seed('.config/thunderbird', 'original')
extra = old.parent / 'aaa-other'
extra.mkdir()
(extra / 'prefs.js').write_bytes((old / 'prefs.js').read_bytes())
self.assertEqual(self.plan()['profile'], str(old))
def test_new_profile_does_not_overwrite_an_unconfigured_profile(self):
old = self.seed('.thunderbird', 'managed.default-release', account=False)
(old / 'prefs.js').write_text('// Existing local preferences, no mail account.\n')
self.assertEqual(self.plan()['profile'], str(old) + '-1')
def test_pending_managed_bootstrap_is_reused(self):
old = self.seed('.thunderbird', 'managed.default-release', account=False)
(old / 'user.js').write_text('// Managed by Ansible from profile_desktop_gnome\n')
self.assertEqual(self.plan()['profile'], str(old))
def test_other_installation_with_its_own_account_is_preserved(self):
old = self.seed('.thunderbird', 'original')
other = old.parent / 'beta'
other.mkdir()
(other / 'prefs.js').write_bytes((old / 'prefs.js').read_bytes())
registry = old.parent / 'profiles.ini'
registry.write_text(registry.read_text() + '[InstallBETA]\nDefault=beta\nLocked=1\n')
result = self.plan()
self.assertIn('[InstallBETA]\nDefault=beta\nLocked=1', result['profiles_ini'])
if __name__ == '__main__':
unittest.main()