diff --git a/scripts/dashboard-web.js b/scripts/dashboard-web.js index a7d5316de..271cc6961 100644 --- a/scripts/dashboard-web.js +++ b/scripts/dashboard-web.js @@ -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(); diff --git a/tests/scripts/dashboard-web.test.js b/tests/scripts/dashboard-web.test.js index 68ca16b26..304f3c921 100644 --- a/tests/scripts/dashboard-web.test.js +++ b/tests/scripts/dashboard-web.test.js @@ -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-');