fauxnix-cli 2.1.0 → 2.2.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 +20 -9
- package/dist/cli.js +25 -3
- package/dist/commands/archive.js +100 -2
- package/dist/commands/files.d.ts +8 -0
- package/dist/commands/files.js +131 -19
- package/dist/commands/gzip-node.js +4 -0
- package/dist/commands/text-filters.js +102 -19
- package/dist/commands/text-io.js +11 -4
- package/dist/doctor.js +35 -0
- package/dist/executor.d.ts +39 -2
- package/dist/executor.js +150 -13
- package/dist/facade-sea.cjs +518 -86
- package/dist/facade.js +6 -2
- package/dist/install.js +87 -44
- package/dist/mcp-launch.d.ts +22 -0
- package/dist/mcp-launch.js +44 -0
- package/dist/mcp.js +8 -2
- package/dist/parser.js +15 -0
- package/dist/ps-host.d.ts +5 -0
- package/dist/ps-host.js +47 -23
- package/dist/qwen-launch.d.ts +5 -12
- package/dist/qwen-launch.js +5 -29
- package/dist/translator.d.ts +9 -0
- package/dist/translator.js +73 -2
- package/package.json +67 -67
package/dist/translator.js
CHANGED
|
@@ -277,7 +277,11 @@ export function varExpr(name, index, param, length = false, extra) {
|
|
|
277
277
|
}
|
|
278
278
|
switch (name) {
|
|
279
279
|
case 'HOME':
|
|
280
|
-
|
|
280
|
+
// Session-scoped like every other variable (#255): assignments write
|
|
281
|
+
// $env:HOME + SETVALS, `env -u`/unset track UNSETVARS — fx-scalar0 is
|
|
282
|
+
// the one resolver that honors all three. `$HOME` (the PowerShell
|
|
283
|
+
// automatic) would always answer with the real profile.
|
|
284
|
+
return "(fx-scalar0 'HOME')";
|
|
281
285
|
case 'PWD':
|
|
282
286
|
return 'fx-posix([string]$PWD.Path)';
|
|
283
287
|
case 'USER':
|
|
@@ -504,6 +508,60 @@ export function operandExpr(w) {
|
|
|
504
508
|
return pathExpr(normalizeLiteralPath(lit));
|
|
505
509
|
return exprOfWord(w);
|
|
506
510
|
}
|
|
511
|
+
/**
|
|
512
|
+
* Wildcard-escape characters that must reach `Get-Item -Path` literally
|
|
513
|
+
* (PowerShell's escape is a backtick before `*`, `?` or `[`).
|
|
514
|
+
*/
|
|
515
|
+
function wcEscapeLiteral(s) {
|
|
516
|
+
return s.replace(/[*?[]/g, '`$&');
|
|
517
|
+
}
|
|
518
|
+
/**
|
|
519
|
+
* Operand expression for handlers whose runtime glob step is `fx-glob`
|
|
520
|
+
* (#255 quote-aware globbing): bash globs a word only where glob characters
|
|
521
|
+
* sat UNQUOTED — quoted parts and backslash-escaped characters are literal
|
|
522
|
+
* even when a variable expands to something containing metas, while unquoted
|
|
523
|
+
* expansions stay glob-active. `fx-glob` unescapes the pattern when no file
|
|
524
|
+
* matches, so unmatched literals keep their shell spelling.
|
|
525
|
+
*/
|
|
526
|
+
export function globOperandExpr(w) {
|
|
527
|
+
const lit = literalOfWord(w);
|
|
528
|
+
// Meta-free literal words keep the ordinary operand path (incl. /tmp, /d/
|
|
529
|
+
// normalization). Anything containing glob characters goes through the
|
|
530
|
+
// quoting-aware walk: only UNQUOTED metas stay glob-active.
|
|
531
|
+
if (lit !== null && !/[*?[]/.test(lit))
|
|
532
|
+
return pathExpr(normalizeLiteralPath(lit));
|
|
533
|
+
const chunks = [];
|
|
534
|
+
const mergeable = (s) => typeof s === 'string' && s.startsWith("'") && s.endsWith("'") && s.length >= 2;
|
|
535
|
+
const pushChunk = (s) => {
|
|
536
|
+
const prev = chunks.length ? chunks[chunks.length - 1] : undefined;
|
|
537
|
+
if (mergeable(prev) && mergeable(s)) {
|
|
538
|
+
// fold adjacent string literals: ('a' + '*' + 'b') → ('a*b'); psStr has
|
|
539
|
+
// already doubled any embedded quotes, so plain concatenation is safe.
|
|
540
|
+
chunks[chunks.length - 1] = "'" + prev.slice(1, -1) + s.slice(1, -1) + "'";
|
|
541
|
+
return;
|
|
542
|
+
}
|
|
543
|
+
chunks.push(s);
|
|
544
|
+
};
|
|
545
|
+
const walk = (parts, quoted) => {
|
|
546
|
+
for (const p of parts) {
|
|
547
|
+
if (p.kind === 'DoubleQuoted') {
|
|
548
|
+
walk(p.parts, true);
|
|
549
|
+
continue;
|
|
550
|
+
}
|
|
551
|
+
if (p.kind === 'Text' || p.kind === 'SingleQuoted') {
|
|
552
|
+
const literal = quoted || p.kind === 'SingleQuoted' || (p.kind === 'Text' && p.escaped === true);
|
|
553
|
+
pushChunk(psStr(literal ? wcEscapeLiteral(p.text) : p.text));
|
|
554
|
+
continue;
|
|
555
|
+
}
|
|
556
|
+
const expr = exprOfWord([p]);
|
|
557
|
+
chunks.push(quoted ? '[WildcardPattern]::Escape([string](' + expr + '))' : '([string](' + expr + '))');
|
|
558
|
+
}
|
|
559
|
+
};
|
|
560
|
+
walk(w, false);
|
|
561
|
+
if (chunks.length === 1)
|
|
562
|
+
return chunks[0];
|
|
563
|
+
return '(' + chunks.join(' + ') + ')';
|
|
564
|
+
}
|
|
507
565
|
/** Flatten quotes but remember whether a part sat inside `"..."`. */
|
|
508
566
|
function wordPartsForSplat(w) {
|
|
509
567
|
const out = [];
|
|
@@ -1638,7 +1696,9 @@ export function wrapScript(body, opts = {}) {
|
|
|
1638
1696
|
' if ($fx_eq -lt 1) { continue }',
|
|
1639
1697
|
' if ($fx_pair.Substring(0, $fx_eq) -ceq $n) { return (fx-svdec $fx_pair.Substring($fx_eq + 1)) }',
|
|
1640
1698
|
' }',
|
|
1641
|
-
|
|
1699
|
+
// Inherited HOME (Git Bash hosts) first; bare-Windows fallback is the
|
|
1700
|
+
// profile, like a bash login shell seeding HOME from passwd (#255).
|
|
1701
|
+
" if ($n -ceq 'HOME') { return $(if ($env:HOME) { [string]$env:HOME } else { [string]$HOME }) }",
|
|
1642
1702
|
" if ($n -ceq 'PWD') { return fx-posix([string]$PWD.Path) }",
|
|
1643
1703
|
" if ($n -ceq 'USER' -or $n -ceq 'LOGNAME') { return [string]$env:USERNAME }",
|
|
1644
1704
|
" if ($n -ceq 'PATH') { return [string]$env:PATH }",
|
|
@@ -2174,6 +2234,14 @@ function fx-capture-bytes($stream) {
|
|
|
2174
2234
|
if ($stream -is [System.IO.MemoryStream]) { return $stream.ToArray() }
|
|
2175
2235
|
return (New-Object byte[] 0)
|
|
2176
2236
|
}
|
|
2237
|
+
# Captured at startup, from the script's own location (never from the
|
|
2238
|
+
# user-mutable environment).
|
|
2239
|
+
$fx_sd = $null
|
|
2240
|
+
if ($PSCommandPath) {
|
|
2241
|
+
$fx_sd = [IO.Path]::GetDirectoryName($PSCommandPath)
|
|
2242
|
+
if ([IO.Path]::GetFileName($fx_sd) -cnotmatch '^fauxnix-[0-9]+-[0-9a-f]{24}$') { $fx_sd = $null }
|
|
2243
|
+
}
|
|
2244
|
+
Set-Variable -Name fx_hostStateDir -Value $fx_sd -Option Constant
|
|
2177
2245
|
while ($true) {
|
|
2178
2246
|
$fx_line = $fx_reader.ReadLine()
|
|
2179
2247
|
if ($null -eq $fx_line) { break }
|
|
@@ -2286,4 +2354,7 @@ while ($true) {
|
|
|
2286
2354
|
$fx_proto.WriteLine($fx_json)
|
|
2287
2355
|
}
|
|
2288
2356
|
}
|
|
2357
|
+
# stdin EOF: the owner is gone or disposed us. Remove our private state
|
|
2358
|
+
# directory (#256) - only if it is a genuine per-session directory.
|
|
2359
|
+
if ($fx_hostStateDir) { Remove-Item -LiteralPath $fx_hostStateDir -Recurse -Force -ErrorAction SilentlyContinue }
|
|
2289
2360
|
`.trim();
|
package/package.json
CHANGED
|
@@ -1,67 +1,67 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "fauxnix-cli",
|
|
3
|
-
"version": "2.
|
|
4
|
-
"description": "Fauxnix — run Linux-style commands on Windows via deterministic PowerShell translation. No VM, no WSL. MCP server + CLI for AI agents.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"bin": {
|
|
7
|
-
"fauxnix": "dist/index.js"
|
|
8
|
-
},
|
|
9
|
-
"files": [
|
|
10
|
-
"dist",
|
|
11
|
-
"README.md",
|
|
12
|
-
"LICENSE"
|
|
13
|
-
],
|
|
14
|
-
"scripts": {
|
|
15
|
-
"prebuild": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
16
|
-
"build": "tsc",
|
|
17
|
-
"postbuild": "node -e \"const fs=require('node:fs');if(fs.existsSync('scripts/build-facade-sea.mjs'))require('node:child_process').execFileSync(process.execPath,['scripts/build-facade-sea.mjs'],{stdio:'inherit'})\"",
|
|
18
|
-
"prepare": "npm run build",
|
|
19
|
-
"prepublishOnly": "npm run release:check -- --require-tag && npm run typecheck && npm run typecheck:test && npm test && npm run test:package",
|
|
20
|
-
"release:check": "node scripts/release-check.mjs",
|
|
21
|
-
"test": "vitest run",
|
|
22
|
-
"test:package": "node scripts/package-smoke.mjs",
|
|
23
|
-
"benchmark:mcp-batch": "npm run build && node scripts/benchmark-mcp-batch.mjs",
|
|
24
|
-
"test:watch": "vitest",
|
|
25
|
-
"typecheck": "tsc --noEmit",
|
|
26
|
-
"dev": "tsx src/index.ts",
|
|
27
|
-
"typecheck:test": "tsc --project tsconfig.test.json"
|
|
28
|
-
},
|
|
29
|
-
"keywords": [
|
|
30
|
-
"bash",
|
|
31
|
-
"powershell",
|
|
32
|
-
"translate",
|
|
33
|
-
"translator",
|
|
34
|
-
"linux",
|
|
35
|
-
"windows",
|
|
36
|
-
"mcp",
|
|
37
|
-
"mcp-server",
|
|
38
|
-
"ai-agent",
|
|
39
|
-
"claude-code",
|
|
40
|
-
"codex",
|
|
41
|
-
"opencode",
|
|
42
|
-
"kimi-code",
|
|
43
|
-
"shell",
|
|
44
|
-
"gbk",
|
|
45
|
-
"utf8"
|
|
46
|
-
],
|
|
47
|
-
"engines": {
|
|
48
|
-
"node": ">=22.20.0"
|
|
49
|
-
},
|
|
50
|
-
"license": "MIT",
|
|
51
|
-
"repository": {
|
|
52
|
-
"type": "git",
|
|
53
|
-
"url": "git+https://github.com/20000419/fauxnix.git"
|
|
54
|
-
},
|
|
55
|
-
"dependencies": {
|
|
56
|
-
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
57
|
-
"iconv-lite": "^0.6.3",
|
|
58
|
-
"postject": "^1.0.0-alpha.6",
|
|
59
|
-
"zod": "^3.24.0"
|
|
60
|
-
},
|
|
61
|
-
"devDependencies": {
|
|
62
|
-
"@types/node": "^20.14.0",
|
|
63
|
-
"tsx": "^4.19.0",
|
|
64
|
-
"typescript": "^5.5.0",
|
|
65
|
-
"vitest": "3.2.6"
|
|
66
|
-
}
|
|
67
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "fauxnix-cli",
|
|
3
|
+
"version": "2.2.0",
|
|
4
|
+
"description": "Fauxnix — run Linux-style commands on Windows via deterministic PowerShell translation. No VM, no WSL. MCP server + CLI for AI agents.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"bin": {
|
|
7
|
+
"fauxnix": "dist/index.js"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"prebuild": "node -e \"require('node:fs').rmSync('dist', { recursive: true, force: true })\"",
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"postbuild": "node -e \"const fs=require('node:fs');if(fs.existsSync('scripts/build-facade-sea.mjs'))require('node:child_process').execFileSync(process.execPath,['scripts/build-facade-sea.mjs'],{stdio:'inherit'})\"",
|
|
18
|
+
"prepare": "npm run build",
|
|
19
|
+
"prepublishOnly": "npm run release:check -- --require-tag && npm run typecheck && npm run typecheck:test && npm test && npm run test:package",
|
|
20
|
+
"release:check": "node scripts/release-check.mjs",
|
|
21
|
+
"test": "vitest run",
|
|
22
|
+
"test:package": "node scripts/package-smoke.mjs",
|
|
23
|
+
"benchmark:mcp-batch": "npm run build && node scripts/benchmark-mcp-batch.mjs",
|
|
24
|
+
"test:watch": "vitest",
|
|
25
|
+
"typecheck": "tsc --noEmit",
|
|
26
|
+
"dev": "tsx src/index.ts",
|
|
27
|
+
"typecheck:test": "tsc --project tsconfig.test.json"
|
|
28
|
+
},
|
|
29
|
+
"keywords": [
|
|
30
|
+
"bash",
|
|
31
|
+
"powershell",
|
|
32
|
+
"translate",
|
|
33
|
+
"translator",
|
|
34
|
+
"linux",
|
|
35
|
+
"windows",
|
|
36
|
+
"mcp",
|
|
37
|
+
"mcp-server",
|
|
38
|
+
"ai-agent",
|
|
39
|
+
"claude-code",
|
|
40
|
+
"codex",
|
|
41
|
+
"opencode",
|
|
42
|
+
"kimi-code",
|
|
43
|
+
"shell",
|
|
44
|
+
"gbk",
|
|
45
|
+
"utf8"
|
|
46
|
+
],
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22.20.0"
|
|
49
|
+
},
|
|
50
|
+
"license": "MIT",
|
|
51
|
+
"repository": {
|
|
52
|
+
"type": "git",
|
|
53
|
+
"url": "git+https://github.com/20000419/fauxnix.git"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@modelcontextprotocol/sdk": "^1.12.0",
|
|
57
|
+
"iconv-lite": "^0.6.3",
|
|
58
|
+
"postject": "^1.0.0-alpha.6",
|
|
59
|
+
"zod": "^3.24.0"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@types/node": "^20.14.0",
|
|
63
|
+
"tsx": "^4.19.0",
|
|
64
|
+
"typescript": "^5.5.0",
|
|
65
|
+
"vitest": "3.2.6"
|
|
66
|
+
}
|
|
67
|
+
}
|