From c10761b1ebe7c5e07e937daaea4faf9c3e2d87e8 Mon Sep 17 00:00:00 2001 From: Miguel Palhas Date: Wed, 19 Aug 2026 15:13:51 +0100 Subject: [PATCH] feat: cover pi and opencode in the home-manager module They have no @file imports, so the module concatenates the shared claude-md fragments into one AGENTS.md per tool (.pi/agent/ and .config/opencode/), and links commands/ into opencode's commands dir. Skills need nothing: pi reads ~/.agents/skills and opencode auto-loads both skill roots, all already linked. --- claude-md/opencode-header.md | 1 + nix/home.nix | 43 +++++++++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 claude-md/opencode-header.md diff --git a/claude-md/opencode-header.md b/claude-md/opencode-header.md new file mode 100644 index 0000000..b2675c5 --- /dev/null +++ b/claude-md/opencode-header.md @@ -0,0 +1 @@ +Screenshots: stored in ~/downloads/screenshots, with date time in the filename diff --git a/nix/home.nix b/nix/home.nix index 4d5e58f..1372659 100644 --- a/nix/home.nix +++ b/nix/home.nix @@ -1,5 +1,6 @@ -# Home-manager module: link centralized agent skills into Claude Code + Codex. -# Usage: add this flake as an input, then import this module in your home config. +# Home-manager module: link centralized agent skills into Claude Code, Codex, +# Pi and opencode. Usage: add this flake as an input, then import this module +# in your home config. # # inputs.agent-skills.url = "git+https://git.naps.pt/yolo/agent-skills.git"; # # in home.nix imports: inputs.agent-skills.homeModules.default @@ -9,9 +10,20 @@ # recursive=true links each FILE individually, so machine-local skills can still # live alongside the managed ones in the same dir (a whole-dir symlink would not). { agent-skills }: -{ config, lib, ... }: +{ + config, + lib, + pkgs, + ... +}: let cfg = config.programs.agentSkills; + + # Pi and opencode have no `@file` imports in context files, so the shared + # fragments are concatenated into one AGENTS.md per tool. + concatMd = + name: files: + pkgs.writeText name (lib.concatMapStringsSep "\n" builtins.readFile files); in { options.programs.agentSkills.machine = lib.mkOption { @@ -65,6 +77,31 @@ in # Entry files: machine-local sections + @imports of the fragments above. ".claude/CLAUDE.md".source = "${agent-skills}/entry/CLAUDE.md"; ".codex/AGENTS.md".source = "${agent-skills}/entry/codex-AGENTS.md"; + + # Pi: skills need no wiring — pi reads ~/.agents/skills, linked above. + # Settings stay unmanaged: pi writes ~/.pi/agent/settings.json itself. + ".pi/agent/AGENTS.md".source = concatMd "pi-AGENTS.md" [ + "${agent-skills}/claude-md/machines/${cfg.machine}.md" + "${agent-skills}/claude-md/operating.md" + "${agent-skills}/claude-md/writing.md" + "${agent-skills}/claude-md/code-comments.md" + "${agent-skills}/claude-md/RTK.md" + ]; + + # opencode auto-loads skills from ~/.claude/skills and ~/.agents/skills, + # so only the rules file and commands need linking here. + ".config/opencode/AGENTS.md".source = concatMd "opencode-AGENTS.md" [ + "${agent-skills}/claude-md/opencode-header.md" + "${agent-skills}/claude-md/machines/${cfg.machine}.md" + "${agent-skills}/claude-md/operating.md" + "${agent-skills}/claude-md/writing.md" + "${agent-skills}/claude-md/code-comments.md" + "${agent-skills}/claude-md/RTK.md" + ]; + ".config/opencode/commands" = { + source = "${agent-skills}/commands"; + recursive = true; + }; }; } # Hook wiring lives in ~/.claude/settings.json, which this module does not own.