feat(#2012): ship hyperhive docs as a nix asset + opt-in ~/.claude pointer

This commit is contained in:
damocles 2026-06-27 14:12:19 +02:00 committed by mara
commit 3fb5cb863b
3 changed files with 57 additions and 5 deletions

View file

@ -70,6 +70,24 @@ let
iconPng = pkgs.runCommand "hive-agent-icon.png" { nativeBuildInputs = [ pkgs.librsvg ]; } ''
rsvg-convert -f png -w 512 -h 512 ${config.hyperhive.icon} -o $out
'';
# Generic, agent-agnostic `~/.claude/CLAUDE.md` installed when
# `hyperhive.docs.enable` is on (root/manager default-on; see
# `manager.nix`). claude auto-loads this user-global memory file every
# session, so it's the discovery hook for the docs asset — no
# per-agent prompt injection. It references the STABLE `$HIVE_ASSETS_DIR`
# env var (not the hashed nix-store path) which the agent resolves at
# read time.
docsClaudeMd = pkgs.writeText "hive-docs-claude.md" ''
# Hyperhive reference docs
The hyperhive subsystem docs ship read-only inside this container at
`$HIVE_ASSETS_DIR/docs/` (resolve the env var, e.g.
`ls "$HIVE_ASSETS_DIR/docs"`).
On a fresh deploy, read `$HIVE_ASSETS_DIR/docs/setup.md` first for the
first-run hive bootstrap commands (forge / gateway / matrix
provisioning, spawning the first sub-agents).
'';
in
{
# Shared scaffolding for every hyperhive harness container.
@ -210,6 +228,18 @@ in
'';
};
options.hyperhive.docs.enable = lib.mkEnableOption ''
install a generic `~/.claude/CLAUDE.md` pointing this agent at the
hyperhive reference docs shipped read-only at `$HIVE_ASSETS_DIR/docs/`
(the repo `docs/` tree, packaged into the assets derivation). claude
auto-loads the file every session, so the docs are discoverable
without any per-agent prompt injection. The docs themselves are
always present at `$HIVE_ASSETS_DIR/docs/`; this option only controls
the auto-loaded pointer. Default-on for the root/manager agent (see
`manager.nix`), off elsewhere; any agent can flip it from its
`agent.nix`.
'';
options.hyperhive.allowedBashPatterns = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
@ -1011,6 +1041,14 @@ in
[ -d "$configDir" ] || continue
chown -hR "$userName:$userName" "$configDir" 2>/dev/null || true
done
${lib.optionalString config.hyperhive.docs.enable ''
# hyperhive.docs.enable: point this agent at the hyperhive docs
# via a managed `~/.claude/CLAUDE.md` (claude auto-loads it every
# session). Symlink → always reflects the current flake; the
# chown -h below sets the link's ownership.
mkdir -p "$homeDir/.claude"
ln -sfn ${docsClaudeMd} "$homeDir/.claude/CLAUDE.md"
''}
if [ -d "$homeDir/.claude" ]; then
chown -hR "$userName:$userName" "$homeDir/.claude" 2>/dev/null || true
# 0755 so hive-core (a different unix user) can list the dir and

View file

@ -1,7 +1,13 @@
{ ... }:
{ lib, ... }:
{
# Entry-point for the privileged root agent (ruth). Referenced from
# `flake.nix` (`nixosConfigurations.ruth`) and the meta-flake's
# `applied/ruth/flake.nix`.
imports = [ ./harness-base.nix ];
# The root/manager bootstraps a fresh hive, so it gets the hyperhive
# reference docs surfaced by default (the `~/.claude/CLAUDE.md` pointer
# → `$HIVE_ASSETS_DIR/docs/setup.md`). `mkDefault` so a manager's own
# `agent.nix` can still turn it off. Other agents default off.
hyperhive.docs.enable = lib.mkDefault true;
}