fix(agents): address PR review comments for Hermes and align Windsurf tests

This commit is contained in:
RUFFY-369
2026-04-21 00:17:08 +05:30
parent fb95260eb5
commit 27afc45dea
4 changed files with 45 additions and 17 deletions
+20 -2
View File
@@ -154,11 +154,29 @@ describe('Agent Adapters', () => {
expect(config).toContain('SKILLS_TABLE_START');
});
it('should parse skill names from XML', () => {
it('should parse skill names from XML correctly within markers', () => {
const adapter = getAdapter('hermes');
const xml = `<available_skills><skill><name>git-ops</name></skill></available_skills>`;
const xml = `
<!-- SKILLS_TABLE_START -->
<available_skills><skill><name>git-ops</name></skill></available_skills>
<!-- SKILLS_TABLE_END -->`;
const names = adapter.parseConfig(xml);
expect(names).toContain('git-ops');
});
it('should ignore <name> tags outside of sync markers', () => {
const adapter = getAdapter('hermes');
const xml = `
<mission><name>save-the-world</name></mission>
<!-- SKILLS_TABLE_START -->
<available_skills><skill><name>git-ops</name></skill></available_skills>
<!-- SKILLS_TABLE_END -->
<footer_meta><name>internal-id</name></footer_meta>`;
const names = adapter.parseConfig(xml);
expect(names).toHaveLength(1);
expect(names).toContain('git-ops');
expect(names).not.toContain('save-the-world');
expect(names).not.toContain('internal-id');
});
});
});
+12 -11
View File
@@ -59,11 +59,21 @@ ${skillsXml}
}
parseConfig(content: string): string[] {
const startMarker = '<!-- SKILLS_TABLE_START -->';
const endMarker = '<!-- SKILLS_TABLE_END -->';
const startIndex = content.indexOf(startMarker);
const endIndex = content.indexOf(endMarker);
if (startIndex === -1 || endIndex === -1) {
return [];
}
const scopedContent = content.substring(startIndex + startMarker.length, endIndex);
const skillNames: string[] = [];
const skillRegex = /<name>([^<]+)<\/name>/g;
let match;
while ((match = skillRegex.exec(content)) !== null) {
while ((match = skillRegex.exec(scopedContent)) !== null) {
skillNames.push(match[1].trim());
}
@@ -77,16 +87,7 @@ ${skillsXml}
async isDetected(): Promise<boolean> {
const projectHermes = join(process.cwd(), '.hermes');
const globalHermes = join(homedir(), '.hermes');
const hermesMd = join(process.cwd(), 'AGENTS.md');
// Check for hermes binary in path if possible
try {
// In a real browser/tool environment we might use which/whereis
// but for detection logic we rely on filesystem markers primarily.
} catch {
// ignore
}
return existsSync(projectHermes) || existsSync(globalHermes) || existsSync(hermesMd);
return existsSync(projectHermes) || existsSync(globalHermes);
}
}
+12 -3
View File
@@ -53,11 +53,21 @@ ${skillsXml}
}
parseConfig(content: string): string[] {
const startMarker = '<!-- SKILLS_TABLE_START -->';
const endMarker = '<!-- SKILLS_TABLE_END -->';
const startIndex = content.indexOf(startMarker);
const endIndex = content.indexOf(endMarker);
if (startIndex === -1 || endIndex === -1) {
return [];
}
const scopedContent = content.substring(startIndex + startMarker.length, endIndex);
const skillNames: string[] = [];
const skillRegex = /<name>([^<]+)<\/name>/g;
let match;
while ((match = skillRegex.exec(content)) !== null) {
while ((match = skillRegex.exec(scopedContent)) !== null) {
skillNames.push(match[1].trim());
}
@@ -71,8 +81,7 @@ ${skillsXml}
async isDetected(): Promise<boolean> {
const projectHermes = join(process.cwd(), '.hermes');
const globalHermes = join(homedir(), '.hermes');
const hermesMd = join(process.cwd(), 'AGENTS.md');
return existsSync(projectHermes) || existsSync(globalHermes) || existsSync(hermesMd);
return existsSync(projectHermes) || existsSync(globalHermes);
}
}
+1 -1
View File
@@ -140,7 +140,7 @@ describe('agents', () => {
expect(adapter.type).toBe('windsurf');
expect(adapter.name).toBe('Windsurf');
expect(adapter.skillsDir).toBe('.windsurf/skills');
expect(adapter.configFile).toBe('.windsurfrules');
expect(adapter.configFile).toBe('.windsurf/rules/skills.md');
});
it('should return adapter for hermes', () => {