fix(codex): keep commented TOML fields, follow symlinked config surfaces
readTomlMeta was dropping any field with a trailing `# comment` (common in real agents/*.toml). readSkills/readAgents/readRules used bare isDirectory()/isFile(), which miss symlinked entries per cc-discovery.js's own documented Dirent quirk — reused its isDirLike/isFileLike instead (exporting isDirLike from cc-discovery.js, which wasn't previously public). Also swapped the "never walks outside" test for one that actually exercises a symlink escape, and dropped the unnecessary isUnder re-export.
This commit is contained in:
@@ -85,6 +85,14 @@ describe("codex-discovery", () => {
|
||||
assert.equal(meta.model, "gpt-5.3-codex-spark");
|
||||
});
|
||||
|
||||
it("keeps a field with a trailing inline comment, and keeps a '#' that is inside the string", () => {
|
||||
const meta = cx.readTomlMeta(
|
||||
'model = "gpt-5.4" # default\n' + 'description = "uses # for headings"\n'
|
||||
);
|
||||
assert.equal(meta.model, "gpt-5.4");
|
||||
assert.equal(meta.description, "uses # for headings");
|
||||
});
|
||||
|
||||
it("reads a rule file's preview", () => {
|
||||
write(
|
||||
path.join(TMP, "rules", "no-force-push.rules"),
|
||||
@@ -119,11 +127,20 @@ describe("codex-discovery", () => {
|
||||
assert.equal(project.exists, false);
|
||||
});
|
||||
|
||||
it("never walks outside the codex roots", () => {
|
||||
write(path.join(TMP, "skills", "esc", "SKILL.md"), "x");
|
||||
for (const row of cx.readSkills({ cwd: REPO })) {
|
||||
it("follows a symlinked skill dir (a supported install pattern) without ever reporting a path outside the codex roots", () => {
|
||||
const outside = fs.mkdtempSync(path.join(os.tmpdir(), "codex-disc-outside-"));
|
||||
write(path.join(outside, "SKILL.md"), "---\nname: linked\n---\nbody");
|
||||
fs.symlinkSync(outside, path.join(TMP, "skills", "linked"), "dir");
|
||||
|
||||
const rows = cx.readSkills({ cwd: REPO });
|
||||
const linked = rows.find((r) => r.name === "linked");
|
||||
assert.ok(linked, "a symlinked skill directory must still be discovered");
|
||||
assert.equal(linked.frontmatter.name, "linked");
|
||||
for (const row of rows) {
|
||||
assert.ok(row.file.startsWith(TMP) || row.file.startsWith(REPO));
|
||||
assert.ok(!row.file.startsWith(outside));
|
||||
}
|
||||
fs.rmSync(outside, { recursive: true, force: true });
|
||||
});
|
||||
|
||||
it("summarizes counts and roots in the overview", () => {
|
||||
|
||||
Reference in New Issue
Block a user