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.

feat(execution): Windows Bot commands find the bundled MinGit

leen.zhou485e8adc156a
diff --git a/packages/execution/src/command/command-context.ts b/packages/execution/src/command/command-context.ts
index a112406..6f69ff7 100644
--- a/packages/execution/src/command/command-context.ts
+++ b/packages/execution/src/command/command-context.ts
@@ -133,8 +133,16 @@ export async function commandResources(
options.systemHome,
temp,
input.pathEntries,
+ options.resourcesDir,
)
- : commandEnvironment(options.platform, options.env, home, temp, input.pathEntries),
+ : commandEnvironment(
+ options.platform,
+ options.env,
+ home,
+ temp,
+ input.pathEntries,
+ options.resourcesDir,
+ ),
input.secretEnv,
);
// A skill runtime lives outside the workplace, so these variables are the only way a
diff --git a/packages/execution/src/command/environment.ts b/packages/execution/src/command/environment.ts
index 4a85a68..765da20 100644
--- a/packages/execution/src/command/environment.ts
+++ b/packages/execution/src/command/environment.ts
@@ -34,12 +34,30 @@ function windowsUserPath(original: Readonly<NodeJS.ProcessEnv>, taken: readonly
return entries;
}
+/**
+ * Windows builds ship MinGit (resources/bin/git); most Windows computers have no Git. Its `cmd`
+ * folder goes after everything else on PATH, so an installed Git always wins and the bundled copy
+ * only fills the gap. Nothing is added on other platforms, in dev runs, or for an odd path.
+ */
+function bundledGitPath(platform: NodeJS.Platform, resourcesDir: string | undefined) {
+ if (platform !== "win32" || !resourcesDir) return [];
+ if (!win32.isAbsolute(resourcesDir) || /[\0\r\n;%"]/.test(resourcesDir)) return [];
+ const directory = win32.join(resourcesDir, "bin", "git", "cmd");
+ try {
+ return statSync(directory).isDirectory() ? [directory] : [];
+ } catch {
+ // No bundled Git (dev run, non-Windows build): commands see only the user's own PATH.
+ return [];
+ }
+}
+
export function commandEnvironment(
platform: NodeJS.Platform,
original: Readonly<NodeJS.ProcessEnv>,
home: string,
temp: string,
additions: string[] = [],
+ resourcesDir?: string,
): NodeJS.ProcessEnv {
const { delimiter, isAbsolute, join } = platform === "win32" ? win32 : posix;
if (
@@ -61,7 +79,9 @@ export function commandEnvironment(
: commandPaths(platform, original.PATH ?? "");
// Explicit choices and the launcher environment select the user's Node/toolchain on Unix.
// Windows retains System32 precedence. No variables other than PATH are imported here.
- const search = windows ? [...paths, ...additions, ...user] : [...additions, ...user, ...paths];
+ const search = windows
+ ? [...paths, ...additions, ...user, ...bundledGitPath(platform, resourcesDir)]
+ : [...additions, ...user, ...paths];
return {
PATH: [...new Set(search)].join(delimiter),
HOME: home,
@@ -139,8 +159,9 @@ export function userTerminalEnvironment(
userHome: string,
temp: string,
additions: string[] = [],
+ resourcesDir?: string,
): NodeJS.ProcessEnv {
- const env = commandEnvironment(platform, original, userHome, temp, additions);
+ const env = commandEnvironment(platform, original, userHome, temp, additions, resourcesDir);
// Pinned only so a sandboxed command cannot plant a global file for a later one.
delete env.GIT_CONFIG_GLOBAL;
for (const [name, valid] of Object.entries(USER_POINTERS)) {