Commit Graph
21 Commits
Author SHA1 Message Date
oqyude 574ec2719c Revert "feat(home,agents): herdr workspaces connect to shared opencode serve (ADR-0006, T34)"
test-runner / smoke (push) Canceled after 0s
This reverts commit 3e85307361.
2026-10-15 20:15:39 +03:00
oqyude 158f08d14a Revert "feat(home,agents): herdr workspaces now actually attach to shared opencode serve (ADR-0006 + symlink)"
This reverts commit 16a44b9fb2.
2026-10-15 20:15:39 +03:00
oqyude 16a44b9fb2 feat(home,agents): herdr workspaces now actually attach to shared opencode serve (ADR-0006 + symlink)
test-runner / smoke (push) Canceled after 0s
Предыдущая редакция (коммит 3e85307) положила шим первым в
Service.Environment herdr-юнита, но в боевом сценарии шим не
сработал: home-manager wrap (/etc/profiles/per-user/oqyude/bin/opencode)
всё равно выигрывал на интерактивных zsh-панелях с oh-my-zsh.

Причина (найдена эмпирически 2026-10-15): /etc/static/zshrc
подгружает oh-my-zsh.sh, который пересобирает $PATH из
$HOME/.nix-profile/bin и своего plugin list (ripgrep, nodejs-22, bun,
gh, ast-grep). Пересобранный PATH не содержит наш шим-каталог,
поэтому command -v opencode в панели возвращает wrap, и herdr
стартовал полный TUI с собственным LLM-аккаунтом.

Решение — второй слой: home-manager home.file кладёт симлинк
~/.local/bin/opencode → opencodeAttachShim/bin/opencode (под тем
же lib.mkIf config.programs.opencode.web.enable). ~/.local/bin
первый в PATH после ~/.local/bin/env, и этот симлинк
переживает пересборку PATH oh-my-zsh.

Проверено боевым тестом (sapphira, 2026-10-15T19:37):
herdr workspace create → herdr agent start opencode →
pane process-info: argv = [.../opencode-1.19.0/bin/opencode,
  attach, http://127.0.0.1:4096, --dir, /tmp/attach-smoke]
(5 аргументов вместо 1 у wrap'а); ss показывает 8 ESTAB
к 127.0.0.1:4096, 0 исходящих на LLM-провайдеры. RSS
упал с 570 МБ до 302 МБ, главный выигрыш — LLM-запросы
централизуются на opencode-web.service, открытие N воркспейсов
не множит N независимых LLM-аккаунтов.

Service.Environment остаётся как страховочный слой; для хостов
без oh-my-zsh он самодостаточен, для текущего sapphira (oh-my-zsh
включён) — нужен оба.

T34 в tasks/manifest.json: добавлены критерии про симлинк,
nixos-rebuild switch rc=0, боевой тест, отсутствие LLM-сокетов.
R1.16 в project-rules.md и инвариант 13 в AGENTS.md: расширены
под двухслойную схему. ADR-0006: новый раздел «Двухслойная
схема» с эмпирическим сценарием и командами теста.
2026-10-15 19:41:32 +03:00
oqyude 3e85307361 feat(home,agents): herdr workspaces connect to shared opencode serve (ADR-0006, T34)
test-runner / smoke (push) Canceled after 0s
herdr-демон v0.9.3 запускает агента как голый `opencode`
(src/detect/mod.rs: `Agent::OpenCode => "opencode"`) и вписывает токен в
шелл панели (src/app/agents.rs: `start_agent`). Конфиг-хука на замену
executable у herdr нет (`herdr --default-config` без `agent.*`).
На 2-4 вкладках это даёт 1.6-3.2 ГиБ opencode-инстансов поверх
5.6 ГиБ sapphira.

Решение: PATH-шим в herdr-юните. `opencodeAttachShim`
(`pkgs.writeShellScriptBin "opencode"`) кладётся первым в
`systemd.user.services.herdr.Service.Environment` под
`lib.mkIf config.programs.opencode.web.enable` и превращает голый
вызов в `opencode attach http://127.0.0.1:4096 --dir "$PWD"`. Реальные
подкоманды шим пропускает насквозь, resume после рестарта демона
(`opencode --session <id>`, src/agent_resume.rs) — в attach-with-session.
На rydiwo, где opencode.nix не импортирован, шим не ставится
(опция на default `false`).

Env (EnvironmentFile с OPENCODE_SERVER_USERNAME/PASSWORD и
GEMINI_API_KEY) тот же sops-файл, что у `opencode-web.service` —
`opencode attach` берёт basic-auth из env автоматически. systemd
НЕ разворачивает `$PATH` в `Environment=` (проверено на sapphira
2026-10-15: `PATH=/x:$PATH` хранится литералом), PATH выписан
целиком из реально существующих каталогов. R2 (Service ≠ serviceConfig)
соблюдён.

Доказательства (sapphira):
  • `nix build .#nixosConfigurations.sapphira.config.system.build.toplevel` — rc=0
  • отрендеренный herdr.service: `Environment=PATH=<shim>/bin:…`,
    `EnvironmentFile` и `ExecStart` не изменены
  • шим-перехват: `opencode --help` → attach help; `opencode serve --help` → passthrough
  • живой сервер: 3 сессии в opencode.db с `directory=/tmp/attach-smoke`
    созданы через `run/attach --attach`
  • `opencode attach` в pty держит связь

Документация (ADR-0006, T34): .agent/decisions/0006-herdr-shared-
opencode-serve.md. R1.16 в project-rules.md, инвариант 13 в AGENTS.md,
T34 в tasks/manifest.json. nixos-rebuild switch НЕ выполнен — на
ваше усмотрение после ревью.

Главный риск (открыто): opencode #55076 — общий сервер при resume
может не вернуть permissions/step-limits (та самая причина, по которой
предыдущая редакция herdr.nix обходила shared service). Митигация
лежит на сервере (OPENCODE_CONFIG_CONTENT cap или выделенный serve),
не в этом модуле. Мониторить; при рецидиве — менять на opencode-web
или поднимать выделенный.
2026-10-15 18:56:48 +03:00
oqyude 2ab48515b9 fix(home): add nodejs_22 to herdr-runtime.nix (herdr-web-ui preflight)
test-runner / smoke (push) Canceled after 0s
После feat(essentials): enable programs.nix-ld, bun-runtime plugin install
прошёл дальше preflight — теперь падает на следующем шаге: «herdr web ui
needs Node 18 or newer for its terminal sidecar, and 'node' is not on the
PATH of the shell that started herdr».

preflight.sh плагина проверяет `node --version` на PATH. На sapphira
node уже был через opencode.nix home.packages (там же, где раньше был
bun — мы его оттуда убрали в прошлом рефакторе). На rydiwo opencode
не подключён, и node отсутствовал.

Добавляю pkgs.nodejs_22 в home.modules.herdr-runtime.nix — это тот же
пакет, что используется в opencode.nix (consistency, один major). На
sapphira он уже был через opencode; home.packages мерджит и дедуплицирует,
так что лишней копии не будет.
2026-10-15 15:33:33 +03:00
oqyude 7f301765b5 refactor(home): extract pkgs.bun into herdr-runtime.nix, drop duplication
test-runner / smoke (push) Canceled after 0s
Раньше bun для пользовательского shell PATH приходил двумя путями:
на sapphira — через opencode.nix:339 (home.packages=[... pkgs.bun ...]),
на rydiwo — добавлен вручную в home/secondary.nix (commit ffd85dc) для
herdr-web-ui plugin'а, который без bun в PATH скачивает generic-linux
runtime и ломается о NixOS dynamic linker.

Теперь:
  • home/modules/herdr-runtime.nix — единый источник pkgs.bun для
    пользовательского PATH (импортируется и в server.nix, и в
    secondary.nix).
  • home/secondary.nix — добавлен импорт herdr-runtime.nix, убран
    прямой home.packages = with pkgs; [ bun ]; и его 10-строчный
    комментарий-объяснение (переехал в herdr-runtime.nix).
  • home/server.nix — добавлен импорт herdr-runtime.nix.
  • home/modules/opencode.nix — pkgs.bun удалён из home.packages
    (он теперь из herdr-runtime.nix), но ОСТАВЛЕН в
    programs.opencode.extraPackages (line 271) — это другой PATH
    (--suffix PATH внутри opencode-wrapped env), не дубликат.

Результат для обоих хостов:
  - shell PATH: bun из /nix/store/...-bun-*/bin/bun
  - opencode-wrapped env (только sapphira): bun через extraPackages
  - herdr-web-ui plugin auto-install на rydiwo: находит bun в PATH,
    не скачивает generic-linux runtime

После этого оба хоста пересобираются (sapphira: opencode/server.nix;
rydiwo: secondary.nix + новый модуль).
2026-10-15 15:07:54 +03:00
oqyude 4d1426cab0 feat(home): add herdr user service + herdr.zeroq.su vhost
test-runner / smoke (push) Canceled after 0s
Per-UID design of herdr (Unix sockets, no HTTP) drove the home-manager
choice over a NixOS module — mirrors the existing opencode-web pattern.

  - home/modules/herdr.nix: new systemd user service running
    herdr 0.9.3 on sapphira, --session herdr-prod,
    EnvironmentFile from sops opencode_server. 2G/4G cgroup caps,
    Restart=always (mitigates herdr#4920).
  - modules/server/nginx.nix: herdr.zeroq.su vhost with Authelia
    forward-auth (wildcard *.zeroq.su policy already covers it).
    Upstream 127.0.0.1:7317 is the Bun server from the
    devswha/herdr-web-ui plugin (970star, MIT) — vhost 502s until
    'herdr plugin install devswha/herdr-web-ui' runs.
  - modules/server/coredns.nix: 192.168.1.20 herdr.zeroq.su A record.
  - home/server.nix: import the new module.
2026-10-15 04:35:06 +03:00
oqyude 3babee5392 opencode: remove opencode-loop plugin
test-runner / smoke (push) Successful in 1s
Reverts the plugin registration added in 4ff7188 ("opencode:
opencode-loop added"). The entry had to be dropped from both places
inside programs.opencode, otherwise the plugin keeps loading in the
TUI:

  settings.plugin -> ~/.config/opencode/opencode.json
  tui.plugin      -> ~/.config/opencode/tui.json

oh-my-openagent is untouched; its agent and category overrides in
~/.omo/omo.jsonc still apply.
2026-10-14 23:44:01 +03:00
oqyude dfb7830d75 nix flake update 2026-10-13 16:16:20 +03:00
oqyude 13552039c7 opencode: opencode fix 2026-10-13 04:33:47 +03:00
oqyude 4ff7188678 opencode: opencode-loop added 2026-10-13 03:46:43 +03:00
oqyude 02927a26bb vtimeline added and formatted 2026-10-09 16:59:45 +03:00
oqyude bc5aad87da opencode remapping 2026-10-09 16:38:16 +03:00
oqyude e7c0fde0b1 tty added and opencode fixed 2026-10-09 14:48:12 +03:00
oqyude 5e9641602a opencode: dynamic HM symlink, env via xlib, document migration journal
Three small things together:

1. relinkHomeManager was pinning the versioned symlink name to
   'home-manager-24-link'. That breaks on every HM major-version bump:
   HM 25 will move the alias to 'home-manager-25-link' and the script
   will silently stop relinking. Derive the name from one hop of the
   stable 'home-manager' symlink, with a guard against the missing case
   so a fallback never accidentally rewrites the profiles/ directory
   itself.

2. programs.opencode.web.environmentFile now reads from
   xlib.dirs.opencode-server-env (added previously in users.nix + dirs.nix).
   The sops materialization and the systemd EnvironmentFile can no
   longer silently desync.

3. Document the oh-my-openagent 2026-07-opencode-config-unification
   migration trap that logs 'Migration backup path already exists' on
   every startup: the backup path embeds the content-hashed store path,
   which stays valid in /nix/store across HM activations, so the
   deterministic collision never resolves itself. Recovery is
   'rm -rf ~/.omo/migration-backup-*' to let omo retry; if it keeps
   failing on the same path the plugin version probably expects a new
   schema and this file needs changes.

Also trim the over-explained [Service] / serviceConfig comment: the
home-manager attrset-union behavior is general, not specific to this
unit, so the explanation got shorter without losing the invariant.
2026-10-07 11:38:16 +03:00
oqyude c73a698857 opencode fix linger 2026-10-04 22:27:55 +03:00
oqyude cc20ee637d opencode oom fixes 2026-10-04 17:41:32 +03:00
oqyude fb56f6310b opencode 2026-10-03 20:21:19 +03:00
oqyude 5f6288bd15 unused code 2026-08-08 17:48:43 +03:00
oqyude af373baecc refind is rofl
121

1

12

12

1

12

12

12

1

asd
2026-03-09 22:07:18 +03:00
oqyude f1a81a6408 Init 2026-03-09 10:50:12 +03:00