25 Commits

Author SHA1 Message Date
Fabio Scotto di Santolo
e0fe207771 Add hugo to Void base packages 2026-04-29 19:27:29 +02:00
Fabio Scotto di Santolo
eaf1a7f182 Change gpg key for encrypt 2026-04-29 18:47:12 +02:00
Fabio Scotto di Santolo
4b5879a67e Add task for extract templates for desktop 2026-04-29 09:02:49 +02:00
Fabio Scotto di Santolo
46b6bcd62c Add gist and github-cli to Void base packages 2026-04-28 20:53:48 +02:00
Fabio Scotto di Santolo
d48d2db0ba Color ap command output in cyan
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-28 18:00:09 +02:00
Fabio Scotto di Santolo
18ea0a02ad Fix Alacritty keyboard bindings 2026-04-28 17:50:02 +02:00
Fabio Scotto di Santolo
fa6b082381 Add Claude to Emacs project agent picker 2026-04-28 17:40:43 +02:00
Fabio Scotto di Santolo
e2a66c623f Add Claude Code agent configuration 2026-04-28 17:29:52 +02:00
Fabio Scotto di Santolo
164b11bb73 Add speech dispatcher to Void packages 2026-04-28 16:19:27 +02:00
Fabio Scotto di Santolo
10b0a6225b Update desktop SSH defaults 2026-04-28 16:14:19 +02:00
Fabio Scotto di Santolo
bcd8635d9e Disable Nextcloud AIO on server 2026-04-28 16:07:34 +02:00
Fabio Scotto di Santolo
aa0f787d00 Skip AI agent dotfiles on servers 2026-04-28 14:55:32 +02:00
Fabio Scotto di Santolo
949ae2c47f Add Nextcloud AIO service 2026-04-28 14:48:21 +02:00
Fabio Scotto di Santolo
16850eba53 Update agent operating notes 2026-04-28 12:12:50 +02:00
Fabio Scotto di Santolo
e0869e72d6 Change i3 and i3lock backgrounds 2026-04-27 21:48:37 +02:00
Fabio Scotto di Santolo
e9af0bd1af Template Codex instructions path 2026-04-27 20:48:18 +02:00
Fabio Scotto di Santolo
763bbd8b9f Gemini: configure CLI and update workstation/wsl inventory 2026-04-27 19:22:20 +02:00
Fabio Scotto di Santolo
950cbff85c Ansible: implement selective AI agent deployment across profiles 2026-04-27 19:17:18 +02:00
Fabio Scotto di Santolo
003679f499 Refactor: centralize AI instructions and opencode config into common dotfiles 2026-04-27 19:17:14 +02:00
Fabio Scotto di Santolo
ab294f4cb7 Add NTFS support to Void desktops 2026-04-27 08:37:56 +02:00
Fabio Scotto di Santolo
325a405012 Add Gemini CLI agent support with robust session parsing 2026-04-27 08:27:34 +02:00
Fabio Scotto di Santolo
c9fa536bb5 Add Gemini CLI to npm packages 2026-04-26 20:43:13 +02:00
Fabio Scotto di Santolo
a108957ba4 Add Codex CLI agent support to project launcher 2026-04-26 19:39:14 +02:00
Fabio Scotto di Santolo
0eba6aa9c8 Add OpenAI Codex CLI to npm packages 2026-04-26 16:11:43 +02:00
Fabio Scotto di Santolo
d036eee00a Move nordic-night-theme load into :config block 2026-04-26 15:58:01 +02:00
49 changed files with 279 additions and 42 deletions

0
.codex Normal file
View File

View File

@@ -6,7 +6,9 @@ Ansible-driven personal infrastructure repo for Void desktops, Linux workstation
- Main orchestration: `ansible/site.yml` - Main orchestration: `ansible/site.yml`
- Inventory and layering inputs: `ansible/inventory/hosts.yml`, `ansible/inventory/group_vars/*.yml`, `ansible/inventory/host_vars/*.yml` - Inventory and layering inputs: `ansible/inventory/hosts.yml`, `ansible/inventory/group_vars/*.yml`, `ansible/inventory/host_vars/*.yml`
- Dotfiles live under `dotfiles/` - Dotfiles live under `dotfiles/`
- OpenCode loads global instructions from `dotfiles/desktop/.config/opencode/opencode.json` - AI agent instructions (bootstrap, rules, knowledge) are centralized in `dotfiles/common/.config/ai/` and shared between OpenCode, Codex, and Gemini CLI.
- OpenCode loads its entrypoint configuration from `dotfiles/common/.config/opencode/opencode.json`.
- Codex config is rendered from `dotfiles/common/.codex/config.toml.j2` so `model_instructions_file` points to the deployed `~/.config/ai/bootstrap.md`.
## Topology ## Topology
- Void desktops: `ikaros`, `nymph` - Void desktops: `ikaros`, `nymph`
@@ -38,7 +40,7 @@ Ansible-driven personal infrastructure repo for Void desktops, Linux workstation
- WSL dev: `ansible-playbook ansible/site.yml --limit deadalus-wsl --check --diff` - WSL dev: `ansible-playbook ansible/site.yml --limit deadalus-wsl --check --diff`
- Server: `ansible-playbook ansible/site.yml --limit prometheus --check --diff` - Server: `ansible-playbook ansible/site.yml --limit prometheus --check --diff`
- Focused checks: - Focused checks:
- Emacs dotfiles only: `ansible-playbook ansible/site.yml --limit ikaros --tags emacs --check --diff` or `--limit nymph --tags emacs --check --diff` - Emacs dotfiles only: `ansible-playbook ansible/site.yml --limit ikaros --tags emacs --check --diff` or `--limit nymph --tags emacs --check --diff`
- Sway/Noctalia bootstrap on nymph: `ansible-playbook ansible/site.yml --limit nymph --tags packages,dotfiles:desktop,sway --check --diff` - Sway/Noctalia bootstrap on nymph: `ansible-playbook ansible/site.yml --limit nymph --tags packages,dotfiles:desktop,sway --check --diff`
- Mail bootstrap: `sh -n scripts/bootstrap_mail.sh` and `shellcheck scripts/bootstrap_mail.sh` - Mail bootstrap: `sh -n scripts/bootstrap_mail.sh` and `shellcheck scripts/bootstrap_mail.sh`
- Windows bootstrap parse: `pwsh -NoProfile -Command "[void][System.Management.Automation.Language.Parser]::ParseFile('scripts/bootstrap_windows_workstation.ps1', [ref]$null, [ref]$null)"` - Windows bootstrap parse: `pwsh -NoProfile -Command "[void][System.Management.Automation.Language.Parser]::ParseFile('scripts/bootstrap_windows_workstation.ps1', [ref]$null, [ref]$null)"`
@@ -55,6 +57,7 @@ Ansible-driven personal infrastructure repo for Void desktops, Linux workstation
## Desktop Void Notes ## Desktop Void Notes
- `profile_desktop_common` owns the shared desktop bootstrap. - `profile_desktop_common` owns the shared desktop bootstrap.
- `.emacs.d` is deployed by a dedicated `profile_desktop_common` task tagged `emacs`. - `.emacs.d` is deployed by a dedicated `profile_desktop_common` task tagged `emacs`.
- NTFS filesystem support is provided by `ntfs-3g` in `ansible/inventory/group_vars/void.yml`.
- User services are managed by `turnstile` and live under `dotfiles/desktop/.config/service/`. - User services are managed by `turnstile` and live under `dotfiles/desktop/.config/service/`.
- `ssh-agent` runs under `turnstile` with stable socket `~/.local/state/ssh-agent/socket`. - `ssh-agent` runs under `turnstile` with stable socket `~/.local/state/ssh-agent/socket`.
- Critical session entrypoints: - Critical session entrypoints:
@@ -73,6 +76,13 @@ Ansible-driven personal infrastructure repo for Void desktops, Linux workstation
- `workstation_host_windows` runs with `gather_facts: false` and validates PSRP settings plus `windows_package_backend` before role execution. - `workstation_host_windows` runs with `gather_facts: false` and validates PSRP settings plus `windows_package_backend` before role execution.
- Windows taskbar pins are driven by `windows_taskbar_pins` in `ansible/inventory/group_vars/workstation_host_windows.yml`; validate identifiers from a real Windows session before changing them. - Windows taskbar pins are driven by `windows_taskbar_pins` in `ansible/inventory/group_vars/workstation_host_windows.yml`; validate identifiers from a real Windows session before changing them.
## Coding Agent Notes
- Shared agent packages live in `ai_agents_npm_packages` in `ansible/inventory/group_vars/all.yml`.
- Shared agent dotfiles live in `ai_agents_dotfiles`; rendered configs live in `ai_agents_templates`.
- Desktop, native workstation, and WSL profiles consume the shared agent package list; do not duplicate package entries in profile-specific vars.
- `dotfiles_common` copies common dotfiles plus `ai_agents_dotfiles`, then renders `ai_agents_templates`.
- Keep `.config/ai/` as the common instruction source; update agent-specific entrypoints to reference it rather than duplicating instruction text.
## Tooling Notes ## Tooling Notes
- Install local tooling with: - Install local tooling with:
- `python3 -m pip install ansible ansible-lint yamllint shellcheck-py` - `python3 -m pip install ansible ansible-lint yamllint shellcheck-py`

View File

@@ -50,6 +50,42 @@ common_dotfiles:
dest: .vimrc dest: .vimrc
mode: "0644" mode: "0644"
- name: bat config - name: bat config
src: .config/bat/.config/bat/ src: .config/bat/
dest: .config/bat/ dest: .config/bat/
mode: preserve mode: preserve
ai_agents_npm_packages:
- name: "opencode-ai"
state: latest
- name: "@anthropic-ai/claude-code"
state: latest
- name: "@openai/codex"
state: latest
- name: "@google/gemini-cli"
state: latest
ai_agents_enabled: true
ai_agents_dotfiles:
- name: AI common config
src: .config/ai/
dest: .config/ai/
mode: preserve
- name: Gemini CLI config
src: .gemini/
dest: .gemini/
mode: preserve
- name: OpenCode config
src: .config/opencode/
dest: .config/opencode/
mode: preserve
- name: Claude Code memory
src: .claude/
dest: .claude/
mode: preserve
ai_agents_templates:
- name: Codex config
src: .codex/config.toml.j2
dest: .codex/config.toml
mode: "0644"

View File

@@ -146,9 +146,7 @@ desktop_source_tools:
desktop_binary_tools: [] desktop_binary_tools: []
desktop_npm_packages: desktop_npm_packages: "{{ ai_agents_npm_packages + [] }}"
- name: "opencode-ai"
state: latest
desktop_common_dotfiles: desktop_common_dotfiles:
- name: XDG autostart entries - name: XDG autostart entries
@@ -183,10 +181,6 @@ desktop_common_dotfiles:
src: .config/yt-dlp/ src: .config/yt-dlp/
dest: .config/yt-dlp/ dest: .config/yt-dlp/
mode: preserve mode: preserve
- name: OpenCode config
src: .config/opencode/
dest: .config/opencode/
mode: preserve
- name: MPV config - name: MPV config
src: .config/mpv/ src: .config/mpv/
dest: .config/mpv/ dest: .config/mpv/

View File

@@ -6,6 +6,7 @@ effective_username: "{{ server_username }}"
effective_user_group: "{{ server_user_group }}" effective_user_group: "{{ server_user_group }}"
effective_user_home: "{{ server_user_home }}" effective_user_home: "{{ server_user_home }}"
server_container_stack_dir: /opt/docker/server server_container_stack_dir: /opt/docker/server
ai_agents_enabled: false
profile_packages: profile_packages:
- avahi-daemon - avahi-daemon
@@ -92,6 +93,14 @@ server_directories:
owner: "1000" owner: "1000"
group: "1000" group: "1000"
mode: "0755" mode: "0755"
- path: /srv/nextcloud
owner: root
group: root
mode: "0755"
- path: /srv/nextcloud/data
owner: root
group: root
mode: "0755"
server_ufw_rules: server_ufw_rules:
- rule: allow - rule: allow

View File

@@ -18,9 +18,12 @@ void_packages_base:
- fuse3 - fuse3
- gcc - gcc
- gdb - gdb
- gist
- github-cli
- gnome-keyring - gnome-keyring
- go - go
- gvfs - gvfs
- hugo
- ImageMagick - ImageMagick
- isync - isync
- libsecret - libsecret
@@ -30,6 +33,7 @@ void_packages_base:
- mu4e - mu4e
- network-manager-applet - network-manager-applet
- nodejs - nodejs
- ntfs-3g
- pavucontrol - pavucontrol
- pipewire - pipewire
- pkg-config - pkg-config
@@ -42,6 +46,7 @@ void_packages_base:
- simple-scan - simple-scan
- socklog - socklog
- socklog-void - socklog-void
- speech-dispatcher
- syncthing - syncthing
- system-config-printer - system-config-printer
- tmux - tmux

View File

@@ -1,6 +1,4 @@
--- ---
workstation_manage_opencode: true workstation_manage_opencode: true
workstation_npm_packages: workstation_npm_packages: "{{ ai_agents_npm_packages + [] }}"
- name: "opencode-ai"
state: latest

View File

@@ -16,6 +16,15 @@
loop: "{{ xdg_user_directories | default([]) }}" loop: "{{ xdg_user_directories | default([]) }}"
when: "'void' in group_names" when: "'void' in group_names"
- name: Extract templates kit to Templates directory
tags: [dotfiles, dotfiles:common]
ansible.builtin.unarchive:
src: "{{ playbook_dir }}/../dotfiles/common/templates_kit.zip"
dest: "{{ effective_user_home }}/Templates"
owner: "{{ effective_username }}"
group: "{{ effective_user_group }}"
when: "'void' in group_names"
- name: Ensure SSH socket directory exists - name: Ensure SSH socket directory exists
tags: [dotfiles, dotfiles:common] tags: [dotfiles, dotfiles:common]
ansible.builtin.file: ansible.builtin.file:
@@ -33,10 +42,41 @@
owner: "{{ effective_username }}" owner: "{{ effective_username }}"
group: "{{ effective_user_group }}" group: "{{ effective_user_group }}"
mode: "{{ item.mode }}" mode: "{{ item.mode }}"
loop: "{{ common_dotfiles | default([]) }}" loop: >-
{{
(common_dotfiles | default([]))
+ ((ai_agents_dotfiles | default([])) if (ai_agents_enabled | default(false)) else [])
}}
loop_control: loop_control:
label: "{{ item.dest }}" label: "{{ item.dest }}"
- name: Ensure AI config directories exist
tags: [dotfiles, dotfiles:common]
ansible.builtin.file:
path: "{{ effective_user_home }}/{{ item }}"
state: directory
owner: "{{ effective_username }}"
group: "{{ effective_user_group }}"
mode: "0755"
loop:
- .codex
when:
- ai_agents_enabled | default(false)
- (ai_agents_templates | default([])) | length > 0
- name: Render AI agent templates
tags: [dotfiles, dotfiles:common]
ansible.builtin.template:
src: "{{ playbook_dir }}/../dotfiles/common/{{ item.src }}"
dest: "{{ effective_user_home }}/{{ item.dest }}"
owner: "{{ effective_username }}"
group: "{{ effective_user_group }}"
mode: "{{ item.mode }}"
loop: "{{ ai_agents_templates | default([]) }}"
loop_control:
label: "{{ item.dest }}"
when: ai_agents_enabled | default(false)
- name: Refresh bat cache - name: Refresh bat cache
tags: [dotfiles, dotfiles:common] tags: [dotfiles, dotfiles:common]
ansible.builtin.command: ansible.builtin.command:

View File

@@ -36,6 +36,25 @@ services:
- web - web
- gitea - gitea
# Disabled: prometheus does not have enough resources to run Nextcloud AIO.
# nextcloud-aio-mastercontainer:
# image: ghcr.io/nextcloud-releases/all-in-one:latest
# container_name: nextcloud-aio-mastercontainer
# init: true
# restart: always
# ports:
# - "127.0.0.1:8080:8080"
# environment:
# APACHE_PORT: "11000"
# APACHE_IP_BINDING: "0.0.0.0"
# APACHE_ADDITIONAL_NETWORK: "server_web"
# NEXTCLOUD_DATADIR: "/srv/nextcloud/data"
# volumes:
# - "nextcloud_aio_mastercontainer:/mnt/docker-aio-config"
# - "/var/run/docker.sock:/var/run/docker.sock:ro"
# networks:
# - web
navidromedb: navidromedb:
image: postgres:13 image: postgres:13
container_name: navidromedb container_name: navidromedb
@@ -87,6 +106,11 @@ services:
networks: networks:
web: web:
name: server_web
external: false external: false
gitea: gitea:
external: false external: false
# volumes:
# nextcloud_aio_mastercontainer:
# name: nextcloud_aio_mastercontainer

View File

@@ -0,0 +1,5 @@
# Claude Code Global Context
Import the shared coding agent bootstrap context:
@~/.config/ai/bootstrap.md

View File

@@ -0,0 +1,16 @@
model = "gpt-5.5"
model_reasoning_effort = "medium"
model_instructions_file = "{{ effective_user_home }}/.config/ai/bootstrap.md"
[projects."/home/fscotto/AnsiblePlaybook"]
trust_level = "trusted"
[tui]
theme = "coldark-dark"
[tui.model_availability_nux]
"gpt-5.5" = 3
[features]
memories = true

View File

@@ -0,0 +1,7 @@
{
"$schema": "https://opencode.ai/config.json",
"instructions": [
"~/.config/ai/bootstrap.md",
"~/.config/ai/rules/safety.md"
]
}

View File

@@ -0,0 +1,14 @@
{
"security": {
"auth": {
"selectedType": "oauth-personal"
}
},
"context": {
"fileName": [
"~/.config/ai/bootstrap.md",
"~/.config/ai/rules/safety.md",
"~/.config/ai/AGENTS.md"
]
}
}

Binary file not shown.

Binary file not shown.

View File

@@ -12,7 +12,7 @@ ap() {
cmd+=(--tag "$1") cmd+=(--tag "$1")
fi fi
printf '+ %s\n' "${cmd[*]}" printf '\033[0;36m+ %s\033[0m\n' "${cmd[*]}"
"${cmd[@]}" "${cmd[@]}"
) )
} }

View File

@@ -40,5 +40,6 @@ white = "#ffffff"
[keyboard] [keyboard]
bindings = [ bindings = [
{ key = "V", mods = "Control|Shift", action = "Paste" }, { key = "V", mods = "Control|Shift", action = "Paste" },
{ key = "C", mods = "Control|Shift", action = "Copy" } { key = "C", mods = "Control|Shift", action = "Copy" },
{ key = "Return", mods = "Shift", chars = "\u001B\r" }
] ]

View File

@@ -9,7 +9,7 @@ font pango:Liberation Mono 10
exec --no-startup-id dex --autostart --environment i3 exec --no-startup-id dex --autostart --environment i3
exec --no-startup-id gnome-keyring-daemon --start --components=secrets exec --no-startup-id gnome-keyring-daemon --start --components=secrets
exec_always --no-startup-id setxkbmap -layout us -variant intl exec_always --no-startup-id setxkbmap -layout us -variant intl
exec_always --no-startup-id feh --bg-fill ~/.config/i3/wallpapers/void-minimalist2.png exec_always --no-startup-id feh --bg-center ~/.config/i3/wallpapers/wallpaper-161664.jpg
exec_always --no-startup-id ~/.config/i3/scripts/setup-gtk-theme.sh exec_always --no-startup-id ~/.config/i3/scripts/setup-gtk-theme.sh
exec --no-startup-id /usr/libexec/xdg-desktop-portal exec --no-startup-id /usr/libexec/xdg-desktop-portal

View File

@@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
wallpaper="$HOME/.config/i3/wallpapers/void-minimalist.png" wallpaper="$HOME/.config/i3/wallpapers/maxresdefault.jpg"
cached="$HOME/.cache/i3lock/wallpaper.png" cached="$HOME/.cache/i3lock/wallpaper.png"
dims_cache="$HOME/.cache/i3lock/dims.txt" dims_cache="$HOME/.cache/i3lock/dims.txt"
dims=$(xdotool getdisplaygeometry | tr ' ' 'x') dims=$(xdotool getdisplaygeometry | tr ' ' 'x')

Binary file not shown.

After

Width:  |  Height:  |  Size: 82 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 116 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

View File

@@ -1,7 +0,0 @@
{
"$schema": "https://opencode.ai/config.json",
"instructions": [
"~/.config/opencode/bootstrap.md",
"~/.config/opencode/rules/safety.md"
]
}

View File

@@ -105,8 +105,8 @@
(define-key projectile-command-map (kbd "v") #'fscotto/project-multi-vterm) (define-key projectile-command-map (kbd "v") #'fscotto/project-multi-vterm)
(define-key projectile-command-map (kbd "V") nil) (define-key projectile-command-map (kbd "V") nil)
(define-key projectile-command-map (kbd "x") #'fscotto/project-external-terminal) (define-key projectile-command-map (kbd "x") #'fscotto/project-external-terminal)
(define-key projectile-command-map (kbd "a") #'fscotto/project-opencode-dwim) (define-key projectile-command-map (kbd "a") #'fscotto/project-agent-dwim)
(define-key projectile-command-map (kbd "A") #'fscotto/project-opencode-session) (define-key projectile-command-map (kbd "A") #'fscotto/project-agent-session)
(define-key projectile-command-map (kbd "g") #'fscotto/project-magit-status)) (define-key projectile-command-map (kbd "g") #'fscotto/project-magit-status))
;;;; LSP ;;;; LSP

View File

@@ -2,9 +2,9 @@
;; Load default theme ;; Load default theme
(use-package nordic-night-theme (use-package nordic-night-theme
:ensure t) :ensure t
:config
(load-theme 'nordic-night t) (load-theme 'nordic-night t))
;; Setting default font ;; Setting default font
(set-frame-font "Liberation Mono 14" nil t) (set-frame-font "Liberation Mono 14" nil t)

View File

@@ -1,4 +1,5 @@
;;functions to support syncing .elfeed between machines (require 'seq)
(require 'subr-x)
;;makes sure elfeed reads index from disk before launching ;;makes sure elfeed reads index from disk before launching
(defvar fscotto/elfeed-initial-update-done nil (defvar fscotto/elfeed-initial-update-done nil
"Non-nil once Elfeed has triggered its first automatic update this session.") "Non-nil once Elfeed has triggered its first automatic update this session.")
@@ -128,16 +129,24 @@ Each entry is a cons cell of display string and session id."
"Return the latest saved OpenCode session id for the current project." "Return the latest saved OpenCode session id for the current project."
(cdr (car (fscotto/opencode-session-candidates (fscotto/project-root))))) (cdr (car (fscotto/opencode-session-candidates (fscotto/project-root)))))
(defun fscotto/project-opencode-dwim () (defun fscotto/project-agent-dwim ()
"Open the most useful OpenCode session for the current project. "Choose an agent for the current project and launch it externally."
Resume the latest saved session when available, otherwise create a new one."
(interactive) (interactive)
(let ((session-id (fscotto/project-opencode-latest-session-id))) (let ((agent (completing-read "Agent: " '("Claude" "Codex" "Gemini" "OpenCode") nil t)))
(if session-id (pcase agent
(fscotto/launch-external-terminal (list "opencode" "--session" session-id) ("Claude"
(fscotto/project-root)) (fscotto/launch-external-terminal '("claude" "--continue")))
(fscotto/project-opencode)))) ("OpenCode"
(let ((session-id (fscotto/project-opencode-latest-session-id)))
(if session-id
(fscotto/launch-external-terminal (list "opencode" "--session" session-id)
(fscotto/project-root))
(fscotto/project-opencode))))
("Codex"
(fscotto/launch-external-terminal '("codex" "resume" "--last")))
("Gemini"
(fscotto/launch-external-terminal '("gemini" "--resume" "latest")
(fscotto/project-root))))))
(defun fscotto/project-opencode-session () (defun fscotto/project-opencode-session ()
"Resume a saved OpenCode session for the current project." "Resume a saved OpenCode session for the current project."
@@ -151,6 +160,78 @@ Resume the latest saved session when available, otherwise create a new one."
(fscotto/launch-external-terminal (list "opencode" "--session" session-id) (fscotto/launch-external-terminal (list "opencode" "--session" session-id)
project-directory)))) project-directory))))
(defun fscotto/gemini-session-candidates (directory)
"Return Gemini session candidates for DIRECTORY.
Each entry is a cons cell of display string and session index.
Tries JSON output first, falls back to text parsing if unavailable."
(let* ((default-directory (file-name-as-directory directory))
(json-output (shell-command-to-string
"gemini --list-sessions --output-format json 2>/dev/null")))
(cond
((string-match "^{" json-output)
(ignore-errors
(require 'json)
(let* ((parsed (json-parse-string json-output))
(sessions (gethash "sessions" parsed)))
(when (vectorp sessions)
(seq-map-indexed
(lambda (s idx)
(let* ((idx-str (number-to-string (1+ idx)))
(msg (if (hash-table-p s)
(or (gethash "firstUserMessage" s) "Session")
"Session"))
(ts (and (hash-table-p s)
(ignore-errors (gethash "lastUpdated" s))
(when (stringp it) (string-trim it))))
(label (if ts (format "%s [%s]" msg ts) msg)))
(cons label idx-str)))
sessions)))))
(t
(let* ((output (shell-command-to-string "gemini --list-sessions"))
(lines (seq-filter (lambda (s) (string-match "\\S-" s))
(split-string output "\n" t)))
(data-lines (seq-drop lines 1))
(candidates nil))
(dolist (line data-lines)
(let ((trimmed (string-trim line)))
(when (string-match
(rx (group (one-or-more digit))
(one-or-more whitespace)
(group (one-or-more nonl)))
trimmed)
(push (cons (match-string 2 trimmed)
(match-string 1 trimmed))
candidates))))
(nreverse candidates))))))
(defun fscotto/project-gemini-session ()
"Choose and resume a Gemini session for the current project."
(interactive)
(let* ((project-directory (fscotto/project-root))
(candidates (fscotto/gemini-session-candidates project-directory)))
(unless candidates
(user-error "No Gemini sessions found for %s" project-directory))
(let* ((selection (completing-read "Gemini session: " candidates nil t))
(session-idx (cdr (assoc selection candidates))))
(fscotto/launch-external-terminal
(list "gemini" "--resume" session-idx)
project-directory))))
(defun fscotto/project-agent-session ()
"Choose an agent and resume a saved session for the current project."
(interactive)
(let ((agent (completing-read "Agent session: " '("Claude" "Codex" "Gemini" "OpenCode") nil t)))
(pcase agent
("Claude"
(fscotto/launch-external-terminal '("claude" "--resume")))
("OpenCode"
(fscotto/project-opencode-session))
("Codex"
(fscotto/launch-external-terminal '("codex" "resume")))
("Gemini"
(fscotto/project-gemini-session)))))
(defun fscotto/project-external-terminal () (defun fscotto/project-external-terminal ()
"Open the external terminal in project root." "Open the external terminal in project root."
(interactive) (interactive)

View File

@@ -145,8 +145,8 @@
"C-c p t" "Test" "C-c p t" "Test"
"C-c p v" "Open multi-vterm in project" "C-c p v" "Open multi-vterm in project"
"C-c p x" "Open external term" "C-c p x" "Open external term"
"C-c p a" "OpenCode (dwim)" "C-c p a" "Choose agent"
"C-c p A" "Choose OpenCode session" "C-c p A" "Choose agent session"
"C-c p e" "Edit project config" "C-c p e" "Edit project config"
"C-c p g" "Project Git status" "C-c p g" "Project Git status"
"C-c p 4" "Other Window" "C-c p 4" "Other Window"

View File

@@ -1,4 +1,8 @@
Host vps
IdentityFile ~/.ssh/id_rsa_vps
Host * Host *
IdentityFile ~/.ssh/id_ed25519
ControlMaster auto ControlMaster auto
ControlPath ~/.local/state/ssh/sockets/%r@%h-%p ControlPath ~/.local/state/ssh/sockets/%r@%h-%p
ControlPersist 600 ControlPersist 600