Orkas is an open-source (MIT), local-first AI team for your desktop: a Commander turns your goal into to-dos and coordinates 16 built-in specialist agents plus Claude Code, Codex, OpenCode, OpenClaw and Hermes, with projects, scheduled automations and connectors. Free app for macOS & Windows; built-in models or your own keys.
JavaScript agent-collaborationagent-harnessagent-orchestrationagent-teamagent-workflowai-assistantai-automationai-employeeai-productivityai-teamai-workflowautonomous-agentsclaude-code-guiclaude-coworkdesktop-agentlocal-firstmulti-agentmulti-agent-systemself-evolving-agentstask-automation
import fs from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
/** Keep deterministic evaluator fixtures on the same project interpreter as
* the test suite, including direct npm test invocations. Explicit evaluator
* overrides remain independent of the ordinary Python suite. */
export function withTestPython(env, repoRoot = fileURLToPath(new URL('../', import.meta.url)), platform = process.platform) {
const result = { ...env };
const localPython = platform === 'win32'
? path.join(repoRoot, 'venv', 'Scripts', 'python.exe')
: path.join(repoRoot, 'venv', 'bin', 'python');
const python = result.ORKAS_TEST_PYTHON || (fs.existsSync(localPython) ? localPython : '');
if (python) {
result.ORKAS_TEST_PYTHON = python;
if (!result.ORKAS_EVAL_PYTHON) result.ORKAS_EVAL_PYTHON = python;
}
return result;
}
/** PowerShell 5.1 cannot import PowerShell 7's core modules. Native Windows
* lanes may be launched by pwsh, so restore the installed system module root
* ahead of inherited user/Core paths without changing the caller environment. */
export function withWindowsPowerShellModules(env, platform = process.platform) {
const result = { ...env };
if (platform !== 'win32') return result;
const systemRoot = result.SystemRoot || result.WINDIR;
if (!systemRoot) return result;
const modules = path.join(systemRoot, 'System32', 'WindowsPowerShell', 'v1.0', 'Modules');
if (!fs.existsSync(modules)) return result;
const key = Object.keys(result).find(name => name.toLowerCase() === 'psmodulepath') || 'PSModulePath';
const inherited = String(result[key] || '').split(';').filter(Boolean);
result[key] = [modules, ...inherited.filter(entry => path.resolve(entry).toLowerCase() !== path.resolve(modules).toLowerCase())].join(';');
return result;
}
function environmentPathKey(env) {
return Object.keys(env).find((key) => key.toLowerCase() === 'path') || 'PATH';
}
function containsGitExecutable(value) {
return String(value || '')
.split(path.delimiter)
.map((entry) => entry.trim().replace(/^"(.*)"$/, '$1'))
.some((entry) => entry && fs.existsSync(path.join(entry, 'git.exe')));
}
function pathEntries(value) {
return String(value || '')
.split(path.delimiter)
.map((entry) => entry.trim().replace(/^"(.*)"$/, '$1'))
.filter(Boolean);
}
function containsPathEntry(entries, candidate) {
const normalized = path.resolve(candidate).toLowerCase();
return entries.some((entry) => path.resolve(entry).toLowerCase() === normalized);
}
function gitBashBinCandidates(gitBins) {
return [...new Set(gitBins.flatMap((gitBin) => [
gitBin,
path.resolve(gitBin, '..', 'bin'),
]))];
}
export function windowsGitBinCandidates(env) {
const candidates = [];
const explicitGit = String(env.ORKAS_TEST_GIT || '').trim();
if (explicitGit) candidates.push(path.dirname(explicitGit));
const localAppData = String(env.LOCALAPPDATA || '').trim();
if (localAppData) {
candidates.push(path.join(localAppData, 'Programs', 'Git', 'cmd'));
const desktopRoot = path.join(localAppData, 'GitHubDesktop');
if (fs.existsSync(desktopRoot)) {
const appDirs = fs.readdirSync(desktopRoot, { withFileTypes: true })
.filter((entry) => entry.isDirectory() && entry.name.startsWith('app-'))
.map((entry) => entry.name)
.sort((left, right) => right.localeCompare(left, undefined, { numeric: true }));
for (const appDir of appDirs) {
candidates.push(path.join(desktopRoot, appDir, 'resources', 'app', 'git', 'cmd'));
}
}
}
for (const root of [env.ProgramFiles, env['ProgramFiles(x86)']]) {
if (root) candidates.push(path.join(String(root), 'Git', 'cmd'));
}
return [...new Set(candidates)];
}
/**
* Desktop test and benchmark processes invoke Git through production sync
* scripts and isolated repository fixtures. Codex Desktop and GitHub Desktop
* can provide Git without placing it on the inherited Windows PATH, so make
* that existing runtime discoverable instead of failing with ENOENT.
*/
export function withWindowsGitOnPath(env, platform = process.platform) {
const result = { ...env };
if (platform !== 'win32') return result;
const pathKey = environmentPathKey(result);
const currentPath = String(result[pathKey] || '');
const currentEntries = pathEntries(currentPath);
const configuredGitBins = windowsGitBinCandidates(result)
.filter((candidate) => fs.existsSync(path.join(candidate, 'git.exe')));
const currentGitBins = currentEntries
.filter((entry) => fs.existsSync(path.join(entry, 'git.exe')));
const prepend = [];
if (!containsGitExecutable(currentPath) && configuredGitBins[0]) {
prepend.push(configuredGitBins[0]);
}
// Windows ships a System32/bash.exe placeholder that only opens the WSL
// installation prompt. Shell-contract tests need the bash.exe that belongs
// to Git for Windows, even when another git.exe is already visible on PATH.
const gitBashBin = gitBashBinCandidates([...currentGitBins, ...configuredGitBins])
.find((candidate) => (
fs.existsSync(path.join(candidate, 'git.exe'))
&& fs.existsSync(path.join(candidate, 'bash.exe'))
));
const configuredBash = String(result.ORKAS_TEST_BASH || '').trim();
const gitBashPath = configuredBash && fs.existsSync(configuredBash)
? configuredBash
: (gitBashBin ? path.join(gitBashBin, 'bash.exe') : '');
if (gitBashBin && !containsPathEntry(currentEntries, gitBashBin)) {
prepend.unshift(gitBashBin);
}
if (gitBashPath) result.ORKAS_TEST_BASH = gitBashPath;
if (prepend.length) {
result[pathKey] = [...new Set(prepend), ...(currentPath ? [currentPath] : [])]
.join(path.delimiter);
}
return result;
}