@@ -118,6 +118,109 @@ describe('agent-prompt.builder', () => {
118118
119119 expect ( result ) . toMatch ( / o u t p u t | f o r m a t | j s o n | s t r u c t u r e d / i) ;
120120 } ) ;
121+
122+ it ( 'should include mandatory_checklist when present' , ( ) => {
123+ const profileWithChecklist : AgentProfile = {
124+ ...mockAgentProfile ,
125+ mandatory_checklist : [
126+ 'Type safety: no any usage' ,
127+ 'Test coverage 90%+' ,
128+ 'SOLID principles applied' ,
129+ ] ,
130+ } ;
131+ const result = buildAgentSystemPrompt ( profileWithChecklist , mockContext ) ;
132+
133+ expect ( result ) . toContain ( '## Mandatory Checklist' ) ;
134+ expect ( result ) . toContain ( '- [ ] Type safety: no any usage' ) ;
135+ expect ( result ) . toContain ( '- [ ] Test coverage 90%+' ) ;
136+ expect ( result ) . toContain ( '- [ ] SOLID principles applied' ) ;
137+ } ) ;
138+
139+ it ( 'should include communication language when present' , ( ) => {
140+ const profileWithLang : AgentProfile = {
141+ ...mockAgentProfile ,
142+ communication : { language : 'Korean' } ,
143+ } ;
144+ const result = buildAgentSystemPrompt ( profileWithLang , mockContext ) ;
145+
146+ expect ( result ) . toContain ( '## Communication' ) ;
147+ expect ( result ) . toContain ( 'IMPORTANT: Always respond in Korean.' ) ;
148+ } ) ;
149+
150+ it ( 'should use agent-specific mode instructions when modes field present' , ( ) => {
151+ const profileWithModes : AgentProfile = {
152+ ...mockAgentProfile ,
153+ modes : {
154+ eval : {
155+ focus : [ 'code quality' , 'security' ] ,
156+ output_format : 'structured review' ,
157+ } ,
158+ } ,
159+ } ;
160+ const result = buildAgentSystemPrompt ( profileWithModes , mockContext ) ;
161+
162+ expect ( result ) . toContain ( '## Mode-Specific Instructions' ) ;
163+ expect ( result ) . toContain ( 'code quality' ) ;
164+ expect ( result ) . toContain ( 'structured review' ) ;
165+ // Should NOT contain generic EVAL instructions
166+ expect ( result ) . not . toContain ( 'Evaluate and assess the implementation quality' ) ;
167+ } ) ;
168+
169+ it ( 'should fall back to generic mode instructions when agent modes not present' , ( ) => {
170+ const result = buildAgentSystemPrompt ( mockAgentProfile , mockContext ) ;
171+
172+ expect ( result ) . toContain ( 'Evaluate and assess the implementation quality' ) ;
173+ expect ( result ) . not . toContain ( '## Mode-Specific Instructions' ) ;
174+ } ) ;
175+
176+ it ( 'should include required skills when present' , ( ) => {
177+ const profileWithSkills : AgentProfile = {
178+ ...mockAgentProfile ,
179+ skills : {
180+ required : [
181+ { name : 'todo_write' , purpose : 'Track implementation' , when : 'Creating plans' } ,
182+ ] ,
183+ recommended : [
184+ { name : 'web_search' , purpose : 'Validate recommendations' , when : 'Evaluating' } ,
185+ ] ,
186+ } ,
187+ } ;
188+ const result = buildAgentSystemPrompt ( profileWithSkills , mockContext ) ;
189+
190+ expect ( result ) . toContain ( '## Required Skills' ) ;
191+ expect ( result ) . toContain ( '**todo_write**: Track implementation (when: Creating plans)' ) ;
192+ expect ( result ) . toContain ( '## Recommended Skills' ) ;
193+ expect ( result ) . toContain ( '**web_search**: Validate recommendations (when: Evaluating)' ) ;
194+ } ) ;
195+
196+ it ( 'should include verification_guide when present' , ( ) => {
197+ const profileWithVerification : AgentProfile = {
198+ ...mockAgentProfile ,
199+ verification_guide : {
200+ steps : [ 'Check type safety' , 'Run tests' , 'Review coverage' ] ,
201+ } ,
202+ } ;
203+ const result = buildAgentSystemPrompt ( profileWithVerification , mockContext ) ;
204+
205+ expect ( result ) . toContain ( '## Verification Guide' ) ;
206+ expect ( result ) . toContain ( 'Check type safety' ) ;
207+ expect ( result ) . toContain ( 'Run tests' ) ;
208+ } ) ;
209+
210+ it ( 'should handle agent without optional rich metadata gracefully' , ( ) => {
211+ // mockAgentProfile has no mandatory_checklist, modes, skills, etc.
212+ const result = buildAgentSystemPrompt ( mockAgentProfile , mockContext ) ;
213+
214+ expect ( result ) . toBeDefined ( ) ;
215+ expect ( result ) . not . toContain ( '## Mandatory Checklist' ) ;
216+ expect ( result ) . not . toContain ( '## Communication' ) ;
217+ expect ( result ) . not . toContain ( '## Required Skills' ) ;
218+ expect ( result ) . not . toContain ( '## Recommended Skills' ) ;
219+ expect ( result ) . not . toContain ( '## Verification Guide' ) ;
220+ expect ( result ) . not . toContain ( '## Mode-Specific Instructions' ) ;
221+ // Should still have generic mode instructions
222+ expect ( result ) . toContain ( 'Evaluate and assess the implementation quality' ) ;
223+ } ) ;
121224 } ) ;
122225
123226 describe ( 'buildTaskDescription' , ( ) => {
0 commit comments