Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ Vendored from [`code-yeongyu/pi-rules`](https://github.com/code-yeongyu/pi-rules
- Imports rewritten by `scripts/vendor-transform.mjs`: `@mariozechner/pi-tui` -> `@earendil-works/pi-tui`; `@mariozechner/pi-coding-agent` symbols -> `../../types.ts` (and `Theme` -> `modes/interactive/theme/theme.ts`); relative `.js` import suffixes -> `.ts`.
- `ui/dynamic-border.ts` and `ui/rules-banner.ts`: constructor parameter properties (`private readonly …`) -> explicit fields + constructor assignment (senpi's root tsconfig is `erasableSyntaxOnly`; parameter properties are disallowed).
- Runtime dep `picomatch` (+ `@types/picomatch`) added to `package.json`.
- No behavior changes. Registers `/rules` and `/reload-rules` and discovers rule files from `.sisyphus/rules`, `.claude/rules`, `.cursor/rules`, `.github/instructions`, `AGENTS.md`, `CLAUDE.md`.
- `rules/project-root.ts`: `findProjectRoot` stops the marker walk when `dirname()` stops progressing, fixing an infinite synchronous loop for targets on a different Windows drive than cwd (or UNC shares). Behavior fix also submitted upstream: https://github.com/code-yeongyu/pi-rules/pull/19 — drop this adaptation once a fixed pi-rules release is re-vendored.
- No other behavior changes. Registers `/rules` and `/reload-rules` and discovers rule files from `.sisyphus/rules`, `.claude/rules`, `.cursor/rules`, `.github/instructions`, `AGENTS.md`, `CLAUDE.md`.

## Conflict zones

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ export function findProjectRoot(startPath: string, markers: ReadonlyArray<string
return null;
}

currentDirectory = dirname(currentDirectory);
const parentDirectory = dirname(currentDirectory);
// Cross-drive / UNC walk: dirname() of a drive root returns the root itself,
// and a root on a different drive than cwd never equals resolve("/"), so the
// walk would spin forever without this guard.
if (parentDirectory === currentDirectory) {
return null;
}
currentDirectory = parentDirectory;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { win32 } from "node:path";
import { describe, expect, it, vi } from "vitest";
import { findProjectRoot } from "../../../src/core/extensions/builtin/rules/rules/project-root.ts";

const { cwdRoot, startPath } = vi.hoisted(() => ({
cwdRoot: "E:\\",
startPath: "C:\\workspace\\plain\\nested",
}));

vi.mock("node:fs", () => ({
existsSync: (path: string) => path === startPath,
statSync: () => ({ isDirectory: () => true }),
}));

vi.mock("node:path", async (importOriginal) => {
const path = await importOriginal<typeof import("node:path")>();
return {
...path,
dirname: path.win32.dirname,
join: path.win32.join,
resolve: (input: string) => (input === "/" ? cwdRoot : path.win32.resolve(input)),
};
});

describe("rules findProjectRoot cross-drive termination", () => {
it("#given startPath on a different drive than cwd (Windows cross-drive) #when finding root #then terminates with null instead of looping forever", () => {
// given
expect(win32.dirname("C:\\")).toBe("C:\\");

// when
const result = findProjectRoot(startPath, [".nonexistent-marker-senpi"]);

// then
expect(result).toBeNull();
});
});