Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

fix(npm): quote Windows batch shim paths

cyh9c43868c0bf0
diff --git a/npm/avibe/bin/avibe.js b/npm/avibe/bin/avibe.js
index 867f713bc..10efb9a8d 100755
--- a/npm/avibe/bin/avibe.js
+++ b/npm/avibe/bin/avibe.js
@@ -136,13 +136,20 @@ function findVibeBinary() {
}
function runCommand(command, args, options = {}) {
- const useShell = options.shell || shouldRunThroughShell(command);
+ if (!options.shell && shouldRunThroughShell(command)) {
+ return runWindowsBatchCommand(command, args, options);
+ }
+
const result = childProcess.spawnSync(command, args, {
stdio: "inherit",
- shell: useShell,
+ shell: options.shell || false,
env: options.env || prependPathEntries(process.env, candidateBinDirs()),
});
+ return normalizeSpawnResult(result);
+}
+
+function normalizeSpawnResult(result) {
if (result.error) {
throw result.error;
}
@@ -154,6 +161,22 @@ function runCommand(command, args, options = {}) {
return result.signal ? 1 : 0;
}
+function runWindowsBatchCommand(command, args, options = {}) {
+ const shellCommand = [quoteWindowsCmdArgument(command), ...args.map(quoteWindowsCmdArgument)].join(" ");
+ const result = childProcess.spawnSync(process.env.ComSpec || "cmd.exe", ["/d", "/s", "/c", shellCommand], {
+ stdio: "inherit",
+ env: options.env || prependPathEntries(process.env, candidateBinDirs()),
+ });
+
+ return normalizeSpawnResult(result);
+}
+
+function quoteWindowsCmdArgument(value) {
+ const rawValue = String(value);
+ const escapedValue = rawValue.replace(/"/g, '\\"');
+ return `"${escapedValue}"`;
+}
+
function shouldRunThroughShell(command) {
if (process.platform !== "win32") {
return false;
diff --git a/npm/avibe/test/cli.test.js b/npm/avibe/test/cli.test.js
index 139437905..c059de37e 100644
--- a/npm/avibe/test/cli.test.js
+++ b/npm/avibe/test/cli.test.js
@@ -62,7 +62,7 @@ function loadCliForUnitTest(overrides = {}) {
module: { exports: {} },
exports: {},
};
- vm.runInNewContext(`${source}\nmodule.exports = { shouldRunThroughShell };`, sandbox, {
+ vm.runInNewContext(`${source}\nmodule.exports = { quoteWindowsCmdArgument, shouldRunThroughShell };`, sandbox, {
filename: cliPath,
});
return sandbox.module.exports;
@@ -165,3 +165,29 @@ test("runs Windows batch wrappers through a shell", { skip: process.platform !==
assert.equal(shouldRunThroughShell("C:\\Users\\alex\\.local\\bin\\vibe.bat"), true);
assert.equal(shouldRunThroughShell("C:\\Users\\alex\\.local\\bin\\vibe.exe"), false);
});
+
+test("quotes Windows batch wrapper paths with spaces", { skip: process.platform !== "win32" }, () => {
+ const { quoteWindowsCmdArgument } = loadCliForUnitTest();
+
+ assert.equal(
+ quoteWindowsCmdArgument("C:\\Users\\Jane Doe\\.local\\bin\\vibe.cmd"),
+ '"C:\\Users\\Jane Doe\\.local\\bin\\vibe.cmd"'
+ );
+ assert.equal(quoteWindowsCmdArgument('C:\\bin\\vibe "dev".cmd'), '"C:\\bin\\vibe \\"dev\\".cmd"');
+});
+
+test("delegates to Windows batch wrappers in paths with spaces", { skip: process.platform !== "win32" }, () => {
+ const temp = makeTempEnv();
+ const spacedBin = path.join(temp.root, "space dir");
+ fs.mkdirSync(spacedBin, { recursive: true });
+ writeFakeVibe(spacedBin, "spaced-vibe");
+
+ const result = runCli(["status", "--json"], {
+ HOME: temp.home,
+ USERPROFILE: temp.home,
+ PATH: spacedBin,
+ });
+
+ assert.equal(result.status, 0);
+ assert.match(result.stdout, /spaced-vibe status --json/);
+});