fauxnix-cli 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +144 -141
- package/dist/cli.d.ts +2 -1
- package/dist/cli.js +61 -21
- package/dist/commands/archive.js +87 -24
- package/dist/commands/files.js +25 -11
- package/dist/commands/install-all.js +2 -1
- package/dist/commands/net.d.ts +9 -0
- package/dist/commands/net.js +51 -15
- package/dist/commands/sysinfo.d.ts +2 -1
- package/dist/commands/sysinfo.js +564 -72
- package/dist/commands/text-filters.js +53 -12
- package/dist/commands/text-io.js +72 -43
- package/dist/doctor.d.ts +1 -0
- package/dist/doctor.js +44 -3
- package/dist/errors.js +14 -4
- package/dist/executor.d.ts +23 -1
- package/dist/executor.js +264 -51
- package/dist/install.js +43 -2
- package/dist/mcp.d.ts +78 -1
- package/dist/mcp.js +193 -9
- package/dist/parser.js +11 -3
- package/dist/powershell.d.ts +22 -0
- package/dist/powershell.js +129 -0
- package/dist/ps-host.d.ts +42 -13
- package/dist/ps-host.js +302 -40
- package/dist/qwen-launch.d.ts +12 -0
- package/dist/qwen-launch.js +29 -0
- package/dist/registry.d.ts +22 -0
- package/dist/registry.js +109 -1
- package/dist/translator.d.ts +13 -6
- package/dist/translator.js +482 -92
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://glama.ai/mcp/servers/20000419/fauxnix)
|
|
8
8
|
|
|
9
|
-
**Run Linux-style commands on Windows — natively, deterministically,
|
|
9
|
+
**Run Linux-style commands on Windows — natively, deterministically, no VM, no WSL.**
|
|
10
10
|
|
|
11
11
|
fauxnix is a bash→PowerShell translation layer built for AI agents. Your agent keeps writing the
|
|
12
12
|
bash it already knows (`ls -la | grep foo`, `find . -name '*.ts' | wc -l`, `kill -9 1234`), and
|
|
@@ -14,8 +14,15 @@ fauxnix deterministically translates each command into PowerShell, executes it n
|
|
|
14
14
|
back output that looks like GNU/Linux: `ls -l` columns, bash-style error messages, coreutils exit
|
|
15
15
|
codes, UTF-8/GBK handled automatically.
|
|
16
16
|
|
|
17
|
+
One-command install for **Claude Code · Codex · OpenCode · Kimi Code · Qwen Code**, plus any MCP
|
|
18
|
+
client. **109 translated commands · 400+ automated tests · 253-case differential corpus verified
|
|
19
|
+
against real GNU coreutils · zero LLM calls at runtime.**
|
|
20
|
+
|
|
21
|
+
## Try it now — no install
|
|
22
|
+
|
|
17
23
|
```bash
|
|
18
|
-
|
|
24
|
+
npx fauxnix-cli@latest "ls -la src | head -3"
|
|
25
|
+
npx fauxnix-cli@latest translate "find . -name '*.log' -mtime +7 -delete"
|
|
19
26
|
```
|
|
20
27
|
|
|
21
28
|

|
|
@@ -29,95 +36,23 @@ $ fauxnix "cat nope.txt"
|
|
|
29
36
|
cat: nope.txt: No such file or directory # not a PowerShell stack trace
|
|
30
37
|
```
|
|
31
38
|
|
|
32
|
-
##
|
|
33
|
-
|
|
34
|
-
Same model (DeepSeek-V4-Pro), same 5 tasks, three execution modes on one Windows machine —
|
|
35
|
-
full data in [`docs/benchmark-deepseek-v4-pro.md`](docs/benchmark-deepseek-v4-pro.md) and
|
|
36
|
-
[`docs/benchmark-ark-models.md](docs/benchmark-ark-models.md):
|
|
37
|
-
|
|
38
|
-
| | PowerShell | **fauxnix** | Git Bash |
|
|
39
|
-
|---|---|---|---|
|
|
40
|
-
| tool calls / unexpected errors | 14 / 9 | **7 / 0** | 4 / 0 |
|
|
41
|
-
| time (T1–T4) | 163s | **66s** | 57s |
|
|
42
|
-
|
|
43
|
-
Across 7 models on the Volcano Ark Coding Plan, the PowerShell-vs-fauxnix gap held for every
|
|
44
|
-
model tested — worst case (kimi-k2-thinking): **3.1× slower with 24 error events** writing
|
|
45
|
-
PowerShell vs zero errors through fauxnix. fauxnix lands within ~15% of the real-bash ceiling
|
|
46
|
-
with no bash toolchain installed.
|
|
47
|
-
|
|
48
|
-
## Why
|
|
49
|
-
|
|
50
|
-
LLM agents are dramatically better at bash than at PowerShell — bash dominates training data, so
|
|
51
|
-
models on Windows often produce "looks right, doesn't run" commands (wrong quoting, `curl` that
|
|
52
|
-
isn't curl, mojibake from codepage mismatches, inscrutable `CategoryInfo` error dumps). Existing
|
|
53
|
-
solutions are either a full VM (WSL — heavy, wrong filesystem, separate environment) or plain
|
|
54
|
-
shell wrappers (still PowerShell underneath).
|
|
55
|
-
|
|
56
|
-
fauxnix takes the third road: **translate, don't emulate**. A large, high-value subset of the
|
|
57
|
-
Linux command line — file ops, text processing, process management, archives, networking basics —
|
|
58
|
-
maps cleanly onto PowerShell + .NET. fauxnix implements that subset faithfully and *fails loudly
|
|
59
|
-
and helpfully* on what it can't translate, so the agent never gets silently-wrong results.
|
|
60
|
-
|
|
61
|
-
Labs now train computer-use agents on fleets of real desktops. Reporting in 2026 (*The
|
|
62
|
-
Information*, widely repeated) has OpenAI buying tens of thousands of Mac mini / Mac Studio
|
|
63
|
-
boxes — no screen, no keyboard — to reinforcement-learn agents that click, edit, test, and
|
|
64
|
-
run bash workflows, and Anthropic renting Mac minis through AWS for the same class of work.
|
|
65
|
-
That scoring environment is macOS. Windows users should not have to install a guest Unix to
|
|
66
|
-
keep up: the agent keeps writing bash; fauxnix makes the Windows box answer like the box the
|
|
67
|
-
agent was trained on. See [`docs/rfc-computer-use-windows.md`](docs/rfc-computer-use-windows.md).
|
|
68
|
-
|
|
69
|
-
## Install
|
|
39
|
+
## Connect your agent — one command
|
|
70
40
|
|
|
71
41
|
```bash
|
|
72
42
|
npm install -g fauxnix-cli
|
|
43
|
+
fauxnix install --claude # or --codex / --opencode / --kimi / --qwen
|
|
44
|
+
fauxnix doctor # verifies encoding, harness config, and MCP round-trip
|
|
73
45
|
```
|
|
74
46
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
```bash
|
|
78
|
-
git clone https://github.com/20000419/fauxnix && cd fauxnix
|
|
79
|
-
npm ci
|
|
80
|
-
npm install -g .
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
> npm package name is `fauxnix-cli` (the `fauxnix` name on npm belongs to an
|
|
84
|
-
> unrelated 2015 websocket library); the installed command is still `fauxnix`.
|
|
85
|
-
|
|
86
|
-
Requires: Windows with PowerShell 5.1+ (built-in) and Node.js ≥ 18.
|
|
87
|
-
|
|
88
|
-
## Quick start
|
|
89
|
-
|
|
90
|
-
```bash
|
|
91
|
-
# one-off commands
|
|
92
|
-
fauxnix "ls -la"
|
|
93
|
-
fauxnix "grep -rn TODO src | wc -l"
|
|
94
|
-
fauxnix "cat log.txt | grep -i error | sort | uniq -c"
|
|
95
|
-
|
|
96
|
-
# see what a command becomes (great for debugging / learning PS)
|
|
97
|
-
fauxnix translate "find . -name '*.log' -mtime +7 -delete"
|
|
98
|
-
|
|
99
|
-
# check your environment
|
|
100
|
-
fauxnix check
|
|
101
|
-
fauxnix doctor # check + encoding, harness config, MCP
|
|
102
|
-
|
|
103
|
-
# write user-level MCP config (idempotent; also --codex/--opencode/--kimi/--qwen)
|
|
104
|
-
fauxnix install --claude
|
|
105
|
-
|
|
106
|
-
# run the MCP stdio server (what agent harnesses connect to)
|
|
107
|
-
fauxnix mcp
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
Unknown commands (git, node, npm, python, cargo, gh, docker, ...) are **passed through natively**
|
|
111
|
-
with argv-style quoting — no string re-parsing, no quoting bugs.
|
|
47
|
+
Idempotent; prints exactly what changed. Manual configurations below if you prefer to edit
|
|
48
|
+
config files yourself.
|
|
112
49
|
|
|
113
|
-
|
|
50
|
+
> npm package name is `fauxnix-cli` (the `fauxnix` name on npm belongs to an unrelated 2015
|
|
51
|
+
> websocket library); the installed command is `fauxnix`. Requires Windows with PowerShell 5.1+
|
|
52
|
+
> (built-in) and Node.js ≥ 18.
|
|
114
53
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
`fauxnix install --claude` (or `--codex` / `--opencode` / `--kimi` / `--qwen`).
|
|
118
|
-
Idempotent; prints what changed. Manual configs below.
|
|
119
|
-
|
|
120
|
-
- **Quickstarts** — copy-paste config + a 10-command smoke: [`docs/examples/`](docs/examples/)
|
|
54
|
+
<details>
|
|
55
|
+
<summary><b>Manual config per harness</b></summary>
|
|
121
56
|
|
|
122
57
|
**Claude Code**
|
|
123
58
|
```bash
|
|
@@ -130,9 +65,9 @@ claude mcp add fauxnix -- fauxnix mcp
|
|
|
130
65
|
command = "fauxnix"
|
|
131
66
|
args = ["mcp"]
|
|
132
67
|
```
|
|
133
|
-
Note: in non-interactive `codex exec` mode, MCP tool calls are auto-denied by
|
|
134
|
-
|
|
135
|
-
|
|
68
|
+
Note: in non-interactive `codex exec` mode, MCP tool calls are auto-denied by the approval
|
|
69
|
+
layer; pass `--dangerously-bypass-approvals-and-sandbox` (or run interactively and approve
|
|
70
|
+
once).
|
|
136
71
|
|
|
137
72
|
**OpenCode** (`opencode.json`)
|
|
138
73
|
```json
|
|
@@ -143,8 +78,7 @@ interactively and approve once).
|
|
|
143
78
|
}
|
|
144
79
|
```
|
|
145
80
|
|
|
146
|
-
**Kimi Code** —
|
|
147
|
-
TOML config: `~/.kimi-code/mcp.json`
|
|
81
|
+
**Kimi Code** — MCP servers live in a JSON file, not the TOML config: `~/.kimi-code/mcp.json`
|
|
148
82
|
```json
|
|
149
83
|
{
|
|
150
84
|
"mcpServers": {
|
|
@@ -154,76 +88,145 @@ TOML config: `~/.kimi-code/mcp.json`
|
|
|
154
88
|
```
|
|
155
89
|
|
|
156
90
|
**Qwen Code** (`~/.qwen/settings.json`)
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
"mcpServers": {
|
|
160
|
-
"fauxnix": { "command": "fauxnix", "args": ["mcp"] }
|
|
161
|
-
}
|
|
162
|
-
}
|
|
91
|
+
```bash
|
|
92
|
+
fauxnix install --qwen
|
|
163
93
|
```
|
|
94
|
+
The installer preserves the rest of `settings.json` and writes an absolute Node + package-entry
|
|
95
|
+
launcher so Qwen startup does not depend on its working directory or `PATH` order. See
|
|
96
|
+
[the Qwen example](docs/examples/qwen.md) for the generated JSON shape.
|
|
164
97
|
|
|
165
98
|
**Any MCP client** — stdio server: `fauxnix mcp`. The tool name is `bash` (override with
|
|
166
|
-
`FAUXNIX_TOOL_NAME`).
|
|
99
|
+
`FAUXNIX_TOOL_NAME`). The tool description already teaches the model the supported subset, so no
|
|
167
100
|
system-prompt changes are required.
|
|
168
101
|
|
|
102
|
+
Copy-paste quickstarts with a 10-command smoke test per harness: [`docs/examples/`](docs/examples/)
|
|
103
|
+
|
|
104
|
+
</details>
|
|
105
|
+
|
|
169
106
|
The MCP session persists `cwd`, environment variables, `export`/`unset`, `cd -`/OLDPWD, and
|
|
170
107
|
positional parameters (`set --` / `$1` / `"$@"`) across tool calls — it behaves like a logged-in
|
|
171
|
-
shell, not a stateless `exec`. `$0` is the MCP tool name
|
|
172
|
-
|
|
108
|
+
shell, not a stateless `exec`. `$0` is the MCP tool name, not a Windows path.
|
|
109
|
+
|
|
110
|
+
For workflows whose commands are already known, the MCP server also exposes `bash_batch`: it
|
|
111
|
+
compiles every step before execution, runs the plan atomically in one session, and returns one
|
|
112
|
+
structured result per step in a single MCP round trip (stops on first nonzero exit by default).
|
|
113
|
+
|
|
114
|
+
```json
|
|
115
|
+
{
|
|
116
|
+
"steps": [
|
|
117
|
+
{ "id": "write", "command": "printf 'a\\r\\nb' > data.txt" },
|
|
118
|
+
{ "id": "measure", "command": "wc -c data.txt" }
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
See [compiled MCP batch plans](docs/rfc-mcp-batch-plans.md) for timeout, budget, cancellation,
|
|
124
|
+
and preflight semantics.
|
|
125
|
+
|
|
126
|
+
## Measured: your model is probably worse at PowerShell than you think
|
|
127
|
+
|
|
128
|
+
Same model (DeepSeek-V4-Pro), same 5 tasks, three execution modes on one Windows machine —
|
|
129
|
+
full data in [`docs/benchmark-deepseek-v4-pro.md`](docs/benchmark-deepseek-v4-pro.md) and
|
|
130
|
+
[`docs/benchmark-ark-models.md`](docs/benchmark-ark-models.md):
|
|
131
|
+
|
|
132
|
+
| | PowerShell | **fauxnix** | Git Bash |
|
|
133
|
+
|---|---|---|---|
|
|
134
|
+
| tool calls / unexpected errors | 14 / 9 | **7 / 0** | 4 / 0 |
|
|
135
|
+
| time (T1–T4) | 163s | **66s** | 57s |
|
|
136
|
+
|
|
137
|
+
Across 7 models on the Volcano Ark Coding Plan, the PowerShell-vs-fauxnix gap held for every
|
|
138
|
+
model tested — worst case (kimi-k2-thinking): **3.1× slower with 24 error events** writing
|
|
139
|
+
PowerShell vs zero errors through fauxnix. fauxnix lands within ~15% of the real-bash ceiling
|
|
140
|
+
with no bash toolchain installed.
|
|
141
|
+
|
|
142
|
+
## Why
|
|
143
|
+
|
|
144
|
+
LLM agents are dramatically better at bash than at PowerShell — bash dominates training data, so
|
|
145
|
+
models on Windows often produce "looks right, doesn't run" commands (wrong quoting, `curl` that
|
|
146
|
+
isn't curl, mojibake from codepage mismatches, inscrutable `CategoryInfo` error dumps).
|
|
147
|
+
|
|
148
|
+
| | fauxnix | Git Bash | WSL | Raw PowerShell |
|
|
149
|
+
|---|---|---|---|---|
|
|
150
|
+
| agent writes plain bash | ✓ | ✓ | ✓ | ✗ |
|
|
151
|
+
| only needs Node (no bash toolchain / VM) | ✓ | ✗ | ✗ (VM, GBs) | ✓ |
|
|
152
|
+
| native Windows filesystem & environment | ✓ | mostly | ✗ (9P bridge) | ✓ |
|
|
153
|
+
| GNU-exact output, verified | ✓ 253-case differential | ✓ (is GNU) | ✓ | ✗ |
|
|
154
|
+
| CRLF / UTF-8 / GBK traps handled | ✓ | locale-dependent | ✓ | ✗ |
|
|
155
|
+
|
|
156
|
+
**If Git Bash already works for you, keep it** — we literally use it as our differential-testing
|
|
157
|
+
oracle. fauxnix is for when you can't or don't want to ship one: agent fleets where the bash
|
|
158
|
+
toolchain drifts or isn't detected (the [Windows ARM64 Git-Bash detection
|
|
159
|
+
failure](https://github.com/anthropics/claude-code/issues/73461) is a live example), CI runners,
|
|
160
|
+
locked-down machines, or anywhere a single `npm install -g` is easier than a toolchain.
|
|
161
|
+
|
|
162
|
+
fauxnix takes the third road: **translate, don't emulate**. A large, high-value subset of the
|
|
163
|
+
Linux command line — file ops, text processing, process management, archives, networking basics —
|
|
164
|
+
maps cleanly onto PowerShell + .NET. fauxnix implements that subset faithfully and *fails loudly
|
|
165
|
+
and helpfully* on what it can't translate, so the agent never gets silently-wrong results.
|
|
166
|
+
That matters as labs train computer-use agents on Mac fleets — the agent keeps writing bash;
|
|
167
|
+
fauxnix makes the Windows box answer like the box the agent was trained on
|
|
168
|
+
([RFC: computer-use parity](docs/rfc-computer-use-windows.md)).
|
|
173
169
|
|
|
174
170
|
## What's translated
|
|
175
171
|
|
|
176
|
-
|
|
177
|
-
development:
|
|
172
|
+
109 commands, output-matched against real GNU coreutils on Windows (Git Bash) during development:
|
|
178
173
|
|
|
179
174
|
- **files**: `ls cp mv rm mkdir rmdir touch mktemp ln readlink realpath basename dirname stat file du df find chmod chown diff`
|
|
180
|
-
- **text filters**: `grep egrep sed awk sort uniq cut tr` — sed/awk scripts are parsed
|
|
181
|
-
|
|
175
|
+
- **text filters**: `grep egrep sed awk sort uniq cut tr` — sed/awk scripts are parsed while
|
|
176
|
+
preparing an executable plan (unsupported constructs throw named errors, never silently
|
|
177
|
+
misbehave)
|
|
182
178
|
- **text I/O**: `echo printf cat head tail wc tee nl tac md5sum sha1sum sha256sum base64 seq yes xargs`
|
|
183
|
-
|
|
184
|
-
`cp` / `mv` / `rm` / `touch` / `du` / `ls` / `ll` / `mkdir` / `rmdir` / `mktemp` / `ln` /
|
|
185
|
-
`readlink` / `realpath` / `basename` / `dirname` / `stat` / `file` / `df` / `chmod` / `chown` /
|
|
186
|
-
`diff` / `tee` / `grep` / `head` / `echo` / `printf` / `cat` / `tail` / `wc` / `sort` / `uniq` /
|
|
187
|
-
`cut` / `tr` / `gzip` / `gunzip` / `zcat` / `zip` / `unzip` carry a `CommandSpec`: unknown options fail with a GNU-style
|
|
188
|
-
usage error instead of being ignored (`find` stays unspec'd so predicates like `-name` still
|
|
189
|
-
compile; `sed`/`awk`/`egrep` stay unspec'd; `tar` stays unspec'd because it is fx-native to
|
|
190
|
-
`tar.exe` and unknown GNU flags must reach bsdtar). Implemented GNU holes: `cp -n` / `mv -n` / `touch -c` / `tee --append` / `grep -m` /
|
|
191
|
-
`head --lines` / `du --max-depth`. `fauxnix list --json` and `docs/command-specs.md` dump the
|
|
192
|
-
same metadata.
|
|
193
179
|
- **shell/system**: `cd pwd export unset env printenv ps kill pkill pgrep sleep which type whoami
|
|
194
180
|
id groups date uname hostname uptime free nproc clear true false test [ [[ : pushd popd dirs sudo
|
|
195
181
|
timeout man history less more source . eval exit alias set shift`
|
|
196
182
|
- **network**: `curl wget ping netstat ss ip ifconfig nslookup dig host`
|
|
197
183
|
- **archives**: `tar gzip gunzip zcat zip unzip`
|
|
198
184
|
|
|
185
|
+
The curated **agent-daily 60** carry a `CommandSpec`: unknown options fail with a GNU-style
|
|
186
|
+
usage error instead of being ignored. The generated [`docs/command-specs.md`](docs/command-specs.md)
|
|
187
|
+
is the exact list, coverage count, option table, and exclusion rationale; `fauxnix list --json`
|
|
188
|
+
exposes the same per-command metadata. `find` stays unspec'd so predicates like `-name` still
|
|
189
|
+
compile; `sed`/`awk`/`egrep` keep their command-specific parsers; `tar` remains native to
|
|
190
|
+
`tar.exe` so supported bsdtar options reach the executable. Implemented GNU holes include
|
|
191
|
+
`cp -n` / `mv -n` / `touch -c` / `tee --append` / `grep -m` / `head --lines` /
|
|
192
|
+
`du --max-depth` / `env -u` / `ps -f` / `command -V` / `date --date=@SECONDS`.
|
|
193
|
+
|
|
199
194
|
Plus shell syntax: pipes, `&&` / `||` / `;`, redirections (`> >> 2> 2>&1 < &>`, `/dev/null`),
|
|
200
195
|
quoting, `$VAR` `$1` `$#` `"$@"` `set --` `shift`, `${name:-word}` `${name//pat/str}`
|
|
201
196
|
`${name:off:len}` `${name[n]}` `${#name[@]}`, `A=(x y z)` array assignment, `$(...)` command
|
|
202
197
|
substitution, `VAR=x cmd` prefixes, `~` expansion, and POSIX-style path normalization
|
|
203
|
-
(`/tmp`, `/d/foo` → `D:\foo`).
|
|
198
|
+
(`/tmp`, `/d/foo` → `D:\foo`). Exit codes follow bash conventions: 0 ok, 1 fail, 2 usage/serious,
|
|
199
|
+
127 command not found, 124 timeout.
|
|
204
200
|
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
Unknown commands (git, node, npm, python, cargo, gh, docker, ...) are **passed through natively**
|
|
202
|
+
with argv-style quoting. Windows `.cmd`/`.bat` shims necessarily pass through `cmd.exe`; fauxnix
|
|
203
|
+
preserves its supported punctuation and fails loudly for `%`, embedded double quotes, NUL, and
|
|
204
|
+
line breaks rather than passing a different argument.
|
|
207
205
|
|
|
208
206
|
## How it works
|
|
209
207
|
|
|
210
208
|
```
|
|
211
|
-
bash command ──parser──▶ AST ──translator──▶ PowerShell script ──executor──▶
|
|
209
|
+
bash command ──parser──▶ AST ──translator──▶ PowerShell script ──executor──▶ selected PowerShell
|
|
212
210
|
│
|
|
213
|
-
agent ◀── GNU-style output, bash-style errors ◀──
|
|
211
|
+
agent ◀── GNU-style output, bash-style errors ◀── UTF-8 framed host protocol ◀┘
|
|
214
212
|
```
|
|
215
213
|
|
|
216
214
|
- **Deterministic translation, zero LLM calls** at runtime.
|
|
217
215
|
- Each command maps to a generator that emits a self-contained PowerShell block honoring the
|
|
218
216
|
"Fauxnix contract": string-per-line stdout, `[Console]::Error.WriteLine` for bash-style
|
|
219
217
|
stderr, `$script:fx_exit` for exit codes, `$input` for stdin.
|
|
220
|
-
- The executor wraps every script with UTF-8 enforcement
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
218
|
+
- The executor wraps every script with UTF-8 enforcement, decodes native output at the process
|
|
219
|
+
boundary (UTF-8 by default or GBK(936) in `ansi` mode), strips CLIXML serialization and
|
|
220
|
+
PowerShell noise from stderr, and rewrites common PowerShell errors (including zh-CN locale
|
|
221
|
+
messages) into bash phrasing. File reads are always sniffed per file (UTF-8 strict → GBK
|
|
222
|
+
fallback), so grep/sed/awk over GBK files works in either mode.
|
|
224
223
|
- Scripts run via `-EncodedCommand` (UTF-16LE) and transparently fall back to a temp `.ps1` file
|
|
225
224
|
when the 32 KB command-line limit would be exceeded.
|
|
226
225
|
|
|
226
|
+
PowerShell 7 is an opt-in, CI-tested tier: set `FAUXNIX_PS=pwsh` before starting fauxnix or its
|
|
227
|
+
MCP harness. The default is Windows PowerShell 5.1; invalid values fail loudly rather than
|
|
228
|
+
falling back. See [PowerShell 7 support](docs/powershell-7.md).
|
|
229
|
+
|
|
227
230
|
## Known deviations (honest list)
|
|
228
231
|
|
|
229
232
|
fauxnix optimizes for the commands agents actually run. Documented deviations:
|
|
@@ -234,15 +237,13 @@ fauxnix optimizes for the commands agents actually run. Documented deviations:
|
|
|
234
237
|
word expansion precedes the temporary environment).
|
|
235
238
|
- `yes` is capped at 65,536 lines — PS 5.1 pipelines cannot signal upstream producers to stop, so
|
|
236
239
|
an unbounded `yes | head` would hang.
|
|
237
|
-
- `tail -f`, `eval`, `alias`, heredocs,
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
(`
|
|
243
|
-
|
|
244
|
-
dotenv-style `source`, word-level `$((...))` arithmetic expansion, `A=(x y z)` arrays, and
|
|
245
|
-
`${name//pat/str}` / `${name:off:len}` are supported.)
|
|
240
|
+
- `tail -f`, `eval`, `alias`, heredocs, `env -i`/`--ignore-environment`, background `&`, and
|
|
241
|
+
output/fd redirects on a non-last pipeline stage are rejected with operation-specific,
|
|
242
|
+
actionable error messages instead of misbehaving. Per-stage `<` remains supported.
|
|
243
|
+
(`if/then/elif/else/fi`, `for x in ...`, `while`/`until`, `case ... esac` (`;;` only),
|
|
244
|
+
backtick substitution, `command -v`, pipeline `read`, dotenv-style `source`, word-level
|
|
245
|
+
`$((...))` arithmetic expansion, `A=(x y z)` arrays, and `${name//pat/str}` /
|
|
246
|
+
`${name:off:len}` are supported.)
|
|
246
247
|
- `command -v <builtin>` prints `/usr/bin/<name>` where bash prints the bare builtin name;
|
|
247
248
|
exit codes and empty-result semantics match.
|
|
248
249
|
- `chmod` maps only the read-only bit; exec bits are no-ops on Windows. `chown` is a silent no-op
|
|
@@ -255,31 +256,33 @@ fauxnix optimizes for the commands agents actually run. Documented deviations:
|
|
|
255
256
|
"not supported" errors at translate time.
|
|
256
257
|
- `curl`/`wget` refuse loopback/private/reserved addresses (localhost, 127.x, ::1, 10.x,
|
|
257
258
|
172.16–31.x, 192.168.x, 169.254.x) as a safety default for agent-driven HTTP.
|
|
258
|
-
- **Native-tool pipelines vs encoding**: PS 5.1 has a single console-encoding knob, so
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
GBK fallback), so grep/sed/awk over GBK *files* works in either mode — unlike Git Bash,
|
|
264
|
-
which only matches the encoding its locale assumes.
|
|
259
|
+
- **Native-tool pipelines vs encoding**: PS 5.1 has a single console-encoding knob, so piping
|
|
260
|
+
localized admin tools (ipconfig, tasklist — GBK on zh-CN) and UTF-8-native dev tools (node,
|
|
261
|
+
curl) cannot both decode cleanly mid-pipeline. Default favors UTF-8 dev tools; set
|
|
262
|
+
`FAUXNIX_NATIVE_ENCODING=ansi` when your agents grep Chinese output of native Windows admin
|
|
263
|
+
tools.
|
|
265
264
|
|
|
266
265
|
## Development
|
|
267
266
|
|
|
268
|
-
```
|
|
267
|
+
```powershell
|
|
269
268
|
npm install
|
|
270
269
|
npm test # unit + real-PowerShell integration suite (Windows only, auto-skipped elsewhere)
|
|
270
|
+
$env:FAUXNIX_PS = 'pwsh'; npm test # same suite through PowerShell 7
|
|
271
271
|
npm run build
|
|
272
272
|
npx tsx scratch/run.mjs "any bash command" # quick live check
|
|
273
273
|
```
|
|
274
274
|
|
|
275
|
-
Differential vs Git Bash is opt-in (`FAUXNIX_DIFF_ORACLE=1`; skips if unset or `bash.exe` is
|
|
275
|
+
Differential vs Git Bash is opt-in (`FAUXNIX_DIFF_ORACLE=1`; skips if unset or `bash.exe` is
|
|
276
|
+
missing — Git Bash is not required). See [`test/differential/README.md`](test/differential/README.md).
|
|
277
|
+
The 253-case corpus enforces the RFC C-7 minimum of 200 cases and a 95% identity gate; the weekly
|
|
278
|
+
oracle runs from `.github/workflows/differential.yml`.
|
|
276
279
|
|
|
277
280
|
Architecture map: `src/parser.ts` (bash subset → AST) · `src/translator.ts` (AST → PowerShell +
|
|
278
281
|
executor wrapper) · `src/executor.ts` (spawn, redirects, session persistence) ·
|
|
279
282
|
`src/commands/*.ts` (per-command generators) · `src/mcp.ts` (MCP server) · `src/cli.ts`.
|
|
280
283
|
|
|
281
|
-
Roadmap: [docs/rfc-roadmap-to-1.0.md](docs/rfc-roadmap-to-1.0.md) — tracks, milestones,
|
|
282
|
-
|
|
284
|
+
Roadmap: [docs/rfc-roadmap-to-1.0.md](docs/rfc-roadmap-to-1.0.md) — tracks, milestones, and the
|
|
285
|
+
RFC process for proposing waves.
|
|
283
286
|
|
|
284
287
|
## Security
|
|
285
288
|
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import './commands/install-all.js';
|
|
2
|
-
export declare const USAGE = "fauxnix \u2014 run Linux-style commands on Windows via PowerShell translation\n\nUsage:\n fauxnix \"ls -la | head -5\" translate + execute a bash-style command\n fauxnix -c \"cmd\" same as above\n fauxnix translate \"cmd\" show the PowerShell translation only\n fauxnix mcp start the MCP stdio server (for agent harnesses)\n fauxnix list list translated commands\n fauxnix list --json same list as machine-readable capability metadata\n fauxnix list --markdown CommandSpec tables (same text as docs/command-specs.md)\n fauxnix check verify the local PowerShell environment\n fauxnix doctor check + encoding, harness config, MCP readiness\n fauxnix install --claude|--codex|--opencode|--kimi|--qwen\n fauxnix --version\n\nNotes:\n Unknown commands (git, node, npm, python, cargo, ...) pass through and run natively.";
|
|
2
|
+
export declare const USAGE = "fauxnix \u2014 run Linux-style commands on Windows via PowerShell translation\n\nUsage:\n fauxnix \"ls -la | head -5\" translate + execute a bash-style command\n fauxnix -c \"cmd\" same as above\n fauxnix translate \"cmd\" show the PowerShell translation only\n fauxnix mcp start the MCP stdio server (for agent harnesses)\n fauxnix list list translated commands\n fauxnix list --json same list as machine-readable capability metadata\n fauxnix list --markdown CommandSpec tables (same text as docs/command-specs.md)\n fauxnix check verify the local PowerShell environment\n fauxnix doctor check + encoding, harness config, MCP readiness\n fauxnix install --claude|--codex|--opencode|--kimi|--qwen\n fauxnix --version\n\nNotes:\n FAUXNIX_PS=pwsh selects the opt-in PowerShell 7 host (5.1 is the default).\n Unknown commands (git, node, npm, python, cargo, ...) pass through and run natively.";
|
|
3
3
|
export declare function runCli(argv: string[]): Promise<void>;
|
|
4
|
+
export declare function runCheck(): Promise<boolean>;
|
package/dist/cli.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { FauxnixSession } from './executor.js';
|
|
3
3
|
import { parseCommand } from './parser.js';
|
|
4
|
-
import { translateCommandList } from './translator.js';
|
|
4
|
+
import { EXECUTE_TRANSLATION, PURE_TRANSLATION, translateCommandList, } from './translator.js';
|
|
5
5
|
import { listCommandsJson, registeredNames, specsMarkdown } from './registry.js';
|
|
6
6
|
import { encodeCommand } from './encoding.js';
|
|
7
7
|
import { startMcpServer } from './mcp.js';
|
|
8
8
|
import { collectDoctorReport } from './doctor.js';
|
|
9
9
|
import { runInstall } from './install.js';
|
|
10
10
|
import { packageVersion } from './version.js';
|
|
11
|
+
import { POWERSHELL_ARGS, powerShellDisplay, powerShellMissingMessage, resolvePowerShell, } from './powershell.js';
|
|
11
12
|
import './commands/install-all.js';
|
|
12
13
|
export const USAGE = `fauxnix — run Linux-style commands on Windows via PowerShell translation
|
|
13
14
|
|
|
@@ -25,6 +26,7 @@ Usage:
|
|
|
25
26
|
fauxnix --version
|
|
26
27
|
|
|
27
28
|
Notes:
|
|
29
|
+
FAUXNIX_PS=pwsh selects the opt-in PowerShell 7 host (5.1 is the default).
|
|
28
30
|
Unknown commands (git, node, npm, python, cargo, ...) pass through and run natively.`;
|
|
29
31
|
export async function runCli(argv) {
|
|
30
32
|
if (argv.length === 0) {
|
|
@@ -75,7 +77,7 @@ export async function runCli(argv) {
|
|
|
75
77
|
if (verb === 'translate') {
|
|
76
78
|
const cmd = rest.join(' ');
|
|
77
79
|
const list = parseCommand(cmd);
|
|
78
|
-
const plans = translateCommandList(list);
|
|
80
|
+
const plans = translateCommandList(list, PURE_TRANSLATION);
|
|
79
81
|
console.log(plans.map((p) => p.script).join('\n# ---- next segment ----\n'));
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
@@ -85,7 +87,7 @@ export async function runCli(argv) {
|
|
|
85
87
|
return;
|
|
86
88
|
}
|
|
87
89
|
const list = parseCommand(cmd);
|
|
88
|
-
const plans = translateCommandList(list);
|
|
90
|
+
const plans = translateCommandList(list, EXECUTE_TRANSLATION);
|
|
89
91
|
const session = new FauxnixSession();
|
|
90
92
|
const result = await session.run(plans);
|
|
91
93
|
if (result.stdout)
|
|
@@ -95,36 +97,74 @@ export async function runCli(argv) {
|
|
|
95
97
|
await session.dispose();
|
|
96
98
|
process.exit(result.exitCode);
|
|
97
99
|
}
|
|
98
|
-
const PS_ARGS = ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass'];
|
|
99
100
|
async function runDoctor() {
|
|
100
|
-
await runCheck();
|
|
101
|
+
const checkOk = await runCheck();
|
|
101
102
|
const report = await collectDoctorReport();
|
|
102
103
|
for (const line of report.lines)
|
|
103
104
|
console.log(line);
|
|
104
|
-
if (!report.ok)
|
|
105
|
+
if (!checkOk || !report.ok)
|
|
105
106
|
process.exitCode = 1;
|
|
106
107
|
}
|
|
107
|
-
async function runCheck() {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
export async function runCheck() {
|
|
109
|
+
const selection = resolvePowerShell();
|
|
110
|
+
console.log('powershell : ' + powerShellDisplay(selection));
|
|
111
|
+
if (selection.error) {
|
|
112
|
+
console.error('status : FAILED');
|
|
113
|
+
console.error(selection.error);
|
|
114
|
+
process.exitCode = 1;
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
const probeCmd = '[Console]::Out.WriteLine($PSVersionTable.PSVersion.ToString()); ' +
|
|
118
|
+
'[Console]::Out.WriteLine([string]$PSVersionTable.PSEdition)';
|
|
119
|
+
const probe = spawn(selection.executable, [...POWERSHELL_ARGS, '-EncodedCommand', encodeCommand(probeCmd)], {
|
|
111
120
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
112
121
|
windowsHide: true,
|
|
113
122
|
});
|
|
114
|
-
probe.on('error', (e) => {
|
|
115
|
-
console.error('status : FAILED to run powershell.exe: ' + e.message);
|
|
116
|
-
process.exit(1);
|
|
117
|
-
});
|
|
118
123
|
let out = '';
|
|
124
|
+
let err = '';
|
|
119
125
|
probe.stdout.on('data', (d) => (out += d.toString('utf8')));
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
126
|
+
probe.stderr.on('data', (d) => (err += d.toString('utf8')));
|
|
127
|
+
const outcome = await new Promise((resolve) => {
|
|
128
|
+
let settled = false;
|
|
129
|
+
const done = (value) => {
|
|
130
|
+
if (settled)
|
|
131
|
+
return;
|
|
132
|
+
settled = true;
|
|
133
|
+
resolve(value);
|
|
134
|
+
};
|
|
135
|
+
probe.once('error', (error) => done({ code: 127, error }));
|
|
136
|
+
probe.once('close', (code) => done({ code: code ?? 1 }));
|
|
137
|
+
});
|
|
138
|
+
if (outcome.error) {
|
|
139
|
+
console.error('status : FAILED');
|
|
140
|
+
if (outcome.error.code === 'ENOENT') {
|
|
141
|
+
console.error(powerShellMissingMessage(selection).trimEnd());
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
console.error(`fauxnix: failed to start ${selection.executable}: ${outcome.error.message}`);
|
|
145
|
+
}
|
|
146
|
+
process.exitCode = 1;
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
if (outcome.code !== 0) {
|
|
150
|
+
console.error(`status : FAILED to run ${selection.executable}`);
|
|
151
|
+
if (err.trim())
|
|
152
|
+
console.error(err.trim());
|
|
153
|
+
process.exitCode = 1;
|
|
154
|
+
return false;
|
|
125
155
|
}
|
|
126
|
-
|
|
127
|
-
|
|
156
|
+
const lines = out.trim().split(/\r?\n/);
|
|
157
|
+
const version = lines[0] ?? '';
|
|
158
|
+
const edition = lines[1] ?? '';
|
|
159
|
+
console.log('version : ' + version);
|
|
160
|
+
console.log('edition : ' + edition);
|
|
161
|
+
if (edition !== selection.expectedEdition) {
|
|
162
|
+
console.error(`status : FAILED: ${selection.executable} reported ${edition || 'no edition'}; ` +
|
|
163
|
+
`expected ${selection.expectedEdition}`);
|
|
128
164
|
process.exitCode = 1;
|
|
165
|
+
return false;
|
|
129
166
|
}
|
|
167
|
+
console.log('commands : ' + registeredNames().length + ' translated, others pass through');
|
|
168
|
+
console.log('status : OK');
|
|
169
|
+
return true;
|
|
130
170
|
}
|