@@ -3,7 +3,11 @@ import fs from 'node:fs'
33import os from 'node:os'
44import path from 'node:path'
55import type { Config } from '@opencode-ai/sdk'
6- import { createConfigHandler } from '../../src/lib/config-handler.ts'
6+ import {
7+ createConfigHandler ,
8+ formatAgentDescription ,
9+ toTitleCase ,
10+ } from '../../src/lib/config-handler.ts'
711import { formatFrontmatter } from '../../src/lib/frontmatter.ts'
812
913describe ( 'config-handler' , ( ) => {
@@ -78,6 +82,67 @@ Command template for ${name}.`,
7882 )
7983 }
8084
85+ describe ( 'toTitleCase' , ( ) => {
86+ test ( 'converts kebab-case to Title-Case' , ( ) => {
87+ expect ( toTitleCase ( 'architecture-strategist' ) ) . toBe (
88+ 'Architecture-Strategist' ,
89+ )
90+ } )
91+
92+ test ( 'handles single word' , ( ) => {
93+ expect ( toTitleCase ( 'oracle' ) ) . toBe ( 'Oracle' )
94+ } )
95+
96+ test ( 'handles empty string' , ( ) => {
97+ expect ( toTitleCase ( '' ) ) . toBe ( '' )
98+ } )
99+
100+ test ( 'handles single-character segments' , ( ) => {
101+ expect ( toTitleCase ( 'a-b-c' ) ) . toBe ( 'A-B-C' )
102+ } )
103+
104+ test ( 'handles numbers in segments' , ( ) => {
105+ expect ( toTitleCase ( 'v2-api-agent' ) ) . toBe ( 'V2-Api-Agent' )
106+ } )
107+
108+ test ( 'preserves already-capitalized characters after first' , ( ) => {
109+ expect ( toTitleCase ( 'REST-API' ) ) . toBe ( 'REST-API' )
110+ expect ( toTitleCase ( 'AI-reviewer' ) ) . toBe ( 'AI-Reviewer' )
111+ } )
112+ } )
113+
114+ describe ( 'formatAgentDescription' , ( ) => {
115+ test ( 'appends branding suffix with title-cased name' , ( ) => {
116+ expect (
117+ formatAgentDescription (
118+ 'code-simplicity-reviewer' ,
119+ 'Reviews code for simplicity' ,
120+ ) ,
121+ ) . toBe (
122+ 'Reviews code for simplicity (Code-Simplicity-Reviewer - Systematic)' ,
123+ )
124+ } )
125+
126+ test ( 'uses fallback when description is undefined' , ( ) => {
127+ expect ( formatAgentDescription ( 'test-agent' , undefined ) ) . toBe (
128+ 'test-agent agent (Test-Agent - Systematic)' ,
129+ )
130+ } )
131+
132+ test ( 'uses fallback when description is empty' , ( ) => {
133+ expect ( formatAgentDescription ( 'test-agent' , '' ) ) . toBe (
134+ 'test-agent agent (Test-Agent - Systematic)' ,
135+ )
136+ } )
137+
138+ test ( 'does not double-brand if suffix already present' , ( ) => {
139+ const alreadyBranded = 'Some description (Test-Agent - Systematic)'
140+ expect ( formatAgentDescription ( 'test-agent' , alreadyBranded ) ) . toBe (
141+ alreadyBranded ,
142+ )
143+ } )
144+ } )
145+
81146 describe ( 'createConfigHandler' , ( ) => {
82147 test ( 'returns a function' , ( ) => {
83148 const handler = createConfigHandler ( {
@@ -104,7 +169,9 @@ Command template for ${name}.`,
104169
105170 expect ( config . agent ) . toBeDefined ( )
106171 expect ( config . agent ?. [ 'test-agent' ] ) . toBeDefined ( )
107- expect ( config . agent ?. [ 'test-agent' ] ?. description ) . toBe ( 'A test agent' )
172+ expect ( config . agent ?. [ 'test-agent' ] ?. description ) . toBe (
173+ 'A test agent (Test-Agent - Systematic)' ,
174+ )
108175 } )
109176
110177 test ( 'collects bundled commands into config' , async ( ) => {
@@ -127,7 +194,7 @@ Command template for ${name}.`,
127194 expect ( config . command ) . toBeDefined ( )
128195 expect ( config . command ?. [ 'systematic:test-command' ] ) . toBeDefined ( )
129196 expect ( config . command ?. [ 'systematic:test-command' ] ?. description ) . toBe (
130- '(systematic ) A test command' ,
197+ '(Systematic ) A test command' ,
131198 )
132199 expect ( config . command ?. [ 'systematic:test-command' ] ?. template ) . toContain (
133200 'Command template for test-command' ,
@@ -150,7 +217,7 @@ Command template for ${name}.`,
150217 expect ( config . command ) . toBeDefined ( )
151218 expect ( config . command ?. [ 'systematic:test-skill' ] ) . toBeDefined ( )
152219 expect ( config . command ?. [ 'systematic:test-skill' ] ?. description ) . toBe (
153- '(systematic - Skill) A test skill' ,
220+ '(Systematic - Skill) A test skill' ,
154221 )
155222 expect ( config . command ?. [ 'systematic:test-skill' ] ?. template ) . toContain (
156223 '<skill-instruction>' ,
@@ -352,7 +419,7 @@ Command template for ${name}.`,
352419
353420 const agent = config . agent ?. [ 'full-agent' ]
354421 expect ( agent ) . toBeDefined ( )
355- expect ( agent ?. description ) . toBe ( 'A full agent' )
422+ expect ( agent ?. description ) . toBe ( 'A full agent (Full-Agent - Systematic) ' )
356423 expect ( agent ?. model ) . toBe ( 'openai/gpt-4' )
357424 expect ( agent ?. temperature ) . toBe ( 0.7 )
358425 expect ( agent ?. top_p ) . toBe ( 1 )
@@ -460,7 +527,7 @@ Full command template.`,
460527
461528 const command = config . command ?. [ 'systematic:full-command' ]
462529 expect ( command ) . toBeDefined ( )
463- expect ( command ?. description ) . toBe ( '(systematic ) A full command' )
530+ expect ( command ?. description ) . toBe ( '(Systematic ) A full command' )
464531 expect ( command ?. agent ) . toBe ( 'oracle' )
465532 expect ( command ?. model ) . toBe ( 'openai/gpt-4' )
466533 expect ( command ?. subtask ) . toBe ( true )
0 commit comments