fix: preserve scoped tools in dashboard frontmatter

This commit is contained in:
Affaan Mustafa
2026-07-26 04:29:23 -04:00
parent c25a4d1ec5
commit b6792e36b5
2 changed files with 25 additions and 2 deletions
+5 -2
View File
@@ -32,8 +32,11 @@ function readFrontmatter(p) {
const s = l.indexOf(':'); if (s <= 0) continue;
let k = l.slice(0, s).trim(), v = l.slice(s + 1).trim();
if ((v.startsWith('"') && v.endsWith('"')) || (v.startsWith("'") && v.endsWith("'"))) v = v.slice(1, -1);
if (v.startsWith('[') && v.endsWith(']')) { try { v = JSON.parse(v); } catch { v = v.slice(1, -1).split(',').map(x => x.trim().replace(/["']/g, '')); } }
if (k === 'tools') v = normalizeAgentTools(v);
if (k === 'tools') {
v = normalizeAgentTools(v);
} else if (v.startsWith('[') && v.endsWith(']')) {
try { v = JSON.parse(v); } catch { v = v.slice(1, -1).split(',').map(x => x.trim().replace(/["']/g, '')); }
}
fm[k] = v;
}
fm._body = c.replace(/^---[\s\S]*?---\n*/, '').trim();
+20
View File
@@ -125,6 +125,26 @@ test('readFrontmatter parses array tools field', () => {
cleanup(testRoot);
});
test('readFrontmatter preserves scoped tools in legacy flow sequences', () => {
const { readFrontmatter } = require(SCRIPT);
testRoot = createTempDir('ecc-test-');
writeFile(testRoot, 'agent.md', [
'---',
'name: scoped-agent',
'tools: [Agent(worker, researcher), Read, Bash(git commit:*, git status:*)]',
'---',
'body',
].join('\n'));
const fm = readFrontmatter(path.join(testRoot, 'agent.md'));
assert.deepStrictEqual(fm.tools, [
'Agent(worker, researcher)',
'Read',
'Bash(git commit:*, git status:*)',
]);
cleanup(testRoot);
});
test('readFrontmatter normalizes comma-separated scalar tools to an array', () => {
const { readFrontmatter } = require(SCRIPT);
testRoot = createTempDir('ecc-test-');