agent: make claudePlugins additive instead of replacing

The base set (skill-creator + base@hyperhive) was declared via the
option's `default`, so a per-agent definition of claudePlugins
replaced it wholesale. Move the base set to a plain `config`
definition instead: a listOf option merges multiple plain definitions
by concatenation, so an agent's own list now adds to the base set
rather than replacing it, while lib.mkForce / lib.mkOverride on the
agent side still replace the whole merged list deliberately (mkDefault
was ruled out explicitly).

Also de-dup at the JSON-render site with lib.unique, so an agent that
names a base-set entry itself doesn't get it installed twice, and
reword the option doc, which still claimed the old REPLACES semantics.

Four module-eval cases cover the unset / agent-adds / mkForce-replaces
/ duplicate-entry shapes.

Refs #4467
This commit is contained in:
atlas 2026-09-18 16:36:44 +02:00 committed by mara
commit b6e180dfbf
2 changed files with 88 additions and 11 deletions

View file

@ -190,10 +190,13 @@ in
options.services.hyperhive.agent.claudePlugins = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
"skill-creator@claude-plugins-official"
"base@hyperhive"
];
# No `default` here — the base set below is set as a plain `config`
# DEFINITION (near the bottom of this file) instead. A
# `default` is exactly what a per-agent definition REPLACES; a second
# definition at the same option instead MERGES, which for a
# `listOf` is a concatenation — the standard NixOS shape for "the base
# set plus whatever the agent adds". `lib.mkForce` / `lib.mkOverride`
# still let an operator replace the whole merged list deliberately.
example = [
"formatter@my-marketplace"
"thinking-tools@anthropics"
@ -208,7 +211,7 @@ in
`/etc/hyperhive/claude-plugins.json`; the harness reads it via
`plugins::install_configured`.
Defaults to Anthropic's `skill-creator` (teaches an agent to
Always includes Anthropic's `skill-creator` (teaches an agent to
write, refine, and evaluate its own skills) plus hyperhive's own
`base` plugin one plugin bundling every skill that applies to
*all* agents regardless of role (currently just `state-hygiene`,
@ -219,11 +222,15 @@ in
Agents get both out of the box, matching the default
marketplaces above.
Note that a per-agent definition REPLACES this default rather
than extending it (ordinary NixOS list-option semantics, same as
`claudeMarketplaces`). An agent that wants extra plugins AND the
defaults should list both `skill-creator@claude-plugins-official`
and `base@hyperhive` alongside them.
A per-agent definition ADDS to that base set rather than
replacing it unlike `claudeMarketplaces`, this list is merged
across every module that defines it (ordinary NixOS list-option
semantics: two plain definitions concatenate). An agent that sets
`services.hyperhive.agent.claudePlugins = [ "foo@bar" ]` gets the
base set plus `foo@bar`, with no need to repeat the base entries.
An operator who wants to replace the base set entirely, rather
than add to it, can still do that with `lib.mkForce` or
`lib.mkOverride`.
'';
};
@ -241,8 +248,20 @@ in
};
config = {
# The base set, as a DEFINITION rather than the option's `default` —
# see the comment on the option above. A plain definition (no
# `lib.mkOrder` wrapper) merges at the same priority as a per-agent
# definition, so `lib.mkForce` on the agent side still wins outright.
services.hyperhive.agent.claudePlugins = [
"skill-creator@claude-plugins-official"
"base@hyperhive"
];
environment.etc."hyperhive/claude-plugins.json".text =
builtins.toJSON config.services.hyperhive.agent.claudePlugins;
# `lib.unique` so an agent that lists `base@hyperhive` (or
# `skill-creator@…`) explicitly, on top of the base set this module
# already contributes, doesn't install it twice.
builtins.toJSON (lib.unique config.services.hyperhive.agent.claudePlugins);
environment.etc."hyperhive/claude-marketplaces.json".text =
builtins.toJSON config.services.hyperhive.agent.claudeMarketplaces;