Skip to content

Commit bef1c8b

Browse files
committed
refactor(config): clarify agent label selection
Replace the inline agent label conditional in the schema generator with a small exhaustive switch helper. This keeps future agent-specific labels out of nested ternaries and makes the config schema label rules easier to extend.
1 parent 1047bca commit bef1c8b

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

‎apps/ccusage/scripts/generate-json-schema.ts‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,24 @@ function createCommandsJsonSchema(
157157
};
158158
}
159159

160+
function getAgentConfigLabel(agentName: AgentName): string {
161+
switch (agentName) {
162+
case 'amp':
163+
case 'claude':
164+
case 'codex':
165+
case 'hermes':
166+
case 'opencode':
167+
return agentName;
168+
case 'pi':
169+
return 'pi-agent';
170+
}
171+
}
172+
160173
function createAgentJsonSchema(
161174
agentName: AgentName,
162175
commandSchemas: Record<string, TokenSchema>,
163176
): JsonSchemaNode {
164-
const agentLabel = agentName === 'pi' ? 'pi-agent' : agentName;
177+
const agentLabel = getAgentConfigLabel(agentName);
165178
return {
166179
type: 'object',
167180
properties: {

0 commit comments

Comments
 (0)