Skip to content

armgit / pibot

Public Imported from GitHub
0

Open-source, local-first AI agent team for your desktop: multi-agent group chats, computer use, browser, MCP, routines and approvals. macOS, Windows, Linux + Android. Built on pi.

fix(dev): repository checks resolve paths correctly on Windows

leen.zhou74e7035a1df6
diff --git a/tools/dev/domain-boundaries.ts b/tools/dev/domain-boundaries.ts
index 53882bc..53c21c5 100644
--- a/tools/dev/domain-boundaries.ts
+++ b/tools/dev/domain-boundaries.ts
@@ -4,6 +4,7 @@
// Run: node tools/dev/domain-boundaries.ts (part of `pnpm lint`)
import { existsSync, readdirSync, readFileSync, statSync } from "node:fs";
import { dirname, join, relative, resolve, sep } from "node:path";
+import { fileURLToPath } from "node:url";
import { buildSync } from "esbuild";
import {
desktopMainInputs,
@@ -81,7 +82,7 @@ const modular: { src: string; root: string[] }[] = [
{ src: "packages/tools/src", root: ["index.ts", "full.ts"] },
];
-const repo = resolve(dirname(new URL(import.meta.url).pathname), "../..");
+const repo = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
const valueImport =
/(?:^|\n)\s*(import|export)\s+(?!type\s)(?:[^;'"]*?\sfrom\s+)?["'](\.{1,2}\/[^"']+)["']|(?<![.\w])import\(\s*["'](\.{1,2}\/[^"']+)["']\s*\)(?!\s*\.)/g;
const problems: string[] = [];
@@ -179,7 +180,9 @@ for (const rule of rules) {
for (const match of text.matchAll(valueImport)) {
const spec = match[2] ?? match[3];
if (!spec) continue;
- const target = relative(src, resolve(dirname(file), spec));
+ const target = relative(src, resolve(dirname(file), spec))
+ .split(sep)
+ .join("/");
if (!target.startsWith("core/") && !target.startsWith(".."))
problems.push(`${relative(repo, file)}: core imports ${target} (value import)`);
}
diff --git a/tools/dev/run-as-node-check.ts b/tools/dev/run-as-node-check.ts
index 8725594..4f11b05 100644
--- a/tools/dev/run-as-node-check.ts
+++ b/tools/dev/run-as-node-check.ts
@@ -7,7 +7,7 @@ import { join, relative, resolve } from "node:path";
const repo = resolve(import.meta.dirname, "../..");
const roots = ["apps", "packages", "tools"];
-const skip = /(^|\/)(node_modules|out|dist|\.cache|coverage)(\/|$)/;
+const skip = /(^|[\\/])(node_modules|out|dist|\.cache|coverage)([\\/]|$)/;
const setting = /ELECTRON_RUN_AS_NODE["']?\s*(?:[:=]|\]\s*=)/;
const clearing = /\b(?:delete\s+[\w.]+\.ELECTRON_RUN_AS_NODE|unset\s+ELECTRON_RUN_AS_NODE)\b/;
diff --git a/tools/dev/tsconfig-references.ts b/tools/dev/tsconfig-references.ts
index 9c8b869..01853d3 100644
--- a/tools/dev/tsconfig-references.ts
+++ b/tools/dev/tsconfig-references.ts
@@ -1,7 +1,7 @@
import { execFileSync } from "node:child_process";
import { existsSync, readdirSync, readFileSync, statSync, writeFileSync } from "node:fs";
import { dirname, join, posix, relative, resolve, sep } from "node:path";
-import { pathToFileURL } from "node:url";
+import { fileURLToPath, pathToFileURL } from "node:url";
export interface WorkspaceProject {
name: string;
@@ -104,7 +104,7 @@ function configPath(from: string, to: string): string {
}
export function loadWorkspaceProjects(
- repo = resolve(dirname(new URL(import.meta.url).pathname), "../.."),
+ repo = resolve(dirname(fileURLToPath(import.meta.url)), "../.."),
) {
const manifests = workspacePatterns(repo)
.flatMap((pattern) => expandPattern(repo, pattern))
@@ -183,7 +183,7 @@ function updateConfig(
export function affectedWorkspaceProjects(
projects: WorkspaceProject[],
changedFiles: readonly string[],
- repo = resolve(dirname(new URL(import.meta.url).pathname), "../.."),
+ repo = resolve(dirname(fileURLToPath(import.meta.url)), "../.."),
) {
const globalFiles = new Set([
"package.json",
@@ -224,7 +224,7 @@ export function affectedWorkspaceProjects(
}
function run(mode: "check" | "write") {
- const repo = resolve(dirname(new URL(import.meta.url).pathname), "../..");
+ const repo = resolve(dirname(fileURLToPath(import.meta.url)), "../..");
const projects = loadWorkspaceProjects(repo);
const byName = new Map(projects.map((project) => [project.name, project]));
const expected = projects.map((project) => ({