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): launch Windows batch shims via shell

cyha8d0d52d1729
diff --git a/npm/avibe/bin/avibe.js b/npm/avibe/bin/avibe.js
index 2448b5529..7d7dc6f2a 100755
--- a/npm/avibe/bin/avibe.js
+++ b/npm/avibe/bin/avibe.js
@@ -129,9 +129,10 @@ function findVibeBinary() {
}
function runCommand(command, args, options = {}) {
+ const useShell = options.shell || shouldRunThroughShell(command);
const result = childProcess.spawnSync(command, args, {
stdio: "inherit",
- shell: options.shell || false,
+ shell: useShell,
env: options.env || prependPathEntries(process.env, candidateBinDirs()),
});
@@ -146,6 +147,15 @@ function runCommand(command, args, options = {}) {
return result.signal ? 1 : 0;
}
+function shouldRunThroughShell(command) {
+ if (process.platform !== "win32") {
+ return false;
+ }
+
+ const extension = path.extname(command).toLowerCase();
+ return extension === ".cmd" || extension === ".bat";
+}
+
function hasCommand(command) {
return Boolean(resolveFromPath(command, prependPathEntries(process.env, candidateBinDirs())));
}
diff --git a/npm/avibe/test/cli.test.js b/npm/avibe/test/cli.test.js
index bcd3cdced..789bdd78d 100644
--- a/npm/avibe/test/cli.test.js
+++ b/npm/avibe/test/cli.test.js
@@ -3,9 +3,11 @@
const assert = require("node:assert/strict");
const childProcess = require("node:child_process");
const fs = require("node:fs");
+const Module = require("node:module");
const os = require("node:os");
const path = require("node:path");
const test = require("node:test");
+const vm = require("node:vm");
const cliPath = path.join(__dirname, "..", "bin", "avibe.js");
@@ -42,6 +44,30 @@ function runCli(args, envOverrides = {}) {
});
}
+function loadCliForUnitTest(overrides = {}) {
+ const source = fs.readFileSync(cliPath, "utf8").replace(/\nmain\(\);\s*$/, "\n");
+ const sandbox = {
+ console,
+ process: {
+ ...process,
+ argv: [process.execPath, cliPath],
+ env: { ...process.env, ...overrides.env },
+ exit(code) {
+ throw new Error(`process.exit(${code})`);
+ },
+ },
+ require: Module.createRequire(cliPath),
+ __dirname: path.dirname(cliPath),
+ __filename: cliPath,
+ module: { exports: {} },
+ exports: {},
+ };
+ vm.runInNewContext(`${source}\nmodule.exports = { shouldRunThroughShell };`, sandbox, {
+ filename: cliPath,
+ });
+ return sandbox.module.exports;
+}
+
test("prints wrapper help without installing", () => {
const temp = makeTempEnv();
const result = runCli(["--help"], {
@@ -112,3 +138,11 @@ test("maps init and start to the default vibe command", () => {
assert.match(init.stdout, /default-vibe\s*$/m);
assert.match(start.stdout, /default-vibe\s*$/m);
});
+
+test("runs Windows batch wrappers through a shell", { skip: process.platform !== "win32" }, () => {
+ const { shouldRunThroughShell } = loadCliForUnitTest();
+
+ assert.equal(shouldRunThroughShell("C:\\Users\\alex\\.local\\bin\\vibe.cmd"), true);
+ assert.equal(shouldRunThroughShell("C:\\Users\\alex\\.local\\bin\\vibe.bat"), true);
+ assert.equal(shouldRunThroughShell("C:\\Users\\alex\\.local\\bin\\vibe.exe"), false);
+});