Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scripts/recommendation-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ function parseCatalog() {
if (cols.length < 4) continue;
const id = cols[0];
if (!/^[a-z0-9-]+$/.test(id)) continue;
// Only Agent Catalog rows point at an agent file; skip other tables (e.g. Intent Routing).
if (!/^agents\/[a-z0-9-]+\.md$/.test(cols[1].replace(/`/g, ''))) continue;

const specialty = cols[2].toLowerCase();
const taskTypes = cols[3]
Expand Down
11 changes: 10 additions & 1 deletion tests/recommendation-engine.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const fs = require('fs');
const path = require('path');

const ROOT = path.resolve(__dirname, '..');
const { recommendAgents, parseAgentMetadata, metadataScore, archetypeBoost, detectTaskType, classifyConfidence } = require(path.join(ROOT, 'scripts', 'recommendation-engine.js'));
const { recommendAgents, parseCatalog, parseAgentMetadata, metadataScore, archetypeBoost, detectTaskType, classifyConfidence } = require(path.join(ROOT, 'scripts', 'recommendation-engine.js'));

const cases = JSON.parse(
fs.readFileSync(path.join(ROOT, 'tests', 'fixtures', 'recommendation', 'cases.json'), 'utf8')
Expand Down Expand Up @@ -331,3 +331,12 @@ test('recommendAgents handles non-numeric memoryScores gracefully', () => {
assert.ok(Number.isFinite(topRec.totalScore), 'totalScore should be finite, not NaN');
assert.equal(topRec.memoryBoost, 0, 'non-numeric memoryScore should be treated as 0');
});

test('parseCatalog returns only agents that have an agents/*.md file', () => {
const agentFiles = fs.readdirSync(path.join(ROOT, 'agents')).filter((f) => f.endsWith('.md'));
const ids = parseCatalog().map((a) => a.id);
assert.deepEqual([...ids].sort(), agentFiles.map((f) => f.replace(/\.md$/, '')).sort());

const recs = recommendAgents({ prompt: 'harden api security audit', topN: 10 }).recommendations;
assert.ok(!recs.some((r) => r.id === 'harden'), 'intent rows must not be recommended as agents');
});