@code-yeongyu/senpi
Version:
Coding agent CLI with read, bash, edit, write tools and session management
23 lines • 996 B
JavaScript
import { resolvePath } from "../utils/paths.js";
import { resolveMovedPath } from "./extensions/builtin/moved-path-guard/resolve.js";
/**
* Whether a session's recorded cwd is `resolvedCwd`, as recorded or where the OmO desktop moved it (senpi#2990).
* The moved-path walk is synchronous filesystem work, so each matcher resolves a distinct recorded cwd at most once:
* create one per listing call, and a filter re-run on every progress tick costs one walk per distinct cwd.
*/
export function sessionCwdMatcher(resolvedCwd) {
const mapped = new Map();
return (cwd) => {
if (cwd === undefined || cwd === "")
return false;
if (resolvePath(cwd) === resolvedCwd)
return true;
let target = mapped.get(cwd);
if (target === undefined) {
target = resolvePath(resolveMovedPath(cwd));
mapped.set(cwd, target);
}
return target === resolvedCwd;
};
}
//# sourceMappingURL=moved-session-cwd.js.map