Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion plugin/scripts/health-check.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ function safeExec(cmd, args, opts = {}) {
encoding: 'utf-8',
stdio: ['ignore', 'pipe', 'ignore'],
timeout: 3000,
// Windows: execFileSync does not honor PATHEXT, so bare 'claude'/'node'
// miss their .cmd shims and read as "not found". Route through cmd.exe.
shell: process.platform === 'win32',
...opts,
}).trim();
} catch {
Expand Down Expand Up @@ -110,7 +113,8 @@ export async function runFullChecks(ctx = {}) {
return data?.plugins || data || {};
})();

const binaryPath = c.pluginData ? join(c.pluginData, 'bin', 'll-search') : null;
const binaryName = process.platform === 'win32' ? 'll-search.exe' : 'll-search';
const binaryPath = c.pluginData ? join(c.pluginData, 'bin', binaryName) : null;
let binaryVersionOutput = null;
let binaryExitCode = 127;
if (binaryPath && existsSync(binaryPath)) {
Expand Down
14 changes: 11 additions & 3 deletions plugin/scripts/lib/health-checks/quick.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,11 @@ export function checkBinaryExists({ pluginData } = {}) {
fix: 'Run /learning-loop:init to download the binary',
});
}
const binPath = join(pluginData, 'bin', 'll-search');
const binPath = join(
pluginData,
'bin',
process.platform === 'win32' ? 'll-search.exe' : 'll-search',
);
if (!existsSync(binPath)) {
return makeCheck({
id: CHECK_IDS['binary-exists'],
Expand All @@ -168,7 +172,7 @@ export function checkBinaryExists({ pluginData } = {}) {
}
try {
const stat = statSync(binPath);
if (!(stat.mode & 0o111)) {
if (process.platform !== 'win32' && !(stat.mode & 0o111)) {
return makeCheck({
id: CHECK_IDS['binary-exists'],
name: 'll-search binary',
Expand Down Expand Up @@ -271,13 +275,17 @@ export function checkShimsExist({ home } = {}) {
fix: 'Set $HOME',
});
}
const isWin = process.platform === 'win32';
const shimExt = isWin ? '.cmd' : '';
const missing = [];
for (const s of ['ll-watch', 'll-search']) {
const p = join(home, '.local/bin', s);
const p = join(home, '.local/bin', s + shimExt);
if (!existsSync(p)) {
missing.push(s);
continue;
}
// Windows .cmd shims carry no POSIX exec bit; existence is sufficient.
if (isWin) continue;
try {
const stat = statSync(p);
if (!(stat.mode & 0o111)) missing.push(`${s} (not executable)`);
Expand Down
54 changes: 54 additions & 0 deletions tests/health-check.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,60 @@ test(
},
);

// Windows checks: the native binary is `ll-search.exe` and the shims are
// `.cmd`, and Node statSync reports no POSIX exec bit for either. These mock
// process.platform so the win32 branches run on the (POSIX) CI runner too.
test('checkBinaryExists: ok on win32 when ll-search.exe present (no POSIX exec bit)', () => {
const original = Object.getOwnPropertyDescriptor(process, 'platform');
Object.defineProperty(process, 'platform', { value: 'win32' });
try {
const dir = mkdtempSync(join(tmpdir(), 'health-bin-win-'));
mkdirSync(join(dir, 'bin'));
writeFileSync(join(dir, 'bin/ll-search.exe'), 'MZ');
const result = checkBinaryExists({ pluginData: dir });
assert.equal(result.status, 'ok');
assert.match(result.detail, /ll-search\.exe$/);
rmSync(dir, { recursive: true, force: true });
} finally {
Object.defineProperty(process, 'platform', original);
}
});

test('checkShimsExist: ok on win32 when .cmd shims present (no POSIX exec bit)', () => {
const original = Object.getOwnPropertyDescriptor(process, 'platform');
Object.defineProperty(process, 'platform', { value: 'win32' });
try {
const home = mkdtempSync(join(tmpdir(), 'health-shims-win-'));
mkdirSync(join(home, '.local/bin'), { recursive: true });
for (const s of ['ll-watch.cmd', 'll-search.cmd']) {
writeFileSync(join(home, '.local/bin', s), '@echo off\n');
}
const result = checkShimsExist({ home });
assert.equal(result.status, 'ok');
rmSync(home, { recursive: true, force: true });
} finally {
Object.defineProperty(process, 'platform', original);
}
});

test('checkShimsExist: fail on win32 when only extensionless shims exist', () => {
const original = Object.getOwnPropertyDescriptor(process, 'platform');
Object.defineProperty(process, 'platform', { value: 'win32' });
try {
const home = mkdtempSync(join(tmpdir(), 'health-shims-win-noext-'));
mkdirSync(join(home, '.local/bin'), { recursive: true });
for (const s of ['ll-watch', 'll-search']) {
writeFileSync(join(home, '.local/bin', s), '#!/usr/bin/env bash\n');
}
const result = checkShimsExist({ home });
assert.equal(result.status, 'fail');
assert.match(result.detail, /ll-watch/);
rmSync(home, { recursive: true, force: true });
} finally {
Object.defineProperty(process, 'platform', original);
}
});

test('checkLocalBinOnPath: ok when ~/.local/bin in PATH', () => {
const result = checkLocalBinOnPath({
home: '/home/test',
Expand Down