Skip to content

Commit 929200b

Browse files
committed
opencode: option to override model used by specialized (sub)agents
1 parent 3c2a315 commit 929200b

File tree

3 files changed

+10
-20
lines changed

3 files changed

+10
-20
lines changed

lib/mkRiglib.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ let
1919
);
2020
};
2121

22-
# Override a derivation so its always built locally, and not queried from remote substituters
22+
# Override a derivation so it is always built locally, and not queried from remote substituters
2323
alwaysLocal =
2424
x:
2525
if pkgs.lib.isDerivation x then

riglets/models.nix

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,8 @@
11
_:
2-
{ lib, ... }:
2+
{ lib, riglib, ... }:
33
{
44
options.models = with lib.types; {
5-
default = {
6-
providerId = lib.mkOption {
7-
type = nullOr str;
8-
description = "Model provider ID. Can be ignored depending on the entrypoint";
9-
default = null;
10-
};
11-
modelId = lib.mkOption {
12-
type = nullOr str;
13-
description = "Model ID";
14-
default = null;
15-
};
16-
};
5+
default = riglib.providerAndModel;
176

187
providers = {
198
disabled = lib.mkOption {
@@ -31,7 +20,7 @@ _:
3120
};
3221

3322
config.riglets.models.meta = {
34-
description = "Pre-select a specific model for a rig (to be imported by compatible entrypoints)";
23+
description = "Pre-select default model for a rig (to be imported by compatible entrypoints)";
3524
status = "stable";
3625
version = "0.1.0";
3726
intent = "base";

riglets/opencode.nix

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ in
3232
let
3333
manifestPath = rig.manifest.override { shownDocRoot = "$RIG_DOCS"; };
3434

35+
toModelId = x: "${x.providerId}/${x.modelId}";
36+
3537
# OpenCode config with permissions and MCP servers
3638
opencodeConfigJson = riglib.toJSON (
3739
{
@@ -112,24 +114,23 @@ in
112114
If models.default.modelId is set, then models.default.providerId must be too
113115
''
114116
else
115-
"${config.models.default.providerId}/${config.models.default.modelId}";
117+
toModelId config.models.default;
116118
}
117119
// lib.optionalAttrs (config.models.providers.disabled != null) {
118120
disabled_providers = config.models.providers.disabled;
119121
}
120122
// lib.optionalAttrs (config.models.providers.enabled != null) {
121123
enabled_providers = config.models.providers.enabled;
122124
}
125+
// lib.optionalAttrs (config.models.specialized != { }) {
126+
agent = lib.mapAttrs (_agentName: toModelId) config.models.specialized;
127+
}
123128
);
124129
in
125130
# Return a folder derivation with bin/ subfolder
126131
pkgs.writeShellScriptBin "opencode" ''
127132
set -euo pipefail
128133

129-
warn() {
130-
printf "\033[0;33m%s\n\033[0m" "$1" >&2
131-
}
132-
133134
export PATH="${rig.toolRoot}/bin:$PATH"
134135
export RIG_DOCS="${rig.docRoot}"
135136
# Exported for convenience

0 commit comments

Comments
 (0)