mirror of
https://github.com/affaan-m/ECC.git
synced 2026-09-24 02:25:10 +02:00
fix: preserve scoped tools in dashboard frontmatter
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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-');
|
||||
|
||||
Reference in New Issue
Block a user