Skip to content

Commit ed7d8fe

Browse files
committed
rigletSchema: using cleaner let-bindings for complex types
1 parent 57ee15f commit ed7d8fe

1 file changed

Lines changed: 37 additions & 30 deletions

File tree

lib/rigletSchema.nix

Lines changed: 37 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,32 @@ let
6262
(types.addCheck localMcpServer (x: x ? command))
6363
(types.addCheck remoteMcpServer (x: x ? url))
6464
];
65+
66+
promptCommand = types.submodule {
67+
options = {
68+
template = mkOption {
69+
description = "The command template itself. Can use $ARGUMENTS, $1, $2...";
70+
type = types.str;
71+
};
72+
73+
description = mkOption {
74+
description = "Short explanation of what this prompt command does. Usually shown in help or autocompletion menu in the harness";
75+
type = types.str;
76+
};
77+
78+
readDocsFirst = mkOption {
79+
description = "Add an instruction to read the riglet's doc first (if it is not eagerly disclosed and contains docs)";
80+
type = types.bool;
81+
default = true;
82+
};
83+
84+
useSubAgent = mkOption {
85+
description = "Have a sub-agent read and run the command (`context: fork` in Claude Code, `subtask: true` in OpenCode). Support depends on harness";
86+
type = types.bool;
87+
default = false;
88+
};
89+
};
90+
};
6591
in
6692
{
6793
options = {
@@ -105,34 +131,10 @@ in
105131
# This is why promptCommands are scoped per riglet.
106132
# WARNING: STILL EXPERIMENTAL. Schema for promptCommands is subject to change
107133
promptCommands = mkOption {
108-
description = ''Reusable prompt templates ("slash commands" for Claude Code, or simply "commands" for OpenCode)'';
109-
type = types.attrsOf (
110-
types.submodule {
111-
options = {
112-
template = mkOption {
113-
description = "The command template itself. Can use $ARGUMENTS, $1, $2...";
114-
type = types.str;
115-
};
116-
117-
description = mkOption {
118-
description = "Short explanation of what this prompt command does. Usually shown in help or autocompletion menu in the harness";
119-
type = types.str;
120-
};
121-
122-
readDocsFirst = mkOption {
123-
description = "Add an instruction to read the riglet's doc first (if it is not eagerly disclosed and contains docs)";
124-
type = types.bool;
125-
default = true;
126-
};
127-
128-
useSubAgent = mkOption {
129-
description = "Have a sub-agent read and run the command (`context: fork` in Claude Code, `subtask: true` in OpenCode). Support depends on harness";
130-
type = types.bool;
131-
default = false;
132-
};
133-
};
134-
}
135-
);
134+
description = ''
135+
Reusable prompt templates ("slash commands" for Claude Code, or simply "commands" for OpenCode)
136+
'';
137+
type = types.attrsOf promptCommand;
136138
default = { };
137139
};
138140

@@ -141,7 +143,9 @@ in
141143
type = types.submodule {
142144
options = {
143145
mainDocFile = mkOption {
144-
description = "Path to the docs' main file (e.g. \"SKILL.md\", \"./files/index.md\"...), relative to 'docs' root";
146+
description = ''
147+
Path to the docs' main file (e.g. "SKILL.md", "./files/index.md"...), relative to 'docs' root
148+
'';
145149
type = types.pathWith {
146150
absolute = false;
147151
};
@@ -182,7 +186,10 @@ in
182186
};
183187

184188
whenToUse = mkOption {
185-
description = "Situations when this riglet should be (at least partially) consulted. Empty list means IMMEDIATELY at startup";
189+
description = ''
190+
Situations when this riglet should be (at least partially) consulted.
191+
Empty list means IMMEDIATELY at startup
192+
'';
186193
type = types.listOf types.singleLineStr;
187194
default = [ ];
188195
};

0 commit comments

Comments
 (0)