fauxnix
fauxnix
Windows上でLinuxスタイルのコマンドを実行 — ネイティブに、決定的に、VMもWSLも不要。
fauxnixは、AIエージェント向けに構築されたbash→PowerShell変換レイヤーです。エージェントは既に知っているbash(ls -la | grep foo、find . -name '*.ts' | wc -l、kill -9 1234)を書き続けるだけで、fauxnixは各コマンドをPowerShellに決定的に変換し、ネイティブに実行し、GNU/Linux風の出力(ls -lの列、bashスタイルのエラーメッセージ、coreutilsの終了コード、UTF-8/GBKの自動処理)を返します。
npm install -g fauxnix-cli # then point any MCP harness at `fauxnix mcp`$ fauxnix "ls -la src | head -2"
-rw-r--r-- 1 me me 1204 Aug 16 09:12 ast.ts
-rw-r--r-- 1 me me 8192 Aug 16 09:12 cli.ts
$ fauxnix "cat nope.txt"
cat: nope.txt: No such file or directory # not a PowerShell stack trace測定結果: あなたのモデルはおそらくPowerShellが思っているより苦手
同じモデル(DeepSeek-V4-Pro)、同じ5つのタスク、1台のWindowsマシンでの3つの実行モード — 完全なデータはdocs/benchmark-deepseek-v4-pro.mdと`docs/benchmark-ark-models.mdにあります:
PowerShell | fauxnix | Git Bash | |
ツール呼び出し / 予期しないエラー | 14 / 9 | 7 / 0 | 4 / 0 |
時間 (T1–T4) | 163s | 66s | 57s |
Volcano Ark Coding Plan上の7モデルすべてで、PowerShellとfauxnixの差はテストしたすべてのモデルで確認されました — 最悪のケース(kimi-k2-thinking): PowerShellで書くと3.1倍遅く、24件のエラーイベントが発生したのに対し、fauxnixではエラーゼロ。fauxnixはbashツールチェーンをインストールしなくても、実際のbashの上限の約15%以内に収まります。
Related MCP server: wmux
なぜか
LLMエージェントはPowerShellよりもbashの方がはるかに得意です — bashはトレーニングデータの大部分を占めるため、Windows上のモデルは「正しく見えるが実行できない」コマンド(誤ったクォート、curlではないcurl、コードページ不一致による文字化け、不可解なCategoryInfoエラーダンプ)を生成することがよくあります。既存の解決策は、完全なVM(WSL — 重く、ファイルシステムが異なり、環境が分離されている)か、単純なシェルラッパー(内部は依然としてPowerShell)のどちらかです。
fauxnixは第三の道を選びます: エミュレートせず、翻訳する。Linuxコマンドラインの大規模で価値の高いサブセット — ファイル操作、テキスト処理、プロセス管理、アーカイブ、ネットワークの基本 — は、PowerShell + .NETにきれいにマッピングできます。fauxnixはそのサブセットを忠実に実装し、翻訳できないものについては大声で役立つように失敗するため、エージェントが黙って間違った結果を得ることはありません。
インストール
npm install -g fauxnix-cliまたはソースから:
git clone https://github.com/20000419/fauxnix && cd fauxnix && npm install -g .npmパッケージ名は
fauxnix-cliです(npmのfauxnixという名前は無関係の2015年のwebsocketライブラリが所有しています)。インストールされるコマンドは依然としてfauxnixです。
必要条件: PowerShell 5.1+(内蔵)とNode.js ≥ 18を搭載したWindows。
クイックスタート
# one-off commands
fauxnix "ls -la"
fauxnix "grep -rn TODO src | wc -l"
fauxnix "cat log.txt | grep -i error | sort | uniq -c"
# see what a command becomes (great for debugging / learning PS)
fauxnix translate "find . -name '*.log' -mtime +7 -delete"
# check your environment
fauxnix check
# run the MCP stdio server (what agent harnesses connect to)
fauxnix mcp未知のコマンド(git、node、npm、python、cargo、gh、dockerなど)は、argvスタイルのクォートでネイティブにそのまま渡されます — 文字列の再解析も、クォートのバグもありません。
エージェントハーネスでの使用
fauxnixには、bashツール(さらにfauxnix_translateとfauxnix_session)を公開するMCP stdioサーバーが含まれています。MCP対応の任意のハーネスから利用できます:
Claude Code
claude mcp add fauxnix -- fauxnix mcpCodex (~/.codex/config.toml または codex mcp add fauxnix -- fauxnix mcp)
[mcp_servers.fauxnix]
command = "fauxnix"
args = ["mcp"]注: 非対話型のcodex execモードでは、MCPツール呼び出しは承認レイヤーによって自動的に拒否されます。--dangerously-bypass-approvals-and-sandboxを渡すか(または対話的に実行して一度承認してください)。
OpenCode (opencode.json)
{
"mcp": {
"fauxnix": { "type": "local", "command": ["fauxnix", "mcp"] }
}
}Kimi Code — 他とは異なり、MCPサーバーはTOML設定ではなくJSONファイルにあります: ~/.kimi-code/mcp.json
{
"mcpServers": {
"fauxnix": { "command": "fauxnix", "args": ["mcp"] }
}
}任意のMCPクライアント — stdioサーバー: fauxnix mcp。ツール名はbashです(FAUXNIX_TOOL_NAMEで上書き可能)。ツールの説明にはサポートされているサブセットが既に含まれているため、システムプロンプトの変更は不要です。
MCPセッションは、ツール呼び出しをまたいでcwd、環境変数、export/unset、cd -/OLDPWDを保持します — ステートレスなexecではなく、ログインしたシェルのように動作します。
翻訳されるもの
約105のコマンド。開発中はすべてWindows(Git Bash)上の実際のGNU coreutilsと出力を照合しています:
ファイル:
ls cp mv rm mkdir rmdir touch mktemp ln readlink realpath basename dirname stat file du df find chmod chown diffテキストフィルタ:
grep egrep sed awk sort uniq cut tr— sed/awkスクリプトは翻訳時に解析されます(サポートされていない構文は名前付きエラーをスローし、黙って誤動作することはありません)テキストI/O:
echo printf cat head tail wc tee nl tac md5sum sha1sum sha256sum base64 seq yes xargsシェル/システム:
cd pwd export unset env printenv ps kill pkill pgrep sleep which type whoami id groups date uname hostname uptime free nproc clear true false test [ [[ : pushd popd dirs sudo timeout man history less more source . eval exit alias setネットワーク:
curl wget ping netstat ss ip ifconfig nslookup dig hostアーカイブ:
tar gzip gunzip zcat zip unzip
さらにシェル構文: パイプ、&& / || / ;、リダイレクト(> >> 2> 2>&1 < &>、/dev/null)、クォート、$VAR $(...)コマンド置換、VAR=x cmdプレフィックス、~展開、POSIXスタイルのパス正規化(/tmp、/d/foo → D:\foo)。
終了コードはbashの慣例に従います: 0=成功、1=失敗、2=使用法/重大なエラー、127=コマンドが見つからない、124=タイムアウト。
仕組み
bash command ──parser──▶ AST ──translator──▶ PowerShell script ──executor──▶ powershell.exe
│
agent ◀── GNU-style output, bash-style errors ◀── decoder (UTF-8 → GBK fallback) ◀┘決定的な翻訳、ランタイムでのLLM呼び出しゼロ。
各コマンドは、「Fauxnix契約」に従った自己完結型のPowerShellブロックを生成するジェネレーターにマッピングされます: 行ごとの文字列stdout、bashスタイルのstderrには
[Console]::Error.WriteLine、終了コードには$script:fx_exit、stdinには$input。エグゼキューターはすべてのスクリプトをUTF-8強制(
[Console]::OutputEncoding、$OutputEncoding、chcp 65001)でラップし、出力を厳密なUTF-8としてデコードし、レガシーなネイティブツールにはGBK(936)フォールバックを使用し、stderrからCLIXMLシリアライゼーションとPowerShellのノイズを除去し、一般的なPowerShellエラー(zh-CNロケールのメッセージを含む)をbashの表現に書き換えます。スクリプトは
-EncodedCommand(UTF-16LE)で実行され、32 KBのコマンドライン制限を超える場合は一時.ps1ファイルに透過的にフォールバックします。
既知の相違点(正直なリスト)
fauxnixは、エージェントが実際に実行するコマンドに最適化されています。文書化された相違点:
X=1単独の代入はexportセマンティクスに従います(セッション全体で1つの環境。bashのシェル変数とエクスポート変数の区別は存在しません)。また、同じセグメント内のプレフィックスは、コマンド自身の単語内の$VARから参照できます(Z=in [[ $Z == in ]]はここでは真ですが、bashでは単語展開が一時環境より先に行われるため偽です)。yesは65,536行に制限されています — PS 5.1のパイプラインは上流のプロデューサーに停止を通知できないため、無制限のyes | headはハングします。tail -f、eval、alias、ヒアドキュメント、while/until/case、単語レベルの$((...))算術展開、バックグラウンド&は、誤動作する代わりに実行可能なエラーメッセージで拒否されます。(if/then/else/fi、for x in ...、バッククォート置換、command -v、パイプラインread、dotenvスタイルのsourceはサポートされています。)command -v <builtin>は、bashが組み込み名のみを出力するのに対し、/usr/bin/<name>を出力します。終了コードと空結果のセマンティクスは一致します。chmodは読み取り専用ビットのみをマッピングします。実行ビットはWindowsでは何もしません。chownは(Git Bashと同様に)黙って何もしません。ps auxの列は近似値です(プロセスごとのCPU%の計算はなく、USERは?と表示されます)。gzip -c/パイプラインのstdinはテキスト忠実であり、バイト忠実ではありません。ファイルモードのgzip fはバイト単位で正確です。ちょうど1行を生成するパイプラインを
wc -lにパイプすると、その行を数えます(bashでは、プロデューサーが末尾の改行を省略した場合0と数えます)。printf 'x' | md5sumはバイト単位で正確です。sed/awkは一般的なサブセットをサポートします。ホールドスペース、ラベル、配列、ループは翻訳時に「サポートされていません」という名前付きエラーをスローします。curl/wgetは、エージェント駆動のHTTPに対する安全なデフォルトとして、ループバック/プライベート/予約済みアドレス(localhost、127.x、::1、10.x、172.16–31.x、192.168.x、169.254.x)を拒否します。ネイティブツールのパイプラインとエンコーディング: PS 5.1にはコンソールエンコーディングのノブが1つしかないため、ローカライズされた管理ツール(ipconfig、tasklist — zh-CNではGBK)とUTF-8ネイティブの開発ツール(node、curl)をパイプライン内で両方きれいにデコードすることはできません。デフォルトはUTF-8の開発ツールを優先します。エージェントがネイティブWindows管理ツールの中国語出力をgrepする場合は、
FAUXNIX_NATIVE_ENCODING=ansiを設定してください。ファイルの読み取りは常にファイルごとにスニッフィングされます(UTF-8厳密 → GBKフォールバック)ため、GBK ファイルに対するgrep/sed/awkはどちらのモードでも機能します — ロケールが想定するエンコーディングのみに一致するGit Bashとは異なります。
開発
npm install
npm test # unit + real-PowerShell integration suite (Windows only, auto-skipped elsewhere)
npm run build
npx tsx scratch/run.mjs "any bash command" # quick live checkアーキテクチャマップ: src/parser.ts(bashサブセット → AST)· src/translator.ts(AST → PowerShell + エグゼキューターラッパー)· src/executor.ts(spawn、リダイレクト、セッション永続化)· src/commands/*.ts(コマンドごとのジェネレーター)· src/mcp.ts(MCPサーバー)· src/cli.ts。
ライセンス
MIT © 20000419
Available Tools
4 toolsbashADestructive
Execute a Linux/bash-style command on this Windows machine.
Commands are deterministically translated to PowerShell and executed natively — no WSL or VM. Output is formatted to look like GNU/Linux tooling (ls -l, ps aux, df -h ...), errors look like bash errors, and text encoding (UTF-8/GBK) is handled automatically.
Supported: pipes (|), && / || / ;, redirections (> >> 2> 2>&1 < /dev/null), variables ($VAR $HOME $1 $# "$@" ~), set -- / shift, array assignment A=(x y z), ${name[n]} ${#name[@]} ${name//pat/str} ${name:off:len}, command substitution $(...), and 109+ coreutils-style commands (., :, [, [[, alias, awk, base64, basename, cat, cd, chmod, chown, clear, command, cp, curl, cut, date...). Unknown commands (git, node, npm, python, cargo...) are passed through and executed natively with argv-style quoting. Not supported: heredocs, env -i/--ignore-environment, background jobs. if/then/elif/else/fi, for-in loops, while/until, case ... esac, and word-level $((...)) arithmetic expansion are supported. CWD, environment variables, export/unset, cd, and positional parameters (set -- / $1 / "$@") persist across calls within this session — a resident PowerShell 5.1 host is started when the MCP session begins (and after reset), so the first bash tool call is already warm. Efficiency: when two or more commands or verification steps are already known, prefer bash_batch once instead of making several bash calls. Keep separate calls only when the next command requires model interpretation of the previous output. For byte-exact work, measure with wc -c or stat -c %s instead of inferring CRLF byte counts from displayed text. MCP capture is bounded to 256 KiB stdout and 64 KiB stderr across the complete command list; larger output is marked truncated. Redirect larger artifacts to files. These transport-safe budgets include room for JSON escaping and duplicate text/structured fields. Exit codes follow bash conventions (0 ok, 1 fail, 2 usage/serious, 127 command not found, 124 timeout, 130 cancelled). The tool also returns structuredContent (schemaVersion 1) with stdout/stderr/exitCode/timedOut/cancelled/truncated/sessionId.
Platform requirement: the execution backend is native Windows PowerShell 5.1+. On hosts without PowerShell on PATH (e.g. Linux containers/sandboxes), the bash tool returns exit code 127 with an actionable error instead of running the command.
Inputs: command (required), timeout_ms.
bash_batchADestructive
Compile and execute a preplanned multi-step bash workflow in one MCP round trip.
Use this instead of repeated bash calls when the complete sequence is already known. Steps run serially and atomically in the same persistent session: later steps see cwd, environment, and files from earlier steps, while run/reset requests cannot interleave. Every command is parsed and translated before step 1 runs, and the result reports each step separately.
By default the batch stops after the first nonzero exit. Set stop_on_error=false only when later steps should still run. timeout_ms and both output limits apply to the whole batch, not once per step. Output defaults to 256 KiB stdout and 64 KiB stderr; redirect larger artifacts to files. Preflight performs no operand-file reads: use sed -e with inline script text instead of sed -f. If a later command depends on model interpretation of an earlier result, use separate bash calls instead. For byte counts, include wc -c or stat -c %s as a verification step rather than calculating CRLF bytes mentally.
Inputs: steps (required), timeout_ms, stop_on_error, stderr_limit_bytes, +1 more.
fauxnix_sessionAIdempotent
Inspect or reset the persistent fauxnix shell session (current directory, environment, positional count, session id). Actions: "status" (default) or "reset".
Inputs: action.
fauxnix_translateARead-onlyIdempotent
Translate a bash-style command into the equivalent PowerShell script WITHOUT executing it. Useful for learning/debugging what fauxnix does under the hood.
Inputs: command (required).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
bash and bash_batch overlap in purpose (both execute commands), but the descriptions give clear guidance on when to use each (batch for preplanned sequences, separate calls when model interpretation is needed). fauxnix_session and fauxnix_translate are clearly distinct. Only minor risk of misselection between the two execution tools.
Two naming families coexist: bare 'bash'/'bash_batch' (shared prefix, but no verb_noun form) and 'fauxnix_session'/'fauxnix_translate' (server-prefixed). The pattern is readable and not chaotic, but conventions are mixed rather than uniform.
Four tools is well-scoped for a shell-emulation server: execution, batched execution, session inspection, and translation each earn their place with no redundancy.
The surface covers execution, batch workflows, session status/reset, and translation introspection, which is solid lifecycle coverage for a shell proxy. Minor gap: no direct way to kill or interrupt a running process beyond reset, but core workflows are covered.
Maintenance
Related MCP Connectors
Secure Linux sandboxes for AI agents, as MCP tools.
Autonomous agent guardrails, bash sandboxing, MCP rugpull diffing & prompt firewalls.
Linux microVMs for AI agents: run commands, read and write files, pause and resume.
Remote MCP access to user-authorized Linux, Windows and Intel Mac devices for AI assistants.
Related MCP Servers
- AlicenseBqualityDmaintenanceHigh-performance MCP server giving AI agents advanced filesystem and automation capabilities on Windows, with 26 tools across file I/O, search, Git, process management, and more.262MIT
- AlicenseNot gradedqualityAmaintenanceA native Windows terminal multiplexer with MCP bridge for AI agents, enabling browser automation, multi-agent coordination, and terminal control.466MIT
- AlicenseNot gradedqualityBmaintenanceProvides a local Windows control plane for PowerShell and AI CLIs, exposing MCP tools for safe terminal sessions, bounded provider calls, routing, committees, and run receipts.MIT
- AlicenseNot gradedqualityBmaintenanceRemote-first, model-independent Windows execution MCP for ChatGPT, Claude, Gemini, and other MCP-compatible AI clients.MIT