Repository navigation
Agents: prune stale claude MCP servers, one Nix workflow per agent, enable toggles - #20
Merged
Merged
Conversation
claude-code's ~/.claude.json MCP merge only ever added servers, so one the module stopped managing (headroom) stayed and failed to connect in every session. The sync now remembers what it wrote and drops those names first; it runs with an empty set too. - claude.nixWorkflow (default on): /nix/store access, nix eval/build/log/flake check and fmt/check without a prompt, Bash timeouts long enough for closure builds and VM tests, and a PostToolUse hook that runs alejandra on edited .nix files. The skills runtime env goes into claude's settings env too. - Machine context: a "Nix builds" line (local KVM, remote builders), hardware read from osConfig.hardware.facter.report. facterFile and the unused facterReport are gone (tests set the report inline). - Breaking: <agent>.enabled and skills.enabled are now .enable. - opencode.model and opencode.titleModel options; the github oauth/pat assertion applies without opencode; the PAT wrapper is github-mcp-server-pat; settings.json drops the ignored mcpServers. - Split into flake-parts/homeModules/agents/ with _machine-context.nix and _claude.nix, and checks for the wiring, the machine context and the claude scripts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rges) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Nix workflow moves from claude.nixWorkflow to homeSpec.agents.nixWorkflow and is rendered per agent, so each one is configured alike and still turned on and off on its own: - claude: permissions.allow, /nix/store, Bash timeouts, PostToolUse hook - opencode v2: shell allow rules after the base rules (last match wins), alejandra as the .nix formatter - kimi: PostToolUse hook and the background task timeout, merged into the config.toml /login also writes (tomlkit, at activation) or into a baked kimi.config. No allow rules: kimi matches the whole command string, so a nix prefix would also approve `nix build . && rm -rf ~`. - pi: ~/.pi/agent/extensions/nix-workflow.ts (bash timeout default and cap, alejandra after edit/write); pi never prompts. - The machine context tells every agent to give long Nix builds and VM tests a long timeout (opencode has no timeout setting). opencode gets package, installPackage and settings like the others. New checks: agents-independent (each agent alone writes exactly its own files and gets the same machine context), and agents-scripts now runs the kimi config.toml merge. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andrewthomaslee
added a commit
to external-systems/pkgs
that referenced
this pull request
Nov 7, 2026
…le (#22) overlays.llm-agents (in overlays.default) builds llm-agents.nix's packages against the org nixpkgs (its shared-nixpkgs overlay) and puts them in place of the attrs consumers already read: claude-code, pi-coding-agent (pi), kimi-code, and opencode, which is opencode v2 only (opencode2, linked as bin/opencode). The whole set stays at pkgs.llm-agents. The kimi-code port in pkgs/ is gone: upstream carries it, a release ahead. The input follows our nixpkgs (one nixpkgs), so cache.numtide.com only hits when the revisions match; otherwise the agents build locally or on the remote builder. The code-agent image follows external-systems/modules#20: skills/pi/kimi/claude .enabled -> .enable. dev/flake.lock pins that PR head until it merges. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
sync-locks pins devenv.yaml to the same revision. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
andrewthomaslee
added a commit
to external-systems/home
that referenced
this pull request
Nov 7, 2026
…gents.nix (#21) ## Summary Uses the agents work from external-systems/modules#20 and the llm-agents.nix overlay from external-systems/pkgs#22. external-systems/skills#13 is already merged. ```diff users/netsa/default.nix, users/matt/default.nix homeSpec.agents = { - claude.enabled = true; # likewise pi, kimi, opencode + claude.enable = true; flake.lock / devenv.yaml / devenv.lock (sync-locks) - modules main e78b5b0 + modules main 507a2b0 (modules#20 merged) - org-pkgs main af32ce7 + org-pkgs main c56f3a9 (pkgs#22 merged) ``` What netsa gets on kamrui-h1 (matt likewise, for claude and pi): | | | |---|---| | Agent versions | claude-code 2.1.319, pi 1.5.0, kimi-code 2.5.2, opencode 2.2.6 (v2) | | Every agent | the same machine context, incl. `Nix builds: local KVM; remote builders: euc-hel-0 (…)` and the long-timeout advice; the same MCP servers and skills | | claude | Nix commands and `/nix/store` without a prompt, 10/60 min Bash timeouts, alejandra hook; the stale `headroom` entry is removed from `~/.claude.json` | | opencode | the same shell allow rules, and alejandra as the `.nix` formatter | | kimi | alejandra hook and a 60 min background task limit, merged into `~/.kimi-code/config.toml` | | pi | `~/.pi/agent/extensions/nix-workflow.ts` (timeout default and cap, alejandra after edits) | ## Evidence - `devenv shell -- fmt` passes; `devenv shell -- nix flake check` → exit 0 (every machine evaluates). - `nix eval` of `kamrui-h1…users.netsa`: the packages are `pi-1.5.0, kimi-code-2.5.2, claude-code-2.1.319, opencode-2.2.6`; the activations are `claudeMcpServers` and `kimiNixWorkflow`; `.pi/agent/extensions/nix-workflow.ts` is present. ## Merge Danger **Door:** two-way **Blast Radius:** netsa, matt external-systems/modules#20 and external-systems/pkgs#22 are merged; the lock is on main for both (`nix flake update modules org-pkgs && sync-locks`). Deploy (owner): `clan machines update kamrui-h1` (and beelink). On first activation, claude's `~/.claude.json` loses the stale `headroom` entry, and kimi's `config.toml` gains the hook and the `[task]` timeout. Every other key in both files is kept. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
andrewthomaslee
added a commit
that referenced
this pull request
Nov 14, 2026
Claude Code's Bash tool replaces `grep` with its bundled ugrep, so a PCRE lookaround silently failed a check in the retro session. The note goes only into ~/.claude/CLAUDE.md (pi, kimi and opencode do not have the wrapper); agents-wiring asserts that CLAUDE.md is the shared machine context plus that note. org-pkgs 2fa0b28 (pkgs#33: eval-warning gate, vm-test --resume, runner self-test, grep -q lint) and skills d6f59bf (#20); sync-locks in the same commit. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes and workflow improvements for
homeModules.agentsfrom a review of the agents config.1. Stale claude MCP servers are removed. The activation merge into
~/.claude.jsononly ever added servers, so a server the module stopped managing (headroom) stayed there and failed to connect in every session.Servers added by hand with
claude mcp add, and every other key, are kept.2. One Nix workflow for every agent (
homeSpec.agents.nixWorkflow.{enable,formatOnEdit}, on by default). It is rendered per agent in_nix-workflow.nix, so every agent gets the same defaults and each still turns on and off on its own:fmt,checkwithout a promptpermissions.allowshellallow rules (after the base rules; last match wins)/nix/storeadditionalDirectoriesexternal_directoryruleBASH_*_TIMEOUT_MS10/60 min[task] bash_task_timeout_s60 min.nixeditsformatter.nixfmttool_result)settings.jsonopencode.jsonconfig.tomlat activation²~/.pi/agent/extensions/nix-workflow.ts¹ kimi matches a rule against the whole command string without splitting it, so allowing
nix buildwould also approvenix build . && rm -rf ~.² kimi's
/loginwrites providers, models and oauth into the same file.kimi-config-merge(tomlkit) swaps only the module's hook and keeps every other key and comment. A bakedkimi.configgets the same keys at eval time instead.The skills runtime env (
NODE_PATH) also goes into claude's settings env, so it applies however claude is launched. opencode gainspackage,installPackageandsettings, like the other agents.3. The machine context says where builds run. It adds a line like
Nix builds: local KVM; remote builders: euc-hel-0 (x86_64-linux, aarch64-linux, kvm). Hardware is now read fromosConfig.hardware.facter.report.4. Layout and checks:
Breaking changes (no compat shims, by design):
homeSpec.agents.{pi,kimi,claude,opencode}.enabled.enablehomeSpec.agents.skills.enabledskills.enablemachineContext.facterFile,machineContext.facterReportosConfig.hardware.facter)github-mcp-server-opencodewrappergithub-mcp-server-patSmaller changes:
opencode.modelandopencode.titleModeloptions (previously hardcoded)~/.claude/settings.jsonno longer carries themcpServersclaude ignores thereEvidence
~/.claude.jsonon kamrui-h1 listsartifacthub, github, headroom, nixos; claude reportsheadroom (CONNECTION_CLOSED).After:
claude-mcp-sync, run on a copy of that file with the current server set →["artifacthub","github","nixos"], and every other key is identical (diffofdel(.mcpServers)is empty).checks.agents-independent: each agent enabled alone writes exactly its own files and activations, has skills, and gets the same machine context as with all four on.config.tomlwith no warning; a malformed hook printsIgnored invalid config section 'hooks'.nix-workflow.ts(a broken extension fails withParseError). The handlers themselves need a logged-in model and were not run.opencode.jsonwithout warnings.checks.agents-scriptscovers the kimi merge (it keeps/login's keys and comments and the user's own hook, replaces a stale module hook, removes it when the workflow is off, and creates no file when there is nothing to add) and these cases:.nixfiles are formatted and other files are notchecks.agents-machine-contextcompares the full rendered text for a synthetic machine (facter report, KVM, a remote builder), and checks a KubeVirt-like guest with no KVM and no report.devenv shell -- fmtpasses;devenv shell -- nix flake check→ exit 0 (15 checks).Merge Danger
Door: two-way
Blast Radius: consumers
*.enabled→*.enableinusers/netsaandusers/mattin the PR that bumpsmodules. That PR is open and locked to this branch.dev/flake.lockpins this PR's head.nixWorkflow(harmless underbypassPermissions; adds alejandra to the closure). It can sethomeSpec.agents.nixWorkflow.enable = false. The rename for the image is in AI coding agents from numtide/llm-agents.nix (opencode v2 only); code-agent image uses <agent>.enable pkgs#22.~/.claude.jsonserver that happens to share a name the module manages (github,headroom,nixos,kubernetes,artifacthub).Merge order: this PR → external-systems/pkgs#22 → external-systems/home#21. external-systems/skills#13 is merged;
flake.lockpinsskillsto main (d6ffaf0).🤖 Generated with Claude Code