The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.
perf: avoid duplicate skill file reads
Darwin Pardave5e3863e5122d
diff --git a/scripts/dashboard-web.js b/scripts/dashboard-web.jsindex 5524853bd..9aaba4f89 100644--- a/scripts/dashboard-web.js+++ b/scripts/dashboard-web.js@@ -44,9 +44,7 @@ const PORT = parsePort(process.argv[2] || process.env.ECC_DASHBOARD_PORT || '345const HOST = resolveDashboardHost();const ROOT = path.resolve(__dirname, '..');-function readFrontmatter(p) {- try {- const c = fs.readFileSync(p, 'utf8');+function parseFrontmatter(c) {const m = c.match(/^---\n([\s\S]*?)\n---/);if (!m) return {};const fm = {};@@ -63,9 +61,18 @@ function readFrontmatter(p) {}fm._body = c.replace(/^---[\s\S]*?---\n*/, '').trim();return fm;- } catch { return {}; }}-function readSkill(p) { try { const c = fs.readFileSync(p, 'utf8'); const fm = readFrontmatter(p); return { d: fm.description || '', b: c.replace(/^---[\s\S]*?---\n*/, '').trim() }; } catch { return { d: '', b: '' }; } }+function readFrontmatter(p) {+ try { return parseFrontmatter(fs.readFileSync(p, 'utf8')); }+ catch { return {}; }+}+function readSkill(p) {+ try {+ const c = fs.readFileSync(p, 'utf8');+ const fm = parseFrontmatter(c);+ return { d: fm.description || '', b: c.replace(/^---[\s\S]*?---\n*/, '').trim() };+ } catch { return { d: '', b: '' }; }+}function loadAgents(_root) {const root = _root || ROOT;diff --git a/tests/scripts/dashboard-web.test.js b/tests/scripts/dashboard-web.test.jsindex d9a125dbe..bb523d255 100644--- a/tests/scripts/dashboard-web.test.js+++ b/tests/scripts/dashboard-web.test.js@@ -361,6 +361,28 @@ test('readSkill parses skill frontmatter and body', () => {cleanup(testRoot);});+test('readSkill reads each skill file only once', () => {+ const { readSkill } = require(SCRIPT);+ testRoot = createTempDir('ecc-test-');+ const skillPath = path.join(testRoot, 'SKILL.md');+ writeFile(testRoot, 'SKILL.md', '---\ndescription: A test skill\n---\nbody');+ const originalReadFileSync = fs.readFileSync;+ let readCount = 0;+ fs.readFileSync = (...args) => {+ readCount++;+ return originalReadFileSync(...args);+ };++ try {+ readSkill(skillPath);+ } finally {+ fs.readFileSync = originalReadFileSync;+ cleanup(testRoot);+ }++ assert.strictEqual(readCount, 1);+});+test('readSkill returns empty defaults for missing file', () => {const { readSkill } = require(SCRIPT);const skill = readSkill('/nonexistent/skill/SKILL.md');