Files
Sebastian Mendel 9f17476d0b fix(evals): stage skill resources outside the fixture baseline
Copy the skill directory and the shared references into a temporary
directory outside the fixture workspace, grant the executor access with
--add-dir, and name both base directories in the system prompt. Reject
symbolic links in the staged resources. The dry-run plan prints the
--add-dir argument too.

Assisted-by: claude-code:claude-opus-5-5
Agent-Session: 7d0f7cf1-f8a8-427f-843b-2ca124cfea16
Agent-Host: 0493f0
Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
2026-11-01 18:11:58 +01:00

36 lines
1.4 KiB
JavaScript

'use strict';
const fs = require('node:fs');
const os = require('node:os');
const path = require('node:path');
function stageSkillResources(root, skillName) {
if (!/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(skillName)) throw new Error('invalid skill name');
root = fs.realpathSync(root);
const staged = fs.mkdtempSync(path.join(os.tmpdir(), 'agent-skill-resources-'));
const skillDir = path.join(staged, 'skills', skillName);
const sourceEntry = (file) => {
const entry = fs.lstatSync(file);
if (entry.isSymbolicLink()) throw new Error(`symbolic link in skill resources: ${file}`);
return entry;
};
const copy = (source, destination) => fs.cpSync(source, destination,
{ recursive: true, filter: (file) => Boolean(sourceEntry(file)) });
try {
// Retain the repository layout: both local and ../../references/ links work.
fs.mkdirSync(path.dirname(skillDir), { recursive: true });
sourceEntry(path.join(root, 'skills'));
copy(path.join(root, 'skills', skillName), skillDir);
const shared = path.join(root, 'references');
let sharedEntry;
try { sharedEntry = sourceEntry(shared); } catch (error) { if (error.code !== 'ENOENT') throw error; }
if (sharedEntry) copy(shared, path.join(staged, 'references'));
return { root: staged, skillDir };
} catch (error) {
fs.rmSync(staged, { recursive: true, force: true });
throw error;
}
}
module.exports = { stageSkillResources };