Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ import { WorkspaceModel } from "./workspace.js";

export const CHECKPOINT_ENTRY = "review-loop/checkpoint";

export function isIgnoredWatchPath(repoRoot: string, path: string): boolean {
return relative(repoRoot, path).split(sep).some((part) => part === ".git" || part === "node_modules");
}

function isCheckpoint(value: unknown): value is ReviewCheckpoint {
if (value == null || typeof value !== "object") return false;
const item = value as Partial<ReviewCheckpoint>;
Expand Down Expand Up @@ -93,11 +97,9 @@ export class ReviewController {
private async startWatcher(): Promise<void> {
this.watcher = watch(this.repoRoot, {
ignoreInitial: true,
ignored: (path) => {
const rel = relative(this.repoRoot, path);
return rel === ".git" || rel.startsWith(`.git${sep}`) || rel === "node_modules" || rel.startsWith(`node_modules${sep}`);
},
ignored: (path) => isIgnoredWatchPath(this.repoRoot, path),
});
this.watcher.on("error", () => {});
this.watcher.on("all", (_event, path) => {
const repoPath = this.toRepoPath(path);
if (repoPath == null) return;
Expand Down
7 changes: 7 additions & 0 deletions test/core.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { fileURLToPath } from "node:url";
import { promisify } from "node:util";
import test from "node:test";
import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
import { isIgnoredWatchPath } from "../src/controller.js";
import { composeFeedback } from "../src/prompt.js";
import { createCheckpoint, decodeStored, parsePorcelainPaths, scanAgainstCheckpoint } from "../src/git.js";
import { WorkspaceModel } from "../src/workspace.js";
Expand All @@ -31,6 +32,12 @@ async function git(cwd: string, ...args: string[]): Promise<void> {
await execFileAsync("git", args, { cwd });
}

test("ignores generated dependency and git trees at any depth", () => {
assert.equal(isIgnoredWatchPath("/repo", "/repo/packages/app/node_modules/pkg/file.js"), true);
assert.equal(isIgnoredWatchPath("/repo", "/repo/packages/app/.git/index"), true);
assert.equal(isIgnoredWatchPath("/repo", "/repo/src/file.ts"), false);
});

test("parses porcelain paths including renames", () => {
const output = " M src/a.ts\0R src/new.ts\0src/old.ts\0?? new file.ts\0";
assert.deepEqual(parsePorcelainPaths(output), ["src/a.ts", "src/new.ts", "src/old.ts", "new file.ts"]);
Expand Down