mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-30 04:44:28 +00:00
feat(agent): format available skills as standard XML with absolute path locations
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { formatSkillsForPrompt } from './index'
|
||||
import * as path from 'path'
|
||||
|
||||
describe('formatSkillsForPrompt', () => {
|
||||
it('should return empty string if skills array is empty', () => {
|
||||
expect(formatSkillsForPrompt([])).toBe('')
|
||||
})
|
||||
|
||||
it('should format skills into the XML structure with absolute paths and escaped characters', () => {
|
||||
const skills = [
|
||||
{
|
||||
id: 'skill-1',
|
||||
name: 'Deploy & Test',
|
||||
description: 'Deploys code <deploy> and "runs" tests.',
|
||||
},
|
||||
]
|
||||
|
||||
const expectedLocation = path.join(process.cwd(), '.pi', 'skills', 'skill-1', 'SKILL.md')
|
||||
const result = formatSkillsForPrompt(skills)
|
||||
|
||||
// Verify lines and XML elements
|
||||
expect(result).toContain('<available_skills>')
|
||||
expect(result).toContain('<skill>')
|
||||
expect(result).toContain('<name>Deploy & Test</name>')
|
||||
expect(result).toContain(
|
||||
'<description>Deploys code <deploy> and "runs" tests.</description>',
|
||||
)
|
||||
expect(result).toContain(`<location>${expectedLocation}</location>`)
|
||||
expect(result).toContain('</skill>')
|
||||
expect(result).toContain('</available_skills>')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user