mirror of
https://github.com/badlogic/pi-mono.git
synced 2026-11-05 23:37:25 +00:00
fix(coding-agent): exclude directories from resource loader (#7106)
This fixes the following warning: Warning: Could not read /Users/duncan/Projects/AGENTS.md: Error: EISDIR: illegal operation on a directory, read
This commit is contained in:
parent
b711e26616
commit
58c0bc2fba
2 changed files with 20 additions and 1 deletions
|
|
@ -70,6 +70,9 @@ function loadContextFileFromDir(dir: string): { path: string; content: string }
|
|||
const filePath = join(dir, filename);
|
||||
if (existsSync(filePath)) {
|
||||
try {
|
||||
if (!statSync(filePath).isFile()) {
|
||||
continue;
|
||||
}
|
||||
return {
|
||||
path: filePath,
|
||||
content: readFileSync(filePath, "utf-8"),
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import { mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "nod
|
|||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { pathToFileURL } from "node:url";
|
||||
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import { AuthStorage } from "../src/core/auth-storage.ts";
|
||||
import { ExtensionRunner } from "../src/core/extensions/runner.ts";
|
||||
import { DefaultResourceLoader } from "../src/core/resource-loader.ts";
|
||||
|
|
@ -355,6 +355,22 @@ Content`,
|
|||
expect(agentsFiles.some((f) => f.path.includes("AGENTS.md"))).toBe(true);
|
||||
});
|
||||
|
||||
it("should ignore context file candidates that are directories", async () => {
|
||||
mkdirSync(join(cwd, "AGENTS.md"));
|
||||
writeFileSync(join(cwd, "CLAUDE.md"), "Fallback instructions");
|
||||
const consoleError = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
|
||||
const loader = new DefaultResourceLoader({ cwd, agentDir });
|
||||
await loader.reload();
|
||||
|
||||
expect(loader.getAgentsFiles().agentsFiles).toContainEqual({
|
||||
path: join(cwd, "CLAUDE.md"),
|
||||
content: "Fallback instructions",
|
||||
});
|
||||
expect(consoleError).not.toHaveBeenCalledWith(expect.stringContaining(join(cwd, "AGENTS.md")));
|
||||
consoleError.mockRestore();
|
||||
});
|
||||
|
||||
it("should skip AGENTS.md and CLAUDE.md discovery when noContextFiles is true", async () => {
|
||||
writeFileSync(join(cwd, "AGENTS.md"), "# Project Guidelines\n\nBe helpful.");
|
||||
writeFileSync(join(cwd, "CLAUDE.md"), "# Claude Guidelines\n\nBe helpful.");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue